diff --git a/crates/zclaw-runtime/src/loop_runner.rs b/crates/zclaw-runtime/src/loop_runner.rs index 9877774..f8f9afa 100644 --- a/crates/zclaw-runtime/src/loop_runner.rs +++ b/crates/zclaw-runtime/src/loop_runner.rs @@ -744,7 +744,7 @@ impl AgentLoop { } Ok(Some(Err(e))) => { tracing::error!("[AgentLoop] Chunk error: {}", e); - let _ = tx.send(LoopEvent::Error(format!("LLM 锥应错误: {}", e.to_string()))).await; + let _ = tx.send(LoopEvent::Error(format!("LLM 响应错误: {}", e.to_string()))).await; stream_errored = true; } Ok(None) => break, // Stream ended normally diff --git a/crates/zclaw-runtime/src/tool/builtin/file_read.rs b/crates/zclaw-runtime/src/tool/builtin/file_read.rs index c0a5b84..25fa015 100644 --- a/crates/zclaw-runtime/src/tool/builtin/file_read.rs +++ b/crates/zclaw-runtime/src/tool/builtin/file_read.rs @@ -140,6 +140,7 @@ mod tests { session_id: None, skill_executor: None, path_validator, + event_sender: None, }; let tool = FileReadTool::new(); diff --git a/crates/zclaw-runtime/src/tool/builtin/file_write.rs b/crates/zclaw-runtime/src/tool/builtin/file_write.rs index 684e068..0f1803c 100644 --- a/crates/zclaw-runtime/src/tool/builtin/file_write.rs +++ b/crates/zclaw-runtime/src/tool/builtin/file_write.rs @@ -119,11 +119,24 @@ impl Tool for FileWriteTool { file.write_all(&bytes) .map_err(|e| ZclawError::ToolError(format!("Failed to write file: {}", e)))?; + // Echo content preview in output for artifact auto-creation in frontend + let content_preview: String = if content.len() <= 5000 { + content.to_string() + } else { + let truncation_point = content.char_indices() + .take_while(|(i, _)| *i < 5000) + .last() + .map(|(i, c)| i + c.len_utf8()) + .unwrap_or(5000.min(content.len())); + format!("{}...[truncated, {} total bytes]", &content[..truncation_point], content.len()) + }; + Ok(json!({ "success": true, "bytes_written": bytes.len(), "path": validated_path.to_string_lossy(), - "mode": mode + "mode": mode, + "content": content_preview })) } } @@ -150,6 +163,7 @@ mod tests { session_id: None, skill_executor: None, path_validator, + event_sender: None, } }