-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Expand file tree
/
Copy pathrpc.rs
More file actions
6166 lines (5875 loc) · 207 KB
/
Copy pathrpc.rs
File metadata and controls
6166 lines (5875 loc) · 207 KB
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
//! Auto-generated typed JSON-RPC namespace — do not edit manually.
//!
//! Generated from `api.schema.json` by `scripts/codegen/rust.ts`. The
//! [`ClientRpc`] and [`SessionRpc`] view structs let callers reach every
//! protocol method through a typed namespace tree, so wire method names
//! and request/response shapes live in exactly one place — this file.
#![allow(missing_docs)]
#![allow(clippy::too_many_arguments)]
use super::api_types::{rpc_methods, *};
use super::session_events::SessionMode;
use crate::session::Session;
use crate::{Client, Error};
/// Typed view over the [`Client`]'s server-level RPC namespace.
#[derive(Clone, Copy)]
pub struct ClientRpc<'a> {
pub(crate) client: &'a Client,
}
impl<'a> ClientRpc<'a> {
/// `account.*` sub-namespace.
pub fn account(&self) -> ClientRpcAccount<'a> {
ClientRpcAccount {
client: self.client,
}
}
/// `agentRegistry.*` sub-namespace.
pub fn agent_registry(&self) -> ClientRpcAgentRegistry<'a> {
ClientRpcAgentRegistry {
client: self.client,
}
}
/// `mcp.*` sub-namespace.
pub fn mcp(&self) -> ClientRpcMcp<'a> {
ClientRpcMcp {
client: self.client,
}
}
/// `models.*` sub-namespace.
pub fn models(&self) -> ClientRpcModels<'a> {
ClientRpcModels {
client: self.client,
}
}
/// `secrets.*` sub-namespace.
pub fn secrets(&self) -> ClientRpcSecrets<'a> {
ClientRpcSecrets {
client: self.client,
}
}
/// `sessionFs.*` sub-namespace.
pub fn session_fs(&self) -> ClientRpcSessionFs<'a> {
ClientRpcSessionFs {
client: self.client,
}
}
/// `sessions.*` sub-namespace.
pub fn sessions(&self) -> ClientRpcSessions<'a> {
ClientRpcSessions {
client: self.client,
}
}
/// `skills.*` sub-namespace.
pub fn skills(&self) -> ClientRpcSkills<'a> {
ClientRpcSkills {
client: self.client,
}
}
/// `tools.*` sub-namespace.
pub fn tools(&self) -> ClientRpcTools<'a> {
ClientRpcTools {
client: self.client,
}
}
/// `user.*` sub-namespace.
pub fn user(&self) -> ClientRpcUser<'a> {
ClientRpcUser {
client: self.client,
}
}
/// Checks server responsiveness and returns protocol information.
///
/// Wire method: `ping`.
///
/// # Parameters
///
/// * `params` - Optional message to echo back to the caller.
///
/// # Returns
///
/// Server liveness response, including the echoed message, current server timestamp, and protocol version.
pub async fn ping(&self, params: PingRequest) -> Result<PingResult, Error> {
let wire_params = serde_json::to_value(params)?;
let _value = self
.client
.call(rpc_methods::PING, Some(wire_params))
.await?;
Ok(serde_json::from_value(_value)?)
}
/// Performs the SDK server connection handshake and validates the optional connection token.
///
/// Wire method: `connect`.
///
/// # Parameters
///
/// * `params` - Optional connection token presented by the SDK client during the handshake.
///
/// # Returns
///
/// Handshake result reporting the server's protocol version and package version on success.
pub(crate) async fn connect(&self, params: ConnectRequest) -> Result<ConnectResult, Error> {
let wire_params = serde_json::to_value(params)?;
let _value = self
.client
.call(rpc_methods::CONNECT, Some(wire_params))
.await?;
Ok(serde_json::from_value(_value)?)
}
}
/// `account.*` RPCs.
#[derive(Clone, Copy)]
pub struct ClientRpcAccount<'a> {
pub(crate) client: &'a Client,
}
impl<'a> ClientRpcAccount<'a> {
/// Gets Copilot quota usage for the authenticated user or supplied GitHub token.
///
/// Wire method: `account.getQuota`.
///
/// # Returns
///
/// Quota usage snapshots for the resolved user, keyed by quota type.
pub async fn get_quota(&self) -> Result<AccountGetQuotaResult, Error> {
let wire_params = serde_json::json!({});
let _value = self
.client
.call(rpc_methods::ACCOUNT_GETQUOTA, Some(wire_params))
.await?;
Ok(serde_json::from_value(_value)?)
}
/// Gets Copilot quota usage for the authenticated user or supplied GitHub token.
///
/// Wire method: `account.getQuota`.
///
/// # Parameters
///
/// * `params` - Optional GitHub token used to look up quota for a specific user instead of the global auth context.
///
/// # Returns
///
/// Quota usage snapshots for the resolved user, keyed by quota type.
pub async fn get_quota_with_params(
&self,
params: AccountGetQuotaRequest,
) -> Result<AccountGetQuotaResult, Error> {
let wire_params = serde_json::to_value(params)?;
let _value = self
.client
.call(rpc_methods::ACCOUNT_GETQUOTA, Some(wire_params))
.await?;
Ok(serde_json::from_value(_value)?)
}
}
/// `agentRegistry.*` RPCs.
#[derive(Clone, Copy)]
pub struct ClientRpcAgentRegistry<'a> {
pub(crate) client: &'a Client,
}
impl<'a> ClientRpcAgentRegistry<'a> {
/// Spawns a managed-server child with the supplied configuration and returns a discriminated-union result. The caller (typically the CLI controller) is responsible for attaching to the spawned child and sending any follow-up prompt. When the controller-local spawn gate is closed the server returns JSON-RPC MethodNotFound.
///
/// Wire method: `agentRegistry.spawn`.
///
/// # Parameters
///
/// * `params` - Inputs to spawn a managed-server child via the controller's spawn delegate.
///
/// # Returns
///
/// Outcome of an agentRegistry.spawn call.
///
/// <div class="warning">
///
/// **Experimental.** This API is part of an experimental wire-protocol surface
/// and may change or be removed in future SDK or CLI releases. Pin both the
/// SDK and CLI versions if your code depends on it.
///
/// </div>
pub async fn spawn(
&self,
params: AgentRegistrySpawnRequest,
) -> Result<AgentRegistrySpawnResult, Error> {
let wire_params = serde_json::to_value(params)?;
let _value = self
.client
.call(rpc_methods::AGENTREGISTRY_SPAWN, Some(wire_params))
.await?;
Ok(serde_json::from_value(_value)?)
}
}
/// `mcp.*` RPCs.
#[derive(Clone, Copy)]
pub struct ClientRpcMcp<'a> {
pub(crate) client: &'a Client,
}
impl<'a> ClientRpcMcp<'a> {
/// `mcp.config.*` sub-namespace.
pub fn config(&self) -> ClientRpcMcpConfig<'a> {
ClientRpcMcpConfig {
client: self.client,
}
}
/// Discovers MCP servers from user, workspace, plugin, and builtin sources.
///
/// Wire method: `mcp.discover`.
///
/// # Parameters
///
/// * `params` - Optional working directory used as context for MCP server discovery.
///
/// # Returns
///
/// MCP servers discovered from user, workspace, plugin, and built-in sources.
pub async fn discover(&self, params: McpDiscoverRequest) -> Result<McpDiscoverResult, Error> {
let wire_params = serde_json::to_value(params)?;
let _value = self
.client
.call(rpc_methods::MCP_DISCOVER, Some(wire_params))
.await?;
Ok(serde_json::from_value(_value)?)
}
}
/// `mcp.config.*` RPCs.
#[derive(Clone, Copy)]
pub struct ClientRpcMcpConfig<'a> {
pub(crate) client: &'a Client,
}
impl<'a> ClientRpcMcpConfig<'a> {
/// Lists MCP servers from user configuration.
///
/// Wire method: `mcp.config.list`.
///
/// # Returns
///
/// User-configured MCP servers, keyed by server name.
pub async fn list(&self) -> Result<McpConfigList, Error> {
let wire_params = serde_json::json!({});
let _value = self
.client
.call(rpc_methods::MCP_CONFIG_LIST, Some(wire_params))
.await?;
Ok(serde_json::from_value(_value)?)
}
/// Adds an MCP server to user configuration.
///
/// Wire method: `mcp.config.add`.
///
/// # Parameters
///
/// * `params` - MCP server name and configuration to add to user configuration.
pub async fn add(&self, params: McpConfigAddRequest) -> Result<(), Error> {
let wire_params = serde_json::to_value(params)?;
let _value = self
.client
.call(rpc_methods::MCP_CONFIG_ADD, Some(wire_params))
.await?;
Ok(())
}
/// Updates an MCP server in user configuration.
///
/// Wire method: `mcp.config.update`.
///
/// # Parameters
///
/// * `params` - MCP server name and replacement configuration to write to user configuration.
pub async fn update(&self, params: McpConfigUpdateRequest) -> Result<(), Error> {
let wire_params = serde_json::to_value(params)?;
let _value = self
.client
.call(rpc_methods::MCP_CONFIG_UPDATE, Some(wire_params))
.await?;
Ok(())
}
/// Removes an MCP server from user configuration.
///
/// Wire method: `mcp.config.remove`.
///
/// # Parameters
///
/// * `params` - MCP server name to remove from user configuration.
pub async fn remove(&self, params: McpConfigRemoveRequest) -> Result<(), Error> {
let wire_params = serde_json::to_value(params)?;
let _value = self
.client
.call(rpc_methods::MCP_CONFIG_REMOVE, Some(wire_params))
.await?;
Ok(())
}
/// Enables MCP servers in user configuration for new sessions.
///
/// Wire method: `mcp.config.enable`.
///
/// # Parameters
///
/// * `params` - MCP server names to enable for new sessions.
pub async fn enable(&self, params: McpConfigEnableRequest) -> Result<(), Error> {
let wire_params = serde_json::to_value(params)?;
let _value = self
.client
.call(rpc_methods::MCP_CONFIG_ENABLE, Some(wire_params))
.await?;
Ok(())
}
/// Disables MCP servers in user configuration for new sessions.
///
/// Wire method: `mcp.config.disable`.
///
/// # Parameters
///
/// * `params` - MCP server names to disable for new sessions.
pub async fn disable(&self, params: McpConfigDisableRequest) -> Result<(), Error> {
let wire_params = serde_json::to_value(params)?;
let _value = self
.client
.call(rpc_methods::MCP_CONFIG_DISABLE, Some(wire_params))
.await?;
Ok(())
}
/// Drops this runtime process's in-memory MCP server-definition cache so the next MCP config read observes disk.
///
/// Wire method: `mcp.config.reload`.
pub async fn reload(&self) -> Result<(), Error> {
let wire_params = serde_json::json!({});
let _value = self
.client
.call(rpc_methods::MCP_CONFIG_RELOAD, Some(wire_params))
.await?;
Ok(())
}
}
/// `models.*` RPCs.
#[derive(Clone, Copy)]
pub struct ClientRpcModels<'a> {
pub(crate) client: &'a Client,
}
impl<'a> ClientRpcModels<'a> {
/// Lists Copilot models available to the authenticated user.
///
/// Wire method: `models.list`.
///
/// # Returns
///
/// List of Copilot models available to the resolved user, including capabilities and billing metadata.
pub async fn list(&self) -> Result<ModelList, Error> {
let wire_params = serde_json::json!({});
let _value = self
.client
.call(rpc_methods::MODELS_LIST, Some(wire_params))
.await?;
Ok(serde_json::from_value(_value)?)
}
/// Lists Copilot models available to the authenticated user.
///
/// Wire method: `models.list`.
///
/// # Parameters
///
/// * `params` - Optional GitHub token used to list models for a specific user instead of the global auth context.
///
/// # Returns
///
/// List of Copilot models available to the resolved user, including capabilities and billing metadata.
pub async fn list_with_params(&self, params: ModelsListRequest) -> Result<ModelList, Error> {
let wire_params = serde_json::to_value(params)?;
let _value = self
.client
.call(rpc_methods::MODELS_LIST, Some(wire_params))
.await?;
Ok(serde_json::from_value(_value)?)
}
}
/// `secrets.*` RPCs.
#[derive(Clone, Copy)]
pub struct ClientRpcSecrets<'a> {
pub(crate) client: &'a Client,
}
impl<'a> ClientRpcSecrets<'a> {
/// Registers secret values for redaction in session logs and exports. The SDK calls this to inject dynamically generated secret values (e.g., OIDC tokens).
///
/// Wire method: `secrets.addFilterValues`.
///
/// # Parameters
///
/// * `params` - Secret values to add to the redaction filter.
///
/// # Returns
///
/// Confirmation that the secret values were registered.
pub async fn add_filter_values(
&self,
params: SecretsAddFilterValuesRequest,
) -> Result<SecretsAddFilterValuesResult, Error> {
let wire_params = serde_json::to_value(params)?;
let _value = self
.client
.call(rpc_methods::SECRETS_ADDFILTERVALUES, Some(wire_params))
.await?;
Ok(serde_json::from_value(_value)?)
}
}
/// `sessionFs.*` RPCs.
#[derive(Clone, Copy)]
pub struct ClientRpcSessionFs<'a> {
pub(crate) client: &'a Client,
}
impl<'a> ClientRpcSessionFs<'a> {
/// Registers an SDK client as the session filesystem provider.
///
/// Wire method: `sessionFs.setProvider`.
///
/// # Parameters
///
/// * `params` - Initial working directory, session-state path layout, and path conventions used to register the calling SDK client as the session filesystem provider.
///
/// # Returns
///
/// Indicates whether the calling client was registered as the session filesystem provider.
pub async fn set_provider(
&self,
params: SessionFsSetProviderRequest,
) -> Result<SessionFsSetProviderResult, Error> {
let wire_params = serde_json::to_value(params)?;
let _value = self
.client
.call(rpc_methods::SESSIONFS_SETPROVIDER, Some(wire_params))
.await?;
Ok(serde_json::from_value(_value)?)
}
}
/// `sessions.*` RPCs.
#[derive(Clone, Copy)]
pub struct ClientRpcSessions<'a> {
pub(crate) client: &'a Client,
}
impl<'a> ClientRpcSessions<'a> {
/// Creates a new session by forking persisted history from an existing session.
///
/// Wire method: `sessions.fork`.
///
/// # Parameters
///
/// * `params` - Source session identifier to fork from, optional event-ID boundary, and optional friendly name for the new session.
///
/// # Returns
///
/// Identifier and optional friendly name assigned to the newly forked session.
///
/// <div class="warning">
///
/// **Experimental.** This API is part of an experimental wire-protocol surface
/// and may change or be removed in future SDK or CLI releases. Pin both the
/// SDK and CLI versions if your code depends on it.
///
/// </div>
pub async fn fork(&self, params: SessionsForkRequest) -> Result<SessionsForkResult, Error> {
let wire_params = serde_json::to_value(params)?;
let _value = self
.client
.call(rpc_methods::SESSIONS_FORK, Some(wire_params))
.await?;
Ok(serde_json::from_value(_value)?)
}
/// Connects to an existing remote session and exposes it as an SDK session.
///
/// Wire method: `sessions.connect`.
///
/// # Parameters
///
/// * `params` - Remote session connection parameters.
///
/// # Returns
///
/// Remote session connection result.
///
/// <div class="warning">
///
/// **Experimental.** This API is part of an experimental wire-protocol surface
/// and may change or be removed in future SDK or CLI releases. Pin both the
/// SDK and CLI versions if your code depends on it.
///
/// </div>
pub async fn connect(
&self,
params: ConnectRemoteSessionParams,
) -> Result<RemoteSessionConnectionResult, Error> {
let wire_params = serde_json::to_value(params)?;
let _value = self
.client
.call(rpc_methods::SESSIONS_CONNECT, Some(wire_params))
.await?;
Ok(serde_json::from_value(_value)?)
}
/// Lists persisted sessions, optionally filtered by working-directory context.
///
/// Wire method: `sessions.list`.
///
/// # Returns
///
/// Persisted sessions matching the filter, ordered most-recently-modified first.
///
/// <div class="warning">
///
/// **Experimental.** This API is part of an experimental wire-protocol surface
/// and may change or be removed in future SDK or CLI releases. Pin both the
/// SDK and CLI versions if your code depends on it.
///
/// </div>
pub async fn list(&self) -> Result<SessionList, Error> {
let wire_params = serde_json::json!({});
let _value = self
.client
.call(rpc_methods::SESSIONS_LIST, Some(wire_params))
.await?;
Ok(serde_json::from_value(_value)?)
}
/// Lists persisted sessions, optionally filtered by working-directory context.
///
/// Wire method: `sessions.list`.
///
/// # Parameters
///
/// * `params` - Optional metadata-load limit and filters applied to the returned sessions.
///
/// # Returns
///
/// Persisted sessions matching the filter, ordered most-recently-modified first.
///
/// <div class="warning">
///
/// **Experimental.** This API is part of an experimental wire-protocol surface
/// and may change or be removed in future SDK or CLI releases. Pin both the
/// SDK and CLI versions if your code depends on it.
///
/// </div>
pub async fn list_with_params(
&self,
params: SessionsListRequest,
) -> Result<SessionList, Error> {
let wire_params = serde_json::to_value(params)?;
let _value = self
.client
.call(rpc_methods::SESSIONS_LIST, Some(wire_params))
.await?;
Ok(serde_json::from_value(_value)?)
}
/// Finds the local session bound to a GitHub task ID, if any.
///
/// Wire method: `sessions.findByTaskId`.
///
/// # Parameters
///
/// * `params` - GitHub task ID to look up.
///
/// # Returns
///
/// ID of the local session bound to the given GitHub task, or omitted when none.
///
/// <div class="warning">
///
/// **Experimental.** This API is part of an experimental wire-protocol surface
/// and may change or be removed in future SDK or CLI releases. Pin both the
/// SDK and CLI versions if your code depends on it.
///
/// </div>
pub async fn find_by_task_id(
&self,
params: SessionsFindByTaskIDRequest,
) -> Result<SessionsFindByTaskIDResult, Error> {
let wire_params = serde_json::to_value(params)?;
let _value = self
.client
.call(rpc_methods::SESSIONS_FINDBYTASKID, Some(wire_params))
.await?;
Ok(serde_json::from_value(_value)?)
}
/// Resolves a UUID prefix to a unique session ID, if exactly one session matches.
///
/// Wire method: `sessions.findByPrefix`.
///
/// # Parameters
///
/// * `params` - UUID prefix to resolve to a unique session ID.
///
/// # Returns
///
/// Session ID matching the prefix, omitted when no unique match exists.
///
/// <div class="warning">
///
/// **Experimental.** This API is part of an experimental wire-protocol surface
/// and may change or be removed in future SDK or CLI releases. Pin both the
/// SDK and CLI versions if your code depends on it.
///
/// </div>
pub async fn find_by_prefix(
&self,
params: SessionsFindByPrefixRequest,
) -> Result<SessionsFindByPrefixResult, Error> {
let wire_params = serde_json::to_value(params)?;
let _value = self
.client
.call(rpc_methods::SESSIONS_FINDBYPREFIX, Some(wire_params))
.await?;
Ok(serde_json::from_value(_value)?)
}
/// Returns the most-relevant prior session for a given working-directory context.
///
/// Wire method: `sessions.getLastForContext`.
///
/// # Parameters
///
/// * `params` - Optional working-directory context used to score session relevance.
///
/// # Returns
///
/// Most-relevant session ID for the supplied context, or omitted when no sessions exist.
///
/// <div class="warning">
///
/// **Experimental.** This API is part of an experimental wire-protocol surface
/// and may change or be removed in future SDK or CLI releases. Pin both the
/// SDK and CLI versions if your code depends on it.
///
/// </div>
pub async fn get_last_for_context(
&self,
params: SessionsGetLastForContextRequest,
) -> Result<SessionsGetLastForContextResult, Error> {
let wire_params = serde_json::to_value(params)?;
let _value = self
.client
.call(rpc_methods::SESSIONS_GETLASTFORCONTEXT, Some(wire_params))
.await?;
Ok(serde_json::from_value(_value)?)
}
/// Computes the absolute path to a session's persisted events.jsonl file.
///
/// Wire method: `sessions.getEventFilePath`.
///
/// # Parameters
///
/// * `params` - Session ID whose event-log file path to compute.
///
/// # Returns
///
/// Absolute path to the session's events.jsonl file on disk.
///
/// <div class="warning">
///
/// **Experimental.** This API is part of an experimental wire-protocol surface
/// and may change or be removed in future SDK or CLI releases. Pin both the
/// SDK and CLI versions if your code depends on it.
///
/// </div>
pub async fn get_event_file_path(
&self,
params: SessionsGetEventFilePathRequest,
) -> Result<SessionsGetEventFilePathResult, Error> {
let wire_params = serde_json::to_value(params)?;
let _value = self
.client
.call(rpc_methods::SESSIONS_GETEVENTFILEPATH, Some(wire_params))
.await?;
Ok(serde_json::from_value(_value)?)
}
/// Returns the on-disk byte size of each session's workspace directory.
///
/// Wire method: `sessions.getSizes`.
///
/// # Returns
///
/// Map of sessionId -> on-disk size in bytes for each session's workspace directory.
///
/// <div class="warning">
///
/// **Experimental.** This API is part of an experimental wire-protocol surface
/// and may change or be removed in future SDK or CLI releases. Pin both the
/// SDK and CLI versions if your code depends on it.
///
/// </div>
pub async fn get_sizes(&self) -> Result<SessionSizes, Error> {
let wire_params = serde_json::json!({});
let _value = self
.client
.call(rpc_methods::SESSIONS_GETSIZES, Some(wire_params))
.await?;
Ok(serde_json::from_value(_value)?)
}
/// Returns the subset of the supplied session IDs that are currently held by another running process.
///
/// Wire method: `sessions.checkInUse`.
///
/// # Parameters
///
/// * `params` - Session IDs to test for live in-use locks.
///
/// # Returns
///
/// Session IDs from the input set that are currently in use by another process.
///
/// <div class="warning">
///
/// **Experimental.** This API is part of an experimental wire-protocol surface
/// and may change or be removed in future SDK or CLI releases. Pin both the
/// SDK and CLI versions if your code depends on it.
///
/// </div>
pub async fn check_in_use(
&self,
params: SessionsCheckInUseRequest,
) -> Result<SessionsCheckInUseResult, Error> {
let wire_params = serde_json::to_value(params)?;
let _value = self
.client
.call(rpc_methods::SESSIONS_CHECKINUSE, Some(wire_params))
.await?;
Ok(serde_json::from_value(_value)?)
}
/// Returns a session's persisted remote-steerable flag, if any has been recorded.
///
/// Wire method: `sessions.getPersistedRemoteSteerable`.
///
/// # Parameters
///
/// * `params` - Session ID to look up the persisted remote-steerable flag for.
///
/// # Returns
///
/// The session's persisted remote-steerable flag, or omitted when no value has been persisted.
///
/// <div class="warning">
///
/// **Experimental.** This API is part of an experimental wire-protocol surface
/// and may change or be removed in future SDK or CLI releases. Pin both the
/// SDK and CLI versions if your code depends on it.
///
/// </div>
pub async fn get_persisted_remote_steerable(
&self,
params: SessionsGetPersistedRemoteSteerableRequest,
) -> Result<SessionsGetPersistedRemoteSteerableResult, Error> {
let wire_params = serde_json::to_value(params)?;
let _value = self
.client
.call(
rpc_methods::SESSIONS_GETPERSISTEDREMOTESTEERABLE,
Some(wire_params),
)
.await?;
Ok(serde_json::from_value(_value)?)
}
/// Closes a session: emits shutdown, flushes pending events, releases the in-use lock, and disposes the active session.
///
/// Wire method: `sessions.close`.
///
/// # Parameters
///
/// * `params` - Session ID to close.
///
/// # Returns
///
/// Closes a session: emits shutdown, flushes pending events to disk, releases the in-use lock, disposes the active session. Idempotent: succeeds even if the session is not currently active.
///
/// <div class="warning">
///
/// **Experimental.** This API is part of an experimental wire-protocol surface
/// and may change or be removed in future SDK or CLI releases. Pin both the
/// SDK and CLI versions if your code depends on it.
///
/// </div>
pub async fn close(&self, params: SessionsCloseRequest) -> Result<SessionsCloseResult, Error> {
let wire_params = serde_json::to_value(params)?;
let _value = self
.client
.call(rpc_methods::SESSIONS_CLOSE, Some(wire_params))
.await?;
Ok(serde_json::from_value(_value)?)
}
/// Closes, deactivates, and deletes a set of sessions, returning the bytes freed per session.
///
/// Wire method: `sessions.bulkDelete`.
///
/// # Parameters
///
/// * `params` - Session IDs to close, deactivate, and delete from disk.
///
/// # Returns
///
/// Map of sessionId -> bytes freed by removing the session's workspace directory.
///
/// <div class="warning">
///
/// **Experimental.** This API is part of an experimental wire-protocol surface
/// and may change or be removed in future SDK or CLI releases. Pin both the
/// SDK and CLI versions if your code depends on it.
///
/// </div>
pub async fn bulk_delete(
&self,
params: SessionsBulkDeleteRequest,
) -> Result<SessionBulkDeleteResult, Error> {
let wire_params = serde_json::to_value(params)?;
let _value = self
.client
.call(rpc_methods::SESSIONS_BULKDELETE, Some(wire_params))
.await?;
Ok(serde_json::from_value(_value)?)
}
/// Deletes sessions older than the given threshold, with optional dry-run and exclusion list.
///
/// Wire method: `sessions.pruneOld`.
///
/// # Parameters
///
/// * `params` - Age threshold and optional flags controlling which old sessions are pruned (or simulated when dryRun is true).
///
/// # Returns
///
/// Outcome of the prune operation: deleted IDs, dry-run candidates, skipped IDs, total bytes freed, and the dry-run flag.
///
/// <div class="warning">
///
/// **Experimental.** This API is part of an experimental wire-protocol surface
/// and may change or be removed in future SDK or CLI releases. Pin both the
/// SDK and CLI versions if your code depends on it.
///
/// </div>
pub async fn prune_old(
&self,
params: SessionsPruneOldRequest,
) -> Result<SessionPruneResult, Error> {
let wire_params = serde_json::to_value(params)?;
let _value = self
.client
.call(rpc_methods::SESSIONS_PRUNEOLD, Some(wire_params))
.await?;
Ok(serde_json::from_value(_value)?)
}
/// Flushes a session's pending events to disk.
///
/// Wire method: `sessions.save`.
///
/// # Parameters
///
/// * `params` - Session ID whose pending events should be flushed to disk.
///
/// # Returns
///
/// Flush a session's pending events to disk. No-op when no writer exists for the session (e.g., already closed).
///
/// <div class="warning">
///
/// **Experimental.** This API is part of an experimental wire-protocol surface
/// and may change or be removed in future SDK or CLI releases. Pin both the
/// SDK and CLI versions if your code depends on it.
///
/// </div>
pub async fn save(&self, params: SessionsSaveRequest) -> Result<SessionsSaveResult, Error> {
let wire_params = serde_json::to_value(params)?;
let _value = self
.client
.call(rpc_methods::SESSIONS_SAVE, Some(wire_params))
.await?;
Ok(serde_json::from_value(_value)?)
}
/// Releases the in-use lock held by this process for a session.
///
/// Wire method: `sessions.releaseLock`.
///
/// # Parameters
///
/// * `params` - Session ID whose in-use lock should be released.
///
/// # Returns
///
/// Release the in-use lock held by this process for the given session. No-op when this process does not currently hold a lock for the session.
///
/// <div class="warning">
///
/// **Experimental.** This API is part of an experimental wire-protocol surface
/// and may change or be removed in future SDK or CLI releases. Pin both the
/// SDK and CLI versions if your code depends on it.
///
/// </div>
pub async fn release_lock(
&self,
params: SessionsReleaseLockRequest,
) -> Result<SessionsReleaseLockResult, Error> {
let wire_params = serde_json::to_value(params)?;
let _value = self
.client
.call(rpc_methods::SESSIONS_RELEASELOCK, Some(wire_params))
.await?;
Ok(serde_json::from_value(_value)?)
}
/// Backfills missing summary and context fields on the supplied session metadata records.
///
/// Wire method: `sessions.enrichMetadata`.
///
/// # Parameters
///
/// * `params` - Session metadata records to enrich with summary and context information.
///
/// # Returns
///
/// The enriched metadata records, with summary and context fields backfilled where available. Sessions confirmed empty and unnamed are omitted.
///
/// <div class="warning">
///
/// **Experimental.** This API is part of an experimental wire-protocol surface
/// and may change or be removed in future SDK or CLI releases. Pin both the
/// SDK and CLI versions if your code depends on it.
///
/// </div>
pub async fn enrich_metadata(
&self,
params: SessionsEnrichMetadataRequest,
) -> Result<SessionEnrichMetadataResult, Error> {
let wire_params = serde_json::to_value(params)?;
let _value = self
.client
.call(rpc_methods::SESSIONS_ENRICHMETADATA, Some(wire_params))
.await?;
Ok(serde_json::from_value(_value)?)
}
/// Reloads user, plugin, and (optionally) repo hooks on the active session.
///
/// Wire method: `sessions.reloadPluginHooks`.
///
/// # Parameters
///
/// * `params` - Active session ID and an optional flag for deferring repo-level hooks until folder trust.
///
/// # Returns
///