refactor: dedupe plugin record guards

This commit is contained in:
Peter Steinberger
2026-04-07 00:20:39 +01:00
parent d5801c03ed
commit 4a7edbf471
2 changed files with 2 additions and 9 deletions

View File

@@ -17,7 +17,7 @@ import {
ssrfPolicyFromDangerouslyAllowPrivateNetwork,
type SsrFPolicy,
} from "openclaw/plugin-sdk/ssrf-runtime";
import { resolveUserPath } from "openclaw/plugin-sdk/text-runtime";
import { isRecord, resolveUserPath } from "openclaw/plugin-sdk/text-runtime";
const DEFAULT_COMFY_LOCAL_BASE_URL = "http://127.0.0.1:8188";
const DEFAULT_COMFY_CLOUD_BASE_URL = "https://cloud.comfy.org";
@@ -87,10 +87,6 @@ export function _setComfyFetchGuardForTesting(impl: typeof fetchWithSsrFGuard |
comfyFetchGuard = impl ?? fetchWithSsrFGuard;
}
function isRecord(value: unknown): value is Record<string, unknown> {
return typeof value === "object" && value !== null && !Array.isArray(value);
}
function readConfigString(config: ComfyProviderConfig, key: string): string | undefined {
const value = config[key];
if (typeof value !== "string") {

View File

@@ -2,6 +2,7 @@ import { definePluginEntry } from "openclaw/plugin-sdk/plugin-entry";
import { createProviderApiKeyAuthMethod } from "openclaw/plugin-sdk/provider-auth-api-key";
import { normalizeProviderId } from "openclaw/plugin-sdk/provider-model-shared";
import type { SecretInput } from "openclaw/plugin-sdk/secret-input";
import { isRecord } from "openclaw/plugin-sdk/text-runtime";
import { applyKimiCodeConfig, KIMI_CODING_MODEL_REF } from "./onboard.js";
import { buildKimiCodingProvider } from "./provider-catalog.js";
import { KIMI_REPLAY_POLICY } from "./replay-policy.js";
@@ -10,10 +11,6 @@ import { wrapKimiProviderStream } from "./stream.js";
const PLUGIN_ID = "kimi";
const PROVIDER_ID = "kimi";
function isRecord(value: unknown): value is Record<string, unknown> {
return typeof value === "object" && value !== null && !Array.isArray(value);
}
function findExplicitProviderConfig(
providers: Record<string, unknown> | undefined,
providerId: string,