1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
//! Portable agent runtimes over Codex App Server, OpenCode, and a
//! provider-backed Custom implementation.
//!
//! The hierarchy is [`Agent`] → [`Workspace`] → [`Conversation`]. Implement
//! [`AgentBackend`], [`WorkspaceBackend`] and [`ConversationBackend`] directly to
//! supply your own concrete associated children. The supplied handles implement
//! those same traits.
//!
//! # Choose a task
//!
//! - Construct a supplied agent below, then create children with
//! [`AgentBackend::new_workspace`] and [`WorkspaceBackend::new_conversation`].
//! - [Reopen a durable identity](AgentBuilder::reopen) with fresh integrations.
//! - [Consume a caller-owned conversation](ConversationBackend) without a service.
//! - [Stream native output and resolve interactions](conversation) with a configured backend.
//! - Build passive inputs in [`config`], [`workspace`], [`prompt`], [`model`],
//! [`tool`] and [`knowledge`]; inspect failures through [`error`].
//!
//! Custom retains its direct Provider and Toolset implementations. Each toolset's
//! Handler stays associated and need not be Clone. Prompt streams observe accepted
//! work: dropping an observer neither cancels that work nor releases its slot.
//! Use abort or consuming lifecycle operations and keep the runtime alive through
//! cleanup. Native builders retain no provider value; Custom receives one through
//! [`AgentBuilder::with_provider`]. Exact Model continuations live only within an
//! active prompt loop; durable history contains provider-neutral text.
//!
//! # Construct and shut down a Custom agent
//!
//! This runs locally with memory Lance. Provider construction makes no model
//! request; prompting would require the configured Ollama service and exact model.
//! The result is inspected only after shutdown has been attempted.
//!
//! ```
//! use std::{num::NonZeroUsize, time::Duration};
//! use agents_kit::{AgentBackend, AgentBuilder, AgentStorage};
//! use agents_kit::config::{AgentConfig, CustomAgentConfig, CustomLoopLimits, CustomToolApproval};
//! use agents_kit::{model::ModelSelector, tool::ToolSelection};
//! use providers_kit::{Provider, ProviderConfig};
//! use providers_kit::config::{OllamaConfig, ProviderKind, TransportConfig};
//! use storage_kit::{StateStore, state::config::{LanceStateStoreConfig, StateStoreConfig}};
//! # tokio::runtime::Builder::new_current_thread().enable_all().build()?.block_on(async {
//! let custom = CustomAgentConfig::new(
//! ModelSelector::new("exact-model")?, ToolSelection::None,
//! CustomLoopLimits::new(4, 0, 1)?, CustomToolApproval::Deny,
//! )?;
//! let config = AgentConfig::new(custom.into(), Duration::from_secs(10), NonZeroUsize::MIN)?;
//! let store = StateStore::connect(StateStoreConfig::lance(LanceStateStoreConfig::memory())).await?;
//! let provider = Provider::from_config(ProviderConfig::new(
//! ProviderKind::Ollama(OllamaConfig::local()), TransportConfig::default(),
//! ))?;
//! let agent = AgentBuilder::create(config, AgentStorage::new(store))
//! .with_provider(provider).build().await?;
//! let id = agent.id();
//! let result = agent.info().await;
//! let cleanup = agent.shutdown().await;
//! let info = match (result, cleanup) {
//! (Ok(info), Ok(())) => Ok(info),
//! (Err(primary), Err(cleanup)) => Err(primary.with_supplementary(cleanup)),
//! (Err(error), _) | (_, Err(error)) => Err(error),
//! }?;
//! assert_eq!(info.id(), &id);
//! # Ok::<(), Box<dyn std::error::Error>>(())
//! # })?;
//! # Ok::<(), Box<dyn std::error::Error>>(())
//! ```
/// Agent construction settings and backend runtime policies.
/// Conversation handles, backend contracts, and conversation requests and responses.
/// Validated identities and agent inventory information.
/// Knowledge sources, scopes, ingestion requests, and retrieval policies.
/// Model inventory, opaque selectors, and reasoning settings.
/// Durable notifications, caller resolutions, and notification streams.
/// Prompt requests, responses, and incremental output streams.
/// Portable tool selection and managed tool inventory.
/// Workspace handles, backend contracts, defaults, and workspace requests.
pub use crate;
pub use crateAgentStorage;
pub use crateAgentBuilder;
pub use crate;
pub use crateKitError;
pub use crate;
pub use crateAgentInfo;
pub use crate;
pub use crate;
pub use crateManagedKnowledge;
pub use crate;
pub use crate;
pub use crate;
pub use crate;
pub use crate;
pub use crate;
pub use crate;