gestalt-sdk 0.0.1-alpha.19

Rust SDK scaffolding and generated protocol bindings for Gestalt executable providers
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
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
// Code generated by sdkgen. DO NOT EDIT.

//! Generated native types and clients for agent.proto.

use crate::app::{AgentToolRef, OperationAnnotations, RequestContext, SubjectContext};
use crate::codec::agent::{
    from_wire_agent_interaction, from_wire_agent_provider_capabilities, from_wire_agent_session,
    from_wire_agent_turn, from_wire_list_agent_provider_interactions_response,
    from_wire_list_agent_provider_sessions_response,
    from_wire_list_agent_provider_turn_events_response,
    from_wire_list_agent_provider_turns_response, to_wire_cancel_agent_provider_turn_request,
    to_wire_create_agent_provider_session_request, to_wire_create_agent_provider_turn_request,
    to_wire_get_agent_provider_capabilities_request,
    to_wire_get_agent_provider_interaction_request, to_wire_get_agent_provider_session_request,
    to_wire_get_agent_provider_turn_request, to_wire_list_agent_provider_interactions_request,
    to_wire_list_agent_provider_sessions_request, to_wire_list_agent_provider_turn_events_request,
    to_wire_list_agent_provider_turns_request, to_wire_resolve_agent_provider_interaction_request,
    to_wire_update_agent_provider_session_request,
};
use crate::codec::host_service::{HostServiceChannel, connect_host_service, plain_channel};
use crate::generated::v1;
use crate::rpc_support::GestaltError;

/// Open enum for `gestalt.provider.v1.AgentExecutionStatus`; unknown numeric values are preserved.
pub type AgentExecutionStatus = i32;

/// Named values of `AgentExecutionStatus`.
pub mod agent_execution_status {
    /// AGENT_EXECUTION_STATUS_UNSPECIFIED.
    pub const AGENT_EXECUTION_STATUS_UNSPECIFIED: i32 = 0;
    /// AGENT_EXECUTION_STATUS_PENDING.
    pub const AGENT_EXECUTION_STATUS_PENDING: i32 = 1;
    /// AGENT_EXECUTION_STATUS_RUNNING.
    pub const AGENT_EXECUTION_STATUS_RUNNING: i32 = 2;
    /// AGENT_EXECUTION_STATUS_SUCCEEDED.
    pub const AGENT_EXECUTION_STATUS_SUCCEEDED: i32 = 3;
    /// AGENT_EXECUTION_STATUS_FAILED.
    pub const AGENT_EXECUTION_STATUS_FAILED: i32 = 4;
    /// AGENT_EXECUTION_STATUS_CANCELED.
    pub const AGENT_EXECUTION_STATUS_CANCELED: i32 = 5;
    /// AGENT_EXECUTION_STATUS_WAITING_FOR_INPUT.
    pub const AGENT_EXECUTION_STATUS_WAITING_FOR_INPUT: i32 = 6;
}

/// Open enum for `gestalt.provider.v1.AgentInteractionState`; unknown numeric values are preserved.
pub type AgentInteractionState = i32;

/// Named values of `AgentInteractionState`.
pub mod agent_interaction_state {
    /// AGENT_INTERACTION_STATE_UNSPECIFIED.
    pub const AGENT_INTERACTION_STATE_UNSPECIFIED: i32 = 0;
    /// AGENT_INTERACTION_STATE_PENDING.
    pub const AGENT_INTERACTION_STATE_PENDING: i32 = 1;
    /// AGENT_INTERACTION_STATE_RESOLVED.
    pub const AGENT_INTERACTION_STATE_RESOLVED: i32 = 2;
    /// AGENT_INTERACTION_STATE_CANCELED.
    pub const AGENT_INTERACTION_STATE_CANCELED: i32 = 3;
}

/// Open enum for `gestalt.provider.v1.AgentInteractionType`; unknown numeric values are preserved.
pub type AgentInteractionType = i32;

/// Named values of `AgentInteractionType`.
pub mod agent_interaction_type {
    /// AGENT_INTERACTION_TYPE_UNSPECIFIED.
    pub const AGENT_INTERACTION_TYPE_UNSPECIFIED: i32 = 0;
    /// AGENT_INTERACTION_TYPE_APPROVAL.
    pub const AGENT_INTERACTION_TYPE_APPROVAL: i32 = 1;
    /// AGENT_INTERACTION_TYPE_CLARIFICATION.
    pub const AGENT_INTERACTION_TYPE_CLARIFICATION: i32 = 2;
    /// AGENT_INTERACTION_TYPE_INPUT.
    pub const AGENT_INTERACTION_TYPE_INPUT: i32 = 3;
}

/// Open enum for `gestalt.provider.v1.AgentMessagePartType`; unknown numeric values are preserved.
pub type AgentMessagePartType = i32;

/// Named values of `AgentMessagePartType`.
pub mod agent_message_part_type {
    /// AGENT_MESSAGE_PART_TYPE_UNSPECIFIED.
    pub const AGENT_MESSAGE_PART_TYPE_UNSPECIFIED: i32 = 0;
    /// AGENT_MESSAGE_PART_TYPE_TEXT.
    pub const AGENT_MESSAGE_PART_TYPE_TEXT: i32 = 1;
    /// AGENT_MESSAGE_PART_TYPE_JSON.
    pub const AGENT_MESSAGE_PART_TYPE_JSON: i32 = 2;
    /// AGENT_MESSAGE_PART_TYPE_TOOL_CALL.
    pub const AGENT_MESSAGE_PART_TYPE_TOOL_CALL: i32 = 3;
    /// AGENT_MESSAGE_PART_TYPE_TOOL_RESULT.
    pub const AGENT_MESSAGE_PART_TYPE_TOOL_RESULT: i32 = 4;
    /// AGENT_MESSAGE_PART_TYPE_IMAGE_REF.
    pub const AGENT_MESSAGE_PART_TYPE_IMAGE_REF: i32 = 5;
}

/// Open enum for `gestalt.provider.v1.AgentSessionState`; unknown numeric values are preserved.
pub type AgentSessionState = i32;

/// Named values of `AgentSessionState`.
pub mod agent_session_state {
    /// AGENT_SESSION_STATE_UNSPECIFIED.
    pub const AGENT_SESSION_STATE_UNSPECIFIED: i32 = 0;
    /// AGENT_SESSION_STATE_ACTIVE.
    pub const AGENT_SESSION_STATE_ACTIVE: i32 = 1;
    /// AGENT_SESSION_STATE_ARCHIVED.
    pub const AGENT_SESSION_STATE_ARCHIVED: i32 = 2;
}

/// Open enum for `gestalt.provider.v1.AgentToolSourceMode`; unknown numeric values are preserved.
pub type AgentToolSourceMode = i32;

/// Named values of `AgentToolSourceMode`.
pub mod agent_tool_source_mode {
    /// AGENT_TOOL_SOURCE_MODE_UNSPECIFIED.
    pub const AGENT_TOOL_SOURCE_MODE_UNSPECIFIED: i32 = 0;
    /// AGENT_TOOL_SOURCE_MODE_CATALOG.
    pub const AGENT_TOOL_SOURCE_MODE_CATALOG: i32 = 2;
    /// AGENT_TOOL_SOURCE_MODE_NONE.
    pub const AGENT_TOOL_SOURCE_MODE_NONE: i32 = 3;
}

