nexo-brain 7.23.13 → 7.25.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 (59) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/README.md +15 -11
  3. package/bin/nexo-brain.js +42 -235
  4. package/package.json +1 -1
  5. package/src/auto_update.py +30 -0
  6. package/src/automation_supervisor.py +1 -1
  7. package/src/cli.py +255 -9
  8. package/src/cognitive_control_observatory.py +224 -0
  9. package/src/crons/manifest.json +13 -0
  10. package/src/dashboard/app.py +26 -9
  11. package/src/db/__init__.py +2 -0
  12. package/src/db/_fts.py +38 -8
  13. package/src/db/_learnings.py +1 -1
  14. package/src/db/_memory_v2.py +107 -1
  15. package/src/db/_protocol.py +2 -2
  16. package/src/db/_reminders.py +132 -4
  17. package/src/db/_schema.py +48 -2
  18. package/src/doctor/providers/runtime.py +69 -0
  19. package/src/events_bus.py +4 -5
  20. package/src/learning_resolver.py +419 -0
  21. package/src/lifecycle_events.py +9 -9
  22. package/src/local_context/api.py +67 -5
  23. package/src/local_context/usage_events.py +24 -0
  24. package/src/memory_fabric.py +536 -0
  25. package/src/memory_observation_processor.py +28 -0
  26. package/src/memory_retrieval.py +5 -5
  27. package/src/operator_language.py +2 -0
  28. package/src/plugins/backup.py +1 -1
  29. package/src/plugins/cortex.py +21 -21
  30. package/src/plugins/episodic_memory.py +11 -11
  31. package/src/plugins/goal_engine.py +3 -3
  32. package/src/plugins/personal_scripts.py +75 -0
  33. package/src/plugins/protocol.py +10 -1
  34. package/src/pre_answer_router.py +120 -3
  35. package/src/r_catalog.py +4 -5
  36. package/src/saved_not_used_audit.py +31 -31
  37. package/src/script_registry.py +444 -1
  38. package/src/scripts/deep-sleep/apply_findings.py +79 -17
  39. package/src/scripts/nexo-backup.sh +30 -0
  40. package/src/scripts/nexo-daily-self-audit.py +46 -13
  41. package/src/scripts/nexo-email-migrate-config.py +2 -2
  42. package/src/scripts/nexo-email-monitor.py +19 -19
  43. package/src/scripts/nexo-followup-hygiene.py +40 -8
  44. package/src/scripts/nexo-followup-runner.py +31 -31
  45. package/src/scripts/nexo-inbox-hook.sh +1 -1
  46. package/src/scripts/nexo-learning-validator.py +24 -3
  47. package/src/scripts/nexo-memory-fabric.py +45 -0
  48. package/src/server.py +73 -1
  49. package/src/system_catalog.py +31 -31
  50. package/src/tools_learnings.py +96 -65
  51. package/src/tools_memory_v2.py +2 -2
  52. package/src/tools_sessions.py +25 -7
  53. package/src/tools_transcripts.py +50 -8
  54. package/src/transcript_index.py +105 -2
  55. package/src/transcript_utils.py +65 -13
  56. package/templates/core-prompts/postmortem-consolidator.md +3 -3
  57. package/templates/core-prompts/r17-promise-debt-injection.md +1 -1
  58. package/templates/core-prompts/server-mcp-instructions.md +6 -6
  59. package/tool-enforcement-map.json +143 -13
