nexo-brain 2.6.21 → 3.0.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 (49) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/README.md +72 -20
  3. package/hooks/hooks.json +79 -0
  4. package/package.json +1 -1
  5. package/src/agent_runner.py +296 -8
  6. package/src/cli.py +209 -4
  7. package/src/client_preferences.py +115 -0
  8. package/src/client_sync.py +202 -2
  9. package/src/cognitive/__init__.py +1 -1
  10. package/src/cognitive/_search.py +39 -19
  11. package/src/dashboard/app.py +264 -0
  12. package/src/dashboard/templates/base.html +4 -0
  13. package/src/dashboard/templates/dashboard.html +59 -1
  14. package/src/dashboard/templates/protocol.html +199 -0
  15. package/src/db/__init__.py +23 -1
  16. package/src/db/_learnings.py +31 -4
  17. package/src/db/_personal_scripts.py +12 -0
  18. package/src/db/_protocol.py +303 -0
  19. package/src/db/_schema.py +248 -0
  20. package/src/db/_watchers.py +173 -0
  21. package/src/db/_workflow.py +952 -0
  22. package/src/doctor/providers/runtime.py +1095 -3
  23. package/src/evolution_cycle.py +62 -0
  24. package/src/hook_guardrails.py +308 -0
  25. package/src/hooks/protocol-guardrail.sh +10 -0
  26. package/src/nexo_sdk.py +103 -0
  27. package/src/plugins/cognitive_memory.py +18 -0
  28. package/src/plugins/cortex.py +55 -35
  29. package/src/plugins/guard.py +132 -16
  30. package/src/plugins/protocol.py +911 -0
  31. package/src/plugins/schedule.py +40 -6
  32. package/src/plugins/simple_api.py +103 -0
  33. package/src/plugins/skills.py +67 -0
  34. package/src/plugins/state_watchers.py +79 -0
  35. package/src/plugins/workflow.py +588 -0
  36. package/src/public_contribution.py +86 -12
  37. package/src/script_registry.py +142 -0
  38. package/src/scripts/deep-sleep/apply_findings.py +482 -2
  39. package/src/scripts/deep-sleep/collect.py +49 -4
  40. package/src/scripts/nexo-agent-run.py +2 -0
  41. package/src/scripts/nexo-daily-self-audit.py +843 -5
  42. package/src/scripts/nexo-evolution-run.py +343 -1
  43. package/src/server.py +92 -6
  44. package/src/skills_runtime.py +151 -0
  45. package/src/state_watchers_runtime.py +334 -0
  46. package/src/tools_learnings.py +345 -7
  47. package/src/tools_sessions.py +183 -0
  48. package/templates/CLAUDE.md.template +9 -1
  49. package/templates/CODEX.AGENTS.md.template +10 -2
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nexo-brain",
3
- "version": "2.6.21",
3
+ "version": "3.0.0",
4
4
  "description": "Local cognitive runtime for Claude Code \u2014 persistent memory, overnight learning, doctor diagnostics, personal scripts, recovery-aware jobs, startup preflight, and optional dashboard/power helper.",
