Import the client, server, skills, tests, and build scripts as the starting point for the rebuild, then trim the surfaces this project does not ship: Electron desktop packaging, the marketing website, and the ESP32 firmware tree. CI keeps the web build, e2e, lockfile, release, and Docker workflows. Rename the package and CLI entry points to hermes-ui, drop the prepare hook so npm ci no longer triggers a build, and drop the removed tsconfig and nodemon references. Rewrite AGENTS.md, ARCHITECTURE.md, DEVELOPMENT.md, and the READMEs so the documented package map and hard rules match this repository. reference_code/ is ignored: it is a read-only snapshot, not an input to the build.
54 lines
1.8 KiB
TypeScript
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' })
|
|
})
|
|
})
|