From a53a5222c13433459df52f771d3a7db40c6f3f99 Mon Sep 17 00:00:00 2001 From: francy51 Date: Sat, 28 Feb 2026 15:05:46 -0500 Subject: [PATCH] Remove OpenClaw fallback compatibility --- README.md | 19 ------------------- lib/server/ai.test.ts | 37 +------------------------------------ lib/server/ai.ts | 33 --------------------------------- 3 files changed, 1 insertion(+), 88 deletions(-) diff --git a/README.md b/README.md index 58432e8..11b88b0 100644 --- a/README.md +++ b/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`. diff --git a/lib/server/ai.test.ts b/lib/server/ai.test.ts index 36ec12d..b4f4e32 100644 --- a/lib/server/ai.test.ts +++ b/lib/server/ai.test.ts @@ -5,7 +5,6 @@ import { runAiAnalysis } from './ai'; -type EnvSource = Record; 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; diff --git a/lib/server/ai.ts b/lib/server/ai.ts index 26a2cd1..2a48c4d 100644 --- a/lib/server/ai.ts +++ b/lib/server/ai.ts @@ -31,23 +31,8 @@ type RunAiAnalysisOptions = GetAiConfigOptions & { generate?: (input: AiGenerateInput) => Promise; }; -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