Documentation
¶
Index ¶
- Constants
- func CommitCredential(ctx context.Context, inference CredentialInference, secret string) error
- func CommitLocalCredential(ctx context.Context, inference CredentialInference, value string) error
- func ContextWithoutProbeDisambiguation(ctx context.Context) context.Context
- func FormatOllamaConnectError(err error) error
- func LooksLikePlaceholderSecret(secret string) bool
- func NormalizeOllamaOpenAIBaseURL(baseURL string) string
- func PrepareCredentialForSave(inference CredentialInference, secret string) (string, error)
- func ProbeCredential(ctx context.Context, envKey, secret string) error
- func ProbeCredentialWithMimo(ctx context.Context, envKey, secret string, mimo MimoProbeConfig) error
- func ProbeLocalCredential(ctx context.Context, envKey, value string) error
- func ProviderIDForEnv(envKey string) string
- func SetMimoProbeConfigLoader(fn func() MimoProbeConfig)
- func ValidateCredentialBeforeSave(inference CredentialInference, secret string) error
- func ValidateCredentialSecret(envKey, secret string) error
- func ValidateKeyFormat(secret string) error
- type CredentialInference
- func InferCredentialsFromAPIKey(ctx context.Context, secret string) []CredentialInference
- func InferenceForProvider(providerID string) (CredentialInference, error)
- func InferenceFromOption(opt CredentialProviderOption) CredentialInference
- func LocalCredentialInference(providerID string) (CredentialInference, error)
- type CredentialProviderOption
- type CredentialResolveResult
- type MimoProbeConfig
Constants ¶
const OllamaDefaultBaseURL = ollamaDefaultBaseURL
OllamaDefaultBaseURL is the default OpenAI-compatible Ollama endpoint.
Variables ¶
This section is empty.
Functions ¶
func CommitCredential ¶
func CommitCredential(ctx context.Context, inference CredentialInference, secret string) error
CommitCredential validates and probes a credential before persistence (host calls before SetCredential).
func CommitLocalCredential ¶
func CommitLocalCredential(ctx context.Context, inference CredentialInference, value string) error
CommitLocalCredential validates and probes a no-key provider (e.g. Ollama base URL).
func ContextWithoutProbeDisambiguation ¶
ContextWithoutProbeDisambiguation skips live API probes during ResolveCredential (tests).
func FormatOllamaConnectError ¶
FormatOllamaConnectError turns probe/network failures into actionable setup hints.
func LooksLikePlaceholderSecret ¶
LooksLikePlaceholderSecret reports obvious non-secrets (templates, examples, too short).
func NormalizeOllamaOpenAIBaseURL ¶
NormalizeOllamaOpenAIBaseURL ensures the URL ends with /v1.
func PrepareCredentialForSave ¶
func PrepareCredentialForSave(inference CredentialInference, secret string) (string, error)
PrepareCredentialForSave returns the normalized secret to persist (e.g. Ollama base URL).
func ProbeCredential ¶
ProbeCredential verifies a key against the provider API when a probe is configured.
func ProbeCredentialWithMimo ¶
func ProbeCredentialWithMimo(ctx context.Context, envKey, secret string, mimo MimoProbeConfig) error
ProbeCredentialWithMimo is like ProbeCredential but accepts persisted MiMo routing fields.
func ProbeLocalCredential ¶
ProbeLocalCredential verifies a local provider endpoint when configured.
func ProviderIDForEnv ¶
ProviderIDForEnv maps an env var to registry provider id.
func SetMimoProbeConfigLoader ¶
func SetMimoProbeConfigLoader(fn func() MimoProbeConfig)
SetMimoProbeConfigLoader supplies MiMo region/base from host config (e.g. provider.json).
func ValidateCredentialBeforeSave ¶
func ValidateCredentialBeforeSave(inference CredentialInference, secret string) error
ValidateCredentialBeforeSave checks format/placeholders without a live API probe.
func ValidateCredentialSecret ¶
ValidateCredentialSecret rejects placeholders and obviously invalid keys before persistence.
func ValidateKeyFormat ¶
ValidateKeyFormat checks a pasted secret before any provider is chosen.
Types ¶
type CredentialInference ¶
type CredentialInference struct {
ProviderID string `json:"provider_id"`
DeploymentID string `json:"deployment_id"`
EnvVar string `json:"env_var"`
DisplayName string `json:"display_name"`
}
CredentialInference is save metadata for a gateway chosen in setup UI (no secret).
func InferCredentialsFromAPIKey ¶
func InferCredentialsFromAPIKey(ctx context.Context, secret string) []CredentialInference
InferCredentialsFromAPIKey is deprecated: setup is gateway-first (select provider, then paste key).
func InferenceForProvider ¶
func InferenceForProvider(providerID string) (CredentialInference, error)
InferenceForProvider returns save metadata for a gateway chosen in setup UI.
func InferenceFromOption ¶
func InferenceFromOption(opt CredentialProviderOption) CredentialInference
InferenceFromOption converts a picker row back to persistence metadata.
func LocalCredentialInference ¶
func LocalCredentialInference(providerID string) (CredentialInference, error)
LocalCredentialInference returns setup metadata for no-key providers (e.g. Ollama).
type CredentialProviderOption ¶
type CredentialProviderOption struct {
ProviderID string `json:"provider_id"`
DeploymentID string `json:"deployment_id"`
EnvVar string `json:"env_var"`
DisplayName string `json:"display_name"`
Inferred bool `json:"inferred"`
RequiresKey bool `json:"requires_key"`
Rank int `json:"rank"`
}
CredentialProviderOption is one row for host provider pickers (JSON-safe).
func ListCredentialProviders ¶
func ListCredentialProviders() []CredentialProviderOption
ListCredentialProviders returns all registered setup providers (including local gateways).
type CredentialResolveResult ¶
type CredentialResolveResult struct {
FormatOK bool `json:"format_ok"`
FormatError string `json:"format_error,omitempty"`
Providers []CredentialProviderOption `json:"providers"`
// ProbeDisambiguationUsed is true when ambiguous keys were verified via live provider probes.
ProbeDisambiguationUsed bool `json:"probe_disambiguation_used,omitempty"`
}
CredentialResolveResult is returned after paste-key format validation + provider listing.
func ResolveCredential ¶
func ResolveCredential(ctx context.Context, secret string) CredentialResolveResult
ResolveCredential validates format and lists API-key gateways in registry order. Host apps must select the gateway first; key shape is not used for provider inference.
type MimoProbeConfig ¶
MimoProbeConfig carries Token Plan / payg routing from provider.json for probes.