Skip to content

Latest commit

 

History

History
142 lines (109 loc) · 4.17 KB

README.md

File metadata and controls

142 lines (109 loc) · 4.17 KB

Mebius Code Backend

NestJS backend for Mebius Code, an agentic coding platform with model configuration, server-side workspaces, Plan Mode, tool approvals, SSE events, and audit logging.

Local Development

npm install
cp .env.example .env
docker compose up -d postgres
npm run start:dev

Health check:

GET http://localhost:3000/api/health

On Windows, if PowerShell returns a proxy-related 502 Bad Gateway, bypass the local proxy:

curl.exe --noproxy "*" http://localhost:3000/api/health

Docker Compose

From the repository root:

docker compose up --build

This starts:

  • api: NestJS backend on port 3000.
  • postgres: PostgreSQL database on port 5432.

Core API Surface

GET /api/system/capabilities

POST /api/auth/register
POST /api/auth/login
GET  /api/auth/me
PATCH /api/auth/me/password
PATCH /api/auth/me/preferences

GET    /api/model-configs
POST   /api/model-configs
PATCH  /api/model-configs/:id
DELETE /api/model-configs/:id
POST   /api/model-configs/:id/test

GET  /api/projects
POST /api/projects
POST /api/projects/local
POST /api/projects/:id/import/git
GET  /api/projects/:id/tree
GET  /api/projects/:id/file?path=src/main.ts

POST /api/projects/:projectId/sessions
GET  /api/projects/:projectId/sessions
GET  /api/sessions/:id
GET  /api/sessions/:id/messages
POST /api/sessions/:id/messages
POST /api/sessions/:id/commands
GET  /api/sessions/:id/events?access_token=<jwt>

POST /api/sessions/:id/plan
POST /api/plans/:id/approve
POST /api/sessions/:id/run

GET  /api/approvals/pending
POST /api/approvals/:id/approve
POST /api/approvals/:id/reject
GET  /api/command-policy
PATCH /api/command-policy
GET  /api/sessions/:id/command-runs
POST /api/sessions/:id/command-runs

GET  /api/audit-logs

GET /api/audit-logs supports action, resourceType, resourceId, actorId, limit, and offset query parameters. Regular users are scoped to their own logs; admins can query all actors.

Slash Commands

POST /api/sessions/:id/commands supports these command flows:

/clear
/compact
/model <modelConfigId>
/connect
/connect <provider search>

/connect returns searchable OpenAI-compatible provider options. Submit args.providerId to get the connection form, then submit args.providerId and args.apiKey to validate the provider, save the encrypted model config, and switch the active session model. API keys must be passed through args.apiKey, not embedded in the command string.

Web Search Tool

The agent exposes a read-only web_search tool through Exa hosted MCP by default. It works without a key for light personal use; when the hosted free quota is exhausted, the tool returns guidance instead of failing the agent run.

Optional configuration:

WEB_SEARCH_ENABLED=true
WEB_SEARCH_PROVIDER=exa
EXA_API_KEY=
WEB_SEARCH_MAX_RESULTS=5
WEB_SEARCH_TIMEOUT_MS=10000
WEB_SEARCH_CONTEXT_MAX_CHARACTERS=10000

Set WEB_SEARCH_ENABLED=false to remove the tool from the model prompt. Set EXA_API_KEY to use your own Exa account after hitting hosted free limits. Search results are returned as structured JSON with provider, content, URLs, snippets, and quota guidance when applicable.

Security Defaults

  • Model API keys are encrypted with MEBIUS_CODE_MASTER_KEY.
  • File tools are restricted to the project workspace root.
  • .git, .env, node_modules, dist, and coverage are blocked by default.
  • Attached local workspaces are disabled by default. Set MEBIUS_CODE_LOCAL_WORKSPACES_ENABLED=true outside production mode and use an administrator account to create them.
  • create_patch and run_command require approval.
  • MEBIUS_CODE_COMMAND_ALLOWLIST remains the immutable environment baseline.
  • Administrators can enable Git, Node.js, and Python presets or add command prefixes through Settings > Command permissions.
  • Commands outside the active policy enter approval instead of failing before review. Administrators may enable non-shell commands for the current project.
  • Shell chaining and redirection require explicit review. A project owner can trust the current session for automatic command execution; command substitution and paths outside the project workspace remain blocked.