mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-21 18:26:51 +00:00
* feat(dashboard): add plugin capability declarations * docs(dashboard): describe plugin capabilities * fix(plugins): preserve registry map cloning * fix(dashboard): make plugin grant ids unambiguous * fix(dashboard): align generated plugin grant ids * chore(boards): internalize verb ids and refresh protocol snapshots
53 lines
1.8 KiB
JavaScript
53 lines
1.8 KiB
JavaScript
function formatIdentifiers(values) {
|
|
return values.map((value) => `\`${value}\``).join(", ");
|
|
}
|
|
|
|
function encodeDashboardPluginIdSegment(pluginId) {
|
|
return pluginId.replaceAll("%", "%25").replaceAll(".", "%2E");
|
|
}
|
|
|
|
function resolveDashboardCapabilityIds(manifest, field) {
|
|
if (typeof manifest.id !== "string" || !Array.isArray(manifest.dashboard?.[field])) {
|
|
return [];
|
|
}
|
|
const pluginIdSegment = encodeDashboardPluginIdSegment(manifest.id);
|
|
return manifest.dashboard[field]
|
|
.map((entry) =>
|
|
typeof entry?.id === "string" && entry.id.length > 0
|
|
? `${pluginIdSegment}.${entry.id}`
|
|
: null,
|
|
)
|
|
.filter((value) => value !== null);
|
|
}
|
|
|
|
export function resolvePluginSurface(manifest) {
|
|
const parts = [];
|
|
if (Array.isArray(manifest.channels) && manifest.channels.length > 0) {
|
|
parts.push(`channels: ${formatIdentifiers(manifest.channels)}`);
|
|
}
|
|
if (Array.isArray(manifest.providers) && manifest.providers.length > 0) {
|
|
parts.push(`providers: ${formatIdentifiers(manifest.providers)}`);
|
|
}
|
|
const contracts = Object.keys(manifest.contracts ?? {}).toSorted((left, right) =>
|
|
left.localeCompare(right),
|
|
);
|
|
if (contracts.length > 0) {
|
|
parts.push(`contracts: ${formatIdentifiers(contracts)}`);
|
|
}
|
|
const dashboardDataBindings = resolveDashboardCapabilityIds(manifest, "dataBindings");
|
|
if (dashboardDataBindings.length > 0) {
|
|
parts.push(`dashboard data bindings: ${formatIdentifiers(dashboardDataBindings)}`);
|
|
}
|
|
const dashboardActionVerbs = resolveDashboardCapabilityIds(manifest, "actionVerbs");
|
|
if (dashboardActionVerbs.length > 0) {
|
|
parts.push(`dashboard action verbs: ${formatIdentifiers(dashboardActionVerbs)}`);
|
|
}
|
|
if (Array.isArray(manifest.skills) && manifest.skills.length > 0) {
|
|
parts.push("skills");
|
|
}
|
|
if (parts.length === 0) {
|
|
return "plugin";
|
|
}
|
|
return parts.join("; ");
|
|
}
|