From 6a34a6f3c423a7c57616762eb4cea2b7da52eaf3 Mon Sep 17 00:00:00 2001 From: soryu Date: Sun, 22 Feb 2026 14:39:14 +0000 Subject: feat: Add daemon page with download binary and Cloudflare Agent setup (#77) * feat: soryu-co/soryu - makima: Create DaemonList and DaemonDetail page components * feat: soryu-co/soryu - makima: Add daemon page routes, CSS styles, and navigation * feat: soryu-co/soryu - makima: Create daemon page with download and monitoring * WIP: heartbeat checkpoint * WIP: heartbeat checkpoint * feat: soryu-co/soryu - makima: Integrate Cloudflare Agent setup into daemon page --- makima/cloudflare-agent/README.md | 237 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 237 insertions(+) create mode 100644 makima/cloudflare-agent/README.md (limited to 'makima/cloudflare-agent/README.md') diff --git a/makima/cloudflare-agent/README.md b/makima/cloudflare-agent/README.md new file mode 100644 index 0000000..b33842a --- /dev/null +++ b/makima/cloudflare-agent/README.md @@ -0,0 +1,237 @@ +# Makima Cloudflare Agent + +Edge relay agent for [Makima](https://github.com/soryu-co/makima) — distributed task orchestration for AI coding agents. + +This Cloudflare Worker acts as a **WebSocket relay** between the Makima server and native daemon instances. It runs on Cloudflare's edge network using Durable Objects for persistent state and connections. + +## Why an Edge Relay? + +The full Makima daemon requires native capabilities (process spawning, git operations, filesystem access) that aren't available on Cloudflare Workers. Instead, this agent serves as: + +1. **WebSocket Relay** — Bridges the Makima server with remote daemon instances via persistent WebSocket connections +2. **Task Queue Manager** — Receives tasks from the server and dispatches them to the least-loaded downstream daemon +3. **Status Aggregator** — Tracks daemon health and task history across edge locations +4. **API Proxy** — Provides HTTP endpoints for monitoring and management from the edge + +## Architecture + +``` + Cloudflare Edge + ┌─────────────────────────┐ + │ │ + Makima Server ◄──►│ MakimaAgent │◄──► Native Daemon 1 + (wss://...) │ (Durable Object) │◄──► Native Daemon 2 + │ │◄──► Native Daemon N + │ ┌───────────────────┐ │ + │ │ SQLite State │ │ + │ │ - Task history │ │ + │ │ - Connection logs │ │ + │ └───────────────────┘ │ + │ │ + └─────────────────────────┘ +``` + +**Message flow:** + +1. The agent maintains a persistent WebSocket to the Makima server (upstream) +2. Native daemons connect to the agent via WebSocket at `/ws/daemon` (downstream) +3. When the server sends a `SpawnTask` command, the agent selects the least-loaded downstream daemon and forwards the task +4. Task output, progress, and completion messages from daemons are relayed back to the server +5. The agent sends periodic heartbeats and tracks all task dispatches in SQLite + +## Prerequisites + +- **Cloudflare Account** with Workers and Durable Objects enabled +- **Node.js 18+** and npm +- **Makima Server** running and accessible (default: `wss://api.makima.jp`) +- **API Key** from your Makima server dashboard + +## Quick Setup + +```bash +# Clone and navigate to the cloudflare-agent directory +cd makima/cloudflare-agent + +# Run the interactive setup script +chmod +x setup.sh +./setup.sh +``` + +The setup script will: + +1. Check prerequisites (Node.js 18+, npm, npx) +2. Prompt for your Makima server URL and API key +3. Install npm dependencies +4. Create `.dev.vars` with your secrets +5. Check Cloudflare authentication (offer to log in) +6. Optionally set production secrets +7. Offer to deploy immediately or start a dev server + +## Manual Setup + +If you prefer manual configuration: + +```bash +# 1. Install dependencies +npm install + +# 2. Create local secrets file +cat > .dev.vars <