import { createLogger } from "../../../utils/logger/index.js";
import { init_logger } from "../../../utils/logger.js";
//#region src/agent/skills/marketplace/registry.ts
init_logger();
const log = createLogger("MarketplaceRegistry");
/** Central adapter map — keyed by adapter id (lowercase). */
const adapters = /* @__PURE__ */ new Map();
/** Display-name overrides set via `registerMarketplaceAdapter`. */
const displayNames = /* @__PURE__ */ new Map();
/**
* Register (or replace) a marketplace adapter.
* Built-in adapters call this at module scope; extensions call it from
* `api.registerMarketplaceAdapter()`.
*/
function registerMarketplaceAdapter(registration) {
	const { adapter, displayName } = registration;
	const id = adapter.id;
	if (adapters.has(id)) log.info({ adapterId: id }, `Replacing marketplace adapter: ${id}`);
	else log.info({ adapterId: id }, `Registered marketplace adapter: ${id}`);
	adapters.set(id, adapter);
	if (displayName) displayNames.set(id, displayName);
}
/** Remove a marketplace adapter (e.g. when an extension is unloaded). */
function unregisterMarketplaceAdapter(id) {
	const removed = adapters.delete(id);
	if (removed) {
		displayNames.delete(id);
		log.info({ adapterId: id }, `Unregistered marketplace adapter: ${id}`);
	}
	return removed;
}
/** Get an adapter by id. Returns `undefined` when not registered. */
function getRegisteredAdapter(id) {
	return adapters.get(id);
}
/** All registered adapter ids (insertion order). */
function getRegisteredAdapterIds() {
	return [...adapters.keys()];
}
/** Provider info list for the UI provider picker. */
function listRegisteredProviders() {
	return [...adapters.entries()].map(([id, adapter]) => ({
		id,
		displayName: displayNames.get(id) ?? adapter.id
	}));
}
/** Display name for a given provider id. */
function getProviderDisplayName(id) {
	return displayNames.get(id) ?? id;
}
/** Check whether a provider id is currently registered. */
function isRegisteredProvider(id) {
	return adapters.has(id);
}
//#endregion
export { getProviderDisplayName, getRegisteredAdapter, getRegisteredAdapterIds, isRegisteredProvider, listRegisteredProviders, registerMarketplaceAdapter, unregisterMarketplaceAdapter };

//# sourceMappingURL=registry.js.map