perf(runtime): reduce startup import overhead in logging and schema validation

This commit is contained in:
Peter Steinberger
2026-03-02 18:20:51 +00:00
parent 41c8734afd
commit 82f01d6081
2 changed files with 36 additions and 9 deletions

View File

@@ -1,6 +1,5 @@
import { Chalk } from "chalk";
import type { Logger as TsLogger } from "tslog";
import { CHAT_CHANNEL_ORDER } from "../channels/registry.js";
import { isVerbose } from "../globals.js";
import { defaultRuntime, type RuntimeEnv } from "../runtime.js";
import { clearActiveProgressLine } from "../terminal/progress-line.js";
@@ -94,7 +93,17 @@ const SUBSYSTEM_COLOR_OVERRIDES: Record<string, (typeof SUBSYSTEM_COLORS)[number
};
const SUBSYSTEM_PREFIXES_TO_DROP = ["gateway", "channels", "providers"] as const;
const SUBSYSTEM_MAX_SEGMENTS = 2;
const CHANNEL_SUBSYSTEM_PREFIXES = new Set<string>(CHAT_CHANNEL_ORDER);
// Keep local to avoid importing channel registry into hot logging paths.
const CHANNEL_SUBSYSTEM_PREFIXES = new Set<string>([
"telegram",
"whatsapp",
"discord",
"irc",
"googlechat",
"slack",
"signal",
"imessage",
]);
function pickSubsystemColor(color: ChalkInstance, subsystem: string): ChalkInstance {
const override = SUBSYSTEM_COLOR_OVERRIDES[subsystem];