Some checks failed
Architecture Lint / Linter Tests (pull_request) Successful in 8s
Validate Config / YAML Lint (pull_request) Failing after 5s
Validate Config / JSON Validate (pull_request) Successful in 6s
PR Checklist / pr-checklist (pull_request) Failing after 1m11s
Smoke Test / smoke (pull_request) Failing after 7s
Validate Config / Python Syntax & Import Check (pull_request) Failing after 9s
Validate Config / Shell Script Lint (pull_request) Successful in 15s
Validate Config / Cron Syntax Check (pull_request) Successful in 5s
Validate Config / Deploy Script Dry Run (pull_request) Successful in 5s
Validate Config / Playbook Schema Validation (pull_request) Successful in 7s
Architecture Lint / Lint Repository (pull_request) Failing after 6s
66 lines
1.8 KiB
Python
66 lines
1.8 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
[OPS] Agent Dispatch Framework
|
|
Part of the Gemini Sovereign Infrastructure Suite.
|
|
|
|
Replaces ad-hoc dispatch scripts with a unified framework for tasking agents.
|
|
"""
|
|
|
|
import os
|
|
import sys
|
|
import argparse
|
|
|
|
SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
|
|
if SCRIPT_DIR not in sys.path:
|
|
sys.path.insert(0, SCRIPT_DIR)
|
|
|
|
from ssh_trust import VerifiedSSHExecutor
|
|
|
|
# --- CONFIGURATION ---
|
|
FLEET = {
|
|
"allegro": "167.99.126.228",
|
|
"bezalel": "159.203.146.185"
|
|
}
|
|
|
|
class Dispatcher:
|
|
def __init__(self, executor=None):
|
|
self.executor = executor or VerifiedSSHExecutor()
|
|
|
|
def log(self, message: str):
|
|
print(f"[*] {message}")
|
|
|
|
def dispatch(self, host: str, agent_name: str, task: str):
|
|
self.log(f"Dispatching task to {agent_name} on {host}...")
|
|
|
|
ip = FLEET[host]
|
|
|
|
try:
|
|
res = self.executor.run(
|
|
ip,
|
|
['python3', 'run_agent.py', '--agent', agent_name, '--task', task],
|
|
cwd='/opt/hermes',
|
|
timeout=30,
|
|
)
|
|
if res.returncode == 0:
|
|
self.log(f"[SUCCESS] {agent_name} completed task.")
|
|
print(res.stdout)
|
|
else:
|
|
self.log(f"[FAILURE] {agent_name} failed task.")
|
|
print(res.stderr)
|
|
except Exception as e:
|
|
self.log(f"[ERROR] Dispatch failed: {e}")
|
|
|
|
def main():
|
|
parser = argparse.ArgumentParser(description="Gemini Agent Dispatcher")
|
|
parser.add_argument("host", choices=list(FLEET.keys()), help="Host to dispatch to")
|
|
parser.add_argument("agent", help="Agent name")
|
|
parser.add_argument("task", help="Task description")
|
|
|
|
args = parser.parse_args()
|
|
|
|
dispatcher = Dispatcher()
|
|
dispatcher.dispatch(args.host, args.agent, args.task)
|
|
|
|
if __name__ == "__main__":
|
|
main()
|