Skip to main content

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    /// Cursor-based long-poll for sessions spawned by the runtime (e.g. in response to a Mission Control `start_session` command). The cursor is an opaque token; pass it back to receive only spawn events that occurred AFTER the cursor was issued. Omit the cursor on the first call to receive any events buffered since the runtime started. Internal: this is a CLI background-daemon plumbing primitive. SDK consumers that need to react to runtime-spawned sessions should subscribe to a higher-level event stream rather than driving a long-poll loop.
2238    ///
2239    /// Wire method: `sessions.pollSpawnedSessions`.
2240    ///
2241    /// # Returns
2242    ///
2243    /// Batch of spawn events plus a cursor for follow-up polls.
2244    ///
2245    /// <div class="warning">
2246    ///
2247    /// **Experimental.** This API is part of an experimental wire-protocol surface
2248    /// and may change or be removed in future SDK or CLI releases. Pin both the
2249    /// SDK and CLI versions if your code depends on it.
2250    ///
2251    /// </div>
2252    pub(crate) async fn poll_spawned_sessions(&self) -> Result<PollSpawnedSessionsResult, Error> {
2253        let wire_params = serde_json::json!({});
2254        let _value = self
2255            .client
2256            .call(rpc_methods::SESSIONS_POLLSPAWNEDSESSIONS, Some(wire_params))
2257            .await?;
2258        Ok(serde_json::from_value(_value)?)
2259    }
2260
2261    /// Cursor-based long-poll for sessions spawned by the runtime (e.g. in response to a Mission Control `start_session` command). The cursor is an opaque token; pass it back to receive only spawn events that occurred AFTER the cursor was issued. Omit the cursor on the first call to receive any events buffered since the runtime started. Internal: this is a CLI background-daemon plumbing primitive. SDK consumers that need to react to runtime-spawned sessions should subscribe to a higher-level event stream rather than driving a long-poll loop.
2262    ///
2263    /// Wire method: `sessions.pollSpawnedSessions`.
2264    ///
2265    /// # Parameters
2266    ///
2267    /// * `params` - Cursor and optional long-poll wait for polling runtime-spawned sessions.
2268    ///
2269    /// # Returns
2270    ///
2271    /// Batch of spawn events plus a cursor for follow-up polls.
2272    ///
2273    /// <div class="warning">
2274    ///
2275    /// **Experimental.** This API is part of an experimental wire-protocol surface
2276    /// and may change or be removed in future SDK or CLI releases. Pin both the
2277    /// SDK and CLI versions if your code depends on it.
2278    ///
2279    /// </div>
2280    pub(crate) async fn poll_spawned_sessions_with_params(
2281        &self,
2282        params: SessionsPollSpawnedSessionsRequest,
2283    ) -> Result<PollSpawnedSessionsResult, Error> {
2284        let wire_params = serde_json::to_value(params)?;
2285        let _value = self
2286            .client
2287            .call(rpc_methods::SESSIONS_POLLSPAWNEDSESSIONS, Some(wire_params))
2288            .await?;
2289        Ok(serde_json::from_value(_value)?)
2290    }
2291
2292    /// 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.
2293    ///
2294    /// Wire method: `sessions.registerExtensionToolsOnSession`.
2295    ///
2296    /// # Parameters
2297    ///
2298    /// * `params` - Params to attach an extension loader's tools to a session.
2299    ///
2300    /// # Returns
2301    ///
2302    /// Handle for releasing the extension tool registration.
2303    ///
2304    /// <div class="warning">
2305    ///
2306    /// **Experimental.** This API is part of an experimental wire-protocol surface
2307    /// and may change or be removed in future SDK or CLI releases. Pin both the
2308    /// SDK and CLI versions if your code depends on it.
2309    ///
2310    /// </div>
2311    pub(crate) async fn register_extension_tools_on_session(
2312        &self,
2313        params: RegisterExtensionToolsParams,
2314    ) -> Result<RegisterExtensionToolsResult, Error> {
2315        let wire_params = serde_json::to_value(params)?;
2316        let _value = self
2317            .client
2318            .call(
2319                rpc_methods::SESSIONS_REGISTEREXTENSIONTOOLSONSESSION,
2320                Some(wire_params),
2321            )
2322            .await?;
2323        Ok(serde_json::from_value(_value)?)
2324    }
2325
2326    /// 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.
2327    ///
2328    /// Wire method: `sessions.configureSessionExtensions`.
2329    ///
2330    /// # Parameters
2331    ///
2332    /// * `params` - Params to attach or detach an in-process ExtensionController delegate.
2333    ///
2334    /// <div class="warning">
2335    ///
2336    /// **Experimental.** This API is part of an experimental wire-protocol surface
2337    /// and may change or be removed in future SDK or CLI releases. Pin both the
2338    /// SDK and CLI versions if your code depends on it.
2339    ///
2340    /// </div>
2341    pub(crate) async fn configure_session_extensions(
2342        &self,
2343        params: ConfigureSessionExtensionsParams,
2344    ) -> Result<(), Error> {
2345        let wire_params = serde_json::to_value(params)?;
2346        let _value = self
2347            .client
2348            .call(
2349                rpc_methods::SESSIONS_CONFIGURESESSIONEXTENSIONS,
2350                Some(wire_params),
2351            )
2352            .await?;
2353        Ok(())
2354    }
2355}
2356
2357/// `skills.*` RPCs.
2358#[derive(Clone, Copy)]
2359pub struct ClientRpcSkills<'a> {
2360    pub(crate) client: &'a Client,
2361}
2362
2363impl<'a> ClientRpcSkills<'a> {
2364    /// `skills.config.*` sub-namespace.
2365    pub fn config(&self) -> ClientRpcSkillsConfig<'a> {
2366        ClientRpcSkillsConfig {
2367            client: self.client,
2368        }
2369    }
2370
2371    /// Discovers skills across global and project sources.
2372    ///
2373    /// Wire method: `skills.discover`.
2374    ///
2375    /// # Parameters
2376    ///
2377    /// * `params` - Optional project paths and additional skill directories to include in discovery.
2378    ///
2379    /// # Returns
2380    ///
2381    /// Skills discovered across global and project sources.
2382    ///
2383    /// <div class="warning">
2384    ///
2385    /// **Experimental.** This API is part of an experimental wire-protocol surface
2386    /// and may change or be removed in future SDK or CLI releases. Pin both the
2387    /// SDK and CLI versions if your code depends on it.
2388    ///
2389    /// </div>
2390    pub async fn discover(&self, params: SkillsDiscoverRequest) -> Result<ServerSkillList, Error> {
2391        let wire_params = serde_json::to_value(params)?;
2392        let _value = self
2393            .client
2394            .call(rpc_methods::SKILLS_DISCOVER, Some(wire_params))
2395            .await?;
2396        Ok(serde_json::from_value(_value)?)
2397    }
2398
2399    /// 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.
2400    ///
2401    /// Wire method: `skills.getDiscoveryPaths`.
2402    ///
2403    /// # Parameters
2404    ///
2405    /// * `params` - Optional project paths to enumerate.
2406    ///
2407    /// # Returns
2408    ///
2409    /// Canonical locations where skills can be created so the runtime will recognize them.
2410    ///
2411    /// <div class="warning">
2412    ///
2413    /// **Experimental.** This API is part of an experimental wire-protocol surface
2414    /// and may change or be removed in future SDK or CLI releases. Pin both the
2415    /// SDK and CLI versions if your code depends on it.
2416    ///
2417    /// </div>
2418    pub async fn get_discovery_paths(
2419        &self,
2420        params: SkillsGetDiscoveryPathsRequest,
2421    ) -> Result<SkillDiscoveryPathList, Error> {
2422        let wire_params = serde_json::to_value(params)?;
2423        let _value = self
2424            .client
2425            .call(rpc_methods::SKILLS_GETDISCOVERYPATHS, Some(wire_params))
2426            .await?;
2427        Ok(serde_json::from_value(_value)?)
2428    }
2429}
2430
2431/// `skills.config.*` RPCs.
2432#[derive(Clone, Copy)]
2433pub struct ClientRpcSkillsConfig<'a> {
2434    pub(crate) client: &'a Client,
2435}
2436
2437impl<'a> ClientRpcSkillsConfig<'a> {
2438    /// Replaces the global list of disabled skills.
2439    ///
2440    /// Wire method: `skills.config.setDisabledSkills`.
2441    ///
2442    /// # Parameters
2443    ///
2444    /// * `params` - Skill names to mark as disabled in global configuration, replacing any previous list.
2445    ///
2446    /// <div class="warning">
2447    ///
2448    /// **Experimental.** This API is part of an experimental wire-protocol surface
2449    /// and may change or be removed in future SDK or CLI releases. Pin both the
2450    /// SDK and CLI versions if your code depends on it.
2451    ///
2452    /// </div>
2453    pub async fn set_disabled_skills(
2454        &self,
2455        params: SkillsConfigSetDisabledSkillsRequest,
2456    ) -> Result<(), Error> {
2457        let wire_params = serde_json::to_value(params)?;
2458        let _value = self
2459            .client
2460            .call(
2461                rpc_methods::SKILLS_CONFIG_SETDISABLEDSKILLS,
2462                Some(wire_params),
2463            )
2464            .await?;
2465        Ok(())
2466    }
2467}
2468
2469/// `tools.*` RPCs.
2470#[derive(Clone, Copy)]
2471pub struct ClientRpcTools<'a> {
2472    pub(crate) client: &'a Client,
2473}
2474
2475impl<'a> ClientRpcTools<'a> {
2476    /// Lists built-in tools available for a model.
2477    ///
2478    /// Wire method: `tools.list`.
2479    ///
2480    /// # Parameters
2481    ///
2482    /// * `params` - Optional model identifier whose tool overrides should be applied to the listing.
2483    ///
2484    /// # Returns
2485    ///
2486    /// Built-in tools available for the requested model, with their parameters and instructions.
2487    ///
2488    /// <div class="warning">
2489    ///
2490    /// **Experimental.** This API is part of an experimental wire-protocol surface
2491    /// and may change or be removed in future SDK or CLI releases. Pin both the
2492    /// SDK and CLI versions if your code depends on it.
2493    ///
2494    /// </div>
2495    pub async fn list(&self, params: ToolsListRequest) -> Result<ToolList, Error> {
2496        let wire_params = serde_json::to_value(params)?;
2497        let _value = self
2498            .client
2499            .call(rpc_methods::TOOLS_LIST, Some(wire_params))
2500            .await?;
2501        Ok(serde_json::from_value(_value)?)
2502    }
2503}
2504
2505/// `user.*` RPCs.
2506#[derive(Clone, Copy)]
2507pub struct ClientRpcUser<'a> {
2508    pub(crate) client: &'a Client,
2509}
2510
2511impl<'a> ClientRpcUser<'a> {
2512    /// `user.settings.*` sub-namespace.
2513    pub fn settings(&self) -> ClientRpcUserSettings<'a> {
2514        ClientRpcUserSettings {
2515            client: self.client,
2516        }
2517    }
2518}
2519
2520/// `user.settings.*` RPCs.
2521#[derive(Clone, Copy)]
2522pub struct ClientRpcUserSettings<'a> {
2523    pub(crate) client: &'a Client,
2524}
2525
2526impl<'a> ClientRpcUserSettings<'a> {
2527    /// Drops this runtime process's in-memory user settings cache so the next settings read observes disk.
2528    ///
2529    /// Wire method: `user.settings.reload`.
2530    ///
2531    /// <div class="warning">
2532    ///
2533    /// **Experimental.** This API is part of an experimental wire-protocol surface
2534    /// and may change or be removed in future SDK or CLI releases. Pin both the
2535    /// SDK and CLI versions if your code depends on it.
2536    ///
2537    /// </div>
2538    pub async fn reload(&self) -> Result<(), Error> {
2539        let wire_params = serde_json::json!({});
2540        let _value = self
2541            .client
2542            .call(rpc_methods::USER_SETTINGS_RELOAD, Some(wire_params))
2543            .await?;
2544        Ok(())
2545    }
2546
2547    /// 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.
2548    ///
2549    /// Wire method: `user.settings.get`.
2550    ///
2551    /// # Returns
2552    ///
2553    /// 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.
2554    ///
2555    /// <div class="warning">
2556    ///
2557    /// **Experimental.** This API is part of an experimental wire-protocol surface
2558    /// and may change or be removed in future SDK or CLI releases. Pin both the
2559    /// SDK and CLI versions if your code depends on it.
2560    ///
2561    /// </div>
2562    pub async fn get(&self) -> Result<UserSettingsGetResult, Error> {
2563        let wire_params = serde_json::json!({});
2564        let _value = self
2565            .client
2566            .call(rpc_methods::USER_SETTINGS_GET, Some(wire_params))
2567            .await?;
2568        Ok(serde_json::from_value(_value)?)
2569    }
2570
2571    /// 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.
2572    ///
2573    /// Wire method: `user.settings.set`.
2574    ///
2575    /// # Parameters
2576    ///
2577    /// * `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.
2578    ///
2579    /// # Returns
2580    ///
2581    /// Outcome of writing user settings.
2582    ///
2583    /// <div class="warning">
2584    ///
2585    /// **Experimental.** This API is part of an experimental wire-protocol surface
2586    /// and may change or be removed in future SDK or CLI releases. Pin both the
2587    /// SDK and CLI versions if your code depends on it.
2588    ///
2589    /// </div>
2590    pub async fn set(
2591        &self,
2592        params: UserSettingsSetRequest,
2593    ) -> Result<UserSettingsSetResult, Error> {
2594        let wire_params = serde_json::to_value(params)?;
2595        let _value = self
2596            .client
2597            .call(rpc_methods::USER_SETTINGS_SET, Some(wire_params))
2598            .await?;
2599        Ok(serde_json::from_value(_value)?)
2600    }
2601}
2602
2603/// Typed view over a [`Session`]'s RPC namespace.
2604#[derive(Clone, Copy)]
2605pub struct SessionRpc<'a> {
2606    pub(crate) session: &'a Session,
2607}
2608
2609impl<'a> SessionRpc<'a> {
2610    /// `session.agent.*` sub-namespace.
2611    pub fn agent(&self) -> SessionRpcAgent<'a> {
2612        SessionRpcAgent {
2613            session: self.session,
2614        }
2615    }
2616
2617    /// `session.canvas.*` sub-namespace.
2618    pub fn canvas(&self) -> SessionRpcCanvas<'a> {
2619        SessionRpcCanvas {
2620            session: self.session,
2621        }
2622    }
2623
2624    /// `session.commands.*` sub-namespace.
2625    pub fn commands(&self) -> SessionRpcCommands<'a> {
2626        SessionRpcCommands {
2627            session: self.session,
2628        }
2629    }
2630
2631    /// `session.completions.*` sub-namespace.
2632    pub fn completions(&self) -> SessionRpcCompletions<'a> {
2633        SessionRpcCompletions {
2634            session: self.session,
2635        }
2636    }
2637
2638    /// `session.eventLog.*` sub-namespace.
2639    pub fn event_log(&self) -> SessionRpcEventLog<'a> {
2640        SessionRpcEventLog {
2641            session: self.session,
2642        }
2643    }
2644
2645    /// `session.extensions.*` sub-namespace.
2646    pub fn extensions(&self) -> SessionRpcExtensions<'a> {
2647        SessionRpcExtensions {
2648            session: self.session,
2649        }
2650    }
2651
2652    /// `session.fleet.*` sub-namespace.
2653    pub fn fleet(&self) -> SessionRpcFleet<'a> {
2654        SessionRpcFleet {
2655            session: self.session,
2656        }
2657    }
2658
2659    /// `session.gitHubAuth.*` sub-namespace.
2660    pub fn git_hub_auth(&self) -> SessionRpcGitHubAuth<'a> {
2661        SessionRpcGitHubAuth {
2662            session: self.session,
2663        }
2664    }
2665
2666    /// `session.history.*` sub-namespace.
2667    pub fn history(&self) -> SessionRpcHistory<'a> {
2668        SessionRpcHistory {
2669            session: self.session,
2670        }
2671    }
2672
2673    /// `session.instructions.*` sub-namespace.
2674    pub fn instructions(&self) -> SessionRpcInstructions<'a> {
2675        SessionRpcInstructions {
2676            session: self.session,
2677        }
2678    }
2679
2680    /// `session.lsp.*` sub-namespace.
2681    pub fn lsp(&self) -> SessionRpcLsp<'a> {
2682        SessionRpcLsp {
2683            session: self.session,
2684        }
2685    }
2686
2687    /// `session.mcp.*` sub-namespace.
2688    pub fn mcp(&self) -> SessionRpcMcp<'a> {
2689        SessionRpcMcp {
2690            session: self.session,
2691        }
2692    }
2693
2694    /// `session.metadata.*` sub-namespace.
2695    pub fn metadata(&self) -> SessionRpcMetadata<'a> {
2696        SessionRpcMetadata {
2697            session: self.session,
2698        }
2699    }
2700
2701    /// `session.mode.*` sub-namespace.
2702    pub fn mode(&self) -> SessionRpcMode<'a> {
2703        SessionRpcMode {
2704            session: self.session,
2705        }
2706    }
2707
2708    /// `session.model.*` sub-namespace.
2709    pub fn model(&self) -> SessionRpcModel<'a> {
2710        SessionRpcModel {
2711            session: self.session,
2712        }
2713    }
2714
2715    /// `session.name.*` sub-namespace.
2716    pub fn name(&self) -> SessionRpcName<'a> {
2717        SessionRpcName {
2718            session: self.session,
2719        }
2720    }
2721
2722    /// `session.options.*` sub-namespace.
2723    pub fn options(&self) -> SessionRpcOptions<'a> {
2724        SessionRpcOptions {
2725            session: self.session,
2726        }
2727    }
2728
2729    /// `session.permissions.*` sub-namespace.
2730    pub fn permissions(&self) -> SessionRpcPermissions<'a> {
2731        SessionRpcPermissions {
2732            session: self.session,
2733        }
2734    }
2735
2736    /// `session.plan.*` sub-namespace.
2737    pub fn plan(&self) -> SessionRpcPlan<'a> {
2738        SessionRpcPlan {
2739            session: self.session,
2740        }
2741    }
2742
2743    /// `session.plugins.*` sub-namespace.
2744    pub fn plugins(&self) -> SessionRpcPlugins<'a> {
2745        SessionRpcPlugins {
2746            session: self.session,
2747        }
2748    }
2749
2750    /// `session.provider.*` sub-namespace.
2751    pub fn provider(&self) -> SessionRpcProvider<'a> {
2752        SessionRpcProvider {
2753            session: self.session,
2754        }
2755    }
2756
2757    /// `session.queue.*` sub-namespace.
2758    pub fn queue(&self) -> SessionRpcQueue<'a> {
2759        SessionRpcQueue {
2760            session: self.session,
2761        }
2762    }
2763
2764    /// `session.remote.*` sub-namespace.
2765    pub fn remote(&self) -> SessionRpcRemote<'a> {
2766        SessionRpcRemote {
2767            session: self.session,
2768        }
2769    }
2770
2771    /// `session.schedule.*` sub-namespace.
2772    pub fn schedule(&self) -> SessionRpcSchedule<'a> {
2773        SessionRpcSchedule {
2774            session: self.session,
2775        }
2776    }
2777
2778    /// `session.shell.*` sub-namespace.
2779    pub fn shell(&self) -> SessionRpcShell<'a> {
2780        SessionRpcShell {
2781            session: self.session,
2782        }
2783    }
2784
2785    /// `session.skills.*` sub-namespace.
2786    pub fn skills(&self) -> SessionRpcSkills<'a> {
2787        SessionRpcSkills {
2788            session: self.session,
2789        }
2790    }
2791
2792    /// `session.tasks.*` sub-namespace.
2793    pub fn tasks(&self) -> SessionRpcTasks<'a> {
2794        SessionRpcTasks {
2795            session: self.session,
2796        }
2797    }
2798
2799    /// `session.telemetry.*` sub-namespace.
2800    pub fn telemetry(&self) -> SessionRpcTelemetry<'a> {
2801        SessionRpcTelemetry {
2802            session: self.session,
2803        }
2804    }
2805
2806    /// `session.tools.*` sub-namespace.
2807    pub fn tools(&self) -> SessionRpcTools<'a> {
2808        SessionRpcTools {
2809            session: self.session,
2810        }
2811    }
2812
2813    /// `session.ui.*` sub-namespace.
2814    pub fn ui(&self) -> SessionRpcUi<'a> {
2815        SessionRpcUi {
2816            session: self.session,
2817        }
2818    }
2819
2820    /// `session.usage.*` sub-namespace.
2821    pub fn usage(&self) -> SessionRpcUsage<'a> {
2822        SessionRpcUsage {
2823            session: self.session,
2824        }
2825    }
2826
2827    /// `session.visibility.*` sub-namespace.
2828    pub fn visibility(&self) -> SessionRpcVisibility<'a> {
2829        SessionRpcVisibility {
2830            session: self.session,
2831        }
2832    }
2833
2834    /// `session.workspaces.*` sub-namespace.
2835    pub fn workspaces(&self) -> SessionRpcWorkspaces<'a> {
2836        SessionRpcWorkspaces {
2837            session: self.session,
2838        }
2839    }
2840
2841    /// Suspends the session while preserving persisted state for later resume.
2842    ///
2843    /// Wire method: `session.suspend`.
2844    ///
2845    /// <div class="warning">
2846    ///
2847    /// **Experimental.** This API is part of an experimental wire-protocol surface
2848    /// and may change or be removed in future SDK or CLI releases. Pin both the
2849    /// SDK and CLI versions if your code depends on it.
2850    ///
2851    /// </div>
2852    pub async fn suspend(&self) -> Result<(), Error> {
2853        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
2854        let _value = self
2855            .session
2856            .client()
2857            .call(rpc_methods::SESSION_SUSPEND, Some(wire_params))
2858            .await?;
2859        Ok(())
2860    }
2861
2862    /// Sends a user message to the session and returns its message ID.
2863    ///
2864    /// Wire method: `session.send`.
2865    ///
2866    /// # Parameters
2867    ///
2868    /// * `params` - Parameters for sending a user message to the session
2869    ///
2870    /// # Returns
2871    ///
2872    /// Result of sending a user message
2873    ///
2874    /// <div class="warning">
2875    ///
2876    /// **Experimental.** This API is part of an experimental wire-protocol surface
2877    /// and may change or be removed in future SDK or CLI releases. Pin both the
2878    /// SDK and CLI versions if your code depends on it.
2879    ///
2880    /// </div>
2881    pub async fn send(&self, params: SendRequest) -> Result<SendResult, Error> {
2882        let mut wire_params = serde_json::to_value(params)?;
2883        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
2884        let _value = self
2885            .session
2886            .client()
2887            .call(rpc_methods::SESSION_SEND, Some(wire_params))
2888            .await?;
2889        Ok(serde_json::from_value(_value)?)
2890    }
2891
2892    /// Aborts the current agent turn.
2893    ///
2894    /// Wire method: `session.abort`.
2895    ///
2896    /// # Parameters
2897    ///
2898    /// * `params` - Parameters for aborting the current turn
2899    ///
2900    /// # Returns
2901    ///
2902    /// Result of aborting the current turn
2903    ///
2904    /// <div class="warning">
2905    ///
2906    /// **Experimental.** This API is part of an experimental wire-protocol surface
2907    /// and may change or be removed in future SDK or CLI releases. Pin both the
2908    /// SDK and CLI versions if your code depends on it.
2909    ///
2910    /// </div>
2911    pub async fn abort(&self, params: AbortRequest) -> Result<AbortResult, Error> {
2912        let mut wire_params = serde_json::to_value(params)?;
2913        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
2914        let _value = self
2915            .session
2916            .client()
2917            .call(rpc_methods::SESSION_ABORT, Some(wire_params))
2918            .await?;
2919        Ok(serde_json::from_value(_value)?)
2920    }
2921
2922    /// 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.
2923    ///
2924    /// Wire method: `session.shutdown`.
2925    ///
2926    /// # Parameters
2927    ///
2928    /// * `params` - Parameters for shutting down the session
2929    ///
2930    /// <div class="warning">
2931    ///
2932    /// **Experimental.** This API is part of an experimental wire-protocol surface
2933    /// and may change or be removed in future SDK or CLI releases. Pin both the
2934    /// SDK and CLI versions if your code depends on it.
2935    ///
2936    /// </div>
2937    pub async fn shutdown(&self, params: ShutdownRequest) -> Result<(), Error> {
2938        let mut wire_params = serde_json::to_value(params)?;
2939        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
2940        let _value = self
2941            .session
2942            .client()
2943            .call(rpc_methods::SESSION_SHUTDOWN, Some(wire_params))
2944            .await?;
2945        Ok(())
2946    }
2947
2948    /// Emits a user-visible session log event.
2949    ///
2950    /// Wire method: `session.log`.
2951    ///
2952    /// # Parameters
2953    ///
2954    /// * `params` - Message text, optional severity level, persistence flag, optional follow-up URL, and optional tip.
2955    ///
2956    /// # Returns
2957    ///
2958    /// Identifier of the session event that was emitted for the log message.
2959    ///
2960    /// <div class="warning">
2961    ///
2962    /// **Experimental.** This API is part of an experimental wire-protocol surface
2963    /// and may change or be removed in future SDK or CLI releases. Pin both the
2964    /// SDK and CLI versions if your code depends on it.
2965    ///
2966    /// </div>
2967    pub async fn log(&self, params: LogRequest) -> Result<LogResult, Error> {
2968        let mut wire_params = serde_json::to_value(params)?;
2969        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
2970        let _value = self
2971            .session
2972            .client()
2973            .call(rpc_methods::SESSION_LOG, Some(wire_params))
2974            .await?;
2975        Ok(serde_json::from_value(_value)?)
2976    }
2977}
2978
2979/// `session.agent.*` RPCs.
2980#[derive(Clone, Copy)]
2981pub struct SessionRpcAgent<'a> {
2982    pub(crate) session: &'a Session,
2983}
2984
2985impl<'a> SessionRpcAgent<'a> {
2986    /// Lists custom agents available to the session.
2987    ///
2988    /// Wire method: `session.agent.list`.
2989    ///
2990    /// # Returns
2991    ///
2992    /// Custom agents available to the session.
2993    ///
2994    /// <div class="warning">
2995    ///
2996    /// **Experimental.** This API is part of an experimental wire-protocol surface
2997    /// and may change or be removed in future SDK or CLI releases. Pin both the
2998    /// SDK and CLI versions if your code depends on it.
2999    ///
3000    /// </div>
3001    pub async fn list(&self) -> Result<AgentList, Error> {
3002        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3003        let _value = self
3004            .session
3005            .client()
3006            .call(rpc_methods::SESSION_AGENT_LIST, Some(wire_params))
3007            .await?;
3008        Ok(serde_json::from_value(_value)?)
3009    }
3010
3011    /// Gets the currently selected custom agent for the session.
3012    ///
3013    /// Wire method: `session.agent.getCurrent`.
3014    ///
3015    /// # Returns
3016    ///
3017    /// The currently selected custom agent, or null when using the default agent.
3018    ///
3019    /// <div class="warning">
3020    ///
3021    /// **Experimental.** This API is part of an experimental wire-protocol surface
3022    /// and may change or be removed in future SDK or CLI releases. Pin both the
3023    /// SDK and CLI versions if your code depends on it.
3024    ///
3025    /// </div>
3026    pub async fn get_current(&self) -> Result<AgentGetCurrentResult, Error> {
3027        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3028        let _value = self
3029            .session
3030            .client()
3031            .call(rpc_methods::SESSION_AGENT_GETCURRENT, Some(wire_params))
3032            .await?;
3033        Ok(serde_json::from_value(_value)?)
3034    }
3035
3036    /// Selects a custom agent for subsequent turns in the session.
3037    ///
3038    /// Wire method: `session.agent.select`.
3039    ///
3040    /// # Parameters
3041    ///
3042    /// * `params` - Name of the custom agent to select for subsequent turns.
3043    ///
3044    /// # Returns
3045    ///
3046    /// The newly selected custom agent.
3047    ///
3048    /// <div class="warning">
3049    ///
3050    /// **Experimental.** This API is part of an experimental wire-protocol surface
3051    /// and may change or be removed in future SDK or CLI releases. Pin both the
3052    /// SDK and CLI versions if your code depends on it.
3053    ///
3054    /// </div>
3055    pub async fn select(&self, params: AgentSelectRequest) -> Result<AgentSelectResult, Error> {
3056        let mut wire_params = serde_json::to_value(params)?;
3057        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3058        let _value = self
3059            .session
3060            .client()
3061            .call(rpc_methods::SESSION_AGENT_SELECT, Some(wire_params))
3062            .await?;
3063        Ok(serde_json::from_value(_value)?)
3064    }
3065
3066    /// Clears the selected custom agent and returns the session to the default agent.
3067    ///
3068    /// Wire method: `session.agent.deselect`.
3069    ///
3070    /// <div class="warning">
3071    ///
3072    /// **Experimental.** This API is part of an experimental wire-protocol surface
3073    /// and may change or be removed in future SDK or CLI releases. Pin both the
3074    /// SDK and CLI versions if your code depends on it.
3075    ///
3076    /// </div>
3077    pub async fn deselect(&self) -> Result<(), Error> {
3078        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3079        let _value = self
3080            .session
3081            .client()
3082            .call(rpc_methods::SESSION_AGENT_DESELECT, Some(wire_params))
3083            .await?;
3084        Ok(())
3085    }
3086
3087    /// Reloads custom agent definitions and returns the refreshed list.
3088    ///
3089    /// Wire method: `session.agent.reload`.
3090    ///
3091    /// # Returns
3092    ///
3093    /// Custom agents available to the session after reloading definitions from disk.
3094    ///
3095    /// <div class="warning">
3096    ///
3097    /// **Experimental.** This API is part of an experimental wire-protocol surface
3098    /// and may change or be removed in future SDK or CLI releases. Pin both the
3099    /// SDK and CLI versions if your code depends on it.
3100    ///
3101    /// </div>
3102    pub async fn reload(&self) -> Result<AgentReloadResult, Error> {
3103        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3104        let _value = self
3105            .session
3106            .client()
3107            .call(rpc_methods::SESSION_AGENT_RELOAD, Some(wire_params))
3108            .await?;
3109        Ok(serde_json::from_value(_value)?)
3110    }
3111}
3112
3113/// `session.canvas.*` RPCs.
3114#[derive(Clone, Copy)]
3115pub struct SessionRpcCanvas<'a> {
3116    pub(crate) session: &'a Session,
3117}
3118
3119impl<'a> SessionRpcCanvas<'a> {
3120    /// `session.canvas.action.*` sub-namespace.
3121    pub fn action(&self) -> SessionRpcCanvasAction<'a> {
3122        SessionRpcCanvasAction {
3123            session: self.session,
3124        }
3125    }
3126
3127    /// Lists canvases declared for the session.
3128    ///
3129    /// Wire method: `session.canvas.list`.
3130    ///
3131    /// # Returns
3132    ///
3133    /// Declared canvases available in this session.
3134    ///
3135    /// <div class="warning">
3136    ///
3137    /// **Experimental.** This API is part of an experimental wire-protocol surface
3138    /// and may change or be removed in future SDK or CLI releases. Pin both the
3139    /// SDK and CLI versions if your code depends on it.
3140    ///
3141    /// </div>
3142    pub async fn list(&self) -> Result<CanvasList, Error> {
3143        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3144        let _value = self
3145            .session
3146            .client()
3147            .call(rpc_methods::SESSION_CANVAS_LIST, Some(wire_params))
3148            .await?;
3149        Ok(serde_json::from_value(_value)?)
3150    }
3151
3152    /// Lists currently open canvas instances for the live session.
3153    ///
3154    /// Wire method: `session.canvas.listOpen`.
3155    ///
3156    /// # Returns
3157    ///
3158    /// Live open-canvas snapshot.
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 list_open(&self) -> Result<CanvasListOpenResult, Error> {
3168        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3169        let _value = self
3170            .session
3171            .client()
3172            .call(rpc_methods::SESSION_CANVAS_LISTOPEN, Some(wire_params))
3173            .await?;
3174        Ok(serde_json::from_value(_value)?)
3175    }
3176
3177    /// Opens or focuses a canvas instance.
3178    ///
3179    /// Wire method: `session.canvas.open`.
3180    ///
3181    /// # Parameters
3182    ///
3183    /// * `params` - Canvas open parameters.
3184    ///
3185    /// # Returns
3186    ///
3187    /// Open canvas instance snapshot.
3188    ///
3189    /// <div class="warning">
3190    ///
3191    /// **Experimental.** This API is part of an experimental wire-protocol surface
3192    /// and may change or be removed in future SDK or CLI releases. Pin both the
3193    /// SDK and CLI versions if your code depends on it.
3194    ///
3195    /// </div>
3196    pub async fn open(&self, params: CanvasOpenRequest) -> Result<OpenCanvasInstance, Error> {
3197        let mut wire_params = serde_json::to_value(params)?;
3198        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3199        let _value = self
3200            .session
3201            .client()
3202            .call(rpc_methods::SESSION_CANVAS_OPEN, Some(wire_params))
3203            .await?;
3204        Ok(serde_json::from_value(_value)?)
3205    }
3206
3207    /// Closes an open canvas instance.
3208    ///
3209    /// Wire method: `session.canvas.close`.
3210    ///
3211    /// # Parameters
3212    ///
3213    /// * `params` - Canvas close parameters.
3214    ///
3215    /// <div class="warning">
3216    ///
3217    /// **Experimental.** This API is part of an experimental wire-protocol surface
3218    /// and may change or be removed in future SDK or CLI releases. Pin both the
3219    /// SDK and CLI versions if your code depends on it.
3220    ///
3221    /// </div>
3222    pub async fn close(&self, params: CanvasCloseRequest) -> Result<(), Error> {
3223        let mut wire_params = serde_json::to_value(params)?;
3224        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3225        let _value = self
3226            .session
3227            .client()
3228            .call(rpc_methods::SESSION_CANVAS_CLOSE, Some(wire_params))
3229            .await?;
3230        Ok(())
3231    }
3232}
3233
3234/// `session.canvas.action.*` RPCs.
3235#[derive(Clone, Copy)]
3236pub struct SessionRpcCanvasAction<'a> {
3237    pub(crate) session: &'a Session,
3238}
3239
3240impl<'a> SessionRpcCanvasAction<'a> {
3241    /// Invokes an action on an open canvas instance.
3242    ///
3243    /// Wire method: `session.canvas.action.invoke`.
3244    ///
3245    /// # Parameters
3246    ///
3247    /// * `params` - Canvas action invocation parameters.
3248    ///
3249    /// # Returns
3250    ///
3251    /// Canvas action invocation result.
3252    ///
3253    /// <div class="warning">
3254    ///
3255    /// **Experimental.** This API is part of an experimental wire-protocol surface
3256    /// and may change or be removed in future SDK or CLI releases. Pin both the
3257    /// SDK and CLI versions if your code depends on it.
3258    ///
3259    /// </div>
3260    pub async fn invoke(
3261        &self,
3262        params: CanvasActionInvokeRequest,
3263    ) -> Result<CanvasActionInvokeResult, Error> {
3264        let mut wire_params = serde_json::to_value(params)?;
3265        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3266        let _value = self
3267            .session
3268            .client()
3269            .call(rpc_methods::SESSION_CANVAS_ACTION_INVOKE, Some(wire_params))
3270            .await?;
3271        Ok(serde_json::from_value(_value)?)
3272    }
3273}
3274
3275/// `session.commands.*` RPCs.
3276#[derive(Clone, Copy)]
3277pub struct SessionRpcCommands<'a> {
3278    pub(crate) session: &'a Session,
3279}
3280
3281impl<'a> SessionRpcCommands<'a> {
3282    /// Lists slash commands available in the session.
3283    ///
3284    /// Wire method: `session.commands.list`.
3285    ///
3286    /// # Returns
3287    ///
3288    /// Slash commands available in the session, after applying any include/exclude filters.
3289    ///
3290    /// <div class="warning">
3291    ///
3292    /// **Experimental.** This API is part of an experimental wire-protocol surface
3293    /// and may change or be removed in future SDK or CLI releases. Pin both the
3294    /// SDK and CLI versions if your code depends on it.
3295    ///
3296    /// </div>
3297    pub async fn list(&self) -> Result<CommandList, Error> {
3298        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3299        let _value = self
3300            .session
3301            .client()
3302            .call(rpc_methods::SESSION_COMMANDS_LIST, Some(wire_params))
3303            .await?;
3304        Ok(serde_json::from_value(_value)?)
3305    }
3306
3307    /// Lists slash commands available in the session.
3308    ///
3309    /// Wire method: `session.commands.list`.
3310    ///
3311    /// # Parameters
3312    ///
3313    /// * `params` - Optional filters controlling which command sources to include in the listing.
3314    ///
3315    /// # Returns
3316    ///
3317    /// Slash commands available in the session, after applying any include/exclude filters.
3318    ///
3319    /// <div class="warning">
3320    ///
3321    /// **Experimental.** This API is part of an experimental wire-protocol surface
3322    /// and may change or be removed in future SDK or CLI releases. Pin both the
3323    /// SDK and CLI versions if your code depends on it.
3324    ///
3325    /// </div>
3326    pub async fn list_with_params(
3327        &self,
3328        params: CommandsListRequest,
3329    ) -> Result<CommandList, Error> {
3330        let mut wire_params = serde_json::to_value(params)?;
3331        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3332        let _value = self
3333            .session
3334            .client()
3335            .call(rpc_methods::SESSION_COMMANDS_LIST, Some(wire_params))
3336            .await?;
3337        Ok(serde_json::from_value(_value)?)
3338    }
3339
3340    /// Invokes a slash command in the session.
3341    ///
3342    /// Wire method: `session.commands.invoke`.
3343    ///
3344    /// # Parameters
3345    ///
3346    /// * `params` - Slash command name and optional raw input string to invoke.
3347    ///
3348    /// # Returns
3349    ///
3350    /// Result of invoking the slash command (text output, prompt to send to the agent, completion, or subcommand selection).
3351    ///
3352    /// <div class="warning">
3353    ///
3354    /// **Experimental.** This API is part of an experimental wire-protocol surface
3355    /// and may change or be removed in future SDK or CLI releases. Pin both the
3356    /// SDK and CLI versions if your code depends on it.
3357    ///
3358    /// </div>
3359    pub async fn invoke(
3360        &self,
3361        params: CommandsInvokeRequest,
3362    ) -> Result<SlashCommandInvocationResult, Error> {
3363        let mut wire_params = serde_json::to_value(params)?;
3364        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3365        let _value = self
3366            .session
3367            .client()
3368            .call(rpc_methods::SESSION_COMMANDS_INVOKE, Some(wire_params))
3369            .await?;
3370        Ok(serde_json::from_value(_value)?)
3371    }
3372
3373    /// Reports completion of a pending client-handled slash command.
3374    ///
3375    /// Wire method: `session.commands.handlePendingCommand`.
3376    ///
3377    /// # Parameters
3378    ///
3379    /// * `params` - Pending command request ID and an optional error if the client handler failed.
3380    ///
3381    /// # Returns
3382    ///
3383    /// Indicates whether the pending client-handled command was completed successfully.
3384    ///
3385    /// <div class="warning">
3386    ///
3387    /// **Experimental.** This API is part of an experimental wire-protocol surface
3388    /// and may change or be removed in future SDK or CLI releases. Pin both the
3389    /// SDK and CLI versions if your code depends on it.
3390    ///
3391    /// </div>
3392    pub async fn handle_pending_command(
3393        &self,
3394        params: CommandsHandlePendingCommandRequest,
3395    ) -> Result<CommandsHandlePendingCommandResult, Error> {
3396        let mut wire_params = serde_json::to_value(params)?;
3397        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3398        let _value = self
3399            .session
3400            .client()
3401            .call(
3402                rpc_methods::SESSION_COMMANDS_HANDLEPENDINGCOMMAND,
3403                Some(wire_params),
3404            )
3405            .await?;
3406        Ok(serde_json::from_value(_value)?)
3407    }
3408
3409    /// Executes a slash command synchronously and returns any error.
3410    ///
3411    /// Wire method: `session.commands.execute`.
3412    ///
3413    /// # Parameters
3414    ///
3415    /// * `params` - Slash command name and argument string to execute synchronously.
3416    ///
3417    /// # Returns
3418    ///
3419    /// Error message produced while executing the command, if any.
3420    ///
3421    /// <div class="warning">
3422    ///
3423    /// **Experimental.** This API is part of an experimental wire-protocol surface
3424    /// and may change or be removed in future SDK or CLI releases. Pin both the
3425    /// SDK and CLI versions if your code depends on it.
3426    ///
3427    /// </div>
3428    pub async fn execute(
3429        &self,
3430        params: ExecuteCommandParams,
3431    ) -> Result<ExecuteCommandResult, Error> {
3432        let mut wire_params = serde_json::to_value(params)?;
3433        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3434        let _value = self
3435            .session
3436            .client()
3437            .call(rpc_methods::SESSION_COMMANDS_EXECUTE, Some(wire_params))
3438            .await?;
3439        Ok(serde_json::from_value(_value)?)
3440    }
3441
3442    /// Enqueues a slash command for FIFO processing on the local session.
3443    ///
3444    /// Wire method: `session.commands.enqueue`.
3445    ///
3446    /// # Parameters
3447    ///
3448    /// * `params` - Slash-prefixed command string to enqueue for FIFO processing.
3449    ///
3450    /// # Returns
3451    ///
3452    /// Indicates whether the command was accepted into the local execution queue.
3453    ///
3454    /// <div class="warning">
3455    ///
3456    /// **Experimental.** This API is part of an experimental wire-protocol surface
3457    /// and may change or be removed in future SDK or CLI releases. Pin both the
3458    /// SDK and CLI versions if your code depends on it.
3459    ///
3460    /// </div>
3461    pub async fn enqueue(
3462        &self,
3463        params: EnqueueCommandParams,
3464    ) -> Result<EnqueueCommandResult, Error> {
3465        let mut wire_params = serde_json::to_value(params)?;
3466        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3467        let _value = self
3468            .session
3469            .client()
3470            .call(rpc_methods::SESSION_COMMANDS_ENQUEUE, Some(wire_params))
3471            .await?;
3472        Ok(serde_json::from_value(_value)?)
3473    }
3474
3475    /// Reports whether the host actually executed a queued command and whether to continue processing.
3476    ///
3477    /// Wire method: `session.commands.respondToQueuedCommand`.
3478    ///
3479    /// # Parameters
3480    ///
3481    /// * `params` - Queued-command request ID and the result indicating whether the host executed it (and whether to stop processing further queued commands).
3482    ///
3483    /// # Returns
3484    ///
3485    /// Indicates whether the queued-command response was matched to a pending request.
3486    ///
3487    /// <div class="warning">
3488    ///
3489    /// **Experimental.** This API is part of an experimental wire-protocol surface
3490    /// and may change or be removed in future SDK or CLI releases. Pin both the
3491    /// SDK and CLI versions if your code depends on it.
3492    ///
3493    /// </div>
3494    pub async fn respond_to_queued_command(
3495        &self,
3496        params: CommandsRespondToQueuedCommandRequest,
3497    ) -> Result<CommandsRespondToQueuedCommandResult, Error> {
3498        let mut wire_params = serde_json::to_value(params)?;
3499        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3500        let _value = self
3501            .session
3502            .client()
3503            .call(
3504                rpc_methods::SESSION_COMMANDS_RESPONDTOQUEUEDCOMMAND,
3505                Some(wire_params),
3506            )
3507            .await?;
3508        Ok(serde_json::from_value(_value)?)
3509    }
3510}
3511
3512/// `session.completions.*` RPCs.
3513#[derive(Clone, Copy)]
3514pub struct SessionRpcCompletions<'a> {
3515    pub(crate) session: &'a Session,
3516}
3517
3518impl<'a> SessionRpcCompletions<'a> {
3519    /// 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).
3520    ///
3521    /// Wire method: `session.completions.getTriggerCharacters`.
3522    ///
3523    /// # Returns
3524    ///
3525    /// 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`).
3526    ///
3527    /// <div class="warning">
3528    ///
3529    /// **Experimental.** This API is part of an experimental wire-protocol surface
3530    /// and may change or be removed in future SDK or CLI releases. Pin both the
3531    /// SDK and CLI versions if your code depends on it.
3532    ///
3533    /// </div>
3534    pub async fn get_trigger_characters(
3535        &self,
3536    ) -> Result<CompletionsGetTriggerCharactersResult, Error> {
3537        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3538        let _value = self
3539            .session
3540            .client()
3541            .call(
3542                rpc_methods::SESSION_COMPLETIONS_GETTRIGGERCHARACTERS,
3543                Some(wire_params),
3544            )
3545            .await?;
3546        Ok(serde_json::from_value(_value)?)
3547    }
3548
3549    /// 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.
3550    ///
3551    /// Wire method: `session.completions.request`.
3552    ///
3553    /// # Parameters
3554    ///
3555    /// * `params` - Request host-driven completions for the current composer input.
3556    ///
3557    /// # Returns
3558    ///
3559    /// Host-driven completion items for the current composer input. Empty when the host returns no items or does not support completions.
3560    ///
3561    /// <div class="warning">
3562    ///
3563    /// **Experimental.** This API is part of an experimental wire-protocol surface
3564    /// and may change or be removed in future SDK or CLI releases. Pin both the
3565    /// SDK and CLI versions if your code depends on it.
3566    ///
3567    /// </div>
3568    pub async fn request(
3569        &self,
3570        params: CompletionsRequestRequest,
3571    ) -> Result<CompletionsRequestResult, Error> {
3572        let mut wire_params = serde_json::to_value(params)?;
3573        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3574        let _value = self
3575            .session
3576            .client()
3577            .call(rpc_methods::SESSION_COMPLETIONS_REQUEST, Some(wire_params))
3578            .await?;
3579        Ok(serde_json::from_value(_value)?)
3580    }
3581}
3582
3583/// `session.eventLog.*` RPCs.
3584#[derive(Clone, Copy)]
3585pub struct SessionRpcEventLog<'a> {
3586    pub(crate) session: &'a Session,
3587}
3588
3589impl<'a> SessionRpcEventLog<'a> {
3590    /// Reads a batch of session events from a cursor, optionally waiting for new events.
3591    ///
3592    /// Wire method: `session.eventLog.read`.
3593    ///
3594    /// # Parameters
3595    ///
3596    /// * `params` - Cursor, batch size, and optional long-poll/filter parameters for reading session events.
3597    ///
3598    /// # Returns
3599    ///
3600    /// Batch of session events returned by a read, with cursor and continuation metadata.
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 read(&self, params: EventLogReadRequest) -> Result<EventsReadResult, Error> {
3610        let mut wire_params = serde_json::to_value(params)?;
3611        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3612        let _value = self
3613            .session
3614            .client()
3615            .call(rpc_methods::SESSION_EVENTLOG_READ, Some(wire_params))
3616            .await?;
3617        Ok(serde_json::from_value(_value)?)
3618    }
3619
3620    /// Returns a snapshot of the current tail cursor without consuming events.
3621    ///
3622    /// Wire method: `session.eventLog.tail`.
3623    ///
3624    /// # Returns
3625    ///
3626    /// 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).
3627    ///
3628    /// <div class="warning">
3629    ///
3630    /// **Experimental.** This API is part of an experimental wire-protocol surface
3631    /// and may change or be removed in future SDK or CLI releases. Pin both the
3632    /// SDK and CLI versions if your code depends on it.
3633    ///
3634    /// </div>
3635    pub async fn tail(&self) -> Result<EventLogTailResult, Error> {
3636        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3637        let _value = self
3638            .session
3639            .client()
3640            .call(rpc_methods::SESSION_EVENTLOG_TAIL, Some(wire_params))
3641            .await?;
3642        Ok(serde_json::from_value(_value)?)
3643    }
3644
3645    /// Registers consumer interest in an event type for runtime gating purposes.
3646    ///
3647    /// Wire method: `session.eventLog.registerInterest`.
3648    ///
3649    /// # Parameters
3650    ///
3651    /// * `params` - Event type to register consumer interest for, used by runtime gating logic.
3652    ///
3653    /// # Returns
3654    ///
3655    /// Opaque handle representing an event-type interest registration.
3656    ///
3657    /// <div class="warning">
3658    ///
3659    /// **Experimental.** This API is part of an experimental wire-protocol surface
3660    /// and may change or be removed in future SDK or CLI releases. Pin both the
3661    /// SDK and CLI versions if your code depends on it.
3662    ///
3663    /// </div>
3664    pub async fn register_interest(
3665        &self,
3666        params: RegisterEventInterestParams,
3667    ) -> Result<RegisterEventInterestResult, Error> {
3668        let mut wire_params = serde_json::to_value(params)?;
3669        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3670        let _value = self
3671            .session
3672            .client()
3673            .call(
3674                rpc_methods::SESSION_EVENTLOG_REGISTERINTEREST,
3675                Some(wire_params),
3676            )
3677            .await?;
3678        Ok(serde_json::from_value(_value)?)
3679    }
3680
3681    /// Releases a consumer's previously-registered interest in an event type.
3682    ///
3683    /// Wire method: `session.eventLog.releaseInterest`.
3684    ///
3685    /// # Parameters
3686    ///
3687    /// * `params` - Opaque handle previously returned by `registerInterest` to release.
3688    ///
3689    /// # Returns
3690    ///
3691    /// Indicates whether the operation succeeded.
3692    ///
3693    /// <div class="warning">
3694    ///
3695    /// **Experimental.** This API is part of an experimental wire-protocol surface
3696    /// and may change or be removed in future SDK or CLI releases. Pin both the
3697    /// SDK and CLI versions if your code depends on it.
3698    ///
3699    /// </div>
3700    pub async fn release_interest(
3701        &self,
3702        params: ReleaseEventInterestParams,
3703    ) -> Result<EventLogReleaseInterestResult, Error> {
3704        let mut wire_params = serde_json::to_value(params)?;
3705        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3706        let _value = self
3707            .session
3708            .client()
3709            .call(
3710                rpc_methods::SESSION_EVENTLOG_RELEASEINTEREST,
3711                Some(wire_params),
3712            )
3713            .await?;
3714        Ok(serde_json::from_value(_value)?)
3715    }
3716}
3717
3718/// `session.extensions.*` RPCs.
3719#[derive(Clone, Copy)]
3720pub struct SessionRpcExtensions<'a> {
3721    pub(crate) session: &'a Session,
3722}
3723
3724impl<'a> SessionRpcExtensions<'a> {
3725    /// Lists extensions discovered for the session and their current status.
3726    ///
3727    /// Wire method: `session.extensions.list`.
3728    ///
3729    /// # Returns
3730    ///
3731    /// Extensions discovered for the session, with their current status.
3732    ///
3733    /// <div class="warning">
3734    ///
3735    /// **Experimental.** This API is part of an experimental wire-protocol surface
3736    /// and may change or be removed in future SDK or CLI releases. Pin both the
3737    /// SDK and CLI versions if your code depends on it.
3738    ///
3739    /// </div>
3740    pub async fn list(&self) -> Result<ExtensionList, Error> {
3741        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3742        let _value = self
3743            .session
3744            .client()
3745            .call(rpc_methods::SESSION_EXTENSIONS_LIST, Some(wire_params))
3746            .await?;
3747        Ok(serde_json::from_value(_value)?)
3748    }
3749
3750    /// Enables an extension for the session.
3751    ///
3752    /// Wire method: `session.extensions.enable`.
3753    ///
3754    /// # Parameters
3755    ///
3756    /// * `params` - Source-qualified extension identifier to enable for the session.
3757    ///
3758    /// <div class="warning">
3759    ///
3760    /// **Experimental.** This API is part of an experimental wire-protocol surface
3761    /// and may change or be removed in future SDK or CLI releases. Pin both the
3762    /// SDK and CLI versions if your code depends on it.
3763    ///
3764    /// </div>
3765    pub async fn enable(&self, params: ExtensionsEnableRequest) -> Result<(), Error> {
3766        let mut wire_params = serde_json::to_value(params)?;
3767        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3768        let _value = self
3769            .session
3770            .client()
3771            .call(rpc_methods::SESSION_EXTENSIONS_ENABLE, Some(wire_params))
3772            .await?;
3773        Ok(())
3774    }
3775
3776    /// Disables an extension for the session.
3777    ///
3778    /// Wire method: `session.extensions.disable`.
3779    ///
3780    /// # Parameters
3781    ///
3782    /// * `params` - Source-qualified extension identifier to disable for the session.
3783    ///
3784    /// <div class="warning">
3785    ///
3786    /// **Experimental.** This API is part of an experimental wire-protocol surface
3787    /// and may change or be removed in future SDK or CLI releases. Pin both the
3788    /// SDK and CLI versions if your code depends on it.
3789    ///
3790    /// </div>
3791    pub async fn disable(&self, params: ExtensionsDisableRequest) -> Result<(), Error> {
3792        let mut wire_params = serde_json::to_value(params)?;
3793        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3794        let _value = self
3795            .session
3796            .client()
3797            .call(rpc_methods::SESSION_EXTENSIONS_DISABLE, Some(wire_params))
3798            .await?;
3799        Ok(())
3800    }
3801
3802    /// Reloads extension definitions and processes for the session.
3803    ///
3804    /// Wire method: `session.extensions.reload`.
3805    ///
3806    /// <div class="warning">
3807    ///
3808    /// **Experimental.** This API is part of an experimental wire-protocol surface
3809    /// and may change or be removed in future SDK or CLI releases. Pin both the
3810    /// SDK and CLI versions if your code depends on it.
3811    ///
3812    /// </div>
3813    pub async fn reload(&self) -> Result<(), Error> {
3814        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3815        let _value = self
3816            .session
3817            .client()
3818            .call(rpc_methods::SESSION_EXTENSIONS_RELOAD, Some(wire_params))
3819            .await?;
3820        Ok(())
3821    }
3822
3823    /// 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.
3824    ///
3825    /// Wire method: `session.extensions.sendAttachmentsToMessage`.
3826    ///
3827    /// # Parameters
3828    ///
3829    /// * `params` - Parameters for session.extensions.sendAttachmentsToMessage.
3830    ///
3831    /// <div class="warning">
3832    ///
3833    /// **Experimental.** This API is part of an experimental wire-protocol surface
3834    /// and may change or be removed in future SDK or CLI releases. Pin both the
3835    /// SDK and CLI versions if your code depends on it.
3836    ///
3837    /// </div>
3838    pub async fn send_attachments_to_message(
3839        &self,
3840        params: SendAttachmentsToMessageParams,
3841    ) -> Result<(), Error> {
3842        let mut wire_params = serde_json::to_value(params)?;
3843        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3844        let _value = self
3845            .session
3846            .client()
3847            .call(
3848                rpc_methods::SESSION_EXTENSIONS_SENDATTACHMENTSTOMESSAGE,
3849                Some(wire_params),
3850            )
3851            .await?;
3852        Ok(())
3853    }
3854}
3855
3856/// `session.fleet.*` RPCs.
3857#[derive(Clone, Copy)]
3858pub struct SessionRpcFleet<'a> {
3859    pub(crate) session: &'a Session,
3860}
3861
3862impl<'a> SessionRpcFleet<'a> {
3863    /// Starts fleet mode by submitting the fleet orchestration prompt to the session.
3864    ///
3865    /// Wire method: `session.fleet.start`.
3866    ///
3867    /// # Parameters
3868    ///
3869    /// * `params` - Optional user prompt to combine with the fleet orchestration instructions.
3870    ///
3871    /// # Returns
3872    ///
3873    /// Indicates whether fleet mode was successfully activated.
3874    ///
3875    /// <div class="warning">
3876    ///
3877    /// **Experimental.** This API is part of an experimental wire-protocol surface
3878    /// and may change or be removed in future SDK or CLI releases. Pin both the
3879    /// SDK and CLI versions if your code depends on it.
3880    ///
3881    /// </div>
3882    pub async fn start(&self, params: FleetStartRequest) -> Result<FleetStartResult, Error> {
3883        let mut wire_params = serde_json::to_value(params)?;
3884        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3885        let _value = self
3886            .session
3887            .client()
3888            .call(rpc_methods::SESSION_FLEET_START, Some(wire_params))
3889            .await?;
3890        Ok(serde_json::from_value(_value)?)
3891    }
3892}
3893
3894/// `session.gitHubAuth.*` RPCs.
3895#[derive(Clone, Copy)]
3896pub struct SessionRpcGitHubAuth<'a> {
3897    pub(crate) session: &'a Session,
3898}
3899
3900impl<'a> SessionRpcGitHubAuth<'a> {
3901    /// Gets authentication status and account metadata for the session.
3902    ///
3903    /// Wire method: `session.gitHubAuth.getStatus`.
3904    ///
3905    /// # Returns
3906    ///
3907    /// Authentication status and account metadata for the session.
3908    ///
3909    /// <div class="warning">
3910    ///
3911    /// **Experimental.** This API is part of an experimental wire-protocol surface
3912    /// and may change or be removed in future SDK or CLI releases. Pin both the
3913    /// SDK and CLI versions if your code depends on it.
3914    ///
3915    /// </div>
3916    pub async fn get_status(&self) -> Result<SessionAuthStatus, Error> {
3917        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3918        let _value = self
3919            .session
3920            .client()
3921            .call(rpc_methods::SESSION_GITHUBAUTH_GETSTATUS, Some(wire_params))
3922            .await?;
3923        Ok(serde_json::from_value(_value)?)
3924    }
3925
3926    /// Updates the session's auth credentials used for outbound model and API requests.
3927    ///
3928    /// Wire method: `session.gitHubAuth.setCredentials`.
3929    ///
3930    /// # Parameters
3931    ///
3932    /// * `params` - New auth credentials to install on the session. Omit to leave credentials unchanged.
3933    ///
3934    /// # Returns
3935    ///
3936    /// Indicates whether the credential update succeeded.
3937    ///
3938    /// <div class="warning">
3939    ///
3940    /// **Experimental.** This API is part of an experimental wire-protocol surface
3941    /// and may change or be removed in future SDK or CLI releases. Pin both the
3942    /// SDK and CLI versions if your code depends on it.
3943    ///
3944    /// </div>
3945    pub async fn set_credentials(
3946        &self,
3947        params: SessionSetCredentialsParams,
3948    ) -> Result<SessionSetCredentialsResult, Error> {
3949        let mut wire_params = serde_json::to_value(params)?;
3950        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3951        let _value = self
3952            .session
3953            .client()
3954            .call(
3955                rpc_methods::SESSION_GITHUBAUTH_SETCREDENTIALS,
3956                Some(wire_params),
3957            )
3958            .await?;
3959        Ok(serde_json::from_value(_value)?)
3960    }
3961}
3962
3963/// `session.history.*` RPCs.
3964#[derive(Clone, Copy)]
3965pub struct SessionRpcHistory<'a> {
3966    pub(crate) session: &'a Session,
3967}
3968
3969impl<'a> SessionRpcHistory<'a> {
3970    /// Compacts the session history to reduce context usage.
3971    ///
3972    /// Wire method: `session.history.compact`.
3973    ///
3974    /// # Returns
3975    ///
3976    /// Compaction outcome with the number of tokens and messages removed, summary text, and the resulting context window breakdown.
3977    ///
3978    /// <div class="warning">
3979    ///
3980    /// **Experimental.** This API is part of an experimental wire-protocol surface
3981    /// and may change or be removed in future SDK or CLI releases. Pin both the
3982    /// SDK and CLI versions if your code depends on it.
3983    ///
3984    /// </div>
3985    pub async fn compact(&self) -> Result<HistoryCompactResult, Error> {
3986        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3987        let _value = self
3988            .session
3989            .client()
3990            .call(rpc_methods::SESSION_HISTORY_COMPACT, Some(wire_params))
3991            .await?;
3992        Ok(serde_json::from_value(_value)?)
3993    }
3994
3995    /// Compacts the session history to reduce context usage.
3996    ///
3997    /// Wire method: `session.history.compact`.
3998    ///
3999    /// # Parameters
4000    ///
4001    /// * `params` - Optional compaction parameters.
4002    ///
4003    /// # Returns
4004    ///
4005    /// Compaction outcome with the number of tokens and messages removed, summary text, and the resulting context window breakdown.
4006    ///
4007    /// <div class="warning">
4008    ///
4009    /// **Experimental.** This API is part of an experimental wire-protocol surface
4010    /// and may change or be removed in future SDK or CLI releases. Pin both the
4011    /// SDK and CLI versions if your code depends on it.
4012    ///
4013    /// </div>
4014    pub async fn compact_with_params(
4015        &self,
4016        params: HistoryCompactRequest,
4017    ) -> Result<HistoryCompactResult, Error> {
4018        let mut wire_params = serde_json::to_value(params)?;
4019        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4020        let _value = self
4021            .session
4022            .client()
4023            .call(rpc_methods::SESSION_HISTORY_COMPACT, Some(wire_params))
4024            .await?;
4025        Ok(serde_json::from_value(_value)?)
4026    }
4027
4028    /// Truncates persisted session history to a specific event.
4029    ///
4030    /// Wire method: `session.history.truncate`.
4031    ///
4032    /// # Parameters
4033    ///
4034    /// * `params` - Identifier of the event to truncate to; this event and all later events are removed.
4035    ///
4036    /// # Returns
4037    ///
4038    /// Number of events that were removed by the truncation.
4039    ///
4040    /// <div class="warning">
4041    ///
4042    /// **Experimental.** This API is part of an experimental wire-protocol surface
4043    /// and may change or be removed in future SDK or CLI releases. Pin both the
4044    /// SDK and CLI versions if your code depends on it.
4045    ///
4046    /// </div>
4047    pub async fn truncate(
4048        &self,
4049        params: HistoryTruncateRequest,
4050    ) -> Result<HistoryTruncateResult, Error> {
4051        let mut wire_params = serde_json::to_value(params)?;
4052        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4053        let _value = self
4054            .session
4055            .client()
4056            .call(rpc_methods::SESSION_HISTORY_TRUNCATE, Some(wire_params))
4057            .await?;
4058        Ok(serde_json::from_value(_value)?)
4059    }
4060
4061    /// Cancels any in-progress background compaction on a local session.
4062    ///
4063    /// Wire method: `session.history.cancelBackgroundCompaction`.
4064    ///
4065    /// # Returns
4066    ///
4067    /// Indicates whether an in-progress background compaction was cancelled.
4068    ///
4069    /// <div class="warning">
4070    ///
4071    /// **Experimental.** This API is part of an experimental wire-protocol surface
4072    /// and may change or be removed in future SDK or CLI releases. Pin both the
4073    /// SDK and CLI versions if your code depends on it.
4074    ///
4075    /// </div>
4076    pub async fn cancel_background_compaction(
4077        &self,
4078    ) -> Result<HistoryCancelBackgroundCompactionResult, Error> {
4079        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
4080        let _value = self
4081            .session
4082            .client()
4083            .call(
4084                rpc_methods::SESSION_HISTORY_CANCELBACKGROUNDCOMPACTION,
4085                Some(wire_params),
4086            )
4087            .await?;
4088        Ok(serde_json::from_value(_value)?)
4089    }
4090
4091    /// Aborts any in-progress manual compaction on a local session.
4092    ///
4093    /// Wire method: `session.history.abortManualCompaction`.
4094    ///
4095    /// # Returns
4096    ///
4097    /// Indicates whether an in-progress manual compaction was aborted.
4098    ///
4099    /// <div class="warning">
4100    ///
4101    /// **Experimental.** This API is part of an experimental wire-protocol surface
4102    /// and may change or be removed in future SDK or CLI releases. Pin both the
4103    /// SDK and CLI versions if your code depends on it.
4104    ///
4105    /// </div>
4106    pub async fn abort_manual_compaction(
4107        &self,
4108    ) -> Result<HistoryAbortManualCompactionResult, Error> {
4109        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
4110        let _value = self
4111            .session
4112            .client()
4113            .call(
4114                rpc_methods::SESSION_HISTORY_ABORTMANUALCOMPACTION,
4115                Some(wire_params),
4116            )
4117            .await?;
4118        Ok(serde_json::from_value(_value)?)
4119    }
4120
4121    /// Produces a markdown summary of the session's conversation context for hand-off scenarios.
4122    ///
4123    /// Wire method: `session.history.summarizeForHandoff`.
4124    ///
4125    /// # Returns
4126    ///
4127    /// Markdown summary of the conversation context (empty when not available).
4128    ///
4129    /// <div class="warning">
4130    ///
4131    /// **Experimental.** This API is part of an experimental wire-protocol surface
4132    /// and may change or be removed in future SDK or CLI releases. Pin both the
4133    /// SDK and CLI versions if your code depends on it.
4134    ///
4135    /// </div>
4136    pub async fn summarize_for_handoff(&self) -> Result<HistorySummarizeForHandoffResult, Error> {
4137        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
4138        let _value = self
4139            .session
4140            .client()
4141            .call(
4142                rpc_methods::SESSION_HISTORY_SUMMARIZEFORHANDOFF,
4143                Some(wire_params),
4144            )
4145            .await?;
4146        Ok(serde_json::from_value(_value)?)
4147    }
4148}
4149
4150/// `session.instructions.*` RPCs.
4151#[derive(Clone, Copy)]
4152pub struct SessionRpcInstructions<'a> {
4153    pub(crate) session: &'a Session,
4154}
4155
4156impl<'a> SessionRpcInstructions<'a> {
4157    /// Gets instruction sources loaded for the session.
4158    ///
4159    /// Wire method: `session.instructions.getSources`.
4160    ///
4161    /// # Returns
4162    ///
4163    /// Instruction sources loaded for the session, in merge order.
4164    ///
4165    /// <div class="warning">
4166    ///
4167    /// **Experimental.** This API is part of an experimental wire-protocol surface
4168    /// and may change or be removed in future SDK or CLI releases. Pin both the
4169    /// SDK and CLI versions if your code depends on it.
4170    ///
4171    /// </div>
4172    pub async fn get_sources(&self) -> Result<InstructionsGetSourcesResult, Error> {
4173        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
4174        let _value = self
4175            .session
4176            .client()
4177            .call(
4178                rpc_methods::SESSION_INSTRUCTIONS_GETSOURCES,
4179                Some(wire_params),
4180            )
4181            .await?;
4182        Ok(serde_json::from_value(_value)?)
4183    }
4184}
4185
4186/// `session.lsp.*` RPCs.
4187#[derive(Clone, Copy)]
4188pub struct SessionRpcLsp<'a> {
4189    pub(crate) session: &'a Session,
4190}
4191
4192impl<'a> SessionRpcLsp<'a> {
4193    /// Loads the merged LSP configuration set for the session's working directory.
4194    ///
4195    /// Wire method: `session.lsp.initialize`.
4196    ///
4197    /// # Parameters
4198    ///
4199    /// * `params` - Parameters for (re)loading the merged LSP configuration set.
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 initialize(&self, params: LspInitializeRequest) -> Result<(), Error> {
4209        let mut wire_params = serde_json::to_value(params)?;
4210        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4211        let _value = self
4212            .session
4213            .client()
4214            .call(rpc_methods::SESSION_LSP_INITIALIZE, Some(wire_params))
4215            .await?;
4216        Ok(())
4217    }
4218}
4219
4220/// `session.mcp.*` RPCs.
4221#[derive(Clone, Copy)]
4222pub struct SessionRpcMcp<'a> {
4223    pub(crate) session: &'a Session,
4224}
4225
4226impl<'a> SessionRpcMcp<'a> {
4227    /// `session.mcp.apps.*` sub-namespace.
4228    pub fn apps(&self) -> SessionRpcMcpApps<'a> {
4229        SessionRpcMcpApps {
4230            session: self.session,
4231        }
4232    }
4233
4234    /// `session.mcp.headers.*` sub-namespace.
4235    pub fn headers(&self) -> SessionRpcMcpHeaders<'a> {
4236        SessionRpcMcpHeaders {
4237            session: self.session,
4238        }
4239    }
4240
4241    /// `session.mcp.oauth.*` sub-namespace.
4242    pub fn oauth(&self) -> SessionRpcMcpOauth<'a> {
4243        SessionRpcMcpOauth {
4244            session: self.session,
4245        }
4246    }
4247
4248    /// 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.
4249    ///
4250    /// Wire method: `session.mcp.list`.
4251    ///
4252    /// # Returns
4253    ///
4254    /// MCP servers configured for the session, with their connection status and host-level state.
4255    ///
4256    /// <div class="warning">
4257    ///
4258    /// **Experimental.** This API is part of an experimental wire-protocol surface
4259    /// and may change or be removed in future SDK or CLI releases. Pin both the
4260    /// SDK and CLI versions if your code depends on it.
4261    ///
4262    /// </div>
4263    pub async fn list(&self) -> Result<McpServerList, Error> {
4264        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
4265        let _value = self
4266            .session
4267            .client()
4268            .call(rpc_methods::SESSION_MCP_LIST, Some(wire_params))
4269            .await?;
4270        Ok(serde_json::from_value(_value)?)
4271    }
4272
4273    /// Lists the tools exposed by a connected MCP server on this session's host.
4274    ///
4275    /// Wire method: `session.mcp.listTools`.
4276    ///
4277    /// # Parameters
4278    ///
4279    /// * `params` - Server name whose tool list should be returned.
4280    ///
4281    /// # Returns
4282    ///
4283    /// Tools exposed by the connected MCP server. Throws when the server is not connected.
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 list_tools(
4293        &self,
4294        params: McpListToolsRequest,
4295    ) -> Result<McpListToolsResult, Error> {
4296        let mut wire_params = serde_json::to_value(params)?;
4297        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4298        let _value = self
4299            .session
4300            .client()
4301            .call(rpc_methods::SESSION_MCP_LISTTOOLS, Some(wire_params))
4302            .await?;
4303        Ok(serde_json::from_value(_value)?)
4304    }
4305
4306    /// Enables an MCP server for the session.
4307    ///
4308    /// Wire method: `session.mcp.enable`.
4309    ///
4310    /// # Parameters
4311    ///
4312    /// * `params` - Name of the MCP server to enable for the session.
4313    ///
4314    /// <div class="warning">
4315    ///
4316    /// **Experimental.** This API is part of an experimental wire-protocol surface
4317    /// and may change or be removed in future SDK or CLI releases. Pin both the
4318    /// SDK and CLI versions if your code depends on it.
4319    ///
4320    /// </div>
4321    pub async fn enable(&self, params: McpEnableRequest) -> Result<(), Error> {
4322        let mut wire_params = serde_json::to_value(params)?;
4323        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4324        let _value = self
4325            .session
4326            .client()
4327            .call(rpc_methods::SESSION_MCP_ENABLE, Some(wire_params))
4328            .await?;
4329        Ok(())
4330    }
4331
4332    /// Disables an MCP server for the session.
4333    ///
4334    /// Wire method: `session.mcp.disable`.
4335    ///
4336    /// # Parameters
4337    ///
4338    /// * `params` - Name of the MCP server to disable for the session.
4339    ///
4340    /// <div class="warning">
4341    ///
4342    /// **Experimental.** This API is part of an experimental wire-protocol surface
4343    /// and may change or be removed in future SDK or CLI releases. Pin both the
4344    /// SDK and CLI versions if your code depends on it.
4345    ///
4346    /// </div>
4347    pub async fn disable(&self, params: McpDisableRequest) -> Result<(), Error> {
4348        let mut wire_params = serde_json::to_value(params)?;
4349        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4350        let _value = self
4351            .session
4352            .client()
4353            .call(rpc_methods::SESSION_MCP_DISABLE, Some(wire_params))
4354            .await?;
4355        Ok(())
4356    }
4357
4358    /// Reloads MCP server connections for the session.
4359    ///
4360    /// Wire method: `session.mcp.reload`.
4361    ///
4362    /// <div class="warning">
4363    ///
4364    /// **Experimental.** This API is part of an experimental wire-protocol surface
4365    /// and may change or be removed in future SDK or CLI releases. Pin both the
4366    /// SDK and CLI versions if your code depends on it.
4367    ///
4368    /// </div>
4369    pub async fn reload(&self) -> Result<(), Error> {
4370        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
4371        let _value = self
4372            .session
4373            .client()
4374            .call(rpc_methods::SESSION_MCP_RELOAD, Some(wire_params))
4375            .await?;
4376        Ok(())
4377    }
4378
4379    /// Reloads MCP server connections for the session with an explicit host-provided configuration.
4380    ///
4381    /// Wire method: `session.mcp.reloadWithConfig`.
4382    ///
4383    /// # Parameters
4384    ///
4385    /// * `params` - Opaque MCP reload configuration.
4386    ///
4387    /// # Returns
4388    ///
4389    /// MCP server startup filtering result.
4390    ///
4391    /// <div class="warning">
4392    ///
4393    /// **Experimental.** This API is part of an experimental wire-protocol surface
4394    /// and may change or be removed in future SDK or CLI releases. Pin both the
4395    /// SDK and CLI versions if your code depends on it.
4396    ///
4397    /// </div>
4398    pub(crate) async fn reload_with_config(
4399        &self,
4400        params: McpReloadWithConfigRequest,
4401    ) -> Result<McpStartServersResult, Error> {
4402        let mut wire_params = serde_json::to_value(params)?;
4403        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4404        let _value = self
4405            .session
4406            .client()
4407            .call(rpc_methods::SESSION_MCP_RELOADWITHCONFIG, Some(wire_params))
4408            .await?;
4409        Ok(serde_json::from_value(_value)?)
4410    }
4411
4412    /// Runs an MCP sampling inference on behalf of an MCP server.
4413    ///
4414    /// Wire method: `session.mcp.executeSampling`.
4415    ///
4416    /// # Parameters
4417    ///
4418    /// * `params` - Identifiers and raw MCP CreateMessageRequest params used to run a sampling inference.
4419    ///
4420    /// # Returns
4421    ///
4422    /// Outcome of an MCP sampling execution: success result, failure error, or cancellation.
4423    ///
4424    /// <div class="warning">
4425    ///
4426    /// **Experimental.** This API is part of an experimental wire-protocol surface
4427    /// and may change or be removed in future SDK or CLI releases. Pin both the
4428    /// SDK and CLI versions if your code depends on it.
4429    ///
4430    /// </div>
4431    pub async fn execute_sampling(
4432        &self,
4433        params: McpExecuteSamplingParams,
4434    ) -> Result<McpSamplingExecutionResult, Error> {
4435        let mut wire_params = serde_json::to_value(params)?;
4436        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4437        let _value = self
4438            .session
4439            .client()
4440            .call(rpc_methods::SESSION_MCP_EXECUTESAMPLING, Some(wire_params))
4441            .await?;
4442        Ok(serde_json::from_value(_value)?)
4443    }
4444
4445    /// Cancels an in-flight MCP sampling execution by request ID.
4446    ///
4447    /// Wire method: `session.mcp.cancelSamplingExecution`.
4448    ///
4449    /// # Parameters
4450    ///
4451    /// * `params` - The requestId previously passed to executeSampling that should be cancelled.
4452    ///
4453    /// # Returns
4454    ///
4455    /// Indicates whether an in-flight sampling execution with the given requestId was found and cancelled.
4456    ///
4457    /// <div class="warning">
4458    ///
4459    /// **Experimental.** This API is part of an experimental wire-protocol surface
4460    /// and may change or be removed in future SDK or CLI releases. Pin both the
4461    /// SDK and CLI versions if your code depends on it.
4462    ///
4463    /// </div>
4464    pub async fn cancel_sampling_execution(
4465        &self,
4466        params: McpCancelSamplingExecutionParams,
4467    ) -> Result<McpCancelSamplingExecutionResult, Error> {
4468        let mut wire_params = serde_json::to_value(params)?;
4469        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4470        let _value = self
4471            .session
4472            .client()
4473            .call(
4474                rpc_methods::SESSION_MCP_CANCELSAMPLINGEXECUTION,
4475                Some(wire_params),
4476            )
4477            .await?;
4478        Ok(serde_json::from_value(_value)?)
4479    }
4480
4481    /// Sets how environment-variable values supplied to MCP servers are resolved (direct or indirect).
4482    ///
4483    /// Wire method: `session.mcp.setEnvValueMode`.
4484    ///
4485    /// # Parameters
4486    ///
4487    /// * `params` - Mode controlling how MCP server env values are resolved (`direct` or `indirect`).
4488    ///
4489    /// # Returns
4490    ///
4491    /// Env-value mode recorded on the session after the update.
4492    ///
4493    /// <div class="warning">
4494    ///
4495    /// **Experimental.** This API is part of an experimental wire-protocol surface
4496    /// and may change or be removed in future SDK or CLI releases. Pin both the
4497    /// SDK and CLI versions if your code depends on it.
4498    ///
4499    /// </div>
4500    pub async fn set_env_value_mode(
4501        &self,
4502        params: McpSetEnvValueModeParams,
4503    ) -> Result<McpSetEnvValueModeResult, Error> {
4504        let mut wire_params = serde_json::to_value(params)?;
4505        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4506        let _value = self
4507            .session
4508            .client()
4509            .call(rpc_methods::SESSION_MCP_SETENVVALUEMODE, Some(wire_params))
4510            .await?;
4511        Ok(serde_json::from_value(_value)?)
4512    }
4513
4514    /// Removes the auto-managed `github` MCP server when present.
4515    ///
4516    /// Wire method: `session.mcp.removeGitHub`.
4517    ///
4518    /// # Returns
4519    ///
4520    /// Indicates whether the auto-managed `github` MCP server was removed (false when nothing to remove).
4521    ///
4522    /// <div class="warning">
4523    ///
4524    /// **Experimental.** This API is part of an experimental wire-protocol surface
4525    /// and may change or be removed in future SDK or CLI releases. Pin both the
4526    /// SDK and CLI versions if your code depends on it.
4527    ///
4528    /// </div>
4529    pub async fn remove_git_hub(&self) -> Result<McpRemoveGitHubResult, Error> {
4530        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
4531        let _value = self
4532            .session
4533            .client()
4534            .call(rpc_methods::SESSION_MCP_REMOVEGITHUB, Some(wire_params))
4535            .await?;
4536        Ok(serde_json::from_value(_value)?)
4537    }
4538
4539    /// Configures the built-in GitHub MCP server for the session's current auth context.
4540    ///
4541    /// Wire method: `session.mcp.configureGitHub`.
4542    ///
4543    /// # Parameters
4544    ///
4545    /// * `params` - Opaque auth info used to configure GitHub MCP.
4546    ///
4547    /// # Returns
4548    ///
4549    /// Result of configuring GitHub MCP.
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 configure_git_hub(
4559        &self,
4560        params: McpConfigureGitHubRequest,
4561    ) -> Result<McpConfigureGitHubResult, 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_CONFIGUREGITHUB, Some(wire_params))
4568            .await?;
4569        Ok(serde_json::from_value(_value)?)
4570    }
4571
4572    /// Starts an individual MCP server on the session's host.
4573    ///
4574    /// Wire method: `session.mcp.startServer`.
4575    ///
4576    /// # Parameters
4577    ///
4578    /// * `params` - Server name and opaque configuration for an individual MCP server start.
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(crate) async fn start_server(&self, params: McpStartServerRequest) -> 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_STARTSERVER, Some(wire_params))
4594            .await?;
4595        Ok(())
4596    }
4597
4598    /// Restarts an individual MCP server on the session's host (stops then starts).
4599    ///
4600    /// Wire method: `session.mcp.restartServer`.
4601    ///
4602    /// # Parameters
4603    ///
4604    /// * `params` - Server name and opaque configuration for an individual MCP server restart.
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 restart_server(
4614        &self,
4615        params: McpRestartServerRequest,
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(rpc_methods::SESSION_MCP_RESTARTSERVER, Some(wire_params))
4623            .await?;
4624        Ok(())
4625    }
4626
4627    /// Stops an individual MCP server on the session's host.
4628    ///
4629    /// Wire method: `session.mcp.stopServer`.
4630    ///
4631    /// # Parameters
4632    ///
4633    /// * `params` - Server name for an individual MCP server stop.
4634    ///
4635    /// <div class="warning">
4636    ///
4637    /// **Experimental.** This API is part of an experimental wire-protocol surface
4638    /// and may change or be removed in future SDK or CLI releases. Pin both the
4639    /// SDK and CLI versions if your code depends on it.
4640    ///
4641    /// </div>
4642    pub async fn stop_server(&self, params: McpStopServerRequest) -> Result<(), Error> {
4643        let mut wire_params = serde_json::to_value(params)?;
4644        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4645        let _value = self
4646            .session
4647            .client()
4648            .call(rpc_methods::SESSION_MCP_STOPSERVER, Some(wire_params))
4649            .await?;
4650        Ok(())
4651    }
4652
4653    /// 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.
4654    ///
4655    /// Wire method: `session.mcp.registerExternalClient`.
4656    ///
4657    /// # Parameters
4658    ///
4659    /// * `params` - Registration parameters for an external MCP client.
4660    ///
4661    /// <div class="warning">
4662    ///
4663    /// **Experimental.** This API is part of an experimental wire-protocol surface
4664    /// and may change or be removed in future SDK or CLI releases. Pin both the
4665    /// SDK and CLI versions if your code depends on it.
4666    ///
4667    /// </div>
4668    pub(crate) async fn register_external_client(
4669        &self,
4670        params: McpRegisterExternalClientRequest,
4671    ) -> Result<(), Error> {
4672        let mut wire_params = serde_json::to_value(params)?;
4673        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4674        let _value = self
4675            .session
4676            .client()
4677            .call(
4678                rpc_methods::SESSION_MCP_REGISTEREXTERNALCLIENT,
4679                Some(wire_params),
4680            )
4681            .await?;
4682        Ok(())
4683    }
4684
4685    /// 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.
4686    ///
4687    /// Wire method: `session.mcp.unregisterExternalClient`.
4688    ///
4689    /// # Parameters
4690    ///
4691    /// * `params` - Server name identifying the external client to remove.
4692    ///
4693    /// <div class="warning">
4694    ///
4695    /// **Experimental.** This API is part of an experimental wire-protocol surface
4696    /// and may change or be removed in future SDK or CLI releases. Pin both the
4697    /// SDK and CLI versions if your code depends on it.
4698    ///
4699    /// </div>
4700    pub(crate) async fn unregister_external_client(
4701        &self,
4702        params: McpUnregisterExternalClientRequest,
4703    ) -> Result<(), Error> {
4704        let mut wire_params = serde_json::to_value(params)?;
4705        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4706        let _value = self
4707            .session
4708            .client()
4709            .call(
4710                rpc_methods::SESSION_MCP_UNREGISTEREXTERNALCLIENT,
4711                Some(wire_params),
4712            )
4713            .await?;
4714        Ok(())
4715    }
4716
4717    /// Checks whether a named MCP server is currently running on the session's host.
4718    ///
4719    /// Wire method: `session.mcp.isServerRunning`.
4720    ///
4721    /// # Parameters
4722    ///
4723    /// * `params` - Server name to check running status for.
4724    ///
4725    /// # Returns
4726    ///
4727    /// Whether the named MCP server is running.
4728    ///
4729    /// <div class="warning">
4730    ///
4731    /// **Experimental.** This API is part of an experimental wire-protocol surface
4732    /// and may change or be removed in future SDK or CLI releases. Pin both the
4733    /// SDK and CLI versions if your code depends on it.
4734    ///
4735    /// </div>
4736    pub async fn is_server_running(
4737        &self,
4738        params: McpIsServerRunningRequest,
4739    ) -> Result<McpIsServerRunningResult, Error> {
4740        let mut wire_params = serde_json::to_value(params)?;
4741        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4742        let _value = self
4743            .session
4744            .client()
4745            .call(rpc_methods::SESSION_MCP_ISSERVERRUNNING, Some(wire_params))
4746            .await?;
4747        Ok(serde_json::from_value(_value)?)
4748    }
4749}
4750
4751/// `session.mcp.apps.*` RPCs.
4752#[derive(Clone, Copy)]
4753pub struct SessionRpcMcpApps<'a> {
4754    pub(crate) session: &'a Session,
4755}
4756
4757impl<'a> SessionRpcMcpApps<'a> {
4758    /// Fetch an MCP resource (typically a `ui://` MCP App bundle, per SEP-1865) from a connected server. Requires the `mcp-apps` session capability.
4759    ///
4760    /// Wire method: `session.mcp.apps.readResource`.
4761    ///
4762    /// # Parameters
4763    ///
4764    /// * `params` - MCP server and resource URI to fetch.
4765    ///
4766    /// # Returns
4767    ///
4768    /// Resource contents returned by the MCP server.
4769    ///
4770    /// <div class="warning">
4771    ///
4772    /// **Experimental.** This API is part of an experimental wire-protocol surface
4773    /// and may change or be removed in future SDK or CLI releases. Pin both the
4774    /// SDK and CLI versions if your code depends on it.
4775    ///
4776    /// </div>
4777    pub async fn read_resource(
4778        &self,
4779        params: McpAppsReadResourceRequest,
4780    ) -> Result<McpAppsReadResourceResult, Error> {
4781        let mut wire_params = serde_json::to_value(params)?;
4782        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4783        let _value = self
4784            .session
4785            .client()
4786            .call(
4787                rpc_methods::SESSION_MCP_APPS_READRESOURCE,
4788                Some(wire_params),
4789            )
4790            .await?;
4791        Ok(serde_json::from_value(_value)?)
4792    }
4793
4794    /// 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"`.
4795    ///
4796    /// Wire method: `session.mcp.apps.listTools`.
4797    ///
4798    /// # Parameters
4799    ///
4800    /// * `params` - MCP server to list app-callable tools for.
4801    ///
4802    /// # Returns
4803    ///
4804    /// App-callable tools from the named MCP server.
4805    ///
4806    /// <div class="warning">
4807    ///
4808    /// **Experimental.** This API is part of an experimental wire-protocol surface
4809    /// and may change or be removed in future SDK or CLI releases. Pin both the
4810    /// SDK and CLI versions if your code depends on it.
4811    ///
4812    /// </div>
4813    pub async fn list_tools(
4814        &self,
4815        params: McpAppsListToolsRequest,
4816    ) -> Result<McpAppsListToolsResult, Error> {
4817        let mut wire_params = serde_json::to_value(params)?;
4818        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4819        let _value = self
4820            .session
4821            .client()
4822            .call(rpc_methods::SESSION_MCP_APPS_LISTTOOLS, Some(wire_params))
4823            .await?;
4824        Ok(serde_json::from_value(_value)?)
4825    }
4826
4827    /// 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`.
4828    ///
4829    /// Wire method: `session.mcp.apps.callTool`.
4830    ///
4831    /// # Parameters
4832    ///
4833    /// * `params` - MCP server, tool name, and arguments to invoke from an MCP App view.
4834    ///
4835    /// # Returns
4836    ///
4837    /// Standard MCP CallToolResult
4838    ///
4839    /// <div class="warning">
4840    ///
4841    /// **Experimental.** This API is part of an experimental wire-protocol surface
4842    /// and may change or be removed in future SDK or CLI releases. Pin both the
4843    /// SDK and CLI versions if your code depends on it.
4844    ///
4845    /// </div>
4846    pub async fn call_tool(
4847        &self,
4848        params: McpAppsCallToolRequest,
4849    ) -> Result<SessionMcpAppsCallToolResult, Error> {
4850        let mut wire_params = serde_json::to_value(params)?;
4851        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4852        let _value = self
4853            .session
4854            .client()
4855            .call(rpc_methods::SESSION_MCP_APPS_CALLTOOL, Some(wire_params))
4856            .await?;
4857        Ok(serde_json::from_value(_value)?)
4858    }
4859
4860    /// 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.
4861    ///
4862    /// Wire method: `session.mcp.apps.setHostContext`.
4863    ///
4864    /// # Parameters
4865    ///
4866    /// * `params` - Host context to advertise to MCP App guests.
4867    ///
4868    /// <div class="warning">
4869    ///
4870    /// **Experimental.** This API is part of an experimental wire-protocol surface
4871    /// and may change or be removed in future SDK or CLI releases. Pin both the
4872    /// SDK and CLI versions if your code depends on it.
4873    ///
4874    /// </div>
4875    pub async fn set_host_context(
4876        &self,
4877        params: McpAppsSetHostContextRequest,
4878    ) -> Result<(), Error> {
4879        let mut wire_params = serde_json::to_value(params)?;
4880        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4881        let _value = self
4882            .session
4883            .client()
4884            .call(
4885                rpc_methods::SESSION_MCP_APPS_SETHOSTCONTEXT,
4886                Some(wire_params),
4887            )
4888            .await?;
4889        Ok(())
4890    }
4891
4892    /// Read the current host context advertised to MCP App guests.
4893    ///
4894    /// Wire method: `session.mcp.apps.getHostContext`.
4895    ///
4896    /// # Returns
4897    ///
4898    /// Current host context advertised to MCP App guests.
4899    ///
4900    /// <div class="warning">
4901    ///
4902    /// **Experimental.** This API is part of an experimental wire-protocol surface
4903    /// and may change or be removed in future SDK or CLI releases. Pin both the
4904    /// SDK and CLI versions if your code depends on it.
4905    ///
4906    /// </div>
4907    pub async fn get_host_context(&self) -> Result<McpAppsHostContext, Error> {
4908        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
4909        let _value = self
4910            .session
4911            .client()
4912            .call(
4913                rpc_methods::SESSION_MCP_APPS_GETHOSTCONTEXT,
4914                Some(wire_params),
4915            )
4916            .await?;
4917        Ok(serde_json::from_value(_value)?)
4918    }
4919
4920    /// 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.
4921    ///
4922    /// Wire method: `session.mcp.apps.diagnose`.
4923    ///
4924    /// # Parameters
4925    ///
4926    /// * `params` - MCP server to diagnose MCP Apps wiring for.
4927    ///
4928    /// # Returns
4929    ///
4930    /// Diagnostic snapshot of MCP Apps wiring for the named server.
4931    ///
4932    /// <div class="warning">
4933    ///
4934    /// **Experimental.** This API is part of an experimental wire-protocol surface
4935    /// and may change or be removed in future SDK or CLI releases. Pin both the
4936    /// SDK and CLI versions if your code depends on it.
4937    ///
4938    /// </div>
4939    pub async fn diagnose(
4940        &self,
4941        params: McpAppsDiagnoseRequest,
4942    ) -> Result<McpAppsDiagnoseResult, Error> {
4943        let mut wire_params = serde_json::to_value(params)?;
4944        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4945        let _value = self
4946            .session
4947            .client()
4948            .call(rpc_methods::SESSION_MCP_APPS_DIAGNOSE, Some(wire_params))
4949            .await?;
4950        Ok(serde_json::from_value(_value)?)
4951    }
4952}
4953
4954/// `session.mcp.headers.*` RPCs.
4955#[derive(Clone, Copy)]
4956pub struct SessionRpcMcpHeaders<'a> {
4957    pub(crate) session: &'a Session,
4958}
4959
4960impl<'a> SessionRpcMcpHeaders<'a> {
4961    /// 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.
4962    ///
4963    /// Wire method: `session.mcp.headers.handlePendingHeadersRefreshRequest`.
4964    ///
4965    /// # Parameters
4966    ///
4967    /// * `params` - MCP headers refresh request id and the host response.
4968    ///
4969    /// # Returns
4970    ///
4971    /// Indicates whether the pending MCP headers refresh response was accepted.
4972    ///
4973    /// <div class="warning">
4974    ///
4975    /// **Experimental.** This API is part of an experimental wire-protocol surface
4976    /// and may change or be removed in future SDK or CLI releases. Pin both the
4977    /// SDK and CLI versions if your code depends on it.
4978    ///
4979    /// </div>
4980    pub async fn handle_pending_headers_refresh_request(
4981        &self,
4982        params: McpHeadersHandlePendingHeadersRefreshRequestRequest,
4983    ) -> Result<McpHeadersHandlePendingHeadersRefreshRequestResult, Error> {
4984        let mut wire_params = serde_json::to_value(params)?;
4985        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4986        let _value = self
4987            .session
4988            .client()
4989            .call(
4990                rpc_methods::SESSION_MCP_HEADERS_HANDLEPENDINGHEADERSREFRESHREQUEST,
4991                Some(wire_params),
4992            )
4993            .await?;
4994        Ok(serde_json::from_value(_value)?)
4995    }
4996}
4997
4998/// `session.mcp.oauth.*` RPCs.
4999#[derive(Clone, Copy)]
5000pub struct SessionRpcMcpOauth<'a> {
5001    pub(crate) session: &'a Session,
5002}
5003
5004impl<'a> SessionRpcMcpOauth<'a> {
5005    /// 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.
5006    ///
5007    /// Wire method: `session.mcp.oauth.respond`.
5008    ///
5009    /// # Parameters
5010    ///
5011    /// * `params` - MCP OAuth request id and optional provider response.
5012    ///
5013    /// # Returns
5014    ///
5015    /// Empty result after recording the MCP OAuth response.
5016    ///
5017    /// <div class="warning">
5018    ///
5019    /// **Experimental.** This API is part of an experimental wire-protocol surface
5020    /// and may change or be removed in future SDK or CLI releases. Pin both the
5021    /// SDK and CLI versions if your code depends on it.
5022    ///
5023    /// </div>
5024    pub(crate) async fn respond(
5025        &self,
5026        params: McpOauthRespondRequest,
5027    ) -> Result<McpOauthRespondResult, Error> {
5028        let mut wire_params = serde_json::to_value(params)?;
5029        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5030        let _value = self
5031            .session
5032            .client()
5033            .call(rpc_methods::SESSION_MCP_OAUTH_RESPOND, Some(wire_params))
5034            .await?;
5035        Ok(serde_json::from_value(_value)?)
5036    }
5037
5038    /// 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.
5039    ///
5040    /// Wire method: `session.mcp.oauth.handlePendingRequest`.
5041    ///
5042    /// # Parameters
5043    ///
5044    /// * `params` - Pending MCP OAuth request ID and host-provided token or cancellation response.
5045    ///
5046    /// # Returns
5047    ///
5048    /// Indicates whether the pending MCP OAuth response was accepted.
5049    ///
5050    /// <div class="warning">
5051    ///
5052    /// **Experimental.** This API is part of an experimental wire-protocol surface
5053    /// and may change or be removed in future SDK or CLI releases. Pin both the
5054    /// SDK and CLI versions if your code depends on it.
5055    ///
5056    /// </div>
5057    pub async fn handle_pending_request(
5058        &self,
5059        params: McpOauthHandlePendingRequest,
5060    ) -> Result<McpOauthHandlePendingResult, Error> {
5061        let mut wire_params = serde_json::to_value(params)?;
5062        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5063        let _value = self
5064            .session
5065            .client()
5066            .call(
5067                rpc_methods::SESSION_MCP_OAUTH_HANDLEPENDINGREQUEST,
5068                Some(wire_params),
5069            )
5070            .await?;
5071        Ok(serde_json::from_value(_value)?)
5072    }
5073
5074    /// Starts OAuth authentication for a remote MCP server.
5075    ///
5076    /// Wire method: `session.mcp.oauth.login`.
5077    ///
5078    /// # Parameters
5079    ///
5080    /// * `params` - Remote MCP server name and optional overrides controlling reauthentication, OAuth client display name, callback success-page copy, and static OAuth client selection.
5081    ///
5082    /// # Returns
5083    ///
5084    /// OAuth authorization URL the caller should open, or empty when cached tokens already authenticated the server.
5085    ///
5086    /// <div class="warning">
5087    ///
5088    /// **Experimental.** This API is part of an experimental wire-protocol surface
5089    /// and may change or be removed in future SDK or CLI releases. Pin both the
5090    /// SDK and CLI versions if your code depends on it.
5091    ///
5092    /// </div>
5093    pub async fn login(&self, params: McpOauthLoginRequest) -> Result<McpOauthLoginResult, Error> {
5094        let mut wire_params = serde_json::to_value(params)?;
5095        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5096        let _value = self
5097            .session
5098            .client()
5099            .call(rpc_methods::SESSION_MCP_OAUTH_LOGIN, Some(wire_params))
5100            .await?;
5101        Ok(serde_json::from_value(_value)?)
5102    }
5103}
5104
5105/// `session.metadata.*` RPCs.
5106#[derive(Clone, Copy)]
5107pub struct SessionRpcMetadata<'a> {
5108    pub(crate) session: &'a Session,
5109}
5110
5111impl<'a> SessionRpcMetadata<'a> {
5112    /// Returns a snapshot of the session's identifying metadata, mode, agent, and remote info.
5113    ///
5114    /// Wire method: `session.metadata.snapshot`.
5115    ///
5116    /// # Returns
5117    ///
5118    /// Point-in-time snapshot of slow-changing session identifier and state fields
5119    ///
5120    /// <div class="warning">
5121    ///
5122    /// **Experimental.** This API is part of an experimental wire-protocol surface
5123    /// and may change or be removed in future SDK or CLI releases. Pin both the
5124    /// SDK and CLI versions if your code depends on it.
5125    ///
5126    /// </div>
5127    pub async fn snapshot(&self) -> Result<SessionMetadataSnapshot, Error> {
5128        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5129        let _value = self
5130            .session
5131            .client()
5132            .call(rpc_methods::SESSION_METADATA_SNAPSHOT, Some(wire_params))
5133            .await?;
5134        Ok(serde_json::from_value(_value)?)
5135    }
5136
5137    /// Reports whether the local session is currently processing user/agent messages.
5138    ///
5139    /// Wire method: `session.metadata.isProcessing`.
5140    ///
5141    /// # Returns
5142    ///
5143    /// Indicates whether the local session is currently processing a turn or background continuation.
5144    ///
5145    /// <div class="warning">
5146    ///
5147    /// **Experimental.** This API is part of an experimental wire-protocol surface
5148    /// and may change or be removed in future SDK or CLI releases. Pin both the
5149    /// SDK and CLI versions if your code depends on it.
5150    ///
5151    /// </div>
5152    pub async fn is_processing(&self) -> Result<MetadataIsProcessingResult, Error> {
5153        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5154        let _value = self
5155            .session
5156            .client()
5157            .call(
5158                rpc_methods::SESSION_METADATA_ISPROCESSING,
5159                Some(wire_params),
5160            )
5161            .await?;
5162        Ok(serde_json::from_value(_value)?)
5163    }
5164
5165    /// Returns a snapshot of activity flags for the session.
5166    ///
5167    /// Wire method: `session.metadata.activity`.
5168    ///
5169    /// # Returns
5170    ///
5171    /// Current activity flags for the session.
5172    ///
5173    /// <div class="warning">
5174    ///
5175    /// **Experimental.** This API is part of an experimental wire-protocol surface
5176    /// and may change or be removed in future SDK or CLI releases. Pin both the
5177    /// SDK and CLI versions if your code depends on it.
5178    ///
5179    /// </div>
5180    pub async fn activity(&self) -> Result<SessionActivity, Error> {
5181        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5182        let _value = self
5183            .session
5184            .client()
5185            .call(rpc_methods::SESSION_METADATA_ACTIVITY, Some(wire_params))
5186            .await?;
5187        Ok(serde_json::from_value(_value)?)
5188    }
5189
5190    /// Returns the token breakdown for the session's current context window for a given model.
5191    ///
5192    /// Wire method: `session.metadata.contextInfo`.
5193    ///
5194    /// # Parameters
5195    ///
5196    /// * `params` - Model identifier and token limits used to compute the context-info breakdown.
5197    ///
5198    /// # Returns
5199    ///
5200    /// Token breakdown for the session's current context window, or null if uninitialized.
5201    ///
5202    /// <div class="warning">
5203    ///
5204    /// **Experimental.** This API is part of an experimental wire-protocol surface
5205    /// and may change or be removed in future SDK or CLI releases. Pin both the
5206    /// SDK and CLI versions if your code depends on it.
5207    ///
5208    /// </div>
5209    pub async fn context_info(
5210        &self,
5211        params: MetadataContextInfoRequest,
5212    ) -> Result<MetadataContextInfoResult, Error> {
5213        let mut wire_params = serde_json::to_value(params)?;
5214        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5215        let _value = self
5216            .session
5217            .client()
5218            .call(rpc_methods::SESSION_METADATA_CONTEXTINFO, Some(wire_params))
5219            .await?;
5220        Ok(serde_json::from_value(_value)?)
5221    }
5222
5223    /// Records a working-directory/git context change and emits a `session.context_changed` event.
5224    ///
5225    /// Wire method: `session.metadata.recordContextChange`.
5226    ///
5227    /// # Parameters
5228    ///
5229    /// * `params` - Updated working-directory/git context to record on the session.
5230    ///
5231    /// # Returns
5232    ///
5233    /// 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).
5234    ///
5235    /// <div class="warning">
5236    ///
5237    /// **Experimental.** This API is part of an experimental wire-protocol surface
5238    /// and may change or be removed in future SDK or CLI releases. Pin both the
5239    /// SDK and CLI versions if your code depends on it.
5240    ///
5241    /// </div>
5242    pub async fn record_context_change(
5243        &self,
5244        params: MetadataRecordContextChangeRequest,
5245    ) -> Result<MetadataRecordContextChangeResult, Error> {
5246        let mut wire_params = serde_json::to_value(params)?;
5247        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5248        let _value = self
5249            .session
5250            .client()
5251            .call(
5252                rpc_methods::SESSION_METADATA_RECORDCONTEXTCHANGE,
5253                Some(wire_params),
5254            )
5255            .await?;
5256        Ok(serde_json::from_value(_value)?)
5257    }
5258
5259    /// Updates the session's recorded working directory.
5260    ///
5261    /// Wire method: `session.metadata.setWorkingDirectory`.
5262    ///
5263    /// # Parameters
5264    ///
5265    /// * `params` - Absolute path to set as the session's new working directory.
5266    ///
5267    /// # Returns
5268    ///
5269    /// 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.
5270    ///
5271    /// <div class="warning">
5272    ///
5273    /// **Experimental.** This API is part of an experimental wire-protocol surface
5274    /// and may change or be removed in future SDK or CLI releases. Pin both the
5275    /// SDK and CLI versions if your code depends on it.
5276    ///
5277    /// </div>
5278    pub async fn set_working_directory(
5279        &self,
5280        params: MetadataSetWorkingDirectoryRequest,
5281    ) -> Result<MetadataSetWorkingDirectoryResult, Error> {
5282        let mut wire_params = serde_json::to_value(params)?;
5283        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5284        let _value = self
5285            .session
5286            .client()
5287            .call(
5288                rpc_methods::SESSION_METADATA_SETWORKINGDIRECTORY,
5289                Some(wire_params),
5290            )
5291            .await?;
5292        Ok(serde_json::from_value(_value)?)
5293    }
5294
5295    /// Re-tokenizes the session's existing messages against a model and returns aggregate token totals.
5296    ///
5297    /// Wire method: `session.metadata.recomputeContextTokens`.
5298    ///
5299    /// # Parameters
5300    ///
5301    /// * `params` - Model identifier to use when re-tokenizing the session's existing messages.
5302    ///
5303    /// # Returns
5304    ///
5305    /// 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.
5306    ///
5307    /// <div class="warning">
5308    ///
5309    /// **Experimental.** This API is part of an experimental wire-protocol surface
5310    /// and may change or be removed in future SDK or CLI releases. Pin both the
5311    /// SDK and CLI versions if your code depends on it.
5312    ///
5313    /// </div>
5314    pub async fn recompute_context_tokens(
5315        &self,
5316        params: MetadataRecomputeContextTokensRequest,
5317    ) -> Result<MetadataRecomputeContextTokensResult, Error> {
5318        let mut wire_params = serde_json::to_value(params)?;
5319        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5320        let _value = self
5321            .session
5322            .client()
5323            .call(
5324                rpc_methods::SESSION_METADATA_RECOMPUTECONTEXTTOKENS,
5325                Some(wire_params),
5326            )
5327            .await?;
5328        Ok(serde_json::from_value(_value)?)
5329    }
5330}
5331
5332/// `session.mode.*` RPCs.
5333#[derive(Clone, Copy)]
5334pub struct SessionRpcMode<'a> {
5335    pub(crate) session: &'a Session,
5336}
5337
5338impl<'a> SessionRpcMode<'a> {
5339    /// Gets the current agent interaction mode.
5340    ///
5341    /// Wire method: `session.mode.get`.
5342    ///
5343    /// # Returns
5344    ///
5345    /// The session mode the agent is operating in
5346    ///
5347    /// <div class="warning">
5348    ///
5349    /// **Experimental.** This API is part of an experimental wire-protocol surface
5350    /// and may change or be removed in future SDK or CLI releases. Pin both the
5351    /// SDK and CLI versions if your code depends on it.
5352    ///
5353    /// </div>
5354    pub async fn get(&self) -> Result<SessionMode, Error> {
5355        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5356        let _value = self
5357            .session
5358            .client()
5359            .call(rpc_methods::SESSION_MODE_GET, Some(wire_params))
5360            .await?;
5361        Ok(serde_json::from_value(_value)?)
5362    }
5363
5364    /// Sets the current agent interaction mode.
5365    ///
5366    /// Wire method: `session.mode.set`.
5367    ///
5368    /// # Parameters
5369    ///
5370    /// * `params` - Agent interaction mode to apply to the session.
5371    ///
5372    /// <div class="warning">
5373    ///
5374    /// **Experimental.** This API is part of an experimental wire-protocol surface
5375    /// and may change or be removed in future SDK or CLI releases. Pin both the
5376    /// SDK and CLI versions if your code depends on it.
5377    ///
5378    /// </div>
5379    pub async fn set(&self, params: ModeSetRequest) -> Result<(), Error> {
5380        let mut wire_params = serde_json::to_value(params)?;
5381        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5382        let _value = self
5383            .session
5384            .client()
5385            .call(rpc_methods::SESSION_MODE_SET, Some(wire_params))
5386            .await?;
5387        Ok(())
5388    }
5389}
5390
5391/// `session.model.*` RPCs.
5392#[derive(Clone, Copy)]
5393pub struct SessionRpcModel<'a> {
5394    pub(crate) session: &'a Session,
5395}
5396
5397impl<'a> SessionRpcModel<'a> {
5398    /// Gets the currently selected model for the session.
5399    ///
5400    /// Wire method: `session.model.getCurrent`.
5401    ///
5402    /// # Returns
5403    ///
5404    /// 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.
5405    ///
5406    /// <div class="warning">
5407    ///
5408    /// **Experimental.** This API is part of an experimental wire-protocol surface
5409    /// and may change or be removed in future SDK or CLI releases. Pin both the
5410    /// SDK and CLI versions if your code depends on it.
5411    ///
5412    /// </div>
5413    pub async fn get_current(&self) -> Result<CurrentModel, Error> {
5414        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5415        let _value = self
5416            .session
5417            .client()
5418            .call(rpc_methods::SESSION_MODEL_GETCURRENT, Some(wire_params))
5419            .await?;
5420        Ok(serde_json::from_value(_value)?)
5421    }
5422
5423    /// Switches the session to a model and optional reasoning configuration.
5424    ///
5425    /// Wire method: `session.model.switchTo`.
5426    ///
5427    /// # Parameters
5428    ///
5429    /// * `params` - Target model identifier and optional reasoning effort, summary, capability overrides, and context tier.
5430    ///
5431    /// # Returns
5432    ///
5433    /// The model identifier active on the session after the switch.
5434    ///
5435    /// <div class="warning">
5436    ///
5437    /// **Experimental.** This API is part of an experimental wire-protocol surface
5438    /// and may change or be removed in future SDK or CLI releases. Pin both the
5439    /// SDK and CLI versions if your code depends on it.
5440    ///
5441    /// </div>
5442    pub async fn switch_to(
5443        &self,
5444        params: ModelSwitchToRequest,
5445    ) -> Result<ModelSwitchToResult, Error> {
5446        let mut wire_params = serde_json::to_value(params)?;
5447        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5448        let _value = self
5449            .session
5450            .client()
5451            .call(rpc_methods::SESSION_MODEL_SWITCHTO, Some(wire_params))
5452            .await?;
5453        Ok(serde_json::from_value(_value)?)
5454    }
5455
5456    /// Updates the session's reasoning effort without changing the selected model.
5457    ///
5458    /// Wire method: `session.model.setReasoningEffort`.
5459    ///
5460    /// # Parameters
5461    ///
5462    /// * `params` - Reasoning effort level to apply to the currently selected model.
5463    ///
5464    /// # Returns
5465    ///
5466    /// 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.
5467    ///
5468    /// <div class="warning">
5469    ///
5470    /// **Experimental.** This API is part of an experimental wire-protocol surface
5471    /// and may change or be removed in future SDK or CLI releases. Pin both the
5472    /// SDK and CLI versions if your code depends on it.
5473    ///
5474    /// </div>
5475    pub async fn set_reasoning_effort(
5476        &self,
5477        params: ModelSetReasoningEffortRequest,
5478    ) -> Result<ModelSetReasoningEffortResult, Error> {
5479        let mut wire_params = serde_json::to_value(params)?;
5480        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5481        let _value = self
5482            .session
5483            .client()
5484            .call(
5485                rpc_methods::SESSION_MODEL_SETREASONINGEFFORT,
5486                Some(wire_params),
5487            )
5488            .await?;
5489        Ok(serde_json::from_value(_value)?)
5490    }
5491
5492    /// 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.
5493    ///
5494    /// Wire method: `session.model.list`.
5495    ///
5496    /// # Returns
5497    ///
5498    /// The list of models available to this session.
5499    ///
5500    /// <div class="warning">
5501    ///
5502    /// **Experimental.** This API is part of an experimental wire-protocol surface
5503    /// and may change or be removed in future SDK or CLI releases. Pin both the
5504    /// SDK and CLI versions if your code depends on it.
5505    ///
5506    /// </div>
5507    pub async fn list(&self) -> Result<SessionModelList, Error> {
5508        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5509        let _value = self
5510            .session
5511            .client()
5512            .call(rpc_methods::SESSION_MODEL_LIST, Some(wire_params))
5513            .await?;
5514        Ok(serde_json::from_value(_value)?)
5515    }
5516
5517    /// 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.
5518    ///
5519    /// Wire method: `session.model.list`.
5520    ///
5521    /// # Parameters
5522    ///
5523    /// * `params` - Optional listing options.
5524    ///
5525    /// # Returns
5526    ///
5527    /// The list of models available to this session.
5528    ///
5529    /// <div class="warning">
5530    ///
5531    /// **Experimental.** This API is part of an experimental wire-protocol surface
5532    /// and may change or be removed in future SDK or CLI releases. Pin both the
5533    /// SDK and CLI versions if your code depends on it.
5534    ///
5535    /// </div>
5536    pub async fn list_with_params(
5537        &self,
5538        params: ModelListRequest,
5539    ) -> Result<SessionModelList, Error> {
5540        let mut wire_params = serde_json::to_value(params)?;
5541        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5542        let _value = self
5543            .session
5544            .client()
5545            .call(rpc_methods::SESSION_MODEL_LIST, Some(wire_params))
5546            .await?;
5547        Ok(serde_json::from_value(_value)?)
5548    }
5549}
5550
5551/// `session.name.*` RPCs.
5552#[derive(Clone, Copy)]
5553pub struct SessionRpcName<'a> {
5554    pub(crate) session: &'a Session,
5555}
5556
5557impl<'a> SessionRpcName<'a> {
5558    /// Gets the session's friendly name.
5559    ///
5560    /// Wire method: `session.name.get`.
5561    ///
5562    /// # Returns
5563    ///
5564    /// The session's friendly name, or null when not yet set.
5565    ///
5566    /// <div class="warning">
5567    ///
5568    /// **Experimental.** This API is part of an experimental wire-protocol surface
5569    /// and may change or be removed in future SDK or CLI releases. Pin both the
5570    /// SDK and CLI versions if your code depends on it.
5571    ///
5572    /// </div>
5573    pub async fn get(&self) -> Result<NameGetResult, Error> {
5574        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5575        let _value = self
5576            .session
5577            .client()
5578            .call(rpc_methods::SESSION_NAME_GET, Some(wire_params))
5579            .await?;
5580        Ok(serde_json::from_value(_value)?)
5581    }
5582
5583    /// Sets the session's friendly name.
5584    ///
5585    /// Wire method: `session.name.set`.
5586    ///
5587    /// # Parameters
5588    ///
5589    /// * `params` - New friendly name to apply to the session.
5590    ///
5591    /// <div class="warning">
5592    ///
5593    /// **Experimental.** This API is part of an experimental wire-protocol surface
5594    /// and may change or be removed in future SDK or CLI releases. Pin both the
5595    /// SDK and CLI versions if your code depends on it.
5596    ///
5597    /// </div>
5598    pub async fn set(&self, params: NameSetRequest) -> Result<(), Error> {
5599        let mut wire_params = serde_json::to_value(params)?;
5600        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5601        let _value = self
5602            .session
5603            .client()
5604            .call(rpc_methods::SESSION_NAME_SET, Some(wire_params))
5605            .await?;
5606        Ok(())
5607    }
5608
5609    /// Persists an auto-generated session summary as the session's name when no user-set name exists.
5610    ///
5611    /// Wire method: `session.name.setAuto`.
5612    ///
5613    /// # Parameters
5614    ///
5615    /// * `params` - Auto-generated session summary to apply as the session's name when no user-set name exists.
5616    ///
5617    /// # Returns
5618    ///
5619    /// Indicates whether the auto-generated summary was applied as the session's name.
5620    ///
5621    /// <div class="warning">
5622    ///
5623    /// **Experimental.** This API is part of an experimental wire-protocol surface
5624    /// and may change or be removed in future SDK or CLI releases. Pin both the
5625    /// SDK and CLI versions if your code depends on it.
5626    ///
5627    /// </div>
5628    pub async fn set_auto(&self, params: NameSetAutoRequest) -> Result<NameSetAutoResult, Error> {
5629        let mut wire_params = serde_json::to_value(params)?;
5630        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5631        let _value = self
5632            .session
5633            .client()
5634            .call(rpc_methods::SESSION_NAME_SETAUTO, Some(wire_params))
5635            .await?;
5636        Ok(serde_json::from_value(_value)?)
5637    }
5638}
5639
5640/// `session.options.*` RPCs.
5641#[derive(Clone, Copy)]
5642pub struct SessionRpcOptions<'a> {
5643    pub(crate) session: &'a Session,
5644}
5645
5646impl<'a> SessionRpcOptions<'a> {
5647    /// Patches the genuinely-mutable subset of session options.
5648    ///
5649    /// Wire method: `session.options.update`.
5650    ///
5651    /// # Parameters
5652    ///
5653    /// * `params` - Patch of mutable session options to apply to the running session.
5654    ///
5655    /// # Returns
5656    ///
5657    /// Indicates whether the session options patch was applied successfully.
5658    ///
5659    /// <div class="warning">
5660    ///
5661    /// **Experimental.** This API is part of an experimental wire-protocol surface
5662    /// and may change or be removed in future SDK or CLI releases. Pin both the
5663    /// SDK and CLI versions if your code depends on it.
5664    ///
5665    /// </div>
5666    pub async fn update(
5667        &self,
5668        params: SessionUpdateOptionsParams,
5669    ) -> Result<SessionUpdateOptionsResult, Error> {
5670        let mut wire_params = serde_json::to_value(params)?;
5671        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5672        let _value = self
5673            .session
5674            .client()
5675            .call(rpc_methods::SESSION_OPTIONS_UPDATE, Some(wire_params))
5676            .await?;
5677        Ok(serde_json::from_value(_value)?)
5678    }
5679}
5680
5681/// `session.permissions.*` RPCs.
5682#[derive(Clone, Copy)]
5683pub struct SessionRpcPermissions<'a> {
5684    pub(crate) session: &'a Session,
5685}
5686
5687impl<'a> SessionRpcPermissions<'a> {
5688    /// `session.permissions.folderTrust.*` sub-namespace.
5689    pub fn folder_trust(&self) -> SessionRpcPermissionsFolderTrust<'a> {
5690        SessionRpcPermissionsFolderTrust {
5691            session: self.session,
5692        }
5693    }
5694
5695    /// `session.permissions.locations.*` sub-namespace.
5696    pub fn locations(&self) -> SessionRpcPermissionsLocations<'a> {
5697        SessionRpcPermissionsLocations {
5698            session: self.session,
5699        }
5700    }
5701
5702    /// `session.permissions.paths.*` sub-namespace.
5703    pub fn paths(&self) -> SessionRpcPermissionsPaths<'a> {
5704        SessionRpcPermissionsPaths {
5705            session: self.session,
5706        }
5707    }
5708
5709    /// `session.permissions.urls.*` sub-namespace.
5710    pub fn urls(&self) -> SessionRpcPermissionsUrls<'a> {
5711        SessionRpcPermissionsUrls {
5712            session: self.session,
5713        }
5714    }
5715
5716    /// Replaces selected permission policy fields (rules, paths, URLs, exclusions, allow-all flags) on the session.
5717    ///
5718    /// Wire method: `session.permissions.configure`.
5719    ///
5720    /// # Parameters
5721    ///
5722    /// * `params` - Patch of permission policy fields to apply (omit a field to leave it unchanged).
5723    ///
5724    /// # Returns
5725    ///
5726    /// Indicates whether the operation succeeded.
5727    ///
5728    /// <div class="warning">
5729    ///
5730    /// **Experimental.** This API is part of an experimental wire-protocol surface
5731    /// and may change or be removed in future SDK or CLI releases. Pin both the
5732    /// SDK and CLI versions if your code depends on it.
5733    ///
5734    /// </div>
5735    pub async fn configure(
5736        &self,
5737        params: PermissionsConfigureParams,
5738    ) -> Result<PermissionsConfigureResult, Error> {
5739        let mut wire_params = serde_json::to_value(params)?;
5740        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5741        let _value = self
5742            .session
5743            .client()
5744            .call(
5745                rpc_methods::SESSION_PERMISSIONS_CONFIGURE,
5746                Some(wire_params),
5747            )
5748            .await?;
5749        Ok(serde_json::from_value(_value)?)
5750    }
5751
5752    /// Provides a decision for a pending tool permission request.
5753    ///
5754    /// Wire method: `session.permissions.handlePendingPermissionRequest`.
5755    ///
5756    /// # Parameters
5757    ///
5758    /// * `params` - Pending permission request ID and the decision to apply (approve/reject and scope).
5759    ///
5760    /// # Returns
5761    ///
5762    /// Indicates whether the permission decision was applied; false when the request was already resolved.
5763    ///
5764    /// <div class="warning">
5765    ///
5766    /// **Experimental.** This API is part of an experimental wire-protocol surface
5767    /// and may change or be removed in future SDK or CLI releases. Pin both the
5768    /// SDK and CLI versions if your code depends on it.
5769    ///
5770    /// </div>
5771    pub async fn handle_pending_permission_request(
5772        &self,
5773        params: PermissionDecisionRequest,
5774    ) -> Result<PermissionRequestResult, Error> {
5775        let mut wire_params = serde_json::to_value(params)?;
5776        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5777        let _value = self
5778            .session
5779            .client()
5780            .call(
5781                rpc_methods::SESSION_PERMISSIONS_HANDLEPENDINGPERMISSIONREQUEST,
5782                Some(wire_params),
5783            )
5784            .await?;
5785        Ok(serde_json::from_value(_value)?)
5786    }
5787
5788    /// Reconstructs the set of pending tool permission requests from the session's event history.
5789    ///
5790    /// Wire method: `session.permissions.pendingRequests`.
5791    ///
5792    /// # Returns
5793    ///
5794    /// List of pending permission requests reconstructed from event history.
5795    ///
5796    /// <div class="warning">
5797    ///
5798    /// **Experimental.** This API is part of an experimental wire-protocol surface
5799    /// and may change or be removed in future SDK or CLI releases. Pin both the
5800    /// SDK and CLI versions if your code depends on it.
5801    ///
5802    /// </div>
5803    pub async fn pending_requests(&self) -> Result<PendingPermissionRequestList, Error> {
5804        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5805        let _value = self
5806            .session
5807            .client()
5808            .call(
5809                rpc_methods::SESSION_PERMISSIONS_PENDINGREQUESTS,
5810                Some(wire_params),
5811            )
5812            .await?;
5813        Ok(serde_json::from_value(_value)?)
5814    }
5815
5816    /// Enables or disables automatic approval of tool permission requests for the session.
5817    ///
5818    /// Wire method: `session.permissions.setApproveAll`.
5819    ///
5820    /// # Parameters
5821    ///
5822    /// * `params` - Allow-all toggle for tool permission requests, with an optional telemetry source.
5823    ///
5824    /// # Returns
5825    ///
5826    /// Indicates whether the operation succeeded.
5827    ///
5828    /// <div class="warning">
5829    ///
5830    /// **Experimental.** This API is part of an experimental wire-protocol surface
5831    /// and may change or be removed in future SDK or CLI releases. Pin both the
5832    /// SDK and CLI versions if your code depends on it.
5833    ///
5834    /// </div>
5835    pub async fn set_approve_all(
5836        &self,
5837        params: PermissionsSetApproveAllRequest,
5838    ) -> Result<PermissionsSetApproveAllResult, Error> {
5839        let mut wire_params = serde_json::to_value(params)?;
5840        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5841        let _value = self
5842            .session
5843            .client()
5844            .call(
5845                rpc_methods::SESSION_PERMISSIONS_SETAPPROVEALL,
5846                Some(wire_params),
5847            )
5848            .await?;
5849        Ok(serde_json::from_value(_value)?)
5850    }
5851
5852    /// 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.
5853    ///
5854    /// Wire method: `session.permissions.setAllowAll`.
5855    ///
5856    /// # Parameters
5857    ///
5858    /// * `params` - Whether to enable full allow-all permissions for the session.
5859    ///
5860    /// # Returns
5861    ///
5862    /// Indicates whether the operation succeeded and reports the post-mutation state.
5863    ///
5864    /// <div class="warning">
5865    ///
5866    /// **Experimental.** This API is part of an experimental wire-protocol surface
5867    /// and may change or be removed in future SDK or CLI releases. Pin both the
5868    /// SDK and CLI versions if your code depends on it.
5869    ///
5870    /// </div>
5871    pub async fn set_allow_all(
5872        &self,
5873        params: PermissionsSetAllowAllRequest,
5874    ) -> Result<AllowAllPermissionSetResult, Error> {
5875        let mut wire_params = serde_json::to_value(params)?;
5876        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5877        let _value = self
5878            .session
5879            .client()
5880            .call(
5881                rpc_methods::SESSION_PERMISSIONS_SETALLOWALL,
5882                Some(wire_params),
5883            )
5884            .await?;
5885        Ok(serde_json::from_value(_value)?)
5886    }
5887
5888    /// Returns whether full allow-all permissions are currently active for the session.
5889    ///
5890    /// Wire method: `session.permissions.getAllowAll`.
5891    ///
5892    /// # Returns
5893    ///
5894    /// Current full allow-all permission state.
5895    ///
5896    /// <div class="warning">
5897    ///
5898    /// **Experimental.** This API is part of an experimental wire-protocol surface
5899    /// and may change or be removed in future SDK or CLI releases. Pin both the
5900    /// SDK and CLI versions if your code depends on it.
5901    ///
5902    /// </div>
5903    pub async fn get_allow_all(&self) -> Result<AllowAllPermissionState, Error> {
5904        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5905        let _value = self
5906            .session
5907            .client()
5908            .call(
5909                rpc_methods::SESSION_PERMISSIONS_GETALLOWALL,
5910                Some(wire_params),
5911            )
5912            .await?;
5913        Ok(serde_json::from_value(_value)?)
5914    }
5915
5916    /// Adds or removes session-scoped or location-scoped permission rules.
5917    ///
5918    /// Wire method: `session.permissions.modifyRules`.
5919    ///
5920    /// # Parameters
5921    ///
5922    /// * `params` - Scope and add/remove instructions for modifying session- or location-scoped permission rules.
5923    ///
5924    /// # Returns
5925    ///
5926    /// Indicates whether the operation succeeded.
5927    ///
5928    /// <div class="warning">
5929    ///
5930    /// **Experimental.** This API is part of an experimental wire-protocol surface
5931    /// and may change or be removed in future SDK or CLI releases. Pin both the
5932    /// SDK and CLI versions if your code depends on it.
5933    ///
5934    /// </div>
5935    pub async fn modify_rules(
5936        &self,
5937        params: PermissionsModifyRulesParams,
5938    ) -> Result<PermissionsModifyRulesResult, Error> {
5939        let mut wire_params = serde_json::to_value(params)?;
5940        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5941        let _value = self
5942            .session
5943            .client()
5944            .call(
5945                rpc_methods::SESSION_PERMISSIONS_MODIFYRULES,
5946                Some(wire_params),
5947            )
5948            .await?;
5949        Ok(serde_json::from_value(_value)?)
5950    }
5951
5952    /// Sets whether the client wants permission prompts bridged into session events.
5953    ///
5954    /// Wire method: `session.permissions.setRequired`.
5955    ///
5956    /// # Parameters
5957    ///
5958    /// * `params` - Toggles whether permission prompts should be bridged into session events for this client.
5959    ///
5960    /// # Returns
5961    ///
5962    /// Indicates whether the operation succeeded.
5963    ///
5964    /// <div class="warning">
5965    ///
5966    /// **Experimental.** This API is part of an experimental wire-protocol surface
5967    /// and may change or be removed in future SDK or CLI releases. Pin both the
5968    /// SDK and CLI versions if your code depends on it.
5969    ///
5970    /// </div>
5971    pub async fn set_required(
5972        &self,
5973        params: PermissionsSetRequiredRequest,
5974    ) -> Result<PermissionsSetRequiredResult, Error> {
5975        let mut wire_params = serde_json::to_value(params)?;
5976        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5977        let _value = self
5978            .session
5979            .client()
5980            .call(
5981                rpc_methods::SESSION_PERMISSIONS_SETREQUIRED,
5982                Some(wire_params),
5983            )
5984            .await?;
5985        Ok(serde_json::from_value(_value)?)
5986    }
5987
5988    /// Clears session-scoped tool permission approvals.
5989    ///
5990    /// Wire method: `session.permissions.resetSessionApprovals`.
5991    ///
5992    /// # Returns
5993    ///
5994    /// Indicates whether the operation succeeded.
5995    ///
5996    /// <div class="warning">
5997    ///
5998    /// **Experimental.** This API is part of an experimental wire-protocol surface
5999    /// and may change or be removed in future SDK or CLI releases. Pin both the
6000    /// SDK and CLI versions if your code depends on it.
6001    ///
6002    /// </div>
6003    pub async fn reset_session_approvals(
6004        &self,
6005    ) -> Result<PermissionsResetSessionApprovalsResult, Error> {
6006        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6007        let _value = self
6008            .session
6009            .client()
6010            .call(
6011                rpc_methods::SESSION_PERMISSIONS_RESETSESSIONAPPROVALS,
6012                Some(wire_params),
6013            )
6014            .await?;
6015        Ok(serde_json::from_value(_value)?)
6016    }
6017
6018    /// Notifies the runtime that a permission prompt UI has been shown to the user.
6019    ///
6020    /// Wire method: `session.permissions.notifyPromptShown`.
6021    ///
6022    /// # Parameters
6023    ///
6024    /// * `params` - Notification payload describing the permission prompt that the client just rendered.
6025    ///
6026    /// # Returns
6027    ///
6028    /// Indicates whether the operation succeeded.
6029    ///
6030    /// <div class="warning">
6031    ///
6032    /// **Experimental.** This API is part of an experimental wire-protocol surface
6033    /// and may change or be removed in future SDK or CLI releases. Pin both the
6034    /// SDK and CLI versions if your code depends on it.
6035    ///
6036    /// </div>
6037    pub async fn notify_prompt_shown(
6038        &self,
6039        params: PermissionPromptShownNotification,
6040    ) -> Result<PermissionsNotifyPromptShownResult, Error> {
6041        let mut wire_params = serde_json::to_value(params)?;
6042        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6043        let _value = self
6044            .session
6045            .client()
6046            .call(
6047                rpc_methods::SESSION_PERMISSIONS_NOTIFYPROMPTSHOWN,
6048                Some(wire_params),
6049            )
6050            .await?;
6051        Ok(serde_json::from_value(_value)?)
6052    }
6053}
6054
6055/// `session.permissions.folderTrust.*` RPCs.
6056#[derive(Clone, Copy)]
6057pub struct SessionRpcPermissionsFolderTrust<'a> {
6058    pub(crate) session: &'a Session,
6059}
6060
6061impl<'a> SessionRpcPermissionsFolderTrust<'a> {
6062    /// Reports whether a folder is trusted according to the user's folder trust state.
6063    ///
6064    /// Wire method: `session.permissions.folderTrust.isTrusted`.
6065    ///
6066    /// # Parameters
6067    ///
6068    /// * `params` - Folder path to check for trust.
6069    ///
6070    /// # Returns
6071    ///
6072    /// Folder trust check result.
6073    ///
6074    /// <div class="warning">
6075    ///
6076    /// **Experimental.** This API is part of an experimental wire-protocol surface
6077    /// and may change or be removed in future SDK or CLI releases. Pin both the
6078    /// SDK and CLI versions if your code depends on it.
6079    ///
6080    /// </div>
6081    pub async fn is_trusted(
6082        &self,
6083        params: FolderTrustCheckParams,
6084    ) -> Result<FolderTrustCheckResult, Error> {
6085        let mut wire_params = serde_json::to_value(params)?;
6086        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6087        let _value = self
6088            .session
6089            .client()
6090            .call(
6091                rpc_methods::SESSION_PERMISSIONS_FOLDERTRUST_ISTRUSTED,
6092                Some(wire_params),
6093            )
6094            .await?;
6095        Ok(serde_json::from_value(_value)?)
6096    }
6097
6098    /// Adds a folder to the user's trusted folders list.
6099    ///
6100    /// Wire method: `session.permissions.folderTrust.addTrusted`.
6101    ///
6102    /// # Parameters
6103    ///
6104    /// * `params` - Folder path to add to trusted folders.
6105    ///
6106    /// # Returns
6107    ///
6108    /// Indicates whether the operation succeeded.
6109    ///
6110    /// <div class="warning">
6111    ///
6112    /// **Experimental.** This API is part of an experimental wire-protocol surface
6113    /// and may change or be removed in future SDK or CLI releases. Pin both the
6114    /// SDK and CLI versions if your code depends on it.
6115    ///
6116    /// </div>
6117    pub async fn add_trusted(
6118        &self,
6119        params: FolderTrustAddParams,
6120    ) -> Result<PermissionsFolderTrustAddTrustedResult, Error> {
6121        let mut wire_params = serde_json::to_value(params)?;
6122        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6123        let _value = self
6124            .session
6125            .client()
6126            .call(
6127                rpc_methods::SESSION_PERMISSIONS_FOLDERTRUST_ADDTRUSTED,
6128                Some(wire_params),
6129            )
6130            .await?;
6131        Ok(serde_json::from_value(_value)?)
6132    }
6133}
6134
6135/// `session.permissions.locations.*` RPCs.
6136#[derive(Clone, Copy)]
6137pub struct SessionRpcPermissionsLocations<'a> {
6138    pub(crate) session: &'a Session,
6139}
6140
6141impl<'a> SessionRpcPermissionsLocations<'a> {
6142    /// Resolves the permission location key and type for a working directory.
6143    ///
6144    /// Wire method: `session.permissions.locations.resolve`.
6145    ///
6146    /// # Parameters
6147    ///
6148    /// * `params` - Working directory to resolve into a location-permissions key.
6149    ///
6150    /// # Returns
6151    ///
6152    /// Resolved location-permissions key and type.
6153    ///
6154    /// <div class="warning">
6155    ///
6156    /// **Experimental.** This API is part of an experimental wire-protocol surface
6157    /// and may change or be removed in future SDK or CLI releases. Pin both the
6158    /// SDK and CLI versions if your code depends on it.
6159    ///
6160    /// </div>
6161    pub async fn resolve(
6162        &self,
6163        params: PermissionLocationResolveParams,
6164    ) -> Result<PermissionLocationResolveResult, Error> {
6165        let mut wire_params = serde_json::to_value(params)?;
6166        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6167        let _value = self
6168            .session
6169            .client()
6170            .call(
6171                rpc_methods::SESSION_PERMISSIONS_LOCATIONS_RESOLVE,
6172                Some(wire_params),
6173            )
6174            .await?;
6175        Ok(serde_json::from_value(_value)?)
6176    }
6177
6178    /// Applies persisted location-scoped tool approvals and allowed directories for a working directory to this session's permission service.
6179    ///
6180    /// Wire method: `session.permissions.locations.apply`.
6181    ///
6182    /// # Parameters
6183    ///
6184    /// * `params` - Working directory to load persisted location permissions for.
6185    ///
6186    /// # Returns
6187    ///
6188    /// Summary of persisted location permissions applied to the session.
6189    ///
6190    /// <div class="warning">
6191    ///
6192    /// **Experimental.** This API is part of an experimental wire-protocol surface
6193    /// and may change or be removed in future SDK or CLI releases. Pin both the
6194    /// SDK and CLI versions if your code depends on it.
6195    ///
6196    /// </div>
6197    pub async fn apply(
6198        &self,
6199        params: PermissionLocationApplyParams,
6200    ) -> Result<PermissionLocationApplyResult, Error> {
6201        let mut wire_params = serde_json::to_value(params)?;
6202        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6203        let _value = self
6204            .session
6205            .client()
6206            .call(
6207                rpc_methods::SESSION_PERMISSIONS_LOCATIONS_APPLY,
6208                Some(wire_params),
6209            )
6210            .await?;
6211        Ok(serde_json::from_value(_value)?)
6212    }
6213
6214    /// Persists a tool approval for a permission location and applies its rules to this session's live permission service.
6215    ///
6216    /// Wire method: `session.permissions.locations.addToolApproval`.
6217    ///
6218    /// # Parameters
6219    ///
6220    /// * `params` - Location-scoped tool approval to persist.
6221    ///
6222    /// # Returns
6223    ///
6224    /// Indicates whether the operation succeeded.
6225    ///
6226    /// <div class="warning">
6227    ///
6228    /// **Experimental.** This API is part of an experimental wire-protocol surface
6229    /// and may change or be removed in future SDK or CLI releases. Pin both the
6230    /// SDK and CLI versions if your code depends on it.
6231    ///
6232    /// </div>
6233    pub async fn add_tool_approval(
6234        &self,
6235        params: PermissionLocationAddToolApprovalParams,
6236    ) -> Result<PermissionsLocationsAddToolApprovalResult, Error> {
6237        let mut wire_params = serde_json::to_value(params)?;
6238        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6239        let _value = self
6240            .session
6241            .client()
6242            .call(
6243                rpc_methods::SESSION_PERMISSIONS_LOCATIONS_ADDTOOLAPPROVAL,
6244                Some(wire_params),
6245            )
6246            .await?;
6247        Ok(serde_json::from_value(_value)?)
6248    }
6249}
6250
6251/// `session.permissions.paths.*` RPCs.
6252#[derive(Clone, Copy)]
6253pub struct SessionRpcPermissionsPaths<'a> {
6254    pub(crate) session: &'a Session,
6255}
6256
6257impl<'a> SessionRpcPermissionsPaths<'a> {
6258    /// Returns the session's allowed directories and primary working directory.
6259    ///
6260    /// Wire method: `session.permissions.paths.list`.
6261    ///
6262    /// # Returns
6263    ///
6264    /// Snapshot of the session's allow-listed directories and primary working directory.
6265    ///
6266    /// <div class="warning">
6267    ///
6268    /// **Experimental.** This API is part of an experimental wire-protocol surface
6269    /// and may change or be removed in future SDK or CLI releases. Pin both the
6270    /// SDK and CLI versions if your code depends on it.
6271    ///
6272    /// </div>
6273    pub async fn list(&self) -> Result<PermissionPathsList, Error> {
6274        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6275        let _value = self
6276            .session
6277            .client()
6278            .call(
6279                rpc_methods::SESSION_PERMISSIONS_PATHS_LIST,
6280                Some(wire_params),
6281            )
6282            .await?;
6283        Ok(serde_json::from_value(_value)?)
6284    }
6285
6286    /// Adds a directory to the session's allow-list.
6287    ///
6288    /// Wire method: `session.permissions.paths.add`.
6289    ///
6290    /// # Parameters
6291    ///
6292    /// * `params` - Directory path to add to the session's allowed directories.
6293    ///
6294    /// # Returns
6295    ///
6296    /// Indicates whether the operation succeeded.
6297    ///
6298    /// <div class="warning">
6299    ///
6300    /// **Experimental.** This API is part of an experimental wire-protocol surface
6301    /// and may change or be removed in future SDK or CLI releases. Pin both the
6302    /// SDK and CLI versions if your code depends on it.
6303    ///
6304    /// </div>
6305    pub async fn add(
6306        &self,
6307        params: PermissionPathsAddParams,
6308    ) -> Result<PermissionsPathsAddResult, Error> {
6309        let mut wire_params = serde_json::to_value(params)?;
6310        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6311        let _value = self
6312            .session
6313            .client()
6314            .call(
6315                rpc_methods::SESSION_PERMISSIONS_PATHS_ADD,
6316                Some(wire_params),
6317            )
6318            .await?;
6319        Ok(serde_json::from_value(_value)?)
6320    }
6321
6322    /// Updates the session's primary working directory used by the permission policy.
6323    ///
6324    /// Wire method: `session.permissions.paths.updatePrimary`.
6325    ///
6326    /// # Parameters
6327    ///
6328    /// * `params` - Directory path to set as the session's new primary working directory.
6329    ///
6330    /// # Returns
6331    ///
6332    /// Indicates whether the operation succeeded.
6333    ///
6334    /// <div class="warning">
6335    ///
6336    /// **Experimental.** This API is part of an experimental wire-protocol surface
6337    /// and may change or be removed in future SDK or CLI releases. Pin both the
6338    /// SDK and CLI versions if your code depends on it.
6339    ///
6340    /// </div>
6341    pub async fn update_primary(
6342        &self,
6343        params: PermissionPathsUpdatePrimaryParams,
6344    ) -> Result<PermissionsPathsUpdatePrimaryResult, Error> {
6345        let mut wire_params = serde_json::to_value(params)?;
6346        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6347        let _value = self
6348            .session
6349            .client()
6350            .call(
6351                rpc_methods::SESSION_PERMISSIONS_PATHS_UPDATEPRIMARY,
6352                Some(wire_params),
6353            )
6354            .await?;
6355        Ok(serde_json::from_value(_value)?)
6356    }
6357
6358    /// Reports whether a path falls within any of the session's allowed directories.
6359    ///
6360    /// Wire method: `session.permissions.paths.isPathWithinAllowedDirectories`.
6361    ///
6362    /// # Parameters
6363    ///
6364    /// * `params` - Path to evaluate against the session's allowed directories.
6365    ///
6366    /// # Returns
6367    ///
6368    /// Indicates whether the supplied path is within the session's allowed directories.
6369    ///
6370    /// <div class="warning">
6371    ///
6372    /// **Experimental.** This API is part of an experimental wire-protocol surface
6373    /// and may change or be removed in future SDK or CLI releases. Pin both the
6374    /// SDK and CLI versions if your code depends on it.
6375    ///
6376    /// </div>
6377    pub async fn is_path_within_allowed_directories(
6378        &self,
6379        params: PermissionPathsAllowedCheckParams,
6380    ) -> Result<PermissionPathsAllowedCheckResult, Error> {
6381        let mut wire_params = serde_json::to_value(params)?;
6382        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6383        let _value = self
6384            .session
6385            .client()
6386            .call(
6387                rpc_methods::SESSION_PERMISSIONS_PATHS_ISPATHWITHINALLOWEDDIRECTORIES,
6388                Some(wire_params),
6389            )
6390            .await?;
6391        Ok(serde_json::from_value(_value)?)
6392    }
6393
6394    /// Reports whether a path falls within the session's workspace (primary) directory.
6395    ///
6396    /// Wire method: `session.permissions.paths.isPathWithinWorkspace`.
6397    ///
6398    /// # Parameters
6399    ///
6400    /// * `params` - Path to evaluate against the session's workspace (primary) directory.
6401    ///
6402    /// # Returns
6403    ///
6404    /// Indicates whether the supplied path is within the session's workspace directory.
6405    ///
6406    /// <div class="warning">
6407    ///
6408    /// **Experimental.** This API is part of an experimental wire-protocol surface
6409    /// and may change or be removed in future SDK or CLI releases. Pin both the
6410    /// SDK and CLI versions if your code depends on it.
6411    ///
6412    /// </div>
6413    pub async fn is_path_within_workspace(
6414        &self,
6415        params: PermissionPathsWorkspaceCheckParams,
6416    ) -> Result<PermissionPathsWorkspaceCheckResult, Error> {
6417        let mut wire_params = serde_json::to_value(params)?;
6418        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6419        let _value = self
6420            .session
6421            .client()
6422            .call(
6423                rpc_methods::SESSION_PERMISSIONS_PATHS_ISPATHWITHINWORKSPACE,
6424                Some(wire_params),
6425            )
6426            .await?;
6427        Ok(serde_json::from_value(_value)?)
6428    }
6429}
6430
6431/// `session.permissions.urls.*` RPCs.
6432#[derive(Clone, Copy)]
6433pub struct SessionRpcPermissionsUrls<'a> {
6434    pub(crate) session: &'a Session,
6435}
6436
6437impl<'a> SessionRpcPermissionsUrls<'a> {
6438    /// Toggles the runtime's URL-permission policy between unrestricted and restricted modes.
6439    ///
6440    /// Wire method: `session.permissions.urls.setUnrestrictedMode`.
6441    ///
6442    /// # Parameters
6443    ///
6444    /// * `params` - Whether the URL-permission policy should run in unrestricted mode.
6445    ///
6446    /// # Returns
6447    ///
6448    /// Indicates whether the operation succeeded.
6449    ///
6450    /// <div class="warning">
6451    ///
6452    /// **Experimental.** This API is part of an experimental wire-protocol surface
6453    /// and may change or be removed in future SDK or CLI releases. Pin both the
6454    /// SDK and CLI versions if your code depends on it.
6455    ///
6456    /// </div>
6457    pub async fn set_unrestricted_mode(
6458        &self,
6459        params: PermissionUrlsSetUnrestrictedModeParams,
6460    ) -> Result<PermissionsUrlsSetUnrestrictedModeResult, Error> {
6461        let mut wire_params = serde_json::to_value(params)?;
6462        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6463        let _value = self
6464            .session
6465            .client()
6466            .call(
6467                rpc_methods::SESSION_PERMISSIONS_URLS_SETUNRESTRICTEDMODE,
6468                Some(wire_params),
6469            )
6470            .await?;
6471        Ok(serde_json::from_value(_value)?)
6472    }
6473}
6474
6475/// `session.plan.*` RPCs.
6476#[derive(Clone, Copy)]
6477pub struct SessionRpcPlan<'a> {
6478    pub(crate) session: &'a Session,
6479}
6480
6481impl<'a> SessionRpcPlan<'a> {
6482    /// Reads the session plan file from the workspace.
6483    ///
6484    /// Wire method: `session.plan.read`.
6485    ///
6486    /// # Returns
6487    ///
6488    /// Existence, contents, and resolved path of the session plan file.
6489    ///
6490    /// <div class="warning">
6491    ///
6492    /// **Experimental.** This API is part of an experimental wire-protocol surface
6493    /// and may change or be removed in future SDK or CLI releases. Pin both the
6494    /// SDK and CLI versions if your code depends on it.
6495    ///
6496    /// </div>
6497    pub async fn read(&self) -> Result<PlanReadResult, Error> {
6498        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6499        let _value = self
6500            .session
6501            .client()
6502            .call(rpc_methods::SESSION_PLAN_READ, Some(wire_params))
6503            .await?;
6504        Ok(serde_json::from_value(_value)?)
6505    }
6506
6507    /// Writes new content to the session plan file.
6508    ///
6509    /// Wire method: `session.plan.update`.
6510    ///
6511    /// # Parameters
6512    ///
6513    /// * `params` - Replacement contents to write to the session plan file.
6514    ///
6515    /// <div class="warning">
6516    ///
6517    /// **Experimental.** This API is part of an experimental wire-protocol surface
6518    /// and may change or be removed in future SDK or CLI releases. Pin both the
6519    /// SDK and CLI versions if your code depends on it.
6520    ///
6521    /// </div>
6522    pub async fn update(&self, params: PlanUpdateRequest) -> Result<(), Error> {
6523        let mut wire_params = serde_json::to_value(params)?;
6524        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6525        let _value = self
6526            .session
6527            .client()
6528            .call(rpc_methods::SESSION_PLAN_UPDATE, Some(wire_params))
6529            .await?;
6530        Ok(())
6531    }
6532
6533    /// Deletes the session plan file from the workspace.
6534    ///
6535    /// Wire method: `session.plan.delete`.
6536    ///
6537    /// <div class="warning">
6538    ///
6539    /// **Experimental.** This API is part of an experimental wire-protocol surface
6540    /// and may change or be removed in future SDK or CLI releases. Pin both the
6541    /// SDK and CLI versions if your code depends on it.
6542    ///
6543    /// </div>
6544    pub async fn delete(&self) -> Result<(), Error> {
6545        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6546        let _value = self
6547            .session
6548            .client()
6549            .call(rpc_methods::SESSION_PLAN_DELETE, Some(wire_params))
6550            .await?;
6551        Ok(())
6552    }
6553
6554    /// Reads todo rows from the session SQL database for plan rendering.
6555    ///
6556    /// Wire method: `session.plan.readSqlTodos`.
6557    ///
6558    /// # Returns
6559    ///
6560    /// Todo rows read from the session SQL database. Empty when no session database is available.
6561    ///
6562    /// <div class="warning">
6563    ///
6564    /// **Experimental.** This API is part of an experimental wire-protocol surface
6565    /// and may change or be removed in future SDK or CLI releases. Pin both the
6566    /// SDK and CLI versions if your code depends on it.
6567    ///
6568    /// </div>
6569    pub async fn read_sql_todos(&self) -> Result<PlanReadSqlTodosResult, Error> {
6570        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6571        let _value = self
6572            .session
6573            .client()
6574            .call(rpc_methods::SESSION_PLAN_READSQLTODOS, Some(wire_params))
6575            .await?;
6576        Ok(serde_json::from_value(_value)?)
6577    }
6578
6579    /// 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.
6580    ///
6581    /// Wire method: `session.plan.readSqlTodosWithDependencies`.
6582    ///
6583    /// # Returns
6584    ///
6585    /// Todo rows + dependency edges read from the session SQL database.
6586    ///
6587    /// <div class="warning">
6588    ///
6589    /// **Experimental.** This API is part of an experimental wire-protocol surface
6590    /// and may change or be removed in future SDK or CLI releases. Pin both the
6591    /// SDK and CLI versions if your code depends on it.
6592    ///
6593    /// </div>
6594    pub async fn read_sql_todos_with_dependencies(
6595        &self,
6596    ) -> Result<PlanReadSqlTodosWithDependenciesResult, Error> {
6597        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6598        let _value = self
6599            .session
6600            .client()
6601            .call(
6602                rpc_methods::SESSION_PLAN_READSQLTODOSWITHDEPENDENCIES,
6603                Some(wire_params),
6604            )
6605            .await?;
6606        Ok(serde_json::from_value(_value)?)
6607    }
6608}
6609
6610/// `session.plugins.*` RPCs.
6611#[derive(Clone, Copy)]
6612pub struct SessionRpcPlugins<'a> {
6613    pub(crate) session: &'a Session,
6614}
6615
6616impl<'a> SessionRpcPlugins<'a> {
6617    /// Lists plugins installed for the session.
6618    ///
6619    /// Wire method: `session.plugins.list`.
6620    ///
6621    /// # Returns
6622    ///
6623    /// Plugins installed for the session, with their enabled state and version metadata.
6624    ///
6625    /// <div class="warning">
6626    ///
6627    /// **Experimental.** This API is part of an experimental wire-protocol surface
6628    /// and may change or be removed in future SDK or CLI releases. Pin both the
6629    /// SDK and CLI versions if your code depends on it.
6630    ///
6631    /// </div>
6632    pub async fn list(&self) -> Result<PluginList, Error> {
6633        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6634        let _value = self
6635            .session
6636            .client()
6637            .call(rpc_methods::SESSION_PLUGINS_LIST, Some(wire_params))
6638            .await?;
6639        Ok(serde_json::from_value(_value)?)
6640    }
6641
6642    /// 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.
6643    ///
6644    /// Wire method: `session.plugins.reload`.
6645    ///
6646    /// <div class="warning">
6647    ///
6648    /// **Experimental.** This API is part of an experimental wire-protocol surface
6649    /// and may change or be removed in future SDK or CLI releases. Pin both the
6650    /// SDK and CLI versions if your code depends on it.
6651    ///
6652    /// </div>
6653    pub async fn reload(&self) -> Result<(), Error> {
6654        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6655        let _value = self
6656            .session
6657            .client()
6658            .call(rpc_methods::SESSION_PLUGINS_RELOAD, Some(wire_params))
6659            .await?;
6660        Ok(())
6661    }
6662
6663    /// 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.
6664    ///
6665    /// Wire method: `session.plugins.reload`.
6666    ///
6667    /// # Parameters
6668    ///
6669    /// * `params` - Optional flags controlling which side effects the reload performs.
6670    ///
6671    /// <div class="warning">
6672    ///
6673    /// **Experimental.** This API is part of an experimental wire-protocol surface
6674    /// and may change or be removed in future SDK or CLI releases. Pin both the
6675    /// SDK and CLI versions if your code depends on it.
6676    ///
6677    /// </div>
6678    pub async fn reload_with_params(&self, params: PluginsReloadRequest) -> Result<(), Error> {
6679        let mut wire_params = serde_json::to_value(params)?;
6680        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6681        let _value = self
6682            .session
6683            .client()
6684            .call(rpc_methods::SESSION_PLUGINS_RELOAD, Some(wire_params))
6685            .await?;
6686        Ok(())
6687    }
6688}
6689
6690/// `session.provider.*` RPCs.
6691#[derive(Clone, Copy)]
6692pub struct SessionRpcProvider<'a> {
6693    pub(crate) session: &'a Session,
6694}
6695
6696impl<'a> SessionRpcProvider<'a> {
6697    /// 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.
6698    ///
6699    /// Wire method: `session.provider.getEndpoint`.
6700    ///
6701    /// # Returns
6702    ///
6703    /// A snapshot of the provider endpoint the session is currently configured to talk to.
6704    ///
6705    /// <div class="warning">
6706    ///
6707    /// **Experimental.** This API is part of an experimental wire-protocol surface
6708    /// and may change or be removed in future SDK or CLI releases. Pin both the
6709    /// SDK and CLI versions if your code depends on it.
6710    ///
6711    /// </div>
6712    pub async fn get_endpoint(&self) -> Result<ProviderEndpoint, Error> {
6713        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6714        let _value = self
6715            .session
6716            .client()
6717            .call(rpc_methods::SESSION_PROVIDER_GETENDPOINT, Some(wire_params))
6718            .await?;
6719        Ok(serde_json::from_value(_value)?)
6720    }
6721
6722    /// 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.
6723    ///
6724    /// Wire method: `session.provider.getEndpoint`.
6725    ///
6726    /// # Parameters
6727    ///
6728    /// * `params` - Optional model identifier to scope the endpoint snapshot to.
6729    ///
6730    /// # Returns
6731    ///
6732    /// A snapshot of the provider endpoint the session is currently configured to talk to.
6733    ///
6734    /// <div class="warning">
6735    ///
6736    /// **Experimental.** This API is part of an experimental wire-protocol surface
6737    /// and may change or be removed in future SDK or CLI releases. Pin both the
6738    /// SDK and CLI versions if your code depends on it.
6739    ///
6740    /// </div>
6741    pub async fn get_endpoint_with_params(
6742        &self,
6743        params: ProviderGetEndpointRequest,
6744    ) -> Result<ProviderEndpoint, Error> {
6745        let mut wire_params = serde_json::to_value(params)?;
6746        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6747        let _value = self
6748            .session
6749            .client()
6750            .call(rpc_methods::SESSION_PROVIDER_GETENDPOINT, Some(wire_params))
6751            .await?;
6752        Ok(serde_json::from_value(_value)?)
6753    }
6754
6755    /// 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.
6756    ///
6757    /// Wire method: `session.provider.add`.
6758    ///
6759    /// # Parameters
6760    ///
6761    /// * `params` - BYOK providers and/or models to add to the session's registry at runtime. Both fields are optional; provide providers, models, or both.
6762    ///
6763    /// # Returns
6764    ///
6765    /// The selectable model entries synthesized for the models added by this call.
6766    ///
6767    /// <div class="warning">
6768    ///
6769    /// **Experimental.** This API is part of an experimental wire-protocol surface
6770    /// and may change or be removed in future SDK or CLI releases. Pin both the
6771    /// SDK and CLI versions if your code depends on it.
6772    ///
6773    /// </div>
6774    pub async fn add(&self, params: ProviderAddRequest) -> Result<ProviderAddResult, Error> {
6775        let mut wire_params = serde_json::to_value(params)?;
6776        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6777        let _value = self
6778            .session
6779            .client()
6780            .call(rpc_methods::SESSION_PROVIDER_ADD, Some(wire_params))
6781            .await?;
6782        Ok(serde_json::from_value(_value)?)
6783    }
6784}
6785
6786/// `session.queue.*` RPCs.
6787#[derive(Clone, Copy)]
6788pub struct SessionRpcQueue<'a> {
6789    pub(crate) session: &'a Session,
6790}
6791
6792impl<'a> SessionRpcQueue<'a> {
6793    /// Returns the local session's pending user-facing queued items and steering messages.
6794    ///
6795    /// Wire method: `session.queue.pendingItems`.
6796    ///
6797    /// # Returns
6798    ///
6799    /// Snapshot of the session's pending queued items and immediate-steering messages.
6800    ///
6801    /// <div class="warning">
6802    ///
6803    /// **Experimental.** This API is part of an experimental wire-protocol surface
6804    /// and may change or be removed in future SDK or CLI releases. Pin both the
6805    /// SDK and CLI versions if your code depends on it.
6806    ///
6807    /// </div>
6808    pub async fn pending_items(&self) -> Result<QueuePendingItemsResult, Error> {
6809        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6810        let _value = self
6811            .session
6812            .client()
6813            .call(rpc_methods::SESSION_QUEUE_PENDINGITEMS, Some(wire_params))
6814            .await?;
6815        Ok(serde_json::from_value(_value)?)
6816    }
6817
6818    /// Removes the most recently queued user-facing item (LIFO).
6819    ///
6820    /// Wire method: `session.queue.removeMostRecent`.
6821    ///
6822    /// # Returns
6823    ///
6824    /// Indicates whether a user-facing pending item was removed.
6825    ///
6826    /// <div class="warning">
6827    ///
6828    /// **Experimental.** This API is part of an experimental wire-protocol surface
6829    /// and may change or be removed in future SDK or CLI releases. Pin both the
6830    /// SDK and CLI versions if your code depends on it.
6831    ///
6832    /// </div>
6833    pub async fn remove_most_recent(&self) -> Result<QueueRemoveMostRecentResult, Error> {
6834        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6835        let _value = self
6836            .session
6837            .client()
6838            .call(
6839                rpc_methods::SESSION_QUEUE_REMOVEMOSTRECENT,
6840                Some(wire_params),
6841            )
6842            .await?;
6843        Ok(serde_json::from_value(_value)?)
6844    }
6845
6846    /// Clears all pending queued items on the local session.
6847    ///
6848    /// Wire method: `session.queue.clear`.
6849    ///
6850    /// <div class="warning">
6851    ///
6852    /// **Experimental.** This API is part of an experimental wire-protocol surface
6853    /// and may change or be removed in future SDK or CLI releases. Pin both the
6854    /// SDK and CLI versions if your code depends on it.
6855    ///
6856    /// </div>
6857    pub async fn clear(&self) -> Result<(), Error> {
6858        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6859        let _value = self
6860            .session
6861            .client()
6862            .call(rpc_methods::SESSION_QUEUE_CLEAR, Some(wire_params))
6863            .await?;
6864        Ok(())
6865    }
6866}
6867
6868/// `session.remote.*` RPCs.
6869#[derive(Clone, Copy)]
6870pub struct SessionRpcRemote<'a> {
6871    pub(crate) session: &'a Session,
6872}
6873
6874impl<'a> SessionRpcRemote<'a> {
6875    /// Enables remote session export or steering.
6876    ///
6877    /// Wire method: `session.remote.enable`.
6878    ///
6879    /// # Parameters
6880    ///
6881    /// * `params` - Optional remote session mode ("off", "export", or "on"); defaults to enabling both export and remote steering.
6882    ///
6883    /// # Returns
6884    ///
6885    /// GitHub URL for the session and a flag indicating whether remote steering is enabled.
6886    ///
6887    /// <div class="warning">
6888    ///
6889    /// **Experimental.** This API is part of an experimental wire-protocol surface
6890    /// and may change or be removed in future SDK or CLI releases. Pin both the
6891    /// SDK and CLI versions if your code depends on it.
6892    ///
6893    /// </div>
6894    pub async fn enable(&self, params: RemoteEnableRequest) -> Result<RemoteEnableResult, Error> {
6895        let mut wire_params = serde_json::to_value(params)?;
6896        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6897        let _value = self
6898            .session
6899            .client()
6900            .call(rpc_methods::SESSION_REMOTE_ENABLE, Some(wire_params))
6901            .await?;
6902        Ok(serde_json::from_value(_value)?)
6903    }
6904
6905    /// Disables remote session export and steering.
6906    ///
6907    /// Wire method: `session.remote.disable`.
6908    ///
6909    /// <div class="warning">
6910    ///
6911    /// **Experimental.** This API is part of an experimental wire-protocol surface
6912    /// and may change or be removed in future SDK or CLI releases. Pin both the
6913    /// SDK and CLI versions if your code depends on it.
6914    ///
6915    /// </div>
6916    pub async fn disable(&self) -> Result<(), Error> {
6917        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6918        let _value = self
6919            .session
6920            .client()
6921            .call(rpc_methods::SESSION_REMOTE_DISABLE, Some(wire_params))
6922            .await?;
6923        Ok(())
6924    }
6925
6926    /// Persists a remote-steerability change emitted by the host as a session event.
6927    ///
6928    /// Wire method: `session.remote.notifySteerableChanged`.
6929    ///
6930    /// # Parameters
6931    ///
6932    /// * `params` - New remote-steerability state to persist as a `session.remote_steerable_changed` event.
6933    ///
6934    /// # Returns
6935    ///
6936    /// 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.
6937    ///
6938    /// <div class="warning">
6939    ///
6940    /// **Experimental.** This API is part of an experimental wire-protocol surface
6941    /// and may change or be removed in future SDK or CLI releases. Pin both the
6942    /// SDK and CLI versions if your code depends on it.
6943    ///
6944    /// </div>
6945    pub async fn notify_steerable_changed(
6946        &self,
6947        params: RemoteNotifySteerableChangedRequest,
6948    ) -> Result<RemoteNotifySteerableChangedResult, Error> {
6949        let mut wire_params = serde_json::to_value(params)?;
6950        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6951        let _value = self
6952            .session
6953            .client()
6954            .call(
6955                rpc_methods::SESSION_REMOTE_NOTIFYSTEERABLECHANGED,
6956                Some(wire_params),
6957            )
6958            .await?;
6959        Ok(serde_json::from_value(_value)?)
6960    }
6961}
6962
6963/// `session.schedule.*` RPCs.
6964#[derive(Clone, Copy)]
6965pub struct SessionRpcSchedule<'a> {
6966    pub(crate) session: &'a Session,
6967}
6968
6969impl<'a> SessionRpcSchedule<'a> {
6970    /// Lists the session's currently active scheduled prompts.
6971    ///
6972    /// Wire method: `session.schedule.list`.
6973    ///
6974    /// # Returns
6975    ///
6976    /// Snapshot of the currently active recurring prompts for this session.
6977    ///
6978    /// <div class="warning">
6979    ///
6980    /// **Experimental.** This API is part of an experimental wire-protocol surface
6981    /// and may change or be removed in future SDK or CLI releases. Pin both the
6982    /// SDK and CLI versions if your code depends on it.
6983    ///
6984    /// </div>
6985    pub async fn list(&self) -> Result<ScheduleList, Error> {
6986        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6987        let _value = self
6988            .session
6989            .client()
6990            .call(rpc_methods::SESSION_SCHEDULE_LIST, Some(wire_params))
6991            .await?;
6992        Ok(serde_json::from_value(_value)?)
6993    }
6994
6995    /// Removes a scheduled prompt by id.
6996    ///
6997    /// Wire method: `session.schedule.stop`.
6998    ///
6999    /// # Parameters
7000    ///
7001    /// * `params` - Identifier of the scheduled prompt to remove.
7002    ///
7003    /// # Returns
7004    ///
7005    /// Remove a scheduled prompt by id. The result entry is omitted if the id was unknown.
7006    ///
7007    /// <div class="warning">
7008    ///
7009    /// **Experimental.** This API is part of an experimental wire-protocol surface
7010    /// and may change or be removed in future SDK or CLI releases. Pin both the
7011    /// SDK and CLI versions if your code depends on it.
7012    ///
7013    /// </div>
7014    pub async fn stop(&self, params: ScheduleStopRequest) -> Result<ScheduleStopResult, Error> {
7015        let mut wire_params = serde_json::to_value(params)?;
7016        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7017        let _value = self
7018            .session
7019            .client()
7020            .call(rpc_methods::SESSION_SCHEDULE_STOP, Some(wire_params))
7021            .await?;
7022        Ok(serde_json::from_value(_value)?)
7023    }
7024}
7025
7026/// `session.shell.*` RPCs.
7027#[derive(Clone, Copy)]
7028pub struct SessionRpcShell<'a> {
7029    pub(crate) session: &'a Session,
7030}
7031
7032impl<'a> SessionRpcShell<'a> {
7033    /// Starts a shell command and streams output through session notifications.
7034    ///
7035    /// Wire method: `session.shell.exec`.
7036    ///
7037    /// # Parameters
7038    ///
7039    /// * `params` - Shell command to run, with optional working directory and timeout in milliseconds.
7040    ///
7041    /// # Returns
7042    ///
7043    /// Identifier of the spawned process, used to correlate streamed output and exit notifications.
7044    ///
7045    /// <div class="warning">
7046    ///
7047    /// **Experimental.** This API is part of an experimental wire-protocol surface
7048    /// and may change or be removed in future SDK or CLI releases. Pin both the
7049    /// SDK and CLI versions if your code depends on it.
7050    ///
7051    /// </div>
7052    pub async fn exec(&self, params: ShellExecRequest) -> Result<ShellExecResult, Error> {
7053        let mut wire_params = serde_json::to_value(params)?;
7054        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7055        let _value = self
7056            .session
7057            .client()
7058            .call(rpc_methods::SESSION_SHELL_EXEC, Some(wire_params))
7059            .await?;
7060        Ok(serde_json::from_value(_value)?)
7061    }
7062
7063    /// Sends a signal to a shell process previously started via "shell.exec".
7064    ///
7065    /// Wire method: `session.shell.kill`.
7066    ///
7067    /// # Parameters
7068    ///
7069    /// * `params` - Identifier of a process previously returned by "shell.exec" and the signal to send.
7070    ///
7071    /// # Returns
7072    ///
7073    /// Indicates whether the signal was delivered; false if the process was unknown or already exited.
7074    ///
7075    /// <div class="warning">
7076    ///
7077    /// **Experimental.** This API is part of an experimental wire-protocol surface
7078    /// and may change or be removed in future SDK or CLI releases. Pin both the
7079    /// SDK and CLI versions if your code depends on it.
7080    ///
7081    /// </div>
7082    pub async fn kill(&self, params: ShellKillRequest) -> Result<ShellKillResult, Error> {
7083        let mut wire_params = serde_json::to_value(params)?;
7084        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7085        let _value = self
7086            .session
7087            .client()
7088            .call(rpc_methods::SESSION_SHELL_KILL, Some(wire_params))
7089            .await?;
7090        Ok(serde_json::from_value(_value)?)
7091    }
7092
7093    /// Executes a user-requested shell command through the session runtime.
7094    ///
7095    /// Wire method: `session.shell.executeUserRequested`.
7096    ///
7097    /// # Parameters
7098    ///
7099    /// * `params` - User-requested shell command and cancellation handle.
7100    ///
7101    /// # Returns
7102    ///
7103    /// Result of a user-requested shell command.
7104    ///
7105    /// <div class="warning">
7106    ///
7107    /// **Experimental.** This API is part of an experimental wire-protocol surface
7108    /// and may change or be removed in future SDK or CLI releases. Pin both the
7109    /// SDK and CLI versions if your code depends on it.
7110    ///
7111    /// </div>
7112    pub async fn execute_user_requested(
7113        &self,
7114        params: ShellExecuteUserRequestedRequest,
7115    ) -> Result<UserRequestedShellCommandResult, Error> {
7116        let mut wire_params = serde_json::to_value(params)?;
7117        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7118        let _value = self
7119            .session
7120            .client()
7121            .call(
7122                rpc_methods::SESSION_SHELL_EXECUTEUSERREQUESTED,
7123                Some(wire_params),
7124            )
7125            .await?;
7126        Ok(serde_json::from_value(_value)?)
7127    }
7128
7129    /// Cancels a user-requested shell command by request ID.
7130    ///
7131    /// Wire method: `session.shell.cancelUserRequested`.
7132    ///
7133    /// # Parameters
7134    ///
7135    /// * `params` - User-requested shell execution cancellation handle.
7136    ///
7137    /// # Returns
7138    ///
7139    /// Cancellation result for a user-requested shell command.
7140    ///
7141    /// <div class="warning">
7142    ///
7143    /// **Experimental.** This API is part of an experimental wire-protocol surface
7144    /// and may change or be removed in future SDK or CLI releases. Pin both the
7145    /// SDK and CLI versions if your code depends on it.
7146    ///
7147    /// </div>
7148    pub async fn cancel_user_requested(
7149        &self,
7150        params: ShellCancelUserRequestedRequest,
7151    ) -> Result<CancelUserRequestedShellCommandResult, Error> {
7152        let mut wire_params = serde_json::to_value(params)?;
7153        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7154        let _value = self
7155            .session
7156            .client()
7157            .call(
7158                rpc_methods::SESSION_SHELL_CANCELUSERREQUESTED,
7159                Some(wire_params),
7160            )
7161            .await?;
7162        Ok(serde_json::from_value(_value)?)
7163    }
7164}
7165
7166/// `session.skills.*` RPCs.
7167#[derive(Clone, Copy)]
7168pub struct SessionRpcSkills<'a> {
7169    pub(crate) session: &'a Session,
7170}
7171
7172impl<'a> SessionRpcSkills<'a> {
7173    /// Lists skills available to the session.
7174    ///
7175    /// Wire method: `session.skills.list`.
7176    ///
7177    /// # Returns
7178    ///
7179    /// Skills available to the session, with their enabled state.
7180    ///
7181    /// <div class="warning">
7182    ///
7183    /// **Experimental.** This API is part of an experimental wire-protocol surface
7184    /// and may change or be removed in future SDK or CLI releases. Pin both the
7185    /// SDK and CLI versions if your code depends on it.
7186    ///
7187    /// </div>
7188    pub async fn list(&self) -> Result<SkillList, Error> {
7189        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7190        let _value = self
7191            .session
7192            .client()
7193            .call(rpc_methods::SESSION_SKILLS_LIST, Some(wire_params))
7194            .await?;
7195        Ok(serde_json::from_value(_value)?)
7196    }
7197
7198    /// Returns the skills that have been invoked during this session.
7199    ///
7200    /// Wire method: `session.skills.getInvoked`.
7201    ///
7202    /// # Returns
7203    ///
7204    /// Skills invoked during this session, ordered by invocation time (most recent last).
7205    ///
7206    /// <div class="warning">
7207    ///
7208    /// **Experimental.** This API is part of an experimental wire-protocol surface
7209    /// and may change or be removed in future SDK or CLI releases. Pin both the
7210    /// SDK and CLI versions if your code depends on it.
7211    ///
7212    /// </div>
7213    pub async fn get_invoked(&self) -> Result<SkillsGetInvokedResult, Error> {
7214        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7215        let _value = self
7216            .session
7217            .client()
7218            .call(rpc_methods::SESSION_SKILLS_GETINVOKED, Some(wire_params))
7219            .await?;
7220        Ok(serde_json::from_value(_value)?)
7221    }
7222
7223    /// Enables a skill for the session.
7224    ///
7225    /// Wire method: `session.skills.enable`.
7226    ///
7227    /// # Parameters
7228    ///
7229    /// * `params` - Name of the skill to enable for the session.
7230    ///
7231    /// <div class="warning">
7232    ///
7233    /// **Experimental.** This API is part of an experimental wire-protocol surface
7234    /// and may change or be removed in future SDK or CLI releases. Pin both the
7235    /// SDK and CLI versions if your code depends on it.
7236    ///
7237    /// </div>
7238    pub async fn enable(&self, params: SkillsEnableRequest) -> Result<(), Error> {
7239        let mut wire_params = serde_json::to_value(params)?;
7240        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7241        let _value = self
7242            .session
7243            .client()
7244            .call(rpc_methods::SESSION_SKILLS_ENABLE, Some(wire_params))
7245            .await?;
7246        Ok(())
7247    }
7248
7249    /// Disables a skill for the session.
7250    ///
7251    /// Wire method: `session.skills.disable`.
7252    ///
7253    /// # Parameters
7254    ///
7255    /// * `params` - Name of the skill to disable for the session.
7256    ///
7257    /// <div class="warning">
7258    ///
7259    /// **Experimental.** This API is part of an experimental wire-protocol surface
7260    /// and may change or be removed in future SDK or CLI releases. Pin both the
7261    /// SDK and CLI versions if your code depends on it.
7262    ///
7263    /// </div>
7264    pub async fn disable(&self, params: SkillsDisableRequest) -> Result<(), Error> {
7265        let mut wire_params = serde_json::to_value(params)?;
7266        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7267        let _value = self
7268            .session
7269            .client()
7270            .call(rpc_methods::SESSION_SKILLS_DISABLE, Some(wire_params))
7271            .await?;
7272        Ok(())
7273    }
7274
7275    /// Reloads skill definitions for the session.
7276    ///
7277    /// Wire method: `session.skills.reload`.
7278    ///
7279    /// # Returns
7280    ///
7281    /// Diagnostics from reloading skill definitions, with warnings and errors as separate lists.
7282    ///
7283    /// <div class="warning">
7284    ///
7285    /// **Experimental.** This API is part of an experimental wire-protocol surface
7286    /// and may change or be removed in future SDK or CLI releases. Pin both the
7287    /// SDK and CLI versions if your code depends on it.
7288    ///
7289    /// </div>
7290    pub async fn reload(&self) -> Result<SkillsLoadDiagnostics, Error> {
7291        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7292        let _value = self
7293            .session
7294            .client()
7295            .call(rpc_methods::SESSION_SKILLS_RELOAD, Some(wire_params))
7296            .await?;
7297        Ok(serde_json::from_value(_value)?)
7298    }
7299
7300    /// Ensures the session's skill definitions have been loaded from disk.
7301    ///
7302    /// Wire method: `session.skills.ensureLoaded`.
7303    ///
7304    /// <div class="warning">
7305    ///
7306    /// **Experimental.** This API is part of an experimental wire-protocol surface
7307    /// and may change or be removed in future SDK or CLI releases. Pin both the
7308    /// SDK and CLI versions if your code depends on it.
7309    ///
7310    /// </div>
7311    pub async fn ensure_loaded(&self) -> Result<(), Error> {
7312        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7313        let _value = self
7314            .session
7315            .client()
7316            .call(rpc_methods::SESSION_SKILLS_ENSURELOADED, Some(wire_params))
7317            .await?;
7318        Ok(())
7319    }
7320}
7321
7322/// `session.tasks.*` RPCs.
7323#[derive(Clone, Copy)]
7324pub struct SessionRpcTasks<'a> {
7325    pub(crate) session: &'a Session,
7326}
7327
7328impl<'a> SessionRpcTasks<'a> {
7329    /// Starts a background agent task in the session.
7330    ///
7331    /// Wire method: `session.tasks.startAgent`.
7332    ///
7333    /// # Parameters
7334    ///
7335    /// * `params` - Agent type, prompt, name, and optional description and model override for the new task.
7336    ///
7337    /// # Returns
7338    ///
7339    /// Identifier assigned to the newly started background agent task.
7340    ///
7341    /// <div class="warning">
7342    ///
7343    /// **Experimental.** This API is part of an experimental wire-protocol surface
7344    /// and may change or be removed in future SDK or CLI releases. Pin both the
7345    /// SDK and CLI versions if your code depends on it.
7346    ///
7347    /// </div>
7348    pub async fn start_agent(
7349        &self,
7350        params: TasksStartAgentRequest,
7351    ) -> Result<TasksStartAgentResult, Error> {
7352        let mut wire_params = serde_json::to_value(params)?;
7353        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7354        let _value = self
7355            .session
7356            .client()
7357            .call(rpc_methods::SESSION_TASKS_STARTAGENT, Some(wire_params))
7358            .await?;
7359        Ok(serde_json::from_value(_value)?)
7360    }
7361
7362    /// Lists background tasks tracked by the session.
7363    ///
7364    /// Wire method: `session.tasks.list`.
7365    ///
7366    /// # Returns
7367    ///
7368    /// Background tasks currently tracked by the session.
7369    ///
7370    /// <div class="warning">
7371    ///
7372    /// **Experimental.** This API is part of an experimental wire-protocol surface
7373    /// and may change or be removed in future SDK or CLI releases. Pin both the
7374    /// SDK and CLI versions if your code depends on it.
7375    ///
7376    /// </div>
7377    pub async fn list(&self) -> Result<TaskList, Error> {
7378        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7379        let _value = self
7380            .session
7381            .client()
7382            .call(rpc_methods::SESSION_TASKS_LIST, Some(wire_params))
7383            .await?;
7384        Ok(serde_json::from_value(_value)?)
7385    }
7386
7387    /// Refreshes metadata for any detached background shells the runtime knows about.
7388    ///
7389    /// Wire method: `session.tasks.refresh`.
7390    ///
7391    /// # Returns
7392    ///
7393    /// 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.
7394    ///
7395    /// <div class="warning">
7396    ///
7397    /// **Experimental.** This API is part of an experimental wire-protocol surface
7398    /// and may change or be removed in future SDK or CLI releases. Pin both the
7399    /// SDK and CLI versions if your code depends on it.
7400    ///
7401    /// </div>
7402    pub async fn refresh(&self) -> Result<TasksRefreshResult, Error> {
7403        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7404        let _value = self
7405            .session
7406            .client()
7407            .call(rpc_methods::SESSION_TASKS_REFRESH, Some(wire_params))
7408            .await?;
7409        Ok(serde_json::from_value(_value)?)
7410    }
7411
7412    /// Waits for all in-flight background tasks and any follow-up turns to settle.
7413    ///
7414    /// Wire method: `session.tasks.waitForPending`.
7415    ///
7416    /// # Returns
7417    ///
7418    /// 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).
7419    ///
7420    /// <div class="warning">
7421    ///
7422    /// **Experimental.** This API is part of an experimental wire-protocol surface
7423    /// and may change or be removed in future SDK or CLI releases. Pin both the
7424    /// SDK and CLI versions if your code depends on it.
7425    ///
7426    /// </div>
7427    pub async fn wait_for_pending(&self) -> Result<TasksWaitForPendingResult, Error> {
7428        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7429        let _value = self
7430            .session
7431            .client()
7432            .call(rpc_methods::SESSION_TASKS_WAITFORPENDING, Some(wire_params))
7433            .await?;
7434        Ok(serde_json::from_value(_value)?)
7435    }
7436
7437    /// Returns progress information for a background task by ID.
7438    ///
7439    /// Wire method: `session.tasks.getProgress`.
7440    ///
7441    /// # Parameters
7442    ///
7443    /// * `params` - Identifier of the background task to fetch progress for.
7444    ///
7445    /// # Returns
7446    ///
7447    /// Progress information for the task, or null when no task with that ID is tracked.
7448    ///
7449    /// <div class="warning">
7450    ///
7451    /// **Experimental.** This API is part of an experimental wire-protocol surface
7452    /// and may change or be removed in future SDK or CLI releases. Pin both the
7453    /// SDK and CLI versions if your code depends on it.
7454    ///
7455    /// </div>
7456    pub async fn get_progress(
7457        &self,
7458        params: TasksGetProgressRequest,
7459    ) -> Result<TasksGetProgressResult, Error> {
7460        let mut wire_params = serde_json::to_value(params)?;
7461        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7462        let _value = self
7463            .session
7464            .client()
7465            .call(rpc_methods::SESSION_TASKS_GETPROGRESS, Some(wire_params))
7466            .await?;
7467        Ok(serde_json::from_value(_value)?)
7468    }
7469
7470    /// Returns the first sync-waiting task that can currently be promoted to background mode.
7471    ///
7472    /// Wire method: `session.tasks.getCurrentPromotable`.
7473    ///
7474    /// # Returns
7475    ///
7476    /// The first sync-waiting task that can currently be promoted to background mode.
7477    ///
7478    /// <div class="warning">
7479    ///
7480    /// **Experimental.** This API is part of an experimental wire-protocol surface
7481    /// and may change or be removed in future SDK or CLI releases. Pin both the
7482    /// SDK and CLI versions if your code depends on it.
7483    ///
7484    /// </div>
7485    pub async fn get_current_promotable(&self) -> Result<TasksGetCurrentPromotableResult, Error> {
7486        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7487        let _value = self
7488            .session
7489            .client()
7490            .call(
7491                rpc_methods::SESSION_TASKS_GETCURRENTPROMOTABLE,
7492                Some(wire_params),
7493            )
7494            .await?;
7495        Ok(serde_json::from_value(_value)?)
7496    }
7497
7498    /// Promotes an eligible synchronously-waited task so it continues running in the background.
7499    ///
7500    /// Wire method: `session.tasks.promoteToBackground`.
7501    ///
7502    /// # Parameters
7503    ///
7504    /// * `params` - Identifier of the task to promote to background mode.
7505    ///
7506    /// # Returns
7507    ///
7508    /// Indicates whether the task was successfully promoted to background mode.
7509    ///
7510    /// <div class="warning">
7511    ///
7512    /// **Experimental.** This API is part of an experimental wire-protocol surface
7513    /// and may change or be removed in future SDK or CLI releases. Pin both the
7514    /// SDK and CLI versions if your code depends on it.
7515    ///
7516    /// </div>
7517    pub async fn promote_to_background(
7518        &self,
7519        params: TasksPromoteToBackgroundRequest,
7520    ) -> Result<TasksPromoteToBackgroundResult, Error> {
7521        let mut wire_params = serde_json::to_value(params)?;
7522        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7523        let _value = self
7524            .session
7525            .client()
7526            .call(
7527                rpc_methods::SESSION_TASKS_PROMOTETOBACKGROUND,
7528                Some(wire_params),
7529            )
7530            .await?;
7531        Ok(serde_json::from_value(_value)?)
7532    }
7533
7534    /// Atomically promotes the first promotable sync-waiting task to background mode and returns it.
7535    ///
7536    /// Wire method: `session.tasks.promoteCurrentToBackground`.
7537    ///
7538    /// # Returns
7539    ///
7540    /// The promoted task as it now exists in background mode, omitted if no promotable task was waiting.
7541    ///
7542    /// <div class="warning">
7543    ///
7544    /// **Experimental.** This API is part of an experimental wire-protocol surface
7545    /// and may change or be removed in future SDK or CLI releases. Pin both the
7546    /// SDK and CLI versions if your code depends on it.
7547    ///
7548    /// </div>
7549    pub async fn promote_current_to_background(
7550        &self,
7551    ) -> Result<TasksPromoteCurrentToBackgroundResult, Error> {
7552        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7553        let _value = self
7554            .session
7555            .client()
7556            .call(
7557                rpc_methods::SESSION_TASKS_PROMOTECURRENTTOBACKGROUND,
7558                Some(wire_params),
7559            )
7560            .await?;
7561        Ok(serde_json::from_value(_value)?)
7562    }
7563
7564    /// Cancels a background task.
7565    ///
7566    /// Wire method: `session.tasks.cancel`.
7567    ///
7568    /// # Parameters
7569    ///
7570    /// * `params` - Identifier of the background task to cancel.
7571    ///
7572    /// # Returns
7573    ///
7574    /// Indicates whether the background task was successfully cancelled.
7575    ///
7576    /// <div class="warning">
7577    ///
7578    /// **Experimental.** This API is part of an experimental wire-protocol surface
7579    /// and may change or be removed in future SDK or CLI releases. Pin both the
7580    /// SDK and CLI versions if your code depends on it.
7581    ///
7582    /// </div>
7583    pub async fn cancel(&self, params: TasksCancelRequest) -> Result<TasksCancelResult, Error> {
7584        let mut wire_params = serde_json::to_value(params)?;
7585        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7586        let _value = self
7587            .session
7588            .client()
7589            .call(rpc_methods::SESSION_TASKS_CANCEL, Some(wire_params))
7590            .await?;
7591        Ok(serde_json::from_value(_value)?)
7592    }
7593
7594    /// Removes a completed or cancelled background task from tracking.
7595    ///
7596    /// Wire method: `session.tasks.remove`.
7597    ///
7598    /// # Parameters
7599    ///
7600    /// * `params` - Identifier of the completed or cancelled task to remove from tracking.
7601    ///
7602    /// # Returns
7603    ///
7604    /// Indicates whether the task was removed. False when the task does not exist or is still running/idle.
7605    ///
7606    /// <div class="warning">
7607    ///
7608    /// **Experimental.** This API is part of an experimental wire-protocol surface
7609    /// and may change or be removed in future SDK or CLI releases. Pin both the
7610    /// SDK and CLI versions if your code depends on it.
7611    ///
7612    /// </div>
7613    pub async fn remove(&self, params: TasksRemoveRequest) -> Result<TasksRemoveResult, Error> {
7614        let mut wire_params = serde_json::to_value(params)?;
7615        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7616        let _value = self
7617            .session
7618            .client()
7619            .call(rpc_methods::SESSION_TASKS_REMOVE, Some(wire_params))
7620            .await?;
7621        Ok(serde_json::from_value(_value)?)
7622    }
7623
7624    /// Sends a message to a background agent task.
7625    ///
7626    /// Wire method: `session.tasks.sendMessage`.
7627    ///
7628    /// # Parameters
7629    ///
7630    /// * `params` - Identifier of the target agent task, message content, and optional sender agent ID.
7631    ///
7632    /// # Returns
7633    ///
7634    /// Indicates whether the message was delivered, with an error message when delivery failed.
7635    ///
7636    /// <div class="warning">
7637    ///
7638    /// **Experimental.** This API is part of an experimental wire-protocol surface
7639    /// and may change or be removed in future SDK or CLI releases. Pin both the
7640    /// SDK and CLI versions if your code depends on it.
7641    ///
7642    /// </div>
7643    pub async fn send_message(
7644        &self,
7645        params: TasksSendMessageRequest,
7646    ) -> Result<TasksSendMessageResult, Error> {
7647        let mut wire_params = serde_json::to_value(params)?;
7648        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7649        let _value = self
7650            .session
7651            .client()
7652            .call(rpc_methods::SESSION_TASKS_SENDMESSAGE, Some(wire_params))
7653            .await?;
7654        Ok(serde_json::from_value(_value)?)
7655    }
7656}
7657
7658/// `session.telemetry.*` RPCs.
7659#[derive(Clone, Copy)]
7660pub struct SessionRpcTelemetry<'a> {
7661    pub(crate) session: &'a Session,
7662}
7663
7664impl<'a> SessionRpcTelemetry<'a> {
7665    /// Gets the telemetry engagement ID currently associated with the session, when available.
7666    ///
7667    /// Wire method: `session.telemetry.getEngagementId`.
7668    ///
7669    /// # Returns
7670    ///
7671    /// Telemetry engagement ID for the session, when available.
7672    ///
7673    /// <div class="warning">
7674    ///
7675    /// **Experimental.** This API is part of an experimental wire-protocol surface
7676    /// and may change or be removed in future SDK or CLI releases. Pin both the
7677    /// SDK and CLI versions if your code depends on it.
7678    ///
7679    /// </div>
7680    pub async fn get_engagement_id(&self) -> Result<SessionTelemetryEngagement, Error> {
7681        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7682        let _value = self
7683            .session
7684            .client()
7685            .call(
7686                rpc_methods::SESSION_TELEMETRY_GETENGAGEMENTID,
7687                Some(wire_params),
7688            )
7689            .await?;
7690        Ok(serde_json::from_value(_value)?)
7691    }
7692
7693    /// Sets feature override key/value pairs to attach to subsequent telemetry events for the session.
7694    ///
7695    /// Wire method: `session.telemetry.setFeatureOverrides`.
7696    ///
7697    /// # Parameters
7698    ///
7699    /// * `params` - Feature override key/value pairs to attach to subsequent telemetry events from this session.
7700    ///
7701    /// <div class="warning">
7702    ///
7703    /// **Experimental.** This API is part of an experimental wire-protocol surface
7704    /// and may change or be removed in future SDK or CLI releases. Pin both the
7705    /// SDK and CLI versions if your code depends on it.
7706    ///
7707    /// </div>
7708    pub async fn set_feature_overrides(
7709        &self,
7710        params: TelemetrySetFeatureOverridesRequest,
7711    ) -> Result<(), Error> {
7712        let mut wire_params = serde_json::to_value(params)?;
7713        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7714        let _value = self
7715            .session
7716            .client()
7717            .call(
7718                rpc_methods::SESSION_TELEMETRY_SETFEATUREOVERRIDES,
7719                Some(wire_params),
7720            )
7721            .await?;
7722        Ok(())
7723    }
7724}
7725
7726/// `session.tools.*` RPCs.
7727#[derive(Clone, Copy)]
7728pub struct SessionRpcTools<'a> {
7729    pub(crate) session: &'a Session,
7730}
7731
7732impl<'a> SessionRpcTools<'a> {
7733    /// Provides the result for a pending external tool call.
7734    ///
7735    /// Wire method: `session.tools.handlePendingToolCall`.
7736    ///
7737    /// # Parameters
7738    ///
7739    /// * `params` - Pending external tool call request ID, with the tool result or an error describing why it failed.
7740    ///
7741    /// # Returns
7742    ///
7743    /// Indicates whether the external tool call result was handled successfully.
7744    ///
7745    /// <div class="warning">
7746    ///
7747    /// **Experimental.** This API is part of an experimental wire-protocol surface
7748    /// and may change or be removed in future SDK or CLI releases. Pin both the
7749    /// SDK and CLI versions if your code depends on it.
7750    ///
7751    /// </div>
7752    pub async fn handle_pending_tool_call(
7753        &self,
7754        params: HandlePendingToolCallRequest,
7755    ) -> Result<HandlePendingToolCallResult, Error> {
7756        let mut wire_params = serde_json::to_value(params)?;
7757        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7758        let _value = self
7759            .session
7760            .client()
7761            .call(
7762                rpc_methods::SESSION_TOOLS_HANDLEPENDINGTOOLCALL,
7763                Some(wire_params),
7764            )
7765            .await?;
7766        Ok(serde_json::from_value(_value)?)
7767    }
7768
7769    /// Resolves, builds, and validates the runtime tool list for the session.
7770    ///
7771    /// Wire method: `session.tools.initializeAndValidate`.
7772    ///
7773    /// # Returns
7774    ///
7775    /// 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.
7776    ///
7777    /// <div class="warning">
7778    ///
7779    /// **Experimental.** This API is part of an experimental wire-protocol surface
7780    /// and may change or be removed in future SDK or CLI releases. Pin both the
7781    /// SDK and CLI versions if your code depends on it.
7782    ///
7783    /// </div>
7784    pub async fn initialize_and_validate(&self) -> Result<ToolsInitializeAndValidateResult, Error> {
7785        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7786        let _value = self
7787            .session
7788            .client()
7789            .call(
7790                rpc_methods::SESSION_TOOLS_INITIALIZEANDVALIDATE,
7791                Some(wire_params),
7792            )
7793            .await?;
7794        Ok(serde_json::from_value(_value)?)
7795    }
7796
7797    /// Returns lightweight metadata for the session's currently initialized tools.
7798    ///
7799    /// Wire method: `session.tools.getCurrentMetadata`.
7800    ///
7801    /// # Returns
7802    ///
7803    /// Current lightweight tool metadata snapshot for the session.
7804    ///
7805    /// <div class="warning">
7806    ///
7807    /// **Experimental.** This API is part of an experimental wire-protocol surface
7808    /// and may change or be removed in future SDK or CLI releases. Pin both the
7809    /// SDK and CLI versions if your code depends on it.
7810    ///
7811    /// </div>
7812    pub async fn get_current_metadata(&self) -> Result<ToolsGetCurrentMetadataResult, Error> {
7813        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7814        let _value = self
7815            .session
7816            .client()
7817            .call(
7818                rpc_methods::SESSION_TOOLS_GETCURRENTMETADATA,
7819                Some(wire_params),
7820            )
7821            .await?;
7822        Ok(serde_json::from_value(_value)?)
7823    }
7824
7825    /// Updates the current session's live subagent settings after user settings change. The persisted user settings remain the source of truth for future sessions.
7826    ///
7827    /// Wire method: `session.tools.updateSubagentSettings`.
7828    ///
7829    /// # Parameters
7830    ///
7831    /// * `params` - Subagent settings to apply to the current session
7832    ///
7833    /// # Returns
7834    ///
7835    /// Empty result after applying subagent settings
7836    ///
7837    /// <div class="warning">
7838    ///
7839    /// **Experimental.** This API is part of an experimental wire-protocol surface
7840    /// and may change or be removed in future SDK or CLI releases. Pin both the
7841    /// SDK and CLI versions if your code depends on it.
7842    ///
7843    /// </div>
7844    pub async fn update_subagent_settings(
7845        &self,
7846        params: UpdateSubagentSettingsRequest,
7847    ) -> Result<ToolsUpdateSubagentSettingsResult, Error> {
7848        let mut wire_params = serde_json::to_value(params)?;
7849        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7850        let _value = self
7851            .session
7852            .client()
7853            .call(
7854                rpc_methods::SESSION_TOOLS_UPDATESUBAGENTSETTINGS,
7855                Some(wire_params),
7856            )
7857            .await?;
7858        Ok(serde_json::from_value(_value)?)
7859    }
7860}
7861
7862/// `session.ui.*` RPCs.
7863#[derive(Clone, Copy)]
7864pub struct SessionRpcUi<'a> {
7865    pub(crate) session: &'a Session,
7866}
7867
7868impl<'a> SessionRpcUi<'a> {
7869    /// Runs a transient no-tools model query against the current conversation context.
7870    ///
7871    /// Wire method: `session.ui.ephemeralQuery`.
7872    ///
7873    /// # Parameters
7874    ///
7875    /// * `params` - Transient question to answer without adding it to conversation history.
7876    ///
7877    /// # Returns
7878    ///
7879    /// Transient answer generated from current conversation context.
7880    ///
7881    /// <div class="warning">
7882    ///
7883    /// **Experimental.** This API is part of an experimental wire-protocol surface
7884    /// and may change or be removed in future SDK or CLI releases. Pin both the
7885    /// SDK and CLI versions if your code depends on it.
7886    ///
7887    /// </div>
7888    pub async fn ephemeral_query(
7889        &self,
7890        params: UIEphemeralQueryRequest,
7891    ) -> Result<UIEphemeralQueryResult, Error> {
7892        let mut wire_params = serde_json::to_value(params)?;
7893        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7894        let _value = self
7895            .session
7896            .client()
7897            .call(rpc_methods::SESSION_UI_EPHEMERALQUERY, Some(wire_params))
7898            .await?;
7899        Ok(serde_json::from_value(_value)?)
7900    }
7901
7902    /// Requests structured input from a UI-capable client.
7903    ///
7904    /// Wire method: `session.ui.elicitation`.
7905    ///
7906    /// # Parameters
7907    ///
7908    /// * `params` - Prompt message and JSON schema describing the form fields to elicit from the user.
7909    ///
7910    /// # Returns
7911    ///
7912    /// The elicitation response (accept with form values, decline, or cancel)
7913    ///
7914    /// <div class="warning">
7915    ///
7916    /// **Experimental.** This API is part of an experimental wire-protocol surface
7917    /// and may change or be removed in future SDK or CLI releases. Pin both the
7918    /// SDK and CLI versions if your code depends on it.
7919    ///
7920    /// </div>
7921    pub async fn elicitation(
7922        &self,
7923        params: UIElicitationRequest,
7924    ) -> Result<UIElicitationResponse, Error> {
7925        let mut wire_params = serde_json::to_value(params)?;
7926        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7927        let _value = self
7928            .session
7929            .client()
7930            .call(rpc_methods::SESSION_UI_ELICITATION, Some(wire_params))
7931            .await?;
7932        Ok(serde_json::from_value(_value)?)
7933    }
7934
7935    /// Provides the user response for a pending elicitation request.
7936    ///
7937    /// Wire method: `session.ui.handlePendingElicitation`.
7938    ///
7939    /// # Parameters
7940    ///
7941    /// * `params` - Pending elicitation request ID and the user's response (accept/decline/cancel + form values).
7942    ///
7943    /// # Returns
7944    ///
7945    /// Indicates whether the elicitation response was accepted; false if it was already resolved by another client.
7946    ///
7947    /// <div class="warning">
7948    ///
7949    /// **Experimental.** This API is part of an experimental wire-protocol surface
7950    /// and may change or be removed in future SDK or CLI releases. Pin both the
7951    /// SDK and CLI versions if your code depends on it.
7952    ///
7953    /// </div>
7954    pub async fn handle_pending_elicitation(
7955        &self,
7956        params: UIHandlePendingElicitationRequest,
7957    ) -> Result<UIElicitationResult, Error> {
7958        let mut wire_params = serde_json::to_value(params)?;
7959        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7960        let _value = self
7961            .session
7962            .client()
7963            .call(
7964                rpc_methods::SESSION_UI_HANDLEPENDINGELICITATION,
7965                Some(wire_params),
7966            )
7967            .await?;
7968        Ok(serde_json::from_value(_value)?)
7969    }
7970
7971    /// Resolves a pending `user_input.requested` event with the user's response.
7972    ///
7973    /// Wire method: `session.ui.handlePendingUserInput`.
7974    ///
7975    /// # Parameters
7976    ///
7977    /// * `params` - Request ID of a pending `user_input.requested` event and the user's response.
7978    ///
7979    /// # Returns
7980    ///
7981    /// Indicates whether the pending UI request was resolved by this call.
7982    ///
7983    /// <div class="warning">
7984    ///
7985    /// **Experimental.** This API is part of an experimental wire-protocol surface
7986    /// and may change or be removed in future SDK or CLI releases. Pin both the
7987    /// SDK and CLI versions if your code depends on it.
7988    ///
7989    /// </div>
7990    pub async fn handle_pending_user_input(
7991        &self,
7992        params: UIHandlePendingUserInputRequest,
7993    ) -> Result<UIHandlePendingResult, Error> {
7994        let mut wire_params = serde_json::to_value(params)?;
7995        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7996        let _value = self
7997            .session
7998            .client()
7999            .call(
8000                rpc_methods::SESSION_UI_HANDLEPENDINGUSERINPUT,
8001                Some(wire_params),
8002            )
8003            .await?;
8004        Ok(serde_json::from_value(_value)?)
8005    }
8006
8007    /// Resolves a pending `sampling.requested` event with a sampling result, or rejects it.
8008    ///
8009    /// Wire method: `session.ui.handlePendingSampling`.
8010    ///
8011    /// # Parameters
8012    ///
8013    /// * `params` - Request ID of a pending `sampling.requested` event and an optional sampling result payload (omit to reject).
8014    ///
8015    /// # Returns
8016    ///
8017    /// Indicates whether the pending UI request was resolved by this call.
8018    ///
8019    /// <div class="warning">
8020    ///
8021    /// **Experimental.** This API is part of an experimental wire-protocol surface
8022    /// and may change or be removed in future SDK or CLI releases. Pin both the
8023    /// SDK and CLI versions if your code depends on it.
8024    ///
8025    /// </div>
8026    pub async fn handle_pending_sampling(
8027        &self,
8028        params: UIHandlePendingSamplingRequest,
8029    ) -> Result<UIHandlePendingResult, Error> {
8030        let mut wire_params = serde_json::to_value(params)?;
8031        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8032        let _value = self
8033            .session
8034            .client()
8035            .call(
8036                rpc_methods::SESSION_UI_HANDLEPENDINGSAMPLING,
8037                Some(wire_params),
8038            )
8039            .await?;
8040        Ok(serde_json::from_value(_value)?)
8041    }
8042
8043    /// Resolves a pending `auto_mode_switch.requested` event with the user's accept/decline decision.
8044    ///
8045    /// Wire method: `session.ui.handlePendingAutoModeSwitch`.
8046    ///
8047    /// # Parameters
8048    ///
8049    /// * `params` - Request ID of a pending `auto_mode_switch.requested` event and the user's response.
8050    ///
8051    /// # Returns
8052    ///
8053    /// Indicates whether the pending UI request was resolved by this call.
8054    ///
8055    /// <div class="warning">
8056    ///
8057    /// **Experimental.** This API is part of an experimental wire-protocol surface
8058    /// and may change or be removed in future SDK or CLI releases. Pin both the
8059    /// SDK and CLI versions if your code depends on it.
8060    ///
8061    /// </div>
8062    pub async fn handle_pending_auto_mode_switch(
8063        &self,
8064        params: UIHandlePendingAutoModeSwitchRequest,
8065    ) -> Result<UIHandlePendingResult, Error> {
8066        let mut wire_params = serde_json::to_value(params)?;
8067        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8068        let _value = self
8069            .session
8070            .client()
8071            .call(
8072                rpc_methods::SESSION_UI_HANDLEPENDINGAUTOMODESWITCH,
8073                Some(wire_params),
8074            )
8075            .await?;
8076        Ok(serde_json::from_value(_value)?)
8077    }
8078
8079    /// Resolves a pending `session_limits_exhausted.requested` event with the user's selected limit action.
8080    ///
8081    /// Wire method: `session.ui.handlePendingSessionLimitsExhausted`.
8082    ///
8083    /// # Parameters
8084    ///
8085    /// * `params` - Request ID of a pending `session_limits_exhausted.requested` event and the user's selected limit action.
8086    ///
8087    /// # Returns
8088    ///
8089    /// Indicates whether the pending UI request was resolved by this call.
8090    ///
8091    /// <div class="warning">
8092    ///
8093    /// **Experimental.** This API is part of an experimental wire-protocol surface
8094    /// and may change or be removed in future SDK or CLI releases. Pin both the
8095    /// SDK and CLI versions if your code depends on it.
8096    ///
8097    /// </div>
8098    pub async fn handle_pending_session_limits_exhausted(
8099        &self,
8100        params: UIHandlePendingSessionLimitsExhaustedRequest,
8101    ) -> Result<UIHandlePendingResult, Error> {
8102        let mut wire_params = serde_json::to_value(params)?;
8103        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8104        let _value = self
8105            .session
8106            .client()
8107            .call(
8108                rpc_methods::SESSION_UI_HANDLEPENDINGSESSIONLIMITSEXHAUSTED,
8109                Some(wire_params),
8110            )
8111            .await?;
8112        Ok(serde_json::from_value(_value)?)
8113    }
8114
8115    /// Resolves a pending `exit_plan_mode.requested` event with the user's response.
8116    ///
8117    /// Wire method: `session.ui.handlePendingExitPlanMode`.
8118    ///
8119    /// # Parameters
8120    ///
8121    /// * `params` - Request ID of a pending `exit_plan_mode.requested` event and the user's response.
8122    ///
8123    /// # Returns
8124    ///
8125    /// Indicates whether the pending UI request was resolved by this call.
8126    ///
8127    /// <div class="warning">
8128    ///
8129    /// **Experimental.** This API is part of an experimental wire-protocol surface
8130    /// and may change or be removed in future SDK or CLI releases. Pin both the
8131    /// SDK and CLI versions if your code depends on it.
8132    ///
8133    /// </div>
8134    pub async fn handle_pending_exit_plan_mode(
8135        &self,
8136        params: UIHandlePendingExitPlanModeRequest,
8137    ) -> Result<UIHandlePendingResult, Error> {
8138        let mut wire_params = serde_json::to_value(params)?;
8139        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8140        let _value = self
8141            .session
8142            .client()
8143            .call(
8144                rpc_methods::SESSION_UI_HANDLEPENDINGEXITPLANMODE,
8145                Some(wire_params),
8146            )
8147            .await?;
8148        Ok(serde_json::from_value(_value)?)
8149    }
8150
8151    /// Registers an in-process handler for auto-mode-switch requests so the server bridge skips dispatch.
8152    ///
8153    /// Wire method: `session.ui.registerDirectAutoModeSwitchHandler`.
8154    ///
8155    /// # Returns
8156    ///
8157    /// 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).
8158    ///
8159    /// <div class="warning">
8160    ///
8161    /// **Experimental.** This API is part of an experimental wire-protocol surface
8162    /// and may change or be removed in future SDK or CLI releases. Pin both the
8163    /// SDK and CLI versions if your code depends on it.
8164    ///
8165    /// </div>
8166    pub async fn register_direct_auto_mode_switch_handler(
8167        &self,
8168    ) -> Result<UIRegisterDirectAutoModeSwitchHandlerResult, Error> {
8169        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8170        let _value = self
8171            .session
8172            .client()
8173            .call(
8174                rpc_methods::SESSION_UI_REGISTERDIRECTAUTOMODESWITCHHANDLER,
8175                Some(wire_params),
8176            )
8177            .await?;
8178        Ok(serde_json::from_value(_value)?)
8179    }
8180
8181    /// Unregisters a previously-registered in-process auto-mode-switch handler by its opaque handle.
8182    ///
8183    /// Wire method: `session.ui.unregisterDirectAutoModeSwitchHandler`.
8184    ///
8185    /// # Parameters
8186    ///
8187    /// * `params` - Opaque handle previously returned by `registerDirectAutoModeSwitchHandler` to release.
8188    ///
8189    /// # Returns
8190    ///
8191    /// Indicates whether the handle was active and the registration count was decremented.
8192    ///
8193    /// <div class="warning">
8194    ///
8195    /// **Experimental.** This API is part of an experimental wire-protocol surface
8196    /// and may change or be removed in future SDK or CLI releases. Pin both the
8197    /// SDK and CLI versions if your code depends on it.
8198    ///
8199    /// </div>
8200    pub async fn unregister_direct_auto_mode_switch_handler(
8201        &self,
8202        params: UIUnregisterDirectAutoModeSwitchHandlerRequest,
8203    ) -> Result<UIUnregisterDirectAutoModeSwitchHandlerResult, Error> {
8204        let mut wire_params = serde_json::to_value(params)?;
8205        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8206        let _value = self
8207            .session
8208            .client()
8209            .call(
8210                rpc_methods::SESSION_UI_UNREGISTERDIRECTAUTOMODESWITCHHANDLER,
8211                Some(wire_params),
8212            )
8213            .await?;
8214        Ok(serde_json::from_value(_value)?)
8215    }
8216}
8217
8218/// `session.usage.*` RPCs.
8219#[derive(Clone, Copy)]
8220pub struct SessionRpcUsage<'a> {
8221    pub(crate) session: &'a Session,
8222}
8223
8224impl<'a> SessionRpcUsage<'a> {
8225    /// Gets accumulated usage metrics for the session.
8226    ///
8227    /// Wire method: `session.usage.getMetrics`.
8228    ///
8229    /// # Returns
8230    ///
8231    /// Accumulated session usage metrics, including premium request cost, token counts, model breakdown, and code-change totals.
8232    ///
8233    /// <div class="warning">
8234    ///
8235    /// **Experimental.** This API is part of an experimental wire-protocol surface
8236    /// and may change or be removed in future SDK or CLI releases. Pin both the
8237    /// SDK and CLI versions if your code depends on it.
8238    ///
8239    /// </div>
8240    pub async fn get_metrics(&self) -> Result<UsageGetMetricsResult, Error> {
8241        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8242        let _value = self
8243            .session
8244            .client()
8245            .call(rpc_methods::SESSION_USAGE_GETMETRICS, Some(wire_params))
8246            .await?;
8247        Ok(serde_json::from_value(_value)?)
8248    }
8249}
8250
8251/// `session.visibility.*` RPCs.
8252#[derive(Clone, Copy)]
8253pub struct SessionRpcVisibility<'a> {
8254    pub(crate) session: &'a Session,
8255}
8256
8257impl<'a> SessionRpcVisibility<'a> {
8258    /// 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").
8259    ///
8260    /// Wire method: `session.visibility.get`.
8261    ///
8262    /// # Returns
8263    ///
8264    /// Current sharing status and shareable GitHub URL for a session.
8265    ///
8266    /// <div class="warning">
8267    ///
8268    /// **Experimental.** This API is part of an experimental wire-protocol surface
8269    /// and may change or be removed in future SDK or CLI releases. Pin both the
8270    /// SDK and CLI versions if your code depends on it.
8271    ///
8272    /// </div>
8273    pub async fn get(&self) -> Result<VisibilityGetResult, Error> {
8274        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8275        let _value = self
8276            .session
8277            .client()
8278            .call(rpc_methods::SESSION_VISIBILITY_GET, Some(wire_params))
8279            .await?;
8280        Ok(serde_json::from_value(_value)?)
8281    }
8282
8283    /// 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.
8284    ///
8285    /// Wire method: `session.visibility.set`.
8286    ///
8287    /// # Parameters
8288    ///
8289    /// * `params` - Desired sharing status for the session.
8290    ///
8291    /// # Returns
8292    ///
8293    /// Effective sharing status and shareable GitHub URL after updating session visibility.
8294    ///
8295    /// <div class="warning">
8296    ///
8297    /// **Experimental.** This API is part of an experimental wire-protocol surface
8298    /// and may change or be removed in future SDK or CLI releases. Pin both the
8299    /// SDK and CLI versions if your code depends on it.
8300    ///
8301    /// </div>
8302    pub async fn set(&self, params: VisibilitySetRequest) -> Result<VisibilitySetResult, Error> {
8303        let mut wire_params = serde_json::to_value(params)?;
8304        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8305        let _value = self
8306            .session
8307            .client()
8308            .call(rpc_methods::SESSION_VISIBILITY_SET, Some(wire_params))
8309            .await?;
8310        Ok(serde_json::from_value(_value)?)
8311    }
8312}
8313
8314/// `session.workspaces.*` RPCs.
8315#[derive(Clone, Copy)]
8316pub struct SessionRpcWorkspaces<'a> {
8317    pub(crate) session: &'a Session,
8318}
8319
8320impl<'a> SessionRpcWorkspaces<'a> {
8321    /// Gets current workspace metadata for the session.
8322    ///
8323    /// Wire method: `session.workspaces.getWorkspace`.
8324    ///
8325    /// # Returns
8326    ///
8327    /// Current workspace metadata for the session, including its absolute filesystem path when available.
8328    ///
8329    /// <div class="warning">
8330    ///
8331    /// **Experimental.** This API is part of an experimental wire-protocol surface
8332    /// and may change or be removed in future SDK or CLI releases. Pin both the
8333    /// SDK and CLI versions if your code depends on it.
8334    ///
8335    /// </div>
8336    pub async fn get_workspace(&self) -> Result<WorkspacesGetWorkspaceResult, Error> {
8337        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8338        let _value = self
8339            .session
8340            .client()
8341            .call(
8342                rpc_methods::SESSION_WORKSPACES_GETWORKSPACE,
8343                Some(wire_params),
8344            )
8345            .await?;
8346        Ok(serde_json::from_value(_value)?)
8347    }
8348
8349    /// Lists files stored in the session workspace files directory.
8350    ///
8351    /// Wire method: `session.workspaces.listFiles`.
8352    ///
8353    /// # Returns
8354    ///
8355    /// Relative paths of files stored in the session workspace files directory.
8356    ///
8357    /// <div class="warning">
8358    ///
8359    /// **Experimental.** This API is part of an experimental wire-protocol surface
8360    /// and may change or be removed in future SDK or CLI releases. Pin both the
8361    /// SDK and CLI versions if your code depends on it.
8362    ///
8363    /// </div>
8364    pub async fn list_files(&self) -> Result<WorkspacesListFilesResult, Error> {
8365        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8366        let _value = self
8367            .session
8368            .client()
8369            .call(rpc_methods::SESSION_WORKSPACES_LISTFILES, Some(wire_params))
8370            .await?;
8371        Ok(serde_json::from_value(_value)?)
8372    }
8373
8374    /// Reads a file from the session workspace files directory.
8375    ///
8376    /// Wire method: `session.workspaces.readFile`.
8377    ///
8378    /// # Parameters
8379    ///
8380    /// * `params` - Relative path of the workspace file to read.
8381    ///
8382    /// # Returns
8383    ///
8384    /// Contents of the requested workspace file as a UTF-8 string.
8385    ///
8386    /// <div class="warning">
8387    ///
8388    /// **Experimental.** This API is part of an experimental wire-protocol surface
8389    /// and may change or be removed in future SDK or CLI releases. Pin both the
8390    /// SDK and CLI versions if your code depends on it.
8391    ///
8392    /// </div>
8393    pub async fn read_file(
8394        &self,
8395        params: WorkspacesReadFileRequest,
8396    ) -> Result<WorkspacesReadFileResult, Error> {
8397        let mut wire_params = serde_json::to_value(params)?;
8398        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8399        let _value = self
8400            .session
8401            .client()
8402            .call(rpc_methods::SESSION_WORKSPACES_READFILE, Some(wire_params))
8403            .await?;
8404        Ok(serde_json::from_value(_value)?)
8405    }
8406
8407    /// Creates or overwrites a file in the session workspace files directory.
8408    ///
8409    /// Wire method: `session.workspaces.createFile`.
8410    ///
8411    /// # Parameters
8412    ///
8413    /// * `params` - Relative path and UTF-8 content for the workspace file to create or overwrite.
8414    ///
8415    /// <div class="warning">
8416    ///
8417    /// **Experimental.** This API is part of an experimental wire-protocol surface
8418    /// and may change or be removed in future SDK or CLI releases. Pin both the
8419    /// SDK and CLI versions if your code depends on it.
8420    ///
8421    /// </div>
8422    pub async fn create_file(&self, params: WorkspacesCreateFileRequest) -> Result<(), Error> {
8423        let mut wire_params = serde_json::to_value(params)?;
8424        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8425        let _value = self
8426            .session
8427            .client()
8428            .call(
8429                rpc_methods::SESSION_WORKSPACES_CREATEFILE,
8430                Some(wire_params),
8431            )
8432            .await?;
8433        Ok(())
8434    }
8435
8436    /// Lists workspace checkpoints in chronological order.
8437    ///
8438    /// Wire method: `session.workspaces.listCheckpoints`.
8439    ///
8440    /// # Returns
8441    ///
8442    /// Workspace checkpoints in chronological order; empty when the workspace is not enabled.
8443    ///
8444    /// <div class="warning">
8445    ///
8446    /// **Experimental.** This API is part of an experimental wire-protocol surface
8447    /// and may change or be removed in future SDK or CLI releases. Pin both the
8448    /// SDK and CLI versions if your code depends on it.
8449    ///
8450    /// </div>
8451    pub async fn list_checkpoints(&self) -> Result<WorkspacesListCheckpointsResult, Error> {
8452        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8453        let _value = self
8454            .session
8455            .client()
8456            .call(
8457                rpc_methods::SESSION_WORKSPACES_LISTCHECKPOINTS,
8458                Some(wire_params),
8459            )
8460            .await?;
8461        Ok(serde_json::from_value(_value)?)
8462    }
8463
8464    /// Reads the content of a workspace checkpoint by number.
8465    ///
8466    /// Wire method: `session.workspaces.readCheckpoint`.
8467    ///
8468    /// # Parameters
8469    ///
8470    /// * `params` - Checkpoint number to read.
8471    ///
8472    /// # Returns
8473    ///
8474    /// Checkpoint content as a UTF-8 string, or null when the checkpoint or workspace is missing.
8475    ///
8476    /// <div class="warning">
8477    ///
8478    /// **Experimental.** This API is part of an experimental wire-protocol surface
8479    /// and may change or be removed in future SDK or CLI releases. Pin both the
8480    /// SDK and CLI versions if your code depends on it.
8481    ///
8482    /// </div>
8483    pub async fn read_checkpoint(
8484        &self,
8485        params: WorkspacesReadCheckpointRequest,
8486    ) -> Result<WorkspacesReadCheckpointResult, Error> {
8487        let mut wire_params = serde_json::to_value(params)?;
8488        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8489        let _value = self
8490            .session
8491            .client()
8492            .call(
8493                rpc_methods::SESSION_WORKSPACES_READCHECKPOINT,
8494                Some(wire_params),
8495            )
8496            .await?;
8497        Ok(serde_json::from_value(_value)?)
8498    }
8499
8500    /// Saves pasted content as a UTF-8 file in the session workspace.
8501    ///
8502    /// Wire method: `session.workspaces.saveLargePaste`.
8503    ///
8504    /// # Parameters
8505    ///
8506    /// * `params` - Pasted content to save as a UTF-8 file in the session workspace.
8507    ///
8508    /// # Returns
8509    ///
8510    /// Descriptor for the saved paste file, or null when the workspace is unavailable.
8511    ///
8512    /// <div class="warning">
8513    ///
8514    /// **Experimental.** This API is part of an experimental wire-protocol surface
8515    /// and may change or be removed in future SDK or CLI releases. Pin both the
8516    /// SDK and CLI versions if your code depends on it.
8517    ///
8518    /// </div>
8519    pub async fn save_large_paste(
8520        &self,
8521        params: WorkspacesSaveLargePasteRequest,
8522    ) -> Result<WorkspacesSaveLargePasteResult, Error> {
8523        let mut wire_params = serde_json::to_value(params)?;
8524        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8525        let _value = self
8526            .session
8527            .client()
8528            .call(
8529                rpc_methods::SESSION_WORKSPACES_SAVELARGEPASTE,
8530                Some(wire_params),
8531            )
8532            .await?;
8533        Ok(serde_json::from_value(_value)?)
8534    }
8535
8536    /// Computes a diff for the session workspace.
8537    ///
8538    /// Wire method: `session.workspaces.diff`.
8539    ///
8540    /// # Parameters
8541    ///
8542    /// * `params` - Parameters for computing a workspace diff.
8543    ///
8544    /// # Returns
8545    ///
8546    /// Workspace diff result for the requested mode.
8547    ///
8548    /// <div class="warning">
8549    ///
8550    /// **Experimental.** This API is part of an experimental wire-protocol surface
8551    /// and may change or be removed in future SDK or CLI releases. Pin both the
8552    /// SDK and CLI versions if your code depends on it.
8553    ///
8554    /// </div>
8555    pub async fn diff(&self, params: WorkspacesDiffRequest) -> Result<WorkspaceDiffResult, Error> {
8556        let mut wire_params = serde_json::to_value(params)?;
8557        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8558        let _value = self
8559            .session
8560            .client()
8561            .call(rpc_methods::SESSION_WORKSPACES_DIFF, Some(wire_params))
8562            .await?;
8563        Ok(serde_json::from_value(_value)?)
8564    }
8565}