nexo-brain 2.0.0 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (370) hide show
  1. package/README.md +143 -44
  2. package/bin/nexo-brain.js +53 -26
  3. package/package.json +15 -3
  4. package/scripts/migrate-to-unified 2.sh +813 -0
  5. package/scripts/migrate-v1.5-to-v1.6 2.py +778 -0
  6. package/scripts/migrate-v1.7-to-v1.8 2.py +214 -0
  7. package/scripts/pre-commit-check 2.sh +55 -0
  8. package/src/__pycache__/auto_update.cpython-310.pyc +0 -0
  9. package/src/__pycache__/hnsw_index.cpython-310.pyc +0 -0
  10. package/src/__pycache__/kg_populate.cpython-310.pyc +0 -0
  11. package/src/__pycache__/knowledge_graph.cpython-310.pyc +0 -0
  12. package/src/__pycache__/plugin_loader.cpython-310.pyc +0 -0
  13. package/src/__pycache__/tools_coordination.cpython-310.pyc +0 -0
  14. package/src/__pycache__/tools_credentials.cpython-310.pyc +0 -0
  15. package/src/__pycache__/tools_learnings.cpython-310.pyc +0 -0
  16. package/src/__pycache__/tools_menu.cpython-310.pyc +0 -0
  17. package/src/__pycache__/tools_reminders.cpython-310.pyc +0 -0
  18. package/src/__pycache__/tools_reminders_crud.cpython-310.pyc +0 -0
  19. package/src/__pycache__/tools_sessions.cpython-310.pyc +0 -0
  20. package/src/__pycache__/tools_task_history.cpython-310.pyc +0 -0
  21. package/src/auto_close_sessions 2.py +159 -0
  22. package/src/auto_update 2.py +634 -0
  23. package/src/claim_graph 2.py +323 -0
  24. package/src/cognitive/__init__ 2.py +62 -0
  25. package/src/cognitive/__pycache__/__init__.cpython-310.pyc +0 -0
  26. package/src/cognitive/__pycache__/_core.cpython-310.pyc +0 -0
  27. package/src/cognitive/__pycache__/_decay.cpython-310.pyc +0 -0
  28. package/src/cognitive/__pycache__/_ingest.cpython-310.pyc +0 -0
  29. package/src/cognitive/__pycache__/_memory.cpython-310.pyc +0 -0
  30. package/src/cognitive/__pycache__/_search.cpython-310.pyc +0 -0
  31. package/src/cognitive/__pycache__/_trust.cpython-310.pyc +0 -0
  32. package/src/cognitive/_core 2.py +567 -0
  33. package/src/cognitive/_decay 2.py +382 -0
  34. package/src/cognitive/_ingest 2.py +892 -0
  35. package/src/cognitive/_memory 2.py +912 -0
  36. package/src/cognitive/_search 2.py +949 -0
  37. package/src/cognitive/_trust 2.py +464 -0
  38. package/src/cognitive/_trust.py +10 -36
  39. package/src/crons/manifest 2.json +106 -0
  40. package/src/crons/manifest.json +106 -0
  41. package/src/crons/sync 2.py +217 -0
  42. package/src/crons/sync.py +217 -0
  43. package/src/dashboard/__init__ 2.py +0 -0
  44. package/src/dashboard/__pycache__/__init__.cpython-310.pyc +0 -0
  45. package/src/dashboard/__pycache__/app.cpython-310.pyc +0 -0
  46. package/src/dashboard/app 2.py +789 -0
  47. package/src/dashboard/app.py +16 -2
  48. package/src/dashboard/templates/dashboard.html +3 -2
  49. package/src/db/__init__ 2.py +89 -0
  50. package/src/db/__pycache__/__init__.cpython-310.pyc +0 -0
  51. package/src/db/__pycache__/__init__.cpython-312.pyc +0 -0
  52. package/src/db/__pycache__/__init__.cpython-314.pyc +0 -0
  53. package/src/db/__pycache__/_core.cpython-310.pyc +0 -0
  54. package/src/db/__pycache__/_core.cpython-312.pyc +0 -0
  55. package/src/db/__pycache__/_core.cpython-314.pyc +0 -0
  56. package/src/db/__pycache__/_credentials.cpython-310.pyc +0 -0
  57. package/src/db/__pycache__/_credentials.cpython-312.pyc +0 -0
  58. package/src/db/__pycache__/_credentials.cpython-314.pyc +0 -0
  59. package/src/db/__pycache__/_entities.cpython-310.pyc +0 -0
  60. package/src/db/__pycache__/_entities.cpython-312.pyc +0 -0
  61. package/src/db/__pycache__/_entities.cpython-314.pyc +0 -0
  62. package/src/db/__pycache__/_episodic.cpython-310.pyc +0 -0
  63. package/src/db/__pycache__/_episodic.cpython-312.pyc +0 -0
  64. package/src/db/__pycache__/_episodic.cpython-314.pyc +0 -0
  65. package/src/db/__pycache__/_evolution.cpython-310.pyc +0 -0
  66. package/src/db/__pycache__/_evolution.cpython-312.pyc +0 -0
  67. package/src/db/__pycache__/_evolution.cpython-314.pyc +0 -0
  68. package/src/db/__pycache__/_fts.cpython-310.pyc +0 -0
  69. package/src/db/__pycache__/_fts.cpython-312.pyc +0 -0
  70. package/src/db/__pycache__/_fts.cpython-314.pyc +0 -0
  71. package/src/db/__pycache__/_learnings.cpython-310.pyc +0 -0
  72. package/src/db/__pycache__/_learnings.cpython-312.pyc +0 -0
  73. package/src/db/__pycache__/_learnings.cpython-314.pyc +0 -0
  74. package/src/db/__pycache__/_reminders.cpython-310.pyc +0 -0
  75. package/src/db/__pycache__/_reminders.cpython-312.pyc +0 -0
  76. package/src/db/__pycache__/_reminders.cpython-314.pyc +0 -0
  77. package/src/db/__pycache__/_schema.cpython-310.pyc +0 -0
  78. package/src/db/__pycache__/_schema.cpython-312.pyc +0 -0
  79. package/src/db/__pycache__/_schema.cpython-314.pyc +0 -0
  80. package/src/db/__pycache__/_sessions.cpython-310.pyc +0 -0
  81. package/src/db/__pycache__/_sessions.cpython-312.pyc +0 -0
  82. package/src/db/__pycache__/_sessions.cpython-314.pyc +0 -0
  83. package/src/db/__pycache__/_tasks.cpython-310.pyc +0 -0
  84. package/src/db/__pycache__/_tasks.cpython-312.pyc +0 -0
  85. package/src/db/__pycache__/_tasks.cpython-314.pyc +0 -0
  86. package/src/db/_core 2.py +417 -0
  87. package/src/db/_credentials 2.py +124 -0
  88. package/src/db/_entities 2.py +178 -0
  89. package/src/db/_episodic 2.py +738 -0
  90. package/src/db/_episodic.py +1 -1
  91. package/src/db/_evolution 2.py +54 -0
  92. package/src/db/_fts 2.py +406 -0
  93. package/src/db/_learnings 2.py +168 -0
  94. package/src/db/_reminders 2.py +338 -0
  95. package/src/db/_reminders.py +9 -5
  96. package/src/db/_schema 2.py +364 -0
  97. package/src/db/_sessions 2.py +300 -0
  98. package/src/db/_tasks 2.py +91 -0
  99. package/src/evolution_cycle 2.py +266 -0
  100. package/src/hnsw_index 2.py +254 -0
  101. package/src/hooks/auto_capture 2.py +208 -0
  102. package/src/hooks/caffeinate-guard 2.sh +8 -0
  103. package/src/hooks/capture-session 2.sh +21 -0
  104. package/src/hooks/capture-session.sh +2 -0
  105. package/src/hooks/capture-tool-logs 2.sh +127 -0
  106. package/src/hooks/capture-tool-logs.sh +3 -2
  107. package/src/hooks/daily-briefing-check 2.sh +33 -0
  108. package/src/hooks/inbox-hook 2.sh +76 -0
  109. package/src/hooks/inbox-hook.sh +3 -2
  110. package/src/hooks/post-compact 2.sh +148 -0
  111. package/src/hooks/post-compact.sh +1 -1
  112. package/src/hooks/pre-compact 2.sh +151 -0
  113. package/src/hooks/pre-compact.sh +1 -1
  114. package/src/hooks/session-start 2.sh +268 -0
  115. package/src/hooks/session-start.sh +6 -3
  116. package/src/hooks/session-stop 2.sh +140 -0
  117. package/src/hooks/session-stop.sh +3 -2
  118. package/src/kg_populate 2.py +290 -0
  119. package/src/knowledge_graph 2.py +257 -0
  120. package/src/maintenance 2.py +59 -0
  121. package/src/migrate_embeddings 2.py +122 -0
  122. package/src/plugin_loader 2.py +202 -0
  123. package/src/plugins/__init__ 2.py +0 -0
  124. package/src/plugins/__pycache__/__init__ 2.cpython-310.pyc +0 -0
  125. package/src/plugins/__pycache__/__init__.cpython-310.pyc +0 -0
  126. package/src/plugins/__pycache__/adaptive_mode 2.cpython-310.pyc +0 -0
  127. package/src/plugins/__pycache__/adaptive_mode.cpython-310.pyc +0 -0
  128. package/src/plugins/__pycache__/agents 2.cpython-310.pyc +0 -0
  129. package/src/plugins/__pycache__/agents.cpython-310.pyc +0 -0
  130. package/src/plugins/__pycache__/artifact_registry 2.cpython-310.pyc +0 -0
  131. package/src/plugins/__pycache__/artifact_registry.cpython-310.pyc +0 -0
  132. package/src/plugins/__pycache__/backup 2.cpython-310.pyc +0 -0
  133. package/src/plugins/__pycache__/backup.cpython-310.pyc +0 -0
  134. package/src/plugins/__pycache__/cognitive_memory 2.cpython-310.pyc +0 -0
  135. package/src/plugins/__pycache__/cognitive_memory.cpython-310.pyc +0 -0
  136. package/src/plugins/__pycache__/core_rules 2.cpython-310.pyc +0 -0
  137. package/src/plugins/__pycache__/core_rules.cpython-310.pyc +0 -0
  138. package/src/plugins/__pycache__/cortex 2.cpython-310.pyc +0 -0
  139. package/src/plugins/__pycache__/cortex.cpython-310.pyc +0 -0
  140. package/src/plugins/__pycache__/entities 2.cpython-310.pyc +0 -0
  141. package/src/plugins/__pycache__/entities.cpython-310.pyc +0 -0
  142. package/src/plugins/__pycache__/episodic_memory 2.cpython-310.pyc +0 -0
  143. package/src/plugins/__pycache__/episodic_memory.cpython-310.pyc +0 -0
  144. package/src/plugins/__pycache__/evolution 2.cpython-310.pyc +0 -0
  145. package/src/plugins/__pycache__/evolution.cpython-310.pyc +0 -0
  146. package/src/plugins/__pycache__/guard 2.cpython-310.pyc +0 -0
  147. package/src/plugins/__pycache__/guard.cpython-310.pyc +0 -0
  148. package/src/plugins/__pycache__/knowledge_graph_tools 2.cpython-310.pyc +0 -0
  149. package/src/plugins/__pycache__/knowledge_graph_tools.cpython-310.pyc +0 -0
  150. package/src/plugins/__pycache__/preferences 2.cpython-310.pyc +0 -0
  151. package/src/plugins/__pycache__/preferences.cpython-310.pyc +0 -0
  152. package/src/plugins/__pycache__/update 2.cpython-310.pyc +0 -0
  153. package/src/plugins/__pycache__/update.cpython-310.pyc +0 -0
  154. package/src/plugins/adaptive_mode 2.py +805 -0
  155. package/src/plugins/agents 2.py +52 -0
  156. package/src/plugins/artifact_registry 2.py +450 -0
  157. package/src/plugins/backup 2.py +104 -0
  158. package/src/plugins/cognitive_memory 2.py +564 -0
  159. package/src/plugins/core_rules 2.py +252 -0
  160. package/src/plugins/core_rules.py +34 -17
  161. package/src/plugins/cortex 2.py +299 -0
  162. package/src/plugins/entities 2.py +67 -0
  163. package/src/plugins/episodic_memory 2.py +533 -0
  164. package/src/plugins/evolution 2.py +115 -0
  165. package/src/plugins/guard 2.py +746 -0
  166. package/src/plugins/knowledge_graph_tools 2.py +105 -0
  167. package/src/plugins/preferences 2.py +47 -0
  168. package/src/plugins/update 2.py +256 -0
  169. package/src/plugins/update.py +18 -0
  170. package/src/requirements 2.txt +12 -0
  171. package/src/rules/__init__ 2.py +0 -0
  172. package/src/rules/core-rules 2.json +331 -0
  173. package/src/rules/migrate 2.py +207 -0
  174. package/src/scripts/check-context 2.py +264 -0
  175. package/src/scripts/check-context.py +4 -7
  176. package/src/scripts/deep-sleep/apply_findings.py +570 -167
  177. package/src/scripts/deep-sleep/collect.py +480 -0
  178. package/src/scripts/deep-sleep/extract-prompt.md +233 -0
  179. package/src/scripts/deep-sleep/extract.py +249 -0
  180. package/src/scripts/deep-sleep/synthesize-prompt.md +197 -0
  181. package/src/scripts/deep-sleep/synthesize.py +191 -0
  182. package/src/scripts/nexo-auto-update 2.py +6 -0
  183. package/src/scripts/nexo-backup 2.sh +25 -0
  184. package/src/scripts/nexo-brain-activation 2.sh +140 -0
  185. package/src/scripts/nexo-catchup 2.py +242 -0
  186. package/src/scripts/nexo-catchup.py +5 -8
  187. package/src/scripts/nexo-cognitive-decay 2.py +182 -0
  188. package/src/scripts/nexo-daily-self-audit 2.py +552 -0
  189. package/src/scripts/nexo-daily-self-audit.py +28 -19
  190. package/src/scripts/nexo-deep-sleep 2.sh +97 -0
  191. package/src/scripts/nexo-deep-sleep.sh +31 -16
  192. package/src/scripts/nexo-evolution-run 2.py +597 -0
  193. package/src/scripts/nexo-evolution-run.py +5 -20
  194. package/src/scripts/nexo-followup-hygiene 2.py +112 -0
  195. package/src/scripts/nexo-followup-hygiene.py +4 -2
  196. package/src/scripts/nexo-github-monitor 2.py +256 -0
  197. package/src/scripts/nexo-github-monitor.py +6 -9
  198. package/src/scripts/nexo-immune 2.py +927 -0
  199. package/src/scripts/nexo-immune.py +4 -17
  200. package/src/scripts/nexo-inbox-hook 2.sh +74 -0
  201. package/src/scripts/nexo-install 2.py +6 -0
  202. package/src/scripts/nexo-learning-housekeep 2.py +245 -0
  203. package/src/scripts/nexo-learning-validator 2.py +207 -0
  204. package/src/scripts/nexo-learning-validator.py +0 -29
  205. package/src/scripts/nexo-migrate 2.py +232 -0
  206. package/src/scripts/nexo-postmortem-consolidator 2.py +421 -0
  207. package/src/scripts/nexo-postmortem-consolidator.py +9 -20
  208. package/src/scripts/nexo-pre-commit 2.py +120 -0
  209. package/src/scripts/nexo-prevent-sleep 2.sh +29 -0
  210. package/src/scripts/nexo-proactive-dashboard 2.py +345 -0
  211. package/src/scripts/nexo-proactive-dashboard.py +1 -0
  212. package/src/scripts/nexo-reflection 2.py +253 -0
  213. package/src/scripts/nexo-runtime-preflight 2.py +274 -0
  214. package/src/scripts/nexo-send-email 2.py +25 -0
  215. package/src/scripts/nexo-send-reply 2.py +178 -0
  216. package/src/scripts/nexo-sleep 2.py +592 -0
  217. package/src/scripts/nexo-sleep.py +8 -18
  218. package/src/scripts/nexo-snapshot-restore 2.sh +35 -0
  219. package/src/scripts/nexo-synthesis 2.py +253 -0
  220. package/src/scripts/nexo-synthesis.py +8 -19
  221. package/src/scripts/nexo-tcc-approve 2.sh +79 -0
  222. package/src/scripts/nexo-update 2.sh +161 -0
  223. package/src/scripts/nexo-watchdog 2.sh +878 -0
  224. package/src/scripts/nexo-watchdog-smoke 2.py +119 -0
  225. package/src/server 2.py +733 -0
  226. package/src/server.py +6 -1
  227. package/src/storage_router 2.py +32 -0
  228. package/src/tools_coordination 2.py +102 -0
  229. package/src/tools_credentials 2.py +68 -0
  230. package/src/tools_learnings 2.py +220 -0
  231. package/src/tools_menu 2.py +227 -0
  232. package/src/tools_menu.py +1 -1
  233. package/src/tools_reminders 2.py +86 -0
  234. package/src/tools_reminders_crud 2.py +159 -0
  235. package/src/tools_reminders_crud.py +7 -0
  236. package/src/tools_sessions 2.py +476 -0
  237. package/src/tools_sessions.py +67 -0
  238. package/src/tools_task_history 2.py +57 -0
  239. package/templates/CLAUDE.md 2.template +63 -0
  240. package/templates/openclaw 2.json +13 -0
  241. package/tests/__init__ 2.py +0 -0
  242. package/tests/conftest 2.py +71 -0
  243. package/tests/test_cognitive 2.py +205 -0
  244. package/tests/test_knowledge_graph 2.py +140 -0
  245. package/tests/test_migrations 2.py +137 -0
  246. package/src/__pycache__/auto_close_sessions.cpython-310.pyc +0 -0
  247. package/src/__pycache__/auto_close_sessions.cpython-314.pyc +0 -0
  248. package/src/__pycache__/auto_update.cpython-314.pyc +0 -0
  249. package/src/__pycache__/claim_graph.cpython-310.pyc +0 -0
  250. package/src/__pycache__/claim_graph.cpython-314.pyc +0 -0
  251. package/src/__pycache__/evolution_cycle.cpython-310.pyc +0 -0
  252. package/src/__pycache__/evolution_cycle.cpython-314.pyc +0 -0
  253. package/src/__pycache__/hnsw_index.cpython-314.pyc +0 -0
  254. package/src/__pycache__/kg_populate.cpython-314.pyc +0 -0
  255. package/src/__pycache__/knowledge_graph.cpython-314.pyc +0 -0
  256. package/src/__pycache__/maintenance.cpython-310.pyc +0 -0
  257. package/src/__pycache__/maintenance.cpython-314.pyc +0 -0
  258. package/src/__pycache__/migrate_embeddings.cpython-310.pyc +0 -0
  259. package/src/__pycache__/migrate_embeddings.cpython-314.pyc +0 -0
  260. package/src/__pycache__/plugin_loader.cpython-314.pyc +0 -0
  261. package/src/__pycache__/server.cpython-310.pyc +0 -0
  262. package/src/__pycache__/server.cpython-314.pyc +0 -0
  263. package/src/__pycache__/storage_router.cpython-310.pyc +0 -0
  264. package/src/__pycache__/storage_router.cpython-314.pyc +0 -0
  265. package/src/__pycache__/tools_coordination.cpython-314.pyc +0 -0
  266. package/src/__pycache__/tools_credentials.cpython-314.pyc +0 -0
  267. package/src/__pycache__/tools_learnings.cpython-314.pyc +0 -0
  268. package/src/__pycache__/tools_menu.cpython-314.pyc +0 -0
  269. package/src/__pycache__/tools_reminders.cpython-314.pyc +0 -0
  270. package/src/__pycache__/tools_reminders_crud.cpython-314.pyc +0 -0
  271. package/src/__pycache__/tools_sessions.cpython-314.pyc +0 -0
  272. package/src/__pycache__/tools_task_history.cpython-314.pyc +0 -0
  273. package/src/cognitive/__pycache__/__init__.cpython-314.pyc +0 -0
  274. package/src/cognitive/__pycache__/_core.cpython-314.pyc +0 -0
  275. package/src/cognitive/__pycache__/_decay.cpython-314.pyc +0 -0
  276. package/src/cognitive/__pycache__/_ingest.cpython-314.pyc +0 -0
  277. package/src/cognitive/__pycache__/_memory.cpython-314.pyc +0 -0
  278. package/src/cognitive/__pycache__/_search.cpython-314.pyc +0 -0
  279. package/src/cognitive/__pycache__/_trust.cpython-314.pyc +0 -0
  280. package/src/dashboard/__pycache__/__init__.cpython-314.pyc +0 -0
  281. package/src/dashboard/__pycache__/app.cpython-314.pyc +0 -0
  282. package/src/hooks/__pycache__/auto_capture.cpython-310.pyc +0 -0
  283. package/src/hooks/__pycache__/auto_capture.cpython-314.pyc +0 -0
  284. package/src/plugins/__pycache__/__init__.cpython-314.pyc +0 -0
  285. package/src/plugins/__pycache__/adaptive_mode.cpython-314.pyc +0 -0
  286. package/src/plugins/__pycache__/agents.cpython-314.pyc +0 -0
  287. package/src/plugins/__pycache__/artifact_registry.cpython-314.pyc +0 -0
  288. package/src/plugins/__pycache__/backup.cpython-314.pyc +0 -0
  289. package/src/plugins/__pycache__/cognitive_memory.cpython-314.pyc +0 -0
  290. package/src/plugins/__pycache__/core_rules.cpython-314.pyc +0 -0
  291. package/src/plugins/__pycache__/cortex.cpython-314.pyc +0 -0
  292. package/src/plugins/__pycache__/entities.cpython-314.pyc +0 -0
  293. package/src/plugins/__pycache__/episodic_memory.cpython-314.pyc +0 -0
  294. package/src/plugins/__pycache__/evolution.cpython-314.pyc +0 -0
  295. package/src/plugins/__pycache__/guard.cpython-314.pyc +0 -0
  296. package/src/plugins/__pycache__/knowledge_graph_tools.cpython-314.pyc +0 -0
  297. package/src/plugins/__pycache__/preferences.cpython-314.pyc +0 -0
  298. package/src/rules/__pycache__/__init__.cpython-310.pyc +0 -0
  299. package/src/rules/__pycache__/__init__.cpython-314.pyc +0 -0
  300. package/src/rules/__pycache__/migrate.cpython-310.pyc +0 -0
  301. package/src/rules/__pycache__/migrate.cpython-314.pyc +0 -0
  302. package/src/scripts/__pycache__/check-context.cpython-310.pyc +0 -0
  303. package/src/scripts/__pycache__/check-context.cpython-314.pyc +0 -0
  304. package/src/scripts/__pycache__/nexo-auto-update.cpython-310.pyc +0 -0
  305. package/src/scripts/__pycache__/nexo-auto-update.cpython-314.pyc +0 -0
  306. package/src/scripts/__pycache__/nexo-catchup.cpython-310.pyc +0 -0
  307. package/src/scripts/__pycache__/nexo-catchup.cpython-314.pyc +0 -0
  308. package/src/scripts/__pycache__/nexo-cognitive-decay.cpython-310.pyc +0 -0
  309. package/src/scripts/__pycache__/nexo-cognitive-decay.cpython-314.pyc +0 -0
  310. package/src/scripts/__pycache__/nexo-daily-self-audit.cpython-310.pyc +0 -0
  311. package/src/scripts/__pycache__/nexo-daily-self-audit.cpython-314.pyc +0 -0
  312. package/src/scripts/__pycache__/nexo-evolution-run.cpython-310.pyc +0 -0
  313. package/src/scripts/__pycache__/nexo-evolution-run.cpython-314.pyc +0 -0
  314. package/src/scripts/__pycache__/nexo-followup-hygiene.cpython-310.pyc +0 -0
  315. package/src/scripts/__pycache__/nexo-followup-hygiene.cpython-314.pyc +0 -0
  316. package/src/scripts/__pycache__/nexo-github-monitor.cpython-310.pyc +0 -0
  317. package/src/scripts/__pycache__/nexo-github-monitor.cpython-314.pyc +0 -0
  318. package/src/scripts/__pycache__/nexo-immune.cpython-310.pyc +0 -0
  319. package/src/scripts/__pycache__/nexo-immune.cpython-314.pyc +0 -0
  320. package/src/scripts/__pycache__/nexo-install.cpython-310.pyc +0 -0
  321. package/src/scripts/__pycache__/nexo-install.cpython-314.pyc +0 -0
  322. package/src/scripts/__pycache__/nexo-learning-housekeep.cpython-310.pyc +0 -0
  323. package/src/scripts/__pycache__/nexo-learning-housekeep.cpython-314.pyc +0 -0
  324. package/src/scripts/__pycache__/nexo-learning-validator.cpython-310.pyc +0 -0
  325. package/src/scripts/__pycache__/nexo-learning-validator.cpython-314.pyc +0 -0
  326. package/src/scripts/__pycache__/nexo-migrate.cpython-310.pyc +0 -0
  327. package/src/scripts/__pycache__/nexo-migrate.cpython-314.pyc +0 -0
  328. package/src/scripts/__pycache__/nexo-postmortem-consolidator.cpython-310.pyc +0 -0
  329. package/src/scripts/__pycache__/nexo-postmortem-consolidator.cpython-314.pyc +0 -0
  330. package/src/scripts/__pycache__/nexo-pre-commit.cpython-310.pyc +0 -0
  331. package/src/scripts/__pycache__/nexo-pre-commit.cpython-314.pyc +0 -0
  332. package/src/scripts/__pycache__/nexo-proactive-dashboard.cpython-310.pyc +0 -0
  333. package/src/scripts/__pycache__/nexo-proactive-dashboard.cpython-314.pyc +0 -0
  334. package/src/scripts/__pycache__/nexo-reflection.cpython-310.pyc +0 -0
  335. package/src/scripts/__pycache__/nexo-reflection.cpython-314.pyc +0 -0
  336. package/src/scripts/__pycache__/nexo-runtime-preflight.cpython-310.pyc +0 -0
  337. package/src/scripts/__pycache__/nexo-runtime-preflight.cpython-314.pyc +0 -0
  338. package/src/scripts/__pycache__/nexo-send-email.cpython-310.pyc +0 -0
  339. package/src/scripts/__pycache__/nexo-send-email.cpython-314.pyc +0 -0
  340. package/src/scripts/__pycache__/nexo-send-reply.cpython-310.pyc +0 -0
  341. package/src/scripts/__pycache__/nexo-send-reply.cpython-314.pyc +0 -0
  342. package/src/scripts/__pycache__/nexo-sleep.cpython-310.pyc +0 -0
  343. package/src/scripts/__pycache__/nexo-sleep.cpython-314.pyc +0 -0
  344. package/src/scripts/__pycache__/nexo-synthesis.cpython-310.pyc +0 -0
  345. package/src/scripts/__pycache__/nexo-synthesis.cpython-314.pyc +0 -0
  346. package/src/scripts/__pycache__/nexo-watchdog-smoke.cpython-310.pyc +0 -0
  347. package/src/scripts/__pycache__/nexo-watchdog-smoke.cpython-314.pyc +0 -0
  348. package/src/scripts/deep-sleep/__pycache__/analyze_session.cpython-310.pyc +0 -0
  349. package/src/scripts/deep-sleep/__pycache__/analyze_session.cpython-314.pyc +0 -0
  350. package/src/scripts/deep-sleep/__pycache__/apply_findings.cpython-310.pyc +0 -0
  351. package/src/scripts/deep-sleep/__pycache__/apply_findings.cpython-314.pyc +0 -0
  352. package/src/scripts/deep-sleep/__pycache__/collect_transcripts.cpython-310.pyc +0 -0
  353. package/src/scripts/deep-sleep/__pycache__/collect_transcripts.cpython-314.pyc +0 -0
  354. package/src/scripts/deep-sleep/analyze_session.py +0 -217
  355. package/src/scripts/deep-sleep/collect_transcripts.py +0 -145
  356. package/src/scripts/deep-sleep/prompt.md +0 -109
  357. package/tests/__pycache__/__init__.cpython-310.pyc +0 -0
  358. package/tests/__pycache__/__init__.cpython-314.pyc +0 -0
  359. package/tests/__pycache__/conftest.cpython-310-pytest-9.0.2.pyc +0 -0
  360. package/tests/__pycache__/conftest.cpython-310.pyc +0 -0
  361. package/tests/__pycache__/conftest.cpython-314-pytest-9.0.2.pyc +0 -0
  362. package/tests/__pycache__/test_cognitive.cpython-310-pytest-9.0.2.pyc +0 -0
  363. package/tests/__pycache__/test_cognitive.cpython-310.pyc +0 -0
  364. package/tests/__pycache__/test_cognitive.cpython-314-pytest-9.0.2.pyc +0 -0
  365. package/tests/__pycache__/test_knowledge_graph.cpython-310-pytest-9.0.2.pyc +0 -0
  366. package/tests/__pycache__/test_knowledge_graph.cpython-310.pyc +0 -0
  367. package/tests/__pycache__/test_knowledge_graph.cpython-314-pytest-9.0.2.pyc +0 -0
  368. package/tests/__pycache__/test_migrations.cpython-310-pytest-9.0.2.pyc +0 -0
  369. package/tests/__pycache__/test_migrations.cpython-310.pyc +0 -0
  370. package/tests/__pycache__/test_migrations.cpython-314-pytest-9.0.2.pyc +0 -0
