Skip to content

Commit ef1f3e3

Browse files
committed
cbstate and chat, add explaination and example
1 parent 6f53603 commit ef1f3e3

24 files changed

+156
-150
lines changed

docs/api/browser/click.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ data:
2121
<CBBaseInfo/>
2222
<CBParameters/>
2323

24-
### Examples
24+
### Examples
2525

26-
```js
26+
```js
2727
// Using Codebolt's browser API, you can interact with elements on a web page.
2828
// For example, let's say there's a button with the ID "test" on the page.
2929
// You can use Codebolt's browser API to click on this button.
@@ -42,12 +42,11 @@ data:
4242
// Putting it all together:
4343
codebolt.browser.click("#test");
4444

45-
```
45+
```
4646

47-
### Explaination
47+
### Explaination
4848

4949
[Browser](../../concepts/browser) Click function is used to click on the browser by selecting specific elementId.
5050

51-
A browser is a used to access and display web pages on the internet. When a browser is open, users can interact with various elements on web pages, such as buttons, links, forms, and images.
51+
A browser is a used to access and display web pages. When a browser is open, users can interact with various elements on web pages, such as buttons, links, forms, and images.
5252

53-
One common action in web development and automation is clicking on specific elements within a web page. This action is typically performed by selecting the element using its unique identifier, often referred to as the element ID, and then triggering a click event on that element.

docs/api/browser/close.md

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,8 @@ data:
3030
```
3131
### Explaination
3232

33-
Navigation: The script first opens a browser window/tab and navigates to the specified URL using codebolt.browser.goToPage(url). In this example, it navigates to "https://example.com".
34-
35-
Testing: Once on the web page, the script performs various tests to validate the functionality of the application.
36-
37-
Closing the Page: After completing the tests on the current page, the codebolt.browser.close() function is used to close the current page/tab. This action is useful for cleaning up after testing is complete and for ensuring that the browser environment is left in a desired state.
33+
The script first opens a browser window/tab and navigates to the specified URL using codebolt.browser.goToPage(url). In this example, it navigates to "https://example.com".
3834

35+
After completing the task on the current page, the codebolt.browser.close() function is used to close the current page.
3936

4037

docs/api/browser/enter.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,4 @@ await codebolt.browser.enter();
3838

3939
### Explanation:
4040

41-
Navigation: The script navigates to the sign-in page of the website.
42-
43-
Entering Data: Using codebolt.browser.type(), the script fills in the username and password fields with the appropriate credentials.
44-
45-
Simulating Enter Key Press: Instead of clicking a submit button, the script uses codebolt.browser.enter() to simulate pressing the Enter key. This action triggers the default submission behavior of the form, submitting the entered username and password for authentication.
41+
The codebolt.browser.enter() function is used to submit the form. Suppose there is a login form and I want to automatically submit it using a script. Then, we want to send text to a username field on the login page using the type() function, which has two parameters: eventid and "value". After inputting all the information, we call enter() to submit the form.

docs/api/browser/extractText.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,5 @@ console.log(pageText);
3232

3333
### Explaination:
3434

35-
Navigation: The script starts by navigating to the news website's homepage using codebolt.browser.goToPage("https://example-news.com").
35+
If we want to extract all the text on the webpage, we can use the codebolt.browser.extractText() function. This function returns the text, which we can store in a variable and use.
3636

37-
Text Extraction: Once the page has loaded, the script uses codebolt.browser.extractText() to extract all the text content from the current page. This function captures all textual information present on the web page, including headings, paragraphs, and any other text elements.
38-
39-
Processing the Extracted Text: The extracted text is stored in the variable pageText. In this example, the script simply logs the extracted text to the console using console.log(pageText). In a real-world scenario, you might further process this text to analyze news headlines, summarize content, or extract specific information.

docs/api/browser/getContent.md

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -16,28 +16,7 @@ data:
1616
<CBBaseInfo/>
1717
<CBParameters/>
1818

19-
### Examples:
2019

21-
```js
20+
### Status
21+
Working Progress...
2222

