//#region src/cli/proxy-cli.ts
let proxyCliRuntimePromise;
async function loadProxyCliRuntime() {
	proxyCliRuntimePromise ??= import("./proxy-cli.runtime-B0ckXKrk.js");
	return await proxyCliRuntimePromise;
}
function parseOptionalNumber(value) {
	if (!value) return;
	const parsed = Number(value);
	return Number.isFinite(parsed) ? parsed : void 0;
}
function registerProxyCli(program) {
	const proxy = program.command("proxy").description("Run the OpenClaw debug proxy and inspect captured traffic");
	proxy.command("start").description("Start the local explicit debug proxy").option("--host <host>", "Bind host", "127.0.0.1").option("--port <port>", "Bind port", parseOptionalNumber).action(async (opts) => {
		await (await loadProxyCliRuntime()).runDebugProxyStartCommand(opts);
	});
	proxy.command("run").description("Run a child command with OpenClaw debug proxy capture enabled").allowUnknownOption(true).allowExcessArguments(true).option("--host <host>", "Bind host", "127.0.0.1").option("--port <port>", "Bind port", parseOptionalNumber).argument("[cmd...]", "Command to run after --").action(async (cmd, opts) => {
		await (await loadProxyCliRuntime()).runDebugProxyRunCommand({
			host: opts.host,
			port: opts.port,
			commandArgs: cmd
		});
	});
	proxy.command("coverage").description("Report current debug proxy transport coverage and remaining gaps").action(async () => {
		await (await loadProxyCliRuntime()).runDebugProxyCoverageCommand();
	});
	proxy.command("sessions").description("List recent capture sessions").option("--limit <count>", "Maximum sessions to show", parseOptionalNumber).action(async (opts) => {
		await (await loadProxyCliRuntime()).runDebugProxySessionsCommand(opts);
	});
	proxy.command("query").description("Run a built-in query preset against captured traffic").requiredOption("--preset <name>", "Query preset: double-sends, retry-storms, cache-busting, ws-duplicate-frames, missing-ack, error-bursts").option("--session <id>", "Restrict to a capture session id").action(async (opts) => {
		await (await loadProxyCliRuntime()).runDebugProxyQueryCommand({
			preset: opts.preset,
			sessionId: opts.session
		});
	});
	proxy.command("blob").description("Read a captured payload blob by id").requiredOption("--id <blobId>", "Blob id").action(async (opts) => {
		await (await loadProxyCliRuntime()).readDebugProxyBlobCommand({ blobId: opts.id });
	});
	proxy.command("purge").description("Delete all captured traffic metadata and blobs").action(async () => {
		await (await loadProxyCliRuntime()).runDebugProxyPurgeCommand();
	});
}
//#endregion
export { registerProxyCli };
