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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
//! # Agent Development Kit (ADK) for Rust
//!
//! [](https://crates.io/crates/adk-rust)
//! [](https://docs.rs/adk-rust)
//! [](https://github.com/zavora-ai/adk-rust/blob/main/LICENSE)
//!
//! A flexible and modular framework for developing and deploying AI agents in Rust.
//! ADK-Rust is model-agnostic and deployment-agnostic: this umbrella crate re-exports the
//! ADK-Rust crates behind feature flags grouped into four tiers.
//!
//! ## Quick Start
//!
//! Create your first AI agent in minutes:
//!
//! ```no_run
//! use adk_rust::prelude::*;
//! use adk_rust::Launcher;
//! use std::sync::Arc;
//!
//! #[tokio::main]
//! async fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
//! let api_key = std::env::var("GOOGLE_API_KEY")?;
//! let model = GeminiModel::new(&api_key, "gemini-3.8-flash")?;
//!
//! let agent = LlmAgentBuilder::new("assistant")
//! .description("A helpful AI assistant")
//! .instruction("You are a friendly assistant. Answer questions concisely.")
//! .model(Arc::new(model))
//! .build()?;
//!
//! // Run in interactive console mode
//! Launcher::new(Arc::new(agent)).run().await?;
//! Ok(())
//! }
//! ```
//!
//! ## Installation
//!
//! Add to your `Cargo.toml`:
//!
//! ```toml
//! [dependencies]
//! adk-rust = "3.0.0"
//! tokio = { version = "1.40", features = ["full"] }
//! dotenvy = "0.15" # For loading .env files
//! ```
//!
//! ### Feature Presets
//!
//! ```toml
//! # Minimal (default) — agents, Gemini, runner, sessions (fastest build)
//! adk-rust = "3.0.0"
//!
//! # Standard — minimal + OpenAI, Anthropic (and the adk-anthropic client), skills, graph,
//! # auth, server, eval, guardrail, plugin, artifacts, tools, memory, telemetry, computer-use
//! adk-rust = { version = "3.0.0", features = ["standard"] }
//!
//! # Enterprise — standard + realtime, browser, rag, payments, awp, and autonomy: the
//! # harness, its kernel, durable and background runs, approvals and signed audit
//! adk-rust = { version = "3.0.0", features = ["enterprise"] }
//!
//! # Full — enterprise + audio, code, sandbox, code-tools, the AWP website, vision, and the
//! # graph-functional, graph-node-cache, graph-delta, graph-time-travel, and graph-yaml capabilities
//! adk-rust = { version = "3.0.0", features = ["full"] }
//!
//! # Custom — pick exactly what you need
//! adk-rust = { version = "3.0.0", default-features = false, features = [
//! "agents", "gemini", "tools", "sessions", "openai", "openrouter"
//! ] }
//! ```
//!
//! ## Autonomous Agents
//!
//! 3.0 builds agents that work on their own inside limits you set: goals that iterate until a
//! check passes and park on a decision; wake-ups on a schedule, a file change, a webhook or a
//! queue message; one governed tool path with tool policies, approvals across runs, run
//! budgets, spend caps, a kill switch and a signed audit log; and durable runs that resume
//! after a crash.
//!
//! | Module | Feature | What it holds |
//! |--------|---------|---------------|
//! | `harness` | `harness` (in `enterprise` and `full`) | The governed harness agent: modes, standing approvals, a sandboxed shell, plans and durable goals |
//! | `kernel` | `harness-kernel` (in `enterprise` and `full`) | The agent kernel `adk-rust up` runs: processes, wake sources, the event bus and the control plane |
//! | `surface` | `surface` (in no tier) | The surface engine and the web home, over a harness or a kernel |
//! | `vision` | `vision` (in `full`); `vision-local` adds the on-device backends | Local-first perception: regions in source pixels, verified weights, the egress gate, cloud describers and `sam-3.1`; with `harness`, the vision pack |
//!
//! [Build an autonomous agent](https://github.com/zavora-ai/adk-rust/blob/main/docs/official_docs/autonomy/index.md)
//! takes one agent from a scaffold to running on its own.
//!
//! ## Agent Types
//!
//! ADK-Rust provides several agent types for different use cases:
//!
//! ### LlmAgent - AI-Powered Reasoning
//!
//! The core agent type that uses Large Language Models for intelligent
//! reasoning. `GoogleSearchTool` below requires the `tools` feature (included in
//! `standard` and above); the agent itself needs only the default tier:
//!
//! ```no_run
//! # #[cfg(feature = "tools")]
//! # async fn example() -> adk_rust::Result<()> {
//! use adk_rust::prelude::*;
//! use std::sync::Arc;
//!
//! let api_key = std::env::var("GOOGLE_API_KEY").map_err(|e| AdkError::config(e.to_string()))?;
//! let model = GeminiModel::new(&api_key, "gemini-3.8-flash")?;
//!
//! let agent = LlmAgentBuilder::new("researcher")
//! .description("Research assistant with web search")
//! .instruction("Search for information and provide detailed summaries.")
//! .model(Arc::new(model))
//! .tool(Arc::new(GoogleSearchTool::new())) // Add tools
//! .build()?;
//! # Ok(())
//! # }
//! ```
//!
//! ### Workflow Agents - Deterministic Pipelines
//!
//! For predictable, multi-step workflows:
//!
//! ```no_run
//! use adk_rust::prelude::*;
//! use std::sync::Arc;
//!
//! # async fn example() -> Result<()> {
//! # let researcher: Arc<dyn Agent> = todo!();
//! # let writer: Arc<dyn Agent> = todo!();
//! # let reviewer: Arc<dyn Agent> = todo!();
//! // Sequential: Execute agents in order
//! let pipeline = SequentialAgent::new(
//! "content_pipeline",
//! vec![researcher, writer, reviewer]
//! );
//!
//! // Parallel: Execute agents concurrently
//! # let analyst1: Arc<dyn Agent> = todo!();
//! # let analyst2: Arc<dyn Agent> = todo!();
//! let parallel = ParallelAgent::new(
//! "multi_analysis",
//! vec![analyst1, analyst2]
//! );
//!
//! // Loop: Iterate until condition met
//! # let refiner: Arc<dyn Agent> = todo!();
//! let loop_agent = LoopAgent::new("iterative_refiner", vec![refiner])
//! .with_max_iterations(5);
//! # Ok(())
//! # }
//! ```
//!
//! ### Multi-Agent Systems
//!
//! Build hierarchical agent systems with automatic delegation:
//!
//! ```no_run
//! use adk_rust::prelude::*;
//! use std::sync::Arc;
//!
//! # async fn example() -> Result<()> {
//! # let model: Arc<dyn Llm> = todo!();
//! # let code_agent: Arc<dyn Agent> = todo!();
//! # let test_agent: Arc<dyn Agent> = todo!();
//! let coordinator = LlmAgentBuilder::new("coordinator")
//! .description("Development team coordinator")
//! .instruction("Delegate coding tasks to specialists.")
//! .model(model)
//! .sub_agent(code_agent) // Delegate to sub-agents
//! .sub_agent(test_agent)
//! .build()?;
//! # Ok(())
//! # }
//! ```
//!
//! ## Tools
//!
//! Give your agents capabilities beyond conversation. The tool types below
//! require the `tools` feature (included in `standard` and above):
//!
//! ### Function Tools - Custom Operations
//!
//! Convert any async function into a tool:
//!
//! ```no_run
//! # #[cfg(feature = "tools")]
//! # fn example() -> adk_rust::Result<()> {
//! use adk_rust::prelude::*;
//! use adk_rust::serde_json::{json, Value};
//! use std::sync::Arc;
//!
//! async fn get_weather(_ctx: Arc<dyn ToolContext>, args: Value) -> Result<Value> {
//! let city = args["city"].as_str().unwrap_or("Unknown");
//! // Your weather API call here
//! Ok(json!({
//! "temperature": 72.0,
//! "conditions": "Sunny",
//! "city": city
//! }))
//! }
//!
//! let weather_tool = FunctionTool::new(
//! "get_weather",
//! "Get current weather for a city",
//! get_weather,
//! );
//! # Ok(())
//! # }
//! ```
//!
//! ### Built-in Tools
//!
//! Ready-to-use tools included with ADK:
//!
//! - `GoogleSearchTool` - Web search via Google
//! - `ExitLoopTool` - Control loop termination
//! - `LoadArtifactsTool` - Access stored artifacts
//!
//! ### MCP Tools - External Integrations
//!
//! Connect to Model Context Protocol servers using the `rmcp` crate:
//!
//! ```ignore
//! use adk_rust::prelude::*;
//! use adk_rust::tool::McpToolset;
//! use rmcp::{ServiceExt, transport::TokioChildProcess};
//! use tokio::process::Command;
//!
//! # async fn example() -> Result<(), Box<dyn std::error::Error>> {
//! // Connect to an MCP server (e.g., filesystem, database)
//! let client = ().serve(TokioChildProcess::new(
//! Command::new("npx")
//! .arg("-y")
//! .arg("@modelcontextprotocol/server-filesystem")
//! .arg("/path/to/dir")
//! )?).await?;
//!
//! let mcp_tools = McpToolset::new(client);
//!
//! // Add all MCP tools to your agent
//! # let builder: LlmAgentBuilder = todo!();
//! let agent = builder.toolset(Arc::new(mcp_tools)).build()?;
//! # Ok(())
//! # }
//! ```
//!
//! ## Sessions & State
//!
//! Manage conversation context and working memory:
//!
//! ```no_run
//! use adk_rust::prelude::*;
//! use adk_rust::session::{SessionService, CreateRequest};
//! use adk_rust::serde_json::json;
//! use std::collections::HashMap;
//!
//! # async fn example() -> Result<()> {
//! let session_service = InMemorySessionService::new();
//!
//! // Create a session
//! let session = session_service.create(CreateRequest {
//! app_name: "my_app".to_string(),
//! user_id: "user_123".to_string(),
//! session_id: None,
//! state: HashMap::new(),
//! }).await?;
//!
//! // Read state (State trait provides read access)
//! let state = session.state();
//! let config = state.get("app:config"); // Returns Option<Value>
//! # Ok(())
//! # }
//! ```
//!
//! ## Callbacks
//!
//! Intercept and customize agent behavior:
//!
//! ```no_run
//! use adk_rust::prelude::*;
//! use std::sync::Arc;
//!
//! # async fn example() -> Result<()> {
//! # let model: Arc<dyn Llm> = todo!();
//! let agent = LlmAgentBuilder::new("monitored_agent")
//! .model(model)
//! // Modify or inspect model responses
//! .after_model_callback(Box::new(|_ctx, response| {
//! Box::pin(async move {
//! println!("Model responded");
//! Ok(Some(response)) // Return modified response or None to keep original
//! })
//! }))
//! // Track tool usage
//! .before_tool_callback(Box::new(|_ctx| {
//! Box::pin(async move {
//! println!("Tool about to be called");
//! Ok(None) // Continue execution
//! })
//! }))
//! .build()?;
//! # Ok(())
//! # }
//! ```
//!
//! ## Artifacts
//!
//! Store and retrieve binary data (images, files, etc.). Requires the
//! `artifacts` feature (included in `standard` and above):
//!
//! ```no_run
//! # #[cfg(feature = "artifacts")]
//! # async fn example() -> adk_rust::Result<()> {
//! use adk_rust::prelude::*;
//! use adk_rust::artifact::{ArtifactService, SaveRequest, LoadRequest};
//!
//! let artifact_service = InMemoryArtifactService::new();
//!
//! // Save an artifact
//! let response = artifact_service.save(SaveRequest {
//! app_name: "my_app".to_string(),
//! user_id: "user_123".to_string(),
//! session_id: "session_456".to_string(),
//! file_name: "sales_chart.png".to_string(),
//! part: Part::Text { text: "chart data".to_string() },
//! version: None,
//! }).await?;
//!
//! // Load an artifact
//! let loaded = artifact_service.load(LoadRequest {
//! app_name: "my_app".to_string(),
//! user_id: "user_123".to_string(),
//! session_id: "session_456".to_string(),
//! file_name: "sales_chart.png".to_string(),
//! version: None,
//! }).await?;
//! # Ok(())
//! # }
//! ```
//!
//! ## Deployment Options
//!
//! ### Console Mode (Interactive CLI)
//!
//! ```no_run
//! use adk_rust::prelude::*;
//! use adk_rust::Launcher;
//! use std::sync::Arc;
//!
//! # async fn example() -> Result<()> {
//! # let agent: Arc<dyn Agent> = todo!();
//! // Interactive chat in terminal
//! Launcher::new(agent).run().await?;
//! # Ok(())
//! # }
//! ```
//!
//! ### Server Mode (REST API)
//!
//! With the `cli` feature, [`Launcher`] is `adk_cli::Launcher`, which also serves the agent
//! over HTTP on `127.0.0.1`:
//!
//! ```bash
//! cargo run -- serve --port 8080
//! ```
//!
//! The server exposes `GET /api/health`, the session endpoints under `/api/sessions` and
//! `/api/apps/{app}/users/{user}/sessions`, `POST /api/run/{app}/{user}/{session}` (SSE),
//! and `POST /api/run_sse`. See `adk-server` for the full list. The web home of `adk-surface`
//! (feature `surface`) is served by the harness launcher, or mounted on a server you build
//! (spec 3.3 §5.1).
//!
//! ### Agent-to-Agent (A2A) Protocol
//!
//! Expose your agent for inter-agent communication. Requires the `server`
//! feature (included in `standard` and above):
//!
//! ```no_run
//! # #[cfg(feature = "server")]
//! # async fn example() -> adk_rust::Result<()> {
//! use adk_rust::server::{create_app_with_a2a, ServerConfig};
//! use adk_rust::AgentLoader;
//!
//! # let agent_loader: std::sync::Arc<dyn AgentLoader> = todo!();
//! # let session_service: std::sync::Arc<dyn adk_rust::session::SessionService> = todo!();
//! // Create server with A2A protocol support
//! let config = ServerConfig::new(agent_loader, session_service);
//! let app = create_app_with_a2a(config, Some("http://localhost:8080"));
//!
//! // Run the server (requires axum dependency)
//! // let listener = tokio::net::TcpListener::bind("127.0.0.1:8080").await?;
//! // axum::serve(listener, app).await?;
//! # Ok(())
//! # }
//! ```
//!
//! ## Observability
//!
//! Built-in OpenTelemetry support for production monitoring. Requires the
//! `telemetry` feature (included in `standard` and above); OTLP export adds
//! `telemetry-otlp`:
//!
//! ```no_run
//! # #[cfg(feature = "telemetry")]
//! # fn example() -> Result<(), Box<dyn std::error::Error>> {
//! use adk_rust::telemetry::init_telemetry;
//!
//! // Basic telemetry with console logging
//! init_telemetry("my-agent-service")?;
//!
//! // With `features = ["telemetry-otlp"]`, export spans to a collector instead:
//! // adk_rust::telemetry::init_with_otlp("my-agent-service", "http://localhost:4317")?;
//!
//! // All agent operations now emit traces and metrics
//! # Ok(())
//! # }
//! ```
//!
//! ## Architecture
//!
//! ADK-Rust uses a layered architecture for modularity:
//!
//! ```text
//! ┌─────────────────────────────────────────────────────────────┐
//! │ Application Layer │
//! │ Launcher • REST Server • A2A │
//! ├─────────────────────────────────────────────────────────────┤
//! │ Runner Layer │
//! │ Agent Execution • Event Streaming │
//! ├─────────────────────────────────────────────────────────────┤
//! │ Agent Layer │
//! │ LlmAgent • CustomAgent • Sequential • Parallel • Loop │
//! ├─────────────────────────────────────────────────────────────┤
//! │ Service Layer │
//! │ Models • Tools • Sessions • Artifacts • Memory │
//! └─────────────────────────────────────────────────────────────┘
//! ```
//!
//! ## Feature Flags
//!
//! | Feature | Description | Preset |
//! |---------|-------------|--------|
//! | `agents` | Agent implementations | minimal (default) |
//! | `models` | Model integrations | minimal (default) |
//! | `gemini` | Gemini model support | minimal (default) |
//! | `runner` | Execution runtime | minimal (default) |
//! | `sessions` | Session management | minimal (default) |
//! | `openai` | OpenAI model support | standard |
//! | `anthropic` / `anthropic-client` | Anthropic model support / the `adk-anthropic` client | standard |
//! | `tools` | Tool system | standard |
//! | `skills` | Skill discovery | standard |
//! | `artifacts` | Artifact storage | standard |
//! | `memory` | Semantic memory | standard |
//! | `telemetry` | OpenTelemetry | standard |
//! | `guardrail` | Input/output validation | standard |
//! | `auth` | Access control | standard |
//! | `plugin` | Plugin system | standard |
//! | `server` | HTTP server + A2A | standard |
//! | `graph` | Graph workflows | standard |
//! | `eval` | Agent evaluation | standard |
//! | `computer-use` | Governed desktop-automation orchestration | standard |
//! | `realtime` | Voice/audio streaming | enterprise |
//! | `browser` | Browser automation | enterprise |
//! | `rag` | RAG pipeline | enterprise |
//! | `payments` | Agentic commerce (ACP/AP2) | enterprise |
//! | `awp` | Agentic Web Protocol | enterprise |
//! | `autonomy` | An agent that runs unattended: the harness and its kernel, durable and background runs, cron and webhook wake-ups, the approvals service, SQLite stores, signed audit | enterprise |
//! | `code`, `sandbox`, `code-tools` | Code execution and sandboxed execution | full |
//! | `audio` | Audio processing | full |
//! | `graph-functional`, `graph-node-cache`, `graph-delta`, `graph-time-travel`, `graph-yaml` | Graph capabilities | full |
//! | `harness` | The governed, durable harness agent (`adk-harness`) | enterprise |
//! | `harness-kernel` | The agent kernel, the harness's always-on form (`adk-kernel`) | enterprise |
//! | `website` | The AWP website product (`adk-website`, `adk-site`) | full |
//! | `vision` | Local-first perception (`adk-vision`): regions, manifests, the egress gate, cloud describers, `sam-3.1`, the image privacy guardrail | full |
//! | `vision-local` | `vision` + the on-device backends: RF-DETR, EfficientSAM, SAM 2.1, SigLIP 2, PP-OCRv6, PaddleOCR-VL-1.6 | opt-in |
//! | `surface` | Agent surfaces: the engine and the web home (`adk-surface`) | opt-in |
//! | `harness-browser`, `harness-computer-use`, `harness-payments`, `harness-voice`, `harness-managed` | Harness packs | opt-in |
//! | `cli` | CLI launcher with serve mode | opt-in |
//! | `managed-runtime` | Managed agent runtime (`adk-managed`) | opt-in |
//! | `enterprise-client` | Enterprise client SDK (`adk-enterprise`) | opt-in |
//! | `gemini-agent-platform` | Every Gemini Enterprise Agent Platform integration except realtime transports and host-side deploy tooling | opt-in |
//! | `gemini-agent-platform-full` | `gemini-agent-platform` + Vertex AI Live API (realtime stack) | opt-in |
//! | `gcp-deploy` | Agent Engine deployment client (host-side; not part of `gemini-agent-platform`) | opt-in |
//!
//! Production backends (`postgres-session`, `redis-memory`, ...), additional providers,
//! and specialist integrations are opt-in features as well; `Cargo.toml` lists every one.
//!
//! ## Examples
//!
//! The [adk-playground](https://github.com/zavora-ai/adk-playground) repository holds the
//! teaching examples. This repository's
//! [examples directory](https://github.com/zavora-ai/adk-rust/tree/main/examples) holds the
//! standalone scenario and release-validation crates that CI runs.
//!
//! ## Related Crates
//!
//! ADK-Rust is composed of modular crates that can be used independently:
//!
//! - [`adk-core`](https://docs.rs/adk-core) - Core traits and types
//! - [`adk-agent`](https://docs.rs/adk-agent) - Agent implementations
//! - [`adk-model`](https://docs.rs/adk-model) - LLM integrations
//! - [`adk-tool`](https://docs.rs/adk-tool) - Tool system
//! - [`adk-session`](https://docs.rs/adk-session) - Session management
//! - [`adk-artifact`](https://docs.rs/adk-artifact) - Artifact storage
//! - [`adk-runner`](https://docs.rs/adk-runner) - Execution runtime
//! - [`adk-server`](https://docs.rs/adk-server) - HTTP server
//! - [`adk-telemetry`](https://docs.rs/adk-telemetry) - Observability
// ============================================================================
// Core (always available)
// ============================================================================
/// Core traits and types.
///
/// Always available regardless of feature flags. Includes:
/// - [`Agent`] - The fundamental trait for all agents
/// - [`Tool`] / [`Toolset`] - For extending agents with capabilities
/// - [`Session`] / [`State`] - For managing conversation context
/// - [`Event`] - For streaming agent responses
/// - [`AdkError`] / [`Result`] - Unified error handling
pub use *;
// Re-export common dependencies for convenience
pub use anyhow;
pub use async_trait;
pub use futures;
pub use serde;
pub use serde_json;
pub use tokio;
// ============================================================================
// Component Modules (feature-gated)
// ============================================================================
/// Agent implementations (LLM, Custom, Workflow agents).
///
/// Provides the core agent types:
/// - [`LlmAgent`](agent::LlmAgent) - AI-powered agent using LLMs
/// - [`CustomAgent`](agent::CustomAgent) - Implement custom agent logic
/// - [`SequentialAgent`](agent::SequentialAgent) - Execute agents in sequence
/// - [`ParallelAgent`](agent::ParallelAgent) - Execute agents concurrently
/// - [`LoopAgent`](agent::LoopAgent) - Iterative execution until condition met
///
/// Available with feature: `agents`
/// Model integrations (Gemini, etc.).
///
/// Provides LLM implementations:
/// - [`GeminiModel`](model::GeminiModel) - Google's Gemini models
///
/// ADK is model-agnostic - implement the [`Llm`] trait for other providers.
///
/// Available with feature: `models`
/// Tool system and built-in tools.
///
/// Give agents capabilities beyond conversation:
/// - `FunctionTool` - Wrap async functions as tools
/// - `GoogleSearchTool` - Web search
/// - `ExitLoopTool` - Control loop agents
/// - `McpToolset` - MCP server integration with the `mcp` feature
/// - `CodeTool` / `PythonCodeTool` / `JavaScriptCodeTool` / `MontyPythonCodeTool` -
/// Code execution with the `code-tools` feature (included in `full`); the
/// embedded live paths need `code-embedded-js` / `code-embedded-python`
///
/// Available with feature: `tools`
/// AgentSkills parsing, indexing, and runtime injection helpers.
///
/// Provides:
/// - Skill file discovery from `.skills/`
/// - Frontmatter validation (`name`, `description`)
/// - Lexical skill selection
/// - Runner plugin helper for skill injection
///
/// Available with feature: `skills`
/// Session management.
///
/// Manage conversation context and state:
/// - [`InMemorySessionService`](session::InMemorySessionService) - In-memory sessions
/// - Session creation, retrieval, and lifecycle
/// - State management with scoped prefixes
///
/// Available with feature: `sessions`
/// Artifact storage.
///
/// Store and retrieve binary data:
/// - [`InMemoryArtifactService`](artifact::InMemoryArtifactService) - In-memory storage
/// - Version tracking for artifacts
/// - Namespace scoping
///
/// Available with feature: `artifacts`
/// Memory system with semantic search.
///
/// Long-term memory for agents:
/// - [`InMemoryMemoryService`](memory::InMemoryMemoryService) - In-memory storage
/// - Semantic search capabilities
/// - Memory retrieval and updates
///
/// Available with feature: `memory`
/// Agent execution runtime.
///
/// The engine that manages agent execution:
/// - [`Runner`](runner::Runner) - Executes agents with full context
/// - [`RunnerConfig`](runner::RunnerConfig) - Configuration options
/// - Event streaming and tool coordination
///
/// Available with feature: `runner`
/// HTTP server (REST + A2A).
///
/// Deploy agents as web services:
/// - REST API for chat interactions
/// - A2A (Agent-to-Agent) protocol support
/// - Routes of your own beside them, such as the web home of `adk-surface`
///
/// Available with feature: `server`
/// Telemetry (OpenTelemetry integration).
///
/// Production observability:
/// - Distributed tracing
/// - Metrics collection
/// - Log correlation
///
/// Available with feature: `telemetry`
/// Deployment tooling (Agent Engine BYOC deployment client).
///
/// Host-side utilities for deploying agents:
/// - `deploy::gcp` — create, poll, get, and delete ReasoningEngines
///
/// Available with feature: `gcp-deploy`
/// Graph-based workflow engine (LangGraph-inspired).
///
/// Build complex agent workflows with:
/// - [`StateGraph`](graph::StateGraph) - Graph builder with nodes and edges
/// - [`GraphAgent`](graph::GraphAgent) - ADK Agent integration
/// - [`Checkpointer`](graph::Checkpointer) - Persistent state for human-in-the-loop
/// - [`Router`](graph::Router) - Conditional edge routing helpers
/// - Cycle support with recursion limits
/// - Streaming execution modes
///
/// Available with feature: `graph`
/// Graph, auth, and v8 wire contracts for safe computer-use orchestration.
///
/// Available with feature: `computer-use` (included in `standard`).
/// Agent Client Protocol: external ACP agents as tools, and ADK agents as ACP agents.
///
/// - [`AcpAgentTool`](acp::AcpAgentTool) - An external ACP agent (Claude Code, Codex,
/// Kiro CLI) as a tool
/// - [`AcpSession`](acp::AcpSession) - A persistent session with an external ACP agent
/// - [`AcpConnection`](acp::AcpConnection) - One external ACP agent shared by several
/// sessions, with listing, loading, forking, archiving and authentication
/// - [`agent_client_protocol`](acp::agent_client_protocol) - The official ACP SDK
///
/// Exposing an ADK agent over ACP needs `adk-acp`'s `server` feature.
///
/// Available with feature: `acp`
///
/// # Example
///
/// ```rust
/// use adk_rust::acp::AcpAgentTool;
///
/// let reviewer = AcpAgentTool::new("claude-code --acp")
/// .name("code_reviewer")
/// .description("Reviews a change and reports problems");
/// ```
/// Agentic Web Protocol: discovery, capability manifests, trust, consent, and events for
/// agent-facing websites.
///
/// Available with feature: `awp`
/// Code execution substrate (experimental — `full` preset).
///
/// First-class code execution for agents and generated projects:
/// - [`CodeExecutor`](code::CodeExecutor) - Backend trait for execution
/// - [`ExecutionRequest`](code::ExecutionRequest) - Typed execution request
/// - [`ExecutionResult`](code::ExecutionResult) - Structured execution result
/// - [`SandboxPolicy`](code::SandboxPolicy) - Sandbox capability model
/// - [`Workspace`](code::Workspace) - Collaborative project context
///
/// Available with feature: `code`
/// Python `CodeRuntime` for the CodeActAgent, backed by the Monty interpreter
/// (experimental).
///
/// Lets a [`CodeActAgent`](agent::codeact::CodeActAgent) act by writing Python:
/// - [`MontyRuntime`](codeact_monty::MontyRuntime) - The `CodeRuntime` implementation
/// - [`OsAccess`](codeact_monty::OsAccess) - Host-granted filesystem/environment/clock policy
/// - [`PathAccess`](codeact_monty::PathAccess) - Read-only / read-write mount modes
///
/// Available with feature: `codeact-monty` (implies `codeact`)
/// Isolated code execution runtime (experimental — `full` preset).
///
/// Provides the [`SandboxBackend`](sandbox::SandboxBackend) trait and built-in backends:
/// - [`ProcessBackend`](sandbox::ProcessBackend) - Subprocess execution with timeout and env isolation
/// - `WasmBackend` - In-process WASM execution via wasmtime (requires `wasm` feature)
/// - [`SandboxTool`](sandbox::SandboxTool) - Tool trait implementation for agent integration
///
/// Available with feature: `sandbox`
/// Lightweight console launcher — always available with the `runner` feature.
///
/// When the `cli` feature is enabled, this is replaced by the full-featured
/// `adk_cli::Launcher` with `--serve` mode, readline history, and thinking
/// block rendering.
pub use Launcher;
/// Full-featured CLI launcher with console and serve modes.
///
/// Requires the `cli` feature, which no tier includes; add it to any preset.
/// Provides `--serve` mode, `rustyline` history, and `clap` CLI parsing.
pub use Launcher;
/// Real-time bidirectional streaming (voice, video).
///
/// Provides real-time audio/video streaming for voice-enabled agents:
/// - [`RealtimeAgent`](realtime::RealtimeAgent) - Agent with voice capabilities
/// - [`RealtimeRunner`](realtime::RealtimeRunner) - Session management and tool execution
/// - Multiple providers: OpenAI Realtime, Gemini Live
///
/// Available with feature: `realtime`
/// Browser automation (WebDriver).
///
/// Provides browser automation tools for agents:
/// - [`BrowserSession`](browser::BrowserSession) - WebDriver session management
/// - [`BrowserToolset`](browser::BrowserToolset) - Browser tools for agents
///
/// Available with feature: `browser`
/// Agent evaluation framework.
///
/// Test and validate agent behavior:
/// - [`Evaluator`](eval::Evaluator) - Run evaluation suites
/// - [`EvaluationConfig`](eval::EvaluationConfig) - Configure evaluation parameters
///
/// Available with feature: `eval`
/// Guardrails for safety and policy enforcement.
///
/// Validate agent inputs and outputs:
/// - [`GuardrailSet`](guardrail::GuardrailSet) - Collection of guardrails
/// - [`ContentFilter`](guardrail::ContentFilter) - Content safety filtering
///
/// Available with feature: `guardrail`
/// Authentication and access control.
///
/// Manage agent permissions and identity:
/// - [`Permission`](auth::Permission) - Permission definitions
/// - [`AccessControl`](auth::AccessControl) - Access control enforcement
///
/// Available with feature: `auth`
/// Agentic commerce and payment orchestration.
///
/// Provides protocol-neutral payment primitives and adapters for:
/// - ACP stable `2026-01-30`
/// - ACP experimental surfaces behind `acp-experimental`
/// - AP2 `v0.1-alpha` as of `2026-03-22`
///
/// Available with feature: `payments`
/// Plugin system for extending agent behavior.
///
/// Extensible callback architecture for agent lifecycle hooks:
/// - Plugin registration and discovery
/// - Before/after hooks for agent operations
///
/// Available with feature: `plugin`
/// Audio processing pipeline (experimental — `full` preset).
///
/// Provides audio capabilities for agents:
/// - [`TtsProvider`](audio::TtsProvider) - Text-to-speech synthesis
/// - [`SttProvider`](audio::SttProvider) - Speech-to-text transcription
/// - [`AudioProcessor`](audio::AudioProcessor) - Audio effects processing
/// - `AudioPipeline` - Composable audio pipelines
/// - Cloud providers: ElevenLabs, OpenAI, Gemini, Cartesia, Deepgram, AssemblyAI
/// - Local inference: MLX (Apple Silicon), ONNX Runtime
///
/// Available with feature: `audio`
/// Retrieval-Augmented Generation (RAG) pipeline.
///
/// Modular RAG system with trait-based components:
/// - [`RagPipeline`](rag::RagPipeline) - Orchestrates ingest and query workflows
/// - [`RagTool`](rag::RagTool) - Agentic retrieval via `Tool` trait
/// - [`InMemoryVectorStore`](rag::InMemoryVectorStore) - Zero-dependency vector store
/// - Chunking strategies: fixed-size, recursive, markdown-aware
/// - Feature-gated backends: Gemini, OpenAI, Qdrant, LanceDB, pgvector
///
/// Available with feature: `rag`
/// Shared action node types for graph workflows.
///
/// Provides the type definitions for all 14 action node types:
/// - Trigger nodes (manual, webhook, schedule, event)
/// - Data nodes (HTTP, Set, Transform)
/// - Control flow nodes (Switch, Loop, Merge, Wait)
/// - Compute nodes (Code)
/// - Infrastructure nodes (Database)
/// - Communication nodes (Email, Notification, RSS, File)
///
/// Available with feature: `action`
pub use adk_action;
/// Anthropic API client types and HTTP client.
///
/// Direct access to the `adk-anthropic` crate for low-level Anthropic API usage:
/// - [`Anthropic`](anthropic_client::Anthropic) - HTTP client struct
/// - Wire types: `MessageCreateParams`, `Message`, `ContentBlock`, etc.
/// - Streaming: `MessageStreamEvent`, `ContentBlockDelta`
/// - Error handling: `Error` enum with typed variants
///
/// For high-level agent usage, prefer `adk-model`'s `AnthropicClient` instead.
///
/// Available with feature: `anthropic-client`
/// Local inference in process through mistral.rs, with no separate model server.
///
/// Everything `adk-mistralrs` exports:
/// - [`MistralRsModel`](mistralrs::MistralRsModel) - Text models implementing [`Llm`], with
/// tool calling for an `LlmAgent`, streamed or not
/// - [`MistralRsConfig`](mistralrs::MistralRsConfig), [`ModelSource`](mistralrs::ModelSource),
/// [`QuantizationLevel`](mistralrs::QuantizationLevel) - Loading from safetensors or GGUF,
/// in-situ quantization, and [`DeviceConfig`](mistralrs::DeviceConfig) layer ranges across GPUs
/// - [`MistralRsAdapterModel`](mistralrs::MistralRsAdapterModel) - LoRA and X-LoRA adapters
/// - [`MistralRsVisionModel`](mistralrs::MistralRsVisionModel),
/// [`MistralRsEmbeddingModel`](mistralrs::MistralRsEmbeddingModel),
/// [`MistralRsSpeechModel`](mistralrs::MistralRsSpeechModel),
/// [`MistralRsDiffusionModel`](mistralrs::MistralRsDiffusionModel) - Other modalities
/// - [`MistralRsMultiModel`](mistralrs::MistralRsMultiModel) - Several models served by name
///
/// GPU support comes from `adk-mistralrs`'s own `cuda` and `metal` features, and
/// `McpClientConfig::connect`, which connects MCP servers as governed toolsets, from its `mcp`
/// feature.
///
/// Available with feature: `mistralrs`
///
/// # Example
///
/// ```rust,no_run
/// use adk_rust::mistralrs::{MistralRsConfig, MistralRsModel, ModelSource, QuantizationLevel};
///
/// # #[tokio::main]
/// # async fn main() -> adk_rust::mistralrs::Result<()> {
/// let config = MistralRsConfig::builder()
/// .model_source(ModelSource::huggingface("Qwen/Qwen3-4B"))
/// .isq(QuantizationLevel::Q4K)
/// .build();
/// let model = MistralRsModel::new(config).await?;
/// # let _ = model;
/// # Ok(())
/// # }
/// ```
// ============================================================================
// v0.7.0 Competitive Parity Feature Re-exports (opt-in only)
// ============================================================================
// --- adk-server features ---
/// YAML agent configuration loader and hot reload watcher.
///
/// Declaratively define agents in YAML files with hot reload support:
/// - [`YamlAgentDefinition`](server::yaml_agent::YamlAgentDefinition) - YAML schema types
/// - [`AgentConfigLoader`](server::yaml_agent::AgentConfigLoader) - Load and validate YAML agent files
/// - [`HotReloadWatcher`](server::yaml_agent::HotReloadWatcher) - Watch for file changes and reload agents
///
/// Available with feature: `yaml-agent`
/// Agent Registry REST API for agent discovery and management.
///
/// Register, discover, and manage agents through a REST API:
/// - [`AgentCard`](server::registry::AgentCard) - Agent metadata
/// - [`AgentRegistryStore`](server::registry::AgentRegistryStore) - Storage backend trait
/// - [`InMemoryAgentRegistryStore`](server::registry::InMemoryAgentRegistryStore) - In-memory storage
/// - [`registry_router`](server::registry::registry_router) - Axum router for registry endpoints
///
/// Available with feature: `server`
// --- adk-tool features ---
/// MCP sampling callback support.
///
/// Handle `sampling/createMessage` requests from MCP servers:
/// - [`SamplingHandler`](tool::sampling::SamplingHandler) - Trait for handling sampling requests
/// - [`LlmSamplingHandler`](tool::sampling::LlmSamplingHandler) - Default handler routing to agent's LLM
/// - [`SamplingRequest`](tool::sampling::SamplingRequest) / [`SamplingResponse`](tool::sampling::SamplingResponse) - Wire types
///
/// Available with feature: `mcp-sampling`
/// Native Slack toolset for agent-driven Slack interactions.
///
/// Built-in Slack tools for agents:
/// - [`SlackToolset`](tool::slack::SlackToolset) - Toolset implementing `adk_core::Toolset`
/// - Tools: `slack_send_message`, `slack_read_channel`, `slack_add_reaction`, `slack_list_threads`
///
/// Available with feature: `slack`
/// Native BigQuery toolset for data-analysis agents.
///
/// Built-in BigQuery tools for agents:
/// - [`BigQueryToolset`](tool::bigquery::BigQueryToolset) - Toolset implementing `adk_core::Toolset`
/// - Tools: `bigquery_execute_sql`, `bigquery_get_table_schema`, `bigquery_list_datasets`, `bigquery_list_tables`
///
/// Available with feature: `bigquery`
/// Native Spanner toolset for Cloud Spanner interactions.
///
/// Built-in Spanner tools for agents:
/// - [`SpannerToolset`](tool::spanner::SpannerToolset) - Toolset implementing `adk_core::Toolset`
/// - Tools: `spanner_execute_sql`, `spanner_get_table_schema`, `spanner_list_tables`
///
/// Available with feature: `spanner`
// --- adk-eval features ---
/// User personas for evaluation.
///
/// Define simulated user personas for realistic multi-turn test conversations:
/// - [`PersonaProfile`](eval::personas::PersonaProfile) - Persona definition
/// - [`UserSimulator`](eval::personas::UserSimulator) - Generate persona-driven messages
/// - [`PersonaRegistry`](eval::personas::PersonaRegistry) - Load personas from directory
///
/// Available with feature: `eval`
// --- adk-realtime features ---
/// Video avatar configuration for realtime sessions.
///
/// Attach a video avatar to realtime voice agents:
/// - [`AvatarConfig`](realtime::avatar::AvatarConfig) - Avatar source, lip-sync, and rendering settings
/// - [`LipSyncConfig`](realtime::avatar::LipSyncConfig) - Lip-sync configuration
/// - [`RenderingConfig`](realtime::avatar::RenderingConfig) - Rendering parameters
///
/// Available with feature: `video-avatar`
// ============================================================================
// Managed Agent Runtime (feature-gated, experimental)
// ============================================================================
/// Managed agent runtime — durable, resumable, provider-neutral agent execution.
///
/// Provides the `ManagedAgentRuntime` trait and `DefaultManagedAgentRuntime`:
/// - [`ManagedAgentRuntime`](managed::ManagedAgentRuntime) - Central lifecycle trait
/// - [`DefaultManagedAgentRuntime`](managed::DefaultManagedAgentRuntime) - Default implementation
/// - [`ManagedAgentDef`](managed::types::ManagedAgentDef) - Declarative agent definition
/// - [`SessionEvent`](managed::types::SessionEvent) - Provider-neutral event stream
/// - [`UserEvent`](managed::types::UserEvent) - Client-to-agent events
/// - [`ModelResolver`](managed::ModelResolver) - ModelRef → Arc<dyn Llm> resolution
/// - [`ScriptedLlm`](managed::ScriptedLlm) - Deterministic testing double
///
/// STABILITY: Experimental, additive, feature-gated. No breaking changes to
/// existing `Runner`/`LlmAgent` APIs when this feature is disabled.
///
/// Available with feature: `managed-runtime`
/// The governed, durable harness agent (spec 3.1 §8.4).
///
/// Everything `adk-harness` exports: [`HarnessAgent`](harness::HarnessAgent) and its
/// builder, the modes, standing approvals, the shell, todos, instructions, skills, team
/// members, plan graphs and goals. With the `cli` feature it also re-exports the CLI's
/// `HarnessLauncher`, which runs a harness at the console or behind the server,
/// `ConsolePrompter`, which asks for approvals at the terminal, and the `ConsoleIo` it
/// reads from.
///
/// Available with feature: `harness` (included in `enterprise` and `full`)
///
/// # Example
///
/// ```rust
/// use adk_rust::harness::{HarnessAgent, HarnessMode, InstructionsConfig, Workspace};
/// use adk_rust::model::{ScriptedLlm, ScriptedResponse};
/// use std::sync::Arc;
///
/// # fn main() -> adk_rust::Result<()> {
/// let model = Arc::new(ScriptedLlm::new("scripted", vec![ScriptedResponse::text("done")]));
/// let harness = HarnessAgent::builder("harness")
/// .model(model)
/// .workspace(Workspace::new(std::env::temp_dir()))
/// .project_instructions(InstructionsConfig { user_file: None, ..InstructionsConfig::default() })
/// .mode(HarnessMode::Plan)
/// .build()?;
/// assert_eq!(harness.info().default_mode, HarnessMode::Plan);
/// # Ok(())
/// # }
/// ```
/// The agent kernel, the always-on form of the harness (spec 3.2 §8.2).
///
/// Everything `adk-kernel` exports: the [`Kernel`](kernel::Kernel) supervisor and its
/// builder, the process table, wake sources, the event bus and the
/// [`control`](kernel::control) plane `adk-rust up` serves.
///
/// Available with feature: `harness-kernel` (included in `enterprise` and `full`)
///
/// # Example
///
/// ```rust
/// use std::sync::Arc;
/// use adk_rust::kernel::{Kernel, KernelConfig, QueueClass};
///
/// let kernel = Kernel::builder()
/// .config(KernelConfig::default().with_app_name("ops"))
/// .run_store(Arc::new(adk_rust::InMemoryRunStore::new()))
/// .build()
/// .unwrap();
/// assert_eq!(kernel.config().queues, QueueClass::defaults());
/// ```
/// Local-first perception for agents (spec 3.7).
///
/// Everything `adk-vision` exports: artifact-backed images, regions in source pixels with
/// their transform chains, model manifests pinned by revision and SHA-256, the perception
/// traits and [`VisionRuntime`](vision::VisionRuntime), the [`EgressGate`](vision::EgressGate)
/// a remote backend's every image passes, the governed [`VisionToolset`](vision::VisionToolset),
/// the cloud describers and Meta `sam-3.1`. With `harness`, `pack_vision` gives a harness the
/// vision pack.
///
/// Available with feature: `vision` (included in `full`); the on-device backends with
/// `vision-local`
///
/// # Example
///
/// ```rust
/// use adk_rust::vision::{BBox, DecodedImage, SourceImage, Transform, TransformChain};
///
/// // A 3024×1964 screenshot, cropped and downscaled before a model sees it: a box the model
/// // answers in its own pixels maps back to the screenshot's.
/// let chain = TransformChain::new(3024, 1964)
/// .then(Transform::Crop { x: 1000, y: 500, width: 800, height: 600 })
/// .unwrap()
/// .then(Transform::Resize { width: 400, height: 300 })
/// .unwrap();
/// let source = chain.bbox_to_source(&BBox::new(10.0, 10.0, 110.0, 60.0));
/// assert_eq!(source, BBox::new(1020.0, 520.0, 1220.0, 620.0));
///
/// let page = SourceImage::from_pixels(DecodedImage::filled(64, 64, [255; 4])).unwrap();
/// assert!(page.digest().to_string().starts_with("sha256:"));
/// ```
/// Agent surfaces: the engine every surface runs on, and the web home (spec 3.3).
///
/// Everything `adk-surface` exports: the [`SurfaceEngine`](surface::SurfaceEngine) with its
/// sources, decision cards in the words of spec 3.3 §8, the rules of what each surface may
/// decide, [`web::router`](surface::web::router) for `ServerBuilder::add_api_routes`, and
/// [`web::home`](surface::web::home), the page, for `ServerBuilder::add_root_routes`.
///
/// Available with feature: `surface` (opt-in, in no tier)
///
/// # Example
///
/// ```rust
/// use adk_rust::surface::{Caller, Origin, SurfaceKind, rules};
///
/// let chat = Caller::human("ana", SurfaceKind::Chat, Origin::Chat { channel: "Telegram".into() });
/// assert!(!rules::may_resume(&chat));
/// ```
/// The AWP 2.0 website product (spec 3.5 Part C, §7.1, D-14): site kinds and their charter
/// templates, the team of eight agents, onboarding, jobs, incidents, alarms and the weekly
/// review.
///
/// Available with feature: `website` (in `full`).
///
/// # Example
///
/// ```rust
/// use adk_rust::website::onboarding::{StartingPoint, plan};
///
/// // The onboarding plan for a site that starts from nothing.
/// let steps = plan(&StartingPoint::Nothing, None);
/// assert!(!steps.is_empty());
/// ```
/// The site pipeline of an AWP 2.0 website (spec 3.5 §7.8): content as files, the built-in
/// generator, the launch gate, signed releases in the site log, hosts, migration and freeze.
///
/// Available with feature: `website` (in `full`).
///
/// # Example
///
/// ```rust
/// use adk_rust::site::content::SiteConfig;
///
/// let config = SiteConfig::from_toml("name = \"Example\"\ndomain = \"example.com\"\nlanguages = [\"en\"]\n").unwrap();
/// assert_eq!(config.base_url(), "https://example.com");
/// ```
// ============================================================================
// Enterprise Client SDK (feature-gated, experimental)
// ============================================================================
/// Enterprise client SDK — native Rust client for the ADK-Rust Enterprise
/// Managed Agent Service.
///
/// Provides `EnterpriseClient` for interacting with the platform over HTTP/SSE:
/// - [`EnterpriseClient`](enterprise::EnterpriseClient) - Primary API client
/// - [`ClientConfig`](enterprise::ClientConfig) - Client configuration
/// - Agent, Environment, and Session CRUD
/// - SSE event streaming with auto-reconnect
/// - Vault and Memory management (beta)
///
/// This crate has zero dependency on `adk-model`, `adk-runner`, or `adk-agent` —
/// it communicates exclusively via HTTP with the managed agent platform.
///
/// STABILITY: Experimental, additive, feature-gated.
///
/// Available with feature: `enterprise-client`
pub use adk_enterprise;
// ============================================================================
// Convenience Functions
// ============================================================================
/// Detect LLM provider from environment variables.
///
/// Checks environment variables in precedence order and returns the first
/// matching provider that was compiled through Cargo features. The default
/// `minimal` tier detects Gemini via `GOOGLE_API_KEY`; add `openai` or
/// `anthropic` to widen detection.
///
/// 1. `GOOGLE_GENAI_USE_ENTERPRISE` / `GOOGLE_GENAI_USE_VERTEXAI` truthy
/// (`1` or case-insensitive `true`) → Gemini on Vertex AI via Application
/// Default Credentials, using `GOOGLE_CLOUD_PROJECT` and
/// `GOOGLE_CLOUD_LOCATION` (requires the `gemini-vertex` feature;
/// `GOOGLE_GENAI_USE_ENTERPRISE` takes precedence when both are set)
/// 2. `ANTHROPIC_API_KEY` → Anthropic (Claude)
/// 3. `OPENAI_API_KEY` → OpenAI
/// 4. `GOOGLE_API_KEY` → Gemini
///
/// When a Vertex flag is truthy but the `gemini-vertex` feature is not
/// compiled, a `tracing` warning is emitted and detection falls through to
/// the API-key steps, which may select the Gemini Studio endpoint
/// (`generativelanguage.googleapis.com`).
///
/// # Errors
///
/// Returns [`AdkError`] when no supported environment variable is set, or
/// when a Vertex flag is truthy but `GOOGLE_CLOUD_PROJECT` /
/// `GOOGLE_CLOUD_LOCATION` is missing.
///
/// # Example
///
/// ```rust,ignore
/// use adk_rust::provider_from_env;
/// use std::sync::Arc;
///
/// let model: Arc<dyn adk_rust::Llm> = provider_from_env()?;
/// ```
/// High-level single-turn agent invocation.
///
/// Creates an agent with the given instructions, sends the input, and returns
/// the text response. Detects the provider from `ANTHROPIC_API_KEY`, then
/// `OPENAI_API_KEY`, then `GOOGLE_API_KEY` (Gemini on AI Studio), among the
/// providers compiled in. Unlike [`provider_from_env`], it does not read the
/// Vertex AI flags.
///
/// This is the fastest way to get started with ADK — a single function call
/// that handles provider selection, session creation, agent building, and
/// execution.
///
/// # Arguments
///
/// * `instructions` - System instructions for the agent
/// * `input` - User input to send to the agent
///
/// # Returns
///
/// The agent's text response as a `String`.
///
/// # Errors
///
/// Returns [`AdkError`] when no supported environment variable is set, or
/// when agent execution fails.
///
/// # Example
///
/// ```rust,ignore
/// use adk_rust::run;
///
/// let response = run("You are a helpful assistant.", "What is 2 + 2?").await?;
/// println!("{response}");
/// ```
pub async
// ============================================================================
// Prelude
// ============================================================================
/// Convenience prelude for common imports.
///
/// Import everything you need with a single line:
///
/// ```
/// use adk_rust::prelude::*;
/// ```
///
/// This includes:
/// - Core traits: `Agent`, `Tool`, `Llm`, `Session`
/// - Agent builders: `LlmAgentBuilder`, `CustomAgentBuilder`
/// - Workflow agents: `SequentialAgent`, `ParallelAgent`, `LoopAgent`
/// - Models: `GeminiModel`
/// - Tools: `FunctionTool`, `GoogleSearchTool`, `McpToolset`
/// - Services: `InMemorySessionService`, `InMemoryArtifactService`
/// - Runtime: `Runner`, `RunnerConfig`
/// - Harness (feature `harness`): `HarnessAgent`, `HarnessAgentBuilder`, `HarnessMode`
/// - Common types: `Arc`, `Result`, `Content`, `Event`