@@ -2,6 +2,7 @@ import { createLogger } from '@sim/logger'
22import { type NextRequest , NextResponse } from 'next/server'
33import { getSession } from '@/lib/auth'
44import { SIM_AGENT_API_URL } from '@/lib/copilot/constants'
5+ import { fetchGo } from '@/lib/copilot/request/go/fetch'
56import { env } from '@/lib/core/config/env'
67
78const logger = createLogger ( 'CopilotAutoAllowedToolsAPI' )
@@ -30,9 +31,15 @@ export async function GET() {
3031
3132 const userId = session . user . id
3233
33- const res = await fetch (
34+ const res = await fetchGo (
3435 `${ SIM_AGENT_API_URL } /api/tool-preferences/auto-allowed?userId=${ encodeURIComponent ( userId ) } ` ,
35- { method : 'GET' , headers : copilotHeaders ( ) }
36+ {
37+ method : 'GET' ,
38+ headers : copilotHeaders ( ) ,
39+ spanName : 'sim → go /api/tool-preferences/auto-allowed' ,
40+ operation : 'list_auto_allowed_tools' ,
41+ attributes : { 'user.id' : userId } ,
42+ }
3643 )
3744
3845 if ( ! res . ok ) {
@@ -66,10 +73,13 @@ export async function POST(request: NextRequest) {
6673 return NextResponse . json ( { error : 'toolId must be a string' } , { status : 400 } )
6774 }
6875
69- const res = await fetch ( `${ SIM_AGENT_API_URL } /api/tool-preferences/auto-allowed` , {
76+ const res = await fetchGo ( `${ SIM_AGENT_API_URL } /api/tool-preferences/auto-allowed` , {
7077 method : 'POST' ,
7178 headers : copilotHeaders ( ) ,
7279 body : JSON . stringify ( { userId, toolId : body . toolId } ) ,
80+ spanName : 'sim → go /api/tool-preferences/auto-allowed' ,
81+ operation : 'add_auto_allowed_tool' ,
82+ attributes : { 'user.id' : userId , 'tool.id' : body . toolId } ,
7383 } )
7484
7585 if ( ! res . ok ) {
@@ -107,9 +117,15 @@ export async function DELETE(request: NextRequest) {
107117 return NextResponse . json ( { error : 'toolId query parameter is required' } , { status : 400 } )
108118 }
109119
110- const res = await fetch (
120+ const res = await fetchGo (
111121 `${ SIM_AGENT_API_URL } /api/tool-preferences/auto-allowed?userId=${ encodeURIComponent ( userId ) } &toolId=${ encodeURIComponent ( toolId ) } ` ,
112- { method : 'DELETE' , headers : copilotHeaders ( ) }
122+ {
123+ method : 'DELETE' ,
124+ headers : copilotHeaders ( ) ,
125+ spanName : 'sim → go /api/tool-preferences/auto-allowed' ,
126+ operation : 'remove_auto_allowed_tool' ,
127+ attributes : { 'user.id' : userId , 'tool.id' : toolId } ,
128+ }
113129 )
114130
115131 if ( ! res . ok ) {
0 commit comments