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:
86
desktop/src-tauri/src/browser/error.rs
Normal file
86
desktop/src-tauri/src/browser/error.rs
Normal file
@@ -0,0 +1,86 @@
|
||||
// Browser automation error types
|
||||
|
||||
use serde::Serialize;
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Debug, Error, Serialize)]
|
||||
pub enum BrowserError {
|
||||
#[error("WebDriver connection failed: {0}")]
|
||||
ConnectionFailed(String),
|
||||
|
||||
#[error("Session not found: {0}")]
|
||||
SessionNotFound(String),
|
||||
|
||||
#[error("Element not found: {selector}")]
|
||||
ElementNotFound { selector: String },
|
||||
|
||||
#[error("Navigation failed: {url}")]
|
||||
NavigationFailed { url: String },
|
||||
|
||||
#[error("Timeout waiting for element: {selector}")]
|
||||
Timeout { selector: String },
|
||||
|
||||
#[error("Invalid selector: {selector}")]
|
||||
InvalidSelector { selector: String },
|
||||
|
||||
#[error("JavaScript execution failed: {message}")]
|
||||
ScriptError { message: String },
|
||||
|
||||
#[error("Screenshot failed: {reason}")]
|
||||
ScreenshotFailed { reason: String },
|
||||
|
||||
#[error("Form interaction failed: {field}")]
|
||||
FormError { field: String },
|
||||
|
||||
#[error("WebDriver not available: {reason}")]
|
||||
DriverNotAvailable { reason: String },
|
||||
|
||||
#[error("Session already exists: {id}")]
|
||||
SessionExists { id: String },
|
||||
|
||||
#[error("Operation cancelled by user")]
|
||||
Cancelled,
|
||||
|
||||
#[error("Configuration error: {0}")]
|
||||
ConfigError(String),
|
||||
|
||||
#[error("IO error: {0}")]
|
||||
IoError(String),
|
||||
|
||||
#[error("WebDriver command failed: {0}")]
|
||||
CommandFailed(String),
|
||||
|
||||
#[error("Unknown error: {0}")]
|
||||
Unknown(String),
|
||||
}
|
||||
|
||||
// Manual conversion from fantoccini errors since the enum variants differ between versions
|
||||
impl From<fantoccini::error::NewSessionError> for BrowserError {
|
||||
fn from(e: fantoccini::error::NewSessionError) -> Self {
|
||||
BrowserError::ConnectionFailed(e.to_string())
|
||||
}
|
||||
}
|
||||
|
||||
impl From<fantoccini::error::CmdError> for BrowserError {
|
||||
fn from(e: fantoccini::error::CmdError) -> Self {
|
||||
// Convert to string and wrap in appropriate error type
|
||||
let msg = e.to_string();
|
||||
if msg.contains("not found") || msg.contains("no such element") {
|
||||
BrowserError::ElementNotFound { selector: msg }
|
||||
} else if msg.contains("timeout") || msg.contains("timed out") {
|
||||
BrowserError::Timeout { selector: msg }
|
||||
} else if msg.contains("script") || msg.contains("javascript") {
|
||||
BrowserError::ScriptError { message: msg }
|
||||
} else {
|
||||
BrowserError::CommandFailed(msg)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<std::io::Error> for BrowserError {
|
||||
fn from(e: std::io::Error) -> Self {
|
||||
BrowserError::IoError(e.to_string())
|
||||
}
|
||||
}
|
||||
|
||||
pub type Result<T> = std::result::Result<T, BrowserError>;
|
||||
Reference in New Issue
Block a user