musecode

package
v8.0.75 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2026 License: MIT Imports: 24 Imported by: 0

Documentation

Overview

Package musecode serves Muse Code CLI client endpoints, generating /muse-code/models from CPA's available models and relaying auxiliary endpoints to the selected Meta upstream.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MarshalCompact

func MarshalCompact(resp Response) ([]byte, error)

MarshalCompact encodes resp as compact JSON via *ojson.Doc.

Types

type EffortVariant

type EffortVariant struct {
	ReasoningEffort string `json:"reasoningEffort"`
}

EffortVariant describes a selectable reasoning effort variant.

type Handler

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

Handler serves Muse Code CLI endpoints, generating /muse-code/models locally and relaying allowlisted auxiliary endpoints to Meta using managed Meta credentials.

func NewHandler

func NewHandler(authManager *auth.Manager, cfg *config.Config) *Handler

NewHandler constructs a Muse Code endpoint relay handler.

func (*Handler) Handle

func (h *Handler) Handle(c *gin.Context)

Handle serves GET /muse-code/models locally and forwards allowlisted /muse-code/* relay requests to the selected Meta origin.

func (*Handler) HandleModels

func (h *Handler) HandleModels(c *gin.Context)

HandleModels serves GET /muse-code/models from CPA's available model catalog (or the configured Home loader when Home mode is enabled).

func (*Handler) SetModelListHooks

func (h *Handler) SetModelListHooks(homeLoader HomeModelsLoader, responseWriter ModelListWriter)

SetModelListHooks configures optional hooks for loading Home-mode models and writing intercepted model catalog responses.

func (*Handler) UpdateConfig

func (h *Handler) UpdateConfig(cfg *config.Config)

UpdateConfig updates the handler's runtime configuration snapshot.

type HomeModelsLoader

type HomeModelsLoader func(c *gin.Context) ([]ModelInput, bool)

HomeModelsLoader loads scoped models when Home mode is active. Returning false indicates the loader has already written an HTTP error response.

type Limits

type Limits struct {
	Context int `json:"context,omitempty"`
	Output  int `json:"output,omitempty"`
}

Limits describes context window and max output token limits.

type Modalities

type Modalities struct {
	Input  []string `json:"input"`
	Output []string `json:"output"`
}

Modalities lists supported input and output content modalities.

type ModelEntry

type ModelEntry struct {
	ID       string        `json:"id"`
	Object   string        `json:"object"`
	Created  int64         `json:"created"`
	OwnedBy  string        `json:"owned_by"`
	Metadata ModelMetadata `json:"metadata"`
}

ModelEntry represents a single model record inside Response.Data.

type ModelInput

type ModelInput struct {
	ID                        string
	MetadataModelID           string
	Created                   int64
	OwnedBy                   string
	Type                      string
	DisplayName               string
	Description               string
	ContextLength             int
	MaxContextLength          int
	MaxCompletionTokens       int
	InputTokenLimit           int
	OutputTokenLimit          int
	Thinking                  *registry.ThinkingSupport
	ExplicitThinking          bool
	SupportedInputModalities  []string
	ExplicitInputModalities   bool
	SupportedOutputModalities []string
	HasOutputModalities       bool
	Routes                    []ModelRoute
}

ModelInput represents a normalized available model entry used to construct the Muse Code /muse-code/models catalog.

func ModelInputsFromGlobalRegistry

func ModelInputsFromGlobalRegistry(reg *registry.ModelRegistry) []ModelInput

ModelInputsFromGlobalRegistry extracts ModelInput entries from reg, preserving per-provider route metadata so conflicting capabilities merge conservatively.

func ModelInputsFromRegistry

func ModelInputsFromRegistry(infos []*registry.ModelInfo) []ModelInput

ModelInputsFromRegistry converts registry ModelInfo records into ModelInput entries.

type ModelListWriter

type ModelListWriter func(c *gin.Context, sourceFormat string, payload any)

ModelListWriter writes the final serialized model catalog response.

type ModelMetadata

type ModelMetadata struct {
	MuseCode MuseCodeMetadata `json:"muse-code"`
}

ModelMetadata wraps provider-client metadata for a model entry.

type ModelRoute

type ModelRoute struct {
	Provider                  string
	MetadataModelID           string
	Created                   int64
	OwnedBy                   string
	Type                      string
	DisplayName               string
	Description               string
	ContextLength             int
	MaxContextLength          int
	MaxCompletionTokens       int
	InputTokenLimit           int
	OutputTokenLimit          int
	Thinking                  *registry.ThinkingSupport
	ExplicitThinking          bool
	SupportedInputModalities  []string
	ExplicitInputModalities   bool
	SupportedOutputModalities []string
	HasOutputModalities       bool
}

ModelRoute describes one provider-specific route serving a public model ID.

type MuseCodeMetadata

type MuseCodeMetadata struct {
	Name                 string                   `json:"name"`
	Family               string                   `json:"family"`
	ReleaseDate          string                   `json:"release_date"`
	IsHidden             bool                     `json:"is_hidden"`
	Attachment           bool                     `json:"attachment"`
	Reasoning            bool                     `json:"reasoning"`
	Temperature          bool                     `json:"temperature"`
	ToolCall             bool                     `json:"tool_call"`
	Modalities           Modalities               `json:"modalities"`
	Limit                *Limits                  `json:"limit,omitempty"`
	Options              Options                  `json:"options"`
	Variants             map[string]EffortVariant `json:"variants,omitempty"`
	Description          *string                  `json:"description"`
	BackgroundAgentModel string                   `json:"background_agent_model,omitempty"`
}

MuseCodeMetadata describes model capabilities and defaults consumed by Muse Code CLI.

type Options

type Options struct {
	ReasoningEffort string   `json:"reasoningEffort,omitempty"`
	ForceReasoning  bool     `json:"forceReasoning,omitempty"`
	Include         []string `json:"include,omitempty"`
	Temperature     *float64 `json:"temperature,omitempty"`
	TopP            *float64 `json:"top_p,omitempty"`
}

Options contains default request options injected by Muse Code CLI.

type Response

type Response struct {
	Object string       `json:"object"`
	Data   []ModelEntry `json:"data"`
}

Response represents the /muse-code/models response envelope.

func BuildModelsResponse

func BuildModelsResponse(inputs []ModelInput) Response

BuildModelsResponse builds a Muse Code compatible model catalog from the given inputs.

Jump to

Keyboard shortcuts

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