refactor!: remove google-antigravity provider support

This commit is contained in:
Peter Steinberger
2026-02-23 05:20:14 +01:00
parent 558a0137bb
commit 382fe8009a
41 changed files with 43 additions and 2373 deletions

View File

@@ -7,11 +7,6 @@ import {
resolveAwsSdkEnvVarName,
resolveEnvApiKey,
} from "../../agents/model-auth.js";
import {
ANTIGRAVITY_GEMINI_31_FORWARD_COMPAT_CANDIDATES,
ANTIGRAVITY_OPUS_46_FORWARD_COMPAT_CANDIDATES,
resolveForwardCompatModel,
} from "../../agents/model-forward-compat.js";
import { ensureOpenClawModelsJson } from "../../agents/models-config.js";
import { ensurePiAuthJsonFromAuthProfiles } from "../../agents/pi-auth-json.js";
import type { ModelRegistry } from "../../agents/pi-model-discovery.js";
@@ -106,23 +101,13 @@ export async function loadModelRegistry(cfg: OpenClawConfig) {
await ensurePiAuthJsonFromAuthProfiles(agentDir);
const authStorage = discoverAuthStorage(agentDir);
const registry = discoverModels(authStorage, agentDir);
const appended = appendAntigravityForwardCompatModels(registry.getAll(), registry);
const models = appended.models;
const synthesizedForwardCompat = appended.synthesizedForwardCompat;
const models = registry.getAll();
let availableKeys: Set<string> | undefined;
let availabilityErrorMessage: string | undefined;
try {
const availableModels = loadAvailableModels(registry);
availableKeys = new Set(availableModels.map((model) => modelKey(model.provider, model.id)));
for (const synthesized of synthesizedForwardCompat) {
if (hasAvailableTemplate(availableKeys, synthesized.templatePrefixes)) {
availableKeys.add(synthesized.key);
for (const aliasKey of synthesized.availabilityAliasKeys) {
availableKeys.add(aliasKey);
}
}
}
} catch (err) {
if (!shouldFallbackToAuthHeuristics(err)) {
throw err;
@@ -138,60 +123,6 @@ export async function loadModelRegistry(cfg: OpenClawConfig) {
return { registry, models, availableKeys, availabilityErrorMessage };
}
type SynthesizedForwardCompat = {
key: string;
templatePrefixes: readonly string[];
availabilityAliasKeys: readonly string[];
};
function appendAntigravityForwardCompatModels(
models: Model<Api>[],
modelRegistry: ModelRegistry,
): { models: Model<Api>[]; synthesizedForwardCompat: SynthesizedForwardCompat[] } {
const nextModels = [...models];
const synthesizedForwardCompat: SynthesizedForwardCompat[] = [];
const candidates = [
...ANTIGRAVITY_OPUS_46_FORWARD_COMPAT_CANDIDATES,
...ANTIGRAVITY_GEMINI_31_FORWARD_COMPAT_CANDIDATES,
];
for (const candidate of candidates) {
const key = modelKey("google-antigravity", candidate.id);
const hasForwardCompat = nextModels.some((model) => modelKey(model.provider, model.id) === key);
if (hasForwardCompat) {
continue;
}
const fallback = resolveForwardCompatModel("google-antigravity", candidate.id, modelRegistry);
if (!fallback) {
continue;
}
nextModels.push(fallback);
synthesizedForwardCompat.push({
key,
templatePrefixes: candidate.templatePrefixes,
availabilityAliasKeys: candidate.availabilityAliasIds.map((id) =>
modelKey("google-antigravity", id),
),
});
}
return { models: nextModels, synthesizedForwardCompat };
}
function hasAvailableTemplate(
availableKeys: Set<string>,
templatePrefixes: readonly string[],
): boolean {
for (const key of availableKeys) {
if (templatePrefixes.some((prefix) => key.startsWith(prefix))) {
return true;
}
}
return false;
}
export function toModelRow(params: {
model?: Model<Api>;
key: string;