( record: Record<string, unknown>, sessionId: string, agentId: string, baseUrl: string, )
| 40 | } |
| 41 | |
| 42 | function rehydrateRecord( |
| 43 | record: Record<string, unknown>, |
| 44 | sessionId: string, |
| 45 | agentId: string, |
| 46 | baseUrl: string, |
| 47 | ): void { |
| 48 | const type = record['type']; |
| 49 | if (type === 'turn.prompt' || type === 'turn.steer') { |
| 50 | rehydrateParts(record['input'] as unknown as ContentPart[], sessionId, agentId, baseUrl); |
| 51 | return; |
| 52 | } |
| 53 | if (type === 'context.append_message') { |
| 54 | const message = record['message'] as { content: ContentPart[] }; |
| 55 | rehydrateParts(message.content, sessionId, agentId, baseUrl); |
| 56 | return; |
| 57 | } |
| 58 | if (type === 'context.append_loop_event') { |
| 59 | const event = record['event'] as Record<string, unknown>; |
| 60 | if (event['type'] === 'tool.result') { |
| 61 | const result = event['result'] as Record<string, unknown>; |
| 62 | if (typeof result['output'] !== 'string') { |
| 63 | rehydrateParts(result['output'] as ContentPart[], sessionId, agentId, baseUrl); |
| 64 | } |
| 65 | } else if (event['type'] === 'content.part') { |
| 66 | rehydrateParts([event['part'] as ContentPart], sessionId, agentId, baseUrl); |
| 67 | } |
| 68 | return; |
| 69 | } |
| 70 | } |
| 71 | |
| 72 | function rehydrateParts( |
| 73 | parts: ContentPart[], |
no test coverage detected