agent-orchestrator/src-tauri/src/commands/pty.rs
Hibryda 8b3b0ab720 feat(error): add Rust AppError enum and migrate command modules
- AppError enum with 10 variants (Database, Auth, Filesystem, Ipc, NotFound,
  Validation, Sidecar, Config, Network, Internal) + serde tag serialization
- From impls for rusqlite::Error, std::io::Error, serde_json::Error
- Migrated 9 command modules from Result<T, String> to Result<T, AppError>
- Frontend receives structured {kind, detail} objects via IPC
2026-03-18 01:22:04 +01:00

34 lines
957 B
Rust

use tauri::State;
use crate::AppState;
use crate::error::AppError;
use crate::pty::PtyOptions;
#[tauri::command]
#[tracing::instrument(skip(state), fields(shell = ?options.shell))]
pub fn pty_spawn(
state: State<'_, AppState>,
options: PtyOptions,
) -> Result<String, AppError> {
state.pty_manager.spawn(options).map_err(AppError::sidecar)
}
#[tauri::command]
pub fn pty_write(state: State<'_, AppState>, id: String, data: String) -> Result<(), AppError> {
state.pty_manager.write(&id, &data).map_err(AppError::sidecar)
}
#[tauri::command]
pub fn pty_resize(
state: State<'_, AppState>,
id: String,
cols: u16,
rows: u16,
) -> Result<(), AppError> {
state.pty_manager.resize(&id, cols, rows).map_err(AppError::sidecar)
}
#[tauri::command]
#[tracing::instrument(skip(state))]
pub fn pty_kill(state: State<'_, AppState>, id: String) -> Result<(), AppError> {
state.pty_manager.kill(&id).map_err(AppError::sidecar)
}