MCPcopy Create free account
hub / github.com/Roy3838/Observer / fetchAgentReferenceData

Function fetchAgentReferenceData

app/src/utils/agentParser.ts:266–305  ·  view source on GitHub ↗
(
  references: AgentReference[]
)

Source from the content-addressed store, hash-verified

264 * @returns Array of complete agent reference data
265 */
266export async function fetchAgentReferenceData(
267 references: AgentReference[]
268): Promise<AgentReferenceData[]> {
269 const results: AgentReferenceData[] = [];
270
271 for (const reference of references) {
272 try {
273 // Fetch agent config and code from agent_database
274 const agent = await getAgent(reference.agentId);
275 const code = agent ? await getAgentCode(reference.agentId) : null;
276 const memory = agent ? await getAgentMemory(reference.agentId) : '';
277
278 // Fetch recent runs from IterationStore
279 let recentRuns: IterationData[] = [];
280 if (reference.runCount > 0) {
281 recentRuns = await getRecentAgentRuns(reference.agentId, reference.runCount);
282 }
283
284 results.push({
285 reference,
286 agent,
287 code,
288 memory,
289 recentRuns
290 });
291 } catch (error) {
292 console.error(`Failed to fetch data for agent ${reference.agentId}:`, error);
293 // Add placeholder entry for failed fetch
294 results.push({
295 reference,
296 agent: null,
297 code: null,
298 memory: '',
299 recentRuns: []
300 });
301 }
302 }
303
304 return results;
305}
306
307/**
308 * Extract unique agent references from all messages in conversation

Callers 2

sendConversationFunction · 0.90
handleAgentBadgeClickFunction · 0.90

Calls 6

getAgentFunction · 0.90
getAgentCodeFunction · 0.90
getAgentMemoryFunction · 0.90
getRecentAgentRunsFunction · 0.85
pushMethod · 0.80
errorMethod · 0.80

Tested by

no test coverage detected