Before 4.0, you were able to run a script like this:
import bpy
bpy.data.node_groups['NODE_GROUP_NAME'].inputs.new('NodeSocketFloat', 'SOCKET_NAME')
and it would allow you to use any socket type used in blender, including geometry node exclusive ones such as boolean, integer, string, etc.
In 4.0, the API for node groups changed, so I tried modifying the code like this:
import bpy
bpy.data.node_groups['NODE_GROUP_NAME'].interface.new_socket(name='SOCKET_NAME', socket_type='NodeSocketFloat')
which works for the shader node-supported sockets (including boolean and integer, as those seem to now be properly supported in shader nodes), but if you try to add any other node type, such as NodeSocketMenu, it will give you an error:
TypeError: NodeTreeInterface.new_socket(): error with keyword argument "socket_type"
- enum "NodeSocketMenu" not found in ('NodeSocketBool', 'NodeSocketVector',
'NodeSocketInt', 'NodeSocketShader', 'NodeSocketFloat', 'NodeSocketColor')
which implies they removed the option to add unsupported sockets to shader nodes. However, appending a node group from a previous version that did have unsupported nodes (eg. string, image, material, etc.) still works. For the string type specifically, you can even just use the string inputs from the Principled Volume node in a node group and it will still work. So are unsupported node sockets in shader nodes possible in 4.0+, but just not via python or something? I'm trying to get the new menu socket in shader nodes.