fix local markdown attachment regressions
This commit is contained in:
@@ -4,15 +4,15 @@ use crate::context::RequestContext;
|
||||
use crate::error::WebError;
|
||||
use crate::hermes_tools::manifest;
|
||||
use crate::transport::convex::{execute_retired_mutation_by_name, execute_retired_query_by_name};
|
||||
use axum::Json;
|
||||
use axum::body::Body;
|
||||
use axum::extract::{Extension, Path, Query, State};
|
||||
use axum::http::{HeaderMap, HeaderName, HeaderValue, StatusCode, header};
|
||||
use axum::http::{header, HeaderMap, HeaderName, HeaderValue, StatusCode};
|
||||
use axum::response::Response;
|
||||
use axum::Json;
|
||||
use control_plane::{AppendAiRuntimeEventInput, UpsertAiRuntimeRunInput};
|
||||
use futures_util::TryStreamExt;
|
||||
use serde::Deserialize;
|
||||
use serde_json::{Value, json};
|
||||
use serde_json::{json, Value};
|
||||
use std::collections::{BTreeMap, HashMap, HashSet, VecDeque};
|
||||
use std::env;
|
||||
use std::fs;
|
||||
@@ -1049,7 +1049,7 @@ pub async fn resume_session(
|
||||
) -> Result<(StatusCode, HeaderMap, Json<Value>), WebError> {
|
||||
if is_acp_session_query(&query) {
|
||||
let result = get_acp_session(&state, &context, &session_id, &query).await?;
|
||||
let mut payload = result.2.0;
|
||||
let mut payload = result.2 .0;
|
||||
payload["resumed"] = Value::Bool(true);
|
||||
payload["resumeSource"] = payload
|
||||
.get("persistence")
|
||||
@@ -1573,8 +1573,8 @@ pub async fn create_run(
|
||||
Some(®istration.profile),
|
||||
)
|
||||
.await?;
|
||||
if let Some(runtime) = register_runtime_from_create_run_response(®istration, &result.2.0) {
|
||||
let mut payload = result.2.0;
|
||||
if let Some(runtime) = register_runtime_from_create_run_response(®istration, &result.2 .0) {
|
||||
let mut payload = result.2 .0;
|
||||
payload["runtime"] = runtime;
|
||||
Ok((result.0, result.1, Json(payload)))
|
||||
} else {
|
||||
@@ -2230,7 +2230,11 @@ fn profile_home(profile: &str) -> PathBuf {
|
||||
return home;
|
||||
}
|
||||
let candidate = home.join("profiles").join(profile);
|
||||
if candidate.exists() { candidate } else { home }
|
||||
if candidate.exists() {
|
||||
candidate
|
||||
} else {
|
||||
home
|
||||
}
|
||||
}
|
||||
|
||||
fn profile_config_path(profile: &str) -> PathBuf {
|
||||
@@ -6325,8 +6329,8 @@ fn stamp_client_headers_into(headers: &mut HeaderMap) {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::app::{AppConfig, AppState, build_app};
|
||||
use axum::body::{Body, to_bytes};
|
||||
use crate::app::{build_app, AppConfig, AppState};
|
||||
use axum::body::{to_bytes, Body};
|
||||
use axum::http::Request;
|
||||
use axum::routing::{get, post};
|
||||
use control_plane::{DirectoryGrantInput, UpsertAiRuntimeRunInput, UpsertUserInput};
|
||||
@@ -6379,16 +6383,12 @@ mod tests {
|
||||
let files = changed.as_array().expect("changed files");
|
||||
|
||||
assert_eq!(files.len(), 2);
|
||||
assert!(
|
||||
files
|
||||
.iter()
|
||||
.any(|file| { file["path"] == "a.md" && file["changeType"] == "modified" })
|
||||
);
|
||||
assert!(
|
||||
files
|
||||
.iter()
|
||||
.any(|file| { file["path"] == "b.md" && file["changeType"] == "added" })
|
||||
);
|
||||
assert!(files
|
||||
.iter()
|
||||
.any(|file| { file["path"] == "a.md" && file["changeType"] == "modified" }));
|
||||
assert!(files
|
||||
.iter()
|
||||
.any(|file| { file["path"] == "b.md" && file["changeType"] == "added" }));
|
||||
assert!(!files.iter().any(|file| {
|
||||
file["path"]
|
||||
.as_str()
|
||||
@@ -6424,11 +6424,9 @@ mod tests {
|
||||
assert!(files.iter().any(|file| {
|
||||
file["path"] == "maps/a.mindmap.json" && file["changeType"] == "modified"
|
||||
}));
|
||||
assert!(
|
||||
files.iter().any(|file| {
|
||||
file["path"] == "office/a.docx" && file["changeType"] == "modified"
|
||||
})
|
||||
);
|
||||
assert!(files
|
||||
.iter()
|
||||
.any(|file| { file["path"] == "office/a.docx" && file["changeType"] == "modified" }));
|
||||
|
||||
let _ = std::fs::remove_dir_all(&root);
|
||||
}
|
||||
@@ -8469,10 +8467,8 @@ mod tests {
|
||||
let instructions = body["instructions"].as_str().expect("instructions");
|
||||
assert!(instructions.contains("\"sourceKind\":\"local_folder\""));
|
||||
assert!(instructions.contains("\"fileReference\""));
|
||||
assert!(
|
||||
instructions
|
||||
.contains("\"rootUri\":\"file:///mnt/Data1T/Mnote_data/users/user_1/我的空间\"")
|
||||
);
|
||||
assert!(instructions
|
||||
.contains("\"rootUri\":\"file:///mnt/Data1T/Mnote_data/users/user_1/我的空间\""));
|
||||
assert!(instructions.contains("\"aiAccessScope\""));
|
||||
assert!(instructions.contains("\"allowedRoots\""));
|
||||
assert!(instructions.contains("\"editorTarget\""));
|
||||
@@ -8493,10 +8489,8 @@ mod tests {
|
||||
assert!(
|
||||
!instructions.contains("恶意 runTargetSnapshot.editorTarget 正文不应进入 instructions")
|
||||
);
|
||||
assert!(
|
||||
!instructions
|
||||
.contains("恶意 runTargetSnapshot.workspacePath 正文不应进入 instructions")
|
||||
);
|
||||
assert!(!instructions
|
||||
.contains("恶意 runTargetSnapshot.workspacePath 正文不应进入 instructions"));
|
||||
assert!(!instructions.contains("\"contextBlocks\""));
|
||||
assert!(!instructions.contains("\"pageXml\""));
|
||||
assert!(!instructions.contains("\"pageText\""));
|
||||
@@ -8595,11 +8589,10 @@ mod tests {
|
||||
env.get("MNOTE_AI_WORKSPACE_ROOT").map(String::as_str),
|
||||
Some("/mnt/Data1T/Mnote_data/users/user_1/我的空间")
|
||||
);
|
||||
assert!(
|
||||
!env.get("MNOTE_AI_ALLOWED_ROOTS_JSON")
|
||||
.unwrap()
|
||||
.contains("/mnt/Data1T/Mnote_data/users/user_2")
|
||||
);
|
||||
assert!(!env
|
||||
.get("MNOTE_AI_ALLOWED_ROOTS_JSON")
|
||||
.unwrap()
|
||||
.contains("/mnt/Data1T/Mnote_data/users/user_2"));
|
||||
let scope = serde_json::from_str::<serde_json::Value>(
|
||||
env.get("MNOTE_AI_ACCESS_SCOPE_JSON").expect("scope"),
|
||||
)
|
||||
@@ -8669,12 +8662,10 @@ mod tests {
|
||||
payload["allowedRoots"][0]["source"],
|
||||
"sqlite_directory_grant"
|
||||
);
|
||||
assert!(
|
||||
payload["allowedRoots"][0]["grantIds"]
|
||||
.as_array()
|
||||
.map(|items| !items.is_empty())
|
||||
.unwrap_or(false)
|
||||
);
|
||||
assert!(payload["allowedRoots"][0]["grantIds"]
|
||||
.as_array()
|
||||
.map(|items| !items.is_empty())
|
||||
.unwrap_or(false));
|
||||
assert!(!payload.to_string().contains("file:///tmp/evil"));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user