| Server IP : 85.155.190.233 / Your IP : 216.73.216.103 Web Server : nginx/1.24.0 System : Linux antigravity-cli 6.8.0-31-generic #31-Ubuntu SMP PREEMPT_DYNAMIC Sat Apr 20 00:40:06 UTC 2024 x86_64 User : wp-moonbloom ( 1001) PHP Version : 8.3.6 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /opt/Gemini_Swarm_Core/scripts/ |
Upload File : |
import os
import sys
from pathlib import Path
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
import _ssh
# Calculate local root directory dynamically
SCRIPTS_DIR = Path(__file__).resolve().parent
LOCAL_DIR = SCRIPTS_DIR.parent
WORKSPACE_ROOT = LOCAL_DIR.parent
REMOTE_DIR = "/opt/Gemini_Swarm_Core"
REMOTE_AGENTS_DIR = "/opt/Gemini_Swarm_Core/.agents"
IGNORED_DIRS = {".git", "node_modules", "__pycache__", "venv"}
IGNORED_FILES = {
".env", ".env.local",
# deploy/setup scripts — never needed on VPS
"deploy_vps.py", "deploy_gemini_creds.py", "deploy_gcp_credentials.py",
"setup_vps.py", "setup_remote_bridge.py", "setup_swarm_cli.py",
# local SSH helpers — VPS has no use for these
"_ssh.py",
# debug/test scripts — local only
"intercept_gemini_fetch.py", "debug_cli_network.py",
"test_direct_oauth.py", "test_sdk_oauth.py", "test_gemini.py",
"test_tokeninfo.py", "test_vertex_on_googleai.py", "check_cli_token.py",
"run_remote.py", "read_session_log.py",
}
def upload_tree(sftp, local_root: Path, remote_root: str, label: str) -> None:
for root, dirs, files in os.walk(local_root):
dirs[:] = [d for d in dirs if d not in IGNORED_DIRS]
rel_path = os.path.relpath(root, local_root)
remote_subdir = remote_root if rel_path == "." else (remote_root + "/" + rel_path.replace("\\", "/"))
try:
sftp.mkdir(remote_subdir)
except IOError:
pass
for fname in files:
if fname in IGNORED_FILES or fname.endswith((".pyc", ".log")):
continue
local_file = os.path.join(root, fname)
remote_file = remote_subdir + "/" + fname
_ssh.safe_print(f" [{label}] {os.path.relpath(local_file, local_root)} -> {remote_file}")
sftp.put(local_file, remote_file)
def deploy() -> None:
try:
client = _ssh.connect()
except Exception:
return
_ssh.safe_print("Connected. Uploading files...")
sftp = client.open_sftp()
try:
sftp.mkdir(REMOTE_DIR)
except IOError:
pass
# Upload Gemini_Swarm_Core/
upload_tree(sftp, LOCAL_DIR, REMOTE_DIR, "core")
# Upload .agents/plugins/ → /opt/Gemini_Swarm_Core/.agents/plugins/
plugins_local = WORKSPACE_ROOT / ".agents" / "plugins"
if plugins_local.exists():
_ssh.safe_print("Uploading .agents/plugins/...")
plugins_remote = REMOTE_AGENTS_DIR + "/plugins"
try:
sftp.mkdir(REMOTE_AGENTS_DIR)
except IOError:
pass
try:
sftp.mkdir(plugins_remote)
except IOError:
pass
upload_tree(sftp, plugins_local, plugins_remote, "plugins")
else:
_ssh.safe_print("No .agents/plugins/ found locally — skipping.")
# Upload .agents/skills/ → /opt/Gemini_Swarm_Core/.agents/skills/
skills_local = WORKSPACE_ROOT / ".agents" / "skills"
if skills_local.exists():
_ssh.safe_print("Uploading .agents/skills/...")
skills_remote = REMOTE_AGENTS_DIR + "/skills"
try:
sftp.mkdir(REMOTE_AGENTS_DIR)
except IOError:
pass
try:
sftp.mkdir(skills_remote)
except IOError:
pass
upload_tree(sftp, skills_local, skills_remote, "skills")
else:
_ssh.safe_print("No .agents/skills/ found locally — skipping.")
sftp.close()
_ssh.safe_print("Upload complete. Restarting tg-bridge service...")
_, stdout, stderr = client.exec_command(
"systemctl restart tg-bridge.service && systemctl status tg-bridge.service --no-pager"
)
exit_status = stdout.channel.recv_exit_status()
out = stdout.read().decode("utf-8", errors="replace")
err = stderr.read().decode("utf-8", errors="replace")
if exit_status == 0:
_ssh.safe_print(f"Service restarted OK.\n{out}")
else:
_ssh.safe_print(f"Service restart failed.\n{err}")
client.close()
_ssh.safe_print("Deployment complete.")
if __name__ == "__main__":
deploy()