mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 08:10:44 +00:00
fix(plugins): extract provider config policy contexts
This commit is contained in:
36
src/plugins/provider-config-context.types.ts
Normal file
36
src/plugins/provider-config-context.types.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
import type { ModelProviderConfig } from "../config/types.js";
|
||||
import type { OpenClawConfig } from "../config/types.openclaw.js";
|
||||
|
||||
/**
|
||||
* Provider-owned config normalization for `models.providers.<id>` entries.
|
||||
*
|
||||
* Use this for provider-specific config cleanup that should stay with the
|
||||
* plugin rather than in core config-policy tables.
|
||||
*/
|
||||
export type ProviderNormalizeConfigContext = {
|
||||
provider: string;
|
||||
providerConfig: ModelProviderConfig;
|
||||
};
|
||||
|
||||
/**
|
||||
* Provider-owned env/config auth marker resolution for `models.providers`.
|
||||
*
|
||||
* Use this when a provider resolves auth from env vars that do not follow the
|
||||
* generic API-key conventions.
|
||||
*/
|
||||
export type ProviderResolveConfigApiKeyContext = {
|
||||
provider: string;
|
||||
env: NodeJS.ProcessEnv;
|
||||
};
|
||||
|
||||
/**
|
||||
* Provider-owned config-default application input.
|
||||
*
|
||||
* Use this when a provider needs to add global config defaults that depend on
|
||||
* provider auth mode or provider-specific model families.
|
||||
*/
|
||||
export type ProviderApplyConfigDefaultsContext = {
|
||||
provider: string;
|
||||
config: OpenClawConfig;
|
||||
env: NodeJS.ProcessEnv;
|
||||
};
|
||||
@@ -1,12 +1,12 @@
|
||||
import { normalizeProviderId } from "../agents/provider-id.js";
|
||||
import type { ModelProviderConfig } from "../config/types.js";
|
||||
import type { OpenClawConfig } from "../config/types.openclaw.js";
|
||||
import { loadBundledPluginPublicArtifactModuleSync } from "./public-surface-loader.js";
|
||||
import type {
|
||||
ProviderApplyConfigDefaultsContext,
|
||||
ProviderNormalizeConfigContext,
|
||||
ProviderResolveConfigApiKeyContext,
|
||||
} from "./types.js";
|
||||
} from "./provider-config-context.types.js";
|
||||
import { loadBundledPluginPublicArtifactModuleSync } from "./public-surface-loader.js";
|
||||
|
||||
const PROVIDER_POLICY_ARTIFACT_CANDIDATES = ["provider-policy-api.js"] as const;
|
||||
|
||||
|
||||
@@ -89,6 +89,11 @@ import type {
|
||||
import type { PluginKind } from "./plugin-kind.types.js";
|
||||
import type { PluginOrigin } from "./plugin-origin.types.js";
|
||||
import type { SecretInputMode } from "./provider-auth-types.js";
|
||||
import type {
|
||||
ProviderApplyConfigDefaultsContext,
|
||||
ProviderNormalizeConfigContext,
|
||||
ProviderResolveConfigApiKeyContext,
|
||||
} from "./provider-config-context.types.js";
|
||||
import type {
|
||||
ProviderExternalAuthProfile,
|
||||
ProviderExternalOAuthProfile,
|
||||
@@ -432,16 +437,11 @@ export type ProviderNormalizeModelIdContext = {
|
||||
modelId: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* Provider-owned config normalization for `models.providers.<id>` entries.
|
||||
*
|
||||
* Use this for provider-specific config cleanup that should stay with the
|
||||
* plugin rather than in core config-policy tables.
|
||||
*/
|
||||
export type ProviderNormalizeConfigContext = {
|
||||
provider: string;
|
||||
providerConfig: ModelProviderConfig;
|
||||
};
|
||||
export type {
|
||||
ProviderApplyConfigDefaultsContext,
|
||||
ProviderNormalizeConfigContext,
|
||||
ProviderResolveConfigApiKeyContext,
|
||||
} from "./provider-config-context.types.js";
|
||||
|
||||
/**
|
||||
* Provider-owned transport normalization for arbitrary provider/model config.
|
||||
@@ -456,17 +456,6 @@ export type ProviderNormalizeTransportContext = {
|
||||
baseUrl?: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* Provider-owned env/config auth marker resolution for `models.providers`.
|
||||
*
|
||||
* Use this when a provider resolves auth from env vars that do not follow the
|
||||
* generic API-key conventions.
|
||||
*/
|
||||
export type ProviderResolveConfigApiKeyContext = {
|
||||
provider: string;
|
||||
env: NodeJS.ProcessEnv;
|
||||
};
|
||||
|
||||
/**
|
||||
* Runtime auth input for providers that need an extra exchange step before
|
||||
* inference. The incoming `apiKey` is the raw credential resolved from auth
|
||||
@@ -800,18 +789,6 @@ export type ProviderFailoverErrorContext = {
|
||||
errorMessage: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* Provider-owned config-default application input.
|
||||
*
|
||||
* Use this when a provider needs to add global config defaults that depend on
|
||||
* provider auth mode or provider-specific model families.
|
||||
*/
|
||||
export type ProviderApplyConfigDefaultsContext = {
|
||||
provider: string;
|
||||
config: OpenClawConfig;
|
||||
env: NodeJS.ProcessEnv;
|
||||
};
|
||||
|
||||
/**
|
||||
* Generic embedding provider shape returned by provider plugins.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user