fix(gateway): harden agent provider routing
This commit is contained in:
@@ -5,34 +5,23 @@ import { resolveMSTeamsCredentials } from "../../msteams/token.js";
|
||||
import { listEnabledSignalAccounts } from "../../signal/accounts.js";
|
||||
import { listEnabledSlackAccounts } from "../../slack/accounts.js";
|
||||
import { listEnabledTelegramAccounts } from "../../telegram/accounts.js";
|
||||
import { normalizeMessageProvider } from "../../utils/message-provider.js";
|
||||
import {
|
||||
DELIVERABLE_MESSAGE_PROVIDERS,
|
||||
type DeliverableMessageProvider,
|
||||
normalizeMessageProvider,
|
||||
} from "../../utils/message-provider.js";
|
||||
import {
|
||||
listEnabledWhatsAppAccounts,
|
||||
resolveWhatsAppAccount,
|
||||
} from "../../web/accounts.js";
|
||||
import { webAuthExists } from "../../web/session.js";
|
||||
|
||||
export type MessageProviderId =
|
||||
| "whatsapp"
|
||||
| "telegram"
|
||||
| "discord"
|
||||
| "slack"
|
||||
| "signal"
|
||||
| "imessage"
|
||||
| "msteams";
|
||||
export type MessageProviderId = DeliverableMessageProvider;
|
||||
|
||||
const MESSAGE_PROVIDERS: MessageProviderId[] = [
|
||||
"whatsapp",
|
||||
"telegram",
|
||||
"discord",
|
||||
"slack",
|
||||
"signal",
|
||||
"imessage",
|
||||
"msteams",
|
||||
];
|
||||
const MESSAGE_PROVIDERS = [...DELIVERABLE_MESSAGE_PROVIDERS];
|
||||
|
||||
function isKnownProvider(value: string): value is MessageProviderId {
|
||||
return (MESSAGE_PROVIDERS as string[]).includes(value);
|
||||
return (MESSAGE_PROVIDERS as readonly string[]).includes(value);
|
||||
}
|
||||
|
||||
async function isWhatsAppConfigured(cfg: ClawdbotConfig): Promise<boolean> {
|
||||
|
||||
@@ -1,16 +1,12 @@
|
||||
import type { ClawdbotConfig } from "../../config/config.js";
|
||||
import type { SessionEntry } from "../../config/sessions.js";
|
||||
import type {
|
||||
DeliverableMessageProvider,
|
||||
GatewayMessageProvider,
|
||||
} from "../../utils/message-provider.js";
|
||||
import { normalizeE164 } from "../../utils.js";
|
||||
|
||||
export type OutboundProvider =
|
||||
| "whatsapp"
|
||||
| "telegram"
|
||||
| "discord"
|
||||
| "slack"
|
||||
| "signal"
|
||||
| "imessage"
|
||||
| "msteams"
|
||||
| "none";
|
||||
export type OutboundProvider = DeliverableMessageProvider | "none";
|
||||
|
||||
export type HeartbeatTarget = OutboundProvider | "last";
|
||||
|
||||
@@ -25,15 +21,7 @@ export type OutboundTargetResolution =
|
||||
| { ok: false; error: Error };
|
||||
|
||||
export function resolveOutboundTarget(params: {
|
||||
provider:
|
||||
| "whatsapp"
|
||||
| "telegram"
|
||||
| "discord"
|
||||
| "slack"
|
||||
| "signal"
|
||||
| "imessage"
|
||||
| "msteams"
|
||||
| "webchat";
|
||||
provider: GatewayMessageProvider;
|
||||
to?: string;
|
||||
allowFrom?: string[];
|
||||
}): OutboundTargetResolution {
|
||||
|
||||
Reference in New Issue
Block a user