Skip to content

Commit bcc0e3d

Browse files
committed
refactor: remove core test extension leaks
1 parent 8cd9007 commit bcc0e3d

20 files changed

Lines changed: 149 additions & 41 deletions

extensions/matrix/runtime-api.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export {
99
export * from "./src/account-selection.js";
1010
export * from "./src/env-vars.js";
1111
export * from "./src/storage-paths.js";
12+
export { ensureMatrixSdkInstalled, isMatrixSdkAvailable } from "./src/matrix/deps.js";
1213
export {
1314
assertHttpUrlTargetsPrivateNetwork,
1415
closeDispatcher,

src/acp/persistent-bindings.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { beforeEach, describe, expect, it, vi } from "vitest";
2-
import { parseTelegramTopicConversation } from "../../extensions/telegram/api.js";
32
import { resolveAgentWorkspaceDir } from "../agents/agent-scope.js";
43
import type { ChannelConfiguredBindingProvider, ChannelPlugin } from "../channels/plugins/types.js";
54
import type { OpenClawConfig } from "../config/config.js";
5+
import { parseTelegramTopicConversation } from "../plugin-sdk/telegram.js";
66
import { setActivePluginRegistry } from "../plugins/runtime.js";
77
import { createChannelTestPluginBase, createTestRegistry } from "../test-utils/channel-plugins.js";
88
import { buildConfiguredAcpSessionKey } from "./persistent-bindings.types.js";

src/agents/minimax-docs.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
MINIMAX_DEFAULT_MODEL_ID,
66
MINIMAX_DEFAULT_MODEL_REF,
77
MINIMAX_TEXT_MODEL_REFS,
8-
} from "../../extensions/minimax/api.js";
8+
} from "../plugin-sdk/minimax.js";
99

1010
const repoRoot = path.resolve(import.meta.dirname, "../..");
1111
const testingDoc = fs.readFileSync(path.join(repoRoot, "docs/help/testing.md"), "utf8");

