Skip to content

Commit 34c9a12

Browse files
docs response format updated
1 parent b4a3dd2 commit 34c9a12

File tree

12 files changed

+239
-109
lines changed

12 files changed

+239
-109
lines changed

docs/api/apiaccess/agent/findAgent.md

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,25 @@ data:
3535

3636
### Response Structure
3737

38-
The method returns a Promise that resolves to a `FindAgentByTaskResponse` object with:
39-
- `type`: The response type, always "findAgentByTaskResponse"
40-
- `agents`: Array of found agents, each containing:
41-
- `type`: The agent type, typically "function"
42-
- `function`: Agent function details including:
43-
- `name`: The name/identifier of the agent
44-
- `description`: Detailed description of the agent's capabilities
45-
- `parameters`: Parameter specification object with type, properties, required fields, and additionalProperties flag
46-
- `strict`: Boolean indicating whether the agent enforces strict parameter validation
38+
The method returns a Promise that resolves to a `FindAgentByTaskResponse` object with the following properties:
39+
40+
**Response Properties:**
41+
- `type`: Always "findAgentByTaskResponse"
42+
- `agents`: Optional array of agent objects containing found agents
43+
- `success`: Optional boolean indicating if the operation was successful
44+
- `message`: Optional string with additional information
45+
- `error`: Optional string containing error details if the operation failed
46+
- `messageId`: Optional unique identifier for the message
47+
- `threadId`: Optional thread identifier
48+
49+
**Agent Structure:**
50+
Each agent in the `agents` array has the following structure:
51+
- `type`: Always "function"
52+
- `function`: Agent function details including:
53+
- `name`: The name/identifier of the agent
54+
- `description`: Detailed description of the agent's capabilities
55+
- `parameters`: Parameter specification object with type, properties, required fields, and additionalProperties flag
56+
- `strict`: Optional boolean indicating whether the agent enforces strict parameter validation
4757

4858
### Examples
4959

docs/api/apiaccess/agent/getAgentsDetail.md

Lines changed: 33 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,28 @@ data:
2323

2424
### Response Structure
2525

26-
The method returns a Promise that resolves to an `AgentsDetailResponse` object with:
27-
- `type`: "agentsDetailResponse"
28-
- `messageId`: Unique message identifier string
29-
- `threadId`: Thread identifier string
30-
- `success`: Boolean indicating if the request was successful
31-
- `payload`: Object containing the actual data:
32-
- `agents`: Array of detailed agent objects, each containing:
33-
- `id`: Unique agent identifier
34-
- `name`: Agent display name
35-
- `description`: Agent description text
36-
- `capabilities`: Array of agent capabilities (may be empty)
37-
- `isLocal`: Boolean indicating if the agent is local
38-
- `version`: Version string of the agent
39-
- `status`: Numeric status code (1 = active)
40-
- `unique_id`: Unique identifier string for the agent
26+
The method returns a Promise that resolves to an `AgentsDetailResponse` object with the following properties:
27+
28+
**Response Properties:**
29+
- `type`: Always "agentsDetailResponse"
30+
- `payload`: Optional object containing the actual agent details data
31+
- `agents`: Array of agent detail objects with detailed agent information
32+
- `success`: Optional boolean indicating if the operation was successful
33+
- `message`: Optional string with additional information
34+
- `error`: Optional string containing error details if the operation failed
35+
- `messageId`: Optional unique identifier for the message
36+
- `threadId`: Optional thread identifier
37+
38+
**Agent Detail Structure:**
39+
Each agent in the `payload.agents` array has the following structure:
40+
- `id`: Unique agent identifier
41+
- `name`: Agent display name
42+
- `description`: Agent description text
43+
- `capabilities`: Optional array of agent capabilities
44+
- `isLocal`: Boolean indicating if the agent is local
45+
- `version`: Version string of the agent
46+
- `status`: String status of the agent
47+
- `unique_id`: Unique identifier string for the agent
4148

4249
### Examples
4350

