use std::collections::BTreeMap;
use std::path::PathBuf;
use crate::contracts::ExecutionPolicy;
pub const REPL_STARTUP_LATENCY_BUDGET_MS: u128 = 50;
pub const REPL_MEMORY_BUDGET_BYTES: usize = 2 * 1024 * 1024;
pub(crate) const META_PREFIX: char = ':';
pub const REPL_HISTORY_ENTRY_MAX_CHARS: usize = 8 * 1024;
pub const REPL_HISTORY_FILE_MAX_BYTES: u64 = 8 * 1024 * 1024;
pub const REPL_HISTORY_MAX_ENTRIES: usize = 50_000;
pub const REPL_COMPLETION_MAX_CANDIDATES: usize = 512;
pub const REPL_COMPLETION_REGISTRY_MAX_ENTRIES: usize = 1024;
pub const REPL_COMPLETION_ENTRY_MAX_CHARS: usize = 256;
pub const REPL_COMPLETION_REGISTRY_MAX_OWNERS: usize = 256;
pub const REPL_PLUGIN_COMPLETION_MAX_NAMESPACES: usize = 256;
pub const REPL_PROFILE_MAX_CHARS: usize = 64;
pub const REPL_PROMPT_MAX_CHARS: usize = 128;
pub const REPL_STARTUP_DIAGNOSTIC_MAX_ENTRIES: usize = 128;
pub const REPL_LAST_ERROR_MAX_CHARS: usize = 2_048;
pub const REPL_MULTILINE_BUFFER_MAX_CHARS: usize = 64 * 1024;
pub const REPL_COMMAND_MAX_CHARS: usize = 64 * 1024;
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct ReplStartupContract {
pub prompt: String,
pub include_profile_context: bool,
pub policy: ExecutionPolicy,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct ReplShutdownContract {
pub session_id: String,
pub commands_executed: usize,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct ReplSession {
pub session_id: String,
pub prompt: String,
pub profile: String,
pub policy: ExecutionPolicy,
pub commands_executed: usize,
pub last_exit_code: i32,
pub trace_mode: bool,
pub history: Vec<String>,
pub history_limit: usize,
pub history_enabled: bool,
pub history_file: Option<PathBuf>,
pub config_path: Option<String>,
pub pending_multiline: Option<String>,
pub last_error: Option<String>,
pub plugin_completion_hooks: BTreeMap<String, Vec<String>>,
pub completion_registries: BTreeMap<String, Vec<String>>,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum ReplStream {
Stdout,
Stderr,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct ReplFrame {
pub stream: ReplStream,
pub content: String,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum ReplInput {
Line(String),
Interrupt,
Eof,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum ReplEvent {
Continue(Option<ReplFrame>),
Exit(Option<ReplFrame>),
Interrupted(ReplFrame),
}
#[derive(Debug, thiserror::Error)]
pub enum ReplError {
#[error(transparent)]
Parser(#[from] crate::routing::parser::ParseError),
#[error(transparent)]
Route(#[from] crate::routing::registry::RouteError),
#[error("kernel execution failed")]
Kernel(crate::kernel::KernelError),
#[error("core execution failed: {0}")]
Core(String),
#[error(transparent)]
Emit(#[from] crate::shared::output::EmitError),
#[error(transparent)]
Json(#[from] serde_json::Error),
#[error(transparent)]
Io(#[from] std::io::Error),
#[error("invalid repl command: {0}")]
InvalidMetaCommand(String),
#[error("invalid command input: {0}")]
InvalidCommandInput(String),
#[error("history index out of bounds: {0}")]
HistoryIndexOutOfBounds(usize),
}