src/agents/ollama-stream.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
buildAssistantMessage,
99
parseNdjsonStream,
1010
resolveOllamaBaseUrlForRun,
11-
} from "../../extensions/ollama/runtime-api.js";
11+
} from "../plugin-sdk/ollama-runtime.js";
1212
import {
1313
__testing as extraParamsTesting,
1414
applyExtraParamsToAgent,

src/agents/pi-embedded-runner-extraparams.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import type { StreamFn } from "@mariozechner/pi-agent-core";
22
import type { Context, Model, SimpleStreamOptions } from "@mariozechner/pi-ai";
33
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
4-
import { createConfiguredOllamaCompatNumCtxWrapper } from "../../extensions/ollama/runtime-api.js";
54
import {
65
createAnthropicBetaHeadersWrapper,
76
createAnthropicFastModeWrapper,
@@ -10,6 +9,7 @@ import {
109
resolveAnthropicFastMode,
1110
resolveAnthropicServiceTier,
1211
} from "../../test/helpers/providers/anthropic-contract.js";
12+
import { createConfiguredOllamaCompatNumCtxWrapper } from "../plugin-sdk/ollama-runtime.js";
1313
import { __testing as extraParamsTesting } from "./pi-embedded-runner/extra-params.js";
1414
import {
1515
createOpenRouterSystemCacheWrapper,

src/agents/pi-embedded-runner/run/attempt.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import { streamSimple } from "@mariozechner/pi-ai";
22
import { describe, expect, it, vi } from "vitest";
3+
import type { OpenClawConfig } from "../../../config/config.js";
34
import {
45
isOllamaCompatProvider,
56
resolveOllamaCompatNumCtxEnabled,
67
shouldInjectOllamaCompatNumCtx,
78
wrapOllamaCompatNumCtx,
8-
} from "../../../../extensions/ollama/runtime-api.js";
9-
import type { OpenClawConfig } from "../../../config/config.js";
9+
} from "../../../plugin-sdk/ollama-runtime.js";
1010
import { appendBootstrapPromptWarning } from "../../bootstrap-budget.js";
1111
import { SYSTEM_PROMPT_CACHE_BOUNDARY } from "../../system-prompt-cache-boundary.js";
1212
import { buildAgentSystemPrompt } from "../../system-prompt.js";

src/agents/pi-tools.create-openclaw-coding-tools.adds-claude-style-aliases-schemas-without-dropping-c.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import fs from "node:fs/promises";
22
import os from "node:os";
33
import path from "node:path";
44
import { describe, expect, it } from "vitest";
5-
import { applyXaiModelCompat } from "../../extensions/xai/api.js";
65
import {
6+
applyXaiModelCompat,
77
findUnsupportedSchemaKeywords,
88
GEMINI_UNSUPPORTED_SCHEMA_KEYWORDS,
99
XAI_UNSUPPORTED_SCHEMA_KEYWORDS,

src/agents/pi-tools.model-provider-collision.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { describe, expect, it } from "vitest";
22
import {
33
HTML_ENTITY_TOOL_CALL_ARGUMENTS_ENCODING,
44
XAI_TOOL_SCHEMA_PROFILE,
5-
} from "../../extensions/xai/api.js";
5+
} from "../plugin-sdk/provider-tools.js";
66
import { __testing } from "./pi-tools.js";
77
import type { AnyAgentTool } from "./pi-tools.types.js";
88

src/channels/plugins/contracts/group-policy.provider-owned.contract.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { describe, expect, it } from "vitest";
2-
import { evaluateZaloGroupAccess } from "../../../../extensions/zalo/test-api.js";
2+
import { evaluateZaloGroupAccess } from "../../../plugin-sdk/zalo-setup.js";
33

44
function expectAllowedZaloGroupAccess(params: Parameters<typeof evaluateZaloGroupAccess>[0]) {
55
expect(evaluateZaloGroupAccess(params)).toMatchObject({

src/commands/doctor/shared/legacy-web-search-migrate.ts

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import type { OpenClawConfig } from "../../../config/config.js";
22
import { mergeMissing } from "../../../config/legacy.shared.js";
3-
import { BUNDLED_WEB_SEARCH_PROVIDER_PLUGIN_IDS } from "../../../plugins/bundled-capability-metadata.js";
3+
import {
4+
loadPluginManifestRegistry,
5+
resolveManifestContractOwnerPluginId,
6+
} from "../../../plugins/manifest-registry.js";
47

58
type JsonRecord = Record<string, unknown>;
69

@@ -9,12 +12,11 @@ const MODERN_SCOPED_WEB_SEARCH_KEYS = new Set(["openaiCodex"]);
912
// Tavily only ever used the plugin-owned config path, so there is no legacy
1013
// `tools.web.search.tavily.*` shape to migrate.
1114
const NON_MIGRATED_LEGACY_WEB_SEARCH_PROVIDER_IDS = new Set(["tavily"]);
12-
const LEGACY_WEB_SEARCH_PROVIDER_PLUGIN_IDS = Object.fromEntries(
13-
Object.entries(BUNDLED_WEB_SEARCH_PROVIDER_PLUGIN_IDS).filter(
14-
([providerId]) => !NON_MIGRATED_LEGACY_WEB_SEARCH_PROVIDER_IDS.has(providerId),
15-
),
16-
);
17-
const LEGACY_WEB_SEARCH_PROVIDER_IDS = Object.keys(LEGACY_WEB_SEARCH_PROVIDER_PLUGIN_IDS);
15+
const LEGACY_WEB_SEARCH_PROVIDER_IDS = loadPluginManifestRegistry({ cache: true })
16+
.plugins.filter((plugin) => plugin.origin === "bundled")
17+
.flatMap((plugin) => plugin.contracts?.webSearchProviders ?? [])
18+
.filter((providerId) => !NON_MIGRATED_LEGACY_WEB_SEARCH_PROVIDER_IDS.has(providerId))
19+
.toSorted((left, right) => left.localeCompare(right));
1820
const LEGACY_WEB_SEARCH_PROVIDER_ID_SET = new Set(LEGACY_WEB_SEARCH_PROVIDER_IDS);
1921
const LEGACY_GLOBAL_WEB_SEARCH_PROVIDER_ID = "brave";
2022

@@ -84,8 +86,11 @@ function resolveLegacyGlobalWebSearchMigration(search: JsonRecord): {
8486
return null;
8587
}
8688
const pluginId =
87-
LEGACY_WEB_SEARCH_PROVIDER_PLUGIN_IDS[LEGACY_GLOBAL_WEB_SEARCH_PROVIDER_ID] ??
88-
LEGACY_GLOBAL_WEB_SEARCH_PROVIDER_ID;
89+
resolveManifestContractOwnerPluginId({
90+
contract: "webSearchProviders",
91+
value: LEGACY_GLOBAL_WEB_SEARCH_PROVIDER_ID,
92+
origin: "bundled",
93+
}) ?? LEGACY_GLOBAL_WEB_SEARCH_PROVIDER_ID;
8994
return {
9095
pluginId,
9196
payload,
@@ -233,7 +238,11 @@ function normalizeLegacyWebSearchConfigRecord<T extends JsonRecord>(
233238
if (!scoped || Object.keys(scoped).length === 0) {
234239
continue;
235240
}
236-
const pluginId = LEGACY_WEB_SEARCH_PROVIDER_PLUGIN_IDS[providerId];
241+
const pluginId = resolveManifestContractOwnerPluginId({
242+
contract: "webSearchProviders",
243+
value: providerId,
244+
origin: "bundled",
245+
});
237246
if (!pluginId) {
238247
continue;
239248
}

0 commit comments

Comments
 (0)