Self-evolving Context Database for AI Agents. Unify Agent Memory, Knowledge RAG and Skills.
Python agent-contextagent-memoryagent-pluginsagentic-ragcontext-databasedsh-pluginknowledge-basememorymemory-managementself-evolvingvector-database
fix(client): 修复单文件在远程server部署时上传失败问题 (#331) (#352)
Qin Haojie885783ea0785
diff --git a/crates/ov_cli/src/client.rs b/crates/ov_cli/src/client.rsindex 8b7cf492c..be9c68709 100644--- a/crates/ov_cli/src/client.rs+++ b/crates/ov_cli/src/client.rs@@ -433,30 +433,63 @@ impl HttpClient {directly_upload_media: bool,) -> Result<serde_json::Value> {let path_obj = Path::new(path);-- // Check if it's a local directory and not a local server- if path_obj.exists() && path_obj.is_dir() && !self.is_local_server() {- // Zip the directory- let zip_file = self.zip_directory(path_obj)?;- let temp_path = self.upload_temp_file(zip_file.path()).await?;-- let body = serde_json::json!({- "temp_path": temp_path,- "target": target,- "reason": reason,- "instruction": instruction,- "wait": wait,- "timeout": timeout,- "strict": strict,- "ignore_dirs": ignore_dirs,- "include": include,- "exclude": exclude,- "directly_upload_media": directly_upload_media,- });-- self.post("/api/v1/resources", &body).await++ if path_obj.exists() && !self.is_local_server() {+ if path_obj.is_dir() {+ let zip_file = self.zip_directory(path_obj)?;+ let temp_path = self.upload_temp_file(zip_file.path()).await?;++ let body = serde_json::json!({+ "temp_path": temp_path,+ "target": target,+ "reason": reason,+ "instruction": instruction,+ "wait": wait,+ "timeout": timeout,+ "strict": strict,+ "ignore_dirs": ignore_dirs,+ "include": include,+ "exclude": exclude,+ "directly_upload_media": directly_upload_media,+ });++ self.post("/api/v1/resources", &body).await+ } else if path_obj.is_file() {+ let temp_path = self.upload_temp_file(path_obj).await?;++ let body = serde_json::json!({+ "temp_path": temp_path,+ "target": target,+ "reason": reason,+ "instruction": instruction,+ "wait": wait,+ "timeout": timeout,+ "strict": strict,+ "ignore_dirs": ignore_dirs,+ "include": include,+ "exclude": exclude,+ "directly_upload_media": directly_upload_media,+ });++ self.post("/api/v1/resources", &body).await+ } else {+ let body = serde_json::json!({+ "path": path,+ "target": target,+ "reason": reason,+ "instruction": instruction,+ "wait": wait,+ "timeout": timeout,+ "strict": strict,+ "ignore_dirs": ignore_dirs,+ "include": include,+ "exclude": exclude,+ "directly_upload_media": directly_upload_media,+ });++ self.post("/api/v1/resources", &body).await+ }} else {- // Regular case - use path directlylet body = serde_json::json!({"path": path,"target": target,@@ -470,7 +503,7 @@ impl HttpClient {"exclude": exclude,"directly_upload_media": directly_upload_media,});-+self.post("/api/v1/resources", &body).await}}@@ -483,16 +516,34 @@ impl HttpClient {) -> Result<serde_json::Value> {let path_obj = Path::new(data);- if path_obj.exists() && path_obj.is_dir() && !self.is_local_server() {- let zip_file = self.zip_directory(path_obj)?;- let temp_path = self.upload_temp_file(zip_file.path()).await?;-- let body = serde_json::json!({- "temp_path": temp_path,- "wait": wait,- "timeout": timeout,- });- self.post("/api/v1/skills", &body).await+ if path_obj.exists() && !self.is_local_server() {+ if path_obj.is_dir() {+ let zip_file = self.zip_directory(path_obj)?;+ let temp_path = self.upload_temp_file(zip_file.path()).await?;++ let body = serde_json::json!({+ "temp_path": temp_path,+ "wait": wait,+ "timeout": timeout,+ });+ self.post("/api/v1/skills", &body).await+ } else if path_obj.is_file() {+ let temp_path = self.upload_temp_file(path_obj).await?;++ let body = serde_json::json!({+ "temp_path": temp_path,+ "wait": wait,+ "timeout": timeout,+ });+ self.post("/api/v1/skills", &body).await+ } else {+ let body = serde_json::json!({+ "data": data,+ "wait": wait,+ "timeout": timeout,+ });+ self.post("/api/v1/skills", &body).await+ }} else {let body = serde_json::json!({"data": data,diff --git a/crates/ov_cli/src/config.rs b/crates/ov_cli/src/config.rsindex 299b31ebc..57a817895 100644--- a/crates/ov_cli/src/config.rs+++ b/crates/ov_cli/src/config.rs@@ -3,6 +3,8 @@ use std::path::PathBuf;use crate::error::{Error, Result};+const OPENVIKING_CLI_CONFIG_ENV: &str = "OPENVIKING_CLI_CONFIG_FILE";+#[derive(Debug, Clone, Serialize, Deserialize)]pub struct Config {#[serde(default = "default_url")]@@ -53,6 +55,14 @@ impl Config {}pub fn load_default() -> Result<Self> {+ // Resolution order: env var > default path+ if let Ok(env_path) = std::env::var(OPENVIKING_CLI_CONFIG_ENV) {+ let p = PathBuf::from(env_path);+ if p.exists() {+ return Self::from_file(&p.to_string_lossy());+ }+ }+let config_path = default_config_path()?;if config_path.exists() {Self::from_file(&config_path.to_string_lossy())diff --git a/crates/ov_cli/src/main.rs b/crates/ov_cli/src/main.rsindex 1f6b59a45..affb78bfa 100644--- a/crates/ov_cli/src/main.rs+++ b/crates/ov_cli/src/main.rs@@ -74,9 +74,9 @@ enum Commands {/// Wait until processing is complete#[arg(long)]wait: bool,- /// Wait timeout in seconds+ /// Wait timeout in seconds (only used with --wait)#[arg(long)]- timeout: f64,+ timeout: Option<f64>,/// No strict mode for directory scanning#[arg(long = "no-strict", default_value_t = false)]no_strict: bool,@@ -588,7 +588,7 @@ async fn handle_add_resource(reason: String,instruction: String,wait: bool,- timeout: f64,+ timeout: Option<f64>,no_strict: bool,ignore_dirs: Option<String>,include: Option<String>,@@ -635,7 +635,7 @@ async fn handle_add_resource(reason,instruction,wait,- Some(timeout),+ timeout,strict,ignore_dirs,include,diff --git a/openviking_cli/client/http.py b/openviking_cli/client/http.pyindex 20c7c2e96..e63a3a407 100644--- a/openviking_cli/client/http.py+++ b/openviking_cli/client/http.py@@ -304,13 +304,19 @@ class AsyncHTTPClient(BaseClient):}path_obj = Path(path)- if path_obj.exists() and path_obj.is_dir() and not self._is_local_server():- zip_path = self._zip_directory(path)- try:- temp_path = await self._upload_temp_file(zip_path)+ if path_obj.exists() and not self._is_local_server():+ if path_obj.is_dir():+ zip_path = self._zip_directory(path)+ try:+ temp_path = await self._upload_temp_file(zip_path)+ request_data["temp_path"] = temp_path+ finally:+ Path(zip_path).unlink(missing_ok=True)+ elif path_obj.is_file():+ temp_path = await self._upload_temp_file(path)request_data["temp_path"] = temp_path- finally:- Path(zip_path).unlink(missing_ok=True)+ else:+ request_data["path"] = pathelse:request_data["path"] = path@@ -334,13 +340,19 @@ class AsyncHTTPClient(BaseClient):if isinstance(data, str):path_obj = Path(data)- if path_obj.exists() and path_obj.is_dir() and not self._is_local_server():- zip_path = self._zip_directory(data)- try:- temp_path = await self._upload_temp_file(zip_path)+ if path_obj.exists() and not self._is_local_server():+ if path_obj.is_dir():+ zip_path = self._zip_directory(data)+ try:+ temp_path = await self._upload_temp_file(zip_path)+ request_data["temp_path"] = temp_path+ finally:+ Path(zip_path).unlink(missing_ok=True)+ elif path_obj.is_file():+ temp_path = await self._upload_temp_file(data)request_data["temp_path"] = temp_path- finally:- Path(zip_path).unlink(missing_ok=True)+ else:+ request_data["data"] = dataelse:request_data["data"] = dataelse: