Skip to main content

Overview

The VibeLearn worker is an Express.js HTTP server managed by Bun, running on port 37778. It handles:
  • Session lifecycle (init, observations)
  • The 5-step analysis pipeline
  • Upstream sync with retry queue
  • System health and admin

Startup

The worker is started by the SessionStart hook if not already running:
The worker is kept alive by plugin/scripts/worker-wrapper.cjs (Bun-managed). Environment variable VIBELEARN_MANAGED=true is set in the worker process.

API Endpoints

Session Management

POST /api/sessions/init
POST /api/sessions/observations

VibeLearn Analysis Pipeline

All analysis endpoints accept { contentSessionId }. The concepts endpoint also accepts { last_assistant_message }. Concept extraction response:

VibeLearn Data

System

Analysis Pipeline Implementation

Each analysis endpoint is implemented in src/services/worker/http/routes/VibeLearnRoutes.ts:

LLM Provider Selection

createAgentRunner() in VibeLearnRoutes creates a (prompt: string) => Promise<string> function that tries providers in order:
  1. Gemini — if VIBELEARN_GEMINI_API_KEY is set in settings
  2. OpenRouter — if VIBELEARN_OPENROUTER_API_KEY is set
  3. Anthropic — direct HTTP to api.anthropic.com using ANTHROPIC_API_KEY

Logs

Log level controlled by VIBELEARN_LOG_LEVEL in settings (debug, info, warn, error).

Route Registration

Routes are registered in WorkerService.registerRoutes():