utils/provider/provider_profile library

Classes

BenchmarkedOllamaModel
Benchmarked Ollama model with latency data.
CodexCredentials
Resolved codex credentials.
OllamaModelDescriptor
Ollama model descriptor.
ProfileEnv
Environment variables for a provider profile.
ProfileFile
Persisted profile file structure.
RankedOllamaModel
Ranked Ollama model with score and reasons.
SystemPromptBlock
A block of system prompt text with cache scope.

Enums

CacheScope
Cache scope for system prompt blocks.
ProviderProfile
Supported provider profiles.
RecommendationGoal
Recommendation goal for model selection.

Functions

appendSystemContext({required SystemPrompt systemPrompt, required Map<String, String> context}) List<String>
Append system context entries to the system prompt.
applyBenchmarkLatency({required List<RankedOllamaModel> models, required Map<String, int?> benchmarkMs, required RecommendationGoal goal}) List<BenchmarkedOllamaModel>
Apply benchmark latency data to ranked models, re-sort by adjusted score.
buildCodexProfileEnv({String? model, String? baseUrl, String? apiKey, Map<String, String>? processEnv, CodexCredentialResolver? resolveCodexApiCredentials}) ProfileEnv?
Build a Codex profile environment. Returns null if credentials unavailable.
buildGeminiProfileEnv({String? model, String? baseUrl, String? apiKey, Map<String, String>? processEnv}) ProfileEnv?
Build a Gemini profile environment. Returns null if no API key found.
buildLaunchEnv({required ProviderProfile profile, required ProfileFile? persisted, required RecommendationGoal goal, Map<String, String>? processEnv, String getOllamaChatBaseUrl(String? baseUrl)?, Future<String> resolveOllamaDefaultModel(RecommendationGoal goal)?, ProviderRequestResolver? resolveProviderRequest, CodexCredentialResolver? resolveCodexApiCredentials, bool isCodexBaseUrl(String url)?}) Future<Map<String, String>>
Build the full launch environment for a given profile.
buildOllamaProfileEnv({required String model, String? baseUrl, required String getOllamaChatBaseUrl(String? baseUrl)}) ProfileEnv
Build an Ollama profile environment.
buildOpenAIProfileEnv({required RecommendationGoal goal, String? model, String? baseUrl, String? apiKey, Map<String, String>? processEnv, ProviderRequestResolver? resolveProviderRequest}) ProfileEnv?
Build an OpenAI profile environment. Returns null if no API key found.
createProfileFile({required ProviderProfile profile, required ProfileEnv env}) ProfileFile
Create a profile file with current timestamp.
getGoalDefaultOpenAIModel(RecommendationGoal goal) String
Get the default OpenAI model for a goal.
isViableOllamaChatModel(OllamaModelDescriptor model) bool
Check if a model is viable for chat (not embedding/reranking).
normalizeRecommendationGoal(String? goal) RecommendationGoal
Normalize a recommendation goal string to enum.
normalizeToolInput({required String toolName, required Map<String, dynamic> input, String? cwd, String? agentId, Map<String, dynamic> getPlan(String? agentId)?}) Map<String, dynamic>
Normalize tool input for specific tools before execution.
normalizeToolInputForAPI({required String toolName, required Map<String, dynamic> input}) Map<String, dynamic>
Strip injected fields before sending to API.
prependUserContext({required List<Map<String, dynamic>> messages, required Map<String, String> context}) List<Map<String, dynamic>>
Prepend user context as a system-reminder message.
rankOllamaModels({required List<OllamaModelDescriptor> models, required RecommendationGoal goal}) List<RankedOllamaModel>
Rank Ollama models by composite score for a given goal.
recommendOllamaModel({required List<OllamaModelDescriptor> models, required RecommendationGoal goal}) RankedOllamaModel?
Recommend the best Ollama model for a given goal.
sanitizeApiKey(String? key) String?
Sanitize an API key, returning null for empty or placeholder values.
selectAutoProfile({required String? recommendedOllamaModel}) ProviderProfile
Select auto profile based on recommended Ollama model availability.
selectRecommendedOllamaModel<T extends OllamaModelDescriptor>(List<T> models) → T?
Select the first viable chat model from a list.
splitSysPromptPrefix({required SystemPrompt systemPrompt, bool skipGlobalCacheForSystemPrompt = false, bool useGlobalCacheFeature = false, String? dynamicBoundary, Set<String>? cliSyspromptPrefixes}) List<SystemPromptBlock>
Split system prompt blocks by content type for API cache control.

Typedefs

CodexCredentialResolver = CodexCredentials? Function({String? codexApiKey, Map<String, String>? processEnv})
Callback type for resolving codex API credentials.
ProviderRequestResolver = String Function({String? baseUrl, required String fallbackModel, String? model})
Callback type for resolving provider transport.
SystemPrompt = List<String>
System prompt is a list of strings.