-- Built-in interface definitions. Mirrors backend/services/interface_catalog.py.

INSERT INTO interface_definitions
  (interface_type, name, capability, field_schema, enabled, version)
VALUES
  ('openai-llm', 'OpenAI Compatible LLM', 'LLM',
   $$ {"fields":[
     {"key":"modelId","label":"Model ID","group":"values","type":"text","required":true},
     {"key":"apiUrl","label":"API URL","group":"values","type":"url","required":true},
     {"key":"apiKey","label":"API Key","group":"secrets","type":"password","required":true},
     {"key":"temperature","label":"Temperature","group":"values","type":"number","required":false,"default":0.7}
   ]} $$::jsonb, TRUE, 1),
  ('openai-asr', 'OpenAI Compatible ASR', 'ASR',
   $$ {"fields":[
     {"key":"modelId","label":"Model ID","group":"values","type":"text","required":true},
     {"key":"apiUrl","label":"API URL","group":"values","type":"url","required":true},
     {"key":"apiKey","label":"API Key","group":"secrets","type":"password","required":true},
     {"key":"language","label":"Language","group":"values","type":"text","required":false,"default":"zh"}
   ]} $$::jsonb, TRUE, 1),
  ('openai-tts', 'OpenAI Compatible TTS', 'TTS',
   $$ {"fields":[
     {"key":"modelId","label":"Model ID","group":"values","type":"text","required":true},
     {"key":"apiUrl","label":"API URL","group":"values","type":"url","required":true},
     {"key":"apiKey","label":"API Key","group":"secrets","type":"password","required":true},
     {"key":"voice","label":"Voice","group":"values","type":"text","required":false},
     {"key":"speed","label":"Speed","group":"values","type":"number","required":false,"default":1.0},
     {"key":"sourceSampleRate","label":"Source Sample Rate","group":"values","type":"number","required":false,"default":24000}
   ]} $$::jsonb, TRUE, 1),
  ('openai-embedding', 'OpenAI Compatible Embedding', 'Embedding',
   $$ {"fields":[
     {"key":"modelId","label":"Model ID","group":"values","type":"text","required":true},
     {"key":"apiUrl","label":"API URL","group":"values","type":"url","required":true},
     {"key":"apiKey","label":"API Key","group":"secrets","type":"password","required":true},
     {"key":"dimensions","label":"Dimensions","group":"values","type":"number","required":false}
   ]} $$::jsonb, TRUE, 1),
  ('openai-realtime', 'OpenAI Realtime', 'Realtime',
   $$ {"fields":[
     {"key":"modelId","label":"Model ID","group":"values","type":"text","required":true},
     {"key":"apiUrl","label":"API URL","group":"values","type":"url","required":true},
     {"key":"apiKey","label":"API Key","group":"secrets","type":"password","required":true},
     {"key":"voice","label":"Voice","group":"values","type":"text","required":false}
   ]} $$::jsonb, TRUE, 1),
  ('dify', 'Dify Agent', 'Agent',
   $$ {"fields":[
     {"key":"apiUrl","label":"API URL","group":"values","type":"url","required":true},
     {"key":"apiKey","label":"API Key","group":"secrets","type":"password","required":true}
   ]} $$::jsonb, TRUE, 1),
  ('fastgpt', 'FastGPT Agent', 'Agent',
   $$ {"fields":[
     {"key":"apiUrl","label":"API URL","group":"values","type":"url","required":true},
     {"key":"apiKey","label":"API Key","group":"secrets","type":"password","required":true},
     {"key":"appId","label":"App ID","group":"values","type":"text","required":true}
   ]} $$::jsonb, TRUE, 1),
  ('opencode', 'OpenCode Agent', 'Agent',
   $$ {"fields":[
     {"key":"apiUrl","label":"API URL","group":"values","type":"url","required":true},
     {"key":"apiKey","label":"API Key","group":"secrets","type":"password","required":true}
   ]} $$::jsonb, TRUE, 1),
  ('stepfun-realtime', 'StepFun StepAudio Realtime', 'Realtime',
   $$ {"fields":[
     {"key":"modelId","label":"Model ID","group":"values","type":"text","required":true},
     {"key":"apiUrl","label":"API URL","group":"values","type":"url","required":true},
     {"key":"apiKey","label":"API Key","group":"secrets","type":"password","required":true},
     {"key":"voice","label":"Voice","group":"values","type":"text","required":true,"default":"linjiajiejie"},
     {"key":"inputSampleRate","label":"Input Sample Rate","group":"values","type":"number","required":false,"default":24000},
     {"key":"outputSampleRate","label":"Output Sample Rate","group":"values","type":"number","required":false,"default":24000},
     {"key":"prefixPaddingMs","label":"VAD Prefix Padding (ms)","group":"values","type":"number","required":false,"default":500},
     {"key":"silenceDurationMs","label":"VAD Silence Duration (ms)","group":"values","type":"number","required":false,"default":300},
     {"key":"energyAwakenessThreshold","label":"VAD Energy Threshold","group":"values","type":"number","required":false,"default":2500}
   ]} $$::jsonb, TRUE, 1),
  ('xfyun-asr', 'Xfyun Streaming ASR', 'ASR',
   $$ {"fields":[
     {"key":"apiUrl","label":"WebSocket URL","group":"values","type":"url","required":true},
     {"key":"appId","label":"App ID","group":"secrets","type":"password","required":true},
     {"key":"apiKey","label":"API Key","group":"secrets","type":"password","required":true},
     {"key":"apiSecret","label":"API Secret","group":"secrets","type":"password","required":true},
     {"key":"language","label":"Language","group":"values","type":"text","required":false,"default":"zh_cn"},
     {"key":"domain","label":"Domain","group":"values","type":"text","required":false,"default":"iat"},
     {"key":"accent","label":"Accent","group":"values","type":"text","required":false,"default":"mandarin"},
     {"key":"dynamicCorrection","label":"Dynamic Correction","group":"values","type":"boolean","required":false,"default":false},
     {"key":"frameSize","label":"Frame Size","group":"values","type":"number","required":false,"default":1280}
   ]} $$::jsonb, TRUE, 1),
  ('xfyun-tts', 'Xfyun TTS', 'TTS',
   $$ {"fields":[
     {"key":"apiUrl","label":"WebSocket URL","group":"values","type":"url","required":true},
     {"key":"appId","label":"App ID","group":"secrets","type":"password","required":true},
     {"key":"apiKey","label":"API Key","group":"secrets","type":"password","required":true},
     {"key":"apiSecret","label":"API Secret","group":"secrets","type":"password","required":true},
     {"key":"voice","label":"Voice","group":"values","type":"text","required":false},
     {"key":"speed","label":"Speed","group":"values","type":"number","required":false,"default":50},
     {"key":"volume","label":"Volume","group":"values","type":"number","required":false,"default":50},
     {"key":"pitch","label":"Pitch","group":"values","type":"number","required":false,"default":50},
     {"key":"sourceSampleRate","label":"Source Sample Rate","group":"values","type":"number","required":false,"default":16000}
   ]} $$::jsonb, TRUE, 1),
  ('xfyun-super-tts', 'Xfyun Super TTS', 'TTS',
   $$ {"fields":[
     {"key":"apiUrl","label":"WebSocket URL","group":"values","type":"url","required":true},
     {"key":"appId","label":"App ID","group":"secrets","type":"password","required":true},
     {"key":"apiKey","label":"API Key","group":"secrets","type":"password","required":true},
     {"key":"apiSecret","label":"API Secret","group":"secrets","type":"password","required":true},
     {"key":"voice","label":"Voice","group":"values","type":"text","required":false},
     {"key":"speed","label":"Speed","group":"values","type":"number","required":false,"default":50},
     {"key":"volume","label":"Volume","group":"values","type":"number","required":false,"default":50},
     {"key":"pitch","label":"Pitch","group":"values","type":"number","required":false,"default":50},
     {"key":"oralLevel","label":"Oral Level","group":"values","type":"text","required":false,"default":"mid"},
     {"key":"sourceSampleRate","label":"Source Sample Rate","group":"values","type":"number","required":false,"default":24000},
     {"key":"textAggregationMode","label":"Text Aggregation Mode","group":"values","type":"text","required":false,"default":"token"}
   ]} $$::jsonb, TRUE, 1),
  ('dashscope-asr', 'DashScope ASR', 'ASR',
   $$ {"fields":[
     {"key":"modelId","label":"Model ID","group":"values","type":"text","required":true},
     {"key":"apiUrl","label":"API URL","group":"values","type":"url","required":true},
     {"key":"apiKey","label":"API Key","group":"secrets","type":"password","required":true},
     {"key":"language","label":"Language","group":"values","type":"text","required":false,"default":"zh"}
   ]} $$::jsonb, TRUE, 1),
  ('dashscope-tts', 'DashScope TTS', 'TTS',
   $$ {"fields":[
     {"key":"modelId","label":"Model ID","group":"values","type":"text","required":true},
     {"key":"apiUrl","label":"API URL","group":"values","type":"url","required":true},
     {"key":"apiKey","label":"API Key","group":"secrets","type":"password","required":true},
     {"key":"voice","label":"Voice","group":"values","type":"text","required":false}
   ]} $$::jsonb, TRUE, 1),
  ('gemini-realtime', 'Gemini Realtime', 'Realtime',
   $$ {"fields":[
     {"key":"modelId","label":"Model ID","group":"values","type":"text","required":true},
     {"key":"apiUrl","label":"API URL","group":"values","type":"url","required":true},
     {"key":"apiKey","label":"API Key","group":"secrets","type":"password","required":true}
   ]} $$::jsonb, TRUE, 1)
ON CONFLICT (interface_type) DO UPDATE SET
  name = EXCLUDED.name,
  capability = EXCLUDED.capability,
  field_schema = EXCLUDED.field_schema,
  enabled = TRUE,
  version = EXCLUDED.version,
  updated_at = now();
