mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-19 13:11:40 +00:00
style(providers): normalize import and wrap formatting
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { buildPluginConfigSchema } from "openclaw/plugin-sdk/core";
|
||||
import type { OpenClawPluginConfigSchema } from "../runtime-api.js";
|
||||
import { z } from "openclaw/plugin-sdk/zod";
|
||||
import type { OpenClawPluginConfigSchema } from "../runtime-api.js";
|
||||
|
||||
export const ACPX_PERMISSION_MODES = ["approve-all", "approve-reads", "deny-all"] as const;
|
||||
export type AcpxPermissionMode = (typeof ACPX_PERMISSION_MODES)[number];
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import type { z } from "openclaw/plugin-sdk/zod";
|
||||
import { AcpxPluginConfigSchema } from "./config-schema.js";
|
||||
import type {
|
||||
AcpxPluginConfig,
|
||||
@@ -10,7 +11,6 @@ import type {
|
||||
AcpxMcpServer,
|
||||
ResolvedAcpxPluginConfig,
|
||||
} from "./config-schema.js";
|
||||
import type { z } from "openclaw/plugin-sdk/zod";
|
||||
export {
|
||||
ACPX_NON_INTERACTIVE_POLICIES,
|
||||
ACPX_PERMISSION_MODES,
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { formatCliCommand } from "openclaw/plugin-sdk/cli-runtime";
|
||||
import type {
|
||||
OpenClawPluginApi,
|
||||
ProviderAuthContext,
|
||||
ProviderResolveDynamicModelContext,
|
||||
ProviderRuntimeModel,
|
||||
} from "openclaw/plugin-sdk/plugin-entry";
|
||||
import { formatCliCommand } from "openclaw/plugin-sdk/cli-runtime";
|
||||
import {
|
||||
CLAUDE_CLI_PROFILE_ID,
|
||||
applyAuthProfileConfig,
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
import { definePluginEntry } from "openclaw/plugin-sdk/plugin-entry";
|
||||
import { createProviderApiKeyAuthMethod } from "openclaw/plugin-sdk/provider-auth-api-key";
|
||||
import { ensureModelAllowlistEntry } from "openclaw/plugin-sdk/provider-onboard";
|
||||
import { BYTEPLUS_CODING_MODEL_CATALOG, BYTEPLUS_MODEL_CATALOG } from "./models.js";
|
||||
import { buildBytePlusCodingProvider, buildBytePlusProvider } from "./provider-catalog.js";
|
||||
import {
|
||||
BYTEPLUS_CODING_MODEL_CATALOG,
|
||||
BYTEPLUS_MODEL_CATALOG,
|
||||
} from "./models.js";
|
||||
|
||||
const PROVIDER_ID = "byteplus";
|
||||
const BYTEPLUS_DEFAULT_MODEL_REF = "byteplus-plan/ark-code-latest";
|
||||
|
||||
@@ -95,7 +95,9 @@ describe("google generative ai helpers", () => {
|
||||
});
|
||||
|
||||
it("parses project-aware oauth auth payloads into bearer headers", () => {
|
||||
expect(parseGeminiAuth(JSON.stringify({ token: "oauth-token", projectId: "project-1" }))).toEqual({
|
||||
expect(
|
||||
parseGeminiAuth(JSON.stringify({ token: "oauth-token", projectId: "project-1" })),
|
||||
).toEqual({
|
||||
headers: {
|
||||
Authorization: "Bearer oauth-token",
|
||||
"Content-Type": "application/json",
|
||||
|
||||
@@ -1,13 +1,7 @@
|
||||
import type { ImageGenerationProvider } from "openclaw/plugin-sdk/image-generation";
|
||||
import { resolveApiKeyForProvider } from "openclaw/plugin-sdk/provider-auth-runtime";
|
||||
import {
|
||||
assertOkOrThrowHttpError,
|
||||
postJsonRequest,
|
||||
} from "openclaw/plugin-sdk/provider-http";
|
||||
import {
|
||||
normalizeGoogleModelId,
|
||||
resolveGoogleGenerativeAiHttpRequestConfig,
|
||||
} from "./api.js";
|
||||
import { assertOkOrThrowHttpError, postJsonRequest } from "openclaw/plugin-sdk/provider-http";
|
||||
import { normalizeGoogleModelId, resolveGoogleGenerativeAiHttpRequestConfig } from "./api.js";
|
||||
|
||||
const DEFAULT_GOOGLE_IMAGE_MODEL = "gemini-3.1-flash-image-preview";
|
||||
const DEFAULT_OUTPUT_MIME = "image/png";
|
||||
|
||||
@@ -27,10 +27,7 @@ import {
|
||||
|
||||
const MINIMAX_SEARCH_ENDPOINT_GLOBAL = "https://api.minimax.io/v1/coding_plan/search";
|
||||
const MINIMAX_SEARCH_ENDPOINT_CN = "https://api.minimaxi.com/v1/coding_plan/search";
|
||||
const MINIMAX_CODING_PLAN_ENV_VARS = [
|
||||
"MINIMAX_CODE_PLAN_KEY",
|
||||
"MINIMAX_CODING_API_KEY",
|
||||
] as const;
|
||||
const MINIMAX_CODING_PLAN_ENV_VARS = ["MINIMAX_CODE_PLAN_KEY", "MINIMAX_CODING_API_KEY"] as const;
|
||||
|
||||
type MiniMaxSearchResult = {
|
||||
title?: string;
|
||||
|
||||
@@ -34,9 +34,7 @@ describe("kimi web search provider", () => {
|
||||
models: { providers: { moonshot: { baseUrl: "https://proxy.example/v1" } } },
|
||||
} as unknown as OpenClawConfig;
|
||||
|
||||
expect(__testing.resolveKimiBaseUrl(undefined, proxyConfig)).toBe(
|
||||
"https://api.moonshot.ai/v1",
|
||||
);
|
||||
expect(__testing.resolveKimiBaseUrl(undefined, proxyConfig)).toBe("https://api.moonshot.ai/v1");
|
||||
});
|
||||
|
||||
it("keeps explicit kimi baseUrl over models.providers.moonshot.baseUrl", () => {
|
||||
|
||||
@@ -109,10 +109,7 @@ function resolveKimiBaseUrl(kimi?: KimiConfig, openClawConfig?: OpenClawConfig):
|
||||
const moonshotBaseUrl = openClawConfig?.models?.providers?.moonshot?.baseUrl;
|
||||
if (typeof moonshotBaseUrl === "string") {
|
||||
const normalizedMoonshotBaseUrl = trimTrailingSlashes(moonshotBaseUrl.trim());
|
||||
if (
|
||||
normalizedMoonshotBaseUrl &&
|
||||
isNativeMoonshotBaseUrl(normalizedMoonshotBaseUrl)
|
||||
) {
|
||||
if (normalizedMoonshotBaseUrl && isNativeMoonshotBaseUrl(normalizedMoonshotBaseUrl)) {
|
||||
return normalizedMoonshotBaseUrl;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
import { definePluginEntry } from "openclaw/plugin-sdk/plugin-entry";
|
||||
import { createProviderApiKeyAuthMethod } from "openclaw/plugin-sdk/provider-auth-api-key";
|
||||
import { ensureModelAllowlistEntry } from "openclaw/plugin-sdk/provider-onboard";
|
||||
import { DOUBAO_CODING_MODEL_CATALOG, DOUBAO_MODEL_CATALOG } from "./models.js";
|
||||
import { buildDoubaoCodingProvider, buildDoubaoProvider } from "./provider-catalog.js";
|
||||
import {
|
||||
DOUBAO_CODING_MODEL_CATALOG,
|
||||
DOUBAO_MODEL_CATALOG,
|
||||
} from "./models.js";
|
||||
|
||||
const PROVIDER_ID = "volcengine";
|
||||
const VOLCENGINE_DEFAULT_MODEL_REF = "volcengine-plan/ark-code-latest";
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
import { Type } from "@sinclair/typebox";
|
||||
import { getRuntimeConfigSnapshot } from "openclaw/plugin-sdk/config-runtime";
|
||||
import type { OpenClawConfig } from "openclaw/plugin-sdk/plugin-entry";
|
||||
import {
|
||||
jsonResult,
|
||||
readStringParam,
|
||||
} from "openclaw/plugin-sdk/provider-web-search";
|
||||
import { jsonResult, readStringParam } from "openclaw/plugin-sdk/provider-web-search";
|
||||
import {
|
||||
buildXaiCodeExecutionPayload,
|
||||
requestXaiCodeExecution,
|
||||
|
||||
@@ -6,10 +6,7 @@ import {
|
||||
composeProviderStreamWrappers,
|
||||
createToolStreamWrapper,
|
||||
} from "openclaw/plugin-sdk/provider-stream";
|
||||
import {
|
||||
jsonResult,
|
||||
readProviderEnvValue,
|
||||
} from "openclaw/plugin-sdk/provider-web-search";
|
||||
import { jsonResult, readProviderEnvValue } from "openclaw/plugin-sdk/provider-web-search";
|
||||
import {
|
||||
applyXaiModelCompat,
|
||||
normalizeXaiModelId,
|
||||
@@ -20,13 +17,13 @@ import {
|
||||
import { applyXaiConfig, XAI_DEFAULT_MODEL_REF } from "./onboard.js";
|
||||
import { buildXaiProvider } from "./provider-catalog.js";
|
||||
import { isModernXaiModel, resolveXaiForwardCompatModel } from "./provider-models.js";
|
||||
import { resolveFallbackXaiAuth } from "./src/tool-auth-shared.js";
|
||||
import { resolveEffectiveXSearchConfig } from "./src/x-search-config.js";
|
||||
import {
|
||||
createXaiFastModeWrapper,
|
||||
createXaiToolCallArgumentDecodingWrapper,
|
||||
createXaiToolPayloadCompatibilityWrapper,
|
||||
} from "./stream.js";
|
||||
import { resolveFallbackXaiAuth } from "./src/tool-auth-shared.js";
|
||||
import { createXaiWebSearchProvider } from "./web-search.js";
|
||||
|
||||
const PROVIDER_ID = "xai";
|
||||
@@ -37,7 +34,7 @@ const OPENAI_COMPATIBLE_REPLAY_HOOKS = buildProviderReplayFamilyHooks({
|
||||
function hasResolvableXaiApiKey(config: unknown): boolean {
|
||||
return Boolean(
|
||||
resolveFallbackXaiAuth(config as OpenClawConfig | undefined)?.apiKey ||
|
||||
readProviderEnvValue(["XAI_API_KEY"]),
|
||||
readProviderEnvValue(["XAI_API_KEY"]),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
import { NON_ENV_SECRETREF_MARKER } from "openclaw/plugin-sdk/provider-auth-runtime";
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
import {
|
||||
isXaiToolEnabled,
|
||||
resolveFallbackXaiAuth,
|
||||
|
||||
@@ -10,11 +10,11 @@ import {
|
||||
resolveTimeoutSeconds,
|
||||
writeCache,
|
||||
} from "openclaw/plugin-sdk/provider-web-search";
|
||||
import { isXaiToolEnabled, resolveXaiToolApiKey } from "./src/tool-auth-shared.js";
|
||||
import {
|
||||
resolveEffectiveXSearchConfig,
|
||||
resolveLegacyXSearchConfig,
|
||||
} from "./src/x-search-config.js";
|
||||
import { isXaiToolEnabled, resolveXaiToolApiKey } from "./src/tool-auth-shared.js";
|
||||
import {
|
||||
buildXaiXSearchPayload,
|
||||
requestXaiXSearch,
|
||||
|
||||
@@ -74,7 +74,9 @@ describe("minimax provider catalog", () => {
|
||||
);
|
||||
|
||||
const providers = await resolveImplicitProvidersForTest({ agentDir });
|
||||
const apiHighspeed = providers?.minimax?.models?.find((model) => model.id === "MiniMax-M2.7-highspeed");
|
||||
const apiHighspeed = providers?.minimax?.models?.find(
|
||||
(model) => model.id === "MiniMax-M2.7-highspeed",
|
||||
);
|
||||
const portalHighspeed = providers?.["minimax-portal"]?.models?.find(
|
||||
(model) => model.id === "MiniMax-M2.7-highspeed",
|
||||
);
|
||||
|
||||
@@ -5,14 +5,6 @@ import {
|
||||
select as clackSelect,
|
||||
text as clackText,
|
||||
} from "@clack/prompts";
|
||||
import type { AuthProfileCredential } from "../../agents/auth-profiles/types.js";
|
||||
import type { OpenClawConfig } from "../../config/config.js";
|
||||
import type {
|
||||
ProviderAuthMethod,
|
||||
ProviderAuthResult,
|
||||
ProviderPlugin,
|
||||
} from "../../plugins/types.js";
|
||||
import type { RuntimeEnv } from "../../runtime.js";
|
||||
import {
|
||||
resolveAgentDir,
|
||||
resolveAgentWorkspaceDir,
|
||||
@@ -24,13 +16,21 @@ import {
|
||||
loadAuthProfileStoreForRuntime,
|
||||
upsertAuthProfile,
|
||||
} from "../../agents/auth-profiles.js";
|
||||
import type { AuthProfileCredential } from "../../agents/auth-profiles/types.js";
|
||||
import { normalizeProviderId } from "../../agents/model-selection.js";
|
||||
import { resolveDefaultAgentWorkspaceDir } from "../../agents/workspace.js";
|
||||
import { formatCliCommand } from "../../cli/command-format.js";
|
||||
import { parseDurationMs } from "../../cli/parse-duration.js";
|
||||
import type { OpenClawConfig } from "../../config/config.js";
|
||||
import { logConfigUpdated } from "../../config/logging.js";
|
||||
import { applyAuthProfileConfig } from "../../plugins/provider-auth-helpers.js";
|
||||
import { resolvePluginProviders } from "../../plugins/providers.runtime.js";
|
||||
import type {
|
||||
ProviderAuthMethod,
|
||||
ProviderAuthResult,
|
||||
ProviderPlugin,
|
||||
} from "../../plugins/types.js";
|
||||
import type { RuntimeEnv } from "../../runtime.js";
|
||||
import { stylePromptHint, stylePromptMessage } from "../../terminal/prompt-style.js";
|
||||
import { createClackPrompter } from "../../wizard/clack-prompter.js";
|
||||
import { isRemoteEnvironment } from "../oauth-env.js";
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import type { OpenClawConfig } from "../config/config.js";
|
||||
import type { ProviderPlugin } from "../plugins/types.js";
|
||||
import type { FlowContribution, FlowOption } from "./types.js";
|
||||
import { resolveManifestProviderAuthChoices } from "../plugins/provider-auth-choices.js";
|
||||
import {
|
||||
resolveProviderModelPickerEntries,
|
||||
resolveProviderWizardOptions,
|
||||
} from "../plugins/provider-wizard.js";
|
||||
import { resolvePluginProviders } from "../plugins/providers.runtime.js";
|
||||
import type { ProviderPlugin } from "../plugins/types.js";
|
||||
import type { FlowContribution, FlowOption } from "./types.js";
|
||||
import { mergeFlowContributions, sortFlowContributionsByLabel } from "./types.js";
|
||||
|
||||
export type ProviderFlowScope = "text-inference" | "image-generation";
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
// without recursing through provider-specific facades.
|
||||
|
||||
import type { BedrockDiscoveryConfig, ModelDefinitionConfig } from "../config/types.models.js";
|
||||
import type { ProviderPlugin } from "../plugins/types.js";
|
||||
import {
|
||||
buildAnthropicReplayPolicyForModel,
|
||||
buildGoogleGeminiReplayPolicy,
|
||||
@@ -15,6 +14,7 @@ import {
|
||||
resolveTaggedReasoningOutputMode,
|
||||
sanitizeGoogleGeminiReplayHistory,
|
||||
} from "../plugins/provider-replay-helpers.js";
|
||||
import type { ProviderPlugin } from "../plugins/types.js";
|
||||
import type {
|
||||
ProviderReasoningOutputModeContext,
|
||||
ProviderReplayPolicyContext,
|
||||
|
||||
@@ -163,9 +163,7 @@ export type ProviderToolCompatFamily = "gemini";
|
||||
|
||||
export function buildProviderToolCompatFamilyHooks(family: ProviderToolCompatFamily): {
|
||||
normalizeToolSchemas: (ctx: ProviderNormalizeToolSchemasContext) => AnyAgentTool[];
|
||||
inspectToolSchemas: (
|
||||
ctx: ProviderNormalizeToolSchemasContext,
|
||||
) => ProviderToolSchemaDiagnostic[];
|
||||
inspectToolSchemas: (ctx: ProviderNormalizeToolSchemasContext) => ProviderToolSchemaDiagnostic[];
|
||||
} {
|
||||
switch (family) {
|
||||
case "gemini":
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import JSON5 from "json5";
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
import JSON5 from "json5";
|
||||
import type { ChannelConfigRuntimeSchema } from "../channels/plugins/types.plugin.js";
|
||||
import type { PluginConfigUiHint, PluginKind } from "./types.js";
|
||||
import { MANIFEST_KEY } from "../compat/legacy-names.js";
|
||||
import { matchBoundaryFileOpenFailure, openBoundaryFileSync } from "../infra/boundary-file-read.js";
|
||||
import { isRecord } from "../utils.js";
|
||||
import type { PluginConfigUiHint, PluginKind } from "./types.js";
|
||||
|
||||
export const PLUGIN_MANIFEST_FILENAME = "openclaw.plugin.json";
|
||||
export const PLUGIN_MANIFEST_FILENAMES = [PLUGIN_MANIFEST_FILENAME] as const;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { OpenClawConfig } from "../config/config.js";
|
||||
import { normalizeProviderIdForAuth } from "../agents/model-selection.js";
|
||||
import type { OpenClawConfig } from "../config/config.js";
|
||||
import { normalizePluginsConfig, resolveEffectiveEnableState } from "./config-state.js";
|
||||
import { loadPluginManifestRegistry } from "./manifest-registry.js";
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import type { ProviderPlugin } from "./types.js";
|
||||
import {
|
||||
buildProviderPluginMethodChoice,
|
||||
resolveProviderModelPickerEntries,
|
||||
@@ -7,6 +6,7 @@ import {
|
||||
resolveProviderWizardOptions,
|
||||
runProviderModelSelectedHook,
|
||||
} from "./provider-wizard.js";
|
||||
import type { ProviderPlugin } from "./types.js";
|
||||
|
||||
const resolvePluginProviders = vi.hoisted(() => vi.fn<() => ProviderPlugin[]>(() => []));
|
||||
vi.mock("./providers.runtime.js", () => ({
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
import type { OpenClawConfig } from "../config/config.js";
|
||||
import type { WizardPrompter } from "../wizard/prompts.js";
|
||||
import type {
|
||||
ProviderAuthMethod,
|
||||
ProviderPlugin,
|
||||
ProviderPluginWizardModelPicker,
|
||||
ProviderPluginWizardSetup,
|
||||
} from "./types.js";
|
||||
import { DEFAULT_PROVIDER } from "../agents/defaults.js";
|
||||
import { normalizeProviderId } from "../agents/model-selection.js";
|
||||
import type { OpenClawConfig } from "../config/config.js";
|
||||
import type { WizardPrompter } from "../wizard/prompts.js";
|
||||
import {
|
||||
buildPluginSnapshotCacheEnvKey,
|
||||
resolvePluginSnapshotCacheTtlMs,
|
||||
shouldUsePluginSnapshotCache,
|
||||
} from "./cache-controls.js";
|
||||
import { resolvePluginProviders } from "./providers.runtime.js";
|
||||
import type {
|
||||
ProviderAuthMethod,
|
||||
ProviderPlugin,
|
||||
ProviderPluginWizardModelPicker,
|
||||
ProviderPluginWizardSetup,
|
||||
} from "./types.js";
|
||||
|
||||
export const PROVIDER_PLUGIN_CHOICE_PREFIX = "provider-plugin:";
|
||||
type ProviderWizardCacheEntry = {
|
||||
|
||||
@@ -44,10 +44,7 @@ export function getProviderEnvVars(providerId: string): string[] {
|
||||
return Array.isArray(envVars) ? [...envVars] : [];
|
||||
}
|
||||
|
||||
const EXTRA_PROVIDER_AUTH_ENV_VARS = [
|
||||
"MINIMAX_CODE_PLAN_KEY",
|
||||
"MINIMAX_CODING_API_KEY",
|
||||
] as const;
|
||||
const EXTRA_PROVIDER_AUTH_ENV_VARS = ["MINIMAX_CODE_PLAN_KEY", "MINIMAX_CODING_API_KEY"] as const;
|
||||
|
||||
const KNOWN_SECRET_ENV_VARS = [
|
||||
...new Set(Object.values(PROVIDER_ENV_VARS).flatMap((keys) => keys)),
|
||||
|
||||
Reference in New Issue
Block a user