{"version":3,"file":"agent/actions/schemas.mjs","sources":["webpack://@agent-infra/browser-use/./src/agent/actions/schemas.ts"],"sourcesContent":["/**\n * The following code is modified based on\n * https://github.com/nanobrowser/nanobrowser/blob/master/chrome-extension/src/background/agent/actions/schemas.ts\n *\n * Apache-2.0 License\n * Copyright (c) 2024 alexchenzl\n * https://github.com/nanobrowser/nanobrowser/blob/master/LICENSE\n */\nimport { z } from 'zod';\n\nexport interface ActionSchema<T extends z.ZodType = z.ZodType> {\n  name: string;\n  description: string;\n  schema: T;\n}\n\nexport const doneActionSchema = {\n  name: 'done',\n  description: 'Complete task',\n  schema: z.object({\n    text: z.string(),\n  }),\n} as const satisfies ActionSchema;\n\n// Basic Navigation Actions\nexport const searchGoogleActionSchema = {\n  name: 'search_google',\n  description: 'Search Google in the current tab',\n  schema: z.object({\n    query: z.string(),\n  }),\n} as const satisfies ActionSchema;\n\nexport const goToUrlActionSchema = {\n  name: 'go_to_url',\n  description: 'Navigate to URL in the current tab',\n  schema: z.object({\n    url: z.string(),\n  }),\n} as const satisfies ActionSchema;\n\nexport const goBackActionSchema = {\n  name: 'go_back',\n  description: 'Go back to the previous page',\n  schema: z.object({}),\n} as const satisfies ActionSchema;\n\nexport const clickElementActionSchema = {\n  name: 'click_element',\n  description: 'Click element',\n  schema: z.object({\n    desc: z.string().optional(), // some small LLM can not generate a description, so let it be optional (but it's still makred as required in json schema)\n    index: z.number(),\n    xpath: z.string().optional(),\n  }),\n} as const satisfies ActionSchema;\n\nexport const inputTextActionSchema = {\n  name: 'input_text',\n  description: 'Input text into an interactive input element',\n  schema: z.object({\n    desc: z.string().optional(),\n    index: z.number(),\n    text: z.string(),\n    xpath: z.string().optional(),\n  }),\n} as const satisfies ActionSchema;\n\n// Tab Management Actions\nexport const switchTabActionSchema = {\n  name: 'switch_tab',\n  description: 'Switch to tab by id',\n  schema: z.object({\n    tab_id: z.string(),\n  }),\n} as const satisfies ActionSchema;\n\nexport const openTabActionSchema = {\n  name: 'open_tab',\n  description: 'Open URL in new tab',\n  schema: z.object({\n    url: z.string(),\n  }),\n} as const satisfies ActionSchema;\n\n// Content Actions\nexport const extractContentActionSchema = {\n  name: 'extract_content',\n  description:\n    'Extract page content to retrieve specific information from the page, e.g. all company names, a specifc description, all information about, links with companies in structured format or simply links',\n  schema: z.object({\n    goal: z.string(),\n  }),\n} as const satisfies ActionSchema;\n\n// Cache Actions\nexport const cacheContentActionSchema = {\n  name: 'cache_content',\n  description: 'Cache the extracted content of the page',\n  schema: z.object({\n    content: z.string(),\n  }),\n} as const satisfies ActionSchema;\n\nexport const scrollDownActionSchema = {\n  name: 'scroll_down',\n  description:\n    'Scroll down the page by pixel amount - if no amount is specified, scroll down one page',\n  schema: z.object({\n    desc: z.string().optional(),\n    amount: z.number().optional(),\n  }),\n} as const satisfies ActionSchema;\n\nexport const scrollUpActionSchema = {\n  name: 'scroll_up',\n  description:\n    'Scroll up the page by pixel amount - if no amount is specified, scroll up one page',\n  schema: z.object({\n    desc: z.string().optional(),\n    amount: z.number().optional(),\n  }),\n} as const satisfies ActionSchema;\n\nexport const sendKeysActionSchema = {\n  name: 'send_keys',\n  description:\n    'Send strings of special keys like Backspace, Insert, PageDown, Delete, Enter. Shortcuts such as `Control+o`, `Control+Shift+T` are supported as well. This gets used in keyboard press. Be aware of different operating systems and their shortcuts',\n  schema: z.object({\n    desc: z.string().optional(),\n    keys: z.string(),\n  }),\n} as const satisfies ActionSchema;\n\nexport const scrollToTextActionSchema = {\n  name: 'scroll_to_text',\n  description:\n    'If you dont find something which you want to interact with, scroll to it',\n  schema: z.object({\n    desc: z.string().optional(),\n    text: z.string(),\n  }),\n} as const satisfies ActionSchema;\n\nexport const getDropdownOptionsActionSchema = {\n  name: 'get_dropdown_options',\n  description: 'Get all options from a native dropdown',\n  schema: z.object({\n    index: z.number(),\n  }),\n} as const satisfies ActionSchema;\n\nexport const selectDropdownOptionActionSchema = {\n  name: 'select_dropdown_option',\n  description:\n    'Select dropdown option for interactive element index by the text of the option you want to select',\n  schema: z.object({\n    index: z.number(),\n    text: z.string(),\n  }),\n} as const satisfies ActionSchema;\n"],"names":["doneActionSchema","z","searchGoogleActionSchema","goToUrlActionSchema","goBackActionSchema","clickElementActionSchema","inputTextActionSchema","switchTabActionSchema","openTabActionSchema","extractContentActionSchema","cacheContentActionSchema","scrollDownActionSchema","scrollUpActionSchema","sendKeysActionSchema","scrollToTextActionSchema","getDropdownOptionsActionSchema","selectDropdownOptionActionSchema"],"mappings":";;;;;AAgBO,MAAMA,mBAAmB;IAC9B,MAAM;IACN,aAAa;IACb,QAAQC,EAAE,MAAM,CAAC;QACf,MAAMA,EAAE,MAAM;IAChB;AACF;AAGO,MAAMC,2BAA2B;IACtC,MAAM;IACN,aAAa;IACb,QAAQD,EAAE,MAAM,CAAC;QACf,OAAOA,EAAE,MAAM;IACjB;AACF;AAEO,MAAME,sBAAsB;IACjC,MAAM;IACN,aAAa;IACb,QAAQF,EAAE,MAAM,CAAC;QACf,KAAKA,EAAE,MAAM;IACf;AACF;AAEO,MAAMG,qBAAqB;IAChC,MAAM;IACN,aAAa;IACb,QAAQH,EAAE,MAAM,CAAC,CAAC;AACpB;AAEO,MAAMI,2BAA2B;IACtC,MAAM;IACN,aAAa;IACb,QAAQJ,EAAE,MAAM,CAAC;QACf,MAAMA,EAAE,MAAM,GAAG,QAAQ;QACzB,OAAOA,EAAE,MAAM;QACf,OAAOA,EAAE,MAAM,GAAG,QAAQ;IAC5B;AACF;AAEO,MAAMK,wBAAwB;IACnC,MAAM;IACN,aAAa;IACb,QAAQL,EAAE,MAAM,CAAC;QACf,MAAMA,EAAE,MAAM,GAAG,QAAQ;QACzB,OAAOA,EAAE,MAAM;QACf,MAAMA,EAAE,MAAM;QACd,OAAOA,EAAE,MAAM,GAAG,QAAQ;IAC5B;AACF;AAGO,MAAMM,wBAAwB;IACnC,MAAM;IACN,aAAa;IACb,QAAQN,EAAE,MAAM,CAAC;QACf,QAAQA,EAAE,MAAM;IAClB;AACF;AAEO,MA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