@@ -1 +1 @@
1
- R17 promise-debt: your last message promised a future action but no tool call matching that promise happened in the next two turns. If the action is still pending, execute it NOW — promise without execution opens operational debt (learning #38 / #29 Fase A R29). If the promise was a misstatement, correct it explicitly in the next message. Do not produce visible text for this reminder — act on it. After handling the silent action, continue with your previous task; this reminder is silent context, not a new instruction.
1
+ R17 promise-debt: your last message promised a future action but no tool call matching that promise happened in the next two turns. If the action is still pending, execute it NOW — promise without execution opens operational debt (learning #38 / #29 Phase A R29). If the promise was a misstatement, correct it explicitly in the next message. Do not produce visible text for this reminder — act on it. After handling the silent action, continue with your previous task; this reminder is silent context, not a new instruction.
@@ -29,14 +29,14 @@
29
29
  - **Dissonance:** user contradicts memory→`nexo_cognitive_dissonance`. Frustrated→force=True
30
30
  - **Trust:** <40=paranoid verify twice, >80=fluid. Check: `nexo_cognitive_trust`
31
31
 
32
- ## Guardian Rules (Fase 2 Capa 3 — R26–R33)
32
+ ## Guardian Rules (Phase 2 Layer 3 — R26–R33)
33
33
  - **R26 no jargon:** Never use NEXO internal jargon (protocol debt, cortex evaluation, guard_check, heartbeat, runtime check, shadow/soft/hard) when talking to the user. Translate to plain operational language. First answer to the operator on any thread leads with the recommendation or status, not the diagnostic.
34
34
  - **R26b silent enforcement:** Never tell the user that Guardian / Protocol Enforcer / a system reminder forced you to do something. Apply the required action silently. When a reminder says "Do not produce visible text", that silence applies to the entire reminder turn: no prose before the tool call, no prose after it, and if there is no fresh operator message then the visible output must stay empty.
35
35
  - **R27 2–3 sentences:** Keep each decision point to 2–3 short sentences. Details only if asked. Prefer conclusion + next action over option dumps or raw diagnostics.
36
- - **R28 correction → learning:** If the user corrects you, BEFORE you answer the next question run `nexo_learning_add` with the new rule. Do not batch. This is the Fase 2 Capa 3 reinforcement of the Capa 2 auto_capture hook and the Capa 1 server-side dedup.
37
- - **R29 promise = execute:** If you write 'I will now ...' / 'implementing ...' / 'enviando ...' in chat or email, you execute the action in the same turn. Promise without execution opens a `promise_debt`. See also R17 (post-user-message classifier).
38
- - **R30 pre-done evidence:** Before saying done/listo/fixed/completado, verify with concrete evidence (test output, curl, screenshot, DB row). Then close with `nexo_task_close` attaching the evidence. R30 cannot be disabled; operators may only adjust its mode to shadow / soft / hard in `~/.nexo/config/guardian.json`.
36
+ - **R28 correction → learning:** If the user corrects you, BEFORE you answer the next question run `nexo_learning_add` with the new rule. Do not batch. This is the Phase 2 Layer 3 reinforcement of the Layer 2 auto_capture hook and the Layer 1 server-side dedup.
37
+ - **R29 promise = execute:** If you write 'I will now ...' / 'implementing ...' / 'sending ...' in chat or email, you execute the action in the same turn. Promise without execution opens a `promise_debt`. See also R17 (post-user-message classifier).
38
+ - **R30 pre-done evidence:** Before saying done/fixed/completed/sent, verify with concrete evidence (test output, curl, screenshot, DB row). Then close with `nexo_task_close` attaching the evidence. R30 cannot be disabled; operators may only adjust its mode to shadow / soft / hard in `~/.nexo/config/guardian.json`.
39
39
  - **R31 no assumptions:** Any claim about server, DNS, route, port or IP is verified with `dig` / `nexo_system_catalog` / project-atlas BEFORE it is stated. Rule #156 in blocking learnings — past confabulations had real cost.
40
- - **R32 Nora/María read-only:** Their infrastructure is observed, never written. Only act on Nora/María resources with explicit permission in the current user message. See learnings #283, #336, #358; the Capa 2 engine enforces this with R25.
40
+ - **R32 Nora/María read-only:** Their infrastructure is observed, never written. Only act on Nora/María resources with explicit permission in the current user message. See learnings #283, #336, #358; the Layer 2 engine enforces this with R25.
41
41
  - **R33 procedure lookup:** To discover available tools, reusable skills, or the canonical location of an artifact, use `nexo_system_catalog` / `nexo_tool_explain` / `nexo_skill_match` — do not assume tool names from memory. If a skill already covers the flow, use it instead of improvising.
42
- - **R34 identity coherence:** NEXO is a single identity shared across terminals. When there are 2+ active sessions, THEY ARE ALL YOU. Before denying an action ("I haven't done that" / "yo no" / "I didn't"), first consult `nexo_recent_context` / `nexo_session_diary_read` / `nexo_change_log`. Another terminal may have acted. Anti-example: saying "no he enviado ese email" without checking `nexo_change_log` when a sibling session already sent it.
42
+ - **R34 identity coherence:** NEXO is a single identity shared across terminals. When there are 2+ active sessions, THEY ARE ALL YOU. Before denying an action ("I haven't done that" / "I didn't do that" / "I didn't"), first consult `nexo_recent_context` / `nexo_session_diary_read` / `nexo_change_log`. Another terminal may have acted. Anti-example: saying "I did not send that email" without checking `nexo_change_log` when a sibling session already sent it.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://nexo-brain.com/schemas/tool-enforcement-map-v2.1.json",
3
3
  "version": "2.2.0",
4
- "description": "Canonical map of all NEXO Brain MCP tools with enforcement rules, dependency chains, and behavioral hints. Source of truth for Protocol Enforcer (Desktop + headless). v2.1 adds schema support for Fase 2 event-driven rules (R01-R33): server_side_rules at tool level, per-rule mode (shadow|soft|hard), core_rule flag, and new rule types (pre_tool_intent, post_user_message, on_output_classify, before_tool_strict_block). Backward-compatible: executors that only handle v2.0 rule types ignore the new fields.",
4
+ "description": "Canonical map of all NEXO Brain MCP tools with enforcement rules, dependency chains, and behavioral hints. Source of truth for Protocol Enforcer (Desktop + headless). v2.1 adds schema support for Phase 2 event-driven rules (R01-R33): server_side_rules at tool level, per-rule mode (shadow|soft|hard), core_rule flag, and new rule types (pre_tool_intent, post_user_message, on_output_classify, before_tool_strict_block). Backward-compatible: executors that only handle v2.0 rule types ignore the new fields.",
5
5
  "tools": {
6
6
  "nexo_adaptive_decay": {
7
7
  "description": "Trigger inter-session tension decay",
@@ -94,6 +94,45 @@
94
94
  },
95
95
  "triggers_after": []
96
96
  },
97
+ "nexo_agent_archive": {
98
+ "description": "Archive or restore a personal-script-backed agent",
99
+ "category": "agent",
100
+ "source": "plugin:personal_scripts",
101
+ "requires": [],
102
+ "provides": [],
103
+ "internal_calls": [],
104
+ "enforcement": {
105
+ "level": "none",
106
+ "rules": []
107
+ },
108
+ "triggers_after": []
109
+ },
110
+ "nexo_agent_disable": {
111
+ "description": "Disable a personal-script-backed agent",
112
+ "category": "agent",
113
+ "source": "plugin:personal_scripts",
114
+ "requires": [],
115
+ "provides": [],
116
+ "internal_calls": [],
117
+ "enforcement": {
118
+ "level": "none",
119
+ "rules": []
120
+ },
121
+ "triggers_after": []
122
+ },
123
+ "nexo_agent_enable": {
124
+ "description": "Enable a personal-script-backed agent",
125
+ "category": "agent",
126
+ "source": "plugin:personal_scripts",
127
+ "requires": [],
128
+ "provides": [],
129
+ "internal_calls": [],
130
+ "enforcement": {
131
+ "level": "none",
132
+ "rules": []
133
+ },
134
+ "triggers_after": []
135
+ },
97
136
  "nexo_agent_delete": {
98
137
  "description": "Remove agent from registry",
99
138
  "category": "agent",
@@ -133,6 +172,45 @@
133
172
  },
134
173
  "triggers_after": []
135
174
  },
175
+ "nexo_agent_schedule": {
176
+ "description": "Set or clear cadence for a personal-script-backed agent",
177
+ "category": "agent",
178
+ "source": "plugin:personal_scripts",
179
+ "requires": [],
180
+ "provides": [],
181
+ "internal_calls": [],
182
+ "enforcement": {
183
+ "level": "none",
184
+ "rules": []
185
+ },
186
+ "triggers_after": []
187
+ },
188
+ "nexo_agent_status": {
189
+ "description": "Read composed runtime status for one personal-script-backed agent",
190
+ "category": "agent",
191
+ "source": "plugin:personal_scripts",
192
+ "requires": [],
193
+ "provides": [],
194
+ "internal_calls": [],
195
+ "enforcement": {
196
+ "level": "none",
197
+ "rules": []
198
+ },
199
+ "triggers_after": []
200
+ },
201
+ "nexo_agents_list": {
202
+ "description": "List personal scripts marked as NEXO agents",
203
+ "category": "agent",
204
+ "source": "plugin:personal_scripts",
205
+ "requires": [],
206
+ "provides": [],
207
+ "internal_calls": [],
208
+ "enforcement": {
209
+ "level": "none",
210
+ "rules": []
211
+ },
212
+ "triggers_after": []
213
+ },
136
214
  "nexo_agent_update": {
137
215
  "description": "Update agent fields",
138
216
  "category": "agent",
@@ -1137,6 +1215,19 @@
1137
1215
  },
1138
1216
  "triggers_after": []
1139
1217
  },
