Remove OpenClaw fallback compatibility

This commit is contained in:
2026-02-28 15:05:46 -05:00
parent b9f3b7f9d0
commit a53a5222c1
3 changed files with 1 additions and 88 deletions

View File

@@ -5,7 +5,6 @@ import {
runAiAnalysis
} from './ai';
type EnvSource = Record<string, string | undefined>;
const CODING_API_BASE_URL = 'https://api.z.ai/api/coding/paas/v4';
describe('ai config and runtime', () => {
@@ -87,25 +86,10 @@ describe('ai config and runtime', () => {
expect(generate).not.toHaveBeenCalled();
});
it('warns once when deprecated OPENCLAW_* env vars are present', () => {
const warn = mock((_message: string) => {});
const env: EnvSource = {
OPENCLAW_API_KEY: 'legacy-key',
OPENCLAW_BASE_URL: 'http://legacy.local',
ZHIPU_API_KEY: 'new-key'
};
getAiConfig({ env, warn });
getAiConfig({ env, warn });
expect(warn).toHaveBeenCalledTimes(1);
});
it('warns once when ZHIPU_BASE_URL is set because coding endpoint is hardcoded', () => {
const warn = mock((_message: string) => {});
const env: EnvSource = {
const env = {
ZHIPU_API_KEY: 'new-key',
ZHIPU_BASE_URL: 'https://api.z.ai/api/paas/v4'
};
@@ -116,25 +100,6 @@ describe('ai config and runtime', () => {
expect(warn).toHaveBeenCalledTimes(1);
});
it('does not consume OPENCLAW_* values for live generation', async () => {
const generate = mock(async () => ({ text: 'should-not-be-used' }));
const warn = mock((_message: string) => {});
const result = await runAiAnalysis('Legacy-only env prompt', undefined, {
env: {
OPENCLAW_API_KEY: 'legacy-key',
OPENCLAW_MODEL: 'legacy-model'
},
warn,
generate
});
expect(result.provider).toBe('local-fallback');
expect(result.model).toBe('glm-4.7-flashx');
expect(generate).not.toHaveBeenCalled();
expect(warn).toHaveBeenCalledTimes(1);
});
it('uses configured ZHIPU values and injected generator when API key exists', async () => {
const createModel = mock((config: {
apiKey?: string;