feat: add authHeader field to OpenClawProviderConfig and reuse type in form state

Add optional `authHeader` boolean to support vendor-specific auth headers
(e.g. Longcat). Refactor `resetOpenclawState` to use the shared
`OpenClawProviderConfig` type instead of an inline duplicate definition.
This commit is contained in:
Jason
2026-03-11 23:56:41 +08:00
parent ce985763f0
commit 51825dac20
2 changed files with 4 additions and 15 deletions
@@ -1,5 +1,5 @@
import { useState, useCallback, useMemo } from "react";
import type { OpenClawModel } from "@/types";
import type { OpenClawModel, OpenClawProviderConfig } from "@/types";
import type { AppId } from "@/lib/api";
import { useProvidersQuery } from "@/lib/query/queries";
import { OPENCLAW_DEFAULT_CONFIG } from "../helpers/opencodeFormUtils";
@@ -31,13 +31,7 @@ export interface OpenclawFormState {
handleOpenclawApiChange: (api: string) => void;
handleOpenclawModelsChange: (models: OpenClawModel[]) => void;
handleOpenclawUserAgentChange: (enabled: boolean) => void;
resetOpenclawState: (config?: {
baseUrl?: string;
apiKey?: string;
api?: string;
models?: OpenClawModel[];
headers?: Record<string, string>;
}) => void;
resetOpenclawState: (config?: OpenClawProviderConfig) => void;
}
function parseOpenclawField<T>(
@@ -178,13 +172,7 @@ export function useOpenclawFormState({
);
const resetOpenclawState = useCallback(
(config?: {
baseUrl?: string;
apiKey?: string;
api?: string;
models?: OpenClawModel[];
headers?: Record<string, string>;
}) => {
(config?: OpenClawProviderConfig) => {
setOpenclawProviderKey("");
setOpenclawBaseUrl(config?.baseUrl || "");
setOpenclawApiKey(config?.apiKey || "");
+1
View File
@@ -523,6 +523,7 @@ export interface OpenClawProviderConfig {
api?: string; // API 协议类型(如 "openai-completions"、"anthropic"
models?: OpenClawModel[]; // 可用模型列表
headers?: Record<string, string>; // 自定义请求头(如 User-Agent
authHeader?: boolean; // 供应商自定义认证开关(如 Longcat)
}
// OpenClaw agents.defaults 完整配置