1- import  {  ActionDetail  }  from  '../action/action.dto' ; 
2- import  {  PrismaService  }  from  '../common/prisma.service' ; 
31import  {  Injectable ,  Logger  }  from  '@nestjs/common' ; 
42import  {  ActionResultNotFoundError  }  from  '@refly/errors' ; 
5- import  {  ActionResult  }  from  '../../generated/client' ; 
63import  {  AbortActionRequest ,  EntityType ,  GetActionResultData ,  User  }  from  '@refly/openapi-schema' ; 
74import  {  batchReplaceRegex ,  genActionResultID ,  pick  }  from  '@refly/utils' ; 
85import  pLimit  from  'p-limit' ; 
9- import  {  ProviderService  }  from  '../provider/provider.service' ; 
6+ import  {  ActionResult  }  from  '../../generated/client' ; 
7+ import  {  ActionDetail  }  from  '../action/action.dto' ; 
8+ import  {  PrismaService  }  from  '../common/prisma.service' ; 
109import  {  providerItem2ModelInfo  }  from  '../provider/provider.dto' ; 
10+ import  {  ProviderService  }  from  '../provider/provider.service' ; 
11+ import  {  ToolCallService  }  from  '../tool-call/tool-call.service' ; 
1112
1213@Injectable ( ) 
1314export  class  ActionService  { 
@@ -22,6 +23,7 @@ export class ActionService {
2223  constructor ( 
2324    private  readonly  prisma : PrismaService , 
2425    private  readonly  providerService : ProviderService , 
26+     private  readonly  toolCallService : ToolCallService , 
2527  )  { } 
2628
2729  async  getActionResult ( user : User ,  param : GetActionResultData [ 'query' ] ) : Promise < ActionDetail >  { 
@@ -58,7 +60,12 @@ export class ActionService {
5860      orderBy : {  order : 'asc'  } , 
5961    } ) ; 
6062
61-     return  {  ...result ,  steps,  modelInfo } ; 
63+     const  toolCalls  =  await  this . toolCallService . fetchToolCalls ( result . resultId ,  result . version ) ; 
64+     const  toolCallsByStep  =  this . toolCallService . groupToolCallsByStep ( steps ,  toolCalls ) ; 
65+     const  stepsWithToolCalls  =  this . toolCallService . attachToolCallsToSteps ( steps ,  toolCallsByStep ) ; 
66+     await  this . toolCallService . deriveAndUpdateActionStatus ( result ,  toolCalls ) ; 
67+ 
68+     return  {  ...result ,  steps : stepsWithToolCalls ,  modelInfo } ; 
6269  } 
6370
6471  async  duplicateActionResults ( 
0 commit comments