render mcp apps inline in goose2 (#8877)
Signed-off-by: Andrew Harvard <aharvard@squareup.com>
This commit is contained in:
@@ -36,6 +36,17 @@ use std::io::Read;
|
||||
use std::path::PathBuf;
|
||||
use tracing::warn;
|
||||
|
||||
const GOOSE_SERVER_SECRET_KEY_ENV: &str = "GOOSE_SERVER__SECRET_KEY";
|
||||
|
||||
fn generate_serve_secret_key() -> String {
|
||||
use rand::distributions::{Alphanumeric, DistString};
|
||||
|
||||
format!(
|
||||
"goose-acp-{}",
|
||||
Alphanumeric.sample_string(&mut rand::thread_rng(), 32)
|
||||
)
|
||||
}
|
||||
|
||||
#[derive(Parser)]
|
||||
#[command(name = "goose", author, version, display_name = "", about, long_about = None)]
|
||||
pub struct Cli {
|
||||
@@ -1086,13 +1097,22 @@ async fn handle_serve_command(host: String, port: u16, builtins: Vec<String>) ->
|
||||
config_dir: Paths::config_dir(),
|
||||
goose_platform: GoosePlatform::GooseCli,
|
||||
}));
|
||||
let router = create_router(server);
|
||||
let secret_key = std::env::var(GOOSE_SERVER_SECRET_KEY_ENV)
|
||||
.ok()
|
||||
.map(|secret| secret.trim().to_string())
|
||||
.filter(|secret| !secret.is_empty())
|
||||
.unwrap_or_else(generate_serve_secret_key);
|
||||
let router = create_router(server, secret_key);
|
||||
|
||||
let addr: SocketAddr = format!("{}:{}", host, port).parse()?;
|
||||
info!("Starting ACP server on {}", addr);
|
||||
|
||||
let listener = tokio::net::TcpListener::bind(addr).await?;
|
||||
axum::serve(listener, router).await?;
|
||||
axum::serve(
|
||||
listener,
|
||||
router.into_make_service_with_connect_info::<SocketAddr>(),
|
||||
)
|
||||
.await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user