mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-22 07:08:14 +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.
55 lines
2.1 KiB
TypeScript
55 lines
2.1 KiB
TypeScript
import {
|
|
normalizeOptionalLowercaseString,
|
|
normalizeOptionalString,
|
|
} from "@openclaw/normalization-core/string-coerce";
|
|
import { sanitizeTerminalText } from "../../packages/terminal-core/src/safe-text.js";
|
|
import { isCliProvider } from "../agents/model-selection.js";
|
|
import type { SessionEntry } from "../config/sessions/types.js";
|
|
import type { OpenClawConfig } from "../config/types.openclaw.js";
|
|
|
|
const AGENT_RUNTIME_LABELS: Readonly<Record<string, string>> = {
|
|
openclaw: "OpenClaw Default",
|
|
codex: "OpenAI Codex",
|
|
"codex-cli": "OpenAI Codex",
|
|
"claude-cli": "Claude CLI",
|
|
"google-gemini-cli": "Gemini CLI",
|
|
};
|
|
|
|
export function resolveAgentRuntimeLabel(args: {
|
|
config?: OpenClawConfig;
|
|
sessionEntry?: Pick<
|
|
SessionEntry,
|
|
"acp" | "agentRuntimeOverride" | "agentHarnessId" | "modelProvider" | "providerOverride"
|
|
>;
|
|
resolvedHarness?: string;
|
|
fallbackProvider?: string;
|
|
}): string {
|
|
const acpAgentRaw = normalizeOptionalString(args.sessionEntry?.acp?.agent);
|
|
const acpAgent = acpAgentRaw ? sanitizeTerminalText(acpAgentRaw) : undefined;
|
|
if (acpAgent) {
|
|
const backendRaw = normalizeOptionalString(args.sessionEntry?.acp?.backend);
|
|
const backend = backendRaw ? sanitizeTerminalText(backendRaw) : undefined;
|
|
return backend ? `${acpAgent} (acp/${backend})` : `${acpAgent} (acp)`;
|
|
}
|
|
|
|
const runtimeRaw = normalizeOptionalString(args.resolvedHarness);
|
|
const runtime = normalizeOptionalLowercaseString(runtimeRaw);
|
|
if (runtime && runtime !== "auto" && runtime !== "default") {
|
|
return AGENT_RUNTIME_LABELS[runtime] ?? sanitizeTerminalText(runtimeRaw ?? runtime);
|
|
}
|
|
|
|
const providerRaw =
|
|
normalizeOptionalString(args.sessionEntry?.modelProvider) ??
|
|
normalizeOptionalString(args.sessionEntry?.providerOverride) ??
|
|
normalizeOptionalString(args.fallbackProvider);
|
|
const provider = providerRaw ? sanitizeTerminalText(providerRaw) : undefined;
|
|
if (provider && isCliProvider(provider, args.config)) {
|
|
return (
|
|
AGENT_RUNTIME_LABELS[normalizeOptionalLowercaseString(providerRaw) ?? ""] ??
|
|
`${provider} (cli)`
|
|
);
|
|
}
|
|
|
|
return AGENT_RUNTIME_LABELS.openclaw;
|
|
}
|