1218
+ "nexo_cognitive_control_observatory": {
1219
+ "description": "Read-only cognitive quality metrics",
1220
+ "category": "cognitive",
1221
+ "source": "server",
1222
+ "requires": [],
1223
+ "provides": [],
1224
+ "internal_calls": [],
1225
+ "enforcement": {
1226
+ "level": "none",
1227
+ "rules": []
1228
+ },
1229
+ "triggers_after": []
1230
+ },
1140
1231
  "nexo_cortex_check": {
1141
1232
  "description": "Cognitive pre-action check",
1142
1233
  "category": "cortex",
@@ -1668,6 +1759,19 @@
1668
1759
  },
1669
1760
  "triggers_after": []
1670
1761
  },
1762
+ "nexo_followup_lifecycle": {
1763
+ "description": "Return followups grouped by lifecycle lane",
1764
+ "category": "followups",
1765
+ "source": "server",
1766
+ "requires": [],
1767
+ "provides": [],
1768
+ "internal_calls": [],
1769
+ "enforcement": {
1770
+ "level": "none",
1771
+ "rules": []
1772
+ },
1773
+ "triggers_after": []
1774
+ },
1671
1775
  "nexo_followup_note": {
1672
1776
  "description": "Append note to followup",
1673
1777
  "category": "followups",
@@ -2170,6 +2274,19 @@
2170
2274
  },
