import "./paths-mmi2xb99.js";
import { f as theme } from "./globals-D5pM_phR.js";
import "./utils-3Lue6wVm.js";
import { c as defaultRuntime } from "./subsystem-_lp1q2Mi.js";
import "./boolean-BhvV-zDA.js";
import "./env-aEqmsXHj.js";
import "./chrome-7Zn7OYzP.js";
import "./logging-D4aavsm_.js";
import "./config-VoJVjSgT.js";
import "./agent-scope-u760_XKU.js";
import "./exec-NeyMP-Tl.js";
import "./edwinpai-root-fGTEvnPp.js";
import "./model-selection-CMHF17-l.js";
import "./github-copilot-token-Bu-iLSUh.js";
import "./command-format-D8drL8c2.js";
import "./manifest-registry-Cobl4jxs.js";
import "./client-BdG39O7o.js";
import "./message-channel-B4I_vLJb.js";
import "./ws-CvzJ5P1j.js";
import "./sandbox-Cnho92pr.js";
import "./plugins-B3jBOs5H.js";
import "./accounts-DmCFbO1K.js";
import "./routes--IwjIOyE.js";
import "./pi-embedded-helpers-bcXOORS6.js";
import "./skills-DMXslih8.js";
import "./server-context-CysGziRI.js";
import "./ports-CgQyR_CW.js";
import "./paths-CzSw2xi4.js";
import "./redact-DKKIzZKH.js";
import "./tool-display-CEyvKqx1.js";
import { t as parseTimeoutMs } from "./parse-timeout-C18B_iao.js";
import "./channel-summary-b-OepsoT.js";
import { t as formatDocsLink } from "./links-BKmnIRTU.js";
import { t as runTui } from "./tui-N6eeHe7P.js";

//#region ../../src/cli/tui-cli.ts
function registerTuiCli(program) {
	program.command("tui").description("Open a terminal UI connected to the Gateway").option("--url <url>", "Gateway WebSocket URL (defaults to gateway.remote.url when configured)").option("--token <token>", "Gateway token (if required)").option("--password <password>", "Gateway password (if required)").option("--session <key>", "Session key (default: \"main\", or \"global\" when scope is global)").option("--deliver", "Deliver assistant replies", false).option("--thinking <level>", "Thinking level override").option("--message <text>", "Send an initial message after connecting").option("--timeout-ms <ms>", "Agent timeout in ms (defaults to agents.defaults.timeoutSeconds)").option("--history-limit <n>", "History entries to load", "200").addHelpText("after", () => `\n${theme.muted("Docs:")} ${formatDocsLink("/cli/tui", "docs.edwinpai.com/cli/tui")}\n`).action(async (opts) => {
		try {
			const timeoutMs = parseTimeoutMs(opts.timeoutMs);
			if (opts.timeoutMs !== void 0 && timeoutMs === void 0) defaultRuntime.error(`warning: invalid --timeout-ms "${String(opts.timeoutMs)}"; ignoring`);
			const historyLimit = Number.parseInt(String(opts.historyLimit ?? "200"), 10);
			await runTui({
				url: opts.url,
				token: opts.token,
				password: opts.password,
				session: opts.session,
				deliver: Boolean(opts.deliver),
				thinking: opts.thinking,
				message: opts.message,
				timeoutMs,
				historyLimit: Number.isNaN(historyLimit) ? void 0 : historyLimit
			});
		} catch (err) {
			defaultRuntime.error(String(err));
			defaultRuntime.exit(1);
		}
	});
}

//#endregion
export { registerTuiCli };