@@ -5,7 +5,7 @@ import { eq } from 'drizzle-orm'
55import { type NextRequest , NextResponse } from 'next/server'
66import { generateAgentCard , generateSkillsFromWorkflow } from '@/lib/a2a/agent-card'
77import type { AgentCapabilities , AgentSkill } from '@/lib/a2a/types'
8- import { checkHybridAuth } from '@/lib/auth/hybrid'
8+ import { checkSessionOrInternalAuth } from '@/lib/auth/hybrid'
99import { getRedisClient } from '@/lib/core/config/redis'
1010import { loadWorkflowFromNormalizedTables } from '@/lib/workflows/persistence/utils'
1111import { checkWorkspaceAccess } from '@/lib/workspaces/permissions/utils'
@@ -40,7 +40,7 @@ export async function GET(request: NextRequest, { params }: { params: Promise<Ro
4040 }
4141
4242 if ( ! agent . agent . isPublished ) {
43- const auth = await checkHybridAuth ( request , { requireWorkflowId : false } )
43+ const auth = await checkSessionOrInternalAuth ( request , { requireWorkflowId : false } )
4444 if ( ! auth . success ) {
4545 return NextResponse . json ( { error : 'Agent not published' } , { status : 404 } )
4646 }
@@ -81,7 +81,7 @@ export async function PUT(request: NextRequest, { params }: { params: Promise<Ro
8181 const { agentId } = await params
8282
8383 try {
84- const auth = await checkHybridAuth ( request , { requireWorkflowId : false } )
84+ const auth = await checkSessionOrInternalAuth ( request , { requireWorkflowId : false } )
8585 if ( ! auth . success || ! auth . userId ) {
8686 return NextResponse . json ( { error : 'Unauthorized' } , { status : 401 } )
8787 }
@@ -151,7 +151,7 @@ export async function DELETE(request: NextRequest, { params }: { params: Promise
151151 const { agentId } = await params
152152
153153 try {
154- const auth = await checkHybridAuth ( request , { requireWorkflowId : false } )
154+ const auth = await checkSessionOrInternalAuth ( request , { requireWorkflowId : false } )
155155 if ( ! auth . success || ! auth . userId ) {
156156 return NextResponse . json ( { error : 'Unauthorized' } , { status : 401 } )
157157 }
@@ -189,7 +189,7 @@ export async function POST(request: NextRequest, { params }: { params: Promise<R
189189 const { agentId } = await params
190190
191191 try {
192- const auth = await checkHybridAuth ( request , { requireWorkflowId : false } )
192+ const auth = await checkSessionOrInternalAuth ( request , { requireWorkflowId : false } )
193193 if ( ! auth . success || ! auth . userId ) {
194194 logger . warn ( 'A2A agent publish auth failed:' , { error : auth . error , hasUserId : ! ! auth . userId } )
195195 return NextResponse . json ( { error : auth . error || 'Unauthorized' } , { status : 401 } )
0 commit comments