fix: thread accountId through subagent announce delivery
Co-authored-by: Adam Holt <adam91holt@users.noreply.github.com>
This commit is contained in:
5
src/utils/account-id.ts
Normal file
5
src/utils/account-id.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
export function normalizeAccountId(value?: string): string | undefined {
|
||||
if (typeof value !== "string") return undefined;
|
||||
const trimmed = value.trim();
|
||||
return trimmed || undefined;
|
||||
}
|
||||
21
src/utils/delivery-context.ts
Normal file
21
src/utils/delivery-context.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { normalizeAccountId } from "./account-id.js";
|
||||
|
||||
export type DeliveryContext = {
|
||||
channel?: string;
|
||||
to?: string;
|
||||
accountId?: string;
|
||||
};
|
||||
|
||||
export function normalizeDeliveryContext(context?: DeliveryContext): DeliveryContext | undefined {
|
||||
if (!context) return undefined;
|
||||
const channel =
|
||||
typeof context.channel === "string" ? context.channel.trim() : undefined;
|
||||
const to = typeof context.to === "string" ? context.to.trim() : undefined;
|
||||
const accountId = normalizeAccountId(context.accountId);
|
||||
if (!channel && !to && !accountId) return undefined;
|
||||
return {
|
||||
channel: channel || undefined,
|
||||
to: to || undefined,
|
||||
accountId,
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user