dev-box / launch_picoclaw.py
ameobius's picture
Upload launch_picoclaw.py with huggingface_hub
924a5d2 verified
Raw History Blame Contribute Delete
1.51 kB
#!/usr/bin/env python3
"""Launch picoclaw gateway — works across versions."""
import sys
import os
# Set config dir
os.environ.setdefault("PICOCLAW_HOME", "/app/.picoclaw")
try:
import picoclaw
# Try different entry points
if hasattr(picoclaw, "gateway"):
gw = picoclaw.gateway
if callable(gw):
gw()
elif hasattr(gw, "run"):
gw.run()
elif hasattr(picoclaw, "run_gateway"):
picoclaw.run_gateway()
elif hasattr(picoclaw, "cli"):
cli = picoclaw.cli
if hasattr(cli, "main"):
sys.argv = ["picoclaw", "gateway"]
cli.main()
else:
# Search for gateway function in submodules
import importlib
for name in ["picoclaw.gateway", "picoclaw.cli", "picoclaw.main", "picoclaw.app"]:
try:
mod = importlib.import_module(name)
if hasattr(mod, "main"):
sys.argv = ["picoclaw", "gateway"]
mod.main()
break
if hasattr(mod, "run"):
mod.run()
break
except ImportError:
continue
else:
print("ERROR: Cannot find gateway entry point in picoclaw", file=sys.stderr)
print(f"Available: {dir(picoclaw)}", file=sys.stderr)
sys.exit(1)
except Exception as e:
print(f"ERROR: {e}", file=sys.stderr)
import traceback
traceback.print_exc()
sys.exit(1)