nexo-brain 5.3.13 → 5.3.15
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.
- package/.claude-plugin/plugin.json +1 -1
- package/bin/nexo-brain.js +52 -1
- package/package.json +1 -1
- package/src/crons/sync.py +18 -4
- package/src/dashboard/static/favicon 2.svg +32 -0
- package/src/dashboard/static/nexo-logo 2.png +0 -0
- package/src/dashboard/static/nexo-logo 2.svg +40 -0
- package/src/dashboard/static/style 2.css +2458 -0
- package/src/dashboard/templates/adaptive 2.html +118 -0
- package/src/dashboard/templates/artifacts 2.html +133 -0
- package/src/dashboard/templates/backups 2.html +136 -0
- package/src/dashboard/templates/base 2.html +417 -0
- package/src/dashboard/templates/calendar 2.html +591 -0
- package/src/dashboard/templates/chat 2.html +356 -0
- package/src/dashboard/templates/claims 2.html +259 -0
- package/src/dashboard/templates/cortex 2.html +321 -0
- package/src/dashboard/templates/credentials 2.html +128 -0
- package/src/dashboard/templates/crons 2.html +370 -0
- package/src/dashboard/templates/dashboard 2.html +494 -0
- package/src/dashboard/templates/dreams 2.html +252 -0
- package/src/dashboard/templates/email 2.html +160 -0
- package/src/dashboard/templates/evolution 2.html +189 -0
- package/src/dashboard/templates/feed 2.html +249 -0
- package/src/dashboard/templates/followup_health 2.html +170 -0
- package/src/dashboard/templates/graph 2.html +201 -0
- package/src/dashboard/templates/guard 2.html +259 -0
- package/src/dashboard/templates/inbox 2.html +251 -0
- package/src/dashboard/templates/memory 2.html +420 -0
- package/src/dashboard/templates/operations 2.html +608 -0
- package/src/dashboard/templates/plugins 2.html +185 -0
- package/src/dashboard/templates/protocol 2.html +199 -0
- package/src/dashboard/templates/rules 2.html +246 -0
- package/src/dashboard/templates/sentiment 2.html +247 -0
- package/src/dashboard/templates/sessions 2.html +218 -0
- package/src/dashboard/templates/skills 2.html +329 -0
- package/src/dashboard/templates/somatic 2.html +73 -0
- package/src/dashboard/templates/triggers 2.html +133 -0
- package/src/dashboard/templates/trust 2.html +360 -0
- package/src/db/__init__ 2.py +259 -0
- package/src/db/_core 2.py +437 -0
- package/src/db/_credentials 2.py +124 -0
- package/src/db/_entities.py +1 -1
- package/src/db/_episodic 2.py +762 -0
- package/src/db/_evolution 2.py +54 -0
- package/src/db/_fts 2.py +406 -0
- package/src/db/_goal_profiles 2.py +376 -0
- package/src/db/_hot_context 2.py +660 -0
- package/src/db/_outcomes 2.py +800 -0
- package/src/db/_personal_scripts 2.py +582 -0
- package/src/db/_sessions 2.py +330 -0
- package/src/db/_tasks 2.py +91 -0
- package/src/db/_watchers 2.py +173 -0
- package/src/doctor/formatters 2.py +52 -0
- package/src/doctor/models 2.py +69 -0
- package/src/doctor/planes 2.py +87 -0
- package/src/doctor/providers/__init__ 2.py +1 -0
- package/src/doctor/providers/deep 2.py +367 -0
- package/src/evolution_cycle 2.py +519 -0
- package/src/hooks/auto_capture 2.py +208 -0
- package/src/hooks/caffeinate-guard 2.sh +8 -0
- package/src/hooks/capture-session 2.sh +21 -0
- package/src/hooks/capture-tool-logs 2.sh +158 -0
- package/src/hooks/daily-briefing-check 2.sh +33 -0
- package/src/hooks/heartbeat-enforcement 2.py +90 -0
- package/src/hooks/heartbeat-posttool 2.sh +18 -0
- package/src/hooks/inbox-hook 2.sh +76 -0
- package/src/hooks/post-compact 2.sh +152 -0
- package/src/hooks/pre-compact 2.sh +169 -0
- package/src/hooks/protocol-guardrail 2.sh +10 -0
- package/src/hooks/protocol-pretool-guardrail 2.sh +9 -0
- package/src/hooks/session-stop 2.sh +52 -0
- package/src/kg_populate 2.py +292 -0
- package/src/maintenance 2.py +53 -0
- package/src/memory_backends 2.py +71 -0
- package/src/migrate_embeddings 2.py +124 -0
- package/src/nexo_sdk 2.py +103 -0
- package/src/observability 2.py +199 -0
- package/src/plugin_loader 2.py +217 -0
- package/src/plugins/__init__ 2.py +0 -0
- package/src/plugins/agents.py +10 -3
- package/src/plugins/artifact_registry 2.py +450 -0
- package/src/plugins/backup 2.py +127 -0
- package/src/plugins/claims_tools 2.py +119 -0
- package/src/plugins/cognitive_memory 2.py +609 -0
- package/src/plugins/core_rules 2.py +252 -0
- package/src/plugins/cortex 2.py +1155 -0
- package/src/plugins/entities 2.py +67 -0
- package/src/plugins/episodic_memory 2.py +560 -0
- package/src/plugins/evolution 2.py +167 -0
- package/src/plugins/goal_engine 2.py +142 -0
- package/src/plugins/guard 2.py +862 -0
- package/src/plugins/impact 2.py +29 -0
- package/src/plugins/knowledge_graph_tools 2.py +137 -0
- package/src/plugins/media_memory_tools 2.py +98 -0
- package/src/plugins/memory_export 2.py +196 -0
- package/src/plugins/outcomes 2.py +130 -0
- package/src/plugins/personal_scripts 2.py +117 -0
- package/src/plugins/preferences 2.py +47 -0
- package/src/plugins/protocol 2.py +1449 -0
- package/src/plugins/schedule.py +2 -1
- package/src/plugins/simple_api 2.py +106 -0
- package/src/plugins/skills 2.py +341 -0
- package/src/plugins/state_watchers 2.py +79 -0
- package/src/plugins/update 2.py +986 -0
- package/src/plugins/user_state_tools 2.py +43 -0
- package/src/plugins/workflow 2.py +588 -0
- package/src/protocol_settings 2.py +59 -0
- package/src/public_contribution 2.py +466 -0
- package/src/public_evolution_queue 2.py +241 -0
- package/src/requirements 2.txt +14 -0
- package/src/requirements.txt +1 -1
- package/src/retroactive_learnings 2.py +373 -0
- package/src/rules/__init__ 2.py +0 -0
- package/src/rules/core-rules 2.json +331 -0
- package/src/rules/migrate 2.py +207 -0
- package/src/runtime_power 2.py +874 -0
- package/src/runtime_power.py +18 -1
- package/src/script_registry 2.py +1559 -0
- package/src/scripts/check-context 2.py +272 -0
- package/src/scripts/deep-sleep/apply_findings 2.py +2327 -0
- package/src/scripts/deep-sleep/collect 2.py +928 -0
- package/src/scripts/deep-sleep/extract 2.py +330 -0
- package/src/scripts/deep-sleep/extract-prompt 2.md +285 -0
- package/src/scripts/deep-sleep/synthesize 2.py +312 -0
- package/src/scripts/deep-sleep/synthesize-prompt 2.md +336 -0
- package/src/scripts/nexo-agent-run 2.py +75 -0
- package/src/scripts/nexo-auto-update 2.py +6 -0
- package/src/scripts/nexo-backup 2.sh +25 -0
- package/src/scripts/nexo-brain-activation 2.sh +140 -0
- package/src/scripts/nexo-catchup 2.py +300 -0
- package/src/scripts/nexo-cognitive-decay 2.py +257 -0
- package/src/scripts/nexo-cortex-cycle 2.py +293 -0
- package/src/scripts/nexo-cron-wrapper 2.sh +53 -0
- package/src/scripts/nexo-cron-wrapper.sh +7 -0
- package/src/scripts/nexo-daily-self-audit 2.py +2161 -0
- package/src/scripts/nexo-dashboard 2.sh +29 -0
- package/src/scripts/nexo-deep-sleep 2.sh +86 -0
- package/src/scripts/nexo-evolution-run 2.py +1664 -0
- package/src/scripts/nexo-followup-hygiene 2.py +139 -0
- package/src/scripts/nexo-hook-record 2.py +42 -0
- package/src/scripts/nexo-immune 2.py +936 -0
- package/src/scripts/nexo-impact-scorer 2.py +117 -0
- package/src/scripts/nexo-inbox-hook 2.sh +74 -0
- package/src/scripts/nexo-install 2.py +6 -0
- package/src/scripts/nexo-learning-housekeep 2.py +401 -0
- package/src/scripts/nexo-learning-validator 2.py +266 -0
- package/src/scripts/nexo-migrate 2.py +260 -0
- package/src/scripts/nexo-outcome-checker 2.py +127 -0
- package/src/scripts/nexo-postmortem-consolidator 2.py +456 -0
- package/src/scripts/nexo-pre-commit 2.py +120 -0
- package/src/scripts/nexo-prevent-sleep 2.sh +35 -0
- package/src/scripts/nexo-proactive-dashboard 2.py +354 -0
- package/src/scripts/nexo-reflection 2.py +256 -0
- package/src/scripts/nexo-runtime-preflight 2.py +274 -0
- package/src/scripts/nexo-sleep 2.py +631 -0
- package/src/scripts/nexo-snapshot-restore 2.sh +35 -0
- package/src/scripts/nexo-sync-clients 2.py +16 -0
- package/src/scripts/nexo-synthesis 2.py +475 -0
- package/src/scripts/nexo-tcc-approve 2.sh +79 -0
- package/src/scripts/nexo-update 2.sh +306 -0
- package/src/scripts/nexo-watchdog 2.sh +1207 -0
- package/src/scripts/nexo-watchdog-smoke 2.py +119 -0
- package/src/scripts/rehydrate_learnings_from_archive 2.py +245 -0
- package/src/server 2.py +1296 -0
- package/src/skills/run-nexo-audit-phase/guide 2.md +43 -0
- package/src/skills/run-nexo-audit-phase/skill 2.json +59 -0
- package/src/skills/run-nexo-core-fix-cycle/guide 2.md +17 -0
- package/src/skills/run-nexo-core-fix-cycle/script 2.py +276 -0
- package/src/skills/run-nexo-core-fix-cycle/skill 2.json +58 -0
- package/src/skills/run-release-final-audit/guide 2.md +16 -0
- package/src/skills/run-release-final-audit/script 2.py +259 -0
- package/src/skills/run-release-final-audit/skill 2.json +77 -0
- package/src/skills/run-runtime-doctor/guide 2.md +12 -0
- package/src/skills/run-runtime-doctor/script 2.py +21 -0
- package/src/skills/run-runtime-doctor/skill 2.json +25 -0
- package/src/skills_runtime 2.py +932 -0
- package/src/state_watchers_runtime 2.py +475 -0
- package/src/storage_router 2.py +32 -0
- package/src/system_catalog 2.py +786 -0
- package/src/tools_coordination 2.py +103 -0
- package/src/tools_credentials 2.py +68 -0
- package/src/tools_drive 2.py +487 -0
- package/src/tools_hot_context 2.py +163 -0
- package/src/tools_learnings 2.py +612 -0
- package/src/tools_menu 2.py +229 -0
- package/src/tools_reminders 2.py +88 -0
- package/src/tools_reminders_crud 2.py +363 -0
- package/src/tools_sessions 2.py +1054 -0
- package/src/tools_system_catalog 2.py +19 -0
- package/src/tools_task_history 2.py +57 -0
- package/src/tools_transcripts 2.py +98 -0
- package/src/transcript_utils 2.py +412 -0
- package/src/user_context 2.py +46 -0
- package/src/user_data_portability 2.py +328 -0
- package/src/user_state_model 2.py +170 -0
- package/templates/CLAUDE.md 2.template +108 -0
- package/templates/CODEX.AGENTS.md 2.template +66 -0
- package/templates/launchagents/README 2.md +132 -0
- package/templates/launchagents/com.nexo.auto-close-sessions 2.plist +39 -0
- package/templates/launchagents/com.nexo.auto-close-sessions.plist +1 -1
- package/templates/launchagents/com.nexo.catchup 2.plist +39 -0
- package/templates/launchagents/com.nexo.catchup.plist +1 -1
- package/templates/launchagents/com.nexo.cognitive-decay 2.plist +40 -0
- package/templates/launchagents/com.nexo.dashboard 2.plist +43 -0
- package/templates/launchagents/com.nexo.dashboard.plist +1 -1
- package/templates/launchagents/com.nexo.deep-sleep 2.plist +43 -0
- package/templates/launchagents/com.nexo.deep-sleep.plist +1 -1
- package/templates/launchagents/com.nexo.evolution 2.plist +44 -0
- package/templates/launchagents/com.nexo.evolution.plist +1 -1
- package/templates/launchagents/com.nexo.followup-hygiene 2.plist +45 -0
- package/templates/launchagents/com.nexo.followup-hygiene.plist +1 -1
- package/templates/launchagents/com.nexo.immune 2.plist +41 -0
- package/templates/launchagents/com.nexo.immune.plist +1 -1
- package/templates/launchagents/com.nexo.postmortem 2.plist +45 -0
- package/templates/launchagents/com.nexo.postmortem.plist +1 -1
- package/templates/launchagents/com.nexo.self-audit 2.plist +47 -0
- package/templates/launchagents/com.nexo.self-audit.plist +1 -1
- package/templates/launchagents/com.nexo.synthesis 2.plist +45 -0
- package/templates/launchagents/com.nexo.synthesis.plist +1 -1
- package/templates/launchagents/com.nexo.watchdog 2.plist +37 -0
- package/templates/launchagents/com.nexo.watchdog.plist +1 -1
- package/templates/nexo_helper 2.py +301 -0
- package/templates/openclaw 2.json +13 -0
- package/templates/plugin-template 2.py +40 -0
- package/templates/script-template 2.py +59 -0
- package/templates/script-template 2.sh +13 -0
- package/templates/script-template.py +5 -4
- package/templates/skill-script-template 2.py +48 -0
- package/templates/skill-script-template.py +2 -1
- package/templates/skill-template 2.md +33 -0
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
<key>HOME</key>
|
|
38
38
|
<string>{{HOME}}</string>
|
|
39
39
|
<key>PATH</key>
|
|
40
|
-
<string>/usr/local/bin:/usr/bin:/bin
|
|
40
|
+
<string>/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:__NEXO_HOME__/bin</string>
|
|
41
41
|
<key>NEXO_HOME</key>
|
|
42
42
|
<string>{{NEXO_HOME}}</string>
|
|
43
43
|
<key>NEXO_CODE</key>
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<!-- com.nexo.synthesis
|
|
3
|
+
Runs nexo-synthesis.py every 2 hours to generate a daily synthesis
|
|
4
|
+
document. Aggregates session diaries, error patterns, pending items,
|
|
5
|
+
and self-evaluation notes into coordination/daily-synthesis.md.
|
|
6
|
+
This file is read at the start of each session to give NEXO context
|
|
7
|
+
about what happened recently without replaying full session logs.
|
|
8
|
+
-->
|
|
9
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
10
|
+
<plist version="1.0">
|
|
11
|
+
<dict>
|
|
12
|
+
<key>Label</key>
|
|
13
|
+
<string>com.nexo.synthesis</string>
|
|
14
|
+
|
|
15
|
+
<key>ProgramArguments</key>
|
|
16
|
+
<array>
|
|
17
|
+
<string>/usr/bin/python3</string>
|
|
18
|
+
<string>{{NEXO_HOME}}/scripts/nexo-synthesis.py</string>
|
|
19
|
+
</array>
|
|
20
|
+
|
|
21
|
+
<key>StartInterval</key>
|
|
22
|
+
<integer>7200</integer>
|
|
23
|
+
|
|
24
|
+
<key>RunAtLoad</key>
|
|
25
|
+
<false/>
|
|
26
|
+
|
|
27
|
+
<key>StandardOutPath</key>
|
|
28
|
+
<string>{{NEXO_HOME}}/coordination/synthesis-stdout.log</string>
|
|
29
|
+
|
|
30
|
+
<key>StandardErrorPath</key>
|
|
31
|
+
<string>{{NEXO_HOME}}/coordination/synthesis-stderr.log</string>
|
|
32
|
+
|
|
33
|
+
<key>EnvironmentVariables</key>
|
|
34
|
+
<dict>
|
|
35
|
+
<key>HOME</key>
|
|
36
|
+
<string>{{HOME}}</string>
|
|
37
|
+
<key>PATH</key>
|
|
38
|
+
<string>/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:__NEXO_HOME__/bin</string>
|
|
39
|
+
<key>NEXO_HOME</key>
|
|
40
|
+
<string>{{NEXO_HOME}}</string>
|
|
41
|
+
<key>NEXO_CODE</key>
|
|
42
|
+
<string>{{NEXO_CODE}}</string>
|
|
43
|
+
</dict>
|
|
44
|
+
</dict>
|
|
45
|
+
</plist>
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
<key>HOME</key>
|
|
36
36
|
<string>{{HOME}}</string>
|
|
37
37
|
<key>PATH</key>
|
|
38
|
-
<string>/
|
|
38
|
+
<string>/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:__NEXO_HOME__/bin</string>
|
|
39
39
|
<key>NEXO_HOME</key>
|
|
40
40
|
<string>{{NEXO_HOME}}</string>
|
|
41
41
|
<key>NEXO_CODE</key>
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<!-- com.nexo.watchdog
|
|
3
|
+
Runs nexo-watchdog.sh every 30 minutes to monitor system health.
|
|
4
|
+
Checks that the NEXO MCP server, cron jobs, and key infrastructure
|
|
5
|
+
services are alive. Writes results to watchdog-status.json and
|
|
6
|
+
watchdog-report.txt. Sets a .watchdog-alert flag when failures are
|
|
7
|
+
detected so the next Claude session can alert the user immediately.
|
|
8
|
+
-->
|
|
9
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
10
|
+
<plist version="1.0">
|
|
11
|
+
<dict>
|
|
12
|
+
<key>Label</key>
|
|
13
|
+
<string>com.nexo.watchdog</string>
|
|
14
|
+
<key>ProgramArguments</key>
|
|
15
|
+
<array>
|
|
16
|
+
<string>/bin/bash</string>
|
|
17
|
+
<string>{{NEXO_HOME}}/scripts/nexo-watchdog.sh</string>
|
|
18
|
+
</array>
|
|
19
|
+
<key>StartInterval</key>
|
|
20
|
+
<integer>1800</integer>
|
|
21
|
+
<key>RunAtLoad</key>
|
|
22
|
+
<true/>
|
|
23
|
+
<key>StandardOutPath</key>
|
|
24
|
+
<string>{{NEXO_HOME}}/logs/watchdog-stdout.log</string>
|
|
25
|
+
<key>StandardErrorPath</key>
|
|
26
|
+
<string>{{NEXO_HOME}}/logs/watchdog-stderr.log</string>
|
|
27
|
+
<key>EnvironmentVariables</key>
|
|
28
|
+
<dict>
|
|
29
|
+
<key>PATH</key>
|
|
30
|
+
<string>/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:__NEXO_HOME__/bin</string>
|
|
31
|
+
<key>NEXO_HOME</key>
|
|
32
|
+
<string>{{NEXO_HOME}}</string>
|
|
33
|
+
<key>NEXO_CODE</key>
|
|
34
|
+
<string>{{NEXO_CODE}}</string>
|
|
35
|
+
</dict>
|
|
36
|
+
</dict>
|
|
37
|
+
</plist>
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
<key>EnvironmentVariables</key>
|
|
28
28
|
<dict>
|
|
29
29
|
<key>PATH</key>
|
|
30
|
-
<string>/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin</string>
|
|
30
|
+
<string>/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:__NEXO_HOME__/bin</string>
|
|
31
31
|
<key>NEXO_HOME</key>
|
|
32
32
|
<string>{{NEXO_HOME}}</string>
|
|
33
33
|
<key>NEXO_CODE</key>
|
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
"""NEXO Helper — vendorable utility for personal scripts.
|
|
2
|
+
|
|
3
|
+
Provides stable access to NEXO MCP tools via the CLI.
|
|
4
|
+
Copy this file next to your script or keep it in NEXO_HOME/templates/.
|
|
5
|
+
|
|
6
|
+
This module does NOT import any NEXO internals (db, server, cognitive).
|
|
7
|
+
All communication goes through the stable `nexo scripts call` CLI.
|
|
8
|
+
"""
|
|
9
|
+
from __future__ import annotations
|
|
10
|
+
|
|
11
|
+
import json
|
|
12
|
+
import os
|
|
13
|
+
import shutil
|
|
14
|
+
import subprocess
|
|
15
|
+
import sys
|
|
16
|
+
from pathlib import Path
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def _detect_nexo_home() -> Path:
|
|
20
|
+
env_home = os.environ.get("NEXO_HOME", "").strip()
|
|
21
|
+
if env_home:
|
|
22
|
+
return Path(env_home).expanduser()
|
|
23
|
+
|
|
24
|
+
helper_path = Path(__file__).resolve()
|
|
25
|
+
inferred_home = helper_path.parent.parent
|
|
26
|
+
if (
|
|
27
|
+
helper_path.parent.name == "templates"
|
|
28
|
+
and (inferred_home / "scripts").is_dir()
|
|
29
|
+
and (inferred_home / "config").is_dir()
|
|
30
|
+
):
|
|
31
|
+
return inferred_home
|
|
32
|
+
|
|
33
|
+
default_home = Path.home() / ".nexo"
|
|
34
|
+
if default_home.is_dir():
|
|
35
|
+
return default_home
|
|
36
|
+
|
|
37
|
+
claude_home = Path.home() / "claude"
|
|
38
|
+
if claude_home.is_dir():
|
|
39
|
+
return claude_home
|
|
40
|
+
|
|
41
|
+
return default_home
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
NEXO_HOME = _detect_nexo_home()
|
|
45
|
+
DEFAULT_ALLOWED_TOOLS = "Read,Write,Edit,Glob,Grep,Bash,mcp__nexo__*"
|
|
46
|
+
DEFAULT_NEXO_TIMEOUT_SECONDS = max(15, int(os.environ.get("NEXO_HELPER_TIMEOUT", "90")))
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def _load_schedule() -> dict:
|
|
50
|
+
schedule_path = NEXO_HOME / "config" / "schedule.json"
|
|
51
|
+
if not schedule_path.is_file():
|
|
52
|
+
return {}
|
|
53
|
+
try:
|
|
54
|
+
return json.loads(schedule_path.read_text())
|
|
55
|
+
except Exception:
|
|
56
|
+
return {}
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def _resolve_automation_backend() -> str:
|
|
60
|
+
data = _load_schedule()
|
|
61
|
+
return str(data.get("automation_backend", "claude_code") or "claude_code")
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def _load_bootstrap_prompt() -> str:
|
|
65
|
+
backend = _resolve_automation_backend()
|
|
66
|
+
if backend == "codex":
|
|
67
|
+
path = Path.home() / ".codex" / "AGENTS.md"
|
|
68
|
+
else:
|
|
69
|
+
path = Path.home() / ".claude" / "CLAUDE.md"
|
|
70
|
+
if not path.is_file():
|
|
71
|
+
return ""
|
|
72
|
+
try:
|
|
73
|
+
return path.read_text()
|
|
74
|
+
except Exception:
|
|
75
|
+
return ""
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
def _resolve_nexo_cli() -> str:
|
|
79
|
+
candidates = []
|
|
80
|
+
|
|
81
|
+
env_cli = os.environ.get("NEXO_BIN", "").strip()
|
|
82
|
+
if env_cli:
|
|
83
|
+
candidates.append(Path(env_cli).expanduser())
|
|
84
|
+
|
|
85
|
+
candidates.extend(
|
|
86
|
+
[
|
|
87
|
+
NEXO_HOME / "bin" / "nexo",
|
|
88
|
+
Path.home() / ".local" / "bin" / "nexo",
|
|
89
|
+
Path.home() / "bin" / "nexo",
|
|
90
|
+
]
|
|
91
|
+
)
|
|
92
|
+
|
|
93
|
+
for candidate in candidates:
|
|
94
|
+
try:
|
|
95
|
+
if candidate.is_file() and os.access(candidate, os.X_OK):
|
|
96
|
+
return str(candidate)
|
|
97
|
+
except OSError:
|
|
98
|
+
continue
|
|
99
|
+
|
|
100
|
+
return shutil.which("nexo") or "nexo"
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
def run_nexo(args: list[str]) -> str:
|
|
104
|
+
"""Run a nexo CLI command and return stdout.
|
|
105
|
+
|
|
106
|
+
Raises RuntimeError on non-zero exit.
|
|
107
|
+
"""
|
|
108
|
+
env = os.environ.copy()
|
|
109
|
+
env.setdefault("NEXO_HOME", str(NEXO_HOME))
|
|
110
|
+
result = subprocess.run(
|
|
111
|
+
[_resolve_nexo_cli(), *args],
|
|
112
|
+
capture_output=True,
|
|
113
|
+
text=True,
|
|
114
|
+
timeout=DEFAULT_NEXO_TIMEOUT_SECONDS,
|
|
115
|
+
env=env,
|
|
116
|
+
)
|
|
117
|
+
if result.returncode != 0:
|
|
118
|
+
raise RuntimeError(result.stderr.strip() or result.stdout.strip() or f"nexo exited {result.returncode}")
|
|
119
|
+
return result.stdout
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
def call_tool(name: str, payload: dict | None = None) -> str:
|
|
123
|
+
"""Call a NEXO MCP tool by name. Returns raw text output."""
|
|
124
|
+
args = ["scripts", "call", name, "--input", json.dumps(payload or {})]
|
|
125
|
+
return run_nexo(args)
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
def call_tool_text(name: str, payload: dict | None = None) -> str:
|
|
129
|
+
"""Call a NEXO MCP tool and return text output."""
|
|
130
|
+
return call_tool(name, payload)
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
def call_tool_json(name: str, payload: dict | None = None) -> dict:
|
|
134
|
+
"""Call a NEXO MCP tool and return parsed JSON output."""
|
|
135
|
+
args = ["scripts", "call", name, "--input", json.dumps(payload or {}), "--json-output"]
|
|
136
|
+
out = run_nexo(args)
|
|
137
|
+
return json.loads(out)
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
def _extract_json_object(text: str) -> dict:
|
|
141
|
+
raw = str(text or "").strip()
|
|
142
|
+
if not raw:
|
|
143
|
+
raise RuntimeError("Automation backend returned empty output.")
|
|
144
|
+
|
|
145
|
+
if raw.startswith("```"):
|
|
146
|
+
lines = raw.splitlines()
|
|
147
|
+
if len(lines) >= 2:
|
|
148
|
+
end = len(lines)
|
|
149
|
+
for i in range(len(lines) - 1, 0, -1):
|
|
150
|
+
if lines[i].strip() == "```":
|
|
151
|
+
end = i
|
|
152
|
+
break
|
|
153
|
+
raw = "\n".join(lines[1:end]).strip()
|
|
154
|
+
|
|
155
|
+
try:
|
|
156
|
+
parsed = json.loads(raw)
|
|
157
|
+
if isinstance(parsed, dict):
|
|
158
|
+
return parsed
|
|
159
|
+
except Exception:
|
|
160
|
+
pass
|
|
161
|
+
|
|
162
|
+
start = raw.find("{")
|
|
163
|
+
if start < 0:
|
|
164
|
+
raise RuntimeError("Automation backend did not return a JSON object.")
|
|
165
|
+
|
|
166
|
+
depth = 0
|
|
167
|
+
in_string = False
|
|
168
|
+
escape = False
|
|
169
|
+
for idx in range(start, len(raw)):
|
|
170
|
+
ch = raw[idx]
|
|
171
|
+
if in_string:
|
|
172
|
+
if escape:
|
|
173
|
+
escape = False
|
|
174
|
+
elif ch == "\\":
|
|
175
|
+
escape = True
|
|
176
|
+
elif ch == '"':
|
|
177
|
+
in_string = False
|
|
178
|
+
continue
|
|
179
|
+
|
|
180
|
+
if ch == '"':
|
|
181
|
+
in_string = True
|
|
182
|
+
elif ch == "{":
|
|
183
|
+
depth += 1
|
|
184
|
+
elif ch == "}":
|
|
185
|
+
depth -= 1
|
|
186
|
+
if depth == 0:
|
|
187
|
+
candidate = raw[start : idx + 1]
|
|
188
|
+
try:
|
|
189
|
+
parsed = json.loads(candidate)
|
|
190
|
+
except Exception as exc:
|
|
191
|
+
raise RuntimeError(f"Automation backend returned invalid JSON object: {exc}") from exc
|
|
192
|
+
if isinstance(parsed, dict):
|
|
193
|
+
return parsed
|
|
194
|
+
break
|
|
195
|
+
|
|
196
|
+
raise RuntimeError("Automation backend did not return a parseable JSON object.")
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
def run_automation_text(
|
|
200
|
+
prompt: str,
|
|
201
|
+
*,
|
|
202
|
+
model: str = "",
|
|
203
|
+
reasoning_effort: str = "",
|
|
204
|
+
cwd: str = "",
|
|
205
|
+
timeout: int | None = None,
|
|
206
|
+
allowed_tools: str = DEFAULT_ALLOWED_TOOLS,
|
|
207
|
+
append_system_prompt: str = "",
|
|
208
|
+
include_bootstrap: bool = True,
|
|
209
|
+
) -> str:
|
|
210
|
+
"""Run the configured NEXO automation backend and return text output.
|
|
211
|
+
|
|
212
|
+
This avoids hardcoding provider CLIs such as `claude -p` inside personal
|
|
213
|
+
scripts. The runtime routes the call through the selected backend and its
|
|
214
|
+
configured model profile.
|
|
215
|
+
"""
|
|
216
|
+
runner = NEXO_HOME / "scripts" / "nexo-agent-run.py"
|
|
217
|
+
if not runner.exists():
|
|
218
|
+
raise RuntimeError(f"Automation runner not found: {runner}")
|
|
219
|
+
|
|
220
|
+
cmd = [sys.executable, str(runner), "--prompt", prompt, "--output-format", "text"]
|
|
221
|
+
if model:
|
|
222
|
+
cmd.extend(["--model", model])
|
|
223
|
+
if reasoning_effort:
|
|
224
|
+
cmd.extend(["--reasoning-effort", reasoning_effort])
|
|
225
|
+
if cwd:
|
|
226
|
+
cmd.extend(["--cwd", cwd])
|
|
227
|
+
merged_system_prompt = []
|
|
228
|
+
if include_bootstrap:
|
|
229
|
+
bootstrap = _load_bootstrap_prompt()
|
|
230
|
+
if bootstrap:
|
|
231
|
+
merged_system_prompt.append(bootstrap)
|
|
232
|
+
if append_system_prompt:
|
|
233
|
+
merged_system_prompt.append(append_system_prompt)
|
|
234
|
+
if merged_system_prompt:
|
|
235
|
+
cmd.extend(["--append-system-prompt", "\n\n".join(merged_system_prompt)])
|
|
236
|
+
if allowed_tools:
|
|
237
|
+
cmd.extend(["--allowed-tools", allowed_tools])
|
|
238
|
+
|
|
239
|
+
env = os.environ.copy()
|
|
240
|
+
env.setdefault("NEXO_HOME", str(NEXO_HOME))
|
|
241
|
+
env.setdefault("NEXO_CODE", env.get("NEXO_CODE", str(NEXO_HOME)))
|
|
242
|
+
result = subprocess.run(
|
|
243
|
+
cmd,
|
|
244
|
+
capture_output=True,
|
|
245
|
+
text=True,
|
|
246
|
+
env=env,
|
|
247
|
+
timeout=(int(timeout) if timeout else None),
|
|
248
|
+
)
|
|
249
|
+
if result.returncode != 0:
|
|
250
|
+
raise RuntimeError(result.stderr.strip() or result.stdout.strip() or f"automation backend exited {result.returncode}")
|
|
251
|
+
return result.stdout
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
def run_automation_json(
|
|
255
|
+
prompt: str,
|
|
256
|
+
*,
|
|
257
|
+
model: str = "",
|
|
258
|
+
reasoning_effort: str = "",
|
|
259
|
+
cwd: str = "",
|
|
260
|
+
timeout: int | None = None,
|
|
261
|
+
allowed_tools: str = DEFAULT_ALLOWED_TOOLS,
|
|
262
|
+
append_system_prompt: str = "",
|
|
263
|
+
include_bootstrap: bool = True,
|
|
264
|
+
) -> dict:
|
|
265
|
+
"""Run the configured backend and return a parsed JSON object."""
|
|
266
|
+
runner = NEXO_HOME / "scripts" / "nexo-agent-run.py"
|
|
267
|
+
if not runner.exists():
|
|
268
|
+
raise RuntimeError(f"Automation runner not found: {runner}")
|
|
269
|
+
|
|
270
|
+
cmd = [sys.executable, str(runner), "--prompt", prompt, "--output-format", "json"]
|
|
271
|
+
if model:
|
|
272
|
+
cmd.extend(["--model", model])
|
|
273
|
+
if reasoning_effort:
|
|
274
|
+
cmd.extend(["--reasoning-effort", reasoning_effort])
|
|
275
|
+
if cwd:
|
|
276
|
+
cmd.extend(["--cwd", cwd])
|
|
277
|
+
merged_system_prompt = []
|
|
278
|
+
if include_bootstrap:
|
|
279
|
+
bootstrap = _load_bootstrap_prompt()
|
|
280
|
+
if bootstrap:
|
|
281
|
+
merged_system_prompt.append(bootstrap)
|
|
282
|
+
if append_system_prompt:
|
|
283
|
+
merged_system_prompt.append(append_system_prompt)
|
|
284
|
+
if merged_system_prompt:
|
|
285
|
+
cmd.extend(["--append-system-prompt", "\n\n".join(merged_system_prompt)])
|
|
286
|
+
if allowed_tools:
|
|
287
|
+
cmd.extend(["--allowed-tools", allowed_tools])
|
|
288
|
+
|
|
289
|
+
env = os.environ.copy()
|
|
290
|
+
env.setdefault("NEXO_HOME", str(NEXO_HOME))
|
|
291
|
+
env.setdefault("NEXO_CODE", env.get("NEXO_CODE", str(NEXO_HOME)))
|
|
292
|
+
result = subprocess.run(
|
|
293
|
+
cmd,
|
|
294
|
+
capture_output=True,
|
|
295
|
+
text=True,
|
|
296
|
+
env=env,
|
|
297
|
+
timeout=(int(timeout) if timeout else None),
|
|
298
|
+
)
|
|
299
|
+
if result.returncode != 0:
|
|
300
|
+
raise RuntimeError(result.stderr.strip() or result.stdout.strip() or f"automation backend exited {result.returncode}")
|
|
301
|
+
return _extract_json_object(result.stdout)
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"""Personal NEXO MCP plugin scaffold.
|
|
2
|
+
|
|
3
|
+
This file lives in NEXO_HOME/plugins/ and is loaded by the NEXO MCP server.
|
|
4
|
+
Edit the handler below to implement your personal capability.
|
|
5
|
+
|
|
6
|
+
If this plugin ever needs an autonomous model call, route it through the
|
|
7
|
+
configured NEXO automation backend instead of hardcoding `claude -p` or
|
|
8
|
+
provider-specific model names directly inside the plugin.
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
from __future__ import annotations
|
|
12
|
+
|
|
13
|
+
import json
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def handle_example_tool(payload_json: str = "{}") -> str:
|
|
17
|
+
"""Example personal MCP tool.
|
|
18
|
+
|
|
19
|
+
Args:
|
|
20
|
+
payload_json: JSON string with your input payload.
|
|
21
|
+
"""
|
|
22
|
+
try:
|
|
23
|
+
payload = json.loads(payload_json or "{}")
|
|
24
|
+
except Exception as exc:
|
|
25
|
+
return json.dumps({"ok": False, "error": f"invalid json: {exc}"}, ensure_ascii=False)
|
|
26
|
+
|
|
27
|
+
return json.dumps({
|
|
28
|
+
"ok": True,
|
|
29
|
+
"message": "Personal plugin scaffold created. Edit this handler in NEXO_HOME/plugins.",
|
|
30
|
+
"payload": payload,
|
|
31
|
+
}, ensure_ascii=False)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
TOOLS = [
|
|
35
|
+
(
|
|
36
|
+
handle_example_tool,
|
|
37
|
+
"nexo_example_tool",
|
|
38
|
+
"Example personal MCP tool scaffold. Edit it in NEXO_HOME/plugins.",
|
|
39
|
+
),
|
|
40
|
+
]
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# nexo: name=example-script
|
|
3
|
+
# nexo: description=Example personal script using the stable NEXO CLI
|
|
4
|
+
# nexo: category=automation
|
|
5
|
+
# nexo: runtime=python
|
|
6
|
+
# nexo: timeout=60
|
|
7
|
+
# nexo: tools=nexo_learning_search,nexo_schedule_status
|
|
8
|
+
# nexo: interval_seconds=300
|
|
9
|
+
# nexo: schedule_required=false
|
|
10
|
+
|
|
11
|
+
"""Example personal script for NEXO.
|
|
12
|
+
|
|
13
|
+
This template demonstrates:
|
|
14
|
+
- Inline metadata for auto-discovery
|
|
15
|
+
- Safe CLI calls through nexo_helper
|
|
16
|
+
- Optional agent calls through the configured automation backend
|
|
17
|
+
- Timeout handling (via metadata)
|
|
18
|
+
- argparse for user arguments
|
|
19
|
+
- No direct DB access
|
|
20
|
+
- Clean exit codes
|
|
21
|
+
"""
|
|
22
|
+
|
|
23
|
+
import argparse
|
|
24
|
+
import sys
|
|
25
|
+
|
|
26
|
+
# nexo_helper.py is in NEXO_HOME/templates/ — copy it next to your script
|
|
27
|
+
# or add the templates dir to your path
|
|
28
|
+
try:
|
|
29
|
+
from nexo_helper import call_tool_text, run_automation_text
|
|
30
|
+
except ImportError:
|
|
31
|
+
import os
|
|
32
|
+
sys.path.insert(0, os.path.join(os.environ.get("NEXO_HOME", "~/.nexo"), "templates"))
|
|
33
|
+
from nexo_helper import call_tool_text, run_automation_text
|
|
34
|
+
|
|
35
|
+
# If this script ever needs an autonomous model call:
|
|
36
|
+
# 1. use resolve_user_model() to get the user's configured model
|
|
37
|
+
# 2. pass it to run_automation_text(...)
|
|
38
|
+
# 3. DO NOT hardcode model names — the user picks their model once
|
|
39
|
+
# Example:
|
|
40
|
+
# from client_preferences import resolve_user_model
|
|
41
|
+
# result = run_automation_text(
|
|
42
|
+
# "Summarize pending issues",
|
|
43
|
+
# model=resolve_user_model(),
|
|
44
|
+
# )
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def main():
|
|
48
|
+
parser = argparse.ArgumentParser(description="Example NEXO personal script")
|
|
49
|
+
parser.add_argument("--query", default="cron", help="Search query for learnings")
|
|
50
|
+
args = parser.parse_args()
|
|
51
|
+
|
|
52
|
+
print(f"Searching learnings for: {args.query}")
|
|
53
|
+
result = call_tool_text("nexo_learning_search", {"query": args.query})
|
|
54
|
+
print(result)
|
|
55
|
+
return 0
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
if __name__ == "__main__":
|
|
59
|
+
raise SystemExit(main())
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# nexo: name=example-script
|
|
3
|
+
# nexo: description=Example personal shell script using the stable NEXO CLI
|
|
4
|
+
# nexo: category=automation
|
|
5
|
+
# nexo: runtime=shell
|
|
6
|
+
# nexo: timeout=60
|
|
7
|
+
# nexo: schedule=08:00
|
|
8
|
+
# nexo: schedule_required=false
|
|
9
|
+
|
|
10
|
+
set -euo pipefail
|
|
11
|
+
|
|
12
|
+
echo "Hello from NEXO personal shell script"
|
|
13
|
+
echo "NEXO_HOME=${NEXO_HOME:-}"
|
|
@@ -33,13 +33,14 @@ except ImportError:
|
|
|
33
33
|
from nexo_helper import call_tool_text, run_automation_text
|
|
34
34
|
|
|
35
35
|
# If this script ever needs an autonomous model call:
|
|
36
|
-
# 1. use
|
|
37
|
-
# 2. pass
|
|
38
|
-
# 3. DO NOT hardcode
|
|
36
|
+
# 1. use resolve_user_model() to get the user's configured model
|
|
37
|
+
# 2. pass it to run_automation_text(...)
|
|
38
|
+
# 3. DO NOT hardcode model names — the user picks their model once
|
|
39
39
|
# Example:
|
|
40
|
+
# from client_preferences import resolve_user_model
|
|
40
41
|
# result = run_automation_text(
|
|
41
42
|
# "Summarize pending issues",
|
|
42
|
-
# model=
|
|
43
|
+
# model=resolve_user_model(),
|
|
43
44
|
# )
|
|
44
45
|
|
|
45
46
|
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Skill script template.
|
|
3
|
+
|
|
4
|
+
This script is meant to be referenced by a Skill v2 definition.
|
|
5
|
+
It should use the stable NEXO CLI rather than importing internal DB modules.
|
|
6
|
+
If it needs an agentic model call, route it through NEXO's configured
|
|
7
|
+
automation backend instead of hardcoding `claude -p` or a provider model.
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
import argparse
|
|
11
|
+
import os
|
|
12
|
+
import subprocess
|
|
13
|
+
import sys
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def main() -> int:
|
|
17
|
+
parser = argparse.ArgumentParser()
|
|
18
|
+
parser.add_argument("--query", default="")
|
|
19
|
+
args = parser.parse_args()
|
|
20
|
+
|
|
21
|
+
nexo_code = os.environ.get("NEXO_CODE", "")
|
|
22
|
+
if not nexo_code:
|
|
23
|
+
print("NEXO_CODE not set", file=sys.stderr)
|
|
24
|
+
return 1
|
|
25
|
+
|
|
26
|
+
cli_py = os.path.join(nexo_code, "cli.py")
|
|
27
|
+
cmd = [
|
|
28
|
+
sys.executable,
|
|
29
|
+
cli_py,
|
|
30
|
+
"scripts",
|
|
31
|
+
"call",
|
|
32
|
+
"nexo_learning_search",
|
|
33
|
+
"--input",
|
|
34
|
+
'{"query": %r}' % args.query,
|
|
35
|
+
]
|
|
36
|
+
result = subprocess.run(cmd, text=True)
|
|
37
|
+
return result.returncode
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
# Agentic example for future edits:
|
|
41
|
+
# from client_preferences import resolve_user_model
|
|
42
|
+
# from nexo_helper import run_automation_text
|
|
43
|
+
# result = run_automation_text("Analyze this", model=resolve_user_model())
|
|
44
|
+
# print(result)
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
if __name__ == "__main__":
|
|
48
|
+
raise SystemExit(main())
|
|
@@ -38,8 +38,9 @@ def main() -> int:
|
|
|
38
38
|
|
|
39
39
|
|
|
40
40
|
# Agentic example for future edits:
|
|
41
|
+
# from client_preferences import resolve_user_model
|
|
41
42
|
# from nexo_helper import run_automation_text
|
|
42
|
-
# result = run_automation_text("Analyze this", model=
|
|
43
|
+
# result = run_automation_text("Analyze this", model=resolve_user_model())
|
|
43
44
|
# print(result)
|
|
44
45
|
|
|
45
46
|
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# Skill Template
|
|
2
|
+
|
|
3
|
+
Create a directory under one of:
|
|
4
|
+
- `NEXO_HOME/skills/<slug>/`
|
|
5
|
+
- `src/skills/<slug>/`
|
|
6
|
+
- `community/skills/<slug>/`
|
|
7
|
+
|
|
8
|
+
Required files:
|
|
9
|
+
- `skill.json`
|
|
10
|
+
- `guide.md`
|
|
11
|
+
|
|
12
|
+
Optional:
|
|
13
|
+
- `script.py` or `script.sh`
|
|
14
|
+
|
|
15
|
+
Example `skill.json`:
|
|
16
|
+
|
|
17
|
+
```json
|
|
18
|
+
{
|
|
19
|
+
"id": "SK-EXAMPLE",
|
|
20
|
+
"name": "Example Skill",
|
|
21
|
+
"description": "What this skill does.",
|
|
22
|
+
"level": "draft",
|
|
23
|
+
"mode": "guide",
|
|
24
|
+
"source_kind": "personal",
|
|
25
|
+
"execution_level": "none",
|
|
26
|
+
"approval_required": false,
|
|
27
|
+
"tags": ["example"],
|
|
28
|
+
"trigger_patterns": ["example task"],
|
|
29
|
+
"params_schema": {},
|
|
30
|
+
"command_template": {},
|
|
31
|
+
"stable_after_uses": 10
|
|
32
|
+
}
|
|
33
|
+
```
|