rs-adk 0.5.0

Agent runtime for Gemini Live — tools, streaming, agent transfer, middleware
Documentation
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
// AUTO-GENERATED by adk-transpiler -- do not edit manually
// Source: adk-js
// Generated: 2026-03-02T01:19:11Z

#![allow(dead_code, unused_imports, clippy::type_complexity)]

use crate::context::AgentEvent;
use crate::{Agent, AgentError, InvocationContext, ToolFunction};
use async_trait::async_trait;
use std::sync::Arc;

// BaseAgent — base class, fields merged into child agents via inheritance.

// ---- LlmAgent ----

/// The configuration options for creating an LLM-based agent.
/// (Inherits fields from BaseAgent)
// Cannot derive Clone: contains trait objects
pub struct LlmAgentConfig {
    pub name: String,
    /// The model to use for the agent.
    pub model: Option<String>,
    /// Instructions for the LLM model, guiding the agent's behavior.
    pub instruction: Option<String>,
    /// Instructions for all the agents in the entire agent tree. ONLY the globalInstruction in root agent will take effect. For example: use globalInstruction to make all agents have a stable identity or personality.
    pub global_instruction: Option<String>,
    /// Tools available to this agent.
    pub tools: Option<Vec<Arc<dyn ToolFunction>>>,
    /// The additional content generation configurations. NOTE: not all fields are usable, e.g. tools must be configured via `tools`, thinking_config must be configured via `planner` in LlmAgent. For example: use this config to adjust model temperature, configure safety settings, etc.
    pub generate_content_config: Option<serde_json::Value>,
    /// Disallows LLM-controlled transferring to the parent agent. NOTE: Setting this as True also prevents this agent to continue reply to the end-user. This behavior prevents one-way transfer, in which end-user may be stuck with one agent that cannot transfer to other agents in the agent tree.
    pub disallow_transfer_to_parent: Option<bool>,
    /// Disallows LLM-controlled transferring to the peer agents.
    pub disallow_transfer_to_peers: Option<bool>,
    /// Controls content inclusion in model requests. Options:   default: Model receives relevant conversation history   none: Model receives no prior history, operates solely on current   instruction and input
    pub include_contents: Option<String>,
    /// The input schema when agent is used as a tool.
    pub input_schema: Option<serde_json::Value>,
    /// The output schema when agent replies.
    pub output_schema: Option<serde_json::Value>,
    /// The key in session state to store the output of the agent. Typically use cases: - Extracts agent reply for later use, such as in tools, callbacks, etc. - Connects agents to coordinate with each other.
    pub output_key: Option<String>,
    /// Processors to run before the LLM request is sent.
    pub request_processors: Option<Vec<serde_json::Value>>,
    /// Processors to run after the LLM response is received.
    pub response_processors: Option<Vec<serde_json::Value>>,
    /// Instructs the agent to make a plan and execute it step by step.
    pub code_executor: Option<serde_json::Value>,
    pub description: Option<String>,
    pub parent_agent: Option<Arc<dyn Agent>>,
    pub sub_agents: Option<Vec<Arc<dyn Agent>>>,
    /// Callbacks to be called before calling the LLM.
    pub before_model_callback: Option<Box<dyn Fn(&InvocationContext) + Send + Sync>>,
    /// Callbacks to be called after calling the LLM.
    pub after_model_callback: Option<Box<dyn Fn(&InvocationContext) + Send + Sync>>,
    /// Callbacks to be called before calling the tool.
    pub before_tool_callback: Option<Box<dyn Fn(&InvocationContext) + Send + Sync>>,
    /// Callbacks to be called after calling the tool.
    pub after_tool_callback: Option<Box<dyn Fn(&InvocationContext) + Send + Sync>>,
    pub before_agent_callback: Option<Box<dyn Fn(&InvocationContext) + Send + Sync>>,
    pub after_agent_callback: Option<Box<dyn Fn(&InvocationContext) + Send + Sync>>,
}

impl LlmAgentConfig {
    pub fn new(name: impl Into<String>) -> Self {
        Self {
            name: name.into(),
            model: None,
            instruction: None,
            global_instruction: None,
            tools: None,
            generate_content_config: None,
            disallow_transfer_to_parent: None,
            disallow_transfer_to_peers: None,
            include_contents: None,
            input_schema: None,
            output_schema: None,
            output_key: None,
            request_processors: None,
            response_processors: None,
            code_executor: None,
            description: None,
            parent_agent: None,
            sub_agents: None,
            before_model_callback: None,
            after_model_callback: None,
            before_tool_callback: None,
            after_tool_callback: None,
            before_agent_callback: None,
            after_agent_callback: None,
        }
    }
}

pub struct LlmAgentBuilder {
    config: LlmAgentConfig,
}

impl LlmAgentBuilder {
    pub fn new(name: impl Into<String>) -> Self {
        Self {
            config: LlmAgentConfig::new(name),
        }
    }

    pub fn model(mut self, value: String) -> Self {
        self.config.model = Some(value);
        self
    }

    pub fn instruction(mut self, value: String) -> Self {
        self.config.instruction = Some(value);
        self
    }

    pub fn global_instruction(mut self, value: String) -> Self {
        self.config.global_instruction = Some(value);
        self
    }

    pub fn tools(mut self, value: Vec<Arc<dyn ToolFunction>>) -> Self {
        self.config.tools = Some(value);
        self
    }

    pub fn generate_content_config(mut self, value: serde_json::Value) -> Self {
        self.config.generate_content_config = Some(value);
        self
    }

    pub fn disallow_transfer_to_parent(mut self, value: bool) -> Self {
        self.config.disallow_transfer_to_parent = Some(value);
        self
    }

    pub fn disallow_transfer_to_peers(mut self, value: bool) -> Self {
        self.config.disallow_transfer_to_peers = Some(value);
        self
    }

    pub fn include_contents(mut self, value: String) -> Self {
        self.config.include_contents = Some(value);
        self
    }

    pub fn input_schema(mut self, value: serde_json::Value) -> Self {
        self.config.input_schema = Some(value);
        self
    }

    pub fn output_schema(mut self, value: serde_json::Value) -> Self {
        self.config.output_schema = Some(value);
        self
    }

