forked from BasedHardware/omi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontrolPlane.spawnAdapter.test.ts
More file actions
54 lines (48 loc) · 1.94 KB
/
Copy pathcontrolPlane.spawnAdapter.test.ts
File metadata and controls
54 lines (48 loc) · 1.94 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
// resolveSpawnableCodingAgentAdapterId — the host's connected-coding-agent pick
// behind spawn_agent's managed-cloud fallback (see controlTools.test.ts for the
// dispatch-level regression suite). Hermetic: every impure edge (env, Claude
// OAuth status, kernel registration) is injected, so nothing here reads the real
// credentials file or touches the process-wide kernel singleton.
import { describe, expect, it } from 'vitest'
import { resolveSpawnableCodingAgentAdapterId } from './controlPlane'
/** No adapter launch commands configured. */
const EMPTY_ENV: NodeJS.ProcessEnv = {}
describe('resolveSpawnableCodingAgentAdapterId', () => {
it('picks Claude Code (acp) when its OAuth is connected', () => {
const registered: string[] = []
const picked = resolveSpawnableCodingAgentAdapterId({
env: EMPTY_ENV,
claudeConnected: () => true,
ensureRegistered: (id) => {
registered.push(id)
return true
}
})
expect(picked).toBe('acp')
expect(registered).toEqual(['acp'])
})
it('skips a signed-out Claude Code and falls through to a configured external agent', () => {
const picked = resolveSpawnableCodingAgentAdapterId({
env: { OMI_OPENCLAW_ADAPTER_COMMAND: 'openclaw acp' },
claudeConnected: () => false,
ensureRegistered: () => true
})
expect(picked).toBe('openclaw')
})
it('returns null when nothing is connected (signed-out Claude, no external commands)', () => {
const picked = resolveSpawnableCodingAgentAdapterId({
env: EMPTY_ENV,
claudeConnected: () => false,
ensureRegistered: () => true
})
expect(picked).toBeNull()
})
it('falls through past an agent whose kernel registration fails', () => {
const picked = resolveSpawnableCodingAgentAdapterId({
env: { OMI_HERMES_ADAPTER_COMMAND: 'hermes acp' },
claudeConnected: () => true,
ensureRegistered: (id) => id !== 'acp'
})
expect(picked).toBe('hermes')
})
})