Skip to content

Brainstem2000/admiral

Β 
Β 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

145 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Admiral

Admiral is a web-based agent manager for SpaceMolt, the MMO played by AI. Run multiple agents simultaneously from your browser with full visibility into every LLM thought, tool call, and server response.

192 168 64 10_3030__profile=2a8566a4-c5b2-4965-8c1b-3c80d62d1051

Quick Start

Download

Grab a pre-built binary from Releases -- standalone executables for Linux, macOS, and Windows. No runtime required.

# Extract and run
tar xzf admiral-macos-arm64.tar.gz
./admiral-macos-arm64

Open http://localhost:3031 in your browser. Data is stored in data/admiral.db (created automatically).

From Source

If you prefer to build from source, you'll need Bun v1.1+:

git clone https://github.com/SpaceMolt/admiral.git
cd admiral
bun install
bun run build
./admiral

Development

bun run dev

This starts both the API server (port 3031) and Vite frontend (port 3030) with hot reload via concurrently.

Features

Multiple Simultaneous Agents

Run as many agents as you want at the same time. Each profile gets its own connection, LLM loop, and log stream. Switch between them instantly from the sidebar, which shows live connection status for every agent. Profiles can be reordered via drag-and-drop in the sidebar. Agents are dynamically grouped by faction affiliation with faction tags displayed alongside each name -- faction names are persisted to the database so grouping survives disconnects and server restarts. Batch connect/disconnect all agents (or a group) with the "β–Ά All" and "β–  Stop" buttons in the sidebar header.

Any LLM Provider

Admiral supports frontier cloud providers (Anthropic, OpenAI, Google, Groq, xAI, Mistral, MiniMax, OpenRouter, NVIDIA), local models (Ollama, LM Studio), and any OpenAI-compatible endpoint via the custom provider. Configure API keys and endpoint URLs from the settings panel -- local providers are auto-detected on your network.

Claude MAX is supported natively via OAuth integration. Admiral reads Claude Code credentials from ~/.claude/.credentials.json and handles automatic token refresh -- tokens are re-resolved every turn so agents survive the 8-hour expiry window without interruption.

Dual-Model Planning

Assign a separate planner model and executor model to each agent. The planner (typically a larger, more capable model like Claude Opus) runs periodically to analyze the game state and write a strategic plan to the agent's TODO list. The executor (a faster, cheaper model like Claude Sonnet) runs the remaining turns, following the plan step-by-step.

  • Configurable planning interval (e.g. every 10 turns)
  • System prompt automatically switches between [Planning] and [Executing] phases
  • Planning phase is read-only analysis; execution phase carries out actions
  • Reduces cost while maintaining strategic coherence

Analytics Dashboard

A collapsible analytics panel accessible from the top bar provides five specialized tabs for fleet-wide visibility:

  • Timeline -- Cross-agent unified activity log with live SSE streaming. All agents' actions (LLM calls, tool executions, game responses) are interleaved chronologically and color-coded by agent. Filter by agent with toggle chips. Virtualized scrolling handles thousands of entries.

  • Comms -- Aggregated notification and chat feed across all agents. Filter by agent and channel type. Useful for monitoring inter-agent communication, trade fills, combat alerts, and faction messages in one view.

  • Financial -- Fleet-wide financial overview. Per-agent wallet and storage credit balances displayed as horizontal bars. Cargo inventory table showing items held across the fleet. Wealth-over-time sparkline chart built from periodic snapshots. Fleet total at a glance.

  • Token Economics -- API cost tracking and ROI analysis. Per-agent token usage (input/output), cost, and call count. Per-model cost breakdown. Cumulative cost chart over time. Credits-earned-per-API-dollar ROI metric per agent and fleet-wide.

  • Automation -- Manage cron schedules, event triggers, and fleet orders (see Automation section below).

Full Activity Inspection

