import "./paths-mmi2xb99.js";
import { t as createSubsystemLogger } from "./subsystem-D4e4nOE7.js";
import "./utils-DLd4fFd2.js";
import "./boolean-Djq1Hgv8.js";
import "./env-Bdq5Y-tD.js";
import "./chrome-CpAaM-7H.js";
import { t as loadEdwinPAIPlugins } from "./loader-nlcizznp.js";
import "./logging-BdXz5wtj.js";
import { r as loadConfig } from "./config-C9wUwpYY.js";
import { c as resolveDefaultAgentId, s as resolveAgentWorkspaceDir } from "./agent-scope-BcV171ci.js";
import "./exec-B_ziy0Fn.js";
import "./edwinpai-root-BaNzp4sP.js";
import "./model-selection-ChysOie6.js";
import "./github-copilot-token-D-EydSr2.js";
import "./command-format-XQlUKdf6.js";
import "./manifest-registry-DThGPzHr.js";
import "./internal-Ft2bMMnL.js";
import "./files-C_lcxjDi.js";
import "./client-FZxVEb3g.js";
import "./tailnet-CsQPCZBE.js";
import "./call-Dm_M_SfO.js";
import "./message-channel-eeeqF-J8.js";
import "./ws-ld1ms-Ht.js";
import "./sandbox-B_7wnPz0.js";
import "./deliver-Ce4muAXi.js";
import "./plugins-D_f06tiR.js";
import "./accounts-Blm-CSIN.js";
import "./dispatcher-kTQZ3t7n.js";
import "./pi-model-discovery-DZFI_e0Z.js";
import "./routes-CHh8zZx-.js";
import "./pi-embedded-helpers-Hus0BP0L.js";
import "./skills-B9WXNmn5.js";
import "./server-context-CdZ_-Xj5.js";
import "./ports-SUg8rnQx.js";
import "./paths-1OcM9YBo.js";
import "./image-yOVg03mb.js";
import "./exec-approvals-K3ABdHGm.js";
import "./nodes-screen-24Fv30p2.js";
import "./redact-DbMu650y.js";
import "./tool-display-D8xZqYsu.js";
import "./control-service-DYqjNgPG.js";
import "./restart-sentinel-DkbwzVUl.js";
import "./channel-selection-BXORBOHN.js";
import "./channel-summary-xp5M-jlo.js";
import "./commands-Bl1f7vmP.js";
import "./pairing-store-F36xrrvf.js";
import "./login-qr-DWYOkTgz.js";
import "./links-DlcX3SnL.js";
import "./progress-D4tnjzku.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 };