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