profile

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2026 License: AGPL-3.0, AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

Package profile owns the canonical provider descriptor catalog used by domain validation and operator-facing setup surfaces.

It owns stable locator, durable connection-shape, credential requirement and authoring, ambient/reference display labels, catalog-noun, and protocol facts. Credential storage sources, provider probe diagnostics, and ChatGPT login mechanics are deliberately outside this catalog; provider runtime authentication strategies belong to their outbound adapters. Bedrock endpoint resolution is the exception to static catalog-only data: ResolveBedrockEndpoint normalizes the required operator-authored inference endpoint and appends one protocol operation. BedrockCatalogURL independently projects canonical regional catalog connectivity. Region never supplies an inference namespace. Compatibility changes live outside this catalog and never drive routing. Routing construction boundaries obtain concrete provider/protocol, Azure endpoint, and Bedrock region predicates through RoutingConstructionFacts; adapters must not reconstruct that catalog mapping independently.

Static manifest truth lives here.

Runtime adapter dispatch is owned by outbound provider composition, not by this catalog. AmbientOrReference is shared authoring semantics only: provider adapters separately own identity discovery, lifecycle, signing or token acquisition, and request authentication. It is not authority for a generic cloud authenticator.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AzureResourceRootFromProjectEndpoint

func AzureResourceRootFromProjectEndpoint(raw string) (string, error)

func BedrockCatalogURL

func BedrockCatalogURL(region string) string

BedrockCatalogURL returns the canonical regional Mantle model catalog. The catalog service is region-owned and independent from a model's authored inference namespace.

func BedrockMantleRegionFromEndpoint

func BedrockMantleRegionFromEndpoint(baseURL string) string

BedrockMantleRegionFromEndpoint extracts a Mantle region from a canonical endpoint URL, or returns empty when the URL is not a Mantle host.

func BedrockMantleRegionLabel

func BedrockMantleRegionLabel(region string) string

BedrockMantleRegionLabel returns the operator-facing geography plus its durable region ID, or the trimmed ID when the catalog does not contain it.

func CatalogItemLabelForSpec

func CatalogItemLabelForSpec(spec string) string

func CloneModelIDs

func CloneModelIDs(ids []string) []string

CloneModelIDs protects operator read models from accidental mutation by callers or transport renderers.

func ConcreteProviderProtocolsForSpec

func ConcreteProviderProtocolsForSpec(spec string) []string

ConcreteProviderProtocolsForSpec returns concrete provider contracts in the catalog-declared order. Buffered and streaming entries with the same Kind remain distinct because they select different upstream wire contracts.

func ConnectionShapeForSpec added in v1.1.0

func ConnectionShapeForSpec(spec string) (routing.ConnectionShape, bool)

ConnectionShapeForSpec returns the durable connection shape declared by the canonical provider catalog. Unknown provider identifiers have no shape.

func DecodeProviderProtocolFromPersistence

func DecodeProviderProtocolFromPersistence(spec string, providerProtocol string) (string, error)

DecodeProviderProtocolFromPersistence normalizes one persisted provider protocol token. Empty means "unspecified" and is valid.

func DefaultAuthHeaderForSpec

func DefaultAuthHeaderForSpec(spec string) string

DefaultAuthHeaderForSpec returns the canonical auth header name for a provider spec, or empty if the provider does not expose a header choice.

func DefaultEnvKeyForSpec

func DefaultEnvKeyForSpec(spec string) string

DefaultEnvKeyForSpec returns the canonical environment variable name for a provider spec, or empty if the provider has no stable env key convention.

func DefaultExecuteBaseURL

func DefaultExecuteBaseURL(spec string) string

func DerivedProtocolForSpec

func DerivedProtocolForSpec(spec string) (string, bool)

DerivedProtocolForSpec returns the catalog-selected protocol that operator authoring omits. Routing remains the authority that validates and materializes the derived protocol.

