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;
|
return undefined;
|
||||||
}
|
}
|
||||||
export function resolveImageConfig(cfg, apiPluginConfig) {
|
export function resolveImageConfig(cfg, apiPluginConfig) {
|
||||||
const toolsConfig = (apiPluginConfig ??
|
const config = (apiPluginConfig ?? cfg?.plugins?.entries?.["1h-tools"]?.config);
|
||||||
cfg?.plugins?.entries?.["1h-tools"]?.config ??
|
return config?.image;
|
||||||
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,
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
export function resolveConfiguredImageBaseUrl(cfg, pluginCfg) {
|
export function resolveConfiguredImageBaseUrl(cfg, pluginCfg) {
|
||||||
return (normalizeOptionalString(pluginCfg?.baseUrl) ??
|
return (normalizeOptionalString(pluginCfg?.baseUrl) ??
|
||||||
|
|||||||
Vendored
+2
-19
@@ -18,25 +18,8 @@ export function resolvePluginApiKey(rawKey) {
|
|||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
export function resolveVideoConfig(cfg, apiPluginConfig) {
|
export function resolveVideoConfig(cfg, apiPluginConfig) {
|
||||||
const toolsConfig = (apiPluginConfig ??
|
const config = (apiPluginConfig ?? cfg?.plugins?.entries?.["1h-tools"]?.config);
|
||||||
cfg?.plugins?.entries?.["1h-tools"]?.config ??
|
return config?.video;
|
||||||
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,
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
export function resolveConfiguredOpenAIBaseUrl(cfg, pluginCfg) {
|
export function resolveConfiguredOpenAIBaseUrl(cfg, pluginCfg) {
|
||||||
return (normalizeOptionalString(pluginCfg?.baseUrl) ??
|
return (normalizeOptionalString(pluginCfg?.baseUrl) ??
|
||||||
|
|||||||
@@ -67,11 +67,6 @@
|
|||||||
"configContracts": {
|
"configContracts": {
|
||||||
"secretInputs": {
|
"secretInputs": {
|
||||||
"paths": [
|
"paths": [
|
||||||
{
|
|
||||||
"path": "apiKey",
|
|
||||||
"expected": "string",
|
|
||||||
"ownerKind": "capability"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"path": "video.apiKey",
|
"path": "video.apiKey",
|
||||||
"expected": "string",
|
"expected": "string",
|
||||||
@@ -86,10 +81,6 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"uiHints": {
|
"uiHints": {
|
||||||
"apiKey": {
|
|
||||||
"label": "API Key",
|
|
||||||
"sensitive": true
|
|
||||||
},
|
|
||||||
"video.apiKey": {
|
"video.apiKey": {
|
||||||
"label": "Video API Key",
|
"label": "Video API Key",
|
||||||
"sensitive": true
|
"sensitive": true
|
||||||
@@ -103,37 +94,6 @@
|
|||||||
"type": "object",
|
"type": "object",
|
||||||
"additionalProperties": false,
|
"additionalProperties": false,
|
||||||
"properties": {
|
"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": {
|
"video": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"title": "Video Generation Settings",
|
"title": "Video Generation Settings",
|
||||||
|
|||||||
+3
-33
@@ -64,40 +64,10 @@ export function resolveImageConfig(
|
|||||||
cfg: ImageGenerationRequest["cfg"] | undefined,
|
cfg: ImageGenerationRequest["cfg"] | undefined,
|
||||||
apiPluginConfig?: Record<string, unknown>,
|
apiPluginConfig?: Record<string, unknown>,
|
||||||
): ImagePluginConfig | undefined {
|
): ImagePluginConfig | undefined {
|
||||||
const toolsConfig = (apiPluginConfig ??
|
const config = (apiPluginConfig ?? cfg?.plugins?.entries?.["1h-tools"]?.config) as
|
||||||
cfg?.plugins?.entries?.["1h-tools"]?.config ??
|
| { image?: ImagePluginConfig }
|
||||||
cfg?.plugins?.entries?.["tools"]?.config) as
|
|
||||||
| {
|
|
||||||
image?: ImagePluginConfig;
|
|
||||||
baseUrl?: string;
|
|
||||||
apiKey?: string | SecretRefObject;
|
|
||||||
defaultModel?: string;
|
|
||||||
models?: string[];
|
|
||||||
allowPrivateNetwork?: boolean;
|
|
||||||
}
|
|
||||||
| undefined;
|
| undefined;
|
||||||
|
return config?.image;
|
||||||
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,
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function resolveConfiguredImageBaseUrl(
|
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,
|
cfg: VideoGenerationRequest["cfg"] | undefined,
|
||||||
apiPluginConfig?: Record<string, unknown>,
|
apiPluginConfig?: Record<string, unknown>,
|
||||||
): VideoPluginConfig | undefined {
|
): VideoPluginConfig | undefined {
|
||||||
const toolsConfig = (apiPluginConfig ??
|
const config = (apiPluginConfig ?? cfg?.plugins?.entries?.["1h-tools"]?.config) as
|
||||||
cfg?.plugins?.entries?.["1h-tools"]?.config ??
|
| { video?: VideoPluginConfig }
|
||||||
cfg?.plugins?.entries?.["tools"]?.config) as
|
|
||||||
| { video?: VideoPluginConfig; baseUrl?: string; apiKey?: string | SecretRefObject; defaultModel?: string; models?: string[]; allowPrivateNetwork?: boolean }
|
|
||||||
| undefined;
|
| undefined;
|
||||||
|
return config?.video;
|
||||||
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,
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function resolveConfiguredOpenAIBaseUrl(
|
export function resolveConfiguredOpenAIBaseUrl(
|
||||||
|
|||||||
Reference in new issue
Block a user