forked from BasedHardware/omi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinterface.test.ts
More file actions
95 lines (88 loc) · 3.26 KB
/
Copy pathinterface.test.ts
File metadata and controls
95 lines (88 loc) · 3.26 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
import { describe, expect, it } from 'vitest'
import {
adapterCapabilitiesFor,
assertAdapterBindingContract,
assertAdapterAttemptResultContract,
isProductionAdapterId,
type AdapterAttemptContext,
type AdapterBindingHandle
} from './interface'
function makeBinding(overrides: Partial<AdapterBindingHandle> = {}): AdapterBindingHandle {
return {
sessionId: 'omi-session',
adapterId: 'acp',
adapterNativeSessionId: 'native-1',
resumeFidelity: 'native',
cwd: 'C:/work',
...overrides
}
}
function makeContext(binding: AdapterBindingHandle): AdapterAttemptContext {
return {
sessionId: 'omi-session',
runId: 'run-1',
attemptId: 'attempt-1',
binding,
prompt: [{ type: 'text', text: 'hi' }],
mode: 'act'
}
}
describe('adapter contracts', () => {
it('rejects an empty native session id', () => {
expect(() =>
assertAdapterBindingContract(makeBinding({ adapterNativeSessionId: '' }), 'openBinding')
).toThrow('empty adapterNativeSessionId')
})
it('rejects conflating the Omi session id with the native session id', () => {
expect(() =>
assertAdapterBindingContract(
makeBinding({ adapterNativeSessionId: 'omi-session' }),
'openBinding'
)
).toThrow('conflated Omi sessionId')
})
it('rejects an attempt result whose native id does not match its binding', () => {
const binding = makeBinding()
const context = makeContext(binding)
expect(() =>
assertAdapterAttemptResultContract(
context,
{ text: '', adapterSessionId: 'other-native', terminalStatus: 'succeeded' },
'executeAttempt'
)
).toThrow('for binding native-1')
expect(() =>
assertAdapterAttemptResultContract(
context,
{ text: '', adapterSessionId: 'omi-session', terminalStatus: 'succeeded' },
'executeAttempt'
)
).toThrow('conflated Omi sessionId')
expect(() =>
assertAdapterAttemptResultContract(
context,
{ text: 'ok', adapterSessionId: 'native-1', terminalStatus: 'succeeded' },
'executeAttempt'
)
).not.toThrow()
})
})
describe('capability matrix', () => {
it('derives restart behavior from resume/pinning expectations', () => {
expect(adapterCapabilitiesFor('acp').restartBehavior).toBe('native_bindings_survive')
expect(adapterCapabilitiesFor('openclaw').restartBehavior).toBe('native_bindings_survive')
expect(adapterCapabilitiesFor('hermes').restartBehavior).toBe('process_local_bindings_stale')
expect(adapterCapabilitiesFor('codex').restartBehavior).toBe('process_local_bindings_stale')
// pi-mono has no native resume but pins its worker → process_local_bindings_stale.
expect(adapterCapabilitiesFor('pi-mono').restartBehavior).toBe('process_local_bindings_stale')
})
it('knows the production adapters, including the managed-cloud pi-mono (PR-D)', () => {
expect(isProductionAdapterId('acp')).toBe(true)
expect(isProductionAdapterId('openclaw')).toBe(true)
expect(isProductionAdapterId('hermes')).toBe(true)
expect(isProductionAdapterId('codex')).toBe(true)
// pi-mono is now a registered managed-cloud production adapter (matrix member).
expect(isProductionAdapterId('pi-mono')).toBe(true)
expect(isProductionAdapterId('a2a')).toBe(false)
})
})