Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
use crate::backend::TerminalBackend;
use crate::renderer::{FramePacer, Renderer};
use crate::CrosstermBackend;
use crossterm::event::{poll, read};
use cortex_tui_buffer::Buffer;
use cortex_tui_core::Result;
use cortex_tui_input::Event;
use crossterm::event::{poll, read};
use std::time::{Duration, Instant};

/// Application state for the event loop.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! Terminal backend abstraction and crossterm implementation.

use crate::Capabilities;
use cortex_tui_core::{Color, Error, Result, TextAttributes};
use crossterm::{
cursor::{Hide, MoveTo, Show},
event::{
Expand All @@ -17,7 +18,6 @@ use crossterm::{
LeaveAlternateScreen,
},
};
use cortex_tui_core::{Color, Error, Result, TextAttributes};
use std::io::{self, Stdout, Write};

/// Trait for terminal backend implementations.
Expand Down
4 changes: 3 additions & 1 deletion cortex-tui-framework/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ pub use cortex_tui_widgets as widgets;
pub mod prelude {
pub use cortex_tui_core::{Color, Point, Rect, Size, Style, TextAttributes};
pub use cortex_tui_input::{Event, KeyCode, KeyModifiers, MouseButton, MouseEvent};
pub use cortex_tui_layout::{AlignContent, AlignItems, FlexDirection, FlexWrap, JustifyContent};
pub use cortex_tui_layout::{
AlignContent, AlignItems, FlexDirection, FlexWrap, JustifyContent,
};
pub use cortex_tui_terminal::Application;
pub use cortex_tui_widgets::{BoxWidget, Input, ScrollBox, TextWidget, Widget};
}
9 changes: 5 additions & 4 deletions src/cortex-app-server/src/api/agents.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

use std::sync::Arc;

use axum::{Json, extract::{Path, State}};
use axum::{
Json,
extract::{Path, State},
};

use crate::error::{AppError, AppResult};
use crate::state::AppState;
Expand Down Expand Up @@ -344,9 +347,7 @@ fn parse_agent_content(content: &str, _format: &str) -> AppResult<(String, Agent
}

/// Import an agent from file content.
pub async fn import_agent(
Json(req): Json<ImportAgentRequest>,
) -> AppResult<Json<AgentDefinition>> {
pub async fn import_agent(Json(req): Json<ImportAgentRequest>) -> AppResult<Json<AgentDefinition>> {
// Parse the content to extract name and other metadata
let (name, agent) = parse_agent_content(&req.content, &req.format)?;

Expand Down
5 changes: 4 additions & 1 deletion src/cortex-app-server/src/api/discovery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
use std::sync::Arc;
use std::time::{Duration, Instant};

use axum::{Json, extract::{Query, State}};
use axum::{
Json,
extract::{Query, State},
};

use crate::error::AppResult;
use crate::mdns::MdnsDiscovery;
Expand Down
5 changes: 4 additions & 1 deletion src/cortex-app-server/src/api/files.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

use std::sync::Arc;

use axum::{Json, extract::{Query, State}};
use axum::{
Json,
extract::{Query, State},
};

use crate::error::{AppError, AppResult};
use crate::state::AppState;
Expand Down
5 changes: 4 additions & 1 deletion src/cortex-app-server/src/api/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,10 @@ pub fn routes() -> Router<Arc<AppState>> {
.route("/agents", post(agents::create_agent))
.route("/agents/builtin", get(agents::list_builtin_agents))
.route("/agents/import", post(agents::import_agent))
.route("/agents/generate-prompt", post(agents::generate_agent_prompt))
.route(
"/agents/generate-prompt",
post(agents::generate_agent_prompt),
)
.route("/agents/:name", get(agents::get_agent))
.route("/agents/:name", axum::routing::put(agents::update_agent))
.route("/agents/:name", delete(agents::delete_agent))
Expand Down
5 changes: 4 additions & 1 deletion src/cortex-app-server/src/api/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

use std::sync::Arc;

use axum::{Json, extract::{Path, State}};
use axum::{
Json,
extract::{Path, State},
};

use crate::error::{AppError, AppResult};
use crate::state::AppState;
Expand Down
5 changes: 4 additions & 1 deletion src/cortex-app-server/src/api/stored_sessions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

use std::sync::Arc;

use axum::{Json, extract::{Path, State}};
use axum::{
Json,
extract::{Path, State},
};

use crate::error::{AppError, AppResult};
use crate::state::AppState;
Expand Down
5 changes: 4 additions & 1 deletion src/cortex-app-server/src/api/terminals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@

use std::sync::Arc;

use axum::{Json, extract::{Path, Query, State}};
use axum::{
Json,
extract::{Path, Query, State},
};

use crate::error::{AppError, AppResult};
use crate::state::AppState;
Expand Down
5 changes: 4 additions & 1 deletion src/cortex-app-server/src/api/tools.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

use std::sync::Arc;

use axum::{Json, extract::{Path, State}};
use axum::{
Json,
extract::{Path, State},
};

use crate::error::AppResult;
use crate::state::AppState;
Expand Down
4 changes: 2 additions & 2 deletions src/cortex-app-server/src/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ pub struct AuthService {
/// Decoding key for JWT.
decoding_key: Option<DecodingKey>,
/// API key hash cache.
api_key_hashes: RwLock<HashMap<String, String>>,
_api_key_hashes: RwLock<HashMap<String, String>>,
/// Revoked tokens.
revoked_tokens: RwLock<HashMap<String, u64>>,
}
Expand Down Expand Up @@ -134,7 +134,7 @@ impl AuthService {
config,
encoding_key,
decoding_key,
api_key_hashes: RwLock::new(HashMap::new()),
_api_key_hashes: RwLock::new(HashMap::new()),
revoked_tokens: RwLock::new(HashMap::new()),
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/cortex-app-server/src/session_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,7 @@ pub enum SessionError {
}

/// Forward events from CLI session to WebSocket.
async fn forward_events(
async fn _forward_events(
event_rx: async_channel::Receiver<Event>,
ws_tx: mpsc::Sender<WsMessage>,
session_id: String,
Expand Down
5 changes: 2 additions & 3 deletions src/cortex-app-server/src/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
//! the same storage directory.

use std::fs;
use std::io::{BufRead, BufReader, BufWriter, Write};
use std::io::{BufRead, BufReader, BufWriter};
use std::path::{Path, PathBuf};

use fs2::FileExt;
Expand Down Expand Up @@ -93,8 +93,7 @@ impl SessionStorage {
file.lock_exclusive()?;

let writer = BufWriter::new(&file);
let result =
serde_json::to_writer_pretty(writer, session).map_err(std::io::Error::other);
let result = serde_json::to_writer_pretty(writer, session).map_err(std::io::Error::other);

// Lock is automatically released when file is dropped
file.unlock()?;
Expand Down
4 changes: 2 additions & 2 deletions src/cortex-app-server/src/websocket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ async fn handle_socket(socket: WebSocket, state: Arc<AppState>, query: WsConnect

// Create connection context
let mut ctx = ConnectionContext {
id: connection_id.clone(),
_id: connection_id.clone(),
user_id: None,
session_id: query.session_id,
authenticated: query.token.is_some(),
Expand Down Expand Up @@ -448,7 +448,7 @@ async fn handle_text_message(
#[derive(Debug)]
struct ConnectionContext {
/// Connection ID.
id: String,
_id: String,
/// User ID if authenticated.
user_id: Option<String>,
/// Session ID if joined.
Expand Down
2 changes: 1 addition & 1 deletion src/cortex-cli/src/agent_cmd/handlers/copy.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Handler for the `agent copy` command.

use anyhow::{bail, Context, Result};
use anyhow::{Context, Result, bail};

use crate::agent_cmd::cli::CopyArgs;
use crate::agent_cmd::loader::{
Expand Down
4 changes: 2 additions & 2 deletions src/cortex-cli/src/agent_cmd/handlers/create.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
//! Handler for the `agent create` command.

use anyhow::{bail, Context, Result};
use anyhow::{Context, Result, bail};
use std::io::{self, BufRead, Write};

use crate::agent_cmd::cli::CreateArgs;
use crate::agent_cmd::loader::get_agents_dir;
use crate::agent_cmd::types::AgentMode;
use crate::agent_cmd::utils::{validate_model_name, AVAILABLE_TOOLS, RESERVED_NAMES};
use crate::agent_cmd::utils::{AVAILABLE_TOOLS, RESERVED_NAMES, validate_model_name};

use super::generate::run_generate;

Expand Down
2 changes: 1 addition & 1 deletion src/cortex-cli/src/agent_cmd/handlers/edit.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Handler for the `agent edit` command.

use anyhow::{bail, Context, Result};
use anyhow::{Context, Result, bail};
use std::io::{self, BufRead, Write};

use crate::agent_cmd::cli::EditArgs;
Expand Down
2 changes: 1 addition & 1 deletion src/cortex-cli/src/agent_cmd/handlers/generate.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Handler for AI-powered agent generation.

use anyhow::{bail, Context, Result};
use anyhow::{Context, Result, bail};
use std::io::{self, BufRead, Write};

use crate::agent_cmd::cli::CreateArgs;
Expand Down
2 changes: 1 addition & 1 deletion src/cortex-cli/src/agent_cmd/handlers/install.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Handler for the `agent install` command.

use anyhow::{bail, Context, Result};
use anyhow::{Context, Result, bail};

use crate::agent_cmd::cli::InstallArgs;
use crate::agent_cmd::loader::get_agents_dir;
Expand Down
2 changes: 1 addition & 1 deletion src/cortex-cli/src/agent_cmd/handlers/remove.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Handler for the `agent remove` command.

use anyhow::{bail, Context, Result};
use anyhow::{Context, Result, bail};
use std::io::{self, BufRead, Write};

use crate::agent_cmd::cli::RemoveArgs;
Expand Down
2 changes: 1 addition & 1 deletion src/cortex-cli/src/agent_cmd/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//!
//! Contains helper functions used across the agent command module.

use anyhow::{bail, Result};
use anyhow::{Result, bail};

/// Validate a model name for agent creation.
///
Expand Down
18 changes: 7 additions & 11 deletions src/cortex-cli/src/cli/handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,41 +183,38 @@ async fn run_init(init_cli: InitCommand) -> Result<()> {
/// Handle login command.
async fn handle_login(login_cli: LoginCommand) -> Result<()> {
match login_cli.action {
Some(LoginSubcommand::Status) => {
run_login_status(login_cli.config_overrides).await;
}
Some(LoginSubcommand::Status) => run_login_status(login_cli.config_overrides).await,
None => {
if let Some(token) = login_cli.token {
run_login_with_api_key(login_cli.config_overrides, token).await;
run_login_with_api_key(login_cli.config_overrides, token).await
} else if login_cli.use_sso {
eprintln!("Starting enterprise SSO authentication...");
run_login_with_device_code(
login_cli.config_overrides,
login_cli.issuer_base_url,
login_cli.client_id,
)
.await;
.await
} else if login_cli.use_device_code {
run_login_with_device_code(
login_cli.config_overrides,
login_cli.issuer_base_url,
login_cli.client_id,
)
.await;
.await
} else if login_cli.with_api_key {
let api_key = read_api_key_from_stdin();
run_login_with_api_key(login_cli.config_overrides, api_key).await;
run_login_with_api_key(login_cli.config_overrides, api_key).await
} else {
run_login_with_device_code(
login_cli.config_overrides,
login_cli.issuer_base_url,
login_cli.client_id,
)
.await;
.await
}
}
}
Ok(())
}

/// Handle logout command.
Expand All @@ -226,8 +223,7 @@ async fn handle_logout(logout_cli: LogoutCommand) -> Result<()> {
if logout_cli.all {
eprintln!("Logging out from all accounts...");
}
run_logout(logout_cli.config_overrides, skip_confirmation).await;
Ok(())
run_logout(logout_cli.config_overrides, skip_confirmation).await
}

/// Handle completion command.
Expand Down
2 changes: 1 addition & 1 deletion src/cortex-cli/src/dag_cmd/commands.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Command handlers for DAG operations.

use anyhow::{Context, Result, bail};
use anyhow::{Result, bail};
use cortex_agents::task::{DagHydrator, DagStore, TaskStatus};
use std::collections::HashMap;
use std::io::{self, Write};
Expand Down
5 changes: 3 additions & 2 deletions src/cortex-cli/src/dag_cmd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ use anyhow::Result;

// Re-export public types
pub use args::{
DagCli, DagCommands, DagCreateArgs, DagDeleteArgs, DagGraphArgs, DagListArgs, DagResumeArgs,
DagRunArgs, DagStatusArgs, DagValidateArgs, DEFAULT_MAX_CONCURRENT, DEFAULT_TASK_TIMEOUT_SECS,
DEFAULT_MAX_CONCURRENT, DEFAULT_TASK_TIMEOUT_SECS, DagCli, DagCommands, DagCreateArgs,
DagDeleteArgs, DagGraphArgs, DagListArgs, DagResumeArgs, DagRunArgs, DagStatusArgs,
DagValidateArgs,
};
pub use types::{
DagExecutionStats, DagOutputFormat, DagSpecInput, ExecutionStrategy, FailureMode,
Expand Down
2 changes: 1 addition & 1 deletion src/cortex-cli/src/dag_cmd/scheduler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::sync::Arc;
use std::time::{Duration, Instant};
use tokio::sync::{Mutex, RwLock, Semaphore};

use crate::styled_output::{print_error, print_success, print_info};
use crate::styled_output::{print_error, print_info, print_success};

use super::executor::TaskExecutor;
use super::types::{DagExecutionStats, FailureMode, TaskExecutionResult};
Expand Down
4 changes: 2 additions & 2 deletions src/cortex-cli/src/dag_cmd/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ fn test_dag_creation_with_cycle_detection() {
#[tokio::test]
async fn test_task_executor() {
let executor = TaskExecutor::new(30, false);
let task = Task::new("test", "Test task")
.with_metadata("command", serde_json::json!("echo hello"));
let task =
Task::new("test", "Test task").with_metadata("command", serde_json::json!("echo hello"));

// Note: This test requires a running shell
let mut task_with_id = task;
Expand Down
1 change: 0 additions & 1 deletion src/cortex-cli/src/debug_cmd/handlers/file.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//! File command handler.

use anyhow::Result;
use std::path::PathBuf;

use crate::debug_cmd::commands::FileArgs;
use crate::debug_cmd::types::{FileDebugOutput, FileMetadata};
Expand Down
2 changes: 1 addition & 1 deletion src/cortex-cli/src/debug_cmd/handlers/ripgrep.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Ripgrep command handler.

use anyhow::{bail, Result};
use anyhow::{Result, bail};
use std::path::PathBuf;

use crate::debug_cmd::commands::RipgrepArgs;
Expand Down
2 changes: 1 addition & 1 deletion src/cortex-cli/src/debug_cmd/handlers/snapshot.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Snapshot command handler.

use anyhow::{bail, Context, Result};
use anyhow::{Context, Result, bail};

use cortex_engine::list_sessions;
use cortex_engine::rollout::get_rollout_path;
Expand Down
Loading
Loading