Files
openclaw/extensions/codex/src/app-server/plugin-inventory.test-helpers.ts
Kimi Yu e1b8150a06 fix(codex): let owners install plugins from discovered marketplaces (#122389)
* fix(codex): allow owner-approved marketplace plugins

* fix(codex): preserve marketplace validation and remove unused exports

* docs(codex): clarify already-installed plugin authorization
2026-08-12 20:29:40 +00:00

100 lines
2.4 KiB
TypeScript

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> = {},
): 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: [],
};
}