@@ -2030,6 +2030,113 @@ module.exports = {
20302030 expect ( registry . channels ) . toHaveLength ( 1 ) ;
20312031 } ) ;
20322032
2033+ it ( "can prefer setupEntry for configured channel loads during startup" , ( ) => {
2034+ useNoBundledPlugins ( ) ;
2035+ const pluginDir = makeTempDir ( ) ;
2036+ const fullMarker = path . join ( pluginDir , "full-loaded.txt" ) ;
2037+ const setupMarker = path . join ( pluginDir , "setup-loaded.txt" ) ;
2038+ fs . writeFileSync (
2039+ path . join ( pluginDir , "package.json" ) ,
2040+ JSON . stringify (
2041+ {
2042+ name : "@openclaw/setup-runtime-preferred-test" ,
2043+ openclaw : {
2044+ extensions : [ "./index.cjs" ] ,
2045+ setupEntry : "./setup-entry.cjs" ,
2046+ } ,
2047+ } ,
2048+ null ,
2049+ 2 ,
2050+ ) ,
2051+ "utf-8" ,
2052+ ) ;
2053+ fs . writeFileSync (
2054+ path . join ( pluginDir , "openclaw.plugin.json" ) ,
2055+ JSON . stringify (
2056+ {
2057+ id : "setup-runtime-preferred-test" ,
2058+ configSchema : EMPTY_PLUGIN_SCHEMA ,
2059+ channels : [ "setup-runtime-preferred-test" ] ,
2060+ } ,
2061+ null ,
2062+ 2 ,
2063+ ) ,
2064+ "utf-8" ,
2065+ ) ;
2066+ fs . writeFileSync (
2067+ path . join ( pluginDir , "index.cjs" ) ,
2068+ `require("node:fs").writeFileSync(${ JSON . stringify ( fullMarker ) } , "loaded", "utf-8");
2069+ module.exports = {
2070+ id: "setup-runtime-preferred-test",
2071+ register(api) {
2072+ api.registerChannel({
2073+ plugin: {
2074+ id: "setup-runtime-preferred-test",
2075+ meta: {
2076+ id: "setup-runtime-preferred-test",
2077+ label: "Setup Runtime Preferred Test",
2078+ selectionLabel: "Setup Runtime Preferred Test",
2079+ docsPath: "/channels/setup-runtime-preferred-test",
2080+ blurb: "full entry should be deferred while startup is still cold",
2081+ },
2082+ capabilities: { chatTypes: ["direct"] },
2083+ config: {
2084+ listAccountIds: () => ["default"],
2085+ resolveAccount: () => ({ accountId: "default", token: "configured" }),
2086+ },
2087+ outbound: { deliveryMode: "direct" },
2088+ },
2089+ });
2090+ },
2091+ };` ,
2092+ "utf-8" ,
2093+ ) ;
2094+ fs . writeFileSync (
2095+ path . join ( pluginDir , "setup-entry.cjs" ) ,
2096+ `require("node:fs").writeFileSync(${ JSON . stringify ( setupMarker ) } , "loaded", "utf-8");
2097+ module.exports = {
2098+ plugin: {
2099+ id: "setup-runtime-preferred-test",
2100+ meta: {
2101+ id: "setup-runtime-preferred-test",
2102+ label: "Setup Runtime Preferred Test",
2103+ selectionLabel: "Setup Runtime Preferred Test",
2104+ docsPath: "/channels/setup-runtime-preferred-test",
2105+ blurb: "setup runtime preferred",
2106+ },
2107+ capabilities: { chatTypes: ["direct"] },
2108+ config: {
2109+ listAccountIds: () => ["default"],
2110+ resolveAccount: () => ({ accountId: "default", token: "configured" }),
2111+ },
2112+ outbound: { deliveryMode: "direct" },
2113+ },
2114+ };` ,
2115+ "utf-8" ,
2116+ ) ;
2117+
2118+ const registry = loadOpenClawPlugins ( {
2119+ cache : false ,
2120+ preferSetupRuntimeForChannelPlugins : true ,
2121+ config : {
2122+ channels : {
2123+ "setup-runtime-preferred-test" : {
2124+ enabled : true ,
2125+ } ,
2126+ } ,
2127+ plugins : {
2128+ load : { paths : [ pluginDir ] } ,
2129+ allow : [ "setup-runtime-preferred-test" ] ,
2130+ } ,
2131+ } ,
2132+ } ) ;
2133+
2134+ expect ( fs . existsSync ( setupMarker ) ) . toBe ( true ) ;
2135+ expect ( fs . existsSync ( fullMarker ) ) . toBe ( false ) ;
2136+ expect ( registry . channelSetups ) . toHaveLength ( 1 ) ;
2137+ expect ( registry . channels ) . toHaveLength ( 1 ) ;
2138+ } ) ;
2139+
20332140 it ( "blocks before_prompt_build but preserves legacy model overrides when prompt injection is disabled" , async ( ) => {
20342141 useNoBundledPlugins ( ) ;
20352142 const plugin = writePlugin ( {
0 commit comments