Files
hermes-ui/tests/server/ekko-agent-mcp.test.ts
T
toor c93e1fe1bd
Build / build (push) Canceled after 0s
NPM Lockfile Check / npm ci --ignore-scripts (push) Canceled after 0s
Playwright / e2e (push) Canceled after 0s
Phase 002: rebrand to hermes-ui and consolidate i18n to zh/en
Removes the ekko / hermes-web-ui branding from the whole tree and drops
eight locale files, so the project presents one name and one language pair.

Data compatibility is deliberate, not accidental: DB filenames, the JWT
audience, and skill manifest ownership all still recognise their pre-rename
values so existing deployments under ~/.hermes-web-ui keep working without a
re-login or a re-injection.

scripts/harness-check.mjs now scans for the legacy strings and fails the
build on any new occurrence, with an explicit allow-list (and reasons) for
the compatibility paths that must keep them.
2026-10-16 11:11:29 +08:00

99 lines
3.6 KiB
TypeScript

import { join } from 'node:path'
import { beforeEach, describe, expect, it, vi } from 'vitest'
const configMock = vi.hoisted(() => ({
port: 8648,
appHome: '/Users/test/.hermes-web-ui',
}))
vi.mock('../../packages/server/src/config', () => ({
config: configMock,
}))
describe('Ekko MCP server context', () => {
beforeEach(() => {
vi.resetModules()
delete process.env.HERMES_DESKTOP
delete process.env.HERMES_AGENT_NODE
delete process.env.HERMES_WEB_UI_DISABLE_MCP_AUTOINJECT
delete process.env.HERMES_WEB_UI_ALLOW_TRANSIENT_MCP_AUTOINJECT
delete process.env.HERMES_WEB_UI_MCP_BIN
configMock.port = 8648
configMock.appHome = '/Users/test/.hermes-web-ui'
})
it('builds managed MCP servers for the current Web UI port and profile', async () => {
const { buildManagedEkkoMcpServers } = await import('../../packages/server/src/services/ekko-agent/mcp')
const servers = buildManagedEkkoMcpServers('work')
expect(servers['hermes-studio-api']).toEqual({
command: process.execPath,
args: [join(process.cwd(), 'bin/hermes-ui-mcp.mjs'), 'api'],
env: {
HERMES_WEB_UI_URL: 'http://127.0.0.1:8648',
HERMES_WEB_UI_HOME: '/Users/test/.hermes-web-ui',
HERMES_WEBUI_STATE_DIR: '/Users/test/.hermes-web-ui',
HERMES_WEB_UI_PROFILE: 'work',
HERMES_MCP_SERVER_NAME: 'hermes-studio-api',
HERMES_MCP_TOOLSET: 'api',
HERMES_WEB_UI_MANAGED_MCP: '1',
},
enabled: true,
})
expect(servers['hermes-studio-devices']).toMatchObject({
args: [join(process.cwd(), 'bin/hermes-ui-mcp.mjs'), 'devices'],
env: {
HERMES_WEB_UI_URL: 'http://127.0.0.1:8648',
HERMES_WEB_UI_PROFILE: 'work',
HERMES_MCP_TOOLSET: 'devices',
},
})
expect(servers['hermes-studio-use']).toMatchObject({
args: [join(process.cwd(), 'bin/hermes-ui-mcp.mjs'), 'use'],
env: {
HERMES_WEB_UI_URL: 'http://127.0.0.1:8648',
HERMES_WEB_UI_PROFILE: 'work',
HERMES_MCP_TOOLSET: 'use',
},
})
})
it('merges caller-provided MCP servers and lets explicit entries override managed defaults', async () => {
const { resolveEkkoMcpServers } = await import('../../packages/server/src/services/ekko-agent/mcp')
const servers = resolveEkkoMcpServers('default', {
'hermes-studio-api': { command: 'custom-api' },
custom: { command: 'custom-mcp' },
})
expect(servers?.['hermes-studio-api']).toEqual({ command: 'custom-api' })
expect(servers?.custom).toEqual({ command: 'custom-mcp' })
expect(servers?.['hermes-studio-devices']).toBeDefined()
expect(servers?.['hermes-studio-use']).toBeDefined()
})
it('does not add managed MCP servers when startup autoinject is disabled or skipped', async () => {
process.env.HERMES_WEB_UI_DISABLE_MCP_AUTOINJECT = '1'
let mod = await import('../../packages/server/src/services/ekko-agent/mcp')
expect(mod.resolveEkkoMcpServers('default')).toBeUndefined()
expect(mod.resolveEkkoMcpServers('default', { custom: { command: 'custom-mcp' } })).toEqual({
custom: { command: 'custom-mcp' },
})
vi.resetModules()
delete process.env.HERMES_WEB_UI_DISABLE_MCP_AUTOINJECT
configMock.appHome = '/private/tmp/wui-preview-home'
mod = await import('../../packages/server/src/services/ekko-agent/mcp')
expect(mod.resolveEkkoMcpServers('default')).toBeUndefined()
vi.resetModules()
process.env.HERMES_WEB_UI_ALLOW_TRANSIENT_MCP_AUTOINJECT = '1'
mod = await import('../../packages/server/src/services/ekko-agent/mcp')
expect(mod.resolveEkkoMcpServers('default')?.['hermes-studio-api']).toBeDefined()
})
})