import { MetorialSDKBuilder, GetMetorialSDKConfig } from '@metorial/util-endpoint';
import * as MetorialGenerated from '@metorial/generated';
import { MetorialInstanceEndpoint, MetorialPublishersEndpoint, MetorialProvidersEndpoint, MetorialProvidersVersionsEndpoint, MetorialProvidersSpecificationsEndpoint, MetorialProvidersTriggersEndpoint, MetorialProvidersToolsEndpoint, MetorialProvidersAuthMethodsEndpoint, MetorialIntegrationsEndpoint, MetorialIntegrationsProvidersEndpoint, MetorialIntegrationsInstancesEndpoint, MetorialIntegrationsInstancesProvidersEndpoint, MetorialIntegrationsInstanceGroupsEndpoint, MetorialIntegrationsInstanceGroupsProvidersEndpoint, MetorialIntegrationsSetupSessionsEndpoint, MetorialDocumentsEndpoint, MetorialDocumentsVersionsEndpoint, MetorialDocumentsParticipantsEndpoint, MetorialStoresEndpoint, MetorialStoresItemsEndpoint, MetorialStoresParticipantsEndpoint, MetorialFilesEndpoint, MetorialFilesLinksEndpoint, MetorialProviderDeploymentsEndpoint, MetorialProviderDeploymentsConfigsEndpoint, MetorialProviderDeploymentsConfigVaultsEndpoint, MetorialProviderDeploymentsAuthConfigsEndpoint, MetorialProviderDeploymentsAuthConfigsImportsEndpoint, MetorialProviderDeploymentsAuthConfigsExportsEndpoint, MetorialProviderDeploymentsAuthCredentialsEndpoint, MetorialProviderDeploymentsSetupSessionsEndpoint, MetorialSessionsEndpoint, MetorialSessionsProvidersEndpoint, MetorialSessionsParticipantsEndpoint, MetorialSessionsErrorsEndpoint, MetorialSessionsMessagesEndpoint, MetorialSessionsConnectionsEndpoint, MetorialSkillsEndpoint, MetorialSkillsConfigurationsEndpoint, MetorialSkillsAgentsEndpoint, MetorialSkillsItemsEndpoint, MetorialSkillsParticipantsEndpoint, MetorialSkillsExportsEndpoint, MetorialSkillsTemplatesEndpoint, MetorialSkillsTemplatesItemsEndpoint, MetorialSkillsMarketplacesEndpoint, MetorialSkillsMarketplacesPluginsEndpoint, MetorialSkillsPluginsEndpoint, MetorialSkillsPluginsSkillsEndpoint, MetorialSkillsVersionsEndpoint, MetorialSkillsVersionsSnapshotEndpoint, MetorialSkillsGroupsEndpoint, MetorialSkillsGroupsItemsEndpoint, MetorialCallbacksEndpoint, MetorialCallbacksDestinationsEndpoint, MetorialCallbacksEventsEndpoint, MetorialCallbacksInstancesEndpoint, MetorialSessionTemplatesEndpoint, MetorialSessionTemplatesProvidersEndpoint, MetorialProviderRunsEndpoint, MetorialToolCallsEndpoint, MetorialCustomProvidersEndpoint, MetorialCustomProvidersVersionsEndpoint, MetorialCustomProvidersDeploymentsEndpoint, MetorialMagicMcpServersEndpoint, MetorialMagicMcpServersProvidersEndpoint, MetorialMagicMcpGroupsEndpoint, MetorialMagicMcpSessionsEndpoint, MetorialMagicMcpTokensEndpoint, MetorialMagicMcpEndpointsEndpoint, MetorialPortalsEndpoint, MetorialPortalsAuthAppEndpoint, MetorialPortalsAuthSsoTenantsEndpoint, MetorialPortalsAuthSsoTenantsConnectionsEndpoint, MetorialPortalsAccessEndpoint, MetorialPortalsAccessRequestsEndpoint, MetorialPortalsListingsEndpoint, MetorialPortalsConsumerGroupsEndpoint, MetorialPortalsConsumerInvitesEndpoint, MetorialPortalsConsumerProfilesEndpoint } from '@metorial/generated';

type MetorialKeyPrefix = 'metorial_uk_' | 'metorial_mk_' | 'metorial_sk_' | 'metorial_ak_' | 'metorial_pk_';
declare let coreSdkBuilder: MetorialSDKBuilder<"2026-01-01-magnetar", {
    apiVersion: "2026-01-01-magnetar";
    apiKey: `${MetorialKeyPrefix}${string}` | string;
    headers?: Record<string, string>;
    apiHost?: string;
}>;
type MetorialCoreSDKConfig = GetMetorialSDKConfig<typeof coreSdkBuilder>;

