refactor: dedupe provider and channel string helpers

This commit is contained in:
Peter Steinberger
2026-04-07 09:34:48 +01:00
parent b697cec223
commit 649de6d156
14 changed files with 41 additions and 82 deletions

View File

@@ -1,10 +1,11 @@
import { resolveEffectiveMessagesConfig, resolveIdentityName } from "../agents/identity.js";
import { resolveAgentIdentity, resolveEffectiveMessagesConfig } from "../agents/identity.js";
import {
extractShortModelName,
type ResponsePrefixContext,
} from "../auto-reply/reply/response-prefix-template.js";
import type { GetReplyOptions } from "../auto-reply/types.js";
import type { OpenClawConfig } from "../config/config.js";
import { normalizeOptionalString } from "../shared/string-coerce.js";
type ModelSelectionContext = Parameters<NonNullable<GetReplyOptions["onModelSelected"]>>[0];
@@ -28,7 +29,7 @@ export function createReplyPrefixContext(params: {
}): ReplyPrefixContextBundle {
const { cfg, agentId } = params;
const prefixContext: ResponsePrefixContext = {
identityName: resolveIdentityName(cfg, agentId),
identityName: normalizeOptionalString(resolveAgentIdentity(cfg, agentId)?.name),
};
const onModelSelected = (ctx: ModelSelectionContext) => {