@@ -54,8 +61,9 @@ if (agentsList?.agents && agentsList.agents.length > 0) {
5461
// Get detailed information for the selected agents
5562
const agentsDetailResult = await codebolt.agent.getAgentsDetail(agentIds);
5663
console.log('Agent details result type:', agentsDetailResult?.type); // "agentsDetailResponse"
57-
console.log('Message ID:', agentsDetailResult?.messageId);
5864
console.log('Success:', agentsDetailResult?.success);
65+
console.log('Message ID:', agentsDetailResult?.messageId);
66+
console.log('Thread ID:', agentsDetailResult?.threadId);
5967
console.log('Details count:', agentsDetailResult?.payload?.agents?.length || 0);
6068
console.log('Agent details:', agentsDetailResult);
6169

@@ -64,15 +72,20 @@ if (agentsList?.agents && agentsList.agents.length > 0) {
6472
const firstAgent = agentsDetailResult.payload.agents[0];
6573
console.log('First agent ID:', firstAgent.id);
6674
console.log('First agent name:', firstAgent.name);
75+
console.log('First agent description:', firstAgent.description);
6776
console.log('First agent version:', firstAgent.version);
6877
console.log('First agent is local:', firstAgent.isLocal);
78+
console.log('First agent status:', firstAgent.status);
79+
console.log('First agent unique_id:', firstAgent.unique_id);
80+
console.log('First agent capabilities:', firstAgent.capabilities);
6981
}
7082
}
7183

7284
// Example 2: Get details for all agents (using empty array)
7385
const allAgentDetails = await codebolt.agent.getAgentsDetail([]);
7486
console.log('All agent details:', allAgentDetails);
7587
console.log('Success:', allAgentDetails?.success);
88+
console.log('Type:', allAgentDetails?.type);
7689
console.log('Total agents:', allAgentDetails?.payload?.agents?.length || 0);
7790

7891
// Display each agent's key information
@@ -81,15 +94,18 @@ if (allAgentDetails?.payload?.agents) {
8194
console.log(`Agent ${index + 1}:`);
8295
console.log(` - ID: ${agent.id}`);
8396
console.log(` - Name: ${agent.name}`);
97+
console.log(` - Description: ${agent.description}`);
8498
console.log(` - Version: ${agent.version}`);
8599
console.log(` - Status: ${agent.status}`);
86100
console.log(` - Is Local: ${agent.isLocal}`);
87101
console.log(` - Unique ID: ${agent.unique_id}`);
102+
console.log(` - Capabilities: ${agent.capabilities || 'None'}`);
88103
});
89104
}
90105
```
91106
92107
### Usage Notes
93108
94109
- Agent IDs can be obtained from the `getAgentsList()` method using `agent.function?.name`
95-
- Pass an empty array `[]` to get details for all available agents
110+
- Pass an empty array `[]` to get details for all available agents
111+
- The response includes both basic WebSocket response properties and detailed agent information in the `payload` field

docs/api/apiaccess/agent/getAgentsList.md

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ cbparameters:
1212
description: A promise that resolves with the list of agents
1313
typeArgs:
1414
- type: reference
15-
name: AgentsListResponse
15+
name: ListAgentsResponse
1616
data:
1717
name: getAgentsList
1818
category: agent
@@ -23,9 +23,25 @@ data:
2323

2424
### Response Structure
2525

26-
The method returns a Promise that resolves to an `AgentsListResponse` object with:
27-
- `type`: Response type identifier
28-
- `agents`: Array of agent objects containing agent information
26+
The method returns a Promise that resolves to a `ListAgentsResponse` object with the following properties:
27+
28+
**Response Properties:**
29+
- `type`: Always "listAgentsResponse"
30+
- `agents`: Optional array of agent objects containing agent information
31+
- `success`: Optional boolean indicating if the operation was successful
32+
- `message`: Optional string with additional information
33+
- `error`: Optional string containing error details if the operation failed
34+
- `messageId`: Optional unique identifier for the message
35+
- `threadId`: Optional thread identifier
36+
37+
**Agent Structure:**
38+
Each agent in the `agents` array has the following structure:
39+
- `type`: Always "function"
40+
- `function`: Agent function details including:
41+
- `name`: The name/identifier of the agent
42+
- `description`: Detailed description of the agent's capabilities
43+
- `parameters`: Parameter specification object with type, properties, required fields, and additionalProperties flag
44+
- `strict`: Optional boolean indicating whether the agent enforces strict parameter validation
2945

3046
### Examples
3147

@@ -34,6 +50,7 @@ The method returns a Promise that resolves to an `AgentsListResponse` object wit
3450
const downloadedAgents = await codebolt.agent.getAgentsList('downloaded');
3551
console.log('✅ Agents list result:', downloadedAgents);
3652
console.log(' - Type:', downloadedAgents?.type);
53+
console.log(' - Success:', downloadedAgents?.success);
3754
console.log(' - Agents count:', downloadedAgents?.agents?.length || 0);
3855
if (downloadedAgents?.agents?.length > 0) {
3956
console.log(' - First agent:', downloadedAgents.agents[0]);
@@ -46,12 +63,14 @@ if (downloadedAgents?.agents?.length > 0) {
4663
const allAgents = await codebolt.agent.getAgentsList('all');
4764
console.log('✅ All agents result:', allAgents);
4865
console.log(' - Type:', allAgents?.type);
66+
console.log(' - Success:', allAgents?.success);
4967
console.log(' - Total agents count:', allAgents?.agents?.length || 0);
5068

5169
// Example 3: Getting list of local agents
5270
const localAgents = await codebolt.agent.getAgentsList('local');
5371
console.log('✅ Local agents result:', localAgents);
5472
console.log(' - Type:', localAgents?.type);
73+
console.log(' - Success:', localAgents?.success);
5574
console.log(' - Local agents count:', localAgents?.agents?.length || 0);
5675
```
5776

