refactor(core): dedupe embedding imports and env parsing

This commit is contained in:
Peter Steinberger
2026-03-02 15:14:28 +00:00
parent dcf8308c8f
commit e9dd6121f2
6 changed files with 53 additions and 48 deletions

View File

@@ -9,6 +9,17 @@ export function isNonEmptyString(value: unknown): value is string {
return typeof value === "string" && value.trim().length > 0;
}
export function parseEnvValue(raw: string): string {
const trimmed = raw.trim();
if (
(trimmed.startsWith('"') && trimmed.endsWith('"')) ||
(trimmed.startsWith("'") && trimmed.endsWith("'"))
) {
return trimmed.slice(1, -1);
}
return trimmed;
}
export function normalizePositiveInt(value: unknown, fallback: number): number {
if (typeof value === "number" && Number.isFinite(value)) {
return Math.max(1, Math.floor(value));