nexo-brain 5.3.26 → 5.3.28

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 (212) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/package.json +1 -1
  3. package/src/hook_guardrails.py +44 -0
  4. package/src/server.py +3 -0
  5. package/src/tools_sessions.py +6 -1
  6. package/src/dashboard/static/favicon 2.svg +0 -32
  7. package/src/dashboard/static/nexo-logo 2.png +0 -0
  8. package/src/dashboard/static/nexo-logo 2.svg +0 -40
  9. package/src/dashboard/static/style 2.css +0 -2458
  10. package/src/dashboard/templates/adaptive 2.html +0 -118
  11. package/src/dashboard/templates/artifacts 2.html +0 -133
  12. package/src/dashboard/templates/backups 2.html +0 -136
  13. package/src/dashboard/templates/base 2.html +0 -417
  14. package/src/dashboard/templates/calendar 2.html +0 -591
  15. package/src/dashboard/templates/chat 2.html +0 -356
  16. package/src/dashboard/templates/claims 2.html +0 -259
  17. package/src/dashboard/templates/cortex 2.html +0 -321
  18. package/src/dashboard/templates/credentials 2.html +0 -128
  19. package/src/dashboard/templates/crons 2.html +0 -370
  20. package/src/dashboard/templates/dashboard 2.html +0 -494
  21. package/src/dashboard/templates/dreams 2.html +0 -252
  22. package/src/dashboard/templates/email 2.html +0 -160
  23. package/src/dashboard/templates/evolution 2.html +0 -189
  24. package/src/dashboard/templates/feed 2.html +0 -249
  25. package/src/dashboard/templates/followup_health 2.html +0 -170
  26. package/src/dashboard/templates/graph 2.html +0 -201
  27. package/src/dashboard/templates/guard 2.html +0 -259
  28. package/src/dashboard/templates/inbox 2.html +0 -251
  29. package/src/dashboard/templates/memory 2.html +0 -420
  30. package/src/dashboard/templates/operations 2.html +0 -608
  31. package/src/dashboard/templates/plugins 2.html +0 -185
  32. package/src/dashboard/templates/protocol 2.html +0 -199
  33. package/src/dashboard/templates/rules 2.html +0 -246
  34. package/src/dashboard/templates/sentiment 2.html +0 -247
  35. package/src/dashboard/templates/sessions 2.html +0 -218
  36. package/src/dashboard/templates/skills 2.html +0 -329
  37. package/src/dashboard/templates/somatic 2.html +0 -73
  38. package/src/dashboard/templates/triggers 2.html +0 -133
  39. package/src/dashboard/templates/trust 2.html +0 -360
  40. package/src/db/__init__ 2.py +0 -259
  41. package/src/db/_core 2.py +0 -437
  42. package/src/db/_credentials 2.py +0 -124
  43. package/src/db/_episodic 2.py +0 -762
  44. package/src/db/_evolution 2.py +0 -54
  45. package/src/db/_fts 2.py +0 -406
  46. package/src/db/_goal_profiles 2.py +0 -376
  47. package/src/db/_hot_context 2.py +0 -660
  48. package/src/db/_outcomes 2.py +0 -800
  49. package/src/db/_personal_scripts 2.py +0 -582
  50. package/src/db/_sessions 2.py +0 -330
  51. package/src/db/_tasks 2.py +0 -91
  52. package/src/db/_watchers 2.py +0 -173
  53. package/src/doctor/formatters 2.py +0 -52
  54. package/src/doctor/models 2.py +0 -69
  55. package/src/doctor/planes 2.py +0 -87
  56. package/src/doctor/providers/__init__ 2.py +0 -1
  57. package/src/doctor/providers/deep 2.py +0 -367
  58. package/src/evolution_cycle 2.py +0 -519
  59. package/src/hooks/auto_capture 2.py +0 -208
  60. package/src/hooks/caffeinate-guard 2.sh +0 -8
  61. package/src/hooks/capture-session 2.sh +0 -21
  62. package/src/hooks/capture-tool-logs 2.sh +0 -158
  63. package/src/hooks/daily-briefing-check 2.sh +0 -33
  64. package/src/hooks/heartbeat-enforcement 2.py +0 -90
  65. package/src/hooks/heartbeat-posttool 2.sh +0 -18
  66. package/src/hooks/inbox-hook 2.sh +0 -76
  67. package/src/hooks/post-compact 2.sh +0 -152
  68. package/src/hooks/pre-compact 2.sh +0 -169
  69. package/src/hooks/protocol-guardrail 2.sh +0 -10
  70. package/src/hooks/protocol-pretool-guardrail 2.sh +0 -9
  71. package/src/hooks/session-stop 2.sh +0 -52
  72. package/src/kg_populate 2.py +0 -292
  73. package/src/maintenance 2.py +0 -53
  74. package/src/memory_backends 2.py +0 -71
  75. package/src/migrate_embeddings 2.py +0 -124
  76. package/src/nexo_sdk 2.py +0 -103
  77. package/src/observability 2.py +0 -199
  78. package/src/plugin_loader 2.py +0 -217
  79. package/src/plugins/__init__ 2.py +0 -0
  80. package/src/plugins/artifact_registry 2.py +0 -450
  81. package/src/plugins/backup 2.py +0 -127
  82. package/src/plugins/claims_tools 2.py +0 -119
  83. package/src/plugins/cognitive_memory 2.py +0 -609
  84. package/src/plugins/core_rules 2.py +0 -252
  85. package/src/plugins/cortex 2.py +0 -1155
  86. package/src/plugins/entities 2.py +0 -67
  87. package/src/plugins/episodic_memory 2.py +0 -560
  88. package/src/plugins/evolution 2.py +0 -167
  89. package/src/plugins/goal_engine 2.py +0 -142
  90. package/src/plugins/guard 2.py +0 -862
  91. package/src/plugins/impact 2.py +0 -29
  92. package/src/plugins/knowledge_graph_tools 2.py +0 -137
  93. package/src/plugins/media_memory_tools 2.py +0 -98
  94. package/src/plugins/memory_export 2.py +0 -196
  95. package/src/plugins/outcomes 2.py +0 -130
  96. package/src/plugins/personal_scripts 2.py +0 -117
  97. package/src/plugins/preferences 2.py +0 -47
  98. package/src/plugins/protocol 2.py +0 -1449
  99. package/src/plugins/simple_api 2.py +0 -106
  100. package/src/plugins/skills 2.py +0 -341
  101. package/src/plugins/state_watchers 2.py +0 -79
  102. package/src/plugins/update 2.py +0 -986
  103. package/src/plugins/user_state_tools 2.py +0 -43
  104. package/src/plugins/workflow 2.py +0 -588
  105. package/src/protocol_settings 2.py +0 -59
  106. package/src/public_contribution 2.py +0 -466
  107. package/src/public_evolution_queue 2.py +0 -241
  108. package/src/requirements 2.txt +0 -14
  109. package/src/retroactive_learnings 2.py +0 -373
  110. package/src/rules/__init__ 2.py +0 -0
  111. package/src/rules/core-rules 2.json +0 -331
  112. package/src/rules/migrate 2.py +0 -207
  113. package/src/runtime_power 2.py +0 -874
  114. package/src/script_registry 2.py +0 -1559
  115. package/src/scripts/check-context 2.py +0 -272
  116. package/src/scripts/deep-sleep/apply_findings 2.py +0 -2327
  117. package/src/scripts/deep-sleep/collect 2.py +0 -928
  118. package/src/scripts/deep-sleep/extract 2.py +0 -330
  119. package/src/scripts/deep-sleep/extract-prompt 2.md +0 -285
  120. package/src/scripts/deep-sleep/synthesize 2.py +0 -312
  121. package/src/scripts/deep-sleep/synthesize-prompt 2.md +0 -336
  122. package/src/scripts/nexo-agent-run 2.py +0 -75
  123. package/src/scripts/nexo-auto-update 2.py +0 -6
  124. package/src/scripts/nexo-backup 2.sh +0 -25
  125. package/src/scripts/nexo-brain-activation 2.sh +0 -140
  126. package/src/scripts/nexo-catchup 2.py +0 -300
  127. package/src/scripts/nexo-cognitive-decay 2.py +0 -257
  128. package/src/scripts/nexo-cortex-cycle 2.py +0 -293
  129. package/src/scripts/nexo-cron-wrapper 2.sh +0 -53
  130. package/src/scripts/nexo-daily-self-audit 2.py +0 -2161
  131. package/src/scripts/nexo-dashboard 2.sh +0 -29
  132. package/src/scripts/nexo-deep-sleep 2.sh +0 -86
  133. package/src/scripts/nexo-evolution-run 2.py +0 -1664
  134. package/src/scripts/nexo-followup-hygiene 2.py +0 -139
  135. package/src/scripts/nexo-hook-record 2.py +0 -42
  136. package/src/scripts/nexo-immune 2.py +0 -936
  137. package/src/scripts/nexo-impact-scorer 2.py +0 -117
  138. package/src/scripts/nexo-inbox-hook 2.sh +0 -74
  139. package/src/scripts/nexo-install 2.py +0 -6
  140. package/src/scripts/nexo-learning-housekeep 2.py +0 -401
  141. package/src/scripts/nexo-learning-validator 2.py +0 -266
  142. package/src/scripts/nexo-migrate 2.py +0 -260
  143. package/src/scripts/nexo-outcome-checker 2.py +0 -127
  144. package/src/scripts/nexo-postmortem-consolidator 2.py +0 -456
  145. package/src/scripts/nexo-pre-commit 2.py +0 -120
  146. package/src/scripts/nexo-prevent-sleep 2.sh +0 -35
  147. package/src/scripts/nexo-proactive-dashboard 2.py +0 -354
  148. package/src/scripts/nexo-reflection 2.py +0 -256
  149. package/src/scripts/nexo-runtime-preflight 2.py +0 -274
  150. package/src/scripts/nexo-sleep 2.py +0 -631
  151. package/src/scripts/nexo-snapshot-restore 2.sh +0 -35
  152. package/src/scripts/nexo-sync-clients 2.py +0 -16
  153. package/src/scripts/nexo-synthesis 2.py +0 -475
  154. package/src/scripts/nexo-tcc-approve 2.sh +0 -79
  155. package/src/scripts/nexo-update 2.sh +0 -306
  156. package/src/scripts/nexo-watchdog 2.sh +0 -1207
  157. package/src/scripts/nexo-watchdog-smoke 2.py +0 -119
  158. package/src/scripts/rehydrate_learnings_from_archive 2.py +0 -245
  159. package/src/server 2.py +0 -1296
  160. package/src/skills/run-nexo-audit-phase/guide 2.md +0 -43
  161. package/src/skills/run-nexo-audit-phase/skill 2.json +0 -59
  162. package/src/skills/run-nexo-core-fix-cycle/guide 2.md +0 -17
  163. package/src/skills/run-nexo-core-fix-cycle/script 2.py +0 -276
  164. package/src/skills/run-nexo-core-fix-cycle/skill 2.json +0 -58
  165. package/src/skills/run-release-final-audit/guide 2.md +0 -16
  166. package/src/skills/run-release-final-audit/script 2.py +0 -259
  167. package/src/skills/run-release-final-audit/skill 2.json +0 -77
  168. package/src/skills/run-runtime-doctor/guide 2.md +0 -12
  169. package/src/skills/run-runtime-doctor/script 2.py +0 -21
  170. package/src/skills/run-runtime-doctor/skill 2.json +0 -25
  171. package/src/skills_runtime 2.py +0 -932
  172. package/src/state_watchers_runtime 2.py +0 -475
  173. package/src/storage_router 2.py +0 -32
  174. package/src/system_catalog 2.py +0 -786
  175. package/src/tools_coordination 2.py +0 -103
  176. package/src/tools_credentials 2.py +0 -68
  177. package/src/tools_drive 2.py +0 -487
  178. package/src/tools_hot_context 2.py +0 -163
  179. package/src/tools_learnings 2.py +0 -612
  180. package/src/tools_menu 2.py +0 -229
  181. package/src/tools_reminders 2.py +0 -88
  182. package/src/tools_reminders_crud 2.py +0 -363
  183. package/src/tools_sessions 2.py +0 -1054
  184. package/src/tools_system_catalog 2.py +0 -19
  185. package/src/tools_task_history 2.py +0 -57
  186. package/src/tools_transcripts 2.py +0 -98
  187. package/src/transcript_utils 2.py +0 -412
  188. package/src/user_context 2.py +0 -46
  189. package/src/user_data_portability 2.py +0 -328
  190. package/src/user_state_model 2.py +0 -170
  191. package/templates/CLAUDE.md 2.template +0 -108
  192. package/templates/CODEX.AGENTS.md 2.template +0 -66
  193. package/templates/launchagents/README 2.md +0 -132
  194. package/templates/launchagents/com.nexo.auto-close-sessions 2.plist +0 -39
  195. package/templates/launchagents/com.nexo.catchup 2.plist +0 -39
  196. package/templates/launchagents/com.nexo.cognitive-decay 2.plist +0 -40
  197. package/templates/launchagents/com.nexo.dashboard 2.plist +0 -43
  198. package/templates/launchagents/com.nexo.deep-sleep 2.plist +0 -43
  199. package/templates/launchagents/com.nexo.evolution 2.plist +0 -44
  200. package/templates/launchagents/com.nexo.followup-hygiene 2.plist +0 -45
  201. package/templates/launchagents/com.nexo.immune 2.plist +0 -41
  202. package/templates/launchagents/com.nexo.postmortem 2.plist +0 -45
  203. package/templates/launchagents/com.nexo.self-audit 2.plist +0 -47
  204. package/templates/launchagents/com.nexo.synthesis 2.plist +0 -45
  205. package/templates/launchagents/com.nexo.watchdog 2.plist +0 -37
  206. package/templates/nexo_helper 2.py +0 -301
  207. package/templates/openclaw 2.json +0 -13
  208. package/templates/plugin-template 2.py +0 -40
  209. package/templates/script-template 2.py +0 -59
  210. package/templates/script-template 2.sh +0 -13
  211. package/templates/skill-script-template 2.py +0 -48
  212. package/templates/skill-template 2.md +0 -33