/// Native message type for `gestalt.provider.v1.AgentCatalogToolConfig`.
#[derive(Clone, Debug, Default, PartialEq)]
pub struct AgentCatalogToolConfig {
    /// The `refs` field.
    pub refs: Vec<AgentToolRef>,
    /// The `tools` field.
    pub tools: Vec<ListedAgentTool>,
}

/// Native message type for `gestalt.provider.v1.AgentInteraction`.
#[derive(Clone, Debug, Default, PartialEq)]
pub struct AgentInteraction {
    /// The `id` field.
    pub id: String,
    /// The `type` field.
    pub r#type: AgentInteractionType,
    /// The `state` field.
    pub state: AgentInteractionState,
    /// The `title` field.
    pub title: String,
    /// The `prompt` field.
    pub prompt: String,
    /// The `request` field; None when unset.
    pub request: Option<serde_json::Map<String, serde_json::Value>>,
    /// The `resolution` field; None when unset.
    pub resolution: Option<serde_json::Map<String, serde_json::Value>>,
    /// The `created_at` field; None when unset.
    pub created_at: Option<std::time::SystemTime>,
    /// The `resolved_at` field; None when unset.
    pub resolved_at: Option<std::time::SystemTime>,
    /// The `turn_id` field.
    pub turn_id: String,
    /// The `session_id` field.
    pub session_id: String,
}

/// Native message type for `gestalt.provider.v1.AgentMessage`.
#[derive(Clone, Debug, Default, PartialEq)]
pub struct AgentMessage {
    /// The `role` field.
    pub role: String,
    /// The `text` field.
    pub text: String,
    /// The `parts` field.
    pub parts: Vec<AgentMessagePart>,
    /// The `metadata` field; None when unset.
    pub metadata: Option<serde_json::Map<String, serde_json::Value>>,
}

/// Native message type for `gestalt.provider.v1.AgentMessagePart`.
#[derive(Clone, Debug, Default, PartialEq)]
pub struct AgentMessagePart {
    /// The `type` field.
    pub r#type: AgentMessagePartType,
    /// The `text` field.
    pub text: String,
    /// The `json` field; None when unset.
    pub json: Option<serde_json::Map<String, serde_json::Value>>,
    /// The `tool_call` field; None when unset.
    pub tool_call: Option<AgentMessagePartToolCall>,
    /// The `tool_result` field; None when unset.
    pub tool_result: Option<AgentMessagePartToolResult>,
    /// The `image_ref` field; None when unset.
    pub image_ref: Option<AgentMessagePartImageRef>,
}

/// Native message type for `gestalt.provider.v1.AgentMessagePartImageRef`.
#[derive(Clone, Debug, Default, PartialEq)]
pub struct AgentMessagePartImageRef {
    /// The `uri` field.
    pub uri: String,
    /// The `mime_type` field.
    pub mime_type: String,
}

/// Native message type for `gestalt.provider.v1.AgentMessagePartToolCall`.
#[derive(Clone, Debug, Default, PartialEq)]
pub struct AgentMessagePartToolCall {
    /// The `id` field.
    pub id: String,
    /// The `tool_id` field.
    pub tool_id: String,
    /// The `arguments` field; None when unset.
    pub arguments: Option<serde_json::Map<String, serde_json::Value>>,
}

/// Native message type for `gestalt.provider.v1.AgentMessagePartToolResult`.
#[derive(Clone, Debug, Default, PartialEq)]
pub struct AgentMessagePartToolResult {
    /// The `tool_call_id` field.
    pub tool_call_id: String,
    /// The `status` field.
    pub status: i32,
    /// The `content` field.
    pub content: String,
    /// The `output` field; None when unset.
    pub output: Option<serde_json::Map<String, serde_json::Value>>,
}

/// Native message type for `gestalt.provider.v1.AgentNoTools`.
#[derive(Clone, Debug, Default, PartialEq)]
pub struct AgentNoTools {}

/// Values of the `kind` oneof in `AgentOutput`; the message field is None when unset.
#[allow(clippy::enum_variant_names, clippy::large_enum_variant)]
#[derive(Clone, Debug, PartialEq)]
pub enum AgentOutputKind {
    /// The `text` variant.
    Text(AgentTextOutput),
    /// The `structured` variant.
    Structured(AgentStructuredOutput),
}

/// Native message type for `gestalt.provider.v1.AgentOutput`.
#[derive(Clone, Debug, Default, PartialEq)]
pub struct AgentOutput {
    /// The `kind` oneof; None when unset.
    pub kind: Option<AgentOutputKind>,
}

/// Native message type for `gestalt.provider.v1.AgentProviderCapabilities`.
#[derive(Clone, Debug, Default, PartialEq)]
pub struct AgentProviderCapabilities {
    /// The `streaming_text` field.
    pub streaming_text: bool,
    /// The `tool_calls` field.
    pub tool_calls: bool,
    /// The `parallel_tool_calls` field.
    pub parallel_tool_calls: bool,
    /// The `interactions` field.
    pub interactions: bool,
    /// The `resumable_turns` field.
    pub resumable_turns: bool,
    /// The `reasoning_summaries` field.
    pub reasoning_summaries: bool,
    /// Provider list APIs can apply non-zero limits and summary projections without
    /// hydrating every source record. Providers that set this must order sessions
    /// and turns by the relevant newest-first recency fields before applying limit.
    ///
    /// The `bounded_list_hydration` field.
    pub bounded_list_hydration: bool,
    /// The `supported_tool_sources` field.
    pub supported_tool_sources: Vec<AgentToolSourceMode>,
    /// The `supports_session_start` field.
    pub supports_session_start: bool,
    /// The `supports_prepared_workspace` field.
    pub supports_prepared_workspace: bool,
}

/// Native message type for `gestalt.provider.v1.AgentSession`.
#[derive(Clone, Debug, Default, PartialEq)]
pub struct AgentSession {
    /// The `id` field.
    pub id: String,
    /// The `provider_name` field.
    pub provider_name: String,
    /// The `model` field.
    pub model: String,
    /// The `client_ref` field.
    pub client_ref: String,
    /// The `state` field.
    pub state: AgentSessionState,
    /// The `metadata` field; None when unset.
    pub metadata: Option<serde_json::Map<String, serde_json::Value>>,
    /// The `created_by_subject_id` field.
    pub created_by_subject_id: String,
    /// The `created_at` field; None when unset.
    pub created_at: Option<std::time::SystemTime>,
    /// The `updated_at` field; None when unset.
    pub updated_at: Option<std::time::SystemTime>,
    /// The `last_turn_at` field; None when unset.
    pub last_turn_at: Option<std::time::SystemTime>,
}

/// Native message type for `gestalt.provider.v1.AgentSessionStartConfig`.
#[derive(Clone, Debug, Default, PartialEq)]
pub struct AgentSessionStartConfig {
    /// The `hooks` field.
    pub hooks: Vec<AgentSessionStartHook>,
}

/// Native message type for `gestalt.provider.v1.AgentSessionStartHook`.
#[derive(Clone, Debug, Default, PartialEq)]
pub struct AgentSessionStartHook {
    /// The `id` field.
    pub id: String,
    /// The `type` field.
    pub r#type: String,
    /// The `command` field.
    pub command: Vec<String>,
    /// The `cwd` field.
    pub cwd: String,
    /// The `timeout` field.
    pub timeout: String,
    /// The `env` field.
    pub env: std::collections::BTreeMap<String, String>,
    /// The `output` field; None when unset.
    pub output: Option<AgentSessionStartHookOutput>,
}

