diff --git a/agent-node/src/agent_node/skills/shell_bridge.py b/agent-node/src/agent_node/skills/shell_bridge.py index b71fd22..90383d5 100644 --- a/agent-node/src/agent_node/skills/shell_bridge.py +++ b/agent-node/src/agent_node/skills/shell_bridge.py @@ -205,18 +205,17 @@ decoded = STRIP_START_FENCE.sub('', decoded) decoded = STRIP_BRACKET_FENCE.sub('', decoded) - # Strip Windows internals: title-set escape sequences, bat call/del lines - clean_no_ansi = ANSI_ESCAPE.sub('', decoded) - clean_no_ansi = WIN_TITLE_RE.sub('', clean_no_ansi) - clean_no_ansi = BAT_CALL_RE.sub('', clean_no_ansi) - clean_no_ansi = DEL_RE.sub('', clean_no_ansi) + # Strip Windows internals but preserve core ANSI codes for the interactive UI + clean_live = WIN_TITLE_RE.sub('', decoded) + clean_live = BAT_CALL_RE.sub('', clean_live) + clean_live = DEL_RE.sub('', clean_live) # Line-Aware Stealthing for extra safety (protocol fence markers) - lines = clean_no_ansi.splitlines(keepends=True) + lines = clean_live.splitlines(keepends=True) clean_lines = [line for line in lines if not PROTOCOL_HINT_PATTERN.search(line)] stealth_out = "".join(clean_lines) - if stealth_out.strip(): + if stealth_out: with self.lock: self._apply_stream_throttling(sess, session_id, stealth_out, on_event) self._detect_edge_prompts(sess, session_id, active_tid, on_event) diff --git a/tmp/swarm/responses/res_req_df9eb05f.json b/tmp/swarm/responses/res_req_df9eb05f.json deleted file mode 100644 index 44b8483..0000000 --- a/tmp/swarm/responses/res_req_df9eb05f.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "request_id": "req_df9eb05f", - "status": "success", - "output": " \u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588 \u2588\u2588 \u2588\u2588 \u2588\u2588\n \u2588\u2588 \u2588\u2588 \u2588\u2588 \u2588\u2588 \u2588\u2588 \u2588\u2588 \u2588\u2588\n \u2588\u2588 \u2588\u2588\u2588\u2588 \u2588\u2588 \u2588\u2588\u2588 \u2588\u2588\u2588\u2588 \u2588\u2588 \u2584\n \u2588\u2588 \u2588\u2588 \u2588\u2588 \u2588\u2588 \u2588\u2588 \u2588\u2588 \u2588\u2588 \u2588\u2588 Version 2026.04.03 \u2588\n \u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588 \u2588\u2588 \u2588\u2588\u2588\u2588 \u2588\u2588 \u2588\u2588 \u2588\u2588 jerxie@google.com (Pro) \u2588\n \u2588\n Workspace: ~/Projects/PersonalProject/cortex- \u2588\n hub/swarm_framework/agents/agent_1 \u2588\n Model: Gemini Next \u2588\n Conversation: 176b68f7-7106-40b2-ba22-1f48bdf11cb9 \u2588\n \u2588\n \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 \u2588\n > echo hello \u2588\n \u2588\n \u25b8 Thought for 1s, 859 tokens \u2588\n The user wants me to run the command `echo hello`. \u2588\n \u2588\n \u25cf Bash(echo hello) (ctrl+o to expand) \u2580\n \u28fe Running...\n \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n >\n \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nEsc to cancel Gemini Next\n\n" -} \ No newline at end of file diff --git a/tmp/swarm/responses/test_res_1.json b/tmp/swarm/responses/test_res_1.json deleted file mode 100644 index db8a00b..0000000 --- a/tmp/swarm/responses/test_res_1.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "request_id": "test_req_1", - "status": "success", - "output": " expand)\n\n \u25b8 Thought for 1s, 230 tokens\t\n Okay, I see the directory listing. Nothing immediately stands out as \"conv\". The...\n I'm not sure what you mean by \"conv\". Could you please clarify?\n\n Are you referring to:\n\n 1. Conversation history (viewing or resuming a past conversation)?\n 2. A specific command or abbreviation in your project? \u2584\n 3. Something else? \u2588\n \u2588\n I can see the list of recent conversations in the context (ranging from \"Agent \u2588\n Capability Inquiry\" to \"Integrating Internal ABM Specs\"). If you'd like to refer to one \u2588\n of those, please let me know which one! \u2580\n\n \u2503 /btw test message\n \u2503\n \u2503 Hello! I have received your test message. I am here and ready to assist you. Please\n \u2503 let me know what you need help with or what task you would like to work on!\n \u2503 Tab to expand \u00b7 Space/Enter/Esc to dismiss\n \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n >\n \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n ? for shortcuts Gemini Next\n\n" -} \ No newline at end of file diff --git a/tmp/swarm/responses/test_res_2.json b/tmp/swarm/responses/test_res_2.json deleted file mode 100644 index e0ee79c..0000000 --- a/tmp/swarm/responses/test_res_2.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "request_id": "test_req_2", - "status": "success", - "output": "\n \u2022 0817f48e-0f6b-4e14-8501-1ea192ee44f1: Agent Capability Inquiry (2026-04-06)\n \u2022 b9c082ef-4452-4936-9f55-8033fa44a417: Automating Integration Test Resolution (2026-04-\n 06)\n \u2022 fa38997c-40e5-40be-bb0c-3065be498a62: Reviewing And Fixing Documentation (2026-04-06)\n \u2022 6f1106f4-5141-4501-9c37-e3440b8b83aa: Fixing Integration Test Failures (2025-12-05)\n \u2022 cb5ab337-1d10-4fb0-971e-5e8e027235e6: Analyzing MKS Feature Gate Logic (2026-04-03)\n \u2022 5b537bcd-49be-4a00-9ce2-74463c8a1c27: Extracting Google Doc Comments (2026-04-02)\n \u2022 4ba38f09-adbf-494a-aa4e-c2dac1c9ac6a: Implementing MKS Versioning Decoupling (2026-04-\n 02) \u2584\n \u2022 a5443dbf-bd66-427e-a859-c93bbb99cb10: Implementing MKS Feature Gates (2026-04-01) \u2588\n \u2022 fb24440c-f5d0-4292-802c-0412f31bea83: Integrating Internal ABM Specs (2026-04-01) \u2588\n \u2588\n Please let me know if you would like to retrieve information from any of these past \u2588\n conversations. You can refer to them by their ID or title.* \u2580\n\n \u2503 /btw hello from agent 2\n \u2503\n \u2503 Hello Agent 2! How can I assist you today? Feel free to share the task or question\n \u2503 you are working on.\n \u2503 Tab to expand \u00b7 Space/Enter/Esc to dismiss\n \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n >\n \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n ? for shortcuts Gemini Next\n\n" -} \ No newline at end of file diff --git a/tmp/swarm/responses/test_res_3.json b/tmp/swarm/responses/test_res_3.json deleted file mode 100644 index 8fb4873..0000000 --- a/tmp/swarm/responses/test_res_3.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "request_id": "test_req_3", - "status": "success", - "output": "\n \u25cf ListDir(/usr/local/google/home/jerxie/Projects/PersonalProject/corte...) (ctrl+o to\n expand)\n\n \u25b8 Thought for 1s, 222 tokens\n I listed the directory contents. I don't see anything named `conv` or obviously ...\n Could you please clarify what you mean by conv ?\n \u2584\n Are you referring to the conversation history, or is it a specific command or file you'd\u2588\n like me to look at? I've listed the root directory and didn't find an obvious match. \u2580\n\n \u2503 /btw hello from agent 3\n \u2503\n \u2503 Hello Agent 3! I am currently operating in the cortex-hub environment. Based on\n \u2503 the project context, recent work here has focused on resolving integration test\n \u2503 failures, updating documentation in the docs/reviews/ directory, and implementing\n \u2503 feature gates for Managed Kubernetes Service (MKS) versioning decoupling.\n \u2503\n \u2503 Please let me know how we can collaborate or what information you need regarding\n \u2503 these tasks.\n \u2503 Tab to expand \u00b7 Space/Enter/Esc to dismiss\n \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n >\n \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n ? for shortcuts Gemini Next\n\n" -} \ No newline at end of file diff --git a/tmp/swarm/responses/test_res_4.json b/tmp/swarm/responses/test_res_4.json deleted file mode 100644 index d4a12af..0000000 --- a/tmp/swarm/responses/test_res_4.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "request_id": "test_req_4", - "status": "success", - "output": " \u2022 Extracting Google Doc Comments (5b537bcd-49be-4a00-9ce2-74463c8a1c27)\t\t\t\n \u2022 Implementing MKS Versioning Decoupling (4ba38f09-adbf-494a-aa4e-c2dac1c9ac6a)\n \u2022 Summary: Refactoring version structures to establish feature-gating mechanism.\n \u2022 Implementing MKS Feature Gates (a5443dbf-bd66-427e-a859-c93bbb99cb10)\t\t\t\n \u2022 Summary: Refining feature gating for MKS bare-metal release assets.\t\t\t\n \u2022 Integrating Internal ABM Specs (fb24440c-f5d0-4292-802c-0412f31bea83)\t\t\t\n \u2022 Summary: Decoupling MKS ABM versioning by updating build configuration.\n\n\n Please let me know if you would like to continue or reference any of these, or start a\n new topic.\n \u2500\u2500\u2500\u2500\u2500\u2500 \u2584\n Summary of work: Listed recent conversations after the user skipped the selection \u2588\n prompt.*** \u2580\n\n \u2503 /btw hello from agent 4\n \u2503\n \u2503 Hello! I acknowledge the greeting from Agent 4. Please let me know what you would\n \u2503 like to coordinate on or how I can assist you regarding our current tasks or\n \u2503 conversation history.\n \u2503 Tab to expand \u00b7 Space/Enter/Esc to dismiss\n \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n >\n \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n ? for shortcuts Gemini Next\n\n" -} \ No newline at end of file diff --git a/tmp/swarm/scripts/swarm_aligner.py b/tmp/swarm/scripts/swarm_aligner.py deleted file mode 100644 index 0105a92..0000000 --- a/tmp/swarm/scripts/swarm_aligner.py +++ /dev/null @@ -1,80 +0,0 @@ -import os -import subprocess -import time - -SESSION_NAME = "jetski_swarm" - -def get_windows(): - cmd = f"tmux list-windows -t {SESSION_NAME} -F '#I:#W'" - result = subprocess.run(cmd, shell=True, capture_output=True, text=True) - if result.returncode != 0: - print("Error listing windows. Is tmux running?") - return [] - return result.stdout.strip().split('\n') - -def capture_pane(window_id): - cmd = f"tmux capture-pane -p -t {SESSION_NAME}:{window_id}" - result = subprocess.run(cmd, shell=True, capture_output=True, text=True) - return result.stdout - -def send_keys(window_id, keys): - cmd = f"tmux send-keys -t {SESSION_NAME}:{window_id} {keys}" - subprocess.run(cmd, shell=True) - -def main(): - windows = get_windows() - if not windows: - return - - for win in windows: - if not win: - continue - try: - win_id, win_name = win.split(':') - except ValueError: - continue - - # Skip master and orchestrator if we want to focus on agents - if win_name in ["master", "orchestrator"]: - continue - - print(f"\n========================================") - print(f"Targeting Window: {win_id} ({win_name})") - print(f"========================================") - - while True: - output = capture_pane(win_id) - lines = output.split('\n') - # Show last 10 lines - print("\n".join(lines[-10:])) - print("----------------------------------------") - - print("Commands: [u] Up, [d] Down, [e] Enter, [n] Next Agent, [q] Quit") - print("Or type a string to send as keys.") - - try: - choice = input("Choice: ").strip() - except EOFError: - print("No interactive terminal. Exiting.") - return - - if choice == 'u': - send_keys(win_id, "Up") - elif choice == 'd': - send_keys(win_id, "Down") - elif choice == 'e': - send_keys(win_id, "Enter") - elif choice == 'n': - print("Moving to next agent.") - break - elif choice == 'q': - print("Quitting.") - return - elif choice: - # Send text - send_keys(win_id, f"\"{choice}\"") - - time.sleep(1) # Give time for screen to update - -if __name__ == "__main__": - main() diff --git a/tmp/swarm/scripts/swarm_auto_aligner.py b/tmp/swarm/scripts/swarm_auto_aligner.py deleted file mode 100644 index 73f1819..0000000 --- a/tmp/swarm/scripts/swarm_auto_aligner.py +++ /dev/null @@ -1,104 +0,0 @@ -import os -import subprocess -import time -import re - -SESSION_NAME = "jetski_swarm" - -def get_windows(): - cmd = f"tmux list-windows -t {SESSION_NAME} -F '#I:#W'" - result = subprocess.run(cmd, shell=True, capture_output=True, text=True) - if result.returncode != 0: - print("Error listing windows. Is tmux running?") - return [] - return result.stdout.strip().split('\n') - -def get_panes(window_id): - cmd = f"tmux list-panes -t {SESSION_NAME}:{window_id} -F '#P'" - result = subprocess.run(cmd, shell=True, capture_output=True, text=True) - if result.returncode != 0: - return [] - return result.stdout.strip().split('\n') - -def capture_pane(target): - cmd = f"tmux capture-pane -p -t {SESSION_NAME}:{target}" - result = subprocess.run(cmd, shell=True, capture_output=True, text=True) - return result.stdout - -def send_keys(target, keys): - cmd = f"tmux send-keys -t {SESSION_NAME}:{target} {keys}" - subprocess.run(cmd, shell=True) - -def analyze_and_respond(target, content): - # Heuristic 1: File Access Prompt - if "Allow access to this file?" in content: - print(f"Detected File Access prompt in target {target}") - # Search for "always allow" - match = re.search(r"([0-9]+)\..*always allow.*", content, re.IGNORECASE) - if match: - option = match.group(1) - print(f"Found 'always allow' option: {option}. Sending...") - send_keys(target, f"{option} Enter") - return True - else: - # Fallback to option 2 if not found but prompt exists - print("Could not find specific 'always allow' option. Defaulting to 2.") - send_keys(target, "2 Enter") - return True - - # Heuristic 2: Confirmation Prompt [y/n] - if re.search(r"\[y/n\]", content, re.IGNORECASE): - print(f"Detected [y/N] prompt in target {target}") - send_keys(target, "y Enter") - return True - - # Heuristic 3: Confirmation Prompt with default Yes [Y/n] - if re.search(r"\[Y/n\]", content): - print(f"Detected [Y/n] prompt in target {target}") - send_keys(target, "y Enter") - return True - - return False - -def process_target(target): - # Poll a few times to give it a chance to settle or show prompt - for _ in range(3): - content = capture_pane(target) - if analyze_and_respond(target, content): - # Wait a bit after sending keys for screen to update - time.sleep(2) - return True - time.sleep(1) - return False - -def main(): - print("Starting Advanced Swarm Auto Aligner...") - windows = get_windows() - if not windows: - return - - for win in windows: - if not win: - continue - try: - win_id, win_name = win.split(':') - except ValueError: - continue - - # Skip orchestrator - if win_name in ["orchestrator"]: - continue - - print(f"Checking Window: {win_id} ({win_name})") - - if win_name == "grid": - panes = get_panes(win_id) - for pane in panes: - target = f"{win_id}.{pane}" - print(f"Checking Grid Pane: {target}") - process_target(target) - else: - process_target(win_id) - -if __name__ == "__main__": - main() diff --git a/tmp/swarm/scripts/swarm_cli.py b/tmp/swarm/scripts/swarm_cli.py deleted file mode 100644 index 7fceff6..0000000 --- a/tmp/swarm/scripts/swarm_cli.py +++ /dev/null @@ -1,72 +0,0 @@ -import os -import time -import json -import argparse -import uuid - -BASE_DIR = "/usr/local/google/home/jerxie/Projects/PersonalProject/cortex-hub/tmp/swarm" -REQUESTS_DIR = os.path.join(BASE_DIR, "requests") -RESPONSES_DIR = os.path.join(BASE_DIR, "responses") - -def main(): - parser = argparse.ArgumentParser(description="Swarm CLI") - parser.add_argument("--target", required=True, help="Target agent") - parser.add_argument("--prompt", required=True, help="Instruction prompt") - parser.add_argument("--mode", choices=["normal", "yolo"], default="normal", help="Mode: normal or yolo") - - args = parser.parse_args() - - req_id = f"req_{uuid.uuid4().hex[:8]}" - resp_file = os.path.join(RESPONSES_DIR, f"res_{req_id}.json") - - req_data = { - "request_id": req_id, - "target_agent": args.target, - "prompt": args.prompt, - "response_file": resp_file - } - - print(f"Target: {args.target}") - print(f"Prompt: {args.prompt}") - print(f"Mode: {args.mode}") - - if args.mode == "normal": - try: - confirm = input("Are you sure you want to send this command? [y/N]: ") - if confirm.lower() != 'y': - print("Aborted.") - return - except EOFError: - print("No interactive terminal found, aborting in normal mode.") - return - - os.makedirs(REQUESTS_DIR, exist_ok=True) - req_file = os.path.join(REQUESTS_DIR, f"{req_id}.json") - - with open(req_file, 'w') as f: - json.dump(req_data, f, indent=2) - - print(f"Request {req_id} sent.") - print(f"Waiting for response in {resp_file}...") - - # Wait for response - start_time = time.time() - timeout = 30 # seconds - while time.time() - start_time < timeout: - if os.path.exists(resp_file): - print("Response received:") - try: - with open(resp_file, 'r') as f: - resp = json.load(f) - print(resp.get("output")) - return - except json.JSONDecodeError: - # File might be still being written - time.sleep(0.5) - continue - time.sleep(1) - - print("Timed out waiting for response.") - -if __name__ == "__main__": - main() diff --git a/tmp/swarm/scripts/swarm_orchestrator.py b/tmp/swarm/scripts/swarm_orchestrator.py deleted file mode 100644 index 3449238..0000000 --- a/tmp/swarm/scripts/swarm_orchestrator.py +++ /dev/null @@ -1,77 +0,0 @@ -import os -import time -import json -import subprocess - -BASE_DIR = "/usr/local/google/home/jerxie/Projects/PersonalProject/cortex-hub/tmp/swarm" -REQUESTS_DIR = os.path.join(BASE_DIR, "requests") -RESPONSES_DIR = os.path.join(BASE_DIR, "responses") -SESSION_NAME = "jetski_swarm" - -def process_request(file_path): - try: - with open(file_path, 'r') as f: - req = json.load(f) - - req_id = req.get("request_id") - target = req.get("target_agent") - prompt = req.get("prompt") - resp_file = req.get("response_file") - - # Mapping for Grid layout - if target.startswith("agent_"): - try: - agent_num = int(target.split("_")[1]) - target = f"grid.{agent_num - 1}" - print(f"Mapped {req.get('target_agent')} to {target}") - except ValueError: - pass - - print(f"Processing {req_id} for {target}...") - - # Send keys - cmd = f"tmux send-keys -t {SESSION_NAME}:{target} \"{prompt}\" C-m" - subprocess.run(cmd, shell=True, check=True) - - # Wait for agent to process (simple wait for now) - time.sleep(5) - - # Capture pane - cap_cmd = f"tmux capture-pane -p -t {SESSION_NAME}:{target}" - result = subprocess.run(cap_cmd, shell=True, capture_output=True, text=True, check=True) - - # Write response - resp_data = { - "request_id": req_id, - "status": "success", - "output": result.stdout - } - - # Ensure target file directory exists - os.makedirs(os.path.dirname(resp_file), exist_ok=True) - - with open(resp_file, 'w') as f: - json.dump(resp_data, f, indent=2) - - # Delete request - os.remove(file_path) - print(f"Completed {req_id}") - - except Exception as e: - print(f"Error processing {file_path}: {e}") - -def main(): - print("Swarm Orchestrator started polling...") - while True: - try: - files = os.listdir(REQUESTS_DIR) - for file in files: - if file.endswith(".json"): - file_path = os.path.join(REQUESTS_DIR, file) - process_request(file_path) - except Exception as e: - print(f"Polling error: {e}") - time.sleep(2) - -if __name__ == "__main__": - main()