proxy

package
v0.33.0 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultClaudeDesktopListenAddr is the loopback address used by the Ollama
	// app and the Claude Desktop profile it manages.
	DefaultClaudeDesktopListenAddr = "127.0.0.1:11435"
)
View Source
const (
	MaxClaudeDesktopModels = 5
)

Variables

This section is empty.

Functions

func ClaudeDesktopMappings

func ClaudeDesktopMappings(models []ClaudeDesktopModel) map[string]string

ClaudeDesktopMappings returns the explicit route-to-model mapping represented by an assigned model catalog.

func DefaultClaudeDesktopMappings

func DefaultClaudeDesktopMappings(fullAccess bool) map[string]string

DefaultClaudeDesktopMappings returns the initial Claude-to-Ollama mapping for the current account tier. Accounts without Pro access expose only the free Sonnet route; the remaining routes intentionally stay unassigned.

func DefaultClaudeDesktopMappingsForModels

func DefaultClaudeDesktopMappingsForModels(available []ClaudeDesktopModel, fullAccess bool) map[string]string

DefaultClaudeDesktopMappingsForModels resolves the default recommendation names to the exact Ollama routes in the current catalog. This preserves server-owned aliases such as the current DeepSeek Flash revision.

func ProbeClaudeDesktop

func ProbeClaudeDesktop(ctx context.Context, baseURL string) error

ProbeClaudeDesktop verifies that baseURL is served by Ollama's Claude gateway rather than another process using the configured port.

Types

type ClaudeDesktop

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

ClaudeDesktop is the local gateway that Claude Desktop reaches through its native third-party inference mode. It is deliberately an ordinary HTTP reverse proxy: Claude terminates its own gateway protocol here, so no TLS interception or system trust changes are necessary.

func NewClaudeDesktop

func NewClaudeDesktop(config ClaudeDesktopConfig) (*ClaudeDesktop, error)

NewClaudeDesktop creates a Claude Desktop proxy.

func (*ClaudeDesktop) Addr

func (p *ClaudeDesktop) Addr() string

func (*ClaudeDesktop) Close

func (p *ClaudeDesktop) Close(ctx context.Context) error

func (*ClaudeDesktop) Counts

func (p *ClaudeDesktop) Counts() ClaudeDesktopCounts

func (*ClaudeDesktop) Models

func (p *ClaudeDesktop) Models() []ClaudeDesktopModel

Models returns the model subset currently advertised to Claude Desktop.

func (*ClaudeDesktop) ServeHTTP

func (p *ClaudeDesktop) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*ClaudeDesktop) SetModels

func (p *ClaudeDesktop) SetModels(models []ClaudeDesktopModel) error

SetModels replaces the complete model subset advertised to Claude Desktop.

func (*ClaudeDesktop) Start

func (p *ClaudeDesktop) Start() error

type ClaudeDesktopAccessReason

type ClaudeDesktopAccessReason string
const (
	ClaudeDesktopAccessCloudOff                ClaudeDesktopAccessReason = "cloud_off"
	ClaudeDesktopAccessSignInRequired          ClaudeDesktopAccessReason = "sign_in_required"
	ClaudeDesktopAccessUpgradeRequired         ClaudeDesktopAccessReason = "upgrade_required"
	ClaudeDesktopAccessVerificationUnavailable ClaudeDesktopAccessReason = "verification_unavailable"
	ClaudeDesktopAccessModelNotInstalled       ClaudeDesktopAccessReason = "model_not_installed"
)

type ClaudeDesktopAccessState

type ClaudeDesktopAccessState struct {
	Cloud   ClaudeDesktopCloudStatus
	Account ClaudeDesktopAccountStatus
	Plan    string
}

ClaudeDesktopAccessState is the current account and Cloud state used to evaluate Claude Desktop models. Callers should resolve it again at each user action or proxy request because both settings and account state can change.

type ClaudeDesktopAccountStatus

type ClaudeDesktopAccountStatus string
const (
	ClaudeDesktopAccountUnknown   ClaudeDesktopAccountStatus = "unknown"
	ClaudeDesktopAccountSignedOut ClaudeDesktopAccountStatus = "signed_out"
	ClaudeDesktopAccountSignedIn  ClaudeDesktopAccountStatus = "signed_in"
)

type ClaudeDesktopAvailability

type ClaudeDesktopAvailability string
const (
	ClaudeDesktopAvailabilityUnknown     ClaudeDesktopAvailability = "unknown"
	ClaudeDesktopAvailabilityAvailable   ClaudeDesktopAvailability = "available"
	ClaudeDesktopAvailabilityUnavailable ClaudeDesktopAvailability = "unavailable"
)

type ClaudeDesktopCloudStatus

type ClaudeDesktopCloudStatus string
const (
	ClaudeDesktopCloudUnknown ClaudeDesktopCloudStatus = "unknown"
	ClaudeDesktopCloudOff     ClaudeDesktopCloudStatus = "off"
	ClaudeDesktopCloudOn      ClaudeDesktopCloudStatus = "on"
)

type ClaudeDesktopConfig