/// Native message type for `gestalt.provider.v1.AgentSessionStartHookOutput`.
#[derive(Clone, Debug, Default, PartialEq)]
pub struct AgentSessionStartHookOutput {
    /// The `additional_context` field.
    pub additional_context: bool,
    /// The `metadata` field.
    pub metadata: bool,
}

/// Native message type for `gestalt.provider.v1.AgentStructuredOutput`.
#[derive(Clone, Debug, Default, PartialEq)]
pub struct AgentStructuredOutput {
    /// The `schema` field; None when unset.
    pub schema: Option<serde_json::Map<String, serde_json::Value>>,
}

/// Native message type for `gestalt.provider.v1.AgentTextOutput`.
#[derive(Clone, Debug, Default, PartialEq)]
pub struct AgentTextOutput {}

/// Values of the `source` oneof in `AgentToolConfig`; the message field is None when unset.
#[allow(clippy::enum_variant_names, clippy::large_enum_variant)]
#[derive(Clone, Debug, PartialEq)]
pub enum AgentToolConfigSource {
    /// The `none` variant.
    None(AgentNoTools),
    /// The `catalog` variant.
    Catalog(AgentCatalogToolConfig),
}

/// Native message type for `gestalt.provider.v1.AgentToolConfig`.
#[derive(Clone, Debug, Default, PartialEq)]
pub struct AgentToolConfig {
    /// The `source` oneof; None when unset.
    pub source: Option<AgentToolConfigSource>,
}

/// Values of the `output` oneof in `AgentTurn`; the message field is None when unset.
#[allow(clippy::enum_variant_names, clippy::large_enum_variant)]
#[derive(Clone, Debug, PartialEq)]
pub enum AgentTurnOutput {
    /// The `text` variant.
    Text(AgentTurnTextOutput),
    /// The `structured` variant.
    Structured(AgentTurnStructuredOutput),
}

/// Native message type for `gestalt.provider.v1.AgentTurn`.
#[derive(Clone, Debug, Default, PartialEq)]
pub struct AgentTurn {
    /// The `id` field.
    pub id: String,
    /// The `session_id` field.
    pub session_id: String,
    /// The `provider_name` field.
    pub provider_name: String,
    /// The `model` field.
    pub model: String,
    /// The `status` field.
    pub status: AgentExecutionStatus,
    /// The `messages` field.
    pub messages: Vec<AgentMessage>,
    /// The `status_message` field.
    pub status_message: String,
    /// The `created_by_subject_id` field.
    pub created_by_subject_id: String,
    /// The `created_at` field; None when unset.
    pub created_at: Option<std::time::SystemTime>,
    /// The `started_at` field; None when unset.
    pub started_at: Option<std::time::SystemTime>,
    /// The `completed_at` field; None when unset.
    pub completed_at: Option<std::time::SystemTime>,
    /// The `execution_ref` field.
    pub execution_ref: String,
    /// The `output` oneof; None when unset.
    pub output: Option<AgentTurnOutput>,
}

/// Native message type for `gestalt.provider.v1.AgentTurnDisplay`.
#[derive(Clone, Debug, Default, PartialEq)]
pub struct AgentTurnDisplay {
    /// The `kind` field.
    pub kind: String,
    /// The `phase` field.
    pub phase: String,
    /// The `text` field.
    pub text: String,
    /// The `label` field.
    pub label: String,
    /// The `ref` field.
    pub r#ref: String,
    /// The `parent_ref` field.
    pub parent_ref: String,
    /// The `input` field; None when unset.
    pub input: Option<serde_json::Value>,
    /// The `output` field; None when unset.
    pub output: Option<serde_json::Value>,
    /// The `error` field; None when unset.
    pub error: Option<serde_json::Value>,
    /// The `action` field.
    pub action: String,
    /// The `format` field.
    pub format: String,
    /// The `language` field.
    pub language: String,
}

/// Native message type for `gestalt.provider.v1.AgentTurnEvent`.
#[derive(Clone, Debug, Default, PartialEq)]
pub struct AgentTurnEvent {
    /// The `id` field.
    pub id: String,
    /// The `turn_id` field.
    pub turn_id: String,
    /// The `seq` field.
    pub seq: i64,
    /// The `type` field.
    pub r#type: String,
    /// The `source` field.
    pub source: String,
    /// The `visibility` field.
    pub visibility: String,
    /// The `data` field; None when unset.
    pub data: Option<serde_json::Map<String, serde_json::Value>>,
    /// The `created_at` field; None when unset.
    pub created_at: Option<std::time::SystemTime>,
    /// The `display` field; None when unset.
    pub display: Option<AgentTurnDisplay>,
}

/// Native message type for `gestalt.provider.v1.AgentTurnStructuredOutput`.
#[derive(Clone, Debug, Default, PartialEq)]
pub struct AgentTurnStructuredOutput {
    /// The `text` field.
    pub text: String,
    /// The `value` field; None when unset.
    pub value: Option<serde_json::Map<String, serde_json::Value>>,
}

/// Native message type for `gestalt.provider.v1.AgentTurnTextOutput`.
#[derive(Clone, Debug, Default, PartialEq)]
pub struct AgentTurnTextOutput {
    /// The `text` field.
    pub text: String,
}

/// Native message type for `gestalt.provider.v1.AgentWorkspace`.
#[derive(Clone, Debug, Default, PartialEq)]
pub struct AgentWorkspace {
    /// The `checkouts` field.
    pub checkouts: Vec<AgentWorkspaceGitCheckout>,
    /// The `cwd` field.
    pub cwd: String,
}

/// Native message type for `gestalt.provider.v1.AgentWorkspaceGitCheckout`.
#[derive(Clone, Debug, Default, PartialEq)]
pub struct AgentWorkspaceGitCheckout {
    /// The `url` field.
    pub url: String,
    /// The `ref` field.
    pub r#ref: String,
    /// The `path` field.
    pub path: String,
}

/// Native message type for `gestalt.provider.v1.CancelAgentProviderTurnRequest`.
#[derive(Clone, Debug, Default, PartialEq)]
pub struct CancelAgentProviderTurnRequest {
    /// The `turn_id` field.
    pub turn_id: String,
    /// The `reason` field.
    pub reason: String,
    /// The `subject` field; None when unset.
    pub subject: Option<SubjectContext>,
    /// The `context` field; None when unset.
    pub context: Option<RequestContext>,
    /// The `provider_name` field.
    pub provider_name: String,
}

