Skip to content

Commit 2948790

Browse files
committed
updated
1 parent fac86f0 commit 2948790

21 files changed

+795
-878
lines changed

docs/api/apiaccess/chat/askQuestion.md

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ cbparameters:
1818
description: A promise that resolves with the user's response.
1919
typeArgs:
2020
- type: intrinsic
21-
name: string
21+
name: askQuestion
2222
data:
2323
name: askQuestion
2424
category: chat
@@ -27,6 +27,56 @@ data:
2727
<CBBaseInfo/>
2828
<CBParameters/>
2929

30+
## Response Structure
31+
32+
The `askQuestion` function returns a response object with the following structure:
33+
34+
```js
35+
{
36+
type: 'feedbackResponse',
37+
message: {
38+
type: 'messageResponse',
39+
userMessage: '',
40+
currentFile: '',
41+
mentionedFiles: [],
42+
mentionedFullPaths: [],
43+
mentionedFolders: [],
44+
actions: [],
45+
mentionedAgents: [],
46+
selectedAgent: { id: '', name: '', lastMessage: {} },
47+
universalAgentLastMessage: '',
48+
mentionedMultiFile: [],
49+
uploadedImages: [],
50+
selection: null,
51+
controlFiles: [],
52+
feedbackMessage: 'Yes', // The user's response/selection
53+
links: [],
54+
terminalMessage: '',
55+
messageId: 'zhkmrrla0s9gjpf7pz7ipj',
56+
threadId: '3de168de-d7f9-4c58-8650-4d3029b3477c',
57+
templateType: 'userChat',
58+
processId: '',
59+
mentionedMCPs: [],
60+
mentionedDocs: [],
61+
agentId: '6dd799b5-43c2-4c55-ba49-cae6cbac2498',
62+
agentInstanceId: '3b1ab5e8-f367-4e19-9984-d20e6949aaed'
63+
},
64+
sender: { senderType: 'user', senderInfo: {} },
65+
templateType: 'userChat',
66+
data: { text: '' },
67+
messageId: 'msg_1750742351218_ol08itg',
68+
timestamp: '2025-06-24T05:19:11.218Z'
69+
}
70+
```
71+
72+
### Key Response Fields
73+
74+
- **`feedbackMessage`**: Contains the user's actual response or button selection
75+
- **`messageId`**: Unique identifier for the message
76+
- **`threadId`**: Identifier for the conversation thread
77+
- **`timestamp`**: When the response was received
78+
- **`agentId`** and **`agentInstanceId`**: Identifiers for the agent handling the question
79+
3080
### Examples
3181

3282
```js
@@ -65,6 +115,14 @@ const errorAction = await codebolt.chat.askQuestion(
65115
);
66116
console.log('Error action choice:', errorAction);
67117

118+
// Example 6: Accessing the feedback message from response
119+
const userChoice = await codebolt.chat.askQuestion(
120+
"Do you want to continue?",
121+
["Yes", "No"]
122+
);
123+
// Access the actual user selection
124+
const selectedOption = userChoice.message.feedbackMessage;
125+
console.log('User selected:', selectedOption);
68126
```
69127

70128
### Explanation

docs/api/apiaccess/chat/getChatHistory.md

Lines changed: 75 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,88 @@ data:
2121
<CBParameters/>
2222

2323