@@ -0,0 +1,338 @@
1
+ """NEXO DB — Reminders module."""
2
+ import sqlite3, time, datetime
3
+ from datetime import timedelta
4
+ from db._core import get_db, now_epoch
5
+ from db._fts import fts_upsert
6
+
7
+ # ── Reminders ──────────────────────────────────────────────────────
8
+
9
+ def create_reminder(id: str, description: str, date: str = None,
10
+ status: str = 'PENDING', category: str = 'general') -> dict:
11
+ """Create a new reminder."""
12
+ conn = get_db()
13
+ now = now_epoch()
14
+ try:
15
+ conn.execute(
16
+ "INSERT INTO reminders (id, date, description, status, category, created_at, updated_at) "
17
+ "VALUES (?, ?, ?, ?, ?, ?, ?)",
18
+ (id, date, description, status, category, now, now)
19
+ )
20
+ conn.commit()
21
+ except sqlite3.IntegrityError:
22
+ return {"error": f"Reminder {id} already exists. Use update instead."}
23
+ row = conn.execute("SELECT * FROM reminders WHERE id = ?", (id,)).fetchone()
24
+ return dict(row)
25
+
26
+
27
+ def update_reminder(id: str, **kwargs) -> dict:
28
+ """Update any fields of a reminder: description, date, status, category."""
29
+ conn = get_db()
30
+ row = conn.execute("SELECT * FROM reminders WHERE id = ?", (id,)).fetchone()
31
+ if not row:
32
+ return {"error": f"Reminder {id} not found"}
33
+ allowed = {"description", "date", "status", "category"}
34
+ updates = {k: v for k, v in kwargs.items() if k in allowed}
35
+ if not updates:
36
+ return {"error": "No valid fields to update"}
37
+ updates["updated_at"] = now_epoch()
38
+ set_clause = ", ".join(f"{k} = ?" for k in updates)
39
+ values = list(updates.values()) + [id]
40
+ conn.execute(f"UPDATE reminders SET {set_clause} WHERE id = ?", values)
41
+ conn.commit()
42
+ row = conn.execute("SELECT * FROM reminders WHERE id = ?", (id,)).fetchone()
43
+ return dict(row)
44
+
45
+
46
+ def complete_reminder(id: str) -> dict:
47
+ """Mark a reminder as completed with today's date."""
48
+ today = datetime.date.today().isoformat()
49
+ return update_reminder(id, status="COMPLETED")
50
+
51
+
52
+ def delete_reminder(id: str) -> bool:
53
+ """Delete a reminder."""
54
+ conn = get_db()
55
+ result = conn.execute("DELETE FROM reminders WHERE id = ?", (id,))
56
+ conn.commit()
57
+ deleted = result.rowcount > 0
58
+ return deleted
59
+
60
+
61
+ def get_reminders(filter_type: str = 'all') -> list[dict]:
62
+ """Get reminders by filter: 'all' (active), 'due' (date <= today), 'completed'."""
63
+ conn = get_db()
64
+ today = datetime.date.today().isoformat()
65
+ if filter_type == 'completed':
66
+ rows = conn.execute(
67
+ "SELECT * FROM reminders WHERE status LIKE 'COMPLETED%' ORDER BY updated_at DESC"
68
+ ).fetchall()
69
+ elif filter_type == 'due':
70
+ rows = conn.execute(
71
+ "SELECT * FROM reminders WHERE status NOT LIKE 'COMPLETED%' "
72
+ "AND status NOT IN ('DELETED','archived','blocked','waiting') "
73
+ "AND date IS NOT NULL AND date <= ? "
74
+ "ORDER BY date ASC",
75
+ (today,)
76
+ ).fetchall()
77
+ else: # 'all' — active only
78
+ rows = conn.execute(
79
+ "SELECT * FROM reminders WHERE status NOT LIKE 'COMPLETED%' "
80
+ "AND status NOT IN ('DELETED','archived','blocked','waiting') "
81
+ "ORDER BY date ASC NULLS LAST"
82
+ ).fetchall()
83
+ return [dict(r) for r in rows]
84
+
85
+
86
+ def get_reminder(id: str) -> dict | None:
87
+ """Get a single reminder by id."""
88
+ conn = get_db()
89
+ row = conn.execute("SELECT * FROM reminders WHERE id = ?", (id,)).fetchone()
90
+ return dict(row) if row else None
91
+
92
+
93
+ def find_similar_followups(description: str, threshold: float = 0.3) -> list[dict]:
94
+ """Find open followups similar to a description using keyword overlap.
95
+
96
+ Uses asymmetric scoring: what fraction of the SMALLER token set overlaps
97
+ with the larger. This handles different-length texts better than Jaccard.
98
+
99
+ Returns matches sorted by similarity score (highest first).
100
+ threshold: minimum overlap ratio (0.0-1.0) to consider a match.
101
+ """
102
+ conn = get_db()
103
+ rows = conn.execute(
104
+ "SELECT * FROM followups WHERE status NOT LIKE 'COMPLETED%' "
105
+ "AND status NOT IN ('DELETED','archived','blocked','waiting')"
106
+ ).fetchall()
107
+
108
+ def tokenize(text: str) -> set:
109
+ return {w.lower() for w in text.split() if len(w) > 3}
110
+
111
+ query_tokens = tokenize(description)
112
+ if not query_tokens:
113
+ return []
114
+
115
+ matches = []
116
+ for row in rows:
117
+ existing_tokens = tokenize(f"{row['id']} {row['description']} {row['verification'] or ''}")
118
+ if not existing_tokens:
119
+ continue
120
+ intersection = query_tokens & existing_tokens
121
+ if not intersection:
122
+ continue
123
+ smaller = min(len(query_tokens), len(existing_tokens))
124
+ score = len(intersection) / smaller if smaller else 0
125
+ if score >= threshold:
126
+ matches.append({**dict(row), "_similarity": round(score, 2)})
127
+
128
+ matches.sort(key=lambda x: x["_similarity"], reverse=True)
129
+ return matches[:5]
130
+
131
+
132
+ # ── Followups ──────────────────────────────────────────────────────
133
+
134
+ def create_followup(id: str, description: str, date: str = None,
135
+ verification: str = '', status: str = 'PENDING',
136
+ reasoning: str = '', recurrence: str = None) -> dict:
137
+ """Create a new followup with optional reasoning and recurrence.
138
+
139
+ Checks for similar open followups before creating. If a match is found,
140
+ returns a warning with the existing followup ID (still creates the new one).
141
+
142
+ recurrence format: 'weekly:monday', 'monthly:1', 'monthly:10', 'quarterly', etc.
143
+ When a recurring followup is completed, a new one is auto-created with the next date.
144
+ """
145
+ conn = get_db()
146
+ now = now_epoch()
147
+
148
+ # Anti-duplicate check
149
+ similar = find_similar_followups(description)
150
+ warning = ""
151
+ if similar:
152
+ ids = ", ".join(s["id"] for s in similar[:3])
153
+ warning = f" ⚠ SIMILAR FOLLOWUPS EXIST: {ids} (scores: {', '.join(str(s['_similarity']) for s in similar[:3])}). Consider updating instead."
154
+
155
+ try:
156
+ conn.execute(
157
+ "INSERT INTO followups (id, date, description, verification, status, reasoning, recurrence, created_at, updated_at) "
158
+ "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)",
159
+ (id, date, description, verification, status, reasoning, recurrence, now, now)
160
+ )
161
+ conn.commit()
162
+ fts_upsert("followup", id, id, f"{description} {verification} {reasoning}", "followup", commit=False)
163
+ except sqlite3.IntegrityError:
164
+ return {"error": f"Followup {id} already exists. Use update instead."}
165
+ row = conn.execute("SELECT * FROM followups WHERE id = ?", (id,)).fetchone()
166
+ result = dict(row)
167
+ if warning:
168
+ result["warning"] = warning
169
+ return result
170
+
171
+
172
+ def update_followup(id: str, **kwargs) -> dict:
173
+ """Update any fields of a followup: description, date, verification, status, reasoning."""
174
+ conn = get_db()
175
+ row = conn.execute("SELECT * FROM followups WHERE id = ?", (id,)).fetchone()
176
+ if not row:
177
+ return {"error": f"Followup {id} not found"}
178
+ allowed = {"description", "date", "verification", "status", "reasoning", "recurrence"}
179
+ updates = {k: v for k, v in kwargs.items() if k in allowed}
180
+ if not updates:
181
+ return {"error": "No valid fields to update"}
182
+ updates["updated_at"] = now_epoch()
183
+ set_clause = ", ".join(f"{k} = ?" for k in updates)
184
+ values = list(updates.values()) + [id]
185
+ conn.execute(f"UPDATE followups SET {set_clause} WHERE id = ?", values)
186
+ conn.commit()
187
+ row = conn.execute("SELECT * FROM followups WHERE id = ?", (id,)).fetchone()
188
+ r = dict(row)
189
+ fts_upsert("followup", id, id, f"{r.get('description','')} {r.get('verification','')} {r.get('reasoning','')}", "followup", commit=False)
190
+ return r
191
+
192
+
193
+ def _calc_next_recurrence_date(recurrence: str, current_date: str = None) -> str:
194
+ """Calculate the next date for a recurring followup.
195
+
196
+ Formats:
197
+ weekly:monday, weekly:thursday, weekly:friday, weekly:sunday
198
+ monthly:1, monthly:10, monthly:15
199
+ quarterly
200
+ """
201
+ today = datetime.date.today()
202
+ base = datetime.date.fromisoformat(current_date) if current_date else today
203
+
204
+ if recurrence.startswith('weekly:'):
205
+ day_name = recurrence.split(':')[1].lower()
206
+ day_map = {'monday': 0, 'tuesday': 1, 'wednesday': 2, 'thursday': 3,
207
+ 'friday': 4, 'saturday': 5, 'sunday': 6}
208
+ target_day = day_map.get(day_name, 0)
209
+ days_ahead = (target_day - today.weekday()) % 7
210
+ if days_ahead == 0:
211
+ days_ahead = 7 # next week, not today
212
+ return (today + datetime.timedelta(days=days_ahead)).isoformat()
213
+
214
+ elif recurrence.startswith('monthly:'):
215
+ target_day = int(recurrence.split(':')[1])
216
+ # Next month from today
217
+ if today.month == 12:
218
+ next_date = datetime.date(today.year + 1, 1, min(target_day, 28))
219
+ else:
220
+ import calendar
221
+ max_day = calendar.monthrange(today.year, today.month + 1)[1]
222
+ next_date = datetime.date(today.year, today.month + 1, min(target_day, max_day))
223
+ return next_date.isoformat()
224
+
225
+ elif recurrence == 'quarterly':
226
+ # 3 months from current date
227
+ month = base.month + 3
228
+ year = base.year
229
+ if month > 12:
230
+ month -= 12
231
+ year += 1
232
+ import calendar
233
+ max_day = calendar.monthrange(year, month)[1]
234
+ return datetime.date(year, month, min(base.day, max_day)).isoformat()
235
+
236
+ return None
237
+
238
+
239
+ def complete_followup(id: str, result: str = '') -> dict:
240
+ """Mark a followup as completed with today's date and optional result.
241
+ If the followup has a recurrence pattern, auto-creates the next occurrence."""
242
+ conn = get_db()
243
+ row = conn.execute("SELECT * FROM followups WHERE id = ?", (id,)).fetchone()
244
+ if not row:
245
+ return {"error": f"Followup {id} not found"}
246
+
247
+ today = datetime.date.today().isoformat()
248
+ kwargs = {"status": "COMPLETED"}
249
+ if result:
250
+ existing = row["verification"] or ''
251
+ kwargs["verification"] = f"{existing}\n{result}".strip() if existing else result
252
+
253
+ update_result = update_followup(id, **kwargs)
254
+
255
+ # Auto-regenerate if recurring
256
+ recurrence = row["recurrence"]
257
+ if recurrence:
258
+ next_date = _calc_next_recurrence_date(recurrence, row["date"])
259
+ if next_date:
260
+ # Rename completed one to include date suffix, then create fresh one
261
+ archived_id = f"{id}-{today}"
262
+ conn.execute("UPDATE followups SET id = ? WHERE id = ?", (archived_id, id))
263
+ conn.commit()
264
+
265
+ # Fix FTS: remove old entry for original ID, add entry for archived ID
266
+ conn.execute("DELETE FROM unified_search WHERE source = 'followup' AND source_id = ?", (id,))
267
+ archived_row = conn.execute("SELECT * FROM followups WHERE id = ?", (archived_id,)).fetchone()
268
+ if archived_row:
269
+ fts_upsert(
270
+ "followup", archived_id, archived_id,
271
+ f"{archived_row['description']} {archived_row['verification'] or ''} {archived_row['reasoning'] or ''}",
272
+ "followup", commit=False,
273
+ )
274
+
275
+ # create_followup handles its own FTS entry for the new recurring ID
276
+ create_followup(
277
+ id=id,
278
+ description=row["description"],
279
+ date=next_date,
280
+ verification='',
281
+ reasoning=row["reasoning"] or '',
282
+ recurrence=recurrence,
283
+ )
284
+
285
+ # Return accurate result: the completed one is now archived_id, not id
286
+ return {
287
+ "id": archived_id,
288
+ "status": "COMPLETED",
289
+ "recurrence": recurrence,
290
+ "next_id": id,
291
+ "next_date": next_date,
292
+ }
293
+
294
+ return update_result
295
+
296
+
297
+ def delete_followup(id: str) -> bool:
298
+ """Delete a followup."""
299
+ conn = get_db()
300
+ result = conn.execute("DELETE FROM followups WHERE id = ?", (id,))
301
+ conn.execute("DELETE FROM unified_search WHERE source = 'followup' AND source_id = ?", (str(id),))
302
+ conn.commit()
303
+ deleted = result.rowcount > 0
304
+ return deleted
305
+
306
+
307
+ def get_followups(filter_type: str = 'all') -> list[dict]:
308
+ """Get followups by filter: 'all' (active), 'due' (date <= today), 'completed'."""
309
+ conn = get_db()
310
+ today = datetime.date.today().isoformat()
311
+ if filter_type == 'completed':
312
+ rows = conn.execute(
313
+ "SELECT * FROM followups WHERE status LIKE 'COMPLETED%' ORDER BY updated_at DESC"
314
+ ).fetchall()
315
+ elif filter_type == 'due':
316
+ rows = conn.execute(
317
+ "SELECT * FROM followups WHERE status NOT LIKE 'COMPLETED%' "
318
+ "AND status NOT IN ('DELETED','archived','blocked','waiting') "
319
+ "AND date IS NOT NULL AND date <= ? "
320
+ "ORDER BY date ASC",
321
+ (today,)
322
+ ).fetchall()
323
+ else: # 'all' — active only
324
+ rows = conn.execute(
325
+ "SELECT * FROM followups WHERE status NOT LIKE 'COMPLETED%' "
326
+ "AND status NOT IN ('DELETED','archived','blocked','waiting') "
327
+ "ORDER BY date ASC NULLS LAST"
328
+ ).fetchall()
329
+ return [dict(r) for r in rows]
330
+
331
+
332
+ def get_followup(id: str) -> dict | None:
333
+ """Get a single followup by id."""
334
+ conn = get_db()
335
+ row = conn.execute("SELECT * FROM followups WHERE id = ?", (id,)).fetchone()
336
+ return dict(row) if row else None
337
+
338
+
@@ -69,14 +69,16 @@ def get_reminders(filter_type: str = 'all') -> list[dict]:
69
69
  elif filter_type == 'due':
