Elffuss BraidHub

kikocis/continue public

main · 3.7 KiBSourceRawPermalink

HTTP Wire Protocol: cn remote � cn serve

This document describes the HTTP protocol used for communication between the cn remote client and cn serve server

Overview

The protocol uses a polling-based REST API where:

Endpoints

GET /state

Returns the current chat state including message history and processing status.

Response:

{
  "chatHistory": [
    {
      "role": "user" | "assistant" | "system",
      "content": "string",
      "isStreaming": boolean,
      "messageType": "tool-start" | "tool-result" | "tool-error" | "system",
      "toolName": "string",
      "toolResult": "string"
    }
  ],
  "isProcessing": boolean,
  "messageQueueLength": number
}

POST /message

Sends a user message to the server. Messages are queued and processed sequentially.

Request Body:

{
  "message": "string"
}

Response:

{
  "queued": true,
  "position": number,
  "willInterrupt": boolean
}

Special Cases:

GET /diff

Returns the git diff between the current branch and main branch.

Response (Success):

{
  "diff": "string"
}

Response (Error):

POST /exit

Gracefully shuts down the server.

Response:

{
  "message": "Server shutting down",
  "success": true
}

Message Types

Messages in the chat history can have different types:

Protocol Flow

  1. Client starts: Begins polling GET /state every 500ms
  2. User sends message: Client posts to POST /message
  3. Server queues message: Returns queue position
  4. Server processes: Updates state with streaming responses
  5. Client displays: Shows updates from state polling
  6. Interruption: Client sends empty message to interrupt
  7. Exit: Client sends /exit or POST /exit to shutdown

Implementation Files

Server Implementation

Client Implementation

Type Definitions

Testing

Features

Message Queueing

Streaming Support

Auto-shutdown

Error Handling

Security Considerations