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
125
126
127
128
129
130
131
132
133
//! Anthropic Managed Agents API (preview).
//!
//! Managed Agents lets you provision long-running agent sessions backed by
//! Anthropic-managed compute environments, persistent memory stores, and
//! credential vaults. Each session references a versioned agent and an
//! environment, drives a [stream of events](crate::managed_agents::events),
//! and may produce outputs as files.
//!
//! # Beta status
//!
//! All requests in this module require the `managed-agents-2026-04-01`
//! beta header, which the SDK adds automatically. Outcomes additionally
//! require `managed-agents-2026-04-01-research-preview`.
//!
//! **The API surface is in preview and will change.** Field names,
//! request shapes, and resource relationships are not yet stable. We
//! follow the broader claude-api forward-compatibility contract: every
//! union deserializes into `Other(Value)` when the wire `type` tag is
//! unknown, so brand-new variants don't break the build. New `Known`
//! variants are minor bumps that may require sweeping `Other` matches.
//!
//! Gated on the `managed-agents-preview` feature.
//!
//! # Layout
//!
//! - [`sessions`] -- create, retrieve, list, archive, delete sessions;
//! send and stream events.
//! - [`vaults`] -- credential vaults for MCP authentication.
//! - [`memory_stores`] -- persistent memory across sessions.
//! - [`agents`] -- agent definitions (create only in this version; full
//! CRUD lands once docs are available).
//!
//! # Create a session and send a message
//!
//! ```no_run
//! use claude_api::{Client,
//! managed_agents::sessions::{AgentRef, CreateSessionRequest},
//! managed_agents::events::OutgoingUserEvent};
//! # async fn run() -> Result<(), claude_api::Error> {
//! let client = Client::new(std::env::var("ANTHROPIC_API_KEY").unwrap());
//! let ma = client.managed_agents();
//! let session = ma.sessions().create(
//! CreateSessionRequest::builder()
//! .agent(AgentRef::latest("agt_..."))
//! .build()?,
//! ).await?;
//! let sessions = ma.sessions();
//! sessions.events(session.id)
//! .send(&[OutgoingUserEvent::message("Hello!")])
//! .await?;
//! # Ok(())
//! # }
//! ```
use crateClient;
/// Top-level namespace handle for the Managed Agents API.
///
/// Obtained via [`Client::managed_agents`].
/// Beta header value required on every Managed Agents API request.
pub const MANAGED_AGENTS_BETA: &str = "managed-agents-2026-04-01";
/// Additional beta header value required for research-preview features
/// like outcomes. Add **alongside** [`MANAGED_AGENTS_BETA`]. Opt in
/// via [`Sessions::with_research_preview`](sessions::Sessions::with_research_preview).
pub const MANAGED_AGENTS_RESEARCH_PREVIEW_BETA: &str =
"managed-agents-2026-04-01-research-preview";
/// Pick the right beta-header slice for a Managed Agents request.
///
/// Returns the base header on its own, or both headers when the
/// caller has opted into research-preview features (outcomes via
/// `user.define_outcome` events, span outcome events, and the
/// `Session.outcome_evaluations` field).
pub const