import { defineGateway } from '../define.js'

export default defineGateway({
  id: 'clinepass',
  label: 'ClinePass',
  vendorId: 'openai',
  category: 'hosted',
  defaultBaseUrl: 'https://api.cline.bot/api/v1',
  defaultModel: 'cline-pass/deepseek-v4-flash',
  setup: {
    requiresAuth: true,
    authMode: 'api-key',
    credentialEnvVars: ['CLINE_API_KEY'],
    dedicatedCredentialsOnly: true,
  },
  transportConfig: {
    kind: 'openai-compatible',
  },
  preset: {
    id: 'clinepass',
    vendorId: 'openai',
    description: 'ClinePass - AI model gateway with usage limits',
    apiKeyEnvVars: ['CLINE_API_KEY'],
    modelEnvVars: ['CLINE_API_MODEL', 'OPENAI_MODEL'],
  },
  validation: {
    kind: 'credential-env',
    routing: {
      matchDefaultBaseUrl: true,
    },
    credentialEnvVars: ['CLINE_API_KEY'],
    missingCredentialMessage:
      'ClinePass auth is required. Set CLINE_API_KEY.',
  },
  catalog: {
    source: 'static',
    models: [
      {
        id: 'cline-pass/qwen3.7-max',
        apiName: 'cline-pass/qwen3.7-max',
        aliases: ['qwen3.7-max'],
        modelDescriptorId: 'qwen3.7-max',
        label: 'Qwen3.7 Max',
        contextWindow: 1_000_000,
        maxOutputTokens: 67_072,
        capabilities: {
          supportsFunctionCalling: true,
          supportsReasoning: true,
        },
        reasoning: {
          mode: 'levels',
          levels: ['low', 'medium', 'high', 'xhigh'],
          wireFormat: 'reasoning_effort',
        },
      },
      {
        id: 'cline-pass/qwen3.7-plus',
        apiName: 'cline-pass/qwen3.7-plus',
        aliases: ['qwen3.7-plus'],
        modelDescriptorId: 'qwen3.7-plus',
        label: 'Qwen3.7 Plus',
        contextWindow: 1_000_000,
        maxOutputTokens: 67_072,
        capabilities: {
          supportsVision: true,
          supportsFunctionCalling: true,
          supportsReasoning: true,
        },
        reasoning: {
          mode: 'levels',
          levels: ['low', 'medium', 'high', 'xhigh'],
          wireFormat: 'reasoning_effort',
        },
      },
      {
        id: 'cline-pass/minimax-m3',
        apiName: 'cline-pass/minimax-m3',
        aliases: ['minimax-m3'],
        modelDescriptorId: 'minimax-m3',
        label: 'MiniMax M3',
        contextWindow: 524_288,
        maxOutputTokens: 524_288,
        capabilities: {
          supportsVision: true,
          supportsFunctionCalling: true,
          supportsReasoning: false,
        },
      },
      {
        id: 'cline-pass/glm-5.2',
        apiName: 'cline-pass/glm-5.2',
        aliases: ['glm-5.2'],
        modelDescriptorId: 'glm-5.2',
        label: 'GLM 5.2',
        contextWindow: 202_752,
        maxOutputTokens: 202_752,
        capabilities: {
          supportsVision: true,
          supportsFunctionCalling: true,
          supportsReasoning: true,
        },
        reasoning: {
          mode: 'levels',
          levels: ['low', 'medium', 'high', 'xhigh'],
          wireFormat: 'reasoning_effort',
        },
      },
      {
        id: 'cline-pass/kimi-k2.7-code',
        apiName: 'cline-pass/kimi-k2.7-code',
        aliases: ['kimi-k2.7-code'],
        modelDescriptorId: 'kimi-k2.7-code',
        label: 'Kimi K2.7 Code',
        contextWindow: 262_144,
        maxOutputTokens: 32_768,
        capabilities: {
          supportsVision: true,
          supportsFunctionCalling: true,
          supportsReasoning: true,
        },
        reasoning: {
          mode: 'levels',
          levels: ['low', 'medium', 'high', 'xhigh'],
          wireFormat: 'reasoning_effort',
        },
      },
      {
        id: 'cline-pass/kimi-k2.6',
        apiName: 'cline-pass/kimi-k2.6',
        aliases: ['kimi-k2.6'],
        modelDescriptorId: 'kimi-k2.6',
        label: 'Kimi K2.6',
        contextWindow: 262_144,
        maxOutputTokens: 262_144,
        capabilities: {
          supportsVision: true,
          supportsFunctionCalling: true,
          supportsReasoning: true,
        },
        reasoning: {
          mode: 'levels',
          levels: ['low', 'medium', 'high', 'xhigh'],
          wireFormat: 'reasoning_effort',
        },
      },
      {
        id: 'cline-pass/deepseek-v4-pro',
        apiName: 'cline-pass/deepseek-v4-pro',
        aliases: ['deepseek-v4-pro'],
        modelDescriptorId: 'deepseek-v4-pro',
        label: 'DeepSeek V4 Pro',
        contextWindow: 1_048_576,
        maxOutputTokens: 393_216,
        capabilities: {
          supportsVision: true,
          supportsFunctionCalling: true,
          supportsReasoning: true,
        },
        reasoning: {
          mode: 'levels',
          levels: ['low', 'medium', 'high', 'xhigh'],
          wireFormat: 'reasoning_effort',
        },
      },
      {
        id: 'cline-pass/deepseek-v4-flash',
        apiName: 'cline-pass/deepseek-v4-flash',
        aliases: ['deepseek-v4-flash'],
        modelDescriptorId: 'deepseek-v4-flash',
        label: 'DeepSeek V4 Flash',
        contextWindow: 1_048_576,
        maxOutputTokens: 393_216,
        capabilities: {
          supportsVision: true,
          supportsFunctionCalling: true,
          supportsReasoning: true,
        },
        reasoning: {
          mode: 'levels',
          levels: ['low', 'medium', 'high', 'xhigh'],
          wireFormat: 'reasoning_effort',
        },
      },
      {
        id: 'cline-pass/mimo-v2.5',
        apiName: 'cline-pass/mimo-v2.5',
        aliases: ['mimo-v2.5'],
        modelDescriptorId: 'mimo-v2.5',
        label: 'MiMo V2.5',
        contextWindow: 1_048_576,
        maxOutputTokens: 65_536,
        capabilities: {
          supportsVision: true,
          supportsFunctionCalling: true,
          supportsReasoning: true,
        },
        reasoning: {
          mode: 'levels',
          levels: ['low', 'medium', 'high', 'xhigh'],
          wireFormat: 'reasoning_effort',
        },
      },
      {
        id: 'cline-pass/mimo-v2.5-pro',
        apiName: 'cline-pass/mimo-v2.5-pro',
        aliases: ['mimo-v2.5-pro'],
        modelDescriptorId: 'mimo-v2.5-pro',
        label: 'MiMo V2.5 Pro',
        contextWindow: 1_048_576,
        maxOutputTokens: 65_536,
        capabilities: {
          supportsFunctionCalling: true,
          supportsReasoning: true,
        },
        reasoning: {
          mode: 'levels',
          levels: ['low', 'medium', 'high', 'xhigh'],
          wireFormat: 'reasoning_effort',
        },
      },
    ],
  },
  usage: {
    supported: true,
    ui: {
      showResetCountdown: true,
      compactProgressBar: false,
    },
  },
})
