import bpy
scene=bpy.context.scene
tree=bpy.data.node_groups.get('Lantern Compositor')
# Finish compositor setup using Blender 5.1 socket controls.
if tree:
    tree.nodes.clear()
    gi=tree.nodes.new('NodeGroupInput'); gi.location=(-420,0)
    go=tree.nodes.new('NodeGroupOutput'); go.location=(300,0)
    gl=tree.nodes.new('CompositorNodeGlare'); gl.location=(-80,0)
    # Type is a menu socket in this Blender build: 0 likely streaks, 1 fog glow; set by name where possible.
    for sname,val in [('Type',1),('Quality',2),('Threshold',1.0),('Size',7),('Strength',0.8)]:
        s=gl.inputs.get(sname)
        if s:
            try: s.default_value=val
            except: pass
    tree.links.new(gi.outputs.get('Image'),gl.inputs.get('Image'))
    tree.links.new(gl.outputs.get('Image'),go.inputs.get('Image'))
    scene.compositing_node_group=tree
    scene.render.use_compositing=True
# final settings
scene.render.engine='CYCLES'; scene.render.resolution_x=1536; scene.render.resolution_y=1536; scene.render.resolution_percentage=100; scene.cycles.samples=64; scene.render.filepath='<repo>/apps/console/camping_lantern_final.png'
bpy.ops.wm.save_as_mainfile(filepath='<repo>/apps/console/camping_lantern.blend')
result={'comp':bool(scene.compositing_node_group),'use':scene.render.use_compositing,'nodes':[(n.name,n.bl_idname) for n in tree.nodes],'links':len(tree.links),'engine':scene.render.engine}