refactor(plugins): remove dead provider seams (#124134)

This commit is contained in:
Peter Steinberger
2026-08-15 02:40:46 -07:00
committed by GitHub
parent 9fabdb40dc
commit 12ff4be126
5 changed files with 1 additions and 88 deletions
-14
View File
@@ -17,7 +17,6 @@ import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it, vi }
import { applyCliRuntimeRecallTimeoutDefault } from "./config.js";
import plugin, { testing } from "./index.js";
import { resolveActiveRecallForRun } from "./recall-state.js";
import { hasRememberAcrossConversationsAgent } from "./session-policy.js";
// Match only lone surrogates so valid supplementary-plane characters remain allowed.
const UNPAIRED_SURROGATE_RE =
@@ -821,19 +820,6 @@ describe("active-memory plugin", () => {
expect(hoisted.getActiveMemorySearchManager).not.toHaveBeenCalled();
});
it("does not synthesize a main agent when every configured agent opts out", () => {
expect(
hasRememberAcrossConversationsAgent({
agents: {
list: [
{ id: "personal", memory: { search: { rememberAcrossConversations: false } } },
{ id: "support", memory: { search: { rememberAcrossConversations: false } } },
],
},
}),
).toBe(false);
});
it("keeps the outer hook timeout at the live-config ceiling", () => {
registerPluginConfig({ timeoutMs: 90_000 });
@@ -127,12 +127,6 @@ function isActiveMemoryPluginEnabled(cfg: OpenClawConfig): boolean {
return plugins.entries["active-memory"]?.enabled !== false;
}
function hasRememberAcrossConversationsAgent(cfg: OpenClawConfig): boolean {
const configuredAgentIds = cfg.agents?.list?.map((agent) => agent.id) ?? [];
const agentIds = configuredAgentIds.length > 0 ? configuredAgentIds : ["main"];
return agentIds.some((agentId) => resolveRememberAcrossConversations(cfg, agentId));
}
function shouldRememberAcrossConversations(cfg: OpenClawConfig, agentId: string): boolean {
return resolveRememberAcrossConversations(cfg, agentId);
}
@@ -438,7 +432,6 @@ export {
isEnabledForAgent,
isPrivateRecallDestination,
isSessionActiveMemoryDisabled,
hasRememberAcrossConversationsAgent,
lacksAdminToMutateActiveMemoryGlobal,
resolveCommandSessionKey,
setSessionActiveMemoryDisabled,
-40
View File
@@ -45,17 +45,6 @@ async function withLiveChutesDiscovery<T>(
}
}
function createAuthEchoFetchMock() {
return vi.fn().mockImplementation((_url, init?: { headers?: HeadersInit }) => {
const auth = readAuthorizationHeader(init);
return Promise.resolve(
jsonResponse({
data: [{ id: auth ? `${auth}-model` : "public-model" }],
}),
);
});
}
function readAuthorizationHeader(init?: { headers?: HeadersInit }): string {
const headers = init?.headers;
if (headers instanceof Headers) {
@@ -311,35 +300,6 @@ describe("chutes-models", () => {
});
});
it("evicts oldest token entries when cache reaches max size", async () => {
const mockFetch = createAuthEchoFetchMock();
await withLiveChutesDiscovery(mockFetch, async () => {
for (let i = 0; i < 150; i += 1) {
await discoverChutesModels(`cache-token-${i}`);
}
await discoverChutesModels("cache-token-0");
expect(mockFetch).toHaveBeenCalledTimes(151);
});
});
it("prunes expired token cache entries during subsequent discovery", async () => {
const mockFetch = createAuthEchoFetchMock();
await withLiveChutesDiscovery(
mockFetch,
async () => {
await discoverChutesModels("token-a");
vi.advanceTimersByTime(5 * 60 * 1000 + 1);
await discoverChutesModels("token-b");
await discoverChutesModels("token-a");
expect(mockFetch).toHaveBeenCalledTimes(3);
},
{ now: "2026-03-01T00:00:00.000Z" },
);
});
it("does not cache 401 fallback under the failed token key", async () => {
const mockFetch = vi.fn().mockImplementation((_url, init?: { headers?: HeadersInit }) => {
if (readAuthorizationHeader(init) === "Bearer failed-token") {
+1 -10
View File
@@ -1,11 +1,6 @@
// Xai tests cover api plugin behavior.
import { describe, expect, it } from "vitest";
import {
isXaiModelHint,
resolveXaiForwardCompatModel,
resolveXaiTransport,
XAI_BASE_URL,
} from "./api.js";
import { resolveXaiForwardCompatModel, resolveXaiTransport, XAI_BASE_URL } from "./api.js";
describe("xai api helpers", () => {
it("uses shared endpoint classification for native xAI transports", () => {
@@ -68,8 +63,4 @@ describe("xai api helpers", () => {
expect(model?.reasoning).toBe(true);
},
);
it("detects xAI model hints", () => {
expect(isXaiModelHint("x-ai/grok-4")).toBe(true);
});
});
-17
View File
@@ -1,5 +1,4 @@
// Xai API module exposes the plugin public contract.
import { normalizeOptionalLowercaseString } from "openclaw/plugin-sdk/string-coerce-runtime";
import {
applyXaiModelCompat,
HTML_ENTITY_TOOL_CALL_ARGUMENTS_ENCODING,
@@ -26,20 +25,4 @@ export { applyXaiRuntimeModelCompat } from "./runtime-model-compat.js";
export { applyXaiModelCompat, HTML_ENTITY_TOOL_CALL_ARGUMENTS_ENCODING, XAI_TOOL_SCHEMA_PROFILE };
export { resolveXaiTransport } from "./provider-routing.js";
export function isXaiModelHint(modelId: string): boolean {
return getModelProviderHint(modelId) === "x-ai";
}
export { normalizeNativeXaiModelId as normalizeXaiModelId };
function getModelProviderHint(modelId: string): string | null {
const trimmed = normalizeOptionalLowercaseString(modelId);
if (!trimmed) {
return null;
}
const slashIndex = trimmed.indexOf("/");
if (slashIndex <= 0) {
return null;
}
return trimmed.slice(0, slashIndex) || null;
}