The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
feat(artifacts): add presentation artifact operations
Steven Enamakelbade910eb758
diff --git a/crates/openhuman-core/src/agent/artifacts/ops.rs b/crates/openhuman-core/src/agent/artifacts/ops.rsindex e70a21288f..452c69120b 100644--- a/crates/openhuman-core/src/agent/artifacts/ops.rs+++ b/crates/openhuman-core/src/agent/artifacts/ops.rs@@ -6,7 +6,7 @@ use crate::core::Outcome;// Imports used only by the `documents`-gated presentation regeneration helper// below; when the feature is off the PresentationTool is compiled out.#[cfg(feature = "documents")]-use crate::security::approval::{ApprovalChatContext, APPROVAL_CHAT_CONTEXT};+use crate::security::approval::ApprovalChatContext;#[cfg(feature = "documents")]use crate::security::SecurityPolicy;#[cfg(feature = "documents")]@@ -153,7 +153,7 @@ pub async fn ai_delete_artifact(/// live config and run it inside both:/// - `PresentationTool::with_regenerate_target(artifact_id)` so `create_artifact`/// reuses the id + directory instead of minting a new one, and-/// - `APPROVAL_CHAT_CONTEXT.scope({thread_id, client_id}, …)` so the+/// - the chat context `{thread_id, client_id}` handed to the tool so the/// Pending/Ready/Failed events route back to the originating chat/// surface (the RPC carries no ambient chat context of its own).///@@ -229,9 +229,7 @@ async fn regenerate_presentation(request_id: None,};- let result = APPROVAL_CHAT_CONTEXT- .scope(chat_ctx, async move { tool.execute(args).await })- .await;+ let result = tool.run(args, Some(&chat_ctx)).await;match result {Ok(tool_result) => {diff --git a/crates/openhuman-core/src/tools/impl/presentation/mod.rs b/crates/openhuman-core/src/tools/impl/presentation/mod.rsindex 2c87d642c9..64b2767337 100644--- a/crates/openhuman-core/src/tools/impl/presentation/mod.rs+++ b/crates/openhuman-core/src/tools/impl/presentation/mod.rs@@ -289,6 +289,28 @@ impl Tool for PresentationTool {}async fn execute(&self, args: Value) -> anyhow::Result<ToolResult> {+ self.run(args, None).await+ }++ async fn execute_with_context(+ &self,+ args: Value,+ _options: tinytools::ToolCallOptions,+ context: Option<&dyn tinytools::ToolRunContext>,+ ) -> anyhow::Result<ToolResult> {+ let approval = crate::agent::tinyagents::host::run_context::approval_for_tool(context);+ self.run(args, approval.chat.as_ref()).await+ }+}++impl PresentationTool {+ /// Produces the deck for a turn whose chat routing is `chat` (`None`+ /// outside a chat turn).+ pub(crate) async fn run(+ &self,+ args: Value,+ chat: Option<&crate::security::approval::ApprovalChatContext>,+ ) -> anyhow::Result<ToolResult> {let input: GeneratePresentationInput = match serde_json::from_value(args.clone()) {Ok(v) => v,Err(err) => {@@ -331,6 +353,7 @@ impl Tool for PresentationTool {"pptx",None,self.regenerate_target.as_deref(),+ chat,).await.map_err(anyhow::Error::msg)?;@@ -366,6 +389,7 @@ impl Tool for PresentationTool {&self.files_dir,&meta.id,&err.to_string(),+ chat,).await;tracing::warn!(@@ -383,7 +407,8 @@ impl Tool for PresentationTool {.map(|n| n.to_string_lossy().into_owned()).unwrap_or_default();let reason = format!("failed to write generated deck ({filename}): {err}");- let _ = fail_artifact(&self.workspace_dir, &self.files_dir, &meta.id, &reason).await;+ let _ =+ fail_artifact(&self.workspace_dir, &self.files_dir, &meta.id, &reason, chat).await;tracing::warn!(target: "presentation",err = %err,@@ -395,7 +420,7 @@ impl Tool for PresentationTool {}let size_bytes = bytes.len() as u64;- let updated = match finalize_artifact(&self.workspace_dir, &meta.id, size_bytes).await {+ let updated = match finalize_artifact(&self.workspace_dir, &meta.id, size_bytes, chat).await {Ok(updated) => updated,Err(err) => {let reason = format!("failed to finalize artifact: {err}");@@ -405,8 +430,14 @@ impl Tool for PresentationTool {// errors are swallowed — they can only happen if the same// ledger backend is unavailable, in which case nothing we// do here will help.- let _ =- fail_artifact(&self.workspace_dir, &self.files_dir, &meta.id, &reason).await;+ let _ = fail_artifact(+ &self.workspace_dir,+ &self.files_dir,+ &meta.id,+ &reason,+ chat,+ )+ .await;tracing::warn!(target: "presentation",err = %err,