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

Function markAsyncToolStatus

apps/sim/lib/copilot/async-runs/repository.ts:322–368  ·  view source on GitHub ↗
(
  toolCallId: string,
  status: CopilotAsyncToolStatus,
  updates: {
    claimedBy?: string | null
    claimedAt?: Date | null
    result?: AsyncCompletionData | null
    error?: string | null
    completedAt?: Date | null
  } = {}
)

Source from the content-addressed store, hash-verified

320}
321
322async function markAsyncToolStatus(
323 toolCallId: string,
324 status: CopilotAsyncToolStatus,
325 updates: {
326 claimedBy?: string | null
327 claimedAt?: Date | null
328 result?: AsyncCompletionData | null
329 error?: string | null
330 completedAt?: Date | null
331 } = {}
332) {
333 return withDbSpan(
334 TraceSpan.CopilotAsyncRunsMarkAsyncToolStatus,
335 'UPDATE',
336 'copilot_async_tool_calls',
337 {
338 [TraceAttr.ToolCallId]: toolCallId,
339 [TraceAttr.CopilotAsyncToolStatus]: status,
340 [TraceAttr.CopilotAsyncToolHasError]: !!updates.error,
341 [TraceAttr.CopilotAsyncToolClaimedBy]: updates.claimedBy ?? undefined,
342 },
343 async () => {
344 const claimedAt =
345 updates.claimedAt !== undefined
346 ? updates.claimedAt
347 : status === 'running' && updates.claimedBy
348 ? new Date()
349 : undefined
350
351 const [row] = await db
352 .update(copilotAsyncToolCalls)
353 .set({
354 status,
355 claimedBy: updates.claimedBy,
356 claimedAt,
357 result: updates.result,
358 error: updates.error,
359 completedAt: updates.completedAt,
360 updatedAt: new Date(),
361 })
362 .where(eq(copilotAsyncToolCalls.toolCallId, toolCallId))
363 .returning()
364
365 return row ?? null
366 }
367 )
368}
369
370export async function markAsyncToolRunning(toolCallId: string, claimedBy: string) {
371 return markAsyncToolStatus(toolCallId, 'running', { claimedBy })

Callers 3

markAsyncToolRunningFunction · 0.85
completeAsyncToolCallFunction · 0.85
markAsyncToolDeliveredFunction · 0.85

Calls 3

withDbSpanFunction · 0.85
setMethod · 0.65
eqFunction · 0.50

Tested by

no test coverage detected