declare let createMetorialCoreSDK: (config: {
    apiKey: `${MetorialKeyPrefix}${string}` | string;
    apiVersion?: "2026-01-01-magnetar";
    headers?: Record<string, string>;
    apiHost?: string;
    fetch?: any;
} & {
    enableDebugLogging?: boolean;
}) => {
    instance: MetorialInstanceEndpoint;
    publishers: MetorialPublishersEndpoint;
    providers: MetorialProvidersEndpoint & {
        versions: MetorialProvidersVersionsEndpoint;
        specifications: MetorialProvidersSpecificationsEndpoint;
        triggers: MetorialProvidersTriggersEndpoint;
        tools: MetorialProvidersToolsEndpoint;
        authMethods: MetorialProvidersAuthMethodsEndpoint;
    };
    integrations: MetorialIntegrationsEndpoint & {
        providers: MetorialIntegrationsProvidersEndpoint;
        instances: MetorialIntegrationsInstancesEndpoint & {
            providers: MetorialIntegrationsInstancesProvidersEndpoint;
        };
        instanceGroups: MetorialIntegrationsInstanceGroupsEndpoint & {
            providers: MetorialIntegrationsInstanceGroupsProvidersEndpoint;
        };
        setupSessions: MetorialIntegrationsSetupSessionsEndpoint;
    };
    documents: MetorialDocumentsEndpoint & {
        versions: MetorialDocumentsVersionsEndpoint;
        participants: MetorialDocumentsParticipantsEndpoint;
    };
    stores: MetorialStoresEndpoint & {
        items: MetorialStoresItemsEndpoint;
        participants: MetorialStoresParticipantsEndpoint;
    };
    files: MetorialFilesEndpoint & {
        links: MetorialFilesLinksEndpoint;
        upload: (input: {
            file: File | Blob;
            purpose: string;
            title?: string;
            store?: {
                id: string;
                path: string;
            };
        }) => Promise<MetorialGenerated.DashboardInstanceFilesGetOutput>;
    };
    providerDeployments: MetorialProviderDeploymentsEndpoint & {
        configs: MetorialProviderDeploymentsConfigsEndpoint;
        configVaults: MetorialProviderDeploymentsConfigVaultsEndpoint;
        authConfigs: MetorialProviderDeploymentsAuthConfigsEndpoint & {
            imports: MetorialProviderDeploymentsAuthConfigsImportsEndpoint;
            exports: MetorialProviderDeploymentsAuthConfigsExportsEndpoint;
        };
        authCredentials: MetorialProviderDeploymentsAuthCredentialsEndpoint;
        setupSessions: MetorialProviderDeploymentsSetupSessionsEndpoint;
    };
    providerSetupSessions: MetorialProviderDeploymentsSetupSessionsEndpoint;
    sessions: MetorialSessionsEndpoint & {
        providers: MetorialSessionsProvidersEndpoint;
        participants: MetorialSessionsParticipantsEndpoint;
        errors: MetorialSessionsErrorsEndpoint;
        messages: MetorialSessionsMessagesEndpoint;
        connections: MetorialSessionsConnectionsEndpoint;
    };
    skills: MetorialSkillsEndpoint & {
        configurations: MetorialSkillsConfigurationsEndpoint;
        agents: MetorialSkillsAgentsEndpoint;
        items: MetorialSkillsItemsEndpoint;
        participants: MetorialSkillsParticipantsEndpoint;
        exports: MetorialSkillsExportsEndpoint;
        templates: MetorialSkillsTemplatesEndpoint & {
            items: MetorialSkillsTemplatesItemsEndpoint;
        };
        marketplaces: MetorialSkillsMarketplacesEndpoint & {
            plugins: MetorialSkillsMarketplacesPluginsEndpoint;
        };
        plugins: MetorialSkillsPluginsEndpoint & {
            skills: MetorialSkillsPluginsSkillsEndpoint;
        };
        versions: MetorialSkillsVersionsEndpoint & {
            snapshot: MetorialSkillsVersionsSnapshotEndpoint;
        };
        groups: MetorialSkillsGroupsEndpoint & {
            items: MetorialSkillsGroupsItemsEndpoint;
        };
    };
    callbacks: MetorialCallbacksEndpoint & {
        destinations: MetorialCallbacksDestinationsEndpoint;
        events: MetorialCallbacksEventsEndpoint;
        instances: MetorialCallbacksInstancesEndpoint;
    };
    sessionTemplates: MetorialSessionTemplatesEndpoint & {
        providers: MetorialSessionTemplatesProvidersEndpoint;
    };
    providerRuns: MetorialProviderRunsEndpoint;
    toolCalls: MetorialToolCallsEndpoint;
    customProviders: MetorialCustomProvidersEndpoint & {
        versions: MetorialCustomProvidersVersionsEndpoint;
        deployments: MetorialCustomProvidersDeploymentsEndpoint;
    };
    magicMcp: {
        servers: MetorialMagicMcpServersEndpoint & {
            providers: MetorialMagicMcpServersProvidersEndpoint;
        };
        groups: MetorialMagicMcpGroupsEndpoint;
        sessions: MetorialMagicMcpSessionsEndpoint;
        tokens: MetorialMagicMcpTokensEndpoint;
        endpoints: MetorialMagicMcpEndpointsEndpoint;
    };
    portals: MetorialPortalsEndpoint & {
        auth: MetorialPortalsAuthAppEndpoint & {
            ssoTenants: MetorialPortalsAuthSsoTenantsEndpoint & {
                connections: MetorialPortalsAuthSsoTenantsConnectionsEndpoint;
            };
        };
        access: MetorialPortalsAccessEndpoint;
        accessRequests: MetorialPortalsAccessRequestsEndpoint;
        listings: MetorialPortalsListingsEndpoint;
        consumerGroups: MetorialPortalsConsumerGroupsEndpoint;
        consumerInvites: MetorialPortalsConsumerInvitesEndpoint;
        consumerProfiles: MetorialPortalsConsumerProfilesEndpoint;
    };
} & {
    _config: {
        apiVersion: "2026-01-01-magnetar";
        apiKey: `${MetorialKeyPrefix}${string}` | string;
        headers?: Record<string, string>;
        apiHost?: string;
    } & {
        apiHost: string;
    };
};
type MetorialCoreSDK = ReturnType<typeof createMetorialCoreSDK>;

