Skip to main content

pharos_native/runtime/
agent_ingest.rs

1//! Root adapter for Architect attachment ingest and platform media extraction.
2
3use std::path::Path;
4
5use pharos_runtime_architect::AgentErrorKind;
6use pharos_runtime_architect::attachment_ingest::{self, MediaExtractMode};
7use pharos_runtime_architect::database::ArchitectStore;
8
9pub use pharos_runtime_architect::attachment_ingest::{
10    ArchitectAttachmentExtract, ArchitectAttachmentIngest, ArchitectTranscriptIngest, parse_task_id,
11};
12
13/// Extracts context through the configured database adapter and shared media helper.
14pub fn extract_architect_attachment_from_store(
15    store: &ArchitectStore,
16    task_id: i64,
17    attachment_id: i64,
18    storage_root: &Path,
19) -> Result<ArchitectAttachmentExtract, AgentErrorKind> {
20    attachment_ingest::extract_attachment_in_store(
21        store,
22        task_id,
23        attachment_id,
24        storage_root,
25        Some(extract_platform_media),
26    )
27}
28
29/// Maps Architect media requests to the platform helper transport.
30fn extract_platform_media(
31    mode: MediaExtractMode,
32    input_path: &Path,
33    allowed_root: &Path,
34    media_type: &str,
35    original_name: &str,
36) -> Result<String, AgentErrorKind> {
37    use super::agent_media;
38    let mode = match mode {
39        MediaExtractMode::AudioTranscript => agent_media::MediaExtractMode::AudioTranscript,
40        MediaExtractMode::ImageOcr => agent_media::MediaExtractMode::ImageOcr,
41        MediaExtractMode::ScannedPdfOcr => agent_media::MediaExtractMode::ScannedPdfOcr,
42    };
43    agent_media::extract_media_with_platform_helper(
44        mode,
45        input_path,
46        allowed_root,
47        media_type,
48        original_name,
49    )
50}