import type { Command } from "commander"; export type { GatewayRpcOpts } from "./gateway-rpc.types.js"; import type { GatewayRpcOpts } from "./gateway-rpc.types.js"; type GatewayRpcRuntimeModule = typeof import("./gateway-rpc.runtime.js"); let gatewayRpcRuntimePromise: Promise | undefined; async function loadGatewayRpcRuntime(): Promise { gatewayRpcRuntimePromise ??= import("./gateway-rpc.runtime.js"); return gatewayRpcRuntimePromise; } export function addGatewayClientOptions(cmd: Command) { return cmd .option("--url ", "Gateway WebSocket URL (defaults to gateway.remote.url when configured)") .option("--token ", "Gateway token (if required)") .option("--timeout ", "Timeout in ms", "30000") .option("--expect-final", "Wait for final response (agent)", false); } export async function callGatewayFromCli( method: string, opts: GatewayRpcOpts, params?: unknown, extra?: { expectFinal?: boolean; progress?: boolean }, ) { const runtime = await loadGatewayRpcRuntime(); return await runtime.callGatewayFromCliRuntime(method, opts, params, extra); }