#!/usr/bin/env node
import "./pi-embedded-helpers-C7GyAcoc.js";
import { Cr as applyTemplate, Wt as monitorWebChannel, Yt as waitForever, et as loadDotEnv, qt as installUnhandledRejectionHandler, t as getReplyFromConfig } from "./reply-Bnpxcafr.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-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 { r as normalizeEnv } from "./env-ChCKTuXK.js";
import "./github-copilot-token-BqhLBQWA.js";
import "./version-BKRSzdyx.js";
import { o as loadConfig } from "./config-ZjEd8561.js";
import "./manifest-registry-DEGu_o5t.js";
import "./plugins-Ct7Mnq1x.js";
import { b as resolveSessionKey, i as loadSessionStore, s as saveSessionStore, y as deriveSessionKey } from "./sessions-COz6-MPd.js";
import "./image-DYRH6hYg.js";
import "./dist-nhxaQYGz.js";
import "./lib-pS0Bd7GL.js";
import "./src-ByySp9O0.js";
import "./core-B7QS0Vnt.js";
import "./pi-model-discovery-Cy-rVVvR.js";
import "./sandbox-BeaBvIJZ.js";
import { E as formatUncaughtError, c as describePortOwner, l as ensurePortAvailable, s as PortInUseError, u as handlePortError } from "./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 { o as resolveStorePath } from "./paths-DLKQOevr.js";
import "./tool-images-DlkXfMNL.js";
import "./redact-1AXapBET.js";
import "./tool-display-DYOxwSs6.js";
import "./deliver-CkS1xVhO.js";
import "./dispatcher-CoG7Bmmx.js";
import "./dist-B556KqJe.js";
import "./pi-tool-definition-adapter-CnsO-0rY.js";
import "./manager-6pqEqm7q.js";
import "./sqlite-CYnXobrn.js";
import "./warnings-Ds_WSeah.js";
import "./proxy-from-env-DxUIcU4P.js";
import "./login-qr-ekueLD_2.js";
import "./channel-summary-1rzVva2g.js";
import "./device-identity-CpMBJtRJ.js";
import "./client-BM6xyPUD.js";
import "./call-JFo1_L0m.js";
import "./koi-events-DhwDeG-q.js";
import "./pairing-store-BrlNnaod.js";
import "./links-BupJpVpQ.js";
import "./progress-EICDZThJ.js";
import "./node-pairing-DuliQoRe.js";
import "./pi-tools.policy-XgYp6L9R.js";
import "./onboard-helpers-FO60qqTG.js";
import "./prompt-style-hXUwxLRe.js";
import "./pairing-labels-DLc3GnhN.js";
import "./satisfies-Dp_OBiSc.js";
import "./session-cost-usage-BNV86lI0.js";
import "./control-service-DQtH-td4.js";
import "./restart-sentinel-BqQzvk3k.js";
import "./channel-selection-DhBJOelv.js";
import "./event-log-CL2tmo5v.js";
import { t as createDefaultDeps } from "./deps-CX3Skz28.js";
import { l as ensureBinary, u as promptYesNo } from "./tailscale-CDBmRrBH.js";
import { t as isMainModule } from "./is-main-9SjMCZPE.js";
import { t as ensureSKYKOICliOnPath } from "./path-env-DLiKMTfX.js";
import { t as assertSupportedRuntime } from "./runtime-guard-Btp4Sks0.js";
import "./ports-wWIKjGeR.js";
import "./config-guard-CmbWsYQa.js";
import "./logging-CSvbGeqF.js";
import "./note-DdyFyHLV.js";
import "./clack-prompter-CCgKKgnN.js";
import "./onboarding-CCpP66LJ.js";
import "./onboard-skills-ChDFxeGS.js";
import "./github-copilot-auth-CRvtl8wF.js";
import "./onboard-channels-BiwGmgdU.js";
import "./plugin-auto-enable-WPZfV7Dp.js";
import "./archive-DnVN3g6v.js";
import "./skill-scanner-BCGU84pB.js";
import "./installs-BBJbDnE-.js";
import "./health-format-Cw_wWsUk.js";
import "./update-runner-BF2ZUZuV.js";
import "./auth-CeZ-Kq3Y.js";
import "./audit-B5CUzM1R.js";
import "./table-C-_kZeNX.js";
import "./skills-status-B0uJbSLd.js";
import "./service-CgbWVYSz.js";
import "./systemd-CKUsCXqF.js";
import "./diagnostics-CBJs_eaH.js";
import "./node-service-CnU49y0d.js";
import "./channels-status-issues-D_rjAibL.js";
import "./doctor-completion-CLMLUQj9.js";
import "./register.subclis-B7sqTsBj.js";
import "./gateway-rpc-BLmNrKaj.js";
import "./help-format-BgbvAVIq.js";
import "./admin-unlock--4SPdpdy.js";
import "./koi-Dv4SlCoI.js";
import "./plugin-registry-Bb6CC447.js";
import "./control-ui-assets-C6cSlkkc.js";
import "./configure-BQQN1fFr.js";
import "./daemon-runtime-BTR2GDIQ.js";
import "./systemd-linger-Cu8buxAR.js";
import "./widearea-dns-BVskGRhX.js";
import "./bonjour-discovery-DjvriZpZ.js";
import "./ensure-local-gateway-CWMjpIBa.js";
import "./login-BPXcLBkt.js";
import "./auth-health-BQXG_lTS.js";
import "./doctor-Ce1sxck6.js";
import "./completion-cli-Q3xLcOzu.js";
import "./service-audit-D1ElVIM8.js";
import "./hooks-status-CxWUG7p9.js";
import "./tui-Dh1acgyz.js";
import "./channel-options-CsA4EdIA.js";
import { n as buildProgram } from "./program-DMa1pnc4.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 };