mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-26 04:15:48 -06:00
e1b8150a06
* fix(codex): allow owner-approved marketplace plugins * fix(codex): preserve marketplace validation and remove unused exports * docs(codex): clarify already-installed plugin authorization
100 lines
2.4 KiB
TypeScript
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: [],
|
|
};
|
|
}
|