feat: Enhance OAuth module and OpenRouter client functionality

- Updated OAuth module to include unused imports for better clarity.
- Refactored OpenRouterClient to improve chat functionality and added support for tools in chat requests.
- Modified internet tools (Download, Fetch, Search) to use a more flexible internet mode check.
- Introduced new Bash tools for managing background jobs (BashOutput, BashKill).
- Enhanced workflow tool to parse and execute workflow scripts with arguments.
- Updated status and workflow views to reflect new agent and findings counts.
- Added IPC protocol definitions for client requests and state payloads.
This commit is contained in:
asepharyana
2026-07-11 20:21:59 +07:00
parent c1ad206a00
commit 802d9677ae
42 changed files with 1423 additions and 925 deletions
+1
View File
@@ -2,5 +2,6 @@ pub mod client;
pub mod conn;
pub mod diff;
pub mod frame;
pub mod protocol;
pub mod server;
pub mod snapshot;
+71
View File
@@ -0,0 +1,71 @@
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum KeyAction {
Char(char),
Enter,
Escape,
Backspace,
Delete,
Tab,
Up,
Down,
Left,
Right,
Home,
End,
PageUp,
PageDown,
Function(u8),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum ClientRequest {
Tick,
KeyPress {
key: KeyAction,
ctrl: bool,
alt: bool,
shift: bool,
},
Submit(String),
Resize(u16, u16),
Close,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct MessageEntry {
pub role: String,
pub content: String,
pub timestamp: i64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ToastEntry {
pub kind: String,
pub message: String,
pub created_at: i64,
pub lifetime_ms: u64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct StatePayload {
pub mode: String,
pub session_id: String,
pub messages: Vec<MessageEntry>,
pub edit_count: u32,
pub message_count: usize,
pub overlay: Option<String>,
pub toasts: Vec<ToastEntry>,
pub dirty: bool,
pub input_buffer: String,
pub input_cursor: usize,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum DaemonFrame {
StateUpdate(Box<StatePayload>),
StreamToken(String),
SystemNote { kind: String, message: String },
Closed,
}
+59 -17
View File
@@ -1,42 +1,84 @@
use std::net::TcpListener;
use std::os::unix::net::UnixListener;
use std::thread;
use anyhow::Result;
use super::conn::Connection;
enum ListenerKind {
Tcp(TcpListener),
Unix(UnixListener),
}
pub struct IpcServer {
listener: TcpListener,
listener: ListenerKind,
}
impl IpcServer {
pub fn bind(addr: &str) -> Result<Self> {
let listener = TcpListener::bind(addr)?;
Ok(IpcServer { listener })
Ok(IpcServer { listener: ListenerKind::Tcp(listener) })
}
pub fn bind_unix(path: &str) -> Result<Self> {
let _ = std::fs::remove_file(path);
let listener = UnixListener::bind(path)?;
Ok(IpcServer { listener: ListenerKind::Unix(listener) })
}
pub fn accept(&self) -> Result<Connection> {
let (stream, _addr) = self.listener.accept()?;
stream.set_nodelay(true)?;
Ok(Connection::Tcp(stream))
match &self.listener {
ListenerKind::Tcp(l) => {
let (stream, _addr) = l.accept()?;
stream.set_nodelay(true)?;
Ok(Connection::Tcp(stream))
}
ListenerKind::Unix(l) => {
let (stream, _addr) = l.accept()?;
Ok(Connection::Unix(stream))
}
}
}
pub fn accept_with_handler<F>(self, handler: F) -> thread::JoinHandle<()>
where
F: Fn(Connection) -> Result<()> + Send + 'static,
{
thread::spawn(move || {
for stream in self.listener.incoming() {
match stream {
Ok(stream) => {
if let Err(e) = handler(Connection::Tcp(stream)) {
eprintln!("ipc handler error: {}", e);
match self.listener {
ListenerKind::Tcp(l) => {
thread::spawn(move || {
for stream in l.incoming() {
match stream {
Ok(s) => {
let _ = s.set_nodelay(true);
if let Err(e) = handler(Connection::Tcp(s)) {
eprintln!("ipc handler error: {}", e);
}
}
Err(e) => {
eprintln!("ipc accept error: {}", e);
break;
}
}
}
Err(e) => {
eprintln!("ipc accept error: {}", e);
break;
}
}
})
}
})
ListenerKind::Unix(l) => {
thread::spawn(move || {
for stream in l.incoming() {
match stream {
Ok(s) => {
if let Err(e) = handler(Connection::Unix(s)) {
eprintln!("ipc handler error: {}", e);
}
}
Err(e) => {
eprintln!("ipc accept error: {}", e);
break;
}
}
}
})
}
}
}
}