import "./pi-embedded-helpers-C7GyAcoc.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 "./logger-BKidfKRU.js";
import "./exec-XH65-wH1.js";
import "./koi-scope-je0O-Kk9.js";
import "./model-selection-DHqY0wuU.js";
import "./dist-CFhZJtYo.js";
import "./dist-cjs-DiQp4ztu.js";
import "./boolean-D-3joTkO.js";
import "./env-ChCKTuXK.js";
import "./github-copilot-token-BqhLBQWA.js";
import "./version-BKRSzdyx.js";
import "./config-ZjEd8561.js";
import "./manifest-registry-DEGu_o5t.js";
import "./plugins-Ct7Mnq1x.js";
import "./sessions-COz6-MPd.js";
import "./dist-nhxaQYGz.js";
import "./lib-pS0Bd7GL.js";
import "./src-ByySp9O0.js";
import "./core-B7QS0Vnt.js";
import "./sandbox-BeaBvIJZ.js";
import "./chrome-CROsH9kD.js";
import "./skills-D0qJwRRD.js";
import "./routes-DP4mWBwK.js";
import "./server-context-0I52nf-b.js";
import "./image-ops-CQFojSu1.js";
import "./message-channel-CaDAAMe0.js";
import "./logging-ADUQX6n5.js";
import "./accounts-DFSZwaCs.js";
import "./paths-DLKQOevr.js";
import "./tool-images-DlkXfMNL.js";
import "./redact-1AXapBET.js";
import "./tool-display-DYOxwSs6.js";
import "./channel-summary-1rzVva2g.js";
import "./device-identity-CpMBJtRJ.js";
import "./client-BM6xyPUD.js";
import "./call-JFo1_L0m.js";
import { t as formatDocsLink } from "./links-BupJpVpQ.js";
import { t as parseTimeoutMs } from "./parse-timeout-B-Mg8iIP.js";
import { t as runTui } from "./tui-Dh1acgyz.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 };