proxy

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2026 License: MIT Imports: 53 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	// DefaultMaxToolResultChars limits single tool output to ~30k chars (~7.5k tokens)
	DefaultMaxToolResultChars = 30000

	// DefaultMaxTotalContextChars limits entire conversation history to ~800k chars (~200k tokens)
	// matching Claude Code, Gemini, and modern frontier LLM context windows.
	DefaultMaxTotalContextChars = 800000
)

Variables

This section is empty.

Functions

func EstimateMessageTokens added in v0.3.0

func EstimateMessageTokens(messages []providers.ChatMessage) int

EstimateMessageTokens provides an approximation of token count

func PruneHistoryToFit added in v0.3.0

func PruneHistoryToFit(messages []providers.ChatMessage, maxChars int) []providers.ChatMessage

PruneHistoryToFit keeps the leading system prompt and the latest N messages within maxChars

func RecordRequest added in v0.3.0

func RecordRequest(entry RequestLog)

RecordRequest records a completed request into the ring buffer and notifies SSE subscribers

func SanitizeAndGuardrailMessages added in v0.3.0

func SanitizeAndGuardrailMessages(messages []providers.ChatMessage, maxToolChars int) []providers.ChatMessage

SanitizeAndGuardrailMessages strips historical thinking blocks from older turns as required by upstream APIs, while preserving 100% of messages, turns, tool outputs, and context without artificial gateway limits.

Types

type AnthropicContentBlock added in v0.2.0

type AnthropicContentBlock struct {
	Type string `json:"type"`
	Text string `json:"text,omitempty"`
}

type AnthropicMessage added in v0.2.0

type AnthropicMessage struct {
	Role    string      `json:"role"`
	Content interface{} `json:"content"` // string or []AnthropicContentBlock
}

type AnthropicMessageRequest added in v0.2.0

type AnthropicMessageRequest struct {
	Model       string                 `json:"model"`
	Messages    []AnthropicMessage     `json:"messages"`
	System      interface{}            `json:"system,omitempty"` // string or []contentBlock
	MaxTokens   int                    `json:"max_tokens,omitempty"`
	Stream      bool                   `json:"stream,omitempty"`
	Temperature *float64               `json:"temperature,omitempty"`
	Metadata    map[string]interface{} `json:"metadata,omitempty"`
	Tools       []interface{}          `json:"tools,omitempty"`
	ToolChoice  interface{}            `json:"tool_choice,omitempty"`
}

AnthropicMessageRequest represents an incoming /v1/messages POST request

type ExtractedToolCall added in v0.3.0

type ExtractedToolCall struct {
	ID    string                 `json:"id"`
	Name  string                 `json:"name"`
	Input map[string]interface{} `json:"input"`
}

func ExtractXmlToolCalls added in v0.3.0

func ExtractXmlToolCalls(text string) (string, []ExtractedToolCall)

ExtractXmlToolCalls finds <tool_use>, <tool_call>, or <invoke> blocks in static text

type LogHub added in v0.3.0

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

LogHub manages the in-memory request ring buffer and live SSE subscribers

type RequestLog added in v0.3.0

type RequestLog struct {
	ID         string    `json:"id"`
	Timestamp  time.Time `json:"timestamp"`
	Endpoint   string    `json:"endpoint"`
	Model      string    `json:"model"`
	Provider   string    `json:"provider,omitempty"`
	StatusCode int       `json:"status_code"`
	DurationMs int64     `json:"duration_ms"`
	Tokens     int       `json:"tokens,omitempty"`
	Error      string    `json:"error,omitempty"`
}

RequestLog represents a single tracked request through GoRoute

func GetRecentLogs added in v0.3.0

func GetRecentLogs() []RequestLog

GetRecentLogs returns a copy of recent request logs

type Server

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

func NewServer

func NewServer(r *router.Router, limiter *quota.Limiter, enableDashboard bool) *Server

func (*Server) Handler

func (s *Server) Handler() http.Handler

func (*Server) Reload added in v0.3.0

func (s *Server) Reload() error

Reload reads the configuration from disk and re-registers all providers and combos dynamically

func (*Server) SetConfigPaths added in v0.3.0

func (s *Server) SetConfigPaths(cfgPath, storePath string)

type VncManager added in v0.4.0

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

type VncSession added in v0.4.0

type VncSession struct {
	SessionID    string `json:"sessionId"`
	ConnectionID string `json:"connectionId"`
	ProviderID   string `json:"providerId"`
	URL          string `json:"url"`
	Status       string `json:"status"` // "running", "stopped", "harvested"
	StartedAt    string `json:"startedAt"`
	VNCPort      int    `json:"vncPort"`
}

type XmlStreamParser added in v0.3.0

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

XmlStreamParser handles streaming text deltas and intercepts XML tool calls across chunks.

func NewXmlStreamParser added in v0.3.0

func NewXmlStreamParser() *XmlStreamParser

func (*XmlStreamParser) Feed added in v0.3.0

func (p *XmlStreamParser) Feed(chunk string) (string, []ExtractedToolCall)

func (*XmlStreamParser) Flush added in v0.3.0

func (p *XmlStreamParser) Flush() string

Jump to

Keyboard shortcuts

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