🤯 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
💄 style(referral): update reward rules copy (#15923)
YuTengjing3c907ff0fd71
diff --git a/apps/server/src/routers/lambda/__tests__/integration/aiAgent/serverCallAgent.integration.test.ts b/apps/server/src/routers/lambda/__tests__/integration/aiAgent/serverCallAgent.integration.test.tsindex f28866c7076..66da4bed3ae 100644--- a/apps/server/src/routers/lambda/__tests__/integration/aiAgent/serverCallAgent.integration.test.ts+++ b/apps/server/src/routers/lambda/__tests__/integration/aiAgent/serverCallAgent.integration.test.ts@@ -38,7 +38,7 @@ vi.mock('@/server/services/file', () => ({})),}));-let mockResponsesCreate: ReturnType<typeof vi.spyOn>;+let mockResponsesCreate: any;let serverDB: LobeChatDatabase;let userId: string;let parentAgentId: string;diff --git a/apps/server/src/routers/tools/_helpers/marketConnections.test.ts b/apps/server/src/routers/tools/_helpers/marketConnections.test.tsindex aee9792bad2..2d14dc8afbc 100644--- a/apps/server/src/routers/tools/_helpers/marketConnections.test.ts+++ b/apps/server/src/routers/tools/_helpers/marketConnections.test.ts@@ -1,8 +1,10 @@import { afterEach, describe, expect, it, vi } from 'vitest';import {+ isMarketConnectionsAuthError,isMarketConnectionsTimeoutError,listMarketConnectionsWithTimeout,+ listOptionalMarketConnectionsWithTimeout,MARKET_CONNECTIONS_REQUEST_TIMEOUT_MS,} from './marketConnections';@@ -31,4 +33,33 @@ describe('marketConnections helpers', () => {expect(isMarketConnectionsTimeoutError(new DOMException('Aborted', 'AbortError'))).toBe(true);expect(isMarketConnectionsTimeoutError(new Error('market failed'))).toBe(false);});++ it('detects Market auth failures', () => {+ expect(+ isMarketConnectionsAuthError({+ errorBody: { error: 'unauthorized', error_description: 'Missing bearer token' },+ status: 401,+ }),+ ).toBe(true);+ expect(isMarketConnectionsAuthError(new Error('Network error'))).toBe(false);+ });++ it('returns empty connections for optional auth failures', async () => {+ const listConnections = vi.fn().mockRejectedValue({+ errorBody: { error: 'unauthorized', error_description: 'Missing bearer token' },+ status: 401,+ });++ await expect(listOptionalMarketConnectionsWithTimeout({ listConnections })).resolves.toEqual({+ connections: [],+ success: true,+ });+ });++ it('rethrows non-auth failures for optional connections', async () => {+ const error = new Error('Market API unavailable');+ const listConnections = vi.fn().mockRejectedValue(error);++ await expect(listOptionalMarketConnectionsWithTimeout({ listConnections })).rejects.toBe(error);+ });});diff --git a/apps/server/src/routers/tools/_helpers/marketConnections.ts b/apps/server/src/routers/tools/_helpers/marketConnections.tsindex f07bf84de19..52cf085c29f 100644--- a/apps/server/src/routers/tools/_helpers/marketConnections.ts+++ b/apps/server/src/routers/tools/_helpers/marketConnections.ts@@ -4,6 +4,47 @@ export const MARKET_CONNECTIONS_REQUEST_TIMEOUT_MS = 10_000;type MarketConnectClient = Pick<MarketSDK['connect'], 'listConnections'>;+const isRecord = (value: unknown): value is Record<string, unknown> =>+ typeof value === 'object' && value !== null;++const getStringField = (value: unknown, key: string) => {+ if (!isRecord(value)) return;++ const field = value[key];+ return typeof field === 'string' ? field : undefined;+};++const includesAuthError = (value?: string) => {+ const normalized = value?.toLowerCase();++ if (!normalized) return false;++ return (+ normalized === 'unauthorized' ||+ normalized === 'invalid_token' ||+ normalized === 'token_expired' ||+ normalized.includes('missing bearer token') ||+ normalized.includes('unauthorized') ||+ normalized.includes('invalid_token') ||+ normalized.includes('token expired')+ );+};++export const isMarketConnectionsAuthError = (error: unknown): boolean => {+ if (!isRecord(error)) return false;++ const status = error.status;+ const errorBody = error.errorBody;++ return (+ status === 401 ||+ includesAuthError(getStringField(error, 'name')) ||+ includesAuthError(getStringField(error, 'message')) ||+ includesAuthError(getStringField(errorBody, 'error')) ||+ includesAuthError(getStringField(errorBody, 'error_description'))+ );+};+export const isMarketConnectionsTimeoutError = (error: unknown): boolean =>error instanceof Error && (error.name === 'TimeoutError' || error.name === 'AbortError');@@ -15,3 +56,18 @@ export const listMarketConnectionsWithTimeout = async (signal: AbortSignal.timeout(timeoutMs),});};++export const listOptionalMarketConnectionsWithTimeout = async (+ marketConnect: MarketConnectClient,+ timeoutMs = MARKET_CONNECTIONS_REQUEST_TIMEOUT_MS,+): Promise<ListConnectionsResponse> => {+ try {+ return await listMarketConnectionsWithTimeout(marketConnect, timeoutMs);+ } catch (error) {+ if (isMarketConnectionsAuthError(error)) {+ return { connections: [], success: true };+ }++ throw error;+ }+};diff --git a/apps/server/src/routers/tools/market.ts b/apps/server/src/routers/tools/market.tsindex f1575364a94..12fda36ed95 100644--- a/apps/server/src/routers/tools/market.ts+++ b/apps/server/src/routers/tools/market.ts@@ -23,7 +23,7 @@ import { createSandboxService } from '@/server/services/sandbox';import { scheduleToolCallReport } from './_helpers';import {isMarketConnectionsTimeoutError,- listMarketConnectionsWithTimeout,+ listOptionalMarketConnectionsWithTimeout,MARKET_CONNECTIONS_REQUEST_TIMEOUT_MS,} from './_helpers/marketConnections';@@ -540,7 +540,7 @@ export const marketRouter = router({log('connectListConnections');try {- const response = await listMarketConnectionsWithTimeout(ctx.marketSDK.connect);+ const response = await listOptionalMarketConnectionsWithTimeout(ctx.marketSDK.connect);// Debug logginglog('connectListConnections raw response: %O', response);log('connectListConnections connections: %O', response.connections);diff --git a/locales/en-US/subscription.json b/locales/en-US/subscription.jsonindex 19f12226f28..b48f73e00c5 100644--- a/locales/en-US/subscription.json+++ b/locales/en-US/subscription.json@@ -410,14 +410,13 @@"referral.rules.backfill.title": "Backfill Invite Code","referral.rules.description": "Learn about referral reward program rules","referral.rules.expiry": "Credit validity: Available referral credits will be cleared after 100 days of user inactivity",- "referral.rules.missedCode": "Missed invite code: You can <0>backfill</0> within 7 days of registration. After backfilling, you still need to perform a valid action and complete a payment to receive rewards",+ "referral.rules.missedCode": "Missed invite code: You can <0>backfill</0> within 7 days of registration. If you have already made a real payment and pass verification, rewards are processed after binding; otherwise they are processed after your first real payment","referral.rules.priority": "Credit consumption priority: Free credits → Subscription credits → Referral credits → Top-up credits","referral.rules.registration": "Registration method: Invited users register via referral link or enter referral code on registration page","referral.rules.reward": "Reward: Referrer and invitee each receive {{reward}}M credits",- "referral.rules.rewardDelay": "Reward processing: Credits will be distributed within 1 hour after the invitee completes a payment and passes verification",+ "referral.rules.rewardDelay": "Reward processing: Credits are granted after the invitee completes a real payment and passes verification","referral.rules.title": "Program Rules",- "referral.rules.validInvitation": "Valid invitation: Invitee registers with your referral code, performs one valid action, and completes a payment (subscription or credit top-up)",- "referral.rules.validOperation": "Valid action criteria: Send one message on Chat page, or generate one image on image page",+ "referral.rules.validInvitation": "Valid invitation: Invitee registers with your referral code and completes a real payment (subscription or personal credit top-up)","referral.stats.availableBalance": "Available Balance","referral.stats.description": "View your referral statistics","referral.stats.title": "Referral Overview",diff --git a/locales/zh-CN/subscription.json b/locales/zh-CN/subscription.jsonindex 87987bb205f..92c9e45bf8a 100644--- a/locales/zh-CN/subscription.json+++ b/locales/zh-CN/subscription.json@@ -410,14 +410,13 @@"referral.rules.backfill.title": "补填邀请码","referral.rules.description": "了解推荐奖励计划规则","referral.rules.expiry": "积分有效期:用户 100 天未活跃后,返利积分将被清除",- "referral.rules.missedCode": "忘记填写邀请码:注册七天内可以<0>补填邀请码</0>,补填后需完成一次有效操作并完成付费才可获得奖励",+ "referral.rules.missedCode": "忘记填写邀请码:注册七天内可以<0>补填邀请码</0>。如果已完成真实付费并通过审核,绑定后会处理奖励;否则会在首次真实付费后处理奖励","referral.rules.priority": "积分使用优先级:免费积分 → 订阅积分 → 返利积分 → 充值积分","referral.rules.registration": "注册方式:被邀请用户通过推荐链接注册或在注册页输入推荐码","referral.rules.reward": "奖励:邀请人和被邀请人各获得 {{reward}}M 积分",- "referral.rules.rewardDelay": "奖励处理:被邀请人付费且审核通过后,积分将在 1 小时内发放",+ "referral.rules.rewardDelay": "奖励处理:被邀请人完成真实付费并通过审核后发放积分","referral.rules.title": "计划规则",- "referral.rules.validInvitation": "有效邀请:被邀请人使用您的推荐码注册、完成一次有效操作,并完成付费(订阅或积分充值)",- "referral.rules.validOperation": "有效操作标准:在对话页发送一条消息,或在图片页生成一张图片",+ "referral.rules.validInvitation": "有效邀请:被邀请人使用您的推荐码注册,并完成真实付费(订阅或个人积分充值)","referral.stats.availableBalance": "可用余额","referral.stats.description": "查看您的推荐统计数据","referral.stats.title": "推荐概览",diff --git a/packages/locales/src/default/subscription.ts b/packages/locales/src/default/subscription.tsindex 4cfa9ecddfb..66aef245fcf 100644--- a/packages/locales/src/default/subscription.ts+++ b/packages/locales/src/default/subscription.ts@@ -478,21 +478,19 @@ export default {'referral.rules.expiry':'Credit validity: Available referral credits will be cleared after 100 days of user inactivity','referral.rules.missedCode':- 'Missed invite code: You can <0>backfill</0> within 7 days of registration. After backfilling, you still need to perform a valid action and complete a payment to receive rewards',+ 'Missed invite code: You can <0>backfill</0> within 7 days of registration. If you have already made a real payment and pass verification, rewards are processed after binding; otherwise they are processed after your first real payment','referral.rules.priority':'Credit consumption priority: Free credits → Subscription credits → Referral credits → Top-up credits','referral.rules.registration':'Registration method: Invited users register via referral link or enter referral code on registration page','referral.rules.reward': 'Reward: Referrer and invitee each receive {{reward}}M credits','referral.rules.rewardDelay':- 'Reward processing: Credits will be distributed within 1 hour after the invitee completes a payment and passes verification',+ 'Reward processing: Credits are granted after the invitee completes a real payment and passes verification','referral.rules.title': 'Program Rules','referral.rules.validInvitation':- 'Valid invitation: Invitee registers with your referral code, performs one valid action, and completes a payment (subscription or credit top-up)',+ 'Valid invitation: Invitee registers with your referral code and completes a real payment (subscription or personal credit top-up)','referral.rules.antiAbuse':'If fraudulent activity is detected (e.g., mass registration of disposable email accounts), the associated accounts will be permanently banned',- 'referral.rules.validOperation':- 'Valid action criteria: Send one message on Chat page, or generate one image on image page','referral.stats.availableBalance': 'Available Balance','referral.stats.description': 'View your referral statistics','referral.stats.title': 'Referral Overview',