23-
// Navigate to the blog page
24-
await codebolt.browser.goToPage("https://example-blog.com/article")
25-
26-
// Retrieve the HTML content of the current page
27-
const pageContent = await codebolt.browser.getContent()
28-
29-
// Log the retrieved content to the console (or save it as needed)
30-
console.log(pageContent)
31-
32-
```
33-
34-
### Explanation:
35-
The codebolt.browser.getContent() function is used to retrieve the entire HTML content of the current web page. This function is particularly useful in web scraping, data extraction, and automated testing scenarios where you need to capture the full structure and content of a web page for further processing or analysis.
36-
37-
### Explaination of the code:
38-
39-
Navigation: The script begins by navigating to the specific blog page using codebolt.browser.goToPage("https://example-blog.com/article").
40-
41-
Content Retrieval: Once the page has fully loaded, the script uses codebolt.browser.getContent() to retrieve the complete HTML content of the current page. This includes all HTML tags, embedded styles, scripts, and textual content.
42-
43-
Processing the Retrieved Content: The retrieved HTML content is stored in the variable pageContent. In this example, the script logs the HTML content to the console using console.log(pageContent). In a real-world scenario, you might save this content to a file or a database for later analysis or offline access.

docs/api/browser/getHTML.md

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ data:
1818
<CBBaseInfo/>
1919
<CBParameters/>
2020

21+
2122
### Examples :
2223

2324
```js
@@ -37,11 +38,3 @@ console.log(htmlContent)
3738

3839
The codebolt.browser.getHTML() function is used to retrieve the HTML content of the current web page. This function is particularly useful for web scraping, data extraction, and automated testing scenarios where you need to capture the entire HTML structure and content of a web page for further analysis or processing.
3940

40-
41-
### Explaination of the code:
42-
43-
Navigation: The script begins by navigating to the specific blog page using codebolt.browser.goToPage("https://example-blog.com/article").
44-
45-
HTML Content Retrieval: Once the page has fully loaded, the script uses codebolt.browser.getHTML() to retrieve the complete HTML content of the current page. The function returns a promise that resolves to the HTML content, which includes all HTML tags, embedded styles, scripts, and textual content.
46-
47-
Processing the Retrieved HTML: The retrieved HTML content is stored in the variable htmlContent. In this example, the script logs the HTML content to the console using console.log(htmlContent). Additionally, the example demonstrates how to save the HTML content to a file using Node.js's file system module (fs), which writes the HTML content to a file named product-page.html.

docs/api/browser/getMarkdown.md

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,6 @@ console.log(markdownContent);
3939
The codebolt.browser.getMarkdown() function is used to retrieve the Markdown representation of the content on the current web page. This function is particularly useful for converting HTML content into a more readable and editable Markdown format, which is widely used in documentation, blogging, and content management systems.
4040

4141

42-
### Explanation of the Code
43-
44-
Navigation: The script starts by navigating to a specific blog post page using codebolt.browser.goToPage("https://example-blog.com/post/12345").
45-
46-
47-
Markdown Content Retrieval: Once the page has fully loaded, the script uses codebolt.browser.getMarkdown() to retrieve the content of the current page in Markdown format. This function converts the HTML content into Markdown, capturing the structure and text in a more readable format.
48-
49-
50-
Processing the Retrieved Markdown: The retrieved Markdown content is stored in the variable markdownContent. In this example, the script logs the Markdown content to the console using console.log(markdownContent). Additionally, the example demonstrates how to save the Markdown content to a file using Node.js's file system module (fs), which writes the content to a file named post.md.
51-
5242

5343

5444

docs/api/browser/getPDF.md

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -16,32 +16,7 @@ data:
1616
<CBBaseInfo/>
1717
<CBParameters/>
1818

19-
### Examples:
2019

21-
```js
20+
### Status
21+
Working Progress...
2222

23-
// Navigate to the news article page
24-
await codebolt.browser.goToPage("https://example-news.com/article/12345");
25-
26-
// Retrieve the PDF content of the current page
27-
const pdfContent = await codebolt.browser.getPDF();
28-
29-
// Log a message to indicate the PDF has been retrieved (optional)
30-
console.log("PDF content retrieved successfully");
31-
32-
```
33-
34-
35-
### Explanation
36-
37-
The codebolt.browser.getPDF() function is used to retrieve a PDF representation of the current web page. This function is particularly useful for generating PDF versions of web pages for documentation, archiving, or sharing purposes. It captures the visual layout and content of the web page as a PDF file.
38-
39-
40-
41-
### Explanation of the Code
42-
43-
Navigation: The script starts by navigating to a specific news article page using codebolt.browser.goToPage("https://example-news.com/article/12345").
44-
45-
PDF Content Retrieval: Once the page has fully loaded, the script uses codebolt.browser.getPDF() to retrieve the content of the current page as a PDF. This function captures the entire visual layout and content of the page, creating a PDF file that mirrors the web page's appearance.
46-
47-
Processing the Retrieved PDF: The retrieved PDF content is stored in the variable pdfContent. In this example, the script logs a message to the console to indicate that the PDF has been successfully retrieved.