    pub fn output_key(mut self, value: String) -> Self {
        self.config.output_key = Some(value);
        self
    }

    pub fn request_processors(mut self, value: Vec<serde_json::Value>) -> Self {
        self.config.request_processors = Some(value);
        self
    }

    pub fn response_processors(mut self, value: Vec<serde_json::Value>) -> Self {
        self.config.response_processors = Some(value);
        self
    }

    pub fn code_executor(mut self, value: serde_json::Value) -> Self {
        self.config.code_executor = Some(value);
        self
    }

    pub fn description(mut self, value: String) -> Self {
        self.config.description = Some(value);
        self
    }

    pub fn parent_agent(mut self, value: Arc<dyn Agent>) -> Self {
        self.config.parent_agent = Some(value);
        self
    }

    pub fn sub_agents(mut self, value: Vec<Arc<dyn Agent>>) -> Self {
        self.config.sub_agents = Some(value);
        self
    }

    pub fn build(self) -> LlmAgent {
        LlmAgent {
            config: self.config,
        }
    }
}

pub struct LlmAgent {
    pub config: LlmAgentConfig,
}

// Agent trait impl for LlmAgent should be provided by the application.

// ---- LoopAgent ----

/// The configuration options for creating a loop agent.
/// (Inherits fields from BaseAgent)
// Cannot derive Clone: contains trait objects
pub struct LoopAgentConfig {
    pub name: String,
    /// The maximum number of iterations the loop agent will run. If not provided, the loop agent will run indefinitely.
    pub max_iterations: Option<f64>,
    pub description: Option<String>,
    pub parent_agent: Option<Arc<dyn Agent>>,
    pub sub_agents: Option<Vec<Arc<dyn Agent>>>,
    pub before_agent_callback: Option<Box<dyn Fn(&InvocationContext) + Send + Sync>>,
    pub after_agent_callback: Option<Box<dyn Fn(&InvocationContext) + Send + Sync>>,
}

impl LoopAgentConfig {
    pub fn new(name: impl Into<String>) -> Self {
        Self {
            name: name.into(),
            max_iterations: None,
            description: None,
            parent_agent: None,
            sub_agents: None,
            before_agent_callback: None,
            after_agent_callback: None,
        }
    }
}

pub struct LoopAgentBuilder {
    config: LoopAgentConfig,
}

impl LoopAgentBuilder {
    pub fn new(name: impl Into<String>) -> Self {
        Self {
            config: LoopAgentConfig::new(name),
        }
    }

    pub fn max_iterations(mut self, value: f64) -> Self {
        self.config.max_iterations = Some(value);
        self
    }

    pub fn description(mut self, value: String) -> Self {
        self.config.description = Some(value);
        self
    }

    pub fn parent_agent(mut self, value: Arc<dyn Agent>) -> Self {
        self.config.parent_agent = Some(value);
        self
    }

    pub fn sub_agents(mut self, value: Vec<Arc<dyn Agent>>) -> Self {
        self.config.sub_agents = Some(value);
        self
    }

    pub fn build(self) -> LoopAgent {
        LoopAgent {
            config: self.config,
        }
    }
}

pub struct LoopAgent {
    pub config: LoopAgentConfig,
}

#[async_trait]
impl Agent for LoopAgent {
    fn name(&self) -> &str {
        &self.config.name
    }

    fn sub_agents(&self) -> Vec<Arc<dyn Agent>> {
        self.config.sub_agents.clone().unwrap_or_default()
    }

    async fn run_live(&self, ctx: &mut InvocationContext) -> Result<(), AgentError> {
        let inner = crate::agents::loop_agent::LoopAgent::new(
            &self.config.name,
            self.sub_agents(),
            self.config.max_iterations.map(|v| v as u32).unwrap_or(10),
        );
        inner.run_live(ctx).await
    }
}

// ---- ActiveStreamingToolParams ----

/// The parameters for creating an ActiveStreamingTool.
#[derive(Debug, Clone, Default)]
pub struct ActiveStreamingToolParams {
    pub task: Option<serde_json::Value>,
    pub stream: Option<serde_json::Value>,
}

// ---- AgentTool ----

/// The configuration of the agent tool.
// Cannot derive Clone: contains trait objects
pub struct AgentTool {
    /// The reference to the agent instance.
    pub agent: Arc<dyn Agent>,
    /// Whether to skip summarization of the agent output.
    pub skip_summarization: Option<bool>,
}

// ---- Auth ----

/// The auth config sent by tool asking client to collect auth credentials and adk and client will help to fill in the response.
#[derive(Debug, Clone, Default)]
pub struct Auth {
    /// The auth scheme used to collect credentials
    pub auth_scheme: serde_json::Value,
    /// The raw auth credential used to collect credentials. The raw auth credentials are used in some auth scheme that needs to exchange auth credentials. e.g. OAuth2 and OIDC. For other auth scheme, it could be undefined.
    pub raw_auth_credential: Option<serde_json::Value>,
    /// The exchanged auth credential used to collect credentials. adk and client will work together to fill it. For those auth scheme that doesn't need to exchange auth credentials, e.g. API key, service account etc. It's filled by client directly. For those auth scheme that need to exchange auth credentials, e.g. OAuth2 and OIDC, it's first filled by adk. If the raw credentials passed by tool only has client id and client credential, adk will help to generate the corresponding authorization uri and state and store the processed credential in this field. If the raw credentials passed by tool already has authorization uri, state, etc. then it's copied to this field. Client will use this field to guide the user through the OAuth2 flow and fill auth response in this field
    pub exchanged_auth_credential: Option<serde_json::Value>,
    /// A user specified key used to load and save this credential in a credential service.
    pub credential_key: String,
}

// ---- BaseToolParams ----

/// Parameters for the BaseTool constructor.
#[derive(Debug, Clone, Default)]
pub struct BaseToolParams {
    pub name: String,
    pub description: String,
    pub is_long_running: Option<bool>,
}

// ---- RunAsyncToolRequest ----

