nexo-brain 5.3.26 → 5.3.27

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.
Files changed (211) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/package.json +1 -1
  3. package/src/server.py +3 -0
  4. package/src/tools_sessions.py +6 -1
  5. package/src/dashboard/static/favicon 2.svg +0 -32
  6. package/src/dashboard/static/nexo-logo 2.png +0 -0
  7. package/src/dashboard/static/nexo-logo 2.svg +0 -40
  8. package/src/dashboard/static/style 2.css +0 -2458
  9. package/src/dashboard/templates/adaptive 2.html +0 -118
  10. package/src/dashboard/templates/artifacts 2.html +0 -133
  11. package/src/dashboard/templates/backups 2.html +0 -136
  12. package/src/dashboard/templates/base 2.html +0 -417
  13. package/src/dashboard/templates/calendar 2.html +0 -591
  14. package/src/dashboard/templates/chat 2.html +0 -356
  15. package/src/dashboard/templates/claims 2.html +0 -259
  16. package/src/dashboard/templates/cortex 2.html +0 -321
  17. package/src/dashboard/templates/credentials 2.html +0 -128
  18. package/src/dashboard/templates/crons 2.html +0 -370
  19. package/src/dashboard/templates/dashboard 2.html +0 -494
  20. package/src/dashboard/templates/dreams 2.html +0 -252
  21. package/src/dashboard/templates/email 2.html +0 -160
  22. package/src/dashboard/templates/evolution 2.html +0 -189
  23. package/src/dashboard/templates/feed 2.html +0 -249
  24. package/src/dashboard/templates/followup_health 2.html +0 -170
  25. package/src/dashboard/templates/graph 2.html +0 -201
  26. package/src/dashboard/templates/guard 2.html +0 -259
  27. package/src/dashboard/templates/inbox 2.html +0 -251
  28. package/src/dashboard/templates/memory 2.html +0 -420
  29. package/src/dashboard/templates/operations 2.html +0 -608
  30. package/src/dashboard/templates/plugins 2.html +0 -185
  31. package/src/dashboard/templates/protocol 2.html +0 -199
  32. package/src/dashboard/templates/rules 2.html +0 -246
  33. package/src/dashboard/templates/sentiment 2.html +0 -247
  34. package/src/dashboard/templates/sessions 2.html +0 -218
  35. package/src/dashboard/templates/skills 2.html +0 -329
  36. package/src/dashboard/templates/somatic 2.html +0 -73
  37. package/src/dashboard/templates/triggers 2.html +0 -133
  38. package/src/dashboard/templates/trust 2.html +0 -360
  39. package/src/db/__init__ 2.py +0 -259
  40. package/src/db/_core 2.py +0 -437
  41. package/src/db/_credentials 2.py +0 -124
  42. package/src/db/_episodic 2.py +0 -762
  43. package/src/db/_evolution 2.py +0 -54
  44. package/src/db/_fts 2.py +0 -406
  45. package/src/db/_goal_profiles 2.py +0 -376
  46. package/src/db/_hot_context 2.py +0 -660
  47. package/src/db/_outcomes 2.py +0 -800
  48. package/src/db/_personal_scripts 2.py +0 -582
  49. package/src/db/_sessions 2.py +0 -330
  50. package/src/db/_tasks 2.py +0 -91
  51. package/src/db/_watchers 2.py +0 -173
  52. package/src/doctor/formatters 2.py +0 -52
  53. package/src/doctor/models 2.py +0 -69
  54. package/src/doctor/planes 2.py +0 -87
  55. package/src/doctor/providers/__init__ 2.py +0 -1
  56. package/src/doctor/providers/deep 2.py +0 -367
  57. package/src/evolution_cycle 2.py +0 -519
  58. package/src/hooks/auto_capture 2.py +0 -208
  59. package/src/hooks/caffeinate-guard 2.sh +0 -8
  60. package/src/hooks/capture-session 2.sh +0 -21
  61. package/src/hooks/capture-tool-logs 2.sh +0 -158
  62. package/src/hooks/daily-briefing-check 2.sh +0 -33
  63. package/src/hooks/heartbeat-enforcement 2.py +0 -90
  64. package/src/hooks/heartbeat-posttool 2.sh +0 -18
  65. package/src/hooks/inbox-hook 2.sh +0 -76
  66. package/src/hooks/post-compact 2.sh +0 -152
  67. package/src/hooks/pre-compact 2.sh +0 -169
  68. package/src/hooks/protocol-guardrail 2.sh +0 -10
  69. package/src/hooks/protocol-pretool-guardrail 2.sh +0 -9
  70. package/src/hooks/session-stop 2.sh +0 -52
  71. package/src/kg_populate 2.py +0 -292
  72. package/src/maintenance 2.py +0 -53
  73. package/src/memory_backends 2.py +0 -71
  74. package/src/migrate_embeddings 2.py +0 -124
  75. package/src/nexo_sdk 2.py +0 -103
  76. package/src/observability 2.py +0 -199
  77. package/src/plugin_loader 2.py +0 -217
  78. package/src/plugins/__init__ 2.py +0 -0
  79. package/src/plugins/artifact_registry 2.py +0 -450
  80. package/src/plugins/backup 2.py +0 -127
  81. package/src/plugins/claims_tools 2.py +0 -119
  82. package/src/plugins/cognitive_memory 2.py +0 -609
  83. package/src/plugins/core_rules 2.py +0 -252
  84. package/src/plugins/cortex 2.py +0 -1155
  85. package/src/plugins/entities 2.py +0 -67
  86. package/src/plugins/episodic_memory 2.py +0 -560
  87. package/src/plugins/evolution 2.py +0 -167
  88. package/src/plugins/goal_engine 2.py +0 -142
  89. package/src/plugins/guard 2.py +0 -862
  90. package/src/plugins/impact 2.py +0 -29
  91. package/src/plugins/knowledge_graph_tools 2.py +0 -137
  92. package/src/plugins/media_memory_tools 2.py +0 -98
  93. package/src/plugins/memory_export 2.py +0 -196
  94. package/src/plugins/outcomes 2.py +0 -130
  95. package/src/plugins/personal_scripts 2.py +0 -117
  96. package/src/plugins/preferences 2.py +0 -47
  97. package/src/plugins/protocol 2.py +0 -1449
  98. package/src/plugins/simple_api 2.py +0 -106
  99. package/src/plugins/skills 2.py +0 -341
  100. package/src/plugins/state_watchers 2.py +0 -79
  101. package/src/plugins/update 2.py +0 -986
  102. package/src/plugins/user_state_tools 2.py +0 -43
  103. package/src/plugins/workflow 2.py +0 -588
  104. package/src/protocol_settings 2.py +0 -59
  105. package/src/public_contribution 2.py +0 -466
  106. package/src/public_evolution_queue 2.py +0 -241
  107. package/src/requirements 2.txt +0 -14
  108. package/src/retroactive_learnings 2.py +0 -373
  109. package/src/rules/__init__ 2.py +0 -0
  110. package/src/rules/core-rules 2.json +0 -331
  111. package/src/rules/migrate 2.py +0 -207
  112. package/src/runtime_power 2.py +0 -874
  113. package/src/script_registry 2.py +0 -1559
  114. package/src/scripts/check-context 2.py +0 -272
  115. package/src/scripts/deep-sleep/apply_findings 2.py +0 -2327
  116. package/src/scripts/deep-sleep/collect 2.py +0 -928
  117. package/src/scripts/deep-sleep/extract 2.py +0 -330
  118. package/src/scripts/deep-sleep/extract-prompt 2.md +0 -285
  119. package/src/scripts/deep-sleep/synthesize 2.py +0 -312
  120. package/src/scripts/deep-sleep/synthesize-prompt 2.md +0 -336
  121. package/src/scripts/nexo-agent-run 2.py +0 -75
  122. package/src/scripts/nexo-auto-update 2.py +0 -6
  123. package/src/scripts/nexo-backup 2.sh +0 -25
  124. package/src/scripts/nexo-brain-activation 2.sh +0 -140
  125. package/src/scripts/nexo-catchup 2.py +0 -300
  126. package/src/scripts/nexo-cognitive-decay 2.py +0 -257
  127. package/src/scripts/nexo-cortex-cycle 2.py +0 -293
  128. package/src/scripts/nexo-cron-wrapper 2.sh +0 -53
  129. package/src/scripts/nexo-daily-self-audit 2.py +0 -2161
  130. package/src/scripts/nexo-dashboard 2.sh +0 -29
  131. package/src/scripts/nexo-deep-sleep 2.sh +0 -86
  132. package/src/scripts/nexo-evolution-run 2.py +0 -1664
  133. package/src/scripts/nexo-followup-hygiene 2.py +0 -139
  134. package/src/scripts/nexo-hook-record 2.py +0 -42
  135. package/src/scripts/nexo-immune 2.py +0 -936
  136. package/src/scripts/nexo-impact-scorer 2.py +0 -117
  137. package/src/scripts/nexo-inbox-hook 2.sh +0 -74
  138. package/src/scripts/nexo-install 2.py +0 -6
  139. package/src/scripts/nexo-learning-housekeep 2.py +0 -401
  140. package/src/scripts/nexo-learning-validator 2.py +0 -266
  141. package/src/scripts/nexo-migrate 2.py +0 -260
  142. package/src/scripts/nexo-outcome-checker 2.py +0 -127
  143. package/src/scripts/nexo-postmortem-consolidator 2.py +0 -456
  144. package/src/scripts/nexo-pre-commit 2.py +0 -120
  145. package/src/scripts/nexo-prevent-sleep 2.sh +0 -35
  146. package/src/scripts/nexo-proactive-dashboard 2.py +0 -354
  147. package/src/scripts/nexo-reflection 2.py +0 -256
  148. package/src/scripts/nexo-runtime-preflight 2.py +0 -274
  149. package/src/scripts/nexo-sleep 2.py +0 -631
  150. package/src/scripts/nexo-snapshot-restore 2.sh +0 -35
  151. package/src/scripts/nexo-sync-clients 2.py +0 -16
  152. package/src/scripts/nexo-synthesis 2.py +0 -475
  153. package/src/scripts/nexo-tcc-approve 2.sh +0 -79
  154. package/src/scripts/nexo-update 2.sh +0 -306
  155. package/src/scripts/nexo-watchdog 2.sh +0 -1207
  156. package/src/scripts/nexo-watchdog-smoke 2.py +0 -119
  157. package/src/scripts/rehydrate_learnings_from_archive 2.py +0 -245
  158. package/src/server 2.py +0 -1296
  159. package/src/skills/run-nexo-audit-phase/guide 2.md +0 -43
  160. package/src/skills/run-nexo-audit-phase/skill 2.json +0 -59
  161. package/src/skills/run-nexo-core-fix-cycle/guide 2.md +0 -17
  162. package/src/skills/run-nexo-core-fix-cycle/script 2.py +0 -276
  163. package/src/skills/run-nexo-core-fix-cycle/skill 2.json +0 -58
  164. package/src/skills/run-release-final-audit/guide 2.md +0 -16
  165. package/src/skills/run-release-final-audit/script 2.py +0 -259
  166. package/src/skills/run-release-final-audit/skill 2.json +0 -77
  167. package/src/skills/run-runtime-doctor/guide 2.md +0 -12
  168. package/src/skills/run-runtime-doctor/script 2.py +0 -21
  169. package/src/skills/run-runtime-doctor/skill 2.json +0 -25
  170. package/src/skills_runtime 2.py +0 -932
  171. package/src/state_watchers_runtime 2.py +0 -475
  172. package/src/storage_router 2.py +0 -32
  173. package/src/system_catalog 2.py +0 -786
  174. package/src/tools_coordination 2.py +0 -103
  175. package/src/tools_credentials 2.py +0 -68
  176. package/src/tools_drive 2.py +0 -487
  177. package/src/tools_hot_context 2.py +0 -163
  178. package/src/tools_learnings 2.py +0 -612
  179. package/src/tools_menu 2.py +0 -229
  180. package/src/tools_reminders 2.py +0 -88
  181. package/src/tools_reminders_crud 2.py +0 -363
  182. package/src/tools_sessions 2.py +0 -1054
  183. package/src/tools_system_catalog 2.py +0 -19
  184. package/src/tools_task_history 2.py +0 -57
  185. package/src/tools_transcripts 2.py +0 -98
  186. package/src/transcript_utils 2.py +0 -412
  187. package/src/user_context 2.py +0 -46
  188. package/src/user_data_portability 2.py +0 -328
  189. package/src/user_state_model 2.py +0 -170
  190. package/templates/CLAUDE.md 2.template +0 -108
  191. package/templates/CODEX.AGENTS.md 2.template +0 -66
  192. package/templates/launchagents/README 2.md +0 -132
  193. package/templates/launchagents/com.nexo.auto-close-sessions 2.plist +0 -39
  194. package/templates/launchagents/com.nexo.catchup 2.plist +0 -39
  195. package/templates/launchagents/com.nexo.cognitive-decay 2.plist +0 -40
  196. package/templates/launchagents/com.nexo.dashboard 2.plist +0 -43
  197. package/templates/launchagents/com.nexo.deep-sleep 2.plist +0 -43
  198. package/templates/launchagents/com.nexo.evolution 2.plist +0 -44
  199. package/templates/launchagents/com.nexo.followup-hygiene 2.plist +0 -45
  200. package/templates/launchagents/com.nexo.immune 2.plist +0 -41
  201. package/templates/launchagents/com.nexo.postmortem 2.plist +0 -45
  202. package/templates/launchagents/com.nexo.self-audit 2.plist +0 -47
  203. package/templates/launchagents/com.nexo.synthesis 2.plist +0 -45
  204. package/templates/launchagents/com.nexo.watchdog 2.plist +0 -37
  205. package/templates/nexo_helper 2.py +0 -301
  206. package/templates/openclaw 2.json +0 -13
  207. package/templates/plugin-template 2.py +0 -40
  208. package/templates/script-template 2.py +0 -59
  209. package/templates/script-template 2.sh +0 -13
  210. package/templates/skill-script-template 2.py +0 -48
  211. package/templates/skill-template 2.md +0 -33
