mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-22 15:31:07 +00:00
* test: align extension runtime mocks with plugin-sdk Update stale extension tests to mock the plugin-sdk runtime barrels that production code now imports, and harden the Signal tool-result harness around system-event assertions so the channels lane matches current extension boundaries. Regeneration-Prompt: | Verify the failing channels-lane tests against current origin/main in an isolated worktree before changing anything. If the failures reproduce on main, keep the fix test-only unless production behavior is clearly wrong. Recent extension refactors moved Telegram, WhatsApp, and Signal code onto plugin-sdk runtime barrels, so update stale tests that still mock old core module paths to intercept the seams production code now uses. For Signal reaction notifications, avoid brittle assertions that depend on shared queued system-event state when a direct harness spy on enqueue behavior is sufficient. Preserve scope: only touch the failing tests and their local harness, then rerun the reproduced targeted tests plus the full channels lane and repo check gate. * test: fix extension test drift on main * fix: lazy-load bundled web search plugin registry * test: make matrix sweeper failure injection portable * fix: split heavy matrix runtime-api seams * fix: simplify bundled web search id lookup * test: tolerate windows env key casing
93 lines
3.1 KiB
TypeScript
93 lines
3.1 KiB
TypeScript
import { bundledWebSearchPluginRegistrations } from "../bundled-web-search-registry.js";
|
|
import { capturePluginRegistration } from "./captured-registration.js";
|
|
import type { PluginLoadOptions } from "./loader.js";
|
|
import { loadPluginManifestRegistry } from "./manifest-registry.js";
|
|
import type { PluginWebSearchProviderEntry } from "./types.js";
|
|
|
|
type BundledWebSearchProviderEntry = PluginWebSearchProviderEntry & { pluginId: string };
|
|
type BundledWebSearchPluginRegistration = (typeof bundledWebSearchPluginRegistrations)[number];
|
|
|
|
let bundledWebSearchProvidersCache: BundledWebSearchProviderEntry[] | null = null;
|
|
let bundledWebSearchPluginIdsCache: string[] | null = null;
|
|
|
|
function resolveBundledWebSearchPlugin(
|
|
entry: BundledWebSearchPluginRegistration,
|
|
): BundledWebSearchPluginRegistration["plugin"] | null {
|
|
try {
|
|
return entry.plugin;
|
|
} catch {
|
|
return null;
|
|
}
|
|
}
|
|
|
|
function listBundledWebSearchPluginRegistrations() {
|
|
return bundledWebSearchPluginRegistrations
|
|
.map((entry) => {
|
|
const plugin = resolveBundledWebSearchPlugin(entry);
|
|
return plugin ? { ...entry, plugin } : null;
|
|
})
|
|
.filter(
|
|
(
|
|
entry,
|
|
): entry is BundledWebSearchPluginRegistration & {
|
|
plugin: BundledWebSearchPluginRegistration["plugin"];
|
|
} => Boolean(entry),
|
|
);
|
|
}
|
|
|
|
function loadBundledWebSearchPluginIds(): string[] {
|
|
if (!bundledWebSearchPluginIdsCache) {
|
|
bundledWebSearchPluginIdsCache = listBundledWebSearchPluginRegistrations()
|
|
.map(({ plugin }) => plugin.id)
|
|
.toSorted((left, right) => left.localeCompare(right));
|
|
}
|
|
return bundledWebSearchPluginIdsCache;
|
|
}
|
|
|
|
export function listBundledWebSearchPluginIds(): string[] {
|
|
return loadBundledWebSearchPluginIds();
|
|
}
|
|
|
|
function loadBundledWebSearchProviders(): BundledWebSearchProviderEntry[] {
|
|
if (!bundledWebSearchProvidersCache) {
|
|
bundledWebSearchProvidersCache = listBundledWebSearchPluginRegistrations().flatMap(
|
|
({ plugin }) =>
|
|
capturePluginRegistration(plugin).webSearchProviders.map((provider) => ({
|
|
...provider,
|
|
pluginId: plugin.id,
|
|
})),
|
|
);
|
|
}
|
|
return bundledWebSearchProvidersCache;
|
|
}
|
|
|
|
export function resolveBundledWebSearchPluginIds(params: {
|
|
config?: PluginLoadOptions["config"];
|
|
workspaceDir?: string;
|
|
env?: PluginLoadOptions["env"];
|
|
}): string[] {
|
|
const registry = loadPluginManifestRegistry({
|
|
config: params.config,
|
|
workspaceDir: params.workspaceDir,
|
|
env: params.env,
|
|
});
|
|
const bundledWebSearchPluginIdSet = new Set<string>(loadBundledWebSearchPluginIds());
|
|
return registry.plugins
|
|
.filter((plugin) => plugin.origin === "bundled" && bundledWebSearchPluginIdSet.has(plugin.id))
|
|
.map((plugin) => plugin.id)
|
|
.toSorted((left, right) => left.localeCompare(right));
|
|
}
|
|
|
|
export function listBundledWebSearchProviders(): PluginWebSearchProviderEntry[] {
|
|
return loadBundledWebSearchProviders();
|
|
}
|
|
|
|
export function resolveBundledWebSearchPluginId(
|
|
providerId: string | undefined,
|
|
): string | undefined {
|
|
if (!providerId) {
|
|
return undefined;
|
|
}
|
|
return loadBundledWebSearchProviders().find((provider) => provider.id === providerId)?.pluginId;
|
|
}
|