/// The parameters for `runAsync`.
#[derive(Debug, Clone, Default)]
pub struct RunAsyncToolRequest {
    pub args: serde_json::Value,
    pub tool_context: serde_json::Value,
}

// ---- ToolProcessLlmRequest ----

/// The parameters for `processLlmRequest`.
#[derive(Debug, Clone, Default)]
pub struct ToolProcessLlmRequest {
    pub tool_context: serde_json::Value,
    pub llm_request: serde_json::Value,
}

// ---- TraceMergedToolCallsParams ----

#[derive(Debug, Clone, Default)]
pub struct TraceMergedToolCallsParams {
    pub response_event_id: String,
    pub function_response_event: serde_json::Value,
}

// ---- TraceToolCallParams ----

// Cannot derive Clone: contains trait objects
pub struct TraceToolCallParams {
    pub tool: Arc<dyn ToolFunction>,
    pub args: serde_json::Value,
    pub function_response_event: serde_json::Value,
}

// ============================================================
// General type definitions extracted from ADK-JS source
// ============================================================

// ---- A2AMetadataKeys (module: a2a) ----

#[derive(Debug, Clone, PartialEq, Eq)]
pub enum A2AMetadataKeys {
    PARTIAL,
    TaskId,
    ContextId,
    ESCALATE,
    TransferToAgent,
    LongRunning,
    THOUGHT,
}

// ---- ActivityEvent (module: events) ----

/// Represents a generic activity or status update.
#[derive(Debug, Clone, Default)]
pub struct ActivityEvent {
    pub r#type: serde_json::Value,
    pub kind: String,
    pub detail: serde_json::Value,
}

// ---- ApigeeLlmParams (module: models) ----

#[derive(Debug, Clone, Default)]
pub struct ApigeeLlmParams {
    /// The name of the model to use. The model string specifies the LLM provider (e.g., Vertex AI, Gemini), API version, and the model ID. Supported format:     `apigee/[<provider>/][<version>/]<model_id>`     Components:       `provider` (optional): `vertex_ai` or `gemini`.       `version` (optional): The API version (e.g., `v1`, `v1beta`). If not         provided, a default version will selected based on the provider.       `model_id` (required): The model identifier (e.g.,         `gemini-2.5-flash`).     Examples:       - `apigee/gemini-2.5-flash`       - `apigee/v1/gemini-2.5-flash`       - `apigee/vertex_ai/gemini-2.5-flash`       - `apigee/gemini/v1/gemini-2.5-flash`       - `apigee/vertex_ai/v1beta/gemini-2.5-flash`
    pub model: String,
    /// The proxy URL for the provider API. If not provided, it will look for the APIGEE_PROXY_URL environment variable.
    pub proxy_url: Option<String>,
    /// API key to use. If not provided, it will look for the GOOGLE_GENAI_API_KEY or GEMINI_API_KEY environment variable. If gemini provider is selected and no key is provided, the fake key "-" will be used for the "x-goog-api-key" header.
    pub api_key: Option<String>,
}

// ---- AppendEventRequest (module: sessions) ----

/// The parameters for `appendEvent`.
#[derive(Debug, Clone, Default)]
pub struct AppendEventRequest {
    /// The session to append the event to.
    pub session: serde_json::Value,
    /// The event to append.
    pub event: serde_json::Value,
}

// ---- ArtifactVersion (module: artifacts) ----

/// Metadata for a file artifact version.
#[derive(Debug, Clone, Default)]
pub struct ArtifactVersion {
    /// The version number.
    pub version: f64,
    /// The canonical URI of the artifact.
    pub canonical_uri: Option<String>,
    /// Custom metadata associated with the artifact.
    pub custom_metadata: Option<serde_json::Value>,
    /// The MIME type of the artifact.
    pub mime_type: Option<String>,
}

// ---- AuthCredential (module: auth) ----

/// Data class representing an authentication credential. To exchange for the actual credential, please use CredentialExchanger.exchangeCredential(). @example // API Key Auth const authCredential: AuthCredential = {   authType: AuthCredentialTypes.API_KEY,   apiKey: "your_api_key", }; @example // HTTP Auth const authCredential: AuthCredential = {   authType: AuthCredentialTypes.HTTP,   http: {     scheme: "basic",     credentials: {       username: "user",       password: "password",     },   } } @example // OAuth2 Bearer Token in HTTP Header const authCredential: AuthCredential = {   authType: AuthCredentialTypes.HTTP,   http: {     scheme: "bearer",     credentials: {       token: "your_access_token",     },   } } @example // OAuth2 Auth with Authorization Code Flow const authCredential: AuthCredential = {   authType: AuthCredentialTypes.OAUTH2,   oauth2: {     clientId: "your_client_id",     clientSecret: "your_client_secret",   } } @example: // Open ID Connect Auth const authCredential: AuthCredential = {   authType: AuthCredentialTypes.OPEN_ID_CONNECT,   oauth2: {     clientId: "1234",     clientSecret: "secret",     redirectUri: "https://example.com",     scopes: ["scope1", "scope2"],   } } @example: // Auth with resource reference const authCredential: AuthCredential = {   authType: AuthCredentialTypes.API_KEY,   resourceRef: "projects/1234/locations/us-central1/resources/resource1" }
#[derive(Debug, Clone, Default)]
pub struct AuthCredential {
    pub auth_type: serde_json::Value,
    /// Resource reference for the credential. This will be supported in the future.
    pub resource_ref: Option<String>,
    pub api_key: Option<String>,
    pub http: Option<serde_json::Value>,
    pub service_account: Option<serde_json::Value>,
    pub oauth2: Option<serde_json::Value>,
}

// ---- AuthToolArguments (module: auth) ----

/// The arguments for the special long running function tool that is used to request end user credentials.
#[derive(Debug, Clone, Default)]
pub struct AuthToolArguments {
    pub function_call_id: String,
    pub auth_config: serde_json::Value,
}

// ---- BaseArtifactService (module: artifacts) ----

/// Interface for artifact services.
#[derive(Debug, Clone, Default)]
pub struct BaseArtifactService {
    /// Gets metadata for a specific artifact version.
    pub request: serde_json::Value,
}

// ---- BaseCredentialExchanger (module: auth) ----

