@@ -1530,6 +1530,97 @@ describe("updateNpmInstalledPlugins", () => {
15301530 } ) ;
15311531 } ) ;
15321532
1533+ it ( "preserves exact official npm pins when official install sync is not requested" , async ( ) => {
1534+ const installPath = createInstalledPackageDir ( {
1535+ name : "@openclaw/codex" ,
1536+ version : "2026.5.28" ,
1537+ } ) ;
1538+ installPluginFromNpmSpecMock . mockResolvedValue (
1539+ createSuccessfulNpmUpdateResult ( {
1540+ pluginId : "codex" ,
1541+ targetDir : installPath ,
1542+ version : "2026.5.28" ,
1543+ npmResolution : {
1544+ name : "@openclaw/codex" ,
1545+ version : "2026.5.28" ,
1546+ resolvedSpec :
"@openclaw/[email protected] " , 1547+ } ,
1548+ } ) ,
1549+ ) ;
1550+
1551+ const result = await updateNpmInstalledPlugins ( {
1552+ config : createNpmInstallConfig ( {
1553+ pluginId : "codex" ,
1554+ spec :
"@openclaw/[email protected] " , 1555+ installPath,
1556+ resolvedName : "@openclaw/codex" ,
1557+ resolvedSpec :
"@openclaw/[email protected] " , 1558+ resolvedVersion : "2026.5.28" ,
1559+ } ) ,
1560+ pluginIds : [ "codex" ] ,
1561+ dryRun : true ,
1562+ } ) ;
1563+
1564+ expect ( npmInstallCall ( ) ?. spec ) . toBe ( "@openclaw/[email protected] " ) ; 1565+ expect ( npmInstallCall ( ) ?. expectedPluginId ) . toBe ( "codex" ) ;
1566+ expect ( npmInstallCall ( ) ?. trustedSourceLinkedOfficialInstall ) . toBe ( true ) ;
1567+ expect ( result . changed ) . toBe ( false ) ;
1568+ expectRecordFields ( result . outcomes [ 0 ] , {
1569+ pluginId : "codex" ,
1570+ status : "unchanged" ,
1571+ currentVersion : "2026.5.28" ,
1572+ nextVersion : "2026.5.28" ,
1573+ } ) ;
1574+ } ) ;
1575+
1576+ it ( "reinstalls missing exact official npm pins without official install sync" , async ( ) => {
1577+ const extensionsDir = fs . mkdtempSync ( path . join ( os . tmpdir ( ) , "openclaw-missing-plugin-" ) ) ;
1578+ tempDirs . push ( extensionsDir ) ;
1579+ const installPath = path . join ( extensionsDir , "codex" ) ;
1580+ installPluginFromNpmSpecMock . mockResolvedValue (
1581+ createSuccessfulNpmUpdateResult ( {
1582+ pluginId : "codex" ,
1583+ targetDir : installPath ,
1584+ version : "2026.5.28" ,
1585+ npmResolution : {
1586+ name : "@openclaw/codex" ,
1587+ version : "2026.5.28" ,
1588+ resolvedSpec :
"@openclaw/[email protected] " , 1589+ } ,
1590+ } ) ,
1591+ ) ;
1592+
1593+ const result = await updateNpmInstalledPlugins ( {
1594+ config : createNpmInstallConfig ( {
1595+ pluginId : "codex" ,
1596+ spec :
"@openclaw/[email protected] " , 1597+ installPath,
1598+ resolvedName : "@openclaw/codex" ,
1599+ resolvedSpec :
"@openclaw/[email protected] " , 1600+ resolvedVersion : "2026.5.28" ,
1601+ } ) ,
1602+ pluginIds : [ "codex" ] ,
1603+ } ) ;
1604+
1605+ expect ( npmInstallCall ( ) ?. spec ) . toBe ( "@openclaw/[email protected] " ) ; 1606+ expect ( npmInstallCall ( ) ?. extensionsDir ) . toBe ( extensionsDir ) ;
1607+ expect ( runCommandWithTimeoutMock ) . not . toHaveBeenCalled ( ) ;
1608+ expectRecordFields ( result . config . plugins ?. installs ?. codex , {
1609+ source : "npm" ,
1610+ spec :
"@openclaw/[email protected] " , 1611+ installPath,
1612+ version : "2026.5.28" ,
1613+ resolvedName : "@openclaw/codex" ,
1614+ resolvedSpec :
"@openclaw/[email protected] " , 1615+ resolvedVersion : "2026.5.28" ,
1616+ } ) ;
1617+ expectRecordFields ( result . outcomes [ 0 ] , {
1618+ pluginId : "codex" ,
1619+ status : "updated" ,
1620+ nextVersion : "2026.5.28" ,
1621+ } ) ;
1622+ } ) ;
1623+
15331624 it ( "keeps third-party exact pinned npm specs pinned during official install sync" , async ( ) => {
15341625 const installPath = createInstalledPackageDir ( {
15351626 name : "@acme/demo" ,
0 commit comments