mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 21:10:45 +00:00
Merged via squash.
Prepared head SHA: 68e5f2ce19
Co-authored-by: 100yenadmin <239388517+100yenadmin@users.noreply.github.com>
Co-authored-by: jalehman <550978+jalehman@users.noreply.github.com>
Reviewed-by: @jalehman
32 lines
992 B
TypeScript
32 lines
992 B
TypeScript
import { getActivePluginRegistry } from "../../plugins/runtime.js";
|
|
import {
|
|
ErrorCodes,
|
|
errorShape,
|
|
formatValidationErrors,
|
|
validatePluginsUiDescriptorsParams,
|
|
} from "../protocol/index.js";
|
|
import type { GatewayRequestHandlers } from "./types.js";
|
|
|
|
export const pluginHostHookHandlers: GatewayRequestHandlers = {
|
|
"plugins.uiDescriptors": ({ params, respond }) => {
|
|
if (!validatePluginsUiDescriptorsParams(params)) {
|
|
respond(
|
|
false,
|
|
undefined,
|
|
errorShape(
|
|
ErrorCodes.INVALID_REQUEST,
|
|
`invalid plugins.uiDescriptors params: ${formatValidationErrors(validatePluginsUiDescriptorsParams.errors)}`,
|
|
),
|
|
);
|
|
return;
|
|
}
|
|
const descriptors = (getActivePluginRegistry()?.controlUiDescriptors ?? []).map((entry) =>
|
|
Object.assign({}, entry.descriptor, {
|
|
pluginId: entry.pluginId,
|
|
pluginName: entry.pluginName,
|
|
}),
|
|
);
|
|
respond(true, { ok: true, descriptors }, undefined);
|
|
},
|
|
};
|