Skip to content

Commit 103eb09

Browse files
committed
2 parents e75321b + 22491d4 commit 103eb09

28 files changed

+4427
-0
lines changed

testcases/README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Codebolt Agent Library
2+
3+
This library provides a set of tools and utilities for creating Codebolt agents, enabling seamless integration with the Codebolt platform.
4+
5+
## Features
6+
- Create and manage Codebolt agents
7+
- Interact with the Codebolt platform
8+
- Utilize Codebolt's powerful API
9+
10+
## Installation
11+
12+
```bash
13+
npm install @codebolt/codeboltjs
14+
```
15+
16+
## Usage
17+
18+
```javascript
19+
const codebolt = require('@codebolt/codeboltjs');
20+
21+
// Your code here
22+
```
23+
24+
## Documentation
25+
26+
For More Documentation visit [Codebolt's Documentation](https://docs.codebolt.ai)
27+

testcases/index.js

Whitespace-only changes.

testcases/package-lock.json

Lines changed: 62 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

testcases/package.json

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
{
2+
"name": "codeboltjs-test-project",
3+
"version": "1.0.0",
4+
"main": "index.js",
5+
"scripts": {
6+
"start": "node index.js",
7+
"example": "node example.js",
8+
"test": "node test.js",
9+
"test:fs": "node tests/fs-test.js",
10+
"test:git": "node tests/git-test.js",
11+
"test:chat": "node tests/chat-test.js",
12+
"test:terminal": "node tests/terminal-test.js",
13+
"test:browser": "node tests/browser-test.js",
14+
"test:llm": "node tests/llm-test.js",
15+
"test:tools": "node tests/tools-test.js",
16+
"test:vectordb": "node tests/vectordb-test.js",
17+
"test:websocket": "node tests/websocket-test.js",
18+
"test:codeutils": "node tests/codeutils-test.js",
19+
"test:toolBox": "node tests/toolBox-test.js",
20+
"test:debug": "node tests/debug-test.js",
21+
"test:dbmemory": "node tests/dbmemory-test.js",
22+
"test:crawler": "node tests/crawler-test.js",
23+
"test:tokenizer": "node tests/tokenizer-test.js",
24+
"test:task": "node tests/task-test.js",
25+
"test:state": "node tests/state-test.js",
26+
"test:project": "node tests/project-test.js",
27+
"test:agent": "node tests/agent-test.js",
28+
"test:rag": "node tests/rag-test.js",
29+
"test:docutils": "node tests/docutils-test.js",
30+
"test:search": "node tests/search-test.js",
31+
"test:knowledge": "node tests/knowledge-test.js",
32+
"test:codeparsers": "node tests/codeparsers-test.js",
33+
"test:outputparsers": "node tests/outputparsers-test.js",
34+
"test:history": "node tests/history-test.js",
35+
"test:all": "npm run test:fs && npm run test:git && npm run test:chat && npm run test:terminal && npm run test:browser && npm run test:llm && npm run test:tools && npm run test:vectordb && npm run test:websocket && npm run test:codeutils && npm run test:toolBox && npm run test:debug && npm run test:dbmemory && npm run test:crawler && npm run test:tokenizer && npm run test:task && npm run test:state && npm run test:project && npm run test:agent && npm run test:rag && npm run test:docutils && npm run test:search && npm run test:knowledge && npm run test:codeparsers && npm run test:outputparsers && npm run test:history"
36+
},
37+
"keywords": [
38+
"codebolt",
39+
"testing",
40+
"sdk"
41+
],
42+
"author": "",
43+
"license": "ISC",
44+
"description": "Test project for CodeboltJS SDK",
45+
"dependencies": {
46+
"@codebolt/codeboltjs": "file:../../codeboltjs"
47+
}
48+
}

testcases/tests/agent-test.js

Lines changed: 193 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,193 @@
1+
const codebolt = require('@codebolt/codeboltjs');
2+
3+
async function testAgent() {
4+
console.log('🤖 Testing Agent Module');
5+
console.log('=======================');
6+
7+
try {
8+
await codebolt.waitForConnection();
9+
10+
console.log('\n1. Testing agent list retrieval...');
11+
try {
12+
const agentsListResult = await codebolt.agent.getAgentsList('downloaded');
13+
console.log('✅ Agents list result:', agentsListResult);
14+
console.log(' - Type:', agentsListResult?.type);
15+
console.log(' - Agents count:', agentsListResult?.agents?.length || 0);
16+
if (agentsListResult?.agents?.length > 0) {
17+
console.log(' - First agent:', agentsListResult.agents[0]);
18+
}
19+
} catch (error) {
20+
console.log('⚠️ Agent list retrieval failed:', error.message);
21+
}
22+
23+
console.log('\n2. Testing all agents list...');
24+
try {
25+
const allAgentsResult = await codebolt.agent.getAgentsList('all');
26+
console.log('✅ All agents result:', allAgentsResult);
27+
console.log(' - Type:', allAgentsResult?.type);
28+
console.log(' - Total agents count:', allAgentsResult?.agents?.length || 0);
29+
} catch (error) {
30+
console.log('⚠️ All agents list failed:', error.message);
31+
}
32+
33+
console.log('\n3. Testing local agents list...');
34+
try {
35+
const localAgentsResult = await codebolt.agent.getAgentsList('local');
36+
console.log('✅ Local agents result:', localAgentsResult);
37+
console.log(' - Type:', localAgentsResult?.type);
38+
console.log(' - Local agents count:', localAgentsResult?.agents?.length || 0);
39+
} catch (error) {
40+
console.log('⚠️ Local agents list failed:', error.message);
41+
}
42+
43+
// console.log('\n4. Testing agent details retrieval...');
44+
// try {
45+
// // First get some agents to get details for
46+
// const agentsList = await codebolt.agent.getAgentsList('downloaded');
47+
// if (agentsList?.agents && agentsList.agents.length > 0) {
48+
// const agentIds = agentsList.agents.slice(0, 2).map(agent => agent.function?.name || agent.id || agent.name);
49+
// console.log(' - Agent IDs to get details for:', agentIds);
50+
// const agentsDetailResult = await codebolt.agent.getAgentsDetail(agentIds);
51+
// console.log('✅ Agents detail result:', agentsDetailResult);
52+
// console.log(' - Details count:', agentsDetailResult?.agents?.length || 0);
53+
// } else {
54+
// console.log('⚠️ No agents available for detail retrieval');
55+
// }
56+
// } catch (error) {
57+
// console.log('⚠️ Agent details retrieval failed:', error.message);
58+
// }
59+
60+
console.log('\n5. Testing agent finding by task...');
61+
const testTask = 'Generate JavaScript code for a simple calculator';
62+
try {
63+
const findAgentResult = await codebolt.agent.findAgent(
64+
testTask,
65+
3, // maxResult
66+
[], // agents filter
67+
'all', // agentLocation
68+
'use_vector_db' // getFrom
69+
);
70+
console.log('✅ Find agent result:', findAgentResult);
71+
console.log(' - Task:', testTask);
72+
console.log(' - Found agents count:', findAgentResult?.agents?.length || 0);
73+
if (findAgentResult?.agents?.length > 0) {
74+
console.log(' - Best match:', findAgentResult.agents[0]);
75+
}
76+
} catch (error) {
77+
console.log('⚠️ Agent finding failed:', error.message);
78+
}
79+
80+
console.log('\n6. Testing agent finding with different parameters...');
81+
const analysisTask = 'Analyze data and provide insights';
82+
try {
83+
const findAnalysisAgentResult = await codebolt.agent.findAgent(
84+
analysisTask,
85+
1, // maxResult
86+
[], // agents filter
87+
'local_only', // agentLocation
88+
'use_ai' // getFrom
89+
);
90+
console.log('✅ Find analysis agent result:', findAnalysisAgentResult);
91+
console.log(' - Task:', analysisTask);
92+
console.log(' - Location filter:', 'local_only');
93+
console.log(' - Found agents count:', findAnalysisAgentResult?.agents?.length || 0);
94+
} catch (error) {
95+
console.log('⚠️ Analysis agent finding failed:', error.message);
96+
}
97+
98+
console.log('\n7. Testing agent starting...');
99+
try {
100+
// First find an agent
101+
const findResult = await codebolt.agent.findAgent('Documentation Agent', 1);
102+
if (findResult?.agents && findResult.agents.length > 0) {
103+
const agentId = findResult.agents[0].function?.name || findResult.agents[0].id || findResult.agents[0].name;
104+
const startTask = 'Create a simple hello world function';
105+
106+
const startAgentResult = await codebolt.agent.startAgent(agentId, startTask);
107+
console.log('✅ Start agent result:', startAgentResult);
108+
console.log(' - Agent ID:', agentId);
109+
console.log(' - Task:', startTask);
110+
console.log(' - Status:', startAgentResult?.status);
111+
console.log(' - Response type:', startAgentResult?.type);
112+
} else {
113+
console.log('⚠️ No agents found to start');
114+
}
115+
} catch (error) {
116+
console.log('⚠️ Agent starting failed:', error.message);
117+
}
118+
119+
console.log('\n8. Testing agent finding with specific agent filter...');
120+
try {
121+
// Get some agent names first
122+
const agentsList = await codebolt.agent.getAgentsList('downloaded');
123+
if (agentsList?.agents && agentsList.agents.length > 0) {
124+
const agentNames = agentsList.agents.slice(0, 2).map(agent => agent.function?.name || agent.name || agent.id);
125+
126+
const filteredFindResult = await codebolt.agent.findAgent(
127+
'Code generation task',
128+
2,
129+
agentNames, // filter by specific agents
130+
'all',
131+
'use_both'
132+
);
133+
console.log('✅ Filtered find result:', filteredFindResult);
134+
console.log(' - Filter agents:', agentNames);
135+
console.log(' - Found agents count:', filteredFindResult?.agents?.length || 0);
136+
} else {
137+
console.log('⚠️ No agents available for filtering');
138+
}
139+
} catch (error) {
140+
console.log('⚠️ Filtered agent finding failed:', error.message);
141+
}
142+
143+
console.log('\n9. Testing agent finding with remote only location...');
144+
try {
145+
const remoteAgentResult = await codebolt.agent.findAgent(
146+
'Complex data processing task',
147+
5,
148+
[],
149+
'remote_only',
150+
'use_vector_db'
151+
);
152+
console.log('✅ Remote agent result:', remoteAgentResult);
153+
console.log(' - Location filter:', 'remote_only');
154+
console.log(' - Found agents count:', remoteAgentResult?.agents?.length || 0);
155+
} catch (error) {
156+
console.log('⚠️ Remote agent finding failed:', error.message);
157+
}
158+
159+
console.log('\n10. Testing comprehensive agent workflow...');
160+
try {
161+
const workflowTask = 'Build a React component for user authentication';
162+
163+
// Step 1: Find suitable agents
164+
const foundAgents = await codebolt.agent.findAgent(workflowTask, 3);
165+
console.log(' - Found agents for workflow:', foundAgents?.agents?.length || 0);
166+
167+
if (foundAgents?.agents && foundAgents.agents.length > 0) {
168+
// Step 2: Get detailed information about the best agent
169+
const bestAgent = foundAgents.agents[0];
170+
const agentId = bestAgent.function?.name || bestAgent.id || bestAgent.name;
171+
const agentDetails = await codebolt.agent.getAgentsDetail([agentId]);
172+
console.log(' - Agent details retrieved:', agentDetails?.agents?.length || 0);
173+
174+
// Step 3: Start the agent with the task
175+
const workflowResult = await codebolt.agent.startAgent(agentId, workflowTask);
176+
console.log('✅ Workflow completion:', workflowResult?.type);
177+
} else {
178+
console.log('⚠️ No suitable agents found for workflow');
179+
}
180+
} catch (error) {
181+
console.log('⚠️ Agent workflow failed:', error.message);
182+
}
183+
184+
console.log('\n🎉 All agent tests completed successfully!');
185+
console.log('Note: Some tests may show warnings if no agents are available or configured');
186+
187+
} catch (error) {
188+
console.error('❌ Agent test error:', error.message);
189+
console.error('Stack trace:', error.stack);
190+
}
191+
}
192+
193+
testAgent().catch(console.error);

0 commit comments

Comments
 (0)