refactor: drop legacy compatibility fallbacks and strictly structure config under 1h-tools
This commit is contained in:
1 parent
69877803ca
commit
ffe71f24b4
6 files changed
+10
-137
No files matched your search
Vendored
+2
-20
@@ -35,26 +35,8 @@ export function resolvePluginApiKey(rawKey) {
|
||||
return undefined;
|
||||
}
|
||||
export function resolveImageConfig(cfg, apiPluginConfig) {
|
||||
const toolsConfig = (apiPluginConfig ??
|
||||
cfg?.plugins?.entries?.["1h-tools"]?.config ??
|
||||
cfg?.plugins?.entries?.["tools"]?.config);
|
||||
const legacyConfig = (cfg?.plugins?.entries?.["openai-image"]?.config ??
|
||||
cfg?.plugins?.entries?.["bifrost-image"]?.config);
|
||||
const directImageConfig = toolsConfig?.image;
|
||||
const flatToolsConfig = toolsConfig?.baseUrl
|
||||
? {
|
||||
baseUrl: toolsConfig.baseUrl,
|
||||
apiKey: toolsConfig.apiKey,
|
||||
allowPrivateNetwork: toolsConfig.allowPrivateNetwork,
|
||||
defaultModel: toolsConfig.defaultModel,
|
||||
models: toolsConfig.models,
|
||||
}
|
||||
: undefined;
|
||||
return {
|
||||
...legacyConfig,
|
||||
...flatToolsConfig,
|
||||
...directImageConfig,
|
||||
};
|
||||
const config = (apiPluginConfig ?? cfg?.plugins?.entries?.["1h-tools"]?.config);
|
||||
return config?.image;
|
||||
}
|
||||
export function resolveConfiguredImageBaseUrl(cfg, pluginCfg) {
|
||||
return (normalizeOptionalString(pluginCfg?.baseUrl) ??
|
||||
|
||||
Vendored
+2
-19
@@ -18,25 +18,8 @@ export function resolvePluginApiKey(rawKey) {
|
||||
return undefined;
|
||||
}
|
||||
export function resolveVideoConfig(cfg, apiPluginConfig) {
|
||||
const toolsConfig = (apiPluginConfig ??
|
||||
cfg?.plugins?.entries?.["1h-tools"]?.config ??
|
||||
cfg?.plugins?.entries?.["tools"]?.config);
|
||||
const legacyConfig = cfg?.plugins?.entries?.["openai-video"]?.config;
|
||||
const directVideoConfig = toolsConfig?.video;
|
||||
const flatToolsConfig = toolsConfig?.baseUrl
|
||||
? {
|
||||
baseUrl: toolsConfig.baseUrl,
|
||||
apiKey: toolsConfig.apiKey,
|
||||
allowPrivateNetwork: toolsConfig.allowPrivateNetwork,
|
||||
defaultModel: toolsConfig.defaultModel,
|
||||
models: toolsConfig.models,
|
||||
}
|
||||
: undefined;
|
||||
return {
|
||||
...legacyConfig,
|
||||
...flatToolsConfig,
|
||||
...directVideoConfig,
|
||||
};
|
||||
const config = (apiPluginConfig ?? cfg?.plugins?.entries?.["1h-tools"]?.config);
|
||||
return config?.video;
|
||||
}
|
||||
export function resolveConfiguredOpenAIBaseUrl(cfg, pluginCfg) {
|
||||
return (normalizeOptionalString(pluginCfg?.baseUrl) ??
|
||||
|
||||
@@ -67,11 +67,6 @@
|
||||
"configContracts": {
|
||||
"secretInputs": {
|
||||
"paths": [
|
||||
{
|
||||
"path": "apiKey",
|
||||
"expected": "string",
|
||||
"ownerKind": "capability"
|
||||
},
|
||||
{
|
||||
"path": "video.apiKey",
|
||||
"expected": "string",
|
||||
@@ -86,10 +81,6 @@
|
||||
}
|
||||
},
|
||||
"uiHints": {
|
||||
"apiKey": {
|
||||
"label": "API Key",
|
||||
"sensitive": true
|
||||
},
|
||||
"video.apiKey": {
|
||||
"label": "Video API Key",
|
||||
"sensitive": true
|
||||
@@ -103,37 +94,6 @@
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"baseUrl": {
|
||||
"type": "string",
|
||||
"title": "API Base URL",
|
||||
"description": "Base URL of the OpenAI-compatible endpoint"
|
||||
},
|
||||
"apiKey": {
|
||||
"type": [
|
||||
"string",
|
||||
"object"
|
||||
],
|
||||
"title": "API Key",
|
||||
"description": "API Key or SecretRef"
|
||||
},
|
||||
"allowPrivateNetwork": {
|
||||
"type": "boolean",
|
||||
"title": "Allow Private Network",
|
||||
"description": "Allow requests to private/internal network endpoints (e.g. host.incus.internal, 127.0.0.1)",
|
||||
"default": true
|
||||
},
|
||||
"defaultModel": {
|
||||
"type": "string",
|
||||
"title": "Default Model",
|
||||
"description": "Default model ID"
|
||||
},
|
||||
"models": {
|
||||
"type": "array",
|
||||
"title": "Available Models",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"video": {
|
||||
"type": "object",
|
||||
"title": "Video Generation Settings",
|
||||
|
||||
+3
-33
@@ -64,40 +64,10 @@ export function resolveImageConfig(
|
||||
cfg: ImageGenerationRequest["cfg"] | undefined,
|
||||
apiPluginConfig?: Record<string, unknown>,
|
||||
): ImagePluginConfig | undefined {
|
||||
const toolsConfig = (apiPluginConfig ??
|
||||
cfg?.plugins?.entries?.["1h-tools"]?.config ??
|
||||
cfg?.plugins?.entries?.["tools"]?.config) as
|
||||
| {
|
||||
image?: ImagePluginConfig;
|
||||
baseUrl?: string;
|
||||
apiKey?: string | SecretRefObject;
|
||||
defaultModel?: string;
|
||||
models?: string[];
|
||||
allowPrivateNetwork?: boolean;
|
||||
}
|
||||
const config = (apiPluginConfig ?? cfg?.plugins?.entries?.["1h-tools"]?.config) as
|
||||
| { image?: ImagePluginConfig }
|
||||
| undefined;
|
||||
|
||||
const legacyConfig = (
|
||||
cfg?.plugins?.entries?.["openai-image"]?.config ??
|
||||
cfg?.plugins?.entries?.["bifrost-image"]?.config
|
||||
) as ImagePluginConfig | undefined;
|
||||
|
||||
const directImageConfig = toolsConfig?.image;
|
||||
const flatToolsConfig: ImagePluginConfig | undefined = toolsConfig?.baseUrl
|
||||
? {
|
||||
baseUrl: toolsConfig.baseUrl,
|
||||
apiKey: toolsConfig.apiKey,
|
||||
allowPrivateNetwork: toolsConfig.allowPrivateNetwork,
|
||||
defaultModel: toolsConfig.defaultModel,
|
||||
models: toolsConfig.models,
|
||||
}
|
||||
: undefined;
|
||||
|
||||
return {
|
||||
...legacyConfig,
|
||||
...flatToolsConfig,
|
||||
...directImageConfig,
|
||||
};
|
||||
return config?.image;
|
||||
}
|
||||
|
||||
export function resolveConfiguredImageBaseUrl(
|
||||
|
||||
@@ -53,8 +53,6 @@ OpenClaw 视频生成驱动模块,适配标准 **OpenAI Videos API**(`/v1/vi
|
||||
}
|
||||
```
|
||||
|
||||
> **向下兼容提示**:插件仍完全兼容旧版独立插件 `plugins.entries["openai-video"].config` 的配置路径,迁移期间无需强行改动旧配置即可直接读取。
|
||||
|
||||
---
|
||||
|
||||
## 使用方法
|
||||
|
||||
+3
-23
@@ -75,30 +75,10 @@ export function resolveVideoConfig(
|
||||
cfg: VideoGenerationRequest["cfg"] | undefined,
|
||||
apiPluginConfig?: Record<string, unknown>,
|
||||
): VideoPluginConfig | undefined {
|
||||
const toolsConfig = (apiPluginConfig ??
|
||||
cfg?.plugins?.entries?.["1h-tools"]?.config ??
|
||||
cfg?.plugins?.entries?.["tools"]?.config) as
|
||||
| { video?: VideoPluginConfig; baseUrl?: string; apiKey?: string | SecretRefObject; defaultModel?: string; models?: string[]; allowPrivateNetwork?: boolean }
|
||||
const config = (apiPluginConfig ?? cfg?.plugins?.entries?.["1h-tools"]?.config) as
|
||||
| { video?: VideoPluginConfig }
|
||||
| undefined;
|
||||
|
||||
const legacyConfig = cfg?.plugins?.entries?.["openai-video"]?.config as VideoPluginConfig | undefined;
|
||||
|
||||
const directVideoConfig = toolsConfig?.video;
|
||||
const flatToolsConfig: VideoPluginConfig | undefined = toolsConfig?.baseUrl
|
||||
? {
|
||||
baseUrl: toolsConfig.baseUrl,
|
||||
apiKey: toolsConfig.apiKey,
|
||||
allowPrivateNetwork: toolsConfig.allowPrivateNetwork,
|
||||
defaultModel: toolsConfig.defaultModel,
|
||||
models: toolsConfig.models,
|
||||
}
|
||||
: undefined;
|
||||
|
||||
return {
|
||||
...legacyConfig,
|
||||
...flatToolsConfig,
|
||||
...directVideoConfig,
|
||||
};
|
||||
return config?.video;
|
||||
}
|
||||
|
||||
export function resolveConfiguredOpenAIBaseUrl(
|
||||
|
||||
Reference in new issue
Block a user