type ClaudeDesktopConfig struct {
	ListenAddr         string
	OllamaURL          string
	Model              string
	Models             []ClaudeDesktopModel
	Logger             *slog.Logger
	OnCountsChanged    func(ClaudeDesktopCounts)
	RefreshModels      func(context.Context, []ClaudeDesktopModel) ([]ClaudeDesktopModel, error)
	ResolveAccessState func(context.Context) (ClaudeDesktopAccessState, error)
	ListLocalModels    func(context.Context) ([]string, error)
}

ClaudeDesktopConfig configures a Claude Desktop proxy instance.

type ClaudeDesktopCounts

type ClaudeDesktopCounts struct {
	Routed uint64
}

ClaudeDesktopCounts reports requests routed through the proxy.

type ClaudeDesktopModel

type ClaudeDesktopModel struct {
	Name         string
	Description  string
	DisplayName  string
	RequiredPlan string
	OllamaModel  string
	Cloud        bool
	Recommended  bool
	AccountCloud bool
	// contains filtered or unexported fields
}

ClaudeDesktopModel is one Ollama model adapted for Claude Desktop's model catalog. Name is the canonical recommendation identifier shown to users; OllamaModel is the explicit route sent to the local Ollama server.

func ClaudeDesktopModelsFromCloudInventory

func ClaudeDesktopModelsFromCloudInventory(names []string) []ClaudeDesktopModel

ClaudeDesktopModelsFromCloudInventory converts an account-scoped cloud inventory into selectable Claude routes. Presence in this inventory is the entitlement and Auto-mode eligibility check; these models are not recommendations.

func ClaudeDesktopModelsFromRecommendations

func ClaudeDesktopModelsFromRecommendations(recommendations []api.ModelRecommendation) []ClaudeDesktopModel

ClaudeDesktopModelsFromRecommendations converts the endpoint response into the protocol metadata Claude Desktop expects. Recommendation model names, order, descriptions, limits, and plan requirements remain server-owned.

func DefaultClaudeDesktopModels

func DefaultClaudeDesktopModels() []ClaudeDesktopModel

DefaultClaudeDesktopModels is the built-in offline fallback. Keep this list deliberately small; the Ollama.com app-aware endpoint is the primary source.

func FetchClaudeDesktopModels

func FetchClaudeDesktopModels(client *http.Client, req *http.Request) ([]ClaudeDesktopModel, error)

FetchClaudeDesktopModels fetches the app-aware recommendation contract. Callers own request construction and are responsible for falling back when the request or response fails.

func MapClaudeDesktopModels

func MapClaudeDesktopModels(available []ClaudeDesktopModel, mappings map[string]string) []ClaudeDesktopModel

MapClaudeDesktopModels assigns explicit Claude route IDs to Ollama models. Empty routes are omitted and the same Ollama model may serve multiple routes.

func SelectClaudeDesktopModels

func SelectClaudeDesktopModels(available []ClaudeDesktopModel, selected []string) []ClaudeDesktopModel

SelectClaudeDesktopModels preserves the user's explicit order. Names that are no longer recommended remain usable so a transient endpoint change or outage cannot silently replace a saved user choice. Validated Claude IDs are reusable slots assigned in that order, independent of recommendation order.

func UnverifyClaudeDesktopCloudEntitlements

func UnverifyClaudeDesktopCloudEntitlements(models []ClaudeDesktopModel) []ClaudeDesktopModel

UnverifyClaudeDesktopCloudEntitlements prevents fallback metadata from overriding a catalog that was already refreshed from the server.

func VerifyClaudeDesktopModelsWithCloudInventory

func VerifyClaudeDesktopModelsWithCloudInventory(models, inventory []ClaudeDesktopModel) []ClaudeDesktopModel

VerifyClaudeDesktopModelsWithCloudInventory marks matching catalog models as account-verified without replacing their recommendation metadata.

func (ClaudeDesktopModel) GatewayID

func (m ClaudeDesktopModel) GatewayID() string

GatewayID returns the validated Claude-facing ID assigned to this model.

type ClaudeDesktopModelAccess

type ClaudeDesktopModelAccess struct {
	Availability ClaudeDesktopAvailability
	Reason       ClaudeDesktopAccessReason
	RequiredPlan string
}

ClaudeDesktopModelAccess is the policy decision for one model.

func EvaluateClaudeDesktopModelAccess

func EvaluateClaudeDesktopModelAccess(model ClaudeDesktopModel, state ClaudeDesktopAccessState, installed, inventoryKnown bool) ClaudeDesktopModelAccess

EvaluateClaudeDesktopModelAccess applies Claude Desktop's model policy to facts resolved by the app. installed and inventoryKnown only affect local models.

type ClaudeDesktopRoute

type ClaudeDesktopRoute struct {
	ID          string
	DisplayName string
}

ClaudeDesktopRoute is one fixed model ID accepted by Claude Desktop. The gateway advertises the mapped Ollama model as its display name.

func ClaudeDesktopRoutes

func ClaudeDesktopRoutes() []ClaudeDesktopRoute

ClaudeDesktopRoutes returns the fixed routes in Claude's preferred order.

Jump to

Keyboard shortcuts

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