Osascript error NSRegularExpression doesn’t understand the regularExpressionWithPattern _options _error_ message

Hi,
I have an apple script that used to work from cron before I got a new macbook which upgraded me to Sonoma but now it barfs with ‘NSRegularExpression doesn’t understand the “regularExpressionWithPattern_options_error_” message.’
In an attempt to fix this I changed it to use launchd using a plist in ~/Library/LaunchAgents which launches the script but it still hits this error.
It works fine in ScriptDebugger (SD) but not when run from launchd.
Both SD and osascript have ‘Full Disk Access’ and have Automation enabled for ‘Safari, Finder and System Events’
The script is meant to use ~/Library/Script Libraries/RegexAndStuffLib.scptd based on this line of code:
use script “RegexAndStuffLib” version “1.0.7”
but I also have xcode installed so there are other regex libraries installed.

Does anyone have suggestions about what else I need to do to get this to work with Sonoma?