24+
## Response Structure
25+
26+
The `getChatHistory` function returns a response object with the following structure:
27+
28+
```js
29+
{
30+
type: 'getChatHistoryResponse',
31+
chats: [
32+
{
33+
type: 'message',
34+
content: 'Test message waiting for reply from CodeboltJS',
35+
actionType: 'waitforReply',
36+
sender: 'agent',
37+
templateType: 'agentChat',
38+
messageId: 'q2mpskkftknsudeuv1wy8',
39+
data: {}, // Additional message data
40+
agentInstanceId: '3b1ab5e8-f367-4e19-9984-d20e6949aaed',
41+
agentId: '6dd799b5-43c2-4c55-ba49-cae6cbac2498',
42+
threadId: '3de168de-d7f9-4c58-8650-4d3029b3477c',
43+
timestamp: '2025-06-24T05:18:57.474Z'
44+
},
45+
{
46+
type: 'message',
47+
content: 'This is a test question from CodeboltJS. Do you want to continue?',
48+
actionType: 'confirmationRequest',
49+
sender: 'agent',
50+
templateType: 'confirmationChat',
51+
messageId: 'zhkmrrla0s9gjpf7pz7ipj',
52+
threadId: '3de168de-d7f9-4c58-8650-4d3029b3477c',
53+
data: {}, // Additional message data
54+
agentInstanceId: '3b1ab5e8-f367-4e19-9984-d20e6949aaed',
55+
agentId: '6dd799b5-43c2-4c55-ba49-cae6cbac2498',
56+
timestamp: '2025-06-24T05:18:59.488Z'
57+
}
58+
// ... more chat messages
59+
]
60+
}
61+
```
62+
63+
### Key Response Fields
64+
65+
- **`type`**: Always 'getChatHistoryResponse' for this function
66+
- **`chats`**: Array of chat message objects containing the conversation history
67+
68+
### Chat Message Fields
69+
70+
- **`type`**: Type of the message (usually 'message')
71+
- **`content`**: The actual message content/text
72+
- **`actionType`**: Type of action associated with the message (e.g., 'waitforReply', 'confirmationRequest')
73+
- **`sender`**: Who sent the message ('agent' or 'user')
74+
- **`templateType`**: Template used for the message display
75+
- **`messageId`**: Unique identifier for the message
76+
- **`threadId`**: Identifier for the conversation thread
77+
- **`agentId`** and **`agentInstanceId`**: Identifiers for the agent
78+
- **`timestamp`**: When the message was sent (ISO 8601 format)
79+
- **`data`**: Additional message-specific data
80+
2481
### Example
2582

2683
```js
2784
// Retrieve the chat history from the server
2885
const chatHistory = await codebolt.chat.getChatHistory();
86+
console.log('Chat history retrieved:', chatHistory);
87+
88+
// Access individual chat messages
89+
const messages = chatHistory.chats;
90+
messages.forEach((message, index) => {
91+
console.log(`Message ${index + 1}:`, {
92+
sender: message.sender,
93+
content: message.content,
94+
timestamp: message.timestamp,
95+
actionType: message.actionType
96+
});
97+
});
98+
99+
// Filter messages by sender
100+
const agentMessages = chatHistory.chats.filter(msg => msg.sender === 'agent');
101+
const userMessages = chatHistory.chats.filter(msg => msg.sender === 'user');
29102

103+
console.log(`Found ${agentMessages.length} agent messages and ${userMessages.length} user messages`);
30104
```
31105

32106
### Explanation
33107

34-
This function basically helps us get all the previous messages from our Codebolt chats.
108+
This function basically helps us get all the previous messages from our Codebolt chats. It returns a comprehensive history including message content, metadata, and timing information for each interaction in the conversation thread.

docs/api/apiaccess/chat/onActionMessage.md

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

docs/api/apiaccess/chat/sendConfirmationRequest.md

Lines changed: 90 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,103 @@ data:
2727
<CBBaseInfo/>
2828
<CBParameters/>
2929

30-
### Example
30+
## Response Structure
31+
32+
The `sendConfirmationRequest` function returns a response object with the following structure:
33+
34+
```js
35+
{
36+
type: 'feedbackResponse',
37+
message: {
38+
type: 'messageResponse',
39+
userMessage: '',
40+
currentFile: '',
41+
mentionedFiles: [],
42+
mentionedFullPaths: [],
43+
mentionedFolders: [],
44+
actions: [],
45+
mentionedAgents: [],
46+
selectedAgent: { id: '', name: '', lastMessage: {} },
47+
universalAgentLastMessage: '',
48+
mentionedMultiFile: [],
49+
uploadedImages: [],
50+
selection: null,
51+
controlFiles: [],
52+
feedbackMessage: 'Yes', // The user's response/selection
53+
links: [],
54+
terminalMessage: '',
55+
messageId: 'q0onroq8puonkvang8u5g',
56+
threadId: '3de168de-d7f9-4c58-8650-4d3029b3477c',
57+
templateType: 'userChat',
58+
processId: '',
59+
mentionedMCPs: [],
60+
mentionedDocs: [],
61+
agentId: '6dd799b5-43c2-4c55-ba49-cae6cbac2498',
62+
agentInstanceId: 'b28af372-1e67-48cb-8018-2f60d60aa3db'
63+
},
64+
sender: { senderType: 'user', senderInfo: {} },
65+
templateType: 'userChat',
66+
data: { text: '' },
67+
messageId: 'msg_1750742836249_v01cpdk',
68+
timestamp: '2025-06-24T05:27:16.250Z'
69+
}
70+
```
71+
72+
### Key Response Fields
73+
74+
- **`feedbackMessage`**: Contains the user's actual response or button selection
75+
- **`messageId`**: Unique identifier for the message
76+
- **`threadId`**: Identifier for the conversation thread
77+
- **`timestamp`**: When the response was received
78+
- **`agentId`** and **`agentInstanceId`**: Identifiers for the agent handling the confirmation
79+
80+
### Examples
3181

