mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-12 21:53:00 -06:00
58452de711
* 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
40 lines
1.2 KiB
TypeScript
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]";
|
|
}
|