-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Expand file tree
/
Copy pathrpc.rs
More file actions
8665 lines (8277 loc) · 300 KB
/
Copy pathrpc.rs
File metadata and controls
8665 lines (8277 loc) · 300 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)]
#![allow(deprecated)]
#![allow(dead_code)]
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,
}
}
/// `agents.*` sub-namespace.
pub fn agents(&self) -> ClientRpcAgents<'a> {
ClientRpcAgents {
client: self.client,
}
}
/// `instructions.*` sub-namespace.
pub fn instructions(&self) -> ClientRpcInstructions<'a> {
ClientRpcInstructions {
client: self.client,
}
}
/// `llmInference.*` sub-namespace.
pub fn llm_inference(&self) -> ClientRpcLlmInference<'a> {
ClientRpcLlmInference {
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,
}
}
/// `plugins.*` sub-namespace.
pub fn plugins(&self) -> ClientRpcPlugins<'a> {
ClientRpcPlugins {
client: self.client,
}
}
/// `runtime.*` sub-namespace.
pub fn runtime(&self) -> ClientRpcRuntime<'a> {
ClientRpcRuntime {
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.
///
/// <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 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. Marked internal because this is JSON-RPC transport plumbing invoked automatically by an SDK client's own `connect()` wrapper, not a user-facing method. Stays internal as long as the SDK client owns the handshake; would only become public if the SDK ever exposed the raw schema surface to consumers without a connection wrapper.
///
/// Wire method: `connect`.
///
/// # Parameters
///
/// * `params` - Parameters for the `server.connect` handshake: an optional connection token and optional connection-level opt-ins (e.g. GitHub telemetry forwarding).
///
/// # Returns
///
/// Handshake result reporting the server's protocol version and package version on success.
///
/// <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(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.
///
/// <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_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.
///
/// <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_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)?)
}
/// Gets the currently active authentication credentials from the global auth manager.
///
/// Wire method: `account.getCurrentAuth`.
///
/// # Returns
///
/// Current authentication state
///
/// <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_current_auth(&self) -> Result<AccountGetCurrentAuthResult, Error> {
let wire_params = serde_json::json!({});
let _value = self
.client
.call(rpc_methods::ACCOUNT_GETCURRENTAUTH, Some(wire_params))
.await?;
Ok(serde_json::from_value(_value)?)
}
/// Gets all authenticated users available for account switching.
///
/// Wire method: `account.getAllUsers`.
///
/// # Returns
///
/// List of all authenticated users
///
/// <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_all_users(&self) -> Result<AccountGetAllUsersResult, Error> {
let wire_params = serde_json::json!({});
let _value = self
.client
.call(rpc_methods::ACCOUNT_GETALLUSERS, Some(wire_params))
.await?;
Ok(serde_json::from_value(_value)?)
}
/// Stores authentication credentials after successful login (e.g., device code flow).
///
/// Wire method: `account.login`.
///
/// # Parameters
///
/// * `params` - Credentials to store after successful authentication
///
/// # Returns
///
/// Result of a successful login; throws on failure
///
/// <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 login(&self, params: AccountLoginRequest) -> Result<AccountLoginResult, Error> {
let wire_params = serde_json::to_value(params)?;
let _value = self
.client
.call(rpc_methods::ACCOUNT_LOGIN, Some(wire_params))
.await?;
Ok(serde_json::from_value(_value)?)
}
/// Removes user authentication from keychain and persisted state.
///
/// Wire method: `account.logout`.
///
/// # Parameters
///
/// * `params` - User to log out
///
/// # Returns
///
/// Logout result indicating if more users remain
///
/// <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 logout(&self, params: AccountLogoutRequest) -> Result<AccountLogoutResult, Error> {
let wire_params = serde_json::to_value(params)?;
let _value = self
.client
.call(rpc_methods::ACCOUNT_LOGOUT, 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)?)
}
}
/// `agents.*` RPCs.
#[derive(Clone, Copy)]
pub struct ClientRpcAgents<'a> {
pub(crate) client: &'a Client,
}
impl<'a> ClientRpcAgents<'a> {
/// Discovers custom agents across user, project, plugin, and remote sources.
///
/// Wire method: `agents.discover`.
///
/// # Parameters
///
/// * `params` - Optional project paths to include in agent discovery.
///
/// # Returns
///
/// Agents discovered across user, project, plugin, and remote sources.
///
/// <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 discover(&self, params: AgentsDiscoverRequest) -> Result<ServerAgentList, Error> {
let wire_params = serde_json::to_value(params)?;
let _value = self
.client
.call(rpc_methods::AGENTS_DISCOVER, Some(wire_params))
.await?;
Ok(serde_json::from_value(_value)?)
}
/// Returns the canonical directories where a client may create custom agents that the runtime will recognize, including ones that do not exist yet. Project directories become active once created.
///
/// Wire method: `agents.getDiscoveryPaths`.
///
/// # Parameters
///
/// * `params` - Optional project paths to include when enumerating agent discovery directories.
///
/// # Returns
///
/// Canonical locations where custom agents can be created so the runtime will recognize them.
///
/// <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_discovery_paths(
&self,
params: AgentsGetDiscoveryPathsRequest,
) -> Result<AgentDiscoveryPathList, Error> {
let wire_params = serde_json::to_value(params)?;
let _value = self
.client
.call(rpc_methods::AGENTS_GETDISCOVERYPATHS, Some(wire_params))
.await?;
Ok(serde_json::from_value(_value)?)
}
}
/// `instructions.*` RPCs.
#[derive(Clone, Copy)]
pub struct ClientRpcInstructions<'a> {
pub(crate) client: &'a Client,
}
impl<'a> ClientRpcInstructions<'a> {
/// Discovers instruction sources across user, repository, and plugin sources.
///
/// Wire method: `instructions.discover`.
///
/// # Parameters
///
/// * `params` - Optional project paths to include in instruction discovery.
///
/// # Returns
///
/// Instruction sources discovered across user, repository, and plugin sources.
///
/// <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 discover(
&self,
params: InstructionsDiscoverRequest,
) -> Result<ServerInstructionSourceList, Error> {
let wire_params = serde_json::to_value(params)?;
let _value = self
.client
.call(rpc_methods::INSTRUCTIONS_DISCOVER, Some(wire_params))
.await?;
Ok(serde_json::from_value(_value)?)
}
/// Returns the canonical files and directories where a client may create custom instructions that the runtime will recognize, including ones that do not exist yet. Repository targets become active once created.
///
/// Wire method: `instructions.getDiscoveryPaths`.
///
/// # Parameters
///
/// * `params` - Optional project paths to include when enumerating instruction discovery targets.
///
/// # Returns
///
/// Canonical files and directories where custom instructions can be created so the runtime will recognize them.
///
/// <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_discovery_paths(
&self,
params: InstructionsGetDiscoveryPathsRequest,
) -> Result<InstructionDiscoveryPathList, Error> {
let wire_params = serde_json::to_value(params)?;
let _value = self
.client
.call(
rpc_methods::INSTRUCTIONS_GETDISCOVERYPATHS,
Some(wire_params),
)
.await?;
Ok(serde_json::from_value(_value)?)
}
}
/// `llmInference.*` RPCs.
#[derive(Clone, Copy)]
pub struct ClientRpcLlmInference<'a> {
pub(crate) client: &'a Client,
}
impl<'a> ClientRpcLlmInference<'a> {
/// Registers an SDK client as the LLM inference callback provider.
///
/// Wire method: `llmInference.setProvider`.
///
/// # Returns
///
/// Indicates whether the calling client was registered as the LLM inference provider.
///
/// <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 set_provider(&self) -> Result<LlmInferenceSetProviderResult, Error> {
let wire_params = serde_json::json!({});
let _value = self
.client
.call(rpc_methods::LLMINFERENCE_SETPROVIDER, Some(wire_params))
.await?;
Ok(serde_json::from_value(_value)?)
}
/// Delivers the response head (status + headers) for an in-flight request, correlated by the requestId the runtime supplied in httpRequestStart. Must be called exactly once per request before any httpResponseChunk frames.
///
/// Wire method: `llmInference.httpResponseStart`.
///
/// # Parameters
///
/// * `params` - Response head.
///
/// # Returns
///
/// Whether the start frame was accepted.
///
/// <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 http_response_start(
&self,
params: LlmInferenceHttpResponseStartRequest,
) -> Result<LlmInferenceHttpResponseStartResult, Error> {
let wire_params = serde_json::to_value(params)?;
let _value = self
.client
.call(
rpc_methods::LLMINFERENCE_HTTPRESPONSESTART,
Some(wire_params),
)
.await?;
Ok(serde_json::from_value(_value)?)
}
/// Delivers a body byte range (or a terminal transport error) for an in-flight response, correlated by requestId. Set `end` true on the last chunk. When `error` is set the response terminates with a transport-level failure and the runtime raises an APIConnectionError.
///
/// Wire method: `llmInference.httpResponseChunk`.
///
/// # Parameters
///
/// * `params` - A response body chunk or terminal error.
///
/// # Returns
///
/// Whether the chunk was accepted.
///
/// <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 http_response_chunk(
&self,
params: LlmInferenceHttpResponseChunkRequest,
) -> Result<LlmInferenceHttpResponseChunkResult, Error> {
let wire_params = serde_json::to_value(params)?;
let _value = self
.client
.call(
rpc_methods::LLMINFERENCE_HTTPRESPONSECHUNK,
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.
///
/// <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 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.
///
/// <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<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.
///
/// <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 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.
///
/// <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 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.
///
/// <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 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.
///
/// <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 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.
///
/// <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 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`.
///
/// <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 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.
///
/// <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<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.
///
/// <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: 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)?)
}
}
/// `plugins.*` RPCs.
#[derive(Clone, Copy)]
pub struct ClientRpcPlugins<'a> {
pub(crate) client: &'a Client,
}
impl<'a> ClientRpcPlugins<'a> {
/// `plugins.marketplaces.*` sub-namespace.
pub fn marketplaces(&self) -> ClientRpcPluginsMarketplaces<'a> {
ClientRpcPluginsMarketplaces {
client: self.client,
}
}
/// Lists plugins installed in user/global state.
///
/// Wire method: `plugins.list`.
///
/// # Returns
///
/// Plugins installed in user/global state.
///
/// <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<PluginListResult, Error> {
let wire_params = serde_json::json!({});
let _value = self
.client
.call(rpc_methods::PLUGINS_LIST, Some(wire_params))
.await?;
Ok(serde_json::from_value(_value)?)
}
/// Installs a plugin from a marketplace, GitHub repo, URL, or local path.
///
/// Wire method: `plugins.install`.
///
/// # Parameters
///
/// * `params` - Plugin source and optional working directory for relative-path resolution.
///
/// # Returns
///
/// Result of installing a plugin.
///
/// <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 install(
&self,
params: PluginsInstallRequest,
) -> Result<PluginInstallResult, Error> {
let wire_params = serde_json::to_value(params)?;
let _value = self
.client
.call(rpc_methods::PLUGINS_INSTALL, Some(wire_params))
.await?;
Ok(serde_json::from_value(_value)?)
}
/// Uninstalls an installed plugin.
///
/// Wire method: `plugins.uninstall`.
///
/// # Parameters
///
/// * `params` - Name (or spec) of the plugin to uninstall.
///
/// <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 uninstall(&self, params: PluginsUninstallRequest) -> Result<(), Error> {
let wire_params = serde_json::to_value(params)?;
let _value = self
.client
.call(rpc_methods::PLUGINS_UNINSTALL, Some(wire_params))
.await?;
Ok(())
}