fix: wire slack into delivery routing
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { sendMessageDiscord } from "../discord/send.js";
|
||||
import { sendMessageIMessage } from "../imessage/send.js";
|
||||
import { logWebSelfId, sendMessageWhatsApp } from "../providers/web/index.js";
|
||||
import { sendMessageSlack } from "../slack/send.js";
|
||||
import { sendMessageSignal } from "../signal/send.js";
|
||||
import { sendMessageSlack } from "../slack/send.js";
|
||||
import { sendMessageTelegram } from "../telegram/send.js";
|
||||
|
||||
@@ -464,12 +464,15 @@ export async function runCronIsolatedAgentTurn(params: {
|
||||
};
|
||||
}
|
||||
const slackTarget = resolvedDelivery.to;
|
||||
const textLimit = resolveTextChunkLimit(params.cfg, "slack");
|
||||
try {
|
||||
for (const payload of payloads) {
|
||||
const mediaList =
|
||||
payload.mediaUrls ?? (payload.mediaUrl ? [payload.mediaUrl] : []);
|
||||
if (mediaList.length === 0) {
|
||||
await params.deps.sendMessageSlack(slackTarget, payload.text ?? "");
|
||||
for (const chunk of chunkText(payload.text ?? "", textLimit)) {
|
||||
await params.deps.sendMessageSlack(slackTarget, chunk);
|
||||
}
|
||||
} else {
|
||||
let first = true;
|
||||
for (const url of mediaList) {
|
||||
|
||||
@@ -137,7 +137,14 @@ export type HookAgentPayload = {
|
||||
wakeMode: "now" | "next-heartbeat";
|
||||
sessionKey: string;
|
||||
deliver: boolean;
|
||||
channel: "last" | "whatsapp" | "telegram" | "discord" | "signal" | "imessage";
|
||||
channel:
|
||||
| "last"
|
||||
| "whatsapp"
|
||||
| "telegram"
|
||||
| "discord"
|
||||
| "slack"
|
||||
| "signal"
|
||||
| "imessage";
|
||||
to?: string;
|
||||
thinking?: string;
|
||||
timeoutSeconds?: number;
|
||||
@@ -171,6 +178,7 @@ export function normalizeAgentPayload(
|
||||
channelRaw === "whatsapp" ||
|
||||
channelRaw === "telegram" ||
|
||||
channelRaw === "discord" ||
|
||||
channelRaw === "slack" ||
|
||||
channelRaw === "signal" ||
|
||||
channelRaw === "imessage" ||
|
||||
channelRaw === "last"
|
||||
@@ -183,7 +191,8 @@ export function normalizeAgentPayload(
|
||||
if (channel === null) {
|
||||
return {
|
||||
ok: false,
|
||||
error: "channel must be last|whatsapp|telegram|discord|signal|imessage",
|
||||
error:
|
||||
"channel must be last|whatsapp|telegram|discord|slack|signal|imessage",
|
||||
};
|
||||
}
|
||||
const toRaw = payload.to;
|
||||
|
||||
@@ -21,6 +21,7 @@ import { createSubsystemLogger } from "../logging.js";
|
||||
import { getQueueSize } from "../process/command-queue.js";
|
||||
import { webAuthExists } from "../providers/web/index.js";
|
||||
import { defaultRuntime, type RuntimeEnv } from "../runtime.js";
|
||||
import { sendMessageSlack } from "../slack/send.js";
|
||||
import { sendMessageSignal } from "../signal/send.js";
|
||||
import { sendMessageSlack } from "../slack/send.js";
|
||||
import { sendMessageTelegram } from "../telegram/send.js";
|
||||
@@ -391,7 +392,9 @@ async function deliverHeartbeatReply(params: {
|
||||
|
||||
if (channel === "slack") {
|
||||
if (mediaUrls.length === 0) {
|
||||
await deps.sendSlack(to, text);
|
||||
for (const chunk of chunkText(text, textLimit)) {
|
||||
await deps.sendSlack(to, chunk);
|
||||
}
|
||||
return;
|
||||
}
|
||||
let first = true;
|
||||
@@ -402,7 +405,6 @@ async function deliverHeartbeatReply(params: {
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (mediaUrls.length === 0) {
|
||||
await deps.sendDiscord(to, text, { verbose: false });
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user