Skip to content

feat: regent mothership#2

Open
soyboyscout wants to merge 13 commits intomainfrom
claude/regent-ai-agents-MTnY9
Open

feat: regent mothership#2
soyboyscout wants to merge 13 commits intomainfrom
claude/regent-ai-agents-MTnY9

Conversation

@soyboyscout
Copy link
Member

@soyboyscout soyboyscout commented Mar 2, 2026


Summary by cubic

Adds the Mothership backend for real-time sync, hybrid memory search, and a Mastra-based agent runtime with MCP tools, wired to the extension. Security is hardened end-to-end; production Docker is included. README is rewritten with architecture diagrams, setup guides, and a WebSocket protocol reference.

  • New Features

    • Backend/API: Hono HTTP+WebSocket; SQLite (WAL) with migrations; REST /api/v1 for auth, workspaces, sessions, events, memory, agents/runs, MCP, invites, notifications; event bus; lane queue; retention; Docker/Caddy; non-root.
    • Memory/Search: FTS5 + sqlite-vec hybrid ranking (RRF); auto-embed events; provider-agnostic embeddings; API keys encrypted at rest; caps and error handling.
    • MCP/Agents: Mastra-powered streaming agent runtime (tool calls, context, limits); MCP stdio allowlist and blocked flags; HTTP URL validation and timeouts; MCP tools bridged to Mastra createTool(); provider credential → model resolver; auth on run start/stop; per-run rate limiting.
    • WebSocket/Extension: first-message auth; workspace membership check on tab:register; events:store → memory; context:query → context:results; agent:start/stop streaming; provider credentials upsert; notification pushes. Extension adds background WS with auto-reconnect, context routing, agent panel, memory search UI, and a popup for server URL/token/workspace.
    • Hardening: 30‑day JWTs with revoke (dev-only ephemeral secret by default); RBAC on workspace routes; rate limits on auth/workspace create; sanitized FTS5; fix MCP disconnect IDOR; strict CORS with ALLOWED_ORIGINS and optional EXTENSION_ID; transactional token bucket; input caps; JWTs in chrome.storage.local; prod requires JWT_SECRET; atomic user/workspace create and migrations; session upsert inside event-store tx; stricter JWT payload validation; guarded password checks; WS broadcast try/catch; improved logging.
    • Docs: README updated with Mastra-based agent flow, architecture and sequence diagrams, local/Docker setup, MCP examples and allowlist, DB schema/migrations, and WebSocket message protocol.
  • Migration

    • Server: copy .env.example → .env (set JWT_SECRET; optionally EXTENSION_ID/ALLOWED_ORIGINS), npm install, npm run dev (or build/start), or docker-compose (JWT_SECRET required; healthcheck; non-root).
    • Create an account via /auth/register or /auth/login, generate a token (30‑day), and revoke via /auth/revoke if needed.
    • In the extension popup, enter the server URL and token, select a workspace, and Connect. Optionally add provider API keys (encrypted at rest) to enable embeddings, search, and tools.

Written for commit 77041ad. Summary will update on new commits.

Summary by CodeRabbit

  • New Features
    • Full mothership backend: user auth, workspaces, sessions, invites, notifications, memory storage, hybrid search/embeddings, agents with run management, and real‑time sync via WebSockets.
    • Browser extension: connection UI & popup controls, sidebar connection indicator, debounced memory search, agent panel (run/stream), cross‑session events, and in‑app notifications.
  • Chores
    • Dev/ops scaffolding: environment example, Docker/Caddy, compose, build config, and automated data retention.

EntelligenceAI PR Summary

This PR implements a full-stack real-time event synchronization system called 'Mothership' for cross-session/cross-device AI event sharing.

Backend (mothership/):

  • Node.js/TypeScript server with Hono framework, SQLite database, and WebSocket support
  • RESTful API with JWT authentication for user/workspace/session/event management
  • Database schema with 7 tables supporting multi-tenant workspaces and role-based access control
  • WebSocket gateway with token authentication, heartbeat monitoring, and event broadcasting
  • Lane-based queue system for serial task execution per session to prevent race conditions
  • Event bus pattern for real-time cross-tab communication

Extension Integration:

  • Background service worker WebSocket manager with exponential backoff reconnect logic
  • Popup UI for configuring Mothership connection (URL, API token, workspace selection)
  • Sidebar connection status indicator and remote session event display
  • Automatic event forwarding from RegentSidecar to Mothership backend
  • Cross-session event synchronization displayed in sidebar with visual distinction
  • Message passing architecture between content scripts, background worker, and popup

Confidence Score: 1/5 - Blocking Issues

  • Critical security vulnerabilities present: DELETE endpoint can affect resources outside workspace boundary (mcp.ts), run quota bypass via WebSocket (runtime.ts), and cross-workspace data leakage risks (agents.ts, memory.ts)
  • New blocking issue introduced: removal of ROUND_TIMEOUT causes indefinite hangs when providers stall, making the system unreliable in production
  • Multiple authorization bypass vulnerabilities: role typo fallback to level 0, missing agent-run ownership validation, and unvalidated foreign key references across workspaces
  • High volume of unresolved correctness issues (48 total) including JSON parsing errors that can crash endpoints, malformed data handling, and Docker permission issues that will cause runtime failures
Files requiring special attention
  • mothership/src/agents/runtime.ts
  • mothership/src/api/routes/mcp.ts
  • mothership/src/api/middleware/workspace.ts
  • mothership/src/api/routes/agents.ts
  • mothership/src/api/routes/memory.ts

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants