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

@@ -27,6 +27,12 @@ interface Clone {
bootstrapReady?: boolean;
bootstrapFiles?: Array<{ name: string; path: string; exists: boolean }>;
updatedAt?: string;
// 人格相关字段
emoji?: string; // Agent emoji, e.g., "🦞", "🤖", "💻"
personality?: string; // 人格风格: professional, friendly, creative, concise
communicationStyle?: string; // 沟通风格描述
notes?: string; // 用户备注
onboardingCompleted?: boolean; // 是否完成首次引导
}
interface UsageStats {
@@ -93,6 +99,11 @@ interface QuickConfig {
autoSaveContext?: boolean;
fileWatching?: boolean;
privacyOptIn?: boolean;
// 人格相关字段
emoji?: string;
personality?: string;
communicationStyle?: string;
notes?: string;
}
interface WorkspaceInfo {
@@ -746,7 +757,8 @@ export const useGatewayStore = create<GatewayStore>((set, get) => {
loadClones: async () => {
try {
const result = await get().client.listClones();
const clones = result?.clones || result?.agents || [];
// API 可能返回数组,也可能返回 {clones: [...]} 或 {agents: [...]}
const clones = Array.isArray(result) ? result : (result?.clones || result?.agents || []);
set({ clones });
useChatStore.getState().syncAgents(clones);
@@ -1221,7 +1233,7 @@ export const useGatewayStore = create<GatewayStore>((set, get) => {
try {
const result = await get().client.listHandRuns(name, opts);
const runs: HandRun[] = (result?.runs || []).map((r: RawHandRun) => ({
runId: r.runId || r.run_id || r.id,
runId: r.runId || r.run_id || r.id || '',
status: r.status || 'unknown',
startedAt: r.startedAt || r.started_at || r.created_at || new Date().toISOString(),
completedAt: r.completedAt || r.completed_at || r.finished_at,
@@ -1486,15 +1498,15 @@ export const useGatewayStore = create<GatewayStore>((set, get) => {
try {
const result = await get().client.listApprovals(status);
const approvals: Approval[] = (result?.approvals || []).map((a: RawApproval) => ({
id: a.id || a.approval_id,
handName: a.hand_name || a.handName,
runId: a.run_id || a.runId,
id: a.id || a.approval_id || '',
handName: a.hand_name || a.handName || '',
runId: a.run_id || a.runId || '',
status: a.status || 'pending',
requestedAt: a.requested_at || a.requestedAt || new Date().toISOString(),
requestedBy: a.requested_by || a.requestedBy,
reason: a.reason || a.description,
requestedBy: a.requested_by || a.requestedBy || '',
reason: a.reason || a.description || '',
action: a.action || 'execute',
params: a.params,
params: a.params || {},
respondedAt: a.responded_at || a.respondedAt,
respondedBy: a.responded_by || a.respondedBy,
responseReason: a.response_reason || a.responseReason,