/** * 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(); }); }); });