import { invoke } from '@tauri-apps/api/core';
import {
  AgentConfigStatus,
  SaveAgentRuntimeConfigRequest,
  UpdateRemoteApiKeyRequest,
} from '../types/agentSettings';

class AgentSettingsBridge {
  async getStatus(): Promise<AgentConfigStatus> {
    return invoke<AgentConfigStatus>('get_agent_config_status');
  }

  async saveRuntimeConfig(request: SaveAgentRuntimeConfigRequest): Promise<AgentConfigStatus> {
    return invoke<AgentConfigStatus>('save_agent_runtime_config', { request });
  }

  async updateRemoteApiKey(request: UpdateRemoteApiKeyRequest): Promise<AgentConfigStatus> {
    return invoke<AgentConfigStatus>('update_remote_api_key', { request });
  }

  async clearRemoteApiKey(): Promise<AgentConfigStatus> {
    return invoke<AgentConfigStatus>('clear_remote_api_key');
  }
}

export const agentSettingsBridge = new AgentSettingsBridge();
