Skip to main content

troupekit_ffi/
lib.rs

1uniffi::setup_scaffolding!();
2
3mod agent;
4mod error;
5mod graph;
6mod host;
7mod records;
8mod stream;
9
10pub use agent::{AgentBuilder, AgentHandle};
11pub use error::{ErrorCode, HostError, TroupekitError};
12pub use graph::{GraphBuilder, GraphHandle};
13#[cfg(feature = "knowledge")]
14pub use host::HostEmbedder;
15pub use host::{
16    EventListener, HostModel, HostTool, HostTransport, HttpSink, TokenSink, TraceListener,
17};
18pub use records::{
19    Event, EventKind, GraphResult, HostHeader, HostHttpRequest, HostMessage, HostModelCaps,
20    HostReply, HostRequest, Pause, Progress, RunResult, RuntimeSettings, Usage,
21};
22#[cfg(feature = "knowledge")]
23pub use records::{KnowledgeConfig, MemoryConfig};
24pub use stream::RunStream;
25
26/// Returns the troupekit version, exported to Swift and Kotlin.
27/// Input: none. Output: the value of `troupekit_ffi_core::version`,
28/// passed through unchanged.
29#[uniffi::export]
30pub fn version() -> String {
31    troupekit_ffi_core::version()
32}
33
34/// Sets the process-wide runtime once, before the first agent is built.
35/// Exported as `initialize` (freeze open question Q2). Input: the settings.
36/// Output: the neutral layer's result, its error converted.
37#[uniffi::export(name = "initialize")]
38pub fn init(settings: RuntimeSettings) -> Result<(), TroupekitError> {
39    Ok(troupekit_ffi_core::init(settings.into())?)
40}