/// Base interface for credential exchangers. Credential exchangers are responsible for exchanging credentials from one format or scheme to another.
#[derive(Debug, Clone, Default)]
pub struct BaseCredentialExchanger {
    pub auth_credential: serde_json::Value,
    pub auth_scheme: Option<serde_json::Value>,
}

// ---- BaseCredentialService (module: auth) ----

/// Abstract class for Service that loads / saves tool credentials from / to the backend credential store.
#[derive(Debug, Clone, Default)]
pub struct BaseCredentialService {
    pub auth_config: serde_json::Value,
    pub tool_context: serde_json::Value,
}

// ---- BaseLlmConnection (module: models) ----

/// The base class for a live model connection.
#[derive(Debug, Clone, Default)]
pub struct BaseLlmConnection {}

// ---- BaseMemoryService (module: memory) ----

/// Base interface for memory services. The service provides functionalities to ingest sessions into memory so that the memory can be used for user queries.
#[derive(Debug, Clone, Default)]
pub struct BaseMemoryService {}

// ---- BasePolicyEngine (module: plugins) ----

#[derive(Debug, Clone, Default)]
pub struct BasePolicyEngine {}

// ---- CallCodeEvent (module: events) ----

/// Represents a request to execute code.
#[derive(Debug, Clone)]
pub struct CallCodeEvent {
    pub r#type: serde_json::Value,
    pub code: rs_genai::prelude::ExecutableCode,
}

// ---- CodeExecutionInput (module: code_executors) ----

/// A structure that contains the input of code execution. */
#[derive(Debug, Clone, Default)]
pub struct CodeExecutionInput {
    /// The code to execute.
    pub code: String,
    /// The input files available to the code.
    pub input_files: Vec<serde_json::Value>,
    /// The execution ID for the stateful code execution.
    pub execution_id: Option<String>,
}

// ---- CodeExecutionResult (module: code_executors) ----

#[derive(Debug, Clone, Default)]
pub struct CodeExecutionResult {
    pub code: String,
    pub result_stdout: String,
    pub result_stderr: String,
    pub timestamp: f64,
}

// ---- CodeGroupMatch (module: code_executors) ----

#[derive(Debug, Clone, Default)]
pub struct CodeGroupMatch {
    pub groups: Option</* {prefix?: string; codeStr?: string} */ String>,
    pub index: Option<f64>,
    pub length: Option<f64>,
}

// ---- CodeResultEvent (module: events) ----

/// Represents the result of code execution.
#[derive(Debug, Clone)]
pub struct CodeResultEvent {
    pub r#type: serde_json::Value,
    pub result: rs_genai::prelude::CodeExecutionResult,
}

// ---- ContentEvent (module: events) ----

/// Represents partial content (text delta) intended for the user.
#[derive(Debug, Clone, Default)]
pub struct ContentEvent {
    pub r#type: serde_json::Value,
    pub content: String,
}

// ---- CreateSessionRequest (module: sessions) ----

/// The parameters for `createSession`.
#[derive(Debug, Clone, Default)]
pub struct CreateSessionRequest {
    /// The name of the application.
    pub app_name: String,
    /// The ID of the user.
    pub user_id: String,
    /// The initial state of the session.
    pub state: Option<serde_json::Value>,
    /// The ID of the session. A new ID will be generated if not provided.
    pub session_id: Option<String>,
}

// ---- DataPartType (module: a2a) ----

/// The types of data parts.
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum DataPartType {
    FunctionCall,
    FunctionResponse,
    CodeExecResult,
    CodeExecutableCode,
}

// ---- DeleteArtifactRequest (module: artifacts) ----

/// The parameters for `deleteArtifact`.
#[derive(Debug, Clone, Default)]
pub struct DeleteArtifactRequest {
    /// The app name.
    pub app_name: String,
    /// The user ID.
    pub user_id: String,
    /// The session ID.
    pub session_id: String,
    /// The filename of the artifact.
    pub filename: String,
}

// ---- DeleteSessionRequest (module: sessions) ----

/// The parameters for `deleteSession`.
#[derive(Debug, Clone, Default)]
pub struct DeleteSessionRequest {
    /// The name of the application.
    pub app_name: String,
    /// The ID of the user.
    pub user_id: String,
    /// The ID of the session.
    pub session_id: String,
}

// ---- ErrorEvent (module: events) ----

/// Represents a runtime error.
#[derive(Debug, Clone, Default)]
pub struct ErrorEvent {
    pub r#type: serde_json::Value,
    pub error: serde_json::Value,
}

// ---- Event (module: events) ----

/// Represents an event in a conversation between agents and users. It is used to store the content of the conversation, as well as the actions taken by the agents like function calls, etc.
#[derive(Debug, Clone, Default)]
pub struct Event {
    /// The unique identifier of the event. Do not assign the ID. It will be assigned by the session.
    pub id: String,
    /// The invocation ID of the event. Should be non-empty before appending to a session.
    pub invocation_id: String,
    /// "user" or the name of the agent, indicating who appended the event to the session.
    pub author: Option<String>,
    /// The actions taken by the agent.
    pub actions: serde_json::Value,
    /// Set of ids of the long running function calls. Agent client will know from this field about which function call is long running. Only valid for function call event
    pub long_running_tool_ids: Option<Vec<String>>,
    /// The branch of the event. The format is like agent_1.agent_2.agent_3, where agent_1 is the parent of agent_2, and agent_2 is the parent of agent_3. Branch is used when multiple sub-agent shouldn't see their peer agents' conversation history.
    pub branch: Option<String>,
    /// The timestamp of the event.
    pub timestamp: f64,
}

// ---- EventActions (module: events) ----