@@ -1,420 +0,0 @@
1
- {% extends "base.html" %}
2
-
3
- {% block title %}Memory Flow{% endblock %}
4
- {% block page_title %}Memory Flow{% endblock %}
5
-
6
- {% block head %}
7
- <style>
8
- .flow-connector {
9
- position: absolute;
10
- height: 3px;
11
- background: linear-gradient(90deg, var(--from), var(--to));
12
- top: 50%;
13
- transform: translateY(-50%);
14
- border-radius: 2px;
15
- overflow: hidden;
16
- }
17
- .flow-connector::after {
18
- content: '';
19
- position: absolute;
20
- top: 0; left: -100%; width: 60%; height: 100%;
21
- background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
22
- animation: flowPulse 2s ease-in-out infinite;
23
- }
24
- @keyframes flowPulse {
25
- 0% { left: -60%; }
26
- 100% { left: 160%; }
27
- }
28
- .flow-box {
29
- transition: transform 0.2s, box-shadow 0.2s;
30
- }
31
- .flow-box:hover {
32
- transform: translateY(-2px);
33
- box-shadow: 0 8px 25px rgba(0,0,0,0.3);
34
- }
35
- .memory-card {
36
- transition: all 0.2s ease;
37
- cursor: pointer;
38
- }
39
- .memory-card:hover {
40
- border-color: rgba(124,58,237,0.4);
41
- box-shadow: 0 0 20px rgba(124,58,237,0.1);
42
- }
43
- .memory-card .full-content {
44
- max-height: 0;
45
- overflow: hidden;
46
- transition: max-height 0.3s ease;
47
- }
48
- .memory-card.expanded .full-content {
49
- max-height: 500px;
50
- }
51
- .strength-bar {
52
- transition: width 0.8s ease-out;
53
- }
54
- @keyframes countUp {
55
- from { opacity: 0; transform: translateY(10px); }
56
- to { opacity: 1; transform: translateY(0); }
57
- }
58
- .count-animate {
59
- animation: countUp 0.5s ease-out forwards;
60
- }
61
- </style>
62
- {% endblock %}
63
-
64
- {% block header_actions %}
65
- <div class="flex items-center gap-2">
66
- <input type="text" id="search-input" placeholder="Search memories..."
67
- class="bg-slate-800 border border-slate-700 rounded-lg px-3 py-1.5 text-xs text-slate-200 placeholder-slate-500 focus:outline-none focus:ring-1 focus:ring-violet-500 w-64"
68
- onkeydown="if(event.key==='Enter')searchMemories()">
69
- <button onclick="searchMemories()" class="px-3 py-1.5 text-xs bg-violet-600 text-white rounded-lg hover:bg-violet-500 transition-colors font-medium">Search</button>
70
- </div>
71
- {% endblock %}
72
-
73
- {% block content %}
74
- <!-- Flow Diagram -->
75
- <div class="mb-6">
76
- <h2 class="text-xs uppercase tracking-wider text-slate-500 font-semibold mb-4">Memory Pipeline</h2>
77
- <div class="relative flex items-center justify-center gap-0 py-6 px-4" id="flow-diagram">
78
- <!-- STM Box -->
79
- <div class="flow-box bg-cyan-500/10 border border-cyan-500/30 rounded-xl p-5 text-center min-w-[140px] z-10">
80
- <div class="text-xs uppercase tracking-wider text-cyan-400 font-semibold mb-1">STM</div>
81
- <div class="text-3xl font-display font-bold text-cyan-300 count-animate" id="count-stm">--</div>
82
- <div class="text-[10px] text-cyan-500/60 mt-1">Short-Term</div>
83
- </div>
84
-
85
- <!-- Arrow STM -> LTM -->
86
- <div class="flex flex-col items-center mx-2 z-10">
87
- <div class="text-[10px] text-emerald-400 font-mono font-semibold mb-1" id="count-promoted">--</div>
88
- <div class="w-24 h-[3px] rounded-full relative overflow-hidden bg-gradient-to-r from-cyan-500 to-violet-500">
89
- <div class="absolute top-0 left-0 w-1/2 h-full bg-gradient-to-r from-transparent via-white/40 to-transparent" style="animation: flowPulse 2s ease-in-out infinite;"></div>
90
- </div>
91
- <div class="text-[10px] text-slate-600 mt-1">promoted</div>
92
- </div>
93
-
94
- <!-- LTM Box -->
95
- <div class="flow-box bg-violet-500/10 border border-violet-500/30 rounded-xl p-5 text-center min-w-[140px] z-10">
96
- <div class="text-xs uppercase tracking-wider text-violet-400 font-semibold mb-1">LTM</div>
97
- <div class="text-3xl font-display font-bold text-violet-300 count-animate" id="count-ltm">--</div>
98
- <div class="text-[10px] text-violet-500/60 mt-1">Long-Term</div>
99
- </div>
100
-
101
- <!-- Arrow to Dreamed -->
102
- <div class="flex flex-col items-center mx-2 z-10">
103
- <div class="text-[10px] text-indigo-400 font-mono font-semibold mb-1" id="count-dreamed">--</div>
104
- <div class="w-16 h-[3px] rounded-full bg-gradient-to-r from-violet-500 to-indigo-500 relative overflow-hidden">
105
- <div class="absolute top-0 left-0 w-1/2 h-full bg-gradient-to-r from-transparent via-white/30 to-transparent" style="animation: flowPulse 3s ease-in-out infinite;"></div>
106
- </div>
107
- <div class="text-[10px] text-slate-600 mt-1">dreamed</div>
108
- </div>
109
-
110
- <!-- Dreamed Box -->
111
- <div class="flow-box bg-indigo-500/10 border border-indigo-500/30 rounded-xl p-5 text-center min-w-[130px] z-10">
112
- <div class="text-xs uppercase tracking-wider text-indigo-400 font-semibold mb-1">Dreamed</div>
113
- <div class="text-3xl font-display font-bold text-indigo-300 count-animate" id="count-dreamed-box">--</div>
114
- <div class="text-[10px] text-indigo-500/60 mt-1">Insights</div>
115
- </div>
116
-
117
- <!-- Quarantine Branch (below STM) -->
118
- <div class="absolute left-[calc(50%-280px)] top-[calc(100%-10px)] flex flex-col items-center z-10" id="quarantine-branch">
119
- <div class="w-[3px] h-8 bg-gradient-to-b from-cyan-500/50 to-amber-500/50 rounded-full"></div>
120
- <div class="flow-box bg-amber-500/10 border border-amber-500/30 rounded-xl p-4 text-center min-w-[120px]">
121
- <div class="text-xs uppercase tracking-wider text-amber-400 font-semibold mb-1">Quarantine</div>
122
- <div class="text-2xl font-display font-bold text-amber-300 count-animate" id="count-quarantine">--</div>
123
- <div class="text-[10px] text-amber-500/60 mt-1">Pending Review</div>
124
- </div>
125
- </div>
126
- </div>
127
- </div>
128
-
129
- <!-- Hot Context -->
130
- <div class="mb-6">
131
- <div class="flex flex-col gap-3 lg:flex-row lg:items-center lg:justify-between mb-3">
132
- <div>
133
- <h2 class="text-xs uppercase tracking-wider text-slate-500 font-semibold flex items-center gap-2">
134
- <span class="w-2 h-2 rounded-full bg-emerald-400 glow-dot" style="color:#34d399"></span>
135
- Hot Context 24h
136
- </h2>
137
- <p class="text-xs text-slate-600 mt-1">Recent operational memory shared across sessions, clients, and channels.</p>
138
- </div>
139
- <div class="flex items-center gap-2">
140
- <input type="text" id="context-query" placeholder="Search recent context..."
141
- class="bg-slate-800 border border-slate-700 rounded-lg px-3 py-1.5 text-xs text-slate-200 placeholder-slate-500 focus:outline-none focus:ring-1 focus:ring-emerald-500 w-64"
142
- onkeydown="if(event.key==='Enter')loadRecentContext()">
143
- <button onclick="loadRecentContext()" class="px-3 py-1.5 text-xs bg-emerald-600 text-white rounded-lg hover:bg-emerald-500 transition-colors font-medium">Refresh</button>
144
- </div>
145
- </div>
146
-
147
- <div class="grid grid-cols-1 xl:grid-cols-2 gap-5">
148
- <div class="bg-emerald-500/5 border border-emerald-500/20 rounded-xl p-4">
149
- <div class="flex items-center justify-between mb-3">
150
- <div class="text-xs uppercase tracking-wider text-emerald-400 font-semibold">Active Contexts</div>
151
- <div class="text-[10px] text-slate-500 font-mono" id="hot-context-count">--</div>
152
- </div>
153
- <div class="space-y-2" id="hot-context-list">
154
- <div class="text-xs text-slate-600 text-center py-6">Loading...</div>
155
- </div>
156
- </div>
157
-
158
- <div class="bg-emerald-500/5 border border-emerald-500/20 rounded-xl p-4">
159
- <div class="flex items-center justify-between mb-3">
160
- <div class="text-xs uppercase tracking-wider text-emerald-400 font-semibold">Recent Events</div>
161
- <div class="text-[10px] text-slate-500 font-mono" id="hot-event-count">--</div>
162
- </div>
163
- <div class="space-y-2" id="hot-event-list">
164
- <div class="text-xs text-slate-600 text-center py-6">Loading...</div>
165
- </div>
166
- </div>
167
- </div>
168
- </div>
169
-
170
- <!-- Two-column: STM and LTM Recent -->
171
- <div class="grid grid-cols-1 lg:grid-cols-2 gap-5 mb-6" id="columns-area">
172
- <!-- Recent STM -->
173
- <div>
174
- <h2 class="text-xs uppercase tracking-wider text-slate-500 font-semibold mb-3 flex items-center gap-2">
175
- <span class="w-2 h-2 rounded-full bg-cyan-400 glow-dot" style="color:#22d3ee"></span>
176
- Recent STM
177
- </h2>
178
- <div class="space-y-2" id="stm-list">
179
- <div class="text-xs text-slate-600 text-center py-8">Loading...</div>
180
- </div>
181
- </div>
182
-
183
- <!-- Recent LTM -->
184
- <div>
185
- <h2 class="text-xs uppercase tracking-wider text-slate-500 font-semibold mb-3 flex items-center gap-2">
186
- <span class="w-2 h-2 rounded-full bg-violet-400 glow-dot" style="color:#a78bfa"></span>
187
- Recent LTM
188
- </h2>
189
- <div class="space-y-2" id="ltm-list">
190
- <div class="text-xs text-slate-600 text-center py-8">Loading...</div>
191
- </div>
192
- </div>
193
- </div>
194
-
195
- <!-- Quarantine Items -->
196
- <div class="mb-6" id="quarantine-section">
197
- <h2 class="text-xs uppercase tracking-wider text-slate-500 font-semibold mb-3 flex items-center gap-2">
198
- <span class="w-2 h-2 rounded-full bg-amber-400 glow-dot" style="color:#fbbf24"></span>
199
- Quarantine Queue
200
- </h2>
201
- <div class="space-y-2" id="quarantine-list">
202
- <div class="text-xs text-slate-600 text-center py-4">Loading...</div>
203
- </div>
204
- </div>
205
-
206
- <!-- Search Results (hidden by default) -->
207
- <div class="mb-6 hidden" id="search-results-section">
208
- <div class="flex items-center justify-between mb-3">
209
- <h2 class="text-xs uppercase tracking-wider text-slate-500 font-semibold flex items-center gap-2">
210
- Search Results
211
- <span class="text-violet-400 font-mono" id="search-count"></span>
212
- </h2>
213
- <button onclick="clearSearch()" class="text-xs text-slate-500 hover:text-slate-300 transition-colors">Clear</button>
214
- </div>
215
- <div class="space-y-2" id="search-results"></div>
216
- </div>
217
- {% endblock %}
218
-
219
- {% block scripts %}
220
- <script>
221
- const REFRESH_MS = 60000;
222
-
223
- function sourceTypeBadge(type) {
224
- const map = {
225
- learning: 'bg-blue-500/10 text-blue-400',
226
- feedback: 'bg-pink-500/10 text-pink-400',
227
- preference: 'bg-violet-500/10 text-violet-400',
228
- diary: 'bg-cyan-500/10 text-cyan-400',
229
- decision: 'bg-amber-500/10 text-amber-400',
230
- };
231
- return map[type] || 'bg-slate-700 text-slate-400';
232
- }
233
-
234
- function renderMemoryCard(m) {
235
- const content = m.content || '';
236
- const snippet = content.length > 180 ? content.substring(0, 180) + '...' : content;
237
- const hasMore = content.length > 180;
238
- const strength = m.strength != null ? m.strength : null;
239
- const sourceType = m.source_type || 'unknown';
240
- const domain = m.domain || '';
241
- const created = m.created_at ? relativeTime(m.created_at) : '';
242
-
243
- return `<div class="memory-card bg-slate-900/50 border border-slate-800/50 rounded-xl p-4" onclick="this.classList.toggle('expanded')">
244
- <div class="flex items-center gap-2 mb-2 flex-wrap">
245
- <span class="text-[10px] px-1.5 py-0.5 rounded font-medium ${sourceTypeBadge(sourceType)}">${escapeHtml(sourceType)}</span>
246
- ${domain ? `<span class="text-[10px] px-1.5 py-0.5 rounded bg-slate-800 text-slate-500">${escapeHtml(domain)}</span>` : ''}
247
- <span class="text-[10px] text-slate-600 ml-auto font-mono">${escapeHtml(created)}</span>
248
- </div>
249
- <p class="text-sm text-slate-300 leading-relaxed">${escapeHtml(snippet)}</p>
250
- ${hasMore ? `<div class="full-content mt-2 pt-2 border-t border-slate-800/50">
251
- <p class="text-sm text-slate-300 leading-relaxed whitespace-pre-wrap">${escapeHtml(content)}</p>
252
- </div>
253
- <div class="text-[10px] text-violet-400 mt-1">Click to expand</div>` : ''}
254
- ${strength != null ? `<div class="mt-2 flex items-center gap-2">
255
- <span class="text-[10px] text-slate-600">Strength</span>
256
- <div class="flex-1 h-1.5 bg-slate-800 rounded-full overflow-hidden">
257
- <div class="strength-bar h-full rounded-full ${strength > 0.7 ? 'bg-emerald-500' : strength > 0.4 ? 'bg-violet-500' : 'bg-amber-500'}" style="width:${(strength * 100).toFixed(0)}%"></div>
258
- </div>
259
- <span class="text-[10px] text-slate-500 font-mono">${strength.toFixed(2)}</span>
260
- </div>` : ''}
261
- </div>`;
262
- }
263
-
264
- function renderQuarantineCard(m) {
265
- const content = m.content || '';
266
- const reason = m.quarantine_reason || m.reason || 'Unknown reason';
267
- return `<div class="bg-amber-500/5 border border-amber-500/20 rounded-xl p-4">
268
- <div class="flex items-center gap-2 mb-2">
269
- <span class="text-[10px] px-1.5 py-0.5 rounded bg-amber-500/10 text-amber-400 font-medium">quarantine</span>
270
- <span class="text-[10px] text-amber-500/60 ml-auto">${escapeHtml(reason)}</span>
271
- </div>
272
- <p class="text-sm text-slate-400 leading-relaxed">${escapeHtml(content.length > 200 ? content.substring(0, 200) + '...' : content)}</p>
273
- </div>`;
274
- }
275
-
276
- function recentTime(value) {
277
- if (value === null || value === undefined || value === '') return '--';
278
- if (typeof value === 'number') return relativeTime(new Date(value * 1000).toISOString());
279
- if (/^\d+(\.\d+)?$/.test(String(value))) return relativeTime(new Date(parseFloat(value) * 1000).toISOString());
280
- return relativeTime(value);
281
- }
282
-
283
- function renderHotContextCard(item) {
284
- const title = item.title || item.context_key || '(untitled)';
285
- const summary = item.summary || '';
286
- const state = item.state || 'active';
287
- const owner = item.owner || '';
288
- const lastEvent = item.last_event_at ? recentTime(item.last_event_at) : '';
289
- return `<div class="bg-slate-900/50 border border-emerald-500/15 rounded-xl p-4">
290
- <div class="flex items-center gap-2 mb-2 flex-wrap">
291
- <span class="text-[10px] px-1.5 py-0.5 rounded bg-emerald-500/10 text-emerald-400 font-medium">${escapeHtml(state)}</span>
292
- ${owner ? `<span class="text-[10px] px-1.5 py-0.5 rounded bg-slate-800 text-slate-500">${escapeHtml(owner)}</span>` : ''}
293
- <span class="text-[10px] text-slate-600 ml-auto font-mono">${escapeHtml(lastEvent)}</span>
294
- </div>
295
- <div class="text-sm text-slate-200 leading-relaxed">${escapeHtml(title)}</div>
296
- ${summary ? `<div class="text-xs text-slate-400 leading-relaxed mt-2">${escapeHtml(summary)}</div>` : ''}
297
- <div class="text-[10px] text-slate-600 font-mono mt-2">${escapeHtml(item.context_key || '')}</div>
298
- </div>`;
299
- }
300
-
301
- function renderHotEventCard(event) {
302
- const title = event.title || event.context_key || '(event)';
303
- const summary = event.summary || event.body || '';
304
- const created = event.created_at ? recentTime(event.created_at) : '';
305
- return `<div class="bg-slate-900/50 border border-emerald-500/15 rounded-xl p-4">
306
- <div class="flex items-center gap-2 mb-2 flex-wrap">
307
- <span class="text-[10px] px-1.5 py-0.5 rounded bg-emerald-500/10 text-emerald-400 font-medium">${escapeHtml(event.event_type || 'event')}</span>
308
- <span class="text-[10px] text-slate-600 ml-auto font-mono">${escapeHtml(created)}</span>
309
- </div>
310
- <div class="text-sm text-slate-200 leading-relaxed">${escapeHtml(title)}</div>
311
- ${summary ? `<div class="text-xs text-slate-400 leading-relaxed mt-2 whitespace-pre-wrap">${escapeHtml(summary)}</div>` : ''}
312
- <div class="text-[10px] text-slate-600 font-mono mt-2">${escapeHtml(event.context_key || '')}</div>
313
- </div>`;
314
- }
315
-
316
- async function loadRecentContext() {
317
- const q = document.getElementById('context-query').value.trim();
318
- const url = '/api/recent-context?hours=24&limit=8' + (q ? `&query=${encodeURIComponent(q)}` : '');
319
- const data = await fetchJSON(url);
320
- if (!data) return;
321
-
322
- document.getElementById('hot-context-count').textContent = formatNumber((data.counts && data.counts.contexts) || 0);
323
- document.getElementById('hot-event-count').textContent = formatNumber((data.counts && data.counts.events) || 0);
324
-
325
- const contexts = data.contexts || [];
326
- const events = data.events || [];
327
- document.getElementById('hot-context-list').innerHTML = contexts.length === 0
328
- ? '<div class="text-xs text-slate-600 text-center py-6">No active hot context in the last 24h</div>'
329
- : contexts.map(renderHotContextCard).join('');
330
- document.getElementById('hot-event-list').innerHTML = events.length === 0
331
- ? '<div class="text-xs text-slate-600 text-center py-6">No recent events in the last 24h</div>'
332
- : events.map(renderHotEventCard).join('');
333
- }
334
-
335
- async function loadFlow() {
336
- const data = await fetchJSON('/api/memory/flow');
337
- if (!data) return;
338
-
339
- const c = data.counts || {};
340
- animateCount('count-stm', c.stm || 0);
341
- animateCount('count-ltm', c.ltm || 0);
342
- animateCount('count-quarantine', c.quarantine || 0);
343
- animateCount('count-dreamed-box', c.dreamed || 0);
344
- document.getElementById('count-promoted').textContent = formatNumber(c.promoted || 0);
345
- document.getElementById('count-dreamed').textContent = formatNumber(c.dreamed || 0);
346
-
347
- // STM recent
348
- const stmList = document.getElementById('stm-list');
349
- const stmItems = data.stm_recent || [];
350
- stmList.innerHTML = stmItems.length === 0
351
- ? '<div class="text-xs text-slate-600 text-center py-6">No recent STM memories</div>'
352
- : stmItems.map(renderMemoryCard).join('');
353
-
354
- // LTM recent
355
- const ltmList = document.getElementById('ltm-list');
356
- const ltmItems = data.ltm_recent || [];
357
- ltmList.innerHTML = ltmItems.length === 0
358
- ? '<div class="text-xs text-slate-600 text-center py-6">No recent LTM memories</div>'
359
- : ltmItems.map(renderMemoryCard).join('');
360
-
361
- // Quarantine
362
- const qList = document.getElementById('quarantine-list');
363
- const qItems = data.quarantine || [];
364
- qList.innerHTML = qItems.length === 0
365
- ? '<div class="text-xs text-slate-600 text-center py-4">No items in quarantine</div>'
366
- : qItems.map(renderQuarantineCard).join('');
367
- }
368
-
369
- function animateCount(id, target) {
370
- const el = document.getElementById(id);
371
- if (!el) return;
372
- const start = parseInt(el.textContent) || 0;
373
- if (start === target) { el.textContent = formatNumber(target); return; }
374
- const duration = 600;
375
- const startTime = performance.now();
376
- function step(now) {
377
- const progress = Math.min((now - startTime) / duration, 1);
378
- const eased = 1 - Math.pow(1 - progress, 3);
379
- el.textContent = formatNumber(Math.round(start + (target - start) * eased));
380
- if (progress < 1) requestAnimationFrame(step);
381
- }
382
- requestAnimationFrame(step);
383
- }
384
-
385
- async function searchMemories() {
386
- const q = document.getElementById('search-input').value.trim();
387
- if (!q) return;
388
-
389
- const section = document.getElementById('search-results-section');
390
- const results = document.getElementById('search-results');
391
- const count = document.getElementById('search-count');
392
-
393
- section.classList.remove('hidden');
394
- results.innerHTML = '<div class="text-xs text-slate-500 text-center py-4">Searching...</div>';
395
-
396
- const data = await fetchJSON(`/api/memories?q=${encodeURIComponent(q)}&limit=30`);
397
- if (!data) {
398
- results.innerHTML = '<div class="text-xs text-red-400 text-center py-4">Search failed</div>';
399
- return;
400
- }
401
-
402
- const items = data.results || [];
403
- count.textContent = `(${items.length})`;
404
- results.innerHTML = items.length === 0
405
- ? '<div class="text-xs text-slate-600 text-center py-6">No memories found</div>'
406
- : items.map(renderMemoryCard).join('');
407
- }
408
-
409
- function clearSearch() {
410
- document.getElementById('search-results-section').classList.add('hidden');
411
- document.getElementById('search-input').value = '';
412
- }
413
-
414
- // Init
415
- loadRecentContext();
416
- loadFlow();
417
- setInterval(loadRecentContext, REFRESH_MS);
418
- setInterval(loadFlow, REFRESH_MS);
419
- </script>
420
- {% endblock %}