MCPcopy
hub / github.com/simstudioai/sim / getLatestRunForStream

Function getLatestRunForStream

apps/sim/lib/copilot/async-runs/repository.ts:169–180  ·  view source on GitHub ↗
(streamId: string, userId?: string)

Source from the content-addressed store, hash-verified

167// Un-instrumented: called from a 4 Hz resume poll; per-call spans
168// swamped traces. Use Prom histograms if latency visibility is needed.
169export async function getLatestRunForStream(streamId: string, userId?: string) {
170 const conditions = userId
171 ? and(eq(copilotRuns.streamId, streamId), eq(copilotRuns.userId, userId))
172 : eq(copilotRuns.streamId, streamId)
173 const [run] = await db
174 .select()
175 .from(copilotRuns)
176 .where(conditions)
177 .orderBy(desc(copilotRuns.startedAt))
178 .limit(1)
179 return run ?? null
180}
181
182export async function getRunSegment(runId: string) {
183 return withDbSpan(

Callers 5

route.tsFile · 0.90
GETFunction · 0.90
route.tsFile · 0.90
handleResumeRequestBodyFunction · 0.90
startInnerFunction · 0.90

Calls 1

eqFunction · 0.50

Tested by

no test coverage detected