filepath = "/root/web-apps/efesto/backend/src/services/agentService.js"

with open(filepath, "r") as f:
    content = f.read()

old = "const askedForPhotos = /(?:quiero"
idx = content.find(old)
if idx > 0:
    end = content.find(';', idx) + 1
    old_full = content[idx:end]
    new = 'const askedForPhotos = /fotos?|imagene?s?|images?|muestram|envíam|mandam|enséñam|enseñam|ver.*propiedad|tienes.*foto|puedo ver/i.test(messageText);'
    content = content.replace(old_full, new)
    with open(filepath, "w") as f:
        f.write(content)
    print("OK - production regex fixed")
else:
    print("ERROR - not found")
