Skip to content

Commit 1d79387

Browse files
committed
updated agentlib
1 parent 34672e9 commit 1d79387

File tree

9 files changed

+166
-11
lines changed

9 files changed

+166
-11
lines changed

Diff for: docs/api/1_api_index.md

+6
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,12 @@ cbapicategory:
6363
- name: VectorDB
6464
link: /docs/api/vectordb
6565
description: Provides Vector DB related Functionalities for Storing and Managing of Vector Embedding
66+
- name: MCP
67+
link: /docs/api/mcp
68+
description: Manages modular tools and services through WebSocket communication. Execute tools, retrieve tool details, and monitor enabled MCP instances in real-time
69+
- name: Agent
70+
link: /docs/api/agent
71+
description: Manages AI agents for tasks using WebSocket. Start agents, assign tasks, and track their status in real-time.
6672

6773
---
6874
# Codebolt AI Agent Framework API

Diff for: docs/api/agentlib/_category_.json

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"label": "Agentlib",
3+
"position": 2.5,
4+
"collapsible": true,
5+
"collapsed": true,
6+
"className": "red",
7+
"link": {
8+
"type": "doc",
9+
"id": "api/agentlib/index"
10+
}
11+
}

Diff for: docs/api/agentlib/agent.md

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
---
2+
name: AgentLib
3+
cbbaseinfo:
4+
description: Central class for managing AI agent operations including tool execution, subagent coordination, and task processing through LLM interactions.
5+
cbparameters:
6+
parameters:
7+
- name: tools
8+
typeName: Array<any>
9+
description: Initial set of tools available to the agent
10+
- name: systemPrompt
11+
typeName: SystemPrompt
12+
description: Base prompt configuration for the agent
13+
- name: maxRun
14+
typeName: number (optional)
15+
description: Maximum execution cycles (0 = unlimited)
16+
default: 0
17+
- name: subAgents
18+
typeName: Array<any>
19+
description: List of subordinate agents
20+
default: []
21+
returns:
22+
signatureTypeName: Class
23+
description: Agent instance with task processing capabilities
24+
data:
25+
name: Agent
26+
category: agent
27+
link: agent.md
28+
---
29+
<CBBaseInfo/>
30+
<CBParameters/>
31+
32+
33+
### Key Features
34+
- **Tool Integration**: Execute local and MCP tools
35+
- **Subagent Coordination**: Manage nested agent workflows
36+
- **Conversation Management**: Maintain context-aware dialog history
37+
- **Automatic Retry**: Configurable execution attempts
38+
39+
### Example Usage
40+
41+
```javascript
42+
// Initialize agent with tools and prompts
43+
const systemPrompt = new SystemPrompt("You are a helpful AI assistant");
44+
const taskInstruction = new TaskInstruction("Process user request", { priority: "high" });
45+
46+
const agent = new Agent(
47+
[imageProcessorTool, dataValidatorTool],
48+
systemPrompt,
49+
3, // max 3 attempts
50+
[reportGeneratorAgent]
51+
);
52+
53+
// Execute task
54+
const result = await agent.run(taskInstruction);
55+
if (result.success) {
56+
console.log("Task completed:", result.message);
57+
} else {
58+
console.error("Failed:", result.error);
59+
}

Diff for: docs/api/agentlib/index.md

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
cbapicategory:
3+
- name: Agentlib
4+
link: /docs/api/agentlib/agent
5+
description: Central class for managing AI agent operations including tool execution, subagent coordination, and task processing through LLM interactions..
6+
- name: systemPrompt
7+
link: /docs/api/agentlib/systemPrompt
8+
description: Class for loading and managing AI system prompts from YAML files with key-based retrieval.
9+
- name: taskInstructions
10+
link: /docs/api/agentlib/taskInstructions
11+
description:
12+
- name: usermessage
13+
link: /docs/api/agentlib/usermessage
14+
description:
15+
16+
---
17+
# cbstate
18+
<CBAPICategory />

Diff for: docs/api/agentlib/systemPrompt.md

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
---
2+
name: SystemPrompt
3+
cbbaseinfo:
4+
description: Class for loading and managing AI system prompts from YAML files with key-based retrieval
5+
cbparameters:
6+
parameters:
7+
- name: filepath
8+
typeName: string
9+
description: Path to YAML prompt file (absolute or relative)
10+
default: ""
11+
- name: key
12+
typeName: string
13+
description: Identifier for specific prompt in YAML file
14+
default: ""
15+
returns:
16+
signatureTypeName: Class
17+
description: SystemPrompt instance with loaded prompt configuration
18+
data:
19+
name: system-prompt
20+
category: prompt-management
21+
link: system-prompt.md
22+
---
23+
<CBBaseInfo/>
24+
<CBParameters/>
25+
26+
### Key Features
27+
- **YAML Loading**: Load prompt configurations from structured YAML files
28+
- **Key-Based Access**: Retrieve prompts using defined identifier keys
29+
- **Error Handling**: Validate file structure and key existence
30+
- **Path Resolution**: Automatic handling of relative/absolute file paths
31+
32+
### Example Usage
33+
34+
```javascript
35+
// Load prompt configuration
36+
const promptLoader = new SystemPrompt(
37+
"./config/prompts.yaml",
38+
"customerServiceGreeting"
39+
);
40+
41+
try {
42+
// Retrieve formatted prompt text
43+
const promptText = promptLoader.toPromptText();
44+
console.log("System prompt:", promptText);
45+
46+
/* Example output:
47+
System prompt: "Welcome to our service! How may I assist you today?"
48+
*/
49+
} catch (error) {
50+
console.error("Prompt loading failed:", error.message);
51+
}

Diff for: docs/api/agentlib/taskInstructions.md

Whitespace-only changes.

Diff for: docs/api/agentlib/usermessage.md

Whitespace-only changes.

Diff for: docs/api/mcp/executeTool.md

+21-11
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
---
22
name: executeTool
33
cbbaseinfo:
4-
description: Executes a specified tool with the provided parameters.
4+
description: Executes a specified tool with the provided parameters via WebSocket connection.
55
cbparameters:
66
parameters:
77
- name: toolName
88
typeName: string
9-
description: The name of the tool to execute.
9+
description: The name of the tool to execute
1010
- name: params
1111
typeName: any
12-
description: Parameters required for executing the tool.
12+
description: Parameters to pass to the tool
1313
- name: mcpServer
1414
typeName: string (optional)
15-
description: The MCP server to use for execution.
15+
description: Target MCP server URL (uses default connection if not specified)
1616
returns:
1717
signatureTypeName: Promise
18-
description: A promise that resolves with the tool execution result.
18+
description: A promise that resolves with execution result or rejects with error
1919
typeArgs:
2020
- type: reference
2121
name: any
@@ -29,9 +29,19 @@ data:
2929

3030
### Example
3131

32-
```js
33-
// Example: Executing a tool
34-
const result = await codebolt.mcp.executeTool("imageProcessor", { imageUrl: "https://example.com/image.jpg" });
35-
console.log("Tool Execution Result:", result);
36-
37-
```
32+
```javascript
33+
// Execute a data processing tool
34+
try {
35+
const result = await codeboltMCP.executeTool(
36+
"dataProcessor",
37+
{
38+
operation: "encrypt",
39+
payload: "sensitive-data-123"
40+
},
41+
"wss://production-mcp.example.com"
42+
);
43+
44+
console.log("Execution Result:", result);
45+
} catch (error) {
46+
console.error("Execution Failed:", error);
47+
}

Diff for: docs/api/websocket/_category_.json

Whitespace-only changes.

0 commit comments

Comments
 (0)