mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-06 00:42:55 +00:00
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.
36 lines
1.1 KiB
TypeScript
36 lines
1.1 KiB
TypeScript
import {
|
|
normalizeLowercaseStringOrEmpty,
|
|
normalizeOptionalString,
|
|
} from "@openclaw/normalization-core/string-coerce";
|
|
|
|
export function parseCronThreadIdOption(value: unknown): number | undefined {
|
|
const raw = normalizeOptionalString(value);
|
|
if (!raw) {
|
|
return undefined;
|
|
}
|
|
if (!/^\d+$/.test(raw)) {
|
|
throw new Error("--thread-id must be a positive integer Telegram topic thread id");
|
|
}
|
|
const parsed = Number.parseInt(raw, 10);
|
|
if (!Number.isSafeInteger(parsed) || parsed <= 0) {
|
|
throw new Error("--thread-id must be a safe positive integer Telegram topic thread id");
|
|
}
|
|
return parsed;
|
|
}
|
|
|
|
export function normalizeCronSessionTargetOption(value: unknown): string | undefined {
|
|
const raw = normalizeOptionalString(value);
|
|
if (!raw) {
|
|
return undefined;
|
|
}
|
|
const lower = normalizeLowercaseStringOrEmpty(raw);
|
|
if (lower === "main" || lower === "isolated" || lower === "current") {
|
|
return lower;
|
|
}
|
|
if (lower.startsWith("session:")) {
|
|
const id = normalizeOptionalString(raw.slice(8));
|
|
return id ? `session:${id}` : undefined;
|
|
}
|
|
return undefined;
|
|
}
|