@@ -28,19 +28,21 @@ export async function processCollaborationRun(run: TeamRun): Promise<void> {
2828 let totalTokens = 0 ;
2929 let totalCost = 0 ;
3030
31+ let teamData : { name : string ; config : CollaborationConfig ; mode : string ; output_route_ids : string [ ] | null } | null = null ;
32+
3133 try {
3234 // 1. Fetch team config
3335 const teamResponse = await supabase
3436 . from ( 'teams' )
35- . select ( 'config, mode' )
37+ . select ( 'name, config, mode, output_route_ids ' )
3638 . eq ( 'id' , run . team_id )
3739 . single ( ) ;
3840
3941 if ( teamResponse . error || ! teamResponse . data ) {
4042 throw new Error ( `Failed to load team: ${ teamResponse . error ?. message ?? 'not found' } ` ) ;
4143 }
4244
43- const teamData = teamResponse . data as { config : CollaborationConfig ; mode : string } ;
45+ teamData = teamResponse . data as { name : string ; config : CollaborationConfig ; mode : string ; output_route_ids : string [ ] | null } ;
4446 const config = teamData . config ;
4547
4648 if ( ! config . agent_ids ?. length || config . agent_ids . length < 2 ) {
@@ -193,8 +195,9 @@ export async function processCollaborationRun(run: TeamRun): Promise<void> {
193195 // Fire webhook (fire-and-forget)
194196 void dispatchTeamRunWebhooks (
195197 { id : run . id , team_id : run . team_id , workspace_id : run . workspace_id , status : 'completed' , input_task : run . input_task , output : finalOutput } ,
196- `Collaboration Team ${ run . team_id } ` ,
198+ teamData . name ,
197199 'team_run.completed' ,
200+ teamData . output_route_ids ,
198201 ) ;
199202
200203 } catch ( error : unknown ) {
@@ -214,8 +217,9 @@ export async function processCollaborationRun(run: TeamRun): Promise<void> {
214217
215218 void dispatchTeamRunWebhooks (
216219 { id : run . id , team_id : run . team_id , workspace_id : run . workspace_id , status : 'failed' , input_task : run . input_task , error_message : errMsg } ,
217- `Collaboration Team ${ run . team_id } ` ,
220+ teamData ?. name ?? `Collaboration Team ${ run . team_id } ` ,
218221 'team_run.failed' ,
222+ teamData ?. output_route_ids ?? null ,
219223 ) ;
220224 }
221225}
0 commit comments