/// Native message type for `gestalt.provider.v1.CreateAgentProviderSessionRequest`.
#[derive(Clone, Debug, Default, PartialEq)]
pub struct CreateAgentProviderSessionRequest {
    /// The provider mints the session id returned on AgentSession. Creation is
    /// idempotent on idempotency_key scoped per subject (created_by_subject_id):
    /// a replayed key returns the existing session, an empty key always creates.
    /// Idempotency is scoped to the provider's session store.
    ///
    /// The `idempotency_key` field.
    pub idempotency_key: String,
    /// The `model` field.
    pub model: String,
    /// The `client_ref` field.
    pub client_ref: String,
    /// The `metadata` field; None when unset.
    pub metadata: Option<serde_json::Map<String, serde_json::Value>>,
    /// The `created_by_subject_id` field.
    pub created_by_subject_id: String,
    /// The `subject` field; None when unset.
    pub subject: Option<SubjectContext>,
    /// The `session_start` field; None when unset.
    pub session_start: Option<AgentSessionStartConfig>,
    /// The `prepared_workspace` field; None when unset.
    pub prepared_workspace: Option<PreparedAgentWorkspace>,
    /// The `provider_name` field.
    pub provider_name: String,
    /// The `workspace` field; None when unset.
    pub workspace: Option<AgentWorkspace>,
    /// The `context` field; None when unset.
    pub context: Option<RequestContext>,
    /// The `tools` field; None when unset.
    pub tools: Option<AgentToolConfig>,
}

/// Native message type for `gestalt.provider.v1.CreateAgentProviderTurnRequest`.
#[derive(Clone, Debug, Default, PartialEq)]
pub struct CreateAgentProviderTurnRequest {
    /// The `turn_id` field.
    pub turn_id: String,
    /// The `session_id` field.
    pub session_id: String,
    /// The `idempotency_key` field.
    pub idempotency_key: String,
    /// The `model` field.
    pub model: String,
    /// The `messages` field.
    pub messages: Vec<AgentMessage>,
    /// The `metadata` field; None when unset.
    pub metadata: Option<serde_json::Map<String, serde_json::Value>>,
    /// The `created_by_subject_id` field.
    pub created_by_subject_id: String,
    /// The `execution_ref` field.
    pub execution_ref: String,
    /// The `subject` field; None when unset.
    pub subject: Option<SubjectContext>,
    /// The `model_options` field; None when unset.
    pub model_options: Option<serde_json::Map<String, serde_json::Value>>,
    /// Optional provider-owned turn execution budget, in seconds.
    /// If unset or zero, the provider chooses its own execution timeout. This does
    /// not control the CreateTurn RPC deadline.
    ///
    /// The `timeout_seconds` field.
    pub timeout_seconds: i32,
    /// The `output` field; None when unset.
    pub output: Option<AgentOutput>,
    /// The `context` field; None when unset.
    pub context: Option<RequestContext>,
    /// The `provider_name` field.
    pub provider_name: String,
}

/// Native message type for `gestalt.provider.v1.GetAgentProviderCapabilitiesRequest`.
#[derive(Clone, Debug, Default, PartialEq)]
pub struct GetAgentProviderCapabilitiesRequest {}

/// Native message type for `gestalt.provider.v1.GetAgentProviderInteractionRequest`.
#[derive(Clone, Debug, Default, PartialEq)]
pub struct GetAgentProviderInteractionRequest {
    /// The `interaction_id` field.
    pub interaction_id: String,
    /// The `subject` field; None when unset.
    pub subject: Option<SubjectContext>,
    /// The `context` field; None when unset.
    pub context: Option<RequestContext>,
}

/// Native message type for `gestalt.provider.v1.GetAgentProviderSessionRequest`.
#[derive(Clone, Debug, Default, PartialEq)]
pub struct GetAgentProviderSessionRequest {
    /// The `session_id` field.
    pub session_id: String,
    /// The `subject` field; None when unset.
    pub subject: Option<SubjectContext>,
    /// The `context` field; None when unset.
    pub context: Option<RequestContext>,
    /// The `provider_name` field.
    pub provider_name: String,
}

/// Native message type for `gestalt.provider.v1.GetAgentProviderTurnRequest`.
#[derive(Clone, Debug, Default, PartialEq)]
pub struct GetAgentProviderTurnRequest {
    /// The `turn_id` field.
    pub turn_id: String,
    /// The `subject` field; None when unset.
    pub subject: Option<SubjectContext>,
    /// The `context` field; None when unset.
    pub context: Option<RequestContext>,
    /// The `provider_name` field.
    pub provider_name: String,
}

/// Native message type for `gestalt.provider.v1.ListAgentProviderInteractionsRequest`.
#[derive(Clone, Debug, Default, PartialEq)]
pub struct ListAgentProviderInteractionsRequest {
    /// The `turn_id` field.
    pub turn_id: String,
    /// The `subject` field; None when unset.
    pub subject: Option<SubjectContext>,
    /// The `context` field; None when unset.
    pub context: Option<RequestContext>,
    /// The `provider_name` field.
    pub provider_name: String,
}

/// Native message type for `gestalt.provider.v1.ListAgentProviderInteractionsResponse`.
#[derive(Clone, Debug, Default, PartialEq)]
pub struct ListAgentProviderInteractionsResponse {
    /// The `interactions` field.
    pub interactions: Vec<AgentInteraction>,
}

/// Native message type for `gestalt.provider.v1.ListAgentProviderSessionsRequest`.
#[derive(Clone, Debug, Default, PartialEq)]
pub struct ListAgentProviderSessionsRequest {
    /// The `subject` field; None when unset.
    pub subject: Option<SubjectContext>,
    /// The `session_ids` field.
    pub session_ids: Vec<String>,
    /// The `state` field.
    pub state: AgentSessionState,
    /// When non-zero and bounded_list_hydration is supported, cap results after
    /// ordering sessions newest-first by last_turn_at, updated_at, then created_at.
    ///
    /// The `limit` field.
    pub limit: i32,
    /// When true and bounded_list_hydration is supported, omit heavy fields such as
    /// metadata unless exact session_ids require direct lookup.
    ///
    /// The `summary_only` field.
    pub summary_only: bool,
    /// The `provider_name` field.
    pub provider_name: String,
    /// The `context` field; None when unset.
    pub context: Option<RequestContext>,
}

/// Native message type for `gestalt.provider.v1.ListAgentProviderSessionsResponse`.
#[derive(Clone, Debug, Default, PartialEq)]
pub struct ListAgentProviderSessionsResponse {
    /// The `sessions` field.
    pub sessions: Vec<AgentSession>,
}

/// Native message type for `gestalt.provider.v1.ListAgentProviderTurnEventsRequest`.
#[derive(Clone, Debug, Default, PartialEq)]
pub struct ListAgentProviderTurnEventsRequest {
    /// The `turn_id` field.
    pub turn_id: String,
    /// The `after_seq` field.
    pub after_seq: i64,
    /// The `limit` field.
    pub limit: i32,
    /// The `subject` field; None when unset.
    pub subject: Option<SubjectContext>,
    /// The `context` field; None when unset.
    pub context: Option<RequestContext>,
    /// The `provider_name` field.
    pub provider_name: String,
}

/// Native message type for `gestalt.provider.v1.ListAgentProviderTurnEventsResponse`.
#[derive(Clone, Debug, Default, PartialEq)]
pub struct ListAgentProviderTurnEventsResponse {
    /// The `events` field.
    pub events: Vec<AgentTurnEvent>,
}

/// Native message type for `gestalt.provider.v1.ListAgentProviderTurnsRequest`.
#[derive(Clone, Debug, Default, PartialEq)]
pub struct ListAgentProviderTurnsRequest {
    /// The `session_id` field.
    pub session_id: String,
    /// The `subject` field; None when unset.
    pub subject: Option<SubjectContext>,
    /// The `turn_ids` field.
    pub turn_ids: Vec<String>,
    /// The `status` field.
    pub status: AgentExecutionStatus,
    /// When non-zero and bounded_list_hydration is supported, cap results after
    /// ordering turns newest-first by created_at.
    ///
    /// The `limit` field.
    pub limit: i32,
    /// When true and bounded_list_hydration is supported, omit heavy fields such as
    /// messages, output text, and structured output unless exact turn_ids require
    /// direct lookup.
    ///
    /// The `summary_only` field.
    pub summary_only: bool,
    /// The `context` field; None when unset.
    pub context: Option<RequestContext>,
    /// The `provider_name` field.
    pub provider_name: String,
}

