UNPKG

@lobehub/market-types

Version:

[![NPM version](https://img.shields.io/npm/v/@lobehub/market-sdk.svg?style=flat)](https://npmjs.org/package/@lobehub/market-types) [![NPM downloads](https://img.shields.io/npm/dm/@lobehub/market-sdk.svg?style=flat)](https://npmjs.org/package/@lobehub/mark

1,616 lines (1,600 loc) 69.2 kB
import { z } from 'zod'; /** * Base structure for a single resource item in the marketplace. * This interface defines the common properties shared by all marketplace items, * including plugins, agents, and other resources. */ interface MarketItemBase { /** Author or organization name */ author?: string; /** Category name used for classification */ category?: string; /** Optional: Compatibility information for different platforms or versions */ compatibility?: Record<string, any>; /** Resource creation date in the marketplace (ISO 8601 format) */ createdAt: string; /** Localized short description displayed in the marketplace listing */ description: string; /** URL to the resource's homepage or documentation */ homepage?: string; /** Icon URL or Emoji character */ icon?: string; /** Globally unique identifier, typically contains author/namespace and name */ identifier: string; /** URL pointing to the detailed manifest file for this resource */ manifestUrl: string; /** Localized display name shown in the marketplace listing */ name: string; /** List of localized tags for filtering and categorization */ tags?: string[]; /** Resource's last update date in the marketplace (ISO 8601 format) */ updatedAt: string; } /** * Category list request query parameters * * Query parameters for retrieving category statistics with optional filtering. */ interface CategoryListQuery { /** Optional locale for localized search, defaults to 'en-US' */ locale?: string; /** Optional search query to filter plugins before counting categories */ q?: string; } /** * Single category item with plugin count * * Represents a category and the number of plugins in that category. */ interface CategoryItem { /** Category name */ category: string; /** Number of plugins in this category */ count: number; } /** * Category list response type * * Array of categories with their respective plugin counts. */ type CategoryListResponse = CategoryItem[]; /** * Single entry in a marketplace sitemap (identifier + last modified). */ interface SitemapItem { /** Resource identifier (slug) */ identifier: string; /** Last modification time (ISO 8601) */ lastModified: string; } /** * Paginated sitemap response for agents, plugins, or skills. */ interface SitemapResponse { /** Current page number (1-based) */ currentPage: number; /** Items on this page */ items: SitemapItem[]; /** Page size used for this response */ pageSize: number; /** Total number of published items */ totalCount: number; /** Total number of pages */ totalPages: number; } /** * Agent event tracking types * * These types describe the payload used when recording user agent events such as * adding, chatting with, or clicking an agent card. */ type AgentEventType = 'add' | 'chat' | 'click'; /** Payload for recording an agent event */ interface AgentEventRequest { /** Event name */ event: AgentEventType; /** Agent identifier */ identifier: string; /** Optional event source */ source?: string; } /** * Agent resource item definition that extends the base marketplace structure. * * Agents represent AI personalities or specialized assistants that can be installed * from the marketplace. They include the base properties of marketplace items along * with any agent-specific properties. */ interface AgentItem extends MarketItemBase { /** Optional agent capabilities and features */ capabilities?: { /** Whether the agent supports memory/history */ memory?: boolean; /** Whether the agent supports additional tools */ tools?: boolean; }; } /** * Query parameters for listing agents in the marketplace. * Mirrors SkillListQuery and PluginListQuery in structure for consistency. * * Named AgentMarketListQuery (not AgentListQuery) to avoid collision with the * SDK's own AgentListQuery which contains additional SDK-specific fields. */ interface AgentMarketListQuery { /** Filter by category */ category?: string; /** Filter by agents with skills/plugins attached */ haveSkills?: boolean; /** Filter by official status */ isOfficial?: 'false' | 'true'; /** Locale for localized content */ locale?: string; /** Filter by namespace */ namespace?: string; /** Sort direction */ order?: 'asc' | 'desc'; /** Filter by owner ID */ ownerId?: number; /** Page number (1-based) */ page?: number; /** Number of items per page */ pageSize?: number; /** Search query string */ q?: string; /** Sort field */ sort?: 'createdAt' | 'knowledgeCount' | 'mostUsage' | 'name' | 'pluginCount' | 'recommended' | 'relevance' | 'tokenUsage' | 'updatedAt'; /** Publication status filter */ status?: 'all' | 'archived' | 'deprecated' | 'published' | 'unpublished'; /** Visibility filter */ visibility?: 'all' | 'internal' | 'private' | 'public'; } /** * Top Plugin Interface * Unified interface for top plugins data */ interface TopPlugin { avatar: string; /** Call count (when sortBy is 'calls') */ callCount?: number; category: string; identifier: string; /** Install count (when sortBy is 'installs') */ installCount?: number; name: string; } /** * Sort options for top plugins */ type PluginSortBy = 'installs' | 'calls'; /** * Top plugins query parameters */ interface TopPluginsQuery { /** Maximum number of plugins to return */ limit?: number; /** Date range as [startDate, endDate] */ range: [string, string]; /** Sort criteria: 'installs' or 'calls' */ sortBy?: PluginSortBy; } /** * Install Failure Analysis Interface * Defines the structure for plugin install failure analysis data */ interface InstallFailureAnalysis { /** Number of failed installation attempts */ failureCount: number; /** Failure rate as a decimal (e.g., 0.2736 for 27.36%) */ failureRate: number; /** Most common error message for this plugin */ mostCommonError: string; /** Plugin identifier */ pluginIdentifier: string; /** Plugin display name */ pluginName: string; /** Total number of installation attempts (successful + failed) */ totalInstallAttempts: number; } /** * Install failure analysis query parameters */ interface InstallFailureAnalysisQuery { /** Maximum number of plugins to return */ limit?: number; /** Date range as [startDate, endDate] */ range: [string, string]; } /** * Standard Credential Keys * * Pre-defined credential key catalog for common providers. * Skill authors should prefer these standard keys over custom ones. * * Rules: * 1. `key` represents a capability, not a final env variable name. * 2. Same provider with different auth methods should have different keys. * 3. Custom keys are allowed but standard keys should be preferred. */ declare const StandardCredKeys: { readonly ANTHROPIC: "anthropic"; readonly COHERE: "cohere"; readonly DEEPSEEK: "deepseek"; readonly GOOGLE_AI: "google-ai"; readonly GROQ: "groq"; readonly HUGGINGFACE: "huggingface"; readonly MISTRAL: "mistral"; readonly OPENAI: "openai"; readonly PERPLEXITY: "perplexity"; readonly REPLICATE: "replicate"; readonly AWS: "aws"; readonly AZURE: "azure"; readonly CLOUDFLARE: "cloudflare"; readonly FIREBASE_SA: "firebase-sa"; readonly GCP_SA: "gcp-sa"; readonly SUPABASE: "supabase"; readonly VERCEL: "vercel"; readonly BITBUCKET_PAT: "bitbucket-pat"; readonly GITHUB_OAUTH: "github-oauth"; readonly GITHUB_PAT: "github-pat"; readonly GITLAB_PAT: "gitlab-pat"; readonly DISCORD_BOT: "discord-bot"; readonly DISCORD_WEBHOOK: "discord-webhook"; readonly SENDGRID: "sendgrid"; readonly SLACK_OAUTH: "slack-oauth"; readonly SLACK_WEBHOOK: "slack-webhook"; readonly TWILIO: "twilio"; readonly AIRTABLE: "airtable"; readonly MONGODB: "mongodb"; readonly PLANETSCALE: "planetscale"; readonly REDIS: "redis"; readonly STRIPE: "stripe"; readonly JIRA_PAT: "jira-pat"; readonly LINEAR_OAUTH: "linear-oauth"; readonly NOTION_OAUTH: "notion-oauth"; readonly NOTION_PAT: "notion-pat"; }; type StandardCredKey = (typeof StandardCredKeys)[keyof typeof StandardCredKeys]; /** * Creds Domain Types * * Shared types for the Credential system used by Market API and SDK. */ /** * Credential type taxonomy: * - `kv-env`: Key-value pairs injected as environment variables * - `kv-header`: Key-value pairs injected as HTTP headers (not supported in sandbox) * - `oauth`: OAuth connection reference (reuses existing Connect system) * - `file`: Encrypted file stored in object storage */ type CredType = 'file' | 'kv-env' | 'kv-header' | 'oauth'; /** * Config for `kv-env` type credentials */ interface KVEnvCredConfig { /** * Optional mapping from payload keys to environment variable names. * If not specified, payload keys are used as-is (uppercased). * Example: { "OPENAI_API_KEY": "MY_OPENAI_KEY" } */ envMapping?: Record<string, string>; } /** * Config for `kv-header` type credentials */ interface KVHeaderCredConfig { /** * Mapping from payload keys to HTTP header names. * Example: { "API_KEY": "Authorization" } */ headerMapping?: Record<string, string>; } /** * Config for `oauth` type credentials */ interface OAuthCredConfig { /** * OAuth provider ID (e.g., 'github', 'linear', 'google') * Must match a provider registered in the Connect system. */ providerId: string; /** * Required OAuth scopes for this credential. */ scopes?: string[]; } /** * Config for `file` type credentials */ interface FileCredConfig { /** * Allowed MIME types for the file. * Example: ['application/json', 'application/x-pem-file'] */ allowedMimeTypes?: string[]; /** * Environment variable name to inject the file path. * Example: "GOOGLE_APPLICATION_CREDENTIALS" */ filePathEnvName?: string; /** * Maximum file size in bytes. */ maxSizeBytes?: number; } /** * Union type for credential configs based on type */ type CredConfig = FileCredConfig | KVEnvCredConfig | KVHeaderCredConfig | OAuthCredConfig; /** * Skill's declaration of required credentials. * Stored in `skills.creds` JSONB column. */ interface SkillCredDeclaration { /** * Type-specific configuration */ config?: CredConfig; /** * Human-readable description of what this credential is used for */ description?: string; /** * Unique key identifying this credential requirement. * Should use StandardCredKeys when possible. * Examples: 'github-pat', 'openai', 'gcp-sa' */ key: string; /** * Display name for the credential */ name: string; /** * Whether this credential is required for the skill to function */ required: boolean; /** * Credential type */ type: CredType; } /** * User credential summary (masked, safe to return to frontend) */ interface UserCredSummary { createdAt: string; description?: string; /** * For file type: original file name */ fileName?: string; /** * For file type: file size in bytes */ fileSize?: number; id: number; key: string; lastUsedAt?: string; /** * Additional non-sensitive metadata */ manifest?: Record<string, unknown>; /** * Masked preview of the credential value. * Examples: "sk-****xxxx", "Connected to @octocat", "service-account.json" */ maskedPreview?: string; name: string; /** * For oauth type: provider avatar URL */ oauthAvatar?: string; /** * For oauth type: provider ID */ oauthProvider?: string; /** * For oauth type: provider username */ oauthUsername?: string; type: CredType; updatedAt: string; } /** * Status of a skill's credential requirement for a specific user */ interface SkillCredStatus { /** * The bound credential if satisfied */ boundCred?: UserCredSummary; description?: string; key: string; name: string; required: boolean; /** * Whether the user has provided this credential */ satisfied: boolean; type: CredType; } /** * Decrypted payload structure for kv-env and kv-header types. * Supports multiple key-value pairs in a single credential. */ interface KVPayload { /** * Key-value pairs to inject. * Example: { "OPENAI_API_KEY": "sk-xxx", "OPENAI_ORG_ID": "org-xxx" } */ values: Record<string, string>; } /** * Request payload for explicit credential injection (by key list) */ interface InjectCredsRequest { /** * List of credential keys to inject. * Each key should match a user's credential key. */ keys: string[]; /** * Whether this is a sandbox environment (default: true). * When true, kv-header type credentials will be skipped. */ sandbox?: boolean; /** * Topic/conversation ID for session isolation. * Required to identify the sandbox session. */ topicId: string; /** * User ID for session isolation. * Required to identify the sandbox session. */ userId: string; } /** * File credential info in injection response */ interface InjectedFileInfo { /** * File content URL (S3 URL, needs to be fetched) */ content: string; /** * Environment variable name for the file path (if specified) */ envName?: string; /** * Original file name */ fileName: string; /** * Credential key */ key: string; /** * File MIME type */ mimeType: string; } /** * Response payload for credential injection */ interface InjectCredsResponse { credentials: { /** * Environment variables to inject */ env: Record<string, string>; /** * Files to write (for sandbox environments) */ files: InjectedFileInfo[]; /** * HTTP headers to inject (not supported in sandbox) */ headers: Record<string, string>; }; /** * Keys that were requested but not found */ notFound: string[]; /** * Whether all requested keys were found and injected */ success: boolean; /** * Credentials that cannot be injected in sandbox environment (kv-header type) */ unsupportedInSandbox: string[]; } /** * Request payload for skill-based credential injection */ interface InjectCredsForSkillRequest { /** * Whether this is a sandbox environment (default: true). * When true, kv-header type credentials will be skipped. */ sandbox?: boolean; /** * Skill identifier to inject credentials for */ skillIdentifier: string; /** * Topic/conversation ID for session isolation. * Required to identify the sandbox session. */ topicId: string; /** * User ID for session isolation. * Required to identify the sandbox session. */ userId: string; } /** * Response payload for skill-based credential injection */ interface InjectCredsForSkillResponse { credentials: { /** * Environment variables to inject */ env: Record<string, string>; /** * Files to write (for sandbox environments) */ files: InjectedFileInfo[]; /** * HTTP headers to inject (not supported in sandbox) */ headers: Record<string, string>; }; /** * Required credentials that are missing */ missing: Array<{ key: string; name: string; type: CredType; }>; /** * Whether all required credentials are satisfied */ success: boolean; /** * Credentials that cannot be injected in sandbox environment (kv-header type) */ unsupportedInSandbox: string[]; } /** * MCP (Model Context Protocol) Type Definitions * * This file contains type definitions for the MCP protocol used in cloud gateway functionality. */ /** * Content item in MCP tool response */ interface McpToolContent { /** Additional data for other types */ data?: string; /** Error message for error type */ message?: string; /** MIME type of the content */ mimeType?: string; /** Text content for text/error types */ text?: string; /** Content type */ type: 'text' | 'error' | 'image' | 'resource'; } /** * Cloud Gateway Request Interface */ interface CloudGatewayRequest { /** Tool parameters payload */ apiParams: Record<string, any>; /** Plugin unique identifier */ identifier: string; /** Tool name to invoke */ toolName: string; } /** * Cloud Gateway Response Interface */ interface CloudGatewayResponse { /** Array of content items returned by the tool */ content: McpToolContent[]; /** Whether this result represents an error */ isError?: boolean; } /** * Error response for cloud gateway */ interface CloudGatewayErrorResponse { /** Error code (optional) */ code?: string; /** Additional error details */ details?: any; /** Error message */ message: string; } /** * Connection types for plugin communication. * - http: The plugin communicates via HTTP protocol * - stdio: The plugin communicates via standard input/output */ declare const ConnectionTypeEnum: z.ZodEnum<["http", "stdio", "sse"]>; type ConnectionType = z.infer<typeof ConnectionTypeEnum>; /** * Plugin connection types for overall plugin communication strategy. * - local: Plugin only supports local communication (stdio) * - remote: Plugin only supports remote communication (http) * - hybrid: Plugin supports both local and remote communication */ declare const PluginConnectionTypeEnum: z.ZodEnum<["local", "remote", "hybrid"]>; type PluginConnectionType = z.infer<typeof PluginConnectionTypeEnum>; /** * Plugin installation methods. * Different ways to install and deploy a plugin. */ declare const InstallationMethodEnum: z.ZodEnum<["npm", "go", "python", "docker", "git", "binaryUrl", "manual", "none"]>; type InstallationMethod = z.infer<typeof InstallationMethodEnum>; /** * System dependency required by a plugin. * Defines a software dependency that must be installed on the system. */ interface SystemDependency { /** Command to check if the dependency is installed */ checkCommand?: string; /** Description of what this dependency is for */ description?: string; /** Platform-specific installation instructions */ installInstructions?: Record<string, string>; /** Name of the dependency */ name: string; /** Minimum required version */ requiredVersion?: string; /** Type of dependency (e.g., 'runtime', 'library') */ type?: string; /** Whether version parsing is required to check compatibility */ versionParsingRequired?: boolean; } /** * Connection configuration for a plugin. * Defines how the application should communicate with the plugin. */ interface ConnectionConfig { /** Command-line arguments for the plugin process */ args?: string[]; /** Command to execute to start the plugin */ command?: string; /** * JSON Schema 配置 * 插件运行时需要的 configSchema */ configSchema?: any; /** Type of connection (http or stdio) */ type: ConnectionType; /** URL for HTTP-based plugins */ url?: string; } /** * Details for installing a plugin. * Provides specific information needed during the installation process. */ interface InstallationDetails { /** Package name for npm, pip, or other package managers */ packageName?: string; /** Git repository URL to clone */ repositoryUrlToClone?: string; /** Ordered list of setup steps to execute after installation */ setupSteps?: string[]; } /** * Deployment option for a plugin. * A plugin can offer multiple deployment options, each with different requirements. */ interface DeploymentOption { /** Connection configuration for this deployment option */ connection: ConnectionConfig; /** Human-readable description of this deployment option */ description?: string; /** Detailed installation instructions */ installationDetails?: InstallationDetails; /** Method used to install this plugin */ installationMethod: string; /** Whether this is the recommended deployment option */ isRecommended?: boolean; /** System dependencies required for this deployment option */ systemDependencies?: SystemDependency[]; } /** * Schema defining the capabilities a plugin can provide. * Each capability is represented as a boolean flag. */ declare const PluginCapabilitiesSchema: z.ZodObject<{ /** Whether the plugin provides custom prompts */ prompts: z.ZodDefault<z.ZodBoolean>; /** Whether the plugin provides resources (assets) */ resources: z.ZodDefault<z.ZodBoolean>; /** Whether the plugin provides tools (functions) */ tools: z.ZodDefault<z.ZodBoolean>; }, "strip", z.ZodTypeAny, { prompts: boolean; resources: boolean; tools: boolean; }, { prompts?: boolean | undefined; resources?: boolean | undefined; tools?: boolean | undefined; }>; /** * Definition of a tool that a plugin can provide. * Tools are functions that can be called by the chat application. */ interface PluginTool { /** Human-readable description of what the tool does */ description?: string; /** JSON schema defining the expected input parameters */ inputSchema?: Record<string, any>; /** Unique identifier for the tool within the plugin */ name: string; } /** * Definition of a resource (asset) that a plugin can provide. * Resources can be images, data files, or other assets needed by the plugin. */ interface PluginResource { /** MIME type of the resource (e.g., 'image/png', 'application/json') */ mimeType?: string; /** Optional display name for the resource */ name?: string; /** URI where the resource can be accessed */ uri: string; } /** * Definition of an argument for a prompt template. * Arguments allow users to customize the prompt when using it. */ interface PromptArgument { /** Human-readable description of the argument's purpose */ description?: string; /** Argument identifier */ name: string; /** Whether the argument must be provided (defaults to false if omitted) */ required?: boolean; /** Data type of the argument (e.g., 'string', 'number') */ type?: string; } /** * Definition of a prompt template that a plugin can provide. * Prompts are pre-defined templates that can be used in conversations. */ interface PluginPrompt { /** List of customizable arguments for this prompt */ arguments?: PromptArgument[]; /** Human-readable description of what the prompt does */ description: string; /** Unique identifier for the prompt within the plugin */ name: string; } /** * Plugin compatibility information. * Defines the compatibility requirements for a plugin with respect to app versions and platforms. */ interface PluginCompatibility { /** Maximum app version the plugin is compatible with */ maxAppVersion?: string; /** Minimum app version required to use the plugin */ minAppVersion?: string; /** List of supported platforms (e.g., 'web', 'desktop', 'mobile') */ platforms?: string[]; } /** * Simplified plugin version information. * Contains minimal version data for plugin version lists. */ interface PluginVersionSummary { /** Creation timestamp (ISO 8601 format) */ createdAt: string; /** Whether this is the latest version of the plugin */ isLatest: boolean; /** Whether this version has been validated by the system */ isValidated: boolean; /** Semantic version string (e.g., "1.0.0") */ version: string; } /** * Base plugin item schema with Zod validation. * Defines the structure and validation rules for plugin items in the marketplace. */ declare const BasePluginItemSchema: z.ZodObject<{ author: z.ZodOptional<z.ZodString>; capabilities: z.ZodObject<{ prompts: z.ZodDefault<z.ZodBoolean>; resources: z.ZodDefault<z.ZodBoolean>; tools: z.ZodDefault<z.ZodBoolean>; }, "strip", z.ZodTypeAny, { prompts: boolean; resources: boolean; tools: boolean; }, { prompts?: boolean | undefined; resources?: boolean | undefined; tools?: boolean | undefined; }>; category: z.ZodOptional<z.ZodString>; commentCount: z.ZodDefault<z.ZodNumber>; connectionType: z.ZodOptional<z.ZodEnum<["local", "remote", "hybrid"]>>; createdAt: z.ZodString; description: z.ZodString; github: z.ZodOptional<z.ZodObject<{ language: z.ZodOptional<z.ZodString>; license: z.ZodOptional<z.ZodString>; stars: z.ZodOptional<z.ZodNumber>; url: z.ZodString; }, "strip", z.ZodTypeAny, { url: string; language?: string | undefined; license?: string | undefined; stars?: number | undefined; }, { url: string; language?: string | undefined; license?: string | undefined; stars?: number | undefined; }>>; haveCloudEndpoint: z.ZodOptional<z.ZodBoolean>; homepage: z.ZodOptional<z.ZodString>; icon: z.ZodOptional<z.ZodString>; identifier: z.ZodString; installCount: z.ZodDefault<z.ZodNumber>; isClaimed: z.ZodDefault<z.ZodBoolean>; isFeatured: z.ZodDefault<z.ZodBoolean>; isOfficial: z.ZodDefault<z.ZodBoolean>; isValidated: z.ZodDefault<z.ZodBoolean>; manifestUrl: z.ZodString; name: z.ZodString; promptsCount: z.ZodOptional<z.ZodNumber>; ratingAverage: z.ZodOptional<z.ZodNumber>; ratingCount: z.ZodDefault<z.ZodNumber>; resourcesCount: z.ZodOptional<z.ZodNumber>; toolsCount: z.ZodOptional<z.ZodNumber>; updatedAt: z.ZodString; }, "strip", z.ZodTypeAny, { createdAt: string; name: string; updatedAt: string; capabilities: { prompts: boolean; resources: boolean; tools: boolean; }; commentCount: number; description: string; identifier: string; installCount: number; isClaimed: boolean; isFeatured: boolean; isOfficial: boolean; isValidated: boolean; manifestUrl: string; ratingCount: number; author?: string | undefined; category?: string | undefined; connectionType?: "local" | "remote" | "hybrid" | undefined; github?: { url: string; language?: string | undefined; license?: string | undefined; stars?: number | undefined; } | undefined; haveCloudEndpoint?: boolean | undefined; homepage?: string | undefined; icon?: string | undefined; promptsCount?: number | undefined; ratingAverage?: number | undefined; resourcesCount?: number | undefined; toolsCount?: number | undefined; }, { createdAt: string; name: string; updatedAt: string; capabilities: { prompts?: boolean | undefined; resources?: boolean | undefined; tools?: boolean | undefined; }; description: string; identifier: string; manifestUrl: string; author?: string | undefined; category?: string | undefined; commentCount?: number | undefined; connectionType?: "local" | "remote" | "hybrid" | undefined; github?: { url: string; language?: string | undefined; license?: string | undefined; stars?: number | undefined; } | undefined; haveCloudEndpoint?: boolean | undefined; homepage?: string | undefined; icon?: string | undefined; installCount?: number | undefined; isClaimed?: boolean | undefined; isFeatured?: boolean | undefined; isOfficial?: boolean | undefined; isValidated?: boolean | undefined; promptsCount?: number | undefined; ratingAverage?: number | undefined; ratingCount?: number | undefined; resourcesCount?: number | undefined; toolsCount?: number | undefined; }>; /** * Plugin marketplace item definition. * Extends the base marketplace item with plugin-specific properties. * This interface represents a plugin as it appears in the marketplace listing. */ interface MarketPluginItem extends MarketItemBase { /** Capabilities provided by this plugin */ capabilities?: { /** Whether the plugin provides custom prompts */ prompts: boolean; /** Whether the plugin provides resources (assets) */ resources: boolean; /** Whether the plugin provides tools (functions) */ tools: boolean; }; /** Number of comments on this plugin */ commentCount?: number; /** Connection type strategy for communicating with the plugin */ connectionType?: PluginConnectionType; /** GitHub repository information */ github?: { language?: string; license?: string; stars?: number; url: string; }; /** Whether the plugin has a cloud endpoint available for official cloud-hosted deployment */ haveCloudEndpoint?: boolean; /** Number of times this plugin has been installed */ installCount?: number; /** Whether this plugin has been claimed by its original author */ isClaimed?: boolean; /** Whether this plugin is featured in the marketplace */ isFeatured?: boolean; /** Whether this plugin is officially maintained by LobeHub */ isOfficial?: boolean; /** Whether this plugin has been validated by the system */ isValidated?: boolean; /** Number of prompts provided by this plugin */ promptsCount?: number; /** Average rating (typically 1-5 scale) */ ratingAverage?: number; /** Number of ratings received */ ratingCount?: number; /** Number of resources provided by this plugin */ resourcesCount?: number; summary?: string; /** Number of tools provided by this plugin */ toolsCount?: number; } /** Type alias for the base plugin item validated by Zod schema */ type BasePluginItem = z.infer<typeof BasePluginItemSchema>; /** * Query parameters for listing plugins in the marketplace. * Mirrors SkillListQuery in structure for consistency. */ interface PluginListQuery { /** Filter by category */ category?: string; /** Filter by MCP connection type */ connectionType?: 'http' | 'sse' | 'stdio'; /** Filter by claimed status */ isClaimed?: 'false' | 'true'; /** Filter by featured status */ isFeatured?: 'false' | 'true'; /** Filter by official status */ isOfficial?: 'false' | 'true'; /** Locale for localized content */ locale?: string; /** Sort direction */ order?: 'asc' | 'desc'; /** Filter by owner ID */ ownerId?: number; /** Page number (1-based) */ page?: number; /** Number of items per page */ pageSize?: number; /** Search query string */ q?: string; /** Sort field */ sort?: 'commentCount' | 'createdAt' | 'githubUpdateAt' | 'installCount' | 'isFeatured' | 'isValidated' | 'ratingAverage' | 'ratingCount' | 'recommended' | 'relevance' | 'stars' | 'updatedAt'; /** Publication status filter */ status?: 'all' | 'archived' | 'deprecated' | 'published' | 'unpublished'; /** Filter by tag */ tag?: string; /** Visibility filter */ visibility?: 'all' | 'internal' | 'private' | 'public'; } /** * Plugin manifest definition. * This is the complete specification of a plugin, including all its capabilities, * metadata, and deployment options. */ interface PluginItemDetail extends Omit<MarketPluginItem, 'author' | 'manifestUrl'> { artifacts?: { docker?: { imageName?: string; tag?: string; }; npm?: { packageName?: string; version?: string; }; pypi?: { packageName?: string; version?: string; }; }; /** Author information */ author?: { /** Author or organization name */ name: string; /** URL to the author's website or profile */ url?: string; }; /** Connection type strategy for communicating with the plugin */ connectionType?: PluginConnectionType; /** Available deployment options */ deploymentOptions?: DeploymentOption[]; /** * GitHub */ github?: { language?: string; license?: string; stars?: number; url: string; }; overview: { readme: string; summary?: string; }; /** List of prompt templates provided by this plugin */ prompts?: PluginPrompt[]; /** List of resources provided by this plugin */ resources?: PluginResource[]; /** List of tools provided by this plugin */ tools?: PluginTool[]; /** Date when the plugin was created in the marketplace (ISO 8601 format) */ validatedAt?: string; /** Semantic version string (e.g., "1.0.0") */ version: string; /** List of all versions of this plugin with simplified information */ versions: PluginVersionSummary[]; } /** * Plugin manifest definition. * This is the complete specification of a plugin, including all its capabilities, * metadata, and deployment options. */ interface PluginManifest extends Omit<MarketPluginItem, 'author' | 'manifestUrl'> { /** Author information */ author?: { /** Author or organization name */ name: string; /** URL to the author's website or profile */ url?: string; }; /** Available deployment options */ deploymentOptions?: DeploymentOption[]; overview?: { readme?: string; summary?: string; }; /** List of prompt templates provided by this plugin */ prompts?: PluginPrompt[]; /** List of resources provided by this plugin */ resources?: PluginResource[]; /** List of tools provided by this plugin */ tools?: PluginTool[]; /** Date when the plugin was created in the marketplace (ISO 8601 format) */ validatedAt?: string; /** Semantic version string (e.g., "1.0.0") */ version: string; } /** * Schema for admin-managed plugin items with additional status and visibility fields. * Extends the base plugin schema with administrative properties. */ declare const AdminPluginItemSchema: z.ZodObject<{ author: z.ZodOptional<z.ZodString>; capabilities: z.ZodObject<{ prompts: z.ZodDefault<z.ZodBoolean>; resources: z.ZodDefault<z.ZodBoolean>; tools: z.ZodDefault<z.ZodBoolean>; }, "strip", z.ZodTypeAny, { prompts: boolean; resources: boolean; tools: boolean; }, { prompts?: boolean | undefined; resources?: boolean | undefined; tools?: boolean | undefined; }>; category: z.ZodOptional<z.ZodString>; commentCount: z.ZodDefault<z.ZodNumber>; connectionType: z.ZodOptional<z.ZodEnum<["local", "remote", "hybrid"]>>; createdAt: z.ZodString; description: z.ZodString; github: z.ZodOptional<z.ZodObject<{ language: z.ZodOptional<z.ZodString>; license: z.ZodOptional<z.ZodString>; stars: z.ZodOptional<z.ZodNumber>; url: z.ZodString; }, "strip", z.ZodTypeAny, { url: string; language?: string | undefined; license?: string | undefined; stars?: number | undefined; }, { url: string; language?: string | undefined; license?: string | undefined; stars?: number | undefined; }>>; haveCloudEndpoint: z.ZodOptional<z.ZodBoolean>; homepage: z.ZodOptional<z.ZodString>; icon: z.ZodOptional<z.ZodString>; identifier: z.ZodString; installCount: z.ZodDefault<z.ZodNumber>; isClaimed: z.ZodDefault<z.ZodBoolean>; isFeatured: z.ZodDefault<z.ZodBoolean>; isOfficial: z.ZodDefault<z.ZodBoolean>; isValidated: z.ZodDefault<z.ZodBoolean>; manifestUrl: z.ZodString; name: z.ZodString; promptsCount: z.ZodOptional<z.ZodNumber>; ratingAverage: z.ZodOptional<z.ZodNumber>; ratingCount: z.ZodDefault<z.ZodNumber>; resourcesCount: z.ZodOptional<z.ZodNumber>; toolsCount: z.ZodOptional<z.ZodNumber>; updatedAt: z.ZodString; } & { /** Publication status of the plugin */ status: z.ZodEnum<["published", "unpublished", "archived", "deprecated"]>; /** Visibility level of the plugin */ visibility: z.ZodEnum<["public", "private", "internal"]>; }, "strip", z.ZodTypeAny, { createdAt: string; name: string; updatedAt: string; status: "archived" | "deprecated" | "published" | "unpublished"; capabilities: { prompts: boolean; resources: boolean; tools: boolean; }; commentCount: number; description: string; identifier: string; installCount: number; isClaimed: boolean; isFeatured: boolean; isOfficial: boolean; isValidated: boolean; manifestUrl: string; ratingCount: number; visibility: "internal" | "private" | "public"; author?: string | undefined; category?: string | undefined; connectionType?: "local" | "remote" | "hybrid" | undefined; github?: { url: string; language?: string | undefined; license?: string | undefined; stars?: number | undefined; } | undefined; haveCloudEndpoint?: boolean | undefined; homepage?: string | undefined; icon?: string | undefined; promptsCount?: number | undefined; ratingAverage?: number | undefined; resourcesCount?: number | undefined; toolsCount?: number | undefined; }, { createdAt: string; name: string; updatedAt: string; status: "archived" | "deprecated" | "published" | "unpublished"; capabilities: { prompts?: boolean | undefined; resources?: boolean | undefined; tools?: boolean | undefined; }; description: string; identifier: string; manifestUrl: string; visibility: "internal" | "private" | "public"; author?: string | undefined; category?: string | undefined; commentCount?: number | undefined; connectionType?: "local" | "remote" | "hybrid" | undefined; github?: { url: string; language?: string | undefined; license?: string | undefined; stars?: number | undefined; } | undefined; haveCloudEndpoint?: boolean | undefined; homepage?: string | undefined; icon?: string | undefined; installCount?: number | undefined; isClaimed?: boolean | undefined; isFeatured?: boolean | undefined; isOfficial?: boolean | undefined; isValidated?: boolean | undefined; promptsCount?: number | undefined; ratingAverage?: number | undefined; ratingCount?: number | undefined; resourcesCount?: number | undefined; toolsCount?: number | undefined; }>; /** * Interface for admin-managed plugin items. * Extends the market plugin item with administrative properties. */ interface AdminPluginItem extends MarketPluginItem { /** GitHub last update timestamp (ISO 8601 format) */ githubUpdateAt?: string; /** Unique numeric identifier for the plugin in the database */ id: number; /** User ID of the plugin owner */ ownerId: number; /** Publication status of the plugin */ status: 'published' | 'unpublished' | 'archived'; /** Visibility level controlling who can access the plugin */ visibility: 'public' | 'private' | 'internal'; } /** * Plugin version database model. * Represents a specific version of a plugin in the database. */ interface PluginVersion { /** Creation timestamp (ISO 8601 format) */ createdAt: string; /** Unique numeric identifier for the version */ id: number; /** Whether this is the latest version of the plugin */ isLatest: boolean; /** Whether this version has been validated by the system */ isValidated: boolean; /** The full manifest data for this version */ manifest: PluginManifest; /** URL to the manifest file, or null if stored directly */ manifestUrl: string | null; /** Additional metadata for this version */ meta: Record<string, any> | null; /** ID of the parent plugin */ pluginId: number; /** Number of prompts provided by this version */ promptsCount: number; /** Number of resources provided by this version */ resourcesCount: number; /** Number of tools provided by this version */ toolsCount: number; /** Last update timestamp (ISO 8601 format) */ updatedAt: string; /** Semantic version string (e.g., "1.0.0") */ version: string; } /** * Detailed admin plugin item with version history. * Used for displaying complete plugin information in the admin interface. */ interface AdminPluginItemDetail extends Omit<AdminPluginItem, 'manifestUrl'> { /** Full manifest data for the current version */ manifest: PluginManifest; /** List of all versions of this plugin */ versions: PluginVersion[]; } /** * Admin deployment option with database ID. * Extends the basic deployment option with a database identifier. */ interface AdminDeploymentOption extends DeploymentOption { /** Unique numeric identifier for the deployment option */ id: number; } /** * Admin system dependency with database ID. * Extends the basic system dependency with a database identifier. */ interface AdminSystemDependency extends SystemDependency { /** Unique numeric identifier for the system dependency */ id: number; } /** * Plugin version localization data. * Represents localized content for a specific plugin version in a particular language. */ interface PluginVersionLocalization { /** Creation timestamp (ISO 8601 format) */ createdAt: string; /** Localized description of the plugin */ description: string; /** Unique numeric identifier for the localization */ id: number; /** Language/locale code (e.g., 'en-US', 'zh-CN') */ locale: string; /** Localized display name of the plugin */ name: string; /** ID of the parent plugin version */ pluginVersionId: number; /** Localized summary of the plugin */ summary?: string; /** Array of localized tags for categorization and search */ tags?: string[]; } /** * 不完整i18n插件项 * 表示pluginVersionLocalizations只有1个条目的插件 */ interface IncompleteI18nPlugin { /** 插件标识符 */ identifier: string; /** 本地化条目数量 */ localizationCount: number; /** 插件ID */ pluginId: number; /** 插件版本 */ version: string; } /** * Range Data Point Interface * Defines the structure for daily trend data points in analysis */ interface RangeDataPoint { /** Current period count */ count: number; /** Date in YYYY-MM-DD format */ date: string; /** Previous period count for comparison */ prevCount: number; } /** * Range Statistics Interface * Defines the structure for range-based statistics */ interface RangeStats { /** Array of daily data points */ data: RangeDataPoint[]; /** Display configuration */ display: string; /** Total sum for previous period */ prevSum: number; /** Total sum for current period */ sum: number; } /** * Range query parameters for trend analysis */ interface RangeQuery { /** Display configuration */ display: string; /** Optional previous period range for comparison */ prevRange?: [string, string]; /** Date range as [startDate, endDate] */ range: [string, string]; } /** * Plugin event tracking types * * These types describe the payload used when recording user plugin events such as * installs, activations, uninstalls, or clicks. */ type PluginEventType = 'install' | 'activate' | 'uninstall' | 'click'; /** Payload for recording a plugin event */ interface PluginEventRequest { /** Event name */ event: PluginEventType; /** Plugin identifier */ identifier: string; /** Optional event source */ source?: string; } /** * Plugin Call Report Types * * This module defines the types for plugin call reporting functionality. * These types support users reporting their plugin method invocations to help improve * plugin performance monitoring and provide usage analytics. * These types are shared between the API server and client SDKs. */ /** * Plugin method types */ type PluginMethodType = 'tool' | 'prompt' | 'resource'; /** * Custom plugin information for non-marketplace plugins */ interface CustomPluginInfo { avatar?: string; /** Plugin description */ description?: string; /** Plugin name/title */ name?: string; } /** * Call report request data */ interface CallReportRequest { /** Call execution duration in milliseconds */ callDurationMs: number; /** Client ID (optional, for M2M authentication) */ clientId?: string; /** Client IP address (real user IP) */ clientIp?: string; /** Custom plugin information (required if isCustomPlugin is true) */ customPluginInfo?: CustomPluginInfo; /** Error code if call failed */ errorCode?: string; /** Error message if call failed */ errorMessage?: string; /** Plugin identifier */ identifier: string; /** Input parameters sent to the method */ inputParams?: any; /** Whether this is a custom/local plugin (not from marketplace) */ isCustomPlugin?: boolean; /** Additional metadata about the call */ metadata?: Record<string, any>; /** Specific method name being called */ methodName: string; /** Plugin method type (tool/prompt/resource) */ methodType: PluginMethodType; /** Output/response from the method */ outputResult?: any; /** Platform information */ platform?: string; /** Request size in bytes */ requestSizeBytes?: number; /** Response size in bytes */ responseSizeBytes?: number; /** Session ID for correlating multiple calls */ sessionId?: string; /** Whether the call was successful */ success: boolean; /** Trace ID for distributed tracing */ traceId?: string; /** User agent (real user agent) */ userAgent?: string; /** Plugin version */ version: string; } /** * Call report response data */ interface CallReportResponse { /** Message about the processing result */ message: string; /** Whether the report was successfully recorded */ success: boolean; } /** * Call statistics data */ interface CallStats { /** Average call duration in milliseconds */ averageCallTime: number; /** Call statistics by method type */ byMethodType: Record<PluginMethodType, { averageCallTime: number; failedCalls: number; successRate: number; successfulCalls: number; totalCalls: number; }>; /** Statistics by plugin source (marketplace vs custom) */ byPluginSource: { custom: { averageCallTime: number; successRate: number; totalCalls: number; }; marketplace: { averageCallTime: number; successRate: number; totalCalls: number; }; }; /** Number of failed calls */ failedCalls: number; /** Success rate as percentage */ successRate: number; /** Number of successful calls */ successfulCalls: number; /** Most common call errors */ topErrors: Array<{ count: number; errorCode: string; errorMessage: string; }>; /** Most frequently called methods */ topMethods: Array<{ averageCallTime: number; count: number; methodName: string; methodType: PluginMethodType; successRate: number; }>; /** Total number of call attempts */ totalCalls: number; } /** * Call log entry data */ interface CallLogEntry { /** Call execution duration in milliseconds */ callDurationMs: number; /** When the log was created */ createdAt: string; /** Custom plugin information */ customPluginInfo?: CustomPluginInfo | null; /** Error code if failed */ errorCode?: string | null; /** Error message if failed */ errorMessage?: string | null; /** Log entry ID */ id: number; /** Plugin identifier */ identifier: string; /** Whether this is a custom plugin */ isCustomPlugin: boolean; /** Method name */ methodName: string; /** Plugin method type */ methodType: PluginMethodType; /** Platform information */ platform?: string | null; /** Request size in bytes */ requestSizeBytes?: number | null; /** Response size in bytes */ responseSizeBytes?: number | null; /** Session ID */ sessionId?: string | null; /** Whether call was successful */ success: boolean; /** Trace ID */ traceId?: string | null; /** Plugin version */ version: string; } /** * Plugin Install Report Types * * This module defines the types for plugin installation reporting functionality. * These types support users reporting their installation attempts to help improve * plugin validation and provide analytics. These types are shared between the API server and client SDKs. */ /** * Install report request data */ interface InstallReportRequest { /** Client ID (optional, for M2M authentication) */ clientId?: string; /** Client IP address (real user IP) */ clientIp?: string; /** Error code if installation failed */ errorCode?: string; /** Error message if installation failed */ errorMessage?: string; /** Plugin identifier */ identifier: string; /** Installation du