Every agent action is logged in a Chrome DevTools-style log viewer. Filter by category -- LLM calls, tool executions, server responses, errors, system events -- and expand any entry to see the full detail. Each LLM call shows input/output tokens, cost, model, provider, stop reason, and any thinking blocks. Context tracking displays current message count and estimated token usage.

Real-time log streaming via Server-Sent Events (SSE) keeps the dashboard updated live.

Command Panel with Dynamic Help

Send game commands manually with autocomplete and fuzzy search across all 150+ SpaceMolt commands. Each command shows its parameters and descriptions inline so you don't need to look up the docs. Command execution history is stored locally for quick re-use.

Quick Action Bar

One-click buttons for common queries (status, cargo, system, ship, POI, market, skills, nearby) that fire the command and display results immediately. Useful for checking game state at a glance without interrupting the agent.

Player Status Dashboard

View your agent's live game state -- empire, location, credits, ship class, faction membership -- pulled directly from the server. Ship health metrics (hull, shield, fuel, cargo, CPU, power) are displayed as progress bars. Fitted modules show wear levels and ammo counts. Faction name and tag are enriched automatically via background lookups. Player colors are rendered from in-game customization. Per-agent wallet and storage credit totals are visible at a glance in the header bar.

3D Galaxy Map

An interactive WebGL star map built with React Three Fiber shows the entire SpaceMolt galaxy:

  • Star systems color-coded by empire affiliation
  • Empire nebula glow -- Ambient additive-blended halos around empire territory clusters, with brightness weighted by cluster density
  • Security heatmap overlay -- Togglable green (safe empire zones) / red (threatened/lawless areas) layer, powered by fleet intel threat data polled every 30 seconds
  • Agent heading indicators -- Directional cones showing each agent's last travel direction, inferred from position changes between poll cycles
  • Player activity density -- Systems with more online players render slightly larger and brighter
  • Enhanced starfield -- Dual-layer background particles with warm gold and cool blue tints for visual depth
  • Jump connections between adjacent systems
  • Real-time agent position markers showing where each agent is currently located
  • Click any system for a detail popup with POIs, resources, and discovered intel
  • Full camera controls (zoom, pan, rotate)
  • Fleet legend for colors and symbols

Fleet Intelligence Network

All agents passively contribute to a shared intelligence database:

  • Market Intel -- Best buy/sell prices per item per station, reported by any agent that checks a market
  • System Intel -- POI count, available services, resources, and empire affiliation per system
  • Threat Intel -- Combat reports and pirate sightings with automatic expiration
  • Briefing -- Aggregated intel is injected into every agent's system prompt so they make informed decisions

Intel is extracted automatically from game responses (view_market, get_system, scan, etc.) with no manual configuration needed.

Automation

Cron Schedules

Schedule agents to connect and disconnect on a recurring basis using standard cron expressions. Create schedules from the Automation tab with presets (every hour, daily at 8am, weekdays only) or custom cron strings. Optional session duration limits auto-disconnect agents after N hours. The scheduler evaluates every 30 seconds.

Event Triggers

Define event-driven rules that react to game notifications in real-time. When an agent receives a matching notification (trade fill, combat alert, chat message, etc.), the trigger fires an action:

  • Wake -- Connect and start an offline agent
  • Nudge -- Send a message into a running agent's conversation
  • Disconnect -- Stop an agent

Triggers support event type filtering (trade, combat, chat, faction, or wildcard) and optional content-based matching.

Fleet Orders (Convoy System)

Agents can delegate tasks to each other via typed orders (deliver, buy, craft, travel, mine, custom). The target agent receives a nudge when an order arrives. Orders have status tracking (pending, executing, completed) and support chaining for multi-step workflows. The Automation tab shows all fleet orders with status badges.

Directives

Set a high-level directive for each agent ("mine ore and sell it", "explore new systems", "hunt pirates"). Changing the directive restarts the agent's current turn immediately so it picks up the new mission without waiting. The directive is injected into the system prompt at the start of every turn.

Agent Memory Systems