/// Native message type for `gestalt.provider.v1.ListAgentProviderTurnsResponse`.
#[derive(Clone, Debug, Default, PartialEq)]
pub struct ListAgentProviderTurnsResponse {
    /// The `turns` field.
    pub turns: Vec<AgentTurn>,
}

/// Native message type for `gestalt.provider.v1.ListedAgentTool`.
#[derive(Clone, Debug, Default, PartialEq)]
pub struct ListedAgentTool {
    /// The `id` field.
    pub id: String,
    /// The `mcp_name` field.
    pub mcp_name: String,
    /// The `title` field.
    pub title: String,
    /// The `description` field.
    pub description: String,
    /// The `input_schema` field.
    pub input_schema: String,
    /// The `output_schema` field.
    pub output_schema: String,
    /// The `annotations` field; None when unset.
    pub annotations: Option<OperationAnnotations>,
    /// The `ref` field; None when unset.
    pub r#ref: Option<AgentToolRef>,
    /// The `tags` field.
    pub tags: Vec<String>,
    /// The `search_text` field.
    pub search_text: String,
}

/// Native message type for `gestalt.provider.v1.PreparedAgentWorkspace`.
#[derive(Clone, Debug, Default, PartialEq)]
pub struct PreparedAgentWorkspace {
    /// The `root` field.
    pub root: String,
    /// The `cwd` field.
    pub cwd: String,
}

/// Native message type for `gestalt.provider.v1.ResolveAgentProviderInteractionRequest`.
#[derive(Clone, Debug, Default, PartialEq)]
pub struct ResolveAgentProviderInteractionRequest {
    /// The `interaction_id` field.
    pub interaction_id: String,
    /// The `resolution` field; None when unset.
    pub resolution: Option<serde_json::Map<String, serde_json::Value>>,
    /// The `subject` field; None when unset.
    pub subject: Option<SubjectContext>,
    /// The `turn_id` field.
    pub turn_id: String,
    /// The `context` field; None when unset.
    pub context: Option<RequestContext>,
    /// The `provider_name` field.
    pub provider_name: String,
}

/// Native message type for `gestalt.provider.v1.UpdateAgentProviderSessionRequest`.
#[derive(Clone, Debug, Default, PartialEq)]
pub struct UpdateAgentProviderSessionRequest {
    /// The `session_id` field.
    pub session_id: String,
    /// The `client_ref` field.
    pub client_ref: String,
    /// The `state` field.
    pub state: AgentSessionState,
    /// The `metadata` field; None when unset.
    pub metadata: Option<serde_json::Map<String, serde_json::Value>>,
    /// The `subject` field; None when unset.
    pub subject: Option<SubjectContext>,
    /// The `context` field; None when unset.
    pub context: Option<RequestContext>,
    /// The `provider_name` field.
    pub provider_name: String,
}

/// Agent is the authoritative agent data boundary. Read RPCs for
/// sessions, turns, turn events, and interactions should use provider-owned
/// control-plane state and should not require a live execution sandbox,
/// pod-level transport, or cached tunnel.
///
/// Client for the `gestalt.provider.v1.Agent` service.
pub struct Agent {
    inner: v1::agent_client::AgentClient<HostServiceChannel>,
    timeout: Option<std::time::Duration>,
    context: Option<RequestContext>,
}

impl Agent {
    /// Creates a client over an established channel.
    pub fn new(channel: tonic::transport::Channel) -> Self {
        Self {
            inner: v1::agent_client::AgentClient::new(plain_channel(channel)),
            timeout: None,
            context: None,
        }
    }

    /// Sets a deadline applied to every unary call; calls that run past it
    /// fail with DEADLINE_EXCEEDED. Streaming calls are unaffected.
    pub fn with_timeout(mut self, timeout: std::time::Duration) -> Self {
        self.timeout = Some(timeout);
        self
    }

    /// Sets the default request context, injected into outgoing requests
    /// that do not carry one.
    pub fn with_context(mut self, context: RequestContext) -> Self {
        self.context = Some(context);
        self
    }

    /// Connects to the `agent` host service described by the environment.
    pub async fn connect() -> Result<Self, GestaltError> {
        Self::connect_named("").await
    }

    /// Connects to the named `agent` host-service binding.
    pub async fn connect_named(name: &str) -> Result<Self, GestaltError> {
        Ok(Self {
            inner: v1::agent_client::AgentClient::new(connect_host_service("agent", name).await?),
            timeout: None,
            context: None,
        })
    }

    /// Calls `gestalt.provider.v1.Agent.CreateSession`.
    pub async fn create_session(
        &mut self,
        idempotency_key: String,
        model: String,
        options: AgentCreateSessionOptions,
    ) -> Result<AgentSession, GestaltError> {
        let request = CreateAgentProviderSessionRequest {
            idempotency_key,
            model,
            provider_name: options.provider_name,
            client_ref: options.client_ref,
            metadata: options.metadata,
            workspace: options.workspace,
            tools: options.tools,
            context: self.context.clone(),
            ..Default::default()
        };
        let mut tonic_request =
            tonic::Request::new(to_wire_create_agent_provider_session_request(request));
        if let Some(timeout) = self.timeout {
            tonic_request.set_timeout(timeout);
        }
        let response = self.inner.create_session(tonic_request).await?;
        Ok(from_wire_agent_session(response.into_inner()))
    }

    /// Calls `gestalt.provider.v1.Agent.CreateSession` with the full request and response messages.
    pub async fn create_session_raw(
        &mut self,
        request: CreateAgentProviderSessionRequest,
    ) -> Result<AgentSession, GestaltError> {
        let mut request = request;
        if request.context.is_none() {
            request.context = self.context.clone();
        }
        let mut tonic_request =
            tonic::Request::new(to_wire_create_agent_provider_session_request(request));
        if let Some(timeout) = self.timeout {
            tonic_request.set_timeout(timeout);
        }
        let response = self.inner.create_session(tonic_request).await?;
        Ok(from_wire_agent_session(response.into_inner()))
    }

    /// Calls `gestalt.provider.v1.Agent.GetSession`.
    pub async fn get_session(
        &mut self,
        session_id: String,
        options: AgentGetSessionOptions,
    ) -> Result<AgentSession, GestaltError> {
        let request = GetAgentProviderSessionRequest {
            session_id,
            provider_name: options.provider_name,
            context: self.context.clone(),
            ..Default::default()
        };
        let mut tonic_request =
            tonic::Request::new(to_wire_get_agent_provider_session_request(request));
        if let Some(timeout) = self.timeout {
            tonic_request.set_timeout(timeout);
        }
        let response = self.inner.get_session(tonic_request).await?;
        Ok(from_wire_agent_session(response.into_inner()))
    }

