Remove OpenClaw fallback compatibility
This commit is contained in:
19
README.md
19
README.md
@@ -100,25 +100,6 @@ WORKFLOW_LOCAL_QUEUE_CONCURRENCY=100
|
||||
If `ZHIPU_API_KEY` is unset, the app uses local fallback analysis so task workflows still run.
|
||||
`ZHIPU_BASE_URL` is deprecated and ignored; runtime always uses `https://api.z.ai/api/coding/paas/v4`.
|
||||
|
||||
## Migration from OPENCLAW_* to ZHIPU_*
|
||||
|
||||
This repository now uses direct provider calls through AI SDK. The legacy gateway container path is removed.
|
||||
The AI runtime endpoint is fixed to `https://api.z.ai/api/coding/paas/v4`.
|
||||
|
||||
| Legacy variable | Replacement |
|
||||
| --- | --- |
|
||||
| `OPENCLAW_API_KEY` | `ZHIPU_API_KEY` |
|
||||
| `OPENCLAW_MODEL` | `ZHIPU_MODEL` |
|
||||
| `OPENCLAW_BASE_URL` | Removed (runtime endpoint is hardcoded to `https://api.z.ai/api/coding/paas/v4`) |
|
||||
| `OPENCLAW_AUTH_MODE` | Removed (not needed with direct provider calls) |
|
||||
| `OPENCLAW_BASIC_AUTH_USERNAME` | Removed |
|
||||
| `OPENCLAW_BASIC_AUTH_PASSWORD` | Removed |
|
||||
| `OPENCLAW_API_KEY_HEADER` | Removed |
|
||||
| `OPENCLAW_PORT` | Removed (no gateway service) |
|
||||
| `OPENCLAW_IMAGE` | Removed |
|
||||
| `OPENCLAW_BUILD_CONTEXT` | Removed |
|
||||
| `OPENCLAW_DOCKERFILE` | Removed |
|
||||
|
||||
## API surface
|
||||
|
||||
All endpoints below are defined in Elysia at `lib/server/api/app.ts` and exposed via `app/api/[[...slugs]]/route.ts`.
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -31,23 +31,8 @@ type RunAiAnalysisOptions = GetAiConfigOptions & {
|
||||
generate?: (input: AiGenerateInput) => Promise<AiGenerateOutput>;
|
||||
};
|
||||
|
||||
const DEPRECATED_LEGACY_GATEWAY_ENV_KEYS = [
|
||||
'OPENCLAW_BASE_URL',
|
||||
'OPENCLAW_API_KEY',
|
||||
'OPENCLAW_MODEL',
|
||||
'OPENCLAW_AUTH_MODE',
|
||||
'OPENCLAW_BASIC_AUTH_USERNAME',
|
||||
'OPENCLAW_BASIC_AUTH_PASSWORD',
|
||||
'OPENCLAW_API_KEY_HEADER',
|
||||
'OPENCLAW_PORT',
|
||||
'OPENCLAW_IMAGE',
|
||||
'OPENCLAW_BUILD_CONTEXT',
|
||||
'OPENCLAW_DOCKERFILE'
|
||||
] as const;
|
||||
|
||||
const CODING_API_BASE_URL = 'https://api.z.ai/api/coding/paas/v4';
|
||||
|
||||
let warnedDeprecatedGatewayEnv = false;
|
||||
let warnedIgnoredZhipuBaseUrl = false;
|
||||
|
||||
function envValue(name: string, env: EnvSource = process.env) {
|
||||
@@ -69,22 +54,6 @@ function parseTemperature(value: string | undefined) {
|
||||
return Math.min(Math.max(parsed, 0), 2);
|
||||
}
|
||||
|
||||
function warnDeprecatedGatewayEnv(env: EnvSource, warn: (message: string) => void) {
|
||||
if (warnedDeprecatedGatewayEnv) {
|
||||
return;
|
||||
}
|
||||
|
||||
const presentKeys = DEPRECATED_LEGACY_GATEWAY_ENV_KEYS.filter((key) => Boolean(envValue(key, env)));
|
||||
if (presentKeys.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
warnedDeprecatedGatewayEnv = true;
|
||||
warn(
|
||||
`[AI SDK] Deprecated OPENCLAW_* variables are ignored after migration: ${presentKeys.join(', ')}. Use ZHIPU_API_KEY, ZHIPU_MODEL, and AI_TEMPERATURE.`
|
||||
);
|
||||
}
|
||||
|
||||
function warnIgnoredZhipuBaseUrl(env: EnvSource, warn: (message: string) => void) {
|
||||
if (warnedIgnoredZhipuBaseUrl) {
|
||||
return;
|
||||
@@ -134,7 +103,6 @@ async function defaultGenerate(input: AiGenerateInput): Promise<AiGenerateOutput
|
||||
|
||||
export function getAiConfig(options?: GetAiConfigOptions) {
|
||||
const env = options?.env ?? process.env;
|
||||
warnDeprecatedGatewayEnv(env, options?.warn ?? console.warn);
|
||||
warnIgnoredZhipuBaseUrl(env, options?.warn ?? console.warn);
|
||||
|
||||
return {
|
||||
@@ -185,6 +153,5 @@ export async function runAiAnalysis(prompt: string, systemPrompt?: string, optio
|
||||
}
|
||||
|
||||
export function __resetAiWarningsForTests() {
|
||||
warnedDeprecatedGatewayEnv = false;
|
||||
warnedIgnoredZhipuBaseUrl = false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user