#!/usr/bin/env node
import "./pi-embedded-helpers-Df7l-4vq.js";
import { Ar as applyTemplate, Zt as monitorWebChannel, en as installUnhandledRejectionHandler, et as loadDotEnv, nn as waitForever, t as getReplyFromConfig } from "./reply-CZUaueaY.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 "./logger-BKidfKRU.js";
import { n as runExec, t as runCommandWithTimeout } from "./exec-BBWSxSu-.js";
import "./koi-scope-BeICsBhH.js";
import "./model-selection-DvQd6xjM.js";
import "./dist-Czg7dzzf.js";
import "./dist-cjs-CtVce_lP.js";
import "./boolean-D-3joTkO.js";
import { r as normalizeEnv } from "./env-ChCKTuXK.js";
import "./github-copilot-token-BqhLBQWA.js";
import { o as loadConfig } from "./config-BOTdzMIB.js";
import "./manifest-registry-D7MfBQxU.js";
import "./plugins-dW6cc0qG.js";
import { b as resolveSessionKey, i as loadSessionStore, s as saveSessionStore, y as deriveSessionKey } from "./sessions-DyqGkYWU.js";
import "./image-CUVl1Hhm.js";
import "./dist-iFsGHQA2.js";
import "./lib-C-WEldjv.js";
import "./src-CiVOi-Ma.js";
import "./core-DrwlWTgS.js";
import "./pi-model-discovery-E8vIYAbb.js";
import "./sandbox-CDOYKOkn.js";
import { E as formatUncaughtError, c as describePortOwner, l as ensurePortAvailable, s as PortInUseError, u as handlePortError } from "./chrome-CTicuLaA.js";
import "./skills-DHpPesfZ.js";
import "./routes-C952rvWJ.js";
import "./server-context-Cs8Yx5qf.js";
import "./image-ops-B6MN1Uli.js";
import "./message-channel-B-LM-U45.js";
import "./logging-Dn5qdhsZ.js";
import "./accounts-B8F2xBS8.js";
import { o as resolveStorePath } from "./paths-DSzdyYR5.js";
import "./tool-images-DOYdkgEG.js";
import "./redact-Db6nXe_o.js";
import "./tool-display-CGLMse-l.js";
import "./deliver-BU-ss2iZ.js";
import "./dispatcher-Da_eDTB8.js";
import "./dist-JRNJAZWM.js";
import "./pi-tool-definition-adapter-DZBstpDD.js";
import "./manager-CvGvPIqL.js";
import "./sqlite-CbC9FUO2.js";
import "./warnings-D1qUihoO.js";
import "./proxy-from-env-BBdtl5-Y.js";
import "./login-qr-BDJgj3j2.js";
import "./channel-summary-DZinsO88.js";
import "./device-identity-CBC9Fa-4.js";
import "./client-CnWPlz1L.js";
import "./call-By5olg7I.js";
import "./koi-events-CVGX2xkt.js";
import "./pairing-store-DnxZNJ-U.js";
import "./links-DlFnXfJ_.js";
import "./progress-X-YSIEVf.js";
import "./node-pairing-ClP_ps1x.js";
import "./pi-tools.policy-CA2hGIde.js";
import "./onboard-helpers-DXmuVr9a.js";
import "./prompt-style-ko1k1LE0.js";
import "./pairing-labels-CNooTiAc.js";
import "./satisfies-D4f4jwpc.js";
import "./session-cost-usage-BiwFgQ3E.js";
import "./control-service-CamrxDfq.js";
import "./channel-selection-BTYECKhQ.js";
import "./event-log-DMRSRkMD.js";
import { t as createDefaultDeps } from "./deps-BkqEahC_.js";
import { l as ensureBinary, u as promptYesNo } from "./tailscale-C88PrOS1.js";
import { t as isMainModule } from "./is-main-Do9cUL72.js";
import { t as ensureSKYKOICliOnPath } from "./path-env-B9AK_97y.js";
import { g as assertSupportedRuntime } from "./daemon-runtime-EHtDn8NC.js";
import "./ports-0IosJaYp.js";
import "./config-guard-GucPWd71.js";
import "./logging-D-QZpI1i.js";
import "./note-D68Wd3Zr.js";
import "./clack-prompter-DF6HE5p6.js";
import "./onboarding-HT8NN42O.js";
import "./onboard-skills-YZFGxDZB.js";
import "./github-copilot-auth-BDRjMk4p.js";
import "./onboard-channels-BqKUp6cL.js";
import "./plugin-auto-enable-BIRsItbt.js";
import "./archive-BrDQDedR.js";
import "./skill-scanner-BSxHCT2R.js";
import "./installs-D-K256Jd.js";
import "./health-format-CW12kvrh.js";
import "./update-runner-D7y7t7Dm.js";
import "./auth-tu2F7_70.js";
import "./audit-D_KuVAWW.js";
import "./table-Bu1gPkD7.js";
import "./skills-status-CrL8zDk3.js";
import "./service-C6lyBW0F.js";
import "./systemd-C7TaOB0r.js";
import "./diagnostics-B6_fjn4Z.js";
import "./node-service-CtGQ_WCB.js";
import "./channels-status-issues-CNNkv5DB.js";
import "./register.subclis-DU1_EbNo.js";
import "./gateway-rpc-FMQ_vIWH.js";
import "./help-format-CN9mmVLD.js";
import "./admin-unlock-DfFhvRis.js";
import "./koi-B9sw4JKe.js";
import "./plugin-registry-BQc-z1Y2.js";
import "./configure-BGddNvFM.js";
import "./systemd-linger-DFrKH2dP.js";
import "./widearea-dns-nPnswBoX.js";
import "./bonjour-discovery-D3DvZVgk.js";
import "./ensure-local-gateway-CwgaMY79.js";
import "./login-A_sTANpw.js";
import "./auth-health-Dbdl2a43.js";
import "./doctor-gZ7cszFo.js";
import "./completion-cli-B06sgaew.js";
import "./service-audit-Bqgp6PlY.js";
import "./hooks-status-CV-O6Xro.js";
import "./tui-QrrdMeaH.js";
import "./channel-options-DBAp2tQo.js";
import { n as buildProgram } from "./program-B9hoSXbr.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 };