|
| 1 | +import { GoToPageResponse, UrlResponse, GetMarkdownResponse, HtmlReceived, ExtractTextResponse, GetContentResponse } from '@codebolt/types'; |
| 2 | +/** |
| 3 | + * A module for interacting with a browser through WebSockets. |
| 4 | + */ |
| 5 | +declare const cbbrowser: { |
| 6 | + /** |
| 7 | + * Opens a new page in the browser. |
| 8 | + */ |
| 9 | + newPage: () => Promise<unknown>; |
| 10 | + /** |
| 11 | + * Retrieves the current URL of the browser's active page. |
| 12 | + * @returns {Promise<UrlResponse>} A promise that resolves with the URL. |
| 13 | + */ |
| 14 | + getUrl: () => Promise<UrlResponse>; |
| 15 | + /** |
| 16 | + * Navigates to a specified URL. |
| 17 | + * @param {string} url - The URL to navigate to. |
| 18 | + * @returns {Promise<GoToPageResponse>} A promise that resolves when navigation is complete. |
| 19 | + */ |
| 20 | + goToPage: (url: string) => Promise<GoToPageResponse>; |
| 21 | + /** |
| 22 | + * Takes a screenshot of the current page. |
| 23 | + */ |
| 24 | + screenshot: () => Promise<unknown>; |
| 25 | + /** |
| 26 | + * Retrieves the HTML content of the current page. |
| 27 | + * @returns {Promise<HtmlReceived>} A promise that resolves with the HTML content. |
| 28 | + */ |
| 29 | + getHTML: () => Promise<HtmlReceived>; |
| 30 | + /** |
| 31 | + * Retrieves the Markdown content of the current page. |
| 32 | + * @returns {Promise<GetMarkdownResponse>} A promise that resolves with the Markdown content. |
| 33 | + */ |
| 34 | + getMarkdown: () => Promise<GetMarkdownResponse>; |
| 35 | + /** |
| 36 | + * Retrieves the PDF content of the current page. |
| 37 | + * |
| 38 | + */ |
| 39 | + getPDF: () => void; |
| 40 | + /** |
| 41 | + * Converts the PDF content of the current page to text. |
| 42 | + */ |
| 43 | + pdfToText: () => void; |
| 44 | + /** |
| 45 | + * Retrieves the content of the current page. |
| 46 | + * @returns {Promise<GetContentResponse>} A promise that resolves with the content. |
| 47 | + */ |
| 48 | + getContent: () => Promise<GetContentResponse>; |
| 49 | + /** |
| 50 | + * Retrieves the snapshot of the current page. |
| 51 | + * @returns {Promise<GetContentResponse>} A promise that resolves with the content. |
| 52 | + */ |
| 53 | + getSnapShot: () => Promise<any>; |
| 54 | + /** |
| 55 | + * Retrieves browser info like height width scrollx scrolly of the current page. |
| 56 | + * @returns {Promise<GetContentResponse>} A promise that resolves with the content. |
| 57 | + */ |
| 58 | + getBrowserInfo: () => Promise<any>; |
| 59 | + /** |
| 60 | + * Extracts text from the current page. |
| 61 | + * @returns {Promise<ExtractTextResponse>} A promise that resolves with the extracted text. |
| 62 | + * |
| 63 | + */ |
| 64 | + extractText: () => Promise<ExtractTextResponse>; |
| 65 | + /** |
| 66 | + * Closes the current page. |
| 67 | + */ |
| 68 | + close: () => void; |
| 69 | + /** |
| 70 | + * Scrolls the current page in a specified direction by a specified number of pixels. |
| 71 | + * @param {string} direction - The direction to scroll. |
| 72 | + * @param {string} pixels - The number of pixels to scroll. |
| 73 | + * @returns {Promise<any>} A promise that resolves when the scroll action is complete. |
| 74 | + */ |
| 75 | + scroll: (direction: string, pixels: string) => Promise<unknown>; |
| 76 | + /** |
| 77 | + * Types text into a specified element on the page. |
| 78 | + * @param {string} elementid - The ID of the element to type into. |
| 79 | + * @param {string} text - The text to type. |
| 80 | + * @returns {Promise<any>} A promise that resolves when the typing action is complete. |
| 81 | + */ |
| 82 | + type: (elementid: string, text: string) => Promise<unknown>; |
| 83 | + /** |
| 84 | + * Clicks on a specified element on the page. |
| 85 | + * @param {string} elementid - The ID of the element to click. |
| 86 | + * @returns {Promise<any>} A promise that resolves when the click action is complete. |
| 87 | + */ |
| 88 | + click: (elementid: string) => Promise<unknown>; |
| 89 | + /** |
| 90 | + * Simulates the Enter key press on the current page. |
| 91 | + * @returns {Promise<any>} A promise that resolves when the Enter action is complete. |
| 92 | + */ |
| 93 | + enter: () => Promise<unknown>; |
| 94 | + /** |
| 95 | + * Performs a search on the current page using a specified query. |
| 96 | + * @param {string} elementid - The ID of the element to perform the search in. |
| 97 | + * @param {string} query - The search query. |
| 98 | + * @returns {Promise<any>} A promise that resolves with the search results. |
| 99 | + */ |
| 100 | + search: (elementid: string, query: string) => Promise<unknown>; |
| 101 | +}; |
| 102 | +export default cbbrowser; |
| 103 | +/*** |
| 104 | +
|
| 105 | +start_browser(objective: string, url: string, previous_command: string, browser_content: string) { |
| 106 | + cbbrowser.newPage(); |
| 107 | +} |
| 108 | + */ |
0 commit comments