feat(sessions): add unified /sessions/messages entry point
Add SessionsService#routeIncomingMessage: if the user has an active non-completed session, route to its agent by status (only objective_discovery is implemented so far - any other status rejects with a clear 409 rather than failing silently); otherwise run the intent router first and only create a session + start Agent 1 when it detects a learning intent, replying as plain conversational Max (PERSONALITY_PROMPT only, no session) otherwise. Exposed as POST /sessions/messages (JWT-protected), the new single entry point the chat window should call instead of unconditionally creating a session on every message. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
dc368a32f0
commit
ce25d3f290
@@ -11,6 +11,7 @@ describe('SessionsController', () => {
|
||||
findOne: jest.fn(),
|
||||
sendObjectiveMessage: jest.fn(),
|
||||
confirmObjective: jest.fn(),
|
||||
routeIncomingMessage: jest.fn(),
|
||||
};
|
||||
const request = {
|
||||
user: { sub: 7, email: 'w@example.com' },
|
||||
@@ -66,4 +67,16 @@ describe('SessionsController', () => {
|
||||
await controller.confirmObjective(1, request);
|
||||
expect(sessionsService.confirmObjective).toHaveBeenCalledWith(1, 7);
|
||||
});
|
||||
|
||||
it('should route an incoming message for the authenticated user', async () => {
|
||||
sessionsService.routeIncomingMessage.mockResolvedValueOnce({
|
||||
type: 'chat',
|
||||
reply: 'ok',
|
||||
});
|
||||
await controller.routeMessage({ message: 'Salut' }, request);
|
||||
expect(sessionsService.routeIncomingMessage).toHaveBeenCalledWith(
|
||||
7,
|
||||
'Salut',
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user