
moltbox.py#!/usr/bin/env python3 import asyncio import os import sys async def main(): print("Starting MoltBot in micro-VM sandbox...") print("Type 'exit' or press Ctrl+D to quit\n") try: from boxlite import InteractiveBox term_mode = os.environ.get("TERM", "xterm-256color") async with InteractiveBox(name="moltbox", image="ubuntu:26.04", env=[("TERM", term_mode)], ports=[(18789, 18789)], auto_remove=False, reuse_existing=True) as itbox: await itbox.wait() except KeyboardInterrupt: print("\n\nInterrupted by Ctrl+C") except Exception as e: print(f"\nError: {e}", file=sys.stderr) import traceback traceback.print_exc() sys.exit(1) if __name__ == "__main__": asyncio.run(main()) 执行 pip install boxlite
执行 python moltbox.py 进入沙箱
进入沙箱后,粘贴以下命令,按回车
apt-get update -y apt-get install -y --no-install-recommends curl ca-certificates curl -fsSL https://deb.nodesource.com/setup_22.x | bash - apt-get install -y nodejs Or the full updated script for Ubuntu: #!/bin/sh set -e export DEBIAN_FROnTEND=noninteractive export PATH=/usr/local/bin:$PATH # --- Install Node.js + clawdbot if missing --- if ! command -v clawdbot >/dev/null 2>&1; then apt-get update -y apt-get install -y --no-install-recommends python3 make g++ git ca-certificates curl lsof curl -fsSL https://deb.nodesource.com/setup_22.x | bash - apt-get install -y nodejs npm config set cache /tmp/npm-cache npm install -g clawdbot@latest fi # --- Configure & start gateway --- set -eu CONF_DIR=/root/.clawdbot mkdir -p "$CONF_DIR" BIN=$(command -v clawdbot || true) if [ -z "$BIN" ]; then BIN="$(npm bin -g)/clawdbot" fi export CLAWDBOT_STATE_DIR="$CONF_DIR" export CLAWDBOT_CONFIG_PATH="$CONF_DIR/clawdbot.json" TOKEN=$(head -c 16 /dev/urandom | od -A n -t x1 | tr -d ' \n') PORT=18789 cat > "$CLAWDBOT_CONFIG_PATH" <<EOF { "gateway": { "mode": "local", "bind": "lan", "port": $PORT, "auth": { "mode": "token", "token": "$TOKEN" }, "controlUi": { "enabled": true, "allowInsecureAuth": true } } } EOF "$BIN" gateway run --allow-unconfigured --force --dev --bind lan --port "$PORT" --token "$TOKEN" & PID=$! echo "Gateway PID: $PID" echo "Endpoint: http://127.0.0.1:$PORT?token=$TOKEN" for i in $(seq 1 120); do if curl -so /dev/null --connect-timeout 1 "http://127.0.0.1:$PORT/" 2>/dev/null; then echo "Gateway is ready!" break fi sleep 2 done 本方案沙箱基于 https://github.com/boxlite-ai/boxlite 一个轻松跑在本地,基于 micro-VM 的沙箱实现
1 ccc00 1 月 31 日 请问可以运行在 vps 的 Linux 吗? 还是要运行在 kvm/qemu 的虚拟的 Linux ? |