@@ -85,6 +85,10 @@ describe("stageBundledPluginRuntime", () => {
8585 recursive : true ,
8686 } ) ;
8787 setupRepoFiles ( repoRoot , {
88+ "dist/plugin-sdk/index.js" : "export const sdk = true;\n" ,
89+ "dist/plugin-sdk/channel-entry-contract.js" :
90+ "export { contract } from '../channel-entry-contract-abc.js';\n" ,
91+ "dist/channel-entry-contract-abc.js" : "export const contract = true;\n" ,
8892 [ bundledDistPluginFile ( "diffs" , "index.js" ) ] : "export default {}\n" ,
8993 [ bundledDistPluginFile ( "diffs" , "node_modules/@pierre/diffs/index.js" ) ] :
9094 "export default {}\n" ,
@@ -109,7 +113,7 @@ describe("stageBundledPluginRuntime", () => {
109113 path . join ( repoRoot , "dist" , "extensions" , "node_modules" , "openclaw" , "plugin-sdk" ) ,
110114 )
111115 . isSymbolicLink ( ) ,
112- ) . toBe ( true ) ;
116+ ) . toBe ( false ) ;
113117 expect (
114118 fs . readFileSync (
115119 path . join ( repoRoot , "dist" , "extensions" , "node_modules" , "openclaw" , "package.json" ) ,
@@ -123,13 +127,47 @@ describe("stageBundledPluginRuntime", () => {
123127 ) ,
124128 ) . toContain ( '"./plugin-sdk/*": "./plugin-sdk/*.js"' ) ;
125129 expect (
126- fs . realpathSync (
127- path . join ( repoRoot , "dist" , "extensions" , "node_modules" , "openclaw" , "plugin-sdk" ) ,
130+ fs . readFileSync (
131+ path . join (
132+ repoRoot ,
133+ "dist" ,
134+ "extensions" ,
135+ "node_modules" ,
136+ "openclaw" ,
137+ "plugin-sdk" ,
138+ "channel-entry-contract.js" ,
139+ ) ,
140+ "utf8" ,
128141 ) ,
129- ) . toBe ( fs . realpathSync ( path . join ( repoRoot , "dist" , " plugin-sdk" ) ) ) ;
142+ ) . toContain ( "../../../../ plugin-sdk/channel-entry-contract.js" ) ;
130143 expect ( fs . existsSync ( path . join ( runtimePluginDir , "node_modules" , "openclaw" ) ) ) . toBe ( false ) ;
131144 } ) ;
132145
146+ it ( "keeps extension-local plugin-sdk wrappers resolving canonical dist chunks" , async ( ) => {
147+ const repoRoot = makeRepoRoot ( "openclaw-stage-bundled-runtime-sdk-wrapper-" ) ;
148+ createDistPluginDir ( repoRoot , "diffs" ) ;
149+ setupRepoFiles ( repoRoot , {
150+ "dist/plugin-sdk/channel-entry-contract.js" :
151+ "export { contract } from '../channel-entry-contract-abc.js';\n" ,
152+ "dist/channel-entry-contract-abc.js" : "export const contract = true;\n" ,
153+ [ bundledDistPluginFile ( "diffs" , "index.js" ) ] : "export default {}\n" ,
154+ } ) ;
155+
156+ stageBundledPluginRuntime ( { repoRoot } ) ;
157+
158+ const wrapperPath = path . join (
159+ repoRoot ,
160+ "dist" ,
161+ "extensions" ,
162+ "node_modules" ,
163+ "openclaw" ,
164+ "plugin-sdk" ,
165+ "channel-entry-contract.js" ,
166+ ) ;
167+ const wrapperModule = await import ( `${ pathToFileURL ( wrapperPath ) . href } ?t=${ Date . now ( ) } ` ) ;
168+ expect ( wrapperModule . contract ) . toBe ( true ) ;
169+ } ) ;
170+
133171 it ( "writes wrappers that forward plugin entry imports into canonical dist files" , async ( ) => {
134172 const repoRoot = makeRepoRoot ( "openclaw-stage-bundled-runtime-chunks-" ) ;
135173 createDistPluginDir ( repoRoot , "diffs" ) ;
0 commit comments