Files
openclaw/src/channels/native-command-session-targets.ts
2026-04-07 11:18:18 +01:00

24 lines
740 B
TypeScript

import { normalizeLowercaseStringOrEmpty } from "../shared/string-coerce.js";
export type ResolveNativeCommandSessionTargetsParams = {
agentId: string;
sessionPrefix: string;
userId: string;
targetSessionKey: string;
boundSessionKey?: string;
lowercaseSessionKey?: boolean;
};
export function resolveNativeCommandSessionTargets(
params: ResolveNativeCommandSessionTargetsParams,
) {
const rawSessionKey =
params.boundSessionKey ?? `agent:${params.agentId}:${params.sessionPrefix}:${params.userId}`;
return {
sessionKey: params.lowercaseSessionKey
? normalizeLowercaseStringOrEmpty(rawSessionKey)
: rawSessionKey,
commandTargetSessionKey: params.boundSessionKey ?? params.targetSessionKey,
};
}