Documentation
¶
Index ¶
- func DefaultCallOptions() domain.CallOptions
- func EnsureTimeout(t time.Duration) time.Duration
- func NewProvider(cfg *config.Config, store credential.CredentialStore, warnW io.Writer) (domain.AIProvider, error)
- func ResolveAPIKey(provider, configKey string, store credential.CredentialStore, warnW io.Writer) (string, error)
- func ResolveOptions(defaults domain.CallOptions, opts ...domain.Option) domain.CallOptions
- func SafeHTTPClient() *http.Client
- func TruncateForError(s string, maxLen int) string
- func ValidateEndpoint(endpoint string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultCallOptions ¶
func DefaultCallOptions() domain.CallOptions
DefaultCallOptions returns sensible defaults for AI provider calls.
func EnsureTimeout ¶
EnsureTimeout returns t if positive, otherwise the default 60s.
func NewProvider ¶
func NewProvider(cfg *config.Config, store credential.CredentialStore, warnW io.Writer) (domain.AIProvider, error)
NewProvider creates an AIProvider based on configuration. Returns (nil, nil) when no provider is configured (zero-API mode). store may be nil (keychain unavailable). warnW receives plaintext warnings.
func ResolveAPIKey ¶
func ResolveAPIKey(provider, configKey string, store credential.CredentialStore, warnW io.Writer) (string, error)
ResolveAPIKey resolves an API key using the priority chain: 1. LORE_AI_API_KEY env var (no warning) 2. keychain via store.Get() if key is "" or "@keychain" 3. plaintext config value (emits warning) 4. empty string (caller decides if error)
func ResolveOptions ¶
func ResolveOptions(defaults domain.CallOptions, opts ...domain.Option) domain.CallOptions
ResolveOptions applies variadic options over defaults, returning final options.
func SafeHTTPClient ¶
SafeHTTPClient returns an http.Client with connection limits, a global timeout, and redirect-following disabled (prevents SSRF via open redirects).
func TruncateForError ¶
TruncateForError returns s truncated to maxLen bytes for safe inclusion in error messages. Prevents multi-MB response bodies from being propagated in error chains.
func ValidateEndpoint ¶
ValidateEndpoint checks that an endpoint URL uses http or https scheme only. Rejects file://, gopher://, javascript:, and other dangerous schemes. Also rejects plain http for non-localhost endpoints to prevent credential leakage.
Types ¶
This section is empty.