@@ -11,7 +11,7 @@ import type {ElementHandle, Page} from '../third_party/index.js';
1111import { parseKey } from '../utils/keyboard.js' ;
1212
1313import { ToolCategory } from './categories.js' ;
14- import { defineTool , isolatedContextSchema } from './ToolDefinition.js' ;
14+ import { defineTool , pageIdSchema } from './ToolDefinition.js' ;
1515
1616const dblClickSchema = zod
1717 . boolean ( )
@@ -83,15 +83,15 @@ export const clickAt = defineTool({
8383 conditions : [ 'computerVision' ] ,
8484 } ,
8585 schema : {
86- ...isolatedContextSchema ,
86+ ...pageIdSchema ,
8787 x : zod . number ( ) . describe ( 'The x coordinate' ) ,
8888 y : zod . number ( ) . describe ( 'The y coordinate' ) ,
8989 dblClick : dblClickSchema ,
9090 includeSnapshot : includeSnapshotSchema ,
9191 } ,
9292 handler : async ( request , response , context ) => {
93- const page = context . resolvePageByContext (
94- request . params . isolatedContext ,
93+ const page = context . resolvePageById (
94+ request . params . pageId ,
9595 ) ;
9696 await context . waitForEventsAfterAction ( async ( ) => {
9797 await page . mouse . click ( request . params . x , request . params . y , {
@@ -221,7 +221,7 @@ export const fill = defineTool({
221221 readOnlyHint : false ,
222222 } ,
223223 schema : {
224- ...isolatedContextSchema ,
224+ ...pageIdSchema ,
225225 uid : zod
226226 . string ( )
227227 . describe (
@@ -231,8 +231,8 @@ export const fill = defineTool({
231231 includeSnapshot : includeSnapshotSchema ,
232232 } ,
233233 handler : async ( request , response , context ) => {
234- const page = context . resolvePageByContext (
235- request . params . isolatedContext ,
234+ const page = context . resolvePageById (
235+ request . params . pageId ,
236236 ) ;
237237 await context . waitForEventsAfterAction ( async ( ) => {
238238 await fillFormElement (
@@ -289,7 +289,7 @@ export const fillForm = defineTool({
289289 readOnlyHint : false ,
290290 } ,
291291 schema : {
292- ...isolatedContextSchema ,
292+ ...pageIdSchema ,
293293 elements : zod
294294 . array (
295295 zod . object ( {
@@ -301,8 +301,8 @@ export const fillForm = defineTool({
301301 includeSnapshot : includeSnapshotSchema ,
302302 } ,
303303 handler : async ( request , response , context ) => {
304- const page = context . resolvePageByContext (
305- request . params . isolatedContext ,
304+ const page = context . resolvePageById (
305+ request . params . pageId ,
306306 ) ;
307307 for ( const element of request . params . elements ) {
308308 await context . waitForEventsAfterAction ( async ( ) => {
@@ -329,7 +329,7 @@ export const uploadFile = defineTool({
329329 readOnlyHint : false ,
330330 } ,
331331 schema : {
332- ...isolatedContextSchema ,
332+ ...pageIdSchema ,
333333 uid : zod
334334 . string ( )
335335 . describe (
@@ -351,9 +351,7 @@ export const uploadFile = defineTool({
351351 // a type=file element. In this case, we want to default to
352352 // Page.waitForFileChooser() and upload the file this way.
353353 try {
354- const page = context . resolvePageByContext (
355- request . params . isolatedContext ,
356- ) ;
354+ const page = context . resolvePageById ( request . params . pageId ) ;
357355 const [ fileChooser ] = await Promise . all ( [
358356 page . waitForFileChooser ( { timeout : 3000 } ) ,
359357 handle . asLocator ( ) . click ( ) ,
@@ -366,9 +364,7 @@ export const uploadFile = defineTool({
366364 }
367365 }
368366 if ( request . params . includeSnapshot ) {
369- const page = context . resolvePageByContext (
370- request . params . isolatedContext ,
371- ) ;
367+ const page = context . resolvePageById ( request . params . pageId ) ;
372368 response . includeSnapshot ( { page } ) ;
373369 }
374370 response . appendResponseLine ( `File uploaded from ${ filePath } .` ) ;
@@ -386,7 +382,7 @@ export const pressKey = defineTool({
386382 readOnlyHint : false ,
387383 } ,
388384 schema : {
389- ...isolatedContextSchema ,
385+ ...pageIdSchema ,
390386 key : zod
391387 . string ( )
392388 . describe (
@@ -395,8 +391,8 @@ export const pressKey = defineTool({
395391 includeSnapshot : includeSnapshotSchema ,
396392 } ,
397393 handler : async ( request , response , context ) => {
398- const page = context . resolvePageByContext (
399- request . params . isolatedContext ,
394+ const page = context . resolvePageById (
395+ request . params . pageId ,
400396 ) ;
401397 const tokens = parseKey ( request . params . key ) ;
402398 const [ key , ...modifiers ] = tokens ;
0 commit comments