Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

feat(presentation): add slide deck engine with typed slide models

Steven Enamakeld7abcf65ac9f
diff --git a/crates/openhuman-core/src/tools/impl/presentation/engine.rs b/crates/openhuman-core/src/tools/impl/presentation/engine.rs
index b97e7df9e4..90c64ef9a9 100644
--- a/crates/openhuman-core/src/tools/impl/presentation/engine.rs
+++ b/crates/openhuman-core/src/tools/impl/presentation/engine.rs
@@ -25,11 +25,11 @@
use std::time::Duration;
use crate::tools::implementations::document::format::spec::{
- WirePresentationSpec, WireSlideImage, WireSlideSpec,
+ SlideImage, SlideSpec, WirePresentationSpec, WireSlideImage, WireSlideSpec,
};
use tokio::time::timeout;
-use super::types::{GeneratePresentationInput, PresentationError, ResolvedSlideImage};
+use super::types::{GeneratePresentationInput, PresentationError};
use crate::modules::documents;
/// Run the synthesis. Returns the serialised `.pptx` bytes ready to be written
@@ -39,7 +39,7 @@ use crate::modules::documents;
/// it surfaces as [`PresentationError::GenerationTimeout`].
pub(super) async fn generate(
input: &GeneratePresentationInput,
- images: &[Vec<ResolvedSlideImage>],
+ images: &[Vec<SlideImage>],
deadline: Duration,
config: Option<&crate::config::Config>,
) -> Result<Vec<u8>, PresentationError> {
@@ -134,7 +134,7 @@ pub(super) async fn generate(
/// keeps them consistent.
fn build_request(
input: &GeneratePresentationInput,
- images: &[Vec<ResolvedSlideImage>],
+ images: &[Vec<SlideImage>],
) -> (WirePresentationSpec, Vec<u8>) {
let mut payload = Vec::new();
let mut slides = Vec::with_capacity(input.slides.len());
diff --git a/crates/openhuman-core/src/tools/impl/presentation/mod.rs b/crates/openhuman-core/src/tools/impl/presentation/mod.rs
index 89d1bdb0f3..3181ef9a29 100644
--- a/crates/openhuman-core/src/tools/impl/presentation/mod.rs
+++ b/crates/openhuman-core/src/tools/impl/presentation/mod.rs
@@ -48,8 +48,8 @@ mod types;
mod tests;
use self::types::{
- validate_input, GeneratePresentationInput, GeneratePresentationOutput, ResolvedSlideImage,
- SlideImage, SlideImageSource, MAX_IMAGE_BYTES,
+ validate_input, GeneratePresentationInput, GeneratePresentationOutput, SlideImageRequest,
+ SlideImageSource, MAX_IMAGE_BYTES,
};
/// Generation timeout. `ppt-rs` typically completes the full 64-slide
@@ -441,7 +441,7 @@ impl PresentationTool {
async fn resolve_images(
&self,
input: &GeneratePresentationInput,
- ) -> (Vec<Vec<ResolvedSlideImage>>, Vec<String>) {
+ ) -> (Vec<Vec<SlideImage>>, Vec<String>) {
self.resolve_images_with_inspector(
input,
&ModuleImageInspector {
@@ -455,8 +455,8 @@ impl PresentationTool {
&self,
input: &GeneratePresentationInput,
inspector: &impl ImageInspector,
- ) -> (Vec<Vec<ResolvedSlideImage>>, Vec<String>) {
- let mut per_slide: Vec<Vec<ResolvedSlideImage>> = Vec::with_capacity(input.slides.len());
+ ) -> (Vec<Vec<SlideImage>>, Vec<String>) {
+ let mut per_slide: Vec<Vec<SlideImage>> = Vec::with_capacity(input.slides.len());
let mut warnings: Vec<String> = Vec::new();
for (slide_idx, spec) in input.slides.iter().enumerate() {
@@ -481,15 +481,15 @@ impl PresentationTool {
(per_slide, warnings)
}
- /// Resolve a single [`SlideImage`] to validated, embeddable bytes.
+ /// Resolve a single [`SlideImageRequest`] to validated, embeddable bytes.
/// Returns `Err(reason)` (a short human-readable string) when the
/// image cannot be embedded — the caller turns that into a skip
/// warning.
async fn resolve_one_image(
&self,
- image: &SlideImage,
+ image: &SlideImageRequest,
inspector: &impl ImageInspector,
- ) -> Result<ResolvedSlideImage, String> {
+ ) -> Result<SlideImage, String> {
let bytes = match &image.source {
SlideImageSource::Artifact { artifact_id } => {
read_artifact_bytes(&self.workspace_dir, &self.files_dir, artifact_id)
@@ -534,7 +534,7 @@ impl PresentationTool {
let facts = inspector.inspect(&bytes).await?;
- Ok(ResolvedSlideImage {
+ Ok(SlideImage {
bytes,
format: facts.format,
width_px: facts.width_px,
diff --git a/crates/openhuman-core/src/tools/impl/presentation/types.rs b/crates/openhuman-core/src/tools/impl/presentation/types.rs
index c5d7640276..c886cee4d2 100644
--- a/crates/openhuman-core/src/tools/impl/presentation/types.rs
+++ b/crates/openhuman-core/src/tools/impl/presentation/types.rs
@@ -1,6 +1,5 @@
//! Typed input / output / error contracts for the `generate_presentation` tool.
-use crate::tools::implementations::document::format::spec::ImageFormat;
use serde::{Deserialize, Serialize};
use crate::modules::documents::DocumentCallError;
@@ -27,12 +26,14 @@ pub enum SlideImageSource {
File { path: String },
}
-/// One image attached to a slide. `caption`, when present, is rendered
+/// One image the agent asks for on a slide (the tool's input shape; the bus
+/// `SlideImage` it resolves to carries bytes, format and dimensions).
+/// `caption`, when present, is rendered
/// as a trailing text bullet beneath the image in v1 (a true
/// image-anchored caption shape is deferred with the grid layout).
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
-pub struct SlideImage {
+pub struct SlideImageRequest {
/// Image data source. See [`SlideImageSource`].
pub source: SlideImageSource,
/// Optional caption rendered as a bullet under the image.
@@ -43,7 +44,7 @@ pub struct SlideImage {
/// Slide spec — one entry per content slide in the generated deck.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
-pub struct SlideSpec {
+pub struct SlideRequest {
/// Slide title. Empty / omitted is allowed for visually
/// minimalist decks but at least one of `title` / `body` /
/// `bullets` must be populated.
@@ -64,20 +65,7 @@ pub struct SlideSpec {
/// async `execute()` boundary; a bad image is skipped with a
/// warning rather than failing the whole deck.
#[serde(default)]
- pub images: Vec<SlideImage>,
-}
-
-/// An image resolved + validated at the async boundary, ready for the
-/// (synchronous, pure) engine to embed. Carries the decoded bytes, the
-/// `ppt-rs` format token (`"PNG"` / `"JPEG"`), and the native pixel
-/// dimensions used for aspect-preserving placement.
-#[derive(Debug, Clone)]
-pub(super) struct ResolvedSlideImage {
- pub bytes: Vec<u8>,
- pub format: ImageFormat,
- pub width_px: u32,
- pub height_px: u32,
- pub caption: Option<String>,
+ pub images: Vec<SlideImageRequest>,
}
/// Top-level input for the `generate_presentation` tool.
@@ -97,7 +85,7 @@ pub struct GeneratePresentationInput {
pub theme: Option<String>,
/// Slide specs, in display order. Must contain at least one entry.
#[serde(default)]
- pub slides: Vec<SlideSpec>,
+ pub slides: Vec<SlideRequest>,
}
/// Tool output returned via [`tinytools::ToolResult`]