Files
openclaw/src/gateway/server-utils.ts
Peter Steinberger 00d8d7ead0 refactor: extract normalization core package
Extract shared normalization/coercion helpers into private @openclaw/normalization-core workspace package while preserving existing plugin SDK helper subpaths.\n\nAlso keeps direct normalization-core imports internal, wires UI/build/loader resolution, and replaces the slow PR network CodeQL lane with a fast added-line boundary scan while retaining full CodeQL for scheduled/manual runs.\n\nVerification: local moved tests, plugin SDK boundary tests, extension loader tests, agents-support shard, UI build/test, build artifacts, lint, workflow guards, autoreview, and GitHub CI passed on PR head 963d893715.
2026-05-31 01:33:00 +01:00

39 lines
1.2 KiB
TypeScript

import { normalizeTrimmedStringList } from "@openclaw/normalization-core/string-normalization";
import { defaultVoiceWakeTriggers } from "../infra/voicewake.js";
export function normalizeVoiceWakeTriggers(input: unknown): string[] {
const cleaned = normalizeTrimmedStringList(input)
.slice(0, 32)
.map((value) => value.slice(0, 64));
return cleaned.length > 0 ? cleaned : defaultVoiceWakeTriggers();
}
export function formatError(err: unknown): string {
if (err instanceof Error) {
return err.message;
}
if (typeof err === "string") {
return err;
}
const statusValue = (err as { status?: unknown })?.status;
const codeValue = (err as { code?: unknown })?.code;
const hasStatus = statusValue !== undefined;
const hasCode = codeValue !== undefined;
if (hasStatus || hasCode) {
const statusText =
typeof statusValue === "string" || typeof statusValue === "number"
? String(statusValue)
: "unknown";
const codeText =
typeof codeValue === "string" || typeof codeValue === "number"
? String(codeValue)
: "unknown";
return `status=${statusText} code=${codeText}`;
}
try {
return JSON.stringify(err, null, 2);
} catch {
return String(err);
}
}