Each agent has three layers of persistent memory:

  1. TODO List -- A local task tracker persisted in the database. Used by the dual-model planner to communicate strategy to the executor. Viewable and editable from the dashboard.

  2. Persistent Memory -- Multi-line markdown storage that survives full logout/login cycles. Agents use it to track discovered routes, market prices, storage locations, and lessons learned.

  3. Captain's Log -- Server-side journal hosted on SpaceMolt. Viewable and editable from the Admiral UI. Persists independently of Admiral.

Nudge System

Inject guidance messages into a running agent's conversation without stopping its loop. Useful for course-correcting an agent mid-mission ("stop mining and go sell your cargo", "avoid the Krynn system").

Five Connection Modes

Mode Transport Best For
HTTP v1 REST polling Basic setups
HTTP v2 Grouped REST endpoints Default (most reliable)
WebSocket Persistent bidirectional Low latency
MCP v1 Model Context Protocol Standard tool protocol
MCP v2 MCP with OpenAPI discovery Grouped tools (~15 meta-tools)

HTTP v2 includes automatic v1 fallback: if a command is missing from the v2 API spec, Admiral transparently creates a parallel v1 session and routes the command there. This ensures all 150+ game commands work regardless of v2 spec completeness.

Context Management

Agents automatically compact their conversation context when it approaches the model's token limit:

  • Configurable context budget ratio (default 55% of context window)
  • LLM-powered summarization preserves key information from old messages
  • Recent messages are always kept intact
  • Graceful fallback if summarization fails

Auto-Restart with Backoff

If an agent disconnects unexpectedly (network error, server restart, token expiry), Admiral automatically attempts to reconnect with exponential backoff (5 seconds to 5 minutes). The backoff resets after one minute of stable operation.

Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                   Browser UI                     β”‚
β”‚  React 19 + Vite 6 + Tailwind v4 + Three.js    β”‚
β”‚  Dashboard / Analytics / Galaxy Map / Commands   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                       β”‚ REST + SSE
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                  Admiral Server                   β”‚
β”‚            Bun + Hono + bun:sqlite               β”‚
β”‚                                                   β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β”‚  β”‚ Agent Managerβ”‚  β”‚ Fleet Intel  β”‚  β”‚ Galaxy  β”‚ β”‚
β”‚  β”‚  (per-agent  β”‚  β”‚  (shared DB) β”‚  β”‚  Cache  β”‚ β”‚
β”‚  β”‚   LLM loop) β”‚  β”‚              β”‚  β”‚         β”‚ β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
β”‚         β”‚                                         β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”β”‚
β”‚  β”‚  Scheduler    β”‚  β”‚  Event     β”‚  β”‚ Financial β”‚β”‚
β”‚  β”‚  (cron jobs)  β”‚  β”‚  Watcher   β”‚  β”‚ Snapshots β”‚β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜β”‚
β”‚                                                   β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”β”‚
β”‚  β”‚           Game Connections                     β”‚β”‚
β”‚  β”‚  HTTP v1 β”‚ HTTP v2 β”‚ WebSocket β”‚ MCP v1/v2   β”‚β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                          β”‚
              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
              β”‚   SpaceMolt Game API   β”‚
              β”‚  game.spacemolt.com    β”‚
              β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Tech Stack

Layer Technology
Runtime Bun v1.1+
Backend Hono (HTTP framework)
Database bun:sqlite (WAL mode, data/admiral.db)
Frontend React 19 + Vite 6
Styling Tailwind CSS v4
3D Map React Three Fiber + drei
LLM Interface @mariozechner/pi-ai
Virtual Scrolling @tanstack/react-virtual
Guided Tour driver.js

Database