func EncodeProviderProtocolForPersistence

func EncodeProviderProtocolForPersistence(providerProtocol string) string

func InferredCredentialHeaderForBackendURL

func InferredCredentialHeaderForBackendURL(baseURL string) string

InferredCredentialHeaderForBackendURL returns the initial default credential header inferred from a Custom Endpoint backend URL. It is a cheap heuristic seed only: the operator can always change it, and no credential is ever selected implicitly. Unknown or unparsable URLs fall back to the profile default (Authorization).

Rules (RFC: Custom Endpoint Credential Header):

  • path contains /anthropic/ -> x-api-key
  • Azure Foundry Anthropic-looking host -> x-api-key
  • Azure OpenAI-looking host -> api-key
  • otherwise -> Authorization

func LocatorLabelForProvider

func LocatorLabelForProvider(spec string) string

func NormalizeAzureProjectEndpoint

func NormalizeAzureProjectEndpoint(raw string) (string, error)

func NormalizeAzureResourceLocator

func NormalizeAzureResourceLocator(raw string) (string, error)

func NormalizeProviderProtocolForSpec added in v1.1.0

func NormalizeProviderProtocolForSpec(spec string, providerProtocol string) (string, error)

NormalizeProviderProtocolForSpec validates one authored or persisted exact concrete protocol token. Delivery-bearing suffixes are not migration spellings: they are part of the selected provider contract.

func NormalizeRunPodEndpoint added in v1.1.0

func NormalizeRunPodEndpoint(raw string) (string, error)

NormalizeRunPodEndpoint converts a Runpod endpoint ID/slug into the executable OpenAI-compatible base URL. Full HTTP(S) URLs are preserved except for trailing-slash normalization. The helper is pure and performs no Runpod control-plane or inference I/O.

func ProviderProtocolKind added in v1.1.0

func ProviderProtocolKind(spec string, providerProtocol string) (protocolkind.ProtocolKind, bool)

ProviderProtocolKind resolves one exact concrete provider protocol to its shared semantic wire family.

func ProviderRequestPath

func ProviderRequestPath(providerSpec string, kind protocolkind.ProtocolKind) (string, error)

ProviderRequestPath resolves the HTTP subpath for a provider and protocol combination. It is the single source of truth for provider-edge request path selection so provider adapters do not each own the same protocol switch. The path is the bare operation (the API namespace is part of the authored base URL); every provider that runs over an OpenAI-compatible surface uses the same three operations.

func ProviderSetupKeywordSummaryForSpec

func ProviderSetupKeywordSummaryForSpec(spec string) string

ProviderSetupKeywordSummaryForSpec returns a compact picker-search inventory. It must not be used as setup behavior authority.

func ProviderSetupKeywordsForSpec

func ProviderSetupKeywordsForSpec(spec string) []string

ProviderSetupKeywordsForSpec returns non-authoritative search/copy keywords declared for one provider spec.

func RequiresCredential

func RequiresCredential(spec, baseURL string) bool

func RequiresLocator

func RequiresLocator(spec string) bool

func RoutingConstructionFacts

func RoutingConstructionFacts() routing.TargetConstructionFacts

RoutingConstructionFacts adapts the provider catalog to routing's construction contract. Construction boundaries use this function so provider aliases and conservative protocol defaults cannot diverge by transport.

func SupportedAuthHeadersForSpec

func SupportedAuthHeadersForSpec(spec string) []string

SupportedAuthHeadersForSpec returns the common auth-header picker options for a provider spec. Manual entry remains a separate escape hatch.

func SupportedExecutionProtocolsForSpec

func SupportedExecutionProtocolsForSpec(spec string) []protocolkind.ProtocolKind

func SupportedSpecs

func SupportedSpecs() []string

func SupportsBedrockMantleRegion

func SupportsBedrockMantleRegion(region string) bool

SupportsBedrockMantleRegion reports whether a region is in the canonical Mantle list.

