I get a failed response 404 on my script, can you help me fix it? On Nstbrowser API documentation they say this is the BaseURL: http://localhost:8848/api/agent

const puppeteer = require('puppeteer-core');
const fs = require('fs');
const path = require('path');
const readline = require('readline');

// Load titles from a .txt file
const titles = fs.readFileSync(path.join(__dirname, 'titles.txt'), 'utf-8').split('\n');

// Function to launch profile via WebSocket with Nstbrowser
async function launchProfile(profileId) {
    const wsUrl = `http://localhost:8848/api/agent/connect/{profileId}${profileId}`;
    try {
        console.log(`Attempting to connect to WebSocket URL: ${wsUrl}`);
        const browser = await puppeteer.connect({ browserWSEndpoint: wsUrl });
        console.log(`Connected to profile: ${profileId}`);
        return browser;
    } catch (error) {
        console.error(`Failed to launch profile ${profileId} at ${wsUrl}:`, error.message);
        throw error;
    }
}

// Function to upload video to YouTube
async function uploadVideo(page, videoFile, title) {
    try {
        await page.goto('https://studio.youtube.com', { waitUntil: 'networkidle2' });

        await page.waitForSelector('input[type="file"]', { visible: true });
        const inputUploadHandle = await page.$('input[type="file"]');
        await inputUploadHandle.uploadFile(videoFile);
        console.log(`Uploading video: ${videoFile}`);

        await page.waitForSelector('#title-textbox');
        await page.type('#title-textbox', title);
        console.log(`Video title set to: ${title}`);

        await page.click('button[aria-label="Done"]');
        console.log('Video upload complete');
    } catch (error) {
        console.error(`Failed to upload video ${videoFile}:`, error);
    }
}

// Wait for IP rotation before continuing
async function rotateIP() {
    return new Promise((resolve) => {
        const rl = readline.createInterface({
            input: process.stdin,
            output: process.stdout,
        });
        rl.question('Please rotate your IP and press Enter to continue...', () => {
            rl.close();
            resolve();
        });
    });
}

// Main function to execute uploads across profiles
(async () => {
    const profiles = [
        { id: '0a07793d-cb85-4697-aa32-791f455f1a3e', name: 'YT_2' },
        { id: 'f9cacd2d-da6f-4b66-afc9-39080fa17dbf', name: 'YT_3' },
        // Add more profiles as needed
    ];

    const videoFolder = path.join(__dirname, 'videos');
    const videoFiles = fs.readdirSync(videoFolder).filter(file => file.endsWith('.mp4'));

    for (const profile of profiles) {
        console.log(`Launching profile: ${profile.name}`);
        try {
            const browser = await launchProfile(profile.id);
            const page = await browser.newPage();

            for (const video of videoFiles) {
                const randomTitle = titles[Math.floor(Math.random() * titles.length)];
                const videoPath = path.join(videoFolder, video);
                await uploadVideo(page, videoPath, randomTitle);

                await rotateIP();
            }

            await browser.close();
            console.log(`Closed profile: ${profile.name}`);
        } catch (error) {
            console.error(`Error in profile ${profile.name}:`, error);
        }
    }
})();