forked from BasedHardware/omi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathacp.integration.test.ts
More file actions
50 lines (45 loc) · 2.01 KB
/
Copy pathacp.integration.test.ts
File metadata and controls
50 lines (45 loc) · 2.01 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
// Real-subprocess integration test: no child_process mocking. Spawns the
// fixture fake-ACP peer as an actual Node child process, exercising the
// adapter's real spawn / readline framing / kill machinery — the parts the
// mocked suites structurally cannot cover. Requires no coding-agent install.
import { join } from 'node:path'
import { describe, expect, it } from 'vitest'
import { ClaudeCodeRuntimeAdapter } from './claudeCode'
import { assertAdapterBindingContract, type AdapterStreamEvent } from './interface'
const FIXTURE = join(__dirname, 'fixtures', 'fakeAcpSubprocess.mjs')
describe('AcpRuntimeAdapter against a real subprocess', () => {
it('runs the full open → prompt → stream → result → stop lifecycle', async () => {
const adapter = new ClaudeCodeRuntimeAdapter({ acpEntry: FIXTURE })
try {
const binding = await adapter.openBinding({
sessionId: 'omi-session',
cwd: process.cwd()
})
assertAdapterBindingContract(binding, 'openBinding')
expect(binding.adapterNativeSessionId).toBe('fake-native-session')
const events: AdapterStreamEvent[] = []
const result = await adapter.executeAttempt(
{
sessionId: 'omi-session',
runId: 'run-1',
attemptId: 'attempt-1',
binding,
prompt: [{ type: 'text', text: 'integration ping' }],
mode: 'act'
},
(event) => events.push(event),
new AbortController().signal
)
expect(events).toContainEqual({ type: 'text_delta', text: 'echo: integration ping' })
expect(result.text).toBe('echo: integration ping')
expect(result.adapterSessionId).toBe('fake-native-session')
expect(result.terminalStatus).toBe('succeeded')
expect(result.inputTokens).toBe(3)
// The standard usage_update notification (0.002 cumulative) takes
// precedence over the legacy per-turn _meta fallback (0.001).
expect(result.costUsd).toBeCloseTo(0.002)
} finally {
await adapter.stop()
}
}, 15_000)
})