func SupportsExecutionProtocolForSpec

func SupportsExecutionProtocolForSpec(spec string, protocolKind protocolkind.ProtocolKind) bool

func SupportsProviderProtocolForSpec

func SupportsProviderProtocolForSpec(spec string, providerProtocol string) bool

func SupportsSpec

func SupportsSpec(spec string) bool

func ValidateCatalogProfile added in v1.1.0

func ValidateCatalogProfile(provider Profile) error

ValidateCatalogProfile rejects incomplete profile metadata before it reaches routing, codecs, or operator projections. Concrete protocol names ending in `_stream` are SSE contracts; suffix-free names are buffered HTTP JSON contracts. Keeping that coherence in the catalog prevents a split-brain target from reaching Exchange.

func ValidateStandardConnection added in v1.1.0

func ValidateStandardConnection(provider routing.Provider, draft routing.StandardConnectionDraft) (routing.StandardConnectionDraft, error)

ValidateStandardConnection applies the complete profile-owned durable connection contract for one ordinary provider. Routing supplies this one construction fact and remains unaware of locator or credential policies.

Types

type BedrockEndpointResolution

type BedrockEndpointResolution struct {
	BaseURL          string
	RequestURL       string
	InputWasComplete bool
}

BedrockEndpointResolution is the single parsed representation of an operator-authored Bedrock endpoint paired with its selected protocol.

func ResolveBedrockEndpoint

func ResolveBedrockEndpoint(endpoint, region string, kind protocolkind.ProtocolKind) (BedrockEndpointResolution, error)

ResolveBedrockEndpoint normalizes one operator-authored inference API URL and appends only the selected protocol operation. Region validates canonical AWS hosts and supplies signing authority; it never supplies an inference namespace. Before protocol selection, one recognized terminal operation is stripped without inferring a protocol. A conflicting operation, catalog URL, namespace contradiction, or canonical host/region mismatch is rejected.

type BedrockMantleRegionSpec

type BedrockMantleRegionSpec struct {
	ID       string
	Label    string
	Keywords []string
}

BedrockMantleRegionSpec is one canonical Mantle region entry.

Label stays short for picker rows; Keywords carry city aliases and other search hints so the picker stays searchable without inventing a second row column.

func BedrockMantleRegions

func BedrockMantleRegions() []BedrockMantleRegionSpec

BedrockMantleRegions returns the canonical region catalog in stable order.

type CredentialAuthoring added in v1.1.0

type CredentialAuthoring uint8

CredentialAuthoring states how an operator supplies a credential that the connection requires. It is deliberately separate from CredentialRequirement: ChatGPT requires durable credential state but obtains it interactively, whereas Bedrock may use ambient AWS identity without a reference.

const (
	CredentialAuthoringInvalid CredentialAuthoring = iota
	CredentialAuthoringReference
	CredentialAuthoringNone
	CredentialAuthoringInteractive
	CredentialAuthoringAmbientOrReference
)

type CredentialRequirement

type CredentialRequirement uint8

CredentialRequirement states whether a durable credential reference is a valid or required target fact. It does not describe where credentials live.

const (
	CredentialUnsupported CredentialRequirement = iota
	CredentialRequired
	CredentialOptional
	CredentialRequiredOutsideLoopback
)

type CredentialSpec

type CredentialSpec struct {
	Requirement     CredentialRequirement
	Authoring       CredentialAuthoring
	SuggestedEnvVar string
	// AmbientLabel and ReferenceLabel are operator-facing authoring nouns for
	// AmbientOrReference. They never enter routing or provider requests.
	AmbientLabel   string
	ReferenceLabel string
}

type LocatorKind

type LocatorKind uint8
const (
	LocatorFixed LocatorKind = iota
	LocatorBaseURL
	LocatorAzureProject
	LocatorAWSRegion
)

type LocatorSpec

type LocatorSpec struct {
	Kind    LocatorKind
	Label   string
	Default string
}

