@@ -7,115 +7,123 @@ async function testAgent() {
77 try {
88 await codebolt . waitForConnection ( ) ;
99
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...');
10+ // console.log('\n1. Testing agent list retrieval...');
2411 // 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);
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+ // }
2919 // } catch (error) {
30- // console.log('⚠️ All agents list failed:', error.message);
20+ // console.log('⚠️ Agent list retrieval failed:', error.message);
3121 // }
3222
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- // }
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+ // / / }
4232
43- console . log ( '\n2. Testing getAgentsDetail method...' ) ;
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+ // // }
4442
45- try {
46- // Get the list of agents first
47- const agentsList = await codebolt . agent . getAgentsList ( 'downloaded' ) ;
48- // console.log('✅ Agents list result:', JSON.stringify(agentsList));
49- if ( agentsList ?. agents && agentsList . agents . length > 0 ) {
50- // Get agent IDs from the first few agents
51- const agentIds = agentsList . agents . slice ( 0 , 3 ) . map ( agent => agent . function ?. name ) ;
52- console . log ( ' - Agent IDs to get details for:' , agentIds ) ;
43+ // console.log('\n2. Testing getAgentsDetail method...');
44+
45+ // try {
46+ // // Get the list of agents first
47+ // const agentsList = await codebolt.agent.getAgentsList('downloaded');
48+ // // console.log('✅ Agents list result:', JSON.stringify(agentsList));
49+ // if (agentsList?.agents && agentsList.agents.length > 0) {
50+ // // Get agent IDs from the first few agents
51+ // const agentIds = agentsList.agents.slice(0, 3).map(agent => agent.function?.name);
52+ // console.log(' - Agent IDs to get details for:', agentIds);
5353
54- // Get details for the selected agents
55- const agentsDetailResult = await codebolt . agent . getAgentsDetail ( agentIds ) ;
56- console . log ( '✅ Agents detail result type:' , agentsDetailResult ?. type ) ;
57- console . log ( ' - Expected type: "agentsDetailResponse"' ) ;
58- console . log ( ' - Details count:' , agentsDetailResult ?. agents ?. length || 0 ) ;
59- console . log ( '✅ Agents detail result:' , JSON . stringify ( agentsDetailResult ) ) ;
54+ // // Get details for the selected agents
55+ // const agentsDetailResult = await codebolt.agent.getAgentsDetail(agentIds);
56+ // console.log('✅ Agents detail result type:', agentsDetailResult?.type);
57+ // console.log(' - Expected type: "agentsDetailResponse"');
58+ // console.log(' - Details count:', agentsDetailResult?.agents?.length || 0);
59+ // console.log('✅ Agents detail result:', JSON.stringify(agentsDetailResult));
6060
61- } else {
62- console . log ( '⚠️ No agents available for detail retrieval' ) ;
63- }
61+ // } else {
62+ // console.log('⚠️ No agents available for detail retrieval');
63+ // }
6464
65- // Test with empty agent list
65+ // // Test with empty agent list
6666
6767
68- } catch ( error ) {
69- console . log ( '⚠️ getAgentsDetail failed:' , error . message ) ;
70- }
68+ // } catch (error) {
69+ // console.log('⚠️ getAgentsDetail failed:', error.message);
70+ // }
7171
72- console . log ( '\n5. Testing agent finding by task...' ) ;
73- const testTask = 'create node js app' ;
74- try {
75- const findAgentResult = await codebolt . agent . findAgent (
76- testTask ,
77- 3 , // maxResult
78- [ ] , // agents filter
79- 'remote_only' , // agentLocation
80- 'use_both' // getFrom
81- ) ;
82- console . log ( '✅ Find agent result:' , findAgentResult ) ;
83- console . log ( ' - Task:' , testTask ) ;
84- console . log ( ' - Found agents count:' , findAgentResult ?. agents ?. length || 0 ) ;
85- if ( findAgentResult ?. agents ?. length > 0 ) {
86- console . log ( ' - Best match:' , findAgentResult . agents [ 0 ] ) ;
87- }
88- } catch ( error ) {
89- console . log ( '⚠️ Agent finding failed:' , error . message ) ;
90- }
72+ // console.log('\n5. Testing agent finding by task...');
73+ // const testTask = 'create node js app';
74+ // try {
75+ // const findAgentResult = await codebolt.agent.findAgent(
76+ // testTask,
77+ // 3, // maxResult
78+ // [], // agents filter
79+ // 'remote_only', // agentLocation
80+ // 'use_both' // getFrom
81+ // );
82+ // console.log('✅ Find agent result:', findAgentResult);
83+ // console.log(' - Task:', testTask);
84+ // console.log(' - Found agents count:', findAgentResult?.agents?.length || 0);
85+ // if (findAgentResult?.agents?.length > 0) {
86+ // console.log(' - Best match:', findAgentResult.agents[0]);
87+ // }
88+ // } catch (error) {
89+ // console.log('⚠️ Agent finding failed:', error.message);
90+ // }
9191
92- console . log ( '\n6. Testing agent finding with different parameters...' ) ;
93- const analysisTask = 'Analyze data and provide insights' ;
94- try {
95- const findAnalysisAgentResult = await codebolt . agent . findAgent (
96- analysisTask ,
97- 1 , // maxResult
98- [ ] , // agents filter
99- 'local_only' , // agentLocation
100- 'use_ai' // getFrom
101- ) ;
102- console . log ( '✅ Find analysis agent result:' , findAnalysisAgentResult ) ;
103- console . log ( ' - Task:' , analysisTask ) ;
104- console . log ( ' - Location filter:' , 'local_only' ) ;
105- console . log ( ' - Found agents count:' , findAnalysisAgentResult ?. agents ?. length || 0 ) ;
106- } catch ( error ) {
107- console . log ( '⚠️ Analysis agent finding failed:' , error . message ) ;
108- }
92+ // console.log('\n6. Testing agent finding with different parameters...');
93+ // const analysisTask = 'Analyze data and provide insights';
94+ // try {
95+ // const findAnalysisAgentResult = await codebolt.agent.findAgent(
96+ // analysisTask,
97+ // 1, // maxResult
98+ // [], // agents filter
99+ // 'local_only', // agentLocation
100+ // 'use_ai' // getFrom
101+ // );
102+ // console.log('✅ Find analysis agent result:', findAnalysisAgentResult);
103+ // console.log(' - Task:', analysisTask);
104+ // console.log(' - Location filter:', 'local_only');
105+ // console.log(' - Found agents count:', findAnalysisAgentResult?.agents?.length || 0);
106+ // } catch (error) {
107+ // console.log('⚠️ Analysis agent finding failed:', error.message);
108+ // }
109109
110110 console . log ( '\n7. Testing agent starting...' ) ;
111111 try {
112112 // First find an agent
113- const findResult = await codebolt . agent . findAgent ( 'Documentation Agent' , 1 ) ;
113+ const findResult = await await codebolt . agent . findAgent (
114+ 'create node js app' ,
115+ 10 , // maxResult
116+ [ ] , // agents filter
117+ 'remote_only' , // agentLocation
118+ 'use_both' // getFrom
119+ ) ;
120+ console . log ( '✅ Find result:' , JSON . stringify ( findResult ) ) ;
114121 if ( findResult ?. agents && findResult . agents . length > 0 ) {
115122 const agentId = findResult . agents [ 0 ] . function ?. name || findResult . agents [ 0 ] . id || findResult . agents [ 0 ] . name ;
116- const startTask = 'Create a simple hello world function' ;
123+ const startTask = 'Hi how are you' ;
124+ console . log ( '✅ Start task:' , startTask , agentId ) ;
117125
118- const startAgentResult = await codebolt . agent . startAgent ( agentId , startTask ) ;
126+ const startAgentResult = await codebolt . agent . startAgent ( "act" , startTask ) ;
119127 console . log ( '✅ Start agent result:' , startAgentResult ) ;
120128 console . log ( ' - Agent ID:' , agentId ) ;
121129 console . log ( ' - Task:' , startTask ) ;
@@ -128,70 +136,70 @@ async function testAgent() {
128136 console . log ( '⚠️ Agent starting failed:' , error . message ) ;
129137 }
130138
131- console . log ( '\n8. Testing agent finding with specific agent filter...' ) ;
132- try {
133- // Get some agent names first
134- const agentsList = await codebolt . agent . getAgentsList ( 'downloaded' ) ;
135- if ( agentsList ?. agents && agentsList . agents . length > 0 ) {
136- const agentNames = agentsList . agents . slice ( 0 , 2 ) . map ( agent => agent . function ?. name || agent . name || agent . id ) ;
139+ // console.log('\n8. Testing agent finding with specific agent filter...');
140+ // try {
141+ // // Get some agent names first
142+ // const agentsList = await codebolt.agent.getAgentsList('downloaded');
143+ // if (agentsList?.agents && agentsList.agents.length > 0) {
144+ // const agentNames = agentsList.agents.slice(0, 2).map(agent => agent.function?.name || agent.name || agent.id);
137145
138- const filteredFindResult = await codebolt . agent . findAgent (
139- 'Code generation task' ,
140- 2 ,
141- agentNames , // filter by specific agents
142- 'all' ,
143- 'use_both'
144- ) ;
145- console . log ( '✅ Filtered find result:' , filteredFindResult ) ;
146- console . log ( ' - Filter agents:' , agentNames ) ;
147- console . log ( ' - Found agents count:' , filteredFindResult ?. agents ?. length || 0 ) ;
148- } else {
149- console . log ( '⚠️ No agents available for filtering' ) ;
150- }
151- } catch ( error ) {
152- console . log ( '⚠️ Filtered agent finding failed:' , error . message ) ;
153- }
146+ // const filteredFindResult = await codebolt.agent.findAgent(
147+ // 'Code generation task',
148+ // 2,
149+ // agentNames, // filter by specific agents
150+ // 'all',
151+ // 'use_both'
152+ // );
153+ // console.log('✅ Filtered find result:', filteredFindResult);
154+ // console.log(' - Filter agents:', agentNames);
155+ // console.log(' - Found agents count:', filteredFindResult?.agents?.length || 0);
156+ // } else {
157+ // console.log('⚠️ No agents available for filtering');
158+ // }
159+ // } catch (error) {
160+ // console.log('⚠️ Filtered agent finding failed:', error.message);
161+ // }
154162
155- console . log ( '\n9. Testing agent finding with remote only location...' ) ;
156- try {
157- const remoteAgentResult = await codebolt . agent . findAgent (
158- 'Complex data processing task' ,
159- 5 ,
160- [ ] ,
161- 'remote_only' ,
162- 'use_vector_db'
163- ) ;
164- console . log ( '✅ Remote agent result:' , remoteAgentResult ) ;
165- console . log ( ' - Location filter:' , 'remote_only' ) ;
166- console . log ( ' - Found agents count:' , remoteAgentResult ?. agents ?. length || 0 ) ;
167- } catch ( error ) {
168- console . log ( '⚠️ Remote agent finding failed:' , error . message ) ;
169- }
163+ // console.log('\n9. Testing agent finding with remote only location...');
164+ // try {
165+ // const remoteAgentResult = await codebolt.agent.findAgent(
166+ // 'Complex data processing task',
167+ // 5,
168+ // [],
169+ // 'remote_only',
170+ // 'use_vector_db'
171+ // );
172+ // console.log('✅ Remote agent result:', remoteAgentResult);
173+ // console.log(' - Location filter:', 'remote_only');
174+ // console.log(' - Found agents count:', remoteAgentResult?.agents?.length || 0);
175+ // } catch (error) {
176+ // console.log('⚠️ Remote agent finding failed:', error.message);
177+ // }
170178
171- console . log ( '\n10. Testing comprehensive agent workflow...' ) ;
172- try {
173- const workflowTask = 'Build a React component for user authentication' ;
179+ // console.log('\n10. Testing comprehensive agent workflow...');
180+ // try {
181+ // const workflowTask = 'Build a React component for user authentication';
174182
175- // Step 1: Find suitable agents
176- const foundAgents = await codebolt . agent . findAgent ( workflowTask , 3 ) ;
177- console . log ( ' - Found agents for workflow:' , foundAgents ?. agents ?. length || 0 ) ;
183+ // // Step 1: Find suitable agents
184+ // const foundAgents = await codebolt.agent.findAgent(workflowTask, 3);
185+ // console.log(' - Found agents for workflow:', foundAgents?.agents?.length || 0);
178186
179- if ( foundAgents ?. agents && foundAgents . agents . length > 0 ) {
180- // Step 2: Get detailed information about the best agent
181- const bestAgent = foundAgents . agents [ 0 ] ;
182- const agentId = bestAgent . function ?. name || bestAgent . id || bestAgent . name ;
183- const agentDetails = await codebolt . agent . getAgentsDetail ( [ agentId ] ) ;
184- console . log ( ' - Agent details retrieved:' , agentDetails ?. agents ?. length || 0 ) ;
187+ // if (foundAgents?.agents && foundAgents.agents.length > 0) {
188+ // // Step 2: Get detailed information about the best agent
189+ // const bestAgent = foundAgents.agents[0];
190+ // const agentId = bestAgent.function?.name || bestAgent.id || bestAgent.name;
191+ // const agentDetails = await codebolt.agent.getAgentsDetail([agentId]);
192+ // console.log(' - Agent details retrieved:', agentDetails?.agents?.length || 0);
185193
186- // Step 3: Start the agent with the task
187- const workflowResult = await codebolt . agent . startAgent ( agentId , workflowTask ) ;
188- console . log ( '✅ Workflow completion:' , workflowResult ?. type ) ;
189- } else {
190- console . log ( '⚠️ No suitable agents found for workflow' ) ;
191- }
192- } catch ( error ) {
193- console . log ( '⚠️ Agent workflow failed:' , error . message ) ;
194- }
194+ // // Step 3: Start the agent with the task
195+ // const workflowResult = await codebolt.agent.startAgent(agentId, workflowTask);
196+ // console.log('✅ Workflow completion:', workflowResult?.type);
197+ // } else {
198+ // console.log('⚠️ No suitable agents found for workflow');
199+ // }
200+ // } catch (error) {
201+ // console.log('⚠️ Agent workflow failed:', error.message);
202+ // }
195203
196204 console . log ( '\n🎉 All agent tests completed successfully!' ) ;
197205 console . log ( 'Note: Some tests may show warnings if no agents are available or configured' ) ;
0 commit comments