MCPcopy Index your code
hub / github.com/simstudioai/sim / getOldestSeq

Function getOldestSeq

apps/sim/lib/copilot/request/session/buffer.ts:204–218  ·  view source on GitHub ↗
(streamId: string)

Source from the content-addressed store, hash-verified

202}
203
204export async function getOldestSeq(streamId: string): Promise<number | null> {
205 return withRedisRetry({ operation: 'get_oldest_seq', streamId }, async (redis) => {
206 const entries = await redis.zrangebyscore(getEventsKey(streamId), '-inf', '+inf', 'LIMIT', 0, 1)
207 if (!entries || entries.length === 0) {
208 return null
209 }
210 try {
211 const parsed = JSON.parse(entries[0]) as { seq?: number }
212 return typeof parsed.seq === 'number' ? parsed.seq : null
213 } catch {
214 logger.warn('Failed to parse oldest outbox entry', { streamId })
215 return null
216 }
217 })
218}
219
220export async function getLatestSeq(streamId: string): Promise<number | null> {
221 return withRedisRetry({ operation: 'get_latest_seq', streamId }, async (redis) => {

Callers 1

checkForReplayGapFunction · 0.90

Calls 4

parseMethod · 0.80
withRedisRetryFunction · 0.70
getEventsKeyFunction · 0.70
warnMethod · 0.65

Tested by

no test coverage detected