runtime-resolver.test.js
1.71 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
/**
* Unit Tests — core/runtime-resolver.js
*
* runtime-resolver is a pure function that takes (agent, client) config objects
* and infers protocol, transport, launcher from them.
*/
import { describe, it, expect } from 'vitest';
const { resolve, buildLauncherConfig } = require('../../src/core/runtime-resolver');
describe('runtime-resolver', () => {
describe('resolve', () => {
it('should resolve local claude agent', () => {
const config = resolve(
{ type: 'executor', client: 'claude', deploy: 'local' },
{ name: 'claude', command: 'claude', acpArgs: ['--chat'], acpProtocol: 'claude-stream' }
);
expect(config).toBeDefined();
expect(config.protocol).toBe('claude-stream');
expect(config.transport).toBe('pipe');
});
it('should resolve acp protocol for non-claude clients', () => {
const config = resolve(
{ type: 'executor', client: 'gemini', deploy: 'local' },
{ name: 'gemini', command: 'gemini-cli', acpArgs: [], acpProtocol: 'acp' }
);
expect(config.protocol).toBe('acp');
});
it('should throw if client is missing', () => {
expect(() => resolve({ type: 'executor', deploy: 'local' }, undefined)).toThrow();
});
});
describe('buildLauncherConfig', () => {
it('should build process launcher config for local deploy', () => {
const config = buildLauncherConfig(
{ command: 'claude', acpArgs: ['--chat'] },
'local'
);
expect(config).toBeDefined();
expect(config.type).toBe('process');
expect(config.command).toBe('claude');
});
it('should throw for unknown deploy type', () => {
expect(() => buildLauncherConfig({}, 'unknown')).toThrow();
});
});
});