MCPcopy Create free account
hub / github.com/OpenHands/OpenHands / buildTranscriptEntries

Function buildTranscriptEntries

src/utils/transcript-export/index.ts:264–495  ·  view source on GitHub ↗
(
  events: OpenHandsEvent[],
  includeToolDetails: boolean,
)

Source from the content-addressed store, hash-verified

262 );
263
264const buildTranscriptEntries = (
265 events: OpenHandsEvent[],
266 includeToolDetails: boolean,
267): TranscriptEntry[] => {
268 const uiEvents = events.reduce<OpenHandsEvent[]>((current, event) => {
269 try {
270 return handleEventForUI(event, current);
271 } catch {
272 return current;
273 }
274 }, []);
275 const actionsById = new Map(
276 events.filter(isActionEvent).map((event) => [event.id, event]),
277 );
278 const entries: TranscriptEntry[] = [];
279 const emittedNarrationActionIds = new Set<string>();
280 const renderableEvents = uiEvents.filter(
281 (event) =>
282 (isSwitchLLMObservationEvent(event) && !event.observation.is_error) ||
283 shouldRenderEvent(event),
284 );
285 const renderedItems = groupEvents(
286 renderableEvents,
287 Number.MAX_SAFE_INTEGER,
288 events,
289 );
290
291 const addActionNarration = (action: ActionEvent) => {
292 if (
293 emittedNarrationActionIds.has(action.id) ||
294 !canRenderActionNarration(action)
295 ) {
296 return;
297 }
298 emittedNarrationActionIds.add(action.id);
299 const content = getActionNarration(action);
300 if (content) {
301 entries.push({
302 kind: "message",
303 author: "assistant",
304 content,
305 timestamp: action.timestamp,
306 });
307 }
308 };
309
310 for (const item of renderedItems) {
311 if (item.kind === "group") continue;
312 if (item.kind === "thought") {
313 addActionNarration(item.action);
314 continue;
315 }
316
317 const { event } = item;
318 try {
319 const narrationAction = isActionEvent(event)
320 ? event
321 : isObservationEvent(event)

Callers 2

eventsToMarkdownFunction · 0.85
eventsToHtmlFunction · 0.85

Calls 15

handleEventForUIFunction · 0.90
shouldRenderEventFunction · 0.90
groupEventsFunction · 0.90
isActionEventFunction · 0.90
isObservationEventFunction · 0.90
isMessageEventFunction · 0.90
parseMessageFromEventFunction · 0.90
splitInlineThinkFunction · 0.90
isStreamingDeltaEventFunction · 0.90
isAgentErrorEventFunction · 0.90
isACPToolCallEventFunction · 0.90

Tested by

no test coverage detected