    /// Calls `gestalt.provider.v1.Agent.GetSession` with the full request and response messages.
    pub async fn get_session_raw(
        &mut self,
        request: GetAgentProviderSessionRequest,
    ) -> Result<AgentSession, GestaltError> {
        let mut request = request;
        if request.context.is_none() {
            request.context = self.context.clone();
        }
        let mut tonic_request =
            tonic::Request::new(to_wire_get_agent_provider_session_request(request));
        if let Some(timeout) = self.timeout {
            tonic_request.set_timeout(timeout);
        }
        let response = self.inner.get_session(tonic_request).await?;
        Ok(from_wire_agent_session(response.into_inner()))
    }

    /// Calls `gestalt.provider.v1.Agent.ListSessions`.
    pub async fn list_sessions(
        &mut self,
        options: AgentListSessionsOptions,
    ) -> Result<Vec<AgentSession>, GestaltError> {
        let request = ListAgentProviderSessionsRequest {
            session_ids: options.session_ids,
            state: options.state,
            limit: options.limit,
            summary_only: options.summary_only,
            provider_name: options.provider_name,
            context: self.context.clone(),
            ..Default::default()
        };
        let mut tonic_request =
            tonic::Request::new(to_wire_list_agent_provider_sessions_request(request));
        if let Some(timeout) = self.timeout {
            tonic_request.set_timeout(timeout);
        }
        let response = from_wire_list_agent_provider_sessions_response(
            self.inner.list_sessions(tonic_request).await?.into_inner(),
        );
        Ok(response.sessions)
    }

    /// Calls `gestalt.provider.v1.Agent.ListSessions` with the full request and response messages.
    pub async fn list_sessions_raw(
        &mut self,
        request: ListAgentProviderSessionsRequest,
    ) -> Result<ListAgentProviderSessionsResponse, GestaltError> {
        let mut request = request;
        if request.context.is_none() {
            request.context = self.context.clone();
        }
        let mut tonic_request =
            tonic::Request::new(to_wire_list_agent_provider_sessions_request(request));
        if let Some(timeout) = self.timeout {
            tonic_request.set_timeout(timeout);
        }
        let response = self.inner.list_sessions(tonic_request).await?;
        Ok(from_wire_list_agent_provider_sessions_response(
            response.into_inner(),
        ))
    }

    /// Calls `gestalt.provider.v1.Agent.UpdateSession`.
    pub async fn update_session(
        &mut self,
        session_id: String,
        options: AgentUpdateSessionOptions,
    ) -> Result<AgentSession, GestaltError> {
        let request = UpdateAgentProviderSessionRequest {
            session_id,
            client_ref: options.client_ref,
            state: options.state,
            provider_name: options.provider_name,
            metadata: options.metadata,
            context: self.context.clone(),
            ..Default::default()
        };
        let mut tonic_request =
            tonic::Request::new(to_wire_update_agent_provider_session_request(request));
        if let Some(timeout) = self.timeout {
            tonic_request.set_timeout(timeout);
        }
        let response = self.inner.update_session(tonic_request).await?;
        Ok(from_wire_agent_session(response.into_inner()))
    }

    /// Calls `gestalt.provider.v1.Agent.UpdateSession` with the full request and response messages.
    pub async fn update_session_raw(
        &mut self,
        request: UpdateAgentProviderSessionRequest,
    ) -> Result<AgentSession, GestaltError> {
        let mut request = request;
        if request.context.is_none() {
            request.context = self.context.clone();
        }
        let mut tonic_request =
            tonic::Request::new(to_wire_update_agent_provider_session_request(request));
        if let Some(timeout) = self.timeout {
            tonic_request.set_timeout(timeout);
        }
        let response = self.inner.update_session(tonic_request).await?;
        Ok(from_wire_agent_session(response.into_inner()))
    }

    /// Calls `gestalt.provider.v1.Agent.CreateTurn`.
    pub async fn create_turn(
        &mut self,
        session_id: String,
        idempotency_key: String,
        model: String,
        messages: Vec<AgentMessage>,
        options: AgentCreateTurnOptions,
    ) -> Result<AgentTurn, GestaltError> {
        let request = CreateAgentProviderTurnRequest {
            session_id,
            idempotency_key,
            model,
            messages,
            execution_ref: options.execution_ref,
            timeout_seconds: options.timeout_seconds,
            provider_name: options.provider_name,
            metadata: options.metadata,
            model_options: options.model_options,
            output: options.output,
            context: self.context.clone(),
            ..Default::default()
        };
        let mut tonic_request =
            tonic::Request::new(to_wire_create_agent_provider_turn_request(request));
        if let Some(timeout) = self.timeout {
            tonic_request.set_timeout(timeout);
        }
        let response = self.inner.create_turn(tonic_request).await?;
        Ok(from_wire_agent_turn(response.into_inner()))
    }

    /// Calls `gestalt.provider.v1.Agent.CreateTurn` with the full request and response messages.
    pub async fn create_turn_raw(
        &mut self,
        request: CreateAgentProviderTurnRequest,
    ) -> Result<AgentTurn, GestaltError> {
        let mut request = request;
        if request.context.is_none() {
            request.context = self.context.clone();
        }
        let mut tonic_request =
            tonic::Request::new(to_wire_create_agent_provider_turn_request(request));
        if let Some(timeout) = self.timeout {
            tonic_request.set_timeout(timeout);
        }
        let response = self.inner.create_turn(tonic_request).await?;
        Ok(from_wire_agent_turn(response.into_inner()))
    }

    /// Calls `gestalt.provider.v1.Agent.GetTurn`.
    pub async fn get_turn(
        &mut self,
        turn_id: String,
        options: AgentGetTurnOptions,
    ) -> Result<AgentTurn, GestaltError> {
        let request = GetAgentProviderTurnRequest {
            turn_id,
            provider_name: options.provider_name,
            context: self.context.clone(),
            ..Default::default()
        };
        let mut tonic_request =
            tonic::Request::new(to_wire_get_agent_provider_turn_request(request));
        if let Some(timeout) = self.timeout {
            tonic_request.set_timeout(timeout);
        }
        let response = self.inner.get_turn(tonic_request).await?;
        Ok(from_wire_agent_turn(response.into_inner()))
    }

    /// Calls `gestalt.provider.v1.Agent.GetTurn` with the full request and response messages.
    pub async fn get_turn_raw(
        &mut self,
        request: GetAgentProviderTurnRequest,
    ) -> Result<AgentTurn, GestaltError> {
        let mut request = request;
        if request.context.is_none() {
            request.context = self.context.clone();
        }
        let mut tonic_request =
            tonic::Request::new(to_wire_get_agent_provider_turn_request(request));
        if let Some(timeout) = self.timeout {
            tonic_request.set_timeout(timeout);
        }
        let response = self.inner.get_turn(tonic_request).await?;
        Ok(from_wire_agent_turn(response.into_inner()))
    }

    /// Calls `gestalt.provider.v1.Agent.ListTurns`.
    pub async fn list_turns(
        &mut self,
        session_id: String,
        options: AgentListTurnsOptions,
    ) -> Result<Vec<AgentTurn>, GestaltError> {
        let request = ListAgentProviderTurnsRequest {
            session_id,
            turn_ids: options.turn_ids,
            status: options.status,
            limit: options.limit,
            summary_only: options.summary_only,
            provider_name: options.provider_name,
            context: self.context.clone(),
            ..Default::default()
        };
        let mut tonic_request =
            tonic::Request::new(to_wire_list_agent_provider_turns_request(request));
        if let Some(timeout) = self.timeout {
            tonic_request.set_timeout(timeout);
        }
        let response = from_wire_list_agent_provider_turns_response(
            self.inner.list_turns(tonic_request).await?.into_inner(),
        );
        Ok(response.turns)
    }

