mirror of
https://github.com/AgentDeskAI/browser-tools-mcp.git
synced 2025-06-27 00:41:26 +00:00
edited prompts + added toggle for autopaste screenshots
This commit is contained in:
parent
7b838947df
commit
03cb3ca70c
@ -1272,6 +1272,13 @@ server.tool("runNextJSAudit", {}, async () => ({
|
|||||||
Remember to use a CDN to serve your media (images, videos, etc.) to improve the loading speed.
|
Remember to use a CDN to serve your media (images, videos, etc.) to improve the loading speed.
|
||||||
|
|
||||||
For the image format, use WebP if possible because it has a smaller size than PNG and JPEG.
|
For the image format, use WebP if possible because it has a smaller size than PNG and JPEG.
|
||||||
|
|
||||||
|
Given the provided procedures, begin by analyzing all of our Next.js pages.
|
||||||
|
Check to see what metadata already exists, look for any robot.txt files, and take a closer look at some of the other aspects of our project to determine areas of improvement.
|
||||||
|
Once you've performed this comprehensive analysis, return back a report on what we can do to improve our application.
|
||||||
|
Do not actually make the code changes yet, just return a comprehensive plan that you will ask for approval for.
|
||||||
|
If feedback is provided, adjust the plan accordingly and ask for approval again.
|
||||||
|
If the user approves of the plan, go ahead and proceed to implement all the necessary code changes to completely optimize our application.
|
||||||
`,
|
`,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
@ -1295,6 +1302,8 @@ server.tool(
|
|||||||
6. Deeply reflect on what could be wrong + produce a comprehensive analysis of the issue
|
6. Deeply reflect on what could be wrong + produce a comprehensive analysis of the issue
|
||||||
7. Suggest additional logs if the issue persists or if the source is not yet clear
|
7. Suggest additional logs if the issue persists or if the source is not yet clear
|
||||||
8. Once a fix is implemented, ask for approval to remove the previously added logs
|
8. Once a fix is implemented, ask for approval to remove the previously added logs
|
||||||
|
|
||||||
|
Note: DO NOT run any of our audits (runAccessibilityAudit, runPerformanceAudit, runBestPracticesAudit, runSEOAudit, runNextJSAudit) when in debugging mode unless explicitly asked to do so or unless you switch to audit mode.
|
||||||
`,
|
`,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
@ -171,7 +171,11 @@ let selectedElement: any = null;
|
|||||||
|
|
||||||
// Add new state for tracking screenshot requests
|
// Add new state for tracking screenshot requests
|
||||||
interface ScreenshotCallback {
|
interface ScreenshotCallback {
|
||||||
resolve: (value: { data: string; path?: string }) => void;
|
resolve: (value: {
|
||||||
|
data: string;
|
||||||
|
path?: string;
|
||||||
|
autoPaste?: boolean;
|
||||||
|
}) => void;
|
||||||
reject: (reason: Error) => void;
|
reject: (reason: Error) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -592,6 +596,7 @@ interface ScreenshotMessage {
|
|||||||
data?: string;
|
data?: string;
|
||||||
path?: string;
|
path?: string;
|
||||||
error?: string;
|
error?: string;
|
||||||
|
autoPaste?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class BrowserConnector {
|
export class BrowserConnector {
|
||||||
@ -708,13 +713,18 @@ export class BrowserConnector {
|
|||||||
if (data.type === "screenshot-data" && data.data) {
|
if (data.type === "screenshot-data" && data.data) {
|
||||||
console.log("Received screenshot data");
|
console.log("Received screenshot data");
|
||||||
console.log("Screenshot path from extension:", data.path);
|
console.log("Screenshot path from extension:", data.path);
|
||||||
|
console.log("Auto-paste setting from extension:", data.autoPaste);
|
||||||
// Get the most recent callback since we're not using requestId anymore
|
// Get the most recent callback since we're not using requestId anymore
|
||||||
const callbacks = Array.from(screenshotCallbacks.values());
|
const callbacks = Array.from(screenshotCallbacks.values());
|
||||||
if (callbacks.length > 0) {
|
if (callbacks.length > 0) {
|
||||||
const callback = callbacks[0];
|
const callback = callbacks[0];
|
||||||
console.log("Found callback, resolving promise");
|
console.log("Found callback, resolving promise");
|
||||||
// Pass both the data and path to the resolver
|
// Pass both the data, path and autoPaste to the resolver
|
||||||
callback.resolve({ data: data.data, path: data.path });
|
callback.resolve({
|
||||||
|
data: data.data,
|
||||||
|
path: data.path,
|
||||||
|
autoPaste: data.autoPaste,
|
||||||
|
});
|
||||||
screenshotCallbacks.clear(); // Clear all callbacks
|
screenshotCallbacks.clear(); // Clear all callbacks
|
||||||
} else {
|
} else {
|
||||||
console.log("No callbacks found for screenshot");
|
console.log("No callbacks found for screenshot");
|
||||||
@ -945,8 +955,11 @@ export class BrowserConnector {
|
|||||||
console.log("Browser Connector: Generated requestId:", requestId);
|
console.log("Browser Connector: Generated requestId:", requestId);
|
||||||
|
|
||||||
// Create promise that will resolve when we get the screenshot data
|
// Create promise that will resolve when we get the screenshot data
|
||||||
const screenshotPromise = new Promise<{ data: string; path?: string }>(
|
const screenshotPromise = new Promise<{
|
||||||
(resolve, reject) => {
|
data: string;
|
||||||
|
path?: string;
|
||||||
|
autoPaste?: boolean;
|
||||||
|
}>((resolve, reject) => {
|
||||||
console.log(
|
console.log(
|
||||||
`Browser Connector: Setting up screenshot callback for requestId: ${requestId}`
|
`Browser Connector: Setting up screenshot callback for requestId: ${requestId}`
|
||||||
);
|
);
|
||||||
@ -971,8 +984,7 @@ export class BrowserConnector {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}, 10000);
|
}, 10000);
|
||||||
}
|
});
|
||||||
);
|
|
||||||
|
|
||||||
// Send screenshot request to extension
|
// Send screenshot request to extension
|
||||||
const message = JSON.stringify({
|
const message = JSON.stringify({
|
||||||
@ -987,9 +999,14 @@ export class BrowserConnector {
|
|||||||
|
|
||||||
// Wait for screenshot data
|
// Wait for screenshot data
|
||||||
console.log("Browser Connector: Waiting for screenshot data...");
|
console.log("Browser Connector: Waiting for screenshot data...");
|
||||||
const { data: base64Data, path: customPath } = await screenshotPromise;
|
const {
|
||||||
|
data: base64Data,
|
||||||
|
path: customPath,
|
||||||
|
autoPaste,
|
||||||
|
} = await screenshotPromise;
|
||||||
console.log("Browser Connector: Received screenshot data, saving...");
|
console.log("Browser Connector: Received screenshot data, saving...");
|
||||||
console.log("Browser Connector: Custom path from extension:", customPath);
|
console.log("Browser Connector: Custom path from extension:", customPath);
|
||||||
|
console.log("Browser Connector: Auto-paste setting:", autoPaste);
|
||||||
|
|
||||||
// Always prioritize the path from the Chrome extension
|
// Always prioritize the path from the Chrome extension
|
||||||
let targetPath = customPath;
|
let targetPath = customPath;
|
||||||
@ -1049,9 +1066,9 @@ export class BrowserConnector {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check if running on macOS before executing AppleScript
|
// Check if running on macOS before executing AppleScript
|
||||||
if (os.platform() === "darwin") {
|
if (os.platform() === "darwin" && autoPaste === true) {
|
||||||
console.log(
|
console.log(
|
||||||
"Browser Connector: Running on macOS, executing AppleScript to paste into Cursor"
|
"Browser Connector: Running on macOS with auto-paste enabled, executing AppleScript to paste into Cursor"
|
||||||
);
|
);
|
||||||
|
|
||||||
// Create the AppleScript to copy the image to clipboard and paste into Cursor
|
// Create the AppleScript to copy the image to clipboard and paste into Cursor
|
||||||
@ -1202,11 +1219,17 @@ export class BrowserConnector {
|
|||||||
console.log(`Browser Connector: stdout: ${stdout}`);
|
console.log(`Browser Connector: stdout: ${stdout}`);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
if (os.platform() === "darwin" && !autoPaste) {
|
||||||
|
console.log(
|
||||||
|
`Browser Connector: Running on macOS but auto-paste is disabled, skipping AppleScript execution`
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
console.log(
|
console.log(
|
||||||
`Browser Connector: Not running on macOS, skipping AppleScript execution`
|
`Browser Connector: Not running on macOS, skipping AppleScript execution`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
res.json({
|
res.json({
|
||||||
path: fullPath,
|
path: fullPath,
|
||||||
|
@ -11,6 +11,7 @@ let settings = {
|
|||||||
screenshotPath: "", // Add new setting for screenshot path
|
screenshotPath: "", // Add new setting for screenshot path
|
||||||
serverHost: "localhost", // Default server host
|
serverHost: "localhost", // Default server host
|
||||||
serverPort: 3025, // Default server port
|
serverPort: 3025, // Default server port
|
||||||
|
allowAutoPaste: false, // Default auto-paste setting
|
||||||
};
|
};
|
||||||
|
|
||||||
// Keep track of debugger state
|
// Keep track of debugger state
|
||||||
@ -978,6 +979,8 @@ async function setupWebSocket() {
|
|||||||
requestId: message.requestId,
|
requestId: message.requestId,
|
||||||
// Only include path if it's configured in settings
|
// Only include path if it's configured in settings
|
||||||
...(settings.screenshotPath && { path: settings.screenshotPath }),
|
...(settings.screenshotPath && { path: settings.screenshotPath }),
|
||||||
|
// Include auto-paste setting
|
||||||
|
autoPaste: settings.allowAutoPaste,
|
||||||
};
|
};
|
||||||
|
|
||||||
console.log("Chrome Extension: Sending screenshot data response", {
|
console.log("Chrome Extension: Sending screenshot data response", {
|
||||||
|
@ -51,6 +51,9 @@
|
|||||||
.checkbox-group {
|
.checkbox-group {
|
||||||
margin-bottom: 8px;
|
margin-bottom: 8px;
|
||||||
}
|
}
|
||||||
|
.checkbox-group-2 {
|
||||||
|
margin-bottom: 6px;
|
||||||
|
}
|
||||||
input[type="number"],
|
input[type="number"],
|
||||||
input[type="text"] {
|
input[type="text"] {
|
||||||
padding: 4px;
|
padding: 4px;
|
||||||
@ -123,6 +126,12 @@
|
|||||||
Wipe All Logs
|
Wipe All Logs
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="checkbox-group-2" style="margin-top: 10px; display: flex; align-items: center;">
|
||||||
|
<label>
|
||||||
|
<input type="checkbox" id="allow-auto-paste">
|
||||||
|
Allow Auto-paste to Cursor
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="settings-section">
|
<div class="settings-section">
|
||||||
|
@ -10,6 +10,7 @@ let settings = {
|
|||||||
// Add server connection settings
|
// Add server connection settings
|
||||||
serverHost: "localhost",
|
serverHost: "localhost",
|
||||||
serverPort: 3025,
|
serverPort: 3025,
|
||||||
|
allowAutoPaste: false, // Default auto-paste setting
|
||||||
};
|
};
|
||||||
|
|
||||||
// Track connection status
|
// Track connection status
|
||||||
@ -340,6 +341,9 @@ advancedSettingsHeader.addEventListener("click", () => {
|
|||||||
chevronIcon.classList.toggle("open");
|
chevronIcon.classList.toggle("open");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Get all inputs by ID
|
||||||
|
const allowAutoPasteCheckbox = document.getElementById("allow-auto-paste");
|
||||||
|
|
||||||
// Update UI from settings
|
// Update UI from settings
|
||||||
function updateUIFromSettings() {
|
function updateUIFromSettings() {
|
||||||
logLimitInput.value = settings.logLimit;
|
logLimitInput.value = settings.logLimit;
|
||||||
@ -351,6 +355,7 @@ function updateUIFromSettings() {
|
|||||||
screenshotPathInput.value = settings.screenshotPath;
|
screenshotPathInput.value = settings.screenshotPath;
|
||||||
serverHostInput.value = settings.serverHost;
|
serverHostInput.value = settings.serverHost;
|
||||||
serverPortInput.value = settings.serverPort;
|
serverPortInput.value = settings.serverPort;
|
||||||
|
allowAutoPasteCheckbox.checked = settings.allowAutoPaste;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save settings
|
// Save settings
|
||||||
@ -414,6 +419,12 @@ serverPortInput.addEventListener("change", (e) => {
|
|||||||
testConnection(settings.serverHost, settings.serverPort);
|
testConnection(settings.serverHost, settings.serverPort);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Add event listener for auto-paste checkbox
|
||||||
|
allowAutoPasteCheckbox.addEventListener("change", (e) => {
|
||||||
|
settings.allowAutoPaste = e.target.checked;
|
||||||
|
saveSettings();
|
||||||
|
});
|
||||||
|
|
||||||
// Function to cancel any ongoing discovery operations
|
// Function to cancel any ongoing discovery operations
|
||||||
function cancelOngoingDiscovery() {
|
function cancelOngoingDiscovery() {
|
||||||
if (isDiscoveryInProgress) {
|
if (isDiscoveryInProgress) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user