#!/usr/bin/env node
import "./pi-embedded-helpers-Ny2JybJV.js";
import { Er as applyTemplate, Qt as waitForever, Xt as installUnhandledRejectionHandler, qt as monitorWebChannel, t as getReplyFromConfig } from "./reply-CL83zh9t.js";
import { r as enableConsoleCapture } from "./subsystem-hATE68va.js";
import "./paths-VdmjGGyc.js";
import "./theme-C5EwWDWE.js";
import "./ansi-By7x1TI7.js";
import { S as toWhatsappJid, d as normalizeE164, n as assertWebChannel } from "./utils-D019Z2NU.js";
import { n as runExec, t as runCommandWithTimeout } from "./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 { r as normalizeEnv } from "./env-Dliiu-O6.js";
import "./github-copilot-token-CNBLk7kR.js";
import { o as loadConfig } from "./config-CJCyYQfd.js";
import "./manifest-registry-oBOOUSYE.js";
import "./plugins-4Dg2aV3Z.js";
import { b as resolveSessionKey, i as loadSessionStore, s as saveSessionStore, y as deriveSessionKey } from "./sessions-p608GJQF.js";
import "./image-Cm8pagSS.js";
import "./dist-qohLth5U.js";
import "./lib-DySFL26z.js";
import "./src-CuBVmkDD.js";
import "./core-CYIM8X9C.js";
import "./pi-model-discovery-BJB6xKfm.js";
import "./sandbox-CH6Z4NF9.js";
import { E as formatUncaughtError, c as describePortOwner, l as ensurePortAvailable, s as PortInUseError, u as handlePortError } from "./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 { o as resolveStorePath } from "./paths-DeB-Vw2o.js";
import "./tool-images-BotO6WKu.js";
import "./redact-AS2CBwfj.js";
import "./tool-display-DcE_Uu-6.js";
import "./deliver-DaqlX5n9.js";
import "./dispatcher-CvOxCTiO.js";
import "./dist-Cldz93r6.js";
import "./pi-tool-definition-adapter-Bm-MOj6J.js";
import "./manager-M02jv6fr.js";
import "./sqlite-ciTubP4r.js";
import "./warnings-WXNLPyeJ.js";
import "./proxy-from-env-CZI-BeJ4.js";
import "./login-qr-jct4RHB3.js";
import "./channel-summary-CaRm5ceF.js";
import "./device-identity-Bb4mQJBL.js";
import "./net-CgTtDqcj.js";
import "./call-CJHT-9_x.js";
import "./koi-events-mTBifGCl.js";
import "./pairing-store-C3Jk-2f9.js";
import "./links-RRRDj3kH.js";
import "./progress-DpXGZ7eP.js";
import "./node-pairing-C8IUm3Xm.js";
import "./pi-tools.policy-C2-uMacJ.js";
import "./onboard-helpers-BfbPZ2qa.js";
import "./prompt-style-VlLGOsyw.js";
import "./pairing-labels-gxX2Garz.js";
import "./satisfies-Bvl3f_kk.js";
import "./session-cost-usage-C1dZUsv0.js";
import "./control-service-Deb7vSlB.js";
import "./channel-selection-C4X4L8u3.js";
import "./event-log-Bp_kcsW9.js";
import { t as createDefaultDeps } from "./deps-C09ak7pX.js";
import { l as ensureBinary, u as promptYesNo } from "./tailscale-B9nalljD.js";
import { t as loadDotEnv } from "./dotenv-2TPorV-O.js";
import { t as isMainModule } from "./is-main-IPFNRi1N.js";
import { t as ensureSKYKOICliOnPath } from "./path-env-DGypuWGK.js";
import { g as assertSupportedRuntime } from "./daemon-runtime-DUaeQ1rH.js";
import "./ports-C1z23xs4.js";
import "./config-guard-CgPeENat.js";
import "./logging-C1O4qtJt.js";
import "./note-DGDjXGAF.js";
import "./clack-prompter-CjPgjdmC.js";
import "./onboarding-Dze4vcK5.js";
import "./onboard-skills-D-hnEsDf.js";
import "./github-copilot-auth-CGviv7_I.js";
import "./onboard-channels-2nIi5fQi.js";
import "./plugin-auto-enable-CAaRgRRA.js";
import "./archive-DfyrMWmh.js";
import "./skill-scanner-oZNfZVUO.js";
import "./installs-zbov_HlD.js";
import "./health-format-wLPqgHrB.js";
import "./update-runner-B6m4iwFl.js";
import "./auth-oGq4xOCr.js";
import "./audit-CfOfhgP7.js";
import "./table-3qkY6e1T.js";
import "./skills-status-DuDN8c7D.js";
import "./service-CYp-ZMZO.js";
import "./systemd-BwrS2WmZ.js";
import "./service-audit-CtA-SSNX.js";
import "./node-service-CMlPSxKk.js";
import "./channels-status-issues-DBv-Cc4W.js";
import "./register.subclis-DG_bEdS6.js";
import "./gateway-rpc-CyFabm9F.js";
import "./help-format-lN5-Ns06.js";
import "./admin-unlock-kahk3vPh.js";
import "./koi-C6i0qbe-.js";
import "./plugin-registry-ChZmVClb.js";
import "./configure-DUPDTU69.js";
import "./systemd-linger-Dppl0X6M.js";
import "./widearea-dns-BV1FENWO.js";
import "./bonjour-discovery-BSmdJTHl.js";
import "./auth-health-B3BNAX3f.js";
import "./doctor-ujPSl1VX.js";
import "./completion-cli-CmOg_YSa.js";
import "./hooks-status-BeE0Lo6_.js";
import "./tui-BPKuWU22.js";
import "./channel-options-CLP3al_9.js";
import { n as buildProgram } from "./program-Bl7ooJiH.js";
import process from "node:process";
import { fileURLToPath } from "node:url";

//#region src/index.ts
loadDotEnv({ quiet: true });
normalizeEnv();
ensureSKYKOICliOnPath();
enableConsoleCapture();
assertSupportedRuntime();
const program = buildProgram();
if (isMainModule({ currentFile: fileURLToPath(import.meta.url) })) {
	installUnhandledRejectionHandler();
	process.on("uncaughtException", (error) => {
		const msg = String(error);
		if (msg.includes("Max reconnect attempts")) {
			console.warn("[SKYKOI] Discord gateway reconnect limit reached (non-fatal):", msg);
			return;
		}
		console.error("[SKYKOI] Uncaught exception:", formatUncaughtError(error));
		process.exit(1);
	});
	program.parseAsync(process.argv).catch((err) => {
		console.error("[SKYKOI] CLI failed:", formatUncaughtError(err));
		process.exit(1);
	});
}

//#endregion
export { PortInUseError, applyTemplate, assertWebChannel, createDefaultDeps, deriveSessionKey, describePortOwner, ensureBinary, ensurePortAvailable, getReplyFromConfig, handlePortError, loadConfig, loadSessionStore, monitorWebChannel, normalizeE164, promptYesNo, resolveSessionKey, resolveStorePath, runCommandWithTimeout, runExec, saveSessionStore, toWhatsappJid, waitForever };