Skip to content

The Vibe server router coordinates prompts, session state, and workspace changes.

Prompt lifecycle

  1. The client sends POST /_vibe-agent/prompt with a prompt and component path.
  2. The router builds a structured prompt using promptBuilder() (including component hierarchy when provided).
  3. agentRouter.routePrompt() dispatches to either local claude-code or the remote Claude host, based on environment flags.
  4. Session updates trigger eventEmitter broadcasts so SSE clients stay in sync.
  5. After the prompt finishes, the workspace is scanned for changes and triggerHMR() touches modified files.

Session updates

  • Session state is held by session() and exposed via GET /_vibe-agent/session-response.
  • GET /_vibe-agent/sse initializes the SSE stream and immediately publishes the current session.
  • DELETE /_vibe-agent/session-response clears the response and think steps.

Workspace tracking

The workspace helper:

  • Calculates additions, deletions, affected files, and branch name via git.
  • Drops changes with git checkout -- . and git clean -fd.
  • Resets to main with git reset --hard origin/main.