LocatorSpec declares the provider-specific connection fact authored by an operator. Fixed providers may carry a runtime default without exposing input.

func LocatorSpecForProvider

func LocatorSpecForProvider(spec string) (LocatorSpec, bool)

type ModelAuthoringOption added in v1.1.0

type ModelAuthoringOption struct {
	Name                       string   `json:"name"`
	ModelName                  string   `json:"model_name,omitempty"`
	ModelPublisher             string   `json:"model_publisher,omitempty"`
	ModelVersion               string   `json:"model_version,omitempty"`
	Family                     string   `json:"family,omitempty"`
	SupportedProviderProtocols []string `json:"supported_provider_protocols,omitempty"`
	DefaultProviderProtocol    string   `json:"default_provider_protocol,omitempty"`
}

ModelAuthoringOption carries one advisory catalog option plus the provider facts that the UI and probe surfaces can render without re-inferring policy.

func CloneModelAuthoringOptions added in v1.1.0

func CloneModelAuthoringOptions(options []ModelAuthoringOption) []ModelAuthoringOption

CloneModelAuthoringOptions protects model-authoring options from accidental mutation by callers or transport renderers.

func NewModelAuthoringOption added in v1.1.0

func NewModelAuthoringOption(
	name string,
	modelName string,
	modelPublisher string,
	modelVersion string,
	family string,
	supportedProtocols []string,
	defaultProtocol string,
) ModelAuthoringOption

NewModelAuthoringOption builds one immutable model-authoring option from raw catalog data.

type ModelAuthoringResolution added in v1.1.0

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

ModelAuthoringResolution interprets one advisory model-authoring option against the provider spec that surfaced it. It keeps discovery facts separate from selection policy so callers can resolve lazily when they actually need a concrete protocol answer.

func ResolveModelAuthoringOption added in v1.1.0

func ResolveModelAuthoringOption(providerSpec string, option ModelAuthoringOption) ModelAuthoringResolution

ResolveModelAuthoringOption returns one conservative resolver for one model-authoring option under one provider spec.

func (ModelAuthoringResolution) DefaultProtocol added in v1.1.0

func (r ModelAuthoringResolution) DefaultProtocol() string

DefaultProtocol returns the explicit option default when present and supported. Sparse options do not invent one.

func (ModelAuthoringResolution) ProtocolOptions added in v1.1.0

func (r ModelAuthoringResolution) ProtocolOptions() []string

ProtocolOptions returns the concrete protocols available for the option. Explicit option metadata wins; sparse option metadata inherits the provider manifest's concrete protocol list.

func (ModelAuthoringResolution) SupportsProtocol added in v1.1.0

func (r ModelAuthoringResolution) SupportsProtocol(protocol string) bool

SupportsProtocol reports whether one concrete protocol is present in the resolved option set.

type ModelDiscoveryMode added in v1.1.0

type ModelDiscoveryMode uint8

ModelDiscoveryMode states whether target authoring has an advisory model discovery facet. It is static authoring metadata, not a conclusion drawn from an empty probe result or a model name.

const (
	ModelDiscoveryModeInvalid ModelDiscoveryMode = iota
	ModelDiscoveryModeAdvisory
	ModelDiscoveryModeNone
)

func ModelDiscoveryModeForSpec added in v1.1.0

func ModelDiscoveryModeForSpec(spec string) ModelDiscoveryMode

type Profile

type Profile struct {
	ProviderID          ProviderID
	ProviderDisplayName string
	SetupHint           string
	// SetupKeywords are search/copy hints only. Locator owns connection
	// semantics; these keywords must not drive setup behavior.
	SetupKeywords       []string
	Locator             LocatorSpec
	Credential          CredentialSpec
	ConnectionShape     routing.ConnectionShape
	ModelDiscovery      ModelDiscoveryMode
	CatalogItemLabel    string
	DefaultAuthHeader   string
	VisibleInOperatorUI bool
	// ProviderProtocols is ordered by preference. The first concrete provider
	// contract is the static default; operators may explicitly select any later
	// contract, including a delivery variant of the same semantic kind.
	ProviderProtocols []ProviderProtocolSpec
}