5
5
  "author": {
6
6
  "name": "NEXO Brain",
package/README.md CHANGED
@@ -6,7 +6,7 @@
6
6
  [![GitHub stars](https://img.shields.io/github/stars/wazionapps/nexo?style=social)](https://github.com/wazionapps/nexo/stargazers)
7
7
  [![License: AGPL-3.0](https://img.shields.io/badge/License-AGPL--3.0-blue.svg)](https://www.gnu.org/licenses/agpl-3.0)
8
8
 
9
- > Local cognitive runtime with a shared brain across Claude Code, Codex, Claude Desktop, and other MCP clients. Persistent memory, selectable terminal and automation backends, overnight learning, self-healing background jobs, startup preflight, and doctor diagnostics. 150+ MCP tools. Benchmarked on LoCoMo (F1 0.588, +55% vs GPT-4).
9
+ > Local cognitive runtime with a shared brain across Claude Code, Codex, Claude Desktop, and other MCP clients. Persistent memory, durable workflow runs, selectable terminal and automation backends, overnight learning, self-healing background jobs, startup preflight, and doctor diagnostics. 150+ MCP tools. Benchmarked on LoCoMo (F1 0.588, +55% vs GPT-4).
10
10
 
11
11
  **NEXO Brain transforms any MCP-compatible AI agent from a stateless assistant into a cognitive partner that remembers, learns, forgets, adapts, and builds a relationship with you over time.**
12
12
 
@@ -18,6 +18,16 @@
18
18
 
19
19
  [Watch the overview on YouTube](https://www.youtube.com/watch?v=IBs7zh7ZMG0) · [Watch the full deep-dive](https://www.youtube.com/watch?v=bKAfowyyy5M)
20
20
 
21
+ Start here:
22
+ - [5-minute quickstart](docs/quickstart-5-minutes.md)
23
+ - [Architecture visuals](docs/architecture-visuals.md)
24
+ - [Memory classes](docs/memory-classes.md)
25
+ - [Session portability](docs/session-portability.md)
26
+ - [Python SDK](docs/sdk-python.md)
27
+ - [Reference verticals](docs/reference-verticals.md)
28
+ - [Measured compare scorecard](compare/README.md)
29
+ - [Public contribution guide](docs/public-contribution.md)
30
+
21
31
  Every time you close a session, everything is lost. Your agent doesn't remember yesterday's decisions, repeats the same mistakes, and starts from zero. NEXO Brain fixes this with a cognitive architecture modeled after how human memory actually works.
22
32
 
23
33
  ## Shared Brain Across Clients
@@ -38,18 +48,32 @@ That means NEXO now manages not only the shared runtime and MCP wiring, but also
38
48
  - For Codex specifically, `nexo chat` and Codex headless automation inject the current bootstrap explicitly, so Codex starts as NEXO even when plain global Codex startup is inconsistent about global instructions.
39
49
  - Deep Sleep now reads both Claude Code and Codex transcript stores, so overnight analysis still works even when the user spends the day in Codex.
40
50
 
41
- Version `2.6.14` closes those parity gaps in practice, `2.6.15` hardens the installed-runtime migration path so existing users actually receive the managed bootstrap updates cleanly, `2.6.16` pushes the system further in three directions, `2.6.17` finishes the annoying last-mile migration bugs for real existing installs, `2.6.18` tightens the remaining practical gaps around manual Codex use, Deep Sleep horizon artifacts, and retrieval honesty, `2.6.20` makes the recommended Claude profile explicit across installer, runtime defaults, existing installs, and the update path itself with `Opus 4.6 with 1M context`, and `2.6.21` upgrades Deep Sleep from passive nightly analysis toward concrete engineering action.
42
-
43
- - Codex now gets managed global bootstrap/model sync in `~/.codex/config.toml`, so sessions opened outside `nexo chat` are much less likely to start as plain Codex.
44
- - Codex config now also persists a managed `mcp_servers.nexo` entry, so the shared brain survives even if ad-hoc Codex MCP state drifts.
45
- - Runtime doctor now audits recent Codex sessions for real startup discipline and verifies Claude Desktop shared-brain metadata explicitly instead of treating both as invisible best-effort wiring.
46
- - Retrieval is smarter by default: HyDE and spreading activation now auto-enable when the query shape benefits, while exact lookups remain conservative.
47
- - Retrieval explanations now surface confidence and the auto-strategy that fired, while associative expansion trims itself back to `top_k` instead of leaking low-signal neighbors.
48
- - Deep Sleep now blends recent context with older context over a 60-day horizon, and memory decay now tracks per-memory `stability` and `difficulty` instead of relying only on global decay constants.
49
- - Deep Sleep now also carries project-priority weighting into its long-horizon context and writes reusable weekly/monthly summary artifacts instead of reasoning only day by day.
50
- - Deep Sleep now semantically deduplicates followups, consolidates overlapping learnings, flags contradictory learnings for review, and backfills explicit engineering followups when recurring patterns imply a concrete fix.
51
- - Existing installs that already had NEXO connected to Codex now backfill that client state automatically during update/sync, so the managed Codex bootstrap actually lands without manual cleanup.
52
- - Bootstrap docs now fall back to the operator name `NEXO` when local metadata is blank, avoiding broken headings in `CLAUDE.md` and `AGENTS.md`.
51
+ Versions `2.6.14` through `2.7.0` established the practical shared-brain baseline: managed Claude/Codex bootstrap, Codex config sync, transcript-aware Deep Sleep, 60-day long-horizon analysis, weekly/monthly summary artifacts, retrieval auto-mode, and the first measured engineering loop.
52
+
53
+ Version `3.0.0` closes the next execution gap:
54
+
55
+ - protocol discipline is now a runtime contract, not just instructions:
56
+ - `nexo_task_open`
57
+ - `nexo_task_close`
58
+ - persistent `protocol_debt`
59
+ - enforceable `Cortex` gates
60
+ - durable execution is now first-class:
61
+ - resumable workflow runs
62
+ - checkpoints
63
+ - replay
64
+ - retries
65
+ - durable goals
66
+ - conditioned learnings on critical files are now real guardrails across Claude hooks, Codex transcript audits, and headless automation prompts
67
+ - repair/correction work now routes through canonical learning capture instead of depending on the model to remember to document after the fact
68
+ - runtime truth is stricter:
69
+ - no more healthy-looking warning storms
70
+ - no more silent Deep Sleep schema drift
71
+ - keep-alive jobs report alive/degraded/duplicated honestly
72
+ - public proof is stronger:
73
+ - measured compare scorecard
74
+ - external and internal ablations
75
+ - `cost_per_solved_task`
76
+ - SDK/API/quickstart surface
53
77
 
54
78
  ### Client Capability Matrix
55
79
 
@@ -230,6 +254,20 @@ User message → Fast Path check → Simple chat? → Respond directly
230
254
 
231
255
  The Cortex was designed through a 3-way AI debate (Claude Opus 4.6 + GPT-5.4 + Gemini 3.1 Pro) and validated against 6 months of real production failures.
232
256
 
257
+ ## Durable Workflow Runtime
258
+
259
+ Memory and guardrails are not enough if long work still restarts from zero.
260
+
261
+ NEXO now ships a durable workflow runtime for multi-step and cross-session execution:
262
+
263
+ - `nexo_workflow_open` creates a persistent run with step metadata, idempotency key, priority, and shared state
264
+ - `nexo_workflow_update` records replayable checkpoints, retry metadata, approval gates, and the current actionable state
265
+ - `nexo_workflow_resume` tells the agent what to do next without guessing
266
+ - `nexo_workflow_replay` reconstructs the recent execution history honestly instead of pretending the run is still in memory
267
+ - `nexo_workflow_list` keeps active and blocked work visible so it does not disappear into reminders or prose notes
268
+
269
+ This is the bridge between "good memory" and "reliable execution": tasks can now preserve state, retries, approval gates, and next action across interruptions.
270
+
233
271
  ## Context Continuity (Auto-Compaction)
234
272
 
235
273
  NEXO Brain automatically preserves session context when Claude Code compacts conversations. Using PreCompact and PostCompact hooks:
@@ -523,7 +561,7 @@ npx nexo-brain # detects current version, migrates automatically
523
561
 
524
562
  NEXO Brain includes a local CLI that runs independently of any single terminal client:
525
563
 
526
- - `nexo chat` — launch the configured terminal client with NEXO as the operator
564
+ - `nexo chat` — launch a NEXO terminal client; if both Claude Code and Codex are available, it asks every time which one to open and puts the last-used client first
527
565
  - `nexo update` — sync runtime from source, run migrations, reconcile schedules
528
566
  - `nexo doctor --tier runtime` — boot/runtime/deep diagnostics with `--fix` mode
529
567
  - `nexo scripts list` — list all personal scripts and their status
@@ -636,20 +674,33 @@ The installer handles everything and syncs the same `nexo` MCP brain into Claude
636
674
  After install, use the runtime CLI:
637
675
 
638
676
  ```bash
639
- nexo chat # Launch the configured terminal client (Claude Code or Codex)
677
+ nexo chat # Launch a NEXO terminal client (asks if both Claude Code and Codex are available)
640
678
  nexo doctor # Check runtime health
641
679
  nexo update # Pull latest version and sync
642
680
  nexo clients sync # Re-sync Claude Code/Desktop/Codex to the same brain
643
681
  nexo scripts list # See your personal scripts
644
682
  ```
645
683
 
646
- During install, NEXO now asks which interactive clients you want to connect, which one `nexo chat` should open by default, whether to enable background automation, which backend should run that automation, and which model profile each active terminal/backend should use. Shared brain stays on in every mode.
684
+ During install, NEXO now asks which interactive clients you want to connect, which one `nexo chat` should suggest first when multiple terminal clients are available, whether to enable background automation, which backend should run that automation, and which model profile each active terminal/backend should use. Shared brain stays on in every mode.
685
+
686
+ Public entry points for the mental model now stay intentionally small:
687
+ - `nexo_remember`
688
+ - `nexo_memory_recall`
689
+ - `nexo_consolidate`
690
+ - `nexo_run_workflow`
691
+
692
+ If you want the shell or Python wrappers instead of raw MCP tools:
693
+ - [docs/quickstart-5-minutes.md](docs/quickstart-5-minutes.md)
694
+ - [docs/memory-classes.md](docs/memory-classes.md)
695
+ - [docs/sdk-python.md](docs/sdk-python.md)
696
+ - [docs/reference-verticals.md](docs/reference-verticals.md)
697
+ - [compare/README.md](compare/README.md)
647
698
 
648
699
  Recommended defaults:
649
700
  - Claude Code: `Opus 4.6 with 1M context`
650
701
  - Codex: `gpt-5.4` with `xhigh` reasoning
651
702
 
652
- Or use the shell alias created during install (e.g. `atlas`), which now runs `nexo chat .` so it opens whichever terminal client you selected as default.
703
+ Or use the shell alias created during install (e.g. `atlas`), which now runs `nexo chat .` so it opens the terminal client you pick for that session, with the last-used option shown first.
653
704
 
654
705
  Your operator will greet you immediately — adapted to the time of day, resuming from where you left off. No cold starts.
655
706
 
@@ -665,6 +716,7 @@ The project still recommends Claude Code as the primary path, but contributions
665
716
 
666
717
  Maintainers and contributors touching startup, bootstrap, Deep Sleep, or shared-brain behavior should also use the client parity checklist:
667
718
  - [docs/client-parity-checklist.md](docs/client-parity-checklist.md)
719
+ - `python3 scripts/verify_release_readiness.py`
668
720
 
669
721
  ### What Gets Installed
670
722
 
@@ -716,7 +768,7 @@ nexo doctor --tier runtime --json # Machine-readable health report
716
768
  nexo doctor --fix # Apply deterministic repairs
717
769
  ```
718
770
 
719
- Personal scripts live in `NEXO_HOME/scripts/` with inline metadata. Their Python templates now include `run_automation_text(...)`, which routes work through the configured NEXO automation backend instead of hardcoding `claude -p` or provider-specific model names. See `docs/writing-scripts.md` for details.
771
+ Personal scripts live in `NEXO_HOME/scripts/` with inline metadata. Their Python templates now include `run_automation_text(...)`, which routes work through the configured NEXO automation backend instead of hardcoding `claude -p` or provider-specific model names. `nexo-agent-run.py` now also supports task profiles (`fast`, `balanced`, `deep`) plus safe backend fallback, so automations can prefer cheaper/faster Codex paths or deeper Claude paths without hardcoding one provider forever. See `docs/writing-scripts.md` for details.
720
772
 
721
773
  Skills v2 combine procedural guides with optional executable scripts. Personal skills live in `NEXO_HOME/skills/`, packaged core skills live in `NEXO_CODE/skills/` during development and `NEXO_HOME/skills-core/` in installed environments, and staged runtime copies live in `NEXO_HOME/skills-runtime/`. Execution is fully autonomous: Deep Sleep can evolve mature guide skills into executable drafts automatically, and runtime execution no longer waits for manual approval. See `docs/skills-v2.md` for the full model.
722
774
 
@@ -842,7 +894,7 @@ When Claude Desktop is installed, `nexo-brain`, `nexo update`, and `nexo clients
842
894
 
843
895
  ### Codex
844
896
 
845
- When Codex CLI is available, `nexo-brain`, `nexo update`, and `nexo clients sync` register the same `nexo` MCP server via `codex mcp add`, so Codex uses the same local memory store as Claude Code and Claude Desktop. If selected during install, `nexo chat` can open Codex directly and background automation can also run through Codex. The current recommended Codex profile is `gpt-5.4` with `xhigh` reasoning.
897
+ When Codex CLI is available, `nexo-brain`, `nexo update`, and `nexo clients sync` register the same `nexo` MCP server via `codex mcp add`, so Codex uses the same local memory store as Claude Code and Claude Desktop. If selected during install, `nexo chat` can open Codex directly and background automation can also run through Codex. Interactive `nexo chat` launches use Codex's aggressive no-confirmation mode so the session does not stall on repetitive approval prompts. The current recommended Codex profile is `gpt-5.4` with `xhigh` reasoning. Runtime Doctor also audits recent Codex sessions for NEXO startup markers and conditioned-file protocol discipline so parity drift does not hide behind the lack of native Claude-style hooks.
846
898
 
847
899
  ### OpenClaw
848
900
 
@@ -956,7 +1008,7 @@ If NEXO Brain is useful to you, consider:
956
1008
  - **Personal scripts registry**: Scripts in `NEXO_HOME/scripts/` tracked in SQLite with metadata, categories, schedules. Full lifecycle: create, sync, reconcile, schedule, unschedule, remove.
957
1009
  - **Orchestrator removed from core** (breaking): Was opt-in personal automation adding complexity for all users. Existing users keep their setup in `NEXO_HOME/scripts/`.
958
1010
  - **Claude Code plugin structure**: `plugin.json`, entry point, packaging for marketplace submission.
959
- - **`nexo chat`**: Official command to launch the configured terminal client with NEXO as operator.
1011
+ - **`nexo chat`**: Official command to launch a NEXO terminal client, asking when multiple supported terminal clients are available.
960
1012
  - **Managed Evolution hardening**: Can modify core behavior modules with rollback followups.
961
1013
  - Cron recovery hardened: TCC diagnostics, keepalive sync, personal schedule catchup.
962
1014
 
package/hooks/hooks.json CHANGED
@@ -2,10 +2,89 @@
2
2
  "hooks": {
3
3
  "SessionStart": [
4
4
  {
5
+ "matcher": "*",
5
6
  "hooks": [
6
7
  {
7
8
  "type": "command",
8
9
  "command": "diff -q \"${CLAUDE_PLUGIN_ROOT}/src/requirements.txt\" \"${CLAUDE_PLUGIN_DATA}/requirements.txt\" >/dev/null 2>&1 || (python3 -m venv \"${CLAUDE_PLUGIN_DATA}/.venv\" 2>/dev/null; cp \"${CLAUDE_PLUGIN_ROOT}/src/requirements.txt\" \"${CLAUDE_PLUGIN_DATA}/requirements.txt\"; \"${CLAUDE_PLUGIN_DATA}/.venv/bin/pip\" install --quiet -r \"${CLAUDE_PLUGIN_DATA}/requirements.txt\") || rm -f \"${CLAUDE_PLUGIN_DATA}/requirements.txt\""
10
+ },
11
+ {
12
+ "type": "command",
13
+ "command": "mkdir -p \"${CLAUDE_PLUGIN_DATA}/operations\" && date +%s > \"${CLAUDE_PLUGIN_DATA}/operations/.session-start-ts\"",
14
+ "timeout": 2
15
+ },
16
+ {
17
+ "type": "command",
18
+ "command": "NEXO_HOME=\"${CLAUDE_PLUGIN_DATA}\" NEXO_CODE=\"${CLAUDE_PLUGIN_ROOT}/src\" bash \"${CLAUDE_PLUGIN_ROOT}/src/hooks/daily-briefing-check.sh\"",
19
+ "timeout": 5
20
+ },
21
+ {
22
+ "type": "command",
23
+ "command": "NEXO_HOME=\"${CLAUDE_PLUGIN_DATA}\" NEXO_CODE=\"${CLAUDE_PLUGIN_ROOT}/src\" bash \"${CLAUDE_PLUGIN_ROOT}/src/hooks/session-start.sh\"",
24
+ "timeout": 35
25
+ }
26
+ ]
27
+ }
28
+ ],
29
+ "Stop": [
30
+ {
31
+ "matcher": "*",
32
+ "hooks": [
33
+ {
34
+ "type": "command",
35
+ "command": "NEXO_HOME=\"${CLAUDE_PLUGIN_DATA}\" NEXO_CODE=\"${CLAUDE_PLUGIN_ROOT}/src\" bash \"${CLAUDE_PLUGIN_ROOT}/src/hooks/session-stop.sh\"",
36
+ "timeout": 10
37
+ }
38
+ ]
39
+ }
40
+ ],
41
+ "PostToolUse": [
42
+ {
43
+ "matcher": "*",
44
+ "hooks": [
45
+ {
46
+ "type": "command",
47
+ "command": "NEXO_HOME=\"${CLAUDE_PLUGIN_DATA}\" NEXO_CODE=\"${CLAUDE_PLUGIN_ROOT}/src\" bash \"${CLAUDE_PLUGIN_ROOT}/src/hooks/capture-tool-logs.sh\"",
48
+ "timeout": 5
49
+ },
50
+ {
51
+ "type": "command",
52
+ "command": "NEXO_HOME=\"${CLAUDE_PLUGIN_DATA}\" NEXO_CODE=\"${CLAUDE_PLUGIN_ROOT}/src\" bash \"${CLAUDE_PLUGIN_ROOT}/src/hooks/capture-session.sh\"",
53
+ "timeout": 3
54
+ },
55
+ {
56
+ "type": "command",
57
+ "command": "NEXO_HOME=\"${CLAUDE_PLUGIN_DATA}\" NEXO_CODE=\"${CLAUDE_PLUGIN_ROOT}/src\" bash \"${CLAUDE_PLUGIN_ROOT}/src/hooks/inbox-hook.sh\"",
58
+ "timeout": 5
59
+ },
60
+ {
61
+ "type": "command",
62
+ "command": "NEXO_HOME=\"${CLAUDE_PLUGIN_DATA}\" NEXO_CODE=\"${CLAUDE_PLUGIN_ROOT}/src\" bash \"${CLAUDE_PLUGIN_ROOT}/src/hooks/protocol-guardrail.sh\"",
63
+ "timeout": 5
64
+ }
65
+ ]
66
+ }
67
+ ],
68
+ "PreCompact": [
69
+ {
70
+ "matcher": "*",
71
+ "hooks": [
72
+ {
73
+ "type": "command",
74
+ "command": "NEXO_HOME=\"${CLAUDE_PLUGIN_DATA}\" NEXO_CODE=\"${CLAUDE_PLUGIN_ROOT}/src\" bash \"${CLAUDE_PLUGIN_ROOT}/src/hooks/pre-compact.sh\"",
75
+ "timeout": 10
76
+ }
77
+ ]
78
+ }
79
+ ],
80
+ "PostCompact": [
81
+ {
82
+ "matcher": "*",
83
+ "hooks": [
84
+ {
85
+ "type": "command",
86
+ "command": "NEXO_HOME=\"${CLAUDE_PLUGIN_DATA}\" NEXO_CODE=\"${CLAUDE_PLUGIN_ROOT}/src\" bash \"${CLAUDE_PLUGIN_ROOT}/src/hooks/post-compact.sh\"",
87
+ "timeout": 10
9
88
  }
10
89
  ]
11
90
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nexo-brain",
3
- "version": "2.6.21",
3
+ "version": "3.0.0",
4
4
  "mcpName": "io.github.wazionapps/nexo",
5
5
  "description": "NEXO Brain — Shared brain for AI agents. Persistent memory, semantic RAG, natural forgetting, metacognitive guard, trust scoring, 150+ MCP tools. Works with Claude Code, Codex, Claude Desktop & any MCP client. 100% local, free.",
6
6
  "homepage": "https://nexo-brain.com",