From ffe71f24b4802cc90db86157f8e698604653c9a1 Mon Sep 17 00:00:00 2001 From: openclaw Date: Mon, 19 Oct 2026 03:47:47 +0000 Subject: [PATCH] refactor: drop legacy compatibility fallbacks and strictly structure config under 1h-tools --- dist/image/index.js | 22 ++-------------------- dist/video/index.js | 21 ++------------------- openclaw.plugin.json | 40 ---------------------------------------- src/image/index.ts | 36 +++--------------------------------- src/video/README.md | 2 -- src/video/index.ts | 26 +++----------------------- 6 files changed, 10 insertions(+), 137 deletions(-) diff --git a/dist/image/index.js b/dist/image/index.js index 155fced..38e3304 100644 --- a/dist/image/index.js +++ b/dist/image/index.js @@ -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) ?? diff --git a/dist/video/index.js b/dist/video/index.js index 4f5d399..7f76462 100644 --- a/dist/video/index.js +++ b/dist/video/index.js @@ -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) ?? diff --git a/openclaw.plugin.json b/openclaw.plugin.json index a7a119b..746ae0f 100644 --- a/openclaw.plugin.json +++ b/openclaw.plugin.json @@ -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", diff --git a/src/image/index.ts b/src/image/index.ts index 5cf6c9d..ebedb64 100644 --- a/src/image/index.ts +++ b/src/image/index.ts @@ -64,40 +64,10 @@ export function resolveImageConfig( cfg: ImageGenerationRequest["cfg"] | undefined, apiPluginConfig?: Record, ): 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( diff --git a/src/video/README.md b/src/video/README.md index 16f9e21..fbd8d3a 100644 --- a/src/video/README.md +++ b/src/video/README.md @@ -53,8 +53,6 @@ OpenClaw 视频生成驱动模块,适配标准 **OpenAI Videos API**(`/v1/vi } ``` -> **向下兼容提示**:插件仍完全兼容旧版独立插件 `plugins.entries["openai-video"].config` 的配置路径,迁移期间无需强行改动旧配置即可直接读取。 - --- ## 使用方法 diff --git a/src/video/index.ts b/src/video/index.ts index 2dba254..4e79e89 100644 --- a/src/video/index.ts +++ b/src/video/index.ts @@ -75,30 +75,10 @@ export function resolveVideoConfig( cfg: VideoGenerationRequest["cfg"] | undefined, apiPluginConfig?: Record, ): 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(