Profile is one canonical provider declaration.

Add/remove/evolve provider specs in this catalog only.

func All

func All() []Profile

func ProfileForSpec added in v1.1.0

func ProfileForSpec(spec string) (Profile, bool)

ProfileForSpec returns the canonical profile for one supported provider identifier. Consumers use its facts without copying catalog membership into their own lookup table.

type ProviderID

type ProviderID string

ProviderID is the canonical provider identity used across runtime seams.

const (
	ProviderSpecOllama      ProviderID = "ollama"
	ProviderSpecLMStudio    ProviderID = "lmstudio"
	ProviderSpecVLLM        ProviderID = "vllm"
	ProviderSpecOpenAI      ProviderID = "openai"
	ProviderSpecChatGPT     ProviderID = "chatgpt"
	ProviderSpecGemini      ProviderID = "gemini"
	ProviderSpecAnthropic   ProviderID = "anthropic"
	ProviderSpecDeepSeek    ProviderID = "deepseek"
	ProviderSpecKimi        ProviderID = "kimi"
	ProviderSpecMistral     ProviderID = "mistral"
	ProviderSpecCerebras    ProviderID = "cerebras"
	ProviderSpecWorkersAI   ProviderID = "workersai"
	ProviderSpecLLM7        ProviderID = "llm7"
	ProviderSpecRunPod      ProviderID = "runpod"
	ProviderSpecNVIDIA      ProviderID = "nvidia"
	ProviderSpecFriendli    ProviderID = "friendli"
	ProviderSpecTogether    ProviderID = "together"
	ProviderSpecDeepInfra   ProviderID = "deepinfra"
	ProviderSpecScaleway    ProviderID = "scaleway"
	ProviderSpecSambaNova   ProviderID = "sambanova"
	ProviderSpecStepFun     ProviderID = "stepfun"
	ProviderSpecNebius      ProviderID = "nebius"
	ProviderSpecGMI         ProviderID = "gmi"
	ProviderSpecGroq        ProviderID = "groq"
	ProviderSpecFireworks   ProviderID = "fireworks"
	ProviderSpecOpenRouter  ProviderID = "openrouter"
	ProviderSpecZAI         ProviderID = "zai"
	ProviderSpecBedrock     ProviderID = "bedrock"
	ProviderSpecAzure       ProviderID = "azure"
	ProviderSpecCustom      ProviderID = "custom"
	ProviderSpecNovita      ProviderID = "novita"
	ProviderSpecBaseten     ProviderID = "baseten"
	ProviderSpecHyperbolic  ProviderID = "hyperbolic"
	ProviderSpecSiliconFlow ProviderID = "siliconflow"
	ProviderSpecOVHCloud    ProviderID = "ovhcloud"
	ProviderSpecModelScope  ProviderID = "modelscope"
)

func ParseProviderID

func ParseProviderID(raw string) (ProviderID, bool)

ParseProviderID parses one provider identifier from external input. Parsing is strict: callers must pass canonical values already validated at client boundary.

type ProviderProtocolSpec

type ProviderProtocolSpec struct {
	// Name is the concrete provider contract persisted in routing and operator
	// projections. Kind names the shared semantic wire grammar; Delivery names
	// the upstream response carrier selected by this concrete contract.
	Name     string
	Kind     protocolkind.ProtocolKind
	Delivery delivery.Delivery
}

func ProviderProtocolSpecForSpec added in v1.1.0

func ProviderProtocolSpecForSpec(spec string, providerProtocol string) (ProviderProtocolSpec, bool)

ProviderProtocolSpecForSpec resolves one exact concrete provider contract.

Jump to

Keyboard shortcuts

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