mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-02-03 21:03:08 +00:00
fix(opencode): parse api-key provider models
This commit is contained in:
@@ -3,7 +3,7 @@ import {
|
|||||||
OpencodeProvider,
|
OpencodeProvider,
|
||||||
resetToolUseIdCounter,
|
resetToolUseIdCounter,
|
||||||
} from '../../../src/providers/opencode-provider.js';
|
} from '../../../src/providers/opencode-provider.js';
|
||||||
import type { ProviderMessage } from '@automaker/types';
|
import type { ProviderMessage, ModelDefinition } from '@automaker/types';
|
||||||
import { collectAsyncGenerator } from '../../utils/helpers.js';
|
import { collectAsyncGenerator } from '../../utils/helpers.js';
|
||||||
import { spawnJSONLProcess, getOpenCodeAuthIndicators } from '@automaker/platform';
|
import { spawnJSONLProcess, getOpenCodeAuthIndicators } from '@automaker/platform';
|
||||||
|
|
||||||
@@ -128,6 +128,28 @@ describe('opencode-provider.ts', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('parseModelsOutput', () => {
|
||||||
|
it('should parse nested provider model IDs', () => {
|
||||||
|
const output = [
|
||||||
|
'openrouter/anthropic/claude-3.5-sonnet',
|
||||||
|
'openai/gpt-4o',
|
||||||
|
'amazon-bedrock/anthropic.claude-sonnet-4-5-20250929-v1:0',
|
||||||
|
].join('\n');
|
||||||
|
|
||||||
|
const parseModelsOutput = (
|
||||||
|
provider as unknown as { parseModelsOutput: (output: string) => ModelDefinition[] }
|
||||||
|
).parseModelsOutput;
|
||||||
|
const models = parseModelsOutput(output);
|
||||||
|
|
||||||
|
expect(models).toHaveLength(3);
|
||||||
|
const openrouterModel = models.find((model) => model.id.startsWith('openrouter/'));
|
||||||
|
|
||||||
|
expect(openrouterModel).toBeDefined();
|
||||||
|
expect(openrouterModel?.provider).toBe('openrouter');
|
||||||
|
expect(openrouterModel?.modelString).toBe('openrouter/anthropic/claude-3.5-sonnet');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('supportsFeature', () => {
|
describe('supportsFeature', () => {
|
||||||
it("should support 'tools' feature", () => {
|
it("should support 'tools' feature", () => {
|
||||||
expect(provider.supportsFeature('tools')).toBe(true);
|
expect(provider.supportsFeature('tools')).toBe(true);
|
||||||
|
|||||||
Reference in New Issue
Block a user