🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
✨ feat(notification): add i18n keys for scheduled task failure (#14088)
YuTengjing57781850ce06
diff --git a/locales/en-US/notification.json b/locales/en-US/notification.jsonindex 81892314466..d4f85ce5088 100644--- a/locales/en-US/notification.json+++ b/locales/en-US/notification.json@@ -1,10 +1,18 @@{+ "agent_cron_job_failed": "Your scheduled task \"{{jobName}}\" failed. Open the task to see the full error.",+ "agent_cron_job_failed_insufficient_budget": "Your scheduled task \"{{jobName}}\" couldn't run because your account is out of credits. Top up or upgrade your plan to resume future runs.",+ "agent_cron_job_failed_insufficient_budget_title": "Scheduled task paused: insufficient credits",+ "agent_cron_job_failed_title": "Scheduled task failed","billboard.learnMore": "Learn more","billboard.menuLabel": "Announcements",+ "image_generation_completed": "Your image \"{{prompt}}\" is ready.",+ "image_generation_completed_title": "Image generation completed","inbox.archiveAll": "Archive all","inbox.empty": "No notifications yet","inbox.emptyUnread": "No unread notifications","inbox.filterUnread": "Show unread only","inbox.markAllRead": "Mark all as read",- "inbox.title": "Notifications"+ "inbox.title": "Notifications",+ "video_generation_completed": "Your video \"{{prompt}}\" is ready.",+ "video_generation_completed_title": "Video generation completed"}diff --git a/locales/en-US/setting.json b/locales/en-US/setting.jsonindex e618d58c4fa..6440d9e8683 100644--- a/locales/en-US/setting.json+++ b/locales/en-US/setting.json@@ -447,11 +447,18 @@"myAgents.status.published": "Published","myAgents.status.unpublished": "Unpublished","myAgents.title": "My Published Agents",+ "notification.category.generation.desc": "Image and video completion notifications",+ "notification.category.generation.title": "Generation",+ "notification.category.schedule.desc": "Scheduled agent run failures and pauses",+ "notification.category.schedule.title": "Scheduled tasks","notification.email.desc": "Receive email notifications when important events occur","notification.email.title": "Email Notifications","notification.enabled": "Enabled","notification.inbox.desc": "Show notifications in the in-app inbox","notification.inbox.title": "Inbox Notifications",+ "notification.item.agent_cron_job_failed": "Scheduled task failures",+ "notification.item.image_generation_completed": "Image generation completed",+ "notification.item.video_generation_completed": "Video generation completed","notification.title": "Notification Channels","plugin.addMCPPlugin": "Add MCP","plugin.addTooltip": "Custom Skills",diff --git a/locales/zh-CN/notification.json b/locales/zh-CN/notification.jsonindex e5d7fa43463..a639b303cd5 100644--- a/locales/zh-CN/notification.json+++ b/locales/zh-CN/notification.json@@ -1,10 +1,18 @@{+ "agent_cron_job_failed": "定时任务「{{jobName}}」执行失败,点击查看详情。",+ "agent_cron_job_failed_insufficient_budget": "定时任务「{{jobName}}」因账户额度不足未能执行。请充值或升级套餐以恢复后续运行。",+ "agent_cron_job_failed_insufficient_budget_title": "定时任务已暂停:额度不足",+ "agent_cron_job_failed_title": "定时任务执行失败","billboard.learnMore": "了解更多","billboard.menuLabel": "公告",+ "image_generation_completed": "图片「{{prompt}}」已生成。",+ "image_generation_completed_title": "图片生成完成","inbox.archiveAll": "全部归档","inbox.empty": "暂无通知","inbox.emptyUnread": "没有未读通知","inbox.filterUnread": "仅显示未读","inbox.markAllRead": "全部标为已读",- "inbox.title": "通知"+ "inbox.title": "通知",+ "video_generation_completed": "视频「{{prompt}}」已生成。",+ "video_generation_completed_title": "视频生成完成"}diff --git a/locales/zh-CN/setting.json b/locales/zh-CN/setting.jsonindex c61d2a28d9d..9c3291225e6 100644--- a/locales/zh-CN/setting.json+++ b/locales/zh-CN/setting.json@@ -454,11 +454,18 @@"myAgents.status.published": "已上架","myAgents.status.unpublished": "未上架","myAgents.title": "我发布的助理",+ "notification.category.generation.desc": "图片和视频生成完成通知",+ "notification.category.generation.title": "生成",+ "notification.category.schedule.desc": "定时助理运行失败和暂停通知",+ "notification.category.schedule.title": "定时任务","notification.email.desc": "当重要事件发生时接收邮件通知","notification.email.title": "邮件通知","notification.enabled": "启用","notification.inbox.desc": "在应用内收件箱中显示通知","notification.inbox.title": "站内通知",+ "notification.item.agent_cron_job_failed": "定时任务执行失败",+ "notification.item.image_generation_completed": "图片生成完成",+ "notification.item.video_generation_completed": "视频生成完成","notification.title": "通知渠道","plugin.addMCPPlugin": "添加 MCP","plugin.addTooltip": "自定义技能",diff --git a/src/app/(backend)/api/webhooks/video/[provider]/route.ts b/src/app/(backend)/api/webhooks/video/[provider]/route.tsindex cf8cfea759a..6df2625f99e 100644--- a/src/app/(backend)/api/webhooks/video/[provider]/route.ts+++ b/src/app/(backend)/api/webhooks/video/[provider]/route.ts@@ -19,8 +19,7 @@ import { type RuntimeVideoGenParams } from 'model-bank';import { NextResponse } from 'next/server';import { chargeAfterGenerate } from '@/business/server/video-generation/chargeAfterGenerate';-// TODO: temporarily disabled until notification UI is polished-// import { notifyVideoCompleted } from '@/business/server/video-generation/notifyVideoCompleted';+import { notifyVideoCompleted } from '@/business/server/video-generation/notifyVideoCompleted';import { AsyncTaskModel } from '@/database/models/asyncTask';import { GenerationModel } from '@/database/models/generation';import { generationBatches } from '@/database/schemas';@@ -217,14 +216,17 @@ export const POST = async (req: Request, { params }: { params: Promise<{ providestatus: AsyncTaskStatus.Success,});- // TODO: temporarily disabled until notification UI is polished- // notifyVideoCompleted({- // generationBatchId: generation.generationBatchId!,- // model: requestedModel,- // prompt: batch?.prompt ?? '',- // topicId: batch?.generationTopicId,- // userId: asyncTask.userId,- // }).catch((err) => console.error('[video-webhook] notification failed:', err));+ try {+ await notifyVideoCompleted({+ generationBatchId: generation.generationBatchId!,+ model: requestedModel,+ prompt: batch?.prompt ?? '',+ topicId: batch?.generationTopicId,+ userId: asyncTask.userId,+ });+ } catch (err) {+ console.error('[video-webhook] notification failed:', err);+ }// Charge after successful video generationtry {diff --git a/src/locales/default/notification.ts b/src/locales/default/notification.tsindex cddb6d8fb7e..3e335d1b7f7 100644--- a/src/locales/default/notification.ts+++ b/src/locales/default/notification.ts@@ -1,10 +1,20 @@export default {+ 'agent_cron_job_failed':+ 'Your scheduled task "{{jobName}}" failed. Open the task to see the full error.',+ 'agent_cron_job_failed_insufficient_budget':+ 'Your scheduled task "{{jobName}}" couldn\'t run because your account is out of credits. Top up or upgrade your plan to resume future runs.',+ 'agent_cron_job_failed_insufficient_budget_title': 'Scheduled task paused: insufficient credits',+ 'agent_cron_job_failed_title': 'Scheduled task failed','billboard.learnMore': 'Learn more','billboard.menuLabel': 'Announcements',+ 'image_generation_completed': 'Your image "{{prompt}}" is ready.',+ 'image_generation_completed_title': 'Image generation completed','inbox.archiveAll': 'Archive all','inbox.empty': 'No notifications yet','inbox.emptyUnread': 'No unread notifications','inbox.filterUnread': 'Show unread only','inbox.markAllRead': 'Mark all as read','inbox.title': 'Notifications',+ 'video_generation_completed': 'Your video "{{prompt}}" is ready.',+ 'video_generation_completed_title': 'Video generation completed',};diff --git a/src/locales/default/setting.ts b/src/locales/default/setting.tsindex d5a538e963a..5c58aa26139 100644--- a/src/locales/default/setting.ts+++ b/src/locales/default/setting.ts@@ -468,6 +468,13 @@ export default {'notification.email.title': 'Email Notifications','notification.inbox.desc': 'Show notifications in the in-app inbox','notification.inbox.title': 'Inbox Notifications',+ 'notification.category.generation.desc': 'Image and video completion notifications',+ 'notification.category.generation.title': 'Generation',+ 'notification.category.schedule.desc': 'Scheduled agent run failures and pauses',+ 'notification.category.schedule.title': 'Scheduled tasks',+ 'notification.item.agent_cron_job_failed': 'Scheduled task failures',+ 'notification.item.image_generation_completed': 'Image generation completed',+ 'notification.item.video_generation_completed': 'Video generation completed','notification.title': 'Notification Channels','myAgents.actions.cancel': 'Cancel','myAgents.actions.confirmDeprecate': 'Confirm Deprecate',diff --git a/src/routes/(main)/settings/hooks/useCategory.tsx b/src/routes/(main)/settings/hooks/useCategory.tsxindex e94e1260ae8..cf5d11a3770 100644--- a/src/routes/(main)/settings/hooks/useCategory.tsx+++ b/src/routes/(main)/settings/hooks/useCategory.tsx@@ -2,7 +2,7 @@ import { isDesktop } from '@lobechat/const';import { Avatar } from '@lobehub/ui';import { SkillsIcon } from '@lobehub/ui/icons';import {- // BellIcon,+ BellIcon,Brain,BrainCircuit,ChartColumnBigIcon,@@ -101,12 +101,11 @@ export const useCategory = () => {key: SettingsTabs.Hotkey,label: t('tab.hotkey'),},- // TODO: temporarily disabled until notification UI is polished- // enableBusinessFeatures && {- // icon: BellIcon,- // key: SettingsTabs.Notification,- // label: t('tab.notification'),- // },+ enableBusinessFeatures && {+ icon: BellIcon,+ key: SettingsTabs.Notification,+ label: t('tab.notification'),+ },].filter(Boolean) as CategoryItem[];groups.push({diff --git a/src/server/routers/async/image.ts b/src/server/routers/async/image.tsindex 72d41d68388..177e5c87c99 100644--- a/src/server/routers/async/image.ts+++ b/src/server/routers/async/image.ts@@ -17,8 +17,7 @@ import { type RuntimeImageGenParams } from 'model-bank';import { z } from 'zod';import { chargeAfterGenerate } from '@/business/server/image-generation/chargeAfterGenerate';-// TODO: temporarily disabled until notification UI is polished-// import { notifyImageCompleted } from '@/business/server/image-generation/notifyImageCompleted';+import { notifyImageCompleted } from '@/business/server/image-generation/notifyImageCompleted';import { createImageBusinessMiddleware } from '@/business/server/trpc-middlewares/async';import { AsyncTaskModel } from '@/database/models/asyncTask';import { FileModel } from '@/database/models/file';@@ -376,15 +375,18 @@ export const imageRouter = router({status: AsyncTaskStatus.Success,});- // TODO: temporarily disabled until notification UI is polished- // notifyImageCompleted({- // duration,- // generationBatchId,- // model,- // prompt: params.prompt,- // topicId: generationTopicId,- // userId: ctx.userId,- // }).catch((err) => console.error('[image-async] notification failed:', err));+ try {+ await notifyImageCompleted({+ duration,+ generationBatchId,+ model,+ prompt: params.prompt,+ topicId: generationTopicId,+ userId: ctx.userId,+ });+ } catch (err) {+ console.error('[image-async] notification failed:', err);+ }if (ENABLE_BUSINESS_FEATURES) {await chargeAfterGenerate({diff --git a/src/server/services/agentRuntime/hooks/HookDispatcher.ts b/src/server/services/agentRuntime/hooks/HookDispatcher.tsindex f6377b1ff75..7eae3a8b866 100644--- a/src/server/services/agentRuntime/hooks/HookDispatcher.ts+++ b/src/server/services/agentRuntime/hooks/HookDispatcher.ts@@ -72,6 +72,26 @@ async function fetchDeliver(url: string, payload: Record<string, unknown>): Prom}}+function buildWebhookPayload(+ event: AnyHookEvent,+ eventFields?: (keyof AgentHookEvent)[],+): Record<string, unknown> {+ if (eventFields) {+ const payload: Record<string, unknown> = {};+ for (const field of eventFields) {+ if (field === 'finalState') continue;+ if (field in event) payload[field] = event[field as keyof AnyHookEvent];+ }+ return payload;+ }++ const payload = { ...event };+ if ('finalState' in payload) {+ delete (payload as { finalState?: unknown }).finalState;+ }+ return payload;+}+/*** HookDispatcher — central hub for registering and dispatching agent lifecycle hooks*@@ -129,12 +149,7 @@ export class HookDispatcher {hook.id,hook.webhook.url,);- // Strip finalState from webhook payload (too large, local-only)- // Webhook delivery only applies to step-level hooks (AgentHookEvent)- const webhookPayload = { ...event };- if ('finalState' in webhookPayload) {- delete (webhookPayload as { finalState?: unknown }).finalState;- }+ const webhookPayload = buildWebhookPayload(event, hook.webhook.eventFields);await deliverWebhook(hook.webhook, {...webhookPayload,hookId: hook.id,diff --git a/src/server/services/agentRuntime/hooks/__tests__/HookDispatcher.test.ts b/src/server/services/agentRuntime/hooks/__tests__/HookDispatcher.test.tsindex 1f6016fdecf..e92f8fbf5b8 100644--- a/src/server/services/agentRuntime/hooks/__tests__/HookDispatcher.test.ts+++ b/src/server/services/agentRuntime/hooks/__tests__/HookDispatcher.test.ts@@ -189,6 +189,47 @@ describe('HookDispatcher', () => {expect(body.hookId).toBe('custom-body-hook');});+ it('should only include selected event fields when eventFields is set', async () => {+ dispatcher.register(operationId, [+ {+ handler: vi.fn(),+ id: 'projected-hook',+ type: 'onError',+ webhook: {+ body: { taskId: 'task_123' },+ eventFields: ['errorMessage', 'reason', 'topicId'],+ url: 'https://example.com/hook',+ },+ },+ ]);++ const serialized = dispatcher.getSerializedHooks(operationId);+ await dispatcher.dispatch(+ operationId,+ 'onError',+ makeEvent({+ errorDetail: 'internal raw error',+ errorMessage: 'Public error',+ finalState: { status: 'error' },+ lastAssistantContent: 'private assistant output',+ reason: 'error',+ topicId: 'topic_123',+ }),+ serialized,+ );++ const call = vi.mocked(global.fetch).mock.calls[0];+ const body = JSON.parse(call[1]?.body as string);+ expect(body).toEqual({+ errorMessage: 'Public error',+ hookId: 'projected-hook',+ hookType: 'onError',+ reason: 'error',+ taskId: 'task_123',+ topicId: 'topic_123',+ });+ });+it('should not call local handler in production mode', async () => {const handler = vi.fn();dispatcher.register(operationId, [diff --git a/src/server/services/agentRuntime/hooks/types.ts b/src/server/services/agentRuntime/hooks/types.tsindex 932e21b6111..7e620c82fb5 100644--- a/src/server/services/agentRuntime/hooks/types.ts+++ b/src/server/services/agentRuntime/hooks/types.ts@@ -38,6 +38,9 @@ export interface AgentHookWebhook {/** Delivery method: 'fetch' (plain HTTP) or 'qstash' (guaranteed delivery). Default: 'qstash' */delivery?: 'fetch' | 'qstash';+ /** Event fields to include in the webhook payload. Defaults to all serializable event fields. */+ eventFields?: (keyof AgentHookEvent)[];+/** Webhook endpoint URL (relative or absolute) */url: string;}