( agentApi: AgentListApi, agentId: string )
| 522 | } |
| 523 | |
| 524 | async function latestRunForAgent( |
| 525 | agentApi: AgentListApi, |
| 526 | agentId: string |
| 527 | ): Promise<Record<string, unknown> | null> { |
| 528 | if (!agentApi.listRuns) return null; |
| 529 | const runs = await agentApi.listRuns(agentId, { runtime: "cloud", limit: 1 }); |
| 530 | const items = field(runs, "items"); |
| 531 | const item = Array.isArray(items) ? items[0] : null; |
| 532 | return isRecord(item) ? item : null; |
| 533 | } |
| 534 | |
| 535 | function latestRunFromItem( |
| 536 | item: Record<string, unknown> |
no test coverage detected