    /// Calls `gestalt.provider.v1.Agent.ListTurns` with the full request and response messages.
    pub async fn list_turns_raw(
        &mut self,
        request: ListAgentProviderTurnsRequest,
    ) -> Result<ListAgentProviderTurnsResponse, GestaltError> {
        let mut request = request;
        if request.context.is_none() {
            request.context = self.context.clone();
        }
        let mut tonic_request =
            tonic::Request::new(to_wire_list_agent_provider_turns_request(request));
        if let Some(timeout) = self.timeout {
            tonic_request.set_timeout(timeout);
        }
        let response = self.inner.list_turns(tonic_request).await?;
        Ok(from_wire_list_agent_provider_turns_response(
            response.into_inner(),
        ))
    }

    /// Calls `gestalt.provider.v1.Agent.CancelTurn`.
    pub async fn cancel_turn(
        &mut self,
        turn_id: String,
        options: AgentCancelTurnOptions,
    ) -> Result<AgentTurn, GestaltError> {
        let request = CancelAgentProviderTurnRequest {
            turn_id,
            reason: options.reason,
            provider_name: options.provider_name,
            context: self.context.clone(),
            ..Default::default()
        };
        let mut tonic_request =
            tonic::Request::new(to_wire_cancel_agent_provider_turn_request(request));
        if let Some(timeout) = self.timeout {
            tonic_request.set_timeout(timeout);
        }
        let response = self.inner.cancel_turn(tonic_request).await?;
        Ok(from_wire_agent_turn(response.into_inner()))
    }

    /// Calls `gestalt.provider.v1.Agent.CancelTurn` with the full request and response messages.
    pub async fn cancel_turn_raw(
        &mut self,
        request: CancelAgentProviderTurnRequest,
    ) -> Result<AgentTurn, GestaltError> {
        let mut request = request;
        if request.context.is_none() {
            request.context = self.context.clone();
        }
        let mut tonic_request =
            tonic::Request::new(to_wire_cancel_agent_provider_turn_request(request));
        if let Some(timeout) = self.timeout {
            tonic_request.set_timeout(timeout);
        }
        let response = self.inner.cancel_turn(tonic_request).await?;
        Ok(from_wire_agent_turn(response.into_inner()))
    }

    /// Calls `gestalt.provider.v1.Agent.ListTurnEvents`.
    pub async fn list_turn_events(
        &mut self,
        turn_id: String,
        options: AgentListTurnEventsOptions,
    ) -> Result<Vec<AgentTurnEvent>, GestaltError> {
        let request = ListAgentProviderTurnEventsRequest {
            turn_id,
            after_seq: options.after_seq,
            limit: options.limit,
            provider_name: options.provider_name,
            context: self.context.clone(),
            ..Default::default()
        };
        let mut tonic_request =
            tonic::Request::new(to_wire_list_agent_provider_turn_events_request(request));
        if let Some(timeout) = self.timeout {
            tonic_request.set_timeout(timeout);
        }
        let response = from_wire_list_agent_provider_turn_events_response(
            self.inner
                .list_turn_events(tonic_request)
                .await?
                .into_inner(),
        );
        Ok(response.events)
    }

    /// Calls `gestalt.provider.v1.Agent.ListTurnEvents` with the full request and response messages.
    pub async fn list_turn_events_raw(
        &mut self,
        request: ListAgentProviderTurnEventsRequest,
    ) -> Result<ListAgentProviderTurnEventsResponse, GestaltError> {
        let mut request = request;
        if request.context.is_none() {
            request.context = self.context.clone();
        }
        let mut tonic_request =
            tonic::Request::new(to_wire_list_agent_provider_turn_events_request(request));
        if let Some(timeout) = self.timeout {
            tonic_request.set_timeout(timeout);
        }
        let response = self.inner.list_turn_events(tonic_request).await?;
        Ok(from_wire_list_agent_provider_turn_events_response(
            response.into_inner(),
        ))
    }

    /// Calls `gestalt.provider.v1.Agent.GetInteraction`.
    pub async fn get_interaction(
        &mut self,
        interaction_id: String,
    ) -> Result<AgentInteraction, GestaltError> {
        let request = GetAgentProviderInteractionRequest {
            interaction_id,
            context: self.context.clone(),
            ..Default::default()
        };
        let mut tonic_request =
            tonic::Request::new(to_wire_get_agent_provider_interaction_request(request));
        if let Some(timeout) = self.timeout {
            tonic_request.set_timeout(timeout);
        }
        let response = self.inner.get_interaction(tonic_request).await?;
        Ok(from_wire_agent_interaction(response.into_inner()))
    }

    /// Calls `gestalt.provider.v1.Agent.GetInteraction` with the full request and response messages.
    pub async fn get_interaction_raw(
        &mut self,
        request: GetAgentProviderInteractionRequest,
    ) -> Result<AgentInteraction, GestaltError> {
        let mut request = request;
        if request.context.is_none() {
            request.context = self.context.clone();
        }
        let mut tonic_request =
            tonic::Request::new(to_wire_get_agent_provider_interaction_request(request));
        if let Some(timeout) = self.timeout {
            tonic_request.set_timeout(timeout);
        }
        let response = self.inner.get_interaction(tonic_request).await?;
        Ok(from_wire_agent_interaction(response.into_inner()))
    }

    /// Calls `gestalt.provider.v1.Agent.ListInteractions`.
    pub async fn list_interactions(
        &mut self,
        turn_id: String,
        options: AgentListInteractionsOptions,
    ) -> Result<Vec<AgentInteraction>, GestaltError> {
        let request = ListAgentProviderInteractionsRequest {
            turn_id,
            provider_name: options.provider_name,
            context: self.context.clone(),
            ..Default::default()
        };
        let mut tonic_request =
            tonic::Request::new(to_wire_list_agent_provider_interactions_request(request));
        if let Some(timeout) = self.timeout {
            tonic_request.set_timeout(timeout);
        }
        let response = from_wire_list_agent_provider_interactions_response(
            self.inner
                .list_interactions(tonic_request)
                .await?
                .into_inner(),
        );
        Ok(response.interactions)
    }

    /// Calls `gestalt.provider.v1.Agent.ListInteractions` with the full request and response messages.
    pub async fn list_interactions_raw(
        &mut self,
        request: ListAgentProviderInteractionsRequest,
    ) -> Result<ListAgentProviderInteractionsResponse, GestaltError> {
        let mut request = request;
        if request.context.is_none() {
            request.context = self.context.clone();
        }
        let mut tonic_request =
            tonic::Request::new(to_wire_list_agent_provider_interactions_request(request));
        if let Some(timeout) = self.timeout {
            tonic_request.set_timeout(timeout);
        }
        let response = self.inner.list_interactions(tonic_request).await?;
        Ok(from_wire_list_agent_provider_interactions_response(
            response.into_inner(),
        ))
    }

