// Environment and configuration types export type Environment = 'dev' | 'production'; export interface EnvironmentHosts { copilot: string; evaluations: string; middleware: string; } export interface IndemnConfig { api_key: string; org_id: string; org_name?: string; user_id: string; environment: Environment; hosts: Record; } // API response types export interface ApiResponse { success: boolean; data: T; msg?: string; } // Agent types export interface Agent { _id: string; name: string; description?: string; channels?: string[]; webhook_url?: string; webhook_enabled?: boolean; trashed?: boolean; id_project?: string; createdAt?: string; updatedAt?: string; } export interface AgentExpanded extends Agent { configurations?: BotConfiguration; functions?: BotFunction[]; mappings?: KBMapping[]; } export interface CreateAgentInput { name: string; channels?: string[]; } export interface UpdateAgentInput { name?: string; description?: string; webhook_url?: string; webhook_enabled?: boolean; } // Bot configuration types export interface AIConfig { system_prompt?: string; system_prompt_ops?: Record; use_default_prompt?: boolean; kb_configuration?: { namespace?: string; index_name?: string; embedding_provider?: string; }; is_reranking_enabled?: boolean; identify_next_step_enabled?: boolean; } export interface FirstMessage { text?: string; quick_replies?: Array<{ type: string; title: string; payload: string }>; } export interface BotConfiguration { ai_config?: AIConfig; first_message?: FirstMessage; is_button_enabled?: boolean; [key: string]: unknown; } export interface SetConfigInput { system_prompt?: string; first_message?: FirstMessage; [key: string]: unknown; } // Function/tool types export interface BotFunction { _id: string; type: string; description?: string; name?: string; url?: string; method?: string; headers?: Record; body?: Record; parameters?: FunctionParameter[]; configurationSchema?: Record; executionSchema?: Record; id_bot?: string; createdAt?: string; updatedAt?: string; } export interface FunctionParameter { _id?: string; name: string; type: string; description?: string; is_required?: boolean; } export interface CreateFunctionInput { type: string; description?: string; name?: string; // Server stores configurationSchema and converts to executionSchema in the update path. // Note: url/method/headers/body at the root are unused legacy fields — actual REST API // config lives inside configurationSchema. See AI-369. configurationSchema?: Record; url?: string; method?: string; headers?: Record; body?: Record; } export interface UpdateFunctionInput { type?: string; description?: string; name?: string; configurationSchema?: Record; url?: string; method?: string; headers?: Record; body?: Record; } // Knowledge base types export interface KnowledgeBase { _id: string; name: string; type?: string; description?: string; id_project?: string; createdAt?: string; updatedAt?: string; } export interface CreateKBInput { name: string; type: string; } export interface UpdateKBInput { name?: string; description?: string; } export interface DataSource { _id: string; name?: string; type?: string; content?: string; question?: string; answer?: string; source_url?: string; status?: string; id_kb?: string; createdAt?: string; updatedAt?: string; } export interface AddDataSourceInput { question?: string; answer?: string; name?: string; source_url?: string; content?: string; } export interface KBMapping { _id: string; id_bot: string; id_kb: string; } // Evaluation types export interface RubricRule { id: string; name: string; severity: 'high' | 'medium' | 'low'; category: 'persona' | 'instruction_compliance' | 'safety' | 'response_quality'; description: string; component_scope?: 'prompt' | 'general' | 'function' | 'knowledge_base'; component_ids?: string[] | null; component_names?: string[] | null; evaluation_criteria?: { pass_conditions: string[]; fail_conditions: string[]; }; } export interface Rubric { _id?: string; rubric_id?: string; agent_id?: string; name: string; description?: string; version?: number; severity_definitions?: Record; rules: RubricRule[]; createdAt?: string; updatedAt?: string; } export interface CreateRubricInput { agent_id?: string; name: string; description?: string; severity_definitions?: Record; rules: RubricRule[]; } export interface TestItem { type: 'single_turn' | 'scenario' | 'voice_simulation'; name: string; inputs: { message?: string; persona?: string; initial_message?: string; max_turns?: number; }; expected: { success_criteria: string[]; expected_outcome?: string; }; tags?: string[]; priority?: 'high' | 'medium' | 'low'; } export interface TestSet { _id?: string; test_set_id?: string; agent_id?: string; name: string; description?: string; version?: number; items: TestItem[]; createdAt?: string; updatedAt?: string; } export interface CreateTestSetInput { agent_id?: string; name: string; description?: string; items: TestItem[]; } export interface EvaluationTriggerInput { bot_id: string; test_set_id: string; rubric_id?: string; concurrency?: number; eval_model?: string; keep?: boolean; limit?: number; component_scope?: string; component_ids?: string[]; conversation_ids?: string[]; mode?: string; } export interface EvaluationTriggerResponse { run_id: string; dataset_id?: string; config_id?: string; status: string; total?: number; items_count?: number; rules_count?: number; } export interface EvaluationRun { run_id: string; dataset_id?: string; agent_id?: string; status: 'pending' | 'running' | 'completed' | 'failed'; total?: number; completed?: number; passed?: number; failed?: number; concurrency?: number; started_at?: string; completed_at?: string; error?: string; criteria_passed?: number; criteria_total?: number; rubric_rules_passed?: number; rubric_rules_total?: number; component_scores?: Record; rubric_id?: string; rubric_version?: number; test_set_id?: string; test_set_version?: number; bot_llm_provider?: string; bot_llm_model?: string; } export interface EvaluationResult { [key: string]: unknown; } export interface BotContext { system_prompt?: string; tools?: BotFunction[]; knowledge_bases?: KnowledgeBase[]; llm_config?: Record; [key: string]: unknown; } // Chat types export interface ChatMessage { text: string; streaming?: boolean; streamId?: string; isFirstChunk?: boolean; streamFinished?: boolean; } export interface SessionRequest { session_id: string | null; bot_type: string; user_id: string; customData: Record; } export interface UserMessage { message: string; messageType: 'text'; bot_type: string; user_id: string; session_id: string; is_user_message_sent: boolean; }