/**
 * HTTP client for the public xopc-store-compatible REST API (packages list, detail, zip download).
 * Used by the store marketplace adapter and SSRF-safe download helpers.
 *
 * Facade: {@link ../../../skills-marketplace.js}.
 */
import type { Config } from '../../../../../config/schema.js';
import { MAX_EXTENSION_STORE_ZIP_BYTES } from '../../../../../extensions/store-zip-limits.js';
import type { SkillMarkdownPreviewPayload } from '../../../types.js';
/**
 * Marketplace provider identifier. Dynamic — extensions can register additional providers
 * via `api.registerMarketplaceAdapter()`. Built-in values: 'store', 'skillhub', 'clawhub'.
 */
export type SkillsMarketplaceProvider = string;
export interface SkillsStoreListParams {
    q?: string;
    page?: number;
    pageSize?: number;
    sort?: 'downloads' | 'newest';
    /** Adapter-defined category id (exact match against package `categories`). */
    category?: string;
}
/** Category option for marketplace filter chips (from adapter). */
export interface MarketplaceCategoryOption {
    id: string;
    label: string;
}
/** Mirrors xopc-store GET /api/v1/packages list response (subset used by UI). */
export interface SkillsStorePackageListItem {
    id: string;
    name: string;
    type: string;
    description: string;
    downloads: number;
    author: {
        username: string;
        avatarUrl: string | null;
    };
    latestVersion?: string;
    updatedAt: string;
    /** Taxonomy / tags from the marketplace (adapter-specific). */
    categories?: string[];
    tags?: string[];
    stars?: number;
    /** Short provenance label for the row (e.g. ClawHub). */
    sourceLabel?: string;
}
/** Unified marketplace package list item (works for all adapters). */
export type MarketplacePackageListItem = SkillsStorePackageListItem;
export interface SkillsStoreListResponse {
    items: SkillsStorePackageListItem[];
    meta: {
        page: number;
        pageSize: number;
        total: number;
        totalPages: number;
    };
}
export declare function resolveSkillsStoreBaseUrl(config: Config): string;
export { MAX_EXTENSION_STORE_ZIP_BYTES };
/**
 * Base URL for extension downloads (defaults to skills store host — usually store.xopc.ai).
 * Override with `XOPC_EXTENSIONS_STORE_URL`.
 */
export declare function resolveExtensionsStoreBaseUrl(config: Config): string;
export declare function getStoreOrigin(baseUrl: string): string;
/**
 * Allow download URLs whose origin matches the configured store base (SSRF guard).
 * Production store is HTTPS-only; local dev (`http://localhost` / `127.0.0.1`) may use HTTP.
 */
export declare function assertDownloadUrlAllowed(downloadUrl: string, storeBaseUrl: string): URL;
export declare function listSkillPackages(storeBaseUrl: string, params: SkillsStoreListParams): Promise<SkillsStoreListResponse>;
/** GET /api/v1/packages/:name — published skill package (public). */
export interface MarketplacePackageDetail {
    id: string;
    name: string;
    type: string;
    description: string;
    readme: string | null;
    downloads: number;
    author: {
        username: string;
        avatarUrl: string | null;
    };
    latestVersion: {
        version: string;
        changelog: string | null;
        publishedAt: string;
    };
}
export declare function fetchMarketplacePackageDetail(storeBaseUrl: string, packageName: string): Promise<MarketplacePackageDetail>;
export declare function resolveSkillZipDownloadUrl(storeBaseUrl: string, packageName: string, version?: string): Promise<{
    downloadUrl: string;
    version: string;
}>;
export declare function downloadSkillZipBuffer(storeBaseUrl: string, downloadUrl: string): Promise<Buffer>;
/** GET /api/v1/packages/:name — subset used for extension installs. */
export interface StorePublishedPackageHead {
    name: string;
    type: string;
    latestVersion: {
        version: string;
        downloadUrl: string;
    };
}
export declare function resolveExtensionZipDownloadUrl(storeBaseUrl: string, packageName: string, version?: string): Promise<{
    downloadUrl: string;
    version: string;
}>;
export declare function downloadExtensionStoreZipBuffer(storeBaseUrl: string, downloadUrl: string): Promise<Buffer>;
export declare function skillIdForMarketplaceInstall(packageName: string): string | undefined;
/**
 * Unified marketplace list response (adapter fills `provider`).
 */
export interface UnifiedMarketplaceListResponse {
    items: MarketplacePackageListItem[];
    meta: {
        page: number;
        pageSize: number;
        total: number;
        totalPages: number;
    };
    provider: string;
}
/**
 * Unified marketplace package detail response.
 */
export interface UnifiedMarketplacePackageDetail extends MarketplacePackageDetail {
    provider: string;
    /** When set (e.g. SkillHub SKILL.md), gateway console renders structured meta + body like installed skills. */
    skillDocPreview?: SkillMarkdownPreviewPayload;
    /** SkillHub-specific fields */
    skillHubInfo?: {
        category: string;
        installs: number;
        stars: number;
        securityReports?: {
            keen?: {
                status: string;
                statusText: string;
                reportUrl?: string;
            };
            sanbu?: {
                status: string;
                statusText: string;
                reportUrl?: string;
            };
        };
    };
}
