import 'package:cutdex_agent/cutdex_agent.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; import 'agent_prompt_policy.dart'; part 'agent_models.freezed.dart'; enum AgentApiType { openAiChatCompletions, openAiResponses, anthropicMessages } @freezed abstract class AgentModelSettings with _$AgentModelSettings { const AgentModelSettings._(); const factory AgentModelSettings({ required String id, int? contextWindow, int? maxOutputTokens, }) = _AgentModelSettings; /// Reserve at most half of a small window when output is unspecified. int get effectiveMaxOutputTokens => maxOutputTokens ?? (contextWindow == null || contextWindow! >= 8192 ? 4096 : contextWindow! ~/ 2); int get effectiveMaxInputTokens => contextWindow == null ? 32000 : contextWindow! - effectiveMaxOutputTokens; bool get hasInstructionBudget => effectiveMaxInputTokens >= ContextBuilder().measureInput(system: AgentPromptPolicy.editorAssistant); bool get hasValidTokenBudget => effectiveMaxInputTokens > 0 && effectiveMaxOutputTokens > 0; } @freezed abstract class AgentProviderSettings with _$AgentProviderSettings { const AgentProviderSettings._(); const factory AgentProviderSettings({ required String id, required String name, required String apiType, required String baseUrl, required List models, String? credentialId, @Default(true) bool enabled, }) = _AgentProviderSettings; } @freezed abstract class AgentSettingsState with _$AgentSettingsState { const AgentSettingsState._(); const factory AgentSettingsState({ @Default(false) bool enabled, @Default([]) List providers, String? selectedProviderId, String? selectedModelId, @Default(0) int revision, }) = _AgentSettingsState; } abstract interface class AgentSettingsRepository { Future load(); Future save(AgentSettingsState settings); }