import { CODEX_PLUGINS_MARKETPLACE_NAME } from "./config.js"; import type { v2 } from "./protocol.js"; export function asPluginInstalled(listed: v2.PluginListResponse): v2.PluginInstalledResponse { const { featuredPluginIds: _featuredPluginIds, ...installed } = listed; return installed; } export function pluginInstalled( plugins: v2.PluginSummary[], marketplace: { name?: string; path?: string | null } = {}, ): v2.PluginInstalledResponse { return asPluginInstalled(pluginList(plugins, marketplace)); } export function pluginList( plugins: v2.PluginSummary[], marketplace: { name?: string; path?: string | null } = {}, ): v2.PluginListResponse { return { marketplaces: [ { name: marketplace.name ?? CODEX_PLUGINS_MARKETPLACE_NAME, path: marketplace.path === undefined ? "/marketplaces/openai-curated" : marketplace.path, interface: null, plugins, }, ], marketplaceLoadErrors: [], featuredPluginIds: [], }; } export function pluginSummary( id: string, overrides: Partial = {}, ): v2.PluginSummary { return { id, name: id, source: { type: "remote" }, installed: false, enabled: false, installPolicy: "AVAILABLE", authPolicy: "ON_USE", availability: "AVAILABLE", interface: null, ...overrides, }; } export function pluginDetail( pluginName: string, apps: v2.AppSummary[], marketplace: { marketplaceName?: string; marketplacePath?: string | null } = {}, ): v2.PluginReadResponse { return { plugin: { marketplaceName: marketplace.marketplaceName ?? CODEX_PLUGINS_MARKETPLACE_NAME, marketplacePath: marketplace.marketplacePath === undefined ? "/marketplaces/openai-curated" : marketplace.marketplacePath, summary: pluginSummary(pluginName, { installed: true, enabled: true }), description: null, skills: [], apps, mcpServers: [], }, }; } export function appSummary(id: string): v2.AppSummary { return { id, name: id, description: null, installUrl: null, category: null, }; } export function appInfo(id: string, accessible: boolean): v2.AppInfo { return { id, name: id, description: null, logoUrl: null, logoUrlDark: null, distributionChannel: null, branding: null, appMetadata: null, labels: null, installUrl: null, isAccessible: accessible, isEnabled: true, pluginDisplayNames: [], }; }