/** * Shared types for pi-mcp-market. * * The `ServerEntry` shape mirrors pi-mcp-adapter's mcp.json entry format * (which pi itself also reads), so entries produced here are drop-in * compatible with the file pi-mcp-adapter consumes. */ /** An mcp.json server entry — compatible with pi-mcp-adapter's ServerEntry. */ export interface ServerEntry { command?: string; args?: string[]; env?: Record; cwd?: string; /** HTTP transport */ url?: string; headers?: Record; auth?: "oauth" | "bearer" | false; bearerToken?: string; bearerTokenEnv?: string; lifecycle?: "keep-alive" | "lazy" | "lazy-keep-alive" | "eager"; idleTimeout?: number; requestTimeoutMs?: number; exposeResources?: boolean; directTools?: boolean | string[]; toolPrefix?: string; includeTools?: string[]; excludeTools?: string[]; approveTools?: boolean | string[]; debug?: boolean; trace?: boolean; disabled?: boolean; } /** Top-level shape of mcp.json. */ export interface McpConfig { mcpServers: Record; settings?: Record; imports?: string[]; } /** A required environment variable declared by a catalog entry. */ export interface RequiredEnv { /** Env var name, e.g. "ANTHROPIC_API_KEY". */ key: string; /** Human-readable label shown in the form. */ label: string; /** Short hint displayed next to the field. */ hint?: string; /** Where the user can obtain the value. */ whereToGet?: string; } /** Classification of authentication required by this server. */ export type AuthType = "none" | "api-key" | "oauth" | "bearer" | "unknown"; /** A single catalog server from a configured remote registry. */ export interface MarketServer { /** Unique id within its source (e.g. "context7"). */ id: string; /** Display name shown in the panel. */ name: string; /** Key used in mcp.json's mcpServers object. Defaults to `name`. */ installName?: string; /** One-line summary for the list row. */ summary: string; /** Longer description shown when the row is focused. */ description?: string; /** Free-form tags, searchable. */ tags?: string[]; /** The mcp.json entry. */ entry: ServerEntry; /** Required env vars the install wizard collects. */ requiredEnv?: RequiredEnv[]; /** Source registry id (the id from registries.json). */ source: string; /** Authentication type classification. */ authType?: AuthType; /** A copyable JSON config snippet shown in the panel detail area. */ configTemplate?: string; /** Number of tools this server exposes (when known from metadata). */ toolCount?: number; /** Whether a valid transport entry could be derived for installation. */ installable: boolean; /** Hint text shown when installable is false (e.g. "需要手动配置"). */ installHint?: string; } /** Payload format of a remote registry source. Defaults to "native" (a plain MarketServer array). */ export type RegistryFormat = "native" | "official" | "glama" | "smithery" | "deepnlp"; /** A remote registry configured by the user. */ export interface RegistrySpec { id: string; name: string; url: string; /** Source payload format; defaults to "native" (pure MarketServer array, current behavior). */ format?: RegistryFormat; /** Extra request headers, e.g. { "Authorization": "Bearer {{API_KEY}}" }. */ headers?: Record; /** * Env var holding the API key for this source. The value is read from * process.env at request time and never persisted. When the env var is * unset the source is marked failed and no request is made. */ apiKeyEnv?: string; } /** Contents of the extension config file `registries.json`. */ export interface RegistriesConfig { registries: RegistrySpec[]; } /** Result of assembling all configured remote registries' catalogs. */ export interface CatalogBundle { servers: MarketServer[]; /** Registries that failed to load (fetch error and no usable cache). */ failures: string[]; /** Invalid entries skipped during validation, keyed by registry id. */ skipped: Record; /** Whether any market source is configured (used to distinguish "unconfigured" from "everything failed"). */ sourcesConfigured: boolean; } /** Panel callbacks used to decouple the panel from I/O. */ export interface MarketCallbacks { isInstalled(installName: string): boolean; getInstalledEntry(installName: string): ServerEntry | undefined; installServer(name: string, entry: ServerEntry): Promise; uninstallServer(name: string): Promise; /** Install pi-mcp-adapter via `pi install npm:pi-mcp-adapter`. */ installAdapter(): Promise; } export type MarketPanelResult = | { action: "closed" } | { action: "installed"; name: string } | { action: "uninstalled"; name: string } | { action: "adapter-installed" };