fix: resolve browser tool syntax errors using robust base64 write-and-run pattern

This commit is contained in:
2026-06-02 14:12:14 -07:00
parent 8299526654
commit a049ee8887

View File

@@ -35,8 +35,11 @@ const { chromium } = require('playwright');
})();
`;
// We need to ensure playwright is installed and the browsers are downloaded.
const setupCmd = `if [ ! -d "node_modules/playwright" ]; then npm install --no-save playwright && npx playwright install chromium; fi && node -e "${script.replace(/"/g, '\\"').replace(/\$/g, "\\$")}"`;
// Encode the script to base64 to bypass any shell quoting/escaping conflicts
const scriptB64 = Buffer.from(script, "utf8").toString("base64");
const tempFile = `.vibn-console-${projectId}.js`;
const setupCmd = `echo "${scriptB64}" | base64 -d > ${tempFile} && if [ ! -d "node_modules/playwright" ]; then npm install --no-save playwright && npx playwright install chromium; fi && node ${tempFile} && rm -f ${tempFile}`;
try {
const res = await execInDevContainer({
@@ -99,7 +102,11 @@ const { chromium } = require('playwright');
})();
`;
const setupCmd = `if [ ! -d "node_modules/playwright" ]; then npm install --no-save playwright && npx playwright install chromium; fi && node -e "${script.replace(/"/g, '\\"').replace(/\$/g, "\\$")}"`;
// Encode the script to base64 to bypass any shell quoting/escaping conflicts
const scriptB64 = Buffer.from(script, "utf8").toString("base64");
const tempFile = `.vibn-navigate-${projectId}.js`;
const setupCmd = `echo "${scriptB64}" | base64 -d > ${tempFile} && if [ ! -d "node_modules/playwright" ]; then npm install --no-save playwright && npx playwright install chromium; fi && node ${tempFile} && rm -f ${tempFile}`;
try {
const res = await execInDevContainer({