import { registerMarketplaceAdapter } from "../../registry.js";
import { downloadSkillZipBuffer, fetchMarketplacePackageDetail, listSkillPackages, resolveSkillZipDownloadUrl, resolveSkillsStoreBaseUrl, skillIdForMarketplaceInstall } from "./store-api-client.js";
//#region src/agent/skills/marketplace/adapters/store/adapter.ts
const storeMarketplaceAdapter = {
	id: "store",
	async listCategories(_config) {
		return [];
	},
	async listPackages(config, params) {
		const response = await listSkillPackages(resolveSkillsStoreBaseUrl(config), params);
		return {
			items: response.items,
			meta: response.meta,
			provider: "store"
		};
	},
	async getPackageDetail(config, packageName) {
		return {
			...await fetchMarketplacePackageDetail(resolveSkillsStoreBaseUrl(config), packageName),
			provider: "store"
		};
	},
	async downloadPackage(config, packageName, version) {
		const base = resolveSkillsStoreBaseUrl(config);
		const { downloadUrl, version: resolvedVersion } = await resolveSkillZipDownloadUrl(base, packageName, version);
		return {
			buffer: await downloadSkillZipBuffer(base, downloadUrl),
			skillId: skillIdForMarketplaceInstall(packageName) ?? packageName,
			version: resolvedVersion
		};
	}
};
registerMarketplaceAdapter({
	adapter: storeMarketplaceAdapter,
	displayName: "XOPC Store"
});
//#endregion
export { storeMarketplaceAdapter };

//# sourceMappingURL=adapter.js.map