import { apiClient } from "./client"; export interface ToolConfig { id: string; tool_type_id: string; project_id: string | null; key: string; value: string; config_type: string; file_path: string | null; port_override: number | null; start_command: string | null; working_directory: string | null; environment_variables: Record | null; volumes: Array<{ source: string; target: string; type?: string }> | null; } export interface CreateToolConfigRequest { tool_type_id: string; project_id?: string; key: string; value: string; config_type?: string; file_path?: string; port_override?: number; start_command?: string; working_directory?: string; environment_variables?: Record; volumes?: Array<{ source: string; target: string; type?: string }>; } export const listToolConfigs = async ( tool_type_id?: string, project_id?: string ): Promise => { const params = new URLSearchParams(); if (tool_type_id) params.append("tool_type_id", tool_type_id); if (project_id) params.append("project_id", project_id); const response = await apiClient.get<{ configs: ToolConfig[] }>( `/tool-configs?${params.toString()}` ); return response.data.configs; }; export const createToolConfig = async ( data: CreateToolConfigRequest ): Promise => { const response = await apiClient.post<{ configs: ToolConfig[] }>("/tool-configs", data); return response.data.configs[0]; }; export const updateToolConfig = async ( id: string, data: CreateToolConfigRequest ): Promise => { const response = await apiClient.put<{ configs: ToolConfig[] }>( `/tool-configs/${id}`, data ); return response.data.configs[0]; }; export const deleteToolConfig = async (id: string): Promise => { await apiClient.delete(`/tool-configs/${id}`); }; export const getToolConfigDefaults = async ( toolTypeId: string ): Promise => { const response = await apiClient.get( `/tool-configs/defaults/${toolTypeId}` ); return response.data; };