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

Function allocateCursor

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

Source from the content-addressed store, hash-verified

81}
82
83export async function allocateCursor(streamId: string): Promise<{
84 seq: number
85 cursor: string
86}> {
87 const config = getStreamConfig()
88 const seq = await withRedisRetry({ operation: 'allocate_cursor', streamId }, async (redis) => {
89 const nextValue = await redis.incr(getSeqKey(streamId))
90 await redis.expire(getSeqKey(streamId), config.ttlSeconds)
91 return typeof nextValue === 'number' ? nextValue : Number(nextValue)
92 })
93
94 return { seq, cursor: String(seq) }
95}
96
97export async function resetBuffer(streamId: string): Promise<void> {
98 await clearBuffer(streamId, 'reset_outbox')

Callers 1

buffer.test.tsFile · 0.90

Calls 3

getStreamConfigFunction · 0.85
withRedisRetryFunction · 0.70
getSeqKeyFunction · 0.70

Tested by

no test coverage detected