forked from BasedHardware/omi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadapterRegistry.test.ts
More file actions
55 lines (48 loc) · 2.13 KB
/
Copy pathadapterRegistry.test.ts
File metadata and controls
55 lines (48 loc) · 2.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import { afterEach, describe, expect, it } from 'vitest'
import {
ADAPTER_PROFILES,
adapterActivationError,
adapterConfiguredCommand,
adapterIsActivated
} from './adapterRegistry'
import { PRODUCTION_ADAPTER_IDS } from './interface'
describe('adapterRegistry', () => {
afterEach(() => {
delete process.env.OMI_OPENCLAW_ADAPTER_COMMAND
delete process.env.OMI_HERMES_ADAPTER_COMMAND
delete process.env.OMI_CODEX_ADAPTER_COMMAND
})
it('registers a profile for every production adapter id', () => {
for (const id of PRODUCTION_ADAPTER_IDS) {
expect(ADAPTER_PROFILES[id].adapterId).toBe(id)
expect(ADAPTER_PROFILES[id].displayName.length).toBeGreaterThan(0)
}
})
it('Claude Code is always activated with no configuration', () => {
expect(adapterIsActivated('acp')).toBe(true)
expect(adapterConfiguredCommand('acp')).toBeUndefined()
expect(adapterActivationError('acp')).toBeUndefined()
})
it('external adapters activate from their env var', () => {
expect(adapterIsActivated('openclaw')).toBe(false)
process.env.OMI_OPENCLAW_ADAPTER_COMMAND = 'openclaw acp'
expect(adapterIsActivated('openclaw')).toBe(true)
expect(adapterConfiguredCommand('openclaw')).toBe('openclaw acp')
expect(adapterIsActivated('hermes')).toBe(false)
expect(adapterIsActivated('codex')).toBe(false)
})
it('preference overrides win over env vars', () => {
process.env.OMI_CODEX_ADAPTER_COMMAND = 'codex-from-env'
expect(adapterConfiguredCommand('codex', { codex: 'npx @agentclientprotocol/codex-acp' })).toBe(
'npx @agentclientprotocol/codex-acp'
)
// Blank/whitespace preferences fall back to the env var.
expect(adapterConfiguredCommand('codex', { codex: ' ' })).toBe('codex-from-env')
})
it('produces an install hint for unconnected external adapters', () => {
expect(adapterActivationError('hermes')).toContain('Install Hermes first')
// Backtick-escaped: chat renders markdown, and bare underscores would be
// eaten as italics (seen live: "OMIHERMESADAPTER_COMMAND").
expect(adapterActivationError('hermes')).toContain('`OMI_HERMES_ADAPTER_COMMAND`')
})
})