declare namespace MetorialSDK {
    type Instance = MetorialGenerated.InstanceGetOutput;
    type Publisher = MetorialGenerated.PublishersGetOutput;
    type Provider = MetorialGenerated.ProvidersGetOutput;
    type ProviderVersion = MetorialGenerated.ProvidersVersionsGetOutput;
    type ProviderSpecification = MetorialGenerated.ProvidersSpecificationsGetOutput;
    type ProviderTrigger = MetorialGenerated.ProvidersTriggersGetOutput;
    type ProviderTool = MetorialGenerated.ProvidersToolsGetOutput;
    type ProviderAuthMethod = MetorialGenerated.ProvidersAuthMethodsGetOutput;
    type Integration = MetorialGenerated.IntegrationsGetOutput;
    type IntegrationProvider = MetorialGenerated.IntegrationsProvidersGetOutput;
    type IntegrationSetupSession = MetorialGenerated.IntegrationsSetupSessionsGetOutput;
    type IntegrationInstance = MetorialGenerated.IntegrationsInstancesGetOutput;
    type IntegrationInstanceProvider = MetorialGenerated.IntegrationsInstancesProvidersGetOutput;
    type IntegrationInstanceGroup = MetorialGenerated.IntegrationsInstanceGroupsGetOutput;
    type IntegrationInstanceGroupProvider = MetorialGenerated.IntegrationsInstanceGroupsProvidersGetOutput;
    type Document = MetorialGenerated.DocumentsGetOutput;
    type DocumentVersion = MetorialGenerated.DocumentsVersionsGetOutput;
    type DocumentParticipant = MetorialGenerated.DocumentsParticipantsGetOutput;
    type Store = MetorialGenerated.StoresGetOutput;
    type StoreItem = MetorialGenerated.StoresItemsGetOutput;
    type StoreParticipant = MetorialGenerated.StoresParticipantsGetOutput;
    type File = MetorialGenerated.FilesGetOutput;
    type FileLink = MetorialGenerated.FilesLinksGetOutput;
    type ProviderCategory = MetorialGenerated.ProviderCategoriesGetOutput;
    type ProviderCollection = MetorialGenerated.ProviderCollectionsGetOutput;
    type ProviderGroup = MetorialGenerated.ProviderGroupsGetOutput;
    type ProviderListing = MetorialGenerated.ProviderListingsGetOutput;
    type ProviderDeployment = MetorialGenerated.ProviderDeploymentsGetOutput;
    type ProviderDeploymentConfig = MetorialGenerated.ProviderDeploymentsConfigsGetOutput;
    type ProviderDeploymentConfigVault = MetorialGenerated.ProviderDeploymentsConfigVaultsGetOutput;
    type ProviderDeploymentAuthCredential = MetorialGenerated.ProviderDeploymentsAuthCredentialsGetOutput;
    type ProviderDeploymentSetupSession = MetorialGenerated.ProviderDeploymentsSetupSessionsGetOutput;
    type ProviderDeploymentAuthConfig = MetorialGenerated.ProviderDeploymentsAuthConfigsGetOutput;
    type ProviderDeploymentAuthConfigImport = MetorialGenerated.ProviderDeploymentsAuthConfigsImportsGetOutput;
    type ProviderDeploymentAuthConfigExport = MetorialGenerated.ProviderDeploymentsAuthConfigsExportsGetOutput;
    type ProviderSetupSession = MetorialGenerated.ProviderDeploymentsSetupSessionsGetOutput;
    type Session = MetorialGenerated.SessionsGetOutput;
    type SessionProvider = MetorialGenerated.SessionsProvidersGetOutput;
    type SessionParticipant = MetorialGenerated.SessionsParticipantsGetOutput;
    type SessionError = MetorialGenerated.SessionsErrorsGetOutput;
    type SessionMessage = MetorialGenerated.SessionsMessagesGetOutput;
    type SessionConnection = MetorialGenerated.SessionsConnectionsGetOutput;
    type Skill = MetorialGenerated.SkillsGetOutput;
    type SkillConfiguration = MetorialGenerated.SkillsConfigurationsGetOutput;
    type SkillAgent = MetorialGenerated.SkillsAgentsGetOutput;
    type SkillItem = MetorialGenerated.SkillsItemsGetOutput;
    type SkillParticipant = MetorialGenerated.SkillsParticipantsGetOutput;
    type SkillExport = MetorialGenerated.SkillsExportsGetOutput;
    type SkillTemplate = MetorialGenerated.SkillsTemplatesGetOutput;
    type SkillTemplateItem = MetorialGenerated.SkillsTemplatesItemsGetOutput;
    type SkillMarketplace = MetorialGenerated.SkillsMarketplacesGetOutput;
    type SkillMarketplacePlugin = MetorialGenerated.SkillsMarketplacesPluginsGetOutput;
    type SkillPlugin = MetorialGenerated.SkillsPluginsGetOutput;
    type SkillPluginSkill = MetorialGenerated.SkillsPluginsSkillsGetOutput;
    type SkillVersion = MetorialGenerated.SkillsVersionsGetOutput;
    type SkillVersionSnapshot = MetorialGenerated.SkillsVersionsSnapshotGetOutput;
    type SkillGroup = MetorialGenerated.SkillsGroupsGetOutput;
    type SkillGroupItem = MetorialGenerated.SkillsGroupsItemsGetOutput;
    type Callback = MetorialGenerated.CallbacksGetOutput;
    type CallbackDestination = MetorialGenerated.CallbacksDestinationsGetOutput;
    type CallbackEvent = MetorialGenerated.CallbacksEventsGetOutput;
    type CallbackInstance = MetorialGenerated.CallbacksInstancesGetOutput;
    type SessionTemplate = MetorialGenerated.SessionTemplatesGetOutput;
    type SessionTemplateProvider = MetorialGenerated.SessionTemplatesProvidersGetOutput;
    type ProviderRun = MetorialGenerated.ProviderRunsGetOutput;
    type ToolCall = MetorialGenerated.ToolCallsGetOutput;
    type CustomProvider = MetorialGenerated.CustomProvidersGetOutput;
    type CustomProviderVersion = MetorialGenerated.CustomProvidersVersionsGetOutput;
    type CustomProviderDeployment = MetorialGenerated.CustomProvidersDeploymentsGetOutput;
    type MagicMcpServer = MetorialGenerated.MagicMcpServersGetOutput;
    type MagicMcpServerProvider = MetorialGenerated.MagicMcpServersProvidersGetOutput;
    type MagicMcpGroup = MetorialGenerated.MagicMcpGroupsGetOutput;
    type MagicMcpSession = MetorialGenerated.MagicMcpSessionsGetOutput;
    type MagicMcpToken = MetorialGenerated.MagicMcpTokensGetOutput;
    type MagicMcpEndpoint = MetorialGenerated.MagicMcpEndpointsGetOutput;
    type Portal = MetorialGenerated.PortalsGetOutput;
    type PortalAccess = MetorialGenerated.PortalsAccessGetOutput;
    type PortalAccessRequest = MetorialGenerated.PortalsAccessRequestsGetOutput;
    type PortalAccessGroup = MetorialGenerated.PortalsConsumerGroupsGetOutput;
    type PortalAccessProfile = MetorialGenerated.PortalsConsumerProfilesGetOutput;
    type PortalAccessInvite = MetorialGenerated.PortalsConsumerInvitesGetOutput;
}

export { type MetorialCoreSDK, MetorialSDK, type MetorialCoreSDKConfig as MetorialSDKConfig, createMetorialCoreSDK, coreSdkBuilder as metorialSdkBuilder };
