Files
openclaw/src/plugin-sdk/tool-send.ts
Tak Hoffman 7f2708a8c3 fix(routing): unify session delivery invariants for duplicate suppression (#33786)
* Routing: unify session delivery invariants

* Routing: address PR review feedback

* Routing: tighten topic and session-scope suppression

* fix(chat): inherit routes for per-account channel-peer sessions
2026-03-03 21:40:38 -06:00

23 lines
774 B
TypeScript

export function extractToolSend(
args: Record<string, unknown>,
expectedAction = "sendMessage",
): { to: string; accountId?: string; threadId?: string } | null {
const action = typeof args.action === "string" ? args.action.trim() : "";
if (action !== expectedAction) {
return null;
}
const to = typeof args.to === "string" ? args.to : undefined;
if (!to) {
return null;
}
const accountId = typeof args.accountId === "string" ? args.accountId.trim() : undefined;
const threadIdRaw =
typeof args.threadId === "string"
? args.threadId.trim()
: typeof args.threadId === "number"
? String(args.threadId)
: "";
const threadId = threadIdRaw.length > 0 ? threadIdRaw : undefined;
return { to, accountId, threadId };
}