feat(embedding,vision): candle embeddings with offline fallback, on-demand clipboard vision capture, and concurrency audit

This commit is contained in:
Riz Ashraf committed 2026-10-07 06:36:09 +01:00
1 parent 5bd8b1587a
commit e4a0fe72df
47 files changed
+6292 -3503

No files matched your search

+7 -10
View File
@@ -1,6 +1,5 @@
use clap::Parser;
use futures_util::{SinkExt, StreamExt};
use tokio::sync::mpsc;
#[derive(Parser)]
#[command(name = "mcp-memory-stub", author, version = env!("APP_VERSION"), about = "Antigravity MCP Memory Stub / Proxy", long_about = None)]
@@ -35,14 +34,14 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
let rt = tokio::runtime::Runtime::new()?;
rt.block_on(async {
let (msg_tx, msg_rx) = async_channel::bounded::<String>(100);
let (shutdown_tx, mut shutdown_rx) = mpsc::channel::<()>(1);
let (shutdown_tx, mut shutdown_rx) = tokio::sync::watch::channel(false);
tokio::spawn(async move {
let mut stdin = tokio::io::BufReader::new(tokio::io::stdin());
while let Some(msg) = mcp_stdio::read_mcp_message(&mut stdin).await {
let _ = msg_tx.send(msg).await;
}
let _ = shutdown_tx.send(()).await;
let _ = shutdown_tx.send(true);
});
let target_url = if cli.target == "http://localhost:3000" {
@@ -58,7 +57,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut retry_count = 0;
loop {
if shutdown_rx.try_recv().is_ok() {
if *shutdown_rx.borrow() {
tracing::info!("Stub shutdown requested");
break;
}
@@ -76,7 +75,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
};
let connect_result = tokio::select! {
_ = shutdown_rx.recv() => {
_ = shutdown_rx.wait_for(|&is_shutdown| is_shutdown) => {
tracing::info!("Shutdown received during connect");
break;
}
@@ -126,11 +125,9 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
if text.len() > 1000 { "..." } else { "" }
);
use tokio::io::AsyncWriteExt;
let mut payload = Vec::with_capacity(text.len() + 1);
payload.extend_from_slice(text.as_bytes());
payload.push(b'\n');
let mut stdout = tokio::io::stdout();
let _ = stdout.write_all(&payload).await;
let _ = stdout.write_all(text.as_bytes()).await;
let _ = stdout.write_all(b"\n").await;
let _ = stdout.flush().await;
}
}
@@ -138,7 +135,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
});
tokio::select! {
_ = shutdown_rx.recv() => {
_ = shutdown_rx.wait_for(|&is_shutdown| is_shutdown) => {
tracing::info!("Shutdown received while connected");
break;
}