@@ -36,6 +36,7 @@ import {
3636 normalizeSessionKeyPreservingOpaquePeerIds ,
3737 parseThreadSessionSuffix ,
3838} from "../sessions/session-key-utils.js" ;
39+ import { createCachedLazyValueGetter } from "./lazy-value.js" ;
3940export type {
4041 AgentPromptGuidance ,
4142 AgentPromptGuidanceEntry ,
@@ -509,7 +510,7 @@ type DefinedChannelPluginEntry<TPlugin> = {
509510 id : string ;
510511 name : string ;
511512 description : string ;
512- configSchema : ChannelEntryConfigSchema < TPlugin > ;
513+ configSchema : ChannelConfigSchema ;
513514 register : ( api : OpenClawPluginApi ) => void ;
514515 channelPlugin : TPlugin ;
515516 setChannelRuntime ?: ( runtime : PluginRuntime ) => void ;
@@ -563,9 +564,9 @@ type CreatedChannelPluginBase<TResolvedAccount> = Pick<
563564/**
564565 * Canonical entry helper for channel plugins.
565566 *
566- * This wraps `definePluginEntry(...)`, registers the channel capability, and
567- * optionally exposes extra full-runtime registration such as tools or gateway
568- * handlers that only make sense outside setup-only registration modes.
567+ * This shares `definePluginEntry(...)`'s lazy schema primitive, registers the
568+ * channel capability, and optionally exposes extra full-runtime registration
569+ * such as tools or gateway handlers outside setup-only registration modes.
569570 */
570571export function defineChannelPluginEntry < TPlugin > ( {
571572 id,
@@ -578,15 +579,14 @@ export function defineChannelPluginEntry<TPlugin>({
578579 registerFull,
579580 registerCapabilities,
580581} : DefineChannelPluginEntryOptions < TPlugin > ) : DefinedChannelPluginEntry < TPlugin > {
581- const resolvedConfigSchema : ChannelEntryConfigSchema < TPlugin > =
582- typeof configSchema === "function"
583- ? configSchema ( )
584- : ( ( configSchema ?? emptyChannelConfigSchema ( ) ) as ChannelEntryConfigSchema < TPlugin > ) ;
585- const entry = {
582+ const getConfigSchema = createCachedLazyValueGetter ( configSchema ?? emptyChannelConfigSchema ) ;
583+ return {
586584 id,
587585 name,
588586 description,
589- configSchema : resolvedConfigSchema ,
587+ get configSchema ( ) {
588+ return getConfigSchema ( ) ;
589+ } ,
590590 register ( api : OpenClawPluginApi ) {
591591 if ( api . registrationMode === "cli-metadata" ) {
592592 registerCliMetadata ?.( api ) ;
@@ -611,9 +611,6 @@ export function defineChannelPluginEntry<TPlugin>({
611611 registerFull ?.( api ) ;
612612 registerCapabilities ?.( api ) ;
613613 } ,
614- } ;
615- return {
616- ...entry ,
617614 channelPlugin : plugin ,
618615 ...( setRuntime ? { setChannelRuntime : setRuntime } : { } ) ,
619616 } ;
0 commit comments