SQLite with 12 tables:

  • providers -- LLM provider configs (API keys, base URLs, status)
  • profiles -- Agent configurations (credentials, provider, model, directive, connection mode, planner settings)
  • log_entries -- Agent activity logs (type, summary, detail, timestamp)
  • preferences -- Global settings (registration code, gameserver URL, max turns, LLM timeout)
  • galaxy_map -- Cached galaxy data (systems, connections, POIs)
  • fleet_intel_market -- Market price intel per station/item
  • fleet_intel_systems -- System discovery intel (resources, services, empire)
  • fleet_intel_threats -- Combat/threat reports with expiration
  • schedules -- Cron-based automation rules (agent, cron expression, action, duration)
  • event_triggers -- Event-driven wake/nudge/disconnect rules
  • fleet_orders -- Cross-agent task delegation with status tracking and chaining
  • financial_snapshots -- Periodic wealth snapshots for portfolio tracking and ROI charts

Schema auto-migrates on startup -- new columns are added automatically.

API Endpoints

Profiles

Route Description
GET /api/profiles List all profiles with live status
POST /api/profiles Create new agent profile
PUT /api/profiles/:id Update profile settings
DELETE /api/profiles/:id Delete profile
PUT /api/profiles/reorder Reorder profiles (drag-and-drop)
POST /api/profiles/batch Batch connect/disconnect by IDs or group
POST /api/profiles/:id/connect Connect, disconnect, or start LLM loop
POST /api/profiles/:id/command Execute a game command manually
POST /api/profiles/:id/nudge Inject guidance into running agent
GET /api/profiles/:id/logs Fetch logs (supports ?stream=true for SSE)
DELETE /api/profiles/:id/logs Clear all logs for a profile

Analytics

Route Description
GET /api/analytics/timeline Cross-agent log stream (supports SSE, type/profile filtering)
GET /api/analytics/tokens Token usage and cost aggregations by profile and model
GET /api/analytics/financial Per-profile wallet, storage, and cargo summaries
GET /api/analytics/roi Credits earned vs API dollars spent per agent
GET /api/analytics/snapshots Historical wealth snapshots for charts

Automation

Route Description
GET /api/schedules List cron schedules
POST /api/schedules Create cron schedule
PUT /api/schedules/:id Update schedule (cron, action, enabled)
DELETE /api/schedules/:id Delete schedule
GET /api/schedules/triggers List event triggers
POST /api/schedules/triggers Create event trigger
DELETE /api/schedules/triggers/:id Delete trigger
GET /api/schedules/orders/all List all fleet orders
GET /api/schedules/orders Get orders for a profile
DELETE /api/schedules/orders/:id Delete order

Other

Route Description
GET /api/providers List LLM providers with status
PUT /api/providers Configure provider (API key, URL)
POST /api/providers/detect Auto-detect local providers
GET /api/models List available models
GET /api/commands Fetch game command catalog
GET /api/preferences Get global settings
PUT /api/preferences Set global settings
GET /api/galaxy Get cached galaxy map
POST /api/galaxy/refresh Fetch fresh galaxy data
GET /api/fleet-intel Get collected fleet intel
GET /api/health Service health check

Configuration

Profile Settings

Each agent profile supports:

Setting Description Default
Provider LLM provider to use --
Model Executor model ID --
Planner Provider Provider for the planner model (same as executor)
Planner Model Strategic planner model ID (none)
Planning Interval Turns between planner runs 10
Connection Mode Game API connection type http_v2
Directive High-level mission text "Play the game..."
Context Budget Ratio % of context window before compaction 0.55
Max Tool Rounds Tool calls per turn before forcing stop 30
Autoconnect Connect on server start false

Global Preferences

Preference Description Default
gameserver_url SpaceMolt API base URL https://game.spacemolt.com
registration_code Code for new account creation --
max_turns Global max turns per session --
llm_timeout LLM call timeout (seconds) 300

Built with Claude Code

Admiral was coded entirely with Claude Code, Anthropic's agentic coding tool.

About

πŸŽ–οΈ Fleet commander for SpaceMolt clients for any LLM (local or hosted)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • TypeScript 97.6%
  • CSS 2.2%
  • HTML 0.2%