credential

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
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

func ContextWithoutProbeDisambiguation(ctx context.Context) context.Context

ContextWithoutProbeDisambiguation skips live API probes during ResolveCredential (tests).

func FormatOllamaConnectError

func FormatOllamaConnectError(err error) error

FormatOllamaConnectError turns probe/network failures into actionable setup hints.

func LooksLikePlaceholderSecret

func LooksLikePlaceholderSecret(secret string) bool

LooksLikePlaceholderSecret reports obvious non-secrets (templates, examples, too short).

func NormalizeOllamaOpenAIBaseURL

func NormalizeOllamaOpenAIBaseURL(baseURL string) string

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

func ProbeCredential(ctx context.Context, envKey, secret string) error

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

func ProbeLocalCredential(ctx context.Context, envKey, value string) error

ProbeLocalCredential verifies a local provider endpoint when configured.

func ProviderIDForEnv

func ProviderIDForEnv(envKey string) string

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

func ValidateCredentialSecret(envKey, secret string) error

ValidateCredentialSecret rejects placeholders and obviously invalid keys before persistence.

func ValidateKeyFormat

func ValidateKeyFormat(secret string) error

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

type MimoProbeConfig struct {
	TokenPlanRegion string
	TokenPlanBase   string
	PaygBase        string
}

MimoProbeConfig carries Token Plan / payg routing from provider.json for probes.

Jump to

Keyboard shortcuts

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