/// Represents the actions attached to an event.
#[derive(Debug, Clone, Default)]
pub struct EventActions {
    /// If true, it won't call model to summarize function response. Only used for function_response event.
    pub skip_summarization: Option<bool>,
    /// Indicates that the event is updating the state with the given delta.
    pub state_delta: String,
    /// Indicates that the event is updating an artifact. key is the filename, value is the version.
    pub artifact_delta: String,
    /// If set, the event transfers to the specified agent.
    pub transfer_to_agent: Option<String>,
    /// The agent is escalating to a higher level agent.
    pub escalate: Option<bool>,
    /// Authentication configurations requested by tool responses. This field will only be set by a tool response event indicating tool request auth credential. - Keys: The function call id. Since one function response event could contain multiple function responses that correspond to multiple function calls. Each function call could request different auth configs. This id is used to identify the function call. - Values: The requested auth config.
    pub requested_auth_configs: String,
    /// A dict of tool confirmation requested by this event, keyed by the function call id.
    pub requested_tool_confirmations: String,
}

// ---- EventType (module: events) ----

/// The types of events that can be parsed from a raw Event.
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum EventType {
    THOUGHT,
    CONTENT,
    ToolCall,
    ToolResult,
    CallCode,
    CodeResult,
    ERROR,
    ACTIVITY,
    ToolConfirmation,
    FINISHED,
}

// ---- Example (module: examples) ----

/// A few-shot example.
#[derive(Debug, Clone)]
pub struct Example {
    /// The input content for the example.
    pub input: rs_genai::prelude::Content,
    /// The expected output content for the example.
    pub output: Vec<rs_genai::prelude::Content>,
}

// ---- ExecuteCodeParams (module: code_executors) ----

/// The parameters for executing code. */
#[derive(Debug, Clone, Default)]
pub struct ExecuteCodeParams {
    /// The invocation context of the code execution.
    pub invocation_context: serde_json::Value,
    /// The input of the code execution.
    pub code_execution_input: serde_json::Value,
}

// ---- ExecutorContext (module: a2a) ----

/// The A2A Agent Executor context.
#[derive(Debug, Clone)]
pub struct ExecutorContext {
    pub user_id: String,
    pub session_id: String,
    pub agent_name: String,
    pub readonly_state: serde_json::Value,
    pub events: Vec<serde_json::Value>,
    pub user_content: rs_genai::prelude::Content,
    pub request_context: serde_json::Value,
}

// ---- File (module: code_executors) ----

/// A structure that contains a file name and its content
#[derive(Debug, Clone, Default)]
pub struct File {
    /// The name of the file with file extension(e.g., ' file.csv')
    pub name: String,
    /// The base64 - encoded bytes of the file content.
    pub content: String,
    /// The mime type of the file (e.g., ' image / png')
    pub mime_type: String,
}

// ---- FileArtifactVersion (module: artifacts) ----

/// Metadata for a file artifact version.
#[derive(Debug, Clone, Default)]
pub struct FileArtifactVersion {
    pub file_name: Option<String>,
}

// ---- FinishedEvent (module: events) ----

/// Represents the final completion of the agent's task.
#[derive(Debug, Clone, Default)]
pub struct FinishedEvent {
    pub r#type: serde_json::Value,
    pub output: Option<serde_json::Value>,
}

// ---- GeminiParams (module: models) ----

/// The parameters for creating a Gemini instance.
#[derive(Debug, Clone, Default)]
pub struct GeminiParams {
    /// The name of the model to use. Defaults to 'gemini-2.5-flash'.
    pub model: Option<String>,
    /// The API key to use for the Gemini API. If not provided, it will look for the GOOGLE_GENAI_API_KEY or GEMINI_API_KEY environment variable.
    pub api_key: Option<String>,
    /// Whether to use Vertex AI. If true, `project`, `location` should be provided.
    pub vertexai: Option<bool>,
    /// The Vertex AI project ID. Required if `vertexai` is true.
    pub project: Option<String>,
    /// The Vertex AI location. Required if `vertexai` is true.
    pub location: Option<String>,
    /// Headers to merge with internally crafted headers.
    pub headers: Option<serde_json::Value>,
}

// ---- GetSessionConfig (module: sessions) ----

/// The configuration of getting a session.
#[derive(Debug, Clone, Default)]
pub struct GetSessionConfig {
    /// The number of recent events to retrieve.
    pub num_recent_events: Option<f64>,
    /// Retrieve events after this timestamp.
    pub after_timestamp: Option<f64>,
}

// ---- GetSessionRequest (module: sessions) ----

/// The parameters for `getSession`.
#[derive(Debug, Clone, Default)]
pub struct GetSessionRequest {
    /// The name of the application.
    pub app_name: String,
    /// The ID of the user.
    pub user_id: String,
    /// The ID of the session.
    pub session_id: String,
    /// The configurations for getting the session.
    pub config: Option<serde_json::Value>,
}

// ---- HttpAuth (module: auth) ----

/// The credentials and metadata for HTTP authentication.
#[derive(Debug, Clone, Default)]
pub struct HttpAuth {
    /// The name of the HTTP Authorization scheme to be used in the Authorization header as defined in RFC7235. The values used SHOULD be registered in the IANA Authentication Scheme registry. Examples: 'basic', 'bearer'
    pub scheme: String,
    pub credentials: serde_json::Value,
}

// ---- HttpCredentials (module: auth) ----

/// Represents the secret token value for HTTP authentication, like user name, password, oauth token, etc.
#[derive(Debug, Clone, Default)]
pub struct HttpCredentials {
    pub username: Option<String>,
    pub password: Option<String>,
    pub token: Option<String>,
}

// ---- InvocationContextParams (module: agents) ----

/// The parameters for creating an invocation context.
// Cannot derive Clone or Default
pub struct InvocationContextParams {
    pub artifact_service: Option<serde_json::Value>,
    pub session_service: Option<serde_json::Value>,
    pub memory_service: Option<serde_json::Value>,
    pub credential_service: Option<serde_json::Value>,
    pub invocation_id: String,
    pub branch: Option<String>,
    pub agent: Arc<dyn Agent>,
    pub user_content: Option<rs_genai::prelude::Content>,
    pub session: serde_json::Value,
    pub end_invocation: Option<bool>,
    pub transcription_cache: Option<Vec<serde_json::Value>>,
    pub run_config: Option<serde_json::Value>,
    pub live_request_queue: Option<serde_json::Value>,
    pub active_streaming_tools: Option<serde_json::Value>,
    pub plugin_manager: serde_json::Value,
}

// ---- ListArtifactKeysRequest (module: artifacts) ----

