@@ -89,112 +89,112 @@ async function testAgent() {
89
89
console . log ( '⚠️ Agent finding failed:' , error . message ) ;
90
90
}
91
91
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
+ }
109
109
110
- // console.log('\n7. Testing agent starting...');
111
- // try {
112
- // // First find an agent
113
- // const findResult = await codebolt.agent.findAgent('Documentation Agent', 1);
114
- // if (findResult?.agents && findResult.agents.length > 0) {
115
- // const agentId = findResult.agents[0].function?.name || findResult.agents[0].id || findResult.agents[0].name;
116
- // const startTask = 'Create a simple hello world function';
110
+ console . log ( '\n7. Testing agent starting...' ) ;
111
+ try {
112
+ // First find an agent
113
+ const findResult = await codebolt . agent . findAgent ( 'Documentation Agent' , 1 ) ;
114
+ if ( findResult ?. agents && findResult . agents . length > 0 ) {
115
+ const agentId = findResult . agents [ 0 ] . function ?. name || findResult . agents [ 0 ] . id || findResult . agents [ 0 ] . name ;
116
+ const startTask = 'Create a simple hello world function' ;
117
117
118
- // const startAgentResult = await codebolt.agent.startAgent(agentId, startTask);
119
- // console.log('✅ Start agent result:', startAgentResult);
120
- // console.log(' - Agent ID:', agentId);
121
- // console.log(' - Task:', startTask);
122
- // console.log(' - Status:', startAgentResult?.status);
123
- // console.log(' - Response type:', startAgentResult?.type);
124
- // } else {
125
- // console.log('⚠️ No agents found to start');
126
- // }
127
- // } catch (error) {
128
- // console.log('⚠️ Agent starting failed:', error.message);
129
- // }
118
+ const startAgentResult = await codebolt . agent . startAgent ( agentId , startTask ) ;
119
+ console . log ( '✅ Start agent result:' , startAgentResult ) ;
120
+ console . log ( ' - Agent ID:' , agentId ) ;
121
+ console . log ( ' - Task:' , startTask ) ;
122
+ console . log ( ' - Status:' , startAgentResult ?. status ) ;
123
+ console . log ( ' - Response type:' , startAgentResult ?. type ) ;
124
+ } else {
125
+ console . log ( '⚠️ No agents found to start' ) ;
126
+ }
127
+ } catch ( error ) {
128
+ console . log ( '⚠️ Agent starting failed:' , error . message ) ;
129
+ }
130
130
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);
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 ) ;
137
137
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
- // }
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
+ }
154
154
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
- // }
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
+ }
170
170
171
- // console.log('\n10. Testing comprehensive agent workflow...');
172
- // try {
173
- // const workflowTask = 'Build a React component for user authentication';
171
+ console . log ( '\n10. Testing comprehensive agent workflow...' ) ;
172
+ try {
173
+ const workflowTask = 'Build a React component for user authentication' ;
174
174
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);
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 ) ;
178
178
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);
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 ) ;
185
185
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
- // }
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
+ }
195
195
196
- // console.log('\n🎉 All agent tests completed successfully!');
197
- // console.log('Note: Some tests may show warnings if no agents are available or configured');
196
+ console . log ( '\n🎉 All agent tests completed successfully!' ) ;
197
+ console . log ( 'Note: Some tests may show warnings if no agents are available or configured' ) ;
198
198
199
199
} catch ( error ) {
200
200
console . error ( '❌ Agent test error:' , error . message ) ;
0 commit comments