fix(opencode): keep model switching runtime-hot

This commit is contained in:
2026-08-21 01:26:20 +08:00
parent 605fef417f
commit cce772299a
10 changed files with 256 additions and 88 deletions

View File

@@ -341,6 +341,7 @@ describe('buildOpencodeRuntimeConfig', () => {
});
it('routes imported Works Square models through the local AI proxy without gateway-token headers', async () => {
const resolveApiKey = vi.fn().mockResolvedValue('stale-host-api-token');
const result = await buildOpencodeRuntimeConfig({
accounts: [
createAccount({
@@ -358,7 +359,8 @@ describe('buildOpencodeRuntimeConfig', () => {
}),
],
defaultAccountId: 'niancode-user-models',
resolveApiKey: vi.fn().mockResolvedValue('local-host-api-token'),
resolveApiKey,
localProxyApiKey: 'current-host-api-token',
});
expect(result.config.provider['niancode-user-models'].options).toEqual({
@@ -368,8 +370,9 @@ describe('buildOpencodeRuntimeConfig', () => {
expect(JSON.stringify(result.config)).not.toContain('X-Works-Square-AI-Token');
expect(JSON.stringify(result.config)).not.toContain('https://open-api.example.com');
expect(result.env).toEqual({
NIANCODE_OPENCODE_NIANCODE_USER_MODELS_API_KEY: 'local-host-api-token',
NIANCODE_OPENCODE_NIANCODE_USER_MODELS_API_KEY: 'current-host-api-token',
});
expect(resolveApiKey).not.toHaveBeenCalled();
});
it('strips DeepSeek routing prefixes from imported Works Square runtime models', async () => {