fix: restore current main ci checks

This commit is contained in:
Peter Steinberger
2026-05-02 05:26:38 +01:00
parent a2cab17ff0
commit 7729e6c104
7 changed files with 53 additions and 19 deletions

View File

@@ -95,6 +95,7 @@ function withGoogleModelProviderFallbacks(
return searchConfig;
}
const gemini = isRecord(searchConfig?.gemini) ? { ...searchConfig.gemini } : {};
const mergedSearchConfig = searchConfig ? { ...searchConfig } : {};
if (provider.apiKey !== undefined) {
gemini.providerApiKey = provider.apiKey;
}
@@ -102,7 +103,7 @@ function withGoogleModelProviderFallbacks(
gemini.providerBaseUrl = provider.baseUrl;
}
return {
...(searchConfig ?? {}),
...mergedSearchConfig,
gemini,
};
}

View File

@@ -3,6 +3,10 @@ import { withEnv, withEnvAsync, withFetchPreconnect } from "openclaw/plugin-sdk/
import { afterEach, describe, expect, it, vi } from "vitest";
import { __testing, createGeminiWebSearchProvider } from "./src/gemini-web-search-provider.js";
type TestModelProviderConfig = NonNullable<
NonNullable<OpenClawConfig["models"]>["providers"]
>[string];
function installGeminiFetch() {
const mockFetch = vi.fn((_input?: unknown, _init?: unknown) =>
Promise.resolve({
@@ -24,6 +28,21 @@ function installGeminiFetch() {
return mockFetch;
}
function createGoogleModelProviderConfig(
overrides: Partial<TestModelProviderConfig>,
): TestModelProviderConfig {
return {
baseUrl: "https://generativelanguage.googleapis.com/v1beta/",
models: [],
...overrides,
};
}
function getFetchHeaders(mockFetch: ReturnType<typeof installGeminiFetch>): Record<string, string> {
const init = mockFetch.mock.calls[0]?.[1] as { headers?: Record<string, string> } | undefined;
return init?.headers ?? {};
}
afterEach(() => {
vi.useRealTimers();
vi.restoreAllMocks();
@@ -118,9 +137,9 @@ describe("google web search provider", () => {
config: {
models: {
providers: {
google: {
google: createGoogleModelProviderConfig({
apiKey: "AIza-provider-test",
},
}),
},
},
},
@@ -129,9 +148,7 @@ describe("google web search provider", () => {
await tool?.execute({ query: "OpenClaw provider key fallback" });
expect(
(mockFetch.mock.calls[0]?.[1]?.headers as Record<string, string>)["x-goog-api-key"],
).toBe("AIza-provider-test");
expect(getFetchHeaders(mockFetch)["x-goog-api-key"]).toBe("AIza-provider-test");
});
});
@@ -154,9 +171,9 @@ describe("google web search provider", () => {
},
models: {
providers: {
google: {
google: createGoogleModelProviderConfig({
apiKey: "AIza-provider-test",
},
}),
},
},
},
@@ -165,9 +182,7 @@ describe("google web search provider", () => {
await tool?.execute({ query: "OpenClaw plugin key precedence" });
expect(
(mockFetch.mock.calls[0]?.[1]?.headers as Record<string, string>)["x-goog-api-key"],
).toBe("AIza-plugin-test");
expect(getFetchHeaders(mockFetch)["x-goog-api-key"]).toBe("AIza-plugin-test");
});
});
@@ -178,10 +193,10 @@ describe("google web search provider", () => {
config: {
models: {
providers: {
google: {
google: createGoogleModelProviderConfig({
apiKey: "AIza-provider-test",
baseUrl: "https://generativelanguage.googleapis.com/provider/v1beta/",
},
}),
},
},
},
@@ -214,9 +229,9 @@ describe("google web search provider", () => {
},
models: {
providers: {
google: {
google: createGoogleModelProviderConfig({
baseUrl: "https://generativelanguage.googleapis.com/provider/v1beta/",
},
}),
},
},
},

View File

@@ -1,9 +1,10 @@
import {
defineBundledChannelEntry,
type OpenClawPluginCommandDefinition,
type OpenClawPluginApi,
} from "openclaw/plugin-sdk/channel-entry-contract";
type RegisteredLineCardCommand = Parameters<OpenClawPluginApi["registerCommand"]>[0];
type RegisteredLineCardCommand = OpenClawPluginCommandDefinition;
let lineCardCommandPromise: Promise<RegisteredLineCardCommand> | null = null;

View File

@@ -19,11 +19,21 @@ import {
} from "../plugins/plugin-module-loader-cache.js";
import type { PluginRuntime } from "../plugins/runtime/types.js";
import { resolveLoaderPackageRoot } from "../plugins/sdk-alias.js";
import type { AnyAgentTool, OpenClawPluginApi, PluginCommandContext } from "../plugins/types.js";
import type {
AnyAgentTool,
OpenClawPluginApi,
OpenClawPluginCommandDefinition,
PluginCommandContext,
} from "../plugins/types.js";
import { toSafeImportPath } from "../shared/import-specifier.js";
import { normalizeLowercaseStringOrEmpty } from "../shared/string-coerce.js";
export type { AnyAgentTool, OpenClawPluginApi, PluginCommandContext };
export type {
AnyAgentTool,
OpenClawPluginApi,
OpenClawPluginCommandDefinition,
PluginCommandContext,
};
type ChannelEntryConfigSchema<TPlugin> =
TPlugin extends ChannelPlugin<unknown>

View File

@@ -165,7 +165,7 @@ function isTrustedSourceLinkedOfficialPackage(pkg: NonNullable<ClawHubPackageDet
const sourceRepo = normalizeOptionalString(pkg.verification?.sourceRepo);
return (
pkg.channel === "official" &&
pkg.isOfficial === true &&
pkg.isOfficial &&
pkg.verification?.tier === "source-linked" &&
(sourceRepo === "openclaw/openclaw" ||
sourceRepo === "github.com/openclaw/openclaw" ||

View File

@@ -191,6 +191,11 @@ export type ResolveRuntimeWebProviderSurfaceParams<
config: OpenClawConfig;
toolConfig: TToolConfig;
}) => unknown;
readConfiguredCredentialFallback?: (params: {
provider: TProvider;
config: OpenClawConfig;
toolConfig: TToolConfig;
}) => { path: string; value: unknown } | undefined;
ignoreKeylessProvidersForConfiguredSurface?: boolean;
emptyProvidersWhenSurfaceMissing?: boolean;
normalizeConfiguredProviderAgainstActiveProviders?: boolean;

View File

@@ -183,6 +183,8 @@ describe("web search runtime", () => {
providers: {
"custom-search": {
apiKey: "custom-provider-key",
baseUrl: "https://custom-search.example/v1",
models: [],
},
},
},