refactor: consolidate remaining coercion helpers (#122020)

This commit is contained in:
Peter Steinberger
2026-08-11 10:22:01 -07:00
committed by GitHub
parent 24bbb416b5
commit cad77fb39c
234 changed files with 1210 additions and 1572 deletions
@@ -14,6 +14,7 @@ import {
type MemoryEmbeddingProviderCreateOptions,
type MemoryEmbeddingProviderCreateResult,
} from "openclaw/plugin-sdk/memory-core-host-engine-embeddings";
import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
import { formatLlamaCppSetupError, resolveNodeLlamaCppImportUrl } from "./node-llama.runtime.js";
type LlamaCppLocalOptions = {
@@ -42,10 +43,6 @@ type LlamaCppModelIdentity = {
}>;
};
function normalizeOptionalString(value: unknown): string | undefined {
return typeof value === "string" && value.trim() ? value.trim() : undefined;
}
function readLocalOptions(options: { local?: unknown }): LlamaCppLocalOptions {
const local = options.local as LlamaCppLocalOptions | undefined;
return local ?? {};
@@ -82,9 +82,7 @@ function extractText(content: unknown): string {
}
function normalizeArguments(value: unknown): Record<string, unknown> {
return value && typeof value === "object" && !Array.isArray(value)
? (value as Record<string, unknown>)
: {};
return asNonArrayRecord(value);
}
async function resolveLlamaCppResponseGrammar(params: {
@@ -710,3 +708,4 @@ if (process.env.VITEST || process.env.NODE_ENV === "test") {
mapToolsToLlamaFunctions,
});
}
import { asNonArrayRecord } from "openclaw/plugin-sdk/string-coerce-runtime";