Skip to main content

Module sdk

Module sdk 

Source
Expand description

Curated Rust SDK surface for embedding imp in other hosts.

This module is the first stable-shaped entry point for using imp as a reusable runtime instead of only through the CLI or TUI. It intentionally wraps the existing imp_session, agent, and ui pieces in one place so host applications can depend on a small public surface.

Current SDK v1 focus:

  • create and manage an ImpSession
  • prompt, steer, follow up, cancel, and wait for completion
  • consume the runtime AgentEvent stream
  • provide a host-side UserInterface bridge
  • switch models and thinking levels for later prompts

Explicitly out of scope for this first slice:

  • TypeScript extension/runtime loading
  • packaged customization discovery
  • a higher-level runtime/session-replacement wrapper above ImpSession
  • CLI/TUI-specific orchestration helpers
  • provider registration and broader host lifecycle policy

§Example

use imp_core::sdk::{AgentEvent, ImpSession, Result, SessionOptions};

#[tokio::main]
async fn main() -> Result<()> {
    let mut session = ImpSession::create(SessionOptions {
        cwd: std::env::current_dir()?,
        ..Default::default()
    })
    .await?;

    session.prompt("Summarize the project in this directory.").await?;

    while let Some(event) = session.recv_event().await {
        match event {
            AgentEvent::MessageDelta { .. } => {}
            AgentEvent::AgentEnd { .. } => break,
            _ => {}
        }
    }

    session.wait().await
}

Re-exports§

pub use crate::agent::AgentCommand;
pub use crate::agent::AgentEvent;
pub use crate::agent::TimingEvent;
pub use crate::agent::TimingStage;
pub use crate::error::Error;
pub use crate::error::Result;
pub use crate::imp_session::ImpSession;
pub use crate::imp_session::ResolvedRuntimeConnection;
pub use crate::imp_session::RuntimeConnectionIntent;
pub use crate::imp_session::SessionChoice;
pub use crate::imp_session::SessionOptions;
pub use crate::mana_review::ManaReviewState;
pub use crate::mana_review::TurnManaReview;
pub use crate::ui::ComponentSpec;
pub use crate::ui::NotifyLevel;
pub use crate::ui::NullInterface;
pub use crate::ui::SelectOption;
pub use crate::ui::UserInterface;
pub use crate::ui::WidgetContent;

Structs§

Model
Resolved model ready for use (metadata + provider reference).

Enums§

ThinkingLevel
How much reasoning/thinking to request from the model.