import { createAutoTestSdkProvider, supportsCloudWorkflowSpecVersion } from './src/tools/autotest-pipeline.js';

function assert(condition, message) {
  if (!condition) throw new Error(message);
}

console.log('\n── AutoTest SDK Provider ──');

assert(supportsCloudWorkflowSpecVersion('3.13') === true, 'cloud runner should accept workflow spec 3.13');
assert(supportsCloudWorkflowSpecVersion('3.16') === false, 'cloud runner should skip unsupported workflow spec 3.16');

const apiProvider = createAutoTestSdkProvider({
  apiKey: 'test-key',
  llmProvider: 'cli',
  cliAvailable: true,
  model: 'claude-sonnet-4-6',
});
assert(apiProvider.name === 'api-key', 'SDK fallback should prefer API key when available');

const savedApiKey = process.env.ANTHROPIC_API_KEY;
delete process.env.ANTHROPIC_API_KEY;
const cliProvider = createAutoTestSdkProvider({
  llmProvider: 'cli',
  cliAvailable: true,
  model: 'claude-sonnet-4-6',
});
assert(cliProvider.name === 'cli', 'SDK fallback should use CLI when no API key is configured');
if (savedApiKey !== undefined) process.env.ANTHROPIC_API_KEY = savedApiKey;

console.log('PASS test-autotest-sdk-provider.js');