/// The parameters for `listArtifactKeys`.
#[derive(Debug, Clone, Default)]
pub struct ListArtifactKeysRequest {
    /// The app name.
    pub app_name: String,
    /// The user ID.
    pub user_id: String,
    /// The session ID.
    pub session_id: String,
}

// ---- ListSessionsRequest (module: sessions) ----

/// The parameters for `listSessions`.
#[derive(Debug, Clone, Default)]
pub struct ListSessionsRequest {
    /// The name of the application.
    pub app_name: String,
    /// The ID of the user.
    pub user_id: String,
}

// ---- ListSessionsResponse (module: sessions) ----

/// The response of listing sessions. The events and states are not set within each Session object.
#[derive(Debug, Clone, Default)]
pub struct ListSessionsResponse {
    /// A list of sessions.
    pub sessions: Vec<serde_json::Value>,
}

// ---- ListVersionsRequest (module: artifacts) ----

/// The parameters for `listVersions`.
#[derive(Debug, Clone, Default)]
pub struct ListVersionsRequest {
    /// The app name.
    pub app_name: String,
    /// The user ID.
    pub user_id: String,
    /// The session ID.
    pub session_id: String,
    /// The filename of the artifact.
    pub filename: String,
}

// ---- LiveRequest (module: agents) ----

/// Request sent to live agents.
#[derive(Debug, Clone, Default)]
pub struct LiveRequest {
    /// If set, send the content to the model in turn-by-turn mode.
    pub content: Option<rs_genai::prelude::Content>,
    /// If set, send the blob to the model in realtime mode.
    pub blob: Option<rs_genai::prelude::Blob>,
    /// If set, signal the start of user activity to the model.
    pub activity_start: Option<rs_genai::prelude::ActivityStart>,
    /// If set, signal the end of user activity to the model.
    pub activity_end: Option<rs_genai::prelude::ActivityEnd>,
    /// If set, close the queue.
    pub close: Option<bool>,
}

// ---- LlmRequest (module: models) ----

/// LLM request class that allows passing in tools, output schema and system instructions to the model.
#[derive(Debug, Clone)]
pub struct LlmRequest {
    /// The model name.
    pub model: Option<String>,
    /// The contents to send to the model.
    pub contents: Vec<rs_genai::prelude::Content>,
    /// Additional config for the generate content request. Tools in generateContentConfig should not be set directly; use appendTools.
    pub config: Option<serde_json::Value>,
    pub live_connect_config: serde_json::Value,
    /// The tools dictionary. Excluded from JSON serialization.
    pub tools_dict: String,
}

// ---- LlmResponse (module: models) ----

/// LLM response class that provides the first candidate response from the model if available. Otherwise, returns error code and message.
#[derive(Debug, Clone, Default)]
pub struct LlmResponse {
    /// The content of the response.
    pub content: Option<rs_genai::prelude::Content>,
    /// The grounding metadata of the response.
    pub grounding_metadata: Option<rs_genai::prelude::GroundingMetadata>,
    /// Indicates whether the text content is part of a unfinished text stream. Only used for streaming mode and when the content is plain text.
    pub partial: Option<bool>,
    /// Indicates whether the response from the model is complete. Only used for streaming mode.
    pub turn_complete: Option<bool>,
    /// Error code if the response is an error. Code varies by model.
    pub error_code: Option<String>,
    /// Error message if the response is an error.
    pub error_message: Option<String>,
    /// Flag indicating that LLM was interrupted when generating the content. Usually it's due to user interruption during a bidi streaming.
    pub interrupted: Option<bool>,
    /// The custom metadata of the LlmResponse. An optional key-value pair to label an LlmResponse. NOTE: the entire object must be JSON serializable.
    pub custom_metadata: Option</* {[key: string]: unknown} */ String>,
    /// The usage metadata of the LlmResponse.
    pub usage_metadata: Option<serde_json::Value>,
    /// The finish reason of the response.
    pub finish_reason: Option<serde_json::Value>,
    /// The session resumption update of the LlmResponse
    pub live_session_resumption_update: Option<rs_genai::prelude::SessionResumptionUpdatePayload>,
    /// Audio transcription of user input.
    pub input_transcription: Option<rs_genai::prelude::TranscriptionPayload>,
    /// Audio transcription of model output.
    pub output_transcription: Option<rs_genai::prelude::TranscriptionPayload>,
}

// ---- LoadArtifactRequest (module: artifacts) ----

/// The parameters for `loadArtifact`.
#[derive(Debug, Clone, Default)]
pub struct LoadArtifactRequest {
    /// The app name.
    pub app_name: String,
    /// The user ID.
    pub user_id: String,
    /// The session ID.
    pub session_id: String,
    /// The filename of the artifact.
    pub filename: String,
    /// The version of the artifact to load. If not provided, the latest version of the artifact is loaded.
    pub version: Option<f64>,
}

// ---- LogLevel (module: utils) ----

/// Log levels for the logger.
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum LogLevel {
    DEBUG,
    INFO,
    WARN,
    ERROR,
}

// ---- Logger (module: utils) ----

/// Logger interface for ADK.
#[derive(Debug, Clone, Default)]
pub struct Logger {}

// ---- MemoryEntry (module: memory) ----

/// Represents one memory entry.
#[derive(Debug, Clone)]
pub struct MemoryEntry {
    /// The content of the memory entry.
    pub content: rs_genai::prelude::Content,
    /// The author of the memory.
    pub author: Option<String>,
    /// The timestamp when the original content of this memory happened. This string will be forwarded to LLM. Preferred format is ISO 8601 format.
    pub timestamp: Option<String>,
}

// ---- MetadataKeys (module: a2a) ----

#[derive(Debug, Clone, PartialEq, Eq)]
pub enum MetadataKeys {
    TYPE,
    LongRunning,
    THOUGHT,
}

// ---- OAuth2Auth (module: auth) ----

