openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
41 lines (40 loc) • 1.27 kB
JavaScript
import { r as emptyPluginConfigSchema } from "./config-schema-D24DJjjb.js";
//#region src/plugin-sdk/lazy-value.ts
function createCachedLazyValueGetter(value, fallback) {
let resolved = false;
let cached;
return () => {
if (!resolved) {
cached = (typeof value === "function" ? value() : value) ?? fallback;
resolved = true;
}
return cached;
};
}
//#endregion
//#region src/plugin-sdk/plugin-entry.ts
/**
* Canonical entry helper for non-channel plugins.
*
* Use this for provider, tool, command, service, memory, and context-engine
* plugins. Channel plugins should use `defineChannelPluginEntry(...)` from
* `openclaw/plugin-sdk/core` so they inherit the channel capability wiring.
*/
function definePluginEntry({ id, name, description, kind, configSchema = emptyPluginConfigSchema, reload, nodeHostCommands, securityAuditCollectors, register }) {
const getConfigSchema = createCachedLazyValueGetter(configSchema);
return {
id,
name,
description,
...kind ? { kind } : {},
...reload ? { reload } : {},
...nodeHostCommands ? { nodeHostCommands } : {},
...securityAuditCollectors ? { securityAuditCollectors } : {},
get configSchema() {
return getConfigSchema();
},
register
};
}
//#endregion
export { definePluginEntry as t };