Repository navigation
Ravenstack Keep Phase 1: MCP server, painted hall UI, and agent gates - #72
Merged
Merged
Conversation
Every screen in ui-v2 went through a single Gemini call. There was no Ollama code path at all, so local models could never work no matter what was installed, and box-adapter.ts described the MCP binds without ever making a request. One missing cloud key took down forge, table, oracle, sentinel, mechanic, hall talk and the gallery at once. - lib/keep/ollama.ts: Ollama client. Accepts a bare host:port, picks a chat tag over an embed-only one, supports JSON mode, and times out instead of hanging. - lib/keep/mcp.ts: streamable-HTTP JSON-RPC client for FastMCP. Handshake, session header, SSE frame parsing, one re-init on a dropped session, and credential redaction on every error path. Forces the /mcp suffix. - lib/keep/router.ts: one place decides the plane. local-first by default per the fortress brief; cloud is a fallback that needs a key and can be hard disabled. The SDK import is dynamic so a cloud problem cannot take down the local path. Reports which plane answered. - lib/keep/net.ts: shared failure classification, so a refused connection keeps its actionable hint across runtimes instead of degrading to a generic error. - box-adapter.ts: the planned binds are calls now. pulse.ts asks MCP dashboard_status first, then KEEP_PULSE_URL, then the fixture — still labeled paper, never invented as live. - Oracle consults the box vault via query_scoped_knowledge when MCP is configured, with catalog excerpts as the labeled fallback. - New Routing panel on the Workshop bench shows which plane is up, which models are installed, and which binds the box lists. - scripts/routing-smoke.ts: 15 checks against a fake Ollama and a fake FastMCP. Run with `bun run test:routing`. Env contract documented in .env.example. With nothing set the app is fully local and spends nothing. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017zDdoQMyjeCxVgcR6QsrGd
Verified live against the box: Ollama is up with qwen3-coder:30b, qwen3-4b-64k, qwen3:4b, gpt-oss:20b-cloud, gemma4, phi4-mini and qwen3:1.7b. None of them matched the preference list, so automatic selection fell through to installed[0] — the 30b coder model — for in-character replies and strict JSON. A `-cloud` tag could also have been picked, which is paid routing and breaks local-first. - Preference order now targets the tags actually installed, fastest capable general tag first; the 30b coder sits below the 4b and is reachable by pinning KEEP_LOCAL_MODEL. Generic families kept as a tail so this still resolves on a different box. - Cloud-routed and embedding tags are excluded from automatic selection only. An explicit KEEP_LOCAL_MODEL still wins — that is the operator being explicit, which the brief allows. - A box with nothing but cloud/embed tags now says exactly that instead of failing mid-chat against an embedder. - docker-compose: removed the host.docker.internal values added in the last commit. The bridge listens on 127.0.0.1:8100 only, so a bridge-networked container cannot reach it that way and would have failed silently. The working options are documented in place instead. Smoke test covers the box inventory: 19 checks, `bun run test:routing`. No tailnet address or Funnel URL is committed — this repo is public. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017zDdoQMyjeCxVgcR6QsrGd
Verified against the running box via the connector rather than assumed.
dashboard_status does not have the shape pulse.ts expected:
- services arrive as objects ({status} / {ok}), so the badge rendered
"[object Object]" for openclaw and "unknown" for reclaw, which is named
reclaw_api on the box.
- the queue key is county_queue, not queue, so the war-table chip read
unknown/0 against a real cursor of 6.
- agents_active is null.
- mcp is deliberately left "unprobed" (a self-probe deadlocks the
single-worker bridge); it now falls back to the bridge unit state.
A live payload with no rooms now says occupancy is unknown on BOTH live
paths instead of letting empty chips read as every room idle.
FastMCP: mcp/src/server.py was pinned to >=2.0.0. Verified it imports and
serves over http on 4.0.5, listing all 14 tools, so the pin moves to
>=4.0.0,<5. The app's MCP client was then driven end to end against that
real server — handshake, session reuse, tools/list, and tools/call on
list_rooms and get_castle_map all decode correctly.
That run also showed Keep MCP names the gate tool list_pending_gates while
reclaw-platform names it pending_gates, so pendingGates() now resolves
whichever the endpoint lists, as queryKnowledge() already did.
routeTree.gen.ts was stale and missing /gallery, so the Grand Gallery portal
pointed at a route the tree did not know. Regenerated; two typecheck errors
go with it.
Smoke test grows to 25 checks and now pins the parser against the real
captured dashboard_status payload.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017zDdoQMyjeCxVgcR6QsrGd
Valerie's persona says she cannot see the box from here, and the hall seats were told never to invent live status — but neither had any way to read it, so every answer was a guess dressed as a diagnosis. - runInspection now reads stack_health over MCP and hands the result to Valerie and Sentinel as a live reading they are told to trust over any assumption. When MCP is unavailable it passes nothing and instructs them to say so, rather than narrating a fiction. - talkInHall does the same with a compact pulse summary (network, service states, queue cursor, local model count, room occupancy). Paper never reaches the persona as live: only a live-sourced pulse is passed. - Both surfaces now show provenance — which model answered and whether it saw the box. Canned action replies clear it, so a scripted line can never be mistaken for a live one. Also ships scripts/add_ollama_models.py context: the box has 7 Ollama tags but OpenClaw registers 3, so qwen3:4b, qwen3-4b-64k and qwen3-coder:30b are unroutable through the gateway. The script is on the box; it is dry-run by default, backs up openclaw.json, re-parses before replacing, and never restarts the gateway. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017zDdoQMyjeCxVgcR6QsrGd
Sprite: PLAYER_SRC was operator-clone.png, which is not a character sheet. Its 16 cells are near-identical blobs on a baked-in opaque navy background (only 20% transparent, against 67-79% for every alternative), so the player rendered as a lit rectangle that changed shape on each turn. Swapped to operator-v3.png, which a per-row mirror test confirms is a real 4-direction walk cycle: row 2 is closer to a mirror of row 1 (0.028) than to row 1 itself (0.052), and their alpha centroids sit on opposite sides of the frame. Frame size now comes from the sheet instead of a hardcoded 38x62 that sliced it. Dialogue and rooms: authEnabled was hardcoded true in auth/client.ts, so the VITE_AUTH_ENABLED switch its own docs describe did nothing. Signed out, every SignInGate screen stayed shut and the hall talk box hit `if (!q || !user) return` — a silent return, which is why it read as broken rather than gated. The server never needed this: requireUserId already falls back to DEV_USER_ID. Wired the flag and made the talk box say what is wrong instead of nothing. Env: Vite exposes only VITE_* to the client and never populates process.env, so OLLAMA_BASE_URL and MCP_BASE_URL in .env were ignored in dev and routing silently used its defaults. vite.config now loads the full .env into process.env for the server functions. Lighting: the map dim was offered as a five-step ladder and the untouched painting was chosen, so LIGHTING defaults to off and both layers are skipped unless asked for. The knob stays for later tuning. The original "lighting is awful" reading was the broken sprite lighting the room, not the map. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017zDdoQMyjeCxVgcR6QsrGd
…overy Drove the talk flow in a browser: the sheet opens, action buttons fire, the input reaches the server. Three things were wrong with what came back. The dialogue box replaced one line per exchange, so asking a second question destroyed the answer to the first. It now keeps the conversation: your turns, the seat's replies, and errors, scrolled to the newest, with a thinking line while a reply is in flight. Scripted action replies are labelled "scripted" so a canned line can never be mistaken for a live one, and the model plus whether it saw the box still ride under each real reply. Failures printed plumbing into an NPC's mouth — the full string was "No model plane answered (route=local-first). local: Ollama unreachable at http://127.0.0.1:11434 (fetch failed | connect ECONNREFUSED ... )". Failures now carry a short headline, an actionable hint, and a separate detail field. The hall shows the first two and logs detail to the console. The smoke test pins the headline under 120 chars and asserts raw socket text stays out of it. Ollama endpoint is now discovered rather than assumed. 127.0.0.1 is correct on the box and on a laptop but means the container itself when the app is containerised, which is exactly how "Ollama is running but the app cannot see it" happens. With nothing configured it probes loopback, host.docker.internal and the docker bridge, caches whichever answers, and names all of them when none do. An explicit OLLAMA_BASE_URL is never silently overridden — a wrong value surfaces as an error, and its hint points at the setting instead of telling the operator to start a daemon they aimed elsewhere on purpose. Smoke test: 26 checks. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017zDdoQMyjeCxVgcR6QsrGd
Oracle, Sentinel, Mechanic, Forge and the Round Table each held a single result that the next question destroyed, and each reported failure only through a toast. A toast disappears, so a failed call left the previous answer on screen looking like the current one — the worst version of this, since the surface was showing a stale answer with no sign anything went wrong. ChatLog now renders the exchange for the three ask/answer surfaces (Oracle, Sentinel, Mechanic): your question, the reply, provenance under it, and a thinking line while it is in flight. Oracle keeps its citations as a footnote on the reply rather than a detached block, so an answer and what it was drawn from cannot drift apart. Forge and the Round Table keep their structured output — a draft Spec and a seat-by-seat finding are not conversation — but their failures are now a persistent panel with the headline and hint instead of a vanishing toast. errorTurn is the single place that decides what a failure looks like: headline and hint on screen, detail to the console. It lives in lib/keep/chat rather than the component module so fast refresh keeps working. Verified in a browser against all five: each renders its own transcript, the question appears as a turn, and the failure shows the short headline with the actionable hint under it. No page errors. Smoke test still 26. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017zDdoQMyjeCxVgcR6QsrGd
main was 9 commits from a common ancestor that ravenstack (this repo's real
default branch, and what the live box actually runs) was 129 commits past.
Merged origin/ravenstack in, then surveyed every file that conflicted before
touching anything, because ravenstack's independent development turned out
to supersede most of the prior session's work outright:
- ai.ts already has its own local-first Ollama routing (completeOllama before
completeGemini, Gemini only as a fallback when a key exists) -- more mature
than the session's router.ts (baked in, no separate module, 90s cold-start
timeout).
- fastmcp.ts is a working, already-deployed MCP client (SSE parsing, dual
funnel/internal endpoints, fail-closed) -- supersedes the session's mcp.ts.
- talk-sheet.tsx has its own full transcript UI (history, typewriter, inline
errors) -- supersedes the session's chat-log.tsx.
- WatchtowerBeacon + MechanicWorkbench + FastMCPGatewayStreamer supersede the
session's routing-panel.tsx.
Deleted, as confirmed-redundant, unused dead code that would only confuse the
next agent: lib/keep/{mcp,router,net,box-adapter,chat}.ts,
components/keep/{chat-log,routing-panel}.tsx, scripts/routing-smoke.ts.
Also deleted three gallery components (gallery-hall.tsx,
portrait-inspection-modal.tsx, wall-manager-modal.tsx) that turned out to be
orphaned: they never existed on ravenstack, and the merge resolved
gallery.tsx and gallery/storage.ts to ravenstack's own simpler, incompatible
API, leaving these three calling functions that no longer exist. Confirmed
zero importers outside their own trio before removing.
What was still genuinely missing, applied on top of the current (not the
prior session's) versions:
- mcp/requirements.txt, pyproject.toml: fastmcp>=2.0.0 -> >=4.0.0,<5. Verified
by actually running fastmcp 4.0.5 against this server.py -- imports clean,
serves over HTTP, all 14 tools listed and callable.
- pulse.ts: a live dashboard_status payload can report a service as an object
({status}/{ok}) instead of a string, which String()'d into "[object
Object]" on the badge; the queue key can also arrive as county_queue rather
than queue. Both fixed additively, without touching the newer room-mapping
logic already built here independently.
- oracle.tsx, sentinel.tsx, forge.tsx, table.tsx: a failed call surfaced only
through sonner's toast, which disappears -- leaving the previous answer on
screen with no visible sign anything failed. Each now also keeps the error
message in a persistent panel until the next attempt.
Verified: tsc clean except the 2 pre-existing GenerateContentConfig errors
confirmed present on origin/ravenstack's own tip (not introduced here); the
repo's own test suite passes 24/24 including the locomotion/facing tests;
`npm run build:box` (the actual box build command) succeeds.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017zDdoQMyjeCxVgcR6QsrGd
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Complete Phase 1 implementation of Ravenstack Keep: a multi-agent command fortress with spatial telemetry, human approval gates, and a walkable painted hall interface. Adds the FastMCP control plane (
mcp/src/server.py), HTTP API layer, two UI implementations (Phaser grid and Grok-painted hall), and foundational database schema for agent specs and operator sessions.Key Changes
MCP Control Plane (
mcp/)server.py(1133 lines): FastMCP server implementing Phase-1 tools + spatial telemetrykeep.db)list_agents,report_agent_status,fetch_castle_map,query_knowledge, etc.gates.py: Human approval gates forapprove_specandunlock_room(all mutations requireconfirm=true)http_api.py: Thin Starlette HTTP layer for visual shell (same SQLite backend, not a second control plane)openclaw_sync.py: Mirror OpenClaw session lifecycle into Keep agent status (Phase A truthful-only sync)requirements.txt: FastMCP ≥4.0.0 and jsonschema dependenciesUI — Phaser Grid (
ui/)KeepScene.ts: Phaser 3 scene rendering 48×48 castle map with room sprites, chips, and HUDhud.ts: Interactive HUD for room selection, path/cost queries, spec approval, and agent statusapi.ts: Client bindings to/api/castle-map,/api/gates,/api/healthpalette.ts: Dark cyber-arcane color tokens (#0b0e14 base, #2de2e6 neon, #ff2a6d magenta)config/seats.ts: Maps spatial rooms ↔ agent rostergenerate_keep_art.pyandprocess_ravenstack_art.pyfor palette-locked 48×48 tilesUI — Painted Hall (
ui-v2/)KeepHallcomponent: Walkable Phaser scene over painted fortress image (1792×1008)HallScene.ts: Player movement, NPC hotspots, zone detection, dialogue triggersworld.ts: Painted world hotspots (NPCs, tables, doors) and collision geometrygallery/: Portrait studio, inspection modal, wall manager for operator avatar customizationkeep/server.ts: Server functions for AI calls (Oracle, Convene Table, Forge Spec, etc.)keep/ai.ts: FORTRESS_BRIEF rules (local-first, one agent = one purpose, no draft-to-execute)keep/mcp.ts: Streamable-HTTP JSON-RPC client for FastMCP (replaces box-adapter)keep/ollama.ts: Local inference plane with Ollama (KEEP_LOCAL_MODEL, KEEP_LOCAL_TIMEOUT_MS)keep/router.ts: Model routing (local default, cloud fallback with explicit key)0001_auth.sql,0002_keep.sql,0003_gallery.sqlfor identity, specs, portraitsDatabase Schema
keep.db(SQLite): Agent specs, status, gates, sessionsDocumentation & Config
ACTIVE.md: Updated with painted hall branch and Phase A living statusmcp/docs/https://claude.ai/code/session_017zDdoQMyjeCxVgcR6QsrGd