refactor(api/chat): remove direct Prisma query from API layer

API layer routes in packages/api/src/chat.ts accessed the database directly via prisma, violating communication layer boundaries.

This refactoring migrates these queries to packages/core/src/chat/chat.ts:
- Added getNewSessionMessages to fetch mapped SSE entries.
- Added getChatWorkflowStatus to check task completions.
- Added abortSession to handle workflow cancellation and task updates in core.
- Updated both core and API tests to match refactored signatures and mock boundaries.
This commit is contained in:
yiling
2026-07-14 16:40:55 +08:00
parent b53b76bc6e
commit 6643d63e81
6 changed files with 330 additions and 147 deletions
+4 -1
View File
@@ -195,7 +195,10 @@ describe('Agent Activities', () => {
} as unknown as AgentExecutionContext
const addEventListenerSpy = vi.spyOn(mockTemporalContext.cancellationSignal, 'addEventListener')
const removeEventListenerSpy = vi.spyOn(mockTemporalContext.cancellationSignal, 'removeEventListener')
const removeEventListenerSpy = vi.spyOn(
mockTemporalContext.cancellationSignal,
'removeEventListener',
)
const executionPromise = agentChatActivity({
teamId: 't1',