/** * Sidecar HTTP server factory. * * Creates a lightweight Node HTTP server bound to `127.0.0.1` on a * port chosen from a fixed pool (default `4096-4105`). The first port * in the pool that successfully binds wins. The companion sidecar * client (`sidecar/src/lib/plugin-client.ts`) probes the same pool to * find the active plugin server. * * Port selection precedence (highest first): * 1. `HIVEMIND_PLUGIN_PORT` — single explicit port * 2. `HIVEMIND_PLUGIN_PORT_LIST` — comma-separated list (env override) * 3. `HIVEMIND_PLUGIN_PORT_LIST` default constant * * The actual bound port is written to * `.hivemind/state/sidecar-port.json` so non-sidecar consumers * (legacy Next.js discovery) can still locate the server. * * Server start does NOT block plugin init — start failures are * handled by the caller (fire-and-forget with log warning). * * @see /Users/apple/hivemind-plugin-private/.planning//plugin-port-pool-2026-06-07/00-landscape.md * @module sidecar/server/factory */ import type { SidecarDependencyRegistry } from "./registry.js"; import type { SseConnectionPool } from "./sse/pool.js"; import type { Route } from "./handler.js"; /** Options for {@link createSidecarServer}. */ export interface SidecarServerOptions { registry: SidecarDependencyRegistry; ssePool: SseConnectionPool; projectDirectory: string; /** Optional routes for the SidecarRouter (SC-02 extension). */ routes?: Route[]; } /** Handle returned by {@link createSidecarServer}. */ export interface SidecarServerHandle { port: number; close: () => Promise; } /** * Create and start a sidecar HTTP server. * * Port allocation: {@link resolveBindPort} picks a port from the * default pool (or env-overridden pool) and the server binds to that * specific port. On success the actual port is written to * `.hivemind/state/sidecar-port.json` for legacy Next.js discovery. * * @param options - Server options including the dependency registry, * SSE pool, and project directory. * @returns A handle with the assigned port and a close function. * @throws `[Hivemind]` error when no port in the pool is free. */ export declare function createSidecarServer(options: SidecarServerOptions): Promise; //# sourceMappingURL=factory.d.ts.map