Skip to main content

Crate app_kit

Crate app_kit 

Source
Expand description

Durable applications over caller-owned storage and configured agents.

Start with AppConfig and App::open, create a Workspace, then select a workflow::Workflow. The App example runs a local state workflow with caller-created embedded Lance StateStore and no Agent value or external service.

workflow contains definitions, execution controls, state operations, graph inspection, immutable checkpoints, and the five concrete App behavior seams. AgentSpec transfers an already-built Agent; App never constructs providers, tools or lower storage from declarations. Exact associated lower Workspace, Conversation and StateTransaction types remain attached.

Call App::shutdown while the captured Tokio runtime and lower runtimes are alive and driven. Run handles observe accepted work; workflow::Execution owns lazy advancement. Dropping an execution can revoke uncommitted work, while observation loss cannot revoke an admitted native commit.

Public supporting types live under workflow. The state serialization registry stores only field/tag codecs; it is not a runtime behavior registry.

§Choose a workflow

§Local workflow

use agents_kit::Agent;
use app_kit::{App, AppConfig, Shutdown, WorkspaceConfig};
use app_kit::workflow::{CheckpointSelector, ExecutionEvent, ExecutionOptions, RunSelector,
    RunStatus, WorkflowDefinition, WorkflowState};
use storage_kit::StateStore;
use storage_kit::state::config::{LanceStateStoreConfig, StateStoreConfig};

let runtime = tokio::runtime::Builder::new_current_thread().enable_all().build()?;
runtime.block_on(async {
let store = StateStore::connect(StateStoreConfig::Lance(LanceStateStoreConfig::memory())).await?;
let definition = WorkflowDefinition::parse(r#"{
    "schema":"app-kit.workflow/v2", "id":"counter", "revision":"r1",
    "state":{"count":0}, "required":["count"],
    "reducers":{"count":"reject_concurrent"}, "entry":"increment",
    "nodes":[{"id":"increment","step":{"kind":"state","mutations":[
        {"kind":"increment","target":"count","value":{"kind":"literal","value":1}}
    ]}}], "routes":{}
}"#)?;
let config = AppConfig::<_, Agent>::new(store, Vec::new(), vec![definition]);
let mut app = App::open(config).await?;
let mut workspace = app.create_workspace(WorkspaceConfig {
    name: Some("local counter".into()), root: std::env::current_dir()?,
}).await?;
let workflow = workspace.workflow("counter".parse()?).await?;
let run = workflow.start(ExecutionOptions::default()).await?;
let snapshot = run.wait().await?;
assert!(matches!(snapshot.status, RunStatus::Succeeded));
assert_eq!(snapshot.state.values()["count"], 1);
app.shutdown(Shutdown::Drain { timeout: std::time::Duration::from_secs(5) }).await?;
})?;

Modules§

workflow
Opaque workflow definitions and runtime handles. Workflow authoring, execution, immutable state, and retained history.

Structs§

AgentSpec
Declares one configured lower agent.
App
An open application generation.
AppConfig
Complete application configuration.
Workspace
An application workspace handle.
WorkspaceConfig
Complete caller-authored workspace configuration.
WorkspaceId
A validated application workspace identity.
WorkspaceSnapshot
The current caller-visible workspace truth.

Enums§

AppError
A safe caller-visible application error.
Shutdown
Selects application shutdown behavior.