diff --git a/CHANGELOG.md b/CHANGELOG.md index 7cbdf6912..669c7984b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,7 @@ Docs: https://docs.openclaw.ai - Cron: accept epoch timestamps and 0ms durations in CLI `--at` parsing. - Cron: reload store data when the store file is recreated or mtime changes. - Cron: deliver announce runs directly, honor delivery mode, and respect wakeMode for summaries. (#8540) Thanks @tyler6204. +- Telegram: include forward_from_chat metadata in forwarded messages and harden cron delivery target checks. (#8392) Thanks @Glucksberg. ## 2026.2.2-3 diff --git a/src/cron/isolated-agent/run.ts b/src/cron/isolated-agent/run.ts index 0ac7013a2..3f6e06f4b 100644 --- a/src/cron/isolated-agent/run.ts +++ b/src/cron/isolated-agent/run.ts @@ -92,18 +92,6 @@ function resolveCronDeliveryBestEffort(job: CronJob): boolean { return false; } -function resolveCronDeliveryFailure( - resolved: Awaited>, -): Error | undefined { - if (resolved.error) { - return resolved.error; - } - if (!resolved.to) { - return new Error("cron delivery target is missing"); - } - return undefined; -} - export type RunCronAgentTurnResult = { status: "ok" | "error" | "skipped"; summary?: string; @@ -460,17 +448,29 @@ export async function runCronIsolatedAgentTurn(params: { ); if (deliveryRequested && !skipHeartbeatDelivery && !skipMessagingToolDelivery) { - const deliveryFailure = resolveCronDeliveryFailure(resolvedDelivery); - if (deliveryFailure) { + if (resolvedDelivery.error) { if (!deliveryBestEffort) { return { status: "error", - error: deliveryFailure.message, + error: resolvedDelivery.error.message, summary, outputText, }; } - logWarn(`[cron:${params.job.id}] ${deliveryFailure.message}`); + logWarn(`[cron:${params.job.id}] ${resolvedDelivery.error.message}`); + return { status: "ok", summary, outputText }; + } + if (!resolvedDelivery.to) { + const message = "cron delivery target is missing"; + if (!deliveryBestEffort) { + return { + status: "error", + error: message, + summary, + outputText, + }; + } + logWarn(`[cron:${params.job.id}] ${message}`); return { status: "ok", summary, outputText }; } try { diff --git a/src/telegram/bot/helpers.ts b/src/telegram/bot/helpers.ts index 4b46db1cc..c6f69e7fb 100644 --- a/src/telegram/bot/helpers.ts +++ b/src/telegram/bot/helpers.ts @@ -253,8 +253,6 @@ export function describeReplyTarget(msg: Message): TelegramReplyTarget | null { }; } -export type TelegramChatType = "private" | "group" | "supergroup" | "channel"; - export type TelegramForwardedContext = { from: string; date?: number; @@ -264,7 +262,7 @@ export type TelegramForwardedContext = { fromTitle?: string; fromSignature?: string; /** Original chat type from forward_from_chat (e.g. "channel", "supergroup", "group"). */ - fromChatType?: TelegramChatType; + fromChatType?: Chat["type"]; /** Original message ID in the source chat (channel forwards). */ fromMessageId?: number; }; @@ -338,7 +336,7 @@ function buildForwardedContextFromChat(params: { } const signature = params.signature?.trim() || undefined; const from = signature ? `${display} (${signature})` : display; - const chatType = (params.chat.type?.trim() || undefined) as TelegramChatType | undefined; + const chatType = (params.chat.type?.trim() || undefined) as Chat["type"] | undefined; return { from, date: params.date,