refactor timeline loading to cursor-based fetch API

This commit is contained in:
Mohamed Boudra
2026-02-14 01:03:36 +07:00
parent c41815dcb7
commit 8169134ac3
22 changed files with 1567 additions and 504 deletions
+33
View File
@@ -0,0 +1,33 @@
import type { AgentTimelineItem, DaemonClient } from '@getpaseo/server'
type TimelineFetchResult = {
entries: Array<{ item: AgentTimelineItem }>
}
type TimelineFetchClient = {
fetchAgentTimeline: (
agentId: string,
options: {
direction: 'tail'
limit: 0
projection: 'projected'
}
) => Promise<TimelineFetchResult>
}
type FetchProjectedTimelineItemsInput = {
client: DaemonClient
agentId: string
}
export async function fetchProjectedTimelineItems(
input: FetchProjectedTimelineItemsInput
): Promise<AgentTimelineItem[]> {
const timelineClient = input.client as unknown as TimelineFetchClient
const timeline = await timelineClient.fetchAgentTimeline(input.agentId, {
direction: 'tail',
limit: 0,
projection: 'projected',
})
return timeline.entries.map((entry) => entry.item)
}