@@ -1,591 +0,0 @@
1
- {% extends "base.html" %}
2
-
3
- {% block title %}Calendar{% endblock %}
4
-
5
- {% block page_title %}Calendar{% endblock %}
6
-
7
- {% block header_actions %}
8
- <!-- View toggle -->
9
- <div class="flex items-center gap-0.5 bg-slate-800/60 rounded-lg p-0.5 mr-3">
10
- <button id="btn-month" onclick="setView('month')" class="text-xs px-3 py-1 rounded-md font-display font-medium transition-all">Month</button>
11
- <button id="btn-week" onclick="setView('week')" class="text-xs px-3 py-1 rounded-md font-display font-medium transition-all">Week</button>
12
- <button id="btn-day" onclick="setView('day')" class="text-xs px-3 py-1 rounded-md font-display font-medium transition-all">Day</button>
13
- </div>
14
- <!-- Navigation -->
15
- <button onclick="navigatePrev()" class="text-slate-400 hover:text-white px-2 py-1 transition-colors text-lg leading-none">&larr;</button>
16
- <span id="period-label" class="text-sm font-display font-medium min-w-[200px] text-center"></span>
17
- <button onclick="navigateNext()" class="text-slate-400 hover:text-white px-2 py-1 transition-colors text-lg leading-none">&rarr;</button>
18
- <button onclick="goToday()" class="text-xs px-2.5 py-1 rounded-md bg-slate-800 text-slate-400 hover:bg-slate-700 transition-colors">Today</button>
19
- {% endblock %}
20
-
21
- {% block head %}
22
- <style>
23
- .modal-backdrop { backdrop-filter: blur(4px); }
24
- .status-done { opacity: 0.6; }
25
- .status-done .item-text { text-decoration: line-through; }
26
- @keyframes calFadeIn { from { opacity: 0; transform: scale(0.96); } to { opacity: 1; transform: scale(1); } }
27
- .modal-animate { animation: calFadeIn 0.15s ease-out; }
28
- @keyframes spin { to { transform: rotate(360deg); } }
29
- .spin { animation: spin 0.6s linear infinite; }
30
- </style>
31
- {% endblock %}
32
-
33
- {% block content %}
34
- <!-- Calendar content area -->
35
- <div id="calendar-content" class="flex-1 overflow-auto"></div>
36
-
37
- <!-- Modal -->
38
- <div id="modal-overlay" class="hidden fixed inset-0 z-[100] flex items-center justify-center modal-backdrop bg-gray-950/70" onclick="closeModal(event)">
39
- <div id="modal-box" class="modal-animate bg-slate-900 border border-slate-700/60 rounded-xl shadow-2xl w-full max-w-lg mx-4 max-h-[85vh] flex flex-col" onclick="event.stopPropagation()">
40
- <!-- Modal header -->
41
- <div class="flex items-center justify-between px-5 py-4 border-b border-slate-800/60 flex-shrink-0">
42
- <div>
43
- <h2 id="modal-title" class="text-base font-display font-semibold text-slate-100"></h2>
44
- <p id="modal-subtitle" class="text-xs text-slate-500 font-mono mt-0.5"></p>
45
- </div>
46
- <button onclick="closeModalDirect()" class="w-7 h-7 flex items-center justify-center rounded-lg text-slate-500 hover:text-slate-200 hover:bg-slate-800 transition-colors text-xl leading-none">&times;</button>
47
- </div>
48
- <!-- Modal body -->
49
- <div id="modal-body" class="overflow-y-auto flex-1 px-5 py-4 space-y-5"></div>
50
- </div>
51
- </div>
52
- {% endblock %}
53
-
54
- {% block scripts %}
55
- <script>
56
- const MONTHS = ['January','February','March','April','May','June','July','August','September','October','November','December'];
57
- const DAYS_SHORT = ['Mon','Tue','Wed','Thu','Fri','Sat','Sun'];
58
- const DAYS_LONG = ['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'];
59
-
60
- let currentView = 'month';
61
- let currentYear = new Date().getFullYear();
62
- let currentMonth = new Date().getMonth() + 1;
63
- let currentWeekStart = getWeekStart(new Date());
64
- let currentDay = new Date();
65
- let calendarItems = { reminders: [], followups: [] };
66
-
67
- // --- Helpers ---
68
-
69
- function today() {
70
- const d = new Date();
71
- return ymd(d);
72
- }
73
-
74
- function ymd(date) {
75
- return `${date.getFullYear()}-${String(date.getMonth()+1).padStart(2,'0')}-${String(date.getDate()).padStart(2,'0')}`;
76
- }
77
-
78
- function parseDate(str) {
79
- const parts = str.slice(0,10).split('-');
80
- return new Date(parseInt(parts[0]), parseInt(parts[1])-1, parseInt(parts[2]));
81
- }
82
-
83
- function getWeekStart(date) {
84
- const d = new Date(date);
85
- const dow = (d.getDay() + 6) % 7;
86
- d.setDate(d.getDate() - dow);
87
- return d;
88
- }
89
-
90
- function addDays(date, n) {
91
- const d = new Date(date);
92
- d.setDate(d.getDate() + n);
93
- return d;
94
- }
95
-
96
- function getItemDate(item) {
97
- return (item.due_date || item.date || '').slice(0, 10);
98
- }
99
-
100
- function getItemStatus(item, dateStr) {
101
- const status = (item.status || 'pending').toLowerCase();
102
- if (status === 'completed' || status === 'done') return 'done';
103
- const todayStr = today();
104
- if (dateStr && dateStr < todayStr) return 'overdue';
105
- return 'pending';
106
- }
107
-
108
- function buildItemsLookup(items) {
109
- const map = {};
110
- (items.reminders || []).forEach(r => {
111
- const d = getItemDate(r);
112
- if (d) {
113
- if (!map[d]) map[d] = { reminders: [], followups: [] };
114
- map[d].reminders.push(r);
115
- }
116
- });
117
- (items.followups || []).forEach(f => {
118
- const d = getItemDate(f);
119
- if (d) {
120
- if (!map[d]) map[d] = { reminders: [], followups: [] };
121
- map[d].followups.push(f);
122
- }
123
- });
124
- return map;
125
- }
126
-
127
- // --- Status badge HTML ---
128
-
129
- function statusBadgeHtml(status) {
130
- if (status === 'done') {
131
- return `<span class="inline-flex items-center gap-1 text-xs font-mono font-semibold px-1.5 py-0.5 rounded bg-emerald-500/15 text-emerald-400 uppercase tracking-wide">
132
- <span class="w-1.5 h-1.5 rounded-full bg-emerald-500 inline-block"></span>DONE
133
- </span>`;
134
- }
135
- if (status === 'overdue') {
136
- return `<span class="inline-flex items-center gap-1 text-xs font-mono font-semibold px-1.5 py-0.5 rounded bg-red-500/15 text-red-400 uppercase tracking-wide">
137
- <span class="w-1.5 h-1.5 rounded-full bg-red-500 inline-block"></span>OVERDUE
138
- </span>`;
139
- }
140
- return `<span class="inline-flex items-center gap-1 text-xs font-mono font-semibold px-1.5 py-0.5 rounded bg-amber-500/15 text-amber-400 uppercase tracking-wide">
141
- <span class="w-1.5 h-1.5 rounded-full bg-amber-500 inline-block"></span>PENDING
142
- </span>`;
143
- }
144
-
145
- function statusDotHtml(status) {
146
- if (status === 'done') return '<span class="w-1.5 h-1.5 rounded-full bg-emerald-500 flex-shrink-0 inline-block"></span>';
147
- if (status === 'overdue') return '<span class="w-1.5 h-1.5 rounded-full bg-red-500 flex-shrink-0 inline-block"></span>';
148
- return '<span class="w-1.5 h-1.5 rounded-full bg-amber-500 flex-shrink-0 inline-block"></span>';
149
- }
150
-
151
- // --- Item card HTML ---
152
-
153
- function itemCardHtml(item, type, dateStr, compact) {
154
- const status = getItemStatus(item, dateStr);
155
- const desc = escapeHtml(item.description || item.content || item.title || '—');
156
- const category = item.category ? escapeHtml(item.category) : null;
157
- const id = item.id;
158
- const isReminder = type === 'reminder';
159
- const isDone = status === 'done';
160
-
161
- const typeTag = isReminder
162
- ? `<span class="text-xs font-mono font-semibold px-1.5 py-0.5 rounded bg-violet-500/15 text-violet-400 uppercase tracking-wide">Reminder</span>`
163
- : `<span class="text-xs font-mono font-semibold px-1.5 py-0.5 rounded bg-pink-500/15 text-pink-400 uppercase tracking-wide">Followup</span>`;
164
-
165
- const catTag = category
166
- ? `<span class="text-xs font-mono px-1.5 py-0.5 rounded bg-slate-700/50 text-slate-400">${category}</span>`
167
- : '';
168
-
169
- const executeBtn = (!isReminder && !isDone)
170
- ? `<button onclick="executeFollowup(${id}, this)" class="ml-auto text-xs px-2.5 py-1 rounded-md bg-violet-600 hover:bg-violet-500 text-white font-display font-medium transition-colors flex-shrink-0 flex items-center gap-1">
171
- <svg class="w-3 h-3" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M5 3l14 9-14 9V3z"/></svg>
172
- Execute
173
- </button>`
174
- : '';
175
-
176
- const idTag = `<span class="text-xs font-mono text-slate-600">#${id}</span>`;
177
-
178
- if (compact) {
179
- return `<div class="flex items-start gap-1.5 py-1 ${isDone ? 'opacity-60' : ''}">
180
- ${statusDotHtml(status)}
181
- <span class="text-xs text-slate-300 leading-snug ${isDone ? 'line-through text-slate-500' : ''} flex-1 min-w-0 truncate">${desc}</span>
182
- </div>`;
183
- }
184
-
185
- return `<div class="bg-slate-800/40 border border-slate-700/40 rounded-lg p-3.5 ${isDone ? 'status-done' : ''}">
186
- <div class="flex items-center gap-2 flex-wrap mb-2">
187
- ${typeTag}
188
- ${statusBadgeHtml(status)}
189
- ${catTag}
190
- ${idTag}
191
- ${executeBtn}
192
- </div>
193
- <div class="text-sm text-slate-200 leading-relaxed item-text">${desc}</div>
194
- </div>`;
195
- }
196
-
197
- // --- Execute followup ---
198
-
199
- async function executeFollowup(id, btn) {
200
- const originalHtml = btn.innerHTML;
201
- btn.innerHTML = `<svg class="w-3 h-3 spin" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" 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> Running`;
202
- btn.disabled = true;
203
- try {
204
- const res = await fetch(`/api/ops/execute/${id}`, { method: 'POST' });
205
- const data = await res.json();
206
- if (res.ok) {
207
- btn.innerHTML = `<svg class="w-3 h-3" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2.5"><path stroke-linecap="round" stroke-linejoin="round" d="M5 13l4 4L19 7"/></svg> Done`;
208
- btn.className = btn.className.replace('bg-violet-600 hover:bg-violet-500', 'bg-emerald-700 cursor-default');
209
- await loadCalendarData();
210
- } else {
211
- const errMsg = data.error || data.detail || 'HTTP ' + res.status;
212
- btn.innerHTML = '\u2717 ' + errMsg;
213
- btn.title = errMsg;
214
- btn.className = btn.className.replace('bg-violet-600 hover:bg-violet-500', 'bg-red-700');
215
- setTimeout(() => { btn.innerHTML = originalHtml; btn.title = ''; btn.disabled = false; btn.className = btn.className.replace('bg-red-700', 'bg-violet-600 hover:bg-violet-500'); }, 3000);
216
- }
217
- } catch(e) {
218
- btn.innerHTML = '\u2717 ' + e.message;
219
- setTimeout(() => { btn.innerHTML = originalHtml; btn.disabled = false; }, 3000);
220
- }
221
- }
222
-
223
- // --- Data loading ---
224
-
225
- async function loadCalendarData() {
226
- try {
227
- const res = await fetch(`/api/calendar?year=${currentYear}&month=${currentMonth}`);
228
- calendarItems = await res.json();
229
- } catch(e) {
230
- calendarItems = { reminders: [], followups: [] };
231
- }
232
- }
233
-
234
- // --- View management ---
235
-
236
- function setView(view) {
237
- currentView = view;
238
- updateViewButtons();
239
- renderView();
240
- }
241
-
242
- function updateViewButtons() {
243
- ['month','week','day'].forEach(v => {
244
- const btn = document.getElementById(`btn-${v}`);
245
- if (v === currentView) {
246
- btn.className = 'text-xs px-3 py-1 rounded-md font-display font-medium transition-all bg-violet-600 text-white';
247
- } else {
248
- btn.className = 'text-xs px-3 py-1 rounded-md font-display font-medium transition-all text-slate-400 hover:text-slate-200';
249
- }
250
- });
251
- }
252
-
253
- function navigatePrev() {
254
- if (currentView === 'month') {
255
- currentMonth--;
256
- if (currentMonth < 1) { currentMonth = 12; currentYear--; }
257
- } else if (currentView === 'week') {
258
- currentWeekStart = addDays(currentWeekStart, -7);
259
- currentYear = currentWeekStart.getFullYear();
260
- currentMonth = currentWeekStart.getMonth() + 1;
261
- } else {
262
- currentDay = addDays(currentDay, -1);
263
- currentYear = currentDay.getFullYear();
264
- currentMonth = currentDay.getMonth() + 1;
265
- }
266
- loadAndRender();
267
- }
268
-
269
- function navigateNext() {
270
- if (currentView === 'month') {
271
- currentMonth++;
272
- if (currentMonth > 12) { currentMonth = 1; currentYear++; }
273
- } else if (currentView === 'week') {
274
- currentWeekStart = addDays(currentWeekStart, 7);
275
- currentYear = currentWeekStart.getFullYear();
276
- currentMonth = currentWeekStart.getMonth() + 1;
277
- } else {
278
- currentDay = addDays(currentDay, 1);
279
- currentYear = currentDay.getFullYear();
280
- currentMonth = currentDay.getMonth() + 1;
281
- }
282
- loadAndRender();
283
- }
284
-
285
- function goToday() {
286
- const now = new Date();
287
- currentYear = now.getFullYear();
288
- currentMonth = now.getMonth() + 1;
289
- currentWeekStart = getWeekStart(now);
290
- currentDay = now;
291
- loadAndRender();
292
- }
293
-
294
- async function loadAndRender() {
295
- await loadCalendarData();
296
- renderView();
297
- }
298
-
299
- function renderView() {
300
- if (currentView === 'month') renderMonth();
301
- else if (currentView === 'week') renderWeek();
302
- else renderDay();
303
- }
304
-
305
- // --- Month view ---
306
-
307
- function renderMonth() {
308
- document.getElementById('period-label').textContent = `${MONTHS[currentMonth - 1]} ${currentYear}`;
309
-
310
- const firstDay = new Date(currentYear, currentMonth - 1, 1);
311
- const daysInMonth = new Date(currentYear, currentMonth, 0).getDate();
312
- const startDow = (firstDay.getDay() + 6) % 7;
313
- const todayStr = today();
314
- const itemsByDate = buildItemsLookup(calendarItems);
315
-
316
- let headerHtml = `<div class="grid grid-cols-7 mb-1">`;
317
- DAYS_SHORT.forEach(d => {
318
- headerHtml += `<div class="p-2 text-center text-xs uppercase tracking-wider text-slate-500 font-display font-medium">${d}</div>`;
319
- });
320
- headerHtml += `</div>`;
321
-
322
- let cells = '';
323
-
324
- // Previous month padding
325
- const prevMonthLast = new Date(currentYear, currentMonth - 1, 0).getDate();
326
- for (let i = startDow - 1; i >= 0; i--) {
327
- cells += `<div class="bg-gray-950 p-2 min-h-[90px] opacity-25">
328
- <div class="text-xs text-slate-500 font-display">${prevMonthLast - i}</div>
329
- </div>`;
330
- }
331
-
332
- // Current month days
333
- for (let d = 1; d <= daysInMonth; d++) {
334
- const dateStr = `${currentYear}-${String(currentMonth).padStart(2,'0')}-${String(d).padStart(2,'0')}`;
335
- const isToday = dateStr === todayStr;
336
- const dayItems = itemsByDate[dateStr];
337
-
338
- const bgClass = `bg-gray-950 hover:bg-slate-900/60 cursor-pointer transition-colors`;
339
- const ringClass = isToday ? 'ring-1 ring-inset ring-violet-500/50' : '';
340
- const dayNumClass = isToday
341
- ? 'w-6 h-6 flex items-center justify-center rounded-full bg-violet-600 text-white font-semibold text-xs'
342
- : 'text-xs text-slate-400 font-display';
343
-
344
- let dotsHtml = '';
345
- if (dayItems) {
346
- const allItems = [
347
- ...dayItems.reminders.map(r => ({ ...r, type: 'reminder' })),
348
- ...dayItems.followups.map(f => ({ ...f, type: 'followup' }))
349
- ];
350
- const total = allItems.length;
351
-
352
- let doneDots = [], pendingDots = [], overdueDots = [];
353
- allItems.forEach(item => {
354
- const st = getItemStatus(item, dateStr);
355
- const color = st === 'done' ? 'bg-emerald-500' : st === 'overdue' ? 'bg-red-500' : 'bg-amber-500';
356
- const dot = `<span class="w-1.5 h-1.5 rounded-full ${color} flex-shrink-0"></span>`;
357
- if (st === 'done') doneDots.push(dot);
358
- else if (st === 'overdue') overdueDots.push(dot);
359
- else pendingDots.push(dot);
360
- });
361
-
362
- const visibleDots = [...overdueDots, ...pendingDots, ...doneDots].slice(0, 5);
363
- const overflow = total > 5 ? `<span class="text-xs text-slate-500 font-mono leading-none">+${total - 5}</span>` : '';
364
- dotsHtml = `<div class="flex flex-wrap gap-0.5 mt-1.5 items-center">${visibleDots.join('')}${overflow}</div>`;
365
- }
366
-
367
- cells += `<div class="${bgClass} ${ringClass} p-2 min-h-[90px]" onclick="openDayModal('${dateStr}')">
368
- <div class="${dayNumClass}">${d}</div>
369
- ${dotsHtml}
370
- </div>`;
371
- }
372
-
373
- // Next month padding
374
- const totalCells = startDow + daysInMonth;
375
- const remaining = totalCells % 7 === 0 ? 0 : 7 - (totalCells % 7);
376
- for (let d = 1; d <= remaining; d++) {
377
- cells += `<div class="bg-gray-950 p-2 min-h-[90px] opacity-25">
378
- <div class="text-xs text-slate-500 font-display">${d}</div>
379
- </div>`;
380
- }
381
-
382
- document.getElementById('calendar-content').innerHTML = `
383
- ${headerHtml}
384
- <div class="grid grid-cols-7 gap-px bg-slate-800/30 rounded-lg overflow-hidden border border-slate-800/30">
385
- ${cells}
386
- </div>
387
- `;
388
- }
389
-
390
- // --- Week view ---
391
-
392
- function renderWeek() {
393
- const weekEnd = addDays(currentWeekStart, 6);
394
- const startLabel = currentWeekStart.toLocaleDateString('en-US', { month: 'short', day: 'numeric' });
395
- const endLabel = weekEnd.toLocaleDateString('en-US', { month: 'short', day: 'numeric', year: 'numeric' });
396
- document.getElementById('period-label').textContent = `${startLabel} \u2013 ${endLabel}`;
397
-
398
- const todayStr = today();
399
- const itemsByDate = buildItemsLookup(calendarItems);
400
-
401
- let headerHtml = `<div class="grid grid-cols-7 gap-px mb-0.5">`;
402
- for (let i = 0; i < 7; i++) {
403
- const d = addDays(currentWeekStart, i);
404
- const dStr = ymd(d);
405
- const isToday = dStr === todayStr;
406
- const dayItems = itemsByDate[dStr];
407
- const count = dayItems ? (dayItems.reminders.length + dayItems.followups.length) : 0;
408
-
409
- headerHtml += `<div class="p-3 text-center ${isToday ? 'bg-violet-500/10' : 'bg-slate-900/30'} rounded-t-lg cursor-pointer hover:bg-slate-800/50 transition-colors" onclick="openDayModal('${dStr}')">
410
- <div class="text-xs uppercase tracking-wider text-slate-500 font-display">${DAYS_SHORT[i]}</div>
411
- <div class="text-lg font-display font-semibold mt-0.5 ${isToday ? 'text-violet-400' : 'text-slate-200'}">${d.getDate()}</div>
412
- ${count > 0 ? `<div class="text-xs font-mono text-slate-500 mt-0.5">${count} item${count !== 1 ? 's' : ''}</div>` : ''}
413
- </div>`;
414
- }
415
- headerHtml += `</div>`;
416
-
417
- let bodyHtml = `<div class="grid grid-cols-7 gap-px bg-slate-800/20 rounded-b-lg overflow-hidden border border-slate-800/30 border-t-0">`;
418
- for (let i = 0; i < 7; i++) {
419
- const d = addDays(currentWeekStart, i);
420
- const dStr = ymd(d);
421
- const isToday = dStr === todayStr;
422
- const dayItems = itemsByDate[dStr];
423
-
424
- let itemsHtml = '';
425
- if (dayItems) {
426
- const allItems = [
427
- ...dayItems.reminders.map(r => ({ ...r, _type: 'reminder' })),
428
- ...dayItems.followups.map(f => ({ ...f, _type: 'followup' }))
429
- ];
430
- allItems.sort((a, b) => {
431
- const order = { overdue: 0, pending: 1, done: 2 };
432
- return order[getItemStatus(a, dStr)] - order[getItemStatus(b, dStr)];
433
- });
434
- itemsHtml = allItems.map(item => itemCardHtml(item, item._type, dStr, true)).join('');
435
- }
436
-
437
- bodyHtml += `<div class="${isToday ? 'bg-violet-500/5' : 'bg-gray-950'} p-2 min-h-[160px] cursor-pointer hover:bg-slate-900/40 transition-colors" onclick="openDayModal('${dStr}')">
438
- ${itemsHtml || `<div class="text-xs text-slate-700 text-center mt-4">\u2014</div>`}
439
- </div>`;
440
- }
441
- bodyHtml += `</div>`;
442
-
443
- document.getElementById('calendar-content').innerHTML = headerHtml + bodyHtml;
444
- }
445
-
446
- // --- Day view ---
447
-
448
- function renderDay() {
449
- const dStr = ymd(currentDay);
450
- const label = currentDay.toLocaleDateString('en-US', { weekday: 'long', day: 'numeric', month: 'long', year: 'numeric' });
451
- document.getElementById('period-label').textContent = label;
452
-
453
- const itemsByDate = buildItemsLookup(calendarItems);
454
- const dayItems = itemsByDate[dStr];
455
-
456
- const dayReminders = dayItems ? dayItems.reminders : [];
457
- const dayFollowups = dayItems ? dayItems.followups : [];
458
- const total = dayReminders.length + dayFollowups.length;
459
-
460
- const todayStr = today();
461
- const isToday = dStr === todayStr;
462
-
463
- let html = `<div class="max-w-2xl mx-auto">`;
464
-
465
- html += `<div class="flex items-center gap-3 mb-6">
466
- <div class="text-2xl font-display font-bold ${isToday ? 'text-violet-400' : 'text-slate-100'}">${label}</div>
467
- <span class="text-sm font-mono text-slate-500">${total} item${total !== 1 ? 's' : ''}</span>
468
- </div>`;
469
-
470
- if (total === 0) {
471
- html += `<div class="text-center py-16 text-slate-600 font-display">
472
- <div class="text-4xl mb-3">\u2014</div>
473
- <div>No items for this day</div>
474
- </div>`;
475
- } else {
476
- if (dayReminders.length > 0) {
477
- html += `<div class="mb-6">
478
- <div class="flex items-center gap-2 mb-3">
479
- <span class="text-xs font-mono font-semibold px-2 py-0.5 rounded bg-violet-500/15 text-violet-400 uppercase tracking-wide">Reminders (User)</span>
480
- <span class="text-xs text-slate-600 font-mono">${dayReminders.length}</span>
481
- </div>
482
- <div class="space-y-2">
483
- ${dayReminders.map(r => itemCardHtml(r, 'reminder', dStr, false)).join('')}
484
- </div>
485
- </div>`;
486
- }
487
-
488
- if (dayFollowups.length > 0) {
489
- html += `<div class="mb-6">
490
- <div class="flex items-center gap-2 mb-3">
491
- <span class="text-xs font-mono font-semibold px-2 py-0.5 rounded bg-pink-500/15 text-pink-400 uppercase tracking-wide">Followups (NEXO)</span>
492
- <span class="text-xs text-slate-600 font-mono">${dayFollowups.length}</span>
493
- </div>
494
- <div class="space-y-2">
495
- ${dayFollowups.map(f => itemCardHtml(f, 'followup', dStr, false)).join('')}
496
- </div>
497
- </div>`;
498
- }
499
- }
500
-
501
- html += `</div>`;
502
- document.getElementById('calendar-content').innerHTML = html;
503
- }
504
-
505
- // --- Modal ---
506
-
507
- function openDayModal(dateStr) {
508
- const date = parseDate(dateStr);
509
- const label = date.toLocaleDateString('en-US', { weekday: 'long', day: 'numeric', month: 'long', year: 'numeric' });
510
-
511
- const itemsByDate = buildItemsLookup(calendarItems);
512
- const dayItems = itemsByDate[dateStr];
513
-
514
- const dayReminders = dayItems ? dayItems.reminders : [];
515
- const dayFollowups = dayItems ? dayItems.followups : [];
516
- const total = dayReminders.length + dayFollowups.length;
517
-
518
- document.getElementById('modal-title').textContent = label;
519
- document.getElementById('modal-subtitle').textContent = `${total} item${total !== 1 ? 's' : ''}`;
520
-
521
- let bodyHtml = '';
522
-
523
- if (total === 0) {
524
- bodyHtml = `<div class="text-center py-10 text-slate-600 font-display">No items for this day</div>`;
525
- } else {
526
- const sortItems = (arr, type) => {
527
- const copy = arr.map(r => ({ ...r, _type: type }));
528
- copy.sort((a, b) => {
529
- const order = { overdue: 0, pending: 1, done: 2 };
530
- return order[getItemStatus(a, dateStr)] - order[getItemStatus(b, dateStr)];
531
- });
532
- return copy;
533
- };
534
-
535
- if (dayReminders.length > 0) {
536
- bodyHtml += `<div>
537
- <div class="flex items-center gap-2 mb-2.5">
538
- <span class="text-xs font-mono font-semibold px-2 py-0.5 rounded bg-violet-500/15 text-violet-400 uppercase tracking-wide">Reminders (User)</span>
539
- <span class="text-xs text-slate-600 font-mono">${dayReminders.length}</span>
540
- </div>
541
- <div class="space-y-2">
542
- ${sortItems(dayReminders, 'reminder').map(r => itemCardHtml(r, 'reminder', dateStr, false)).join('')}
543
- </div>
544
- </div>`;
545
- }
546
-
547
- if (dayFollowups.length > 0) {
548
- bodyHtml += `<div>
549
- <div class="flex items-center gap-2 mb-2.5">
550
- <span class="text-xs font-mono font-semibold px-2 py-0.5 rounded bg-pink-500/15 text-pink-400 uppercase tracking-wide">Followups (NEXO)</span>
551
- <span class="text-xs text-slate-600 font-mono">${dayFollowups.length}</span>
552
- </div>
553
- <div class="space-y-2">
554
- ${sortItems(dayFollowups, 'followup').map(f => itemCardHtml(f, 'followup', dateStr, false)).join('')}
555
- </div>
556
- </div>`;
557
- }
558
- }
559
-
560
- document.getElementById('modal-body').innerHTML = bodyHtml;
561
-
562
- const overlay = document.getElementById('modal-overlay');
563
- overlay.classList.remove('hidden');
564
- const box = document.getElementById('modal-box');
565
- box.classList.remove('modal-animate');
566
- void box.offsetWidth;
567
- box.classList.add('modal-animate');
568
-
569
- document._modalEscHandler = (e) => { if (e.key === 'Escape') closeModalDirect(); };
570
- document.addEventListener('keydown', document._modalEscHandler);
571
- }
572
-
573
- function closeModal(e) {
574
- if (e.target === document.getElementById('modal-overlay')) {
575
- closeModalDirect();
576
- }
577
- }
578
-
579
- function closeModalDirect() {
580
- document.getElementById('modal-overlay').classList.add('hidden');
581
- if (document._modalEscHandler) {
582
- document.removeEventListener('keydown', document._modalEscHandler);
583
- }
584
- }
585
-
586
- // --- Init ---
587
-
588
- updateViewButtons();
589
- loadAndRender();
590
- </script>
591
- {% endblock %}