diff --git a/scripts/fix_table_prompt.py b/scripts/fix_table_prompt.py deleted file mode 100644 index ab0f20d..0000000 --- a/scripts/fix_table_prompt.py +++ /dev/null @@ -1,45 +0,0 @@ -import sqlite3 -import os - -db_path = "/Users/axieyangb/Project/CortexAI/ai-hub/data/ai_hub.db" - -if not os.path.exists(db_path): - print(f"Error: DB not found at {db_path}") - exit(1) - -conn = sqlite3.connect(db_path) -cursor = conn.cursor() - -# Get the monitor template -cursor.execute("SELECT id, system_prompt_content FROM agent_templates WHERE name LIKE '%monitor%' OR name LIKE '%Technical%'") -templates = cursor.fetchall() - -table_instruction = """ -IMPORTANT FORMATTING RULES: -When providing system status or technical reports, ALWAYS use standard GitHub Flavored Markdown (GFM) tables. -- Each row MUST be on a new line. -- You MUST include the separator row (e.g., |---|---|---|) immediately after the header. -- Do NOT skip newlines between table rows. -- Ensure proper alignment and vertical padding. - -Example: -| Component | Status | Notes | -| :--- | :--- | :--- | -| Connectivity | ACTIVE | Responsive via gRPC | -| CPU | 15% | Nominal | -""" - -for tid, content in templates: - if content: - if "IMPORTANT FORMATTING RULES" not in content: - new_content = content + "\n\n" + table_instruction - cursor.execute("UPDATE agent_templates SET system_prompt_content = ? WHERE id = ?", (new_content, tid)) - print(f"Updated template {tid}") - else: - # Fallback if content is null - cursor.execute("UPDATE agent_templates SET system_prompt_content = ? WHERE id = ?", (table_instruction, tid)) - print(f"Initialized template {tid} with instruction") - -conn.commit() -conn.close() -print("Done.") diff --git a/scripts/get_user.py b/scripts/get_user.py deleted file mode 100644 index 1d7a304..0000000 --- a/scripts/get_user.py +++ /dev/null @@ -1,13 +0,0 @@ -import os -import sqlite3 - -def get_db(): - db = sqlite3.connect("ai-hub/data/ai_hub.db") - cur = db.cursor() - cur.execute("SELECT id, email, role, group_id FROM users") - for row in cur.fetchall(): - print(row) - db.close() - -get_db() - diff --git a/scripts/migrate_skills_to_fs.py b/scripts/migrate_skills_to_fs.py deleted file mode 100644 index 59d8e1e..0000000 --- a/scripts/migrate_skills_to_fs.py +++ /dev/null @@ -1,97 +0,0 @@ -import os -import sys -import json -import logging -from sqlalchemy import create_engine -from sqlalchemy.orm import sessionmaker - -# Add the ai-hub to sys.path -sys.path.insert(0, '/app') -from app.db.models import Skill, SkillFile -from app.config import settings - -logging.basicConfig(level=logging.INFO) -logger = logging.getLogger(__name__) - -# The new unified skills directory -BASE_DATA_DIR = "/app/data" -SKILLS_DIR = os.path.join(BASE_DATA_DIR, "skills") -logger.info(f"Target Skills Directory: {SKILLS_DIR}") - -def migrate(): - # Setup Database Connection - db_url = settings.DATABASE_URL - if not db_url: - logger.error("DATABASE_URL is not set!") - sys.exit(1) - - engine = create_engine(db_url) - Session = sessionmaker(bind=engine) - session = Session() - - try: - skills = session.query(Skill).all() - logger.info(f"Found {len(skills)} skills in the database. Starting migration...") - - os.makedirs(SKILLS_DIR, exist_ok=True) - - for skill in skills: - # 1. Determine Feature Parent Directory (default to 'swarm_control' if none) - feature = "swarm_control" - if skill.features and isinstance(skill.features, list) and len(skill.features) > 0: - feature = skill.features[0] - elif isinstance(skill.features, str): - try: - features_list = json.loads(skill.features) - if features_list: feature = features_list[0] - except: - feature = skill.features - - # Slugify the skill name for the folder - slug = skill.name.replace(" ", "_").lower() - - # Target path: /app/data/skills/swarm_control/get_weather/ - target_path = os.path.join(SKILLS_DIR, feature, slug) - os.makedirs(target_path, exist_ok=True) - - logger.info(f"Migrating Skill '{skill.name}' -> {target_path}") - - # 2. Write Virtual Files - skill_md_content = None - has_files = False - for sf in skill.files: - has_files = True - file_abs_path = os.path.join(target_path, sf.file_path) - os.makedirs(os.path.dirname(file_abs_path), exist_ok=True) - with open(file_abs_path, "w") as f: - f.write(sf.content or "") - - if sf.file_path == "SKILL.md": - skill_md_content = sf.content - - # If it didn't have a SKILL.md for some reason but has an old-style description: - if not skill_md_content: - logger.warning(f"Skill '{skill.name}' had no SKILL.md. Generating one...") - with open(os.path.join(target_path, "SKILL.md"), "w") as f: - f.write(f"### Skill Name: {skill.name}\n\n{skill.description or 'No description provided.'}\n") - - # 3. Write Invisible Metadata File (.metadata.json) - # This handles access control and legacy UI metadata properties - metadata = { - "owner_id": skill.owner_id, - "is_system": skill.is_system, - "id": skill.id, # keep track just in case - "extra_metadata": skill.extra_metadata or {"emoji": "🛠️"} - } - with open(os.path.join(target_path, ".metadata.json"), "w") as f: - json.dump(metadata, f, indent=4) - - logger.info("Migration strictly to File System completed perfectly!") - - except Exception as e: - logger.error(f"Migration Failed: {e}") - finally: - session.close() - -if __name__ == "__main__": - migrate() diff --git a/scripts/test_node.py b/scripts/test_node.py deleted file mode 100644 index 834377c..0000000 --- a/scripts/test_node.py +++ /dev/null @@ -1,36 +0,0 @@ -import sys -import os -from agent_node.skills.shell_bridge import ShellSkill - -class DummySync: - def get_session_dir(self, sid): - return "/tmp" - -class DummySandbox: - def verify(self, cmd): - return True, "OK" - @property - def policy(self): - return {} - -def main(): - s = ShellSkill(sync_mgr=DummySync()) - class Task: - task_id = "t1" - payload_json = "pwd\n" - session_id = "s1" - trace_id = "tr1" - timeout_ms = 5000 - - def on_event(msg): - print("ON_EVENT:", msg) - - def on_complete(tid, res, tr): - print("ON_COMPLETE:", res) - - s.execute(Task(), DummySandbox(), on_complete, on_event) - import time - time.sleep(2) - -if __name__ == '__main__': - main() diff --git a/scripts/test_proto.py b/scripts/test_proto.py deleted file mode 100644 index e6dc34a..0000000 --- a/scripts/test_proto.py +++ /dev/null @@ -1,11 +0,0 @@ -import sys -sys.path.append("/app/agent-node") -from protos import agent_pb2 - -event = agent_pb2.ClientTaskMessage(skill_event=agent_pb2.SkillEvent()) -print("Created msg") -try: - wrapped = agent_pb2.ClientTaskMessage(browser_event=event) - print("Wrapped!") -except Exception as e: - print("Exception:", type(e), e) diff --git a/scripts/test_ws.js b/scripts/test_ws.js deleted file mode 100644 index 08e4269..0000000 --- a/scripts/test_ws.js +++ /dev/null @@ -1,31 +0,0 @@ -const WebSocket = require('ws'); - -const ws = new WebSocket('wss://ai.jerxie.com/api/v1/nodes/test-prod-node/stream'); - -ws.on('open', function open() { - console.log('connected, waiting for events...'); -}); - -ws.on('message', function incoming(data) { - const msg = JSON.parse(data); - if (msg.event !== 'heartbeat') { - console.log('[EVENT]', msg.event, JSON.stringify(msg.data)); - } - if (msg.event === 'task_complete' || msg.event === 'task_error') { - process.exit(0); - } -}); - -// Also dispatch a command -setTimeout(async () => { - const http = require('https'); - const body = JSON.stringify({ command: 'uname -a; id; pwd', timeout_ms: 15000 }); - const req = http.request({ - hostname: 'ai.jerxie.com', path: '/api/v1/nodes/test-prod-node/dispatch', - method: 'POST', headers: {'Content-Type': 'application/json', 'X-User-ID': '9a333ccd-9c3f-432f-a030-7b1e1284a436', 'Content-Length': body.length} - }, res => { let data = ''; res.on('data', d => data += d); res.on('end', () => console.log('[DISPATCH]', data)); }); - req.write(body); - req.end(); -}, 1000); - -setTimeout(() => { console.log('timeout'); process.exit(1); }, 20000);