docs/api/browser/getUrl.md

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,4 @@ console.log(`Current URL: ${currentUrl}`);
3434

3535
### Explanation
3636

37-
The codebolt.browser.getUrl() function is used to retrieve the URL of the current active page in the browser. This function is useful in web automation, testing, and navigation scenarios where you need to confirm or log the URL of the page that the browser is currently displaying.
38-
39-
40-
### Explanation of the Code
41-
Navigation to Home Page: The script begins by navigating to the home page of the website using codebolt.browser.goToPage("https://example-website.com").
42-
43-
Retrieving the Current URL: After the page has loaded, the script uses codebolt.browser.getUrl() to retrieve the current URL of the browser's active page. The retrieved URL is stored in the variable currentUrl.
44-
37+
The codebolt.browser.getUrl() function is used to retrieve the URL of the current web page in the browser. This function returns the url, which we can store in a variable and use.

docs/api/browser/pdfToText.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,12 @@ data:
1616
<CBBaseInfo/>
1717
<CBParameters/>
1818

19-
### Examples:
19+
20+
### Status
21+
22+
Working Progress...
23+
24+
<!-- ### Examples:
2025
2126
```js
2227
@@ -29,4 +34,4 @@ codebolt.browser.pdfToText();
2934
```
3035
3136
### Explanation
32-
The codebolt.browser.pdfToText() function is used to convert the PDF content of the current page into text format. This function is particularly useful when dealing with PDF documents in web automation or data extraction scenarios where you need to extract textual information from PDF files.
37+
The codebolt.browser.pdfToText() function is used to convert the PDF content of the current page into text format. This function is particularly useful when dealing with PDF documents in web automation or data extraction scenarios where you need to extract textual information from PDF files. -->

docs/api/browser/screenshot.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@ data:
1616
<CBBaseInfo/>
1717
<CBParameters/>
1818

19-
### Examples:
19+
### Status
20+
21+
Working Progress...
22+
23+
<!-- ### Examples:
2024
2125
```js
2226
@@ -36,4 +40,4 @@ The codebolt.browser.screenshot() function is used to capture a screenshot of th
3640
3741
Navigation: The script navigates to the desired web page using codebolt.browser.goToPage("https://example.com").
3842
39-
Screenshot Capture: Once the page has loaded, the script calls codebolt.browser.screenshot() to capture a screenshot of the current page. This function takes a snapshot of the entire visible area of the web page, including all visible elements and content.
43+
Screenshot Capture: Once the page has loaded, the script calls codebolt.browser.screenshot() to capture a screenshot of the current page. This function takes a snapshot of the entire visible area of the web page, including all visible elements and content. -->

docs/api/browser/scroll.md

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,9 @@ data:
3333
// Scroll down the page by 500 pixels
3434
await codebolt.browser.scroll("down", "500");
3535

36-
// Scroll up the page by 200 pixels
37-
await codebolt.browser.scroll("up", "200");
3836

3937
```
4038

4139
### Explanation:
4240

4341
The codebolt.browser.scroll(direction: string, pixels: string) function is used to scroll the current page in a specified direction by a specified number of pixels. This function is useful for automating scrolling actions on a web page, such as navigating through lengthy content or bringing specific elements into view.
44-
45-
### Explanation of the code:
46-
47-
Scrolling Down: The script calls codebolt.browser.scroll("down", "500") to scroll down the page by 500 pixels. This action brings more content into view, loading additional elements if the page supports dynamic loading or infinite scrolling.
48-
49-
Scrolling Up: Next, the script calls codebolt.browser.scroll("up", "200") to scroll up the page by 200 pixels. This action moves the viewport upward, potentially revealing content that was previously out of view.

docs/api/browser/search.md

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,4 @@ console.log(searchResults);
3939

4040
### Explanation:
4141

