import "./paths-mmi2xb99.js";
import "./globals-D5pM_phR.js";
import "./utils-3Lue6wVm.js";
import { t as createSubsystemLogger } from "./subsystem-_lp1q2Mi.js";
import "./boolean-BhvV-zDA.js";
import "./env-aEqmsXHj.js";
import "./chrome-7Zn7OYzP.js";
import { t as loadEdwinPAIPlugins } from "./loader-364nXh92.js";
import "./logging-D4aavsm_.js";
import { r as loadConfig } from "./config-VoJVjSgT.js";
import { c as resolveDefaultAgentId, s as resolveAgentWorkspaceDir } from "./agent-scope-u760_XKU.js";
import "./exec-NeyMP-Tl.js";
import "./edwinpai-root-fGTEvnPp.js";
import "./model-selection-CMHF17-l.js";
import "./github-copilot-token-Bu-iLSUh.js";
import "./command-format-D8drL8c2.js";
import "./manifest-registry-Cobl4jxs.js";
import "./access-policy-Bz60GPHK.js";
import "./backend-config-CnwghGiS.js";
import "./public-policy-BcsEQrNF.js";
import "./internal-C9ERe0oQ.js";
import "./files-C9aOMd12.js";
import "./client-BdG39O7o.js";
import "./tailnet-D1VxJifZ.js";
import "./call-BuuyfSRn.js";
import "./message-channel-B4I_vLJb.js";
import "./ws-CvzJ5P1j.js";
import "./sandbox-Cnho92pr.js";
import "./deliver-CDl0wl5Y.js";
import "./plugins-B3jBOs5H.js";
import "./accounts-DmCFbO1K.js";
import "./dispatcher-Bo-53pRv.js";
import "./pi-model-discovery-DU5m2tTc.js";
import "./routes--IwjIOyE.js";
import "./pi-embedded-helpers-bcXOORS6.js";
import "./skills-DMXslih8.js";
import "./server-context-CysGziRI.js";
import "./ports-CgQyR_CW.js";
import "./paths-CzSw2xi4.js";
import "./image-Behi5-Q5.js";
import "./exec-approvals-HMeMyfFd.js";
import "./nodes-screen-BCmLkGEF.js";
import "./redact-DKKIzZKH.js";
import "./tool-display-CEyvKqx1.js";
import "./control-service-BCE6PKvq.js";
import "./restart-sentinel-V09ETbcM.js";
import "./channel-selection-nnjP4eS9.js";
import "./channel-summary-b-OepsoT.js";
import "./commands-CYbojHvd.js";
import "./pairing-store-BHWTx_J7.js";
import "./login-qr-C0aXNPXR.js";
import "./links-BKmnIRTU.js";
import "./progress-DIssriZ5.js";

//#region ../../src/plugins/cli.ts
const log = createSubsystemLogger("plugins");
function registerPluginCliCommands(program, cfg) {
	const config = cfg ?? loadConfig();
	const workspaceDir = resolveAgentWorkspaceDir(config, resolveDefaultAgentId(config));
	const logger = {
		info: (msg) => log.info(msg),
		warn: (msg) => log.warn(msg),
		error: (msg) => log.error(msg),
		debug: (msg) => log.debug(msg)
	};
	const registry = loadEdwinPAIPlugins({
		config,
		workspaceDir,
		logger
	});
	const existingCommands = new Set(program.commands.map((cmd) => cmd.name()));
	for (const entry of registry.cliRegistrars) {
		if (entry.commands.length > 0) {
			const overlaps = entry.commands.filter((command) => existingCommands.has(command));
			if (overlaps.length > 0) {
				log.debug(`plugin CLI register skipped (${entry.pluginId}): command already registered (${overlaps.join(", ")})`);
				continue;
			}
		}
		try {
			const result = entry.register({
				program,
				config,
				workspaceDir,
				logger
			});
			if (result && typeof result.then === "function") result.catch((err) => {
				log.warn(`plugin CLI register failed (${entry.pluginId}): ${String(err)}`);
			});
			for (const command of entry.commands) existingCommands.add(command);
		} catch (err) {
			log.warn(`plugin CLI register failed (${entry.pluginId}): ${String(err)}`);
		}
	}
}

//#endregion
export { registerPluginCliCommands };