mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-27 09:02:15 +00:00
Plugins: restore routing seams and discovery fixtures
This commit is contained in:
@@ -8,6 +8,11 @@ import {
|
||||
createScopedAccountConfigAccessors,
|
||||
formatAllowFromLowercase,
|
||||
} from "openclaw/plugin-sdk/compat";
|
||||
import {
|
||||
buildAgentSessionKey,
|
||||
resolveThreadSessionKeys,
|
||||
type RoutePeer,
|
||||
} from "openclaw/plugin-sdk/core";
|
||||
import {
|
||||
buildComputedAccountStatusSnapshot,
|
||||
buildChannelConfigSchema,
|
||||
|
||||
@@ -3,6 +3,7 @@ import {
|
||||
buildAccountScopedDmSecurityPolicy,
|
||||
collectAllowlistProviderRestrictSendersWarnings,
|
||||
} from "openclaw/plugin-sdk/compat";
|
||||
import { buildAgentSessionKey, type RoutePeer } from "openclaw/plugin-sdk/core";
|
||||
import {
|
||||
buildChannelConfigSchema,
|
||||
collectStatusIssuesFromLastError,
|
||||
|
||||
@@ -4,6 +4,7 @@ import {
|
||||
replaceRuntimeAuthProfileStoreSnapshots,
|
||||
} from "../../agents/auth-profiles/store.js";
|
||||
import { QWEN_OAUTH_MARKER } from "../../agents/model-auth-markers.js";
|
||||
import type { ModelDefinitionConfig } from "../../config/types.models.js";
|
||||
import { createCapturedPluginRegistration } from "../../test-utils/plugin-registration.js";
|
||||
import { runProviderCatalog } from "../provider-discovery.js";
|
||||
import type { OpenClawPluginApi, ProviderPlugin } from "../types.js";
|
||||
@@ -58,6 +59,23 @@ function requireProvider(providers: ProviderPlugin[], providerId: string) {
|
||||
return provider;
|
||||
}
|
||||
|
||||
function buildTestModel(params: { id: string; name: string }): ModelDefinitionConfig {
|
||||
return {
|
||||
id: params.id,
|
||||
name: params.name,
|
||||
reasoning: false,
|
||||
input: ["text"],
|
||||
cost: {
|
||||
input: 0,
|
||||
output: 0,
|
||||
cacheRead: 0,
|
||||
cacheWrite: 0,
|
||||
},
|
||||
contextWindow: 128_000,
|
||||
maxTokens: 8_192,
|
||||
};
|
||||
}
|
||||
|
||||
describe("provider discovery contract", () => {
|
||||
afterEach(() => {
|
||||
resolveCopilotApiTokenMock.mockReset();
|
||||
@@ -226,7 +244,7 @@ describe("provider discovery contract", () => {
|
||||
providers: {
|
||||
ollama: {
|
||||
baseUrl: "http://ollama-host:11434/v1/",
|
||||
models: [{ id: "llama3.2", name: "llama3.2" }],
|
||||
models: [buildTestModel({ id: "llama3.2", name: "llama3.2" })],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -234,12 +252,12 @@ describe("provider discovery contract", () => {
|
||||
env: {} as NodeJS.ProcessEnv,
|
||||
resolveProviderApiKey: () => ({ apiKey: undefined }),
|
||||
}),
|
||||
).resolves.toEqual({
|
||||
).resolves.toMatchObject({
|
||||
provider: {
|
||||
baseUrl: "http://ollama-host:11434",
|
||||
api: "ollama",
|
||||
apiKey: "ollama-local",
|
||||
models: [{ id: "llama3.2", name: "llama3.2" }],
|
||||
models: [expect.objectContaining({ id: "llama3.2", name: "llama3.2" })],
|
||||
},
|
||||
});
|
||||
expect(buildOllamaProviderMock).not.toHaveBeenCalled();
|
||||
@@ -405,6 +423,7 @@ describe("provider discovery contract", () => {
|
||||
"minimax-portal": {
|
||||
baseUrl: "https://portal-proxy.example.com/anthropic",
|
||||
apiKey: "explicit-key",
|
||||
models: [],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -431,6 +450,7 @@ describe("provider discovery contract", () => {
|
||||
providers: {
|
||||
modelstudio: {
|
||||
baseUrl: "https://coding.dashscope.aliyuncs.com/v1",
|
||||
models: [],
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user