70
70
  rows = conn.execute(
71
71
  "SELECT * FROM reminders WHERE status NOT LIKE 'COMPLETED%' "
72
- "AND status != 'DELETED' AND date IS NOT NULL AND date <= ? "
72
+ "AND status NOT IN ('DELETED','archived','blocked','waiting') "
73
+ "AND date IS NOT NULL AND date <= ? "
73
74
  "ORDER BY date ASC",
74
75
  (today,)
75
76
  ).fetchall()
76
77
  else: # 'all' — active only
77
78
  rows = conn.execute(
78
79
  "SELECT * FROM reminders WHERE status NOT LIKE 'COMPLETED%' "
79
- "AND status != 'DELETED' ORDER BY date ASC NULLS LAST"
80
+ "AND status NOT IN ('DELETED','archived','blocked','waiting') "
81
+ "ORDER BY date ASC NULLS LAST"
80
82
  ).fetchall()
81
83
  return [dict(r) for r in rows]
82
84
 
@@ -100,7 +102,7 @@ def find_similar_followups(description: str, threshold: float = 0.3) -> list[dic
100
102
  conn = get_db()
101
103
  rows = conn.execute(
102
104
  "SELECT * FROM followups WHERE status NOT LIKE 'COMPLETED%' "
103
- "AND status != 'DELETED'"
105
+ "AND status NOT IN ('DELETED','archived','blocked','waiting')"
104
106
  ).fetchall()
105
107
 
106
108
  def tokenize(text: str) -> set:
@@ -313,14 +315,16 @@ def get_followups(filter_type: str = 'all') -> list[dict]:
313
315
  elif filter_type == 'due':
314
316
  rows = conn.execute(
315
317
  "SELECT * FROM followups WHERE status NOT LIKE 'COMPLETED%' "
316
- "AND status != 'DELETED' AND date IS NOT NULL AND date <= ? "
318
+ "AND status NOT IN ('DELETED','archived','blocked','waiting') "
319
+ "AND date IS NOT NULL AND date <= ? "
317
320
  "ORDER BY date ASC",
318
321
  (today,)
319
322
  ).fetchall()
320
323
  else: # 'all' — active only
321
324
  rows = conn.execute(
322
325
  "SELECT * FROM followups WHERE status NOT LIKE 'COMPLETED%' "
323
- "AND status != 'DELETED' ORDER BY date ASC NULLS LAST"
326
+ "AND status NOT IN ('DELETED','archived','blocked','waiting') "
327
+ "ORDER BY date ASC NULLS LAST"
324
328
  ).fetchall()
325
329
  return [dict(r) for r in rows]
326
330