refactor(types): comprehensive TypeScript type system improvements

Major type system refactoring and error fixes across the codebase:

**Type System Improvements:**
- Extended OpenFangStreamEvent with 'connected' and 'agents_updated' event types
- Added GatewayPong interface for WebSocket pong responses
- Added index signature to MemorySearchOptions for Record compatibility
- Fixed RawApproval interface with hand_name, run_id properties

**Gateway & Protocol Fixes:**
- Fixed performHandshake nonce handling in gateway-client.ts
- Fixed onAgentStream callback type definitions
- Fixed HandRun runId mapping to handle undefined values
- Fixed Approval mapping with proper default values

**Memory System Fixes:**
- Fixed MemoryEntry creation with required properties (lastAccessedAt, accessCount)
- Replaced getByAgent with getAll method in vector-memory.ts
- Fixed MemorySearchOptions type compatibility

**Component Fixes:**
- Fixed ReflectionLog property names (filePath→file, proposedContent→suggestedContent)
- Fixed SkillMarket suggestSkills async call arguments
- Fixed message-virtualization useRef generic type
- Fixed session-persistence messageCount type conversion

**Code Cleanup:**
- Removed unused imports and variables across multiple files
- Consolidated StoredError interface (removed duplicate)
- Deleted obsolete test files (feedbackStore.test.ts, memory-index.test.ts)

**New Features:**
- Added browser automation module (Tauri backend)
- Added Active Learning Panel component
- Added Agent Onboarding Wizard
- Added Memory Graph visualization
- Added Personality Selector
- Added Skill Market store and components

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
iven
2026-03-17 08:05:07 +08:00
parent adfd7024df
commit f4efc823e2
80 changed files with 9496 additions and 1390 deletions

View File

@@ -0,0 +1,124 @@
/**
* FirstConversationPrompt - Welcome prompt for new Agents
*
* Displays a personalized welcome message and quick start suggestions
* when entering a new Agent's chat for the first time.
*/
import { motion } from 'framer-motion';
import { Lightbulb, ArrowRight } from 'lucide-react';
import { cn } from '../lib/utils';
import {
generateWelcomeMessage,
getQuickStartSuggestions,
getScenarioById,
type QuickStartSuggestion,
} from '../lib/personality-presets';
import type { Clone } from '../store/agentStore';
interface FirstConversationPromptProps {
clone: Clone;
onSelectSuggestion?: (text: string) => void;
onDismiss?: () => void;
}
export function FirstConversationPrompt({
clone,
onSelectSuggestion,
}: FirstConversationPromptProps) {
// Generate welcome message
const welcomeMessage = generateWelcomeMessage({
userName: clone.userName,
agentName: clone.nickname || clone.name,
emoji: clone.emoji,
personality: clone.personality,
scenarios: clone.scenarios,
});
// Get quick start suggestions based on scenarios
const suggestions = getQuickStartSuggestions(clone.scenarios || []);
const handleSuggestionClick = (suggestion: QuickStartSuggestion) => {
onSelectSuggestion?.(suggestion.text);
};
return (
<motion.div
initial={{ opacity: 0, y: 20 }}
animate={{ opacity: 1, y: 0 }}
exit={{ opacity: 0, y: -10 }}
className="flex flex-col items-center justify-center py-12 px-4"
>
{/* Avatar with emoji */}
<div className="mb-6">
<div className="w-20 h-20 rounded-2xl bg-gradient-to-br from-primary/20 to-primary/10 dark:from-primary/30 dark:to-primary/20 flex items-center justify-center shadow-lg">
<span className="text-4xl">{clone.emoji || '🦞'}</span>
</div>
</div>
{/* Welcome message */}
<div className="text-center max-w-md mb-8">
<p className="text-lg text-gray-700 dark:text-gray-200 whitespace-pre-line leading-relaxed">
{welcomeMessage}
</p>
</div>
{/* Quick start suggestions */}
<div className="w-full max-w-lg space-y-2">
<div className="flex items-center gap-2 text-sm text-gray-500 dark:text-gray-400 mb-3">
<Lightbulb className="w-4 h-4" />
<span></span>
</div>
{suggestions.map((suggestion, index) => (
<motion.button
key={index}
initial={{ opacity: 0, x: -20 }}
animate={{ opacity: 1, x: 0 }}
transition={{ delay: index * 0.1 }}
onClick={() => handleSuggestionClick(suggestion)}
className={cn(
'w-full flex items-center gap-3 px-4 py-3 rounded-xl',
'bg-gray-50 dark:bg-gray-800/50 border border-gray-200 dark:border-gray-700',
'hover:bg-gray-100 dark:hover:bg-gray-800 hover:border-primary/30',
'transition-all duration-200 group text-left'
)}
>
<span className="text-xl flex-shrink-0">{suggestion.icon}</span>
<span className="flex-1 text-sm text-gray-700 dark:text-gray-200">
{suggestion.text}
</span>
<ArrowRight className="w-4 h-4 text-gray-400 group-hover:text-primary transition-colors flex-shrink-0" />
</motion.button>
))}
</div>
{/* Scenario tags */}
{clone.scenarios && clone.scenarios.length > 0 && (
<div className="mt-8 flex flex-wrap gap-2 justify-center">
{clone.scenarios.map((scenarioId) => {
const scenario = getScenarioById(scenarioId);
if (!scenario) return null;
return (
<span
key={scenarioId}
className={cn(
'px-3 py-1 rounded-full text-xs font-medium',
'bg-primary/10 text-primary dark:bg-primary/20 dark:text-primary'
)}
>
{scenario.label}
</span>
);
})}
</div>
)}
{/* Dismiss hint */}
<p className="mt-8 text-xs text-gray-400 dark:text-gray-500">
</p>
</motion.div>
);
}
export default FirstConversationPrompt;