Skip to content

Commit 7b1ca25

Browse files
committed
renames
1 parent 884f0d4 commit 7b1ca25

File tree

1 file changed

+19
-24
lines changed

1 file changed

+19
-24
lines changed

browserbase/src/playwright.ts

+19-24
Original file line numberDiff line numberDiff line change
@@ -268,23 +268,18 @@ const TOOLS: Tool[] = [
268268
},
269269
},
270270
{
271-
name: "browserbase_screenshot",
271+
name: "browserbase_take_screenshot",
272272
description:
273-
"Takes a screenshot of the current page. Use this tool to learn where you are on the page when controlling the browser with Stagehand. Only use this tool when the other tools are not sufficient to get the information you need.",
273+
"Take a screenshot of the current page. You can't perform actions based on the screenshot, use browser_snapshot for actions.",
274274
inputSchema: {
275275
type: "object",
276276
properties: {
277-
name: {
278-
type: "string",
279-
description:
280-
"Name to save the screenshot under (optional, defaults to timestamp)",
281-
},
282277
sessionId: {
283278
type: "string",
284279
description: "Target session ID (optional, defaults to 'default')",
285280
},
286281
},
287-
required: [], // name is optional
282+
required: [], // No required args
288283
},
289284
},
290285
{
@@ -306,23 +301,23 @@ const TOOLS: Tool[] = [
306301
},
307302
},
308303
{
309-
name: "browserbase_fill",
304+
name: "browserbase_type",
310305
description:
311-
"Fill out an input field with the specified text. Does NOT press Enter.",
306+
"Type text into editable element specified by a selector. Does NOT press Enter by default.",
312307
inputSchema: {
313308
type: "object",
314309
properties: {
315310
selector: {
316311
type: "string",
317312
description: "CSS or Playwright selector for input field",
318313
},
319-
value: { type: "string", description: "Value to fill" },
314+
text: { type: "string", description: "Text to type" },
320315
sessionId: {
321316
type: "string",
322317
description: "Target session ID (optional, defaults to 'default')",
323318
},
324319
},
325-
required: ["selector", "value"],
320+
required: ["selector", "text"],
326321
},
327322
},
328323
{
@@ -610,8 +605,8 @@ async function handleToolCall(
610605
isError: false,
611606
};
612607

613-
case "browserbase_screenshot": {
614-
const screenshotName = args.name || `screenshot_${Date.now()}.png`; // Ensure .png extension
608+
case "browserbase_take_screenshot": {
609+
const screenshotName = `screenshot_${Date.now()}.png`; // Use default timestamp name
615610
console.error(
616611
`Taking screenshot for session ${targetSessionId}, saving as ${screenshotName}`,
617612
);
@@ -713,28 +708,28 @@ async function handleToolCall(
713708
};
714709
}
715710

716-
case "browserbase_fill":
711+
case "browserbase_type":
717712
if (!args.selector)
718713
return {
719714
content: [
720715
{ type: "text", text: "Missing required argument: selector" },
721716
],
722717
isError: true,
723718
};
724-
if (typeof args.value !== "string")
719+
if (typeof args.text !== "string")
725720
return {
726721
content: [
727722
{
728723
type: "text",
729-
text: "Missing or invalid required argument: value (must be a string)",
724+
text: "Missing or invalid required argument: text (must be a string)",
730725
},
731726
],
732727
isError: true,
733728
};
734729
try {
735730
// Fill the input
736731
console.error(
737-
`Attempting to fill '${args.selector}' in session ${targetSessionId} with value (length: ${args.value.length})`,
732+
`Attempting to type into '${args.selector}' in session ${targetSessionId} with text (length: ${args.text.length})`,
738733
);
739734
// Recommended: Wait for the element first
740735
await page.waitForSelector(args.selector, {
@@ -744,32 +739,32 @@ async function handleToolCall(
744739

745740
await page
746741
.locator(args.selector)
747-
.fill(args.value, { timeout: 10000 }); // Use locator and fill with timeout
742+
.fill(args.text, { timeout: 10000 }); // Use args.text
748743
// REMOVED implicit Enter press:
749744
// await page.press(args.selector, "Enter", { timeout: 5000 });
750745
console.error(
751-
`Filled '${args.selector}' successfully in session ${targetSessionId}. (Enter NOT pressed)`,
746+
`Typed into '${args.selector}' successfully in session ${targetSessionId}. (Enter NOT pressed)`,
752747
);
753748
return {
754749
// Avoid logging sensitive values like passwords
755750
content: [
756751
{
757752
type: "text",
758-
text: `Filled element matching selector ${args.selector} in session ${targetSessionId}. Use browserbase_press_key to press Enter if needed.`,
753+
text: `Typed into element matching selector ${args.selector} in session ${targetSessionId}. Use browserbase_press_key to press Enter if needed.`,
759754
},
760755
],
761756
isError: false,
762757
};
763758
} catch (error) {
764759
console.error(
765-
`Failed to fill '${args.selector}' in session ${targetSessionId}: ${
760+
`Failed to type into '${args.selector}' in session ${targetSessionId}: ${
766761
(error as Error).message
767762
}`,
768763
);
769-
let errorMessage = `Failed to fill element matching selector "${args.selector}" in session ${targetSessionId}.`;
764+
let errorMessage = `Failed to type into element matching selector "${args.selector}" in session ${targetSessionId}.`;
770765
if (error instanceof PlaywrightErrors.TimeoutError) {
771766
errorMessage +=
772-
" Reason: Timeout waiting for element or fill action.";
767+
" Reason: Timeout waiting for element or type action.";
773768
} else {
774769
errorMessage += ` Reason: ${(error as Error).message}`;
775770
}

0 commit comments

Comments
 (0)