import type { AdapterConfigFieldsProps } from "../types"; import { Field, DraftInput, help, } from "../../components/agent-config-primitives"; const inputClass = "w-full rounded-md border border-border px-2.5 py-1.5 bg-transparent outline-none text-sm font-mono placeholder:text-muted-foreground/40"; export function OpenClawConfigFields({ isCreate, values, set, config, eff, mark, }: AdapterConfigFieldsProps) { const configuredHeaders = config.headers && typeof config.headers === "object" && !Array.isArray(config.headers) ? (config.headers as Record) : {}; const effectiveHeaders = (eff("adapterConfig", "headers", configuredHeaders) as Record) ?? {}; const effectiveGatewayAuthHeader = typeof effectiveHeaders["x-openclaw-auth"] === "string" ? String(effectiveHeaders["x-openclaw-auth"]) : ""; const commitGatewayAuthHeader = (rawValue: string) => { const nextValue = rawValue.trim(); const nextHeaders: Record = { ...effectiveHeaders }; if (nextValue) { nextHeaders["x-openclaw-auth"] = nextValue; } else { delete nextHeaders["x-openclaw-auth"]; } mark("adapterConfig", "headers", Object.keys(nextHeaders).length > 0 ? nextHeaders : undefined); }; const transport = eff( "adapterConfig", "streamTransport", String(config.streamTransport ?? "sse"), ); const sessionStrategy = eff( "adapterConfig", "sessionKeyStrategy", String(config.sessionKeyStrategy ?? "fixed"), ); return ( <> isCreate ? set!({ url: v }) : mark("adapterConfig", "url", v || undefined) } immediate className={inputClass} placeholder="https://..." /> {!isCreate && ( <> mark("adapterConfig", "paperclipApiUrl", v || undefined)} immediate className={inputClass} placeholder="https://paperclip.example" /> {sessionStrategy === "fixed" && ( mark("adapterConfig", "sessionKey", v || undefined)} immediate className={inputClass} placeholder="paperclip" /> )} mark("adapterConfig", "webhookAuthHeader", v || undefined)} immediate className={inputClass} placeholder="Bearer " /> )} ); }