/// Represents credential value and its metadata for a OAuth2 credential.
#[derive(Debug, Clone, Default)]
pub struct OAuth2Auth {
    pub client_id: Option<String>,
    pub client_secret: Option<String>,
    /// tool or adk can generate the authUri with the state info thus client can verify the state
    pub auth_uri: Option<String>,
    pub state: Option<String>,
    /// tool or adk can decide the redirect_uri if they don't want client to decide
    pub redirect_uri: Option<String>,
    pub auth_response_uri: Option<String>,
    pub auth_code: Option<String>,
    pub access_token: Option<String>,
    pub refresh_token: Option<String>,
    pub expires_at: Option<f64>,
    pub expires_in: Option<f64>,
}

// ---- OAuthGrantType (module: auth) ----

/// Represents the OAuth2 flow (or grant type).
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum OAuthGrantType {
    ClientCredentials,
    AuthorizationCode,
    IMPLICIT,
    PASSWORD,
}

// ---- OTelHooks (module: telemetry) ----

/// Configuration hooks for OpenTelemetry setup. This interface defines the structure for configuring OpenTelemetry components including span processors, metric readers, and log record processors.
#[derive(Debug, Clone, Default)]
pub struct OTelHooks {
    pub span_processors: Option<Vec<serde_json::Value>>,
    pub metric_readers: Option<Vec<serde_json::Value>>,
    pub log_record_processors: Option<Vec<serde_json::Value>>,
}

// ---- OtelExportersConfig (module: telemetry) ----

#[derive(Debug, Clone, Default)]
pub struct OtelExportersConfig {
    pub enable_tracing: Option<bool>,
    pub enable_metrics: Option<bool>,
    pub enable_logging: Option<bool>,
}

// ---- ParsedVersion (module: utils) ----

#[derive(Debug, Clone, Default)]
pub struct ParsedVersion {
    pub valid: bool,
    pub major: f64,
    pub minor: f64,
    pub patch: f64,
}

// ---- PolicyCheckResult (module: plugins) ----

#[derive(Debug, Clone, Default)]
pub struct PolicyCheckResult {
    pub outcome: String,
    pub reason: Option<String>,
}

// ---- RunConfig (module: agents) ----

/// Configs for runtime behavior of agents.
#[derive(Debug, Clone, Default)]
pub struct RunConfig {
    /// Speech configuration for the live agent.
    pub speech_config: Option<rs_genai::prelude::SpeechConfig>,
    /// The output modalities. If not set, it's default to AUDIO.
    pub response_modalities: Option<Vec<rs_genai::prelude::Modality>>,
    /// Whether or not to save the input blobs as artifacts.
    pub save_input_blobs_as_artifacts: Option<bool>,
    /// Whether to support CFC (Compositional Function Calling). Only applicable for StreamingMode.SSE. If it's true. the LIVE API will be invoked. Since only LIVE API supports CFC WARNING: This feature is **experimental** and its API or behavior may change in future releases.
    pub support_cfc: Option<bool>,
    /// Streaming mode, None or StreamingMode.SSE or StreamingMode.BIDI.
    pub streaming_mode: Option<serde_json::Value>,
    /// Output audio transcription config.
    pub output_audio_transcription: Option<serde_json::Value>,
    /// Input transcription for live agents with audio input from user.
    pub input_audio_transcription: Option<serde_json::Value>,
    /// If enabled, the model will detect emotions and adapt its responses accordingly.
    pub enable_affective_dialog: Option<bool>,
    /// Configures the proactivity of the model. This allows the model to respond proactively to the input and to ignore irrelevant input.
    pub proactivity: Option<rs_genai::prelude::ProactivityConfig>,
    /// Realtime input config for live agents with audio input from user.
    pub realtime_input_config: Option<rs_genai::prelude::RealtimeInputConfig>,
    /// A limit on the total number of llm calls for a given run. Valid Values:   - More than 0 and less than sys.maxsize: The bound on the number of llm     calls is enforced, if the value is set in this range.   - Less than or equal to 0: This allows for unbounded number of llm calls.
    pub max_llm_calls: Option<f64>,
    /// If true, the agent loop will suspend on ANY tool call, allowing the client to intercept and execute tools (Client-Side Tool Execution).
    pub pause_on_tool_calls: Option<bool>,
}

// ---- RunnerConfig (module: runner) ----

/// The configuration parameters for the Runner.
// Cannot derive Clone or Default
pub struct RunnerConfig {
    /// The application name.
    pub app_name: String,
    /// The agent to run.
    pub agent: Arc<dyn Agent>,
    pub plugins: Option<Vec<serde_json::Value>>,
    pub artifact_service: Option<serde_json::Value>,
    pub session_service: serde_json::Value,
    pub memory_service: Option<serde_json::Value>,
    pub credential_service: Option<serde_json::Value>,
}

// ---- SaveArtifactRequest (module: artifacts) ----

/// The parameters for `saveArtifact`.
#[derive(Debug, Clone)]
pub struct SaveArtifactRequest {
    /// The app name.
    pub app_name: String,
    /// The user ID.
    pub user_id: String,
    /// The session ID.
    pub session_id: String,
    /// The filename of the artifact.
    pub filename: String,
    /// The artifact to save.
    pub artifact: rs_genai::prelude::Part,
    /// Optional custom metadata to save with the artifact.
    pub custom_metadata: Option<serde_json::Value>,
}

// ---- SearchMemoryRequest (module: memory) ----

/// The parameters for `searchMemory`.
#[derive(Debug, Clone, Default)]
pub struct SearchMemoryRequest {
    pub app_name: String,
    pub user_id: String,
    pub query: String,
}

// ---- SearchMemoryResponse (module: memory) ----

/// Represents the response from a memory search.
#[derive(Debug, Clone, Default)]
pub struct SearchMemoryResponse {
    /// A list of memory entries that are related to the search query.
    pub memories: Vec<serde_json::Value>,
}

// ---- ServiceAccount (module: auth) ----

/// Represents Google Service Account configuration.
#[derive(Debug, Clone, Default)]
pub struct ServiceAccount {
    pub service_account_credential: Option<serde_json::Value>,
    pub scopes: Option<Vec<String>>,
    pub use_default_credential: Option<bool>,
}

// ---- ServiceAccountCredential (module: auth) ----

