mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-26 19:04:23 +00:00
refactor(agent): decouple agent orchestration and relocate workflows
Decoupled high-level agent orchestration (chat, chatWithAgent, autofill) from sandbox execution in `src/agent` to `src/services/agent/agent.ts`. Relocated all related workflows and activities to `src/workflow`.
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
import { describe, it, expect, vi, beforeEach } from 'vitest'
|
||||
import { setupTestDbHooks } from '@/db-test-hooks'
|
||||
import { aiChatActivity } from './agent'
|
||||
import { agentService } from '@/services/agent/agent'
|
||||
|
||||
vi.mock('@/services/agent/agent', () => ({
|
||||
agentService: {
|
||||
chatWithAgent: vi.fn(),
|
||||
},
|
||||
}))
|
||||
|
||||
describe('Agent Activities', () => {
|
||||
setupTestDbHooks()
|
||||
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks()
|
||||
})
|
||||
|
||||
it('should call aiChatActivity', async () => {
|
||||
vi.mocked(agentService.chatWithAgent).mockResolvedValue({
|
||||
text: 'AI response',
|
||||
usage: { inputTokens: 1, outputTokens: 1, model: 'gpt-4' },
|
||||
sessionId: 'mock-session-id',
|
||||
})
|
||||
|
||||
await aiChatActivity({
|
||||
teamId: 't1',
|
||||
agentId: 'b1',
|
||||
message: 'Hi',
|
||||
imageUrls: [],
|
||||
projectId: 'p1',
|
||||
folderId: 'f1',
|
||||
})
|
||||
|
||||
expect(agentService.chatWithAgent).toHaveBeenCalledWith(
|
||||
't1',
|
||||
'b1',
|
||||
'Hi',
|
||||
[],
|
||||
'',
|
||||
undefined,
|
||||
undefined,
|
||||
)
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user