refactor: centralize message target resolution

Co-authored-by: Thinh Dinh <tobalsan@users.noreply.github.com>
This commit is contained in:
Peter Steinberger
2026-01-17 06:03:19 +00:00
parent c7ae5100fa
commit 331141ad77
25 changed files with 192 additions and 194 deletions

View File

@@ -13,6 +13,7 @@ import {
isDeliverableMessageChannel,
normalizeMessageChannel,
} from "../../utils/message-channel.js";
import { missingTargetError } from "./target-errors.js";
export type OutboundChannel = DeliverableMessageChannel | "none";
@@ -145,9 +146,10 @@ export function resolveOutboundTarget(params: {
if (trimmed) {
return { ok: true, to: trimmed };
}
const hint = plugin.messaging?.targetHint;
return {
ok: false,
error: new Error(`Delivering to ${plugin.meta.label} requires a destination`),
error: missingTargetError(plugin.meta.label ?? params.channel, hint),
};
}