/// Represents Google Service Account configuration. @example config = {   type: "service_account",   projectId: "your_project_id",   privateKeyId: "your_private_key_id",   privateKey: "-----BEGIN PRIVATE KEY-----...",   clientEmail: "...@....iam.gserviceaccount.com",   clientId: "your_client_id",   authUri: "https://accounts.google.com/o/oauth2/auth",   tokenUri: "https://oauth2.googleapis.com/token",   authProviderX509CertUrl: "https://www.googleapis.com/oauth2/v1/certs",   clientX509CertUrl: "https://www.googleapis.com/robot/v1/metadata/x509/...",   universeDomain: "googleapis.com", }
#[derive(Debug, Clone, Default)]
pub struct ServiceAccountCredential {
    /// The type should be 'service_account'.
    pub r#type: String,
    /// The project ID of the Google Cloud project.
    pub project_id: String,
    /// The ID of the private key.
    pub private_key_id: String,
    /// The private key value.
    pub private_key: String,
    /// The client email.
    pub client_email: String,
    /// The client ID.
    pub client_id: String,
    /// The authorization URI.
    pub auth_uri: String,
    /// The token URI.
    pub token_uri: String,
    /// URL for auth provider's X.509 cert.
    pub auth_provider_x509_cert_url: String,
    /// URL for the client's X.509 cert.
    pub client_x509_cert_url: String,
    /// The universe domain.
    pub universe_domain: String,
}

// ---- Session (module: sessions) ----

/// Represents a session in a conversation between agents and users.
#[derive(Debug, Clone, Default)]
pub struct Session {
    /// The unique identifier of the session.
    pub id: String,
    /// The name of the app.
    pub app_name: String,
    /// The id of the user.
    pub user_id: String,
    /// The state of the session.
    pub state: serde_json::Value,
    /// The events of the session, e.g. user input, model response, function call/response, etc.
    pub events: Vec<serde_json::Value>,
    /// The last update time of the session.
    pub last_update_time: f64,
}

// ---- StdioConnectionParams (module: tools) ----

/// Defines the parameters for establishing a connection to an MCP server using standard input/output (stdio). This is typically used for running MCP servers as local child processes.
#[derive(Debug, Clone, Default)]
pub struct StdioConnectionParams {
    pub r#type: String,
    pub server_params: serde_json::Value,
    pub timeout: Option<f64>,
}

// ---- StreamableHTTPConnectionParams (module: tools) ----

/// Defines the parameters for establishing a connection to an MCP server over HTTP using Server-Sent Events (SSE) for streaming. Usage:  const connectionParams: StreamableHTTPConnectionParams = {    type: 'StreamableHTTPConnectionParams',    url: 'http://localhost:8788/mcp'  };
#[derive(Debug, Clone, Default)]
pub struct StreamableHTTPConnectionParams {
    pub r#type: String,
    pub url: String,
    /// Use transportOptions.requestInit.headers instead. This field will be ignored if transportOptions is provided even if no headers are specified in transportOptions.
    pub header: Option<serde_json::Value>,
    pub timeout: Option<f64>,
    pub sse_read_timeout: Option<f64>,
    pub terminate_on_close: Option<bool>,
    pub transport_options: Option<serde_json::Value>,
}

// ---- StreamingMode (module: agents) ----

/// The streaming mode for the run config.
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum StreamingMode {
    NONE,
    SSE,
    BIDI,
}

// ---- ThoughtEvent (module: events) ----

/// Represents a reasoning trace (thought) from the agent.
#[derive(Debug, Clone, Default)]
pub struct ThoughtEvent {
    pub r#type: serde_json::Value,
    pub content: String,
}

// ---- ToolCallEvent (module: events) ----

/// Represents a request to execute a tool.
#[derive(Debug, Clone)]
pub struct ToolCallEvent {
    pub r#type: serde_json::Value,
    pub call: rs_genai::prelude::FunctionCall,
}

// ---- ToolCallPolicyContext (module: plugins) ----

// Cannot derive Clone or Default
pub struct ToolCallPolicyContext {
    pub tool: Arc<dyn ToolFunction>,
    pub tool_args: serde_json::Value,
}

// ---- ToolConfirmationEvent (module: events) ----

/// Represents a request for tool confirmation.
#[derive(Debug, Clone, Default)]
pub struct ToolConfirmationEvent {
    pub r#type: serde_json::Value,
    pub confirmations: serde_json::Value,
}

// ---- ToolResultEvent (module: events) ----

/// Represents the result of a tool execution.
#[derive(Debug, Clone)]
pub struct ToolResultEvent {
    pub r#type: serde_json::Value,
    pub result: rs_genai::prelude::FunctionResponse,
}

// ---- TraceAgentInvocationParams (module: telemetry) ----

// Cannot derive Clone or Default
pub struct TraceAgentInvocationParams {
    pub agent: Arc<dyn Agent>,
    pub invocation_context: serde_json::Value,
}

// ---- TraceCallLlmParams (module: telemetry) ----

#[derive(Debug, Clone, Default)]
pub struct TraceCallLlmParams {
    pub invocation_context: serde_json::Value,
    pub event_id: String,
    pub llm_request: serde_json::Value,
    pub llm_response: serde_json::Value,
}

// ---- TraceSendDataParams (module: telemetry) ----

#[derive(Debug, Clone)]
pub struct TraceSendDataParams {
    /// The invocation context for the current agent run.
    pub invocation_context: serde_json::Value,
    /// The ID of the event.
    pub event_id: String,
    /// A list of content objects.
    pub data: Vec<rs_genai::prelude::Content>,
}

// ---- TranscriptionEntry (module: agents) ----

/// Store the data that can be used for transcription.
#[derive(Debug, Clone)]
pub struct TranscriptionEntry {
    /// The role that created this data, typically "user" or "model". For function call, this is undefined.
    pub role: Option<String>,
    pub data: rs_genai::prelude::Blob,
}

// ---- UpdateCodeExecutionResultParams (module: code_executors) ----

/// The parameters for updating the code execution result. */
#[derive(Debug, Clone, Default)]
pub struct UpdateCodeExecutionResultParams {
    pub invocation_id: String,
    pub code: String,
    pub result_stdout: String,
    pub result_stderr: String,
}