proxy

package
v1.3.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 14, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package proxy provides an HTTP proxy that sits between AI coding tools and the Claude API. It intercepts requests to inject relevant project context from mnemo's search index into the system prompt, and tracks token usage from responses.

The proxy listens on a local port and forwards to the upstream Claude API, adding an "X-Mnemo-Tracked" header to indicate context was injected.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClaudeMessage

type ClaudeMessage struct {
	Role    string `json:"role"`
	Content string `json:"content"`
}

ClaudeMessage represents a single message in a Claude API conversation.

type ClaudeRequest

type ClaudeRequest struct {
	Model       string          `json:"model"`
	Messages    []ClaudeMessage `json:"messages"`
	MaxTokens   int             `json:"max_tokens,omitempty"`
	Temperature float64         `json:"temperature,omitempty"`
	System      string          `json:"system,omitempty"`
	Stream      bool            `json:"stream,omitempty"`
}

ClaudeRequest represents an outgoing Claude API request body.

type ClaudeResponse

type ClaudeResponse struct {
	ID      string         `json:"id"`
	Type    string         `json:"type"`
	Role    string         `json:"role"`
	Content []ContentBlock `json:"content"`
	Model   string         `json:"model"`
	Usage   UsageInfo      `json:"usage"`
}

ClaudeResponse represents the Claude API response body with usage metadata.

type ContentBlock

type ContentBlock struct {
	Type string `json:"type"`
	Text string `json:"text"`
}

ContentBlock represents a single content block in a Claude response (text, image, etc.).

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server is the mnemo HTTP proxy that intercepts Claude API requests.

func NewServer

func NewServer(port, upstream string) *Server

NewServer creates a proxy server that listens on port and forwards to upstream.

func (*Server) Shutdown

func (s *Server) Shutdown() error

func (*Server) Start

func (s *Server) Start() error

Start begins listening for HTTP requests and proxying them to the Claude API.

type UsageInfo

type UsageInfo struct {
	InputTokens  int `json:"input_tokens"`
	OutputTokens int `json:"output_tokens"`
}

UsageInfo holds token consumption counts from a Claude API response.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL