/**
 * Residential proxy info — SOCKS5 exit-node proxy for tenants with access.
 */
import path from "path";
import { getContext } from "../client.js";
import { readJsonFile } from "../ipc.js";

export interface ProxyInfo {
  url: string;
  protocol: string;
  host: string;
  port: number;
}

/**
 * Returns the SOCKS5 proxy URL for this tenant, or null if no proxy is available.
 * Use the url with agent-browser --proxy or with any SOCKS5-capable HTTP client.
 */
export async function getProxyInfo(ipcDir?: string): Promise<ProxyInfo | null> {
  const dir = ipcDir ?? getContext().ipcDir;
  return readJsonFile<ProxyInfo>(path.join(dir, "proxy.json")) ?? null;
}
