Files
breakpilot-compliance/admin-compliance/app/api/sdk/v1/agent/scan/route.ts
T
Benjamin Admin 02ff96f74e
Build + Deploy / build-admin-compliance (push) Successful in 2m7s
Build + Deploy / build-backend-compliance (push) Failing after 5m21s
Build + Deploy / build-ai-sdk (push) Successful in 53s
Build + Deploy / build-developer-portal (push) Successful in 1m18s
Build + Deploy / build-tts (push) Successful in 1m42s
Build + Deploy / build-document-crawler (push) Successful in 45s
Build + Deploy / build-dsms-gateway (push) Successful in 27s
Build + Deploy / build-dsms-node (push) Successful in 19s
CI / branch-name (push) Has been skipped
Build + Deploy / trigger-orca (push) Has been skipped
CI / guardrail-integrity (push) Has been skipped
CI / loc-budget (push) Failing after 19s
CI / secret-scan (push) Has been skipped
CI / go-lint (push) Has been skipped
CI / python-lint (push) Has been skipped
CI / nodejs-lint (push) Has been skipped
CI / nodejs-build (push) Successful in 3m6s
CI / dep-audit (push) Has been skipped
CI / sbom-scan (push) Has been skipped
CI / test-go (push) Successful in 55s
CI / test-python-backend (push) Successful in 44s
CI / test-python-document-crawler (push) Successful in 30s
CI / test-python-dsms-gateway (push) Successful in 26s
CI / validate-canonical-controls (push) Successful in 18s
fix: resolve all merge conflict markers from feat/zeroclaw-compliance-agent
9 files had conflict markers from the branch merge. All resolved keeping
the feature branch version. Also split agent_scan_routes.py (534→367 LOC)
by extracting Pydantic models to agent_scan_models.py.

[guardrail-change]

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-05-11 12:15:07 +02:00

71 lines
1.9 KiB
TypeScript

/**
* Agent Scan API Proxy — async scan with polling
*
* POST /api/sdk/v1/agent/scan → starts scan, returns scan_id
* GET /api/sdk/v1/agent/scan?scan_id=xxx → poll status/results
*/
import { NextRequest, NextResponse } from 'next/server'
const BACKEND_URL = process.env.BACKEND_API_URL || 'http://backend-compliance:8002'
export async function POST(request: NextRequest) {
try {
const body = await request.text()
// Start async scan — returns immediately with scan_id
const response = await fetch(`${BACKEND_URL}/api/compliance/agent/scan`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body,
signal: AbortSignal.timeout(300000), // 5 min — multi-page scan + LLM calls
})
if (!response.ok) {
const errorText = await response.text()
return NextResponse.json(
{ error: `Backend: ${response.status}`, detail: errorText },
{ status: response.status }
)
}
const data = await response.json()
return NextResponse.json(data)
} catch (error) {
console.error('Agent scan proxy error:', error)
return NextResponse.json(
{ error: 'Scan konnte nicht gestartet werden' },
{ status: 503 }
)
}
}
export async function GET(request: NextRequest) {
const scanId = request.nextUrl.searchParams.get('scan_id')
if (!scanId) {
return NextResponse.json({ error: 'scan_id parameter required' }, { status: 400 })
}
try {
const response = await fetch(
`${BACKEND_URL}/api/compliance/agent/scan/${scanId}`,
{ signal: AbortSignal.timeout(10000) }
)
if (!response.ok) {
return NextResponse.json(
{ error: `Backend: ${response.status}` },
{ status: response.status }
)
}
const data = await response.json()
return NextResponse.json(data)
} catch (error) {
return NextResponse.json(
{ error: 'Status-Abfrage fehlgeschlagen' },
{ status: 503 }
)
}
}