Skip to main content

aidaemon_core/
lib.rs

1//! # aidaemon-core (experimental sketch)
2//!
3//! A small agent-loop kernel. It owns the loop, the tool contract, typed
4//! outcomes, receipts, budgets, stuck detection, and interrupt/resume. Every
5//! *policy* (approvals, completion checks, context strategies, memory) plugs
6//! in through [`Hook`]. Product features (channels, goals, scheduling,
7//! specialists) live outside this crate.
8//!
9//! The loop, in one sentence: build the request, call the model, and if it
10//! asked for tools run them (read-only ones concurrently, mutating ones one
11//! at a time) and go around again; otherwise ask the stop hooks whether the
12//! answer is acceptable and finish with a typed [`RunOutcome`].
13//!
14//! See the SDK guide at <https://docs.aidaemon.ai/sdk> for the concepts,
15//! `examples/kernel_tour.rs` for a runnable tour of the kernel, and
16//! `aidaemon-sdk`'s `examples/quickstart.rs` for the shortest working agent.
17
18// Feature unification only (cargo-hakari); keeps the unused-dependency lint quiet.
19use workspace_hack as _;
20
21mod agent;
22mod approval;
23mod audience;
24mod authority;
25mod binding;
26pub mod card;
27mod endpoint;
28mod error;
29mod event;
30mod failover;
31mod hook;
32mod limits;
33pub mod mandate_card;
34mod message;
35mod nested;
36mod outcome;
37mod project;
38mod provider;
39mod quota;
40mod receipt;
41pub mod redaction;
42mod run_loop;
43mod safeguard;
44mod service;
45mod state;
46mod store;
47mod stuck;
48mod tool;
49mod tool_loading;
50mod untrusted;
51
52#[cfg(feature = "testing")]
53pub mod conformance;
54#[cfg(feature = "testing")]
55pub mod testing;
56
57pub use agent::{Agent, AgentBuilder, InterruptResolver, Resolution};
58pub use approval::{
59    AUTHORITY_BLOCKED, ApprovalCard, ApprovalRisk, AskReason, CallEffects, CardAction,
60    EGRESS_BLOCKED, EffectClass, EffectKey, HighImpact, InterruptKind, OWNER_DECLINED,
61    OWNER_UNANSWERED, OwnerApprovalRequest, SharedDeclines, UNTRUSTED_BLOCKED,
62};
63pub use audience::{ChannelVisibility, UserRole};
64pub use authority::{AccessLevel, Authority, AuthorityCeiling, AuthorityHook};
65pub use endpoint::{EndpointPublisher, EndpointSource};
66pub use error::{BuildError, CoreError};
67pub use event::{Event, EventSink};
68pub use failover::{
69    DefaultFailover, Failover, FailoverAction, FailoverPolicy, FailoverStep, ProviderSwitch,
70    SwitchReason,
71};
72pub use hook::{
73    Hook, HookContext, HookFailure, HookPoint, LimitDecision, ModelDecision, ModelErrorDecision,
74    StopDecision, StuckDecision, ToolDecision,
75};
76#[doc(hidden)]
77pub use limits::LimitGrants;
78pub use limits::{HARD_TURN_CAP, LimitKind, Limits, RunSnapshot, StopCondition};
79pub use message::{Audio, Image, Message, MessageOrigin, Role, ToolCall};
80pub use nested::{NestedCalls, NestedVerdict};
81pub use outcome::{CallResult, FinishOutcome, RunOutcome, RunStatus};
82pub use project::ProjectRef;
83pub use provider::{
84    ModelRequest, ModelResponse, Provider, ProviderError, RequestOptions, ResponseFormat, Retry,
85    StreamEvent, ToolChoice, ToolLoad, ToolSpec, ToolSurfacing, Usage, collect_stream,
86};
87pub use quota::{Cooldown, QuotaGuard};
88pub use receipt::{InvocationStage, Receipt, ReceiptStatus};
89pub use redaction::RedactionScope;
90pub use safeguard::Safeguard;
91pub use service::{
92    FnService, Schedule, Service, ServiceContext, ServiceError, ServiceEvent, ServiceGate,
93    ServiceHost, ServiceObserver, ServiceRunEnd, ServiceWaker,
94};
95/// Kernel bookkeeping types inside [`RunState`]; not part of the stable API.
96#[doc(hidden)]
97pub use state::{InFlight, PendingFinish};
98pub use state::{Interruption, Pending, RUN_STATE_SCHEMA, RunId, RunState};
99pub use store::{MemoryStore, RunStore, StoreError};
100pub use stuck::{StuckConfig, StuckSignal};
101pub use tool::{
102    AccessManifest, Extensions, Finish, FnTool, Outbound, SameToolStreak, SourceTrust, Tool,
103    ToolAnnotations, ToolContext, ToolError, ToolInfo, ToolOutput, ToolResult,
104    check_argument_types, check_arguments, strip_reserved_arguments,
105};
106pub use tool_loading::{LOAD_TOOLS, LoadedTools};
107
108pub use untrusted::{
109    UNTRUSTED_EGRESS_INTERRUPT, UntrustedHook, UntrustedMode, is_untrusted_egress,
110};
111
112/// Re-exported so tools can observe cancellation without adding the dependency.
113pub use tokio_util::sync::CancellationToken;