mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-24 07:31:44 +00:00
refactor: dedupe talk config record helper
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { isRecord } from "../utils.js";
|
||||
import type {
|
||||
ResolvedTalkConfig,
|
||||
TalkConfig,
|
||||
@@ -7,10 +8,6 @@ import type {
|
||||
import type { OpenClawConfig } from "./types.js";
|
||||
import { coerceSecretRef } from "./types.secrets.js";
|
||||
|
||||
function isPlainObject(value: unknown): value is Record<string, unknown> {
|
||||
return typeof value === "object" && value !== null && !Array.isArray(value);
|
||||
}
|
||||
|
||||
function normalizeString(value: unknown): string | undefined {
|
||||
if (typeof value !== "string") {
|
||||
return undefined;
|
||||
@@ -35,7 +32,7 @@ function normalizeSilenceTimeoutMs(value: unknown): number | undefined {
|
||||
}
|
||||
|
||||
function normalizeTalkProviderConfig(value: unknown): TalkProviderConfig | undefined {
|
||||
if (!isPlainObject(value)) {
|
||||
if (!isRecord(value)) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
@@ -58,7 +55,7 @@ function normalizeTalkProviderConfig(value: unknown): TalkProviderConfig | undef
|
||||
}
|
||||
|
||||
function normalizeTalkProviders(value: unknown): Record<string, TalkProviderConfig> | undefined {
|
||||
if (!isPlainObject(value)) {
|
||||
if (!isRecord(value)) {
|
||||
return undefined;
|
||||
}
|
||||
const providers: Record<string, TalkProviderConfig> = {};
|
||||
@@ -93,7 +90,7 @@ function activeProviderFromTalk(talk: TalkConfig): string | undefined {
|
||||
}
|
||||
|
||||
export function normalizeTalkSection(value: TalkConfig | undefined): TalkConfig | undefined {
|
||||
if (!isPlainObject(value)) {
|
||||
if (!isRecord(value)) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user