feat: 新增 Agent OS 管理与运行时能力

This commit is contained in:
2026-03-01 22:33:55 +08:00
parent 84b0209b03
commit 8f23ec49cf
58 changed files with 4432 additions and 46 deletions
+52
View File
@@ -0,0 +1,52 @@
import { NextResponse } from 'next/server'
import { AdminAuthTokenRequestSchema } from '@/lib/agent-os/schemas'
import { issueAdminToken, isValidAdminKey } from '@/lib/agent-os/admin-auth'
export async function POST(request: Request) {
try {
const body = await request.json()
const validation = AdminAuthTokenRequestSchema.safeParse(body)
if (!validation.success) {
return NextResponse.json(
{
success: false,
error: 'Validation error',
details: validation.error.errors,
},
{ status: 400 }
)
}
const { adminKey, operator } = validation.data
if (!isValidAdminKey(adminKey)) {
return NextResponse.json(
{
success: false,
error: 'Unauthorized',
details: ['Invalid admin key'],
},
{ status: 401 }
)
}
const token = issueAdminToken(operator || 'admin-console')
return NextResponse.json({
success: true,
token: token.token,
operator: token.operator,
expiresAt: new Date(token.expiresAt).toISOString(),
})
} catch (error) {
console.error('[AdminAuth] Failed to issue token:', error)
return NextResponse.json(
{
success: false,
error: 'Internal server error',
},
{ status: 500 }
)
}
}