2171
2275
  "triggers_after": []
2172
2276
  },
2277
+ "nexo_learning_resolve_candidate": {
2278
+ "description": "Dry-run canonical learning resolver",
2279
+ "category": "learning",
2280
+ "source": "server",
2281
+ "requires": [],
2282
+ "provides": [],
2283
+ "internal_calls": [],
2284
+ "enforcement": {
2285
+ "level": "none",
2286
+ "rules": []
2287
+ },
2288
+ "triggers_after": []
2289
+ },
2173
2290
  "nexo_learning_search": {
2174
2291
  "description": "Search learnings by keyword in title and content",
2175
2292
  "category": "learning",
@@ -2527,6 +2644,19 @@
2527
2644
  },
2528
2645
  "triggers_after": []
2529
2646
  },
2647
+ "nexo_intraday_memory_cycle": {
2648
+ "description": "Run a low-limit evidence-backed intraday memory cycle",
2649
+ "category": "memory",
2650
+ "source": "server",
2651
+ "requires": [],
2652
+ "provides": [],
2653
+ "internal_calls": [],
2654
+ "enforcement": {
2655
+ "level": "none",
2656
+ "rules": []
2657
+ },
2658
+ "triggers_after": []
2659
+ },
2530
2660
  "nexo_memory_answer": {
2531
2661
  "description": "Answer memory questions only when Memory Observations evidence exists",
2532
2662
  "category": "memory",
@@ -4378,19 +4508,19 @@
4378
4508
  }
4379
4509
  },
4380
4510
  "enforcement_levels": {
4381
- "must": "OBLIGACIÓNel enforcer FUERZA la llamada inyectando un prompt invisible",
4382
- "should": "AVISOel enforcer inyecta un recordatorio suave, el modelo puede ignorarlo",
4383
- "none": "Sin enforcement — tool bajo demanda del modelo/usuario"
4511
+ "must": "MANDATORYthe enforcer FORCES the call by injecting an invisible prompt",
4512
+ "should": "WARNINGthe enforcer injects a soft reminder; the model may ignore it",
4513
+ "none": "No enforcement — tool is called on model or user demand"
4384
4514
  },
4385
4515
  "rule_types": {
4386
- "on_session_start": "Al inicio de sesión (primeros N mensajes del usuario)",
4387
- "on_session_end": "Al cerrar sesión/chat/app",
4388
- "periodic_by_messages": "Cada N mensajes del usuario sin que se haya llamado",
4389
- "periodic_by_time": "Cada N minutos de sesión activa sin que se haya llamado",
4390
- "after_tool": "Inmediatamente después de que se llame a una tool en watch_tools",
4391
- "before_tool": "Antes de que se use una tool en watch_tools",
4392
- "on_event": "Cuando se detecta un evento específico",
4393
- "conditional": "Solo si se cumple una condición evaluada dinámicamente"
4516
+ "on_session_start": "At session start (first N user messages)",
4517
+ "on_session_end": "When closing the session, chat, or app",
4518
+ "periodic_by_messages": "Every N user messages without the tool being called",
4519
+ "periodic_by_time": "Every N minutes of active session time without the tool being called",
4520
+ "after_tool": "Immediately after a tool in watch_tools is called",
4521
+ "before_tool": "Before a tool in watch_tools is used",
4522
+ "on_event": "When a specific event is detected",
4523
+ "conditional": "Only when a dynamically evaluated condition is met"
4394
4524
  },
4395
4525
  "fase2_schema": {
4396
4526
  "guardian_config_version": "1.0.0",
@@ -4432,6 +4562,6 @@
4432
4562
  "action": "one of: warn, reject, merge, bypass_with_force",
4433
4563
  "force_key": "string — client must pass this key=true to bypass a warning"
4434
4564
  },
4435
- "notes": "Fase 2 rules are added incrementally via Fases A–D. Fase 0 only bumps the schema version and documents the supported extensions. Adding a new rule type REQUIRES simultaneous support in enforcement-engine.js AND enforcement_engine.py (parity rule, see docs/client-parity-checklist.md)."
4565
+ "notes": "Phase 2 rules are added incrementally via Phases A–D. Phase 0 only bumps the schema version and documents the supported extensions. Adding a new rule type REQUIRES simultaneous support in enforcement-engine.js AND enforcement_engine.py (parity rule, see docs/client-parity-checklist.md)."
4436
4566
  }
4437
4567
  }