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
refactor(presentation): build wire spec directly from PresentationSpec
Steven Enamakel252c6687c7be
diff --git a/crates/openhuman-core/src/tools/impl/presentation/engine.rs b/crates/openhuman-core/src/tools/impl/presentation/engine.rsindex 54685493ff..a98522e275 100644--- a/crates/openhuman-core/src/tools/impl/presentation/engine.rs+++ b/crates/openhuman-core/src/tools/impl/presentation/engine.rs@@ -24,12 +24,11 @@use std::time::Duration;-use crate::tools::implementations::document::format::spec::{- SlideImage, SlideSpec, WirePresentationSpec, WireSlideImage, WireSlideSpec,-};+use tinydocs_bus::spec::presentation::PresentationSpec;+use tinydocs_bus::spec::{WirePresentationSpec, WireSlideImage, WireSlideSpec};use tokio::time::timeout;-use super::types::{GeneratePresentationInput, PresentationError};+use super::types::PresentationError;use crate::modules::documents;/// Run the synthesis. Returns the serialised `.pptx` bytes ready to be written@@ -38,12 +37,11 @@ use crate::modules::documents;/// The `deadline` covers the whole call, including the image transfer. Hitting/// it surfaces as [`PresentationError::GenerationTimeout`].pub(super) async fn generate(- input: &GeneratePresentationInput,- images: &[Vec<SlideImage>],+ spec: &PresentationSpec,deadline: Duration,config: Option<&crate::config::Config>,) -> Result<Vec<u8>, PresentationError> {- let (deck, payload) = build_request(input, images);+ let (deck, payload) = build_request(spec);let started = std::time::Instant::now();let slide_count = deck.slides.len();let deadline_secs = deadline.as_secs();@@ -54,7 +52,7 @@ pub(super) async fn generate(deadline_secs,slide_count,image_bytes,- title_chars = input.title.chars().count(),+ title_chars = spec.title.chars().count(),"[presentation:engine] generate:start");@@ -132,26 +130,13 @@ pub(super) async fn generate(/// corresponding slice in `payload`, in the same order, and the module refuses/// the call if they do not add up. Building both here, in one pass, is what/// keeps them consistent.-fn build_request(- input: &GeneratePresentationInput,- images: &[Vec<SlideImage>],-) -> (WirePresentationSpec, Vec<u8>) {+fn build_request(spec: &PresentationSpec) -> (WirePresentationSpec, Vec<u8>) {let mut payload = Vec::new();- let mut slides = Vec::with_capacity(input.slides.len());+ let mut slides = Vec::with_capacity(spec.slides.len());- for (index, slide) in input.slides.iter().enumerate() {- let resolved = images.get(index).map(Vec::as_slice).unwrap_or(&[]);- // The contract builds the slide from already-resolved images; only the- // wire projection (lengths instead of bytes) is made here.- let spec = SlideSpec::new(- slide.title.clone(),- slide.body.clone(),- slide.bullets.clone(),- slide.speaker_notes.clone(),- resolved.to_vec(),- );- let mut wire_images = Vec::with_capacity(spec.images.len());- for image in &spec.images {+ for slide in &spec.slides {+ let mut wire_images = Vec::with_capacity(slide.images.len());+ for image in &slide.images {payload.extend_from_slice(&image.bytes);wire_images.push(WireSlideImage {byte_len: image.bytes.len() as u64,@@ -159,19 +144,19 @@ fn build_request(});}slides.push(WireSlideSpec {- title: spec.title,- body: spec.body,- bullets: spec.bullets,- speaker_notes: spec.speaker_notes,+ title: slide.title.clone(),+ body: slide.body.clone(),+ bullets: slide.bullets.clone(),+ speaker_notes: slide.speaker_notes.clone(),images: wire_images,});}(WirePresentationSpec {- title: input.title.clone(),- author: input.author.clone(),- theme: input.theme.clone(),+ title: spec.title.clone(),+ author: spec.author.clone(),+ theme: spec.theme.clone(),slides,},payload,