    /// Calls `gestalt.provider.v1.Agent.ResolveInteraction`.
    pub async fn resolve_interaction(
        &mut self,
        interaction_id: String,
        resolution: Option<serde_json::Map<String, serde_json::Value>>,
        options: AgentResolveInteractionOptions,
    ) -> Result<AgentInteraction, GestaltError> {
        let request = ResolveAgentProviderInteractionRequest {
            interaction_id,
            resolution,
            turn_id: options.turn_id,
            provider_name: options.provider_name,
            context: self.context.clone(),
            ..Default::default()
        };
        let mut tonic_request =
            tonic::Request::new(to_wire_resolve_agent_provider_interaction_request(request));
        if let Some(timeout) = self.timeout {
            tonic_request.set_timeout(timeout);
        }
        let response = self.inner.resolve_interaction(tonic_request).await?;
        Ok(from_wire_agent_interaction(response.into_inner()))
    }

    /// Calls `gestalt.provider.v1.Agent.ResolveInteraction` with the full request and response messages.
    pub async fn resolve_interaction_raw(
        &mut self,
        request: ResolveAgentProviderInteractionRequest,
    ) -> Result<AgentInteraction, GestaltError> {
        let mut request = request;
        if request.context.is_none() {
            request.context = self.context.clone();
        }
        let mut tonic_request =
            tonic::Request::new(to_wire_resolve_agent_provider_interaction_request(request));
        if let Some(timeout) = self.timeout {
            tonic_request.set_timeout(timeout);
        }
        let response = self.inner.resolve_interaction(tonic_request).await?;
        Ok(from_wire_agent_interaction(response.into_inner()))
    }

    /// Calls `gestalt.provider.v1.Agent.GetCapabilities`.
    pub async fn get_capabilities(
        &mut self,
        request: GetAgentProviderCapabilitiesRequest,
    ) -> Result<AgentProviderCapabilities, GestaltError> {
        let mut tonic_request =
            tonic::Request::new(to_wire_get_agent_provider_capabilities_request(request));
        if let Some(timeout) = self.timeout {
            tonic_request.set_timeout(timeout);
        }
        let response = self.inner.get_capabilities(tonic_request).await?;
        Ok(from_wire_agent_provider_capabilities(response.into_inner()))
    }
}

/// Optional parameters of [`Agent::create_session`]; the default value leaves every
/// option unset.
#[derive(Clone, Debug, Default)]
pub struct AgentCreateSessionOptions {
    /// The `provider_name` field.
    pub provider_name: String,
    /// The `client_ref` field.
    pub client_ref: String,
    /// The `metadata` field; None when unset.
    pub metadata: Option<serde_json::Map<String, serde_json::Value>>,
    /// The `workspace` field; None when unset.
    pub workspace: Option<AgentWorkspace>,
    /// The `tools` field; None when unset.
    pub tools: Option<AgentToolConfig>,
}

/// Optional parameters of [`Agent::get_session`]; the default value leaves every
/// option unset.
#[derive(Clone, Debug, Default)]
pub struct AgentGetSessionOptions {
    /// The `provider_name` field.
    pub provider_name: String,
}

/// Optional parameters of [`Agent::list_sessions`]; the default value leaves every
/// option unset.
#[derive(Clone, Debug, Default)]
pub struct AgentListSessionsOptions {
    /// The `session_ids` field.
    pub session_ids: Vec<String>,
    /// The `state` field.
    pub state: AgentSessionState,
    /// When non-zero and bounded_list_hydration is supported, cap results after
    /// ordering sessions newest-first by last_turn_at, updated_at, then created_at.
    ///
    /// The `limit` field.
    pub limit: i32,
    /// When true and bounded_list_hydration is supported, omit heavy fields such as
    /// metadata unless exact session_ids require direct lookup.
    ///
    /// The `summary_only` field.
    pub summary_only: bool,
    /// The `provider_name` field.
    pub provider_name: String,
}

/// Optional parameters of [`Agent::update_session`]; the default value leaves every
/// option unset.
#[derive(Clone, Debug, Default)]
pub struct AgentUpdateSessionOptions {
    /// The `client_ref` field.
    pub client_ref: String,
    /// The `state` field.
    pub state: AgentSessionState,
    /// The `provider_name` field.
    pub provider_name: String,
    /// The `metadata` field; None when unset.
    pub metadata: Option<serde_json::Map<String, serde_json::Value>>,
}

/// Optional parameters of [`Agent::create_turn`]; the default value leaves every
/// option unset.
#[derive(Clone, Debug, Default)]
pub struct AgentCreateTurnOptions {
    /// The `execution_ref` field.
    pub execution_ref: String,
    /// Optional provider-owned turn execution budget, in seconds.
    /// If unset or zero, the provider chooses its own execution timeout. This does
    /// not control the CreateTurn RPC deadline.
    ///
    /// The `timeout_seconds` field.
    pub timeout_seconds: i32,
    /// The `provider_name` field.
    pub provider_name: String,
    /// The `metadata` field; None when unset.
    pub metadata: Option<serde_json::Map<String, serde_json::Value>>,
    /// The `model_options` field; None when unset.
    pub model_options: Option<serde_json::Map<String, serde_json::Value>>,
    /// The `output` field; None when unset.
    pub output: Option<AgentOutput>,
}

/// Optional parameters of [`Agent::get_turn`]; the default value leaves every
/// option unset.
#[derive(Clone, Debug, Default)]
pub struct AgentGetTurnOptions {
    /// The `provider_name` field.
    pub provider_name: String,
}

/// Optional parameters of [`Agent::list_turns`]; the default value leaves every
/// option unset.
#[derive(Clone, Debug, Default)]
pub struct AgentListTurnsOptions {
    /// The `turn_ids` field.
    pub turn_ids: Vec<String>,
    /// The `status` field.
    pub status: AgentExecutionStatus,
    /// When non-zero and bounded_list_hydration is supported, cap results after
    /// ordering turns newest-first by created_at.
    ///
    /// The `limit` field.
    pub limit: i32,
    /// When true and bounded_list_hydration is supported, omit heavy fields such as
    /// messages, output text, and structured output unless exact turn_ids require
    /// direct lookup.
    ///
    /// The `summary_only` field.
    pub summary_only: bool,
    /// The `provider_name` field.
    pub provider_name: String,
}

/// Optional parameters of [`Agent::cancel_turn`]; the default value leaves every
/// option unset.
#[derive(Clone, Debug, Default)]
pub struct AgentCancelTurnOptions {
    /// The `reason` field.
    pub reason: String,
    /// The `provider_name` field.
    pub provider_name: String,
}

/// Optional parameters of [`Agent::list_turn_events`]; the default value leaves every
/// option unset.
#[derive(Clone, Debug, Default)]
pub struct AgentListTurnEventsOptions {
    /// The `after_seq` field.
    pub after_seq: i64,
    /// The `limit` field.
    pub limit: i32,
    /// The `provider_name` field.
    pub provider_name: String,
}

/// Optional parameters of [`Agent::list_interactions`]; the default value leaves every
/// option unset.
#[derive(Clone, Debug, Default)]
pub struct AgentListInteractionsOptions {
    /// The `provider_name` field.
    pub provider_name: String,
}

/// Optional parameters of [`Agent::resolve_interaction`]; the default value leaves every
/// option unset.
#[derive(Clone, Debug, Default)]
pub struct AgentResolveInteractionOptions {
    /// The `turn_id` field.
    pub turn_id: String,
    /// The `provider_name` field.
    pub provider_name: String,
}