import { useState } from "react"; import { Eye, EyeOff } from "lucide-react"; import type { AdapterConfigFieldsProps } from "../types"; import { Field, DraftInput, help, } from "../../components/agent-config-primitives"; import { PayloadTemplateJsonField, RuntimeServicesJsonField, } from "../runtime-json-fields"; 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"; function SecretField({ label, value, onCommit, placeholder, }: { label: string; value: string; onCommit: (v: string) => void; placeholder?: string; }) { const [visible, setVisible] = useState(false); return (
); } function parseScopes(value: unknown): string { if (Array.isArray(value)) { return value.filter((entry): entry is string => typeof entry === "string").join(", "); } return typeof value === "string" ? value : ""; } export function OpenClawGatewayConfigFields({ 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 effectiveGatewayToken = typeof effectiveHeaders["x-openclaw-token"] === "string" ? String(effectiveHeaders["x-openclaw-token"]) : typeof effectiveHeaders["x-openclaw-auth"] === "string" ? String(effectiveHeaders["x-openclaw-auth"]) : ""; const commitGatewayToken = (rawValue: string) => { const nextValue = rawValue.trim(); const nextHeaders: Record = { ...effectiveHeaders }; if (nextValue) { nextHeaders["x-openclaw-token"] = nextValue; delete nextHeaders["x-openclaw-auth"]; } else { delete nextHeaders["x-openclaw-token"]; delete nextHeaders["x-openclaw-auth"]; } mark("adapterConfig", "headers", Object.keys(nextHeaders).length > 0 ? nextHeaders : undefined); }; const sessionStrategy = eff( "adapterConfig", "sessionKeyStrategy", String(config.sessionKeyStrategy ?? "fixed"), ); return ( <> isCreate ? set!({ url: v }) : mark("adapterConfig", "url", v || undefined) } immediate className={inputClass} placeholder="ws://127.0.0.1:18789" /> {!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", "role", v || undefined)} immediate className={inputClass} placeholder="operator" /> { const parsed = v .split(",") .map((entry) => entry.trim()) .filter(Boolean); mark("adapterConfig", "scopes", parsed.length > 0 ? parsed : undefined); }} immediate className={inputClass} placeholder="operator.admin" /> { const parsed = Number.parseInt(v.trim(), 10); mark( "adapterConfig", "waitTimeoutMs", Number.isFinite(parsed) && parsed > 0 ? parsed : undefined, ); }} immediate className={inputClass} placeholder="120000" />
Always enabled for gateway agents. Paperclip persists a device key during onboarding so pairing approvals remain stable across runs.
)} ); }