fleet-memory/memora-control-plane/src/app/api/think/route.ts
2025-11-13 13:51:42 +01:00

30 lines
914 B
TypeScript

import { NextRequest, NextResponse } from 'next/server';
const DATAPLANE_URL = process.env.MEMORA_CP_DATAPLANE_API_URL || 'http://localhost:8080';
export async function POST(request: NextRequest) {
try {
const body = await request.json();
const agentId = body.agent_id || 'default';
// Remove agent_id from body as it's now in the path
const { agent_id, ...bodyWithoutAgentId } = body;
const response = await fetch(`${DATAPLANE_URL}/api/v1/agents/${agentId}/think`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(bodyWithoutAgentId),
});
const data = await response.json();
return NextResponse.json(data, { status: response.status });
} catch (error) {
console.error('Error thinking:', error);
return NextResponse.json(
{ error: 'Failed to think' },
{ status: 500 }
);
}
}