- Dashboard Overview with real-time status display - Live Log Viewer (scrollable, filterable) - Config Editor with JSON syntax highlighting - Model Switcher for provider management - Provider Manager for API key configuration - Quick Actions for common tasks - API Routes: status, logs, config, actions, models, providers Tech Stack: - Next.js 14 (App Router) - TypeScript - Tailwind CSS - shadcn/ui components - CodeMirror for JSON editing - Docker support with docker-compose
41 lines
1.2 KiB
TypeScript
41 lines
1.2 KiB
TypeScript
import { NextResponse } from 'next/server';
|
|
import { getOpenClawConfig, applyConfig } from '@/lib/openclaw';
|
|
|
|
export async function GET() {
|
|
try {
|
|
const config = await getOpenClawConfig();
|
|
// Mask API keys for security
|
|
const maskedConfig = JSON.parse(JSON.stringify(config));
|
|
if (maskedConfig.auth?.profiles) {
|
|
for (const profile of Object.values(maskedConfig.auth.profiles) as any) {
|
|
if (profile.apiKey) {
|
|
profile.apiKey = profile.apiKey.slice(0, 8) + '***masked***';
|
|
}
|
|
}
|
|
}
|
|
if (maskedConfig.tools?.web?.search?.apiKey) {
|
|
maskedConfig.tools.web.search.apiKey =
|
|
maskedConfig.tools.web.search.apiKey.slice(0, 8) + '***masked***';
|
|
}
|
|
return NextResponse.json(maskedConfig);
|
|
} catch (error) {
|
|
return NextResponse.json(
|
|
{ error: (error as Error).message },
|
|
{ status: 500 }
|
|
);
|
|
}
|
|
}
|
|
|
|
export async function POST(request: Request) {
|
|
try {
|
|
const config = await request.json();
|
|
const result = await applyConfig(config);
|
|
return NextResponse.json(result);
|
|
} catch (error) {
|
|
return NextResponse.json(
|
|
{ error: (error as Error).message },
|
|
{ status: 500 }
|
|
);
|
|
}
|
|
}
|