import { createLogger } from "../../utils/logger/index.js";
import { init_logger } from "../../utils/logger.js";
import { init_paths, resolveExtensionsDir } from "../../config/paths.js";
import { loadConfig } from "../../config/loader.js";
import { getWorkspacePath } from "../../config/workspace-path-helpers.js";
import { ExtensionLoader } from "../../extensions/loader.js";
import "../../config/index.js";
//#region src/tui/extension-host/load-extensions.ts
init_paths();
init_logger();
const log = createLogger("TUI:Extensions");
/** Load activated extensions for embedded TUI (shared registry with AgentService). */
async function loadExtensionsForTuiLocalMode() {
	const config = loadConfig();
	const loader = new ExtensionLoader({
		workspaceDir: getWorkspacePath(config) ?? process.cwd(),
		extensionsDir: resolveExtensionsDir()
	});
	loader.setConfig(config);
	try {
		await loader.loadByActivationPlan();
		const registry = loader.getRegistry();
		log.info({
			extensions: registry.extensions.size,
			tuiRegistrations: registry.getTuiRegistrations().length
		}, "Extensions loaded for local TUI");
		return registry;
	} catch (err) {
		const errorMessage = err instanceof Error ? err.message : String(err);
		log.warn({
			err,
			errorMessage
		}, `Extension load for TUI failed: ${errorMessage}`);
		return loader.getRegistry();
	}
}
//#endregion
export { loadExtensionsForTuiLocalMode };

//# sourceMappingURL=load-extensions.js.map