( references: AgentReference[] )
| 244 | * @returns Array of complete agent reference data |
| 245 | */ |
| 246 | export async function fetchAgentReferenceData( |
| 247 | references: AgentReference[] |
| 248 | ): Promise<AgentReferenceData[]> { |
| 249 | const results: AgentReferenceData[] = []; |
| 250 | |
| 251 | for (const reference of references) { |
| 252 | try { |
| 253 | // Fetch agent config and code from agent_database |
| 254 | const agent = await getAgent(reference.agentId); |
| 255 | const code = agent ? await getAgentCode(reference.agentId) : null; |
| 256 | const memory = agent ? await getAgentMemory(reference.agentId) : ''; |
| 257 | |
| 258 | // Fetch recent runs from IterationStore |
| 259 | let recentRuns: IterationData[] = []; |
| 260 | if (reference.runCount > 0) { |
| 261 | recentRuns = await getRecentAgentRuns(reference.agentId, reference.runCount); |
| 262 | } |
| 263 | |
| 264 | results.push({ |
| 265 | reference, |
| 266 | agent, |
| 267 | code, |
| 268 | memory, |
| 269 | recentRuns |
| 270 | }); |
| 271 | } catch (error) { |
| 272 | console.error(`Failed to fetch data for agent ${reference.agentId}:`, error); |
| 273 | // Add placeholder entry for failed fetch |
| 274 | results.push({ |
| 275 | reference, |
| 276 | agent: null, |
| 277 | code: null, |
| 278 | memory: '', |
| 279 | recentRuns: [] |
| 280 | }); |
| 281 | } |
| 282 | } |
| 283 | |
| 284 | return results; |
| 285 | } |
| 286 | |
| 287 | /** |
| 288 | * Extract unique agent references from all messages in conversation |
nothing calls this directly
no test coverage detected