Files
hermes-web-ui/tests/server/ekko-agent-manager.test.ts
ekko cd15791d3f [codex] Add global Ekko runtime context handling (#1950)
* Add global Ekko runtime context handling

* Pass managed MCP servers to Ekko runs

* Register MCP tools in Ekko runtime

* Watch Ekko agent sources in dev

* Document Ekko chat chain changes
2026-07-05 19:40:34 +08:00

54 lines
1.8 KiB
TypeScript

import { describe, expect, it, vi } from 'vitest'
import { GlobalEkkoAgent } from '../../packages/server/src/services/ekko-agent/manager'
import type { ModelClient, ModelRequest } from '../../packages/ekko-agent/src'
function modelClient(content: string): ModelClient {
return {
provider: 'test',
requestStyle: 'custom-runtime',
capabilities: {
streaming: false,
tools: true,
vision: false,
jsonMode: false,
systemPrompt: true,
},
create: vi.fn(async () => ({ content })),
stream: vi.fn(),
}
}
describe('GlobalEkkoAgent', () => {
it('is created once and handles repeated runs through the same runtime', async () => {
const agent = new GlobalEkkoAgent()
const firstClient = modelClient('first')
const secondClient = modelClient('second')
const first = await agent.run({ messages: ['hi'], modelClient: firstClient })
const second = await agent.run({ messages: ['again'], modelClient: secondClient })
expect(first.output.content).toBe('first')
expect(second.output.content).toBe('second')
expect(agent.runCount).toBe(2)
expect(firstClient.create).toHaveBeenCalledTimes(1)
expect(secondClient.create).toHaveBeenCalledTimes(1)
})
it('passes per-run model defaults, metadata, and tool context', async () => {
const agent = new GlobalEkkoAgent()
const client = modelClient('ok')
await agent.run({
messages: ['hi'],
modelClient: client,
modelDefaults: { model: 'test-model' },
metadata: { session_id: 'session-1' },
toolContext: { mcpServers: { test: { command: 'node', enabled: false } } },
})
const request = vi.mocked(client.create).mock.calls[0]?.[0] as ModelRequest
expect(request.model).toBe('test-model')
expect(request.metadata).toEqual({ session_id: 'session-1' })
})
})