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 ¶
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 ¶
NewHandler constructs a Muse Code endpoint relay handler.
func (*Handler) Handle ¶
Handle serves GET /muse-code/models locally and forwards allowlisted /muse-code/* relay requests to the selected Meta origin.
func (*Handler) HandleModels ¶
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 ¶
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 Modalities ¶
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 ¶
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.