(
requestPayload: Record<string, unknown>,
params: {
userId: string
workflowId?: string
workspaceId?: string
chatId?: string
executionId?: string
runId?: string
abortSignal?: AbortSignal
}
)
| 884 | // --------------------------------------------------------------------------- |
| 885 | |
| 886 | async function buildExecutionContext( |
| 887 | requestPayload: Record<string, unknown>, |
| 888 | params: { |
| 889 | userId: string |
| 890 | workflowId?: string |
| 891 | workspaceId?: string |
| 892 | chatId?: string |
| 893 | executionId?: string |
| 894 | runId?: string |
| 895 | abortSignal?: AbortSignal |
| 896 | } |
| 897 | ): Promise<ExecutionContext> { |
| 898 | const { userId, workflowId, workspaceId, chatId, executionId, runId, abortSignal } = params |
| 899 | const userTimezone = |
| 900 | typeof requestPayload?.userTimezone === 'string' ? requestPayload.userTimezone : undefined |
| 901 | const requestMode = typeof requestPayload?.mode === 'string' ? requestPayload.mode : undefined |
| 902 | const userPermission = |
| 903 | typeof requestPayload?.userPermission === 'string' ? requestPayload.userPermission : undefined |
| 904 | |
| 905 | let execContext: ExecutionContext |
| 906 | if (workflowId) { |
| 907 | execContext = await prepareExecutionContext(userId, workflowId, chatId) |
| 908 | } else { |
| 909 | const decryptedEnvVars = await getEffectiveDecryptedEnv(userId, workspaceId) |
| 910 | execContext = { |
| 911 | userId, |
| 912 | workflowId: '', |
| 913 | workspaceId, |
| 914 | chatId, |
| 915 | decryptedEnvVars, |
| 916 | } |
| 917 | } |
| 918 | |
| 919 | if (userTimezone) execContext.userTimezone = userTimezone |
| 920 | execContext.copilotToolExecution = true |
| 921 | if (requestMode) execContext.requestMode = requestMode |
| 922 | if (userPermission) execContext.userPermission = userPermission |
| 923 | execContext.messageId = |
| 924 | typeof requestPayload?.messageId === 'string' ? requestPayload.messageId : undefined |
| 925 | execContext.executionId = executionId |
| 926 | execContext.runId = runId |
| 927 | execContext.abortSignal = abortSignal |
| 928 | return execContext |
| 929 | } |
| 930 | |
| 931 | async function ensureHeadlessRunIdentity(input: { |
| 932 | requestPayload: Record<string, unknown> |
no test coverage detected