42-
The codebolt.browser.search(elementid: string, query: string) function is used to perform a search on the current page using a specified query. This function allows automation scripts to search for specific content or elements within the page, facilitating tasks such as data extraction, validation, or interaction.
43-
44-
45-
### Explanation of the code:
46-
Performing a Search: The script calls codebolt.browser.search("searchBox", "example query") to perform a search using the search box element with the ID "searchBox" and the query "example query". The function returns a Promise that resolves with the search results.
47-
48-
Processing Search Results: Once the search results are obtained, the script can process them as needed. This may include validating the presence of specific search results, extracting data from the results, or performing further actions based on the search outcome.
42+
The codebolt.browser.search(elementid: string, query: string) function is used to perform a search on the current page using a specified query. This function allows automation scripts to search for specific content or elements within the page.

docs/api/browser/type.md

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ data:
2525
<CBParameters/>
2626

2727

28-
29-
3028
### Examples:
3129

3230
```js
@@ -43,13 +41,4 @@ await codebolt.browser.type("password", "password123");
4341

4442
### Explanation
4543

46-
47-
The codebolt.browser.type(elementid: string, text: string) function is used to simulate typing text into a specified element on the current web page. This function is essential for automating form submissions, text input fields, or any interaction that involves entering textual data.
48-
49-
50-
### Explanation of the code
51-
52-
53-
Typing into Input Fields: The script uses codebolt.browser.type(elementid, text) to simulate typing text into specific input fields on the web page. Each call to codebolt.browser.type() specifies the ID of the target element (e.g., input field) and the text to be entered.
54-
55-
Form Filling: In this example, the script fills out a registration form by typing text into input fields for name, email, and password. This simulates user input and allows the automation script to interact with the web page as if a user were manually entering the information.
44+
The codebolt.browser.type(elementid: string, text: string) function is used to put text into a specified element on the current web page. the type() have two parameter one is elementid and second is value. we can put the value automatic using this type() function.

docs/api/cbstate/addToAgentState.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,20 @@ data:
2222
link: addToAgentState.md
2323
---
2424
<CBBaseInfo/>
25-
<CBParameters/>
25+
<CBParameters/>
26+
27+
### Examples:
28+
```js
29+
// Add a user ID to the agent's state
30+
await codebolt.cbstate.addToAgentState("userID", "12345");
31+
32+
// Add a configuration setting to the agent's state
33+
await codebolt.cbstate.addToAgentState("configSetting", "darkModeEnabled");
34+
35+
```
36+
37+
### Explanation
38+
The codebolt.cbstate.addToAgentState(key: string, value: string) function is used to set key-value pair to the current agent's state. This function allows you to store state information.
39+
40+
41+

docs/api/cbstate/getAgentState.md

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,26 @@ data:
1616
link: getAgentState.md
1717
---
1818
<CBBaseInfo/>
19-
<CBParameters/>
19+
<CBParameters/>
20+
21+
22+
### Examples:
23+
24+
```js
25+
26+
// Retrieve the current state of the agent
27+
const agentState = await codebolt.cbstate.getAgentState();
28+
29+
// Access specific state information
30+
const userID = agentState.userID;
31+
const configSetting = agentState.configSetting;
32+
33+
// Log the retrieved state information
34+
console.log(`User ID: ${userID}`);
35+
console.log(`Configuration Setting: ${configSetting}`);
36+
37+
```
38+
39+
### Explanation
40+
41+
The codebolt.cbstate.getAgentState() function is used to retrieve the current state of the agent. If we are currently set in the agent's state, then we can access this value using getAgentState()

docs/api/cbstate/getApplicationState.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,24 @@ data:
1616
link: getApplicationState.md
1717
---
1818
<CBBaseInfo/>
19-
<CBParameters/>
19+
<CBParameters/>
20+
21+
### Examples
22+
23+
```js
24+
// Retrieve the current application state
25+
const appState = await codebolt.cbstate.getApplicationState();
26+
27+
// Access specific state information
28+
const appVersion = appState.appVersion;
29+
const featureToggle = appState.featureToggle;
30+
31+
// Log the retrieved state information
32+
console.log(`Application Version: ${appVersion}`);
33+
console.log(`Feature Toggle: ${featureToggle}`);
34+
35+
```
36+
37+
### Explanation
38+
39+
The codebolt.cbstate.getApplicationState() function is used to get all the state information that store in the entire agent's state. This function is used to access shared state information relevant to the entire application.

docs/api/chat/eventEmitter.md

Lines changed: 0 additions & 16 deletions
This file was deleted.

0 commit comments

Comments
 (0)