(input: CreateRunSegmentInput)
| 71 | } |
| 72 | |
| 73 | export async function createRunSegment(input: CreateRunSegmentInput) { |
| 74 | return withDbSpan( |
| 75 | TraceSpan.CopilotAsyncRunsCreateRunSegment, |
| 76 | 'INSERT', |
| 77 | 'copilot_runs', |
| 78 | { |
| 79 | [TraceAttr.CopilotExecutionId]: input.executionId, |
| 80 | [TraceAttr.ChatId]: input.chatId, |
| 81 | [TraceAttr.StreamId]: input.streamId, |
| 82 | [TraceAttr.UserId]: input.userId, |
| 83 | [TraceAttr.CopilotRunParentId]: input.parentRunId ?? undefined, |
| 84 | [TraceAttr.CopilotRunAgent]: input.agent ?? undefined, |
| 85 | [TraceAttr.CopilotRunModel]: input.model ?? undefined, |
| 86 | [TraceAttr.CopilotRunProvider]: input.provider ?? undefined, |
| 87 | [TraceAttr.CopilotRunStatus]: input.status ?? 'active', |
| 88 | }, |
| 89 | async () => { |
| 90 | const [run] = await db |
| 91 | .insert(copilotRuns) |
| 92 | .values({ |
| 93 | ...(input.id ? { id: input.id } : {}), |
| 94 | executionId: input.executionId, |
| 95 | parentRunId: input.parentRunId ?? null, |
| 96 | chatId: input.chatId, |
| 97 | userId: input.userId, |
| 98 | workflowId: input.workflowId ?? null, |
| 99 | workspaceId: input.workspaceId ?? null, |
| 100 | streamId: input.streamId, |
| 101 | agent: input.agent ?? null, |
| 102 | model: input.model ?? null, |
| 103 | provider: input.provider ?? null, |
| 104 | requestContext: input.requestContext ?? {}, |
| 105 | status: input.status ?? 'active', |
| 106 | }) |
| 107 | .returning() |
| 108 | return run |
| 109 | } |
| 110 | ) |
| 111 | } |
| 112 | |
| 113 | export async function updateRunStatus( |
| 114 | runId: string, |
no test coverage detected