import "./pi-embedded-helpers-Ny2JybJV.js";
import { s as defaultRuntime } from "./subsystem-hATE68va.js";
import "./paths-VdmjGGyc.js";
import { r as theme } from "./theme-C5EwWDWE.js";
import "./ansi-By7x1TI7.js";
import "./utils-D019Z2NU.js";
import "./exec-xrC0ejqg.js";
import "./koi-scope-D8R_V4oO.js";
import "./model-selection-Bue40sP3.js";
import "./dist-CUiRTtgg.js";
import "./dist-cjs-DKbiqPag.js";
import "./boolean-CBeSt-pi.js";
import "./env-Dliiu-O6.js";
import "./github-copilot-token-CNBLk7kR.js";
import "./config-CJCyYQfd.js";
import "./manifest-registry-oBOOUSYE.js";
import "./plugins-4Dg2aV3Z.js";
import "./sessions-p608GJQF.js";
import "./dist-qohLth5U.js";
import "./lib-DySFL26z.js";
import "./src-CuBVmkDD.js";
import "./core-CYIM8X9C.js";
import "./sandbox-CH6Z4NF9.js";
import "./chrome-qnrH3SE9.js";
import "./skills-belB1fF2.js";
import "./routes-B_ID_OU2.js";
import "./server-context-BfQWGTuX.js";
import "./image-ops-D4trOw4b.js";
import "./message-channel-DFpLxeOe.js";
import "./logging-DbUpYaKc.js";
import "./accounts-Grk0tpBF.js";
import "./paths-DeB-Vw2o.js";
import "./tool-images-BotO6WKu.js";
import "./redact-AS2CBwfj.js";
import "./tool-display-DcE_Uu-6.js";
import "./channel-summary-CaRm5ceF.js";
import "./device-identity-Bb4mQJBL.js";
import "./net-CgTtDqcj.js";
import "./call-CJHT-9_x.js";
import { t as formatDocsLink } from "./links-RRRDj3kH.js";
import { t as parseTimeoutMs } from "./parse-timeout-Cu-tR2v-.js";
import { t as runTui } from "./tui-BPKuWU22.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>", "Koi timeout in ms (defaults to kois.defaults.timeoutSeconds)").option("--history-limit <n>", "History entries to load", "200").addHelpText("after", () => `\n${theme.muted("Docs:")} ${formatDocsLink("/cli/tui", "docs.skykoi.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 };