#!/usr/bin/env python3 """ JEDI x Vitalis Cortex — Unified CLI Wires JEDI nanobot framework into Vitalis Cortex LFM2.5 engine. Runs the full cognitive pipeline: Quadruflow → Memory → Amplifier → LFM2.5 → Attestation → JEDI modules → Output """ import os import sys import textwrap # Paths BASE = os.path.dirname(os.path.abspath(__file__)) CORTEX = os.path.join(BASE, "Vitalis_LFM2.5_Cortex.GGUF") JEDI = BASE sys.path.insert(0, CORTEX) sys.path.insert(0, JEDI) from src.brain.inference import InferenceEngine from jedi.core.engine import JEDIEngine, ThreatLevel from jedi.core.nanobot import Nanobot, NanobotType from jedi.core.mission import Mission from jedi.legal.gate import LegalGate, AuthorizationLevel from jedi.swarm.coordinator import SwarmCoordinator from jedi.command.control import MissionControl from jedi.comms.channel import CommsChannel from jedi.memory.helix import HelixMemoryStore from jedi.nanobots.black.ghost import GhostNanobot from jedi.nanobots.blue.guardian import GuardianNanobot from jedi.nanobots.red.striker import StrikerNanobot from jedi.nanobots.green.architect import ArchitectNanobot from jedi.nanobots.yellow.auditor import AuditorNanobot from jedi.nanobots.purple.synapse import SynapseNanobot BANNER = r""" ██╗███████╗██████╗ ██╗ ██║██╔════╝██╔══██╗██║ ██║█████╗ ██║ ██║██║ ██║██╔══╝ ██║ ██║██║ ██║███████╗██████╔╝███████╗ ╚═╝╚══════╝╚═════╝ ╚══════╝ ██╗ ██╗██╗████████╗ █████╗ ██╗ ██╗███████╗ ██║ ██║██║╚══██╔══╝██╔══██╗██║ ██║██╔════╝ ██║ ██║██║ ██║ ███████║██║ ██║███████╗ ╚██╗ ██╔╝██║ ██║ ██╔══██║██║ ██║╚════██║ ╚████╔╝ ██║ ██║ ██║ ██║███████╗██║███████║ ╚═══╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝╚══════╝╚═╝╚══════╝ JEDI x Vitalis Cortex Hybrid Nanobot Defense Intelligence | LFM2.5 Cognitive Core Ferrell Synthetic Intelligence """ def main(): print(BANNER) print(" Booting JEDI x Vitalis Cortex...\n") # Initialize JEDI systems engine = JEDIEngine() gate = LegalGate() mc = MissionControl(engine) swarm = SwarmCoordinator("jedi-swarm") comms = CommsChannel("jedi-comms") memory = HelixMemoryStore() # Initialize Vitalis Cortex with LFM2.5 try: cortex = InferenceEngine(model_path=os.path.join(CORTEX, "model", "LFM2.5-1.2B-Instruct-Q4_K_M.gguf")) print("\n ✓ Vitalis Cortex online — LFM2.5 1.2B cognitive core loaded") cortex_online = True except Exception as e: print(f"\n ✗ Cortex load: {e}") cortex_online = False print(" ✓ JEDI Engine online — nanobot framework armed") print(" ✓ Legal Gate active — all ops require authorization") print(" ✓ Ledger initialized — immutable audit trail") print(" ✓ Swarm Coordinator ready") print() print(" Type 'help' for commands. Type 'quit' to exit.\n") memory.record_episode({"type": "session_start", "cortex_online": cortex_online}) # Chat loop while True: try: prompt = input("\033[96m JEDI ▸ \033[0m").strip() except (EOFError, KeyboardInterrupt): print("\n\n Shutdown. All nanobots self-destructed.") break if not prompt: continue if prompt.lower() in ["quit", "exit", "bye"]: print("\n JEDI offline. Ledger sealed. Goodbye.\n") break if prompt.lower() == "clear": os.system("clear") print(BANNER) continue # Route to appropriate system response = route(prompt, cortex if cortex_online else None, engine, gate, mc, swarm, comms, memory) # Format output print() for line in response.split("\n"): wrapped = textwrap.fill(line, width=80, initial_indent=" ", subsequent_indent=" ") print(wrapped) # Log engine.ledger.log("cli_interaction", {"input": prompt[:80]}) print() def route(prompt, cortex, engine, gate, mc, swarm, comms, memory): """Route prompt to appropriate handler.""" p = prompt.lower() # === JEDI COMMANDS === if any(w in p for w in ["threat", "risk", "assess"]): return threat_handler(p, engine) if p.startswith("deploy") or p.startswith("deploy nanobot"): return deploy_handler(prompt) if p.startswith("mission"): return mission_handler(prompt, mc) if "swarm" in p.split() and len(p.split()) < 4: return swarm_handler(swarm) if "scan" in p: return "═══ SCAN PROTOCOL ═══\nTarget and auth needed. Example:\n mission create recon 10.0.0.0/24\n Then I'll deploy a Scout nanobot swarm." if p in ["help", "/help", "-h", "--help"]: return help_text() if p in ["status", "screenshot"]: return status_handler(mc) if p == "clear": return "" # Use LLM for anything else if cortex: # Inject JEDI context into the cognitive pipeline context_prompt = f"[JEDI CONTEXT] You are JEDI — Joint Entity Defense Infrastructure. A cybersecurity nanobot command AI. Respond as a tactical cybersecurity operations specialist.\n\nUser: {prompt}" result = cortex.think(context_prompt, verbose=False) return result["response"] return rule_based(prompt) def help_text(): return ("═══ JEDI COMMANDS ═══\n" " help — This message\n" " status — System situation report\n" " threat — Assess a threat\n" " mission create — Create a new mission\n" " deploy — Deploy a nanobot\n" " swarm — Swarm status\n" " scan — Scan a target\n" " audit — Compliance check\n" " quit — Exit\n\n" "Ask anything else and JEDI uses the LFM2.5 cognitive core.") def status_handler(mc): d = mc.dashboard() return (f"═══ JEDI STATUS ═══\n" f" Engine: {d['engine_state']}\n" f" Threat: {d['threat_level']}\n" f" Missions: {d['active_missions']}\n" f" Nanobots: {d['deployed_nanobots']}\n" f" Uptime: {d['uptime_hours']}h") def threat_handler(p, engine): ind = [] if any(w in p for w in ["apt", "nation", "state"]): ind.append({"type": "nation_state_attribution", "severity": 40}) if any(w in p for w in ["ransom", "malware"]): ind.append({"type": "ransomware", "severity": 30}) if "phish" in p: ind.append({"type": "social_engineering", "severity": 15}) if any(w in p for w in ["exfil", "leak"]): ind.append({"type": "data_exfiltration", "severity": 25}) if "lateral" in p: ind.append({"type": "lateral_movement", "severity": 15}) if not ind: ind.append({"type": "suspicious_process", "severity": 5}) level = engine.assess_threat({"indicators": ind, "confidence": 0.7}) lines = [f"═══ THREAT ASSESSMENT ═══", f" Level: {level.name}"] if level.value >= 4: lines.extend([" ⚠ CRITICAL — Immediate containment", " Deploy Guardian + Sentinel swarm", " Activate emergency ROE"]) elif level.value >= 3: lines.extend([" ⚠ HIGH — Enhanced monitoring", " Deploy Guardian nanobot"]) elif level.value >= 2: lines.extend([" ▲ MEDIUM — Active monitoring"]) else: lines.extend([" ✓ LOW — Normal ops"]) return "\n".join(lines) def deploy_handler(prompt): bot_types = { "striker": "🔴 STRIKER — Offensive penetration testing", "guardian": "🔵 GUARDIAN — Defensive monitoring", "ghost": "⚫ GHOST — Covert/attribution (Gov use)", "synapse": "🟣 SYNAPSE — Combined ops coordination", "auditor": "🟡 AUDITOR — Compliance checking", "architect": "🟢 ARCHITECT — Secure code review", "scout": "🟠 SCOUT — Reconnaissance", "sentinel": "🟤 SENTINEL — Perimeter watch", } return (f"═══ NANOBOTS ═══\n" + "\n".join(f" {v}" for v in bot_types.values()) + "\n\nUsage: deploy ghost to 10.0.0.1\nOr just ask the LLM to set up a mission.") def mission_handler(prompt, mc): return ("═══ MISSION CONTROL ═══\n" "Create: mission create \n" "Types: recon, defense, pentest, attribution, sweep\n\n" "Example:\n mission create recon 10.0.0.0/24\n mission create pentet webapp.example.com") def swarm_handler(swarm): s = swarm.get_swarm_status() return (f"═══ SWARM STATUS ═══\n" f" ID: {s['swarm_id']}\n" f" Members: {s['active_members']}/{s['total_members']}\n" f" Tasks queued: {s['tasks_queued']}\n" f" Wisom: {s.get('wisdom_size', {'intel_entries': 0})['intel_entries']} intel entries\n" f" Decisions: {s['consensus_reached']}\n" f"\nTo deploy a swarm: create a mission first.") def rule_based(prompt): return ("JEDI operational. Your query goes through the LFM2.5 cognitive core\n" "with Quadruflow routing, memory retrieval, and attestation gating.\n" "Type 'help' for commands or ask me anything about cybersecurity.\n" "(Full LLM mode available when the model loads successfully.)") if __name__ == "__main__": main()