mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-04 00:44:04 +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.
26 lines
933 B
TypeScript
26 lines
933 B
TypeScript
import { readStringValue } from "../../packages/normalization-core/src/string-coerce.js";
|
|
|
|
export type { ChannelToolSend } from "../channels/plugins/types.public.js";
|
|
|
|
/** Extract the canonical send target fields from tool arguments when the action matches. */
|
|
export function extractToolSend(
|
|
args: Record<string, unknown>,
|
|
expectedAction = "sendMessage",
|
|
): { to: string; accountId?: string; threadId?: string } | null {
|
|
const action = readStringValue(args.action)?.trim() ?? "";
|
|
if (action !== expectedAction) {
|
|
return null;
|
|
}
|
|
const to = readStringValue(args.to);
|
|
if (!to) {
|
|
return null;
|
|
}
|
|
const accountId = readStringValue(args.accountId)?.trim();
|
|
const threadIdRaw =
|
|
typeof args.threadId === "number"
|
|
? String(args.threadId)
|
|
: (readStringValue(args.threadId)?.trim() ?? "");
|
|
const threadId = threadIdRaw.length > 0 ? threadIdRaw : undefined;
|
|
return { to, accountId, threadId };
|
|
}
|