docs/api/apiaccess/agent/startAgent.md

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ cbparameters:
1515
description: A promise that resolves when the agent has been successfully started.
1616
typeArgs:
1717
- type: reference
18-
name: StartAgentResponse
18+
name: TaskCompletionResponse
1919
data:
2020
name: startAgent
2121
category: agent
@@ -26,10 +26,19 @@ data:
2626

2727
### Response Structure
2828

29-
The method returns a Promise that resolves to a `StartAgentResponse` object with:
30-
- `status`: Status of the agent start operation
31-
- `type`: Response type identifier
32-
- Additional agent-specific response data
29+
The method returns a Promise that resolves to a `TaskCompletionResponse` object with the following properties:
30+
31+
**Response Properties:**
32+
- `type`: Always "taskCompletionResponse"
33+
- `from`: Optional string indicating the source of the response
34+
- `agentId`: Optional string containing the ID of the agent that was started
35+
- `task`: Optional string containing the task that was assigned to the agent
36+
- `result`: Optional field containing any result data from the agent start operation
37+
- `success`: Optional boolean indicating if the operation was successful
38+
- `message`: Optional string with additional information
39+
- `error`: Optional string containing error details if the operation failed
40+
- `messageId`: Optional unique identifier for the message
41+
- `threadId`: Optional thread identifier
3342

3443
### Examples
3544

