Flow Mesh Bootstrap — Intelligence-First Setup
Philosophy
The bootstrap has ONE job: get intelligence online as fast as possible. Once an LLM is connected, IT guides the entire remaining setup — not hardcoded wizards.
Flow
mesh bootstrap [--domain mesh.client.com]
│
▼
┌─────────────────────────────────┐
│ Step 0: Deterministic Scan │ No LLM needed
│ - Scan ALL env vars for keys │
│ - Scan tools (cloudflared, pi) │
│ - Scan ports, services, repos │
│ - Build ServerInventory struct │
└──────────┬──────────────────────┘
▼
┌─────────────────────────────────┐
│ Step 1: Connect Intelligence │ THE critical step
│ Try each key in priority order:│
│ 1. FLOW_MESH_INTELLIGENCE_* │
│ 2. KIMI_API_KEY │ → api.kimi.com/coding/v1 (anthropic)
│ 3. ANTHROPIC_API_KEY │ → api.anthropic.com/v1
│ 4. OPENROUTER_API_KEY │ → openrouter.ai/api/v1 (openai)
│ 5. OPENAI_API_KEY │ → api.openai.com/v1
│ 6. Ollama on localhost:11434 │ → no key needed
│ Send test ping to each until │
│ one responds successfully. │
│ Write config to DB. │
└──────────┬──────────────────────┘
│
▼ Intelligence is now online
┌─────────────────────────────────┐
│ Step 2: Hand Off to LLM │
│ │
│ Send setup prompt with full │
│ ServerInventory as context: │
│ │
│ "You are setting up Flow Mesh │
│ on a new server. Here's what │
│ I found: [inventory JSON]. │
│ Guide the setup. You have │
│ these tools: mesh config set, │
│ mesh ps create, mesh auth, │
│ cloudflared tunnel create, │
│ etc. For complex tasks you │
│ can delegate to pi." │
│ │
│ LLM responds with plan + │
│ executes via tool calls. │
└──────────┬──────────────────────┘
│
▼
┌─────────────────────────────────┐
│ Step 3: Interactive or Auto │
│ │
│ --interactive (default): │
│ Chat loop — LLM asks user │
│ for missing info (PATs etc) │
│ │
│ --auto: │
│ LLM configures everything │
│ it can without asking, │
│ prints what's left. │
│ │
│ --headless: │
│ Opens pi session to do │
│ complex setup tasks │
│ (CF tunnel, systemd, etc.) │
└──────────┬──────────────────────┘
▼
┌─────────────────────────────────┐
│ Step 4: Verify & Report │
│ - Health check │
│ - Print URL + credentials │
│ - List what's configured │
│ - List what still needs setup │
└─────────────────────────────────┘
ServerInventory Schema
type ServerInventory struct {
// LLM Keys (name → masked key, tested → bool)
LLMKeys []LLMKeyProbe `json:"llm_keys"`
// Service credentials
AsanaPAT string `json:"asana_pat"` // "found" or ""
AsanaWorkspace string `json:"asana_workspace"` // GID if found
DiscordToken string `json:"discord_token"` // "found" or ""
DiscordGuild string `json:"discord_guild"` // GID if found
// Infrastructure
Cloudflared bool `json:"cloudflared"` // binary available
CFAPIKey bool `json:"cf_api_key"` // can create tunnels
CFTunnels []string `json:"cf_tunnels"` // existing tunnel names
Port8300Free bool `json:"port_8300_free"`
InitSystem string `json:"init_system"` // "systemd" or "other"
OS string `json:"os"` // "AlmaLinux 8.10"
WebServer string `json:"web_server"` // "litespeed", "nginx", etc.
// Tools
Pi bool `json:"pi"` // pi binary available
Bd bool `json:"bd"` // bd binary available
Git bool `json:"git"`
Docker bool `json:"docker"`
// Repos
GitRepos []RepoInfo `json:"git_repos"`
// Domain (from --domain flag)
Domain string `json:"domain,omitempty"`
}
type LLMKeyProbe struct {
EnvVar string `json:"env_var"`
Provider string `json:"provider"` // "anthropic" or "openai"
BaseURL string `json:"base_url"`
Model string `json:"model"`
Working bool `json:"working"` // ping test result
}
Setup Prompt (sent to LLM after connection)
You are the Flow Mesh setup assistant. You're running on a fresh server
and need to complete the installation.
SERVER INVENTORY:
{inventory_json}
YOUR TOOLS:
- mesh config set <key> <value> — set config values
- mesh config set-secret <key> — set secrets (you provide the value)
- mesh auth create-user <user> <pw> — create admin account
- mesh ps create ... — create a mesh
- mesh ps link ... — link Asana/Discord to mesh
- mesh setup nginx|caddy|cloudflared <domain> — generate proxy config
- cloudflared tunnel create <name> — create CF tunnel
- cloudflared tunnel route dns <tunnel> <domain> — set DNS
- systemctl enable --now flow-mesh — start service
RULES:
1. Configure what you can with available information
2. For missing credentials (Asana PAT, Discord token), explain
exactly how to get them with URLs and steps
3. Create an admin user with a random secure password
4. If --domain was provided AND cloudflared + CF_API_KEY available,
create the tunnel and DNS record
5. Generate and install the systemd service unit
6. For complex multi-step tasks, delegate to pi
7. After each action, verify it worked
8. End with a summary of what's configured and what's pending
BEGIN SETUP.
CLI Interface
# Default: interactive chat with LLM guiding setup
mesh bootstrap
# With domain (triggers CF tunnel creation)
mesh bootstrap --domain mesh.client.com
# Auto mode: no questions, configure everything possible
mesh bootstrap --domain mesh.client.com --auto
# Headless: spawn pi for complex tasks
mesh bootstrap --domain mesh.client.com --headless
# Skip intelligence (pure deterministic)
mesh bootstrap --no-intelligence
# Custom install dir
mesh bootstrap --dir /opt/flow-mesh
# Dry run: show what would be done
mesh bootstrap --dry-run