3282
```js
33-
// Send a confirmation request with custom buttons
83+
// Example 1: Send a confirmation request with custom buttons
3484
const response = await codebolt.chat.sendConfirmationRequest(
35-
"Would you like to continue with this operation?",
36-
["Yes, continue", "No, cancel"],
37-
true
85+
"Would you like to continue with this operation?",
86+
["Yes, continue", "No, cancel"],
87+
true
3888
);
3989

4090
console.log("User response:", response);
91+
// Access the actual user selection
92+
const userChoice = response.message.feedbackMessage;
93+
console.log("User selected:", userChoice);
94+
95+
// Example 2: Simple Yes/No confirmation (default buttons)
96+
const confirmResponse = await codebolt.chat.sendConfirmationRequest(
97+
"Are you sure you want to delete this file?",
98+
[], // Uses default Yes/No buttons
99+
false
100+
);
101+
102+
if (confirmResponse.message.feedbackMessage === "Yes") {
103+
console.log("User confirmed deletion");
104+
} else {
105+
console.log("User cancelled deletion");
106+
}
107+
108+
// Example 3: Multiple choice confirmation with feedback
109+
const actionResponse = await codebolt.chat.sendConfirmationRequest(
110+
"How would you like to handle this conflict?",
111+
["Overwrite", "Skip", "Merge", "Cancel"],
112+
true
113+
);
114+
115+
const selectedAction = actionResponse.message.feedbackMessage;
116+
console.log("Selected action:", selectedAction);
117+
118+
// Example 4: Processing confirmation response
119+
const deployResponse = await codebolt.chat.sendConfirmationRequest(
120+
"Ready to deploy to production?",
121+
["Deploy Now", "Schedule Later", "Cancel"],
122+
false
123+
);
124+
41125
```
42126

43127
### Explanation
44128

45-
The `sendConfirmationRequest` function sends a confirmation request to the user with customizable buttons and optional feedback input. This is useful for getting user approval before performing operations or collecting simple input from the user.
129+
The `sendConfirmationRequest` function sends a confirmation request to the user with customizable buttons and optional feedback input. This is useful for getting user approval before performing operations or collecting simple input from the user. The function returns a comprehensive response object containing the user's selection and additional metadata for tracking and processing.

docs/api/apiaccess/fs/writeToFile.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
name: writeToFile
33
cbbaseinfo:
4-
description: 'Writes content to a file at the specified path. Creates the file if it doesn\'t exist or overwrites if it does.'
4+
description: 'Writes content to a file at the specified path. Creates the file if it doesn''t exist or overwrites if it does.'
55
cbparameters:
66
parameters:
77
- name: relPath

docs/api/apiaccess/llm/embedding.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,25 @@
11
# Embedding
22

3-
### How to create Embedding
3+
> **Note**: The embedding API is currently not available in the CodeboltJS.
44
5-
```bash
5+
### Planned Embedding API
6+
7+
The embedding API will allow you to create vector embeddings from text input for use in semantic search, similarity matching, and other AI applications.
8+
9+
```javascript
10+
// This API is not yet implemented
611
import codebolt from "codebolt";
712

813
async function main() {
14+
// Planned API structure (not currently available)
915
const embedding = await codebolt.llm.embeddings.create({
1016
input: "Your text string goes here",
1117
encoding_format: "float",
1218
});
1319

1420
console.log(embedding);
1521
}
22+
```
1623

17-
```
24+
### Status
25+
comming soon....

docs/api/apiaccess/llm/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ cbapicategory:
44
link: /docs/api/apiaccess/llm/inference
55
description: |-
66
Sends an inference request to the LLM and returns the model's response.
7-
The model is selected based on the provided
7+
The model is selected based on the provided llmrole parameter.
88
99
---
1010
# llm

0 commit comments

Comments
 (0)