| 13 | |
| 14 | @Injectable() |
| 15 | export class AgentTraceService { |
| 16 | constructor(private readonly repository: AgentTraceRepository) {} |
| 17 | |
| 18 | async append(event: Parameters<AgentTraceRepository['append']>[0]): Promise<void> { |
| 19 | await this.repository.append(event); |
| 20 | } |
| 21 | |
| 22 | async getRunMetadata( |
| 23 | agentRunId: string, |
| 24 | ): Promise<{ workflowRunId: string; nodeRef: string } | null> { |
| 25 | return this.repository.getRunMetadata(agentRunId); |
| 26 | } |
| 27 | |
| 28 | async list(agentRunId: string, afterSequence?: number): Promise<AgentTracePartEntry[]> { |
| 29 | const rows = |
| 30 | afterSequence && afterSequence > 0 |
| 31 | ? await this.repository.listAfter(agentRunId, afterSequence) |
| 32 | : await this.repository.list(agentRunId); |
| 33 | |
| 34 | return rows.map((row) => ({ |
| 35 | agentRunId: row.agentRunId, |
| 36 | workflowRunId: row.workflowRunId, |
| 37 | nodeRef: row.nodeRef, |
| 38 | sequence: row.sequence, |
| 39 | timestamp: |
| 40 | row.timestamp instanceof Date |
| 41 | ? row.timestamp.toISOString() |
| 42 | : new Date(row.timestamp).toISOString(), |
| 43 | part: (row.payload ?? {}) as Record<string, unknown>, |
| 44 | })); |
| 45 | } |
| 46 | } |
nothing calls this directly
no outgoing calls
no test coverage detected