github_copilot_sdk/generated/rpc.rs
1//! Auto-generated typed JSON-RPC namespace — do not edit manually.
2//!
3//! Generated from `api.schema.json` by `scripts/codegen/rust.ts`. The
4//! [`ClientRpc`] and [`SessionRpc`] view structs let callers reach every
5//! protocol method through a typed namespace tree, so wire method names
6//! and request/response shapes live in exactly one place — this file.
7
8#![allow(missing_docs)]
9#![allow(clippy::too_many_arguments)]
10#![allow(deprecated)]
11#![allow(dead_code)]
12
13use super::api_types::{rpc_methods, *};
14use super::session_events::SessionMode;
15use crate::session::Session;
16use crate::{Client, Error};
17
18/// Typed view over the [`Client`]'s server-level RPC namespace.
19#[derive(Clone, Copy)]
20pub struct ClientRpc<'a> {
21 pub(crate) client: &'a Client,
22}
23
24impl<'a> ClientRpc<'a> {
25 /// `account.*` sub-namespace.
26 pub fn account(&self) -> ClientRpcAccount<'a> {
27 ClientRpcAccount {
28 client: self.client,
29 }
30 }
31
32 /// `agentRegistry.*` sub-namespace.
33 pub fn agent_registry(&self) -> ClientRpcAgentRegistry<'a> {
34 ClientRpcAgentRegistry {
35 client: self.client,
36 }
37 }
38
39 /// `agents.*` sub-namespace.
40 pub fn agents(&self) -> ClientRpcAgents<'a> {
41 ClientRpcAgents {
42 client: self.client,
43 }
44 }
45
46 /// `instructions.*` sub-namespace.
47 pub fn instructions(&self) -> ClientRpcInstructions<'a> {
48 ClientRpcInstructions {
49 client: self.client,
50 }
51 }
52
53 /// `llmInference.*` sub-namespace.
54 pub fn llm_inference(&self) -> ClientRpcLlmInference<'a> {
55 ClientRpcLlmInference {
56 client: self.client,
57 }
58 }
59
60 /// `mcp.*` sub-namespace.
61 pub fn mcp(&self) -> ClientRpcMcp<'a> {
62 ClientRpcMcp {
63 client: self.client,
64 }
65 }
66
67 /// `models.*` sub-namespace.
68 pub fn models(&self) -> ClientRpcModels<'a> {
69 ClientRpcModels {
70 client: self.client,
71 }
72 }
73
74 /// `plugins.*` sub-namespace.
75 pub fn plugins(&self) -> ClientRpcPlugins<'a> {
76 ClientRpcPlugins {
77 client: self.client,
78 }
79 }
80
81 /// `runtime.*` sub-namespace.
82 pub fn runtime(&self) -> ClientRpcRuntime<'a> {
83 ClientRpcRuntime {
84 client: self.client,
85 }
86 }
87
88 /// `secrets.*` sub-namespace.
89 pub fn secrets(&self) -> ClientRpcSecrets<'a> {
90 ClientRpcSecrets {
91 client: self.client,
92 }
93 }
94
95 /// `sessionFs.*` sub-namespace.
96 pub fn session_fs(&self) -> ClientRpcSessionFs<'a> {
97 ClientRpcSessionFs {
98 client: self.client,
99 }
100 }
101
102 /// `sessions.*` sub-namespace.
103 pub fn sessions(&self) -> ClientRpcSessions<'a> {
104 ClientRpcSessions {
105 client: self.client,
106 }
107 }
108
109 /// `skills.*` sub-namespace.
110 pub fn skills(&self) -> ClientRpcSkills<'a> {
111 ClientRpcSkills {
112 client: self.client,
113 }
114 }
115
116 /// `tools.*` sub-namespace.
117 pub fn tools(&self) -> ClientRpcTools<'a> {
118 ClientRpcTools {
119 client: self.client,
120 }
121 }
122
123 /// `user.*` sub-namespace.
124 pub fn user(&self) -> ClientRpcUser<'a> {
125 ClientRpcUser {
126 client: self.client,
127 }
128 }
129
130 /// Checks server responsiveness and returns protocol information.
131 ///
132 /// Wire method: `ping`.
133 ///
134 /// # Parameters
135 ///
136 /// * `params` - Optional message to echo back to the caller.
137 ///
138 /// # Returns
139 ///
140 /// Server liveness response, including the echoed message, current server timestamp, and protocol version.
141 ///
142 /// <div class="warning">
143 ///
144 /// **Experimental.** This API is part of an experimental wire-protocol surface
145 /// and may change or be removed in future SDK or CLI releases. Pin both the
146 /// SDK and CLI versions if your code depends on it.
147 ///
148 /// </div>
149 pub async fn ping(&self, params: PingRequest) -> Result<PingResult, Error> {
150 let wire_params = serde_json::to_value(params)?;
151 let _value = self
152 .client
153 .call(rpc_methods::PING, Some(wire_params))
154 .await?;
155 Ok(serde_json::from_value(_value)?)
156 }
157
158 /// 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.
159 ///
160 /// Wire method: `connect`.
161 ///
162 /// # Parameters
163 ///
164 /// * `params` - Optional connection token presented by the SDK client during the handshake.
165 ///
166 /// # Returns
167 ///
168 /// Handshake result reporting the server's protocol version and package version on success.
169 ///
170 /// <div class="warning">
171 ///
172 /// **Experimental.** This API is part of an experimental wire-protocol surface
173 /// and may change or be removed in future SDK or CLI releases. Pin both the
174 /// SDK and CLI versions if your code depends on it.
175 ///
176 /// </div>
177 pub(crate) async fn connect(&self, params: ConnectRequest) -> Result<ConnectResult, Error> {
178 let wire_params = serde_json::to_value(params)?;
179 let _value = self
180 .client
181 .call(rpc_methods::CONNECT, Some(wire_params))
182 .await?;
183 Ok(serde_json::from_value(_value)?)
184 }
185}
186
187/// `account.*` RPCs.
188#[derive(Clone, Copy)]
189pub struct ClientRpcAccount<'a> {
190 pub(crate) client: &'a Client,
191}
192
193impl<'a> ClientRpcAccount<'a> {
194 /// Gets Copilot quota usage for the authenticated user or supplied GitHub token.
195 ///
196 /// Wire method: `account.getQuota`.
197 ///
198 /// # Returns
199 ///
200 /// Quota usage snapshots for the resolved user, keyed by quota type.
201 ///
202 /// <div class="warning">
203 ///
204 /// **Experimental.** This API is part of an experimental wire-protocol surface
205 /// and may change or be removed in future SDK or CLI releases. Pin both the
206 /// SDK and CLI versions if your code depends on it.
207 ///
208 /// </div>
209 pub async fn get_quota(&self) -> Result<AccountGetQuotaResult, Error> {
210 let wire_params = serde_json::json!({});
211 let _value = self
212 .client
213 .call(rpc_methods::ACCOUNT_GETQUOTA, Some(wire_params))
214 .await?;
215 Ok(serde_json::from_value(_value)?)
216 }
217
218 /// Gets Copilot quota usage for the authenticated user or supplied GitHub token.
219 ///
220 /// Wire method: `account.getQuota`.
221 ///
222 /// # Parameters
223 ///
224 /// * `params` - Optional GitHub token used to look up quota for a specific user instead of the global auth context.
225 ///
226 /// # Returns
227 ///
228 /// Quota usage snapshots for the resolved user, keyed by quota type.
229 ///
230 /// <div class="warning">
231 ///
232 /// **Experimental.** This API is part of an experimental wire-protocol surface
233 /// and may change or be removed in future SDK or CLI releases. Pin both the
234 /// SDK and CLI versions if your code depends on it.
235 ///
236 /// </div>
237 pub async fn get_quota_with_params(
238 &self,
239 params: AccountGetQuotaRequest,
240 ) -> Result<AccountGetQuotaResult, Error> {
241 let wire_params = serde_json::to_value(params)?;
242 let _value = self
243 .client
244 .call(rpc_methods::ACCOUNT_GETQUOTA, Some(wire_params))
245 .await?;
246 Ok(serde_json::from_value(_value)?)
247 }
248
249 /// Gets the currently active authentication credentials from the global auth manager.
250 ///
251 /// Wire method: `account.getCurrentAuth`.
252 ///
253 /// # Returns
254 ///
255 /// Current authentication state
256 ///
257 /// <div class="warning">
258 ///
259 /// **Experimental.** This API is part of an experimental wire-protocol surface
260 /// and may change or be removed in future SDK or CLI releases. Pin both the
261 /// SDK and CLI versions if your code depends on it.
262 ///
263 /// </div>
264 pub async fn get_current_auth(&self) -> Result<AccountGetCurrentAuthResult, Error> {
265 let wire_params = serde_json::json!({});
266 let _value = self
267 .client
268 .call(rpc_methods::ACCOUNT_GETCURRENTAUTH, Some(wire_params))
269 .await?;
270 Ok(serde_json::from_value(_value)?)
271 }
272
273 /// Gets all authenticated users available for account switching.
274 ///
275 /// Wire method: `account.getAllUsers`.
276 ///
277 /// # Returns
278 ///
279 /// List of all authenticated users
280 ///
281 /// <div class="warning">
282 ///
283 /// **Experimental.** This API is part of an experimental wire-protocol surface
284 /// and may change or be removed in future SDK or CLI releases. Pin both the
285 /// SDK and CLI versions if your code depends on it.
286 ///
287 /// </div>
288 pub async fn get_all_users(&self) -> Result<AccountGetAllUsersResult, Error> {
289 let wire_params = serde_json::json!({});
290 let _value = self
291 .client
292 .call(rpc_methods::ACCOUNT_GETALLUSERS, Some(wire_params))
293 .await?;
294 Ok(serde_json::from_value(_value)?)
295 }
296
297 /// Stores authentication credentials after successful login (e.g., device code flow).
298 ///
299 /// Wire method: `account.login`.
300 ///
301 /// # Parameters
302 ///
303 /// * `params` - Credentials to store after successful authentication
304 ///
305 /// # Returns
306 ///
307 /// Result of a successful login; throws on failure
308 ///
309 /// <div class="warning">
310 ///
311 /// **Experimental.** This API is part of an experimental wire-protocol surface
312 /// and may change or be removed in future SDK or CLI releases. Pin both the
313 /// SDK and CLI versions if your code depends on it.
314 ///
315 /// </div>
316 pub async fn login(&self, params: AccountLoginRequest) -> Result<AccountLoginResult, Error> {
317 let wire_params = serde_json::to_value(params)?;
318 let _value = self
319 .client
320 .call(rpc_methods::ACCOUNT_LOGIN, Some(wire_params))
321 .await?;
322 Ok(serde_json::from_value(_value)?)
323 }
324
325 /// Removes user authentication from keychain and persisted state.
326 ///
327 /// Wire method: `account.logout`.
328 ///
329 /// # Parameters
330 ///
331 /// * `params` - User to log out
332 ///
333 /// # Returns
334 ///
335 /// Logout result indicating if more users remain
336 ///
337 /// <div class="warning">
338 ///
339 /// **Experimental.** This API is part of an experimental wire-protocol surface
340 /// and may change or be removed in future SDK or CLI releases. Pin both the
341 /// SDK and CLI versions if your code depends on it.
342 ///
343 /// </div>
344 pub async fn logout(&self, params: AccountLogoutRequest) -> Result<AccountLogoutResult, Error> {
345 let wire_params = serde_json::to_value(params)?;
346 let _value = self
347 .client
348 .call(rpc_methods::ACCOUNT_LOGOUT, Some(wire_params))
349 .await?;
350 Ok(serde_json::from_value(_value)?)
351 }
352}
353
354/// `agentRegistry.*` RPCs.
355#[derive(Clone, Copy)]
356pub struct ClientRpcAgentRegistry<'a> {
357 pub(crate) client: &'a Client,
358}
359
360impl<'a> ClientRpcAgentRegistry<'a> {
361 /// 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.
362 ///
363 /// Wire method: `agentRegistry.spawn`.
364 ///
365 /// # Parameters
366 ///
367 /// * `params` - Inputs to spawn a managed-server child via the controller's spawn delegate.
368 ///
369 /// # Returns
370 ///
371 /// Outcome of an agentRegistry.spawn call.
372 ///
373 /// <div class="warning">
374 ///
375 /// **Experimental.** This API is part of an experimental wire-protocol surface
376 /// and may change or be removed in future SDK or CLI releases. Pin both the
377 /// SDK and CLI versions if your code depends on it.
378 ///
379 /// </div>
380 pub async fn spawn(
381 &self,
382 params: AgentRegistrySpawnRequest,
383 ) -> Result<AgentRegistrySpawnResult, Error> {
384 let wire_params = serde_json::to_value(params)?;
385 let _value = self
386 .client
387 .call(rpc_methods::AGENTREGISTRY_SPAWN, Some(wire_params))
388 .await?;
389 Ok(serde_json::from_value(_value)?)
390 }
391}
392
393/// `agents.*` RPCs.
394#[derive(Clone, Copy)]
395pub struct ClientRpcAgents<'a> {
396 pub(crate) client: &'a Client,
397}
398
399impl<'a> ClientRpcAgents<'a> {
400 /// Discovers custom agents across user, project, plugin, and remote sources.
401 ///
402 /// Wire method: `agents.discover`.
403 ///
404 /// # Parameters
405 ///
406 /// * `params` - Optional project paths to include in agent discovery.
407 ///
408 /// # Returns
409 ///
410 /// Agents discovered across user, project, plugin, and remote sources.
411 ///
412 /// <div class="warning">
413 ///
414 /// **Experimental.** This API is part of an experimental wire-protocol surface
415 /// and may change or be removed in future SDK or CLI releases. Pin both the
416 /// SDK and CLI versions if your code depends on it.
417 ///
418 /// </div>
419 pub async fn discover(&self, params: AgentsDiscoverRequest) -> Result<ServerAgentList, Error> {
420 let wire_params = serde_json::to_value(params)?;
421 let _value = self
422 .client
423 .call(rpc_methods::AGENTS_DISCOVER, Some(wire_params))
424 .await?;
425 Ok(serde_json::from_value(_value)?)
426 }
427
428 /// 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.
429 ///
430 /// Wire method: `agents.getDiscoveryPaths`.
431 ///
432 /// # Parameters
433 ///
434 /// * `params` - Optional project paths to include when enumerating agent discovery directories.
435 ///
436 /// # Returns
437 ///
438 /// Canonical locations where custom agents can be created so the runtime will recognize them.
439 ///
440 /// <div class="warning">
441 ///
442 /// **Experimental.** This API is part of an experimental wire-protocol surface
443 /// and may change or be removed in future SDK or CLI releases. Pin both the
444 /// SDK and CLI versions if your code depends on it.
445 ///
446 /// </div>
447 pub async fn get_discovery_paths(
448 &self,
449 params: AgentsGetDiscoveryPathsRequest,
450 ) -> Result<AgentDiscoveryPathList, Error> {
451 let wire_params = serde_json::to_value(params)?;
452 let _value = self
453 .client
454 .call(rpc_methods::AGENTS_GETDISCOVERYPATHS, Some(wire_params))
455 .await?;
456 Ok(serde_json::from_value(_value)?)
457 }
458}
459
460/// `instructions.*` RPCs.
461#[derive(Clone, Copy)]
462pub struct ClientRpcInstructions<'a> {
463 pub(crate) client: &'a Client,
464}
465
466impl<'a> ClientRpcInstructions<'a> {
467 /// Discovers instruction sources across user, repository, and plugin sources.
468 ///
469 /// Wire method: `instructions.discover`.
470 ///
471 /// # Parameters
472 ///
473 /// * `params` - Optional project paths to include in instruction discovery.
474 ///
475 /// # Returns
476 ///
477 /// Instruction sources discovered across user, repository, and plugin sources.
478 ///
479 /// <div class="warning">
480 ///
481 /// **Experimental.** This API is part of an experimental wire-protocol surface
482 /// and may change or be removed in future SDK or CLI releases. Pin both the
483 /// SDK and CLI versions if your code depends on it.
484 ///
485 /// </div>
486 pub async fn discover(
487 &self,
488 params: InstructionsDiscoverRequest,
489 ) -> Result<ServerInstructionSourceList, Error> {
490 let wire_params = serde_json::to_value(params)?;
491 let _value = self
492 .client
493 .call(rpc_methods::INSTRUCTIONS_DISCOVER, Some(wire_params))
494 .await?;
495 Ok(serde_json::from_value(_value)?)
496 }
497
498 /// 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.
499 ///
500 /// Wire method: `instructions.getDiscoveryPaths`.
501 ///
502 /// # Parameters
503 ///
504 /// * `params` - Optional project paths to include when enumerating instruction discovery targets.
505 ///
506 /// # Returns
507 ///
508 /// Canonical files and directories where custom instructions can be created so the runtime will recognize them.
509 ///
510 /// <div class="warning">
511 ///
512 /// **Experimental.** This API is part of an experimental wire-protocol surface
513 /// and may change or be removed in future SDK or CLI releases. Pin both the
514 /// SDK and CLI versions if your code depends on it.
515 ///
516 /// </div>
517 pub async fn get_discovery_paths(
518 &self,
519 params: InstructionsGetDiscoveryPathsRequest,
520 ) -> Result<InstructionDiscoveryPathList, Error> {
521 let wire_params = serde_json::to_value(params)?;
522 let _value = self
523 .client
524 .call(
525 rpc_methods::INSTRUCTIONS_GETDISCOVERYPATHS,
526 Some(wire_params),
527 )
528 .await?;
529 Ok(serde_json::from_value(_value)?)
530 }
531}
532
533/// `llmInference.*` RPCs.
534#[derive(Clone, Copy)]
535pub struct ClientRpcLlmInference<'a> {
536 pub(crate) client: &'a Client,
537}
538
539impl<'a> ClientRpcLlmInference<'a> {
540 /// Registers an SDK client as the LLM inference callback provider.
541 ///
542 /// Wire method: `llmInference.setProvider`.
543 ///
544 /// # Returns
545 ///
546 /// Indicates whether the calling client was registered as the LLM inference provider.
547 ///
548 /// <div class="warning">
549 ///
550 /// **Experimental.** This API is part of an experimental wire-protocol surface
551 /// and may change or be removed in future SDK or CLI releases. Pin both the
552 /// SDK and CLI versions if your code depends on it.
553 ///
554 /// </div>
555 pub async fn set_provider(&self) -> Result<LlmInferenceSetProviderResult, Error> {
556 let wire_params = serde_json::json!({});
557 let _value = self
558 .client
559 .call(rpc_methods::LLMINFERENCE_SETPROVIDER, Some(wire_params))
560 .await?;
561 Ok(serde_json::from_value(_value)?)
562 }
563
564 /// 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.
565 ///
566 /// Wire method: `llmInference.httpResponseStart`.
567 ///
568 /// # Parameters
569 ///
570 /// * `params` - Response head.
571 ///
572 /// # Returns
573 ///
574 /// Whether the start frame was accepted.
575 ///
576 /// <div class="warning">
577 ///
578 /// **Experimental.** This API is part of an experimental wire-protocol surface
579 /// and may change or be removed in future SDK or CLI releases. Pin both the
580 /// SDK and CLI versions if your code depends on it.
581 ///
582 /// </div>
583 pub async fn http_response_start(
584 &self,
585 params: LlmInferenceHttpResponseStartRequest,
586 ) -> Result<LlmInferenceHttpResponseStartResult, Error> {
587 let wire_params = serde_json::to_value(params)?;
588 let _value = self
589 .client
590 .call(
591 rpc_methods::LLMINFERENCE_HTTPRESPONSESTART,
592 Some(wire_params),
593 )
594 .await?;
595 Ok(serde_json::from_value(_value)?)
596 }
597
598 /// 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.
599 ///
600 /// Wire method: `llmInference.httpResponseChunk`.
601 ///
602 /// # Parameters
603 ///
604 /// * `params` - A response body chunk or terminal error.
605 ///
606 /// # Returns
607 ///
608 /// Whether the chunk was accepted.
609 ///
610 /// <div class="warning">
611 ///
612 /// **Experimental.** This API is part of an experimental wire-protocol surface
613 /// and may change or be removed in future SDK or CLI releases. Pin both the
614 /// SDK and CLI versions if your code depends on it.
615 ///
616 /// </div>
617 pub async fn http_response_chunk(
618 &self,
619 params: LlmInferenceHttpResponseChunkRequest,
620 ) -> Result<LlmInferenceHttpResponseChunkResult, Error> {
621 let wire_params = serde_json::to_value(params)?;
622 let _value = self
623 .client
624 .call(
625 rpc_methods::LLMINFERENCE_HTTPRESPONSECHUNK,
626 Some(wire_params),
627 )
628 .await?;
629 Ok(serde_json::from_value(_value)?)
630 }
631}
632
633/// `mcp.*` RPCs.
634#[derive(Clone, Copy)]
635pub struct ClientRpcMcp<'a> {
636 pub(crate) client: &'a Client,
637}
638
639impl<'a> ClientRpcMcp<'a> {
640 /// `mcp.config.*` sub-namespace.
641 pub fn config(&self) -> ClientRpcMcpConfig<'a> {
642 ClientRpcMcpConfig {
643 client: self.client,
644 }
645 }
646
647 /// Discovers MCP servers from user, workspace, plugin, and builtin sources.
648 ///
649 /// Wire method: `mcp.discover`.
650 ///
651 /// # Parameters
652 ///
653 /// * `params` - Optional working directory used as context for MCP server discovery.
654 ///
655 /// # Returns
656 ///
657 /// MCP servers discovered from user, workspace, plugin, and built-in sources.
658 ///
659 /// <div class="warning">
660 ///
661 /// **Experimental.** This API is part of an experimental wire-protocol surface
662 /// and may change or be removed in future SDK or CLI releases. Pin both the
663 /// SDK and CLI versions if your code depends on it.
664 ///
665 /// </div>
666 pub async fn discover(&self, params: McpDiscoverRequest) -> Result<McpDiscoverResult, Error> {
667 let wire_params = serde_json::to_value(params)?;
668 let _value = self
669 .client
670 .call(rpc_methods::MCP_DISCOVER, Some(wire_params))
671 .await?;
672 Ok(serde_json::from_value(_value)?)
673 }
674}
675
676/// `mcp.config.*` RPCs.
677#[derive(Clone, Copy)]
678pub struct ClientRpcMcpConfig<'a> {
679 pub(crate) client: &'a Client,
680}
681
682impl<'a> ClientRpcMcpConfig<'a> {
683 /// Lists MCP servers from user configuration.
684 ///
685 /// Wire method: `mcp.config.list`.
686 ///
687 /// # Returns
688 ///
689 /// User-configured MCP servers, keyed by server name.
690 ///
691 /// <div class="warning">
692 ///
693 /// **Experimental.** This API is part of an experimental wire-protocol surface
694 /// and may change or be removed in future SDK or CLI releases. Pin both the
695 /// SDK and CLI versions if your code depends on it.
696 ///
697 /// </div>
698 pub async fn list(&self) -> Result<McpConfigList, Error> {
699 let wire_params = serde_json::json!({});
700 let _value = self
701 .client
702 .call(rpc_methods::MCP_CONFIG_LIST, Some(wire_params))
703 .await?;
704 Ok(serde_json::from_value(_value)?)
705 }
706
707 /// Adds an MCP server to user configuration.
708 ///
709 /// Wire method: `mcp.config.add`.
710 ///
711 /// # Parameters
712 ///
713 /// * `params` - MCP server name and configuration to add to user configuration.
714 ///
715 /// <div class="warning">
716 ///
717 /// **Experimental.** This API is part of an experimental wire-protocol surface
718 /// and may change or be removed in future SDK or CLI releases. Pin both the
719 /// SDK and CLI versions if your code depends on it.
720 ///
721 /// </div>
722 pub async fn add(&self, params: McpConfigAddRequest) -> Result<(), Error> {
723 let wire_params = serde_json::to_value(params)?;
724 let _value = self
725 .client
726 .call(rpc_methods::MCP_CONFIG_ADD, Some(wire_params))
727 .await?;
728 Ok(())
729 }
730
731 /// Updates an MCP server in user configuration.
732 ///
733 /// Wire method: `mcp.config.update`.
734 ///
735 /// # Parameters
736 ///
737 /// * `params` - MCP server name and replacement configuration to write to user configuration.
738 ///
739 /// <div class="warning">
740 ///
741 /// **Experimental.** This API is part of an experimental wire-protocol surface
742 /// and may change or be removed in future SDK or CLI releases. Pin both the
743 /// SDK and CLI versions if your code depends on it.
744 ///
745 /// </div>
746 pub async fn update(&self, params: McpConfigUpdateRequest) -> Result<(), Error> {
747 let wire_params = serde_json::to_value(params)?;
748 let _value = self
749 .client
750 .call(rpc_methods::MCP_CONFIG_UPDATE, Some(wire_params))
751 .await?;
752 Ok(())
753 }
754
755 /// Removes an MCP server from user configuration.
756 ///
757 /// Wire method: `mcp.config.remove`.
758 ///
759 /// # Parameters
760 ///
761 /// * `params` - MCP server name to remove from user configuration.
762 ///
763 /// <div class="warning">
764 ///
765 /// **Experimental.** This API is part of an experimental wire-protocol surface
766 /// and may change or be removed in future SDK or CLI releases. Pin both the
767 /// SDK and CLI versions if your code depends on it.
768 ///
769 /// </div>
770 pub async fn remove(&self, params: McpConfigRemoveRequest) -> Result<(), Error> {
771 let wire_params = serde_json::to_value(params)?;
772 let _value = self
773 .client
774 .call(rpc_methods::MCP_CONFIG_REMOVE, Some(wire_params))
775 .await?;
776 Ok(())
777 }
778
779 /// Enables MCP servers in user configuration for new sessions.
780 ///
781 /// Wire method: `mcp.config.enable`.
782 ///
783 /// # Parameters
784 ///
785 /// * `params` - MCP server names to enable for new sessions.
786 ///
787 /// <div class="warning">
788 ///
789 /// **Experimental.** This API is part of an experimental wire-protocol surface
790 /// and may change or be removed in future SDK or CLI releases. Pin both the
791 /// SDK and CLI versions if your code depends on it.
792 ///
793 /// </div>
794 pub async fn enable(&self, params: McpConfigEnableRequest) -> Result<(), Error> {
795 let wire_params = serde_json::to_value(params)?;
796 let _value = self
797 .client
798 .call(rpc_methods::MCP_CONFIG_ENABLE, Some(wire_params))
799 .await?;
800 Ok(())
801 }
802
803 /// Disables MCP servers in user configuration for new sessions.
804 ///
805 /// Wire method: `mcp.config.disable`.
806 ///
807 /// # Parameters
808 ///
809 /// * `params` - MCP server names to disable for new sessions.
810 ///
811 /// <div class="warning">
812 ///
813 /// **Experimental.** This API is part of an experimental wire-protocol surface
814 /// and may change or be removed in future SDK or CLI releases. Pin both the
815 /// SDK and CLI versions if your code depends on it.
816 ///
817 /// </div>
818 pub async fn disable(&self, params: McpConfigDisableRequest) -> Result<(), Error> {
819 let wire_params = serde_json::to_value(params)?;
820 let _value = self
821 .client
822 .call(rpc_methods::MCP_CONFIG_DISABLE, Some(wire_params))
823 .await?;
824 Ok(())
825 }
826
827 /// Drops this runtime process's in-memory MCP server-definition cache so the next MCP config read observes disk.
828 ///
829 /// Wire method: `mcp.config.reload`.
830 ///
831 /// <div class="warning">
832 ///
833 /// **Experimental.** This API is part of an experimental wire-protocol surface
834 /// and may change or be removed in future SDK or CLI releases. Pin both the
835 /// SDK and CLI versions if your code depends on it.
836 ///
837 /// </div>
838 pub async fn reload(&self) -> Result<(), Error> {
839 let wire_params = serde_json::json!({});
840 let _value = self
841 .client
842 .call(rpc_methods::MCP_CONFIG_RELOAD, Some(wire_params))
843 .await?;
844 Ok(())
845 }
846}
847
848/// `models.*` RPCs.
849#[derive(Clone, Copy)]
850pub struct ClientRpcModels<'a> {
851 pub(crate) client: &'a Client,
852}
853
854impl<'a> ClientRpcModels<'a> {
855 /// Lists Copilot models available to the authenticated user.
856 ///
857 /// Wire method: `models.list`.
858 ///
859 /// # Returns
860 ///
861 /// List of Copilot models available to the resolved user, including capabilities and billing metadata.
862 ///
863 /// <div class="warning">
864 ///
865 /// **Experimental.** This API is part of an experimental wire-protocol surface
866 /// and may change or be removed in future SDK or CLI releases. Pin both the
867 /// SDK and CLI versions if your code depends on it.
868 ///
869 /// </div>
870 pub async fn list(&self) -> Result<ModelList, Error> {
871 let wire_params = serde_json::json!({});
872 let _value = self
873 .client
874 .call(rpc_methods::MODELS_LIST, Some(wire_params))
875 .await?;
876 Ok(serde_json::from_value(_value)?)
877 }
878
879 /// Lists Copilot models available to the authenticated user.
880 ///
881 /// Wire method: `models.list`.
882 ///
883 /// # Parameters
884 ///
885 /// * `params` - Optional GitHub token used to list models for a specific user instead of the global auth context.
886 ///
887 /// # Returns
888 ///
889 /// List of Copilot models available to the resolved user, including capabilities and billing metadata.
890 ///
891 /// <div class="warning">
892 ///
893 /// **Experimental.** This API is part of an experimental wire-protocol surface
894 /// and may change or be removed in future SDK or CLI releases. Pin both the
895 /// SDK and CLI versions if your code depends on it.
896 ///
897 /// </div>
898 pub async fn list_with_params(&self, params: ModelsListRequest) -> Result<ModelList, Error> {
899 let wire_params = serde_json::to_value(params)?;
900 let _value = self
901 .client
902 .call(rpc_methods::MODELS_LIST, Some(wire_params))
903 .await?;
904 Ok(serde_json::from_value(_value)?)
905 }
906}
907
908/// `plugins.*` RPCs.
909#[derive(Clone, Copy)]
910pub struct ClientRpcPlugins<'a> {
911 pub(crate) client: &'a Client,
912}
913
914impl<'a> ClientRpcPlugins<'a> {
915 /// `plugins.marketplaces.*` sub-namespace.
916 pub fn marketplaces(&self) -> ClientRpcPluginsMarketplaces<'a> {
917 ClientRpcPluginsMarketplaces {
918 client: self.client,
919 }
920 }
921
922 /// Lists plugins installed in user/global state.
923 ///
924 /// Wire method: `plugins.list`.
925 ///
926 /// # Returns
927 ///
928 /// Plugins installed in user/global state.
929 ///
930 /// <div class="warning">
931 ///
932 /// **Experimental.** This API is part of an experimental wire-protocol surface
933 /// and may change or be removed in future SDK or CLI releases. Pin both the
934 /// SDK and CLI versions if your code depends on it.
935 ///
936 /// </div>
937 pub async fn list(&self) -> Result<PluginListResult, Error> {
938 let wire_params = serde_json::json!({});
939 let _value = self
940 .client
941 .call(rpc_methods::PLUGINS_LIST, Some(wire_params))
942 .await?;
943 Ok(serde_json::from_value(_value)?)
944 }
945
946 /// Installs a plugin from a marketplace, GitHub repo, URL, or local path.
947 ///
948 /// Wire method: `plugins.install`.
949 ///
950 /// # Parameters
951 ///
952 /// * `params` - Plugin source and optional working directory for relative-path resolution.
953 ///
954 /// # Returns
955 ///
956 /// Result of installing a plugin.
957 ///
958 /// <div class="warning">
959 ///
960 /// **Experimental.** This API is part of an experimental wire-protocol surface
961 /// and may change or be removed in future SDK or CLI releases. Pin both the
962 /// SDK and CLI versions if your code depends on it.
963 ///
964 /// </div>
965 pub async fn install(
966 &self,
967 params: PluginsInstallRequest,
968 ) -> Result<PluginInstallResult, Error> {
969 let wire_params = serde_json::to_value(params)?;
970 let _value = self
971 .client
972 .call(rpc_methods::PLUGINS_INSTALL, Some(wire_params))
973 .await?;
974 Ok(serde_json::from_value(_value)?)
975 }
976
977 /// Uninstalls an installed plugin.
978 ///
979 /// Wire method: `plugins.uninstall`.
980 ///
981 /// # Parameters
982 ///
983 /// * `params` - Name (or spec) of the plugin to uninstall.
984 ///
985 /// <div class="warning">
986 ///
987 /// **Experimental.** This API is part of an experimental wire-protocol surface
988 /// and may change or be removed in future SDK or CLI releases. Pin both the
989 /// SDK and CLI versions if your code depends on it.
990 ///
991 /// </div>
992 pub async fn uninstall(&self, params: PluginsUninstallRequest) -> Result<(), Error> {
993 let wire_params = serde_json::to_value(params)?;
994 let _value = self
995 .client
996 .call(rpc_methods::PLUGINS_UNINSTALL, Some(wire_params))
997 .await?;
998 Ok(())
999 }
1000
1001 /// Updates an installed plugin to its latest published version.
1002 ///
1003 /// Wire method: `plugins.update`.
1004 ///
1005 /// # Parameters
1006 ///
1007 /// * `params` - Name (or spec) of the plugin to update.
1008 ///
1009 /// # Returns
1010 ///
1011 /// Result of updating a single plugin.
1012 ///
1013 /// <div class="warning">
1014 ///
1015 /// **Experimental.** This API is part of an experimental wire-protocol surface
1016 /// and may change or be removed in future SDK or CLI releases. Pin both the
1017 /// SDK and CLI versions if your code depends on it.
1018 ///
1019 /// </div>
1020 pub async fn update(&self, params: PluginsUpdateRequest) -> Result<PluginUpdateResult, Error> {
1021 let wire_params = serde_json::to_value(params)?;
1022 let _value = self
1023 .client
1024 .call(rpc_methods::PLUGINS_UPDATE, Some(wire_params))
1025 .await?;
1026 Ok(serde_json::from_value(_value)?)
1027 }
1028
1029 /// Updates every installed plugin to its latest published version.
1030 ///
1031 /// Wire method: `plugins.updateAll`.
1032 ///
1033 /// # Returns
1034 ///
1035 /// Result of updating all installed plugins.
1036 ///
1037 /// <div class="warning">
1038 ///
1039 /// **Experimental.** This API is part of an experimental wire-protocol surface
1040 /// and may change or be removed in future SDK or CLI releases. Pin both the
1041 /// SDK and CLI versions if your code depends on it.
1042 ///
1043 /// </div>
1044 pub async fn update_all(&self) -> Result<PluginUpdateAllResult, Error> {
1045 let wire_params = serde_json::json!({});
1046 let _value = self
1047 .client
1048 .call(rpc_methods::PLUGINS_UPDATEALL, Some(wire_params))
1049 .await?;
1050 Ok(serde_json::from_value(_value)?)
1051 }
1052
1053 /// Enables installed plugins for new sessions.
1054 ///
1055 /// Wire method: `plugins.enable`.
1056 ///
1057 /// # Parameters
1058 ///
1059 /// * `params` - Plugin names (or specs) to enable.
1060 ///
1061 /// <div class="warning">
1062 ///
1063 /// **Experimental.** This API is part of an experimental wire-protocol surface
1064 /// and may change or be removed in future SDK or CLI releases. Pin both the
1065 /// SDK and CLI versions if your code depends on it.
1066 ///
1067 /// </div>
1068 pub async fn enable(&self, params: PluginsEnableRequest) -> Result<(), Error> {
1069 let wire_params = serde_json::to_value(params)?;
1070 let _value = self
1071 .client
1072 .call(rpc_methods::PLUGINS_ENABLE, Some(wire_params))
1073 .await?;
1074 Ok(())
1075 }
1076
1077 /// Disables installed plugins for new sessions.
1078 ///
1079 /// Wire method: `plugins.disable`.
1080 ///
1081 /// # Parameters
1082 ///
1083 /// * `params` - Plugin names (or specs) to disable.
1084 ///
1085 /// <div class="warning">
1086 ///
1087 /// **Experimental.** This API is part of an experimental wire-protocol surface
1088 /// and may change or be removed in future SDK or CLI releases. Pin both the
1089 /// SDK and CLI versions if your code depends on it.
1090 ///
1091 /// </div>
1092 pub async fn disable(&self, params: PluginsDisableRequest) -> Result<(), Error> {
1093 let wire_params = serde_json::to_value(params)?;
1094 let _value = self
1095 .client
1096 .call(rpc_methods::PLUGINS_DISABLE, Some(wire_params))
1097 .await?;
1098 Ok(())
1099 }
1100}
1101
1102/// `plugins.marketplaces.*` RPCs.
1103#[derive(Clone, Copy)]
1104pub struct ClientRpcPluginsMarketplaces<'a> {
1105 pub(crate) client: &'a Client,
1106}
1107
1108impl<'a> ClientRpcPluginsMarketplaces<'a> {
1109 /// Lists all registered marketplaces (defaults + user-added).
1110 ///
1111 /// Wire method: `plugins.marketplaces.list`.
1112 ///
1113 /// # Returns
1114 ///
1115 /// All registered marketplaces, including built-in defaults.
1116 ///
1117 /// <div class="warning">
1118 ///
1119 /// **Experimental.** This API is part of an experimental wire-protocol surface
1120 /// and may change or be removed in future SDK or CLI releases. Pin both the
1121 /// SDK and CLI versions if your code depends on it.
1122 ///
1123 /// </div>
1124 pub async fn list(&self) -> Result<MarketplaceListResult, Error> {
1125 let wire_params = serde_json::json!({});
1126 let _value = self
1127 .client
1128 .call(rpc_methods::PLUGINS_MARKETPLACES_LIST, Some(wire_params))
1129 .await?;
1130 Ok(serde_json::from_value(_value)?)
1131 }
1132
1133 /// Registers a new marketplace from a source (owner/repo, URL, or local path).
1134 ///
1135 /// Wire method: `plugins.marketplaces.add`.
1136 ///
1137 /// # Parameters
1138 ///
1139 /// * `params` - Marketplace source to register.
1140 ///
1141 /// # Returns
1142 ///
1143 /// Result of registering a new marketplace.
1144 ///
1145 /// <div class="warning">
1146 ///
1147 /// **Experimental.** This API is part of an experimental wire-protocol surface
1148 /// and may change or be removed in future SDK or CLI releases. Pin both the
1149 /// SDK and CLI versions if your code depends on it.
1150 ///
1151 /// </div>
1152 pub async fn add(
1153 &self,
1154 params: PluginsMarketplacesAddRequest,
1155 ) -> Result<MarketplaceAddResult, Error> {
1156 let wire_params = serde_json::to_value(params)?;
1157 let _value = self
1158 .client
1159 .call(rpc_methods::PLUGINS_MARKETPLACES_ADD, Some(wire_params))
1160 .await?;
1161 Ok(serde_json::from_value(_value)?)
1162 }
1163
1164 /// Removes a previously-registered marketplace. When the marketplace has dependent plugins and `force` is not set, the marketplace is left intact and the result lists the dependents so the caller can decide whether to retry with `force=true`.
1165 ///
1166 /// Wire method: `plugins.marketplaces.remove`.
1167 ///
1168 /// # Parameters
1169 ///
1170 /// * `params` - Name of the marketplace to remove and an optional force flag.
1171 ///
1172 /// # Returns
1173 ///
1174 /// Outcome of the remove attempt, including dependent-plugin info when applicable.
1175 ///
1176 /// <div class="warning">
1177 ///
1178 /// **Experimental.** This API is part of an experimental wire-protocol surface
1179 /// and may change or be removed in future SDK or CLI releases. Pin both the
1180 /// SDK and CLI versions if your code depends on it.
1181 ///
1182 /// </div>
1183 pub async fn remove(
1184 &self,
1185 params: PluginsMarketplacesRemoveRequest,
1186 ) -> Result<MarketplaceRemoveResult, Error> {
1187 let wire_params = serde_json::to_value(params)?;
1188 let _value = self
1189 .client
1190 .call(rpc_methods::PLUGINS_MARKETPLACES_REMOVE, Some(wire_params))
1191 .await?;
1192 Ok(serde_json::from_value(_value)?)
1193 }
1194
1195 /// Lists plugins advertised by a registered marketplace.
1196 ///
1197 /// Wire method: `plugins.marketplaces.browse`.
1198 ///
1199 /// # Parameters
1200 ///
1201 /// * `params` - Name of the marketplace whose plugin catalog to fetch.
1202 ///
1203 /// # Returns
1204 ///
1205 /// Plugins advertised by the marketplace.
1206 ///
1207 /// <div class="warning">
1208 ///
1209 /// **Experimental.** This API is part of an experimental wire-protocol surface
1210 /// and may change or be removed in future SDK or CLI releases. Pin both the
1211 /// SDK and CLI versions if your code depends on it.
1212 ///
1213 /// </div>
1214 pub async fn browse(
1215 &self,
1216 params: PluginsMarketplacesBrowseRequest,
1217 ) -> Result<MarketplaceBrowseResult, Error> {
1218 let wire_params = serde_json::to_value(params)?;
1219 let _value = self
1220 .client
1221 .call(rpc_methods::PLUGINS_MARKETPLACES_BROWSE, Some(wire_params))
1222 .await?;
1223 Ok(serde_json::from_value(_value)?)
1224 }
1225
1226 /// Re-fetches one or all registered marketplace catalogs.
1227 ///
1228 /// Wire method: `plugins.marketplaces.refresh`.
1229 ///
1230 /// # Returns
1231 ///
1232 /// Result of refreshing one or more marketplace catalogs.
1233 ///
1234 /// <div class="warning">
1235 ///
1236 /// **Experimental.** This API is part of an experimental wire-protocol surface
1237 /// and may change or be removed in future SDK or CLI releases. Pin both the
1238 /// SDK and CLI versions if your code depends on it.
1239 ///
1240 /// </div>
1241 pub async fn refresh(&self) -> Result<MarketplaceRefreshResult, Error> {
1242 let wire_params = serde_json::json!({});
1243 let _value = self
1244 .client
1245 .call(rpc_methods::PLUGINS_MARKETPLACES_REFRESH, Some(wire_params))
1246 .await?;
1247 Ok(serde_json::from_value(_value)?)
1248 }
1249
1250 /// Re-fetches one or all registered marketplace catalogs.
1251 ///
1252 /// Wire method: `plugins.marketplaces.refresh`.
1253 ///
1254 /// # Parameters
1255 ///
1256 /// * `params` - Optional marketplace name; omit to refresh all.
1257 ///
1258 /// # Returns
1259 ///
1260 /// Result of refreshing one or more marketplace catalogs.
1261 ///
1262 /// <div class="warning">
1263 ///
1264 /// **Experimental.** This API is part of an experimental wire-protocol surface
1265 /// and may change or be removed in future SDK or CLI releases. Pin both the
1266 /// SDK and CLI versions if your code depends on it.
1267 ///
1268 /// </div>
1269 pub async fn refresh_with_params(
1270 &self,
1271 params: PluginsMarketplacesRefreshRequest,
1272 ) -> Result<MarketplaceRefreshResult, Error> {
1273 let wire_params = serde_json::to_value(params)?;
1274 let _value = self
1275 .client
1276 .call(rpc_methods::PLUGINS_MARKETPLACES_REFRESH, Some(wire_params))
1277 .await?;
1278 Ok(serde_json::from_value(_value)?)
1279 }
1280}
1281
1282/// `runtime.*` RPCs.
1283#[derive(Clone, Copy)]
1284pub struct ClientRpcRuntime<'a> {
1285 pub(crate) client: &'a Client,
1286}
1287
1288impl<'a> ClientRpcRuntime<'a> {
1289 /// Gracefully shuts down an SDK-owned runtime. The response is sent only after cleanup completes; callers may then terminate the owned runtime process.
1290 ///
1291 /// Wire method: `runtime.shutdown`.
1292 ///
1293 /// <div class="warning">
1294 ///
1295 /// **Experimental.** This API is part of an experimental wire-protocol surface
1296 /// and may change or be removed in future SDK or CLI releases. Pin both the
1297 /// SDK and CLI versions if your code depends on it.
1298 ///
1299 /// </div>
1300 pub async fn shutdown(&self) -> Result<(), Error> {
1301 let wire_params = serde_json::json!({});
1302 let _value = self
1303 .client
1304 .call(rpc_methods::RUNTIME_SHUTDOWN, Some(wire_params))
1305 .await?;
1306 Ok(())
1307 }
1308}
1309
1310/// `secrets.*` RPCs.
1311#[derive(Clone, Copy)]
1312pub struct ClientRpcSecrets<'a> {
1313 pub(crate) client: &'a Client,
1314}
1315
1316impl<'a> ClientRpcSecrets<'a> {
1317 /// Registers secret values for redaction in session logs and exports. The SDK calls this to inject dynamically generated secret values (e.g., OIDC tokens).
1318 ///
1319 /// Wire method: `secrets.addFilterValues`.
1320 ///
1321 /// # Parameters
1322 ///
1323 /// * `params` - Secret values to add to the redaction filter.
1324 ///
1325 /// # Returns
1326 ///
1327 /// Confirmation that the secret values were registered.
1328 ///
1329 /// <div class="warning">
1330 ///
1331 /// **Experimental.** This API is part of an experimental wire-protocol surface
1332 /// and may change or be removed in future SDK or CLI releases. Pin both the
1333 /// SDK and CLI versions if your code depends on it.
1334 ///
1335 /// </div>
1336 pub async fn add_filter_values(
1337 &self,
1338 params: SecretsAddFilterValuesRequest,
1339 ) -> Result<SecretsAddFilterValuesResult, Error> {
1340 let wire_params = serde_json::to_value(params)?;
1341 let _value = self
1342 .client
1343 .call(rpc_methods::SECRETS_ADDFILTERVALUES, Some(wire_params))
1344 .await?;
1345 Ok(serde_json::from_value(_value)?)
1346 }
1347}
1348
1349/// `sessionFs.*` RPCs.
1350#[derive(Clone, Copy)]
1351pub struct ClientRpcSessionFs<'a> {
1352 pub(crate) client: &'a Client,
1353}
1354
1355impl<'a> ClientRpcSessionFs<'a> {
1356 /// Registers an SDK client as the session filesystem provider.
1357 ///
1358 /// Wire method: `sessionFs.setProvider`.
1359 ///
1360 /// # Parameters
1361 ///
1362 /// * `params` - Initial working directory, session-state path layout, and path conventions used to register the calling SDK client as the session filesystem provider.
1363 ///
1364 /// # Returns
1365 ///
1366 /// Indicates whether the calling client was registered as the session filesystem provider.
1367 ///
1368 /// <div class="warning">
1369 ///
1370 /// **Experimental.** This API is part of an experimental wire-protocol surface
1371 /// and may change or be removed in future SDK or CLI releases. Pin both the
1372 /// SDK and CLI versions if your code depends on it.
1373 ///
1374 /// </div>
1375 pub async fn set_provider(
1376 &self,
1377 params: SessionFsSetProviderRequest,
1378 ) -> Result<SessionFsSetProviderResult, Error> {
1379 let wire_params = serde_json::to_value(params)?;
1380 let _value = self
1381 .client
1382 .call(rpc_methods::SESSIONFS_SETPROVIDER, Some(wire_params))
1383 .await?;
1384 Ok(serde_json::from_value(_value)?)
1385 }
1386}
1387
1388/// `sessions.*` RPCs.
1389#[derive(Clone, Copy)]
1390pub struct ClientRpcSessions<'a> {
1391 pub(crate) client: &'a Client,
1392}
1393
1394impl<'a> ClientRpcSessions<'a> {
1395 /// Creates or resumes a local session and returns the opened session ID.
1396 ///
1397 /// Wire method: `sessions.open`.
1398 ///
1399 /// # Returns
1400 ///
1401 /// Result of opening a session.
1402 ///
1403 /// <div class="warning">
1404 ///
1405 /// **Experimental.** This API is part of an experimental wire-protocol surface
1406 /// and may change or be removed in future SDK or CLI releases. Pin both the
1407 /// SDK and CLI versions if your code depends on it.
1408 ///
1409 /// </div>
1410 pub async fn open(&self) -> Result<SessionOpenResult, Error> {
1411 let wire_params = serde_json::json!({});
1412 let _value = self
1413 .client
1414 .call(rpc_methods::SESSIONS_OPEN, Some(wire_params))
1415 .await?;
1416 Ok(serde_json::from_value(_value)?)
1417 }
1418
1419 /// Creates a new session by forking persisted history from an existing session.
1420 ///
1421 /// Wire method: `sessions.fork`.
1422 ///
1423 /// # Parameters
1424 ///
1425 /// * `params` - Source session identifier to fork from, optional event-ID boundary, and optional friendly name for the new session.
1426 ///
1427 /// # Returns
1428 ///
1429 /// Identifier and optional friendly name assigned to the newly forked session.
1430 ///
1431 /// <div class="warning">
1432 ///
1433 /// **Experimental.** This API is part of an experimental wire-protocol surface
1434 /// and may change or be removed in future SDK or CLI releases. Pin both the
1435 /// SDK and CLI versions if your code depends on it.
1436 ///
1437 /// </div>
1438 pub async fn fork(&self, params: SessionsForkRequest) -> Result<SessionsForkResult, Error> {
1439 let wire_params = serde_json::to_value(params)?;
1440 let _value = self
1441 .client
1442 .call(rpc_methods::SESSIONS_FORK, Some(wire_params))
1443 .await?;
1444 Ok(serde_json::from_value(_value)?)
1445 }
1446
1447 /// Connects to an existing remote session and exposes it as an SDK session.
1448 ///
1449 /// Wire method: `sessions.connect`.
1450 ///
1451 /// # Parameters
1452 ///
1453 /// * `params` - Remote session connection parameters.
1454 ///
1455 /// # Returns
1456 ///
1457 /// Remote session connection result.
1458 ///
1459 /// <div class="warning">
1460 ///
1461 /// **Experimental.** This API is part of an experimental wire-protocol surface
1462 /// and may change or be removed in future SDK or CLI releases. Pin both the
1463 /// SDK and CLI versions if your code depends on it.
1464 ///
1465 /// </div>
1466 pub async fn connect(
1467 &self,
1468 params: ConnectRemoteSessionParams,
1469 ) -> Result<RemoteSessionConnectionResult, Error> {
1470 let wire_params = serde_json::to_value(params)?;
1471 let _value = self
1472 .client
1473 .call(rpc_methods::SESSIONS_CONNECT, Some(wire_params))
1474 .await?;
1475 Ok(serde_json::from_value(_value)?)
1476 }
1477
1478 /// Lists sessions, optionally filtered by source and working-directory context. Returned entries are discriminated by `isRemote`: local entries carry only the lightweight `LocalSessionMetadataValue` shape; remote entries carry the full `RemoteSessionMetadataValue` shape (repository, PR number, taskType, etc.).
1479 ///
1480 /// Wire method: `sessions.list`.
1481 ///
1482 /// # Returns
1483 ///
1484 /// Sessions matching the filter, ordered most-recently-modified first.
1485 ///
1486 /// <div class="warning">
1487 ///
1488 /// **Experimental.** This API is part of an experimental wire-protocol surface
1489 /// and may change or be removed in future SDK or CLI releases. Pin both the
1490 /// SDK and CLI versions if your code depends on it.
1491 ///
1492 /// </div>
1493 pub async fn list(&self) -> Result<SessionList, Error> {
1494 let wire_params = serde_json::json!({});
1495 let _value = self
1496 .client
1497 .call(rpc_methods::SESSIONS_LIST, Some(wire_params))
1498 .await?;
1499 Ok(serde_json::from_value(_value)?)
1500 }
1501
1502 /// Lists sessions, optionally filtered by source and working-directory context. Returned entries are discriminated by `isRemote`: local entries carry only the lightweight `LocalSessionMetadataValue` shape; remote entries carry the full `RemoteSessionMetadataValue` shape (repository, PR number, taskType, etc.).
1503 ///
1504 /// Wire method: `sessions.list`.
1505 ///
1506 /// # Parameters
1507 ///
1508 /// * `params` - Optional source filter, metadata-load limit, and context filter applied to the returned sessions.
1509 ///
1510 /// # Returns
1511 ///
1512 /// Sessions matching the filter, ordered most-recently-modified first.
1513 ///
1514 /// <div class="warning">
1515 ///
1516 /// **Experimental.** This API is part of an experimental wire-protocol surface
1517 /// and may change or be removed in future SDK or CLI releases. Pin both the
1518 /// SDK and CLI versions if your code depends on it.
1519 ///
1520 /// </div>
1521 pub async fn list_with_params(
1522 &self,
1523 params: SessionsListRequest,
1524 ) -> Result<SessionList, Error> {
1525 let wire_params = serde_json::to_value(params)?;
1526 let _value = self
1527 .client
1528 .call(rpc_methods::SESSIONS_LIST, Some(wire_params))
1529 .await?;
1530 Ok(serde_json::from_value(_value)?)
1531 }
1532
1533 /// Finds the local session bound to a GitHub task ID, if any.
1534 ///
1535 /// Wire method: `sessions.findByTaskId`.
1536 ///
1537 /// # Parameters
1538 ///
1539 /// * `params` - GitHub task ID to look up.
1540 ///
1541 /// # Returns
1542 ///
1543 /// ID of the local session bound to the given GitHub task, or omitted when none.
1544 ///
1545 /// <div class="warning">
1546 ///
1547 /// **Experimental.** This API is part of an experimental wire-protocol surface
1548 /// and may change or be removed in future SDK or CLI releases. Pin both the
1549 /// SDK and CLI versions if your code depends on it.
1550 ///
1551 /// </div>
1552 pub async fn find_by_task_id(
1553 &self,
1554 params: SessionsFindByTaskIDRequest,
1555 ) -> Result<SessionsFindByTaskIDResult, Error> {
1556 let wire_params = serde_json::to_value(params)?;
1557 let _value = self
1558 .client
1559 .call(rpc_methods::SESSIONS_FINDBYTASKID, Some(wire_params))
1560 .await?;
1561 Ok(serde_json::from_value(_value)?)
1562 }
1563
1564 /// Resolves a UUID prefix to a unique session ID, if exactly one session matches.
1565 ///
1566 /// Wire method: `sessions.findByPrefix`.
1567 ///
1568 /// # Parameters
1569 ///
1570 /// * `params` - UUID prefix to resolve to a unique session ID.
1571 ///
1572 /// # Returns
1573 ///
1574 /// Session ID matching the prefix, omitted when no unique match exists.
1575 ///
1576 /// <div class="warning">
1577 ///
1578 /// **Experimental.** This API is part of an experimental wire-protocol surface
1579 /// and may change or be removed in future SDK or CLI releases. Pin both the
1580 /// SDK and CLI versions if your code depends on it.
1581 ///
1582 /// </div>
1583 pub async fn find_by_prefix(
1584 &self,
1585 params: SessionsFindByPrefixRequest,
1586 ) -> Result<SessionsFindByPrefixResult, Error> {
1587 let wire_params = serde_json::to_value(params)?;
1588 let _value = self
1589 .client
1590 .call(rpc_methods::SESSIONS_FINDBYPREFIX, Some(wire_params))
1591 .await?;
1592 Ok(serde_json::from_value(_value)?)
1593 }
1594
1595 /// Returns the most-relevant prior session for a given working-directory context.
1596 ///
1597 /// Wire method: `sessions.getLastForContext`.
1598 ///
1599 /// # Parameters
1600 ///
1601 /// * `params` - Optional working-directory context used to score session relevance.
1602 ///
1603 /// # Returns
1604 ///
1605 /// Most-relevant session ID for the supplied context, or omitted when no sessions exist.
1606 ///
1607 /// <div class="warning">
1608 ///
1609 /// **Experimental.** This API is part of an experimental wire-protocol surface
1610 /// and may change or be removed in future SDK or CLI releases. Pin both the
1611 /// SDK and CLI versions if your code depends on it.
1612 ///
1613 /// </div>
1614 pub async fn get_last_for_context(
1615 &self,
1616 params: SessionsGetLastForContextRequest,
1617 ) -> Result<SessionsGetLastForContextResult, Error> {
1618 let wire_params = serde_json::to_value(params)?;
1619 let _value = self
1620 .client
1621 .call(rpc_methods::SESSIONS_GETLASTFORCONTEXT, Some(wire_params))
1622 .await?;
1623 Ok(serde_json::from_value(_value)?)
1624 }
1625
1626 /// Computes the absolute path to a session's persisted events.jsonl file. Internal: filesystem paths are only meaningful in-process (CLI and runtime share a filesystem). Currently used by the CLI's contribution-graph feature to read historical events directly. Remote SDK consumers must not depend on this; a proper event-query API would replace it if the contribution graph ever needed to work over the wire.
1627 ///
1628 /// Wire method: `sessions.getEventFilePath`.
1629 ///
1630 /// # Parameters
1631 ///
1632 /// * `params` - Session ID whose event-log file path to compute.
1633 ///
1634 /// # Returns
1635 ///
1636 /// Absolute path to the session's events.jsonl file on disk.
1637 ///
1638 /// <div class="warning">
1639 ///
1640 /// **Experimental.** This API is part of an experimental wire-protocol surface
1641 /// and may change or be removed in future SDK or CLI releases. Pin both the
1642 /// SDK and CLI versions if your code depends on it.
1643 ///
1644 /// </div>
1645 pub(crate) async fn get_event_file_path(
1646 &self,
1647 params: SessionsGetEventFilePathRequest,
1648 ) -> Result<SessionsGetEventFilePathResult, Error> {
1649 let wire_params = serde_json::to_value(params)?;
1650 let _value = self
1651 .client
1652 .call(rpc_methods::SESSIONS_GETEVENTFILEPATH, Some(wire_params))
1653 .await?;
1654 Ok(serde_json::from_value(_value)?)
1655 }
1656
1657 /// Returns the on-disk byte size of each session's workspace directory.
1658 ///
1659 /// Wire method: `sessions.getSizes`.
1660 ///
1661 /// # Returns
1662 ///
1663 /// Map of sessionId -> on-disk size in bytes for each session's workspace directory.
1664 ///
1665 /// <div class="warning">
1666 ///
1667 /// **Experimental.** This API is part of an experimental wire-protocol surface
1668 /// and may change or be removed in future SDK or CLI releases. Pin both the
1669 /// SDK and CLI versions if your code depends on it.
1670 ///
1671 /// </div>
1672 pub async fn get_sizes(&self) -> Result<SessionSizes, Error> {
1673 let wire_params = serde_json::json!({});
1674 let _value = self
1675 .client
1676 .call(rpc_methods::SESSIONS_GETSIZES, Some(wire_params))
1677 .await?;
1678 Ok(serde_json::from_value(_value)?)
1679 }
1680
1681 /// Returns the subset of the supplied session IDs that are currently held by another running process.
1682 ///
1683 /// Wire method: `sessions.checkInUse`.
1684 ///
1685 /// # Parameters
1686 ///
1687 /// * `params` - Session IDs to test for live in-use locks.
1688 ///
1689 /// # Returns
1690 ///
1691 /// Session IDs from the input set that are currently in use by another process.
1692 ///
1693 /// <div class="warning">
1694 ///
1695 /// **Experimental.** This API is part of an experimental wire-protocol surface
1696 /// and may change or be removed in future SDK or CLI releases. Pin both the
1697 /// SDK and CLI versions if your code depends on it.
1698 ///
1699 /// </div>
1700 pub async fn check_in_use(
1701 &self,
1702 params: SessionsCheckInUseRequest,
1703 ) -> Result<SessionsCheckInUseResult, Error> {
1704 let wire_params = serde_json::to_value(params)?;
1705 let _value = self
1706 .client
1707 .call(rpc_methods::SESSIONS_CHECKINUSE, Some(wire_params))
1708 .await?;
1709 Ok(serde_json::from_value(_value)?)
1710 }
1711
1712 /// Returns a session's persisted remote-steerable flag, if any has been recorded. Internal: this is CLI-specific book-keeping used by `--continue` / `--resume` to inherit the prior session's remote-steerable preference. SDK consumers that want similar behavior should manage their own persistence around start/stop calls rather than relying on this runtime-side flag.
1713 ///
1714 /// Wire method: `sessions.getPersistedRemoteSteerable`.
1715 ///
1716 /// # Parameters
1717 ///
1718 /// * `params` - Session ID to look up the persisted remote-steerable flag for.
1719 ///
1720 /// # Returns
1721 ///
1722 /// The session's persisted remote-steerable flag, or omitted when no value has been persisted.
1723 ///
1724 /// <div class="warning">
1725 ///
1726 /// **Experimental.** This API is part of an experimental wire-protocol surface
1727 /// and may change or be removed in future SDK or CLI releases. Pin both the
1728 /// SDK and CLI versions if your code depends on it.
1729 ///
1730 /// </div>
1731 pub(crate) async fn get_persisted_remote_steerable(
1732 &self,
1733 params: SessionsGetPersistedRemoteSteerableRequest,
1734 ) -> Result<SessionsGetPersistedRemoteSteerableResult, Error> {
1735 let wire_params = serde_json::to_value(params)?;
1736 let _value = self
1737 .client
1738 .call(
1739 rpc_methods::SESSIONS_GETPERSISTEDREMOTESTEERABLE,
1740 Some(wire_params),
1741 )
1742 .await?;
1743 Ok(serde_json::from_value(_value)?)
1744 }
1745
1746 /// Closes a session: emits shutdown, flushes pending events, releases the in-use lock, and disposes the active session.
1747 ///
1748 /// Wire method: `sessions.close`.
1749 ///
1750 /// # Parameters
1751 ///
1752 /// * `params` - Session ID to close.
1753 ///
1754 /// # Returns
1755 ///
1756 /// 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.
1757 ///
1758 /// <div class="warning">
1759 ///
1760 /// **Experimental.** This API is part of an experimental wire-protocol surface
1761 /// and may change or be removed in future SDK or CLI releases. Pin both the
1762 /// SDK and CLI versions if your code depends on it.
1763 ///
1764 /// </div>
1765 pub async fn close(&self, params: SessionsCloseRequest) -> Result<SessionsCloseResult, Error> {
1766 let wire_params = serde_json::to_value(params)?;
1767 let _value = self
1768 .client
1769 .call(rpc_methods::SESSIONS_CLOSE, Some(wire_params))
1770 .await?;
1771 Ok(serde_json::from_value(_value)?)
1772 }
1773
1774 /// Closes, deactivates, and deletes a set of sessions, returning the bytes freed per session.
1775 ///
1776 /// Wire method: `sessions.bulkDelete`.
1777 ///
1778 /// # Parameters
1779 ///
1780 /// * `params` - Session IDs to close, deactivate, and delete from disk.
1781 ///
1782 /// # Returns
1783 ///
1784 /// Map of sessionId -> bytes freed by removing the session's workspace directory.
1785 ///
1786 /// <div class="warning">
1787 ///
1788 /// **Experimental.** This API is part of an experimental wire-protocol surface
1789 /// and may change or be removed in future SDK or CLI releases. Pin both the
1790 /// SDK and CLI versions if your code depends on it.
1791 ///
1792 /// </div>
1793 pub async fn bulk_delete(
1794 &self,
1795 params: SessionsBulkDeleteRequest,
1796 ) -> Result<SessionBulkDeleteResult, Error> {
1797 let wire_params = serde_json::to_value(params)?;
1798 let _value = self
1799 .client
1800 .call(rpc_methods::SESSIONS_BULKDELETE, Some(wire_params))
1801 .await?;
1802 Ok(serde_json::from_value(_value)?)
1803 }
1804
1805 /// Deletes sessions older than the given threshold, with optional dry-run and exclusion list.
1806 ///
1807 /// Wire method: `sessions.pruneOld`.
1808 ///
1809 /// # Parameters
1810 ///
1811 /// * `params` - Age threshold and optional flags controlling which old sessions are pruned (or simulated when dryRun is true).
1812 ///
1813 /// # Returns
1814 ///
1815 /// Outcome of the prune operation: deleted IDs, dry-run candidates, skipped IDs, total bytes freed, and the dry-run flag.
1816 ///
1817 /// <div class="warning">
1818 ///
1819 /// **Experimental.** This API is part of an experimental wire-protocol surface
1820 /// and may change or be removed in future SDK or CLI releases. Pin both the
1821 /// SDK and CLI versions if your code depends on it.
1822 ///
1823 /// </div>
1824 pub async fn prune_old(
1825 &self,
1826 params: SessionsPruneOldRequest,
1827 ) -> Result<SessionPruneResult, Error> {
1828 let wire_params = serde_json::to_value(params)?;
1829 let _value = self
1830 .client
1831 .call(rpc_methods::SESSIONS_PRUNEOLD, Some(wire_params))
1832 .await?;
1833 Ok(serde_json::from_value(_value)?)
1834 }
1835
1836 /// Flushes a session's pending events to disk.
1837 ///
1838 /// Wire method: `sessions.save`.
1839 ///
1840 /// # Parameters
1841 ///
1842 /// * `params` - Session ID whose pending events should be flushed to disk.
1843 ///
1844 /// # Returns
1845 ///
1846 /// Flush a session's pending events to disk. No-op when no writer exists for the session (e.g., already closed).
1847 ///
1848 /// <div class="warning">
1849 ///
1850 /// **Experimental.** This API is part of an experimental wire-protocol surface
1851 /// and may change or be removed in future SDK or CLI releases. Pin both the
1852 /// SDK and CLI versions if your code depends on it.
1853 ///
1854 /// </div>
1855 pub async fn save(&self, params: SessionsSaveRequest) -> Result<SessionsSaveResult, Error> {
1856 let wire_params = serde_json::to_value(params)?;
1857 let _value = self
1858 .client
1859 .call(rpc_methods::SESSIONS_SAVE, Some(wire_params))
1860 .await?;
1861 Ok(serde_json::from_value(_value)?)
1862 }
1863
1864 /// Releases the in-use lock held by this process for a session.
1865 ///
1866 /// Wire method: `sessions.releaseLock`.
1867 ///
1868 /// # Parameters
1869 ///
1870 /// * `params` - Session ID whose in-use lock should be released.
1871 ///
1872 /// # Returns
1873 ///
1874 /// 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.
1875 ///
1876 /// <div class="warning">
1877 ///
1878 /// **Experimental.** This API is part of an experimental wire-protocol surface
1879 /// and may change or be removed in future SDK or CLI releases. Pin both the
1880 /// SDK and CLI versions if your code depends on it.
1881 ///
1882 /// </div>
1883 pub async fn release_lock(
1884 &self,
1885 params: SessionsReleaseLockRequest,
1886 ) -> Result<SessionsReleaseLockResult, Error> {
1887 let wire_params = serde_json::to_value(params)?;
1888 let _value = self
1889 .client
1890 .call(rpc_methods::SESSIONS_RELEASELOCK, Some(wire_params))
1891 .await?;
1892 Ok(serde_json::from_value(_value)?)
1893 }
1894
1895 /// Backfills missing summary and context fields on the supplied session metadata records.
1896 ///
1897 /// Wire method: `sessions.enrichMetadata`.
1898 ///
1899 /// # Parameters
1900 ///
1901 /// * `params` - Session metadata records to enrich with summary and context information.
1902 ///
1903 /// # Returns
1904 ///
1905 /// The enriched metadata records, with summary and context fields backfilled where available. Sessions confirmed empty and unnamed are omitted.
1906 ///
1907 /// <div class="warning">
1908 ///
1909 /// **Experimental.** This API is part of an experimental wire-protocol surface
1910 /// and may change or be removed in future SDK or CLI releases. Pin both the
1911 /// SDK and CLI versions if your code depends on it.
1912 ///
1913 /// </div>
1914 pub async fn enrich_metadata(
1915 &self,
1916 params: SessionsEnrichMetadataRequest,
1917 ) -> Result<SessionEnrichMetadataResult, Error> {
1918 let wire_params = serde_json::to_value(params)?;
1919 let _value = self
1920 .client
1921 .call(rpc_methods::SESSIONS_ENRICHMETADATA, Some(wire_params))
1922 .await?;
1923 Ok(serde_json::from_value(_value)?)
1924 }
1925
1926 /// Reloads user, plugin, and (optionally) repo hooks on the active session.
1927 ///
1928 /// Wire method: `sessions.reloadPluginHooks`.
1929 ///
1930 /// # Parameters
1931 ///
1932 /// * `params` - Active session ID and an optional flag for deferring repo-level hooks until folder trust.
1933 ///
1934 /// # Returns
1935 ///
1936 /// Reload all hooks (user, plugin, optionally repo) and apply them to the active session. Call after installing or removing plugins so their hooks take effect immediately. No-op when no active session matches the given sessionId.
1937 ///
1938 /// <div class="warning">
1939 ///
1940 /// **Experimental.** This API is part of an experimental wire-protocol surface
1941 /// and may change or be removed in future SDK or CLI releases. Pin both the
1942 /// SDK and CLI versions if your code depends on it.
1943 ///
1944 /// </div>
1945 pub async fn reload_plugin_hooks(
1946 &self,
1947 params: SessionsReloadPluginHooksRequest,
1948 ) -> Result<SessionsReloadPluginHooksResult, Error> {
1949 let wire_params = serde_json::to_value(params)?;
1950 let _value = self
1951 .client
1952 .call(rpc_methods::SESSIONS_RELOADPLUGINHOOKS, Some(wire_params))
1953 .await?;
1954 Ok(serde_json::from_value(_value)?)
1955 }
1956
1957 /// Loads previously-deferred repo-level hooks on the active session, returning queued startup prompts.
1958 ///
1959 /// Wire method: `sessions.loadDeferredRepoHooks`.
1960 ///
1961 /// # Parameters
1962 ///
1963 /// * `params` - Active session ID whose deferred repo-level hooks should be loaded.
1964 ///
1965 /// # Returns
1966 ///
1967 /// Queued repo-level startup prompts and the total hook command count after loading.
1968 ///
1969 /// <div class="warning">
1970 ///
1971 /// **Experimental.** This API is part of an experimental wire-protocol surface
1972 /// and may change or be removed in future SDK or CLI releases. Pin both the
1973 /// SDK and CLI versions if your code depends on it.
1974 ///
1975 /// </div>
1976 pub async fn load_deferred_repo_hooks(
1977 &self,
1978 params: SessionsLoadDeferredRepoHooksRequest,
1979 ) -> Result<SessionLoadDeferredRepoHooksResult, Error> {
1980 let wire_params = serde_json::to_value(params)?;
1981 let _value = self
1982 .client
1983 .call(
1984 rpc_methods::SESSIONS_LOADDEFERREDREPOHOOKS,
1985 Some(wire_params),
1986 )
1987 .await?;
1988 Ok(serde_json::from_value(_value)?)
1989 }
1990
1991 /// Replaces the manager-wide additional plugins registered with the session manager.
1992 ///
1993 /// Wire method: `sessions.setAdditionalPlugins`.
1994 ///
1995 /// # Parameters
1996 ///
1997 /// * `params` - Manager-wide additional plugins to register; replaces any previously-configured set.
1998 ///
1999 /// # Returns
2000 ///
2001 /// Replace the manager-wide additional plugins. New session creations and subsequent hook reloads see the new set; already-running sessions keep their existing hook installation until the next reload.
2002 ///
2003 /// <div class="warning">
2004 ///
2005 /// **Experimental.** This API is part of an experimental wire-protocol surface
2006 /// and may change or be removed in future SDK or CLI releases. Pin both the
2007 /// SDK and CLI versions if your code depends on it.
2008 ///
2009 /// </div>
2010 pub async fn set_additional_plugins(
2011 &self,
2012 params: SessionsSetAdditionalPluginsRequest,
2013 ) -> Result<SessionsSetAdditionalPluginsResult, Error> {
2014 let wire_params = serde_json::to_value(params)?;
2015 let _value = self
2016 .client
2017 .call(
2018 rpc_methods::SESSIONS_SETADDITIONALPLUGINS,
2019 Some(wire_params),
2020 )
2021 .await?;
2022 Ok(serde_json::from_value(_value)?)
2023 }
2024
2025 /// Gets the dynamic-context board entry count associated with a session, when available. Internal: this exists solely so CLI telemetry events (`rem_spawn_gate`, `rem_consolidation_complete`) can pair START / END board counts around the detached rem-agent spawn. "Dynamic context board" is a runtime-internal concept that is not part of the public SDK contract; the long-term plan is to relocate the telemetry emission into the runtime so this method can be deleted entirely.
2026 ///
2027 /// Wire method: `sessions.getBoardEntryCount`.
2028 ///
2029 /// # Parameters
2030 ///
2031 /// * `params` - Session ID whose board entry count should be returned.
2032 ///
2033 /// # Returns
2034 ///
2035 /// Dynamic-context board entry count, when available.
2036 ///
2037 /// <div class="warning">
2038 ///
2039 /// **Experimental.** This API is part of an experimental wire-protocol surface
2040 /// and may change or be removed in future SDK or CLI releases. Pin both the
2041 /// SDK and CLI versions if your code depends on it.
2042 ///
2043 /// </div>
2044 pub(crate) async fn get_board_entry_count(
2045 &self,
2046 params: SessionsGetBoardEntryCountRequest,
2047 ) -> Result<SessionsGetBoardEntryCountResult, Error> {
2048 let wire_params = serde_json::to_value(params)?;
2049 let _value = self
2050 .client
2051 .call(rpc_methods::SESSIONS_GETBOARDENTRYCOUNT, Some(wire_params))
2052 .await?;
2053 Ok(serde_json::from_value(_value)?)
2054 }
2055
2056 /// Attaches the runtime-managed remote-control singleton to a session, awaiting initial setup. If remote control is already attached to a different session, the singleton is transferred (preserving the underlying Mission Control connection). Returns the final status.
2057 ///
2058 /// Wire method: `sessions.startRemoteControl`.
2059 ///
2060 /// # Parameters
2061 ///
2062 /// * `params` - Parameters for attaching the remote-control singleton to a session.
2063 ///
2064 /// # Returns
2065 ///
2066 /// Wrapper for the singleton's current status.
2067 ///
2068 /// <div class="warning">
2069 ///
2070 /// **Experimental.** This API is part of an experimental wire-protocol surface
2071 /// and may change or be removed in future SDK or CLI releases. Pin both the
2072 /// SDK and CLI versions if your code depends on it.
2073 ///
2074 /// </div>
2075 pub async fn start_remote_control(
2076 &self,
2077 params: SessionsStartRemoteControlRequest,
2078 ) -> Result<RemoteControlStatusResult, Error> {
2079 let wire_params = serde_json::to_value(params)?;
2080 let _value = self
2081 .client
2082 .call(rpc_methods::SESSIONS_STARTREMOTECONTROL, Some(wire_params))
2083 .await?;
2084 Ok(serde_json::from_value(_value)?)
2085 }
2086
2087 /// Atomically rebinds the remote-control singleton to a different session, preserving the underlying Mission Control connection. When `expectedFromSessionId` is provided and does not match the singleton's current `attachedSessionId`, the transfer is rejected with `transferred: false` and the current status is returned unchanged.
2088 ///
2089 /// Wire method: `sessions.transferRemoteControl`.
2090 ///
2091 /// # Parameters
2092 ///
2093 /// * `params` - Parameters for atomically rebinding the remote-control singleton.
2094 ///
2095 /// # Returns
2096 ///
2097 /// Outcome of a transferRemoteControl call.
2098 ///
2099 /// <div class="warning">
2100 ///
2101 /// **Experimental.** This API is part of an experimental wire-protocol surface
2102 /// and may change or be removed in future SDK or CLI releases. Pin both the
2103 /// SDK and CLI versions if your code depends on it.
2104 ///
2105 /// </div>
2106 pub async fn transfer_remote_control(
2107 &self,
2108 params: SessionsTransferRemoteControlRequest,
2109 ) -> Result<RemoteControlTransferResult, Error> {
2110 let wire_params = serde_json::to_value(params)?;
2111 let _value = self
2112 .client
2113 .call(
2114 rpc_methods::SESSIONS_TRANSFERREMOTECONTROL,
2115 Some(wire_params),
2116 )
2117 .await?;
2118 Ok(serde_json::from_value(_value)?)
2119 }
2120
2121 /// Patches the steering state of the active remote-control singleton. When remote control is off, this is a no-op and the off status is returned. Today only `enabled: true` is actionable on the underlying exporter; passing `false` is reserved for future use.
2122 ///
2123 /// Wire method: `sessions.setRemoteControlSteering`.
2124 ///
2125 /// # Parameters
2126 ///
2127 /// * `params` - Patch for the singleton's steering state.
2128 ///
2129 /// # Returns
2130 ///
2131 /// Wrapper for the singleton's current status.
2132 ///
2133 /// <div class="warning">
2134 ///
2135 /// **Experimental.** This API is part of an experimental wire-protocol surface
2136 /// and may change or be removed in future SDK or CLI releases. Pin both the
2137 /// SDK and CLI versions if your code depends on it.
2138 ///
2139 /// </div>
2140 pub async fn set_remote_control_steering(
2141 &self,
2142 params: SessionsSetRemoteControlSteeringRequest,
2143 ) -> Result<RemoteControlStatusResult, Error> {
2144 let wire_params = serde_json::to_value(params)?;
2145 let _value = self
2146 .client
2147 .call(
2148 rpc_methods::SESSIONS_SETREMOTECONTROLSTEERING,
2149 Some(wire_params),
2150 )
2151 .await?;
2152 Ok(serde_json::from_value(_value)?)
2153 }
2154
2155 /// Stops the remote-control singleton. When `expectedSessionId` is provided and does not match the singleton's current `attachedSessionId`, the stop is rejected with `stopped: false` and the current status is returned unchanged (unless `force` is set, in which case the singleton is unconditionally torn down).
2156 ///
2157 /// Wire method: `sessions.stopRemoteControl`.
2158 ///
2159 /// # Returns
2160 ///
2161 /// Outcome of a stopRemoteControl call.
2162 ///
2163 /// <div class="warning">
2164 ///
2165 /// **Experimental.** This API is part of an experimental wire-protocol surface
2166 /// and may change or be removed in future SDK or CLI releases. Pin both the
2167 /// SDK and CLI versions if your code depends on it.
2168 ///
2169 /// </div>
2170 pub async fn stop_remote_control(&self) -> Result<RemoteControlStopResult, Error> {
2171 let wire_params = serde_json::json!({});
2172 let _value = self
2173 .client
2174 .call(rpc_methods::SESSIONS_STOPREMOTECONTROL, Some(wire_params))
2175 .await?;
2176 Ok(serde_json::from_value(_value)?)
2177 }
2178
2179 /// Stops the remote-control singleton. When `expectedSessionId` is provided and does not match the singleton's current `attachedSessionId`, the stop is rejected with `stopped: false` and the current status is returned unchanged (unless `force` is set, in which case the singleton is unconditionally torn down).
2180 ///
2181 /// Wire method: `sessions.stopRemoteControl`.
2182 ///
2183 /// # Parameters
2184 ///
2185 /// * `params` - Parameters for stopping the remote-control singleton.
2186 ///
2187 /// # Returns
2188 ///
2189 /// Outcome of a stopRemoteControl call.
2190 ///
2191 /// <div class="warning">
2192 ///
2193 /// **Experimental.** This API is part of an experimental wire-protocol surface
2194 /// and may change or be removed in future SDK or CLI releases. Pin both the
2195 /// SDK and CLI versions if your code depends on it.
2196 ///
2197 /// </div>
2198 pub async fn stop_remote_control_with_params(
2199 &self,
2200 params: SessionsStopRemoteControlRequest,
2201 ) -> Result<RemoteControlStopResult, Error> {
2202 let wire_params = serde_json::to_value(params)?;
2203 let _value = self
2204 .client
2205 .call(rpc_methods::SESSIONS_STOPREMOTECONTROL, Some(wire_params))
2206 .await?;
2207 Ok(serde_json::from_value(_value)?)
2208 }
2209
2210 /// Returns the current state of the remote-control singleton, including the attached session id and frontend URL when active.
2211 ///
2212 /// Wire method: `sessions.getRemoteControlStatus`.
2213 ///
2214 /// # Returns
2215 ///
2216 /// Wrapper for the singleton's current status.
2217 ///
2218 /// <div class="warning">
2219 ///
2220 /// **Experimental.** This API is part of an experimental wire-protocol surface
2221 /// and may change or be removed in future SDK or CLI releases. Pin both the
2222 /// SDK and CLI versions if your code depends on it.
2223 ///
2224 /// </div>
2225 pub async fn get_remote_control_status(&self) -> Result<RemoteControlStatusResult, Error> {
2226 let wire_params = serde_json::json!({});
2227 let _value = self
2228 .client
2229 .call(
2230 rpc_methods::SESSIONS_GETREMOTECONTROLSTATUS,
2231 Some(wire_params),
2232 )
2233 .await?;
2234 Ok(serde_json::from_value(_value)?)
2235 }
2236
2237 /// Registers extension-provided tools on the given session, gated by an optional `enabled` callback. Returns an opaque unsubscribe function the caller must invoke to deregister the tools when the extension is torn down. Marked internal because `loader`, `enabled`, and the returned `unsubscribe` are in-process handles that cannot cross the JSON-RPC boundary. Disappears once extension discovery / launch / tool registration are owned by the runtime: SDK consumers will pass pure config (search paths, disabled ids) via `SessionOptions` and the runtime will resolve, launch, register, and tear down extensions itself.
2238 ///
2239 /// Wire method: `sessions.registerExtensionToolsOnSession`.
2240 ///
2241 /// # Parameters
2242 ///
2243 /// * `params` - Params to attach an extension loader's tools to a session.
2244 ///
2245 /// # Returns
2246 ///
2247 /// Handle for releasing the extension tool registration.
2248 ///
2249 /// <div class="warning">
2250 ///
2251 /// **Experimental.** This API is part of an experimental wire-protocol surface
2252 /// and may change or be removed in future SDK or CLI releases. Pin both the
2253 /// SDK and CLI versions if your code depends on it.
2254 ///
2255 /// </div>
2256 pub(crate) async fn register_extension_tools_on_session(
2257 &self,
2258 params: RegisterExtensionToolsParams,
2259 ) -> Result<RegisterExtensionToolsResult, Error> {
2260 let wire_params = serde_json::to_value(params)?;
2261 let _value = self
2262 .client
2263 .call(
2264 rpc_methods::SESSIONS_REGISTEREXTENSIONTOOLSONSESSION,
2265 Some(wire_params),
2266 )
2267 .await?;
2268 Ok(serde_json::from_value(_value)?)
2269 }
2270
2271 /// Attaches (or detaches) an in-process ExtensionController delegate for the given session, used by shared-API surfaces that need to query or modify the session's extension state. Pass `controller: undefined` to detach. Marked internal because the controller is an in-process object that cannot cross the JSON-RPC boundary. Disappears alongside `registerExtensionToolsOnSession`: once the runtime owns extension management, the public surface exposes list/enable/disable/reload as dedicated RPCs served by the runtime.
2272 ///
2273 /// Wire method: `sessions.configureSessionExtensions`.
2274 ///
2275 /// # Parameters
2276 ///
2277 /// * `params` - Params to attach or detach an in-process ExtensionController delegate.
2278 ///
2279 /// <div class="warning">
2280 ///
2281 /// **Experimental.** This API is part of an experimental wire-protocol surface
2282 /// and may change or be removed in future SDK or CLI releases. Pin both the
2283 /// SDK and CLI versions if your code depends on it.
2284 ///
2285 /// </div>
2286 pub(crate) async fn configure_session_extensions(
2287 &self,
2288 params: ConfigureSessionExtensionsParams,
2289 ) -> Result<(), Error> {
2290 let wire_params = serde_json::to_value(params)?;
2291 let _value = self
2292 .client
2293 .call(
2294 rpc_methods::SESSIONS_CONFIGURESESSIONEXTENSIONS,
2295 Some(wire_params),
2296 )
2297 .await?;
2298 Ok(())
2299 }
2300}
2301
2302/// `skills.*` RPCs.
2303#[derive(Clone, Copy)]
2304pub struct ClientRpcSkills<'a> {
2305 pub(crate) client: &'a Client,
2306}
2307
2308impl<'a> ClientRpcSkills<'a> {
2309 /// `skills.config.*` sub-namespace.
2310 pub fn config(&self) -> ClientRpcSkillsConfig<'a> {
2311 ClientRpcSkillsConfig {
2312 client: self.client,
2313 }
2314 }
2315
2316 /// Discovers skills across global and project sources.
2317 ///
2318 /// Wire method: `skills.discover`.
2319 ///
2320 /// # Parameters
2321 ///
2322 /// * `params` - Optional project paths and additional skill directories to include in discovery.
2323 ///
2324 /// # Returns
2325 ///
2326 /// Skills discovered across global and project sources.
2327 ///
2328 /// <div class="warning">
2329 ///
2330 /// **Experimental.** This API is part of an experimental wire-protocol surface
2331 /// and may change or be removed in future SDK or CLI releases. Pin both the
2332 /// SDK and CLI versions if your code depends on it.
2333 ///
2334 /// </div>
2335 pub async fn discover(&self, params: SkillsDiscoverRequest) -> Result<ServerSkillList, Error> {
2336 let wire_params = serde_json::to_value(params)?;
2337 let _value = self
2338 .client
2339 .call(rpc_methods::SKILLS_DISCOVER, Some(wire_params))
2340 .await?;
2341 Ok(serde_json::from_value(_value)?)
2342 }
2343
2344 /// Returns the canonical directories where a client may create skills that the runtime will recognize, including ones that do not exist yet. Project directories become active once created.
2345 ///
2346 /// Wire method: `skills.getDiscoveryPaths`.
2347 ///
2348 /// # Parameters
2349 ///
2350 /// * `params` - Optional project paths to enumerate.
2351 ///
2352 /// # Returns
2353 ///
2354 /// Canonical locations where skills can be created so the runtime will recognize them.
2355 ///
2356 /// <div class="warning">
2357 ///
2358 /// **Experimental.** This API is part of an experimental wire-protocol surface
2359 /// and may change or be removed in future SDK or CLI releases. Pin both the
2360 /// SDK and CLI versions if your code depends on it.
2361 ///
2362 /// </div>
2363 pub async fn get_discovery_paths(
2364 &self,
2365 params: SkillsGetDiscoveryPathsRequest,
2366 ) -> Result<SkillDiscoveryPathList, Error> {
2367 let wire_params = serde_json::to_value(params)?;
2368 let _value = self
2369 .client
2370 .call(rpc_methods::SKILLS_GETDISCOVERYPATHS, Some(wire_params))
2371 .await?;
2372 Ok(serde_json::from_value(_value)?)
2373 }
2374}
2375
2376/// `skills.config.*` RPCs.
2377#[derive(Clone, Copy)]
2378pub struct ClientRpcSkillsConfig<'a> {
2379 pub(crate) client: &'a Client,
2380}
2381
2382impl<'a> ClientRpcSkillsConfig<'a> {
2383 /// Replaces the global list of disabled skills.
2384 ///
2385 /// Wire method: `skills.config.setDisabledSkills`.
2386 ///
2387 /// # Parameters
2388 ///
2389 /// * `params` - Skill names to mark as disabled in global configuration, replacing any previous list.
2390 ///
2391 /// <div class="warning">
2392 ///
2393 /// **Experimental.** This API is part of an experimental wire-protocol surface
2394 /// and may change or be removed in future SDK or CLI releases. Pin both the
2395 /// SDK and CLI versions if your code depends on it.
2396 ///
2397 /// </div>
2398 pub async fn set_disabled_skills(
2399 &self,
2400 params: SkillsConfigSetDisabledSkillsRequest,
2401 ) -> Result<(), Error> {
2402 let wire_params = serde_json::to_value(params)?;
2403 let _value = self
2404 .client
2405 .call(
2406 rpc_methods::SKILLS_CONFIG_SETDISABLEDSKILLS,
2407 Some(wire_params),
2408 )
2409 .await?;
2410 Ok(())
2411 }
2412}
2413
2414/// `tools.*` RPCs.
2415#[derive(Clone, Copy)]
2416pub struct ClientRpcTools<'a> {
2417 pub(crate) client: &'a Client,
2418}
2419
2420impl<'a> ClientRpcTools<'a> {
2421 /// Lists built-in tools available for a model.
2422 ///
2423 /// Wire method: `tools.list`.
2424 ///
2425 /// # Parameters
2426 ///
2427 /// * `params` - Optional model identifier whose tool overrides should be applied to the listing.
2428 ///
2429 /// # Returns
2430 ///
2431 /// Built-in tools available for the requested model, with their parameters and instructions.
2432 ///
2433 /// <div class="warning">
2434 ///
2435 /// **Experimental.** This API is part of an experimental wire-protocol surface
2436 /// and may change or be removed in future SDK or CLI releases. Pin both the
2437 /// SDK and CLI versions if your code depends on it.
2438 ///
2439 /// </div>
2440 pub async fn list(&self, params: ToolsListRequest) -> Result<ToolList, Error> {
2441 let wire_params = serde_json::to_value(params)?;
2442 let _value = self
2443 .client
2444 .call(rpc_methods::TOOLS_LIST, Some(wire_params))
2445 .await?;
2446 Ok(serde_json::from_value(_value)?)
2447 }
2448}
2449
2450/// `user.*` RPCs.
2451#[derive(Clone, Copy)]
2452pub struct ClientRpcUser<'a> {
2453 pub(crate) client: &'a Client,
2454}
2455
2456impl<'a> ClientRpcUser<'a> {
2457 /// `user.settings.*` sub-namespace.
2458 pub fn settings(&self) -> ClientRpcUserSettings<'a> {
2459 ClientRpcUserSettings {
2460 client: self.client,
2461 }
2462 }
2463}
2464
2465/// `user.settings.*` RPCs.
2466#[derive(Clone, Copy)]
2467pub struct ClientRpcUserSettings<'a> {
2468 pub(crate) client: &'a Client,
2469}
2470
2471impl<'a> ClientRpcUserSettings<'a> {
2472 /// Drops this runtime process's in-memory user settings cache so the next settings read observes disk.
2473 ///
2474 /// Wire method: `user.settings.reload`.
2475 ///
2476 /// <div class="warning">
2477 ///
2478 /// **Experimental.** This API is part of an experimental wire-protocol surface
2479 /// and may change or be removed in future SDK or CLI releases. Pin both the
2480 /// SDK and CLI versions if your code depends on it.
2481 ///
2482 /// </div>
2483 pub async fn reload(&self) -> Result<(), Error> {
2484 let wire_params = serde_json::json!({});
2485 let _value = self
2486 .client
2487 .call(rpc_methods::USER_SETTINGS_RELOAD, Some(wire_params))
2488 .await?;
2489 Ok(())
2490 }
2491
2492 /// Lists every known user setting (settings.json overlaid with the legacy config.json, config.json wins), each with its effective value, its default, and whether it is at the default — so settings the user has never set still appear with their default value. Does not include repository- or enterprise-managed overrides that the runtime layers on top at session time.
2493 ///
2494 /// Wire method: `user.settings.get`.
2495 ///
2496 /// # Returns
2497 ///
2498 /// Per-key metadata for every known user setting (settings.json overlaid with the legacy config.json, config.json wins), including settings left at their default. Excludes repository- and enterprise-managed overrides.
2499 ///
2500 /// <div class="warning">
2501 ///
2502 /// **Experimental.** This API is part of an experimental wire-protocol surface
2503 /// and may change or be removed in future SDK or CLI releases. Pin both the
2504 /// SDK and CLI versions if your code depends on it.
2505 ///
2506 /// </div>
2507 pub async fn get(&self) -> Result<UserSettingsGetResult, Error> {
2508 let wire_params = serde_json::json!({});
2509 let _value = self
2510 .client
2511 .call(rpc_methods::USER_SETTINGS_GET, Some(wire_params))
2512 .await?;
2513 Ok(serde_json::from_value(_value)?)
2514 }
2515
2516 /// Writes one or more user settings to settings.json, replacing each provided top-level key. A key whose value is null is removed. Returns the keys whose new value is shadowed by a legacy config.json entry (config.json wins on read), which the runtime leaves in place — such writes do not take effect until the legacy value is removed.
2517 ///
2518 /// Wire method: `user.settings.set`.
2519 ///
2520 /// # Parameters
2521 ///
2522 /// * `params` - Partial user settings to write to settings.json. Each top-level key is written individually, replacing the existing value; a key whose value is null is removed.
2523 ///
2524 /// # Returns
2525 ///
2526 /// Outcome of writing user settings.
2527 ///
2528 /// <div class="warning">
2529 ///
2530 /// **Experimental.** This API is part of an experimental wire-protocol surface
2531 /// and may change or be removed in future SDK or CLI releases. Pin both the
2532 /// SDK and CLI versions if your code depends on it.
2533 ///
2534 /// </div>
2535 pub async fn set(
2536 &self,
2537 params: UserSettingsSetRequest,
2538 ) -> Result<UserSettingsSetResult, Error> {
2539 let wire_params = serde_json::to_value(params)?;
2540 let _value = self
2541 .client
2542 .call(rpc_methods::USER_SETTINGS_SET, Some(wire_params))
2543 .await?;
2544 Ok(serde_json::from_value(_value)?)
2545 }
2546}
2547
2548/// Typed view over a [`Session`]'s RPC namespace.
2549#[derive(Clone, Copy)]
2550pub struct SessionRpc<'a> {
2551 pub(crate) session: &'a Session,
2552}
2553
2554impl<'a> SessionRpc<'a> {
2555 /// `session.agent.*` sub-namespace.
2556 pub fn agent(&self) -> SessionRpcAgent<'a> {
2557 SessionRpcAgent {
2558 session: self.session,
2559 }
2560 }
2561
2562 /// `session.canvas.*` sub-namespace.
2563 pub fn canvas(&self) -> SessionRpcCanvas<'a> {
2564 SessionRpcCanvas {
2565 session: self.session,
2566 }
2567 }
2568
2569 /// `session.commands.*` sub-namespace.
2570 pub fn commands(&self) -> SessionRpcCommands<'a> {
2571 SessionRpcCommands {
2572 session: self.session,
2573 }
2574 }
2575
2576 /// `session.completions.*` sub-namespace.
2577 pub fn completions(&self) -> SessionRpcCompletions<'a> {
2578 SessionRpcCompletions {
2579 session: self.session,
2580 }
2581 }
2582
2583 /// `session.eventLog.*` sub-namespace.
2584 pub fn event_log(&self) -> SessionRpcEventLog<'a> {
2585 SessionRpcEventLog {
2586 session: self.session,
2587 }
2588 }
2589
2590 /// `session.extensions.*` sub-namespace.
2591 pub fn extensions(&self) -> SessionRpcExtensions<'a> {
2592 SessionRpcExtensions {
2593 session: self.session,
2594 }
2595 }
2596
2597 /// `session.fleet.*` sub-namespace.
2598 pub fn fleet(&self) -> SessionRpcFleet<'a> {
2599 SessionRpcFleet {
2600 session: self.session,
2601 }
2602 }
2603
2604 /// `session.gitHubAuth.*` sub-namespace.
2605 pub fn git_hub_auth(&self) -> SessionRpcGitHubAuth<'a> {
2606 SessionRpcGitHubAuth {
2607 session: self.session,
2608 }
2609 }
2610
2611 /// `session.history.*` sub-namespace.
2612 pub fn history(&self) -> SessionRpcHistory<'a> {
2613 SessionRpcHistory {
2614 session: self.session,
2615 }
2616 }
2617
2618 /// `session.instructions.*` sub-namespace.
2619 pub fn instructions(&self) -> SessionRpcInstructions<'a> {
2620 SessionRpcInstructions {
2621 session: self.session,
2622 }
2623 }
2624
2625 /// `session.lsp.*` sub-namespace.
2626 pub fn lsp(&self) -> SessionRpcLsp<'a> {
2627 SessionRpcLsp {
2628 session: self.session,
2629 }
2630 }
2631
2632 /// `session.mcp.*` sub-namespace.
2633 pub fn mcp(&self) -> SessionRpcMcp<'a> {
2634 SessionRpcMcp {
2635 session: self.session,
2636 }
2637 }
2638
2639 /// `session.metadata.*` sub-namespace.
2640 pub fn metadata(&self) -> SessionRpcMetadata<'a> {
2641 SessionRpcMetadata {
2642 session: self.session,
2643 }
2644 }
2645
2646 /// `session.mode.*` sub-namespace.
2647 pub fn mode(&self) -> SessionRpcMode<'a> {
2648 SessionRpcMode {
2649 session: self.session,
2650 }
2651 }
2652
2653 /// `session.model.*` sub-namespace.
2654 pub fn model(&self) -> SessionRpcModel<'a> {
2655 SessionRpcModel {
2656 session: self.session,
2657 }
2658 }
2659
2660 /// `session.name.*` sub-namespace.
2661 pub fn name(&self) -> SessionRpcName<'a> {
2662 SessionRpcName {
2663 session: self.session,
2664 }
2665 }
2666
2667 /// `session.options.*` sub-namespace.
2668 pub fn options(&self) -> SessionRpcOptions<'a> {
2669 SessionRpcOptions {
2670 session: self.session,
2671 }
2672 }
2673
2674 /// `session.permissions.*` sub-namespace.
2675 pub fn permissions(&self) -> SessionRpcPermissions<'a> {
2676 SessionRpcPermissions {
2677 session: self.session,
2678 }
2679 }
2680
2681 /// `session.plan.*` sub-namespace.
2682 pub fn plan(&self) -> SessionRpcPlan<'a> {
2683 SessionRpcPlan {
2684 session: self.session,
2685 }
2686 }
2687
2688 /// `session.plugins.*` sub-namespace.
2689 pub fn plugins(&self) -> SessionRpcPlugins<'a> {
2690 SessionRpcPlugins {
2691 session: self.session,
2692 }
2693 }
2694
2695 /// `session.provider.*` sub-namespace.
2696 pub fn provider(&self) -> SessionRpcProvider<'a> {
2697 SessionRpcProvider {
2698 session: self.session,
2699 }
2700 }
2701
2702 /// `session.queue.*` sub-namespace.
2703 pub fn queue(&self) -> SessionRpcQueue<'a> {
2704 SessionRpcQueue {
2705 session: self.session,
2706 }
2707 }
2708
2709 /// `session.remote.*` sub-namespace.
2710 pub fn remote(&self) -> SessionRpcRemote<'a> {
2711 SessionRpcRemote {
2712 session: self.session,
2713 }
2714 }
2715
2716 /// `session.schedule.*` sub-namespace.
2717 pub fn schedule(&self) -> SessionRpcSchedule<'a> {
2718 SessionRpcSchedule {
2719 session: self.session,
2720 }
2721 }
2722
2723 /// `session.shell.*` sub-namespace.
2724 pub fn shell(&self) -> SessionRpcShell<'a> {
2725 SessionRpcShell {
2726 session: self.session,
2727 }
2728 }
2729
2730 /// `session.skills.*` sub-namespace.
2731 pub fn skills(&self) -> SessionRpcSkills<'a> {
2732 SessionRpcSkills {
2733 session: self.session,
2734 }
2735 }
2736
2737 /// `session.tasks.*` sub-namespace.
2738 pub fn tasks(&self) -> SessionRpcTasks<'a> {
2739 SessionRpcTasks {
2740 session: self.session,
2741 }
2742 }
2743
2744 /// `session.telemetry.*` sub-namespace.
2745 pub fn telemetry(&self) -> SessionRpcTelemetry<'a> {
2746 SessionRpcTelemetry {
2747 session: self.session,
2748 }
2749 }
2750
2751 /// `session.tools.*` sub-namespace.
2752 pub fn tools(&self) -> SessionRpcTools<'a> {
2753 SessionRpcTools {
2754 session: self.session,
2755 }
2756 }
2757
2758 /// `session.ui.*` sub-namespace.
2759 pub fn ui(&self) -> SessionRpcUi<'a> {
2760 SessionRpcUi {
2761 session: self.session,
2762 }
2763 }
2764
2765 /// `session.usage.*` sub-namespace.
2766 pub fn usage(&self) -> SessionRpcUsage<'a> {
2767 SessionRpcUsage {
2768 session: self.session,
2769 }
2770 }
2771
2772 /// `session.visibility.*` sub-namespace.
2773 pub fn visibility(&self) -> SessionRpcVisibility<'a> {
2774 SessionRpcVisibility {
2775 session: self.session,
2776 }
2777 }
2778
2779 /// `session.workspaces.*` sub-namespace.
2780 pub fn workspaces(&self) -> SessionRpcWorkspaces<'a> {
2781 SessionRpcWorkspaces {
2782 session: self.session,
2783 }
2784 }
2785
2786 /// Suspends the session while preserving persisted state for later resume.
2787 ///
2788 /// Wire method: `session.suspend`.
2789 ///
2790 /// <div class="warning">
2791 ///
2792 /// **Experimental.** This API is part of an experimental wire-protocol surface
2793 /// and may change or be removed in future SDK or CLI releases. Pin both the
2794 /// SDK and CLI versions if your code depends on it.
2795 ///
2796 /// </div>
2797 pub async fn suspend(&self) -> Result<(), Error> {
2798 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
2799 let _value = self
2800 .session
2801 .client()
2802 .call(rpc_methods::SESSION_SUSPEND, Some(wire_params))
2803 .await?;
2804 Ok(())
2805 }
2806
2807 /// Sends a user message to the session and returns its message ID.
2808 ///
2809 /// Wire method: `session.send`.
2810 ///
2811 /// # Parameters
2812 ///
2813 /// * `params` - Parameters for sending a user message to the session
2814 ///
2815 /// # Returns
2816 ///
2817 /// Result of sending a user message
2818 ///
2819 /// <div class="warning">
2820 ///
2821 /// **Experimental.** This API is part of an experimental wire-protocol surface
2822 /// and may change or be removed in future SDK or CLI releases. Pin both the
2823 /// SDK and CLI versions if your code depends on it.
2824 ///
2825 /// </div>
2826 pub async fn send(&self, params: SendRequest) -> Result<SendResult, Error> {
2827 let mut wire_params = serde_json::to_value(params)?;
2828 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
2829 let _value = self
2830 .session
2831 .client()
2832 .call(rpc_methods::SESSION_SEND, Some(wire_params))
2833 .await?;
2834 Ok(serde_json::from_value(_value)?)
2835 }
2836
2837 /// Aborts the current agent turn.
2838 ///
2839 /// Wire method: `session.abort`.
2840 ///
2841 /// # Parameters
2842 ///
2843 /// * `params` - Parameters for aborting the current turn
2844 ///
2845 /// # Returns
2846 ///
2847 /// Result of aborting the current turn
2848 ///
2849 /// <div class="warning">
2850 ///
2851 /// **Experimental.** This API is part of an experimental wire-protocol surface
2852 /// and may change or be removed in future SDK or CLI releases. Pin both the
2853 /// SDK and CLI versions if your code depends on it.
2854 ///
2855 /// </div>
2856 pub async fn abort(&self, params: AbortRequest) -> Result<AbortResult, Error> {
2857 let mut wire_params = serde_json::to_value(params)?;
2858 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
2859 let _value = self
2860 .session
2861 .client()
2862 .call(rpc_methods::SESSION_ABORT, Some(wire_params))
2863 .await?;
2864 Ok(serde_json::from_value(_value)?)
2865 }
2866
2867 /// Shuts down the session and persists its final state. Awaits any deferred sessionEnd hooks before resolving so user-supplied hook scripts complete before the runtime tears down.
2868 ///
2869 /// Wire method: `session.shutdown`.
2870 ///
2871 /// # Parameters
2872 ///
2873 /// * `params` - Parameters for shutting down the session
2874 ///
2875 /// <div class="warning">
2876 ///
2877 /// **Experimental.** This API is part of an experimental wire-protocol surface
2878 /// and may change or be removed in future SDK or CLI releases. Pin both the
2879 /// SDK and CLI versions if your code depends on it.
2880 ///
2881 /// </div>
2882 pub async fn shutdown(&self, params: ShutdownRequest) -> Result<(), Error> {
2883 let mut wire_params = serde_json::to_value(params)?;
2884 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
2885 let _value = self
2886 .session
2887 .client()
2888 .call(rpc_methods::SESSION_SHUTDOWN, Some(wire_params))
2889 .await?;
2890 Ok(())
2891 }
2892
2893 /// Emits a user-visible session log event.
2894 ///
2895 /// Wire method: `session.log`.
2896 ///
2897 /// # Parameters
2898 ///
2899 /// * `params` - Message text, optional severity level, persistence flag, optional follow-up URL, and optional tip.
2900 ///
2901 /// # Returns
2902 ///
2903 /// Identifier of the session event that was emitted for the log message.
2904 ///
2905 /// <div class="warning">
2906 ///
2907 /// **Experimental.** This API is part of an experimental wire-protocol surface
2908 /// and may change or be removed in future SDK or CLI releases. Pin both the
2909 /// SDK and CLI versions if your code depends on it.
2910 ///
2911 /// </div>
2912 pub async fn log(&self, params: LogRequest) -> Result<LogResult, Error> {
2913 let mut wire_params = serde_json::to_value(params)?;
2914 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
2915 let _value = self
2916 .session
2917 .client()
2918 .call(rpc_methods::SESSION_LOG, Some(wire_params))
2919 .await?;
2920 Ok(serde_json::from_value(_value)?)
2921 }
2922}
2923
2924/// `session.agent.*` RPCs.
2925#[derive(Clone, Copy)]
2926pub struct SessionRpcAgent<'a> {
2927 pub(crate) session: &'a Session,
2928}
2929
2930impl<'a> SessionRpcAgent<'a> {
2931 /// Lists custom agents available to the session.
2932 ///
2933 /// Wire method: `session.agent.list`.
2934 ///
2935 /// # Returns
2936 ///
2937 /// Custom agents available to the session.
2938 ///
2939 /// <div class="warning">
2940 ///
2941 /// **Experimental.** This API is part of an experimental wire-protocol surface
2942 /// and may change or be removed in future SDK or CLI releases. Pin both the
2943 /// SDK and CLI versions if your code depends on it.
2944 ///
2945 /// </div>
2946 pub async fn list(&self) -> Result<AgentList, Error> {
2947 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
2948 let _value = self
2949 .session
2950 .client()
2951 .call(rpc_methods::SESSION_AGENT_LIST, Some(wire_params))
2952 .await?;
2953 Ok(serde_json::from_value(_value)?)
2954 }
2955
2956 /// Gets the currently selected custom agent for the session.
2957 ///
2958 /// Wire method: `session.agent.getCurrent`.
2959 ///
2960 /// # Returns
2961 ///
2962 /// The currently selected custom agent, or null when using the default agent.
2963 ///
2964 /// <div class="warning">
2965 ///
2966 /// **Experimental.** This API is part of an experimental wire-protocol surface
2967 /// and may change or be removed in future SDK or CLI releases. Pin both the
2968 /// SDK and CLI versions if your code depends on it.
2969 ///
2970 /// </div>
2971 pub async fn get_current(&self) -> Result<AgentGetCurrentResult, Error> {
2972 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
2973 let _value = self
2974 .session
2975 .client()
2976 .call(rpc_methods::SESSION_AGENT_GETCURRENT, Some(wire_params))
2977 .await?;
2978 Ok(serde_json::from_value(_value)?)
2979 }
2980
2981 /// Selects a custom agent for subsequent turns in the session.
2982 ///
2983 /// Wire method: `session.agent.select`.
2984 ///
2985 /// # Parameters
2986 ///
2987 /// * `params` - Name of the custom agent to select for subsequent turns.
2988 ///
2989 /// # Returns
2990 ///
2991 /// The newly selected custom agent.
2992 ///
2993 /// <div class="warning">
2994 ///
2995 /// **Experimental.** This API is part of an experimental wire-protocol surface
2996 /// and may change or be removed in future SDK or CLI releases. Pin both the
2997 /// SDK and CLI versions if your code depends on it.
2998 ///
2999 /// </div>
3000 pub async fn select(&self, params: AgentSelectRequest) -> Result<AgentSelectResult, Error> {
3001 let mut wire_params = serde_json::to_value(params)?;
3002 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3003 let _value = self
3004 .session
3005 .client()
3006 .call(rpc_methods::SESSION_AGENT_SELECT, Some(wire_params))
3007 .await?;
3008 Ok(serde_json::from_value(_value)?)
3009 }
3010
3011 /// Clears the selected custom agent and returns the session to the default agent.
3012 ///
3013 /// Wire method: `session.agent.deselect`.
3014 ///
3015 /// <div class="warning">
3016 ///
3017 /// **Experimental.** This API is part of an experimental wire-protocol surface
3018 /// and may change or be removed in future SDK or CLI releases. Pin both the
3019 /// SDK and CLI versions if your code depends on it.
3020 ///
3021 /// </div>
3022 pub async fn deselect(&self) -> Result<(), Error> {
3023 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3024 let _value = self
3025 .session
3026 .client()
3027 .call(rpc_methods::SESSION_AGENT_DESELECT, Some(wire_params))
3028 .await?;
3029 Ok(())
3030 }
3031
3032 /// Reloads custom agent definitions and returns the refreshed list.
3033 ///
3034 /// Wire method: `session.agent.reload`.
3035 ///
3036 /// # Returns
3037 ///
3038 /// Custom agents available to the session after reloading definitions from disk.
3039 ///
3040 /// <div class="warning">
3041 ///
3042 /// **Experimental.** This API is part of an experimental wire-protocol surface
3043 /// and may change or be removed in future SDK or CLI releases. Pin both the
3044 /// SDK and CLI versions if your code depends on it.
3045 ///
3046 /// </div>
3047 pub async fn reload(&self) -> Result<AgentReloadResult, Error> {
3048 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3049 let _value = self
3050 .session
3051 .client()
3052 .call(rpc_methods::SESSION_AGENT_RELOAD, Some(wire_params))
3053 .await?;
3054 Ok(serde_json::from_value(_value)?)
3055 }
3056}
3057
3058/// `session.canvas.*` RPCs.
3059#[derive(Clone, Copy)]
3060pub struct SessionRpcCanvas<'a> {
3061 pub(crate) session: &'a Session,
3062}
3063
3064impl<'a> SessionRpcCanvas<'a> {
3065 /// `session.canvas.action.*` sub-namespace.
3066 pub fn action(&self) -> SessionRpcCanvasAction<'a> {
3067 SessionRpcCanvasAction {
3068 session: self.session,
3069 }
3070 }
3071
3072 /// Lists canvases declared for the session.
3073 ///
3074 /// Wire method: `session.canvas.list`.
3075 ///
3076 /// # Returns
3077 ///
3078 /// Declared canvases available in this session.
3079 ///
3080 /// <div class="warning">
3081 ///
3082 /// **Experimental.** This API is part of an experimental wire-protocol surface
3083 /// and may change or be removed in future SDK or CLI releases. Pin both the
3084 /// SDK and CLI versions if your code depends on it.
3085 ///
3086 /// </div>
3087 pub async fn list(&self) -> Result<CanvasList, Error> {
3088 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3089 let _value = self
3090 .session
3091 .client()
3092 .call(rpc_methods::SESSION_CANVAS_LIST, Some(wire_params))
3093 .await?;
3094 Ok(serde_json::from_value(_value)?)
3095 }
3096
3097 /// Lists currently open canvas instances for the live session.
3098 ///
3099 /// Wire method: `session.canvas.listOpen`.
3100 ///
3101 /// # Returns
3102 ///
3103 /// Live open-canvas snapshot.
3104 ///
3105 /// <div class="warning">
3106 ///
3107 /// **Experimental.** This API is part of an experimental wire-protocol surface
3108 /// and may change or be removed in future SDK or CLI releases. Pin both the
3109 /// SDK and CLI versions if your code depends on it.
3110 ///
3111 /// </div>
3112 pub async fn list_open(&self) -> Result<CanvasListOpenResult, Error> {
3113 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3114 let _value = self
3115 .session
3116 .client()
3117 .call(rpc_methods::SESSION_CANVAS_LISTOPEN, Some(wire_params))
3118 .await?;
3119 Ok(serde_json::from_value(_value)?)
3120 }
3121
3122 /// Opens or focuses a canvas instance.
3123 ///
3124 /// Wire method: `session.canvas.open`.
3125 ///
3126 /// # Parameters
3127 ///
3128 /// * `params` - Canvas open parameters.
3129 ///
3130 /// # Returns
3131 ///
3132 /// Open canvas instance snapshot.
3133 ///
3134 /// <div class="warning">
3135 ///
3136 /// **Experimental.** This API is part of an experimental wire-protocol surface
3137 /// and may change or be removed in future SDK or CLI releases. Pin both the
3138 /// SDK and CLI versions if your code depends on it.
3139 ///
3140 /// </div>
3141 pub async fn open(&self, params: CanvasOpenRequest) -> Result<OpenCanvasInstance, Error> {
3142 let mut wire_params = serde_json::to_value(params)?;
3143 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3144 let _value = self
3145 .session
3146 .client()
3147 .call(rpc_methods::SESSION_CANVAS_OPEN, Some(wire_params))
3148 .await?;
3149 Ok(serde_json::from_value(_value)?)
3150 }
3151
3152 /// Closes an open canvas instance.
3153 ///
3154 /// Wire method: `session.canvas.close`.
3155 ///
3156 /// # Parameters
3157 ///
3158 /// * `params` - Canvas close parameters.
3159 ///
3160 /// <div class="warning">
3161 ///
3162 /// **Experimental.** This API is part of an experimental wire-protocol surface
3163 /// and may change or be removed in future SDK or CLI releases. Pin both the
3164 /// SDK and CLI versions if your code depends on it.
3165 ///
3166 /// </div>
3167 pub async fn close(&self, params: CanvasCloseRequest) -> Result<(), Error> {
3168 let mut wire_params = serde_json::to_value(params)?;
3169 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3170 let _value = self
3171 .session
3172 .client()
3173 .call(rpc_methods::SESSION_CANVAS_CLOSE, Some(wire_params))
3174 .await?;
3175 Ok(())
3176 }
3177}
3178
3179/// `session.canvas.action.*` RPCs.
3180#[derive(Clone, Copy)]
3181pub struct SessionRpcCanvasAction<'a> {
3182 pub(crate) session: &'a Session,
3183}
3184
3185impl<'a> SessionRpcCanvasAction<'a> {
3186 /// Invokes an action on an open canvas instance.
3187 ///
3188 /// Wire method: `session.canvas.action.invoke`.
3189 ///
3190 /// # Parameters
3191 ///
3192 /// * `params` - Canvas action invocation parameters.
3193 ///
3194 /// # Returns
3195 ///
3196 /// Canvas action invocation result.
3197 ///
3198 /// <div class="warning">
3199 ///
3200 /// **Experimental.** This API is part of an experimental wire-protocol surface
3201 /// and may change or be removed in future SDK or CLI releases. Pin both the
3202 /// SDK and CLI versions if your code depends on it.
3203 ///
3204 /// </div>
3205 pub async fn invoke(
3206 &self,
3207 params: CanvasActionInvokeRequest,
3208 ) -> Result<CanvasActionInvokeResult, Error> {
3209 let mut wire_params = serde_json::to_value(params)?;
3210 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3211 let _value = self
3212 .session
3213 .client()
3214 .call(rpc_methods::SESSION_CANVAS_ACTION_INVOKE, Some(wire_params))
3215 .await?;
3216 Ok(serde_json::from_value(_value)?)
3217 }
3218}
3219
3220/// `session.commands.*` RPCs.
3221#[derive(Clone, Copy)]
3222pub struct SessionRpcCommands<'a> {
3223 pub(crate) session: &'a Session,
3224}
3225
3226impl<'a> SessionRpcCommands<'a> {
3227 /// Lists slash commands available in the session.
3228 ///
3229 /// Wire method: `session.commands.list`.
3230 ///
3231 /// # Returns
3232 ///
3233 /// Slash commands available in the session, after applying any include/exclude filters.
3234 ///
3235 /// <div class="warning">
3236 ///
3237 /// **Experimental.** This API is part of an experimental wire-protocol surface
3238 /// and may change or be removed in future SDK or CLI releases. Pin both the
3239 /// SDK and CLI versions if your code depends on it.
3240 ///
3241 /// </div>
3242 pub async fn list(&self) -> Result<CommandList, Error> {
3243 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3244 let _value = self
3245 .session
3246 .client()
3247 .call(rpc_methods::SESSION_COMMANDS_LIST, Some(wire_params))
3248 .await?;
3249 Ok(serde_json::from_value(_value)?)
3250 }
3251
3252 /// Lists slash commands available in the session.
3253 ///
3254 /// Wire method: `session.commands.list`.
3255 ///
3256 /// # Parameters
3257 ///
3258 /// * `params` - Optional filters controlling which command sources to include in the listing.
3259 ///
3260 /// # Returns
3261 ///
3262 /// Slash commands available in the session, after applying any include/exclude filters.
3263 ///
3264 /// <div class="warning">
3265 ///
3266 /// **Experimental.** This API is part of an experimental wire-protocol surface
3267 /// and may change or be removed in future SDK or CLI releases. Pin both the
3268 /// SDK and CLI versions if your code depends on it.
3269 ///
3270 /// </div>
3271 pub async fn list_with_params(
3272 &self,
3273 params: CommandsListRequest,
3274 ) -> Result<CommandList, Error> {
3275 let mut wire_params = serde_json::to_value(params)?;
3276 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3277 let _value = self
3278 .session
3279 .client()
3280 .call(rpc_methods::SESSION_COMMANDS_LIST, Some(wire_params))
3281 .await?;
3282 Ok(serde_json::from_value(_value)?)
3283 }
3284
3285 /// Invokes a slash command in the session.
3286 ///
3287 /// Wire method: `session.commands.invoke`.
3288 ///
3289 /// # Parameters
3290 ///
3291 /// * `params` - Slash command name and optional raw input string to invoke.
3292 ///
3293 /// # Returns
3294 ///
3295 /// Result of invoking the slash command (text output, prompt to send to the agent, completion, or subcommand selection).
3296 ///
3297 /// <div class="warning">
3298 ///
3299 /// **Experimental.** This API is part of an experimental wire-protocol surface
3300 /// and may change or be removed in future SDK or CLI releases. Pin both the
3301 /// SDK and CLI versions if your code depends on it.
3302 ///
3303 /// </div>
3304 pub async fn invoke(
3305 &self,
3306 params: CommandsInvokeRequest,
3307 ) -> Result<SlashCommandInvocationResult, Error> {
3308 let mut wire_params = serde_json::to_value(params)?;
3309 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3310 let _value = self
3311 .session
3312 .client()
3313 .call(rpc_methods::SESSION_COMMANDS_INVOKE, Some(wire_params))
3314 .await?;
3315 Ok(serde_json::from_value(_value)?)
3316 }
3317
3318 /// Reports completion of a pending client-handled slash command.
3319 ///
3320 /// Wire method: `session.commands.handlePendingCommand`.
3321 ///
3322 /// # Parameters
3323 ///
3324 /// * `params` - Pending command request ID and an optional error if the client handler failed.
3325 ///
3326 /// # Returns
3327 ///
3328 /// Indicates whether the pending client-handled command was completed successfully.
3329 ///
3330 /// <div class="warning">
3331 ///
3332 /// **Experimental.** This API is part of an experimental wire-protocol surface
3333 /// and may change or be removed in future SDK or CLI releases. Pin both the
3334 /// SDK and CLI versions if your code depends on it.
3335 ///
3336 /// </div>
3337 pub async fn handle_pending_command(
3338 &self,
3339 params: CommandsHandlePendingCommandRequest,
3340 ) -> Result<CommandsHandlePendingCommandResult, Error> {
3341 let mut wire_params = serde_json::to_value(params)?;
3342 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3343 let _value = self
3344 .session
3345 .client()
3346 .call(
3347 rpc_methods::SESSION_COMMANDS_HANDLEPENDINGCOMMAND,
3348 Some(wire_params),
3349 )
3350 .await?;
3351 Ok(serde_json::from_value(_value)?)
3352 }
3353
3354 /// Executes a slash command synchronously and returns any error.
3355 ///
3356 /// Wire method: `session.commands.execute`.
3357 ///
3358 /// # Parameters
3359 ///
3360 /// * `params` - Slash command name and argument string to execute synchronously.
3361 ///
3362 /// # Returns
3363 ///
3364 /// Error message produced while executing the command, if any.
3365 ///
3366 /// <div class="warning">
3367 ///
3368 /// **Experimental.** This API is part of an experimental wire-protocol surface
3369 /// and may change or be removed in future SDK or CLI releases. Pin both the
3370 /// SDK and CLI versions if your code depends on it.
3371 ///
3372 /// </div>
3373 pub async fn execute(
3374 &self,
3375 params: ExecuteCommandParams,
3376 ) -> Result<ExecuteCommandResult, Error> {
3377 let mut wire_params = serde_json::to_value(params)?;
3378 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3379 let _value = self
3380 .session
3381 .client()
3382 .call(rpc_methods::SESSION_COMMANDS_EXECUTE, Some(wire_params))
3383 .await?;
3384 Ok(serde_json::from_value(_value)?)
3385 }
3386
3387 /// Enqueues a slash command for FIFO processing on the local session.
3388 ///
3389 /// Wire method: `session.commands.enqueue`.
3390 ///
3391 /// # Parameters
3392 ///
3393 /// * `params` - Slash-prefixed command string to enqueue for FIFO processing.
3394 ///
3395 /// # Returns
3396 ///
3397 /// Indicates whether the command was accepted into the local execution queue.
3398 ///
3399 /// <div class="warning">
3400 ///
3401 /// **Experimental.** This API is part of an experimental wire-protocol surface
3402 /// and may change or be removed in future SDK or CLI releases. Pin both the
3403 /// SDK and CLI versions if your code depends on it.
3404 ///
3405 /// </div>
3406 pub async fn enqueue(
3407 &self,
3408 params: EnqueueCommandParams,
3409 ) -> Result<EnqueueCommandResult, Error> {
3410 let mut wire_params = serde_json::to_value(params)?;
3411 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3412 let _value = self
3413 .session
3414 .client()
3415 .call(rpc_methods::SESSION_COMMANDS_ENQUEUE, Some(wire_params))
3416 .await?;
3417 Ok(serde_json::from_value(_value)?)
3418 }
3419
3420 /// Reports whether the host actually executed a queued command and whether to continue processing.
3421 ///
3422 /// Wire method: `session.commands.respondToQueuedCommand`.
3423 ///
3424 /// # Parameters
3425 ///
3426 /// * `params` - Queued-command request ID and the result indicating whether the host executed it (and whether to stop processing further queued commands).
3427 ///
3428 /// # Returns
3429 ///
3430 /// Indicates whether the queued-command response was matched to a pending request.
3431 ///
3432 /// <div class="warning">
3433 ///
3434 /// **Experimental.** This API is part of an experimental wire-protocol surface
3435 /// and may change or be removed in future SDK or CLI releases. Pin both the
3436 /// SDK and CLI versions if your code depends on it.
3437 ///
3438 /// </div>
3439 pub async fn respond_to_queued_command(
3440 &self,
3441 params: CommandsRespondToQueuedCommandRequest,
3442 ) -> Result<CommandsRespondToQueuedCommandResult, Error> {
3443 let mut wire_params = serde_json::to_value(params)?;
3444 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3445 let _value = self
3446 .session
3447 .client()
3448 .call(
3449 rpc_methods::SESSION_COMMANDS_RESPONDTOQUEUEDCOMMAND,
3450 Some(wire_params),
3451 )
3452 .await?;
3453 Ok(serde_json::from_value(_value)?)
3454 }
3455}
3456
3457/// `session.completions.*` RPCs.
3458#[derive(Clone, Copy)]
3459pub struct SessionRpcCompletions<'a> {
3460 pub(crate) session: &'a Session,
3461}
3462
3463impl<'a> SessionRpcCompletions<'a> {
3464 /// Gets the characters that should trigger host-driven completions for the session. Empty disables host-driven completions (e.g. local sessions, or a relay host that does not advertise them).
3465 ///
3466 /// Wire method: `session.completions.getTriggerCharacters`.
3467 ///
3468 /// # Returns
3469 ///
3470 /// Characters that, when typed in the composer, should trigger a `completions.request`. Empty when the session has no host-driven completions (e.g. local sessions, or a relay host that does not advertise `completionTriggerCharacters`).
3471 ///
3472 /// <div class="warning">
3473 ///
3474 /// **Experimental.** This API is part of an experimental wire-protocol surface
3475 /// and may change or be removed in future SDK or CLI releases. Pin both the
3476 /// SDK and CLI versions if your code depends on it.
3477 ///
3478 /// </div>
3479 pub async fn get_trigger_characters(
3480 &self,
3481 ) -> Result<CompletionsGetTriggerCharactersResult, Error> {
3482 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3483 let _value = self
3484 .session
3485 .client()
3486 .call(
3487 rpc_methods::SESSION_COMPLETIONS_GETTRIGGERCHARACTERS,
3488 Some(wire_params),
3489 )
3490 .await?;
3491 Ok(serde_json::from_value(_value)?)
3492 }
3493
3494 /// Requests host-driven completion items for the current composer input. Returns an empty list when the host has no items or does not support completions.
3495 ///
3496 /// Wire method: `session.completions.request`.
3497 ///
3498 /// # Parameters
3499 ///
3500 /// * `params` - Request host-driven completions for the current composer input.
3501 ///
3502 /// # Returns
3503 ///
3504 /// Host-driven completion items for the current composer input. Empty when the host returns no items or does not support completions.
3505 ///
3506 /// <div class="warning">
3507 ///
3508 /// **Experimental.** This API is part of an experimental wire-protocol surface
3509 /// and may change or be removed in future SDK or CLI releases. Pin both the
3510 /// SDK and CLI versions if your code depends on it.
3511 ///
3512 /// </div>
3513 pub async fn request(
3514 &self,
3515 params: CompletionsRequestRequest,
3516 ) -> Result<CompletionsRequestResult, Error> {
3517 let mut wire_params = serde_json::to_value(params)?;
3518 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3519 let _value = self
3520 .session
3521 .client()
3522 .call(rpc_methods::SESSION_COMPLETIONS_REQUEST, Some(wire_params))
3523 .await?;
3524 Ok(serde_json::from_value(_value)?)
3525 }
3526}
3527
3528/// `session.eventLog.*` RPCs.
3529#[derive(Clone, Copy)]
3530pub struct SessionRpcEventLog<'a> {
3531 pub(crate) session: &'a Session,
3532}
3533
3534impl<'a> SessionRpcEventLog<'a> {
3535 /// Reads a batch of session events from a cursor, optionally waiting for new events.
3536 ///
3537 /// Wire method: `session.eventLog.read`.
3538 ///
3539 /// # Parameters
3540 ///
3541 /// * `params` - Cursor, batch size, and optional long-poll/filter parameters for reading session events.
3542 ///
3543 /// # Returns
3544 ///
3545 /// Batch of session events returned by a read, with cursor and continuation metadata.
3546 ///
3547 /// <div class="warning">
3548 ///
3549 /// **Experimental.** This API is part of an experimental wire-protocol surface
3550 /// and may change or be removed in future SDK or CLI releases. Pin both the
3551 /// SDK and CLI versions if your code depends on it.
3552 ///
3553 /// </div>
3554 pub async fn read(&self, params: EventLogReadRequest) -> Result<EventsReadResult, Error> {
3555 let mut wire_params = serde_json::to_value(params)?;
3556 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3557 let _value = self
3558 .session
3559 .client()
3560 .call(rpc_methods::SESSION_EVENTLOG_READ, Some(wire_params))
3561 .await?;
3562 Ok(serde_json::from_value(_value)?)
3563 }
3564
3565 /// Returns a snapshot of the current tail cursor without consuming events.
3566 ///
3567 /// Wire method: `session.eventLog.tail`.
3568 ///
3569 /// # Returns
3570 ///
3571 /// Snapshot of the current tail cursor without returning any events. Use this when a consumer wants to subscribe to live events going forward without first paginating through the entire persisted history (which would happen if `read` were called without a cursor on a long-lived session).
3572 ///
3573 /// <div class="warning">
3574 ///
3575 /// **Experimental.** This API is part of an experimental wire-protocol surface
3576 /// and may change or be removed in future SDK or CLI releases. Pin both the
3577 /// SDK and CLI versions if your code depends on it.
3578 ///
3579 /// </div>
3580 pub async fn tail(&self) -> Result<EventLogTailResult, Error> {
3581 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3582 let _value = self
3583 .session
3584 .client()
3585 .call(rpc_methods::SESSION_EVENTLOG_TAIL, Some(wire_params))
3586 .await?;
3587 Ok(serde_json::from_value(_value)?)
3588 }
3589
3590 /// Registers consumer interest in an event type for runtime gating purposes.
3591 ///
3592 /// Wire method: `session.eventLog.registerInterest`.
3593 ///
3594 /// # Parameters
3595 ///
3596 /// * `params` - Event type to register consumer interest for, used by runtime gating logic.
3597 ///
3598 /// # Returns
3599 ///
3600 /// Opaque handle representing an event-type interest registration.
3601 ///
3602 /// <div class="warning">
3603 ///
3604 /// **Experimental.** This API is part of an experimental wire-protocol surface
3605 /// and may change or be removed in future SDK or CLI releases. Pin both the
3606 /// SDK and CLI versions if your code depends on it.
3607 ///
3608 /// </div>
3609 pub async fn register_interest(
3610 &self,
3611 params: RegisterEventInterestParams,
3612 ) -> Result<RegisterEventInterestResult, Error> {
3613 let mut wire_params = serde_json::to_value(params)?;
3614 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3615 let _value = self
3616 .session
3617 .client()
3618 .call(
3619 rpc_methods::SESSION_EVENTLOG_REGISTERINTEREST,
3620 Some(wire_params),
3621 )
3622 .await?;
3623 Ok(serde_json::from_value(_value)?)
3624 }
3625
3626 /// Releases a consumer's previously-registered interest in an event type.
3627 ///
3628 /// Wire method: `session.eventLog.releaseInterest`.
3629 ///
3630 /// # Parameters
3631 ///
3632 /// * `params` - Opaque handle previously returned by `registerInterest` to release.
3633 ///
3634 /// # Returns
3635 ///
3636 /// Indicates whether the operation succeeded.
3637 ///
3638 /// <div class="warning">
3639 ///
3640 /// **Experimental.** This API is part of an experimental wire-protocol surface
3641 /// and may change or be removed in future SDK or CLI releases. Pin both the
3642 /// SDK and CLI versions if your code depends on it.
3643 ///
3644 /// </div>
3645 pub async fn release_interest(
3646 &self,
3647 params: ReleaseEventInterestParams,
3648 ) -> Result<EventLogReleaseInterestResult, Error> {
3649 let mut wire_params = serde_json::to_value(params)?;
3650 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3651 let _value = self
3652 .session
3653 .client()
3654 .call(
3655 rpc_methods::SESSION_EVENTLOG_RELEASEINTEREST,
3656 Some(wire_params),
3657 )
3658 .await?;
3659 Ok(serde_json::from_value(_value)?)
3660 }
3661}
3662
3663/// `session.extensions.*` RPCs.
3664#[derive(Clone, Copy)]
3665pub struct SessionRpcExtensions<'a> {
3666 pub(crate) session: &'a Session,
3667}
3668
3669impl<'a> SessionRpcExtensions<'a> {
3670 /// Lists extensions discovered for the session and their current status.
3671 ///
3672 /// Wire method: `session.extensions.list`.
3673 ///
3674 /// # Returns
3675 ///
3676 /// Extensions discovered for the session, with their current status.
3677 ///
3678 /// <div class="warning">
3679 ///
3680 /// **Experimental.** This API is part of an experimental wire-protocol surface
3681 /// and may change or be removed in future SDK or CLI releases. Pin both the
3682 /// SDK and CLI versions if your code depends on it.
3683 ///
3684 /// </div>
3685 pub async fn list(&self) -> Result<ExtensionList, Error> {
3686 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3687 let _value = self
3688 .session
3689 .client()
3690 .call(rpc_methods::SESSION_EXTENSIONS_LIST, Some(wire_params))
3691 .await?;
3692 Ok(serde_json::from_value(_value)?)
3693 }
3694
3695 /// Enables an extension for the session.
3696 ///
3697 /// Wire method: `session.extensions.enable`.
3698 ///
3699 /// # Parameters
3700 ///
3701 /// * `params` - Source-qualified extension identifier to enable for the session.
3702 ///
3703 /// <div class="warning">
3704 ///
3705 /// **Experimental.** This API is part of an experimental wire-protocol surface
3706 /// and may change or be removed in future SDK or CLI releases. Pin both the
3707 /// SDK and CLI versions if your code depends on it.
3708 ///
3709 /// </div>
3710 pub async fn enable(&self, params: ExtensionsEnableRequest) -> Result<(), Error> {
3711 let mut wire_params = serde_json::to_value(params)?;
3712 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3713 let _value = self
3714 .session
3715 .client()
3716 .call(rpc_methods::SESSION_EXTENSIONS_ENABLE, Some(wire_params))
3717 .await?;
3718 Ok(())
3719 }
3720
3721 /// Disables an extension for the session.
3722 ///
3723 /// Wire method: `session.extensions.disable`.
3724 ///
3725 /// # Parameters
3726 ///
3727 /// * `params` - Source-qualified extension identifier to disable for the session.
3728 ///
3729 /// <div class="warning">
3730 ///
3731 /// **Experimental.** This API is part of an experimental wire-protocol surface
3732 /// and may change or be removed in future SDK or CLI releases. Pin both the
3733 /// SDK and CLI versions if your code depends on it.
3734 ///
3735 /// </div>
3736 pub async fn disable(&self, params: ExtensionsDisableRequest) -> Result<(), Error> {
3737 let mut wire_params = serde_json::to_value(params)?;
3738 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3739 let _value = self
3740 .session
3741 .client()
3742 .call(rpc_methods::SESSION_EXTENSIONS_DISABLE, Some(wire_params))
3743 .await?;
3744 Ok(())
3745 }
3746
3747 /// Reloads extension definitions and processes for the session.
3748 ///
3749 /// Wire method: `session.extensions.reload`.
3750 ///
3751 /// <div class="warning">
3752 ///
3753 /// **Experimental.** This API is part of an experimental wire-protocol surface
3754 /// and may change or be removed in future SDK or CLI releases. Pin both the
3755 /// SDK and CLI versions if your code depends on it.
3756 ///
3757 /// </div>
3758 pub async fn reload(&self) -> Result<(), Error> {
3759 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3760 let _value = self
3761 .session
3762 .client()
3763 .call(rpc_methods::SESSION_EXTENSIONS_RELOAD, Some(wire_params))
3764 .await?;
3765 Ok(())
3766 }
3767
3768 /// Push attachments into the next user-message turn from an extension. The host should surface them as composer pills and forward them via the next session.send call. Callable only by extension-owned connections.
3769 ///
3770 /// Wire method: `session.extensions.sendAttachmentsToMessage`.
3771 ///
3772 /// # Parameters
3773 ///
3774 /// * `params` - Parameters for session.extensions.sendAttachmentsToMessage.
3775 ///
3776 /// <div class="warning">
3777 ///
3778 /// **Experimental.** This API is part of an experimental wire-protocol surface
3779 /// and may change or be removed in future SDK or CLI releases. Pin both the
3780 /// SDK and CLI versions if your code depends on it.
3781 ///
3782 /// </div>
3783 pub async fn send_attachments_to_message(
3784 &self,
3785 params: SendAttachmentsToMessageParams,
3786 ) -> Result<(), Error> {
3787 let mut wire_params = serde_json::to_value(params)?;
3788 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3789 let _value = self
3790 .session
3791 .client()
3792 .call(
3793 rpc_methods::SESSION_EXTENSIONS_SENDATTACHMENTSTOMESSAGE,
3794 Some(wire_params),
3795 )
3796 .await?;
3797 Ok(())
3798 }
3799}
3800
3801/// `session.fleet.*` RPCs.
3802#[derive(Clone, Copy)]
3803pub struct SessionRpcFleet<'a> {
3804 pub(crate) session: &'a Session,
3805}
3806
3807impl<'a> SessionRpcFleet<'a> {
3808 /// Starts fleet mode by submitting the fleet orchestration prompt to the session.
3809 ///
3810 /// Wire method: `session.fleet.start`.
3811 ///
3812 /// # Parameters
3813 ///
3814 /// * `params` - Optional user prompt to combine with the fleet orchestration instructions.
3815 ///
3816 /// # Returns
3817 ///
3818 /// Indicates whether fleet mode was successfully activated.
3819 ///
3820 /// <div class="warning">
3821 ///
3822 /// **Experimental.** This API is part of an experimental wire-protocol surface
3823 /// and may change or be removed in future SDK or CLI releases. Pin both the
3824 /// SDK and CLI versions if your code depends on it.
3825 ///
3826 /// </div>
3827 pub async fn start(&self, params: FleetStartRequest) -> Result<FleetStartResult, Error> {
3828 let mut wire_params = serde_json::to_value(params)?;
3829 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3830 let _value = self
3831 .session
3832 .client()
3833 .call(rpc_methods::SESSION_FLEET_START, Some(wire_params))
3834 .await?;
3835 Ok(serde_json::from_value(_value)?)
3836 }
3837}
3838
3839/// `session.gitHubAuth.*` RPCs.
3840#[derive(Clone, Copy)]
3841pub struct SessionRpcGitHubAuth<'a> {
3842 pub(crate) session: &'a Session,
3843}
3844
3845impl<'a> SessionRpcGitHubAuth<'a> {
3846 /// Gets authentication status and account metadata for the session.
3847 ///
3848 /// Wire method: `session.gitHubAuth.getStatus`.
3849 ///
3850 /// # Returns
3851 ///
3852 /// Authentication status and account metadata for the session.
3853 ///
3854 /// <div class="warning">
3855 ///
3856 /// **Experimental.** This API is part of an experimental wire-protocol surface
3857 /// and may change or be removed in future SDK or CLI releases. Pin both the
3858 /// SDK and CLI versions if your code depends on it.
3859 ///
3860 /// </div>
3861 pub async fn get_status(&self) -> Result<SessionAuthStatus, Error> {
3862 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3863 let _value = self
3864 .session
3865 .client()
3866 .call(rpc_methods::SESSION_GITHUBAUTH_GETSTATUS, Some(wire_params))
3867 .await?;
3868 Ok(serde_json::from_value(_value)?)
3869 }
3870
3871 /// Updates the session's auth credentials used for outbound model and API requests.
3872 ///
3873 /// Wire method: `session.gitHubAuth.setCredentials`.
3874 ///
3875 /// # Parameters
3876 ///
3877 /// * `params` - New auth credentials to install on the session. Omit to leave credentials unchanged.
3878 ///
3879 /// # Returns
3880 ///
3881 /// Indicates whether the credential update succeeded.
3882 ///
3883 /// <div class="warning">
3884 ///
3885 /// **Experimental.** This API is part of an experimental wire-protocol surface
3886 /// and may change or be removed in future SDK or CLI releases. Pin both the
3887 /// SDK and CLI versions if your code depends on it.
3888 ///
3889 /// </div>
3890 pub async fn set_credentials(
3891 &self,
3892 params: SessionSetCredentialsParams,
3893 ) -> Result<SessionSetCredentialsResult, Error> {
3894 let mut wire_params = serde_json::to_value(params)?;
3895 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3896 let _value = self
3897 .session
3898 .client()
3899 .call(
3900 rpc_methods::SESSION_GITHUBAUTH_SETCREDENTIALS,
3901 Some(wire_params),
3902 )
3903 .await?;
3904 Ok(serde_json::from_value(_value)?)
3905 }
3906}
3907
3908/// `session.history.*` RPCs.
3909#[derive(Clone, Copy)]
3910pub struct SessionRpcHistory<'a> {
3911 pub(crate) session: &'a Session,
3912}
3913
3914impl<'a> SessionRpcHistory<'a> {
3915 /// Compacts the session history to reduce context usage.
3916 ///
3917 /// Wire method: `session.history.compact`.
3918 ///
3919 /// # Returns
3920 ///
3921 /// Compaction outcome with the number of tokens and messages removed, summary text, and the resulting context window breakdown.
3922 ///
3923 /// <div class="warning">
3924 ///
3925 /// **Experimental.** This API is part of an experimental wire-protocol surface
3926 /// and may change or be removed in future SDK or CLI releases. Pin both the
3927 /// SDK and CLI versions if your code depends on it.
3928 ///
3929 /// </div>
3930 pub async fn compact(&self) -> Result<HistoryCompactResult, Error> {
3931 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3932 let _value = self
3933 .session
3934 .client()
3935 .call(rpc_methods::SESSION_HISTORY_COMPACT, Some(wire_params))
3936 .await?;
3937 Ok(serde_json::from_value(_value)?)
3938 }
3939
3940 /// Compacts the session history to reduce context usage.
3941 ///
3942 /// Wire method: `session.history.compact`.
3943 ///
3944 /// # Parameters
3945 ///
3946 /// * `params` - Optional compaction parameters.
3947 ///
3948 /// # Returns
3949 ///
3950 /// Compaction outcome with the number of tokens and messages removed, summary text, and the resulting context window breakdown.
3951 ///
3952 /// <div class="warning">
3953 ///
3954 /// **Experimental.** This API is part of an experimental wire-protocol surface
3955 /// and may change or be removed in future SDK or CLI releases. Pin both the
3956 /// SDK and CLI versions if your code depends on it.
3957 ///
3958 /// </div>
3959 pub async fn compact_with_params(
3960 &self,
3961 params: HistoryCompactRequest,
3962 ) -> Result<HistoryCompactResult, Error> {
3963 let mut wire_params = serde_json::to_value(params)?;
3964 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3965 let _value = self
3966 .session
3967 .client()
3968 .call(rpc_methods::SESSION_HISTORY_COMPACT, Some(wire_params))
3969 .await?;
3970 Ok(serde_json::from_value(_value)?)
3971 }
3972
3973 /// Truncates persisted session history to a specific event.
3974 ///
3975 /// Wire method: `session.history.truncate`.
3976 ///
3977 /// # Parameters
3978 ///
3979 /// * `params` - Identifier of the event to truncate to; this event and all later events are removed.
3980 ///
3981 /// # Returns
3982 ///
3983 /// Number of events that were removed by the truncation.
3984 ///
3985 /// <div class="warning">
3986 ///
3987 /// **Experimental.** This API is part of an experimental wire-protocol surface
3988 /// and may change or be removed in future SDK or CLI releases. Pin both the
3989 /// SDK and CLI versions if your code depends on it.
3990 ///
3991 /// </div>
3992 pub async fn truncate(
3993 &self,
3994 params: HistoryTruncateRequest,
3995 ) -> Result<HistoryTruncateResult, Error> {
3996 let mut wire_params = serde_json::to_value(params)?;
3997 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3998 let _value = self
3999 .session
4000 .client()
4001 .call(rpc_methods::SESSION_HISTORY_TRUNCATE, Some(wire_params))
4002 .await?;
4003 Ok(serde_json::from_value(_value)?)
4004 }
4005
4006 /// Cancels any in-progress background compaction on a local session.
4007 ///
4008 /// Wire method: `session.history.cancelBackgroundCompaction`.
4009 ///
4010 /// # Returns
4011 ///
4012 /// Indicates whether an in-progress background compaction was cancelled.
4013 ///
4014 /// <div class="warning">
4015 ///
4016 /// **Experimental.** This API is part of an experimental wire-protocol surface
4017 /// and may change or be removed in future SDK or CLI releases. Pin both the
4018 /// SDK and CLI versions if your code depends on it.
4019 ///
4020 /// </div>
4021 pub async fn cancel_background_compaction(
4022 &self,
4023 ) -> Result<HistoryCancelBackgroundCompactionResult, Error> {
4024 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
4025 let _value = self
4026 .session
4027 .client()
4028 .call(
4029 rpc_methods::SESSION_HISTORY_CANCELBACKGROUNDCOMPACTION,
4030 Some(wire_params),
4031 )
4032 .await?;
4033 Ok(serde_json::from_value(_value)?)
4034 }
4035
4036 /// Aborts any in-progress manual compaction on a local session.
4037 ///
4038 /// Wire method: `session.history.abortManualCompaction`.
4039 ///
4040 /// # Returns
4041 ///
4042 /// Indicates whether an in-progress manual compaction was aborted.
4043 ///
4044 /// <div class="warning">
4045 ///
4046 /// **Experimental.** This API is part of an experimental wire-protocol surface
4047 /// and may change or be removed in future SDK or CLI releases. Pin both the
4048 /// SDK and CLI versions if your code depends on it.
4049 ///
4050 /// </div>
4051 pub async fn abort_manual_compaction(
4052 &self,
4053 ) -> Result<HistoryAbortManualCompactionResult, Error> {
4054 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
4055 let _value = self
4056 .session
4057 .client()
4058 .call(
4059 rpc_methods::SESSION_HISTORY_ABORTMANUALCOMPACTION,
4060 Some(wire_params),
4061 )
4062 .await?;
4063 Ok(serde_json::from_value(_value)?)
4064 }
4065
4066 /// Produces a markdown summary of the session's conversation context for hand-off scenarios.
4067 ///
4068 /// Wire method: `session.history.summarizeForHandoff`.
4069 ///
4070 /// # Returns
4071 ///
4072 /// Markdown summary of the conversation context (empty when not available).
4073 ///
4074 /// <div class="warning">
4075 ///
4076 /// **Experimental.** This API is part of an experimental wire-protocol surface
4077 /// and may change or be removed in future SDK or CLI releases. Pin both the
4078 /// SDK and CLI versions if your code depends on it.
4079 ///
4080 /// </div>
4081 pub async fn summarize_for_handoff(&self) -> Result<HistorySummarizeForHandoffResult, Error> {
4082 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
4083 let _value = self
4084 .session
4085 .client()
4086 .call(
4087 rpc_methods::SESSION_HISTORY_SUMMARIZEFORHANDOFF,
4088 Some(wire_params),
4089 )
4090 .await?;
4091 Ok(serde_json::from_value(_value)?)
4092 }
4093}
4094
4095/// `session.instructions.*` RPCs.
4096#[derive(Clone, Copy)]
4097pub struct SessionRpcInstructions<'a> {
4098 pub(crate) session: &'a Session,
4099}
4100
4101impl<'a> SessionRpcInstructions<'a> {
4102 /// Gets instruction sources loaded for the session.
4103 ///
4104 /// Wire method: `session.instructions.getSources`.
4105 ///
4106 /// # Returns
4107 ///
4108 /// Instruction sources loaded for the session, in merge order.
4109 ///
4110 /// <div class="warning">
4111 ///
4112 /// **Experimental.** This API is part of an experimental wire-protocol surface
4113 /// and may change or be removed in future SDK or CLI releases. Pin both the
4114 /// SDK and CLI versions if your code depends on it.
4115 ///
4116 /// </div>
4117 pub async fn get_sources(&self) -> Result<InstructionsGetSourcesResult, Error> {
4118 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
4119 let _value = self
4120 .session
4121 .client()
4122 .call(
4123 rpc_methods::SESSION_INSTRUCTIONS_GETSOURCES,
4124 Some(wire_params),
4125 )
4126 .await?;
4127 Ok(serde_json::from_value(_value)?)
4128 }
4129}
4130
4131/// `session.lsp.*` RPCs.
4132#[derive(Clone, Copy)]
4133pub struct SessionRpcLsp<'a> {
4134 pub(crate) session: &'a Session,
4135}
4136
4137impl<'a> SessionRpcLsp<'a> {
4138 /// Loads the merged LSP configuration set for the session's working directory.
4139 ///
4140 /// Wire method: `session.lsp.initialize`.
4141 ///
4142 /// # Parameters
4143 ///
4144 /// * `params` - Parameters for (re)loading the merged LSP configuration set.
4145 ///
4146 /// <div class="warning">
4147 ///
4148 /// **Experimental.** This API is part of an experimental wire-protocol surface
4149 /// and may change or be removed in future SDK or CLI releases. Pin both the
4150 /// SDK and CLI versions if your code depends on it.
4151 ///
4152 /// </div>
4153 pub async fn initialize(&self, params: LspInitializeRequest) -> Result<(), Error> {
4154 let mut wire_params = serde_json::to_value(params)?;
4155 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4156 let _value = self
4157 .session
4158 .client()
4159 .call(rpc_methods::SESSION_LSP_INITIALIZE, Some(wire_params))
4160 .await?;
4161 Ok(())
4162 }
4163}
4164
4165/// `session.mcp.*` RPCs.
4166#[derive(Clone, Copy)]
4167pub struct SessionRpcMcp<'a> {
4168 pub(crate) session: &'a Session,
4169}
4170
4171impl<'a> SessionRpcMcp<'a> {
4172 /// `session.mcp.apps.*` sub-namespace.
4173 pub fn apps(&self) -> SessionRpcMcpApps<'a> {
4174 SessionRpcMcpApps {
4175 session: self.session,
4176 }
4177 }
4178
4179 /// `session.mcp.headers.*` sub-namespace.
4180 pub fn headers(&self) -> SessionRpcMcpHeaders<'a> {
4181 SessionRpcMcpHeaders {
4182 session: self.session,
4183 }
4184 }
4185
4186 /// `session.mcp.oauth.*` sub-namespace.
4187 pub fn oauth(&self) -> SessionRpcMcpOauth<'a> {
4188 SessionRpcMcpOauth {
4189 session: self.session,
4190 }
4191 }
4192
4193 /// Lists MCP servers configured for the session, their connection status, and host-level state. The host-level state (disabled/filtered servers, failed/needs-auth/pending connections, mcp3p policy, full config) is empty/zero when no MCP host has been initialized for the session.
4194 ///
4195 /// Wire method: `session.mcp.list`.
4196 ///
4197 /// # Returns
4198 ///
4199 /// MCP servers configured for the session, with their connection status and host-level state.
4200 ///
4201 /// <div class="warning">
4202 ///
4203 /// **Experimental.** This API is part of an experimental wire-protocol surface
4204 /// and may change or be removed in future SDK or CLI releases. Pin both the
4205 /// SDK and CLI versions if your code depends on it.
4206 ///
4207 /// </div>
4208 pub async fn list(&self) -> Result<McpServerList, Error> {
4209 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
4210 let _value = self
4211 .session
4212 .client()
4213 .call(rpc_methods::SESSION_MCP_LIST, Some(wire_params))
4214 .await?;
4215 Ok(serde_json::from_value(_value)?)
4216 }
4217
4218 /// Lists the tools exposed by a connected MCP server on this session's host.
4219 ///
4220 /// Wire method: `session.mcp.listTools`.
4221 ///
4222 /// # Parameters
4223 ///
4224 /// * `params` - Server name whose tool list should be returned.
4225 ///
4226 /// # Returns
4227 ///
4228 /// Tools exposed by the connected MCP server. Throws when the server is not connected.
4229 ///
4230 /// <div class="warning">
4231 ///
4232 /// **Experimental.** This API is part of an experimental wire-protocol surface
4233 /// and may change or be removed in future SDK or CLI releases. Pin both the
4234 /// SDK and CLI versions if your code depends on it.
4235 ///
4236 /// </div>
4237 pub async fn list_tools(
4238 &self,
4239 params: McpListToolsRequest,
4240 ) -> Result<McpListToolsResult, Error> {
4241 let mut wire_params = serde_json::to_value(params)?;
4242 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4243 let _value = self
4244 .session
4245 .client()
4246 .call(rpc_methods::SESSION_MCP_LISTTOOLS, Some(wire_params))
4247 .await?;
4248 Ok(serde_json::from_value(_value)?)
4249 }
4250
4251 /// Enables an MCP server for the session.
4252 ///
4253 /// Wire method: `session.mcp.enable`.
4254 ///
4255 /// # Parameters
4256 ///
4257 /// * `params` - Name of the MCP server to enable for the session.
4258 ///
4259 /// <div class="warning">
4260 ///
4261 /// **Experimental.** This API is part of an experimental wire-protocol surface
4262 /// and may change or be removed in future SDK or CLI releases. Pin both the
4263 /// SDK and CLI versions if your code depends on it.
4264 ///
4265 /// </div>
4266 pub async fn enable(&self, params: McpEnableRequest) -> Result<(), Error> {
4267 let mut wire_params = serde_json::to_value(params)?;
4268 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4269 let _value = self
4270 .session
4271 .client()
4272 .call(rpc_methods::SESSION_MCP_ENABLE, Some(wire_params))
4273 .await?;
4274 Ok(())
4275 }
4276
4277 /// Disables an MCP server for the session.
4278 ///
4279 /// Wire method: `session.mcp.disable`.
4280 ///
4281 /// # Parameters
4282 ///
4283 /// * `params` - Name of the MCP server to disable for the session.
4284 ///
4285 /// <div class="warning">
4286 ///
4287 /// **Experimental.** This API is part of an experimental wire-protocol surface
4288 /// and may change or be removed in future SDK or CLI releases. Pin both the
4289 /// SDK and CLI versions if your code depends on it.
4290 ///
4291 /// </div>
4292 pub async fn disable(&self, params: McpDisableRequest) -> Result<(), Error> {
4293 let mut wire_params = serde_json::to_value(params)?;
4294 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4295 let _value = self
4296 .session
4297 .client()
4298 .call(rpc_methods::SESSION_MCP_DISABLE, Some(wire_params))
4299 .await?;
4300 Ok(())
4301 }
4302
4303 /// Reloads MCP server connections for the session.
4304 ///
4305 /// Wire method: `session.mcp.reload`.
4306 ///
4307 /// <div class="warning">
4308 ///
4309 /// **Experimental.** This API is part of an experimental wire-protocol surface
4310 /// and may change or be removed in future SDK or CLI releases. Pin both the
4311 /// SDK and CLI versions if your code depends on it.
4312 ///
4313 /// </div>
4314 pub async fn reload(&self) -> Result<(), Error> {
4315 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
4316 let _value = self
4317 .session
4318 .client()
4319 .call(rpc_methods::SESSION_MCP_RELOAD, Some(wire_params))
4320 .await?;
4321 Ok(())
4322 }
4323
4324 /// Reloads MCP server connections for the session with an explicit host-provided configuration.
4325 ///
4326 /// Wire method: `session.mcp.reloadWithConfig`.
4327 ///
4328 /// # Parameters
4329 ///
4330 /// * `params` - Opaque MCP reload configuration.
4331 ///
4332 /// # Returns
4333 ///
4334 /// MCP server startup filtering result.
4335 ///
4336 /// <div class="warning">
4337 ///
4338 /// **Experimental.** This API is part of an experimental wire-protocol surface
4339 /// and may change or be removed in future SDK or CLI releases. Pin both the
4340 /// SDK and CLI versions if your code depends on it.
4341 ///
4342 /// </div>
4343 pub(crate) async fn reload_with_config(
4344 &self,
4345 params: McpReloadWithConfigRequest,
4346 ) -> Result<McpStartServersResult, Error> {
4347 let mut wire_params = serde_json::to_value(params)?;
4348 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4349 let _value = self
4350 .session
4351 .client()
4352 .call(rpc_methods::SESSION_MCP_RELOADWITHCONFIG, Some(wire_params))
4353 .await?;
4354 Ok(serde_json::from_value(_value)?)
4355 }
4356
4357 /// Runs an MCP sampling inference on behalf of an MCP server.
4358 ///
4359 /// Wire method: `session.mcp.executeSampling`.
4360 ///
4361 /// # Parameters
4362 ///
4363 /// * `params` - Identifiers and raw MCP CreateMessageRequest params used to run a sampling inference.
4364 ///
4365 /// # Returns
4366 ///
4367 /// Outcome of an MCP sampling execution: success result, failure error, or cancellation.
4368 ///
4369 /// <div class="warning">
4370 ///
4371 /// **Experimental.** This API is part of an experimental wire-protocol surface
4372 /// and may change or be removed in future SDK or CLI releases. Pin both the
4373 /// SDK and CLI versions if your code depends on it.
4374 ///
4375 /// </div>
4376 pub async fn execute_sampling(
4377 &self,
4378 params: McpExecuteSamplingParams,
4379 ) -> Result<McpSamplingExecutionResult, Error> {
4380 let mut wire_params = serde_json::to_value(params)?;
4381 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4382 let _value = self
4383 .session
4384 .client()
4385 .call(rpc_methods::SESSION_MCP_EXECUTESAMPLING, Some(wire_params))
4386 .await?;
4387 Ok(serde_json::from_value(_value)?)
4388 }
4389
4390 /// Cancels an in-flight MCP sampling execution by request ID.
4391 ///
4392 /// Wire method: `session.mcp.cancelSamplingExecution`.
4393 ///
4394 /// # Parameters
4395 ///
4396 /// * `params` - The requestId previously passed to executeSampling that should be cancelled.
4397 ///
4398 /// # Returns
4399 ///
4400 /// Indicates whether an in-flight sampling execution with the given requestId was found and cancelled.
4401 ///
4402 /// <div class="warning">
4403 ///
4404 /// **Experimental.** This API is part of an experimental wire-protocol surface
4405 /// and may change or be removed in future SDK or CLI releases. Pin both the
4406 /// SDK and CLI versions if your code depends on it.
4407 ///
4408 /// </div>
4409 pub async fn cancel_sampling_execution(
4410 &self,
4411 params: McpCancelSamplingExecutionParams,
4412 ) -> Result<McpCancelSamplingExecutionResult, Error> {
4413 let mut wire_params = serde_json::to_value(params)?;
4414 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4415 let _value = self
4416 .session
4417 .client()
4418 .call(
4419 rpc_methods::SESSION_MCP_CANCELSAMPLINGEXECUTION,
4420 Some(wire_params),
4421 )
4422 .await?;
4423 Ok(serde_json::from_value(_value)?)
4424 }
4425
4426 /// Sets how environment-variable values supplied to MCP servers are resolved (direct or indirect).
4427 ///
4428 /// Wire method: `session.mcp.setEnvValueMode`.
4429 ///
4430 /// # Parameters
4431 ///
4432 /// * `params` - Mode controlling how MCP server env values are resolved (`direct` or `indirect`).
4433 ///
4434 /// # Returns
4435 ///
4436 /// Env-value mode recorded on the session after the update.
4437 ///
4438 /// <div class="warning">
4439 ///
4440 /// **Experimental.** This API is part of an experimental wire-protocol surface
4441 /// and may change or be removed in future SDK or CLI releases. Pin both the
4442 /// SDK and CLI versions if your code depends on it.
4443 ///
4444 /// </div>
4445 pub async fn set_env_value_mode(
4446 &self,
4447 params: McpSetEnvValueModeParams,
4448 ) -> Result<McpSetEnvValueModeResult, Error> {
4449 let mut wire_params = serde_json::to_value(params)?;
4450 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4451 let _value = self
4452 .session
4453 .client()
4454 .call(rpc_methods::SESSION_MCP_SETENVVALUEMODE, Some(wire_params))
4455 .await?;
4456 Ok(serde_json::from_value(_value)?)
4457 }
4458
4459 /// Removes the auto-managed `github` MCP server when present.
4460 ///
4461 /// Wire method: `session.mcp.removeGitHub`.
4462 ///
4463 /// # Returns
4464 ///
4465 /// Indicates whether the auto-managed `github` MCP server was removed (false when nothing to remove).
4466 ///
4467 /// <div class="warning">
4468 ///
4469 /// **Experimental.** This API is part of an experimental wire-protocol surface
4470 /// and may change or be removed in future SDK or CLI releases. Pin both the
4471 /// SDK and CLI versions if your code depends on it.
4472 ///
4473 /// </div>
4474 pub async fn remove_git_hub(&self) -> Result<McpRemoveGitHubResult, Error> {
4475 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
4476 let _value = self
4477 .session
4478 .client()
4479 .call(rpc_methods::SESSION_MCP_REMOVEGITHUB, Some(wire_params))
4480 .await?;
4481 Ok(serde_json::from_value(_value)?)
4482 }
4483
4484 /// Configures the built-in GitHub MCP server for the session's current auth context.
4485 ///
4486 /// Wire method: `session.mcp.configureGitHub`.
4487 ///
4488 /// # Parameters
4489 ///
4490 /// * `params` - Opaque auth info used to configure GitHub MCP.
4491 ///
4492 /// # Returns
4493 ///
4494 /// Result of configuring GitHub MCP.
4495 ///
4496 /// <div class="warning">
4497 ///
4498 /// **Experimental.** This API is part of an experimental wire-protocol surface
4499 /// and may change or be removed in future SDK or CLI releases. Pin both the
4500 /// SDK and CLI versions if your code depends on it.
4501 ///
4502 /// </div>
4503 pub(crate) async fn configure_git_hub(
4504 &self,
4505 params: McpConfigureGitHubRequest,
4506 ) -> Result<McpConfigureGitHubResult, Error> {
4507 let mut wire_params = serde_json::to_value(params)?;
4508 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4509 let _value = self
4510 .session
4511 .client()
4512 .call(rpc_methods::SESSION_MCP_CONFIGUREGITHUB, Some(wire_params))
4513 .await?;
4514 Ok(serde_json::from_value(_value)?)
4515 }
4516
4517 /// Starts an individual MCP server on the session's host.
4518 ///
4519 /// Wire method: `session.mcp.startServer`.
4520 ///
4521 /// # Parameters
4522 ///
4523 /// * `params` - Server name and opaque configuration for an individual MCP server start.
4524 ///
4525 /// <div class="warning">
4526 ///
4527 /// **Experimental.** This API is part of an experimental wire-protocol surface
4528 /// and may change or be removed in future SDK or CLI releases. Pin both the
4529 /// SDK and CLI versions if your code depends on it.
4530 ///
4531 /// </div>
4532 pub(crate) async fn start_server(&self, params: McpStartServerRequest) -> Result<(), Error> {
4533 let mut wire_params = serde_json::to_value(params)?;
4534 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4535 let _value = self
4536 .session
4537 .client()
4538 .call(rpc_methods::SESSION_MCP_STARTSERVER, Some(wire_params))
4539 .await?;
4540 Ok(())
4541 }
4542
4543 /// Restarts an individual MCP server on the session's host (stops then starts).
4544 ///
4545 /// Wire method: `session.mcp.restartServer`.
4546 ///
4547 /// # Parameters
4548 ///
4549 /// * `params` - Server name and opaque configuration for an individual MCP server restart.
4550 ///
4551 /// <div class="warning">
4552 ///
4553 /// **Experimental.** This API is part of an experimental wire-protocol surface
4554 /// and may change or be removed in future SDK or CLI releases. Pin both the
4555 /// SDK and CLI versions if your code depends on it.
4556 ///
4557 /// </div>
4558 pub(crate) async fn restart_server(
4559 &self,
4560 params: McpRestartServerRequest,
4561 ) -> Result<(), Error> {
4562 let mut wire_params = serde_json::to_value(params)?;
4563 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4564 let _value = self
4565 .session
4566 .client()
4567 .call(rpc_methods::SESSION_MCP_RESTARTSERVER, Some(wire_params))
4568 .await?;
4569 Ok(())
4570 }
4571
4572 /// Stops an individual MCP server on the session's host.
4573 ///
4574 /// Wire method: `session.mcp.stopServer`.
4575 ///
4576 /// # Parameters
4577 ///
4578 /// * `params` - Server name for an individual MCP server stop.
4579 ///
4580 /// <div class="warning">
4581 ///
4582 /// **Experimental.** This API is part of an experimental wire-protocol surface
4583 /// and may change or be removed in future SDK or CLI releases. Pin both the
4584 /// SDK and CLI versions if your code depends on it.
4585 ///
4586 /// </div>
4587 pub async fn stop_server(&self, params: McpStopServerRequest) -> Result<(), Error> {
4588 let mut wire_params = serde_json::to_value(params)?;
4589 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4590 let _value = self
4591 .session
4592 .client()
4593 .call(rpc_methods::SESSION_MCP_STOPSERVER, Some(wire_params))
4594 .await?;
4595 Ok(())
4596 }
4597
4598 /// Registers a pre-connected external MCP client (e.g. IDE) on the session's host. The caller retains lifecycle ownership of the client and transport. Marked internal because the `client` and `transport` arguments are in-process MCP SDK instances that cannot be serialized across the JSON-RPC boundary; once the CLI moves on top of the SDK, external clients will be expressed as transport configs the runtime can construct itself.
4599 ///
4600 /// Wire method: `session.mcp.registerExternalClient`.
4601 ///
4602 /// # Parameters
4603 ///
4604 /// * `params` - Registration parameters for an external MCP client.
4605 ///
4606 /// <div class="warning">
4607 ///
4608 /// **Experimental.** This API is part of an experimental wire-protocol surface
4609 /// and may change or be removed in future SDK or CLI releases. Pin both the
4610 /// SDK and CLI versions if your code depends on it.
4611 ///
4612 /// </div>
4613 pub(crate) async fn register_external_client(
4614 &self,
4615 params: McpRegisterExternalClientRequest,
4616 ) -> Result<(), Error> {
4617 let mut wire_params = serde_json::to_value(params)?;
4618 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4619 let _value = self
4620 .session
4621 .client()
4622 .call(
4623 rpc_methods::SESSION_MCP_REGISTEREXTERNALCLIENT,
4624 Some(wire_params),
4625 )
4626 .await?;
4627 Ok(())
4628 }
4629
4630 /// Unregisters a previously registered external MCP client by server name. Marked internal as the paired companion of `registerExternalClient`: only in-process callers that registered a client this way can meaningfully unregister it. Disappears alongside `registerExternalClient`: once external clients are described to the runtime as config rather than handed in as instances, lifecycle (including deregistration) is owned entirely by the runtime.
4631 ///
4632 /// Wire method: `session.mcp.unregisterExternalClient`.
4633 ///
4634 /// # Parameters
4635 ///
4636 /// * `params` - Server name identifying the external client to remove.
4637 ///
4638 /// <div class="warning">
4639 ///
4640 /// **Experimental.** This API is part of an experimental wire-protocol surface
4641 /// and may change or be removed in future SDK or CLI releases. Pin both the
4642 /// SDK and CLI versions if your code depends on it.
4643 ///
4644 /// </div>
4645 pub(crate) async fn unregister_external_client(
4646 &self,
4647 params: McpUnregisterExternalClientRequest,
4648 ) -> Result<(), Error> {
4649 let mut wire_params = serde_json::to_value(params)?;
4650 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4651 let _value = self
4652 .session
4653 .client()
4654 .call(
4655 rpc_methods::SESSION_MCP_UNREGISTEREXTERNALCLIENT,
4656 Some(wire_params),
4657 )
4658 .await?;
4659 Ok(())
4660 }
4661
4662 /// Checks whether a named MCP server is currently running on the session's host.
4663 ///
4664 /// Wire method: `session.mcp.isServerRunning`.
4665 ///
4666 /// # Parameters
4667 ///
4668 /// * `params` - Server name to check running status for.
4669 ///
4670 /// # Returns
4671 ///
4672 /// Whether the named MCP server is running.
4673 ///
4674 /// <div class="warning">
4675 ///
4676 /// **Experimental.** This API is part of an experimental wire-protocol surface
4677 /// and may change or be removed in future SDK or CLI releases. Pin both the
4678 /// SDK and CLI versions if your code depends on it.
4679 ///
4680 /// </div>
4681 pub async fn is_server_running(
4682 &self,
4683 params: McpIsServerRunningRequest,
4684 ) -> Result<McpIsServerRunningResult, Error> {
4685 let mut wire_params = serde_json::to_value(params)?;
4686 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4687 let _value = self
4688 .session
4689 .client()
4690 .call(rpc_methods::SESSION_MCP_ISSERVERRUNNING, Some(wire_params))
4691 .await?;
4692 Ok(serde_json::from_value(_value)?)
4693 }
4694}
4695
4696/// `session.mcp.apps.*` RPCs.
4697#[derive(Clone, Copy)]
4698pub struct SessionRpcMcpApps<'a> {
4699 pub(crate) session: &'a Session,
4700}
4701
4702impl<'a> SessionRpcMcpApps<'a> {
4703 /// Fetch an MCP resource (typically a `ui://` MCP App bundle, per SEP-1865) from a connected server. Requires the `mcp-apps` session capability.
4704 ///
4705 /// Wire method: `session.mcp.apps.readResource`.
4706 ///
4707 /// # Parameters
4708 ///
4709 /// * `params` - MCP server and resource URI to fetch.
4710 ///
4711 /// # Returns
4712 ///
4713 /// Resource contents returned by the MCP server.
4714 ///
4715 /// <div class="warning">
4716 ///
4717 /// **Experimental.** This API is part of an experimental wire-protocol surface
4718 /// and may change or be removed in future SDK or CLI releases. Pin both the
4719 /// SDK and CLI versions if your code depends on it.
4720 ///
4721 /// </div>
4722 pub async fn read_resource(
4723 &self,
4724 params: McpAppsReadResourceRequest,
4725 ) -> Result<McpAppsReadResourceResult, Error> {
4726 let mut wire_params = serde_json::to_value(params)?;
4727 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4728 let _value = self
4729 .session
4730 .client()
4731 .call(
4732 rpc_methods::SESSION_MCP_APPS_READRESOURCE,
4733 Some(wire_params),
4734 )
4735 .await?;
4736 Ok(serde_json::from_value(_value)?)
4737 }
4738
4739 /// List tools that an MCP App view is allowed to call (SEP-1865 visibility filter). Returns tools whose `_meta.ui.visibility` is unset (default `["model","app"]`) or includes `"app"`.
4740 ///
4741 /// Wire method: `session.mcp.apps.listTools`.
4742 ///
4743 /// # Parameters
4744 ///
4745 /// * `params` - MCP server to list app-callable tools for.
4746 ///
4747 /// # Returns
4748 ///
4749 /// App-callable tools from the named MCP server.
4750 ///
4751 /// <div class="warning">
4752 ///
4753 /// **Experimental.** This API is part of an experimental wire-protocol surface
4754 /// and may change or be removed in future SDK or CLI releases. Pin both the
4755 /// SDK and CLI versions if your code depends on it.
4756 ///
4757 /// </div>
4758 pub async fn list_tools(
4759 &self,
4760 params: McpAppsListToolsRequest,
4761 ) -> Result<McpAppsListToolsResult, Error> {
4762 let mut wire_params = serde_json::to_value(params)?;
4763 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4764 let _value = self
4765 .session
4766 .client()
4767 .call(rpc_methods::SESSION_MCP_APPS_LISTTOOLS, Some(wire_params))
4768 .await?;
4769 Ok(serde_json::from_value(_value)?)
4770 }
4771
4772 /// Call an MCP tool from an MCP App view (SEP-1865). Enforces the visibility check that prevents an app iframe from invoking model-only tools. Returns the standard MCP `CallToolResult`.
4773 ///
4774 /// Wire method: `session.mcp.apps.callTool`.
4775 ///
4776 /// # Parameters
4777 ///
4778 /// * `params` - MCP server, tool name, and arguments to invoke from an MCP App view.
4779 ///
4780 /// # Returns
4781 ///
4782 /// Standard MCP CallToolResult
4783 ///
4784 /// <div class="warning">
4785 ///
4786 /// **Experimental.** This API is part of an experimental wire-protocol surface
4787 /// and may change or be removed in future SDK or CLI releases. Pin both the
4788 /// SDK and CLI versions if your code depends on it.
4789 ///
4790 /// </div>
4791 pub async fn call_tool(
4792 &self,
4793 params: McpAppsCallToolRequest,
4794 ) -> Result<SessionMcpAppsCallToolResult, Error> {
4795 let mut wire_params = serde_json::to_value(params)?;
4796 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4797 let _value = self
4798 .session
4799 .client()
4800 .call(rpc_methods::SESSION_MCP_APPS_CALLTOOL, Some(wire_params))
4801 .await?;
4802 Ok(serde_json::from_value(_value)?)
4803 }
4804
4805 /// Replace the host context returned to MCP App guests on `ui/initialize`. Hosts use this to advertise theme, locale, or other metadata to the guest UI.
4806 ///
4807 /// Wire method: `session.mcp.apps.setHostContext`.
4808 ///
4809 /// # Parameters
4810 ///
4811 /// * `params` - Host context to advertise to MCP App guests.
4812 ///
4813 /// <div class="warning">
4814 ///
4815 /// **Experimental.** This API is part of an experimental wire-protocol surface
4816 /// and may change or be removed in future SDK or CLI releases. Pin both the
4817 /// SDK and CLI versions if your code depends on it.
4818 ///
4819 /// </div>
4820 pub async fn set_host_context(
4821 &self,
4822 params: McpAppsSetHostContextRequest,
4823 ) -> Result<(), Error> {
4824 let mut wire_params = serde_json::to_value(params)?;
4825 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4826 let _value = self
4827 .session
4828 .client()
4829 .call(
4830 rpc_methods::SESSION_MCP_APPS_SETHOSTCONTEXT,
4831 Some(wire_params),
4832 )
4833 .await?;
4834 Ok(())
4835 }
4836
4837 /// Read the current host context advertised to MCP App guests.
4838 ///
4839 /// Wire method: `session.mcp.apps.getHostContext`.
4840 ///
4841 /// # Returns
4842 ///
4843 /// Current host context advertised to MCP App guests.
4844 ///
4845 /// <div class="warning">
4846 ///
4847 /// **Experimental.** This API is part of an experimental wire-protocol surface
4848 /// and may change or be removed in future SDK or CLI releases. Pin both the
4849 /// SDK and CLI versions if your code depends on it.
4850 ///
4851 /// </div>
4852 pub async fn get_host_context(&self) -> Result<McpAppsHostContext, Error> {
4853 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
4854 let _value = self
4855 .session
4856 .client()
4857 .call(
4858 rpc_methods::SESSION_MCP_APPS_GETHOSTCONTEXT,
4859 Some(wire_params),
4860 )
4861 .await?;
4862 Ok(serde_json::from_value(_value)?)
4863 }
4864
4865 /// Diagnose MCP Apps wiring for a specific MCP server. Reports the session capability, feature-flag state, advertised extension, and how many tools have `_meta.ui` populated.
4866 ///
4867 /// Wire method: `session.mcp.apps.diagnose`.
4868 ///
4869 /// # Parameters
4870 ///
4871 /// * `params` - MCP server to diagnose MCP Apps wiring for.
4872 ///
4873 /// # Returns
4874 ///
4875 /// Diagnostic snapshot of MCP Apps wiring for the named server.
4876 ///
4877 /// <div class="warning">
4878 ///
4879 /// **Experimental.** This API is part of an experimental wire-protocol surface
4880 /// and may change or be removed in future SDK or CLI releases. Pin both the
4881 /// SDK and CLI versions if your code depends on it.
4882 ///
4883 /// </div>
4884 pub async fn diagnose(
4885 &self,
4886 params: McpAppsDiagnoseRequest,
4887 ) -> Result<McpAppsDiagnoseResult, Error> {
4888 let mut wire_params = serde_json::to_value(params)?;
4889 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4890 let _value = self
4891 .session
4892 .client()
4893 .call(rpc_methods::SESSION_MCP_APPS_DIAGNOSE, Some(wire_params))
4894 .await?;
4895 Ok(serde_json::from_value(_value)?)
4896 }
4897}
4898
4899/// `session.mcp.headers.*` RPCs.
4900#[derive(Clone, Copy)]
4901pub struct SessionRpcMcpHeaders<'a> {
4902 pub(crate) session: &'a Session,
4903}
4904
4905impl<'a> SessionRpcMcpHeaders<'a> {
4906 /// Responds to a pending MCP dynamic headers refresh request. Hosts that subscribe to `mcp.headers_refresh_required` use this to provide short-lived per-server headers or to indicate that no dynamic headers are available for this refresh.
4907 ///
4908 /// Wire method: `session.mcp.headers.handlePendingHeadersRefreshRequest`.
4909 ///
4910 /// # Parameters
4911 ///
4912 /// * `params` - MCP headers refresh request id and the host response.
4913 ///
4914 /// # Returns
4915 ///
4916 /// Indicates whether the pending MCP headers refresh response was accepted.
4917 ///
4918 /// <div class="warning">
4919 ///
4920 /// **Experimental.** This API is part of an experimental wire-protocol surface
4921 /// and may change or be removed in future SDK or CLI releases. Pin both the
4922 /// SDK and CLI versions if your code depends on it.
4923 ///
4924 /// </div>
4925 pub async fn handle_pending_headers_refresh_request(
4926 &self,
4927 params: McpHeadersHandlePendingHeadersRefreshRequestRequest,
4928 ) -> Result<McpHeadersHandlePendingHeadersRefreshRequestResult, Error> {
4929 let mut wire_params = serde_json::to_value(params)?;
4930 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4931 let _value = self
4932 .session
4933 .client()
4934 .call(
4935 rpc_methods::SESSION_MCP_HEADERS_HANDLEPENDINGHEADERSREFRESHREQUEST,
4936 Some(wire_params),
4937 )
4938 .await?;
4939 Ok(serde_json::from_value(_value)?)
4940 }
4941}
4942
4943/// `session.mcp.oauth.*` RPCs.
4944#[derive(Clone, Copy)]
4945pub struct SessionRpcMcpOauth<'a> {
4946 pub(crate) session: &'a Session,
4947}
4948
4949impl<'a> SessionRpcMcpOauth<'a> {
4950 /// Responds to a pending MCP OAuth request with an in-process provider. This internal CLI-only API accepts a live OAuthClientProvider instance and cannot be used over the SDK JSON-RPC boundary. Use session.mcp.oauth.handlePendingRequest instead for the public SDK-safe response path.
4951 ///
4952 /// Wire method: `session.mcp.oauth.respond`.
4953 ///
4954 /// # Parameters
4955 ///
4956 /// * `params` - MCP OAuth request id and optional provider response.
4957 ///
4958 /// # Returns
4959 ///
4960 /// Empty result after recording the MCP OAuth response.
4961 ///
4962 /// <div class="warning">
4963 ///
4964 /// **Experimental.** This API is part of an experimental wire-protocol surface
4965 /// and may change or be removed in future SDK or CLI releases. Pin both the
4966 /// SDK and CLI versions if your code depends on it.
4967 ///
4968 /// </div>
4969 pub(crate) async fn respond(
4970 &self,
4971 params: McpOauthRespondRequest,
4972 ) -> Result<McpOauthRespondResult, Error> {
4973 let mut wire_params = serde_json::to_value(params)?;
4974 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4975 let _value = self
4976 .session
4977 .client()
4978 .call(rpc_methods::SESSION_MCP_OAUTH_RESPOND, Some(wire_params))
4979 .await?;
4980 Ok(serde_json::from_value(_value)?)
4981 }
4982
4983 /// Resolves a pending MCP OAuth request with a host-provided token or cancellation. The pending request is emitted as mcp.oauth_required with the data necessary to authorize the request.
4984 ///
4985 /// Wire method: `session.mcp.oauth.handlePendingRequest`.
4986 ///
4987 /// # Parameters
4988 ///
4989 /// * `params` - Pending MCP OAuth request ID and host-provided token or cancellation response.
4990 ///
4991 /// # Returns
4992 ///
4993 /// Indicates whether the pending MCP OAuth response was accepted.
4994 ///
4995 /// <div class="warning">
4996 ///
4997 /// **Experimental.** This API is part of an experimental wire-protocol surface
4998 /// and may change or be removed in future SDK or CLI releases. Pin both the
4999 /// SDK and CLI versions if your code depends on it.
5000 ///
5001 /// </div>
5002 pub async fn handle_pending_request(
5003 &self,
5004 params: McpOauthHandlePendingRequest,
5005 ) -> Result<McpOauthHandlePendingResult, Error> {
5006 let mut wire_params = serde_json::to_value(params)?;
5007 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5008 let _value = self
5009 .session
5010 .client()
5011 .call(
5012 rpc_methods::SESSION_MCP_OAUTH_HANDLEPENDINGREQUEST,
5013 Some(wire_params),
5014 )
5015 .await?;
5016 Ok(serde_json::from_value(_value)?)
5017 }
5018
5019 /// Starts OAuth authentication for a remote MCP server.
5020 ///
5021 /// Wire method: `session.mcp.oauth.login`.
5022 ///
5023 /// # Parameters
5024 ///
5025 /// * `params` - Remote MCP server name and optional overrides controlling reauthentication, OAuth client display name, callback success-page copy, and static OAuth client selection.
5026 ///
5027 /// # Returns
5028 ///
5029 /// OAuth authorization URL the caller should open, or empty when cached tokens already authenticated the server.
5030 ///
5031 /// <div class="warning">
5032 ///
5033 /// **Experimental.** This API is part of an experimental wire-protocol surface
5034 /// and may change or be removed in future SDK or CLI releases. Pin both the
5035 /// SDK and CLI versions if your code depends on it.
5036 ///
5037 /// </div>
5038 pub async fn login(&self, params: McpOauthLoginRequest) -> Result<McpOauthLoginResult, Error> {
5039 let mut wire_params = serde_json::to_value(params)?;
5040 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5041 let _value = self
5042 .session
5043 .client()
5044 .call(rpc_methods::SESSION_MCP_OAUTH_LOGIN, Some(wire_params))
5045 .await?;
5046 Ok(serde_json::from_value(_value)?)
5047 }
5048}
5049
5050/// `session.metadata.*` RPCs.
5051#[derive(Clone, Copy)]
5052pub struct SessionRpcMetadata<'a> {
5053 pub(crate) session: &'a Session,
5054}
5055
5056impl<'a> SessionRpcMetadata<'a> {
5057 /// Returns a snapshot of the session's identifying metadata, mode, agent, and remote info.
5058 ///
5059 /// Wire method: `session.metadata.snapshot`.
5060 ///
5061 /// # Returns
5062 ///
5063 /// Point-in-time snapshot of slow-changing session identifier and state fields
5064 ///
5065 /// <div class="warning">
5066 ///
5067 /// **Experimental.** This API is part of an experimental wire-protocol surface
5068 /// and may change or be removed in future SDK or CLI releases. Pin both the
5069 /// SDK and CLI versions if your code depends on it.
5070 ///
5071 /// </div>
5072 pub async fn snapshot(&self) -> Result<SessionMetadataSnapshot, Error> {
5073 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5074 let _value = self
5075 .session
5076 .client()
5077 .call(rpc_methods::SESSION_METADATA_SNAPSHOT, Some(wire_params))
5078 .await?;
5079 Ok(serde_json::from_value(_value)?)
5080 }
5081
5082 /// Reports whether the local session is currently processing user/agent messages.
5083 ///
5084 /// Wire method: `session.metadata.isProcessing`.
5085 ///
5086 /// # Returns
5087 ///
5088 /// Indicates whether the local session is currently processing a turn or background continuation.
5089 ///
5090 /// <div class="warning">
5091 ///
5092 /// **Experimental.** This API is part of an experimental wire-protocol surface
5093 /// and may change or be removed in future SDK or CLI releases. Pin both the
5094 /// SDK and CLI versions if your code depends on it.
5095 ///
5096 /// </div>
5097 pub async fn is_processing(&self) -> Result<MetadataIsProcessingResult, Error> {
5098 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5099 let _value = self
5100 .session
5101 .client()
5102 .call(
5103 rpc_methods::SESSION_METADATA_ISPROCESSING,
5104 Some(wire_params),
5105 )
5106 .await?;
5107 Ok(serde_json::from_value(_value)?)
5108 }
5109
5110 /// Returns a snapshot of activity flags for the session.
5111 ///
5112 /// Wire method: `session.metadata.activity`.
5113 ///
5114 /// # Returns
5115 ///
5116 /// Current activity flags for the session.
5117 ///
5118 /// <div class="warning">
5119 ///
5120 /// **Experimental.** This API is part of an experimental wire-protocol surface
5121 /// and may change or be removed in future SDK or CLI releases. Pin both the
5122 /// SDK and CLI versions if your code depends on it.
5123 ///
5124 /// </div>
5125 pub async fn activity(&self) -> Result<SessionActivity, Error> {
5126 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5127 let _value = self
5128 .session
5129 .client()
5130 .call(rpc_methods::SESSION_METADATA_ACTIVITY, Some(wire_params))
5131 .await?;
5132 Ok(serde_json::from_value(_value)?)
5133 }
5134
5135 /// Returns the token breakdown for the session's current context window for a given model.
5136 ///
5137 /// Wire method: `session.metadata.contextInfo`.
5138 ///
5139 /// # Parameters
5140 ///
5141 /// * `params` - Model identifier and token limits used to compute the context-info breakdown.
5142 ///
5143 /// # Returns
5144 ///
5145 /// Token breakdown for the session's current context window, or null if uninitialized.
5146 ///
5147 /// <div class="warning">
5148 ///
5149 /// **Experimental.** This API is part of an experimental wire-protocol surface
5150 /// and may change or be removed in future SDK or CLI releases. Pin both the
5151 /// SDK and CLI versions if your code depends on it.
5152 ///
5153 /// </div>
5154 pub async fn context_info(
5155 &self,
5156 params: MetadataContextInfoRequest,
5157 ) -> Result<MetadataContextInfoResult, Error> {
5158 let mut wire_params = serde_json::to_value(params)?;
5159 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5160 let _value = self
5161 .session
5162 .client()
5163 .call(rpc_methods::SESSION_METADATA_CONTEXTINFO, Some(wire_params))
5164 .await?;
5165 Ok(serde_json::from_value(_value)?)
5166 }
5167
5168 /// Returns the experimental per-source attribution breakdown of the session's current context window as a flat list of entries (skills, subagents, MCP servers, built-in tools, plugin rollups, system/tool-definition costs, with nesting via parentId), plus the successful compaction count. The heaviest individual messages are available separately via `metadata.getContextHeaviestMessages`. Returns null until the session has initialized its system prompt and tool metadata.
5169 ///
5170 /// Wire method: `session.metadata.getContextAttribution`.
5171 ///
5172 /// # Returns
5173 ///
5174 /// Per-source attribution breakdown for the session's current context window, or null if uninitialized.
5175 ///
5176 /// <div class="warning">
5177 ///
5178 /// **Experimental.** This API is part of an experimental wire-protocol surface
5179 /// and may change or be removed in future SDK or CLI releases. Pin both the
5180 /// SDK and CLI versions if your code depends on it.
5181 ///
5182 /// </div>
5183 pub async fn get_context_attribution(&self) -> Result<MetadataContextAttributionResult, Error> {
5184 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5185 let _value = self
5186 .session
5187 .client()
5188 .call(
5189 rpc_methods::SESSION_METADATA_GETCONTEXTATTRIBUTION,
5190 Some(wire_params),
5191 )
5192 .await?;
5193 Ok(serde_json::from_value(_value)?)
5194 }
5195
5196 /// Returns the largest individual messages currently in the session's context window, most-expensive first. Companion to `metadata.getContextAttribution`. Returns an empty list until the session has initialized.
5197 ///
5198 /// Wire method: `session.metadata.getContextHeaviestMessages`.
5199 ///
5200 /// # Parameters
5201 ///
5202 /// * `params` - Parameters for the heaviest-messages query.
5203 ///
5204 /// # Returns
5205 ///
5206 /// The heaviest individual messages in the session's context window, most-expensive first.
5207 ///
5208 /// <div class="warning">
5209 ///
5210 /// **Experimental.** This API is part of an experimental wire-protocol surface
5211 /// and may change or be removed in future SDK or CLI releases. Pin both the
5212 /// SDK and CLI versions if your code depends on it.
5213 ///
5214 /// </div>
5215 pub async fn get_context_heaviest_messages(
5216 &self,
5217 params: MetadataContextHeaviestMessagesRequest,
5218 ) -> Result<MetadataContextHeaviestMessagesResult, Error> {
5219 let mut wire_params = serde_json::to_value(params)?;
5220 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5221 let _value = self
5222 .session
5223 .client()
5224 .call(
5225 rpc_methods::SESSION_METADATA_GETCONTEXTHEAVIESTMESSAGES,
5226 Some(wire_params),
5227 )
5228 .await?;
5229 Ok(serde_json::from_value(_value)?)
5230 }
5231
5232 /// Records a working-directory/git context change and emits a `session.context_changed` event.
5233 ///
5234 /// Wire method: `session.metadata.recordContextChange`.
5235 ///
5236 /// # Parameters
5237 ///
5238 /// * `params` - Updated working-directory/git context to record on the session.
5239 ///
5240 /// # Returns
5241 ///
5242 /// Notify the session that its working directory context has changed. Emits a `session.context_changed` event so consumers (telemetry, OTel tracker, ACP, the timeline UI) can react. Use this when the host has detected a cwd/branch/repo change outside the session's normal lifecycle (e.g., after a shell command in interactive mode).
5243 ///
5244 /// <div class="warning">
5245 ///
5246 /// **Experimental.** This API is part of an experimental wire-protocol surface
5247 /// and may change or be removed in future SDK or CLI releases. Pin both the
5248 /// SDK and CLI versions if your code depends on it.
5249 ///
5250 /// </div>
5251 pub async fn record_context_change(
5252 &self,
5253 params: MetadataRecordContextChangeRequest,
5254 ) -> Result<MetadataRecordContextChangeResult, Error> {
5255 let mut wire_params = serde_json::to_value(params)?;
5256 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5257 let _value = self
5258 .session
5259 .client()
5260 .call(
5261 rpc_methods::SESSION_METADATA_RECORDCONTEXTCHANGE,
5262 Some(wire_params),
5263 )
5264 .await?;
5265 Ok(serde_json::from_value(_value)?)
5266 }
5267
5268 /// Updates the session's recorded working directory.
5269 ///
5270 /// Wire method: `session.metadata.setWorkingDirectory`.
5271 ///
5272 /// # Parameters
5273 ///
5274 /// * `params` - Absolute path to set as the session's new working directory.
5275 ///
5276 /// # Returns
5277 ///
5278 /// Update the session's working directory. Used by the host when the user explicitly changes cwd (e.g., the `/cd` slash command). The host is responsible for `process.chdir` and any related side-effects (file index, etc.); this method only updates the session's own recorded path.
5279 ///
5280 /// <div class="warning">
5281 ///
5282 /// **Experimental.** This API is part of an experimental wire-protocol surface
5283 /// and may change or be removed in future SDK or CLI releases. Pin both the
5284 /// SDK and CLI versions if your code depends on it.
5285 ///
5286 /// </div>
5287 pub async fn set_working_directory(
5288 &self,
5289 params: MetadataSetWorkingDirectoryRequest,
5290 ) -> Result<MetadataSetWorkingDirectoryResult, Error> {
5291 let mut wire_params = serde_json::to_value(params)?;
5292 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5293 let _value = self
5294 .session
5295 .client()
5296 .call(
5297 rpc_methods::SESSION_METADATA_SETWORKINGDIRECTORY,
5298 Some(wire_params),
5299 )
5300 .await?;
5301 Ok(serde_json::from_value(_value)?)
5302 }
5303
5304 /// Re-tokenizes the session's existing messages against a model and returns aggregate token totals.
5305 ///
5306 /// Wire method: `session.metadata.recomputeContextTokens`.
5307 ///
5308 /// # Parameters
5309 ///
5310 /// * `params` - Model identifier to use when re-tokenizing the session's existing messages.
5311 ///
5312 /// # Returns
5313 ///
5314 /// Re-tokenize the session's existing messages against `modelId` and return the token totals. Useful for hosts that want an initial estimate of context usage on session resume, before the next agent turn fires `session.context_info_changed` events. Returns zeros for an empty session.
5315 ///
5316 /// <div class="warning">
5317 ///
5318 /// **Experimental.** This API is part of an experimental wire-protocol surface
5319 /// and may change or be removed in future SDK or CLI releases. Pin both the
5320 /// SDK and CLI versions if your code depends on it.
5321 ///
5322 /// </div>
5323 pub async fn recompute_context_tokens(
5324 &self,
5325 params: MetadataRecomputeContextTokensRequest,
5326 ) -> Result<MetadataRecomputeContextTokensResult, Error> {
5327 let mut wire_params = serde_json::to_value(params)?;
5328 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5329 let _value = self
5330 .session
5331 .client()
5332 .call(
5333 rpc_methods::SESSION_METADATA_RECOMPUTECONTEXTTOKENS,
5334 Some(wire_params),
5335 )
5336 .await?;
5337 Ok(serde_json::from_value(_value)?)
5338 }
5339}
5340
5341/// `session.mode.*` RPCs.
5342#[derive(Clone, Copy)]
5343pub struct SessionRpcMode<'a> {
5344 pub(crate) session: &'a Session,
5345}
5346
5347impl<'a> SessionRpcMode<'a> {
5348 /// Gets the current agent interaction mode.
5349 ///
5350 /// Wire method: `session.mode.get`.
5351 ///
5352 /// # Returns
5353 ///
5354 /// The session mode the agent is operating in
5355 ///
5356 /// <div class="warning">
5357 ///
5358 /// **Experimental.** This API is part of an experimental wire-protocol surface
5359 /// and may change or be removed in future SDK or CLI releases. Pin both the
5360 /// SDK and CLI versions if your code depends on it.
5361 ///
5362 /// </div>
5363 pub async fn get(&self) -> Result<SessionMode, Error> {
5364 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5365 let _value = self
5366 .session
5367 .client()
5368 .call(rpc_methods::SESSION_MODE_GET, Some(wire_params))
5369 .await?;
5370 Ok(serde_json::from_value(_value)?)
5371 }
5372
5373 /// Sets the current agent interaction mode.
5374 ///
5375 /// Wire method: `session.mode.set`.
5376 ///
5377 /// # Parameters
5378 ///
5379 /// * `params` - Agent interaction mode to apply to the session.
5380 ///
5381 /// <div class="warning">
5382 ///
5383 /// **Experimental.** This API is part of an experimental wire-protocol surface
5384 /// and may change or be removed in future SDK or CLI releases. Pin both the
5385 /// SDK and CLI versions if your code depends on it.
5386 ///
5387 /// </div>
5388 pub async fn set(&self, params: ModeSetRequest) -> Result<(), Error> {
5389 let mut wire_params = serde_json::to_value(params)?;
5390 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5391 let _value = self
5392 .session
5393 .client()
5394 .call(rpc_methods::SESSION_MODE_SET, Some(wire_params))
5395 .await?;
5396 Ok(())
5397 }
5398}
5399
5400/// `session.model.*` RPCs.
5401#[derive(Clone, Copy)]
5402pub struct SessionRpcModel<'a> {
5403 pub(crate) session: &'a Session,
5404}
5405
5406impl<'a> SessionRpcModel<'a> {
5407 /// Gets the currently selected model for the session.
5408 ///
5409 /// Wire method: `session.model.getCurrent`.
5410 ///
5411 /// # Returns
5412 ///
5413 /// The currently selected model, reasoning effort, and context tier for the session. The context tier reflects `Session.getContextTier()`, restored from the session journal on resume.
5414 ///
5415 /// <div class="warning">
5416 ///
5417 /// **Experimental.** This API is part of an experimental wire-protocol surface
5418 /// and may change or be removed in future SDK or CLI releases. Pin both the
5419 /// SDK and CLI versions if your code depends on it.
5420 ///
5421 /// </div>
5422 pub async fn get_current(&self) -> Result<CurrentModel, Error> {
5423 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5424 let _value = self
5425 .session
5426 .client()
5427 .call(rpc_methods::SESSION_MODEL_GETCURRENT, Some(wire_params))
5428 .await?;
5429 Ok(serde_json::from_value(_value)?)
5430 }
5431
5432 /// Switches the session to a model and optional reasoning configuration.
5433 ///
5434 /// Wire method: `session.model.switchTo`.
5435 ///
5436 /// # Parameters
5437 ///
5438 /// * `params` - Target model identifier and optional reasoning effort, summary, capability overrides, and context tier.
5439 ///
5440 /// # Returns
5441 ///
5442 /// The model identifier active on the session after the switch.
5443 ///
5444 /// <div class="warning">
5445 ///
5446 /// **Experimental.** This API is part of an experimental wire-protocol surface
5447 /// and may change or be removed in future SDK or CLI releases. Pin both the
5448 /// SDK and CLI versions if your code depends on it.
5449 ///
5450 /// </div>
5451 pub async fn switch_to(
5452 &self,
5453 params: ModelSwitchToRequest,
5454 ) -> Result<ModelSwitchToResult, Error> {
5455 let mut wire_params = serde_json::to_value(params)?;
5456 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5457 let _value = self
5458 .session
5459 .client()
5460 .call(rpc_methods::SESSION_MODEL_SWITCHTO, Some(wire_params))
5461 .await?;
5462 Ok(serde_json::from_value(_value)?)
5463 }
5464
5465 /// Updates the session's reasoning effort without changing the selected model.
5466 ///
5467 /// Wire method: `session.model.setReasoningEffort`.
5468 ///
5469 /// # Parameters
5470 ///
5471 /// * `params` - Reasoning effort level to apply to the currently selected model.
5472 ///
5473 /// # Returns
5474 ///
5475 /// Update the session's reasoning effort without changing the selected model. Use `switchTo` instead when you also need to change the model. The runtime stores the effort on the session and applies it to subsequent turns.
5476 ///
5477 /// <div class="warning">
5478 ///
5479 /// **Experimental.** This API is part of an experimental wire-protocol surface
5480 /// and may change or be removed in future SDK or CLI releases. Pin both the
5481 /// SDK and CLI versions if your code depends on it.
5482 ///
5483 /// </div>
5484 pub async fn set_reasoning_effort(
5485 &self,
5486 params: ModelSetReasoningEffortRequest,
5487 ) -> Result<ModelSetReasoningEffortResult, Error> {
5488 let mut wire_params = serde_json::to_value(params)?;
5489 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5490 let _value = self
5491 .session
5492 .client()
5493 .call(
5494 rpc_methods::SESSION_MODEL_SETREASONINGEFFORT,
5495 Some(wire_params),
5496 )
5497 .await?;
5498 Ok(serde_json::from_value(_value)?)
5499 }
5500
5501 /// Lists models available to this session using its own auth and integration context. Connected hosts (CLI TUI, GitHub App) should call this through the session client so remote sessions return the remote CLI's available models rather than the caller's.
5502 ///
5503 /// Wire method: `session.model.list`.
5504 ///
5505 /// # Returns
5506 ///
5507 /// The list of models available to this session.
5508 ///
5509 /// <div class="warning">
5510 ///
5511 /// **Experimental.** This API is part of an experimental wire-protocol surface
5512 /// and may change or be removed in future SDK or CLI releases. Pin both the
5513 /// SDK and CLI versions if your code depends on it.
5514 ///
5515 /// </div>
5516 pub async fn list(&self) -> Result<SessionModelList, Error> {
5517 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5518 let _value = self
5519 .session
5520 .client()
5521 .call(rpc_methods::SESSION_MODEL_LIST, Some(wire_params))
5522 .await?;
5523 Ok(serde_json::from_value(_value)?)
5524 }
5525
5526 /// Lists models available to this session using its own auth and integration context. Connected hosts (CLI TUI, GitHub App) should call this through the session client so remote sessions return the remote CLI's available models rather than the caller's.
5527 ///
5528 /// Wire method: `session.model.list`.
5529 ///
5530 /// # Parameters
5531 ///
5532 /// * `params` - Optional listing options.
5533 ///
5534 /// # Returns
5535 ///
5536 /// The list of models available to this session.
5537 ///
5538 /// <div class="warning">
5539 ///
5540 /// **Experimental.** This API is part of an experimental wire-protocol surface
5541 /// and may change or be removed in future SDK or CLI releases. Pin both the
5542 /// SDK and CLI versions if your code depends on it.
5543 ///
5544 /// </div>
5545 pub async fn list_with_params(
5546 &self,
5547 params: ModelListRequest,
5548 ) -> Result<SessionModelList, Error> {
5549 let mut wire_params = serde_json::to_value(params)?;
5550 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5551 let _value = self
5552 .session
5553 .client()
5554 .call(rpc_methods::SESSION_MODEL_LIST, Some(wire_params))
5555 .await?;
5556 Ok(serde_json::from_value(_value)?)
5557 }
5558}
5559
5560/// `session.name.*` RPCs.
5561#[derive(Clone, Copy)]
5562pub struct SessionRpcName<'a> {
5563 pub(crate) session: &'a Session,
5564}
5565
5566impl<'a> SessionRpcName<'a> {
5567 /// Gets the session's friendly name.
5568 ///
5569 /// Wire method: `session.name.get`.
5570 ///
5571 /// # Returns
5572 ///
5573 /// The session's friendly name, or null when not yet set.
5574 ///
5575 /// <div class="warning">
5576 ///
5577 /// **Experimental.** This API is part of an experimental wire-protocol surface
5578 /// and may change or be removed in future SDK or CLI releases. Pin both the
5579 /// SDK and CLI versions if your code depends on it.
5580 ///
5581 /// </div>
5582 pub async fn get(&self) -> Result<NameGetResult, Error> {
5583 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5584 let _value = self
5585 .session
5586 .client()
5587 .call(rpc_methods::SESSION_NAME_GET, Some(wire_params))
5588 .await?;
5589 Ok(serde_json::from_value(_value)?)
5590 }
5591
5592 /// Sets the session's friendly name.
5593 ///
5594 /// Wire method: `session.name.set`.
5595 ///
5596 /// # Parameters
5597 ///
5598 /// * `params` - New friendly name to apply to the session.
5599 ///
5600 /// <div class="warning">
5601 ///
5602 /// **Experimental.** This API is part of an experimental wire-protocol surface
5603 /// and may change or be removed in future SDK or CLI releases. Pin both the
5604 /// SDK and CLI versions if your code depends on it.
5605 ///
5606 /// </div>
5607 pub async fn set(&self, params: NameSetRequest) -> Result<(), Error> {
5608 let mut wire_params = serde_json::to_value(params)?;
5609 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5610 let _value = self
5611 .session
5612 .client()
5613 .call(rpc_methods::SESSION_NAME_SET, Some(wire_params))
5614 .await?;
5615 Ok(())
5616 }
5617
5618 /// Persists an auto-generated session summary as the session's name when no user-set name exists.
5619 ///
5620 /// Wire method: `session.name.setAuto`.
5621 ///
5622 /// # Parameters
5623 ///
5624 /// * `params` - Auto-generated session summary to apply as the session's name when no user-set name exists.
5625 ///
5626 /// # Returns
5627 ///
5628 /// Indicates whether the auto-generated summary was applied as the session's name.
5629 ///
5630 /// <div class="warning">
5631 ///
5632 /// **Experimental.** This API is part of an experimental wire-protocol surface
5633 /// and may change or be removed in future SDK or CLI releases. Pin both the
5634 /// SDK and CLI versions if your code depends on it.
5635 ///
5636 /// </div>
5637 pub async fn set_auto(&self, params: NameSetAutoRequest) -> Result<NameSetAutoResult, Error> {
5638 let mut wire_params = serde_json::to_value(params)?;
5639 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5640 let _value = self
5641 .session
5642 .client()
5643 .call(rpc_methods::SESSION_NAME_SETAUTO, Some(wire_params))
5644 .await?;
5645 Ok(serde_json::from_value(_value)?)
5646 }
5647}
5648
5649/// `session.options.*` RPCs.
5650#[derive(Clone, Copy)]
5651pub struct SessionRpcOptions<'a> {
5652 pub(crate) session: &'a Session,
5653}
5654
5655impl<'a> SessionRpcOptions<'a> {
5656 /// Patches the genuinely-mutable subset of session options.
5657 ///
5658 /// Wire method: `session.options.update`.
5659 ///
5660 /// # Parameters
5661 ///
5662 /// * `params` - Patch of mutable session options to apply to the running session.
5663 ///
5664 /// # Returns
5665 ///
5666 /// Indicates whether the session options patch was applied successfully.
5667 ///
5668 /// <div class="warning">
5669 ///
5670 /// **Experimental.** This API is part of an experimental wire-protocol surface
5671 /// and may change or be removed in future SDK or CLI releases. Pin both the
5672 /// SDK and CLI versions if your code depends on it.
5673 ///
5674 /// </div>
5675 pub async fn update(
5676 &self,
5677 params: SessionUpdateOptionsParams,
5678 ) -> Result<SessionUpdateOptionsResult, Error> {
5679 let mut wire_params = serde_json::to_value(params)?;
5680 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5681 let _value = self
5682 .session
5683 .client()
5684 .call(rpc_methods::SESSION_OPTIONS_UPDATE, Some(wire_params))
5685 .await?;
5686 Ok(serde_json::from_value(_value)?)
5687 }
5688}
5689
5690/// `session.permissions.*` RPCs.
5691#[derive(Clone, Copy)]
5692pub struct SessionRpcPermissions<'a> {
5693 pub(crate) session: &'a Session,
5694}
5695
5696impl<'a> SessionRpcPermissions<'a> {
5697 /// `session.permissions.folderTrust.*` sub-namespace.
5698 pub fn folder_trust(&self) -> SessionRpcPermissionsFolderTrust<'a> {
5699 SessionRpcPermissionsFolderTrust {
5700 session: self.session,
5701 }
5702 }
5703
5704 /// `session.permissions.locations.*` sub-namespace.
5705 pub fn locations(&self) -> SessionRpcPermissionsLocations<'a> {
5706 SessionRpcPermissionsLocations {
5707 session: self.session,
5708 }
5709 }
5710
5711 /// `session.permissions.paths.*` sub-namespace.
5712 pub fn paths(&self) -> SessionRpcPermissionsPaths<'a> {
5713 SessionRpcPermissionsPaths {
5714 session: self.session,
5715 }
5716 }
5717
5718 /// `session.permissions.urls.*` sub-namespace.
5719 pub fn urls(&self) -> SessionRpcPermissionsUrls<'a> {
5720 SessionRpcPermissionsUrls {
5721 session: self.session,
5722 }
5723 }
5724
5725 /// Replaces selected permission policy fields (rules, paths, URLs, exclusions, allow-all flags) on the session.
5726 ///
5727 /// Wire method: `session.permissions.configure`.
5728 ///
5729 /// # Parameters
5730 ///
5731 /// * `params` - Patch of permission policy fields to apply (omit a field to leave it unchanged).
5732 ///
5733 /// # Returns
5734 ///
5735 /// Indicates whether the operation succeeded.
5736 ///
5737 /// <div class="warning">
5738 ///
5739 /// **Experimental.** This API is part of an experimental wire-protocol surface
5740 /// and may change or be removed in future SDK or CLI releases. Pin both the
5741 /// SDK and CLI versions if your code depends on it.
5742 ///
5743 /// </div>
5744 pub async fn configure(
5745 &self,
5746 params: PermissionsConfigureParams,
5747 ) -> Result<PermissionsConfigureResult, Error> {
5748 let mut wire_params = serde_json::to_value(params)?;
5749 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5750 let _value = self
5751 .session
5752 .client()
5753 .call(
5754 rpc_methods::SESSION_PERMISSIONS_CONFIGURE,
5755 Some(wire_params),
5756 )
5757 .await?;
5758 Ok(serde_json::from_value(_value)?)
5759 }
5760
5761 /// Provides a decision for a pending tool permission request.
5762 ///
5763 /// Wire method: `session.permissions.handlePendingPermissionRequest`.
5764 ///
5765 /// # Parameters
5766 ///
5767 /// * `params` - Pending permission request ID and the decision to apply (approve/reject and scope).
5768 ///
5769 /// # Returns
5770 ///
5771 /// Indicates whether the permission decision was applied; false when the request was already resolved.
5772 ///
5773 /// <div class="warning">
5774 ///
5775 /// **Experimental.** This API is part of an experimental wire-protocol surface
5776 /// and may change or be removed in future SDK or CLI releases. Pin both the
5777 /// SDK and CLI versions if your code depends on it.
5778 ///
5779 /// </div>
5780 pub async fn handle_pending_permission_request(
5781 &self,
5782 params: PermissionDecisionRequest,
5783 ) -> Result<PermissionRequestResult, Error> {
5784 let mut wire_params = serde_json::to_value(params)?;
5785 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5786 let _value = self
5787 .session
5788 .client()
5789 .call(
5790 rpc_methods::SESSION_PERMISSIONS_HANDLEPENDINGPERMISSIONREQUEST,
5791 Some(wire_params),
5792 )
5793 .await?;
5794 Ok(serde_json::from_value(_value)?)
5795 }
5796
5797 /// Reconstructs the set of pending tool permission requests from the session's event history.
5798 ///
5799 /// Wire method: `session.permissions.pendingRequests`.
5800 ///
5801 /// # Returns
5802 ///
5803 /// List of pending permission requests reconstructed from event history.
5804 ///
5805 /// <div class="warning">
5806 ///
5807 /// **Experimental.** This API is part of an experimental wire-protocol surface
5808 /// and may change or be removed in future SDK or CLI releases. Pin both the
5809 /// SDK and CLI versions if your code depends on it.
5810 ///
5811 /// </div>
5812 pub async fn pending_requests(&self) -> Result<PendingPermissionRequestList, Error> {
5813 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5814 let _value = self
5815 .session
5816 .client()
5817 .call(
5818 rpc_methods::SESSION_PERMISSIONS_PENDINGREQUESTS,
5819 Some(wire_params),
5820 )
5821 .await?;
5822 Ok(serde_json::from_value(_value)?)
5823 }
5824
5825 /// Enables or disables automatic approval of tool permission requests for the session.
5826 ///
5827 /// Wire method: `session.permissions.setApproveAll`.
5828 ///
5829 /// # Parameters
5830 ///
5831 /// * `params` - Allow-all toggle for tool permission requests, with an optional telemetry source.
5832 ///
5833 /// # Returns
5834 ///
5835 /// Indicates whether the operation succeeded.
5836 ///
5837 /// <div class="warning">
5838 ///
5839 /// **Experimental.** This API is part of an experimental wire-protocol surface
5840 /// and may change or be removed in future SDK or CLI releases. Pin both the
5841 /// SDK and CLI versions if your code depends on it.
5842 ///
5843 /// </div>
5844 pub async fn set_approve_all(
5845 &self,
5846 params: PermissionsSetApproveAllRequest,
5847 ) -> Result<PermissionsSetApproveAllResult, Error> {
5848 let mut wire_params = serde_json::to_value(params)?;
5849 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5850 let _value = self
5851 .session
5852 .client()
5853 .call(
5854 rpc_methods::SESSION_PERMISSIONS_SETAPPROVEALL,
5855 Some(wire_params),
5856 )
5857 .await?;
5858 Ok(serde_json::from_value(_value)?)
5859 }
5860
5861 /// Enables or disables full allow-all permissions (tools, paths, and URLs) for the session. Used by attach-mode clients (e.g. LocalRpcSession's `/allow-all` forwarder) to flip the target session's permission state. Unlike `setApproveAll`, this swaps in the unrestricted path and URL managers and emits `session.permissions_changed` on transition. The result returns the authoritative post-mutation state so callers can update their local mirrors without racing the `session.permissions_changed` notification on the same wire.
5862 ///
5863 /// Wire method: `session.permissions.setAllowAll`.
5864 ///
5865 /// # Parameters
5866 ///
5867 /// * `params` - Whether to enable full allow-all permissions for the session.
5868 ///
5869 /// # Returns
5870 ///
5871 /// Indicates whether the operation succeeded and reports the post-mutation state.
5872 ///
5873 /// <div class="warning">
5874 ///
5875 /// **Experimental.** This API is part of an experimental wire-protocol surface
5876 /// and may change or be removed in future SDK or CLI releases. Pin both the
5877 /// SDK and CLI versions if your code depends on it.
5878 ///
5879 /// </div>
5880 pub async fn set_allow_all(
5881 &self,
5882 params: PermissionsSetAllowAllRequest,
5883 ) -> Result<AllowAllPermissionSetResult, Error> {
5884 let mut wire_params = serde_json::to_value(params)?;
5885 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5886 let _value = self
5887 .session
5888 .client()
5889 .call(
5890 rpc_methods::SESSION_PERMISSIONS_SETALLOWALL,
5891 Some(wire_params),
5892 )
5893 .await?;
5894 Ok(serde_json::from_value(_value)?)
5895 }
5896
5897 /// Returns whether full allow-all permissions are currently active for the session.
5898 ///
5899 /// Wire method: `session.permissions.getAllowAll`.
5900 ///
5901 /// # Returns
5902 ///
5903 /// Current full allow-all permission state.
5904 ///
5905 /// <div class="warning">
5906 ///
5907 /// **Experimental.** This API is part of an experimental wire-protocol surface
5908 /// and may change or be removed in future SDK or CLI releases. Pin both the
5909 /// SDK and CLI versions if your code depends on it.
5910 ///
5911 /// </div>
5912 pub async fn get_allow_all(&self) -> Result<AllowAllPermissionState, Error> {
5913 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5914 let _value = self
5915 .session
5916 .client()
5917 .call(
5918 rpc_methods::SESSION_PERMISSIONS_GETALLOWALL,
5919 Some(wire_params),
5920 )
5921 .await?;
5922 Ok(serde_json::from_value(_value)?)
5923 }
5924
5925 /// Adds or removes session-scoped or location-scoped permission rules.
5926 ///
5927 /// Wire method: `session.permissions.modifyRules`.
5928 ///
5929 /// # Parameters
5930 ///
5931 /// * `params` - Scope and add/remove instructions for modifying session- or location-scoped permission rules.
5932 ///
5933 /// # Returns
5934 ///
5935 /// Indicates whether the operation succeeded.
5936 ///
5937 /// <div class="warning">
5938 ///
5939 /// **Experimental.** This API is part of an experimental wire-protocol surface
5940 /// and may change or be removed in future SDK or CLI releases. Pin both the
5941 /// SDK and CLI versions if your code depends on it.
5942 ///
5943 /// </div>
5944 pub async fn modify_rules(
5945 &self,
5946 params: PermissionsModifyRulesParams,
5947 ) -> Result<PermissionsModifyRulesResult, Error> {
5948 let mut wire_params = serde_json::to_value(params)?;
5949 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5950 let _value = self
5951 .session
5952 .client()
5953 .call(
5954 rpc_methods::SESSION_PERMISSIONS_MODIFYRULES,
5955 Some(wire_params),
5956 )
5957 .await?;
5958 Ok(serde_json::from_value(_value)?)
5959 }
5960
5961 /// Sets whether the client wants permission prompts bridged into session events.
5962 ///
5963 /// Wire method: `session.permissions.setRequired`.
5964 ///
5965 /// # Parameters
5966 ///
5967 /// * `params` - Toggles whether permission prompts should be bridged into session events for this client.
5968 ///
5969 /// # Returns
5970 ///
5971 /// Indicates whether the operation succeeded.
5972 ///
5973 /// <div class="warning">
5974 ///
5975 /// **Experimental.** This API is part of an experimental wire-protocol surface
5976 /// and may change or be removed in future SDK or CLI releases. Pin both the
5977 /// SDK and CLI versions if your code depends on it.
5978 ///
5979 /// </div>
5980 pub async fn set_required(
5981 &self,
5982 params: PermissionsSetRequiredRequest,
5983 ) -> Result<PermissionsSetRequiredResult, Error> {
5984 let mut wire_params = serde_json::to_value(params)?;
5985 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5986 let _value = self
5987 .session
5988 .client()
5989 .call(
5990 rpc_methods::SESSION_PERMISSIONS_SETREQUIRED,
5991 Some(wire_params),
5992 )
5993 .await?;
5994 Ok(serde_json::from_value(_value)?)
5995 }
5996
5997 /// Clears session-scoped tool permission approvals.
5998 ///
5999 /// Wire method: `session.permissions.resetSessionApprovals`.
6000 ///
6001 /// # Returns
6002 ///
6003 /// Indicates whether the operation succeeded.
6004 ///
6005 /// <div class="warning">
6006 ///
6007 /// **Experimental.** This API is part of an experimental wire-protocol surface
6008 /// and may change or be removed in future SDK or CLI releases. Pin both the
6009 /// SDK and CLI versions if your code depends on it.
6010 ///
6011 /// </div>
6012 pub async fn reset_session_approvals(
6013 &self,
6014 ) -> Result<PermissionsResetSessionApprovalsResult, Error> {
6015 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6016 let _value = self
6017 .session
6018 .client()
6019 .call(
6020 rpc_methods::SESSION_PERMISSIONS_RESETSESSIONAPPROVALS,
6021 Some(wire_params),
6022 )
6023 .await?;
6024 Ok(serde_json::from_value(_value)?)
6025 }
6026
6027 /// Notifies the runtime that a permission prompt UI has been shown to the user.
6028 ///
6029 /// Wire method: `session.permissions.notifyPromptShown`.
6030 ///
6031 /// # Parameters
6032 ///
6033 /// * `params` - Notification payload describing the permission prompt that the client just rendered.
6034 ///
6035 /// # Returns
6036 ///
6037 /// Indicates whether the operation succeeded.
6038 ///
6039 /// <div class="warning">
6040 ///
6041 /// **Experimental.** This API is part of an experimental wire-protocol surface
6042 /// and may change or be removed in future SDK or CLI releases. Pin both the
6043 /// SDK and CLI versions if your code depends on it.
6044 ///
6045 /// </div>
6046 pub async fn notify_prompt_shown(
6047 &self,
6048 params: PermissionPromptShownNotification,
6049 ) -> Result<PermissionsNotifyPromptShownResult, Error> {
6050 let mut wire_params = serde_json::to_value(params)?;
6051 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6052 let _value = self
6053 .session
6054 .client()
6055 .call(
6056 rpc_methods::SESSION_PERMISSIONS_NOTIFYPROMPTSHOWN,
6057 Some(wire_params),
6058 )
6059 .await?;
6060 Ok(serde_json::from_value(_value)?)
6061 }
6062}
6063
6064/// `session.permissions.folderTrust.*` RPCs.
6065#[derive(Clone, Copy)]
6066pub struct SessionRpcPermissionsFolderTrust<'a> {
6067 pub(crate) session: &'a Session,
6068}
6069
6070impl<'a> SessionRpcPermissionsFolderTrust<'a> {
6071 /// Reports whether a folder is trusted according to the user's folder trust state.
6072 ///
6073 /// Wire method: `session.permissions.folderTrust.isTrusted`.
6074 ///
6075 /// # Parameters
6076 ///
6077 /// * `params` - Folder path to check for trust.
6078 ///
6079 /// # Returns
6080 ///
6081 /// Folder trust check result.
6082 ///
6083 /// <div class="warning">
6084 ///
6085 /// **Experimental.** This API is part of an experimental wire-protocol surface
6086 /// and may change or be removed in future SDK or CLI releases. Pin both the
6087 /// SDK and CLI versions if your code depends on it.
6088 ///
6089 /// </div>
6090 pub async fn is_trusted(
6091 &self,
6092 params: FolderTrustCheckParams,
6093 ) -> Result<FolderTrustCheckResult, Error> {
6094 let mut wire_params = serde_json::to_value(params)?;
6095 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6096 let _value = self
6097 .session
6098 .client()
6099 .call(
6100 rpc_methods::SESSION_PERMISSIONS_FOLDERTRUST_ISTRUSTED,
6101 Some(wire_params),
6102 )
6103 .await?;
6104 Ok(serde_json::from_value(_value)?)
6105 }
6106
6107 /// Adds a folder to the user's trusted folders list.
6108 ///
6109 /// Wire method: `session.permissions.folderTrust.addTrusted`.
6110 ///
6111 /// # Parameters
6112 ///
6113 /// * `params` - Folder path to add to trusted folders.
6114 ///
6115 /// # Returns
6116 ///
6117 /// Indicates whether the operation succeeded.
6118 ///
6119 /// <div class="warning">
6120 ///
6121 /// **Experimental.** This API is part of an experimental wire-protocol surface
6122 /// and may change or be removed in future SDK or CLI releases. Pin both the
6123 /// SDK and CLI versions if your code depends on it.
6124 ///
6125 /// </div>
6126 pub async fn add_trusted(
6127 &self,
6128 params: FolderTrustAddParams,
6129 ) -> Result<PermissionsFolderTrustAddTrustedResult, Error> {
6130 let mut wire_params = serde_json::to_value(params)?;
6131 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6132 let _value = self
6133 .session
6134 .client()
6135 .call(
6136 rpc_methods::SESSION_PERMISSIONS_FOLDERTRUST_ADDTRUSTED,
6137 Some(wire_params),
6138 )
6139 .await?;
6140 Ok(serde_json::from_value(_value)?)
6141 }
6142}
6143
6144/// `session.permissions.locations.*` RPCs.
6145#[derive(Clone, Copy)]
6146pub struct SessionRpcPermissionsLocations<'a> {
6147 pub(crate) session: &'a Session,
6148}
6149
6150impl<'a> SessionRpcPermissionsLocations<'a> {
6151 /// Resolves the permission location key and type for a working directory.
6152 ///
6153 /// Wire method: `session.permissions.locations.resolve`.
6154 ///
6155 /// # Parameters
6156 ///
6157 /// * `params` - Working directory to resolve into a location-permissions key.
6158 ///
6159 /// # Returns
6160 ///
6161 /// Resolved location-permissions key and type.
6162 ///
6163 /// <div class="warning">
6164 ///
6165 /// **Experimental.** This API is part of an experimental wire-protocol surface
6166 /// and may change or be removed in future SDK or CLI releases. Pin both the
6167 /// SDK and CLI versions if your code depends on it.
6168 ///
6169 /// </div>
6170 pub async fn resolve(
6171 &self,
6172 params: PermissionLocationResolveParams,
6173 ) -> Result<PermissionLocationResolveResult, Error> {
6174 let mut wire_params = serde_json::to_value(params)?;
6175 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6176 let _value = self
6177 .session
6178 .client()
6179 .call(
6180 rpc_methods::SESSION_PERMISSIONS_LOCATIONS_RESOLVE,
6181 Some(wire_params),
6182 )
6183 .await?;
6184 Ok(serde_json::from_value(_value)?)
6185 }
6186
6187 /// Applies persisted location-scoped tool approvals and allowed directories for a working directory to this session's permission service.
6188 ///
6189 /// Wire method: `session.permissions.locations.apply`.
6190 ///
6191 /// # Parameters
6192 ///
6193 /// * `params` - Working directory to load persisted location permissions for.
6194 ///
6195 /// # Returns
6196 ///
6197 /// Summary of persisted location permissions applied to the session.
6198 ///
6199 /// <div class="warning">
6200 ///
6201 /// **Experimental.** This API is part of an experimental wire-protocol surface
6202 /// and may change or be removed in future SDK or CLI releases. Pin both the
6203 /// SDK and CLI versions if your code depends on it.
6204 ///
6205 /// </div>
6206 pub async fn apply(
6207 &self,
6208 params: PermissionLocationApplyParams,
6209 ) -> Result<PermissionLocationApplyResult, Error> {
6210 let mut wire_params = serde_json::to_value(params)?;
6211 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6212 let _value = self
6213 .session
6214 .client()
6215 .call(
6216 rpc_methods::SESSION_PERMISSIONS_LOCATIONS_APPLY,
6217 Some(wire_params),
6218 )
6219 .await?;
6220 Ok(serde_json::from_value(_value)?)
6221 }
6222
6223 /// Persists a tool approval for a permission location and applies its rules to this session's live permission service.
6224 ///
6225 /// Wire method: `session.permissions.locations.addToolApproval`.
6226 ///
6227 /// # Parameters
6228 ///
6229 /// * `params` - Location-scoped tool approval to persist.
6230 ///
6231 /// # Returns
6232 ///
6233 /// Indicates whether the operation succeeded.
6234 ///
6235 /// <div class="warning">
6236 ///
6237 /// **Experimental.** This API is part of an experimental wire-protocol surface
6238 /// and may change or be removed in future SDK or CLI releases. Pin both the
6239 /// SDK and CLI versions if your code depends on it.
6240 ///
6241 /// </div>
6242 pub async fn add_tool_approval(
6243 &self,
6244 params: PermissionLocationAddToolApprovalParams,
6245 ) -> Result<PermissionsLocationsAddToolApprovalResult, Error> {
6246 let mut wire_params = serde_json::to_value(params)?;
6247 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6248 let _value = self
6249 .session
6250 .client()
6251 .call(
6252 rpc_methods::SESSION_PERMISSIONS_LOCATIONS_ADDTOOLAPPROVAL,
6253 Some(wire_params),
6254 )
6255 .await?;
6256 Ok(serde_json::from_value(_value)?)
6257 }
6258}
6259
6260/// `session.permissions.paths.*` RPCs.
6261#[derive(Clone, Copy)]
6262pub struct SessionRpcPermissionsPaths<'a> {
6263 pub(crate) session: &'a Session,
6264}
6265
6266impl<'a> SessionRpcPermissionsPaths<'a> {
6267 /// Returns the session's allowed directories and primary working directory.
6268 ///
6269 /// Wire method: `session.permissions.paths.list`.
6270 ///
6271 /// # Returns
6272 ///
6273 /// Snapshot of the session's allow-listed directories and primary working directory.
6274 ///
6275 /// <div class="warning">
6276 ///
6277 /// **Experimental.** This API is part of an experimental wire-protocol surface
6278 /// and may change or be removed in future SDK or CLI releases. Pin both the
6279 /// SDK and CLI versions if your code depends on it.
6280 ///
6281 /// </div>
6282 pub async fn list(&self) -> Result<PermissionPathsList, Error> {
6283 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6284 let _value = self
6285 .session
6286 .client()
6287 .call(
6288 rpc_methods::SESSION_PERMISSIONS_PATHS_LIST,
6289 Some(wire_params),
6290 )
6291 .await?;
6292 Ok(serde_json::from_value(_value)?)
6293 }
6294
6295 /// Adds a directory to the session's allow-list.
6296 ///
6297 /// Wire method: `session.permissions.paths.add`.
6298 ///
6299 /// # Parameters
6300 ///
6301 /// * `params` - Directory path to add to the session's allowed directories.
6302 ///
6303 /// # Returns
6304 ///
6305 /// Indicates whether the operation succeeded.
6306 ///
6307 /// <div class="warning">
6308 ///
6309 /// **Experimental.** This API is part of an experimental wire-protocol surface
6310 /// and may change or be removed in future SDK or CLI releases. Pin both the
6311 /// SDK and CLI versions if your code depends on it.
6312 ///
6313 /// </div>
6314 pub async fn add(
6315 &self,
6316 params: PermissionPathsAddParams,
6317 ) -> Result<PermissionsPathsAddResult, Error> {
6318 let mut wire_params = serde_json::to_value(params)?;
6319 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6320 let _value = self
6321 .session
6322 .client()
6323 .call(
6324 rpc_methods::SESSION_PERMISSIONS_PATHS_ADD,
6325 Some(wire_params),
6326 )
6327 .await?;
6328 Ok(serde_json::from_value(_value)?)
6329 }
6330
6331 /// Updates the session's primary working directory used by the permission policy.
6332 ///
6333 /// Wire method: `session.permissions.paths.updatePrimary`.
6334 ///
6335 /// # Parameters
6336 ///
6337 /// * `params` - Directory path to set as the session's new primary working directory.
6338 ///
6339 /// # Returns
6340 ///
6341 /// Indicates whether the operation succeeded.
6342 ///
6343 /// <div class="warning">
6344 ///
6345 /// **Experimental.** This API is part of an experimental wire-protocol surface
6346 /// and may change or be removed in future SDK or CLI releases. Pin both the
6347 /// SDK and CLI versions if your code depends on it.
6348 ///
6349 /// </div>
6350 pub async fn update_primary(
6351 &self,
6352 params: PermissionPathsUpdatePrimaryParams,
6353 ) -> Result<PermissionsPathsUpdatePrimaryResult, Error> {
6354 let mut wire_params = serde_json::to_value(params)?;
6355 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6356 let _value = self
6357 .session
6358 .client()
6359 .call(
6360 rpc_methods::SESSION_PERMISSIONS_PATHS_UPDATEPRIMARY,
6361 Some(wire_params),
6362 )
6363 .await?;
6364 Ok(serde_json::from_value(_value)?)
6365 }
6366
6367 /// Reports whether a path falls within any of the session's allowed directories.
6368 ///
6369 /// Wire method: `session.permissions.paths.isPathWithinAllowedDirectories`.
6370 ///
6371 /// # Parameters
6372 ///
6373 /// * `params` - Path to evaluate against the session's allowed directories.
6374 ///
6375 /// # Returns
6376 ///
6377 /// Indicates whether the supplied path is within the session's allowed directories.
6378 ///
6379 /// <div class="warning">
6380 ///
6381 /// **Experimental.** This API is part of an experimental wire-protocol surface
6382 /// and may change or be removed in future SDK or CLI releases. Pin both the
6383 /// SDK and CLI versions if your code depends on it.
6384 ///
6385 /// </div>
6386 pub async fn is_path_within_allowed_directories(
6387 &self,
6388 params: PermissionPathsAllowedCheckParams,
6389 ) -> Result<PermissionPathsAllowedCheckResult, Error> {
6390 let mut wire_params = serde_json::to_value(params)?;
6391 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6392 let _value = self
6393 .session
6394 .client()
6395 .call(
6396 rpc_methods::SESSION_PERMISSIONS_PATHS_ISPATHWITHINALLOWEDDIRECTORIES,
6397 Some(wire_params),
6398 )
6399 .await?;
6400 Ok(serde_json::from_value(_value)?)
6401 }
6402
6403 /// Reports whether a path falls within the session's workspace (primary) directory.
6404 ///
6405 /// Wire method: `session.permissions.paths.isPathWithinWorkspace`.
6406 ///
6407 /// # Parameters
6408 ///
6409 /// * `params` - Path to evaluate against the session's workspace (primary) directory.
6410 ///
6411 /// # Returns
6412 ///
6413 /// Indicates whether the supplied path is within the session's workspace directory.
6414 ///
6415 /// <div class="warning">
6416 ///
6417 /// **Experimental.** This API is part of an experimental wire-protocol surface
6418 /// and may change or be removed in future SDK or CLI releases. Pin both the
6419 /// SDK and CLI versions if your code depends on it.
6420 ///
6421 /// </div>
6422 pub async fn is_path_within_workspace(
6423 &self,
6424 params: PermissionPathsWorkspaceCheckParams,
6425 ) -> Result<PermissionPathsWorkspaceCheckResult, Error> {
6426 let mut wire_params = serde_json::to_value(params)?;
6427 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6428 let _value = self
6429 .session
6430 .client()
6431 .call(
6432 rpc_methods::SESSION_PERMISSIONS_PATHS_ISPATHWITHINWORKSPACE,
6433 Some(wire_params),
6434 )
6435 .await?;
6436 Ok(serde_json::from_value(_value)?)
6437 }
6438}
6439
6440/// `session.permissions.urls.*` RPCs.
6441#[derive(Clone, Copy)]
6442pub struct SessionRpcPermissionsUrls<'a> {
6443 pub(crate) session: &'a Session,
6444}
6445
6446impl<'a> SessionRpcPermissionsUrls<'a> {
6447 /// Toggles the runtime's URL-permission policy between unrestricted and restricted modes.
6448 ///
6449 /// Wire method: `session.permissions.urls.setUnrestrictedMode`.
6450 ///
6451 /// # Parameters
6452 ///
6453 /// * `params` - Whether the URL-permission policy should run in unrestricted mode.
6454 ///
6455 /// # Returns
6456 ///
6457 /// Indicates whether the operation succeeded.
6458 ///
6459 /// <div class="warning">
6460 ///
6461 /// **Experimental.** This API is part of an experimental wire-protocol surface
6462 /// and may change or be removed in future SDK or CLI releases. Pin both the
6463 /// SDK and CLI versions if your code depends on it.
6464 ///
6465 /// </div>
6466 pub async fn set_unrestricted_mode(
6467 &self,
6468 params: PermissionUrlsSetUnrestrictedModeParams,
6469 ) -> Result<PermissionsUrlsSetUnrestrictedModeResult, Error> {
6470 let mut wire_params = serde_json::to_value(params)?;
6471 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6472 let _value = self
6473 .session
6474 .client()
6475 .call(
6476 rpc_methods::SESSION_PERMISSIONS_URLS_SETUNRESTRICTEDMODE,
6477 Some(wire_params),
6478 )
6479 .await?;
6480 Ok(serde_json::from_value(_value)?)
6481 }
6482}
6483
6484/// `session.plan.*` RPCs.
6485#[derive(Clone, Copy)]
6486pub struct SessionRpcPlan<'a> {
6487 pub(crate) session: &'a Session,
6488}
6489
6490impl<'a> SessionRpcPlan<'a> {
6491 /// Reads the session plan file from the workspace.
6492 ///
6493 /// Wire method: `session.plan.read`.
6494 ///
6495 /// # Returns
6496 ///
6497 /// Existence, contents, and resolved path of the session plan file.
6498 ///
6499 /// <div class="warning">
6500 ///
6501 /// **Experimental.** This API is part of an experimental wire-protocol surface
6502 /// and may change or be removed in future SDK or CLI releases. Pin both the
6503 /// SDK and CLI versions if your code depends on it.
6504 ///
6505 /// </div>
6506 pub async fn read(&self) -> Result<PlanReadResult, Error> {
6507 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6508 let _value = self
6509 .session
6510 .client()
6511 .call(rpc_methods::SESSION_PLAN_READ, Some(wire_params))
6512 .await?;
6513 Ok(serde_json::from_value(_value)?)
6514 }
6515
6516 /// Writes new content to the session plan file.
6517 ///
6518 /// Wire method: `session.plan.update`.
6519 ///
6520 /// # Parameters
6521 ///
6522 /// * `params` - Replacement contents to write to the session plan file.
6523 ///
6524 /// <div class="warning">
6525 ///
6526 /// **Experimental.** This API is part of an experimental wire-protocol surface
6527 /// and may change or be removed in future SDK or CLI releases. Pin both the
6528 /// SDK and CLI versions if your code depends on it.
6529 ///
6530 /// </div>
6531 pub async fn update(&self, params: PlanUpdateRequest) -> Result<(), Error> {
6532 let mut wire_params = serde_json::to_value(params)?;
6533 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6534 let _value = self
6535 .session
6536 .client()
6537 .call(rpc_methods::SESSION_PLAN_UPDATE, Some(wire_params))
6538 .await?;
6539 Ok(())
6540 }
6541
6542 /// Deletes the session plan file from the workspace.
6543 ///
6544 /// Wire method: `session.plan.delete`.
6545 ///
6546 /// <div class="warning">
6547 ///
6548 /// **Experimental.** This API is part of an experimental wire-protocol surface
6549 /// and may change or be removed in future SDK or CLI releases. Pin both the
6550 /// SDK and CLI versions if your code depends on it.
6551 ///
6552 /// </div>
6553 pub async fn delete(&self) -> Result<(), Error> {
6554 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6555 let _value = self
6556 .session
6557 .client()
6558 .call(rpc_methods::SESSION_PLAN_DELETE, Some(wire_params))
6559 .await?;
6560 Ok(())
6561 }
6562
6563 /// Reads todo rows from the session SQL database for plan rendering.
6564 ///
6565 /// Wire method: `session.plan.readSqlTodos`.
6566 ///
6567 /// # Returns
6568 ///
6569 /// Todo rows read from the session SQL database. Empty when no session database is available.
6570 ///
6571 /// <div class="warning">
6572 ///
6573 /// **Experimental.** This API is part of an experimental wire-protocol surface
6574 /// and may change or be removed in future SDK or CLI releases. Pin both the
6575 /// SDK and CLI versions if your code depends on it.
6576 ///
6577 /// </div>
6578 pub async fn read_sql_todos(&self) -> Result<PlanReadSqlTodosResult, Error> {
6579 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6580 let _value = self
6581 .session
6582 .client()
6583 .call(rpc_methods::SESSION_PLAN_READSQLTODOS, Some(wire_params))
6584 .await?;
6585 Ok(serde_json::from_value(_value)?)
6586 }
6587
6588 /// Reads todo rows AND dependency edges from the session SQL database for structured progress UI. Same defensive behavior as readSqlTodos — returns empty arrays when the database, tables, or columns aren't available. Clients should call this on session start and after every `session.todos_changed` event to refresh structured-UI rendering.
6589 ///
6590 /// Wire method: `session.plan.readSqlTodosWithDependencies`.
6591 ///
6592 /// # Returns
6593 ///
6594 /// Todo rows + dependency edges read from the session SQL database.
6595 ///
6596 /// <div class="warning">
6597 ///
6598 /// **Experimental.** This API is part of an experimental wire-protocol surface
6599 /// and may change or be removed in future SDK or CLI releases. Pin both the
6600 /// SDK and CLI versions if your code depends on it.
6601 ///
6602 /// </div>
6603 pub async fn read_sql_todos_with_dependencies(
6604 &self,
6605 ) -> Result<PlanReadSqlTodosWithDependenciesResult, Error> {
6606 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6607 let _value = self
6608 .session
6609 .client()
6610 .call(
6611 rpc_methods::SESSION_PLAN_READSQLTODOSWITHDEPENDENCIES,
6612 Some(wire_params),
6613 )
6614 .await?;
6615 Ok(serde_json::from_value(_value)?)
6616 }
6617}
6618
6619/// `session.plugins.*` RPCs.
6620#[derive(Clone, Copy)]
6621pub struct SessionRpcPlugins<'a> {
6622 pub(crate) session: &'a Session,
6623}
6624
6625impl<'a> SessionRpcPlugins<'a> {
6626 /// Lists plugins installed for the session.
6627 ///
6628 /// Wire method: `session.plugins.list`.
6629 ///
6630 /// # Returns
6631 ///
6632 /// Plugins installed for the session, with their enabled state and version metadata.
6633 ///
6634 /// <div class="warning">
6635 ///
6636 /// **Experimental.** This API is part of an experimental wire-protocol surface
6637 /// and may change or be removed in future SDK or CLI releases. Pin both the
6638 /// SDK and CLI versions if your code depends on it.
6639 ///
6640 /// </div>
6641 pub async fn list(&self) -> Result<PluginList, Error> {
6642 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6643 let _value = self
6644 .session
6645 .client()
6646 .call(rpc_methods::SESSION_PLUGINS_LIST, Some(wire_params))
6647 .await?;
6648 Ok(serde_json::from_value(_value)?)
6649 }
6650
6651 /// Reloads the session's plugin set, refreshing MCP servers, custom agents, hooks, and skills cache so SDK-driven changes via `server.plugins.*` take effect immediately.
6652 ///
6653 /// Wire method: `session.plugins.reload`.
6654 ///
6655 /// <div class="warning">
6656 ///
6657 /// **Experimental.** This API is part of an experimental wire-protocol surface
6658 /// and may change or be removed in future SDK or CLI releases. Pin both the
6659 /// SDK and CLI versions if your code depends on it.
6660 ///
6661 /// </div>
6662 pub async fn reload(&self) -> Result<(), Error> {
6663 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6664 let _value = self
6665 .session
6666 .client()
6667 .call(rpc_methods::SESSION_PLUGINS_RELOAD, Some(wire_params))
6668 .await?;
6669 Ok(())
6670 }
6671
6672 /// Reloads the session's plugin set, refreshing MCP servers, custom agents, hooks, and skills cache so SDK-driven changes via `server.plugins.*` take effect immediately.
6673 ///
6674 /// Wire method: `session.plugins.reload`.
6675 ///
6676 /// # Parameters
6677 ///
6678 /// * `params` - Optional flags controlling which side effects the reload performs.
6679 ///
6680 /// <div class="warning">
6681 ///
6682 /// **Experimental.** This API is part of an experimental wire-protocol surface
6683 /// and may change or be removed in future SDK or CLI releases. Pin both the
6684 /// SDK and CLI versions if your code depends on it.
6685 ///
6686 /// </div>
6687 pub async fn reload_with_params(&self, params: PluginsReloadRequest) -> Result<(), Error> {
6688 let mut wire_params = serde_json::to_value(params)?;
6689 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6690 let _value = self
6691 .session
6692 .client()
6693 .call(rpc_methods::SESSION_PLUGINS_RELOAD, Some(wire_params))
6694 .await?;
6695 Ok(())
6696 }
6697}
6698
6699/// `session.provider.*` RPCs.
6700#[derive(Clone, Copy)]
6701pub struct SessionRpcProvider<'a> {
6702 pub(crate) session: &'a Session,
6703}
6704
6705impl<'a> SessionRpcProvider<'a> {
6706 /// Returns the provider endpoint and credentials the session is currently configured to talk to, so the caller can make inference calls directly against the same backend the session uses.
6707 ///
6708 /// Wire method: `session.provider.getEndpoint`.
6709 ///
6710 /// # Returns
6711 ///
6712 /// A snapshot of the provider endpoint the session is currently configured to talk to.
6713 ///
6714 /// <div class="warning">
6715 ///
6716 /// **Experimental.** This API is part of an experimental wire-protocol surface
6717 /// and may change or be removed in future SDK or CLI releases. Pin both the
6718 /// SDK and CLI versions if your code depends on it.
6719 ///
6720 /// </div>
6721 pub async fn get_endpoint(&self) -> Result<ProviderEndpoint, Error> {
6722 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6723 let _value = self
6724 .session
6725 .client()
6726 .call(rpc_methods::SESSION_PROVIDER_GETENDPOINT, Some(wire_params))
6727 .await?;
6728 Ok(serde_json::from_value(_value)?)
6729 }
6730
6731 /// Returns the provider endpoint and credentials the session is currently configured to talk to, so the caller can make inference calls directly against the same backend the session uses.
6732 ///
6733 /// Wire method: `session.provider.getEndpoint`.
6734 ///
6735 /// # Parameters
6736 ///
6737 /// * `params` - Optional model identifier to scope the endpoint snapshot to.
6738 ///
6739 /// # Returns
6740 ///
6741 /// A snapshot of the provider endpoint the session is currently configured to talk to.
6742 ///
6743 /// <div class="warning">
6744 ///
6745 /// **Experimental.** This API is part of an experimental wire-protocol surface
6746 /// and may change or be removed in future SDK or CLI releases. Pin both the
6747 /// SDK and CLI versions if your code depends on it.
6748 ///
6749 /// </div>
6750 pub async fn get_endpoint_with_params(
6751 &self,
6752 params: ProviderGetEndpointRequest,
6753 ) -> Result<ProviderEndpoint, Error> {
6754 let mut wire_params = serde_json::to_value(params)?;
6755 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6756 let _value = self
6757 .session
6758 .client()
6759 .call(rpc_methods::SESSION_PROVIDER_GETENDPOINT, Some(wire_params))
6760 .await?;
6761 Ok(serde_json::from_value(_value)?)
6762 }
6763
6764 /// Adds BYOK providers and/or models to the session's registry at runtime, extending the additive registry built from the session's `providers`/`models` options. Both fields are optional, so a call may add providers only, models only, or both. Within a single call providers are registered before models, so a model may reference a provider added in the same call; across calls a model may reference any provider already registered (from session creation or a prior add). A model whose referenced provider is not registered by the end of the call is rejected. Newly added models become selectable via `model.list` / `model.switchTo` and are inherited by sub-agents spawned afterwards.
6765 ///
6766 /// Wire method: `session.provider.add`.
6767 ///
6768 /// # Parameters
6769 ///
6770 /// * `params` - BYOK providers and/or models to add to the session's registry at runtime. Both fields are optional; provide providers, models, or both.
6771 ///
6772 /// # Returns
6773 ///
6774 /// The selectable model entries synthesized for the models added by this call.
6775 ///
6776 /// <div class="warning">
6777 ///
6778 /// **Experimental.** This API is part of an experimental wire-protocol surface
6779 /// and may change or be removed in future SDK or CLI releases. Pin both the
6780 /// SDK and CLI versions if your code depends on it.
6781 ///
6782 /// </div>
6783 pub async fn add(&self, params: ProviderAddRequest) -> Result<ProviderAddResult, Error> {
6784 let mut wire_params = serde_json::to_value(params)?;
6785 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6786 let _value = self
6787 .session
6788 .client()
6789 .call(rpc_methods::SESSION_PROVIDER_ADD, Some(wire_params))
6790 .await?;
6791 Ok(serde_json::from_value(_value)?)
6792 }
6793}
6794
6795/// `session.queue.*` RPCs.
6796#[derive(Clone, Copy)]
6797pub struct SessionRpcQueue<'a> {
6798 pub(crate) session: &'a Session,
6799}
6800
6801impl<'a> SessionRpcQueue<'a> {
6802 /// Returns the local session's pending user-facing queued items and steering messages.
6803 ///
6804 /// Wire method: `session.queue.pendingItems`.
6805 ///
6806 /// # Returns
6807 ///
6808 /// Snapshot of the session's pending queued items and immediate-steering messages.
6809 ///
6810 /// <div class="warning">
6811 ///
6812 /// **Experimental.** This API is part of an experimental wire-protocol surface
6813 /// and may change or be removed in future SDK or CLI releases. Pin both the
6814 /// SDK and CLI versions if your code depends on it.
6815 ///
6816 /// </div>
6817 pub async fn pending_items(&self) -> Result<QueuePendingItemsResult, Error> {
6818 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6819 let _value = self
6820 .session
6821 .client()
6822 .call(rpc_methods::SESSION_QUEUE_PENDINGITEMS, Some(wire_params))
6823 .await?;
6824 Ok(serde_json::from_value(_value)?)
6825 }
6826
6827 /// Removes the most recently queued user-facing item (LIFO).
6828 ///
6829 /// Wire method: `session.queue.removeMostRecent`.
6830 ///
6831 /// # Returns
6832 ///
6833 /// Indicates whether a user-facing pending item was removed.
6834 ///
6835 /// <div class="warning">
6836 ///
6837 /// **Experimental.** This API is part of an experimental wire-protocol surface
6838 /// and may change or be removed in future SDK or CLI releases. Pin both the
6839 /// SDK and CLI versions if your code depends on it.
6840 ///
6841 /// </div>
6842 pub async fn remove_most_recent(&self) -> Result<QueueRemoveMostRecentResult, Error> {
6843 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6844 let _value = self
6845 .session
6846 .client()
6847 .call(
6848 rpc_methods::SESSION_QUEUE_REMOVEMOSTRECENT,
6849 Some(wire_params),
6850 )
6851 .await?;
6852 Ok(serde_json::from_value(_value)?)
6853 }
6854
6855 /// Clears all pending queued items on the local session.
6856 ///
6857 /// Wire method: `session.queue.clear`.
6858 ///
6859 /// <div class="warning">
6860 ///
6861 /// **Experimental.** This API is part of an experimental wire-protocol surface
6862 /// and may change or be removed in future SDK or CLI releases. Pin both the
6863 /// SDK and CLI versions if your code depends on it.
6864 ///
6865 /// </div>
6866 pub async fn clear(&self) -> Result<(), Error> {
6867 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6868 let _value = self
6869 .session
6870 .client()
6871 .call(rpc_methods::SESSION_QUEUE_CLEAR, Some(wire_params))
6872 .await?;
6873 Ok(())
6874 }
6875}
6876
6877/// `session.remote.*` RPCs.
6878#[derive(Clone, Copy)]
6879pub struct SessionRpcRemote<'a> {
6880 pub(crate) session: &'a Session,
6881}
6882
6883impl<'a> SessionRpcRemote<'a> {
6884 /// Enables remote session export or steering.
6885 ///
6886 /// Wire method: `session.remote.enable`.
6887 ///
6888 /// # Parameters
6889 ///
6890 /// * `params` - Optional remote session mode ("off", "export", or "on"); defaults to enabling both export and remote steering.
6891 ///
6892 /// # Returns
6893 ///
6894 /// GitHub URL for the session and a flag indicating whether remote steering is enabled.
6895 ///
6896 /// <div class="warning">
6897 ///
6898 /// **Experimental.** This API is part of an experimental wire-protocol surface
6899 /// and may change or be removed in future SDK or CLI releases. Pin both the
6900 /// SDK and CLI versions if your code depends on it.
6901 ///
6902 /// </div>
6903 pub async fn enable(&self, params: RemoteEnableRequest) -> Result<RemoteEnableResult, Error> {
6904 let mut wire_params = serde_json::to_value(params)?;
6905 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6906 let _value = self
6907 .session
6908 .client()
6909 .call(rpc_methods::SESSION_REMOTE_ENABLE, Some(wire_params))
6910 .await?;
6911 Ok(serde_json::from_value(_value)?)
6912 }
6913
6914 /// Disables remote session export and steering.
6915 ///
6916 /// Wire method: `session.remote.disable`.
6917 ///
6918 /// <div class="warning">
6919 ///
6920 /// **Experimental.** This API is part of an experimental wire-protocol surface
6921 /// and may change or be removed in future SDK or CLI releases. Pin both the
6922 /// SDK and CLI versions if your code depends on it.
6923 ///
6924 /// </div>
6925 pub async fn disable(&self) -> Result<(), Error> {
6926 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6927 let _value = self
6928 .session
6929 .client()
6930 .call(rpc_methods::SESSION_REMOTE_DISABLE, Some(wire_params))
6931 .await?;
6932 Ok(())
6933 }
6934
6935 /// Persists a remote-steerability change emitted by the host as a session event.
6936 ///
6937 /// Wire method: `session.remote.notifySteerableChanged`.
6938 ///
6939 /// # Parameters
6940 ///
6941 /// * `params` - New remote-steerability state to persist as a `session.remote_steerable_changed` event.
6942 ///
6943 /// # Returns
6944 ///
6945 /// Persist a steerability change as a `session.remote_steerable_changed` event. Used by the host (CLI / SDK consumer) when it has just finished enabling or disabling steering on a remote exporter that the runtime does not directly own.
6946 ///
6947 /// <div class="warning">
6948 ///
6949 /// **Experimental.** This API is part of an experimental wire-protocol surface
6950 /// and may change or be removed in future SDK or CLI releases. Pin both the
6951 /// SDK and CLI versions if your code depends on it.
6952 ///
6953 /// </div>
6954 pub async fn notify_steerable_changed(
6955 &self,
6956 params: RemoteNotifySteerableChangedRequest,
6957 ) -> Result<RemoteNotifySteerableChangedResult, Error> {
6958 let mut wire_params = serde_json::to_value(params)?;
6959 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6960 let _value = self
6961 .session
6962 .client()
6963 .call(
6964 rpc_methods::SESSION_REMOTE_NOTIFYSTEERABLECHANGED,
6965 Some(wire_params),
6966 )
6967 .await?;
6968 Ok(serde_json::from_value(_value)?)
6969 }
6970}
6971
6972/// `session.schedule.*` RPCs.
6973#[derive(Clone, Copy)]
6974pub struct SessionRpcSchedule<'a> {
6975 pub(crate) session: &'a Session,
6976}
6977
6978impl<'a> SessionRpcSchedule<'a> {
6979 /// Lists the session's currently active scheduled prompts.
6980 ///
6981 /// Wire method: `session.schedule.list`.
6982 ///
6983 /// # Returns
6984 ///
6985 /// Snapshot of the currently active recurring prompts for this session.
6986 ///
6987 /// <div class="warning">
6988 ///
6989 /// **Experimental.** This API is part of an experimental wire-protocol surface
6990 /// and may change or be removed in future SDK or CLI releases. Pin both the
6991 /// SDK and CLI versions if your code depends on it.
6992 ///
6993 /// </div>
6994 pub async fn list(&self) -> Result<ScheduleList, Error> {
6995 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6996 let _value = self
6997 .session
6998 .client()
6999 .call(rpc_methods::SESSION_SCHEDULE_LIST, Some(wire_params))
7000 .await?;
7001 Ok(serde_json::from_value(_value)?)
7002 }
7003
7004 /// Removes a scheduled prompt by id.
7005 ///
7006 /// Wire method: `session.schedule.stop`.
7007 ///
7008 /// # Parameters
7009 ///
7010 /// * `params` - Identifier of the scheduled prompt to remove.
7011 ///
7012 /// # Returns
7013 ///
7014 /// Remove a scheduled prompt by id. The result entry is omitted if the id was unknown.
7015 ///
7016 /// <div class="warning">
7017 ///
7018 /// **Experimental.** This API is part of an experimental wire-protocol surface
7019 /// and may change or be removed in future SDK or CLI releases. Pin both the
7020 /// SDK and CLI versions if your code depends on it.
7021 ///
7022 /// </div>
7023 pub async fn stop(&self, params: ScheduleStopRequest) -> Result<ScheduleStopResult, Error> {
7024 let mut wire_params = serde_json::to_value(params)?;
7025 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7026 let _value = self
7027 .session
7028 .client()
7029 .call(rpc_methods::SESSION_SCHEDULE_STOP, Some(wire_params))
7030 .await?;
7031 Ok(serde_json::from_value(_value)?)
7032 }
7033}
7034
7035/// `session.shell.*` RPCs.
7036#[derive(Clone, Copy)]
7037pub struct SessionRpcShell<'a> {
7038 pub(crate) session: &'a Session,
7039}
7040
7041impl<'a> SessionRpcShell<'a> {
7042 /// Starts a shell command and streams output through session notifications.
7043 ///
7044 /// Wire method: `session.shell.exec`.
7045 ///
7046 /// # Parameters
7047 ///
7048 /// * `params` - Shell command to run, with optional working directory and timeout in milliseconds.
7049 ///
7050 /// # Returns
7051 ///
7052 /// Identifier of the spawned process, used to correlate streamed output and exit notifications.
7053 ///
7054 /// <div class="warning">
7055 ///
7056 /// **Experimental.** This API is part of an experimental wire-protocol surface
7057 /// and may change or be removed in future SDK or CLI releases. Pin both the
7058 /// SDK and CLI versions if your code depends on it.
7059 ///
7060 /// </div>
7061 pub async fn exec(&self, params: ShellExecRequest) -> Result<ShellExecResult, Error> {
7062 let mut wire_params = serde_json::to_value(params)?;
7063 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7064 let _value = self
7065 .session
7066 .client()
7067 .call(rpc_methods::SESSION_SHELL_EXEC, Some(wire_params))
7068 .await?;
7069 Ok(serde_json::from_value(_value)?)
7070 }
7071
7072 /// Sends a signal to a shell process previously started via "shell.exec".
7073 ///
7074 /// Wire method: `session.shell.kill`.
7075 ///
7076 /// # Parameters
7077 ///
7078 /// * `params` - Identifier of a process previously returned by "shell.exec" and the signal to send.
7079 ///
7080 /// # Returns
7081 ///
7082 /// Indicates whether the signal was delivered; false if the process was unknown or already exited.
7083 ///
7084 /// <div class="warning">
7085 ///
7086 /// **Experimental.** This API is part of an experimental wire-protocol surface
7087 /// and may change or be removed in future SDK or CLI releases. Pin both the
7088 /// SDK and CLI versions if your code depends on it.
7089 ///
7090 /// </div>
7091 pub async fn kill(&self, params: ShellKillRequest) -> Result<ShellKillResult, Error> {
7092 let mut wire_params = serde_json::to_value(params)?;
7093 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7094 let _value = self
7095 .session
7096 .client()
7097 .call(rpc_methods::SESSION_SHELL_KILL, Some(wire_params))
7098 .await?;
7099 Ok(serde_json::from_value(_value)?)
7100 }
7101
7102 /// Executes a user-requested shell command through the session runtime.
7103 ///
7104 /// Wire method: `session.shell.executeUserRequested`.
7105 ///
7106 /// # Parameters
7107 ///
7108 /// * `params` - User-requested shell command and cancellation handle.
7109 ///
7110 /// # Returns
7111 ///
7112 /// Result of a user-requested shell command.
7113 ///
7114 /// <div class="warning">
7115 ///
7116 /// **Experimental.** This API is part of an experimental wire-protocol surface
7117 /// and may change or be removed in future SDK or CLI releases. Pin both the
7118 /// SDK and CLI versions if your code depends on it.
7119 ///
7120 /// </div>
7121 pub async fn execute_user_requested(
7122 &self,
7123 params: ShellExecuteUserRequestedRequest,
7124 ) -> Result<UserRequestedShellCommandResult, Error> {
7125 let mut wire_params = serde_json::to_value(params)?;
7126 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7127 let _value = self
7128 .session
7129 .client()
7130 .call(
7131 rpc_methods::SESSION_SHELL_EXECUTEUSERREQUESTED,
7132 Some(wire_params),
7133 )
7134 .await?;
7135 Ok(serde_json::from_value(_value)?)
7136 }
7137
7138 /// Cancels a user-requested shell command by request ID.
7139 ///
7140 /// Wire method: `session.shell.cancelUserRequested`.
7141 ///
7142 /// # Parameters
7143 ///
7144 /// * `params` - User-requested shell execution cancellation handle.
7145 ///
7146 /// # Returns
7147 ///
7148 /// Cancellation result for a user-requested shell command.
7149 ///
7150 /// <div class="warning">
7151 ///
7152 /// **Experimental.** This API is part of an experimental wire-protocol surface
7153 /// and may change or be removed in future SDK or CLI releases. Pin both the
7154 /// SDK and CLI versions if your code depends on it.
7155 ///
7156 /// </div>
7157 pub async fn cancel_user_requested(
7158 &self,
7159 params: ShellCancelUserRequestedRequest,
7160 ) -> Result<CancelUserRequestedShellCommandResult, Error> {
7161 let mut wire_params = serde_json::to_value(params)?;
7162 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7163 let _value = self
7164 .session
7165 .client()
7166 .call(
7167 rpc_methods::SESSION_SHELL_CANCELUSERREQUESTED,
7168 Some(wire_params),
7169 )
7170 .await?;
7171 Ok(serde_json::from_value(_value)?)
7172 }
7173}
7174
7175/// `session.skills.*` RPCs.
7176#[derive(Clone, Copy)]
7177pub struct SessionRpcSkills<'a> {
7178 pub(crate) session: &'a Session,
7179}
7180
7181impl<'a> SessionRpcSkills<'a> {
7182 /// Lists skills available to the session.
7183 ///
7184 /// Wire method: `session.skills.list`.
7185 ///
7186 /// # Returns
7187 ///
7188 /// Skills available to the session, with their enabled state.
7189 ///
7190 /// <div class="warning">
7191 ///
7192 /// **Experimental.** This API is part of an experimental wire-protocol surface
7193 /// and may change or be removed in future SDK or CLI releases. Pin both the
7194 /// SDK and CLI versions if your code depends on it.
7195 ///
7196 /// </div>
7197 pub async fn list(&self) -> Result<SkillList, Error> {
7198 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7199 let _value = self
7200 .session
7201 .client()
7202 .call(rpc_methods::SESSION_SKILLS_LIST, Some(wire_params))
7203 .await?;
7204 Ok(serde_json::from_value(_value)?)
7205 }
7206
7207 /// Returns the skills that have been invoked during this session.
7208 ///
7209 /// Wire method: `session.skills.getInvoked`.
7210 ///
7211 /// # Returns
7212 ///
7213 /// Skills invoked during this session, ordered by invocation time (most recent last).
7214 ///
7215 /// <div class="warning">
7216 ///
7217 /// **Experimental.** This API is part of an experimental wire-protocol surface
7218 /// and may change or be removed in future SDK or CLI releases. Pin both the
7219 /// SDK and CLI versions if your code depends on it.
7220 ///
7221 /// </div>
7222 pub async fn get_invoked(&self) -> Result<SkillsGetInvokedResult, Error> {
7223 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7224 let _value = self
7225 .session
7226 .client()
7227 .call(rpc_methods::SESSION_SKILLS_GETINVOKED, Some(wire_params))
7228 .await?;
7229 Ok(serde_json::from_value(_value)?)
7230 }
7231
7232 /// Enables a skill for the session.
7233 ///
7234 /// Wire method: `session.skills.enable`.
7235 ///
7236 /// # Parameters
7237 ///
7238 /// * `params` - Name of the skill to enable for the session.
7239 ///
7240 /// <div class="warning">
7241 ///
7242 /// **Experimental.** This API is part of an experimental wire-protocol surface
7243 /// and may change or be removed in future SDK or CLI releases. Pin both the
7244 /// SDK and CLI versions if your code depends on it.
7245 ///
7246 /// </div>
7247 pub async fn enable(&self, params: SkillsEnableRequest) -> Result<(), Error> {
7248 let mut wire_params = serde_json::to_value(params)?;
7249 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7250 let _value = self
7251 .session
7252 .client()
7253 .call(rpc_methods::SESSION_SKILLS_ENABLE, Some(wire_params))
7254 .await?;
7255 Ok(())
7256 }
7257
7258 /// Disables a skill for the session.
7259 ///
7260 /// Wire method: `session.skills.disable`.
7261 ///
7262 /// # Parameters
7263 ///
7264 /// * `params` - Name of the skill to disable for the session.
7265 ///
7266 /// <div class="warning">
7267 ///
7268 /// **Experimental.** This API is part of an experimental wire-protocol surface
7269 /// and may change or be removed in future SDK or CLI releases. Pin both the
7270 /// SDK and CLI versions if your code depends on it.
7271 ///
7272 /// </div>
7273 pub async fn disable(&self, params: SkillsDisableRequest) -> Result<(), Error> {
7274 let mut wire_params = serde_json::to_value(params)?;
7275 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7276 let _value = self
7277 .session
7278 .client()
7279 .call(rpc_methods::SESSION_SKILLS_DISABLE, Some(wire_params))
7280 .await?;
7281 Ok(())
7282 }
7283
7284 /// Reloads skill definitions for the session.
7285 ///
7286 /// Wire method: `session.skills.reload`.
7287 ///
7288 /// # Returns
7289 ///
7290 /// Diagnostics from reloading skill definitions, with warnings and errors as separate lists.
7291 ///
7292 /// <div class="warning">
7293 ///
7294 /// **Experimental.** This API is part of an experimental wire-protocol surface
7295 /// and may change or be removed in future SDK or CLI releases. Pin both the
7296 /// SDK and CLI versions if your code depends on it.
7297 ///
7298 /// </div>
7299 pub async fn reload(&self) -> Result<SkillsLoadDiagnostics, Error> {
7300 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7301 let _value = self
7302 .session
7303 .client()
7304 .call(rpc_methods::SESSION_SKILLS_RELOAD, Some(wire_params))
7305 .await?;
7306 Ok(serde_json::from_value(_value)?)
7307 }
7308
7309 /// Ensures the session's skill definitions have been loaded from disk.
7310 ///
7311 /// Wire method: `session.skills.ensureLoaded`.
7312 ///
7313 /// <div class="warning">
7314 ///
7315 /// **Experimental.** This API is part of an experimental wire-protocol surface
7316 /// and may change or be removed in future SDK or CLI releases. Pin both the
7317 /// SDK and CLI versions if your code depends on it.
7318 ///
7319 /// </div>
7320 pub async fn ensure_loaded(&self) -> Result<(), Error> {
7321 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7322 let _value = self
7323 .session
7324 .client()
7325 .call(rpc_methods::SESSION_SKILLS_ENSURELOADED, Some(wire_params))
7326 .await?;
7327 Ok(())
7328 }
7329}
7330
7331/// `session.tasks.*` RPCs.
7332#[derive(Clone, Copy)]
7333pub struct SessionRpcTasks<'a> {
7334 pub(crate) session: &'a Session,
7335}
7336
7337impl<'a> SessionRpcTasks<'a> {
7338 /// Starts a background agent task in the session.
7339 ///
7340 /// Wire method: `session.tasks.startAgent`.
7341 ///
7342 /// # Parameters
7343 ///
7344 /// * `params` - Agent type, prompt, name, and optional description and model override for the new task.
7345 ///
7346 /// # Returns
7347 ///
7348 /// Identifier assigned to the newly started background agent task.
7349 ///
7350 /// <div class="warning">
7351 ///
7352 /// **Experimental.** This API is part of an experimental wire-protocol surface
7353 /// and may change or be removed in future SDK or CLI releases. Pin both the
7354 /// SDK and CLI versions if your code depends on it.
7355 ///
7356 /// </div>
7357 pub async fn start_agent(
7358 &self,
7359 params: TasksStartAgentRequest,
7360 ) -> Result<TasksStartAgentResult, Error> {
7361 let mut wire_params = serde_json::to_value(params)?;
7362 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7363 let _value = self
7364 .session
7365 .client()
7366 .call(rpc_methods::SESSION_TASKS_STARTAGENT, Some(wire_params))
7367 .await?;
7368 Ok(serde_json::from_value(_value)?)
7369 }
7370
7371 /// Lists background tasks tracked by the session.
7372 ///
7373 /// Wire method: `session.tasks.list`.
7374 ///
7375 /// # Returns
7376 ///
7377 /// Background tasks currently tracked by the session.
7378 ///
7379 /// <div class="warning">
7380 ///
7381 /// **Experimental.** This API is part of an experimental wire-protocol surface
7382 /// and may change or be removed in future SDK or CLI releases. Pin both the
7383 /// SDK and CLI versions if your code depends on it.
7384 ///
7385 /// </div>
7386 pub async fn list(&self) -> Result<TaskList, Error> {
7387 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7388 let _value = self
7389 .session
7390 .client()
7391 .call(rpc_methods::SESSION_TASKS_LIST, Some(wire_params))
7392 .await?;
7393 Ok(serde_json::from_value(_value)?)
7394 }
7395
7396 /// Refreshes metadata for any detached background shells the runtime knows about.
7397 ///
7398 /// Wire method: `session.tasks.refresh`.
7399 ///
7400 /// # Returns
7401 ///
7402 /// Refresh metadata for any detached background shells the runtime knows about. Use after a long pause to pick up exit/output state for shells running outside the agent loop.
7403 ///
7404 /// <div class="warning">
7405 ///
7406 /// **Experimental.** This API is part of an experimental wire-protocol surface
7407 /// and may change or be removed in future SDK or CLI releases. Pin both the
7408 /// SDK and CLI versions if your code depends on it.
7409 ///
7410 /// </div>
7411 pub async fn refresh(&self) -> Result<TasksRefreshResult, Error> {
7412 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7413 let _value = self
7414 .session
7415 .client()
7416 .call(rpc_methods::SESSION_TASKS_REFRESH, Some(wire_params))
7417 .await?;
7418 Ok(serde_json::from_value(_value)?)
7419 }
7420
7421 /// Waits for all in-flight background tasks and any follow-up turns to settle.
7422 ///
7423 /// Wire method: `session.tasks.waitForPending`.
7424 ///
7425 /// # Returns
7426 ///
7427 /// Wait until all in-flight background tasks (agents + shells) and any follow-up turns scheduled by their completions have settled. Returns when the runtime is fully drained or after an internal timeout (default 10 minutes; configurable via COPILOT_TASK_WAIT_TIMEOUT_SECONDS).
7428 ///
7429 /// <div class="warning">
7430 ///
7431 /// **Experimental.** This API is part of an experimental wire-protocol surface
7432 /// and may change or be removed in future SDK or CLI releases. Pin both the
7433 /// SDK and CLI versions if your code depends on it.
7434 ///
7435 /// </div>
7436 pub async fn wait_for_pending(&self) -> Result<TasksWaitForPendingResult, Error> {
7437 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7438 let _value = self
7439 .session
7440 .client()
7441 .call(rpc_methods::SESSION_TASKS_WAITFORPENDING, Some(wire_params))
7442 .await?;
7443 Ok(serde_json::from_value(_value)?)
7444 }
7445
7446 /// Returns progress information for a background task by ID.
7447 ///
7448 /// Wire method: `session.tasks.getProgress`.
7449 ///
7450 /// # Parameters
7451 ///
7452 /// * `params` - Identifier of the background task to fetch progress for.
7453 ///
7454 /// # Returns
7455 ///
7456 /// Progress information for the task, or null when no task with that ID is tracked.
7457 ///
7458 /// <div class="warning">
7459 ///
7460 /// **Experimental.** This API is part of an experimental wire-protocol surface
7461 /// and may change or be removed in future SDK or CLI releases. Pin both the
7462 /// SDK and CLI versions if your code depends on it.
7463 ///
7464 /// </div>
7465 pub async fn get_progress(
7466 &self,
7467 params: TasksGetProgressRequest,
7468 ) -> Result<TasksGetProgressResult, Error> {
7469 let mut wire_params = serde_json::to_value(params)?;
7470 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7471 let _value = self
7472 .session
7473 .client()
7474 .call(rpc_methods::SESSION_TASKS_GETPROGRESS, Some(wire_params))
7475 .await?;
7476 Ok(serde_json::from_value(_value)?)
7477 }
7478
7479 /// Returns the first sync-waiting task that can currently be promoted to background mode.
7480 ///
7481 /// Wire method: `session.tasks.getCurrentPromotable`.
7482 ///
7483 /// # Returns
7484 ///
7485 /// The first sync-waiting task that can currently be promoted to background mode.
7486 ///
7487 /// <div class="warning">
7488 ///
7489 /// **Experimental.** This API is part of an experimental wire-protocol surface
7490 /// and may change or be removed in future SDK or CLI releases. Pin both the
7491 /// SDK and CLI versions if your code depends on it.
7492 ///
7493 /// </div>
7494 pub async fn get_current_promotable(&self) -> Result<TasksGetCurrentPromotableResult, Error> {
7495 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7496 let _value = self
7497 .session
7498 .client()
7499 .call(
7500 rpc_methods::SESSION_TASKS_GETCURRENTPROMOTABLE,
7501 Some(wire_params),
7502 )
7503 .await?;
7504 Ok(serde_json::from_value(_value)?)
7505 }
7506
7507 /// Promotes an eligible synchronously-waited task so it continues running in the background.
7508 ///
7509 /// Wire method: `session.tasks.promoteToBackground`.
7510 ///
7511 /// # Parameters
7512 ///
7513 /// * `params` - Identifier of the task to promote to background mode.
7514 ///
7515 /// # Returns
7516 ///
7517 /// Indicates whether the task was successfully promoted to background mode.
7518 ///
7519 /// <div class="warning">
7520 ///
7521 /// **Experimental.** This API is part of an experimental wire-protocol surface
7522 /// and may change or be removed in future SDK or CLI releases. Pin both the
7523 /// SDK and CLI versions if your code depends on it.
7524 ///
7525 /// </div>
7526 pub async fn promote_to_background(
7527 &self,
7528 params: TasksPromoteToBackgroundRequest,
7529 ) -> Result<TasksPromoteToBackgroundResult, Error> {
7530 let mut wire_params = serde_json::to_value(params)?;
7531 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7532 let _value = self
7533 .session
7534 .client()
7535 .call(
7536 rpc_methods::SESSION_TASKS_PROMOTETOBACKGROUND,
7537 Some(wire_params),
7538 )
7539 .await?;
7540 Ok(serde_json::from_value(_value)?)
7541 }
7542
7543 /// Atomically promotes the first promotable sync-waiting task to background mode and returns it.
7544 ///
7545 /// Wire method: `session.tasks.promoteCurrentToBackground`.
7546 ///
7547 /// # Returns
7548 ///
7549 /// The promoted task as it now exists in background mode, omitted if no promotable task was waiting.
7550 ///
7551 /// <div class="warning">
7552 ///
7553 /// **Experimental.** This API is part of an experimental wire-protocol surface
7554 /// and may change or be removed in future SDK or CLI releases. Pin both the
7555 /// SDK and CLI versions if your code depends on it.
7556 ///
7557 /// </div>
7558 pub async fn promote_current_to_background(
7559 &self,
7560 ) -> Result<TasksPromoteCurrentToBackgroundResult, Error> {
7561 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7562 let _value = self
7563 .session
7564 .client()
7565 .call(
7566 rpc_methods::SESSION_TASKS_PROMOTECURRENTTOBACKGROUND,
7567 Some(wire_params),
7568 )
7569 .await?;
7570 Ok(serde_json::from_value(_value)?)
7571 }
7572
7573 /// Cancels a background task.
7574 ///
7575 /// Wire method: `session.tasks.cancel`.
7576 ///
7577 /// # Parameters
7578 ///
7579 /// * `params` - Identifier of the background task to cancel.
7580 ///
7581 /// # Returns
7582 ///
7583 /// Indicates whether the background task was successfully cancelled.
7584 ///
7585 /// <div class="warning">
7586 ///
7587 /// **Experimental.** This API is part of an experimental wire-protocol surface
7588 /// and may change or be removed in future SDK or CLI releases. Pin both the
7589 /// SDK and CLI versions if your code depends on it.
7590 ///
7591 /// </div>
7592 pub async fn cancel(&self, params: TasksCancelRequest) -> Result<TasksCancelResult, Error> {
7593 let mut wire_params = serde_json::to_value(params)?;
7594 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7595 let _value = self
7596 .session
7597 .client()
7598 .call(rpc_methods::SESSION_TASKS_CANCEL, Some(wire_params))
7599 .await?;
7600 Ok(serde_json::from_value(_value)?)
7601 }
7602
7603 /// Removes a completed or cancelled background task from tracking.
7604 ///
7605 /// Wire method: `session.tasks.remove`.
7606 ///
7607 /// # Parameters
7608 ///
7609 /// * `params` - Identifier of the completed or cancelled task to remove from tracking.
7610 ///
7611 /// # Returns
7612 ///
7613 /// Indicates whether the task was removed. False when the task does not exist or is still running/idle.
7614 ///
7615 /// <div class="warning">
7616 ///
7617 /// **Experimental.** This API is part of an experimental wire-protocol surface
7618 /// and may change or be removed in future SDK or CLI releases. Pin both the
7619 /// SDK and CLI versions if your code depends on it.
7620 ///
7621 /// </div>
7622 pub async fn remove(&self, params: TasksRemoveRequest) -> Result<TasksRemoveResult, Error> {
7623 let mut wire_params = serde_json::to_value(params)?;
7624 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7625 let _value = self
7626 .session
7627 .client()
7628 .call(rpc_methods::SESSION_TASKS_REMOVE, Some(wire_params))
7629 .await?;
7630 Ok(serde_json::from_value(_value)?)
7631 }
7632
7633 /// Sends a message to a background agent task.
7634 ///
7635 /// Wire method: `session.tasks.sendMessage`.
7636 ///
7637 /// # Parameters
7638 ///
7639 /// * `params` - Identifier of the target agent task, message content, and optional sender agent ID.
7640 ///
7641 /// # Returns
7642 ///
7643 /// Indicates whether the message was delivered, with an error message when delivery failed.
7644 ///
7645 /// <div class="warning">
7646 ///
7647 /// **Experimental.** This API is part of an experimental wire-protocol surface
7648 /// and may change or be removed in future SDK or CLI releases. Pin both the
7649 /// SDK and CLI versions if your code depends on it.
7650 ///
7651 /// </div>
7652 pub async fn send_message(
7653 &self,
7654 params: TasksSendMessageRequest,
7655 ) -> Result<TasksSendMessageResult, Error> {
7656 let mut wire_params = serde_json::to_value(params)?;
7657 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7658 let _value = self
7659 .session
7660 .client()
7661 .call(rpc_methods::SESSION_TASKS_SENDMESSAGE, Some(wire_params))
7662 .await?;
7663 Ok(serde_json::from_value(_value)?)
7664 }
7665}
7666
7667/// `session.telemetry.*` RPCs.
7668#[derive(Clone, Copy)]
7669pub struct SessionRpcTelemetry<'a> {
7670 pub(crate) session: &'a Session,
7671}
7672
7673impl<'a> SessionRpcTelemetry<'a> {
7674 /// Gets the telemetry engagement ID currently associated with the session, when available.
7675 ///
7676 /// Wire method: `session.telemetry.getEngagementId`.
7677 ///
7678 /// # Returns
7679 ///
7680 /// Telemetry engagement ID for the session, when available.
7681 ///
7682 /// <div class="warning">
7683 ///
7684 /// **Experimental.** This API is part of an experimental wire-protocol surface
7685 /// and may change or be removed in future SDK or CLI releases. Pin both the
7686 /// SDK and CLI versions if your code depends on it.
7687 ///
7688 /// </div>
7689 pub async fn get_engagement_id(&self) -> Result<SessionTelemetryEngagement, Error> {
7690 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7691 let _value = self
7692 .session
7693 .client()
7694 .call(
7695 rpc_methods::SESSION_TELEMETRY_GETENGAGEMENTID,
7696 Some(wire_params),
7697 )
7698 .await?;
7699 Ok(serde_json::from_value(_value)?)
7700 }
7701
7702 /// Sets feature override key/value pairs to attach to subsequent telemetry events for the session.
7703 ///
7704 /// Wire method: `session.telemetry.setFeatureOverrides`.
7705 ///
7706 /// # Parameters
7707 ///
7708 /// * `params` - Feature override key/value pairs to attach to subsequent telemetry events from this session.
7709 ///
7710 /// <div class="warning">
7711 ///
7712 /// **Experimental.** This API is part of an experimental wire-protocol surface
7713 /// and may change or be removed in future SDK or CLI releases. Pin both the
7714 /// SDK and CLI versions if your code depends on it.
7715 ///
7716 /// </div>
7717 pub async fn set_feature_overrides(
7718 &self,
7719 params: TelemetrySetFeatureOverridesRequest,
7720 ) -> Result<(), Error> {
7721 let mut wire_params = serde_json::to_value(params)?;
7722 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7723 let _value = self
7724 .session
7725 .client()
7726 .call(
7727 rpc_methods::SESSION_TELEMETRY_SETFEATUREOVERRIDES,
7728 Some(wire_params),
7729 )
7730 .await?;
7731 Ok(())
7732 }
7733}
7734
7735/// `session.tools.*` RPCs.
7736#[derive(Clone, Copy)]
7737pub struct SessionRpcTools<'a> {
7738 pub(crate) session: &'a Session,
7739}
7740
7741impl<'a> SessionRpcTools<'a> {
7742 /// Provides the result for a pending external tool call.
7743 ///
7744 /// Wire method: `session.tools.handlePendingToolCall`.
7745 ///
7746 /// # Parameters
7747 ///
7748 /// * `params` - Pending external tool call request ID, with the tool result or an error describing why it failed.
7749 ///
7750 /// # Returns
7751 ///
7752 /// Indicates whether the external tool call result was handled successfully.
7753 ///
7754 /// <div class="warning">
7755 ///
7756 /// **Experimental.** This API is part of an experimental wire-protocol surface
7757 /// and may change or be removed in future SDK or CLI releases. Pin both the
7758 /// SDK and CLI versions if your code depends on it.
7759 ///
7760 /// </div>
7761 pub async fn handle_pending_tool_call(
7762 &self,
7763 params: HandlePendingToolCallRequest,
7764 ) -> Result<HandlePendingToolCallResult, Error> {
7765 let mut wire_params = serde_json::to_value(params)?;
7766 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7767 let _value = self
7768 .session
7769 .client()
7770 .call(
7771 rpc_methods::SESSION_TOOLS_HANDLEPENDINGTOOLCALL,
7772 Some(wire_params),
7773 )
7774 .await?;
7775 Ok(serde_json::from_value(_value)?)
7776 }
7777
7778 /// Resolves, builds, and validates the runtime tool list for the session.
7779 ///
7780 /// Wire method: `session.tools.initializeAndValidate`.
7781 ///
7782 /// # Returns
7783 ///
7784 /// Resolve, build, and validate the runtime tool list for this session. Subagent sessions and consumer flows that need an initialized tool set before `send` invoke this. Default base-class implementation is a no-op for sessions that don't support tool validation.
7785 ///
7786 /// <div class="warning">
7787 ///
7788 /// **Experimental.** This API is part of an experimental wire-protocol surface
7789 /// and may change or be removed in future SDK or CLI releases. Pin both the
7790 /// SDK and CLI versions if your code depends on it.
7791 ///
7792 /// </div>
7793 pub async fn initialize_and_validate(&self) -> Result<ToolsInitializeAndValidateResult, Error> {
7794 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7795 let _value = self
7796 .session
7797 .client()
7798 .call(
7799 rpc_methods::SESSION_TOOLS_INITIALIZEANDVALIDATE,
7800 Some(wire_params),
7801 )
7802 .await?;
7803 Ok(serde_json::from_value(_value)?)
7804 }
7805
7806 /// Returns lightweight metadata for the session's currently initialized tools.
7807 ///
7808 /// Wire method: `session.tools.getCurrentMetadata`.
7809 ///
7810 /// # Returns
7811 ///
7812 /// Current lightweight tool metadata snapshot for the session.
7813 ///
7814 /// <div class="warning">
7815 ///
7816 /// **Experimental.** This API is part of an experimental wire-protocol surface
7817 /// and may change or be removed in future SDK or CLI releases. Pin both the
7818 /// SDK and CLI versions if your code depends on it.
7819 ///
7820 /// </div>
7821 pub async fn get_current_metadata(&self) -> Result<ToolsGetCurrentMetadataResult, Error> {
7822 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7823 let _value = self
7824 .session
7825 .client()
7826 .call(
7827 rpc_methods::SESSION_TOOLS_GETCURRENTMETADATA,
7828 Some(wire_params),
7829 )
7830 .await?;
7831 Ok(serde_json::from_value(_value)?)
7832 }
7833
7834 /// Updates the current session's live subagent settings after user settings change. The persisted user settings remain the source of truth for future sessions.
7835 ///
7836 /// Wire method: `session.tools.updateSubagentSettings`.
7837 ///
7838 /// # Parameters
7839 ///
7840 /// * `params` - Subagent settings to apply to the current session
7841 ///
7842 /// # Returns
7843 ///
7844 /// Empty result after applying subagent settings
7845 ///
7846 /// <div class="warning">
7847 ///
7848 /// **Experimental.** This API is part of an experimental wire-protocol surface
7849 /// and may change or be removed in future SDK or CLI releases. Pin both the
7850 /// SDK and CLI versions if your code depends on it.
7851 ///
7852 /// </div>
7853 pub async fn update_subagent_settings(
7854 &self,
7855 params: UpdateSubagentSettingsRequest,
7856 ) -> Result<ToolsUpdateSubagentSettingsResult, Error> {
7857 let mut wire_params = serde_json::to_value(params)?;
7858 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7859 let _value = self
7860 .session
7861 .client()
7862 .call(
7863 rpc_methods::SESSION_TOOLS_UPDATESUBAGENTSETTINGS,
7864 Some(wire_params),
7865 )
7866 .await?;
7867 Ok(serde_json::from_value(_value)?)
7868 }
7869}
7870
7871/// `session.ui.*` RPCs.
7872#[derive(Clone, Copy)]
7873pub struct SessionRpcUi<'a> {
7874 pub(crate) session: &'a Session,
7875}
7876
7877impl<'a> SessionRpcUi<'a> {
7878 /// Runs a transient no-tools model query against the current conversation context.
7879 ///
7880 /// Wire method: `session.ui.ephemeralQuery`.
7881 ///
7882 /// # Parameters
7883 ///
7884 /// * `params` - Transient question to answer without adding it to conversation history.
7885 ///
7886 /// # Returns
7887 ///
7888 /// Transient answer generated from current conversation context.
7889 ///
7890 /// <div class="warning">
7891 ///
7892 /// **Experimental.** This API is part of an experimental wire-protocol surface
7893 /// and may change or be removed in future SDK or CLI releases. Pin both the
7894 /// SDK and CLI versions if your code depends on it.
7895 ///
7896 /// </div>
7897 pub async fn ephemeral_query(
7898 &self,
7899 params: UIEphemeralQueryRequest,
7900 ) -> Result<UIEphemeralQueryResult, Error> {
7901 let mut wire_params = serde_json::to_value(params)?;
7902 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7903 let _value = self
7904 .session
7905 .client()
7906 .call(rpc_methods::SESSION_UI_EPHEMERALQUERY, Some(wire_params))
7907 .await?;
7908 Ok(serde_json::from_value(_value)?)
7909 }
7910
7911 /// Requests structured input from a UI-capable client.
7912 ///
7913 /// Wire method: `session.ui.elicitation`.
7914 ///
7915 /// # Parameters
7916 ///
7917 /// * `params` - Prompt message and JSON schema describing the form fields to elicit from the user.
7918 ///
7919 /// # Returns
7920 ///
7921 /// The elicitation response (accept with form values, decline, or cancel)
7922 ///
7923 /// <div class="warning">
7924 ///
7925 /// **Experimental.** This API is part of an experimental wire-protocol surface
7926 /// and may change or be removed in future SDK or CLI releases. Pin both the
7927 /// SDK and CLI versions if your code depends on it.
7928 ///
7929 /// </div>
7930 pub async fn elicitation(
7931 &self,
7932 params: UIElicitationRequest,
7933 ) -> Result<UIElicitationResponse, Error> {
7934 let mut wire_params = serde_json::to_value(params)?;
7935 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7936 let _value = self
7937 .session
7938 .client()
7939 .call(rpc_methods::SESSION_UI_ELICITATION, Some(wire_params))
7940 .await?;
7941 Ok(serde_json::from_value(_value)?)
7942 }
7943
7944 /// Provides the user response for a pending elicitation request.
7945 ///
7946 /// Wire method: `session.ui.handlePendingElicitation`.
7947 ///
7948 /// # Parameters
7949 ///
7950 /// * `params` - Pending elicitation request ID and the user's response (accept/decline/cancel + form values).
7951 ///
7952 /// # Returns
7953 ///
7954 /// Indicates whether the elicitation response was accepted; false if it was already resolved by another client.
7955 ///
7956 /// <div class="warning">
7957 ///
7958 /// **Experimental.** This API is part of an experimental wire-protocol surface
7959 /// and may change or be removed in future SDK or CLI releases. Pin both the
7960 /// SDK and CLI versions if your code depends on it.
7961 ///
7962 /// </div>
7963 pub async fn handle_pending_elicitation(
7964 &self,
7965 params: UIHandlePendingElicitationRequest,
7966 ) -> Result<UIElicitationResult, Error> {
7967 let mut wire_params = serde_json::to_value(params)?;
7968 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7969 let _value = self
7970 .session
7971 .client()
7972 .call(
7973 rpc_methods::SESSION_UI_HANDLEPENDINGELICITATION,
7974 Some(wire_params),
7975 )
7976 .await?;
7977 Ok(serde_json::from_value(_value)?)
7978 }
7979
7980 /// Resolves a pending `user_input.requested` event with the user's response.
7981 ///
7982 /// Wire method: `session.ui.handlePendingUserInput`.
7983 ///
7984 /// # Parameters
7985 ///
7986 /// * `params` - Request ID of a pending `user_input.requested` event and the user's response.
7987 ///
7988 /// # Returns
7989 ///
7990 /// Indicates whether the pending UI request was resolved by this call.
7991 ///
7992 /// <div class="warning">
7993 ///
7994 /// **Experimental.** This API is part of an experimental wire-protocol surface
7995 /// and may change or be removed in future SDK or CLI releases. Pin both the
7996 /// SDK and CLI versions if your code depends on it.
7997 ///
7998 /// </div>
7999 pub async fn handle_pending_user_input(
8000 &self,
8001 params: UIHandlePendingUserInputRequest,
8002 ) -> Result<UIHandlePendingResult, Error> {
8003 let mut wire_params = serde_json::to_value(params)?;
8004 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8005 let _value = self
8006 .session
8007 .client()
8008 .call(
8009 rpc_methods::SESSION_UI_HANDLEPENDINGUSERINPUT,
8010 Some(wire_params),
8011 )
8012 .await?;
8013 Ok(serde_json::from_value(_value)?)
8014 }
8015
8016 /// Resolves a pending `sampling.requested` event with a sampling result, or rejects it.
8017 ///
8018 /// Wire method: `session.ui.handlePendingSampling`.
8019 ///
8020 /// # Parameters
8021 ///
8022 /// * `params` - Request ID of a pending `sampling.requested` event and an optional sampling result payload (omit to reject).
8023 ///
8024 /// # Returns
8025 ///
8026 /// Indicates whether the pending UI request was resolved by this call.
8027 ///
8028 /// <div class="warning">
8029 ///
8030 /// **Experimental.** This API is part of an experimental wire-protocol surface
8031 /// and may change or be removed in future SDK or CLI releases. Pin both the
8032 /// SDK and CLI versions if your code depends on it.
8033 ///
8034 /// </div>
8035 pub async fn handle_pending_sampling(
8036 &self,
8037 params: UIHandlePendingSamplingRequest,
8038 ) -> Result<UIHandlePendingResult, Error> {
8039 let mut wire_params = serde_json::to_value(params)?;
8040 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8041 let _value = self
8042 .session
8043 .client()
8044 .call(
8045 rpc_methods::SESSION_UI_HANDLEPENDINGSAMPLING,
8046 Some(wire_params),
8047 )
8048 .await?;
8049 Ok(serde_json::from_value(_value)?)
8050 }
8051
8052 /// Resolves a pending `auto_mode_switch.requested` event with the user's accept/decline decision.
8053 ///
8054 /// Wire method: `session.ui.handlePendingAutoModeSwitch`.
8055 ///
8056 /// # Parameters
8057 ///
8058 /// * `params` - Request ID of a pending `auto_mode_switch.requested` event and the user's response.
8059 ///
8060 /// # Returns
8061 ///
8062 /// Indicates whether the pending UI request was resolved by this call.
8063 ///
8064 /// <div class="warning">
8065 ///
8066 /// **Experimental.** This API is part of an experimental wire-protocol surface
8067 /// and may change or be removed in future SDK or CLI releases. Pin both the
8068 /// SDK and CLI versions if your code depends on it.
8069 ///
8070 /// </div>
8071 pub async fn handle_pending_auto_mode_switch(
8072 &self,
8073 params: UIHandlePendingAutoModeSwitchRequest,
8074 ) -> Result<UIHandlePendingResult, Error> {
8075 let mut wire_params = serde_json::to_value(params)?;
8076 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8077 let _value = self
8078 .session
8079 .client()
8080 .call(
8081 rpc_methods::SESSION_UI_HANDLEPENDINGAUTOMODESWITCH,
8082 Some(wire_params),
8083 )
8084 .await?;
8085 Ok(serde_json::from_value(_value)?)
8086 }
8087
8088 /// Resolves a pending `session_limits_exhausted.requested` event with the user's selected limit action.
8089 ///
8090 /// Wire method: `session.ui.handlePendingSessionLimitsExhausted`.
8091 ///
8092 /// # Parameters
8093 ///
8094 /// * `params` - Request ID of a pending `session_limits_exhausted.requested` event and the user's selected limit action.
8095 ///
8096 /// # Returns
8097 ///
8098 /// Indicates whether the pending UI request was resolved by this call.
8099 ///
8100 /// <div class="warning">
8101 ///
8102 /// **Experimental.** This API is part of an experimental wire-protocol surface
8103 /// and may change or be removed in future SDK or CLI releases. Pin both the
8104 /// SDK and CLI versions if your code depends on it.
8105 ///
8106 /// </div>
8107 pub async fn handle_pending_session_limits_exhausted(
8108 &self,
8109 params: UIHandlePendingSessionLimitsExhaustedRequest,
8110 ) -> Result<UIHandlePendingResult, Error> {
8111 let mut wire_params = serde_json::to_value(params)?;
8112 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8113 let _value = self
8114 .session
8115 .client()
8116 .call(
8117 rpc_methods::SESSION_UI_HANDLEPENDINGSESSIONLIMITSEXHAUSTED,
8118 Some(wire_params),
8119 )
8120 .await?;
8121 Ok(serde_json::from_value(_value)?)
8122 }
8123
8124 /// Resolves a pending `exit_plan_mode.requested` event with the user's response.
8125 ///
8126 /// Wire method: `session.ui.handlePendingExitPlanMode`.
8127 ///
8128 /// # Parameters
8129 ///
8130 /// * `params` - Request ID of a pending `exit_plan_mode.requested` event and the user's response.
8131 ///
8132 /// # Returns
8133 ///
8134 /// Indicates whether the pending UI request was resolved by this call.
8135 ///
8136 /// <div class="warning">
8137 ///
8138 /// **Experimental.** This API is part of an experimental wire-protocol surface
8139 /// and may change or be removed in future SDK or CLI releases. Pin both the
8140 /// SDK and CLI versions if your code depends on it.
8141 ///
8142 /// </div>
8143 pub async fn handle_pending_exit_plan_mode(
8144 &self,
8145 params: UIHandlePendingExitPlanModeRequest,
8146 ) -> Result<UIHandlePendingResult, Error> {
8147 let mut wire_params = serde_json::to_value(params)?;
8148 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8149 let _value = self
8150 .session
8151 .client()
8152 .call(
8153 rpc_methods::SESSION_UI_HANDLEPENDINGEXITPLANMODE,
8154 Some(wire_params),
8155 )
8156 .await?;
8157 Ok(serde_json::from_value(_value)?)
8158 }
8159
8160 /// Registers an in-process handler for auto-mode-switch requests so the server bridge skips dispatch.
8161 ///
8162 /// Wire method: `session.ui.registerDirectAutoModeSwitchHandler`.
8163 ///
8164 /// # Returns
8165 ///
8166 /// Register an in-process handler for `auto_mode_switch.requested` events. The caller still attaches the actual listener via the standard event-subscription mechanism; this registration solely tells the server bridge to skip its own dispatch (so a remote client doesn't race the in-process handler for the same requestId).
8167 ///
8168 /// <div class="warning">
8169 ///
8170 /// **Experimental.** This API is part of an experimental wire-protocol surface
8171 /// and may change or be removed in future SDK or CLI releases. Pin both the
8172 /// SDK and CLI versions if your code depends on it.
8173 ///
8174 /// </div>
8175 pub async fn register_direct_auto_mode_switch_handler(
8176 &self,
8177 ) -> Result<UIRegisterDirectAutoModeSwitchHandlerResult, Error> {
8178 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8179 let _value = self
8180 .session
8181 .client()
8182 .call(
8183 rpc_methods::SESSION_UI_REGISTERDIRECTAUTOMODESWITCHHANDLER,
8184 Some(wire_params),
8185 )
8186 .await?;
8187 Ok(serde_json::from_value(_value)?)
8188 }
8189
8190 /// Unregisters a previously-registered in-process auto-mode-switch handler by its opaque handle.
8191 ///
8192 /// Wire method: `session.ui.unregisterDirectAutoModeSwitchHandler`.
8193 ///
8194 /// # Parameters
8195 ///
8196 /// * `params` - Opaque handle previously returned by `registerDirectAutoModeSwitchHandler` to release.
8197 ///
8198 /// # Returns
8199 ///
8200 /// Indicates whether the handle was active and the registration count was decremented.
8201 ///
8202 /// <div class="warning">
8203 ///
8204 /// **Experimental.** This API is part of an experimental wire-protocol surface
8205 /// and may change or be removed in future SDK or CLI releases. Pin both the
8206 /// SDK and CLI versions if your code depends on it.
8207 ///
8208 /// </div>
8209 pub async fn unregister_direct_auto_mode_switch_handler(
8210 &self,
8211 params: UIUnregisterDirectAutoModeSwitchHandlerRequest,
8212 ) -> Result<UIUnregisterDirectAutoModeSwitchHandlerResult, Error> {
8213 let mut wire_params = serde_json::to_value(params)?;
8214 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8215 let _value = self
8216 .session
8217 .client()
8218 .call(
8219 rpc_methods::SESSION_UI_UNREGISTERDIRECTAUTOMODESWITCHHANDLER,
8220 Some(wire_params),
8221 )
8222 .await?;
8223 Ok(serde_json::from_value(_value)?)
8224 }
8225}
8226
8227/// `session.usage.*` RPCs.
8228#[derive(Clone, Copy)]
8229pub struct SessionRpcUsage<'a> {
8230 pub(crate) session: &'a Session,
8231}
8232
8233impl<'a> SessionRpcUsage<'a> {
8234 /// Gets accumulated usage metrics for the session.
8235 ///
8236 /// Wire method: `session.usage.getMetrics`.
8237 ///
8238 /// # Returns
8239 ///
8240 /// Accumulated session usage metrics, including premium request cost, token counts, model breakdown, and code-change totals.
8241 ///
8242 /// <div class="warning">
8243 ///
8244 /// **Experimental.** This API is part of an experimental wire-protocol surface
8245 /// and may change or be removed in future SDK or CLI releases. Pin both the
8246 /// SDK and CLI versions if your code depends on it.
8247 ///
8248 /// </div>
8249 pub async fn get_metrics(&self) -> Result<UsageGetMetricsResult, Error> {
8250 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8251 let _value = self
8252 .session
8253 .client()
8254 .call(rpc_methods::SESSION_USAGE_GETMETRICS, Some(wire_params))
8255 .await?;
8256 Ok(serde_json::from_value(_value)?)
8257 }
8258}
8259
8260/// `session.visibility.*` RPCs.
8261#[derive(Clone, Copy)]
8262pub struct SessionRpcVisibility<'a> {
8263 pub(crate) session: &'a Session,
8264}
8265
8266impl<'a> SessionRpcVisibility<'a> {
8267 /// Returns the session's current Mission Control sharing status and shareable GitHub URL. Reflects whether the synced session is visible to repository readers ("repo") or restricted to its creator and collaborators ("unshared").
8268 ///
8269 /// Wire method: `session.visibility.get`.
8270 ///
8271 /// # Returns
8272 ///
8273 /// Current sharing status and shareable GitHub URL for a session.
8274 ///
8275 /// <div class="warning">
8276 ///
8277 /// **Experimental.** This API is part of an experimental wire-protocol surface
8278 /// and may change or be removed in future SDK or CLI releases. Pin both the
8279 /// SDK and CLI versions if your code depends on it.
8280 ///
8281 /// </div>
8282 pub async fn get(&self) -> Result<VisibilityGetResult, Error> {
8283 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8284 let _value = self
8285 .session
8286 .client()
8287 .call(rpc_methods::SESSION_VISIBILITY_GET, Some(wire_params))
8288 .await?;
8289 Ok(serde_json::from_value(_value)?)
8290 }
8291
8292 /// Sets the session's Mission Control sharing status, controlling whether the synced session is visible to repository readers. Returns the effective status and shareable GitHub URL after the change.
8293 ///
8294 /// Wire method: `session.visibility.set`.
8295 ///
8296 /// # Parameters
8297 ///
8298 /// * `params` - Desired sharing status for the session.
8299 ///
8300 /// # Returns
8301 ///
8302 /// Effective sharing status and shareable GitHub URL after updating session visibility.
8303 ///
8304 /// <div class="warning">
8305 ///
8306 /// **Experimental.** This API is part of an experimental wire-protocol surface
8307 /// and may change or be removed in future SDK or CLI releases. Pin both the
8308 /// SDK and CLI versions if your code depends on it.
8309 ///
8310 /// </div>
8311 pub async fn set(&self, params: VisibilitySetRequest) -> Result<VisibilitySetResult, Error> {
8312 let mut wire_params = serde_json::to_value(params)?;
8313 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8314 let _value = self
8315 .session
8316 .client()
8317 .call(rpc_methods::SESSION_VISIBILITY_SET, Some(wire_params))
8318 .await?;
8319 Ok(serde_json::from_value(_value)?)
8320 }
8321}
8322
8323/// `session.workspaces.*` RPCs.
8324#[derive(Clone, Copy)]
8325pub struct SessionRpcWorkspaces<'a> {
8326 pub(crate) session: &'a Session,
8327}
8328
8329impl<'a> SessionRpcWorkspaces<'a> {
8330 /// Gets current workspace metadata for the session.
8331 ///
8332 /// Wire method: `session.workspaces.getWorkspace`.
8333 ///
8334 /// # Returns
8335 ///
8336 /// Current workspace metadata for the session, including its absolute filesystem path when available.
8337 ///
8338 /// <div class="warning">
8339 ///
8340 /// **Experimental.** This API is part of an experimental wire-protocol surface
8341 /// and may change or be removed in future SDK or CLI releases. Pin both the
8342 /// SDK and CLI versions if your code depends on it.
8343 ///
8344 /// </div>
8345 pub async fn get_workspace(&self) -> Result<WorkspacesGetWorkspaceResult, Error> {
8346 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8347 let _value = self
8348 .session
8349 .client()
8350 .call(
8351 rpc_methods::SESSION_WORKSPACES_GETWORKSPACE,
8352 Some(wire_params),
8353 )
8354 .await?;
8355 Ok(serde_json::from_value(_value)?)
8356 }
8357
8358 /// Lists files stored in the session workspace files directory.
8359 ///
8360 /// Wire method: `session.workspaces.listFiles`.
8361 ///
8362 /// # Returns
8363 ///
8364 /// Relative paths of files stored in the session workspace files directory.
8365 ///
8366 /// <div class="warning">
8367 ///
8368 /// **Experimental.** This API is part of an experimental wire-protocol surface
8369 /// and may change or be removed in future SDK or CLI releases. Pin both the
8370 /// SDK and CLI versions if your code depends on it.
8371 ///
8372 /// </div>
8373 pub async fn list_files(&self) -> Result<WorkspacesListFilesResult, Error> {
8374 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8375 let _value = self
8376 .session
8377 .client()
8378 .call(rpc_methods::SESSION_WORKSPACES_LISTFILES, Some(wire_params))
8379 .await?;
8380 Ok(serde_json::from_value(_value)?)
8381 }
8382
8383 /// Reads a file from the session workspace files directory.
8384 ///
8385 /// Wire method: `session.workspaces.readFile`.
8386 ///
8387 /// # Parameters
8388 ///
8389 /// * `params` - Relative path of the workspace file to read.
8390 ///
8391 /// # Returns
8392 ///
8393 /// Contents of the requested workspace file as a UTF-8 string.
8394 ///
8395 /// <div class="warning">
8396 ///
8397 /// **Experimental.** This API is part of an experimental wire-protocol surface
8398 /// and may change or be removed in future SDK or CLI releases. Pin both the
8399 /// SDK and CLI versions if your code depends on it.
8400 ///
8401 /// </div>
8402 pub async fn read_file(
8403 &self,
8404 params: WorkspacesReadFileRequest,
8405 ) -> Result<WorkspacesReadFileResult, Error> {
8406 let mut wire_params = serde_json::to_value(params)?;
8407 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8408 let _value = self
8409 .session
8410 .client()
8411 .call(rpc_methods::SESSION_WORKSPACES_READFILE, Some(wire_params))
8412 .await?;
8413 Ok(serde_json::from_value(_value)?)
8414 }
8415
8416 /// Creates or overwrites a file in the session workspace files directory.
8417 ///
8418 /// Wire method: `session.workspaces.createFile`.
8419 ///
8420 /// # Parameters
8421 ///
8422 /// * `params` - Relative path and UTF-8 content for the workspace file to create or overwrite.
8423 ///
8424 /// <div class="warning">
8425 ///
8426 /// **Experimental.** This API is part of an experimental wire-protocol surface
8427 /// and may change or be removed in future SDK or CLI releases. Pin both the
8428 /// SDK and CLI versions if your code depends on it.
8429 ///
8430 /// </div>
8431 pub async fn create_file(&self, params: WorkspacesCreateFileRequest) -> Result<(), Error> {
8432 let mut wire_params = serde_json::to_value(params)?;
8433 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8434 let _value = self
8435 .session
8436 .client()
8437 .call(
8438 rpc_methods::SESSION_WORKSPACES_CREATEFILE,
8439 Some(wire_params),
8440 )
8441 .await?;
8442 Ok(())
8443 }
8444
8445 /// Lists workspace checkpoints in chronological order.
8446 ///
8447 /// Wire method: `session.workspaces.listCheckpoints`.
8448 ///
8449 /// # Returns
8450 ///
8451 /// Workspace checkpoints in chronological order; empty when the workspace is not enabled.
8452 ///
8453 /// <div class="warning">
8454 ///
8455 /// **Experimental.** This API is part of an experimental wire-protocol surface
8456 /// and may change or be removed in future SDK or CLI releases. Pin both the
8457 /// SDK and CLI versions if your code depends on it.
8458 ///
8459 /// </div>
8460 pub async fn list_checkpoints(&self) -> Result<WorkspacesListCheckpointsResult, Error> {
8461 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8462 let _value = self
8463 .session
8464 .client()
8465 .call(
8466 rpc_methods::SESSION_WORKSPACES_LISTCHECKPOINTS,
8467 Some(wire_params),
8468 )
8469 .await?;
8470 Ok(serde_json::from_value(_value)?)
8471 }
8472
8473 /// Reads the content of a workspace checkpoint by number.
8474 ///
8475 /// Wire method: `session.workspaces.readCheckpoint`.
8476 ///
8477 /// # Parameters
8478 ///
8479 /// * `params` - Checkpoint number to read.
8480 ///
8481 /// # Returns
8482 ///
8483 /// Checkpoint content as a UTF-8 string, or null when the checkpoint or workspace is missing.
8484 ///
8485 /// <div class="warning">
8486 ///
8487 /// **Experimental.** This API is part of an experimental wire-protocol surface
8488 /// and may change or be removed in future SDK or CLI releases. Pin both the
8489 /// SDK and CLI versions if your code depends on it.
8490 ///
8491 /// </div>
8492 pub async fn read_checkpoint(
8493 &self,
8494 params: WorkspacesReadCheckpointRequest,
8495 ) -> Result<WorkspacesReadCheckpointResult, Error> {
8496 let mut wire_params = serde_json::to_value(params)?;
8497 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8498 let _value = self
8499 .session
8500 .client()
8501 .call(
8502 rpc_methods::SESSION_WORKSPACES_READCHECKPOINT,
8503 Some(wire_params),
8504 )
8505 .await?;
8506 Ok(serde_json::from_value(_value)?)
8507 }
8508
8509 /// Saves pasted content as a UTF-8 file in the session workspace.
8510 ///
8511 /// Wire method: `session.workspaces.saveLargePaste`.
8512 ///
8513 /// # Parameters
8514 ///
8515 /// * `params` - Pasted content to save as a UTF-8 file in the session workspace.
8516 ///
8517 /// # Returns
8518 ///
8519 /// Descriptor for the saved paste file, or null when the workspace is unavailable.
8520 ///
8521 /// <div class="warning">
8522 ///
8523 /// **Experimental.** This API is part of an experimental wire-protocol surface
8524 /// and may change or be removed in future SDK or CLI releases. Pin both the
8525 /// SDK and CLI versions if your code depends on it.
8526 ///
8527 /// </div>
8528 pub async fn save_large_paste(
8529 &self,
8530 params: WorkspacesSaveLargePasteRequest,
8531 ) -> Result<WorkspacesSaveLargePasteResult, Error> {
8532 let mut wire_params = serde_json::to_value(params)?;
8533 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8534 let _value = self
8535 .session
8536 .client()
8537 .call(
8538 rpc_methods::SESSION_WORKSPACES_SAVELARGEPASTE,
8539 Some(wire_params),
8540 )
8541 .await?;
8542 Ok(serde_json::from_value(_value)?)
8543 }
8544
8545 /// Computes a diff for the session workspace.
8546 ///
8547 /// Wire method: `session.workspaces.diff`.
8548 ///
8549 /// # Parameters
8550 ///
8551 /// * `params` - Parameters for computing a workspace diff.
8552 ///
8553 /// # Returns
8554 ///
8555 /// Workspace diff result for the requested mode.
8556 ///
8557 /// <div class="warning">
8558 ///
8559 /// **Experimental.** This API is part of an experimental wire-protocol surface
8560 /// and may change or be removed in future SDK or CLI releases. Pin both the
8561 /// SDK and CLI versions if your code depends on it.
8562 ///
8563 /// </div>
8564 pub async fn diff(&self, params: WorkspacesDiffRequest) -> Result<WorkspaceDiffResult, Error> {
8565 let mut wire_params = serde_json::to_value(params)?;
8566 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8567 let _value = self
8568 .session
8569 .client()
8570 .call(rpc_methods::SESSION_WORKSPACES_DIFF, Some(wire_params))
8571 .await?;
8572 Ok(serde_json::from_value(_value)?)
8573 }
8574}