/** * Host URL Rewriting for Container Environments * * When Quilltap runs inside Docker — or inside a virtual machine the user has * built and manages themselves — `localhost` and `127.0.0.1` resolve to the * container/VM's own loopback, not the host machine where services like Ollama * or LM Studio are running. * * This module provides a single function that transparently rewrites * localhost URLs to point at the host, so users can configure * `http://localhost:11434` and have it Just Work in every environment. * * Gateway resolution order: * 1. `QUILLTAP_HOST_IP` env var (explicit override) → rewrite to that IP. * This is also the only supported route for a self-managed VM, where * Quilltap has no reliable way to detect the host gateway on its own. * 2. In Docker: rewrite `localhost` → `host.docker.internal` * (Docker Desktop DNS or --add-host on Linux handles the forwarding) * 3. Give up gracefully — return URL unchanged * * @module @quilltap/plugin-utils/host-rewrite */ /** * Check if running in an environment that needs URL rewriting. * * Docker is detected automatically. A hand-rolled VM cannot be, so setting * `QUILLTAP_HOST_IP` is what opts one in — it both enables rewriting and * supplies the gateway address. */ declare function isVMEnvironment(): boolean; /** * Resolve the host gateway address (IP or hostname). * * Tries multiple strategies in order; caches the result so file reads * only happen once per process lifetime. */ declare function resolveHostGateway(): string | null; /** * Rewrite a localhost URL to point at the host gateway. * * No-ops when: * - Not running in a container (and QUILLTAP_HOST_IP is unset) * - The URL doesn't point to localhost or 127.0.0.1 * - Gateway resolution fails * * @param url The URL to potentially rewrite * @returns The original URL or a rewritten version with the gateway host */ declare function rewriteLocalhostUrl(url: string): string; /** * Reset the cached gateway host (for testing). * @internal */ declare function _resetGatewayCache(): void; export { _resetGatewayCache, isVMEnvironment, resolveHostGateway, rewriteLocalhostUrl };