+ {dict.agent.title} +
++ {dict.onboarding.completeSubtitle} +
++ 为你的新智能体起个名字吧 +
++ 多个特点请用逗号分隔 +
++ 注意: + 免费用户最多只能拥有 1 个自定义智能体。 + 升级到高级版可创建最多 3 个智能体。 +
++ {dict.onboarding.completeSubtitle} +
++ {dict.onboarding.completeSubtitle} +
+ + {/* Encouragement */} ++ {dict.onboarding.encouragementDetail} +
++ {dict.onboarding.redirecting} +
+ )} ++ {dict.onboarding.description} +
+ + {/* Feature cards */} +{dict.onboarding.step1}
+{dict.onboarding.step2}
+{dict.onboarding.step3}
++ {dict.onboarding.skipIntro}{' '} + + {dict.onboarding.skipLink} + +
++ 在这里,你可以向未来的自己倾诉当下的心情与期望。 + AI 智能体将以「未来的你」的身份,在 6-12 小时后给你温暖的回复。 +
+ ++ 用文字记录当下的心情、困惑与期望,让未来的自己与你对话 +
++ 根据你的描述,AI 将以「未来的你」给予温暖、治愈的回应 +
++ 追踪你的写信历程,见证自己的成长与改变 +
++ 现在就开始与未来的自己建立连接 +
+ + + ++ {agent.background} +
+ )} + + {/* Actions */} +{error}
+ +已达到智能体上限
++ {isPremium + ? '您已达到 3 个智能体的上限。如需更多,请升级套餐。' + : '免费用户最多只能拥有 1 个智能体。升级到高级版可创建最多 3 个智能体。'} +
++ 完成 onboarding 后,系统会自动为您生成专属的智能体 +
+ +{dictionary.subtitle}
++ {dictionary.noAccount}{' '} + + {dictionary.signUp} + +
+{dictionary.signUpSubtitle}
++ {dictionary.hasAccount}{' '} + + {dictionary.signIn} + +
+{encouragement}
+ )} + + {/* Form */} + ++ {dict.keepThinking} +
+{error}
} + {helperText && !error &&{helperText}
} +{error}
} + {helperText && !error &&{helperText}
} += maxLength ? 'text-red-500' : 'text-gray-400' + )}> + {currentLength}/{maxLength} +
+ )} +${greeting},
+${agentName} 给你的回信已经准备好了!
+ +${greeting},
+Your letter from ${agentName} is ready!
+ +解锁了新成就:${achievementName}
+ ${stampName ? `获得奖励:${stampName}
` : ''} +继续加油!
+ + +` + : ` + + + +You've unlocked a new achievement: ${achievementName}
+ ${stampName ? `Reward: ${stampName}
` : ''} +Keep up the great work!
+ + +`; + + await sendEmail({ + to: user.email, + subject, + html, + }); + + return true; + } catch (error) { + console.error('Failed to send achievement notification:', error); + return false; + } +} + +/** + * 验证邮件配置 + */ +export function validateEmailConfig(): boolean { + return !!APP_URL; +} diff --git a/src/lib/prompts/agent.ts b/src/lib/prompts/agent.ts new file mode 100644 index 0000000..390bb09 --- /dev/null +++ b/src/lib/prompts/agent.ts @@ -0,0 +1,677 @@ +/** + * Agent Prompt Configuration + * + * Generates personalized system prompts for the "future self" AI agent + * based on user's answers to onboarding questions. + */ + +import { format, addYears } from 'date-fns'; +import { zhCN, enUS } from 'date-fns/locale'; + +// ============================================================================ +// Types +// ============================================================================ + +/** + * User's answers to the 4 onboarding questions + */ +export interface OnboardingAnswers { + /** Q1: What kind of person do you want to become in 10 years? */ + future_self: string; + /** Q2: Where do you want to be in 10 years? */ + future_location: string; + /** Q3: What is your biggest worry/anxiety now? */ + current_worry: string; + /** Q4: Who do you care about the most? */ + important_person: string; +} + +/** + * Agent personality configuration + */ +export interface AgentPersonality { + /** Array of personality traits */ + traits: string[]; + /** Overall tone of communication */ + tone: string; + /** Communication style */ + communication_style: string; + /** Expected response length */ + response_length: 'short' | 'medium' | 'long'; + /** Emoji usage frequency */ + emoji_usage: 'none' | 'rare' | 'moderate'; + /** Formality level */ + formality: 'formal' | 'casual' | 'neutral'; +} + +/** + * Language-specific style configuration + */ +export interface LanguageStyle { + greeting: string; + signOff: string; + tone: string; + common_phrases: string[]; +} + +/** + * Complete agent configuration + */ +export interface AgentConfig { + name: string; + background: string; + personality: AgentPersonality; + language_style: LanguageStyle; + system_prompt: string; +} + +// ============================================================================ +// Default Configurations +// ============================================================================ + +/** + * Get the default personality configuration for the future self agent + */ +export function getDefaultPersonality(): AgentPersonality { + return { + traits: ['warm', 'wise', 'patient'], + tone: 'gentle', + communication_style: 'reflective', + response_length: 'medium', + emoji_usage: 'rare', + formality: 'casual' + }; +} + +/** + * Personality type presets based on user倾向 + */ +const personalityPresets: Record