@@ -60,9 +69,10 @@ try {
6069
const startAgentResult = await codebolt.agent.startAgent("act", startTask);
6170

6271
console.log('✅ Start agent result:', startAgentResult);
63-
console.log(' - Agent ID:', agentId);
64-
console.log(' - Task:', startTask);
65-
console.log(' - Status:', startAgentResult?.status);
72+
console.log(' - Agent ID:', startAgentResult?.agentId);
73+
console.log(' - Task:', startAgentResult?.task);
74+
console.log(' - Success:', startAgentResult?.success);
75+
console.log(' - Result:', startAgentResult?.result);
6676
console.log(' - Response type:', startAgentResult?.type);
6777
} else {
6878
console.log('⚠️ No agents found to start');
@@ -75,7 +85,10 @@ try {
7585
try {
7686
const startResponse = await codebolt.agent.startAgent("act", "Help me with data analysis");
7787
console.log('Agent started successfully:', startResponse);
78-
console.log('Status:', startResponse?.status);
88+
console.log('Agent ID:', startResponse?.agentId);
89+
console.log('Task:', startResponse?.task);
90+
console.log('Success:', startResponse?.success);
91+
console.log('Result:', startResponse?.result);
7992
console.log('Type:', startResponse?.type);
8093
} catch (error) {
8194
console.error('Failed to start agent:', error.message);

docs/api/apiaccess/browser/getContent.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,21 @@ data:
1616
<CBBaseInfo/>
1717
<CBParameters/>
1818

19+
### Response Structure
20+
21+
The method returns a Promise that resolves to a `GetContentResponse` object with the following properties:
22+
23+
**Response Properties:**
24+
- `type`: Always "getContentResponse"
25+
- `content`: Optional string containing the page content
26+
- `html`: Optional string containing the HTML content
27+
- `text`: Optional string containing the text content
28+
- `success`: Optional boolean indicating if the operation was successful
29+
- `message`: Optional string with additional information
30+
- `error`: Optional string containing error details if the operation failed
31+
- `messageId`: Optional unique identifier for the message
32+
- `threadId`: Optional thread identifier
33+
1934
### Example
2035

2136
```js
@@ -29,7 +44,9 @@ await new Promise(resolve => setTimeout(resolve, 2000));
2944
const contentResult = await codebolt.browser.getContent();
3045
console.log('✅ Content retrieved:', {
3146
success: contentResult.success,
32-
contentLength: contentResult.content ? contentResult.content.length : 0
47+
contentLength: contentResult.content ? contentResult.content.length : 0,
48+
hasHtml: !!contentResult.html,
49+
hasText: !!contentResult.text
3350
});
3451

3552
// Access the actual content

docs/api/apiaccess/browser/getUrl.md

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -39,21 +39,17 @@ console.log('✅ URL after navigation:', currentUrl);
3939

4040
### Response Structure
4141

42-
```js
43-
{
44-
event: 'browserActionResponse',
45-
eventId: 'getUrl_1750401431606',
46-
payload: {
47-
content: '"https://www.google.com/"',
48-
viewport: {
49-
width: 767,
50-
height: 577
51-
},
52-
currentUrl: 'https://www.google.com/'
53-
},
54-
type: 'getUrlResponse'
55-
}
56-
```
42+
The method returns a Promise that resolves to a `UrlResponse` object with the following properties:
43+
44+
**Response Properties:**
45+
- `type`: Always "urlResponse"
46+
- `url`: Optional string containing the URL
47+
- `currentUrl`: Optional string containing the current URL
48+
- `success`: Optional boolean indicating if the operation was successful
49+
- `message`: Optional string with additional information
50+
- `error`: Optional string containing error details if the operation failed
51+
- `messageId`: Optional unique identifier for the message
52+
- `threadId`: Optional thread identifier
5753

5854
### Explanation
5955

docs/api/apiaccess/browser/goToPage.md

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -44,21 +44,16 @@ await codebolt.browser.goToPage('https://github.com');
4444

4545
### Response Structure
4646

47-
```js
48-
{
49-
event: 'browserActionResponse',
50-
eventId: 'goToPage_1750401433630',
51-
payload: {
52-
content: '"Navigated to https://example.com"',
53-
viewport: {
54-
width: 767,
55-
height: 577
56-
},
57-
currentUrl: 'https://example.com'
58-
},
59-
type: 'goToPageResponse'
60-
}
61-
```
47+
The method returns a Promise that resolves to a `GoToPageResponse` object with the following properties:
48+
49+
**Response Properties:**
50+
- `type`: Always "goToPageResponse"
51+
- `url`: Optional string containing the URL that was navigated to
52+
- `success`: Optional boolean indicating if the navigation was successful
53+
- `message`: Optional string with additional information
54+
- `error`: Optional string containing error details if the operation failed
55+
- `messageId`: Optional unique identifier for the message
56+
- `threadId`: Optional thread identifier
6257

6358
### Explanation
6459

docs/api/apiaccess/browser/screenshot.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ cbbaseinfo:
55
cbparameters:
66
parameters: []
77
returns:
8-
signatureTypeName: Promise<ScreenshotResponse>
8+
signatureTypeName: Promise<BrowserScreenshotResponse>
99
description: A promise that resolves with the screenshot data.
1010
typeArgs: []
1111
data:
@@ -16,6 +16,25 @@ data:
1616
<CBBaseInfo/>
1717
<CBParameters/>
1818

19+
### Response Structure
20+
21+
The method returns a Promise that resolves to a `BrowserScreenshotResponse` object with the following properties:
22+
23+
**Response Properties:**
24+
- `type`: Always "screenshotResponse"
25+
- `payload`: Optional object containing the response data
26+
- `screenshot`: Base64 encoded image data of the screenshot
27+
- `fullPage`: Optional boolean indicating if it's a full page screenshot
28+
- `success`: Optional boolean indicating if the operation was successful
29+
- `content`: Optional string with additional content information
30+
- `viewport`: Optional viewport information object
31+
- `eventId`: Optional string containing the event identifier
32+
- `success`: Optional boolean indicating if the operation was successful
33+
- `message`: Optional string with additional information
34+
- `error`: Optional string containing error details if the operation failed
35+
- `messageId`: Optional unique identifier for the message
36+
- `threadId`: Optional thread identifier
37+
1938
### Example
2039

2140
```js
@@ -28,6 +47,7 @@ await new Promise(resolve => setTimeout(resolve, 2000));
2847
// Take a screenshot of the current page
2948
const screenshotResult = await codebolt.browser.screenshot();
3049
console.log('✅ Screenshot taken:', screenshotResult);
50+
console.log('Screenshot data available:', !!screenshotResult?.payload?.screenshot);
3151
```
3252
3353
### Explanation

0 commit comments

Comments
 (0)