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
18mod agent;
19mod approval;
20mod audience;
21mod authority;
22mod binding;
23pub mod card;
24mod endpoint;
25mod error;
26mod event;
27mod failover;
28mod hook;
29mod limits;
30pub mod mandate_card;
31mod message;
32mod nested;
33mod outcome;
34mod project;
35mod provider;
36mod quota;
37mod receipt;
38pub mod redaction;
39mod run_loop;
40mod safeguard;
41mod service;
42mod state;
43mod store;
44mod stuck;
45mod tool;
46mod tool_loading;
47mod untrusted;
48
49#[cfg(feature = "testing")]
50pub mod conformance;
51#[cfg(feature = "testing")]
52pub mod testing;
53
54pub use agent::{Agent, AgentBuilder, InterruptResolver, Resolution};
55pub use approval::{
56    AUTHORITY_BLOCKED, ApprovalCard, ApprovalRisk, AskReason, CallEffects, CardAction,
57    EGRESS_BLOCKED, EffectClass, EffectKey, HighImpact, InterruptKind, OWNER_DECLINED,
58    OWNER_UNANSWERED, OwnerApprovalRequest, SharedDeclines, UNTRUSTED_BLOCKED,
59};
60pub use audience::{ChannelVisibility, UserRole};
61pub use authority::{AccessLevel, Authority, AuthorityCeiling, AuthorityHook};
62pub use endpoint::{EndpointPublisher, EndpointSource};
63pub use error::{BuildError, CoreError};
64pub use event::{Event, EventSink};
65pub use failover::{
66    DefaultFailover, Failover, FailoverAction, FailoverPolicy, FailoverStep, ProviderSwitch,
67    SwitchReason,
68};
69pub use hook::{
70    Hook, HookContext, HookFailure, HookPoint, LimitDecision, ModelDecision, ModelErrorDecision,
71    StopDecision, StuckDecision, ToolDecision,
72};
73#[doc(hidden)]
74pub use limits::LimitGrants;
75pub use limits::{HARD_TURN_CAP, LimitKind, Limits, RunSnapshot, StopCondition};
76pub use message::{Audio, Image, Message, MessageOrigin, Role, ToolCall};
77pub use nested::{NestedCalls, NestedVerdict};
78pub use outcome::{CallResult, FinishOutcome, RunOutcome, RunStatus};
79pub use project::ProjectRef;
80pub use provider::{
81    ModelRequest, ModelResponse, Provider, ProviderError, RequestOptions, ResponseFormat, Retry,
82    StreamEvent, ToolChoice, ToolLoad, ToolSpec, ToolSurfacing, Usage, collect_stream,
83};
84pub use quota::{Cooldown, QuotaGuard};
85pub use receipt::{InvocationStage, Receipt, ReceiptStatus};
86pub use redaction::RedactionScope;
87pub use safeguard::Safeguard;
88pub use service::{
89    FnService, Schedule, Service, ServiceContext, ServiceError, ServiceEvent, ServiceGate,
90    ServiceHost, ServiceObserver, ServiceRunEnd, ServiceWaker,
91};
92/// Kernel bookkeeping types inside [`RunState`]; not part of the stable API.
93#[doc(hidden)]
94pub use state::{InFlight, PendingFinish};
95pub use state::{Interruption, Pending, RUN_STATE_SCHEMA, RunId, RunState};
96pub use store::{MemoryStore, RunStore, StoreError};
97pub use stuck::{StuckConfig, StuckSignal};
98pub use tool::{
99    AccessManifest, Extensions, Finish, FnTool, Outbound, SameToolStreak, SourceTrust, Tool,
100    ToolAnnotations, ToolContext, ToolError, ToolInfo, ToolOutput, ToolResult,
101    check_argument_types, check_arguments, strip_reserved_arguments,
102};
103pub use tool_loading::{LOAD_TOOLS, LoadedTools};
104
105pub use untrusted::{
106    UNTRUSTED_EGRESS_INTERRUPT, UntrustedHook, UntrustedMode, is_untrusted_egress,
107};
108
109/// Re-exported so tools can observe cancellation without adding the dependency.
110pub use tokio_util::sync::CancellationToken;