import { AhpClientSocket } from "@grackle-ai/ahp-transport"; import type { PowerLineConnection } from "./adapter.js"; import { AhpHostTransport } from "./ahp-host-transport.js"; import type { TunnelRegistry } from "./tunnel-registry.js"; import type { AdapterLogger } from "./logger.js"; /** * Construct an opened {@link AhpHostTransport} for a single PowerLine. * * Opens an `AhpClientSocket` to `${baseUrl}/ahp`, awaits the AHP * `initialize` handshake, and returns the transport ready for use. * * `InMemoryClientIdStore` is used by default — Grackle's adapter * connections are ephemeral (one per provision; reconnect creates a fresh * one). Persistent `clientId` across server restarts is not required for * HR8d. A future optimization (HR8a-followup #1344) would persist for * reconnect-RPC replay efficiency. * * @param baseUrl - Origin URL of the PowerLine (e.g. `ws://127.0.0.1:7433`). * The helper appends `/ahp` to form the WebSocket URL. * @param powerlineToken - Bearer token sent on the HTTP upgrade. * @param environmentId - Used as the `clientIdKey` to namespace the * persisted clientId within the store. * @param logger - Optional logger for state transitions. * @returns The opened transport. */ export declare function createAhpHostTransport(baseUrl: string, powerlineToken: string, environmentId: string, logger?: AdapterLogger): Promise<{ transport: AhpHostTransport; socket: AhpClientSocket; }>; /** * Connect to a PowerLine through a local tunnel port, retrying until the AHP * `ping` succeeds. * * @param environmentId - Stable identifier for the environment. * @param localPort - Local TCP port the tunnel forwards to the PowerLine. * @param powerlineToken - Bearer token for the PowerLine. * @param tunnelRegistry - Registry to clean up on connect failure. * @param logger - Optional logger. * @returns A {@link PowerLineConnection} ready for session operations. */ export declare function connectThroughTunnel(environmentId: string, localPort: number, powerlineToken: string, tunnelRegistry: TunnelRegistry, logger?: AdapterLogger): Promise; /** Single-shot TCP port prober used by {@link waitForLocalPort}. */ export interface PortProber { /** Attempt a single TCP connection to `host:port`, returning `true` if it succeeds. */ probe(port: number, host?: string): Promise; } /** Default {@link PortProber} that uses real TCP sockets. */ export declare const TCP_PORT_PROBER: PortProber; /** Options for {@link waitForLocalPort}. */ export interface WaitForLocalPortOptions { /** Override port probing (primarily for testing). */ portProber?: PortProber; /** Override the sleep function (primarily for testing). */ sleep?: (ms: number) => Promise; } /** * Poll until a TCP connection can be established on localhost at the given port. * Used to wait for a tunnel process to begin accepting connections. */ export declare function waitForLocalPort(port: number, options?: WaitForLocalPortOptions): Promise; //# sourceMappingURL=connect.d.ts.map