Files
openclaw/extensions/whatsapp/src/auto-reply/monitor/message-line.runtime.ts
T
Peter Steinberger 58452de711 refactor(config): config-surface reduction tranche 1 — retire dead keys, dedupe channel schemas, add growth ratchet (#111142)
* refactor(config): retire dead and aliased config keys via doctor migrations

* refactor(config): dedupe bundled channel config schemas into shared builders

* feat(config): add config-surface count ratchet to doc-baseline check

* test(config): drop stale fixtures for retired config keys

* fix(doctor): migrate only positive finite MCP timeout aliases

* fix(migrate-hermes): emit canonical MCP timeouts only

* fix(config): satisfy lint and contract gates
2026-07-19 00:52:37 -07:00

40 lines
1.2 KiB
TypeScript

// Whatsapp plugin module implements message line behavior.
import type { OpenClawConfig } from "openclaw/plugin-sdk/config-contracts";
export {
formatInboundEnvelope,
type EnvelopeFormatOptions,
} from "openclaw/plugin-sdk/channel-inbound";
type WhatsAppMessagePrefixConfig = OpenClawConfig;
function normalizeAgentId(agentId: string): string {
return agentId.trim().toLowerCase() || "main";
}
function resolveIdentityNamePrefix(
cfg: WhatsAppMessagePrefixConfig,
agentId: string,
): string | undefined {
const normalizedAgentId = normalizeAgentId(agentId);
const identityName = cfg.agents?.list
?.find((agent) => normalizeAgentId(agent.id ?? "") === normalizedAgentId)
?.identity?.name?.trim();
return identityName ? `[${identityName}]` : undefined;
}
export function resolveMessagePrefix(
cfg: WhatsAppMessagePrefixConfig,
agentId: string,
opts?: { configured?: string; hasAllowFrom?: boolean; fallback?: string },
): string {
const configured = opts?.configured;
if (configured !== undefined) {
return configured;
}
if (opts?.hasAllowFrom === true) {
return "";
}
return resolveIdentityNamePrefix(cfg, agentId) ?? opts?.fallback ?? "[openclaw]";
}