import { j as theme } from "./registry-Sbac4a4z.js";
import "./paths-By0XjHBk.js";
import "./utils-CTPsqyE_.js";
import { f as defaultRuntime } from "./subsystem-CHbO_DkH.js";
import "./exec-DuYbft0z.js";
import "./agent-scope-Bnsyyeci.js";
import "./model-selection-CCTzD29o.js";
import "./pi-embedded-helpers-j1JrlsI0.js";
import "./config-BngIfn5l.js";
import "./boolean-CbZoNRMn.js";
import "./env-BRnPI9sO.js";
import "./shell-env-Dc3iU7HK.js";
import "./manifest-registry-D1MLZEjS.js";
import "./sandbox-CZGTCone.js";
import "./chrome-38OnGyuN.js";
import "./tailscale-DpKBMIvx.js";
import "./auth-Bkx-QuRN.js";
import "./server-context-DXdk410X.js";
import "./frontmatter-B_jqcova.js";
import "./skills-CYcBtLGH.js";
import "./routes-BwTUoI5h.js";
import "./redact-B3O-RBO1.js";
import "./errors-bI7Tdx75.js";
import "./fs-safe-B0Is-oLk.js";
import "./paths-BWqg8NZT.js";
import "./ssrf-DOZRI5XH.js";
import "./image-ops-BzCBIakN.js";
import "./ports-CB_Iu83U.js";
import "./trash-_YhavPQI.js";
import "./sessions-BCc3THTm.js";
import "./dock-hF45sewN.js";
import "./message-channel-DgjXWzf-.js";
import "./plugins-CF5skkHh.js";
import "./paths-BtvQ7JvU.js";
import "./thinking-COroyVA5.js";
import "./commands-DUzLGgEZ.js";
import "./commands-registry-CwXsDVuO.js";
import "./client-CTrfpKT3.js";
import "./call-Bpjj5p7I.js";
import "./pairing-token-B703A1U3.js";
import "./tool-display-DFOL6UQ9.js";
import { t as parseTimeoutMs } from "./parse-timeout-DmEcHIsV.js";
import { t as formatDocsLink } from "./links-Bqr0FxXx.js";
import { t as runTui } from "./tui-J7Jxp-FF.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.symi.ai/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 };