File bug directly (#6413)
Co-authored-by: Douwe Osinga <douwe@squareup.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -7,7 +7,7 @@ use goose::conversation::Conversation;
|
||||
use goose::model::ModelConfig;
|
||||
use goose::permission::permission_confirmation::PrincipalType;
|
||||
use goose::providers::base::{ConfigKey, ModelInfo, ProviderMetadata, ProviderType};
|
||||
use goose::session::{Session, SessionInsights, SessionType};
|
||||
use goose::session::{Session, SessionInsights, SessionType, SystemInfo};
|
||||
use rmcp::model::{
|
||||
Annotations, Content, EmbeddedResource, Icon, ImageContent, JsonObject, RawAudioContent,
|
||||
RawEmbeddedResource, RawImageContent, RawResource, RawTextContent, ResourceContents, Role,
|
||||
@@ -327,6 +327,7 @@ derive_utoipa!(Icon as IconSchema);
|
||||
#[openapi(
|
||||
paths(
|
||||
super::routes::status::status,
|
||||
super::routes::status::system_info,
|
||||
super::routes::status::diagnostics,
|
||||
super::routes::mcp_ui_proxy::mcp_ui_proxy,
|
||||
super::routes::config_management::backup_config,
|
||||
@@ -483,6 +484,7 @@ derive_utoipa!(Icon as IconSchema);
|
||||
Session,
|
||||
SessionInsights,
|
||||
SessionType,
|
||||
SystemInfo,
|
||||
Conversation,
|
||||
IconSchema,
|
||||
goose::session::extension_data::ExtensionData,
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
use axum::body::Body;
|
||||
use axum::http::HeaderValue;
|
||||
use axum::response::IntoResponse;
|
||||
use axum::{extract::Path, http::StatusCode, routing::get, Router};
|
||||
use goose::session::generate_diagnostics;
|
||||
use axum::{extract::Path, http::StatusCode, routing::get, Json, Router};
|
||||
use goose::session::{generate_diagnostics, get_system_info, SystemInfo};
|
||||
|
||||
#[utoipa::path(get, path = "/status",
|
||||
responses(
|
||||
@@ -13,6 +13,15 @@ async fn status() -> String {
|
||||
"ok".to_string()
|
||||
}
|
||||
|
||||
#[utoipa::path(get, path = "/system_info",
|
||||
responses(
|
||||
(status = 200, description = "System information", body = SystemInfo),
|
||||
)
|
||||
)]
|
||||
async fn system_info() -> Json<SystemInfo> {
|
||||
Json(get_system_info())
|
||||
}
|
||||
|
||||
#[utoipa::path(get, path = "/diagnostics/{session_id}",
|
||||
responses(
|
||||
(status = 200, description = "Diagnostics zip file", content_type = "application/zip", body = Vec<u8>),
|
||||
@@ -42,5 +51,6 @@ async fn diagnostics(Path(session_id): Path<String>) -> impl IntoResponse {
|
||||
pub fn routes() -> Router {
|
||||
Router::new()
|
||||
.route("/status", get(status))
|
||||
.route("/system_info", get(system_info))
|
||||
.route("/diagnostics/{session_id}", get(diagnostics))
|
||||
}
|
||||
|
||||
@@ -1,30 +1,81 @@
|
||||
use crate::config::base::Config;
|
||||
use crate::config::extensions::get_enabled_extensions;
|
||||
use crate::config::paths::Paths;
|
||||
use crate::providers::utils::LOGS_TO_KEEP;
|
||||
use crate::session::SessionManager;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::fs::{self};
|
||||
use std::io::Cursor;
|
||||
use std::io::Write;
|
||||
use utoipa::ToSchema;
|
||||
use zip::write::FileOptions;
|
||||
use zip::ZipWriter;
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
|
||||
pub struct SystemInfo {
|
||||
pub app_version: String,
|
||||
pub os: String,
|
||||
pub os_version: String,
|
||||
pub architecture: String,
|
||||
pub provider: Option<String>,
|
||||
pub model: Option<String>,
|
||||
pub enabled_extensions: Vec<String>,
|
||||
}
|
||||
|
||||
impl SystemInfo {
|
||||
pub fn collect() -> Self {
|
||||
let config = Config::global();
|
||||
let provider = config.get_goose_provider().ok();
|
||||
let model = config.get_goose_model().ok();
|
||||
let enabled_extensions = get_enabled_extensions()
|
||||
.into_iter()
|
||||
.map(|ext| ext.name().to_string())
|
||||
.collect();
|
||||
|
||||
Self {
|
||||
app_version: env!("CARGO_PKG_VERSION").to_string(),
|
||||
os: std::env::consts::OS.to_string(),
|
||||
os_version: sys_info::os_release().unwrap_or_else(|_| "unknown".to_string()),
|
||||
architecture: std::env::consts::ARCH.to_string(),
|
||||
provider,
|
||||
model,
|
||||
enabled_extensions,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn to_text(&self) -> String {
|
||||
format!(
|
||||
"App Version: {}\n\
|
||||
OS: {}\n\
|
||||
OS Version: {}\n\
|
||||
Architecture: {}\n\
|
||||
Provider: {}\n\
|
||||
Model: {}\n\
|
||||
Enabled Extensions: {}\n\
|
||||
Timestamp: {}\n",
|
||||
self.app_version,
|
||||
self.os,
|
||||
self.os_version,
|
||||
self.architecture,
|
||||
self.provider.as_deref().unwrap_or("unknown"),
|
||||
self.model.as_deref().unwrap_or("unknown"),
|
||||
self.enabled_extensions.join(", "),
|
||||
chrono::Utc::now().to_rfc3339()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_system_info() -> SystemInfo {
|
||||
SystemInfo::collect()
|
||||
}
|
||||
|
||||
pub async fn generate_diagnostics(session_id: &str) -> anyhow::Result<Vec<u8>> {
|
||||
let logs_dir = Paths::in_state_dir("logs");
|
||||
let config_dir = Paths::config_dir();
|
||||
let config_path = config_dir.join("config.yaml");
|
||||
let data_dir = Paths::data_dir();
|
||||
|
||||
let system_info = format!(
|
||||
"App Version: {}\n\
|
||||
OS: {}\n\
|
||||
OS Version: {}\n\
|
||||
Architecture: {}\n\
|
||||
Timestamp: {}\n",
|
||||
env!("CARGO_PKG_VERSION"),
|
||||
std::env::consts::OS,
|
||||
sys_info::os_release().unwrap_or_else(|_| "unknown".to_string()),
|
||||
std::env::consts::ARCH,
|
||||
chrono::Utc::now().to_rfc3339()
|
||||
);
|
||||
let system_info = SystemInfo::collect();
|
||||
|
||||
let mut buffer = Vec::new();
|
||||
{
|
||||
@@ -55,7 +106,7 @@ pub async fn generate_diagnostics(session_id: &str) -> anyhow::Result<Vec<u8>> {
|
||||
}
|
||||
|
||||
zip.start_file("system.txt", options)?;
|
||||
zip.write_all(system_info.as_bytes())?;
|
||||
zip.write_all(system_info.to_text().as_bytes())?;
|
||||
|
||||
let schedule_json = data_dir.join("schedule.json");
|
||||
if schedule_json.exists() {
|
||||
|
||||
@@ -4,6 +4,6 @@ pub mod extension_data;
|
||||
mod legacy;
|
||||
pub mod session_manager;
|
||||
|
||||
pub use diagnostics::generate_diagnostics;
|
||||
pub use diagnostics::{generate_diagnostics, get_system_info, SystemInfo};
|
||||
pub use extension_data::{EnabledExtensionsState, ExtensionData, ExtensionState, TodoState};
|
||||
pub use session_manager::{Session, SessionInsights, SessionManager, SessionType};
|
||||
|
||||
Reference in New Issue
Block a user