Files
clawmates/crates/bins/clawmates-node/install.sh
T
Omar SobhandClaude Opus 4.8 2bdd0a23e8
ci / gates (push) Failing after 5s
ci / rust (push) Has been skipped
ci / sandbox-k8s (push) Has been skipped
ci / frontend (push) Has been skipped
ci / e2e (push) Has been skipped
Fleet P0: node registry + daemon + health + connect-host wizard
Users can connect their own local-hardware nodes into a fleet. Each node runs a
new Rust daemon that dials home over an outbound WebSocket, reports host health,
and runs commands we send.

Backend:
- migrations/0018_fleet_nodes.sql: nodes + node_health tables + agent_containers
  (node_id, workspace_id) index. cm-domain NodeId.
- cm-db repo/nodes.rs: create/auth/list+health/get/heartbeat/set_status/delete
  (unchecked sqlx, no .sqlx regen).
- cm-api fleet.rs NodeHub: live daemon channels (node_id→sender) + the WS channel
  runner (heartbeat→DB upsert, exec request/response framing). routes/nodes.rs:
  POST /pair, GET /nodes, SSE /nodes/live, POST /{id}/exec-test, DELETE /{id},
  WS /nodes/agent (token-auth). Wired into AppState + router.

Daemon (new crate crates/bins/clawmates-node):
- sysinfo host metrics (cpu/mem/pressure/swap/disk/load/containers), outbound WSS
  dial + reconnect, heartbeat loop, exec command handling, tailscale-ip probe.
  install.sh convenience installer.

Frontend:
- Fleet sidebar item + FleetOverview + LocalHardware node-health cards (live via
  /api/nodes, 3s poll) + ConnectHostWizard (install → verify connection →
  exec-test). InfraStage dispatches fleet/local; default selection = fleet.

Deferred: P1 (BYO Tailscale + network metrics), P2 (RemoteDriver + placement so
agents actually run on connected nodes).

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
2026-06-24 08:09:14 -07:00

49 lines
1.5 KiB
Bash

#!/usr/bin/env bash
# clawmates-node installer. Downloads the daemon binary and runs it against your
# ClawMates gateway with the pairing token from the "Connect a host" wizard.
#
# curl -fsSL <gateway>/install.sh | bash -s -- --server <gateway> --token <token>
#
# Until binary hosting is wired up you can also build from source:
# cargo build --release -p clawmates-node
# ./target/release/clawmates-node --server <gateway> --token <token>
set -euo pipefail
SERVER=""
TOKEN=""
while [[ $# -gt 0 ]]; do
case "$1" in
--server) SERVER="$2"; shift 2 ;;
--token) TOKEN="$2"; shift 2 ;;
*) shift ;;
esac
done
if [[ -z "$SERVER" || -z "$TOKEN" ]]; then
echo "usage: install.sh --server <https://gateway> --token <token>" >&2
exit 2
fi
BIN_DIR="${CLAWMATES_BIN_DIR:-$HOME/.clawmates/bin}"
BIN="$BIN_DIR/clawmates-node"
mkdir -p "$BIN_DIR"
# Download the prebuilt binary if a release URL is configured; otherwise the user
# builds from source (see header) and points CLAWMATES_NODE_BIN at it.
if [[ -n "${CLAWMATES_NODE_BIN:-}" ]]; then
cp "$CLAWMATES_NODE_BIN" "$BIN"
elif [[ ! -x "$BIN" ]]; then
OS="$(uname -s | tr '[:upper:]' '[:lower:]')"
ARCH="$(uname -m)"
URL="${CLAWMATES_NODE_URL:-$SERVER/dl/clawmates-node-$OS-$ARCH}"
echo "downloading clawmates-node from $URL"
curl -fsSL "$URL" -o "$BIN" || {
echo "download failed — build from source: cargo build --release -p clawmates-node" >&2
exit 1
}
fi
chmod +x "$BIN"
echo "starting clawmates-node → $SERVER"
exec "$BIN" --server "$SERVER" --token "$TOKEN"