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    /// `catalog.*` sub-namespace.
47    pub fn catalog(&self) -> ClientRpcCatalog<'a> {
48        ClientRpcCatalog {
49            client: self.client,
50        }
51    }
52
53    /// `commands.*` sub-namespace.
54    pub fn commands(&self) -> ClientRpcCommands<'a> {
55        ClientRpcCommands {
56            client: self.client,
57        }
58    }
59
60    /// `extensions.*` sub-namespace.
61    pub fn extensions(&self) -> ClientRpcExtensions<'a> {
62        ClientRpcExtensions {
63            client: self.client,
64        }
65    }
66
67    /// `instructions.*` sub-namespace.
68    pub fn instructions(&self) -> ClientRpcInstructions<'a> {
69        ClientRpcInstructions {
70            client: self.client,
71        }
72    }
73
74    /// `llmInference.*` sub-namespace.
75    pub fn llm_inference(&self) -> ClientRpcLlmInference<'a> {
76        ClientRpcLlmInference {
77            client: self.client,
78        }
79    }
80
81    /// `managedSettings.*` sub-namespace.
82    pub fn managed_settings(&self) -> ClientRpcManagedSettings<'a> {
83        ClientRpcManagedSettings {
84            client: self.client,
85        }
86    }
87
88    /// `mcp.*` sub-namespace.
89    pub fn mcp(&self) -> ClientRpcMcp<'a> {
90        ClientRpcMcp {
91            client: self.client,
92        }
93    }
94
95    /// `models.*` sub-namespace.
96    pub fn models(&self) -> ClientRpcModels<'a> {
97        ClientRpcModels {
98            client: self.client,
99        }
100    }
101
102    /// `plugins.*` sub-namespace.
103    pub fn plugins(&self) -> ClientRpcPlugins<'a> {
104        ClientRpcPlugins {
105            client: self.client,
106        }
107    }
108
109    /// `runtime.*` sub-namespace.
110    pub fn runtime(&self) -> ClientRpcRuntime<'a> {
111        ClientRpcRuntime {
112            client: self.client,
113        }
114    }
115
116    /// `secrets.*` sub-namespace.
117    pub fn secrets(&self) -> ClientRpcSecrets<'a> {
118        ClientRpcSecrets {
119            client: self.client,
120        }
121    }
122
123    /// `sessionFs.*` sub-namespace.
124    pub fn session_fs(&self) -> ClientRpcSessionFs<'a> {
125        ClientRpcSessionFs {
126            client: self.client,
127        }
128    }
129
130    /// `sessions.*` sub-namespace.
131    pub fn sessions(&self) -> ClientRpcSessions<'a> {
132        ClientRpcSessions {
133            client: self.client,
134        }
135    }
136
137    /// `skills.*` sub-namespace.
138    pub fn skills(&self) -> ClientRpcSkills<'a> {
139        ClientRpcSkills {
140            client: self.client,
141        }
142    }
143
144    /// `tools.*` sub-namespace.
145    pub fn tools(&self) -> ClientRpcTools<'a> {
146        ClientRpcTools {
147            client: self.client,
148        }
149    }
150
151    /// `user.*` sub-namespace.
152    pub fn user(&self) -> ClientRpcUser<'a> {
153        ClientRpcUser {
154            client: self.client,
155        }
156    }
157
158    /// Checks server responsiveness and returns protocol information.
159    ///
160    /// Wire method: `ping`.
161    ///
162    /// # Parameters
163    ///
164    /// * `params` - Optional message to echo back to the caller.
165    ///
166    /// # Returns
167    ///
168    /// Server liveness response, including the echoed message, current server timestamp, and protocol version.
169    ///
170    /// <div class="warning">
171    ///
172    /// **Experimental.** This API is part of an experimental wire-protocol surface
173    /// and may change or be removed in future SDK or CLI releases. Pin both the
174    /// SDK and CLI versions if your code depends on it.
175    ///
176    /// </div>
177    pub async fn ping(&self, params: PingRequest) -> Result<PingResult, Error> {
178        let wire_params = serde_json::to_value(params)?;
179        let _value = self
180            .client
181            .call(rpc_methods::PING, Some(wire_params))
182            .await?;
183        Ok(serde_json::from_value(_value)?)
184    }
185
186    /// 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.
187    ///
188    /// Wire method: `connect`.
189    ///
190    /// # Parameters
191    ///
192    /// * `params` - Connection-level opt-ins for the `server.connect` handshake. Transport authentication is consumed by the native protocol boundary before dispatch.
193    ///
194    /// # Returns
195    ///
196    /// Handshake result reporting the server's protocol version and package version on success.
197    ///
198    /// <div class="warning">
199    ///
200    /// **Experimental.** This API is part of an experimental wire-protocol surface
201    /// and may change or be removed in future SDK or CLI releases. Pin both the
202    /// SDK and CLI versions if your code depends on it.
203    ///
204    /// </div>
205    pub(crate) async fn connect(&self, params: ConnectRequest) -> Result<ConnectResult, Error> {
206        let wire_params = serde_json::to_value(params)?;
207        let _value = self
208            .client
209            .call(rpc_methods::CONNECT, Some(wire_params))
210            .await?;
211        Ok(serde_json::from_value(_value)?)
212    }
213
214    /// Registers the calling SDK client as the per-entrypoint extension launch provider. Call before creating any sessions. When omitted, the runtime temporarily falls back to its built-in Node launcher for backward compatibility.
215    ///
216    /// Wire method: `registerExtensionLaunchProvider`.
217    ///
218    /// <div class="warning">
219    ///
220    /// **Experimental.** This API is part of an experimental wire-protocol surface
221    /// and may change or be removed in future SDK or CLI releases. Pin both the
222    /// SDK and CLI versions if your code depends on it.
223    ///
224    /// </div>
225    pub async fn register_extension_launch_provider(&self) -> Result<(), Error> {
226        let wire_params = serde_json::json!({});
227        let _value = self
228            .client
229            .call(
230                rpc_methods::REGISTEREXTENSIONLAUNCHPROVIDER,
231                Some(wire_params),
232            )
233            .await?;
234        Ok(())
235    }
236}
237
238/// `account.*` RPCs.
239#[derive(Clone, Copy)]
240pub struct ClientRpcAccount<'a> {
241    pub(crate) client: &'a Client,
242}
243
244impl<'a> ClientRpcAccount<'a> {
245    /// Gets Copilot quota usage for the current or opaquely selected authenticated user.
246    ///
247    /// Wire method: `account.getQuota`.
248    ///
249    /// # Returns
250    ///
251    /// Quota usage snapshots for the resolved user, keyed by quota type.
252    ///
253    /// <div class="warning">
254    ///
255    /// **Experimental.** This API is part of an experimental wire-protocol surface
256    /// and may change or be removed in future SDK or CLI releases. Pin both the
257    /// SDK and CLI versions if your code depends on it.
258    ///
259    /// </div>
260    pub async fn get_quota(&self) -> Result<AccountGetQuotaResult, Error> {
261        let wire_params = serde_json::json!({});
262        let _value = self
263            .client
264            .call(rpc_methods::ACCOUNT_GETQUOTA, Some(wire_params))
265            .await?;
266        Ok(serde_json::from_value(_value)?)
267    }
268
269    /// Gets Copilot quota usage for the current or opaquely selected authenticated user.
270    ///
271    /// Wire method: `account.getQuota`.
272    ///
273    /// # Parameters
274    ///
275    /// * `params` - Optional opaque account selection or compatibility GitHub token used to look up quota.
276    ///
277    /// # Returns
278    ///
279    /// Quota usage snapshots for the resolved user, keyed by quota type.
280    ///
281    /// <div class="warning">
282    ///
283    /// **Experimental.** This API is part of an experimental wire-protocol surface
284    /// and may change or be removed in future SDK or CLI releases. Pin both the
285    /// SDK and CLI versions if your code depends on it.
286    ///
287    /// </div>
288    pub async fn get_quota_with_params(
289        &self,
290        params: AccountGetQuotaRequest,
291    ) -> Result<AccountGetQuotaResult, Error> {
292        let wire_params = serde_json::to_value(params)?;
293        let _value = self
294            .client
295            .call(rpc_methods::ACCOUNT_GETQUOTA, Some(wire_params))
296            .await?;
297        Ok(serde_json::from_value(_value)?)
298    }
299
300    /// Gets the currently active authentication credentials from the global auth manager.
301    ///
302    /// Wire method: `account.getCurrentAuth`.
303    ///
304    /// # Returns
305    ///
306    /// Current authentication state
307    ///
308    /// <div class="warning">
309    ///
310    /// **Experimental.** This API is part of an experimental wire-protocol surface
311    /// and may change or be removed in future SDK or CLI releases. Pin both the
312    /// SDK and CLI versions if your code depends on it.
313    ///
314    /// </div>
315    pub async fn get_current_auth(&self) -> Result<AccountGetCurrentAuthResult, Error> {
316        let wire_params = serde_json::json!({});
317        let _value = self
318            .client
319            .call(rpc_methods::ACCOUNT_GETCURRENTAUTH, Some(wire_params))
320            .await?;
321        Ok(serde_json::from_value(_value)?)
322    }
323
324    /// Gets all authenticated users available for account switching.
325    ///
326    /// Wire method: `account.getAllUsers`.
327    ///
328    /// # Returns
329    ///
330    /// List of all authenticated users
331    ///
332    /// <div class="warning">
333    ///
334    /// **Experimental.** This API is part of an experimental wire-protocol surface
335    /// and may change or be removed in future SDK or CLI releases. Pin both the
336    /// SDK and CLI versions if your code depends on it.
337    ///
338    /// </div>
339    pub async fn get_all_users(&self) -> Result<AccountGetAllUsersResult, Error> {
340        let wire_params = serde_json::json!({});
341        let _value = self
342            .client
343            .call(rpc_methods::ACCOUNT_GETALLUSERS, Some(wire_params))
344            .await?;
345        Ok(serde_json::from_value(_value)?)
346    }
347
348    /// Validates and stores authentication credentials. When login is omitted, resolves the authenticated user from the token before persistence.
349    ///
350    /// Wire method: `account.login`.
351    ///
352    /// # Parameters
353    ///
354    /// * `params` - Credentials to validate and store. Omit login to resolve the authenticated user from the token.
355    ///
356    /// # Returns
357    ///
358    /// Result of a successful login; throws on failure
359    ///
360    /// <div class="warning">
361    ///
362    /// **Experimental.** This API is part of an experimental wire-protocol surface
363    /// and may change or be removed in future SDK or CLI releases. Pin both the
364    /// SDK and CLI versions if your code depends on it.
365    ///
366    /// </div>
367    pub async fn login(&self, params: AccountLoginRequest) -> Result<AccountLoginResult, Error> {
368        let wire_params = serde_json::to_value(params)?;
369        let _value = self
370            .client
371            .call(rpc_methods::ACCOUNT_LOGIN, Some(wire_params))
372            .await?;
373        Ok(serde_json::from_value(_value)?)
374    }
375
376    /// Removes user authentication from keychain and persisted state.
377    ///
378    /// Wire method: `account.logout`.
379    ///
380    /// # Parameters
381    ///
382    /// * `params` - User to log out
383    ///
384    /// # Returns
385    ///
386    /// Logout result indicating if more users remain
387    ///
388    /// <div class="warning">
389    ///
390    /// **Experimental.** This API is part of an experimental wire-protocol surface
391    /// and may change or be removed in future SDK or CLI releases. Pin both the
392    /// SDK and CLI versions if your code depends on it.
393    ///
394    /// </div>
395    pub async fn logout(&self, params: AccountLogoutRequest) -> Result<AccountLogoutResult, Error> {
396        let wire_params = serde_json::to_value(params)?;
397        let _value = self
398            .client
399            .call(rpc_methods::ACCOUNT_LOGOUT, Some(wire_params))
400            .await?;
401        Ok(serde_json::from_value(_value)?)
402    }
403}
404
405/// `agentRegistry.*` RPCs.
406#[derive(Clone, Copy)]
407pub struct ClientRpcAgentRegistry<'a> {
408    pub(crate) client: &'a Client,
409}
410
411impl<'a> ClientRpcAgentRegistry<'a> {
412    /// 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.
413    ///
414    /// Wire method: `agentRegistry.spawn`.
415    ///
416    /// # Parameters
417    ///
418    /// * `params` - Inputs to spawn a managed-server child via the controller's spawn delegate.
419    ///
420    /// # Returns
421    ///
422    /// Outcome of an agentRegistry.spawn call.
423    ///
424    /// <div class="warning">
425    ///
426    /// **Experimental.** This API is part of an experimental wire-protocol surface
427    /// and may change or be removed in future SDK or CLI releases. Pin both the
428    /// SDK and CLI versions if your code depends on it.
429    ///
430    /// </div>
431    pub async fn spawn(
432        &self,
433        params: AgentRegistrySpawnRequest,
434    ) -> Result<AgentRegistrySpawnResult, Error> {
435        let wire_params = serde_json::to_value(params)?;
436        let _value = self
437            .client
438            .call(rpc_methods::AGENTREGISTRY_SPAWN, Some(wire_params))
439            .await?;
440        Ok(serde_json::from_value(_value)?)
441    }
442}
443
444/// `agents.*` RPCs.
445#[derive(Clone, Copy)]
446pub struct ClientRpcAgents<'a> {
447    pub(crate) client: &'a Client,
448}
449
450impl<'a> ClientRpcAgents<'a> {
451    /// Discovers custom agents across user, project, plugin, and remote sources.
452    ///
453    /// Wire method: `agents.discover`.
454    ///
455    /// # Parameters
456    ///
457    /// * `params` - Optional project paths to include in agent discovery.
458    ///
459    /// # Returns
460    ///
461    /// Agents discovered across user, project, plugin, and remote sources.
462    ///
463    /// <div class="warning">
464    ///
465    /// **Experimental.** This API is part of an experimental wire-protocol surface
466    /// and may change or be removed in future SDK or CLI releases. Pin both the
467    /// SDK and CLI versions if your code depends on it.
468    ///
469    /// </div>
470    pub async fn discover(&self, params: AgentsDiscoverRequest) -> Result<ServerAgentList, Error> {
471        let wire_params = serde_json::to_value(params)?;
472        let _value = self
473            .client
474            .call(rpc_methods::AGENTS_DISCOVER, Some(wire_params))
475            .await?;
476        Ok(serde_json::from_value(_value)?)
477    }
478
479    /// 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.
480    ///
481    /// Wire method: `agents.getDiscoveryPaths`.
482    ///
483    /// # Parameters
484    ///
485    /// * `params` - Optional project paths to include when enumerating agent discovery directories.
486    ///
487    /// # Returns
488    ///
489    /// Canonical locations where custom agents can be created so the runtime will recognize them.
490    ///
491    /// <div class="warning">
492    ///
493    /// **Experimental.** This API is part of an experimental wire-protocol surface
494    /// and may change or be removed in future SDK or CLI releases. Pin both the
495    /// SDK and CLI versions if your code depends on it.
496    ///
497    /// </div>
498    pub async fn get_discovery_paths(
499        &self,
500        params: AgentsGetDiscoveryPathsRequest,
501    ) -> Result<AgentDiscoveryPathList, Error> {
502        let wire_params = serde_json::to_value(params)?;
503        let _value = self
504            .client
505            .call(rpc_methods::AGENTS_GETDISCOVERYPATHS, Some(wire_params))
506            .await?;
507        Ok(serde_json::from_value(_value)?)
508    }
509}
510
511/// `catalog.*` RPCs.
512#[derive(Clone, Copy)]
513pub struct ClientRpcCatalog<'a> {
514    pub(crate) client: &'a Client,
515}
516
517impl<'a> ClientRpcCatalog<'a> {
518    /// Requests a bounded catalog search. This host-implemented server method is available through SDK/TUI hosts; standalone and C-ABI runtimes whose host does not implement server-method dispatch return JSON-RPC MethodNotFound. A runtime with search available returns inert candidate summaries, each with an opaque single-use handle scoped to this runtime instance; a runtime without it returns the typed search-unavailable result. Public authorities may be searched anonymously, while an authority that requires credentials yields the typed authentication-required result. All returned text, URLs, and package metadata are untrusted external data and can never trigger instructions, tools, or installation. Read-only: nothing is installed, configured, or persisted.
519    ///
520    /// Wire method: `catalog.search`.
521    ///
522    /// # Parameters
523    ///
524    /// * `params` - A bounded catalog search. Both the query length and the result count are capped by the schema so a caller cannot request an unbounded scan.
525    ///
526    /// # Returns
527    ///
528    /// Outcome of a catalog.search call: either bounded inert candidates, or one typed refusal. Never a partial success.
529    ///
530    /// <div class="warning">
531    ///
532    /// **Experimental.** This API is part of an experimental wire-protocol surface
533    /// and may change or be removed in future SDK or CLI releases. Pin both the
534    /// SDK and CLI versions if your code depends on it.
535    ///
536    /// </div>
537    pub async fn search(&self, params: CatalogSearchRequest) -> Result<CatalogSearchResult, Error> {
538        let wire_params = serde_json::to_value(params)?;
539        let _value = self
540            .client
541            .call(rpc_methods::CATALOG_SEARCH, Some(wire_params))
542            .await?;
543        Ok(serde_json::from_value(_value)?)
544    }
545}
546
547/// `commands.*` RPCs.
548#[derive(Clone, Copy)]
549pub struct ClientRpcCommands<'a> {
550    pub(crate) client: &'a Client,
551}
552
553impl<'a> ClientRpcCommands<'a> {
554    /// 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.
555    ///
556    /// Wire method: `commands.list`.
557    ///
558    /// # Returns
559    ///
560    /// Slash commands available in the session, after applying any include/exclude filters.
561    ///
562    /// <div class="warning">
563    ///
564    /// **Experimental.** This API is part of an experimental wire-protocol surface
565    /// and may change or be removed in future SDK or CLI releases. Pin both the
566    /// SDK and CLI versions if your code depends on it.
567    ///
568    /// </div>
569    pub async fn list(&self) -> Result<CommandList, Error> {
570        let wire_params = serde_json::json!({});
571        let _value = self
572            .client
573            .call(rpc_methods::COMMANDS_LIST, Some(wire_params))
574            .await?;
575        Ok(serde_json::from_value(_value)?)
576    }
577}
578
579/// `extensions.*` RPCs.
580#[derive(Clone, Copy)]
581pub struct ClientRpcExtensions<'a> {
582    pub(crate) client: &'a Client,
583}
584
585impl<'a> ClientRpcExtensions<'a> {
586    /// Discovers user and enabled installed-plugin extensions from persisted Copilot home state, including enablement preferences. Launch-scoped additional plugins are not included.
587    ///
588    /// Wire method: `extensions.discover`.
589    ///
590    /// # Returns
591    ///
592    /// Extensions discovered from persisted Copilot home state and their effective loading mode. Launch-scoped additional plugins are not included.
593    ///
594    /// <div class="warning">
595    ///
596    /// **Experimental.** This API is part of an experimental wire-protocol surface
597    /// and may change or be removed in future SDK or CLI releases. Pin both the
598    /// SDK and CLI versions if your code depends on it.
599    ///
600    /// </div>
601    pub async fn discover(&self) -> Result<DiscoveredExtensions, Error> {
602        let wire_params = serde_json::json!({});
603        let _value = self
604            .client
605            .call(rpc_methods::EXTENSIONS_DISCOVER, Some(wire_params))
606            .await?;
607        Ok(serde_json::from_value(_value)?)
608    }
609
610    /// Persistently enables extension IDs for future sessions. Active sessions are unchanged; use session.extensions.enable to update them.
611    ///
612    /// Wire method: `extensions.enable`.
613    ///
614    /// # Parameters
615    ///
616    /// * `params` - Source-qualified extension identifiers to persistently enable for future sessions.
617    ///
618    /// <div class="warning">
619    ///
620    /// **Experimental.** This API is part of an experimental wire-protocol surface
621    /// and may change or be removed in future SDK or CLI releases. Pin both the
622    /// SDK and CLI versions if your code depends on it.
623    ///
624    /// </div>
625    pub async fn enable(&self, params: DiscoveredExtensionsEnableRequest) -> Result<(), Error> {
626        let wire_params = serde_json::to_value(params)?;
627        let _value = self
628            .client
629            .call(rpc_methods::EXTENSIONS_ENABLE, Some(wire_params))
630            .await?;
631        Ok(())
632    }
633
634    /// Persistently disables extension IDs for future sessions. Active sessions are unchanged; use session.extensions.disable to update them.
635    ///
636    /// Wire method: `extensions.disable`.
637    ///
638    /// # Parameters
639    ///
640    /// * `params` - Source-qualified extension identifiers to persistently disable for future sessions.
641    ///
642    /// <div class="warning">
643    ///
644    /// **Experimental.** This API is part of an experimental wire-protocol surface
645    /// and may change or be removed in future SDK or CLI releases. Pin both the
646    /// SDK and CLI versions if your code depends on it.
647    ///
648    /// </div>
649    pub async fn disable(&self, params: DiscoveredExtensionsDisableRequest) -> Result<(), Error> {
650        let wire_params = serde_json::to_value(params)?;
651        let _value = self
652            .client
653            .call(rpc_methods::EXTENSIONS_DISABLE, Some(wire_params))
654            .await?;
655        Ok(())
656    }
657}
658
659/// `instructions.*` RPCs.
660#[derive(Clone, Copy)]
661pub struct ClientRpcInstructions<'a> {
662    pub(crate) client: &'a Client,
663}
664
665impl<'a> ClientRpcInstructions<'a> {
666    /// Discovers instruction sources across user, repository, and plugin sources.
667    ///
668    /// Wire method: `instructions.discover`.
669    ///
670    /// # Parameters
671    ///
672    /// * `params` - Optional project paths to include in instruction discovery.
673    ///
674    /// # Returns
675    ///
676    /// Instruction sources discovered across user, repository, and plugin sources.
677    ///
678    /// <div class="warning">
679    ///
680    /// **Experimental.** This API is part of an experimental wire-protocol surface
681    /// and may change or be removed in future SDK or CLI releases. Pin both the
682    /// SDK and CLI versions if your code depends on it.
683    ///
684    /// </div>
685    pub async fn discover(
686        &self,
687        params: InstructionsDiscoverRequest,
688    ) -> Result<ServerInstructionSourceList, Error> {
689        let wire_params = serde_json::to_value(params)?;
690        let _value = self
691            .client
692            .call(rpc_methods::INSTRUCTIONS_DISCOVER, Some(wire_params))
693            .await?;
694        Ok(serde_json::from_value(_value)?)
695    }
696
697    /// 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.
698    ///
699    /// Wire method: `instructions.getDiscoveryPaths`.
700    ///
701    /// # Parameters
702    ///
703    /// * `params` - Optional project paths to include when enumerating instruction discovery targets.
704    ///
705    /// # Returns
706    ///
707    /// Canonical files and directories where custom instructions can be created so the runtime will recognize them.
708    ///
709    /// <div class="warning">
710    ///
711    /// **Experimental.** This API is part of an experimental wire-protocol surface
712    /// and may change or be removed in future SDK or CLI releases. Pin both the
713    /// SDK and CLI versions if your code depends on it.
714    ///
715    /// </div>
716    pub async fn get_discovery_paths(
717        &self,
718        params: InstructionsGetDiscoveryPathsRequest,
719    ) -> Result<InstructionDiscoveryPathList, Error> {
720        let wire_params = serde_json::to_value(params)?;
721        let _value = self
722            .client
723            .call(
724                rpc_methods::INSTRUCTIONS_GETDISCOVERYPATHS,
725                Some(wire_params),
726            )
727            .await?;
728        Ok(serde_json::from_value(_value)?)
729    }
730}
731
732/// `llmInference.*` RPCs.
733#[derive(Clone, Copy)]
734pub struct ClientRpcLlmInference<'a> {
735    pub(crate) client: &'a Client,
736}
737
738impl<'a> ClientRpcLlmInference<'a> {
739    /// Registers an SDK client as the LLM inference callback provider.
740    ///
741    /// Wire method: `llmInference.setProvider`.
742    ///
743    /// # Returns
744    ///
745    /// Indicates whether the calling client was registered as the LLM inference provider.
746    ///
747    /// <div class="warning">
748    ///
749    /// **Experimental.** This API is part of an experimental wire-protocol surface
750    /// and may change or be removed in future SDK or CLI releases. Pin both the
751    /// SDK and CLI versions if your code depends on it.
752    ///
753    /// </div>
754    pub async fn set_provider(&self) -> Result<LlmInferenceSetProviderResult, Error> {
755        let wire_params = serde_json::json!({});
756        let _value = self
757            .client
758            .call(rpc_methods::LLMINFERENCE_SETPROVIDER, Some(wire_params))
759            .await?;
760        Ok(serde_json::from_value(_value)?)
761    }
762
763    /// 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.
764    ///
765    /// Wire method: `llmInference.httpResponseStart`.
766    ///
767    /// # Parameters
768    ///
769    /// * `params` - Response head.
770    ///
771    /// # Returns
772    ///
773    /// Whether the start frame was accepted.
774    ///
775    /// <div class="warning">
776    ///
777    /// **Experimental.** This API is part of an experimental wire-protocol surface
778    /// and may change or be removed in future SDK or CLI releases. Pin both the
779    /// SDK and CLI versions if your code depends on it.
780    ///
781    /// </div>
782    pub async fn http_response_start(
783        &self,
784        params: LlmInferenceHttpResponseStartRequest,
785    ) -> Result<LlmInferenceHttpResponseStartResult, Error> {
786        let wire_params = serde_json::to_value(params)?;
787        let _value = self
788            .client
789            .call(
790                rpc_methods::LLMINFERENCE_HTTPRESPONSESTART,
791                Some(wire_params),
792            )
793            .await?;
794        Ok(serde_json::from_value(_value)?)
795    }
796
797    /// 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.
798    ///
799    /// Wire method: `llmInference.httpResponseChunk`.
800    ///
801    /// # Parameters
802    ///
803    /// * `params` - A response body chunk or terminal error.
804    ///
805    /// # Returns
806    ///
807    /// Whether the chunk was accepted.
808    ///
809    /// <div class="warning">
810    ///
811    /// **Experimental.** This API is part of an experimental wire-protocol surface
812    /// and may change or be removed in future SDK or CLI releases. Pin both the
813    /// SDK and CLI versions if your code depends on it.
814    ///
815    /// </div>
816    pub async fn http_response_chunk(
817        &self,
818        params: LlmInferenceHttpResponseChunkRequest,
819    ) -> Result<LlmInferenceHttpResponseChunkResult, Error> {
820        let wire_params = serde_json::to_value(params)?;
821        let _value = self
822            .client
823            .call(
824                rpc_methods::LLMINFERENCE_HTTPRESPONSECHUNK,
825                Some(wire_params),
826            )
827            .await?;
828        Ok(serde_json::from_value(_value)?)
829    }
830}
831
832/// `managedSettings.*` RPCs.
833#[derive(Clone, Copy)]
834pub struct ClientRpcManagedSettings<'a> {
835    pub(crate) client: &'a Client,
836}
837
838impl<'a> ClientRpcManagedSettings<'a> {
839    /// Discovers device-managed settings from production MDM and managed-file sources, validates them against the runtime-owned managed-settings schema, and returns the canonical JSON without requiring a session.
840    ///
841    /// Wire method: `managedSettings.read`.
842    ///
843    /// # Returns
844    ///
845    /// Validated device-managed settings discovered before a session exists.
846    ///
847    /// <div class="warning">
848    ///
849    /// **Experimental.** This API is part of an experimental wire-protocol surface
850    /// and may change or be removed in future SDK or CLI releases. Pin both the
851    /// SDK and CLI versions if your code depends on it.
852    ///
853    /// </div>
854    pub async fn read(&self) -> Result<ManagedSettingsReadResult, Error> {
855        let wire_params = serde_json::json!({});
856        let _value = self
857            .client
858            .call(rpc_methods::MANAGEDSETTINGS_READ, Some(wire_params))
859            .await?;
860        Ok(serde_json::from_value(_value)?)
861    }
862}
863
864/// `mcp.*` RPCs.
865#[derive(Clone, Copy)]
866pub struct ClientRpcMcp<'a> {
867    pub(crate) client: &'a Client,
868}
869
870impl<'a> ClientRpcMcp<'a> {
871    /// `mcp.config.*` sub-namespace.
872    pub fn config(&self) -> ClientRpcMcpConfig<'a> {
873        ClientRpcMcpConfig {
874            client: self.client,
875        }
876    }
877
878    /// Discovers MCP servers from user, workspace, plugin, and builtin sources.
879    ///
880    /// Wire method: `mcp.discover`.
881    ///
882    /// # Parameters
883    ///
884    /// * `params` - Optional working directory used as context for MCP server discovery.
885    ///
886    /// # Returns
887    ///
888    /// MCP servers discovered from user, workspace, plugin, and built-in sources.
889    ///
890    /// <div class="warning">
891    ///
892    /// **Experimental.** This API is part of an experimental wire-protocol surface
893    /// and may change or be removed in future SDK or CLI releases. Pin both the
894    /// SDK and CLI versions if your code depends on it.
895    ///
896    /// </div>
897    pub async fn discover(&self, params: McpDiscoverRequest) -> Result<McpDiscoverResult, Error> {
898        let wire_params = serde_json::to_value(params)?;
899        let _value = self
900            .client
901            .call(rpc_methods::MCP_DISCOVER, Some(wire_params))
902            .await?;
903        Ok(serde_json::from_value(_value)?)
904    }
905
906    /// Requests a side-effect-free MCP install plan from a catalog candidate handle or a caller-supplied card. This host-implemented server method is available through SDK/TUI hosts; standalone and C-ABI runtimes whose host does not implement server-method dispatch return JSON-RPC MethodNotFound. A runtime with planning available returns a normalised plan and opaque single-use plan handle; a runtime without it returns the typed planning-unavailable result. A completed plan reports resource identity, provenance, eligible transport choices, the user-scope target, required typed values and secret placeholders, the policy result, the configuration changes installing would make, and whether a reload would be needed. Planning never writes configuration, stores a secret, or reloads MCP servers, so abandoning a plan needs no call and leaves nothing behind.
907    ///
908    /// Wire method: `mcp.planInstall`.
909    ///
910    /// # Parameters
911    ///
912    /// * `params` - A side-effect-free request for an MCP install plan. Computing a plan never writes configuration, stores a secret, or reloads MCP servers.
913    ///
914    /// # Returns
915    ///
916    /// Outcome of an mcp.planInstall call: either a normalised plan, or one typed refusal. Nothing is written in either case.
917    ///
918    /// <div class="warning">
919    ///
920    /// **Experimental.** This API is part of an experimental wire-protocol surface
921    /// and may change or be removed in future SDK or CLI releases. Pin both the
922    /// SDK and CLI versions if your code depends on it.
923    ///
924    /// </div>
925    pub async fn plan_install(
926        &self,
927        params: McpPlanInstallRequest,
928    ) -> Result<McpPlanInstallResult, Error> {
929        let wire_params = serde_json::to_value(params)?;
930        let _value = self
931            .client
932            .call(rpc_methods::MCP_PLANINSTALL, Some(wire_params))
933            .await?;
934        Ok(serde_json::from_value(_value)?)
935    }
936}
937
938/// `mcp.config.*` RPCs.
939#[derive(Clone, Copy)]
940pub struct ClientRpcMcpConfig<'a> {
941    pub(crate) client: &'a Client,
942}
943
944impl<'a> ClientRpcMcpConfig<'a> {
945    /// Lists MCP servers from user configuration.
946    ///
947    /// Wire method: `mcp.config.list`.
948    ///
949    /// # Returns
950    ///
951    /// User-configured MCP servers, keyed by server name.
952    ///
953    /// <div class="warning">
954    ///
955    /// **Experimental.** This API is part of an experimental wire-protocol surface
956    /// and may change or be removed in future SDK or CLI releases. Pin both the
957    /// SDK and CLI versions if your code depends on it.
958    ///
959    /// </div>
960    pub async fn list(&self) -> Result<McpConfigList, Error> {
961        let wire_params = serde_json::json!({});
962        let _value = self
963            .client
964            .call(rpc_methods::MCP_CONFIG_LIST, Some(wire_params))
965            .await?;
966        Ok(serde_json::from_value(_value)?)
967    }
968
969    /// Adds an MCP server to user configuration.
970    ///
971    /// Wire method: `mcp.config.add`.
972    ///
973    /// # Parameters
974    ///
975    /// * `params` - MCP server name and configuration to add to user configuration.
976    ///
977    /// <div class="warning">
978    ///
979    /// **Experimental.** This API is part of an experimental wire-protocol surface
980    /// and may change or be removed in future SDK or CLI releases. Pin both the
981    /// SDK and CLI versions if your code depends on it.
982    ///
983    /// </div>
984    pub async fn add(&self, params: McpConfigAddRequest) -> Result<(), Error> {
985        let wire_params = serde_json::to_value(params)?;
986        let _value = self
987            .client
988            .call(rpc_methods::MCP_CONFIG_ADD, Some(wire_params))
989            .await?;
990        Ok(())
991    }
992
993    /// Updates an MCP server in user configuration.
994    ///
995    /// Wire method: `mcp.config.update`.
996    ///
997    /// # Parameters
998    ///
999    /// * `params` - MCP server name and replacement configuration to write to user configuration.
1000    ///
1001    /// <div class="warning">
1002    ///
1003    /// **Experimental.** This API is part of an experimental wire-protocol surface
1004    /// and may change or be removed in future SDK or CLI releases. Pin both the
1005    /// SDK and CLI versions if your code depends on it.
1006    ///
1007    /// </div>
1008    pub async fn update(&self, params: McpConfigUpdateRequest) -> Result<(), Error> {
1009        let wire_params = serde_json::to_value(params)?;
1010        let _value = self
1011            .client
1012            .call(rpc_methods::MCP_CONFIG_UPDATE, Some(wire_params))
1013            .await?;
1014        Ok(())
1015    }
1016
1017    /// Removes an MCP server from user configuration.
1018    ///
1019    /// Wire method: `mcp.config.remove`.
1020    ///
1021    /// # Parameters
1022    ///
1023    /// * `params` - MCP server name to remove from user configuration.
1024    ///
1025    /// <div class="warning">
1026    ///
1027    /// **Experimental.** This API is part of an experimental wire-protocol surface
1028    /// and may change or be removed in future SDK or CLI releases. Pin both the
1029    /// SDK and CLI versions if your code depends on it.
1030    ///
1031    /// </div>
1032    pub async fn remove(&self, params: McpConfigRemoveRequest) -> Result<(), Error> {
1033        let wire_params = serde_json::to_value(params)?;
1034        let _value = self
1035            .client
1036            .call(rpc_methods::MCP_CONFIG_REMOVE, Some(wire_params))
1037            .await?;
1038        Ok(())
1039    }
1040
1041    /// Enables MCP servers in user configuration for new sessions.
1042    ///
1043    /// Wire method: `mcp.config.enable`.
1044    ///
1045    /// # Parameters
1046    ///
1047    /// * `params` - MCP server names to enable for new sessions.
1048    ///
1049    /// <div class="warning">
1050    ///
1051    /// **Experimental.** This API is part of an experimental wire-protocol surface
1052    /// and may change or be removed in future SDK or CLI releases. Pin both the
1053    /// SDK and CLI versions if your code depends on it.
1054    ///
1055    /// </div>
1056    pub async fn enable(&self, params: McpConfigEnableRequest) -> Result<(), Error> {
1057        let wire_params = serde_json::to_value(params)?;
1058        let _value = self
1059            .client
1060            .call(rpc_methods::MCP_CONFIG_ENABLE, Some(wire_params))
1061            .await?;
1062        Ok(())
1063    }
1064
1065    /// Disables MCP servers in user configuration for new sessions.
1066    ///
1067    /// Wire method: `mcp.config.disable`.
1068    ///
1069    /// # Parameters
1070    ///
1071    /// * `params` - MCP server names to disable for new sessions.
1072    ///
1073    /// <div class="warning">
1074    ///
1075    /// **Experimental.** This API is part of an experimental wire-protocol surface
1076    /// and may change or be removed in future SDK or CLI releases. Pin both the
1077    /// SDK and CLI versions if your code depends on it.
1078    ///
1079    /// </div>
1080    pub async fn disable(&self, params: McpConfigDisableRequest) -> Result<(), Error> {
1081        let wire_params = serde_json::to_value(params)?;
1082        let _value = self
1083            .client
1084            .call(rpc_methods::MCP_CONFIG_DISABLE, Some(wire_params))
1085            .await?;
1086        Ok(())
1087    }
1088
1089    /// Drops this runtime process's in-memory MCP server-definition cache so the next MCP config read observes disk.
1090    ///
1091    /// Wire method: `mcp.config.reload`.
1092    ///
1093    /// <div class="warning">
1094    ///
1095    /// **Experimental.** This API is part of an experimental wire-protocol surface
1096    /// and may change or be removed in future SDK or CLI releases. Pin both the
1097    /// SDK and CLI versions if your code depends on it.
1098    ///
1099    /// </div>
1100    pub async fn reload(&self) -> Result<(), Error> {
1101        let wire_params = serde_json::json!({});
1102        let _value = self
1103            .client
1104            .call(rpc_methods::MCP_CONFIG_RELOAD, Some(wire_params))
1105            .await?;
1106        Ok(())
1107    }
1108}
1109
1110/// `models.*` RPCs.
1111#[derive(Clone, Copy)]
1112pub struct ClientRpcModels<'a> {
1113    pub(crate) client: &'a Client,
1114}
1115
1116impl<'a> ClientRpcModels<'a> {
1117    /// Lists Copilot models available to the authenticated user.
1118    ///
1119    /// Wire method: `models.list`.
1120    ///
1121    /// # Returns
1122    ///
1123    /// List of Copilot models available to the resolved user, including capabilities and billing metadata.
1124    ///
1125    /// <div class="warning">
1126    ///
1127    /// **Experimental.** This API is part of an experimental wire-protocol surface
1128    /// and may change or be removed in future SDK or CLI releases. Pin both the
1129    /// SDK and CLI versions if your code depends on it.
1130    ///
1131    /// </div>
1132    pub async fn list(&self) -> Result<ModelList, Error> {
1133        let wire_params = serde_json::json!({});
1134        let _value = self
1135            .client
1136            .call(rpc_methods::MODELS_LIST, Some(wire_params))
1137            .await?;
1138        Ok(serde_json::from_value(_value)?)
1139    }
1140
1141    /// Lists Copilot models available to the authenticated user.
1142    ///
1143    /// Wire method: `models.list`.
1144    ///
1145    /// # Parameters
1146    ///
1147    /// * `params` - Optional opaque account selection or compatibility GitHub token used to list models.
1148    ///
1149    /// # Returns
1150    ///
1151    /// List of Copilot models available to the resolved user, including capabilities and billing metadata.
1152    ///
1153    /// <div class="warning">
1154    ///
1155    /// **Experimental.** This API is part of an experimental wire-protocol surface
1156    /// and may change or be removed in future SDK or CLI releases. Pin both the
1157    /// SDK and CLI versions if your code depends on it.
1158    ///
1159    /// </div>
1160    pub async fn list_with_params(&self, params: ModelsListRequest) -> Result<ModelList, Error> {
1161        let wire_params = serde_json::to_value(params)?;
1162        let _value = self
1163            .client
1164            .call(rpc_methods::MODELS_LIST, Some(wire_params))
1165            .await?;
1166        Ok(serde_json::from_value(_value)?)
1167    }
1168
1169    /// Returns the running runtime's complete catalog of well-known built-in model IDs without authentication or network access.
1170    ///
1171    /// Wire method: `models.getBuiltInCatalog`.
1172    ///
1173    /// # Returns
1174    ///
1175    /// The running runtime's complete catalog of well-known built-in model IDs, including supported models and additional IDs with built-in metadata.
1176    ///
1177    /// <div class="warning">
1178    ///
1179    /// **Experimental.** This API is part of an experimental wire-protocol surface
1180    /// and may change or be removed in future SDK or CLI releases. Pin both the
1181    /// SDK and CLI versions if your code depends on it.
1182    ///
1183    /// </div>
1184    pub async fn get_built_in_catalog(&self) -> Result<BuiltInModelCatalog, Error> {
1185        let wire_params = serde_json::json!({});
1186        let _value = self
1187            .client
1188            .call(rpc_methods::MODELS_GETBUILTINCATALOG, Some(wire_params))
1189            .await?;
1190        Ok(serde_json::from_value(_value)?)
1191    }
1192}
1193
1194/// `plugins.*` RPCs.
1195#[derive(Clone, Copy)]
1196pub struct ClientRpcPlugins<'a> {
1197    pub(crate) client: &'a Client,
1198}
1199
1200impl<'a> ClientRpcPlugins<'a> {
1201    /// `plugins.builtin.*` sub-namespace.
1202    pub fn builtin(&self) -> ClientRpcPluginsBuiltin<'a> {
1203        ClientRpcPluginsBuiltin {
1204            client: self.client,
1205        }
1206    }
1207
1208    /// `plugins.marketplaces.*` sub-namespace.
1209    pub fn marketplaces(&self) -> ClientRpcPluginsMarketplaces<'a> {
1210        ClientRpcPluginsMarketplaces {
1211            client: self.client,
1212        }
1213    }
1214
1215    /// Lists plugins installed in user/global state.
1216    ///
1217    /// Wire method: `plugins.list`.
1218    ///
1219    /// # Returns
1220    ///
1221    /// Plugins installed in user/global state.
1222    ///
1223    /// <div class="warning">
1224    ///
1225    /// **Experimental.** This API is part of an experimental wire-protocol surface
1226    /// and may change or be removed in future SDK or CLI releases. Pin both the
1227    /// SDK and CLI versions if your code depends on it.
1228    ///
1229    /// </div>
1230    pub async fn list(&self) -> Result<PluginListResult, Error> {
1231        let wire_params = serde_json::json!({});
1232        let _value = self
1233            .client
1234            .call(rpc_methods::PLUGINS_LIST, Some(wire_params))
1235            .await?;
1236        Ok(serde_json::from_value(_value)?)
1237    }
1238
1239    /// Installs a plugin from a marketplace, GitHub repo, URL, or local path.
1240    ///
1241    /// Wire method: `plugins.install`.
1242    ///
1243    /// # Parameters
1244    ///
1245    /// * `params` - Plugin source and optional working directory for relative-path resolution.
1246    ///
1247    /// # Returns
1248    ///
1249    /// Result of installing a plugin.
1250    ///
1251    /// <div class="warning">
1252    ///
1253    /// **Experimental.** This API is part of an experimental wire-protocol surface
1254    /// and may change or be removed in future SDK or CLI releases. Pin both the
1255    /// SDK and CLI versions if your code depends on it.
1256    ///
1257    /// </div>
1258    pub async fn install(
1259        &self,
1260        params: PluginsInstallRequest,
1261    ) -> Result<PluginInstallResult, Error> {
1262        let wire_params = serde_json::to_value(params)?;
1263        let _value = self
1264            .client
1265            .call(rpc_methods::PLUGINS_INSTALL, Some(wire_params))
1266            .await?;
1267        Ok(serde_json::from_value(_value)?)
1268    }
1269
1270    /// Uninstalls an installed plugin.
1271    ///
1272    /// Wire method: `plugins.uninstall`.
1273    ///
1274    /// # Parameters
1275    ///
1276    /// * `params` - Name (or spec) of the plugin to uninstall.
1277    ///
1278    /// <div class="warning">
1279    ///
1280    /// **Experimental.** This API is part of an experimental wire-protocol surface
1281    /// and may change or be removed in future SDK or CLI releases. Pin both the
1282    /// SDK and CLI versions if your code depends on it.
1283    ///
1284    /// </div>
1285    pub async fn uninstall(&self, params: PluginsUninstallRequest) -> Result<(), Error> {
1286        let wire_params = serde_json::to_value(params)?;
1287        let _value = self
1288            .client
1289            .call(rpc_methods::PLUGINS_UNINSTALL, Some(wire_params))
1290            .await?;
1291        Ok(())
1292    }
1293
1294    /// Updates an installed plugin to its latest published version.
1295    ///
1296    /// Wire method: `plugins.update`.
1297    ///
1298    /// # Parameters
1299    ///
1300    /// * `params` - Name (or spec) of the plugin to update.
1301    ///
1302    /// # Returns
1303    ///
1304    /// Result of updating a single plugin.
1305    ///
1306    /// <div class="warning">
1307    ///
1308    /// **Experimental.** This API is part of an experimental wire-protocol surface
1309    /// and may change or be removed in future SDK or CLI releases. Pin both the
1310    /// SDK and CLI versions if your code depends on it.
1311    ///
1312    /// </div>
1313    pub async fn update(&self, params: PluginsUpdateRequest) -> Result<PluginUpdateResult, Error> {
1314        let wire_params = serde_json::to_value(params)?;
1315        let _value = self
1316            .client
1317            .call(rpc_methods::PLUGINS_UPDATE, Some(wire_params))
1318            .await?;
1319        Ok(serde_json::from_value(_value)?)
1320    }
1321
1322    /// Updates every installed plugin to its latest published version.
1323    ///
1324    /// Wire method: `plugins.updateAll`.
1325    ///
1326    /// # Returns
1327    ///
1328    /// Result of updating all installed plugins.
1329    ///
1330    /// <div class="warning">
1331    ///
1332    /// **Experimental.** This API is part of an experimental wire-protocol surface
1333    /// and may change or be removed in future SDK or CLI releases. Pin both the
1334    /// SDK and CLI versions if your code depends on it.
1335    ///
1336    /// </div>
1337    pub async fn update_all(&self) -> Result<PluginUpdateAllResult, Error> {
1338        let wire_params = serde_json::json!({});
1339        let _value = self
1340            .client
1341            .call(rpc_methods::PLUGINS_UPDATEALL, Some(wire_params))
1342            .await?;
1343        Ok(serde_json::from_value(_value)?)
1344    }
1345
1346    /// Enables installed plugins for new sessions.
1347    ///
1348    /// Wire method: `plugins.enable`.
1349    ///
1350    /// # Parameters
1351    ///
1352    /// * `params` - Plugin names (or specs) to enable.
1353    ///
1354    /// <div class="warning">
1355    ///
1356    /// **Experimental.** This API is part of an experimental wire-protocol surface
1357    /// and may change or be removed in future SDK or CLI releases. Pin both the
1358    /// SDK and CLI versions if your code depends on it.
1359    ///
1360    /// </div>
1361    pub async fn enable(&self, params: PluginsEnableRequest) -> Result<(), Error> {
1362        let wire_params = serde_json::to_value(params)?;
1363        let _value = self
1364            .client
1365            .call(rpc_methods::PLUGINS_ENABLE, Some(wire_params))
1366            .await?;
1367        Ok(())
1368    }
1369
1370    /// Disables installed plugins for new sessions.
1371    ///
1372    /// Wire method: `plugins.disable`.
1373    ///
1374    /// # Parameters
1375    ///
1376    /// * `params` - Plugin names (or specs) to disable.
1377    ///
1378    /// <div class="warning">
1379    ///
1380    /// **Experimental.** This API is part of an experimental wire-protocol surface
1381    /// and may change or be removed in future SDK or CLI releases. Pin both the
1382    /// SDK and CLI versions if your code depends on it.
1383    ///
1384    /// </div>
1385    pub async fn disable(&self, params: PluginsDisableRequest) -> Result<(), Error> {
1386        let wire_params = serde_json::to_value(params)?;
1387        let _value = self
1388            .client
1389            .call(rpc_methods::PLUGINS_DISABLE, Some(wire_params))
1390            .await?;
1391        Ok(())
1392    }
1393}
1394
1395/// `plugins.builtin.*` RPCs.
1396#[derive(Clone, Copy)]
1397pub struct ClientRpcPluginsBuiltin<'a> {
1398    pub(crate) client: &'a Client,
1399}
1400
1401impl<'a> ClientRpcPluginsBuiltin<'a> {
1402    /// Replaces this server's trusted built-in plugin directories while no sessions are active.
1403    ///
1404    /// Wire method: `plugins.builtin.set`.
1405    ///
1406    /// # Parameters
1407    ///
1408    /// * `params` - Trusted built-in plugin directories to use for this runtime process.
1409    ///
1410    /// <div class="warning">
1411    ///
1412    /// **Experimental.** This API is part of an experimental wire-protocol surface
1413    /// and may change or be removed in future SDK or CLI releases. Pin both the
1414    /// SDK and CLI versions if your code depends on it.
1415    ///
1416    /// </div>
1417    pub async fn set(&self, params: PluginsBuiltinSetRequest) -> Result<(), Error> {
1418        let wire_params = serde_json::to_value(params)?;
1419        let _value = self
1420            .client
1421            .call(rpc_methods::PLUGINS_BUILTIN_SET, Some(wire_params))
1422            .await?;
1423        Ok(())
1424    }
1425}
1426
1427/// `plugins.marketplaces.*` RPCs.
1428#[derive(Clone, Copy)]
1429pub struct ClientRpcPluginsMarketplaces<'a> {
1430    pub(crate) client: &'a Client,
1431}
1432
1433impl<'a> ClientRpcPluginsMarketplaces<'a> {
1434    /// Lists all registered marketplaces (defaults + user-added).
1435    ///
1436    /// Wire method: `plugins.marketplaces.list`.
1437    ///
1438    /// # Returns
1439    ///
1440    /// All registered marketplaces, including built-in defaults.
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 list(&self) -> Result<MarketplaceListResult, Error> {
1450        let wire_params = serde_json::json!({});
1451        let _value = self
1452            .client
1453            .call(rpc_methods::PLUGINS_MARKETPLACES_LIST, Some(wire_params))
1454            .await?;
1455        Ok(serde_json::from_value(_value)?)
1456    }
1457
1458    /// Registers a new marketplace from a source (owner/repo, URL, or local path).
1459    ///
1460    /// Wire method: `plugins.marketplaces.add`.
1461    ///
1462    /// # Parameters
1463    ///
1464    /// * `params` - Marketplace source and optional working directory for relative-path resolution.
1465    ///
1466    /// # Returns
1467    ///
1468    /// Result of registering a new marketplace.
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 add(
1478        &self,
1479        params: PluginsMarketplacesAddRequest,
1480    ) -> Result<MarketplaceAddResult, Error> {
1481        let wire_params = serde_json::to_value(params)?;
1482        let _value = self
1483            .client
1484            .call(rpc_methods::PLUGINS_MARKETPLACES_ADD, Some(wire_params))
1485            .await?;
1486        Ok(serde_json::from_value(_value)?)
1487    }
1488
1489    /// 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`.
1490    ///
1491    /// Wire method: `plugins.marketplaces.remove`.
1492    ///
1493    /// # Parameters
1494    ///
1495    /// * `params` - Name of the marketplace to remove and an optional force flag.
1496    ///
1497    /// # Returns
1498    ///
1499    /// Outcome of the remove attempt, including dependent-plugin info when applicable.
1500    ///
1501    /// <div class="warning">
1502    ///
1503    /// **Experimental.** This API is part of an experimental wire-protocol surface
1504    /// and may change or be removed in future SDK or CLI releases. Pin both the
1505    /// SDK and CLI versions if your code depends on it.
1506    ///
1507    /// </div>
1508    pub async fn remove(
1509        &self,
1510        params: PluginsMarketplacesRemoveRequest,
1511    ) -> Result<MarketplaceRemoveResult, Error> {
1512        let wire_params = serde_json::to_value(params)?;
1513        let _value = self
1514            .client
1515            .call(rpc_methods::PLUGINS_MARKETPLACES_REMOVE, Some(wire_params))
1516            .await?;
1517        Ok(serde_json::from_value(_value)?)
1518    }
1519
1520    /// Lists plugins advertised by a registered marketplace.
1521    ///
1522    /// Wire method: `plugins.marketplaces.browse`.
1523    ///
1524    /// # Parameters
1525    ///
1526    /// * `params` - Name of the marketplace whose plugin catalog to fetch.
1527    ///
1528    /// # Returns
1529    ///
1530    /// Plugins advertised by the marketplace.
1531    ///
1532    /// <div class="warning">
1533    ///
1534    /// **Experimental.** This API is part of an experimental wire-protocol surface
1535    /// and may change or be removed in future SDK or CLI releases. Pin both the
1536    /// SDK and CLI versions if your code depends on it.
1537    ///
1538    /// </div>
1539    pub async fn browse(
1540        &self,
1541        params: PluginsMarketplacesBrowseRequest,
1542    ) -> Result<MarketplaceBrowseResult, Error> {
1543        let wire_params = serde_json::to_value(params)?;
1544        let _value = self
1545            .client
1546            .call(rpc_methods::PLUGINS_MARKETPLACES_BROWSE, Some(wire_params))
1547            .await?;
1548        Ok(serde_json::from_value(_value)?)
1549    }
1550
1551    /// Re-fetches one or all registered marketplace catalogs.
1552    ///
1553    /// Wire method: `plugins.marketplaces.refresh`.
1554    ///
1555    /// # Returns
1556    ///
1557    /// Result of refreshing one or more marketplace catalogs.
1558    ///
1559    /// <div class="warning">
1560    ///
1561    /// **Experimental.** This API is part of an experimental wire-protocol surface
1562    /// and may change or be removed in future SDK or CLI releases. Pin both the
1563    /// SDK and CLI versions if your code depends on it.
1564    ///
1565    /// </div>
1566    pub async fn refresh(&self) -> Result<MarketplaceRefreshResult, Error> {
1567        let wire_params = serde_json::json!({});
1568        let _value = self
1569            .client
1570            .call(rpc_methods::PLUGINS_MARKETPLACES_REFRESH, Some(wire_params))
1571            .await?;
1572        Ok(serde_json::from_value(_value)?)
1573    }
1574
1575    /// Re-fetches one or all registered marketplace catalogs.
1576    ///
1577    /// Wire method: `plugins.marketplaces.refresh`.
1578    ///
1579    /// # Parameters
1580    ///
1581    /// * `params` - Optional marketplace name; omit to refresh all.
1582    ///
1583    /// # Returns
1584    ///
1585    /// Result of refreshing one or more marketplace catalogs.
1586    ///
1587    /// <div class="warning">
1588    ///
1589    /// **Experimental.** This API is part of an experimental wire-protocol surface
1590    /// and may change or be removed in future SDK or CLI releases. Pin both the
1591    /// SDK and CLI versions if your code depends on it.
1592    ///
1593    /// </div>
1594    pub async fn refresh_with_params(
1595        &self,
1596        params: PluginsMarketplacesRefreshRequest,
1597    ) -> Result<MarketplaceRefreshResult, Error> {
1598        let wire_params = serde_json::to_value(params)?;
1599        let _value = self
1600            .client
1601            .call(rpc_methods::PLUGINS_MARKETPLACES_REFRESH, Some(wire_params))
1602            .await?;
1603        Ok(serde_json::from_value(_value)?)
1604    }
1605}
1606
1607/// `runtime.*` RPCs.
1608#[derive(Clone, Copy)]
1609pub struct ClientRpcRuntime<'a> {
1610    pub(crate) client: &'a Client,
1611}
1612
1613impl<'a> ClientRpcRuntime<'a> {
1614    /// Gracefully shuts down an SDK-owned runtime. The response is sent only after cleanup completes; callers may then terminate the owned runtime process.
1615    ///
1616    /// Wire method: `runtime.shutdown`.
1617    ///
1618    /// <div class="warning">
1619    ///
1620    /// **Experimental.** This API is part of an experimental wire-protocol surface
1621    /// and may change or be removed in future SDK or CLI releases. Pin both the
1622    /// SDK and CLI versions if your code depends on it.
1623    ///
1624    /// </div>
1625    pub async fn shutdown(&self) -> Result<(), Error> {
1626        let wire_params = serde_json::json!({});
1627        let _value = self
1628            .client
1629            .call(rpc_methods::RUNTIME_SHUTDOWN, Some(wire_params))
1630            .await?;
1631        Ok(())
1632    }
1633}
1634
1635/// `secrets.*` RPCs.
1636#[derive(Clone, Copy)]
1637pub struct ClientRpcSecrets<'a> {
1638    pub(crate) client: &'a Client,
1639}
1640
1641impl<'a> ClientRpcSecrets<'a> {
1642    /// Registers secret values for redaction in session logs and exports. The SDK calls this to inject dynamically generated secret values (e.g., OIDC tokens).
1643    ///
1644    /// Wire method: `secrets.addFilterValues`.
1645    ///
1646    /// # Parameters
1647    ///
1648    /// * `params` - Secret values to add to the redaction filter.
1649    ///
1650    /// # Returns
1651    ///
1652    /// Confirmation that the secret values were registered.
1653    ///
1654    /// <div class="warning">
1655    ///
1656    /// **Experimental.** This API is part of an experimental wire-protocol surface
1657    /// and may change or be removed in future SDK or CLI releases. Pin both the
1658    /// SDK and CLI versions if your code depends on it.
1659    ///
1660    /// </div>
1661    pub async fn add_filter_values(
1662        &self,
1663        params: SecretsAddFilterValuesRequest,
1664    ) -> Result<SecretsAddFilterValuesResult, Error> {
1665        let wire_params = serde_json::to_value(params)?;
1666        let _value = self
1667            .client
1668            .call(rpc_methods::SECRETS_ADDFILTERVALUES, Some(wire_params))
1669            .await?;
1670        Ok(serde_json::from_value(_value)?)
1671    }
1672}
1673
1674/// `sessionFs.*` RPCs.
1675#[derive(Clone, Copy)]
1676pub struct ClientRpcSessionFs<'a> {
1677    pub(crate) client: &'a Client,
1678}
1679
1680impl<'a> ClientRpcSessionFs<'a> {
1681    /// Registers an SDK client as the session filesystem provider.
1682    ///
1683    /// Wire method: `sessionFs.setProvider`.
1684    ///
1685    /// # Parameters
1686    ///
1687    /// * `params` - Initial working directory, session-state path layout, and path conventions used to register the calling SDK client as the session filesystem provider.
1688    ///
1689    /// # Returns
1690    ///
1691    /// Indicates whether the calling client was registered as the session filesystem provider.
1692    ///
1693    /// <div class="warning">
1694    ///
1695    /// **Experimental.** This API is part of an experimental wire-protocol surface
1696    /// and may change or be removed in future SDK or CLI releases. Pin both the
1697    /// SDK and CLI versions if your code depends on it.
1698    ///
1699    /// </div>
1700    pub async fn set_provider(
1701        &self,
1702        params: SessionFsSetProviderRequest,
1703    ) -> Result<SessionFsSetProviderResult, Error> {
1704        let wire_params = serde_json::to_value(params)?;
1705        let _value = self
1706            .client
1707            .call(rpc_methods::SESSIONFS_SETPROVIDER, Some(wire_params))
1708            .await?;
1709        Ok(serde_json::from_value(_value)?)
1710    }
1711}
1712
1713/// `sessions.*` RPCs.
1714#[derive(Clone, Copy)]
1715pub struct ClientRpcSessions<'a> {
1716    pub(crate) client: &'a Client,
1717}
1718
1719impl<'a> ClientRpcSessions<'a> {
1720    /// Creates or resumes a local session and returns the opened session ID.
1721    ///
1722    /// Wire method: `sessions.open`.
1723    ///
1724    /// # Returns
1725    ///
1726    /// Result of opening a session.
1727    ///
1728    /// <div class="warning">
1729    ///
1730    /// **Experimental.** This API is part of an experimental wire-protocol surface
1731    /// and may change or be removed in future SDK or CLI releases. Pin both the
1732    /// SDK and CLI versions if your code depends on it.
1733    ///
1734    /// </div>
1735    pub async fn open(&self) -> Result<SessionOpenResult, Error> {
1736        let wire_params = serde_json::json!({});
1737        let _value = self
1738            .client
1739            .call(rpc_methods::SESSIONS_OPEN, Some(wire_params))
1740            .await?;
1741        Ok(serde_json::from_value(_value)?)
1742    }
1743
1744    /// Creates a new session by forking persisted history from an existing session.
1745    ///
1746    /// Wire method: `sessions.fork`.
1747    ///
1748    /// # Parameters
1749    ///
1750    /// * `params` - Source session identifier to fork from, optional event-ID boundary, and optional friendly name for the new session.
1751    ///
1752    /// # Returns
1753    ///
1754    /// Identifier and optional friendly name assigned to the newly forked session.
1755    ///
1756    /// <div class="warning">
1757    ///
1758    /// **Experimental.** This API is part of an experimental wire-protocol surface
1759    /// and may change or be removed in future SDK or CLI releases. Pin both the
1760    /// SDK and CLI versions if your code depends on it.
1761    ///
1762    /// </div>
1763    pub async fn fork(&self, params: SessionsForkRequest) -> Result<SessionsForkResult, Error> {
1764        let wire_params = serde_json::to_value(params)?;
1765        let _value = self
1766            .client
1767            .call(rpc_methods::SESSIONS_FORK, Some(wire_params))
1768            .await?;
1769        Ok(serde_json::from_value(_value)?)
1770    }
1771
1772    /// Connects to an existing remote session and exposes it as an SDK session.
1773    ///
1774    /// Wire method: `sessions.connect`.
1775    ///
1776    /// # Parameters
1777    ///
1778    /// * `params` - Remote session connection parameters.
1779    ///
1780    /// # Returns
1781    ///
1782    /// Remote session connection result.
1783    ///
1784    /// <div class="warning">
1785    ///
1786    /// **Experimental.** This API is part of an experimental wire-protocol surface
1787    /// and may change or be removed in future SDK or CLI releases. Pin both the
1788    /// SDK and CLI versions if your code depends on it.
1789    ///
1790    /// </div>
1791    pub async fn connect(
1792        &self,
1793        params: ConnectRemoteSessionParams,
1794    ) -> Result<RemoteSessionConnectionResult, Error> {
1795        let wire_params = serde_json::to_value(params)?;
1796        let _value = self
1797            .client
1798            .call(rpc_methods::SESSIONS_CONNECT, Some(wire_params))
1799            .await?;
1800        Ok(serde_json::from_value(_value)?)
1801    }
1802
1803    /// 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.).
1804    ///
1805    /// Wire method: `sessions.list`.
1806    ///
1807    /// # Returns
1808    ///
1809    /// Sessions matching the filter, ordered most-recently-modified first.
1810    ///
1811    /// <div class="warning">
1812    ///
1813    /// **Experimental.** This API is part of an experimental wire-protocol surface
1814    /// and may change or be removed in future SDK or CLI releases. Pin both the
1815    /// SDK and CLI versions if your code depends on it.
1816    ///
1817    /// </div>
1818    pub async fn list(&self) -> Result<SessionList, Error> {
1819        let wire_params = serde_json::json!({});
1820        let _value = self
1821            .client
1822            .call(rpc_methods::SESSIONS_LIST, Some(wire_params))
1823            .await?;
1824        Ok(serde_json::from_value(_value)?)
1825    }
1826
1827    /// 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.).
1828    ///
1829    /// Wire method: `sessions.list`.
1830    ///
1831    /// # Parameters
1832    ///
1833    /// * `params` - Optional source filter, metadata-load limit, and context filter applied to the returned sessions.
1834    ///
1835    /// # Returns
1836    ///
1837    /// Sessions matching the filter, ordered most-recently-modified first.
1838    ///
1839    /// <div class="warning">
1840    ///
1841    /// **Experimental.** This API is part of an experimental wire-protocol surface
1842    /// and may change or be removed in future SDK or CLI releases. Pin both the
1843    /// SDK and CLI versions if your code depends on it.
1844    ///
1845    /// </div>
1846    pub async fn list_with_params(
1847        &self,
1848        params: SessionsListRequest,
1849    ) -> Result<SessionList, Error> {
1850        let wire_params = serde_json::to_value(params)?;
1851        let _value = self
1852            .client
1853            .call(rpc_methods::SESSIONS_LIST, Some(wire_params))
1854            .await?;
1855        Ok(serde_json::from_value(_value)?)
1856    }
1857
1858    /// Reads lightweight persisted metadata for one local session without opening it.
1859    ///
1860    /// Wire method: `sessions.getMetadata`.
1861    ///
1862    /// # Parameters
1863    ///
1864    /// * `params` - Session ID whose persisted metadata should be read.
1865    ///
1866    /// # Returns
1867    ///
1868    /// Persisted local session metadata when the session exists.
1869    ///
1870    /// <div class="warning">
1871    ///
1872    /// **Experimental.** This API is part of an experimental wire-protocol surface
1873    /// and may change or be removed in future SDK or CLI releases. Pin both the
1874    /// SDK and CLI versions if your code depends on it.
1875    ///
1876    /// </div>
1877    pub(crate) async fn get_metadata(
1878        &self,
1879        params: SessionsGetMetadataRequest,
1880    ) -> Result<SessionsGetMetadataResult, Error> {
1881        let wire_params = serde_json::to_value(params)?;
1882        let _value = self
1883            .client
1884            .call(rpc_methods::SESSIONS_GETMETADATA, Some(wire_params))
1885            .await?;
1886        Ok(serde_json::from_value(_value)?)
1887    }
1888
1889    /// Lists recent local session IDs that contain user-visible history, omitting housekeeping-only sessions.
1890    ///
1891    /// Wire method: `sessions.listNonEmptySessionIds`.
1892    ///
1893    /// # Parameters
1894    ///
1895    /// * `params` - Limit for non-empty local session IDs.
1896    ///
1897    /// # Returns
1898    ///
1899    /// Recent local session IDs that contain user-visible history.
1900    ///
1901    /// <div class="warning">
1902    ///
1903    /// **Experimental.** This API is part of an experimental wire-protocol surface
1904    /// and may change or be removed in future SDK or CLI releases. Pin both the
1905    /// SDK and CLI versions if your code depends on it.
1906    ///
1907    /// </div>
1908    pub(crate) async fn list_non_empty_session_ids(
1909        &self,
1910        params: SessionsListNonEmptySessionIdsRequest,
1911    ) -> Result<SessionsListNonEmptySessionIdsResult, Error> {
1912        let wire_params = serde_json::to_value(params)?;
1913        let _value = self
1914            .client
1915            .call(
1916                rpc_methods::SESSIONS_LISTNONEMPTYSESSIONIDS,
1917                Some(wire_params),
1918            )
1919            .await?;
1920        Ok(serde_json::from_value(_value)?)
1921    }
1922
1923    /// Finds the local session bound to a GitHub task ID, if any.
1924    ///
1925    /// Wire method: `sessions.findByTaskId`.
1926    ///
1927    /// # Parameters
1928    ///
1929    /// * `params` - GitHub task ID to look up.
1930    ///
1931    /// # Returns
1932    ///
1933    /// ID of the local session bound to the given GitHub task, or omitted when none.
1934    ///
1935    /// <div class="warning">
1936    ///
1937    /// **Experimental.** This API is part of an experimental wire-protocol surface
1938    /// and may change or be removed in future SDK or CLI releases. Pin both the
1939    /// SDK and CLI versions if your code depends on it.
1940    ///
1941    /// </div>
1942    pub async fn find_by_task_id(
1943        &self,
1944        params: SessionsFindByTaskIDRequest,
1945    ) -> Result<SessionsFindByTaskIDResult, Error> {
1946        let wire_params = serde_json::to_value(params)?;
1947        let _value = self
1948            .client
1949            .call(rpc_methods::SESSIONS_FINDBYTASKID, Some(wire_params))
1950            .await?;
1951        Ok(serde_json::from_value(_value)?)
1952    }
1953
1954    /// Resolves a UUID prefix to a unique session ID, if exactly one session matches.
1955    ///
1956    /// Wire method: `sessions.findByPrefix`.
1957    ///
1958    /// # Parameters
1959    ///
1960    /// * `params` - UUID prefix to resolve to a unique session ID.
1961    ///
1962    /// # Returns
1963    ///
1964    /// Session ID matching the prefix, omitted when no unique match exists.
1965    ///
1966    /// <div class="warning">
1967    ///
1968    /// **Experimental.** This API is part of an experimental wire-protocol surface
1969    /// and may change or be removed in future SDK or CLI releases. Pin both the
1970    /// SDK and CLI versions if your code depends on it.
1971    ///
1972    /// </div>
1973    pub async fn find_by_prefix(
1974        &self,
1975        params: SessionsFindByPrefixRequest,
1976    ) -> Result<SessionsFindByPrefixResult, Error> {
1977        let wire_params = serde_json::to_value(params)?;
1978        let _value = self
1979            .client
1980            .call(rpc_methods::SESSIONS_FINDBYPREFIX, Some(wire_params))
1981            .await?;
1982        Ok(serde_json::from_value(_value)?)
1983    }
1984
1985    /// Returns the most-relevant prior session for a given working-directory context.
1986    ///
1987    /// Wire method: `sessions.getLastForContext`.
1988    ///
1989    /// # Parameters
1990    ///
1991    /// * `params` - Optional working-directory context used to score session relevance.
1992    ///
1993    /// # Returns
1994    ///
1995    /// Most-relevant session ID for the supplied context, or omitted when no sessions exist.
1996    ///
1997    /// <div class="warning">
1998    ///
1999    /// **Experimental.** This API is part of an experimental wire-protocol surface
2000    /// and may change or be removed in future SDK or CLI releases. Pin both the
2001    /// SDK and CLI versions if your code depends on it.
2002    ///
2003    /// </div>
2004    pub async fn get_last_for_context(
2005        &self,
2006        params: SessionsGetLastForContextRequest,
2007    ) -> Result<SessionsGetLastForContextResult, Error> {
2008        let wire_params = serde_json::to_value(params)?;
2009        let _value = self
2010            .client
2011            .call(rpc_methods::SESSIONS_GETLASTFORCONTEXT, Some(wire_params))
2012            .await?;
2013        Ok(serde_json::from_value(_value)?)
2014    }
2015
2016    /// 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.
2017    ///
2018    /// Wire method: `sessions.getEventFilePath`.
2019    ///
2020    /// # Parameters
2021    ///
2022    /// * `params` - Session ID whose event-log file path to compute.
2023    ///
2024    /// # Returns
2025    ///
2026    /// Absolute path to the session's events.jsonl file on disk.
2027    ///
2028    /// <div class="warning">
2029    ///
2030    /// **Experimental.** This API is part of an experimental wire-protocol surface
2031    /// and may change or be removed in future SDK or CLI releases. Pin both the
2032    /// SDK and CLI versions if your code depends on it.
2033    ///
2034    /// </div>
2035    pub(crate) async fn get_event_file_path(
2036        &self,
2037        params: SessionsGetEventFilePathRequest,
2038    ) -> Result<SessionsGetEventFilePathResult, Error> {
2039        let wire_params = serde_json::to_value(params)?;
2040        let _value = self
2041            .client
2042            .call(rpc_methods::SESSIONS_GETEVENTFILEPATH, Some(wire_params))
2043            .await?;
2044        Ok(serde_json::from_value(_value)?)
2045    }
2046
2047    /// Returns the on-disk byte size of each session's workspace directory.
2048    ///
2049    /// Wire method: `sessions.getSizes`.
2050    ///
2051    /// # Returns
2052    ///
2053    /// Map of sessionId -> on-disk size in bytes for each session's workspace directory.
2054    ///
2055    /// <div class="warning">
2056    ///
2057    /// **Experimental.** This API is part of an experimental wire-protocol surface
2058    /// and may change or be removed in future SDK or CLI releases. Pin both the
2059    /// SDK and CLI versions if your code depends on it.
2060    ///
2061    /// </div>
2062    pub async fn get_sizes(&self) -> Result<SessionSizes, Error> {
2063        let wire_params = serde_json::json!({});
2064        let _value = self
2065            .client
2066            .call(rpc_methods::SESSIONS_GETSIZES, Some(wire_params))
2067            .await?;
2068        Ok(serde_json::from_value(_value)?)
2069    }
2070
2071    /// Returns the subset of the supplied session IDs that are currently held by another running process.
2072    ///
2073    /// Wire method: `sessions.checkInUse`.
2074    ///
2075    /// # Parameters
2076    ///
2077    /// * `params` - Session IDs to test for live in-use locks.
2078    ///
2079    /// # Returns
2080    ///
2081    /// Session IDs from the input set that are currently in use by another process.
2082    ///
2083    /// <div class="warning">
2084    ///
2085    /// **Experimental.** This API is part of an experimental wire-protocol surface
2086    /// and may change or be removed in future SDK or CLI releases. Pin both the
2087    /// SDK and CLI versions if your code depends on it.
2088    ///
2089    /// </div>
2090    pub async fn check_in_use(
2091        &self,
2092        params: SessionsCheckInUseRequest,
2093    ) -> Result<SessionsCheckInUseResult, Error> {
2094        let wire_params = serde_json::to_value(params)?;
2095        let _value = self
2096            .client
2097            .call(rpc_methods::SESSIONS_CHECKINUSE, Some(wire_params))
2098            .await?;
2099        Ok(serde_json::from_value(_value)?)
2100    }
2101
2102    /// 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.
2103    ///
2104    /// Wire method: `sessions.getPersistedRemoteSteerable`.
2105    ///
2106    /// # Parameters
2107    ///
2108    /// * `params` - Session ID to look up the persisted remote-steerable flag for.
2109    ///
2110    /// # Returns
2111    ///
2112    /// The session's persisted remote-steerable flag, or omitted when no value has been persisted.
2113    ///
2114    /// <div class="warning">
2115    ///
2116    /// **Experimental.** This API is part of an experimental wire-protocol surface
2117    /// and may change or be removed in future SDK or CLI releases. Pin both the
2118    /// SDK and CLI versions if your code depends on it.
2119    ///
2120    /// </div>
2121    pub(crate) async fn get_persisted_remote_steerable(
2122        &self,
2123        params: SessionsGetPersistedRemoteSteerableRequest,
2124    ) -> Result<SessionsGetPersistedRemoteSteerableResult, Error> {
2125        let wire_params = serde_json::to_value(params)?;
2126        let _value = self
2127            .client
2128            .call(
2129                rpc_methods::SESSIONS_GETPERSISTEDREMOTESTEERABLE,
2130                Some(wire_params),
2131            )
2132            .await?;
2133        Ok(serde_json::from_value(_value)?)
2134    }
2135
2136    /// Closes a session: emits shutdown, flushes pending events, releases the in-use lock, and disposes the active session.
2137    ///
2138    /// Wire method: `sessions.close`.
2139    ///
2140    /// # Parameters
2141    ///
2142    /// * `params` - Session ID to close.
2143    ///
2144    /// # Returns
2145    ///
2146    /// 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.
2147    ///
2148    /// <div class="warning">
2149    ///
2150    /// **Experimental.** This API is part of an experimental wire-protocol surface
2151    /// and may change or be removed in future SDK or CLI releases. Pin both the
2152    /// SDK and CLI versions if your code depends on it.
2153    ///
2154    /// </div>
2155    pub async fn close(&self, params: SessionsCloseRequest) -> Result<SessionsCloseResult, Error> {
2156        let wire_params = serde_json::to_value(params)?;
2157        let _value = self
2158            .client
2159            .call(rpc_methods::SESSIONS_CLOSE, Some(wire_params))
2160            .await?;
2161        Ok(serde_json::from_value(_value)?)
2162    }
2163
2164    /// Closes, deactivates, and deletes a set of sessions, returning the bytes freed per session.
2165    ///
2166    /// Wire method: `sessions.bulkDelete`.
2167    ///
2168    /// # Parameters
2169    ///
2170    /// * `params` - Session IDs to close, deactivate, and delete from disk.
2171    ///
2172    /// # Returns
2173    ///
2174    /// Map of sessionId -> bytes freed by removing the session's workspace directory.
2175    ///
2176    /// <div class="warning">
2177    ///
2178    /// **Experimental.** This API is part of an experimental wire-protocol surface
2179    /// and may change or be removed in future SDK or CLI releases. Pin both the
2180    /// SDK and CLI versions if your code depends on it.
2181    ///
2182    /// </div>
2183    pub async fn bulk_delete(
2184        &self,
2185        params: SessionsBulkDeleteRequest,
2186    ) -> Result<SessionBulkDeleteResult, Error> {
2187        let wire_params = serde_json::to_value(params)?;
2188        let _value = self
2189            .client
2190            .call(rpc_methods::SESSIONS_BULKDELETE, Some(wire_params))
2191            .await?;
2192        Ok(serde_json::from_value(_value)?)
2193    }
2194
2195    /// Deletes one local session from disk after running the same lifecycle hooks as the session manager.
2196    ///
2197    /// Wire method: `sessions.delete`.
2198    ///
2199    /// # Parameters
2200    ///
2201    /// * `params` - Session ID to delete from disk.
2202    ///
2203    /// <div class="warning">
2204    ///
2205    /// **Experimental.** This API is part of an experimental wire-protocol surface
2206    /// and may change or be removed in future SDK or CLI releases. Pin both the
2207    /// SDK and CLI versions if your code depends on it.
2208    ///
2209    /// </div>
2210    pub(crate) async fn delete(&self, params: SessionsDeleteRequest) -> Result<(), Error> {
2211        let wire_params = serde_json::to_value(params)?;
2212        let _value = self
2213            .client
2214            .call(rpc_methods::SESSIONS_DELETE, Some(wire_params))
2215            .await?;
2216        Ok(())
2217    }
2218
2219    /// Deletes sessions older than the given threshold, with optional dry-run and exclusion list.
2220    ///
2221    /// Wire method: `sessions.pruneOld`.
2222    ///
2223    /// # Parameters
2224    ///
2225    /// * `params` - Age threshold and optional flags controlling which old sessions are pruned (or simulated when dryRun is true).
2226    ///
2227    /// # Returns
2228    ///
2229    /// Outcome of the prune operation: deleted IDs, dry-run candidates, skipped IDs, total bytes freed, and the dry-run flag.
2230    ///
2231    /// <div class="warning">
2232    ///
2233    /// **Experimental.** This API is part of an experimental wire-protocol surface
2234    /// and may change or be removed in future SDK or CLI releases. Pin both the
2235    /// SDK and CLI versions if your code depends on it.
2236    ///
2237    /// </div>
2238    pub async fn prune_old(
2239        &self,
2240        params: SessionsPruneOldRequest,
2241    ) -> Result<SessionPruneResult, Error> {
2242        let wire_params = serde_json::to_value(params)?;
2243        let _value = self
2244            .client
2245            .call(rpc_methods::SESSIONS_PRUNEOLD, Some(wire_params))
2246            .await?;
2247        Ok(serde_json::from_value(_value)?)
2248    }
2249
2250    /// Flushes a session's pending events to disk.
2251    ///
2252    /// Wire method: `sessions.save`.
2253    ///
2254    /// # Parameters
2255    ///
2256    /// * `params` - Session ID whose pending events should be flushed to disk.
2257    ///
2258    /// # Returns
2259    ///
2260    /// Flush a session's pending events to disk. No-op when no writer exists for the session (e.g., already closed).
2261    ///
2262    /// <div class="warning">
2263    ///
2264    /// **Experimental.** This API is part of an experimental wire-protocol surface
2265    /// and may change or be removed in future SDK or CLI releases. Pin both the
2266    /// SDK and CLI versions if your code depends on it.
2267    ///
2268    /// </div>
2269    pub async fn save(&self, params: SessionsSaveRequest) -> Result<SessionsSaveResult, Error> {
2270        let wire_params = serde_json::to_value(params)?;
2271        let _value = self
2272            .client
2273            .call(rpc_methods::SESSIONS_SAVE, Some(wire_params))
2274            .await?;
2275        Ok(serde_json::from_value(_value)?)
2276    }
2277
2278    /// Releases the in-use lock held by this process for a session.
2279    ///
2280    /// Wire method: `sessions.releaseLock`.
2281    ///
2282    /// # Parameters
2283    ///
2284    /// * `params` - Session ID whose in-use lock should be released.
2285    ///
2286    /// # Returns
2287    ///
2288    /// 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.
2289    ///
2290    /// <div class="warning">
2291    ///
2292    /// **Experimental.** This API is part of an experimental wire-protocol surface
2293    /// and may change or be removed in future SDK or CLI releases. Pin both the
2294    /// SDK and CLI versions if your code depends on it.
2295    ///
2296    /// </div>
2297    pub async fn release_lock(
2298        &self,
2299        params: SessionsReleaseLockRequest,
2300    ) -> Result<SessionsReleaseLockResult, Error> {
2301        let wire_params = serde_json::to_value(params)?;
2302        let _value = self
2303            .client
2304            .call(rpc_methods::SESSIONS_RELEASELOCK, Some(wire_params))
2305            .await?;
2306        Ok(serde_json::from_value(_value)?)
2307    }
2308
2309    /// Backfills missing summary and context fields on the supplied session metadata records.
2310    ///
2311    /// Wire method: `sessions.enrichMetadata`.
2312    ///
2313    /// # Parameters
2314    ///
2315    /// * `params` - Session metadata records to enrich with summary and context information.
2316    ///
2317    /// # Returns
2318    ///
2319    /// The enriched metadata records, with summary and context fields backfilled where available. Sessions confirmed empty and unnamed are omitted.
2320    ///
2321    /// <div class="warning">
2322    ///
2323    /// **Experimental.** This API is part of an experimental wire-protocol surface
2324    /// and may change or be removed in future SDK or CLI releases. Pin both the
2325    /// SDK and CLI versions if your code depends on it.
2326    ///
2327    /// </div>
2328    pub async fn enrich_metadata(
2329        &self,
2330        params: SessionsEnrichMetadataRequest,
2331    ) -> Result<SessionEnrichMetadataResult, Error> {
2332        let wire_params = serde_json::to_value(params)?;
2333        let _value = self
2334            .client
2335            .call(rpc_methods::SESSIONS_ENRICHMETADATA, Some(wire_params))
2336            .await?;
2337        Ok(serde_json::from_value(_value)?)
2338    }
2339
2340    /// Reloads user, plugin, and (optionally) repo hooks on the active session.
2341    ///
2342    /// Wire method: `sessions.reloadPluginHooks`.
2343    ///
2344    /// # Parameters
2345    ///
2346    /// * `params` - Active session ID and an optional flag for deferring repo-level hooks until folder trust.
2347    ///
2348    /// # Returns
2349    ///
2350    /// 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.
2351    ///
2352    /// <div class="warning">
2353    ///
2354    /// **Experimental.** This API is part of an experimental wire-protocol surface
2355    /// and may change or be removed in future SDK or CLI releases. Pin both the
2356    /// SDK and CLI versions if your code depends on it.
2357    ///
2358    /// </div>
2359    pub async fn reload_plugin_hooks(
2360        &self,
2361        params: SessionsReloadPluginHooksRequest,
2362    ) -> Result<SessionsReloadPluginHooksResult, Error> {
2363        let wire_params = serde_json::to_value(params)?;
2364        let _value = self
2365            .client
2366            .call(rpc_methods::SESSIONS_RELOADPLUGINHOOKS, Some(wire_params))
2367            .await?;
2368        Ok(serde_json::from_value(_value)?)
2369    }
2370
2371    /// Loads previously-deferred repo-level hooks on the active session, returning queued startup prompts.
2372    ///
2373    /// Wire method: `sessions.loadDeferredRepoHooks`.
2374    ///
2375    /// # Parameters
2376    ///
2377    /// * `params` - Active session ID whose deferred repo-level hooks should be loaded.
2378    ///
2379    /// # Returns
2380    ///
2381    /// Queued repo-level startup prompts and the total hook command count after loading.
2382    ///
2383    /// <div class="warning">
2384    ///
2385    /// **Experimental.** This API is part of an experimental wire-protocol surface
2386    /// and may change or be removed in future SDK or CLI releases. Pin both the
2387    /// SDK and CLI versions if your code depends on it.
2388    ///
2389    /// </div>
2390    pub async fn load_deferred_repo_hooks(
2391        &self,
2392        params: SessionsLoadDeferredRepoHooksRequest,
2393    ) -> Result<SessionLoadDeferredRepoHooksResult, Error> {
2394        let wire_params = serde_json::to_value(params)?;
2395        let _value = self
2396            .client
2397            .call(
2398                rpc_methods::SESSIONS_LOADDEFERREDREPOHOOKS,
2399                Some(wire_params),
2400            )
2401            .await?;
2402        Ok(serde_json::from_value(_value)?)
2403    }
2404
2405    /// Replaces the manager-wide additional plugins registered with the session manager.
2406    ///
2407    /// Wire method: `sessions.setAdditionalPlugins`.
2408    ///
2409    /// # Parameters
2410    ///
2411    /// * `params` - Manager-wide additional plugins to register; replaces any previously-configured set.
2412    ///
2413    /// # Returns
2414    ///
2415    /// 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.
2416    ///
2417    /// <div class="warning">
2418    ///
2419    /// **Experimental.** This API is part of an experimental wire-protocol surface
2420    /// and may change or be removed in future SDK or CLI releases. Pin both the
2421    /// SDK and CLI versions if your code depends on it.
2422    ///
2423    /// </div>
2424    pub async fn set_additional_plugins(
2425        &self,
2426        params: SessionsSetAdditionalPluginsRequest,
2427    ) -> Result<SessionsSetAdditionalPluginsResult, Error> {
2428        let wire_params = serde_json::to_value(params)?;
2429        let _value = self
2430            .client
2431            .call(
2432                rpc_methods::SESSIONS_SETADDITIONALPLUGINS,
2433                Some(wire_params),
2434            )
2435            .await?;
2436        Ok(serde_json::from_value(_value)?)
2437    }
2438
2439    /// 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.
2440    ///
2441    /// Wire method: `sessions.getBoardEntryCount`.
2442    ///
2443    /// # Parameters
2444    ///
2445    /// * `params` - Session ID whose board entry count should be returned.
2446    ///
2447    /// # Returns
2448    ///
2449    /// Dynamic-context board entry count, when available.
2450    ///
2451    /// <div class="warning">
2452    ///
2453    /// **Experimental.** This API is part of an experimental wire-protocol surface
2454    /// and may change or be removed in future SDK or CLI releases. Pin both the
2455    /// SDK and CLI versions if your code depends on it.
2456    ///
2457    /// </div>
2458    pub(crate) async fn get_board_entry_count(
2459        &self,
2460        params: SessionsGetBoardEntryCountRequest,
2461    ) -> Result<SessionsGetBoardEntryCountResult, Error> {
2462        let wire_params = serde_json::to_value(params)?;
2463        let _value = self
2464            .client
2465            .call(rpc_methods::SESSIONS_GETBOARDENTRYCOUNT, Some(wire_params))
2466            .await?;
2467        Ok(serde_json::from_value(_value)?)
2468    }
2469
2470    /// 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.
2471    ///
2472    /// Wire method: `sessions.startRemoteControl`.
2473    ///
2474    /// # Parameters
2475    ///
2476    /// * `params` - Parameters for attaching the remote-control singleton to a session.
2477    ///
2478    /// # Returns
2479    ///
2480    /// Wrapper for the singleton's current status.
2481    ///
2482    /// <div class="warning">
2483    ///
2484    /// **Experimental.** This API is part of an experimental wire-protocol surface
2485    /// and may change or be removed in future SDK or CLI releases. Pin both the
2486    /// SDK and CLI versions if your code depends on it.
2487    ///
2488    /// </div>
2489    pub async fn start_remote_control(
2490        &self,
2491        params: SessionsStartRemoteControlRequest,
2492    ) -> Result<RemoteControlStatusResult, Error> {
2493        let wire_params = serde_json::to_value(params)?;
2494        let _value = self
2495            .client
2496            .call(rpc_methods::SESSIONS_STARTREMOTECONTROL, Some(wire_params))
2497            .await?;
2498        Ok(serde_json::from_value(_value)?)
2499    }
2500
2501    /// 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.
2502    ///
2503    /// Wire method: `sessions.transferRemoteControl`.
2504    ///
2505    /// # Parameters
2506    ///
2507    /// * `params` - Parameters for atomically rebinding the remote-control singleton.
2508    ///
2509    /// # Returns
2510    ///
2511    /// Outcome of a transferRemoteControl call.
2512    ///
2513    /// <div class="warning">
2514    ///
2515    /// **Experimental.** This API is part of an experimental wire-protocol surface
2516    /// and may change or be removed in future SDK or CLI releases. Pin both the
2517    /// SDK and CLI versions if your code depends on it.
2518    ///
2519    /// </div>
2520    pub async fn transfer_remote_control(
2521        &self,
2522        params: SessionsTransferRemoteControlRequest,
2523    ) -> Result<RemoteControlTransferResult, Error> {
2524        let wire_params = serde_json::to_value(params)?;
2525        let _value = self
2526            .client
2527            .call(
2528                rpc_methods::SESSIONS_TRANSFERREMOTECONTROL,
2529                Some(wire_params),
2530            )
2531            .await?;
2532        Ok(serde_json::from_value(_value)?)
2533    }
2534
2535    /// 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.
2536    ///
2537    /// Wire method: `sessions.setRemoteControlSteering`.
2538    ///
2539    /// # Parameters
2540    ///
2541    /// * `params` - Patch for the singleton's steering state.
2542    ///
2543    /// # Returns
2544    ///
2545    /// Wrapper for the singleton's current status.
2546    ///
2547    /// <div class="warning">
2548    ///
2549    /// **Experimental.** This API is part of an experimental wire-protocol surface
2550    /// and may change or be removed in future SDK or CLI releases. Pin both the
2551    /// SDK and CLI versions if your code depends on it.
2552    ///
2553    /// </div>
2554    pub async fn set_remote_control_steering(
2555        &self,
2556        params: SessionsSetRemoteControlSteeringRequest,
2557    ) -> Result<RemoteControlStatusResult, Error> {
2558        let wire_params = serde_json::to_value(params)?;
2559        let _value = self
2560            .client
2561            .call(
2562                rpc_methods::SESSIONS_SETREMOTECONTROLSTEERING,
2563                Some(wire_params),
2564            )
2565            .await?;
2566        Ok(serde_json::from_value(_value)?)
2567    }
2568
2569    /// 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).
2570    ///
2571    /// Wire method: `sessions.stopRemoteControl`.
2572    ///
2573    /// # Returns
2574    ///
2575    /// Outcome of a stopRemoteControl call.
2576    ///
2577    /// <div class="warning">
2578    ///
2579    /// **Experimental.** This API is part of an experimental wire-protocol surface
2580    /// and may change or be removed in future SDK or CLI releases. Pin both the
2581    /// SDK and CLI versions if your code depends on it.
2582    ///
2583    /// </div>
2584    pub async fn stop_remote_control(&self) -> Result<RemoteControlStopResult, Error> {
2585        let wire_params = serde_json::json!({});
2586        let _value = self
2587            .client
2588            .call(rpc_methods::SESSIONS_STOPREMOTECONTROL, Some(wire_params))
2589            .await?;
2590        Ok(serde_json::from_value(_value)?)
2591    }
2592
2593    /// 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).
2594    ///
2595    /// Wire method: `sessions.stopRemoteControl`.
2596    ///
2597    /// # Parameters
2598    ///
2599    /// * `params` - Parameters for stopping the remote-control singleton.
2600    ///
2601    /// # Returns
2602    ///
2603    /// Outcome of a stopRemoteControl call.
2604    ///
2605    /// <div class="warning">
2606    ///
2607    /// **Experimental.** This API is part of an experimental wire-protocol surface
2608    /// and may change or be removed in future SDK or CLI releases. Pin both the
2609    /// SDK and CLI versions if your code depends on it.
2610    ///
2611    /// </div>
2612    pub async fn stop_remote_control_with_params(
2613        &self,
2614        params: SessionsStopRemoteControlRequest,
2615    ) -> Result<RemoteControlStopResult, Error> {
2616        let wire_params = serde_json::to_value(params)?;
2617        let _value = self
2618            .client
2619            .call(rpc_methods::SESSIONS_STOPREMOTECONTROL, Some(wire_params))
2620            .await?;
2621        Ok(serde_json::from_value(_value)?)
2622    }
2623
2624    /// Returns the current state of the remote-control singleton, including the attached session id and frontend URL when active.
2625    ///
2626    /// Wire method: `sessions.getRemoteControlStatus`.
2627    ///
2628    /// # Returns
2629    ///
2630    /// Wrapper for the singleton's current status.
2631    ///
2632    /// <div class="warning">
2633    ///
2634    /// **Experimental.** This API is part of an experimental wire-protocol surface
2635    /// and may change or be removed in future SDK or CLI releases. Pin both the
2636    /// SDK and CLI versions if your code depends on it.
2637    ///
2638    /// </div>
2639    pub async fn get_remote_control_status(&self) -> Result<RemoteControlStatusResult, Error> {
2640        let wire_params = serde_json::json!({});
2641        let _value = self
2642            .client
2643            .call(
2644                rpc_methods::SESSIONS_GETREMOTECONTROLSTATUS,
2645                Some(wire_params),
2646            )
2647            .await?;
2648        Ok(serde_json::from_value(_value)?)
2649    }
2650
2651    /// 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.
2652    ///
2653    /// Wire method: `sessions.registerExtensionToolsOnSession`.
2654    ///
2655    /// # Parameters
2656    ///
2657    /// * `params` - Params to attach an extension loader's tools to a session.
2658    ///
2659    /// # Returns
2660    ///
2661    /// Handle for releasing the extension tool registration.
2662    ///
2663    /// <div class="warning">
2664    ///
2665    /// **Experimental.** This API is part of an experimental wire-protocol surface
2666    /// and may change or be removed in future SDK or CLI releases. Pin both the
2667    /// SDK and CLI versions if your code depends on it.
2668    ///
2669    /// </div>
2670    pub(crate) async fn register_extension_tools_on_session(
2671        &self,
2672        params: RegisterExtensionToolsParams,
2673    ) -> Result<RegisterExtensionToolsResult, Error> {
2674        let wire_params = serde_json::to_value(params)?;
2675        let _value = self
2676            .client
2677            .call(
2678                rpc_methods::SESSIONS_REGISTEREXTENSIONTOOLSONSESSION,
2679                Some(wire_params),
2680            )
2681            .await?;
2682        Ok(serde_json::from_value(_value)?)
2683    }
2684
2685    /// 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.
2686    ///
2687    /// Wire method: `sessions.configureSessionExtensions`.
2688    ///
2689    /// # Parameters
2690    ///
2691    /// * `params` - Params to attach or detach an in-process ExtensionController delegate.
2692    ///
2693    /// <div class="warning">
2694    ///
2695    /// **Experimental.** This API is part of an experimental wire-protocol surface
2696    /// and may change or be removed in future SDK or CLI releases. Pin both the
2697    /// SDK and CLI versions if your code depends on it.
2698    ///
2699    /// </div>
2700    pub(crate) async fn configure_session_extensions(
2701        &self,
2702        params: ConfigureSessionExtensionsParams,
2703    ) -> Result<(), Error> {
2704        let wire_params = serde_json::to_value(params)?;
2705        let _value = self
2706            .client
2707            .call(
2708                rpc_methods::SESSIONS_CONFIGURESESSIONEXTENSIONS,
2709                Some(wire_params),
2710            )
2711            .await?;
2712        Ok(())
2713    }
2714}
2715
2716/// `skills.*` RPCs.
2717#[derive(Clone, Copy)]
2718pub struct ClientRpcSkills<'a> {
2719    pub(crate) client: &'a Client,
2720}
2721
2722impl<'a> ClientRpcSkills<'a> {
2723    /// `skills.config.*` sub-namespace.
2724    pub fn config(&self) -> ClientRpcSkillsConfig<'a> {
2725        ClientRpcSkillsConfig {
2726            client: self.client,
2727        }
2728    }
2729
2730    /// Discovers skills across global and project sources.
2731    ///
2732    /// Wire method: `skills.discover`.
2733    ///
2734    /// # Parameters
2735    ///
2736    /// * `params` - Optional project paths and additional skill directories to include in discovery.
2737    ///
2738    /// # Returns
2739    ///
2740    /// Skills discovered across global and project sources.
2741    ///
2742    /// <div class="warning">
2743    ///
2744    /// **Experimental.** This API is part of an experimental wire-protocol surface
2745    /// and may change or be removed in future SDK or CLI releases. Pin both the
2746    /// SDK and CLI versions if your code depends on it.
2747    ///
2748    /// </div>
2749    pub async fn discover(&self, params: SkillsDiscoverRequest) -> Result<ServerSkillList, Error> {
2750        let wire_params = serde_json::to_value(params)?;
2751        let _value = self
2752            .client
2753            .call(rpc_methods::SKILLS_DISCOVER, Some(wire_params))
2754            .await?;
2755        Ok(serde_json::from_value(_value)?)
2756    }
2757
2758    /// 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.
2759    ///
2760    /// Wire method: `skills.getDiscoveryPaths`.
2761    ///
2762    /// # Parameters
2763    ///
2764    /// * `params` - Optional project paths to enumerate.
2765    ///
2766    /// # Returns
2767    ///
2768    /// Canonical locations where skills can be created so the runtime will recognize them.
2769    ///
2770    /// <div class="warning">
2771    ///
2772    /// **Experimental.** This API is part of an experimental wire-protocol surface
2773    /// and may change or be removed in future SDK or CLI releases. Pin both the
2774    /// SDK and CLI versions if your code depends on it.
2775    ///
2776    /// </div>
2777    pub async fn get_discovery_paths(
2778        &self,
2779        params: SkillsGetDiscoveryPathsRequest,
2780    ) -> Result<SkillDiscoveryPathList, Error> {
2781        let wire_params = serde_json::to_value(params)?;
2782        let _value = self
2783            .client
2784            .call(rpc_methods::SKILLS_GETDISCOVERYPATHS, Some(wire_params))
2785            .await?;
2786        Ok(serde_json::from_value(_value)?)
2787    }
2788}
2789
2790/// `skills.config.*` RPCs.
2791#[derive(Clone, Copy)]
2792pub struct ClientRpcSkillsConfig<'a> {
2793    pub(crate) client: &'a Client,
2794}
2795
2796impl<'a> ClientRpcSkillsConfig<'a> {
2797    /// Replaces the global list of disabled skills.
2798    ///
2799    /// Wire method: `skills.config.setDisabledSkills`.
2800    ///
2801    /// # Parameters
2802    ///
2803    /// * `params` - Skill names to mark as disabled in global configuration, replacing any previous list.
2804    ///
2805    /// <div class="warning">
2806    ///
2807    /// **Experimental.** This API is part of an experimental wire-protocol surface
2808    /// and may change or be removed in future SDK or CLI releases. Pin both the
2809    /// SDK and CLI versions if your code depends on it.
2810    ///
2811    /// </div>
2812    pub async fn set_disabled_skills(
2813        &self,
2814        params: SkillsConfigSetDisabledSkillsRequest,
2815    ) -> Result<(), Error> {
2816        let wire_params = serde_json::to_value(params)?;
2817        let _value = self
2818            .client
2819            .call(
2820                rpc_methods::SKILLS_CONFIG_SETDISABLEDSKILLS,
2821                Some(wire_params),
2822            )
2823            .await?;
2824        Ok(())
2825    }
2826
2827    /// Atomically adds or removes one skill from the disabled list.
2828    ///
2829    /// Wire method: `skills.config.setSkillDisabled`.
2830    ///
2831    /// # Parameters
2832    ///
2833    /// * `params` - Adds or removes a single skill from the global disabled list, leaving every other entry untouched.
2834    ///
2835    /// <div class="warning">
2836    ///
2837    /// **Experimental.** This API is part of an experimental wire-protocol surface
2838    /// and may change or be removed in future SDK or CLI releases. Pin both the
2839    /// SDK and CLI versions if your code depends on it.
2840    ///
2841    /// </div>
2842    pub async fn set_skill_disabled(
2843        &self,
2844        params: SkillsConfigSetSkillDisabledRequest,
2845    ) -> Result<(), Error> {
2846        let wire_params = serde_json::to_value(params)?;
2847        let _value = self
2848            .client
2849            .call(
2850                rpc_methods::SKILLS_CONFIG_SETSKILLDISABLED,
2851                Some(wire_params),
2852            )
2853            .await?;
2854        Ok(())
2855    }
2856}
2857
2858/// `tools.*` RPCs.
2859#[derive(Clone, Copy)]
2860pub struct ClientRpcTools<'a> {
2861    pub(crate) client: &'a Client,
2862}
2863
2864impl<'a> ClientRpcTools<'a> {
2865    /// Lists built-in tools available for a model.
2866    ///
2867    /// Wire method: `tools.list`.
2868    ///
2869    /// # Parameters
2870    ///
2871    /// * `params` - Optional model identifier whose tool overrides should be applied to the listing.
2872    ///
2873    /// # Returns
2874    ///
2875    /// Built-in tools available for the requested model, with their parameters and instructions.
2876    ///
2877    /// <div class="warning">
2878    ///
2879    /// **Experimental.** This API is part of an experimental wire-protocol surface
2880    /// and may change or be removed in future SDK or CLI releases. Pin both the
2881    /// SDK and CLI versions if your code depends on it.
2882    ///
2883    /// </div>
2884    pub async fn list(&self, params: ToolsListRequest) -> Result<ToolList, Error> {
2885        let wire_params = serde_json::to_value(params)?;
2886        let _value = self
2887            .client
2888            .call(rpc_methods::TOOLS_LIST, Some(wire_params))
2889            .await?;
2890        Ok(serde_json::from_value(_value)?)
2891    }
2892}
2893
2894/// `user.*` RPCs.
2895#[derive(Clone, Copy)]
2896pub struct ClientRpcUser<'a> {
2897    pub(crate) client: &'a Client,
2898}
2899
2900impl<'a> ClientRpcUser<'a> {
2901    /// `user.settings.*` sub-namespace.
2902    pub fn settings(&self) -> ClientRpcUserSettings<'a> {
2903        ClientRpcUserSettings {
2904            client: self.client,
2905        }
2906    }
2907}
2908
2909/// `user.settings.*` RPCs.
2910#[derive(Clone, Copy)]
2911pub struct ClientRpcUserSettings<'a> {
2912    pub(crate) client: &'a Client,
2913}
2914
2915impl<'a> ClientRpcUserSettings<'a> {
2916    /// Drops this runtime process's in-memory user settings cache so the next settings read observes disk.
2917    ///
2918    /// Wire method: `user.settings.reload`.
2919    ///
2920    /// <div class="warning">
2921    ///
2922    /// **Experimental.** This API is part of an experimental wire-protocol surface
2923    /// and may change or be removed in future SDK or CLI releases. Pin both the
2924    /// SDK and CLI versions if your code depends on it.
2925    ///
2926    /// </div>
2927    pub async fn reload(&self) -> Result<(), Error> {
2928        let wire_params = serde_json::json!({});
2929        let _value = self
2930            .client
2931            .call(rpc_methods::USER_SETTINGS_RELOAD, Some(wire_params))
2932            .await?;
2933        Ok(())
2934    }
2935
2936    /// 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.
2937    ///
2938    /// Wire method: `user.settings.get`.
2939    ///
2940    /// # Returns
2941    ///
2942    /// 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.
2943    ///
2944    /// <div class="warning">
2945    ///
2946    /// **Experimental.** This API is part of an experimental wire-protocol surface
2947    /// and may change or be removed in future SDK or CLI releases. Pin both the
2948    /// SDK and CLI versions if your code depends on it.
2949    ///
2950    /// </div>
2951    pub async fn get(&self) -> Result<UserSettingsGetResult, Error> {
2952        let wire_params = serde_json::json!({});
2953        let _value = self
2954            .client
2955            .call(rpc_methods::USER_SETTINGS_GET, Some(wire_params))
2956            .await?;
2957        Ok(serde_json::from_value(_value)?)
2958    }
2959
2960    /// 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.
2961    ///
2962    /// Wire method: `user.settings.set`.
2963    ///
2964    /// # Parameters
2965    ///
2966    /// * `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.
2967    ///
2968    /// # Returns
2969    ///
2970    /// Outcome of writing user settings.
2971    ///
2972    /// <div class="warning">
2973    ///
2974    /// **Experimental.** This API is part of an experimental wire-protocol surface
2975    /// and may change or be removed in future SDK or CLI releases. Pin both the
2976    /// SDK and CLI versions if your code depends on it.
2977    ///
2978    /// </div>
2979    pub async fn set(
2980        &self,
2981        params: UserSettingsSetRequest,
2982    ) -> Result<UserSettingsSetResult, Error> {
2983        let wire_params = serde_json::to_value(params)?;
2984        let _value = self
2985            .client
2986            .call(rpc_methods::USER_SETTINGS_SET, Some(wire_params))
2987            .await?;
2988        Ok(serde_json::from_value(_value)?)
2989    }
2990}
2991
2992/// Typed view over a [`Session`]'s RPC namespace.
2993#[derive(Clone, Copy)]
2994pub struct SessionRpc<'a> {
2995    pub(crate) session: &'a Session,
2996}
2997
2998impl<'a> SessionRpc<'a> {
2999    /// `session.agent.*` sub-namespace.
3000    pub fn agent(&self) -> SessionRpcAgent<'a> {
3001        SessionRpcAgent {
3002            session: self.session,
3003        }
3004    }
3005
3006    /// `session.canvas.*` sub-namespace.
3007    pub fn canvas(&self) -> SessionRpcCanvas<'a> {
3008        SessionRpcCanvas {
3009            session: self.session,
3010        }
3011    }
3012
3013    /// `session.commands.*` sub-namespace.
3014    pub fn commands(&self) -> SessionRpcCommands<'a> {
3015        SessionRpcCommands {
3016            session: self.session,
3017        }
3018    }
3019
3020    /// `session.completions.*` sub-namespace.
3021    pub fn completions(&self) -> SessionRpcCompletions<'a> {
3022        SessionRpcCompletions {
3023            session: self.session,
3024        }
3025    }
3026
3027    /// `session.contentExclusion.*` sub-namespace.
3028    pub fn content_exclusion(&self) -> SessionRpcContentExclusion<'a> {
3029        SessionRpcContentExclusion {
3030            session: self.session,
3031        }
3032    }
3033
3034    /// `session.debug.*` sub-namespace.
3035    pub fn debug(&self) -> SessionRpcDebug<'a> {
3036        SessionRpcDebug {
3037            session: self.session,
3038        }
3039    }
3040
3041    /// `session.eventLog.*` sub-namespace.
3042    pub fn event_log(&self) -> SessionRpcEventLog<'a> {
3043        SessionRpcEventLog {
3044            session: self.session,
3045        }
3046    }
3047
3048    /// `session.extensions.*` sub-namespace.
3049    pub fn extensions(&self) -> SessionRpcExtensions<'a> {
3050        SessionRpcExtensions {
3051            session: self.session,
3052        }
3053    }
3054
3055    /// `session.factory.*` sub-namespace.
3056    pub fn factory(&self) -> SessionRpcFactory<'a> {
3057        SessionRpcFactory {
3058            session: self.session,
3059        }
3060    }
3061
3062    /// `session.fleet.*` sub-namespace.
3063    pub fn fleet(&self) -> SessionRpcFleet<'a> {
3064        SessionRpcFleet {
3065            session: self.session,
3066        }
3067    }
3068
3069    /// `session.gitHubAuth.*` sub-namespace.
3070    pub fn git_hub_auth(&self) -> SessionRpcGitHubAuth<'a> {
3071        SessionRpcGitHubAuth {
3072            session: self.session,
3073        }
3074    }
3075
3076    /// `session.history.*` sub-namespace.
3077    pub fn history(&self) -> SessionRpcHistory<'a> {
3078        SessionRpcHistory {
3079            session: self.session,
3080        }
3081    }
3082
3083    /// `session.instructions.*` sub-namespace.
3084    pub fn instructions(&self) -> SessionRpcInstructions<'a> {
3085        SessionRpcInstructions {
3086            session: self.session,
3087        }
3088    }
3089
3090    /// `session.limitPrediction.*` sub-namespace.
3091    pub fn limit_prediction(&self) -> SessionRpcLimitPrediction<'a> {
3092        SessionRpcLimitPrediction {
3093            session: self.session,
3094        }
3095    }
3096
3097    /// `session.lsp.*` sub-namespace.
3098    pub fn lsp(&self) -> SessionRpcLsp<'a> {
3099        SessionRpcLsp {
3100            session: self.session,
3101        }
3102    }
3103
3104    /// `session.mcp.*` sub-namespace.
3105    pub fn mcp(&self) -> SessionRpcMcp<'a> {
3106        SessionRpcMcp {
3107            session: self.session,
3108        }
3109    }
3110
3111    /// `session.metadata.*` sub-namespace.
3112    pub fn metadata(&self) -> SessionRpcMetadata<'a> {
3113        SessionRpcMetadata {
3114            session: self.session,
3115        }
3116    }
3117
3118    /// `session.mode.*` sub-namespace.
3119    pub fn mode(&self) -> SessionRpcMode<'a> {
3120        SessionRpcMode {
3121            session: self.session,
3122        }
3123    }
3124
3125    /// `session.model.*` sub-namespace.
3126    pub fn model(&self) -> SessionRpcModel<'a> {
3127        SessionRpcModel {
3128            session: self.session,
3129        }
3130    }
3131
3132    /// `session.name.*` sub-namespace.
3133    pub fn name(&self) -> SessionRpcName<'a> {
3134        SessionRpcName {
3135            session: self.session,
3136        }
3137    }
3138
3139    /// `session.options.*` sub-namespace.
3140    pub fn options(&self) -> SessionRpcOptions<'a> {
3141        SessionRpcOptions {
3142            session: self.session,
3143        }
3144    }
3145
3146    /// `session.permissions.*` sub-namespace.
3147    pub fn permissions(&self) -> SessionRpcPermissions<'a> {
3148        SessionRpcPermissions {
3149            session: self.session,
3150        }
3151    }
3152
3153    /// `session.plan.*` sub-namespace.
3154    pub fn plan(&self) -> SessionRpcPlan<'a> {
3155        SessionRpcPlan {
3156            session: self.session,
3157        }
3158    }
3159
3160    /// `session.plugins.*` sub-namespace.
3161    pub fn plugins(&self) -> SessionRpcPlugins<'a> {
3162        SessionRpcPlugins {
3163            session: self.session,
3164        }
3165    }
3166
3167    /// `session.provider.*` sub-namespace.
3168    pub fn provider(&self) -> SessionRpcProvider<'a> {
3169        SessionRpcProvider {
3170            session: self.session,
3171        }
3172    }
3173
3174    /// `session.queue.*` sub-namespace.
3175    pub fn queue(&self) -> SessionRpcQueue<'a> {
3176        SessionRpcQueue {
3177            session: self.session,
3178        }
3179    }
3180
3181    /// `session.remote.*` sub-namespace.
3182    pub fn remote(&self) -> SessionRpcRemote<'a> {
3183        SessionRpcRemote {
3184            session: self.session,
3185        }
3186    }
3187
3188    /// `session.schedule.*` sub-namespace.
3189    pub fn schedule(&self) -> SessionRpcSchedule<'a> {
3190        SessionRpcSchedule {
3191            session: self.session,
3192        }
3193    }
3194
3195    /// `session.settings.*` sub-namespace.
3196    pub fn settings(&self) -> SessionRpcSettings<'a> {
3197        SessionRpcSettings {
3198            session: self.session,
3199        }
3200    }
3201
3202    /// `session.shell.*` sub-namespace.
3203    pub fn shell(&self) -> SessionRpcShell<'a> {
3204        SessionRpcShell {
3205            session: self.session,
3206        }
3207    }
3208
3209    /// `session.skills.*` sub-namespace.
3210    pub fn skills(&self) -> SessionRpcSkills<'a> {
3211        SessionRpcSkills {
3212            session: self.session,
3213        }
3214    }
3215
3216    /// `session.tasks.*` sub-namespace.
3217    pub fn tasks(&self) -> SessionRpcTasks<'a> {
3218        SessionRpcTasks {
3219            session: self.session,
3220        }
3221    }
3222
3223    /// `session.telemetry.*` sub-namespace.
3224    pub fn telemetry(&self) -> SessionRpcTelemetry<'a> {
3225        SessionRpcTelemetry {
3226            session: self.session,
3227        }
3228    }
3229
3230    /// `session.tools.*` sub-namespace.
3231    pub fn tools(&self) -> SessionRpcTools<'a> {
3232        SessionRpcTools {
3233            session: self.session,
3234        }
3235    }
3236
3237    /// `session.ui.*` sub-namespace.
3238    pub fn ui(&self) -> SessionRpcUi<'a> {
3239        SessionRpcUi {
3240            session: self.session,
3241        }
3242    }
3243
3244    /// `session.usage.*` sub-namespace.
3245    pub fn usage(&self) -> SessionRpcUsage<'a> {
3246        SessionRpcUsage {
3247            session: self.session,
3248        }
3249    }
3250
3251    /// `session.visibility.*` sub-namespace.
3252    pub fn visibility(&self) -> SessionRpcVisibility<'a> {
3253        SessionRpcVisibility {
3254            session: self.session,
3255        }
3256    }
3257
3258    /// `session.workspaces.*` sub-namespace.
3259    pub fn workspaces(&self) -> SessionRpcWorkspaces<'a> {
3260        SessionRpcWorkspaces {
3261            session: self.session,
3262        }
3263    }
3264
3265    /// Suspends the session while preserving persisted state for later resume.
3266    ///
3267    /// Wire method: `session.suspend`.
3268    ///
3269    /// <div class="warning">
3270    ///
3271    /// **Experimental.** This API is part of an experimental wire-protocol surface
3272    /// and may change or be removed in future SDK or CLI releases. Pin both the
3273    /// SDK and CLI versions if your code depends on it.
3274    ///
3275    /// </div>
3276    pub async fn suspend(&self) -> Result<(), Error> {
3277        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3278        let _value = self
3279            .session
3280            .client()
3281            .call(rpc_methods::SESSION_SUSPEND, Some(wire_params))
3282            .await?;
3283        Ok(())
3284    }
3285
3286    /// Sends a user message to the session and returns its message ID.
3287    ///
3288    /// Wire method: `session.send`.
3289    ///
3290    /// # Parameters
3291    ///
3292    /// * `params` - Parameters for sending a user message to the session
3293    ///
3294    /// # Returns
3295    ///
3296    /// Result of sending a user message
3297    ///
3298    /// <div class="warning">
3299    ///
3300    /// **Experimental.** This API is part of an experimental wire-protocol surface
3301    /// and may change or be removed in future SDK or CLI releases. Pin both the
3302    /// SDK and CLI versions if your code depends on it.
3303    ///
3304    /// </div>
3305    pub async fn send(&self, params: SendRequest) -> Result<SendResult, Error> {
3306        let mut wire_params = serde_json::to_value(params)?;
3307        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3308        let _value = self
3309            .session
3310            .client()
3311            .call(rpc_methods::SESSION_SEND, Some(wire_params))
3312            .await?;
3313        Ok(serde_json::from_value(_value)?)
3314    }
3315
3316    /// 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.
3317    ///
3318    /// Wire method: `session.sendMessages`.
3319    ///
3320    /// # Parameters
3321    ///
3322    /// * `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.
3323    ///
3324    /// # Returns
3325    ///
3326    /// Result of sending zero or more user messages
3327    ///
3328    /// <div class="warning">
3329    ///
3330    /// **Experimental.** This API is part of an experimental wire-protocol surface
3331    /// and may change or be removed in future SDK or CLI releases. Pin both the
3332    /// SDK and CLI versions if your code depends on it.
3333    ///
3334    /// </div>
3335    pub async fn send_messages(
3336        &self,
3337        params: SendMessagesRequest,
3338    ) -> Result<SendMessagesResult, Error> {
3339        let mut wire_params = serde_json::to_value(params)?;
3340        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3341        let _value = self
3342            .session
3343            .client()
3344            .call(rpc_methods::SESSION_SENDMESSAGES, Some(wire_params))
3345            .await?;
3346        Ok(serde_json::from_value(_value)?)
3347    }
3348
3349    /// Queues or sends an internal system notification to the session according to its passive policy.
3350    ///
3351    /// Wire method: `session.sendSystemNotification`.
3352    ///
3353    /// # Parameters
3354    ///
3355    /// * `params` - Internal request for sending a system notification.
3356    ///
3357    /// <div class="warning">
3358    ///
3359    /// **Experimental.** This API is part of an experimental wire-protocol surface
3360    /// and may change or be removed in future SDK or CLI releases. Pin both the
3361    /// SDK and CLI versions if your code depends on it.
3362    ///
3363    /// </div>
3364    pub(crate) async fn send_system_notification(
3365        &self,
3366        params: SendSystemNotificationRequest,
3367    ) -> Result<(), Error> {
3368        let mut wire_params = serde_json::to_value(params)?;
3369        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3370        let _value = self
3371            .session
3372            .client()
3373            .call(
3374                rpc_methods::SESSION_SENDSYSTEMNOTIFICATION,
3375                Some(wire_params),
3376            )
3377            .await?;
3378        Ok(())
3379    }
3380
3381    /// Aborts the current agent turn.
3382    ///
3383    /// Wire method: `session.abort`.
3384    ///
3385    /// # Parameters
3386    ///
3387    /// * `params` - Parameters for aborting the current turn
3388    ///
3389    /// # Returns
3390    ///
3391    /// Result of aborting the current turn
3392    ///
3393    /// <div class="warning">
3394    ///
3395    /// **Experimental.** This API is part of an experimental wire-protocol surface
3396    /// and may change or be removed in future SDK or CLI releases. Pin both the
3397    /// SDK and CLI versions if your code depends on it.
3398    ///
3399    /// </div>
3400    pub async fn abort(&self, params: AbortRequest) -> Result<AbortResult, Error> {
3401        let mut wire_params = serde_json::to_value(params)?;
3402        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3403        let _value = self
3404            .session
3405            .client()
3406            .call(rpc_methods::SESSION_ABORT, Some(wire_params))
3407            .await?;
3408        Ok(serde_json::from_value(_value)?)
3409    }
3410
3411    /// Interrupts the current main agent turn while leaving running background work (subagents, sidekicks, and promoted attached shells) alive. No-op when the main loop is not processing.
3412    ///
3413    /// Wire method: `session.interruptMainTurn`.
3414    ///
3415    /// # Parameters
3416    ///
3417    /// * `params` - Parameters for interrupting the main agent turn.
3418    ///
3419    /// # Returns
3420    ///
3421    /// Result of interrupting the main agent turn.
3422    ///
3423    /// <div class="warning">
3424    ///
3425    /// **Experimental.** This API is part of an experimental wire-protocol surface
3426    /// and may change or be removed in future SDK or CLI releases. Pin both the
3427    /// SDK and CLI versions if your code depends on it.
3428    ///
3429    /// </div>
3430    pub async fn interrupt_main_turn(
3431        &self,
3432        params: InterruptMainTurnRequest,
3433    ) -> Result<InterruptMainTurnResult, Error> {
3434        let mut wire_params = serde_json::to_value(params)?;
3435        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3436        let _value = self
3437            .session
3438            .client()
3439            .call(rpc_methods::SESSION_INTERRUPTMAINTURN, Some(wire_params))
3440            .await?;
3441        Ok(serde_json::from_value(_value)?)
3442    }
3443
3444    /// Cancels every running background agent (task-registry subagents plus sidekick agents) without interrupting the main agent loop. Promoted attached shells are left running.
3445    ///
3446    /// Wire method: `session.cancelAllBackgroundAgents`.
3447    ///
3448    /// # Returns
3449    ///
3450    /// The number of running background agents (task-registry agents) that were cancelled.
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 cancel_all_background_agents(
3460        &self,
3461    ) -> Result<SessionCancelAllBackgroundAgentsResult, Error> {
3462        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3463        let _value = self
3464            .session
3465            .client()
3466            .call(
3467                rpc_methods::SESSION_CANCELALLBACKGROUNDAGENTS,
3468                Some(wire_params),
3469            )
3470            .await?;
3471        Ok(serde_json::from_value(_value)?)
3472    }
3473
3474    /// 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.
3475    ///
3476    /// Wire method: `session.shutdown`.
3477    ///
3478    /// # Parameters
3479    ///
3480    /// * `params` - Parameters for shutting down the session
3481    ///
3482    /// <div class="warning">
3483    ///
3484    /// **Experimental.** This API is part of an experimental wire-protocol surface
3485    /// and may change or be removed in future SDK or CLI releases. Pin both the
3486    /// SDK and CLI versions if your code depends on it.
3487    ///
3488    /// </div>
3489    pub async fn shutdown(&self, params: ShutdownRequest) -> Result<(), Error> {
3490        let mut wire_params = serde_json::to_value(params)?;
3491        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3492        let _value = self
3493            .session
3494            .client()
3495            .call(rpc_methods::SESSION_SHUTDOWN, Some(wire_params))
3496            .await?;
3497        Ok(())
3498    }
3499
3500    /// Emits a user-visible session log event.
3501    ///
3502    /// Wire method: `session.log`.
3503    ///
3504    /// # Parameters
3505    ///
3506    /// * `params` - Message text, optional severity level, persistence flag, optional follow-up URL, and optional tip.
3507    ///
3508    /// # Returns
3509    ///
3510    /// Identifier of the session event that was emitted for the log message.
3511    ///
3512    /// <div class="warning">
3513    ///
3514    /// **Experimental.** This API is part of an experimental wire-protocol surface
3515    /// and may change or be removed in future SDK or CLI releases. Pin both the
3516    /// SDK and CLI versions if your code depends on it.
3517    ///
3518    /// </div>
3519    pub async fn log(&self, params: LogRequest) -> Result<LogResult, Error> {
3520        let mut wire_params = serde_json::to_value(params)?;
3521        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3522        let _value = self
3523            .session
3524            .client()
3525            .call(rpc_methods::SESSION_LOG, Some(wire_params))
3526            .await?;
3527        Ok(serde_json::from_value(_value)?)
3528    }
3529}
3530
3531/// `session.agent.*` RPCs.
3532#[derive(Clone, Copy)]
3533pub struct SessionRpcAgent<'a> {
3534    pub(crate) session: &'a Session,
3535}
3536
3537impl<'a> SessionRpcAgent<'a> {
3538    /// Lists agents available to the session. Defaults to custom agents only; pass includeBuiltInAgents to include the effective built-in agents.
3539    ///
3540    /// Wire method: `session.agent.list`.
3541    ///
3542    /// # Returns
3543    ///
3544    /// Agents available to the session.
3545    ///
3546    /// <div class="warning">
3547    ///
3548    /// **Experimental.** This API is part of an experimental wire-protocol surface
3549    /// and may change or be removed in future SDK or CLI releases. Pin both the
3550    /// SDK and CLI versions if your code depends on it.
3551    ///
3552    /// </div>
3553    pub async fn list(&self) -> Result<AgentList, Error> {
3554        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3555        let _value = self
3556            .session
3557            .client()
3558            .call(rpc_methods::SESSION_AGENT_LIST, Some(wire_params))
3559            .await?;
3560        Ok(serde_json::from_value(_value)?)
3561    }
3562
3563    /// Lists agents available to the session. Defaults to custom agents only; pass includeBuiltInAgents to include the effective built-in agents.
3564    ///
3565    /// Wire method: `session.agent.list`.
3566    ///
3567    /// # Parameters
3568    ///
3569    /// * `params` - Controls whether built-in agents and authored prompt text are included.
3570    ///
3571    /// # Returns
3572    ///
3573    /// Agents available to the session.
3574    ///
3575    /// <div class="warning">
3576    ///
3577    /// **Experimental.** This API is part of an experimental wire-protocol surface
3578    /// and may change or be removed in future SDK or CLI releases. Pin both the
3579    /// SDK and CLI versions if your code depends on it.
3580    ///
3581    /// </div>
3582    pub async fn list_with_params(&self, params: AgentListRequest) -> Result<AgentList, Error> {
3583        let mut wire_params = serde_json::to_value(params)?;
3584        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3585        let _value = self
3586            .session
3587            .client()
3588            .call(rpc_methods::SESSION_AGENT_LIST, Some(wire_params))
3589            .await?;
3590        Ok(serde_json::from_value(_value)?)
3591    }
3592
3593    /// Sets an in-memory authored prompt override for an available agent. For built-in agents, this replaces only the static base prompt while preserving runtime-owned dynamic prompt composition and behavior. The special `general-purpose` agent is not overrideable. Overrides are not persisted; resumed and forked sessions start without them, so the host must re-apply them.
3594    ///
3595    /// Wire method: `session.agent.setPrompt`.
3596    ///
3597    /// # Parameters
3598    ///
3599    /// * `params` - An in-memory authored prompt override for an available agent.
3600    ///
3601    /// <div class="warning">
3602    ///
3603    /// **Experimental.** This API is part of an experimental wire-protocol surface
3604    /// and may change or be removed in future SDK or CLI releases. Pin both the
3605    /// SDK and CLI versions if your code depends on it.
3606    ///
3607    /// </div>
3608    pub async fn set_prompt(&self, params: AgentSetPromptRequest) -> Result<(), Error> {
3609        let mut wire_params = serde_json::to_value(params)?;
3610        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3611        let _value = self
3612            .session
3613            .client()
3614            .call(rpc_methods::SESSION_AGENT_SETPROMPT, Some(wire_params))
3615            .await?;
3616        Ok(())
3617    }
3618
3619    /// Gets the currently selected custom agent for the session.
3620    ///
3621    /// Wire method: `session.agent.getCurrent`.
3622    ///
3623    /// # Returns
3624    ///
3625    /// The currently selected custom agent, or null when using the default agent.
3626    ///
3627    /// <div class="warning">
3628    ///
3629    /// **Experimental.** This API is part of an experimental wire-protocol surface
3630    /// and may change or be removed in future SDK or CLI releases. Pin both the
3631    /// SDK and CLI versions if your code depends on it.
3632    ///
3633    /// </div>
3634    pub async fn get_current(&self) -> Result<AgentGetCurrentResult, Error> {
3635        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3636        let _value = self
3637            .session
3638            .client()
3639            .call(rpc_methods::SESSION_AGENT_GETCURRENT, Some(wire_params))
3640            .await?;
3641        Ok(serde_json::from_value(_value)?)
3642    }
3643
3644    /// Selects a custom agent for subsequent turns in the session.
3645    ///
3646    /// Wire method: `session.agent.select`.
3647    ///
3648    /// # Parameters
3649    ///
3650    /// * `params` - Name of the custom agent to select for subsequent turns.
3651    ///
3652    /// # Returns
3653    ///
3654    /// The newly selected custom agent.
3655    ///
3656    /// <div class="warning">
3657    ///
3658    /// **Experimental.** This API is part of an experimental wire-protocol surface
3659    /// and may change or be removed in future SDK or CLI releases. Pin both the
3660    /// SDK and CLI versions if your code depends on it.
3661    ///
3662    /// </div>
3663    pub async fn select(&self, params: AgentSelectRequest) -> Result<AgentSelectResult, Error> {
3664        let mut wire_params = serde_json::to_value(params)?;
3665        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3666        let _value = self
3667            .session
3668            .client()
3669            .call(rpc_methods::SESSION_AGENT_SELECT, Some(wire_params))
3670            .await?;
3671        Ok(serde_json::from_value(_value)?)
3672    }
3673
3674    /// Clears the selected custom agent and returns the session to the default agent.
3675    ///
3676    /// Wire method: `session.agent.deselect`.
3677    ///
3678    /// <div class="warning">
3679    ///
3680    /// **Experimental.** This API is part of an experimental wire-protocol surface
3681    /// and may change or be removed in future SDK or CLI releases. Pin both the
3682    /// SDK and CLI versions if your code depends on it.
3683    ///
3684    /// </div>
3685    pub async fn deselect(&self) -> Result<(), Error> {
3686        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3687        let _value = self
3688            .session
3689            .client()
3690            .call(rpc_methods::SESSION_AGENT_DESELECT, Some(wire_params))
3691            .await?;
3692        Ok(())
3693    }
3694
3695    /// Reloads custom agent definitions and returns the refreshed list.
3696    ///
3697    /// Wire method: `session.agent.reload`.
3698    ///
3699    /// # Returns
3700    ///
3701    /// Custom agents available to the session after reloading definitions from disk.
3702    ///
3703    /// <div class="warning">
3704    ///
3705    /// **Experimental.** This API is part of an experimental wire-protocol surface
3706    /// and may change or be removed in future SDK or CLI releases. Pin both the
3707    /// SDK and CLI versions if your code depends on it.
3708    ///
3709    /// </div>
3710    pub async fn reload(&self) -> Result<AgentReloadResult, Error> {
3711        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3712        let _value = self
3713            .session
3714            .client()
3715            .call(rpc_methods::SESSION_AGENT_RELOAD, Some(wire_params))
3716            .await?;
3717        Ok(serde_json::from_value(_value)?)
3718    }
3719}
3720
3721/// `session.canvas.*` RPCs.
3722#[derive(Clone, Copy)]
3723pub struct SessionRpcCanvas<'a> {
3724    pub(crate) session: &'a Session,
3725}
3726
3727impl<'a> SessionRpcCanvas<'a> {
3728    /// `session.canvas.action.*` sub-namespace.
3729    pub fn action(&self) -> SessionRpcCanvasAction<'a> {
3730        SessionRpcCanvasAction {
3731            session: self.session,
3732        }
3733    }
3734
3735    /// `session.canvas.provider.*` sub-namespace.
3736    pub fn provider(&self) -> SessionRpcCanvasProvider<'a> {
3737        SessionRpcCanvasProvider {
3738            session: self.session,
3739        }
3740    }
3741
3742    /// Lists canvases declared for the session.
3743    ///
3744    /// Wire method: `session.canvas.list`.
3745    ///
3746    /// # Returns
3747    ///
3748    /// Declared canvases available in this session.
3749    ///
3750    /// <div class="warning">
3751    ///
3752    /// **Experimental.** This API is part of an experimental wire-protocol surface
3753    /// and may change or be removed in future SDK or CLI releases. Pin both the
3754    /// SDK and CLI versions if your code depends on it.
3755    ///
3756    /// </div>
3757    pub async fn list(&self) -> Result<CanvasList, Error> {
3758        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3759        let _value = self
3760            .session
3761            .client()
3762            .call(rpc_methods::SESSION_CANVAS_LIST, Some(wire_params))
3763            .await?;
3764        Ok(serde_json::from_value(_value)?)
3765    }
3766
3767    /// Lists currently open canvas instances for the live session.
3768    ///
3769    /// Wire method: `session.canvas.listOpen`.
3770    ///
3771    /// # Returns
3772    ///
3773    /// Live open-canvas snapshot.
3774    ///
3775    /// <div class="warning">
3776    ///
3777    /// **Experimental.** This API is part of an experimental wire-protocol surface
3778    /// and may change or be removed in future SDK or CLI releases. Pin both the
3779    /// SDK and CLI versions if your code depends on it.
3780    ///
3781    /// </div>
3782    pub async fn list_open(&self) -> Result<CanvasListOpenResult, Error> {
3783        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3784        let _value = self
3785            .session
3786            .client()
3787            .call(rpc_methods::SESSION_CANVAS_LISTOPEN, Some(wire_params))
3788            .await?;
3789        Ok(serde_json::from_value(_value)?)
3790    }
3791
3792    /// Opens or focuses a canvas instance.
3793    ///
3794    /// Wire method: `session.canvas.open`.
3795    ///
3796    /// # Parameters
3797    ///
3798    /// * `params` - Canvas open parameters.
3799    ///
3800    /// # Returns
3801    ///
3802    /// Open canvas instance snapshot.
3803    ///
3804    /// <div class="warning">
3805    ///
3806    /// **Experimental.** This API is part of an experimental wire-protocol surface
3807    /// and may change or be removed in future SDK or CLI releases. Pin both the
3808    /// SDK and CLI versions if your code depends on it.
3809    ///
3810    /// </div>
3811    pub async fn open(&self, params: CanvasOpenRequest) -> Result<OpenCanvasInstance, Error> {
3812        let mut wire_params = serde_json::to_value(params)?;
3813        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3814        let _value = self
3815            .session
3816            .client()
3817            .call(rpc_methods::SESSION_CANVAS_OPEN, Some(wire_params))
3818            .await?;
3819        Ok(serde_json::from_value(_value)?)
3820    }
3821
3822    /// Closes an open canvas instance.
3823    ///
3824    /// Wire method: `session.canvas.close`.
3825    ///
3826    /// # Parameters
3827    ///
3828    /// * `params` - Canvas close parameters.
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 close(&self, params: CanvasCloseRequest) -> 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_CANVAS_CLOSE, Some(wire_params))
3844            .await?;
3845        Ok(())
3846    }
3847}
3848
3849/// `session.canvas.action.*` RPCs.
3850#[derive(Clone, Copy)]
3851pub struct SessionRpcCanvasAction<'a> {
3852    pub(crate) session: &'a Session,
3853}
3854
3855impl<'a> SessionRpcCanvasAction<'a> {
3856    /// Invokes an action on an open canvas instance.
3857    ///
3858    /// Wire method: `session.canvas.action.invoke`.
3859    ///
3860    /// # Parameters
3861    ///
3862    /// * `params` - Canvas action invocation parameters.
3863    ///
3864    /// # Returns
3865    ///
3866    /// Canvas action invocation result.
3867    ///
3868    /// <div class="warning">
3869    ///
3870    /// **Experimental.** This API is part of an experimental wire-protocol surface
3871    /// and may change or be removed in future SDK or CLI releases. Pin both the
3872    /// SDK and CLI versions if your code depends on it.
3873    ///
3874    /// </div>
3875    pub async fn invoke(
3876        &self,
3877        params: CanvasActionInvokeRequest,
3878    ) -> Result<CanvasActionInvokeResult, Error> {
3879        let mut wire_params = serde_json::to_value(params)?;
3880        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3881        let _value = self
3882            .session
3883            .client()
3884            .call(rpc_methods::SESSION_CANVAS_ACTION_INVOKE, Some(wire_params))
3885            .await?;
3886        Ok(serde_json::from_value(_value)?)
3887    }
3888}
3889
3890/// `session.canvas.provider.*` RPCs.
3891#[derive(Clone, Copy)]
3892pub struct SessionRpcCanvasProvider<'a> {
3893    pub(crate) session: &'a Session,
3894}
3895
3896impl<'a> SessionRpcCanvasProvider<'a> {
3897    /// Registers an internal canvas provider connection and its contributions.
3898    ///
3899    /// Wire method: `session.canvas.provider.register`.
3900    ///
3901    /// # Parameters
3902    ///
3903    /// * `params` - Internal canvas provider registration parameters.
3904    ///
3905    /// <div class="warning">
3906    ///
3907    /// **Experimental.** This API is part of an experimental wire-protocol surface
3908    /// and may change or be removed in future SDK or CLI releases. Pin both the
3909    /// SDK and CLI versions if your code depends on it.
3910    ///
3911    /// </div>
3912    pub(crate) async fn register(
3913        &self,
3914        params: CanvasProviderRegisterRequest,
3915    ) -> Result<(), Error> {
3916        let mut wire_params = serde_json::to_value(params)?;
3917        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3918        let _value = self
3919            .session
3920            .client()
3921            .call(
3922                rpc_methods::SESSION_CANVAS_PROVIDER_REGISTER,
3923                Some(wire_params),
3924            )
3925            .await?;
3926        Ok(())
3927    }
3928
3929    /// Unregisters an internal canvas provider connection.
3930    ///
3931    /// Wire method: `session.canvas.provider.unregister`.
3932    ///
3933    /// # Parameters
3934    ///
3935    /// * `params` - Internal canvas provider unregistration parameters.
3936    ///
3937    /// <div class="warning">
3938    ///
3939    /// **Experimental.** This API is part of an experimental wire-protocol surface
3940    /// and may change or be removed in future SDK or CLI releases. Pin both the
3941    /// SDK and CLI versions if your code depends on it.
3942    ///
3943    /// </div>
3944    pub(crate) async fn unregister(
3945        &self,
3946        params: CanvasProviderUnregisterRequest,
3947    ) -> Result<(), Error> {
3948        let mut wire_params = serde_json::to_value(params)?;
3949        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3950        let _value = self
3951            .session
3952            .client()
3953            .call(
3954                rpc_methods::SESSION_CANVAS_PROVIDER_UNREGISTER,
3955                Some(wire_params),
3956            )
3957            .await?;
3958        Ok(())
3959    }
3960}
3961
3962/// `session.commands.*` RPCs.
3963#[derive(Clone, Copy)]
3964pub struct SessionRpcCommands<'a> {
3965    pub(crate) session: &'a Session,
3966}
3967
3968impl<'a> SessionRpcCommands<'a> {
3969    /// Lists slash commands available in the session.
3970    ///
3971    /// Wire method: `session.commands.list`.
3972    ///
3973    /// # Returns
3974    ///
3975    /// Slash commands available in the session, after applying any include/exclude filters.
3976    ///
3977    /// <div class="warning">
3978    ///
3979    /// **Experimental.** This API is part of an experimental wire-protocol surface
3980    /// and may change or be removed in future SDK or CLI releases. Pin both the
3981    /// SDK and CLI versions if your code depends on it.
3982    ///
3983    /// </div>
3984    pub async fn list(&self) -> Result<CommandList, Error> {
3985        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3986        let _value = self
3987            .session
3988            .client()
3989            .call(rpc_methods::SESSION_COMMANDS_LIST, Some(wire_params))
3990            .await?;
3991        Ok(serde_json::from_value(_value)?)
3992    }
3993
3994    /// Lists slash commands available in the session.
3995    ///
3996    /// Wire method: `session.commands.list`.
3997    ///
3998    /// # Parameters
3999    ///
4000    /// * `params` - Optional filters controlling which command sources to include in the listing.
4001    ///
4002    /// # Returns
4003    ///
4004    /// Slash commands available in the session, after applying any include/exclude filters.
4005    ///
4006    /// <div class="warning">
4007    ///
4008    /// **Experimental.** This API is part of an experimental wire-protocol surface
4009    /// and may change or be removed in future SDK or CLI releases. Pin both the
4010    /// SDK and CLI versions if your code depends on it.
4011    ///
4012    /// </div>
4013    pub async fn list_with_params(
4014        &self,
4015        params: CommandsListRequest,
4016    ) -> Result<CommandList, Error> {
4017        let mut wire_params = serde_json::to_value(params)?;
4018        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4019        let _value = self
4020            .session
4021            .client()
4022            .call(rpc_methods::SESSION_COMMANDS_LIST, Some(wire_params))
4023            .await?;
4024        Ok(serde_json::from_value(_value)?)
4025    }
4026
4027    /// Invokes a slash command in the session.
4028    ///
4029    /// Wire method: `session.commands.invoke`.
4030    ///
4031    /// # Parameters
4032    ///
4033    /// * `params` - Slash command name and optional raw input string to invoke.
4034    ///
4035    /// # Returns
4036    ///
4037    /// Result of invoking the slash command (text output, prompt to send to the agent, completion, or subcommand selection).
4038    ///
4039    /// <div class="warning">
4040    ///
4041    /// **Experimental.** This API is part of an experimental wire-protocol surface
4042    /// and may change or be removed in future SDK or CLI releases. Pin both the
4043    /// SDK and CLI versions if your code depends on it.
4044    ///
4045    /// </div>
4046    pub async fn invoke(
4047        &self,
4048        params: CommandsInvokeRequest,
4049    ) -> Result<SlashCommandInvocationResult, Error> {
4050        let mut wire_params = serde_json::to_value(params)?;
4051        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4052        let _value = self
4053            .session
4054            .client()
4055            .call(rpc_methods::SESSION_COMMANDS_INVOKE, Some(wire_params))
4056            .await?;
4057        Ok(serde_json::from_value(_value)?)
4058    }
4059
4060    /// Finalizes persistence associated with a client-applied slash-command effect.
4061    ///
4062    /// Wire method: `session.commands.finalizeInvocationEffect`.
4063    ///
4064    /// # Parameters
4065    ///
4066    /// * `params` - The pending slash-command invocation effect to finalize, plus whether the host applied or cancelled it.
4067    ///
4068    /// # Returns
4069    ///
4070    /// Whether finalizing the invocation effect succeeded, and the failure reason when it did not.
4071    ///
4072    /// <div class="warning">
4073    ///
4074    /// **Experimental.** This API is part of an experimental wire-protocol surface
4075    /// and may change or be removed in future SDK or CLI releases. Pin both the
4076    /// SDK and CLI versions if your code depends on it.
4077    ///
4078    /// </div>
4079    pub(crate) async fn finalize_invocation_effect(
4080        &self,
4081        params: CommandsFinalizeInvocationEffectRequest,
4082    ) -> Result<CommandsFinalizeInvocationEffectResult, Error> {
4083        let mut wire_params = serde_json::to_value(params)?;
4084        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4085        let _value = self
4086            .session
4087            .client()
4088            .call(
4089                rpc_methods::SESSION_COMMANDS_FINALIZEINVOCATIONEFFECT,
4090                Some(wire_params),
4091            )
4092            .await?;
4093        Ok(serde_json::from_value(_value)?)
4094    }
4095
4096    /// Reports completion of a pending client-handled slash command.
4097    ///
4098    /// Wire method: `session.commands.handlePendingCommand`.
4099    ///
4100    /// # Parameters
4101    ///
4102    /// * `params` - Pending command request ID and an optional error if the client handler failed.
4103    ///
4104    /// # Returns
4105    ///
4106    /// Indicates whether the pending client-handled command was completed successfully.
4107    ///
4108    /// <div class="warning">
4109    ///
4110    /// **Experimental.** This API is part of an experimental wire-protocol surface
4111    /// and may change or be removed in future SDK or CLI releases. Pin both the
4112    /// SDK and CLI versions if your code depends on it.
4113    ///
4114    /// </div>
4115    pub async fn handle_pending_command(
4116        &self,
4117        params: CommandsHandlePendingCommandRequest,
4118    ) -> Result<CommandsHandlePendingCommandResult, Error> {
4119        let mut wire_params = serde_json::to_value(params)?;
4120        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4121        let _value = self
4122            .session
4123            .client()
4124            .call(
4125                rpc_methods::SESSION_COMMANDS_HANDLEPENDINGCOMMAND,
4126                Some(wire_params),
4127            )
4128            .await?;
4129        Ok(serde_json::from_value(_value)?)
4130    }
4131
4132    /// Executes a slash command synchronously and returns any error.
4133    ///
4134    /// Wire method: `session.commands.execute`.
4135    ///
4136    /// # Parameters
4137    ///
4138    /// * `params` - Slash command name and argument string to execute synchronously.
4139    ///
4140    /// # Returns
4141    ///
4142    /// Error message produced while executing the command, if any.
4143    ///
4144    /// <div class="warning">
4145    ///
4146    /// **Experimental.** This API is part of an experimental wire-protocol surface
4147    /// and may change or be removed in future SDK or CLI releases. Pin both the
4148    /// SDK and CLI versions if your code depends on it.
4149    ///
4150    /// </div>
4151    pub async fn execute(
4152        &self,
4153        params: ExecuteCommandParams,
4154    ) -> Result<ExecuteCommandResult, Error> {
4155        let mut wire_params = serde_json::to_value(params)?;
4156        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4157        let _value = self
4158            .session
4159            .client()
4160            .call(rpc_methods::SESSION_COMMANDS_EXECUTE, Some(wire_params))
4161            .await?;
4162        Ok(serde_json::from_value(_value)?)
4163    }
4164
4165    /// Enqueues a slash command for FIFO processing on the local session.
4166    ///
4167    /// Wire method: `session.commands.enqueue`.
4168    ///
4169    /// # Parameters
4170    ///
4171    /// * `params` - Slash-prefixed command string to enqueue for FIFO processing.
4172    ///
4173    /// # Returns
4174    ///
4175    /// Indicates whether the command was accepted into the local execution queue.
4176    ///
4177    /// <div class="warning">
4178    ///
4179    /// **Experimental.** This API is part of an experimental wire-protocol surface
4180    /// and may change or be removed in future SDK or CLI releases. Pin both the
4181    /// SDK and CLI versions if your code depends on it.
4182    ///
4183    /// </div>
4184    pub async fn enqueue(
4185        &self,
4186        params: EnqueueCommandParams,
4187    ) -> Result<EnqueueCommandResult, Error> {
4188        let mut wire_params = serde_json::to_value(params)?;
4189        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4190        let _value = self
4191            .session
4192            .client()
4193            .call(rpc_methods::SESSION_COMMANDS_ENQUEUE, Some(wire_params))
4194            .await?;
4195        Ok(serde_json::from_value(_value)?)
4196    }
4197
4198    /// Reports whether the host actually executed a queued command and whether to continue processing.
4199    ///
4200    /// Wire method: `session.commands.respondToQueuedCommand`.
4201    ///
4202    /// # Parameters
4203    ///
4204    /// * `params` - Queued-command request ID and the result indicating whether the host executed it (and whether to stop processing further queued commands).
4205    ///
4206    /// # Returns
4207    ///
4208    /// Indicates whether the queued-command response was matched to a pending request.
4209    ///
4210    /// <div class="warning">
4211    ///
4212    /// **Experimental.** This API is part of an experimental wire-protocol surface
4213    /// and may change or be removed in future SDK or CLI releases. Pin both the
4214    /// SDK and CLI versions if your code depends on it.
4215    ///
4216    /// </div>
4217    pub async fn respond_to_queued_command(
4218        &self,
4219        params: CommandsRespondToQueuedCommandRequest,
4220    ) -> Result<CommandsRespondToQueuedCommandResult, Error> {
4221        let mut wire_params = serde_json::to_value(params)?;
4222        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4223        let _value = self
4224            .session
4225            .client()
4226            .call(
4227                rpc_methods::SESSION_COMMANDS_RESPONDTOQUEUEDCOMMAND,
4228                Some(wire_params),
4229            )
4230            .await?;
4231        Ok(serde_json::from_value(_value)?)
4232    }
4233}
4234
4235/// `session.completions.*` RPCs.
4236#[derive(Clone, Copy)]
4237pub struct SessionRpcCompletions<'a> {
4238    pub(crate) session: &'a Session,
4239}
4240
4241impl<'a> SessionRpcCompletions<'a> {
4242    /// 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).
4243    ///
4244    /// Wire method: `session.completions.getTriggerCharacters`.
4245    ///
4246    /// # Returns
4247    ///
4248    /// 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`).
4249    ///
4250    /// <div class="warning">
4251    ///
4252    /// **Experimental.** This API is part of an experimental wire-protocol surface
4253    /// and may change or be removed in future SDK or CLI releases. Pin both the
4254    /// SDK and CLI versions if your code depends on it.
4255    ///
4256    /// </div>
4257    pub async fn get_trigger_characters(
4258        &self,
4259    ) -> Result<CompletionsGetTriggerCharactersResult, Error> {
4260        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
4261        let _value = self
4262            .session
4263            .client()
4264            .call(
4265                rpc_methods::SESSION_COMPLETIONS_GETTRIGGERCHARACTERS,
4266                Some(wire_params),
4267            )
4268            .await?;
4269        Ok(serde_json::from_value(_value)?)
4270    }
4271
4272    /// 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.
4273    ///
4274    /// Wire method: `session.completions.request`.
4275    ///
4276    /// # Parameters
4277    ///
4278    /// * `params` - Request host-driven completions for the current composer input.
4279    ///
4280    /// # Returns
4281    ///
4282    /// Host-driven completion items for the current composer input. Empty when the host returns no items or does not support completions.
4283    ///
4284    /// <div class="warning">
4285    ///
4286    /// **Experimental.** This API is part of an experimental wire-protocol surface
4287    /// and may change or be removed in future SDK or CLI releases. Pin both the
4288    /// SDK and CLI versions if your code depends on it.
4289    ///
4290    /// </div>
4291    pub async fn request(
4292        &self,
4293        params: CompletionsRequestRequest,
4294    ) -> Result<CompletionsRequestResult, Error> {
4295        let mut wire_params = serde_json::to_value(params)?;
4296        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4297        let _value = self
4298            .session
4299            .client()
4300            .call(rpc_methods::SESSION_COMPLETIONS_REQUEST, Some(wire_params))
4301            .await?;
4302        Ok(serde_json::from_value(_value)?)
4303    }
4304}
4305
4306/// `session.contentExclusion.*` RPCs.
4307#[derive(Clone, Copy)]
4308pub struct SessionRpcContentExclusion<'a> {
4309    pub(crate) session: &'a Session,
4310}
4311
4312impl<'a> SessionRpcContentExclusion<'a> {
4313    /// Checks local file system absolute paths within the session working directory against its content-exclusion policy. Results preserve input order. Unsupported paths/filesystems and unavailable policy evaluation return available false, and callers must treat every requested path as excluded.
4314    ///
4315    /// Wire method: `session.contentExclusion.checkPaths`.
4316    ///
4317    /// # Parameters
4318    ///
4319    /// * `params` - Local file system absolute paths within the session working directory to check against its content-exclusion policy.
4320    ///
4321    /// # Returns
4322    ///
4323    /// Batch content-exclusion result. Callers must fail closed when policy evaluation is unavailable.
4324    ///
4325    /// <div class="warning">
4326    ///
4327    /// **Experimental.** This API is part of an experimental wire-protocol surface
4328    /// and may change or be removed in future SDK or CLI releases. Pin both the
4329    /// SDK and CLI versions if your code depends on it.
4330    ///
4331    /// </div>
4332    pub async fn check_paths(
4333        &self,
4334        params: ContentExclusionCheckPathsRequest,
4335    ) -> Result<ContentExclusionCheckPathsResult, Error> {
4336        let mut wire_params = serde_json::to_value(params)?;
4337        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4338        let _value = self
4339            .session
4340            .client()
4341            .call(
4342                rpc_methods::SESSION_CONTENTEXCLUSION_CHECKPATHS,
4343                Some(wire_params),
4344            )
4345            .await?;
4346        Ok(serde_json::from_value(_value)?)
4347    }
4348}
4349
4350/// `session.debug.*` RPCs.
4351#[derive(Clone, Copy)]
4352pub struct SessionRpcDebug<'a> {
4353    pub(crate) session: &'a Session,
4354}
4355
4356impl<'a> SessionRpcDebug<'a> {
4357    /// 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.
4358    ///
4359    /// Wire method: `session.debug.collectLogs`.
4360    ///
4361    /// # Parameters
4362    ///
4363    /// * `params` - Options for collecting a redacted session debug bundle.
4364    ///
4365    /// # Returns
4366    ///
4367    /// Result of collecting a redacted debug bundle.
4368    ///
4369    /// <div class="warning">
4370    ///
4371    /// **Experimental.** This API is part of an experimental wire-protocol surface
4372    /// and may change or be removed in future SDK or CLI releases. Pin both the
4373    /// SDK and CLI versions if your code depends on it.
4374    ///
4375    /// </div>
4376    pub async fn collect_logs(
4377        &self,
4378        params: DebugCollectLogsRequest,
4379    ) -> Result<DebugCollectLogsResult, Error> {
4380        let mut wire_params = serde_json::to_value(params)?;
4381        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4382        let _value = self
4383            .session
4384            .client()
4385            .call(rpc_methods::SESSION_DEBUG_COLLECTLOGS, Some(wire_params))
4386            .await?;
4387        Ok(serde_json::from_value(_value)?)
4388    }
4389}
4390
4391/// `session.eventLog.*` RPCs.
4392#[derive(Clone, Copy)]
4393pub struct SessionRpcEventLog<'a> {
4394    pub(crate) session: &'a Session,
4395}
4396
4397impl<'a> SessionRpcEventLog<'a> {
4398    /// Reads a batch of session events from a cursor, optionally waiting for new events. Supports tail-first reads via `direction: backward`.
4399    ///
4400    /// Wire method: `session.eventLog.read`.
4401    ///
4402    /// # Parameters
4403    ///
4404    /// * `params` - Cursor, batch size, and optional long-poll/filter parameters for reading session events.
4405    ///
4406    /// # Returns
4407    ///
4408    /// Batch of session events returned by a read, with cursor and continuation metadata.
4409    ///
4410    /// <div class="warning">
4411    ///
4412    /// **Experimental.** This API is part of an experimental wire-protocol surface
4413    /// and may change or be removed in future SDK or CLI releases. Pin both the
4414    /// SDK and CLI versions if your code depends on it.
4415    ///
4416    /// </div>
4417    pub async fn read(&self, params: EventLogReadRequest) -> Result<EventsReadResult, Error> {
4418        let mut wire_params = serde_json::to_value(params)?;
4419        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4420        let _value = self
4421            .session
4422            .client()
4423            .call(rpc_methods::SESSION_EVENTLOG_READ, Some(wire_params))
4424            .await?;
4425        Ok(serde_json::from_value(_value)?)
4426    }
4427
4428    /// Returns a snapshot of the current tail cursor without consuming events.
4429    ///
4430    /// Wire method: `session.eventLog.tail`.
4431    ///
4432    /// # Returns
4433    ///
4434    /// 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).
4435    ///
4436    /// <div class="warning">
4437    ///
4438    /// **Experimental.** This API is part of an experimental wire-protocol surface
4439    /// and may change or be removed in future SDK or CLI releases. Pin both the
4440    /// SDK and CLI versions if your code depends on it.
4441    ///
4442    /// </div>
4443    pub async fn tail(&self) -> Result<EventLogTailResult, Error> {
4444        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
4445        let _value = self
4446            .session
4447            .client()
4448            .call(rpc_methods::SESSION_EVENTLOG_TAIL, Some(wire_params))
4449            .await?;
4450        Ok(serde_json::from_value(_value)?)
4451    }
4452
4453    /// Registers consumer interest in an event type for runtime gating purposes.
4454    ///
4455    /// Wire method: `session.eventLog.registerInterest`.
4456    ///
4457    /// # Parameters
4458    ///
4459    /// * `params` - Event type to register consumer interest for, used by runtime gating logic.
4460    ///
4461    /// # Returns
4462    ///
4463    /// Opaque handle representing an event-type interest registration.
4464    ///
4465    /// <div class="warning">
4466    ///
4467    /// **Experimental.** This API is part of an experimental wire-protocol surface
4468    /// and may change or be removed in future SDK or CLI releases. Pin both the
4469    /// SDK and CLI versions if your code depends on it.
4470    ///
4471    /// </div>
4472    pub async fn register_interest(
4473        &self,
4474        params: RegisterEventInterestParams,
4475    ) -> Result<RegisterEventInterestResult, Error> {
4476        let mut wire_params = serde_json::to_value(params)?;
4477        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4478        let _value = self
4479            .session
4480            .client()
4481            .call(
4482                rpc_methods::SESSION_EVENTLOG_REGISTERINTEREST,
4483                Some(wire_params),
4484            )
4485            .await?;
4486        Ok(serde_json::from_value(_value)?)
4487    }
4488
4489    /// Releases a consumer's previously-registered interest in an event type.
4490    ///
4491    /// Wire method: `session.eventLog.releaseInterest`.
4492    ///
4493    /// # Parameters
4494    ///
4495    /// * `params` - Opaque handle previously returned by `registerInterest` to release.
4496    ///
4497    /// # Returns
4498    ///
4499    /// Indicates whether the operation succeeded.
4500    ///
4501    /// <div class="warning">
4502    ///
4503    /// **Experimental.** This API is part of an experimental wire-protocol surface
4504    /// and may change or be removed in future SDK or CLI releases. Pin both the
4505    /// SDK and CLI versions if your code depends on it.
4506    ///
4507    /// </div>
4508    pub async fn release_interest(
4509        &self,
4510        params: ReleaseEventInterestParams,
4511    ) -> Result<EventLogReleaseInterestResult, Error> {
4512        let mut wire_params = serde_json::to_value(params)?;
4513        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4514        let _value = self
4515            .session
4516            .client()
4517            .call(
4518                rpc_methods::SESSION_EVENTLOG_RELEASEINTEREST,
4519                Some(wire_params),
4520            )
4521            .await?;
4522        Ok(serde_json::from_value(_value)?)
4523    }
4524}
4525
4526/// `session.extensions.*` RPCs.
4527#[derive(Clone, Copy)]
4528pub struct SessionRpcExtensions<'a> {
4529    pub(crate) session: &'a Session,
4530}
4531
4532impl<'a> SessionRpcExtensions<'a> {
4533    /// Lists extensions discovered for the session and their current status.
4534    ///
4535    /// Wire method: `session.extensions.list`.
4536    ///
4537    /// # Returns
4538    ///
4539    /// Extensions discovered for the session, with their current status.
4540    ///
4541    /// <div class="warning">
4542    ///
4543    /// **Experimental.** This API is part of an experimental wire-protocol surface
4544    /// and may change or be removed in future SDK or CLI releases. Pin both the
4545    /// SDK and CLI versions if your code depends on it.
4546    ///
4547    /// </div>
4548    pub async fn list(&self) -> Result<ExtensionList, Error> {
4549        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
4550        let _value = self
4551            .session
4552            .client()
4553            .call(rpc_methods::SESSION_EXTENSIONS_LIST, Some(wire_params))
4554            .await?;
4555        Ok(serde_json::from_value(_value)?)
4556    }
4557
4558    /// Enables an extension for the session.
4559    ///
4560    /// Wire method: `session.extensions.enable`.
4561    ///
4562    /// # Parameters
4563    ///
4564    /// * `params` - Source-qualified extension identifier to enable for the session.
4565    ///
4566    /// <div class="warning">
4567    ///
4568    /// **Experimental.** This API is part of an experimental wire-protocol surface
4569    /// and may change or be removed in future SDK or CLI releases. Pin both the
4570    /// SDK and CLI versions if your code depends on it.
4571    ///
4572    /// </div>
4573    pub async fn enable(&self, params: ExtensionsEnableRequest) -> Result<(), Error> {
4574        let mut wire_params = serde_json::to_value(params)?;
4575        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4576        let _value = self
4577            .session
4578            .client()
4579            .call(rpc_methods::SESSION_EXTENSIONS_ENABLE, Some(wire_params))
4580            .await?;
4581        Ok(())
4582    }
4583
4584    /// Disables an extension for the session.
4585    ///
4586    /// Wire method: `session.extensions.disable`.
4587    ///
4588    /// # Parameters
4589    ///
4590    /// * `params` - Source-qualified extension identifier to disable for the session.
4591    ///
4592    /// <div class="warning">
4593    ///
4594    /// **Experimental.** This API is part of an experimental wire-protocol surface
4595    /// and may change or be removed in future SDK or CLI releases. Pin both the
4596    /// SDK and CLI versions if your code depends on it.
4597    ///
4598    /// </div>
4599    pub async fn disable(&self, params: ExtensionsDisableRequest) -> Result<(), Error> {
4600        let mut wire_params = serde_json::to_value(params)?;
4601        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4602        let _value = self
4603            .session
4604            .client()
4605            .call(rpc_methods::SESSION_EXTENSIONS_DISABLE, Some(wire_params))
4606            .await?;
4607        Ok(())
4608    }
4609
4610    /// Reloads extension definitions and processes for the session.
4611    ///
4612    /// Wire method: `session.extensions.reload`.
4613    ///
4614    /// <div class="warning">
4615    ///
4616    /// **Experimental.** This API is part of an experimental wire-protocol surface
4617    /// and may change or be removed in future SDK or CLI releases. Pin both the
4618    /// SDK and CLI versions if your code depends on it.
4619    ///
4620    /// </div>
4621    pub async fn reload(&self) -> Result<(), Error> {
4622        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
4623        let _value = self
4624            .session
4625            .client()
4626            .call(rpc_methods::SESSION_EXTENSIONS_RELOAD, Some(wire_params))
4627            .await?;
4628        Ok(())
4629    }
4630
4631    /// 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.
4632    ///
4633    /// Wire method: `session.extensions.sendAttachmentsToMessage`.
4634    ///
4635    /// # Parameters
4636    ///
4637    /// * `params` - Parameters for session.extensions.sendAttachmentsToMessage.
4638    ///
4639    /// <div class="warning">
4640    ///
4641    /// **Experimental.** This API is part of an experimental wire-protocol surface
4642    /// and may change or be removed in future SDK or CLI releases. Pin both the
4643    /// SDK and CLI versions if your code depends on it.
4644    ///
4645    /// </div>
4646    pub async fn send_attachments_to_message(
4647        &self,
4648        params: SendAttachmentsToMessageParams,
4649    ) -> Result<(), Error> {
4650        let mut wire_params = serde_json::to_value(params)?;
4651        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4652        let _value = self
4653            .session
4654            .client()
4655            .call(
4656                rpc_methods::SESSION_EXTENSIONS_SENDATTACHMENTSTOMESSAGE,
4657                Some(wire_params),
4658            )
4659            .await?;
4660        Ok(())
4661    }
4662}
4663
4664/// `session.factory.*` RPCs.
4665#[derive(Clone, Copy)]
4666pub struct SessionRpcFactory<'a> {
4667    pub(crate) session: &'a Session,
4668}
4669
4670impl<'a> SessionRpcFactory<'a> {
4671    /// `session.factory.journal.*` sub-namespace.
4672    pub fn journal(&self) -> SessionRpcFactoryJournal<'a> {
4673        SessionRpcFactoryJournal {
4674            session: self.session,
4675        }
4676    }
4677
4678    /// Runs a registered factory by name at the top level.
4679    ///
4680    /// Wire method: `session.factory.run`.
4681    ///
4682    /// # Parameters
4683    ///
4684    /// * `params` - Parameters for invoking a registered factory.
4685    ///
4686    /// # Returns
4687    ///
4688    /// Complete current or terminal factory run envelope.
4689    ///
4690    /// <div class="warning">
4691    ///
4692    /// **Experimental.** This API is part of an experimental wire-protocol surface
4693    /// and may change or be removed in future SDK or CLI releases. Pin both the
4694    /// SDK and CLI versions if your code depends on it.
4695    ///
4696    /// </div>
4697    pub async fn run(&self, params: FactoryRunRequest) -> Result<FactoryRunResult, Error> {
4698        let mut wire_params = serde_json::to_value(params)?;
4699        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4700        let _value = self
4701            .session
4702            .client()
4703            .call(rpc_methods::SESSION_FACTORY_RUN, Some(wire_params))
4704            .await?;
4705        Ok(serde_json::from_value(_value)?)
4706    }
4707
4708    /// Resumes a factory run using its persisted name, arguments, journal, and accounting.
4709    ///
4710    /// Wire method: `session.factory.resume`.
4711    ///
4712    /// # Parameters
4713    ///
4714    /// * `params` - Parameters for resuming a factory run from its persisted identity.
4715    ///
4716    /// # Returns
4717    ///
4718    /// Resolved persisted factory identity and resumed run envelope.
4719    ///
4720    /// <div class="warning">
4721    ///
4722    /// **Experimental.** This API is part of an experimental wire-protocol surface
4723    /// and may change or be removed in future SDK or CLI releases. Pin both the
4724    /// SDK and CLI versions if your code depends on it.
4725    ///
4726    /// </div>
4727    pub async fn resume(&self, params: FactoryResumeRequest) -> Result<FactoryResumeResult, Error> {
4728        let mut wire_params = serde_json::to_value(params)?;
4729        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4730        let _value = self
4731            .session
4732            .client()
4733            .call(rpc_methods::SESSION_FACTORY_RESUME, Some(wire_params))
4734            .await?;
4735        Ok(serde_json::from_value(_value)?)
4736    }
4737
4738    /// Internal tool-originated factory invocation.
4739    ///
4740    /// Wire method: `session.factory.runFromTool`.
4741    ///
4742    /// # Parameters
4743    ///
4744    /// * `params` - Internal parameters for invoking a registered factory from a tool.
4745    ///
4746    /// # Returns
4747    ///
4748    /// Complete current or terminal factory run envelope.
4749    ///
4750    /// <div class="warning">
4751    ///
4752    /// **Experimental.** This API is part of an experimental wire-protocol surface
4753    /// and may change or be removed in future SDK or CLI releases. Pin both the
4754    /// SDK and CLI versions if your code depends on it.
4755    ///
4756    /// </div>
4757    pub(crate) async fn run_from_tool(
4758        &self,
4759        params: FactoryToolRunRequest,
4760    ) -> Result<FactoryRunResult, Error> {
4761        let mut wire_params = serde_json::to_value(params)?;
4762        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4763        let _value = self
4764            .session
4765            .client()
4766            .call(rpc_methods::SESSION_FACTORY_RUNFROMTOOL, Some(wire_params))
4767            .await?;
4768        Ok(serde_json::from_value(_value)?)
4769    }
4770
4771    /// Internal tool-originated factory resume.
4772    ///
4773    /// Wire method: `session.factory.resumeFromTool`.
4774    ///
4775    /// # Parameters
4776    ///
4777    /// * `params` - Internal parameters for resuming a factory run from a tool.
4778    ///
4779    /// # Returns
4780    ///
4781    /// Resolved persisted factory identity and resumed run envelope.
4782    ///
4783    /// <div class="warning">
4784    ///
4785    /// **Experimental.** This API is part of an experimental wire-protocol surface
4786    /// and may change or be removed in future SDK or CLI releases. Pin both the
4787    /// SDK and CLI versions if your code depends on it.
4788    ///
4789    /// </div>
4790    pub(crate) async fn resume_from_tool(
4791        &self,
4792        params: FactoryToolResumeRequest,
4793    ) -> Result<FactoryResumeResult, Error> {
4794        let mut wire_params = serde_json::to_value(params)?;
4795        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4796        let _value = self
4797            .session
4798            .client()
4799            .call(
4800                rpc_methods::SESSION_FACTORY_RESUMEFROMTOOL,
4801                Some(wire_params),
4802            )
4803            .await?;
4804        Ok(serde_json::from_value(_value)?)
4805    }
4806
4807    /// Gets the current or settled envelope for a factory run.
4808    ///
4809    /// Wire method: `session.factory.getRun`.
4810    ///
4811    /// # Parameters
4812    ///
4813    /// * `params` - Parameters for retrieving a factory run.
4814    ///
4815    /// # Returns
4816    ///
4817    /// Complete current or terminal factory run envelope.
4818    ///
4819    /// <div class="warning">
4820    ///
4821    /// **Experimental.** This API is part of an experimental wire-protocol surface
4822    /// and may change or be removed in future SDK or CLI releases. Pin both the
4823    /// SDK and CLI versions if your code depends on it.
4824    ///
4825    /// </div>
4826    pub async fn get_run(&self, params: FactoryGetRunRequest) -> Result<FactoryRunResult, Error> {
4827        let mut wire_params = serde_json::to_value(params)?;
4828        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4829        let _value = self
4830            .session
4831            .client()
4832            .call(rpc_methods::SESSION_FACTORY_GETRUN, Some(wire_params))
4833            .await?;
4834        Ok(serde_json::from_value(_value)?)
4835    }
4836
4837    /// Lists durable factory runs for this session in creation order.
4838    ///
4839    /// Wire method: `session.factory.listRuns`.
4840    ///
4841    /// # Parameters
4842    ///
4843    /// * `params` - Parameters for paging factory runs.
4844    ///
4845    /// # Returns
4846    ///
4847    /// A page of factory runs in durable creation order.
4848    ///
4849    /// <div class="warning">
4850    ///
4851    /// **Experimental.** This API is part of an experimental wire-protocol surface
4852    /// and may change or be removed in future SDK or CLI releases. Pin both the
4853    /// SDK and CLI versions if your code depends on it.
4854    ///
4855    /// </div>
4856    pub async fn list_runs(
4857        &self,
4858        params: FactoryListRunsRequest,
4859    ) -> Result<FactoryListRunsResult, Error> {
4860        let mut wire_params = serde_json::to_value(params)?;
4861        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4862        let _value = self
4863            .session
4864            .client()
4865            .call(rpc_methods::SESSION_FACTORY_LISTRUNS, Some(wire_params))
4866            .await?;
4867        Ok(serde_json::from_value(_value)?)
4868    }
4869
4870    /// Gets durable and live observability detail for one factory run.
4871    ///
4872    /// Wire method: `session.factory.getRunDetail`.
4873    ///
4874    /// # Parameters
4875    ///
4876    /// * `params` - Parameters for retrieving a factory run.
4877    ///
4878    /// # Returns
4879    ///
4880    /// Full factory run observability detail.
4881    ///
4882    /// <div class="warning">
4883    ///
4884    /// **Experimental.** This API is part of an experimental wire-protocol surface
4885    /// and may change or be removed in future SDK or CLI releases. Pin both the
4886    /// SDK and CLI versions if your code depends on it.
4887    ///
4888    /// </div>
4889    pub async fn get_run_detail(
4890        &self,
4891        params: FactoryGetRunRequest,
4892    ) -> Result<FactoryRunDetail, Error> {
4893        let mut wire_params = serde_json::to_value(params)?;
4894        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4895        let _value = self
4896            .session
4897            .client()
4898            .call(rpc_methods::SESSION_FACTORY_GETRUNDETAIL, Some(wire_params))
4899            .await?;
4900        Ok(serde_json::from_value(_value)?)
4901    }
4902
4903    /// Pages durable progress for one factory run.
4904    ///
4905    /// Wire method: `session.factory.getRunProgress`.
4906    ///
4907    /// # Parameters
4908    ///
4909    /// * `params` - Parameters for paging factory progress.
4910    ///
4911    /// # Returns
4912    ///
4913    /// A bidirectional page of factory progress.
4914    ///
4915    /// <div class="warning">
4916    ///
4917    /// **Experimental.** This API is part of an experimental wire-protocol surface
4918    /// and may change or be removed in future SDK or CLI releases. Pin both the
4919    /// SDK and CLI versions if your code depends on it.
4920    ///
4921    /// </div>
4922    pub async fn get_run_progress(
4923        &self,
4924        params: FactoryGetRunProgressRequest,
4925    ) -> Result<FactoryProgressPage, Error> {
4926        let mut wire_params = serde_json::to_value(params)?;
4927        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4928        let _value = self
4929            .session
4930            .client()
4931            .call(
4932                rpc_methods::SESSION_FACTORY_GETRUNPROGRESS,
4933                Some(wire_params),
4934            )
4935            .await?;
4936        Ok(serde_json::from_value(_value)?)
4937    }
4938
4939    /// Requests cancellation of a factory run and returns its run envelope.
4940    ///
4941    /// Wire method: `session.factory.cancel`.
4942    ///
4943    /// # Parameters
4944    ///
4945    /// * `params` - Parameters for cancelling a factory run.
4946    ///
4947    /// # Returns
4948    ///
4949    /// Complete current or terminal factory run envelope.
4950    ///
4951    /// <div class="warning">
4952    ///
4953    /// **Experimental.** This API is part of an experimental wire-protocol surface
4954    /// and may change or be removed in future SDK or CLI releases. Pin both the
4955    /// SDK and CLI versions if your code depends on it.
4956    ///
4957    /// </div>
4958    pub async fn cancel(&self, params: FactoryCancelRequest) -> Result<FactoryRunResult, Error> {
4959        let mut wire_params = serde_json::to_value(params)?;
4960        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4961        let _value = self
4962            .session
4963            .client()
4964            .call(rpc_methods::SESSION_FACTORY_CANCEL, Some(wire_params))
4965            .await?;
4966        Ok(serde_json::from_value(_value)?)
4967    }
4968
4969    /// Records a batch of ordered factory progress lines.
4970    ///
4971    /// Wire method: `session.factory.log`.
4972    ///
4973    /// # Parameters
4974    ///
4975    /// * `params` - Parameters for recording factory progress.
4976    ///
4977    /// # Returns
4978    ///
4979    /// Acknowledgement that a factory request was accepted.
4980    ///
4981    /// <div class="warning">
4982    ///
4983    /// **Experimental.** This API is part of an experimental wire-protocol surface
4984    /// and may change or be removed in future SDK or CLI releases. Pin both the
4985    /// SDK and CLI versions if your code depends on it.
4986    ///
4987    /// </div>
4988    pub async fn log(&self, params: FactoryLogRequest) -> Result<FactoryAckResult, Error> {
4989        let mut wire_params = serde_json::to_value(params)?;
4990        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4991        let _value = self
4992            .session
4993            .client()
4994            .call(rpc_methods::SESSION_FACTORY_LOG, Some(wire_params))
4995            .await?;
4996        Ok(serde_json::from_value(_value)?)
4997    }
4998
4999    /// Runs one factory-scoped subagent and returns its result.
5000    ///
5001    /// Wire method: `session.factory.agent`.
5002    ///
5003    /// # Parameters
5004    ///
5005    /// * `params` - Parameters for one factory-scoped subagent call.
5006    ///
5007    /// # Returns
5008    ///
5009    /// Result of one factory-scoped subagent call.
5010    ///
5011    /// <div class="warning">
5012    ///
5013    /// **Experimental.** This API is part of an experimental wire-protocol surface
5014    /// and may change or be removed in future SDK or CLI releases. Pin both the
5015    /// SDK and CLI versions if your code depends on it.
5016    ///
5017    /// </div>
5018    pub async fn agent(&self, params: FactoryAgentRequest) -> Result<FactoryAgentResult, Error> {
5019        let mut wire_params = serde_json::to_value(params)?;
5020        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5021        let _value = self
5022            .session
5023            .client()
5024            .call(rpc_methods::SESSION_FACTORY_AGENT, Some(wire_params))
5025            .await?;
5026        Ok(serde_json::from_value(_value)?)
5027    }
5028}
5029
5030/// `session.factory.journal.*` RPCs.
5031#[derive(Clone, Copy)]
5032pub struct SessionRpcFactoryJournal<'a> {
5033    pub(crate) session: &'a Session,
5034}
5035
5036impl<'a> SessionRpcFactoryJournal<'a> {
5037    /// Reads a memoized factory journal entry.
5038    ///
5039    /// Wire method: `session.factory.journal.get`.
5040    ///
5041    /// # Parameters
5042    ///
5043    /// * `params` - Parameters for reading a factory journal entry.
5044    ///
5045    /// # Returns
5046    ///
5047    /// Result of reading a factory journal entry.
5048    ///
5049    /// <div class="warning">
5050    ///
5051    /// **Experimental.** This API is part of an experimental wire-protocol surface
5052    /// and may change or be removed in future SDK or CLI releases. Pin both the
5053    /// SDK and CLI versions if your code depends on it.
5054    ///
5055    /// </div>
5056    pub async fn get(
5057        &self,
5058        params: FactoryJournalGetRequest,
5059    ) -> Result<FactoryJournalGetResult, Error> {
5060        let mut wire_params = serde_json::to_value(params)?;
5061        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5062        let _value = self
5063            .session
5064            .client()
5065            .call(rpc_methods::SESSION_FACTORY_JOURNAL_GET, Some(wire_params))
5066            .await?;
5067        Ok(serde_json::from_value(_value)?)
5068    }
5069
5070    /// Stores a memoized factory journal entry.
5071    ///
5072    /// Wire method: `session.factory.journal.put`.
5073    ///
5074    /// # Parameters
5075    ///
5076    /// * `params` - Parameters for storing a factory journal entry.
5077    ///
5078    /// # Returns
5079    ///
5080    /// Acknowledgement that a factory request was accepted.
5081    ///
5082    /// <div class="warning">
5083    ///
5084    /// **Experimental.** This API is part of an experimental wire-protocol surface
5085    /// and may change or be removed in future SDK or CLI releases. Pin both the
5086    /// SDK and CLI versions if your code depends on it.
5087    ///
5088    /// </div>
5089    pub async fn put(&self, params: FactoryJournalPutRequest) -> Result<FactoryAckResult, Error> {
5090        let mut wire_params = serde_json::to_value(params)?;
5091        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5092        let _value = self
5093            .session
5094            .client()
5095            .call(rpc_methods::SESSION_FACTORY_JOURNAL_PUT, Some(wire_params))
5096            .await?;
5097        Ok(serde_json::from_value(_value)?)
5098    }
5099}
5100
5101/// `session.fleet.*` RPCs.
5102#[derive(Clone, Copy)]
5103pub struct SessionRpcFleet<'a> {
5104    pub(crate) session: &'a Session,
5105}
5106
5107impl<'a> SessionRpcFleet<'a> {
5108    /// Starts fleet mode by submitting the fleet orchestration prompt to the session.
5109    ///
5110    /// Wire method: `session.fleet.start`.
5111    ///
5112    /// # Parameters
5113    ///
5114    /// * `params` - Optional user prompt to combine with the fleet orchestration instructions.
5115    ///
5116    /// # Returns
5117    ///
5118    /// Indicates whether fleet mode was successfully activated.
5119    ///
5120    /// <div class="warning">
5121    ///
5122    /// **Experimental.** This API is part of an experimental wire-protocol surface
5123    /// and may change or be removed in future SDK or CLI releases. Pin both the
5124    /// SDK and CLI versions if your code depends on it.
5125    ///
5126    /// </div>
5127    pub async fn start(&self, params: FleetStartRequest) -> Result<FleetStartResult, Error> {
5128        let mut wire_params = serde_json::to_value(params)?;
5129        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5130        let _value = self
5131            .session
5132            .client()
5133            .call(rpc_methods::SESSION_FLEET_START, Some(wire_params))
5134            .await?;
5135        Ok(serde_json::from_value(_value)?)
5136    }
5137}
5138
5139/// `session.gitHubAuth.*` RPCs.
5140#[derive(Clone, Copy)]
5141pub struct SessionRpcGitHubAuth<'a> {
5142    pub(crate) session: &'a Session,
5143}
5144
5145impl<'a> SessionRpcGitHubAuth<'a> {
5146    /// Gets authentication status and account metadata for the session.
5147    ///
5148    /// Wire method: `session.gitHubAuth.getStatus`.
5149    ///
5150    /// # Returns
5151    ///
5152    /// Authentication status and account metadata for the session.
5153    ///
5154    /// <div class="warning">
5155    ///
5156    /// **Experimental.** This API is part of an experimental wire-protocol surface
5157    /// and may change or be removed in future SDK or CLI releases. Pin both the
5158    /// SDK and CLI versions if your code depends on it.
5159    ///
5160    /// </div>
5161    pub async fn get_status(&self) -> Result<SessionAuthStatus, Error> {
5162        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5163        let _value = self
5164            .session
5165            .client()
5166            .call(rpc_methods::SESSION_GITHUBAUTH_GETSTATUS, Some(wire_params))
5167            .await?;
5168        Ok(serde_json::from_value(_value)?)
5169    }
5170
5171    /// Updates the session's auth credentials used for outbound model and API requests.
5172    ///
5173    /// Wire method: `session.gitHubAuth.setCredentials`.
5174    ///
5175    /// # Parameters
5176    ///
5177    /// * `params` - New auth credentials to install on the session. Omit to leave credentials unchanged.
5178    ///
5179    /// # Returns
5180    ///
5181    /// Indicates whether the credential update succeeded.
5182    ///
5183    /// <div class="warning">
5184    ///
5185    /// **Experimental.** This API is part of an experimental wire-protocol surface
5186    /// and may change or be removed in future SDK or CLI releases. Pin both the
5187    /// SDK and CLI versions if your code depends on it.
5188    ///
5189    /// </div>
5190    pub async fn set_credentials(
5191        &self,
5192        params: SessionSetCredentialsParams,
5193    ) -> Result<SessionSetCredentialsResult, Error> {
5194        let mut wire_params = serde_json::to_value(params)?;
5195        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5196        let _value = self
5197            .session
5198            .client()
5199            .call(
5200                rpc_methods::SESSION_GITHUBAUTH_SETCREDENTIALS,
5201                Some(wire_params),
5202            )
5203            .await?;
5204        Ok(serde_json::from_value(_value)?)
5205    }
5206
5207    /// Gets the current authentication information for internal session hosts.
5208    ///
5209    /// Wire method: `session.gitHubAuth.getCurrentAuthInfo`.
5210    ///
5211    /// # Returns
5212    ///
5213    /// Current authentication information, or null when no authentication is active.
5214    ///
5215    /// <div class="warning">
5216    ///
5217    /// **Experimental.** This API is part of an experimental wire-protocol surface
5218    /// and may change or be removed in future SDK or CLI releases. Pin both the
5219    /// SDK and CLI versions if your code depends on it.
5220    ///
5221    /// </div>
5222    pub(crate) async fn get_current_auth_info(&self) -> Result<SessionAuthInfoResult, Error> {
5223        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5224        let _value = self
5225            .session
5226            .client()
5227            .call(
5228                rpc_methods::SESSION_GITHUBAUTH_GETCURRENTAUTHINFO,
5229                Some(wire_params),
5230            )
5231            .await?;
5232        Ok(serde_json::from_value(_value)?)
5233    }
5234
5235    /// Gets all authentication accounts available to the internal session host.
5236    ///
5237    /// Wire method: `session.gitHubAuth.getAllAuthAvailable`.
5238    ///
5239    /// # Returns
5240    ///
5241    /// Authentication accounts available to the internal session host.
5242    ///
5243    /// <div class="warning">
5244    ///
5245    /// **Experimental.** This API is part of an experimental wire-protocol surface
5246    /// and may change or be removed in future SDK or CLI releases. Pin both the
5247    /// SDK and CLI versions if your code depends on it.
5248    ///
5249    /// </div>
5250    pub(crate) async fn get_all_auth_available(
5251        &self,
5252    ) -> Result<SessionGitHubAuthGetAllAuthAvailableResult, Error> {
5253        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5254        let _value = self
5255            .session
5256            .client()
5257            .call(
5258                rpc_methods::SESSION_GITHUBAUTH_GETALLAUTHAVAILABLE,
5259                Some(wire_params),
5260            )
5261            .await?;
5262        Ok(serde_json::from_value(_value)?)
5263    }
5264
5265    /// Refreshes Copilot account metadata for the current authentication.
5266    ///
5267    /// Wire method: `session.gitHubAuth.refreshCopilotUser`.
5268    ///
5269    /// # Returns
5270    ///
5271    /// Current authentication information, or null when no authentication is active.
5272    ///
5273    /// <div class="warning">
5274    ///
5275    /// **Experimental.** This API is part of an experimental wire-protocol surface
5276    /// and may change or be removed in future SDK or CLI releases. Pin both the
5277    /// SDK and CLI versions if your code depends on it.
5278    ///
5279    /// </div>
5280    pub(crate) async fn refresh_copilot_user(&self) -> Result<SessionAuthInfoResult, Error> {
5281        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5282        let _value = self
5283            .session
5284            .client()
5285            .call(
5286                rpc_methods::SESSION_GITHUBAUTH_REFRESHCOPILOTUSER,
5287                Some(wire_params),
5288            )
5289            .await?;
5290        Ok(serde_json::from_value(_value)?)
5291    }
5292
5293    /// Logs in a GitHub user through the internal session host.
5294    ///
5295    /// Wire method: `session.gitHubAuth.login`.
5296    ///
5297    /// # Parameters
5298    ///
5299    /// * `params` - Internal GitHub login parameters.
5300    ///
5301    /// # Returns
5302    ///
5303    /// Authentication credentials accepted only at native protocol ingress. Runtime outputs use credential-free `AuthIdentity` metadata.
5304    ///
5305    /// <div class="warning">
5306    ///
5307    /// **Experimental.** This API is part of an experimental wire-protocol surface
5308    /// and may change or be removed in future SDK or CLI releases. Pin both the
5309    /// SDK and CLI versions if your code depends on it.
5310    ///
5311    /// </div>
5312    pub(crate) async fn login(&self, params: SessionAuthLoginRequest) -> Result<AuthInfo, Error> {
5313        let mut wire_params = serde_json::to_value(params)?;
5314        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5315        let _value = self
5316            .session
5317            .client()
5318            .call(rpc_methods::SESSION_GITHUBAUTH_LOGIN, Some(wire_params))
5319            .await?;
5320        Ok(serde_json::from_value(_value)?)
5321    }
5322
5323    /// Switches the session to another available authentication.
5324    ///
5325    /// Wire method: `session.gitHubAuth.switchToAuth`.
5326    ///
5327    /// # Parameters
5328    ///
5329    /// * `params` - Parameters for switching the session's active authentication.
5330    ///
5331    /// <div class="warning">
5332    ///
5333    /// **Experimental.** This API is part of an experimental wire-protocol surface
5334    /// and may change or be removed in future SDK or CLI releases. Pin both the
5335    /// SDK and CLI versions if your code depends on it.
5336    ///
5337    /// </div>
5338    pub(crate) async fn switch_to_auth(
5339        &self,
5340        params: SessionAuthSwitchRequest,
5341    ) -> Result<(), Error> {
5342        let mut wire_params = serde_json::to_value(params)?;
5343        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5344        let _value = self
5345            .session
5346            .client()
5347            .call(
5348                rpc_methods::SESSION_GITHUBAUTH_SWITCHTOAUTH,
5349                Some(wire_params),
5350            )
5351            .await?;
5352        Ok(())
5353    }
5354
5355    /// Logs out the session's current GitHub authentication.
5356    ///
5357    /// Wire method: `session.gitHubAuth.logout`.
5358    ///
5359    /// # Returns
5360    ///
5361    /// Whether the current authentication was logged out.
5362    ///
5363    /// <div class="warning">
5364    ///
5365    /// **Experimental.** This API is part of an experimental wire-protocol surface
5366    /// and may change or be removed in future SDK or CLI releases. Pin both the
5367    /// SDK and CLI versions if your code depends on it.
5368    ///
5369    /// </div>
5370    pub(crate) async fn logout(&self) -> Result<SessionGitHubAuthLogoutResult, Error> {
5371        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5372        let _value = self
5373            .session
5374            .client()
5375            .call(rpc_methods::SESSION_GITHUBAUTH_LOGOUT, Some(wire_params))
5376            .await?;
5377        Ok(serde_json::from_value(_value)?)
5378    }
5379
5380    /// Logs out a specific GitHub authentication.
5381    ///
5382    /// Wire method: `session.gitHubAuth.logoutUser`.
5383    ///
5384    /// # Parameters
5385    ///
5386    /// * `params` - Parameters identifying a GitHub authentication to log out.
5387    ///
5388    /// # Returns
5389    ///
5390    /// Whether the requested authentication was logged out.
5391    ///
5392    /// <div class="warning">
5393    ///
5394    /// **Experimental.** This API is part of an experimental wire-protocol surface
5395    /// and may change or be removed in future SDK or CLI releases. Pin both the
5396    /// SDK and CLI versions if your code depends on it.
5397    ///
5398    /// </div>
5399    pub(crate) async fn logout_user(
5400        &self,
5401        params: SessionAuthLogoutUserRequest,
5402    ) -> Result<SessionGitHubAuthLogoutUserResult, Error> {
5403        let mut wire_params = serde_json::to_value(params)?;
5404        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5405        let _value = self
5406            .session
5407            .client()
5408            .call(
5409                rpc_methods::SESSION_GITHUBAUTH_LOGOUTUSER,
5410                Some(wire_params),
5411            )
5412            .await?;
5413        Ok(serde_json::from_value(_value)?)
5414    }
5415
5416    /// Gets validation errors from the most recent authentication attempt.
5417    ///
5418    /// Wire method: `session.gitHubAuth.lastAuthErrors`.
5419    ///
5420    /// # Returns
5421    ///
5422    /// Validation errors from the most recent authentication attempt.
5423    ///
5424    /// <div class="warning">
5425    ///
5426    /// **Experimental.** This API is part of an experimental wire-protocol surface
5427    /// and may change or be removed in future SDK or CLI releases. Pin both the
5428    /// SDK and CLI versions if your code depends on it.
5429    ///
5430    /// </div>
5431    pub(crate) async fn last_auth_errors(&self) -> Result<AuthValidationErrors, Error> {
5432        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5433        let _value = self
5434            .session
5435            .client()
5436            .call(
5437                rpc_methods::SESSION_GITHUBAUTH_LASTAUTHERRORS,
5438                Some(wire_params),
5439            )
5440            .await?;
5441        Ok(serde_json::from_value(_value)?)
5442    }
5443}
5444
5445/// `session.history.*` RPCs.
5446#[derive(Clone, Copy)]
5447pub struct SessionRpcHistory<'a> {
5448    pub(crate) session: &'a Session,
5449}
5450
5451impl<'a> SessionRpcHistory<'a> {
5452    /// Compacts the session history to reduce context usage.
5453    ///
5454    /// Wire method: `session.history.compact`.
5455    ///
5456    /// # Returns
5457    ///
5458    /// Compaction outcome with the number of tokens and messages removed, summary text, and the resulting context window breakdown.
5459    ///
5460    /// <div class="warning">
5461    ///
5462    /// **Experimental.** This API is part of an experimental wire-protocol surface
5463    /// and may change or be removed in future SDK or CLI releases. Pin both the
5464    /// SDK and CLI versions if your code depends on it.
5465    ///
5466    /// </div>
5467    pub async fn compact(&self) -> Result<HistoryCompactResult, Error> {
5468        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5469        let _value = self
5470            .session
5471            .client()
5472            .call(rpc_methods::SESSION_HISTORY_COMPACT, Some(wire_params))
5473            .await?;
5474        Ok(serde_json::from_value(_value)?)
5475    }
5476
5477    /// Compacts the session history to reduce context usage.
5478    ///
5479    /// Wire method: `session.history.compact`.
5480    ///
5481    /// # Parameters
5482    ///
5483    /// * `params` - Optional compaction parameters.
5484    ///
5485    /// # Returns
5486    ///
5487    /// Compaction outcome with the number of tokens and messages removed, summary text, and the resulting context window breakdown.
5488    ///
5489    /// <div class="warning">
5490    ///
5491    /// **Experimental.** This API is part of an experimental wire-protocol surface
5492    /// and may change or be removed in future SDK or CLI releases. Pin both the
5493    /// SDK and CLI versions if your code depends on it.
5494    ///
5495    /// </div>
5496    pub async fn compact_with_params(
5497        &self,
5498        params: HistoryCompactRequest,
5499    ) -> Result<HistoryCompactResult, Error> {
5500        let mut wire_params = serde_json::to_value(params)?;
5501        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5502        let _value = self
5503            .session
5504            .client()
5505            .call(rpc_methods::SESSION_HISTORY_COMPACT, Some(wire_params))
5506            .await?;
5507        Ok(serde_json::from_value(_value)?)
5508    }
5509
5510    /// Truncates persisted session history to a specific event.
5511    ///
5512    /// Wire method: `session.history.truncate`.
5513    ///
5514    /// # Parameters
5515    ///
5516    /// * `params` - Identifier of the event to truncate to; this event and all later events are removed.
5517    ///
5518    /// # Returns
5519    ///
5520    /// Number of events that were removed by the truncation.
5521    ///
5522    /// <div class="warning">
5523    ///
5524    /// **Experimental.** This API is part of an experimental wire-protocol surface
5525    /// and may change or be removed in future SDK or CLI releases. Pin both the
5526    /// SDK and CLI versions if your code depends on it.
5527    ///
5528    /// </div>
5529    pub async fn truncate(
5530        &self,
5531        params: HistoryTruncateRequest,
5532    ) -> Result<HistoryTruncateResult, Error> {
5533        let mut wire_params = serde_json::to_value(params)?;
5534        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5535        let _value = self
5536            .session
5537            .client()
5538            .call(rpc_methods::SESSION_HISTORY_TRUNCATE, Some(wire_params))
5539            .await?;
5540        Ok(serde_json::from_value(_value)?)
5541    }
5542
5543    /// Lists the user turns that the session can rewind to. Never rejects for a busy session: rewind reads need the session's file-change captures to be settled, so a session that still holds active work answers with `unavailableReason: "session-busy"` and no points, which the caller can retry.
5544    ///
5545    /// Wire method: `session.history.listRewindPoints`.
5546    ///
5547    /// # Returns
5548    ///
5549    /// Rewind points and file-change-tracking availability for the session.
5550    ///
5551    /// <div class="warning">
5552    ///
5553    /// **Experimental.** This API is part of an experimental wire-protocol surface
5554    /// and may change or be removed in future SDK or CLI releases. Pin both the
5555    /// SDK and CLI versions if your code depends on it.
5556    ///
5557    /// </div>
5558    pub async fn list_rewind_points(&self) -> Result<HistoryListRewindPointsResult, Error> {
5559        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5560        let _value = self
5561            .session
5562            .client()
5563            .call(
5564                rpc_methods::SESSION_HISTORY_LISTREWINDPOINTS,
5565                Some(wire_params),
5566            )
5567            .await?;
5568        Ok(serde_json::from_value(_value)?)
5569    }
5570
5571    /// Previews the files that a conversation-and-files rewind would restore.
5572    ///
5573    /// Wire method: `session.history.previewRewind`.
5574    ///
5575    /// # Parameters
5576    ///
5577    /// * `params` - Event boundary to preview for conversation-and-files rewind.
5578    ///
5579    /// # Returns
5580    ///
5581    /// Files and aggregate changes for a prospective rewind.
5582    ///
5583    /// <div class="warning">
5584    ///
5585    /// **Experimental.** This API is part of an experimental wire-protocol surface
5586    /// and may change or be removed in future SDK or CLI releases. Pin both the
5587    /// SDK and CLI versions if your code depends on it.
5588    ///
5589    /// </div>
5590    pub async fn preview_rewind(
5591        &self,
5592        params: HistoryPreviewRewindRequest,
5593    ) -> Result<HistoryPreviewRewindResult, Error> {
5594        let mut wire_params = serde_json::to_value(params)?;
5595        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5596        let _value = self
5597            .session
5598            .client()
5599            .call(
5600                rpc_methods::SESSION_HISTORY_PREVIEWREWIND,
5601                Some(wire_params),
5602            )
5603            .await?;
5604        Ok(serde_json::from_value(_value)?)
5605    }
5606
5607    /// Rewinds the session conversation, optionally restoring files changed by the discarded turns. Not crash-atomic: file restore and conversation truncation are separate stores, applied in that order, so a process crash between them can leave the workspace rewound while the conversation still contains the discarded turns. There is no recovery journal; re-running the same rewind is the recovery path for a crash before truncation lands, since file restore is idempotent (already-restored files are reported as skipped) and truncation is re-derived from the still-retained boundary event. After truncation lands that boundary no longer exists, so the same request is rejected; the only stage that can still be outstanding is snapshot pruning, whose failure leaves orphan snapshots the capture store tolerates. The reverse inconsistency cannot occur, because truncation is never applied before file restore succeeds.
5608    ///
5609    /// Wire method: `session.history.rewind`.
5610    ///
5611    /// # Parameters
5612    ///
5613    /// * `params` - Boundary and mode for rewinding session history.
5614    ///
5615    /// # Returns
5616    ///
5617    /// Structured outcome of a rewind request.
5618    ///
5619    /// <div class="warning">
5620    ///
5621    /// **Experimental.** This API is part of an experimental wire-protocol surface
5622    /// and may change or be removed in future SDK or CLI releases. Pin both the
5623    /// SDK and CLI versions if your code depends on it.
5624    ///
5625    /// </div>
5626    pub async fn rewind(&self, params: HistoryRewindRequest) -> Result<HistoryRewindResult, Error> {
5627        let mut wire_params = serde_json::to_value(params)?;
5628        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5629        let _value = self
5630            .session
5631            .client()
5632            .call(rpc_methods::SESSION_HISTORY_REWIND, Some(wire_params))
5633            .await?;
5634        Ok(serde_json::from_value(_value)?)
5635    }
5636
5637    /// Cancels any in-progress background compaction on a local session.
5638    ///
5639    /// Wire method: `session.history.cancelBackgroundCompaction`.
5640    ///
5641    /// # Returns
5642    ///
5643    /// Indicates whether an in-progress background compaction was cancelled.
5644    ///
5645    /// <div class="warning">
5646    ///
5647    /// **Experimental.** This API is part of an experimental wire-protocol surface
5648    /// and may change or be removed in future SDK or CLI releases. Pin both the
5649    /// SDK and CLI versions if your code depends on it.
5650    ///
5651    /// </div>
5652    pub async fn cancel_background_compaction(
5653        &self,
5654    ) -> Result<HistoryCancelBackgroundCompactionResult, Error> {
5655        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5656        let _value = self
5657            .session
5658            .client()
5659            .call(
5660                rpc_methods::SESSION_HISTORY_CANCELBACKGROUNDCOMPACTION,
5661                Some(wire_params),
5662            )
5663            .await?;
5664        Ok(serde_json::from_value(_value)?)
5665    }
5666
5667    /// Aborts any in-progress manual compaction on a local session.
5668    ///
5669    /// Wire method: `session.history.abortManualCompaction`.
5670    ///
5671    /// # Returns
5672    ///
5673    /// Indicates whether an in-progress manual compaction was aborted.
5674    ///
5675    /// <div class="warning">
5676    ///
5677    /// **Experimental.** This API is part of an experimental wire-protocol surface
5678    /// and may change or be removed in future SDK or CLI releases. Pin both the
5679    /// SDK and CLI versions if your code depends on it.
5680    ///
5681    /// </div>
5682    pub async fn abort_manual_compaction(
5683        &self,
5684    ) -> Result<HistoryAbortManualCompactionResult, Error> {
5685        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5686        let _value = self
5687            .session
5688            .client()
5689            .call(
5690                rpc_methods::SESSION_HISTORY_ABORTMANUALCOMPACTION,
5691                Some(wire_params),
5692            )
5693            .await?;
5694        Ok(serde_json::from_value(_value)?)
5695    }
5696
5697    /// Produces a markdown summary of the session's conversation context for hand-off scenarios.
5698    ///
5699    /// Wire method: `session.history.summarizeForHandoff`.
5700    ///
5701    /// # Returns
5702    ///
5703    /// Markdown summary of the conversation context (empty when not available).
5704    ///
5705    /// <div class="warning">
5706    ///
5707    /// **Experimental.** This API is part of an experimental wire-protocol surface
5708    /// and may change or be removed in future SDK or CLI releases. Pin both the
5709    /// SDK and CLI versions if your code depends on it.
5710    ///
5711    /// </div>
5712    pub async fn summarize_for_handoff(&self) -> Result<HistorySummarizeForHandoffResult, Error> {
5713        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5714        let _value = self
5715            .session
5716            .client()
5717            .call(
5718                rpc_methods::SESSION_HISTORY_SUMMARIZEFORHANDOFF,
5719                Some(wire_params),
5720            )
5721            .await?;
5722        Ok(serde_json::from_value(_value)?)
5723    }
5724
5725    /// Clears the session's conversation history, keeping only system and developer messages, and seeds the fresh context window with a first user message. Must be called from inside a tool handler: the clear has to drop the results of the tool calls its wipe orphans, and it rejects when no tool call is in flight.
5726    ///
5727    /// Wire method: `session.history.clearContext`.
5728    ///
5729    /// # Parameters
5730    ///
5731    /// * `params` - Parameters for clearing the conversation and seeding the window that replaces it.
5732    ///
5733    /// # Returns
5734    ///
5735    /// What a successful clear removed. A clear that could not be applied rejects instead of reporting a count.
5736    ///
5737    /// <div class="warning">
5738    ///
5739    /// **Experimental.** This API is part of an experimental wire-protocol surface
5740    /// and may change or be removed in future SDK or CLI releases. Pin both the
5741    /// SDK and CLI versions if your code depends on it.
5742    ///
5743    /// </div>
5744    pub async fn clear_context(
5745        &self,
5746        params: HistoryClearContextRequest,
5747    ) -> Result<HistoryClearContextResult, Error> {
5748        let mut wire_params = serde_json::to_value(params)?;
5749        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5750        let _value = self
5751            .session
5752            .client()
5753            .call(rpc_methods::SESSION_HISTORY_CLEARCONTEXT, Some(wire_params))
5754            .await?;
5755        Ok(serde_json::from_value(_value)?)
5756    }
5757}
5758
5759/// `session.instructions.*` RPCs.
5760#[derive(Clone, Copy)]
5761pub struct SessionRpcInstructions<'a> {
5762    pub(crate) session: &'a Session,
5763}
5764
5765impl<'a> SessionRpcInstructions<'a> {
5766    /// Gets instruction sources loaded for the session.
5767    ///
5768    /// Wire method: `session.instructions.getSources`.
5769    ///
5770    /// # Returns
5771    ///
5772    /// Instruction sources loaded for the session, in merge order.
5773    ///
5774    /// <div class="warning">
5775    ///
5776    /// **Experimental.** This API is part of an experimental wire-protocol surface
5777    /// and may change or be removed in future SDK or CLI releases. Pin both the
5778    /// SDK and CLI versions if your code depends on it.
5779    ///
5780    /// </div>
5781    pub async fn get_sources(&self) -> Result<InstructionsGetSourcesResult, Error> {
5782        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5783        let _value = self
5784            .session
5785            .client()
5786            .call(
5787                rpc_methods::SESSION_INSTRUCTIONS_GETSOURCES,
5788                Some(wire_params),
5789            )
5790            .await?;
5791        Ok(serde_json::from_value(_value)?)
5792    }
5793}
5794
5795/// `session.limitPrediction.*` RPCs.
5796#[derive(Clone, Copy)]
5797pub struct SessionRpcLimitPrediction<'a> {
5798    pub(crate) session: &'a Session,
5799}
5800
5801impl<'a> SessionRpcLimitPrediction<'a> {
5802    /// Predicts an AI-credit session limit for the session's resolved model. Returns an unavailable result instead of falling back when the current model is unresolved auto.
5803    ///
5804    /// Wire method: `session.limitPrediction.predict`.
5805    ///
5806    /// # Returns
5807    ///
5808    /// Prediction result. Available results include prediction details; unavailable results include an explicit reason.
5809    ///
5810    /// <div class="warning">
5811    ///
5812    /// **Experimental.** This API is part of an experimental wire-protocol surface
5813    /// and may change or be removed in future SDK or CLI releases. Pin both the
5814    /// SDK and CLI versions if your code depends on it.
5815    ///
5816    /// </div>
5817    pub async fn predict(&self) -> Result<SessionLimitPredictionResult, Error> {
5818        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5819        let _value = self
5820            .session
5821            .client()
5822            .call(
5823                rpc_methods::SESSION_LIMITPREDICTION_PREDICT,
5824                Some(wire_params),
5825            )
5826            .await?;
5827        Ok(serde_json::from_value(_value)?)
5828    }
5829
5830    /// Predicts an AI-credit session limit for the session's resolved model. Returns an unavailable result instead of falling back when the current model is unresolved auto.
5831    ///
5832    /// Wire method: `session.limitPrediction.predict`.
5833    ///
5834    /// # Parameters
5835    ///
5836    /// * `params` - Parameters for predicting an AI-credit session limit. Omitting `modelId` uses the session's currently selected model.
5837    ///
5838    /// # Returns
5839    ///
5840    /// Prediction result. Available results include prediction details; unavailable results include an explicit reason.
5841    ///
5842    /// <div class="warning">
5843    ///
5844    /// **Experimental.** This API is part of an experimental wire-protocol surface
5845    /// and may change or be removed in future SDK or CLI releases. Pin both the
5846    /// SDK and CLI versions if your code depends on it.
5847    ///
5848    /// </div>
5849    pub async fn predict_with_params(
5850        &self,
5851        params: SessionLimitPredictionRequest,
5852    ) -> Result<SessionLimitPredictionResult, Error> {
5853        let mut wire_params = serde_json::to_value(params)?;
5854        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5855        let _value = self
5856            .session
5857            .client()
5858            .call(
5859                rpc_methods::SESSION_LIMITPREDICTION_PREDICT,
5860                Some(wire_params),
5861            )
5862            .await?;
5863        Ok(serde_json::from_value(_value)?)
5864    }
5865}
5866
5867/// `session.lsp.*` RPCs.
5868#[derive(Clone, Copy)]
5869pub struct SessionRpcLsp<'a> {
5870    pub(crate) session: &'a Session,
5871}
5872
5873impl<'a> SessionRpcLsp<'a> {
5874    /// Loads the merged LSP configuration set for the session's working directory.
5875    ///
5876    /// Wire method: `session.lsp.initialize`.
5877    ///
5878    /// # Parameters
5879    ///
5880    /// * `params` - Parameters for (re)loading the merged LSP configuration set.
5881    ///
5882    /// <div class="warning">
5883    ///
5884    /// **Experimental.** This API is part of an experimental wire-protocol surface
5885    /// and may change or be removed in future SDK or CLI releases. Pin both the
5886    /// SDK and CLI versions if your code depends on it.
5887    ///
5888    /// </div>
5889    pub async fn initialize(&self, params: LspInitializeRequest) -> Result<(), Error> {
5890        let mut wire_params = serde_json::to_value(params)?;
5891        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5892        let _value = self
5893            .session
5894            .client()
5895            .call(rpc_methods::SESSION_LSP_INITIALIZE, Some(wire_params))
5896            .await?;
5897        Ok(())
5898    }
5899}
5900
5901/// `session.mcp.*` RPCs.
5902#[derive(Clone, Copy)]
5903pub struct SessionRpcMcp<'a> {
5904    pub(crate) session: &'a Session,
5905}
5906
5907impl<'a> SessionRpcMcp<'a> {
5908    /// `session.mcp.apps.*` sub-namespace.
5909    pub fn apps(&self) -> SessionRpcMcpApps<'a> {
5910        SessionRpcMcpApps {
5911            session: self.session,
5912        }
5913    }
5914
5915    /// `session.mcp.headers.*` sub-namespace.
5916    pub fn headers(&self) -> SessionRpcMcpHeaders<'a> {
5917        SessionRpcMcpHeaders {
5918            session: self.session,
5919        }
5920    }
5921
5922    /// `session.mcp.oauth.*` sub-namespace.
5923    pub fn oauth(&self) -> SessionRpcMcpOauth<'a> {
5924        SessionRpcMcpOauth {
5925            session: self.session,
5926        }
5927    }
5928
5929    /// `session.mcp.resources.*` sub-namespace.
5930    pub fn resources(&self) -> SessionRpcMcpResources<'a> {
5931        SessionRpcMcpResources {
5932            session: self.session,
5933        }
5934    }
5935
5936    /// 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.
5937    ///
5938    /// Wire method: `session.mcp.list`.
5939    ///
5940    /// # Returns
5941    ///
5942    /// MCP servers configured for the session, with their connection status and host-level state.
5943    ///
5944    /// <div class="warning">
5945    ///
5946    /// **Experimental.** This API is part of an experimental wire-protocol surface
5947    /// and may change or be removed in future SDK or CLI releases. Pin both the
5948    /// SDK and CLI versions if your code depends on it.
5949    ///
5950    /// </div>
5951    pub async fn list(&self) -> Result<McpServerList, Error> {
5952        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5953        let _value = self
5954            .session
5955            .client()
5956            .call(rpc_methods::SESSION_MCP_LIST, Some(wire_params))
5957            .await?;
5958        Ok(serde_json::from_value(_value)?)
5959    }
5960
5961    /// Lists the tools exposed by a connected MCP server on this session's host. This performs a live `tools/list` request. Tool UI metadata is returned independently of whether MCP Apps rendering is enabled for the session.
5962    ///
5963    /// Wire method: `session.mcp.listTools`.
5964    ///
5965    /// # Parameters
5966    ///
5967    /// * `params` - Server name whose tool list should be returned.
5968    ///
5969    /// # Returns
5970    ///
5971    /// Tools exposed by the connected MCP server. Throws when the server is not connected.
5972    ///
5973    /// <div class="warning">
5974    ///
5975    /// **Experimental.** This API is part of an experimental wire-protocol surface
5976    /// and may change or be removed in future SDK or CLI releases. Pin both the
5977    /// SDK and CLI versions if your code depends on it.
5978    ///
5979    /// </div>
5980    pub async fn list_tools(
5981        &self,
5982        params: McpListToolsRequest,
5983    ) -> Result<McpListToolsResult, Error> {
5984        let mut wire_params = serde_json::to_value(params)?;
5985        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5986        let _value = self
5987            .session
5988            .client()
5989            .call(rpc_methods::SESSION_MCP_LISTTOOLS, Some(wire_params))
5990            .await?;
5991        Ok(serde_json::from_value(_value)?)
5992    }
5993
5994    /// Enables an MCP server for the session.
5995    ///
5996    /// Wire method: `session.mcp.enable`.
5997    ///
5998    /// # Parameters
5999    ///
6000    /// * `params` - Name of the MCP server to enable for the session.
6001    ///
6002    /// <div class="warning">
6003    ///
6004    /// **Experimental.** This API is part of an experimental wire-protocol surface
6005    /// and may change or be removed in future SDK or CLI releases. Pin both the
6006    /// SDK and CLI versions if your code depends on it.
6007    ///
6008    /// </div>
6009    pub async fn enable(&self, params: McpEnableRequest) -> Result<(), Error> {
6010        let mut wire_params = serde_json::to_value(params)?;
6011        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6012        let _value = self
6013            .session
6014            .client()
6015            .call(rpc_methods::SESSION_MCP_ENABLE, Some(wire_params))
6016            .await?;
6017        Ok(())
6018    }
6019
6020    /// Disables an MCP server for the session.
6021    ///
6022    /// Wire method: `session.mcp.disable`.
6023    ///
6024    /// # Parameters
6025    ///
6026    /// * `params` - Name of the MCP server to disable for the session.
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 disable(&self, params: McpDisableRequest) -> Result<(), Error> {
6036        let mut wire_params = serde_json::to_value(params)?;
6037        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6038        let _value = self
6039            .session
6040            .client()
6041            .call(rpc_methods::SESSION_MCP_DISABLE, Some(wire_params))
6042            .await?;
6043        Ok(())
6044    }
6045
6046    /// Reloads MCP server connections for the session.
6047    ///
6048    /// Wire method: `session.mcp.reload`.
6049    ///
6050    /// <div class="warning">
6051    ///
6052    /// **Experimental.** This API is part of an experimental wire-protocol surface
6053    /// and may change or be removed in future SDK or CLI releases. Pin both the
6054    /// SDK and CLI versions if your code depends on it.
6055    ///
6056    /// </div>
6057    pub async fn reload(&self) -> Result<(), Error> {
6058        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6059        let _value = self
6060            .session
6061            .client()
6062            .call(rpc_methods::SESSION_MCP_RELOAD, Some(wire_params))
6063            .await?;
6064        Ok(())
6065    }
6066
6067    /// Releases any turns waiting on an in-flight MCP load without cancelling the load, letting the agent proceed while MCP servers finish connecting in the background. No-op when no MCP load is in flight or waiting turns were already released.
6068    ///
6069    /// Wire method: `session.mcp.moveLoadingToBackground`.
6070    ///
6071    /// # Returns
6072    ///
6073    /// Result of moving in-flight MCP loading to the background.
6074    ///
6075    /// <div class="warning">
6076    ///
6077    /// **Experimental.** This API is part of an experimental wire-protocol surface
6078    /// and may change or be removed in future SDK or CLI releases. Pin both the
6079    /// SDK and CLI versions if your code depends on it.
6080    ///
6081    /// </div>
6082    pub async fn move_loading_to_background(
6083        &self,
6084    ) -> Result<MoveMcpLoadingToBackgroundResult, Error> {
6085        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6086        let _value = self
6087            .session
6088            .client()
6089            .call(
6090                rpc_methods::SESSION_MCP_MOVELOADINGTOBACKGROUND,
6091                Some(wire_params),
6092            )
6093            .await?;
6094        Ok(serde_json::from_value(_value)?)
6095    }
6096
6097    /// Reloads MCP server connections for the session with an explicit host-provided configuration.
6098    ///
6099    /// Wire method: `session.mcp.reloadWithConfig`.
6100    ///
6101    /// # Parameters
6102    ///
6103    /// * `params` - Opaque MCP reload configuration.
6104    ///
6105    /// # Returns
6106    ///
6107    /// MCP server startup filtering result.
6108    ///
6109    /// <div class="warning">
6110    ///
6111    /// **Experimental.** This API is part of an experimental wire-protocol surface
6112    /// and may change or be removed in future SDK or CLI releases. Pin both the
6113    /// SDK and CLI versions if your code depends on it.
6114    ///
6115    /// </div>
6116    pub(crate) async fn reload_with_config(
6117        &self,
6118        params: McpReloadWithConfigRequest,
6119    ) -> Result<McpStartServersResult, Error> {
6120        let mut wire_params = serde_json::to_value(params)?;
6121        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6122        let _value = self
6123            .session
6124            .client()
6125            .call(rpc_methods::SESSION_MCP_RELOADWITHCONFIG, Some(wire_params))
6126            .await?;
6127        Ok(serde_json::from_value(_value)?)
6128    }
6129
6130    /// Runs an MCP sampling inference on behalf of an MCP server.
6131    ///
6132    /// Wire method: `session.mcp.executeSampling`.
6133    ///
6134    /// # Parameters
6135    ///
6136    /// * `params` - Identifiers and raw MCP CreateMessageRequest params used to run a sampling inference.
6137    ///
6138    /// # Returns
6139    ///
6140    /// Outcome of an MCP sampling execution: success result, failure error, or cancellation.
6141    ///
6142    /// <div class="warning">
6143    ///
6144    /// **Experimental.** This API is part of an experimental wire-protocol surface
6145    /// and may change or be removed in future SDK or CLI releases. Pin both the
6146    /// SDK and CLI versions if your code depends on it.
6147    ///
6148    /// </div>
6149    pub async fn execute_sampling(
6150        &self,
6151        params: McpExecuteSamplingParams,
6152    ) -> Result<McpSamplingExecutionResult, Error> {
6153        let mut wire_params = serde_json::to_value(params)?;
6154        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6155        let _value = self
6156            .session
6157            .client()
6158            .call(rpc_methods::SESSION_MCP_EXECUTESAMPLING, Some(wire_params))
6159            .await?;
6160        Ok(serde_json::from_value(_value)?)
6161    }
6162
6163    /// Cancels an in-flight MCP sampling execution by request ID.
6164    ///
6165    /// Wire method: `session.mcp.cancelSamplingExecution`.
6166    ///
6167    /// # Parameters
6168    ///
6169    /// * `params` - The requestId previously passed to executeSampling that should be cancelled.
6170    ///
6171    /// # Returns
6172    ///
6173    /// Indicates whether an in-flight sampling execution with the given requestId was found and cancelled.
6174    ///
6175    /// <div class="warning">
6176    ///
6177    /// **Experimental.** This API is part of an experimental wire-protocol surface
6178    /// and may change or be removed in future SDK or CLI releases. Pin both the
6179    /// SDK and CLI versions if your code depends on it.
6180    ///
6181    /// </div>
6182    pub async fn cancel_sampling_execution(
6183        &self,
6184        params: McpCancelSamplingExecutionParams,
6185    ) -> Result<McpCancelSamplingExecutionResult, Error> {
6186        let mut wire_params = serde_json::to_value(params)?;
6187        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6188        let _value = self
6189            .session
6190            .client()
6191            .call(
6192                rpc_methods::SESSION_MCP_CANCELSAMPLINGEXECUTION,
6193                Some(wire_params),
6194            )
6195            .await?;
6196        Ok(serde_json::from_value(_value)?)
6197    }
6198
6199    /// Sets how environment-variable values supplied to MCP servers are resolved (direct or indirect).
6200    ///
6201    /// Wire method: `session.mcp.setEnvValueMode`.
6202    ///
6203    /// # Parameters
6204    ///
6205    /// * `params` - Mode controlling how MCP server env values are resolved (`direct` or `indirect`).
6206    ///
6207    /// # Returns
6208    ///
6209    /// Env-value mode recorded on the session after the update.
6210    ///
6211    /// <div class="warning">
6212    ///
6213    /// **Experimental.** This API is part of an experimental wire-protocol surface
6214    /// and may change or be removed in future SDK or CLI releases. Pin both the
6215    /// SDK and CLI versions if your code depends on it.
6216    ///
6217    /// </div>
6218    pub async fn set_env_value_mode(
6219        &self,
6220        params: McpSetEnvValueModeParams,
6221    ) -> Result<McpSetEnvValueModeResult, Error> {
6222        let mut wire_params = serde_json::to_value(params)?;
6223        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6224        let _value = self
6225            .session
6226            .client()
6227            .call(rpc_methods::SESSION_MCP_SETENVVALUEMODE, Some(wire_params))
6228            .await?;
6229        Ok(serde_json::from_value(_value)?)
6230    }
6231
6232    /// Removes the auto-managed `github` MCP server when present.
6233    ///
6234    /// Wire method: `session.mcp.removeGitHub`.
6235    ///
6236    /// # Returns
6237    ///
6238    /// Indicates whether the auto-managed `github` MCP server was removed (false when nothing to remove).
6239    ///
6240    /// <div class="warning">
6241    ///
6242    /// **Experimental.** This API is part of an experimental wire-protocol surface
6243    /// and may change or be removed in future SDK or CLI releases. Pin both the
6244    /// SDK and CLI versions if your code depends on it.
6245    ///
6246    /// </div>
6247    pub async fn remove_git_hub(&self) -> Result<McpRemoveGitHubResult, Error> {
6248        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6249        let _value = self
6250            .session
6251            .client()
6252            .call(rpc_methods::SESSION_MCP_REMOVEGITHUB, Some(wire_params))
6253            .await?;
6254        Ok(serde_json::from_value(_value)?)
6255    }
6256
6257    /// Configures the built-in GitHub MCP server for the session's current auth context.
6258    ///
6259    /// Wire method: `session.mcp.configureGitHub`.
6260    ///
6261    /// # Parameters
6262    ///
6263    /// * `params` - Credential-free authentication identity used to configure GitHub MCP.
6264    ///
6265    /// # Returns
6266    ///
6267    /// Result of configuring GitHub MCP.
6268    ///
6269    /// <div class="warning">
6270    ///
6271    /// **Experimental.** This API is part of an experimental wire-protocol surface
6272    /// and may change or be removed in future SDK or CLI releases. Pin both the
6273    /// SDK and CLI versions if your code depends on it.
6274    ///
6275    /// </div>
6276    pub(crate) async fn configure_git_hub(
6277        &self,
6278        params: McpConfigureGitHubRequest,
6279    ) -> Result<McpConfigureGitHubResult, Error> {
6280        let mut wire_params = serde_json::to_value(params)?;
6281        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6282        let _value = self
6283            .session
6284            .client()
6285            .call(rpc_methods::SESSION_MCP_CONFIGUREGITHUB, Some(wire_params))
6286            .await?;
6287        Ok(serde_json::from_value(_value)?)
6288    }
6289
6290    /// Starts an individual MCP server on the live session. Omit `config` for a config-free start-by-name of an already-configured server (reuses the server's already-registered configuration); supply `config` to start from a caller-supplied configuration. 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.
6291    ///
6292    /// Wire method: `session.mcp.startServer`.
6293    ///
6294    /// # Parameters
6295    ///
6296    /// * `params` - Server name and optional configuration for an individual MCP server start. Omit `config` for a config-free start-by-name of an already-configured server.
6297    ///
6298    /// <div class="warning">
6299    ///
6300    /// **Experimental.** This API is part of an experimental wire-protocol surface
6301    /// and may change or be removed in future SDK or CLI releases. Pin both the
6302    /// SDK and CLI versions if your code depends on it.
6303    ///
6304    /// </div>
6305    pub async fn start_server(&self, params: McpStartServerRequest) -> Result<(), Error> {
6306        let mut wire_params = serde_json::to_value(params)?;
6307        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6308        let _value = self
6309            .session
6310            .client()
6311            .call(rpc_methods::SESSION_MCP_STARTSERVER, Some(wire_params))
6312            .await?;
6313        Ok(())
6314    }
6315
6316    /// 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.*`).
6317    ///
6318    /// Wire method: `session.mcp.restartServer`.
6319    ///
6320    /// # Parameters
6321    ///
6322    /// * `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.
6323    ///
6324    /// <div class="warning">
6325    ///
6326    /// **Experimental.** This API is part of an experimental wire-protocol surface
6327    /// and may change or be removed in future SDK or CLI releases. Pin both the
6328    /// SDK and CLI versions if your code depends on it.
6329    ///
6330    /// </div>
6331    pub async fn restart_server(&self, params: McpRestartServerRequest) -> Result<(), Error> {
6332        let mut wire_params = serde_json::to_value(params)?;
6333        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6334        let _value = self
6335            .session
6336            .client()
6337            .call(rpc_methods::SESSION_MCP_RESTARTSERVER, Some(wire_params))
6338            .await?;
6339        Ok(())
6340    }
6341
6342    /// Stops an individual MCP server on the session's host.
6343    ///
6344    /// Wire method: `session.mcp.stopServer`.
6345    ///
6346    /// # Parameters
6347    ///
6348    /// * `params` - Server name for an individual MCP server stop.
6349    ///
6350    /// <div class="warning">
6351    ///
6352    /// **Experimental.** This API is part of an experimental wire-protocol surface
6353    /// and may change or be removed in future SDK or CLI releases. Pin both the
6354    /// SDK and CLI versions if your code depends on it.
6355    ///
6356    /// </div>
6357    pub async fn stop_server(&self, params: McpStopServerRequest) -> Result<(), Error> {
6358        let mut wire_params = serde_json::to_value(params)?;
6359        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6360        let _value = self
6361            .session
6362            .client()
6363            .call(rpc_methods::SESSION_MCP_STOPSERVER, Some(wire_params))
6364            .await?;
6365        Ok(())
6366    }
6367
6368    /// 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.
6369    ///
6370    /// Wire method: `session.mcp.registerExternalClient`.
6371    ///
6372    /// # Parameters
6373    ///
6374    /// * `params` - Registration parameters for an external MCP client.
6375    ///
6376    /// <div class="warning">
6377    ///
6378    /// **Experimental.** This API is part of an experimental wire-protocol surface
6379    /// and may change or be removed in future SDK or CLI releases. Pin both the
6380    /// SDK and CLI versions if your code depends on it.
6381    ///
6382    /// </div>
6383    pub(crate) async fn register_external_client(
6384        &self,
6385        params: McpRegisterExternalClientRequest,
6386    ) -> Result<(), Error> {
6387        let mut wire_params = serde_json::to_value(params)?;
6388        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6389        let _value = self
6390            .session
6391            .client()
6392            .call(
6393                rpc_methods::SESSION_MCP_REGISTEREXTERNALCLIENT,
6394                Some(wire_params),
6395            )
6396            .await?;
6397        Ok(())
6398    }
6399
6400    /// 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.
6401    ///
6402    /// Wire method: `session.mcp.unregisterExternalClient`.
6403    ///
6404    /// # Parameters
6405    ///
6406    /// * `params` - Server name identifying the external client to remove.
6407    ///
6408    /// <div class="warning">
6409    ///
6410    /// **Experimental.** This API is part of an experimental wire-protocol surface
6411    /// and may change or be removed in future SDK or CLI releases. Pin both the
6412    /// SDK and CLI versions if your code depends on it.
6413    ///
6414    /// </div>
6415    pub(crate) async fn unregister_external_client(
6416        &self,
6417        params: McpUnregisterExternalClientRequest,
6418    ) -> Result<(), Error> {
6419        let mut wire_params = serde_json::to_value(params)?;
6420        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6421        let _value = self
6422            .session
6423            .client()
6424            .call(
6425                rpc_methods::SESSION_MCP_UNREGISTEREXTERNALCLIENT,
6426                Some(wire_params),
6427            )
6428            .await?;
6429        Ok(())
6430    }
6431
6432    /// Checks whether a named MCP server is currently running on the session's host.
6433    ///
6434    /// Wire method: `session.mcp.isServerRunning`.
6435    ///
6436    /// # Parameters
6437    ///
6438    /// * `params` - Server name to check running status for.
6439    ///
6440    /// # Returns
6441    ///
6442    /// Whether the named MCP server is running.
6443    ///
6444    /// <div class="warning">
6445    ///
6446    /// **Experimental.** This API is part of an experimental wire-protocol surface
6447    /// and may change or be removed in future SDK or CLI releases. Pin both the
6448    /// SDK and CLI versions if your code depends on it.
6449    ///
6450    /// </div>
6451    pub async fn is_server_running(
6452        &self,
6453        params: McpIsServerRunningRequest,
6454    ) -> Result<McpIsServerRunningResult, Error> {
6455        let mut wire_params = serde_json::to_value(params)?;
6456        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6457        let _value = self
6458            .session
6459            .client()
6460            .call(rpc_methods::SESSION_MCP_ISSERVERRUNNING, Some(wire_params))
6461            .await?;
6462        Ok(serde_json::from_value(_value)?)
6463    }
6464}
6465
6466/// `session.mcp.apps.*` RPCs.
6467#[derive(Clone, Copy)]
6468pub struct SessionRpcMcpApps<'a> {
6469    pub(crate) session: &'a Session,
6470}
6471
6472impl<'a> SessionRpcMcpApps<'a> {
6473    /// Fetch an MCP resource (typically a `ui://` MCP App bundle, per SEP-1865) from a connected server. Requires the `mcp-apps` session capability.
6474    ///
6475    /// Wire method: `session.mcp.apps.readResource`.
6476    ///
6477    /// # Parameters
6478    ///
6479    /// * `params` - MCP server and resource URI to fetch.
6480    ///
6481    /// # Returns
6482    ///
6483    /// Resource contents returned by the MCP server.
6484    ///
6485    /// <div class="warning">
6486    ///
6487    /// **Experimental.** This API is part of an experimental wire-protocol surface
6488    /// and may change or be removed in future SDK or CLI releases. Pin both the
6489    /// SDK and CLI versions if your code depends on it.
6490    ///
6491    /// </div>
6492    pub async fn read_resource(
6493        &self,
6494        params: McpAppsReadResourceRequest,
6495    ) -> Result<McpAppsReadResourceResult, Error> {
6496        let mut wire_params = serde_json::to_value(params)?;
6497        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6498        let _value = self
6499            .session
6500            .client()
6501            .call(
6502                rpc_methods::SESSION_MCP_APPS_READRESOURCE,
6503                Some(wire_params),
6504            )
6505            .await?;
6506        Ok(serde_json::from_value(_value)?)
6507    }
6508
6509    /// 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"`.
6510    ///
6511    /// Wire method: `session.mcp.apps.listTools`.
6512    ///
6513    /// # Parameters
6514    ///
6515    /// * `params` - MCP server to list app-callable tools for.
6516    ///
6517    /// # Returns
6518    ///
6519    /// App-callable tools from the named MCP server.
6520    ///
6521    /// <div class="warning">
6522    ///
6523    /// **Experimental.** This API is part of an experimental wire-protocol surface
6524    /// and may change or be removed in future SDK or CLI releases. Pin both the
6525    /// SDK and CLI versions if your code depends on it.
6526    ///
6527    /// </div>
6528    pub async fn list_tools(
6529        &self,
6530        params: McpAppsListToolsRequest,
6531    ) -> Result<McpAppsListToolsResult, Error> {
6532        let mut wire_params = serde_json::to_value(params)?;
6533        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6534        let _value = self
6535            .session
6536            .client()
6537            .call(rpc_methods::SESSION_MCP_APPS_LISTTOOLS, Some(wire_params))
6538            .await?;
6539        Ok(serde_json::from_value(_value)?)
6540    }
6541
6542    /// 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`.
6543    ///
6544    /// Wire method: `session.mcp.apps.callTool`.
6545    ///
6546    /// # Parameters
6547    ///
6548    /// * `params` - MCP server, tool name, and arguments to invoke from an MCP App view.
6549    ///
6550    /// # Returns
6551    ///
6552    /// Standard MCP CallToolResult
6553    ///
6554    /// <div class="warning">
6555    ///
6556    /// **Experimental.** This API is part of an experimental wire-protocol surface
6557    /// and may change or be removed in future SDK or CLI releases. Pin both the
6558    /// SDK and CLI versions if your code depends on it.
6559    ///
6560    /// </div>
6561    pub async fn call_tool(
6562        &self,
6563        params: McpAppsCallToolRequest,
6564    ) -> Result<SessionMcpAppsCallToolResult, Error> {
6565        let mut wire_params = serde_json::to_value(params)?;
6566        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6567        let _value = self
6568            .session
6569            .client()
6570            .call(rpc_methods::SESSION_MCP_APPS_CALLTOOL, Some(wire_params))
6571            .await?;
6572        Ok(serde_json::from_value(_value)?)
6573    }
6574
6575    /// 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.
6576    ///
6577    /// Wire method: `session.mcp.apps.setHostContext`.
6578    ///
6579    /// # Parameters
6580    ///
6581    /// * `params` - Host context to advertise to MCP App guests.
6582    ///
6583    /// <div class="warning">
6584    ///
6585    /// **Experimental.** This API is part of an experimental wire-protocol surface
6586    /// and may change or be removed in future SDK or CLI releases. Pin both the
6587    /// SDK and CLI versions if your code depends on it.
6588    ///
6589    /// </div>
6590    pub async fn set_host_context(
6591        &self,
6592        params: McpAppsSetHostContextRequest,
6593    ) -> Result<(), Error> {
6594        let mut wire_params = serde_json::to_value(params)?;
6595        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6596        let _value = self
6597            .session
6598            .client()
6599            .call(
6600                rpc_methods::SESSION_MCP_APPS_SETHOSTCONTEXT,
6601                Some(wire_params),
6602            )
6603            .await?;
6604        Ok(())
6605    }
6606
6607    /// Read the current host context advertised to MCP App guests.
6608    ///
6609    /// Wire method: `session.mcp.apps.getHostContext`.
6610    ///
6611    /// # Returns
6612    ///
6613    /// Current host context advertised to MCP App guests.
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 get_host_context(&self) -> Result<McpAppsHostContext, Error> {
6623        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6624        let _value = self
6625            .session
6626            .client()
6627            .call(
6628                rpc_methods::SESSION_MCP_APPS_GETHOSTCONTEXT,
6629                Some(wire_params),
6630            )
6631            .await?;
6632        Ok(serde_json::from_value(_value)?)
6633    }
6634
6635    /// 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.
6636    ///
6637    /// Wire method: `session.mcp.apps.diagnose`.
6638    ///
6639    /// # Parameters
6640    ///
6641    /// * `params` - MCP server to diagnose MCP Apps wiring for.
6642    ///
6643    /// # Returns
6644    ///
6645    /// Diagnostic snapshot of MCP Apps wiring for the named server.
6646    ///
6647    /// <div class="warning">
6648    ///
6649    /// **Experimental.** This API is part of an experimental wire-protocol surface
6650    /// and may change or be removed in future SDK or CLI releases. Pin both the
6651    /// SDK and CLI versions if your code depends on it.
6652    ///
6653    /// </div>
6654    pub async fn diagnose(
6655        &self,
6656        params: McpAppsDiagnoseRequest,
6657    ) -> Result<McpAppsDiagnoseResult, Error> {
6658        let mut wire_params = serde_json::to_value(params)?;
6659        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6660        let _value = self
6661            .session
6662            .client()
6663            .call(rpc_methods::SESSION_MCP_APPS_DIAGNOSE, Some(wire_params))
6664            .await?;
6665        Ok(serde_json::from_value(_value)?)
6666    }
6667}
6668
6669/// `session.mcp.headers.*` RPCs.
6670#[derive(Clone, Copy)]
6671pub struct SessionRpcMcpHeaders<'a> {
6672    pub(crate) session: &'a Session,
6673}
6674
6675impl<'a> SessionRpcMcpHeaders<'a> {
6676    /// 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.
6677    ///
6678    /// Wire method: `session.mcp.headers.handlePendingHeadersRefreshRequest`.
6679    ///
6680    /// # Parameters
6681    ///
6682    /// * `params` - MCP headers refresh request id and the host response.
6683    ///
6684    /// # Returns
6685    ///
6686    /// Indicates whether the pending MCP headers refresh response was accepted.
6687    ///
6688    /// <div class="warning">
6689    ///
6690    /// **Experimental.** This API is part of an experimental wire-protocol surface
6691    /// and may change or be removed in future SDK or CLI releases. Pin both the
6692    /// SDK and CLI versions if your code depends on it.
6693    ///
6694    /// </div>
6695    pub async fn handle_pending_headers_refresh_request(
6696        &self,
6697        params: McpHeadersHandlePendingHeadersRefreshRequestRequest,
6698    ) -> Result<McpHeadersHandlePendingHeadersRefreshRequestResult, Error> {
6699        let mut wire_params = serde_json::to_value(params)?;
6700        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6701        let _value = self
6702            .session
6703            .client()
6704            .call(
6705                rpc_methods::SESSION_MCP_HEADERS_HANDLEPENDINGHEADERSREFRESHREQUEST,
6706                Some(wire_params),
6707            )
6708            .await?;
6709        Ok(serde_json::from_value(_value)?)
6710    }
6711}
6712
6713/// `session.mcp.oauth.*` RPCs.
6714#[derive(Clone, Copy)]
6715pub struct SessionRpcMcpOauth<'a> {
6716    pub(crate) session: &'a Session,
6717}
6718
6719impl<'a> SessionRpcMcpOauth<'a> {
6720    /// 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.
6721    ///
6722    /// Wire method: `session.mcp.oauth.handlePendingRequest`.
6723    ///
6724    /// # Parameters
6725    ///
6726    /// * `params` - Pending MCP OAuth request ID and host-provided token or cancellation response.
6727    ///
6728    /// # Returns
6729    ///
6730    /// Indicates whether the pending MCP OAuth response was accepted.
6731    ///
6732    /// <div class="warning">
6733    ///
6734    /// **Experimental.** This API is part of an experimental wire-protocol surface
6735    /// and may change or be removed in future SDK or CLI releases. Pin both the
6736    /// SDK and CLI versions if your code depends on it.
6737    ///
6738    /// </div>
6739    pub async fn handle_pending_request(
6740        &self,
6741        params: McpOauthHandlePendingRequest,
6742    ) -> Result<McpOauthHandlePendingResult, Error> {
6743        let mut wire_params = serde_json::to_value(params)?;
6744        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6745        let _value = self
6746            .session
6747            .client()
6748            .call(
6749                rpc_methods::SESSION_MCP_OAUTH_HANDLEPENDINGREQUEST,
6750                Some(wire_params),
6751            )
6752            .await?;
6753        Ok(serde_json::from_value(_value)?)
6754    }
6755
6756    /// Notifies the session that MCP OAuth authentication succeeded and updated credentials were persisted, so cached tool definitions can be refreshed.
6757    ///
6758    /// Wire method: `session.mcp.oauth.authenticationStateChanged`.
6759    ///
6760    /// # Parameters
6761    ///
6762    /// * `params` - Identifies the MCP server whose persisted OAuth credentials were updated.
6763    ///
6764    /// <div class="warning">
6765    ///
6766    /// **Experimental.** This API is part of an experimental wire-protocol surface
6767    /// and may change or be removed in future SDK or CLI releases. Pin both the
6768    /// SDK and CLI versions if your code depends on it.
6769    ///
6770    /// </div>
6771    pub async fn authentication_state_changed(
6772        &self,
6773        params: McpOauthAuthenticationStateChangedRequest,
6774    ) -> Result<(), Error> {
6775        let mut wire_params = serde_json::to_value(params)?;
6776        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6777        let _value = self
6778            .session
6779            .client()
6780            .call(
6781                rpc_methods::SESSION_MCP_OAUTH_AUTHENTICATIONSTATECHANGED,
6782                Some(wire_params),
6783            )
6784            .await?;
6785        Ok(())
6786    }
6787
6788    /// Starts OAuth authentication for a remote MCP server.
6789    ///
6790    /// Wire method: `session.mcp.oauth.login`.
6791    ///
6792    /// # Parameters
6793    ///
6794    /// * `params` - Remote MCP server name and optional overrides controlling reauthentication, OAuth client display name, callback success-page copy, and static OAuth client selection.
6795    ///
6796    /// # Returns
6797    ///
6798    /// OAuth authorization URL the caller should open, or empty when cached tokens already authenticated the server.
6799    ///
6800    /// <div class="warning">
6801    ///
6802    /// **Experimental.** This API is part of an experimental wire-protocol surface
6803    /// and may change or be removed in future SDK or CLI releases. Pin both the
6804    /// SDK and CLI versions if your code depends on it.
6805    ///
6806    /// </div>
6807    pub async fn login(&self, params: McpOauthLoginRequest) -> Result<McpOauthLoginResult, Error> {
6808        let mut wire_params = serde_json::to_value(params)?;
6809        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6810        let _value = self
6811            .session
6812            .client()
6813            .call(rpc_methods::SESSION_MCP_OAUTH_LOGIN, Some(wire_params))
6814            .await?;
6815        Ok(serde_json::from_value(_value)?)
6816    }
6817
6818    /// Passively probes a configured remote MCP server to classify whether OAuth is required or a cached/override token is accepted. Does not start OAuth, emit pending OAuth requests, or mutate MCP connection state.
6819    ///
6820    /// Wire method: `session.mcp.oauth.probe`.
6821    ///
6822    /// # Parameters
6823    ///
6824    /// * `params` - Remote MCP server name for a passive OAuth status probe.
6825    ///
6826    /// # Returns
6827    ///
6828    /// Passive MCP OAuth probe result. `authenticated` means the server accepted the probe request while an OAuth-origin access token was attached; it does not prove the server required or independently validated that token. The probe does not make a second unauthenticated request. Failed is an expected probe-domain outcome; JSON-RPC errors are reserved for API-call failures.
6829    ///
6830    /// <div class="warning">
6831    ///
6832    /// **Experimental.** This API is part of an experimental wire-protocol surface
6833    /// and may change or be removed in future SDK or CLI releases. Pin both the
6834    /// SDK and CLI versions if your code depends on it.
6835    ///
6836    /// </div>
6837    pub async fn probe(&self, params: McpOauthProbeRequest) -> Result<McpOauthProbeResult, Error> {
6838        let mut wire_params = serde_json::to_value(params)?;
6839        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6840        let _value = self
6841            .session
6842            .client()
6843            .call(rpc_methods::SESSION_MCP_OAUTH_PROBE, Some(wire_params))
6844            .await?;
6845        Ok(serde_json::from_value(_value)?)
6846    }
6847
6848    /// Responds to a pending MCP OAuth authorization request by its request id.
6849    ///
6850    /// Wire method: `session.mcp.oauth.respond`.
6851    ///
6852    /// # Parameters
6853    ///
6854    /// * `params` - Pending MCP OAuth request id to respond to.
6855    ///
6856    /// # Returns
6857    ///
6858    /// Indicates whether the pending MCP OAuth response was accepted.
6859    ///
6860    /// <div class="warning">
6861    ///
6862    /// **Experimental.** This API is part of an experimental wire-protocol surface
6863    /// and may change or be removed in future SDK or CLI releases. Pin both the
6864    /// SDK and CLI versions if your code depends on it.
6865    ///
6866    /// </div>
6867    pub async fn respond(
6868        &self,
6869        params: McpOauthRespondRequest,
6870    ) -> Result<McpOauthRespondResult, Error> {
6871        let mut wire_params = serde_json::to_value(params)?;
6872        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6873        let _value = self
6874            .session
6875            .client()
6876            .call(rpc_methods::SESSION_MCP_OAUTH_RESPOND, Some(wire_params))
6877            .await?;
6878        Ok(serde_json::from_value(_value)?)
6879    }
6880}
6881
6882/// `session.mcp.resources.*` RPCs.
6883#[derive(Clone, Copy)]
6884pub struct SessionRpcMcpResources<'a> {
6885    pub(crate) session: &'a Session,
6886}
6887
6888impl<'a> SessionRpcMcpResources<'a> {
6889    /// Fetch an MCP resource from a connected server by URI (proxies MCP `resources/read`).
6890    ///
6891    /// Wire method: `session.mcp.resources.read`.
6892    ///
6893    /// # Parameters
6894    ///
6895    /// * `params` - MCP server and resource URI to fetch.
6896    ///
6897    /// # Returns
6898    ///
6899    /// Resource contents returned by the MCP server.
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 read(
6909        &self,
6910        params: McpResourcesReadRequest,
6911    ) -> Result<McpResourcesReadResult, Error> {
6912        let mut wire_params = serde_json::to_value(params)?;
6913        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6914        let _value = self
6915            .session
6916            .client()
6917            .call(rpc_methods::SESSION_MCP_RESOURCES_READ, Some(wire_params))
6918            .await?;
6919        Ok(serde_json::from_value(_value)?)
6920    }
6921
6922    /// Enumerate one page of resources a connected MCP server exposes (proxies MCP `resources/list`). Pass `cursor` to continue from a prior result's `nextCursor`.
6923    ///
6924    /// Wire method: `session.mcp.resources.list`.
6925    ///
6926    /// # Parameters
6927    ///
6928    /// * `params` - MCP server whose resources to enumerate.
6929    ///
6930    /// # Returns
6931    ///
6932    /// One page of resources advertised by the named MCP server.
6933    ///
6934    /// <div class="warning">
6935    ///
6936    /// **Experimental.** This API is part of an experimental wire-protocol surface
6937    /// and may change or be removed in future SDK or CLI releases. Pin both the
6938    /// SDK and CLI versions if your code depends on it.
6939    ///
6940    /// </div>
6941    pub async fn list(
6942        &self,
6943        params: McpResourcesListRequest,
6944    ) -> Result<McpResourcesListResult, Error> {
6945        let mut wire_params = serde_json::to_value(params)?;
6946        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6947        let _value = self
6948            .session
6949            .client()
6950            .call(rpc_methods::SESSION_MCP_RESOURCES_LIST, Some(wire_params))
6951            .await?;
6952        Ok(serde_json::from_value(_value)?)
6953    }
6954
6955    /// Enumerate one page of resource templates a connected MCP server exposes (proxies MCP `resources/templates/list`). Pass `cursor` to continue from a prior result's `nextCursor`.
6956    ///
6957    /// Wire method: `session.mcp.resources.listTemplates`.
6958    ///
6959    /// # Parameters
6960    ///
6961    /// * `params` - MCP server whose resource templates to enumerate.
6962    ///
6963    /// # Returns
6964    ///
6965    /// One page of resource templates advertised by the named MCP server.
6966    ///
6967    /// <div class="warning">
6968    ///
6969    /// **Experimental.** This API is part of an experimental wire-protocol surface
6970    /// and may change or be removed in future SDK or CLI releases. Pin both the
6971    /// SDK and CLI versions if your code depends on it.
6972    ///
6973    /// </div>
6974    pub async fn list_templates(
6975        &self,
6976        params: McpResourcesListTemplatesRequest,
6977    ) -> Result<McpResourcesListTemplatesResult, Error> {
6978        let mut wire_params = serde_json::to_value(params)?;
6979        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6980        let _value = self
6981            .session
6982            .client()
6983            .call(
6984                rpc_methods::SESSION_MCP_RESOURCES_LISTTEMPLATES,
6985                Some(wire_params),
6986            )
6987            .await?;
6988        Ok(serde_json::from_value(_value)?)
6989    }
6990}
6991
6992/// `session.metadata.*` RPCs.
6993#[derive(Clone, Copy)]
6994pub struct SessionRpcMetadata<'a> {
6995    pub(crate) session: &'a Session,
6996}
6997
6998impl<'a> SessionRpcMetadata<'a> {
6999    /// Returns a snapshot of the session's identifying metadata, mode, agent, and remote info.
7000    ///
7001    /// Wire method: `session.metadata.snapshot`.
7002    ///
7003    /// # Returns
7004    ///
7005    /// Point-in-time snapshot of slow-changing session identifier and state fields
7006    ///
7007    /// <div class="warning">
7008    ///
7009    /// **Experimental.** This API is part of an experimental wire-protocol surface
7010    /// and may change or be removed in future SDK or CLI releases. Pin both the
7011    /// SDK and CLI versions if your code depends on it.
7012    ///
7013    /// </div>
7014    pub async fn snapshot(&self) -> Result<SessionMetadataSnapshot, Error> {
7015        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7016        let _value = self
7017            .session
7018            .client()
7019            .call(rpc_methods::SESSION_METADATA_SNAPSHOT, Some(wire_params))
7020            .await?;
7021        Ok(serde_json::from_value(_value)?)
7022    }
7023
7024    /// Reports whether the local session is currently processing user/agent messages.
7025    ///
7026    /// Wire method: `session.metadata.isProcessing`.
7027    ///
7028    /// # Returns
7029    ///
7030    /// Indicates whether the local session is currently processing a turn or background continuation.
7031    ///
7032    /// <div class="warning">
7033    ///
7034    /// **Experimental.** This API is part of an experimental wire-protocol surface
7035    /// and may change or be removed in future SDK or CLI releases. Pin both the
7036    /// SDK and CLI versions if your code depends on it.
7037    ///
7038    /// </div>
7039    pub async fn is_processing(&self) -> Result<MetadataIsProcessingResult, Error> {
7040        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7041        let _value = self
7042            .session
7043            .client()
7044            .call(
7045                rpc_methods::SESSION_METADATA_ISPROCESSING,
7046                Some(wire_params),
7047            )
7048            .await?;
7049        Ok(serde_json::from_value(_value)?)
7050    }
7051
7052    /// Returns a snapshot of activity flags for the session.
7053    ///
7054    /// Wire method: `session.metadata.activity`.
7055    ///
7056    /// # Returns
7057    ///
7058    /// Current activity flags for the session.
7059    ///
7060    /// <div class="warning">
7061    ///
7062    /// **Experimental.** This API is part of an experimental wire-protocol surface
7063    /// and may change or be removed in future SDK or CLI releases. Pin both the
7064    /// SDK and CLI versions if your code depends on it.
7065    ///
7066    /// </div>
7067    pub async fn activity(&self) -> Result<SessionActivity, Error> {
7068        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7069        let _value = self
7070            .session
7071            .client()
7072            .call(rpc_methods::SESSION_METADATA_ACTIVITY, Some(wire_params))
7073            .await?;
7074        Ok(serde_json::from_value(_value)?)
7075    }
7076
7077    /// Returns the token breakdown for the session's current context window for a given model.
7078    ///
7079    /// Wire method: `session.metadata.contextInfo`.
7080    ///
7081    /// # Parameters
7082    ///
7083    /// * `params` - Model identifier and token limits used to compute the context-info breakdown.
7084    ///
7085    /// # Returns
7086    ///
7087    /// Token breakdown for the session's current context window, or null if uninitialized.
7088    ///
7089    /// <div class="warning">
7090    ///
7091    /// **Experimental.** This API is part of an experimental wire-protocol surface
7092    /// and may change or be removed in future SDK or CLI releases. Pin both the
7093    /// SDK and CLI versions if your code depends on it.
7094    ///
7095    /// </div>
7096    pub async fn context_info(
7097        &self,
7098        params: MetadataContextInfoRequest,
7099    ) -> Result<MetadataContextInfoResult, Error> {
7100        let mut wire_params = serde_json::to_value(params)?;
7101        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7102        let _value = self
7103            .session
7104            .client()
7105            .call(rpc_methods::SESSION_METADATA_CONTEXTINFO, Some(wire_params))
7106            .await?;
7107        Ok(serde_json::from_value(_value)?)
7108    }
7109
7110    /// 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.
7111    ///
7112    /// Wire method: `session.metadata.getContextAttribution`.
7113    ///
7114    /// # Returns
7115    ///
7116    /// Per-source attribution breakdown for the session's current context window, or null if uninitialized.
7117    ///
7118    /// <div class="warning">
7119    ///
7120    /// **Experimental.** This API is part of an experimental wire-protocol surface
7121    /// and may change or be removed in future SDK or CLI releases. Pin both the
7122    /// SDK and CLI versions if your code depends on it.
7123    ///
7124    /// </div>
7125    pub async fn get_context_attribution(&self) -> Result<MetadataContextAttributionResult, Error> {
7126        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7127        let _value = self
7128            .session
7129            .client()
7130            .call(
7131                rpc_methods::SESSION_METADATA_GETCONTEXTATTRIBUTION,
7132                Some(wire_params),
7133            )
7134            .await?;
7135        Ok(serde_json::from_value(_value)?)
7136    }
7137
7138    /// 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.
7139    ///
7140    /// Wire method: `session.metadata.getContextHeaviestMessages`.
7141    ///
7142    /// # Parameters
7143    ///
7144    /// * `params` - Parameters for the heaviest-messages query.
7145    ///
7146    /// # Returns
7147    ///
7148    /// The heaviest individual messages in the session's context window, most-expensive first.
7149    ///
7150    /// <div class="warning">
7151    ///
7152    /// **Experimental.** This API is part of an experimental wire-protocol surface
7153    /// and may change or be removed in future SDK or CLI releases. Pin both the
7154    /// SDK and CLI versions if your code depends on it.
7155    ///
7156    /// </div>
7157    pub async fn get_context_heaviest_messages(
7158        &self,
7159        params: MetadataContextHeaviestMessagesRequest,
7160    ) -> Result<MetadataContextHeaviestMessagesResult, Error> {
7161        let mut wire_params = serde_json::to_value(params)?;
7162        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7163        let _value = self
7164            .session
7165            .client()
7166            .call(
7167                rpc_methods::SESSION_METADATA_GETCONTEXTHEAVIESTMESSAGES,
7168                Some(wire_params),
7169            )
7170            .await?;
7171        Ok(serde_json::from_value(_value)?)
7172    }
7173
7174    /// Records a working-directory/git context change and emits a `session.context_changed` event. For a local session, a report whose `cwd` diverges from the session's current working directory is ignored (the call still succeeds but records nothing and emits no event): a local session's working directory is authoritative and is moved via `metadata.setWorkingDirectory` (or an SDK `session.resume` that supplies a `workingDirectory`), not by this method.
7175    ///
7176    /// Wire method: `session.metadata.recordContextChange`.
7177    ///
7178    /// # Parameters
7179    ///
7180    /// * `params` - Updated working-directory/git context to record on the session.
7181    ///
7182    /// # Returns
7183    ///
7184    /// 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). For a local session, a report whose `cwd` diverges from the session's current working directory is ignored (the call still succeeds but records nothing and emits no event); move a local session's working directory via `metadata.setWorkingDirectory` instead.
7185    ///
7186    /// <div class="warning">
7187    ///
7188    /// **Experimental.** This API is part of an experimental wire-protocol surface
7189    /// and may change or be removed in future SDK or CLI releases. Pin both the
7190    /// SDK and CLI versions if your code depends on it.
7191    ///
7192    /// </div>
7193    pub async fn record_context_change(
7194        &self,
7195        params: MetadataRecordContextChangeRequest,
7196    ) -> Result<MetadataRecordContextChangeResult, Error> {
7197        let mut wire_params = serde_json::to_value(params)?;
7198        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7199        let _value = self
7200            .session
7201            .client()
7202            .call(
7203                rpc_methods::SESSION_METADATA_RECORDCONTEXTCHANGE,
7204                Some(wire_params),
7205            )
7206            .await?;
7207        Ok(serde_json::from_value(_value)?)
7208    }
7209
7210    /// Updates the session's working directory. For local sessions the target is validated first (an absolute path that exists on disk) and the permission primary directory is re-based; a rejected validation fails the call before any session state changes.
7211    ///
7212    /// Wire method: `session.metadata.setWorkingDirectory`.
7213    ///
7214    /// # Parameters
7215    ///
7216    /// * `params` - Absolute path to set as the session's new working directory. For local sessions the path must be absolute and exist on disk: it is validated before any session state changes, and a failing validation rejects the call with nothing mutated, persisted, or emitted. Remote sessions record the path as-is.
7217    ///
7218    /// # Returns
7219    ///
7220    /// 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 any related side-effects (file index, etc.); it does NOT change the process working directory (a session's cwd is per-session, not process-global). For local sessions the runtime validates the target first (an absolute path that exists on disk) and re-bases the permission primary directory; a rejected validation fails the call before anything is mutated, persisted, or emitted. Location-scoped permission rules are then re-keyed to the new directory (best-effort). Remote sessions only record the path.
7221    ///
7222    /// <div class="warning">
7223    ///
7224    /// **Experimental.** This API is part of an experimental wire-protocol surface
7225    /// and may change or be removed in future SDK or CLI releases. Pin both the
7226    /// SDK and CLI versions if your code depends on it.
7227    ///
7228    /// </div>
7229    pub async fn set_working_directory(
7230        &self,
7231        params: MetadataSetWorkingDirectoryRequest,
7232    ) -> Result<MetadataSetWorkingDirectoryResult, Error> {
7233        let mut wire_params = serde_json::to_value(params)?;
7234        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7235        let _value = self
7236            .session
7237            .client()
7238            .call(
7239                rpc_methods::SESSION_METADATA_SETWORKINGDIRECTORY,
7240                Some(wire_params),
7241            )
7242            .await?;
7243        Ok(serde_json::from_value(_value)?)
7244    }
7245
7246    /// Re-tokenizes the session's existing messages against a model and returns aggregate token totals.
7247    ///
7248    /// Wire method: `session.metadata.recomputeContextTokens`.
7249    ///
7250    /// # Parameters
7251    ///
7252    /// * `params` - Model identifier to use when re-tokenizing the session's existing messages.
7253    ///
7254    /// # Returns
7255    ///
7256    /// 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.
7257    ///
7258    /// <div class="warning">
7259    ///
7260    /// **Experimental.** This API is part of an experimental wire-protocol surface
7261    /// and may change or be removed in future SDK or CLI releases. Pin both the
7262    /// SDK and CLI versions if your code depends on it.
7263    ///
7264    /// </div>
7265    pub async fn recompute_context_tokens(
7266        &self,
7267        params: MetadataRecomputeContextTokensRequest,
7268    ) -> Result<MetadataRecomputeContextTokensResult, Error> {
7269        let mut wire_params = serde_json::to_value(params)?;
7270        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7271        let _value = self
7272            .session
7273            .client()
7274            .call(
7275                rpc_methods::SESSION_METADATA_RECOMPUTECONTEXTTOKENS,
7276                Some(wire_params),
7277            )
7278            .await?;
7279        Ok(serde_json::from_value(_value)?)
7280    }
7281}
7282
7283/// `session.mode.*` RPCs.
7284#[derive(Clone, Copy)]
7285pub struct SessionRpcMode<'a> {
7286    pub(crate) session: &'a Session,
7287}
7288
7289impl<'a> SessionRpcMode<'a> {
7290    /// Gets the current agent interaction mode.
7291    ///
7292    /// Wire method: `session.mode.get`.
7293    ///
7294    /// # Returns
7295    ///
7296    /// The session mode the agent is operating in
7297    ///
7298    /// <div class="warning">
7299    ///
7300    /// **Experimental.** This API is part of an experimental wire-protocol surface
7301    /// and may change or be removed in future SDK or CLI releases. Pin both the
7302    /// SDK and CLI versions if your code depends on it.
7303    ///
7304    /// </div>
7305    pub async fn get(&self) -> Result<SessionMode, Error> {
7306        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7307        let _value = self
7308            .session
7309            .client()
7310            .call(rpc_methods::SESSION_MODE_GET, Some(wire_params))
7311            .await?;
7312        Ok(serde_json::from_value(_value)?)
7313    }
7314
7315    /// Sets the current agent interaction mode.
7316    ///
7317    /// Wire method: `session.mode.set`.
7318    ///
7319    /// # Parameters
7320    ///
7321    /// * `params` - Agent interaction mode to apply to the session.
7322    ///
7323    /// # Returns
7324    ///
7325    /// Outcome of a session mode change, including any model switch it triggered and follow-up the host must perform.
7326    ///
7327    /// <div class="warning">
7328    ///
7329    /// **Experimental.** This API is part of an experimental wire-protocol surface
7330    /// and may change or be removed in future SDK or CLI releases. Pin both the
7331    /// SDK and CLI versions if your code depends on it.
7332    ///
7333    /// </div>
7334    pub async fn set(&self, params: ModeSetRequest) -> Result<ModeSetResult, Error> {
7335        let mut wire_params = serde_json::to_value(params)?;
7336        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7337        let _value = self
7338            .session
7339            .client()
7340            .call(rpc_methods::SESSION_MODE_SET, Some(wire_params))
7341            .await?;
7342        Ok(serde_json::from_value(_value)?)
7343    }
7344}
7345
7346/// `session.model.*` RPCs.
7347#[derive(Clone, Copy)]
7348pub struct SessionRpcModel<'a> {
7349    pub(crate) session: &'a Session,
7350}
7351
7352impl<'a> SessionRpcModel<'a> {
7353    /// Gets the currently selected model for the session.
7354    ///
7355    /// Wire method: `session.model.getCurrent`.
7356    ///
7357    /// # Returns
7358    ///
7359    /// 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.
7360    ///
7361    /// <div class="warning">
7362    ///
7363    /// **Experimental.** This API is part of an experimental wire-protocol surface
7364    /// and may change or be removed in future SDK or CLI releases. Pin both the
7365    /// SDK and CLI versions if your code depends on it.
7366    ///
7367    /// </div>
7368    pub async fn get_current(&self) -> Result<CurrentModel, Error> {
7369        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7370        let _value = self
7371            .session
7372            .client()
7373            .call(rpc_methods::SESSION_MODEL_GETCURRENT, Some(wire_params))
7374            .await?;
7375        Ok(serde_json::from_value(_value)?)
7376    }
7377
7378    /// Switches the session to a model and optional reasoning configuration.
7379    ///
7380    /// Wire method: `session.model.switchTo`.
7381    ///
7382    /// # Parameters
7383    ///
7384    /// * `params` - Target model identifier and optional reasoning effort, summary, capability overrides, and context tier.
7385    ///
7386    /// # Returns
7387    ///
7388    /// The model identifier active on the session after the switch.
7389    ///
7390    /// <div class="warning">
7391    ///
7392    /// **Experimental.** This API is part of an experimental wire-protocol surface
7393    /// and may change or be removed in future SDK or CLI releases. Pin both the
7394    /// SDK and CLI versions if your code depends on it.
7395    ///
7396    /// </div>
7397    pub async fn switch_to(
7398        &self,
7399        params: ModelSwitchToRequest,
7400    ) -> Result<ModelSwitchToResult, Error> {
7401        let mut wire_params = serde_json::to_value(params)?;
7402        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7403        let _value = self
7404            .session
7405            .client()
7406            .call(rpc_methods::SESSION_MODEL_SWITCHTO, Some(wire_params))
7407            .await?;
7408        Ok(serde_json::from_value(_value)?)
7409    }
7410
7411    /// Resolves and applies organization-managed and repository model overlays.
7412    ///
7413    /// Wire method: `session.model.applyStartupOverlay`.
7414    ///
7415    /// # Parameters
7416    ///
7417    /// * `params` - Managed, repository, and CLI model overrides to overlay onto the session at startup.
7418    ///
7419    /// # Returns
7420    ///
7421    /// The model identifier active on the session after the switch.
7422    ///
7423    /// <div class="warning">
7424    ///
7425    /// **Experimental.** This API is part of an experimental wire-protocol surface
7426    /// and may change or be removed in future SDK or CLI releases. Pin both the
7427    /// SDK and CLI versions if your code depends on it.
7428    ///
7429    /// </div>
7430    pub(crate) async fn apply_startup_overlay(
7431        &self,
7432        params: ModelApplyStartupOverlayRequest,
7433    ) -> Result<ModelSwitchToResult, 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(
7440                rpc_methods::SESSION_MODEL_APPLYSTARTUPOVERLAY,
7441                Some(wire_params),
7442            )
7443            .await?;
7444        Ok(serde_json::from_value(_value)?)
7445    }
7446
7447    /// Updates the session's reasoning effort without changing the selected model.
7448    ///
7449    /// Wire method: `session.model.setReasoningEffort`.
7450    ///
7451    /// # Parameters
7452    ///
7453    /// * `params` - Reasoning effort level to apply to the currently selected model.
7454    ///
7455    /// # Returns
7456    ///
7457    /// 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.
7458    ///
7459    /// <div class="warning">
7460    ///
7461    /// **Experimental.** This API is part of an experimental wire-protocol surface
7462    /// and may change or be removed in future SDK or CLI releases. Pin both the
7463    /// SDK and CLI versions if your code depends on it.
7464    ///
7465    /// </div>
7466    pub async fn set_reasoning_effort(
7467        &self,
7468        params: ModelSetReasoningEffortRequest,
7469    ) -> Result<ModelSetReasoningEffortResult, Error> {
7470        let mut wire_params = serde_json::to_value(params)?;
7471        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7472        let _value = self
7473            .session
7474            .client()
7475            .call(
7476                rpc_methods::SESSION_MODEL_SETREASONINGEFFORT,
7477                Some(wire_params),
7478            )
7479            .await?;
7480        Ok(serde_json::from_value(_value)?)
7481    }
7482
7483    /// 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.
7484    ///
7485    /// Wire method: `session.model.list`.
7486    ///
7487    /// # Returns
7488    ///
7489    /// The list of models available to this session.
7490    ///
7491    /// <div class="warning">
7492    ///
7493    /// **Experimental.** This API is part of an experimental wire-protocol surface
7494    /// and may change or be removed in future SDK or CLI releases. Pin both the
7495    /// SDK and CLI versions if your code depends on it.
7496    ///
7497    /// </div>
7498    pub async fn list(&self) -> Result<SessionModelList, Error> {
7499        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7500        let _value = self
7501            .session
7502            .client()
7503            .call(rpc_methods::SESSION_MODEL_LIST, Some(wire_params))
7504            .await?;
7505        Ok(serde_json::from_value(_value)?)
7506    }
7507
7508    /// 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.
7509    ///
7510    /// Wire method: `session.model.list`.
7511    ///
7512    /// # Parameters
7513    ///
7514    /// * `params` - Optional listing options.
7515    ///
7516    /// # Returns
7517    ///
7518    /// The list of models available to this session.
7519    ///
7520    /// <div class="warning">
7521    ///
7522    /// **Experimental.** This API is part of an experimental wire-protocol surface
7523    /// and may change or be removed in future SDK or CLI releases. Pin both the
7524    /// SDK and CLI versions if your code depends on it.
7525    ///
7526    /// </div>
7527    pub async fn list_with_params(
7528        &self,
7529        params: ModelListRequest,
7530    ) -> Result<SessionModelList, Error> {
7531        let mut wire_params = serde_json::to_value(params)?;
7532        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7533        let _value = self
7534            .session
7535            .client()
7536            .call(rpc_methods::SESSION_MODEL_LIST, Some(wire_params))
7537            .await?;
7538        Ok(serde_json::from_value(_value)?)
7539    }
7540}
7541
7542/// `session.name.*` RPCs.
7543#[derive(Clone, Copy)]
7544pub struct SessionRpcName<'a> {
7545    pub(crate) session: &'a Session,
7546}
7547
7548impl<'a> SessionRpcName<'a> {
7549    /// Gets the session's friendly name.
7550    ///
7551    /// Wire method: `session.name.get`.
7552    ///
7553    /// # Returns
7554    ///
7555    /// The session's friendly name, or null when not yet set.
7556    ///
7557    /// <div class="warning">
7558    ///
7559    /// **Experimental.** This API is part of an experimental wire-protocol surface
7560    /// and may change or be removed in future SDK or CLI releases. Pin both the
7561    /// SDK and CLI versions if your code depends on it.
7562    ///
7563    /// </div>
7564    pub async fn get(&self) -> Result<NameGetResult, Error> {
7565        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7566        let _value = self
7567            .session
7568            .client()
7569            .call(rpc_methods::SESSION_NAME_GET, Some(wire_params))
7570            .await?;
7571        Ok(serde_json::from_value(_value)?)
7572    }
7573
7574    /// Sets the session's friendly name.
7575    ///
7576    /// Wire method: `session.name.set`.
7577    ///
7578    /// # Parameters
7579    ///
7580    /// * `params` - New friendly name to apply to the session.
7581    ///
7582    /// <div class="warning">
7583    ///
7584    /// **Experimental.** This API is part of an experimental wire-protocol surface
7585    /// and may change or be removed in future SDK or CLI releases. Pin both the
7586    /// SDK and CLI versions if your code depends on it.
7587    ///
7588    /// </div>
7589    pub async fn set(&self, params: NameSetRequest) -> Result<(), Error> {
7590        let mut wire_params = serde_json::to_value(params)?;
7591        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7592        let _value = self
7593            .session
7594            .client()
7595            .call(rpc_methods::SESSION_NAME_SET, Some(wire_params))
7596            .await?;
7597        Ok(())
7598    }
7599
7600    /// Persists an auto-generated session summary as the session's name when no user-set name exists.
7601    ///
7602    /// Wire method: `session.name.setAuto`.
7603    ///
7604    /// # Parameters
7605    ///
7606    /// * `params` - Auto-generated session summary to apply as the session's name when no user-set name exists.
7607    ///
7608    /// # Returns
7609    ///
7610    /// Indicates whether the auto-generated summary was applied as the session's name.
7611    ///
7612    /// <div class="warning">
7613    ///
7614    /// **Experimental.** This API is part of an experimental wire-protocol surface
7615    /// and may change or be removed in future SDK or CLI releases. Pin both the
7616    /// SDK and CLI versions if your code depends on it.
7617    ///
7618    /// </div>
7619    pub async fn set_auto(&self, params: NameSetAutoRequest) -> Result<NameSetAutoResult, Error> {
7620        let mut wire_params = serde_json::to_value(params)?;
7621        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7622        let _value = self
7623            .session
7624            .client()
7625            .call(rpc_methods::SESSION_NAME_SETAUTO, Some(wire_params))
7626            .await?;
7627        Ok(serde_json::from_value(_value)?)
7628    }
7629}
7630
7631/// `session.options.*` RPCs.
7632#[derive(Clone, Copy)]
7633pub struct SessionRpcOptions<'a> {
7634    pub(crate) session: &'a Session,
7635}
7636
7637impl<'a> SessionRpcOptions<'a> {
7638    /// Patches the genuinely-mutable subset of session options.
7639    ///
7640    /// Wire method: `session.options.update`.
7641    ///
7642    /// # Parameters
7643    ///
7644    /// * `params` - Patch of mutable session options to apply to the running session.
7645    ///
7646    /// # Returns
7647    ///
7648    /// Indicates whether the session options patch was applied successfully.
7649    ///
7650    /// <div class="warning">
7651    ///
7652    /// **Experimental.** This API is part of an experimental wire-protocol surface
7653    /// and may change or be removed in future SDK or CLI releases. Pin both the
7654    /// SDK and CLI versions if your code depends on it.
7655    ///
7656    /// </div>
7657    pub async fn update(
7658        &self,
7659        params: SessionUpdateOptionsParams,
7660    ) -> Result<SessionUpdateOptionsResult, Error> {
7661        let mut wire_params = serde_json::to_value(params)?;
7662        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7663        let _value = self
7664            .session
7665            .client()
7666            .call(rpc_methods::SESSION_OPTIONS_UPDATE, Some(wire_params))
7667            .await?;
7668        Ok(serde_json::from_value(_value)?)
7669    }
7670}
7671
7672/// `session.permissions.*` RPCs.
7673#[derive(Clone, Copy)]
7674pub struct SessionRpcPermissions<'a> {
7675    pub(crate) session: &'a Session,
7676}
7677
7678impl<'a> SessionRpcPermissions<'a> {
7679    /// `session.permissions.folderTrust.*` sub-namespace.
7680    pub fn folder_trust(&self) -> SessionRpcPermissionsFolderTrust<'a> {
7681        SessionRpcPermissionsFolderTrust {
7682            session: self.session,
7683        }
7684    }
7685
7686    /// `session.permissions.locations.*` sub-namespace.
7687    pub fn locations(&self) -> SessionRpcPermissionsLocations<'a> {
7688        SessionRpcPermissionsLocations {
7689            session: self.session,
7690        }
7691    }
7692
7693    /// `session.permissions.paths.*` sub-namespace.
7694    pub fn paths(&self) -> SessionRpcPermissionsPaths<'a> {
7695        SessionRpcPermissionsPaths {
7696            session: self.session,
7697        }
7698    }
7699
7700    /// `session.permissions.urls.*` sub-namespace.
7701    pub fn urls(&self) -> SessionRpcPermissionsUrls<'a> {
7702        SessionRpcPermissionsUrls {
7703            session: self.session,
7704        }
7705    }
7706
7707    /// Replaces selected permission policy fields (rules, paths, URLs, exclusions, allow-all flags) on the session.
7708    ///
7709    /// Wire method: `session.permissions.configure`.
7710    ///
7711    /// # Parameters
7712    ///
7713    /// * `params` - Patch of permission policy fields to apply (omit a field to leave it unchanged).
7714    ///
7715    /// # Returns
7716    ///
7717    /// Indicates whether the operation succeeded.
7718    ///
7719    /// <div class="warning">
7720    ///
7721    /// **Experimental.** This API is part of an experimental wire-protocol surface
7722    /// and may change or be removed in future SDK or CLI releases. Pin both the
7723    /// SDK and CLI versions if your code depends on it.
7724    ///
7725    /// </div>
7726    pub async fn configure(
7727        &self,
7728        params: PermissionsConfigureParams,
7729    ) -> Result<PermissionsConfigureResult, Error> {
7730        let mut wire_params = serde_json::to_value(params)?;
7731        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7732        let _value = self
7733            .session
7734            .client()
7735            .call(
7736                rpc_methods::SESSION_PERMISSIONS_CONFIGURE,
7737                Some(wire_params),
7738            )
7739            .await?;
7740        Ok(serde_json::from_value(_value)?)
7741    }
7742
7743    /// Provides a decision for a pending tool permission request.
7744    ///
7745    /// Wire method: `session.permissions.handlePendingPermissionRequest`.
7746    ///
7747    /// # Parameters
7748    ///
7749    /// * `params` - Pending permission request ID and the decision to apply (approve/reject and scope).
7750    ///
7751    /// # Returns
7752    ///
7753    /// Indicates whether the permission decision was applied; false when the request was already resolved.
7754    ///
7755    /// <div class="warning">
7756    ///
7757    /// **Experimental.** This API is part of an experimental wire-protocol surface
7758    /// and may change or be removed in future SDK or CLI releases. Pin both the
7759    /// SDK and CLI versions if your code depends on it.
7760    ///
7761    /// </div>
7762    pub async fn handle_pending_permission_request(
7763        &self,
7764        params: PermissionDecisionRequest,
7765    ) -> Result<PermissionRequestResult, Error> {
7766        let mut wire_params = serde_json::to_value(params)?;
7767        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7768        let _value = self
7769            .session
7770            .client()
7771            .call(
7772                rpc_methods::SESSION_PERMISSIONS_HANDLEPENDINGPERMISSIONREQUEST,
7773                Some(wire_params),
7774            )
7775            .await?;
7776        Ok(serde_json::from_value(_value)?)
7777    }
7778
7779    /// Reconstructs the set of pending tool permission requests from the session's event history.
7780    ///
7781    /// Wire method: `session.permissions.pendingRequests`.
7782    ///
7783    /// # Returns
7784    ///
7785    /// List of pending permission requests reconstructed from event history.
7786    ///
7787    /// <div class="warning">
7788    ///
7789    /// **Experimental.** This API is part of an experimental wire-protocol surface
7790    /// and may change or be removed in future SDK or CLI releases. Pin both the
7791    /// SDK and CLI versions if your code depends on it.
7792    ///
7793    /// </div>
7794    pub async fn pending_requests(&self) -> Result<PendingPermissionRequestList, Error> {
7795        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7796        let _value = self
7797            .session
7798            .client()
7799            .call(
7800                rpc_methods::SESSION_PERMISSIONS_PENDINGREQUESTS,
7801                Some(wire_params),
7802            )
7803            .await?;
7804        Ok(serde_json::from_value(_value)?)
7805    }
7806
7807    /// Enables or disables automatic approval of tool permission requests for the session.
7808    ///
7809    /// Wire method: `session.permissions.setApproveAll`.
7810    ///
7811    /// # Parameters
7812    ///
7813    /// * `params` - Allow-all toggle for tool permission requests, with an optional telemetry source.
7814    ///
7815    /// # Returns
7816    ///
7817    /// Indicates whether the operation succeeded.
7818    ///
7819    /// <div class="warning">
7820    ///
7821    /// **Experimental.** This API is part of an experimental wire-protocol surface
7822    /// and may change or be removed in future SDK or CLI releases. Pin both the
7823    /// SDK and CLI versions if your code depends on it.
7824    ///
7825    /// </div>
7826    pub async fn set_approve_all(
7827        &self,
7828        params: PermissionsSetApproveAllRequest,
7829    ) -> Result<PermissionsSetApproveAllResult, Error> {
7830        let mut wire_params = serde_json::to_value(params)?;
7831        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7832        let _value = self
7833            .session
7834            .client()
7835            .call(
7836                rpc_methods::SESSION_PERMISSIONS_SETAPPROVEALL,
7837                Some(wire_params),
7838            )
7839            .await?;
7840        Ok(serde_json::from_value(_value)?)
7841    }
7842
7843    /// Sets the permission mode for the session. `manual` follows the normal approval flow, `assisted` attaches LLM safety recommendations, and `allow-all` automatically approves permission requests. The result returns the authoritative post-mutation mode so callers can update local state without racing the `session.permissions_changed` notification.
7844    ///
7845    /// Wire method: `session.permissions.setMode`.
7846    ///
7847    /// # Parameters
7848    ///
7849    /// * `params` - Permission mode to apply for the session.
7850    ///
7851    /// # Returns
7852    ///
7853    /// Indicates whether the requested permission mode was applied and reports the authoritative post-mutation mode.
7854    ///
7855    /// <div class="warning">
7856    ///
7857    /// **Experimental.** This API is part of an experimental wire-protocol surface
7858    /// and may change or be removed in future SDK or CLI releases. Pin both the
7859    /// SDK and CLI versions if your code depends on it.
7860    ///
7861    /// </div>
7862    pub async fn set_mode(
7863        &self,
7864        params: PermissionsSetModeRequest,
7865    ) -> Result<PermissionsSetModeResult, Error> {
7866        let mut wire_params = serde_json::to_value(params)?;
7867        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7868        let _value = self
7869            .session
7870            .client()
7871            .call(rpc_methods::SESSION_PERMISSIONS_SETMODE, Some(wire_params))
7872            .await?;
7873        Ok(serde_json::from_value(_value)?)
7874    }
7875
7876    /// Returns the current permission mode for the session.
7877    ///
7878    /// Wire method: `session.permissions.getMode`.
7879    ///
7880    /// # Returns
7881    ///
7882    /// Current permission mode.
7883    ///
7884    /// <div class="warning">
7885    ///
7886    /// **Experimental.** This API is part of an experimental wire-protocol surface
7887    /// and may change or be removed in future SDK or CLI releases. Pin both the
7888    /// SDK and CLI versions if your code depends on it.
7889    ///
7890    /// </div>
7891    pub async fn get_mode(&self) -> Result<PermissionsGetModeResult, Error> {
7892        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7893        let _value = self
7894            .session
7895            .client()
7896            .call(rpc_methods::SESSION_PERMISSIONS_GETMODE, Some(wire_params))
7897            .await?;
7898        Ok(serde_json::from_value(_value)?)
7899    }
7900
7901    /// Adds or removes session-scoped or location-scoped permission rules.
7902    ///
7903    /// Wire method: `session.permissions.modifyRules`.
7904    ///
7905    /// # Parameters
7906    ///
7907    /// * `params` - Scope and add/remove instructions for modifying session- or location-scoped permission rules.
7908    ///
7909    /// # Returns
7910    ///
7911    /// Indicates whether the operation succeeded.
7912    ///
7913    /// <div class="warning">
7914    ///
7915    /// **Experimental.** This API is part of an experimental wire-protocol surface
7916    /// and may change or be removed in future SDK or CLI releases. Pin both the
7917    /// SDK and CLI versions if your code depends on it.
7918    ///
7919    /// </div>
7920    pub async fn modify_rules(
7921        &self,
7922        params: PermissionsModifyRulesParams,
7923    ) -> Result<PermissionsModifyRulesResult, Error> {
7924        let mut wire_params = serde_json::to_value(params)?;
7925        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7926        let _value = self
7927            .session
7928            .client()
7929            .call(
7930                rpc_methods::SESSION_PERMISSIONS_MODIFYRULES,
7931                Some(wire_params),
7932            )
7933            .await?;
7934        Ok(serde_json::from_value(_value)?)
7935    }
7936
7937    /// Sets whether the client wants permission prompts bridged into session events.
7938    ///
7939    /// Wire method: `session.permissions.setRequired`.
7940    ///
7941    /// # Parameters
7942    ///
7943    /// * `params` - Toggles whether permission prompts should be bridged into session events for this client.
7944    ///
7945    /// # Returns
7946    ///
7947    /// Indicates whether the operation succeeded.
7948    ///
7949    /// <div class="warning">
7950    ///
7951    /// **Experimental.** This API is part of an experimental wire-protocol surface
7952    /// and may change or be removed in future SDK or CLI releases. Pin both the
7953    /// SDK and CLI versions if your code depends on it.
7954    ///
7955    /// </div>
7956    pub async fn set_required(
7957        &self,
7958        params: PermissionsSetRequiredRequest,
7959    ) -> Result<PermissionsSetRequiredResult, Error> {
7960        let mut wire_params = serde_json::to_value(params)?;
7961        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7962        let _value = self
7963            .session
7964            .client()
7965            .call(
7966                rpc_methods::SESSION_PERMISSIONS_SETREQUIRED,
7967                Some(wire_params),
7968            )
7969            .await?;
7970        Ok(serde_json::from_value(_value)?)
7971    }
7972
7973    /// Clears session-scoped tool permission approvals.
7974    ///
7975    /// Wire method: `session.permissions.resetSessionApprovals`.
7976    ///
7977    /// # Parameters
7978    ///
7979    /// * `params` - Clears session-scoped tool permission approvals, and optionally the location-scoped ones.
7980    ///
7981    /// # Returns
7982    ///
7983    /// Indicates whether the operation succeeded.
7984    ///
7985    /// <div class="warning">
7986    ///
7987    /// **Experimental.** This API is part of an experimental wire-protocol surface
7988    /// and may change or be removed in future SDK or CLI releases. Pin both the
7989    /// SDK and CLI versions if your code depends on it.
7990    ///
7991    /// </div>
7992    pub async fn reset_session_approvals(
7993        &self,
7994        params: PermissionsResetSessionApprovalsRequest,
7995    ) -> Result<PermissionsResetSessionApprovalsResult, Error> {
7996        let mut wire_params = serde_json::to_value(params)?;
7997        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7998        let _value = self
7999            .session
8000            .client()
8001            .call(
8002                rpc_methods::SESSION_PERMISSIONS_RESETSESSIONAPPROVALS,
8003                Some(wire_params),
8004            )
8005            .await?;
8006        Ok(serde_json::from_value(_value)?)
8007    }
8008
8009    /// Notifies the runtime that a permission prompt UI has been shown to the user.
8010    ///
8011    /// Wire method: `session.permissions.notifyPromptShown`.
8012    ///
8013    /// # Parameters
8014    ///
8015    /// * `params` - Notification payload describing the permission prompt that the client just rendered.
8016    ///
8017    /// # Returns
8018    ///
8019    /// Indicates whether the operation succeeded.
8020    ///
8021    /// <div class="warning">
8022    ///
8023    /// **Experimental.** This API is part of an experimental wire-protocol surface
8024    /// and may change or be removed in future SDK or CLI releases. Pin both the
8025    /// SDK and CLI versions if your code depends on it.
8026    ///
8027    /// </div>
8028    pub async fn notify_prompt_shown(
8029        &self,
8030        params: PermissionPromptShownNotification,
8031    ) -> Result<PermissionsNotifyPromptShownResult, Error> {
8032        let mut wire_params = serde_json::to_value(params)?;
8033        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8034        let _value = self
8035            .session
8036            .client()
8037            .call(
8038                rpc_methods::SESSION_PERMISSIONS_NOTIFYPROMPTSHOWN,
8039                Some(wire_params),
8040            )
8041            .await?;
8042        Ok(serde_json::from_value(_value)?)
8043    }
8044}
8045
8046/// `session.permissions.folderTrust.*` RPCs.
8047#[derive(Clone, Copy)]
8048pub struct SessionRpcPermissionsFolderTrust<'a> {
8049    pub(crate) session: &'a Session,
8050}
8051
8052impl<'a> SessionRpcPermissionsFolderTrust<'a> {
8053    /// Reports whether a folder is trusted according to the user's folder trust state.
8054    ///
8055    /// Wire method: `session.permissions.folderTrust.isTrusted`.
8056    ///
8057    /// # Parameters
8058    ///
8059    /// * `params` - Folder path to check for trust.
8060    ///
8061    /// # Returns
8062    ///
8063    /// Folder trust check result.
8064    ///
8065    /// <div class="warning">
8066    ///
8067    /// **Experimental.** This API is part of an experimental wire-protocol surface
8068    /// and may change or be removed in future SDK or CLI releases. Pin both the
8069    /// SDK and CLI versions if your code depends on it.
8070    ///
8071    /// </div>
8072    pub async fn is_trusted(
8073        &self,
8074        params: FolderTrustCheckParams,
8075    ) -> Result<FolderTrustCheckResult, Error> {
8076        let mut wire_params = serde_json::to_value(params)?;
8077        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8078        let _value = self
8079            .session
8080            .client()
8081            .call(
8082                rpc_methods::SESSION_PERMISSIONS_FOLDERTRUST_ISTRUSTED,
8083                Some(wire_params),
8084            )
8085            .await?;
8086        Ok(serde_json::from_value(_value)?)
8087    }
8088
8089    /// Adds a folder to the user's trusted folders list.
8090    ///
8091    /// Wire method: `session.permissions.folderTrust.addTrusted`.
8092    ///
8093    /// # Parameters
8094    ///
8095    /// * `params` - Folder path to add to trusted folders.
8096    ///
8097    /// # Returns
8098    ///
8099    /// Indicates whether the operation succeeded.
8100    ///
8101    /// <div class="warning">
8102    ///
8103    /// **Experimental.** This API is part of an experimental wire-protocol surface
8104    /// and may change or be removed in future SDK or CLI releases. Pin both the
8105    /// SDK and CLI versions if your code depends on it.
8106    ///
8107    /// </div>
8108    pub async fn add_trusted(
8109        &self,
8110        params: FolderTrustAddParams,
8111    ) -> Result<PermissionsFolderTrustAddTrustedResult, Error> {
8112        let mut wire_params = serde_json::to_value(params)?;
8113        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8114        let _value = self
8115            .session
8116            .client()
8117            .call(
8118                rpc_methods::SESSION_PERMISSIONS_FOLDERTRUST_ADDTRUSTED,
8119                Some(wire_params),
8120            )
8121            .await?;
8122        Ok(serde_json::from_value(_value)?)
8123    }
8124}
8125
8126/// `session.permissions.locations.*` RPCs.
8127#[derive(Clone, Copy)]
8128pub struct SessionRpcPermissionsLocations<'a> {
8129    pub(crate) session: &'a Session,
8130}
8131
8132impl<'a> SessionRpcPermissionsLocations<'a> {
8133    /// Resolves the permission location key and type for a working directory.
8134    ///
8135    /// Wire method: `session.permissions.locations.resolve`.
8136    ///
8137    /// # Parameters
8138    ///
8139    /// * `params` - Working directory to resolve into a location-permissions key.
8140    ///
8141    /// # Returns
8142    ///
8143    /// Resolved location-permissions key and type.
8144    ///
8145    /// <div class="warning">
8146    ///
8147    /// **Experimental.** This API is part of an experimental wire-protocol surface
8148    /// and may change or be removed in future SDK or CLI releases. Pin both the
8149    /// SDK and CLI versions if your code depends on it.
8150    ///
8151    /// </div>
8152    pub async fn resolve(
8153        &self,
8154        params: PermissionLocationResolveParams,
8155    ) -> Result<PermissionLocationResolveResult, Error> {
8156        let mut wire_params = serde_json::to_value(params)?;
8157        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8158        let _value = self
8159            .session
8160            .client()
8161            .call(
8162                rpc_methods::SESSION_PERMISSIONS_LOCATIONS_RESOLVE,
8163                Some(wire_params),
8164            )
8165            .await?;
8166        Ok(serde_json::from_value(_value)?)
8167    }
8168
8169    /// Applies persisted location-scoped tool approvals and allowed directories for a working directory to this session's permission service.
8170    ///
8171    /// Wire method: `session.permissions.locations.apply`.
8172    ///
8173    /// # Parameters
8174    ///
8175    /// * `params` - Working directory to load persisted location permissions for.
8176    ///
8177    /// # Returns
8178    ///
8179    /// Summary of persisted location permissions applied to the session.
8180    ///
8181    /// <div class="warning">
8182    ///
8183    /// **Experimental.** This API is part of an experimental wire-protocol surface
8184    /// and may change or be removed in future SDK or CLI releases. Pin both the
8185    /// SDK and CLI versions if your code depends on it.
8186    ///
8187    /// </div>
8188    pub async fn apply(
8189        &self,
8190        params: PermissionLocationApplyParams,
8191    ) -> Result<PermissionLocationApplyResult, Error> {
8192        let mut wire_params = serde_json::to_value(params)?;
8193        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8194        let _value = self
8195            .session
8196            .client()
8197            .call(
8198                rpc_methods::SESSION_PERMISSIONS_LOCATIONS_APPLY,
8199                Some(wire_params),
8200            )
8201            .await?;
8202        Ok(serde_json::from_value(_value)?)
8203    }
8204
8205    /// Persists a tool approval for a permission location and applies its rules to this session's live permission service.
8206    ///
8207    /// Wire method: `session.permissions.locations.addToolApproval`.
8208    ///
8209    /// # Parameters
8210    ///
8211    /// * `params` - Location-scoped tool approval to persist.
8212    ///
8213    /// # Returns
8214    ///
8215    /// Indicates whether the operation succeeded.
8216    ///
8217    /// <div class="warning">
8218    ///
8219    /// **Experimental.** This API is part of an experimental wire-protocol surface
8220    /// and may change or be removed in future SDK or CLI releases. Pin both the
8221    /// SDK and CLI versions if your code depends on it.
8222    ///
8223    /// </div>
8224    pub async fn add_tool_approval(
8225        &self,
8226        params: PermissionLocationAddToolApprovalParams,
8227    ) -> Result<PermissionsLocationsAddToolApprovalResult, Error> {
8228        let mut wire_params = serde_json::to_value(params)?;
8229        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8230        let _value = self
8231            .session
8232            .client()
8233            .call(
8234                rpc_methods::SESSION_PERMISSIONS_LOCATIONS_ADDTOOLAPPROVAL,
8235                Some(wire_params),
8236            )
8237            .await?;
8238        Ok(serde_json::from_value(_value)?)
8239    }
8240}
8241
8242/// `session.permissions.paths.*` RPCs.
8243#[derive(Clone, Copy)]
8244pub struct SessionRpcPermissionsPaths<'a> {
8245    pub(crate) session: &'a Session,
8246}
8247
8248impl<'a> SessionRpcPermissionsPaths<'a> {
8249    /// Returns the session's allowed directories and primary working directory.
8250    ///
8251    /// Wire method: `session.permissions.paths.list`.
8252    ///
8253    /// # Returns
8254    ///
8255    /// Snapshot of the session's allow-listed directories and primary working directory.
8256    ///
8257    /// <div class="warning">
8258    ///
8259    /// **Experimental.** This API is part of an experimental wire-protocol surface
8260    /// and may change or be removed in future SDK or CLI releases. Pin both the
8261    /// SDK and CLI versions if your code depends on it.
8262    ///
8263    /// </div>
8264    pub async fn list(&self) -> Result<PermissionPathsList, Error> {
8265        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8266        let _value = self
8267            .session
8268            .client()
8269            .call(
8270                rpc_methods::SESSION_PERMISSIONS_PATHS_LIST,
8271                Some(wire_params),
8272            )
8273            .await?;
8274        Ok(serde_json::from_value(_value)?)
8275    }
8276
8277    /// Adds a directory to the session's allow-list and activates conventional skill and agent definitions under it.
8278    ///
8279    /// Wire method: `session.permissions.paths.add`.
8280    ///
8281    /// # Parameters
8282    ///
8283    /// * `params` - Directory path to add to the session's allowed directories.
8284    ///
8285    /// # Returns
8286    ///
8287    /// Indicates whether the operation succeeded.
8288    ///
8289    /// <div class="warning">
8290    ///
8291    /// **Experimental.** This API is part of an experimental wire-protocol surface
8292    /// and may change or be removed in future SDK or CLI releases. Pin both the
8293    /// SDK and CLI versions if your code depends on it.
8294    ///
8295    /// </div>
8296    pub async fn add(
8297        &self,
8298        params: PermissionPathsAddParams,
8299    ) -> Result<PermissionsPathsAddResult, Error> {
8300        let mut wire_params = serde_json::to_value(params)?;
8301        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8302        let _value = self
8303            .session
8304            .client()
8305            .call(
8306                rpc_methods::SESSION_PERMISSIONS_PATHS_ADD,
8307                Some(wire_params),
8308            )
8309            .await?;
8310        Ok(serde_json::from_value(_value)?)
8311    }
8312
8313    /// Updates the session's primary working directory used by the permission policy.
8314    ///
8315    /// Wire method: `session.permissions.paths.updatePrimary`.
8316    ///
8317    /// # Parameters
8318    ///
8319    /// * `params` - Directory path to set as the session's new primary working directory.
8320    ///
8321    /// # Returns
8322    ///
8323    /// Indicates whether the operation succeeded.
8324    ///
8325    /// <div class="warning">
8326    ///
8327    /// **Experimental.** This API is part of an experimental wire-protocol surface
8328    /// and may change or be removed in future SDK or CLI releases. Pin both the
8329    /// SDK and CLI versions if your code depends on it.
8330    ///
8331    /// </div>
8332    pub async fn update_primary(
8333        &self,
8334        params: PermissionPathsUpdatePrimaryParams,
8335    ) -> Result<PermissionsPathsUpdatePrimaryResult, Error> {
8336        let mut wire_params = serde_json::to_value(params)?;
8337        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8338        let _value = self
8339            .session
8340            .client()
8341            .call(
8342                rpc_methods::SESSION_PERMISSIONS_PATHS_UPDATEPRIMARY,
8343                Some(wire_params),
8344            )
8345            .await?;
8346        Ok(serde_json::from_value(_value)?)
8347    }
8348
8349    /// Reports whether a path falls within any of the session's allowed directories.
8350    ///
8351    /// Wire method: `session.permissions.paths.isPathWithinAllowedDirectories`.
8352    ///
8353    /// # Parameters
8354    ///
8355    /// * `params` - Path to evaluate against the session's allowed directories.
8356    ///
8357    /// # Returns
8358    ///
8359    /// Indicates whether the supplied path is within the session's allowed directories.
8360    ///
8361    /// <div class="warning">
8362    ///
8363    /// **Experimental.** This API is part of an experimental wire-protocol surface
8364    /// and may change or be removed in future SDK or CLI releases. Pin both the
8365    /// SDK and CLI versions if your code depends on it.
8366    ///
8367    /// </div>
8368    pub async fn is_path_within_allowed_directories(
8369        &self,
8370        params: PermissionPathsAllowedCheckParams,
8371    ) -> Result<PermissionPathsAllowedCheckResult, Error> {
8372        let mut wire_params = serde_json::to_value(params)?;
8373        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8374        let _value = self
8375            .session
8376            .client()
8377            .call(
8378                rpc_methods::SESSION_PERMISSIONS_PATHS_ISPATHWITHINALLOWEDDIRECTORIES,
8379                Some(wire_params),
8380            )
8381            .await?;
8382        Ok(serde_json::from_value(_value)?)
8383    }
8384
8385    /// Reports whether a path falls within the session's workspace (primary) directory.
8386    ///
8387    /// Wire method: `session.permissions.paths.isPathWithinWorkspace`.
8388    ///
8389    /// # Parameters
8390    ///
8391    /// * `params` - Path to evaluate against the session's workspace (primary) directory.
8392    ///
8393    /// # Returns
8394    ///
8395    /// Indicates whether the supplied path is within the session's workspace directory.
8396    ///
8397    /// <div class="warning">
8398    ///
8399    /// **Experimental.** This API is part of an experimental wire-protocol surface
8400    /// and may change or be removed in future SDK or CLI releases. Pin both the
8401    /// SDK and CLI versions if your code depends on it.
8402    ///
8403    /// </div>
8404    pub async fn is_path_within_workspace(
8405        &self,
8406        params: PermissionPathsWorkspaceCheckParams,
8407    ) -> Result<PermissionPathsWorkspaceCheckResult, Error> {
8408        let mut wire_params = serde_json::to_value(params)?;
8409        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8410        let _value = self
8411            .session
8412            .client()
8413            .call(
8414                rpc_methods::SESSION_PERMISSIONS_PATHS_ISPATHWITHINWORKSPACE,
8415                Some(wire_params),
8416            )
8417            .await?;
8418        Ok(serde_json::from_value(_value)?)
8419    }
8420}
8421
8422/// `session.permissions.urls.*` RPCs.
8423#[derive(Clone, Copy)]
8424pub struct SessionRpcPermissionsUrls<'a> {
8425    pub(crate) session: &'a Session,
8426}
8427
8428impl<'a> SessionRpcPermissionsUrls<'a> {
8429    /// Toggles the runtime's URL-permission policy between unrestricted and restricted modes.
8430    ///
8431    /// Wire method: `session.permissions.urls.setUnrestrictedMode`.
8432    ///
8433    /// # Parameters
8434    ///
8435    /// * `params` - Whether the URL-permission policy should run in unrestricted mode.
8436    ///
8437    /// # Returns
8438    ///
8439    /// Indicates whether the operation succeeded.
8440    ///
8441    /// <div class="warning">
8442    ///
8443    /// **Experimental.** This API is part of an experimental wire-protocol surface
8444    /// and may change or be removed in future SDK or CLI releases. Pin both the
8445    /// SDK and CLI versions if your code depends on it.
8446    ///
8447    /// </div>
8448    pub async fn set_unrestricted_mode(
8449        &self,
8450        params: PermissionUrlsSetUnrestrictedModeParams,
8451    ) -> Result<PermissionsUrlsSetUnrestrictedModeResult, Error> {
8452        let mut wire_params = serde_json::to_value(params)?;
8453        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8454        let _value = self
8455            .session
8456            .client()
8457            .call(
8458                rpc_methods::SESSION_PERMISSIONS_URLS_SETUNRESTRICTEDMODE,
8459                Some(wire_params),
8460            )
8461            .await?;
8462        Ok(serde_json::from_value(_value)?)
8463    }
8464}
8465
8466/// `session.plan.*` RPCs.
8467#[derive(Clone, Copy)]
8468pub struct SessionRpcPlan<'a> {
8469    pub(crate) session: &'a Session,
8470}
8471
8472impl<'a> SessionRpcPlan<'a> {
8473    /// Reads the session plan file from the workspace.
8474    ///
8475    /// Wire method: `session.plan.read`.
8476    ///
8477    /// # Returns
8478    ///
8479    /// Existence, contents, and resolved path of the session plan file.
8480    ///
8481    /// <div class="warning">
8482    ///
8483    /// **Experimental.** This API is part of an experimental wire-protocol surface
8484    /// and may change or be removed in future SDK or CLI releases. Pin both the
8485    /// SDK and CLI versions if your code depends on it.
8486    ///
8487    /// </div>
8488    pub async fn read(&self) -> Result<PlanReadResult, Error> {
8489        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8490        let _value = self
8491            .session
8492            .client()
8493            .call(rpc_methods::SESSION_PLAN_READ, Some(wire_params))
8494            .await?;
8495        Ok(serde_json::from_value(_value)?)
8496    }
8497
8498    /// Writes new content to the session plan file.
8499    ///
8500    /// Wire method: `session.plan.update`.
8501    ///
8502    /// # Parameters
8503    ///
8504    /// * `params` - Replacement contents to write to the session plan file.
8505    ///
8506    /// <div class="warning">
8507    ///
8508    /// **Experimental.** This API is part of an experimental wire-protocol surface
8509    /// and may change or be removed in future SDK or CLI releases. Pin both the
8510    /// SDK and CLI versions if your code depends on it.
8511    ///
8512    /// </div>
8513    pub async fn update(&self, params: PlanUpdateRequest) -> Result<(), Error> {
8514        let mut wire_params = serde_json::to_value(params)?;
8515        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8516        let _value = self
8517            .session
8518            .client()
8519            .call(rpc_methods::SESSION_PLAN_UPDATE, Some(wire_params))
8520            .await?;
8521        Ok(())
8522    }
8523
8524    /// Deletes the session plan file from the workspace.
8525    ///
8526    /// Wire method: `session.plan.delete`.
8527    ///
8528    /// <div class="warning">
8529    ///
8530    /// **Experimental.** This API is part of an experimental wire-protocol surface
8531    /// and may change or be removed in future SDK or CLI releases. Pin both the
8532    /// SDK and CLI versions if your code depends on it.
8533    ///
8534    /// </div>
8535    pub async fn delete(&self) -> Result<(), Error> {
8536        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8537        let _value = self
8538            .session
8539            .client()
8540            .call(rpc_methods::SESSION_PLAN_DELETE, Some(wire_params))
8541            .await?;
8542        Ok(())
8543    }
8544
8545    /// Reads todo rows from the session SQL database for plan rendering.
8546    ///
8547    /// Wire method: `session.plan.readSqlTodos`.
8548    ///
8549    /// # Returns
8550    ///
8551    /// Todo rows read from the session SQL database. Empty when no session database is available.
8552    ///
8553    /// <div class="warning">
8554    ///
8555    /// **Experimental.** This API is part of an experimental wire-protocol surface
8556    /// and may change or be removed in future SDK or CLI releases. Pin both the
8557    /// SDK and CLI versions if your code depends on it.
8558    ///
8559    /// </div>
8560    pub async fn read_sql_todos(&self) -> Result<PlanReadSqlTodosResult, Error> {
8561        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8562        let _value = self
8563            .session
8564            .client()
8565            .call(rpc_methods::SESSION_PLAN_READSQLTODOS, Some(wire_params))
8566            .await?;
8567        Ok(serde_json::from_value(_value)?)
8568    }
8569
8570    /// 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.
8571    ///
8572    /// Wire method: `session.plan.readSqlTodosWithDependencies`.
8573    ///
8574    /// # Returns
8575    ///
8576    /// Todo rows + dependency edges read from the session SQL database.
8577    ///
8578    /// <div class="warning">
8579    ///
8580    /// **Experimental.** This API is part of an experimental wire-protocol surface
8581    /// and may change or be removed in future SDK or CLI releases. Pin both the
8582    /// SDK and CLI versions if your code depends on it.
8583    ///
8584    /// </div>
8585    pub async fn read_sql_todos_with_dependencies(
8586        &self,
8587    ) -> Result<PlanReadSqlTodosWithDependenciesResult, Error> {
8588        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8589        let _value = self
8590            .session
8591            .client()
8592            .call(
8593                rpc_methods::SESSION_PLAN_READSQLTODOSWITHDEPENDENCIES,
8594                Some(wire_params),
8595            )
8596            .await?;
8597        Ok(serde_json::from_value(_value)?)
8598    }
8599}
8600
8601/// `session.plugins.*` RPCs.
8602#[derive(Clone, Copy)]
8603pub struct SessionRpcPlugins<'a> {
8604    pub(crate) session: &'a Session,
8605}
8606
8607impl<'a> SessionRpcPlugins<'a> {
8608    /// Lists plugins installed for the session.
8609    ///
8610    /// Wire method: `session.plugins.list`.
8611    ///
8612    /// # Returns
8613    ///
8614    /// Plugins installed for the session, with their enabled state and version metadata.
8615    ///
8616    /// <div class="warning">
8617    ///
8618    /// **Experimental.** This API is part of an experimental wire-protocol surface
8619    /// and may change or be removed in future SDK or CLI releases. Pin both the
8620    /// SDK and CLI versions if your code depends on it.
8621    ///
8622    /// </div>
8623    pub async fn list(&self) -> Result<PluginList, Error> {
8624        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8625        let _value = self
8626            .session
8627            .client()
8628            .call(rpc_methods::SESSION_PLUGINS_LIST, Some(wire_params))
8629            .await?;
8630        Ok(serde_json::from_value(_value)?)
8631    }
8632
8633    /// 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.
8634    ///
8635    /// Wire method: `session.plugins.reload`.
8636    ///
8637    /// <div class="warning">
8638    ///
8639    /// **Experimental.** This API is part of an experimental wire-protocol surface
8640    /// and may change or be removed in future SDK or CLI releases. Pin both the
8641    /// SDK and CLI versions if your code depends on it.
8642    ///
8643    /// </div>
8644    pub async fn reload(&self) -> Result<(), Error> {
8645        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8646        let _value = self
8647            .session
8648            .client()
8649            .call(rpc_methods::SESSION_PLUGINS_RELOAD, Some(wire_params))
8650            .await?;
8651        Ok(())
8652    }
8653
8654    /// 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.
8655    ///
8656    /// Wire method: `session.plugins.reload`.
8657    ///
8658    /// # Parameters
8659    ///
8660    /// * `params` - Optional flags controlling which side effects the reload performs.
8661    ///
8662    /// <div class="warning">
8663    ///
8664    /// **Experimental.** This API is part of an experimental wire-protocol surface
8665    /// and may change or be removed in future SDK or CLI releases. Pin both the
8666    /// SDK and CLI versions if your code depends on it.
8667    ///
8668    /// </div>
8669    pub async fn reload_with_params(&self, params: PluginsReloadRequest) -> Result<(), Error> {
8670        let mut wire_params = serde_json::to_value(params)?;
8671        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8672        let _value = self
8673            .session
8674            .client()
8675            .call(rpc_methods::SESSION_PLUGINS_RELOAD, Some(wire_params))
8676            .await?;
8677        Ok(())
8678    }
8679}
8680
8681/// `session.provider.*` RPCs.
8682#[derive(Clone, Copy)]
8683pub struct SessionRpcProvider<'a> {
8684    pub(crate) session: &'a Session,
8685}
8686
8687impl<'a> SessionRpcProvider<'a> {
8688    /// 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.
8689    ///
8690    /// Wire method: `session.provider.getEndpoint`.
8691    ///
8692    /// # Returns
8693    ///
8694    /// A snapshot of the provider endpoint the session is currently configured to talk to.
8695    ///
8696    /// <div class="warning">
8697    ///
8698    /// **Experimental.** This API is part of an experimental wire-protocol surface
8699    /// and may change or be removed in future SDK or CLI releases. Pin both the
8700    /// SDK and CLI versions if your code depends on it.
8701    ///
8702    /// </div>
8703    pub async fn get_endpoint(&self) -> Result<ProviderEndpoint, Error> {
8704        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8705        let _value = self
8706            .session
8707            .client()
8708            .call(rpc_methods::SESSION_PROVIDER_GETENDPOINT, Some(wire_params))
8709            .await?;
8710        Ok(serde_json::from_value(_value)?)
8711    }
8712
8713    /// 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.
8714    ///
8715    /// Wire method: `session.provider.getEndpoint`.
8716    ///
8717    /// # Parameters
8718    ///
8719    /// * `params` - Optional model identifier to scope the endpoint snapshot to.
8720    ///
8721    /// # Returns
8722    ///
8723    /// A snapshot of the provider endpoint the session is currently configured to talk to.
8724    ///
8725    /// <div class="warning">
8726    ///
8727    /// **Experimental.** This API is part of an experimental wire-protocol surface
8728    /// and may change or be removed in future SDK or CLI releases. Pin both the
8729    /// SDK and CLI versions if your code depends on it.
8730    ///
8731    /// </div>
8732    pub async fn get_endpoint_with_params(
8733        &self,
8734        params: ProviderGetEndpointRequest,
8735    ) -> Result<ProviderEndpoint, Error> {
8736        let mut wire_params = serde_json::to_value(params)?;
8737        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8738        let _value = self
8739            .session
8740            .client()
8741            .call(rpc_methods::SESSION_PROVIDER_GETENDPOINT, Some(wire_params))
8742            .await?;
8743        Ok(serde_json::from_value(_value)?)
8744    }
8745
8746    /// 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.
8747    ///
8748    /// Wire method: `session.provider.add`.
8749    ///
8750    /// # Parameters
8751    ///
8752    /// * `params` - BYOK providers and/or models to add to the session's registry at runtime. Both fields are optional; provide providers, models, or both.
8753    ///
8754    /// # Returns
8755    ///
8756    /// The selectable model entries synthesized for the models added by this call.
8757    ///
8758    /// <div class="warning">
8759    ///
8760    /// **Experimental.** This API is part of an experimental wire-protocol surface
8761    /// and may change or be removed in future SDK or CLI releases. Pin both the
8762    /// SDK and CLI versions if your code depends on it.
8763    ///
8764    /// </div>
8765    pub async fn add(&self, params: ProviderAddRequest) -> Result<ProviderAddResult, Error> {
8766        let mut wire_params = serde_json::to_value(params)?;
8767        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8768        let _value = self
8769            .session
8770            .client()
8771            .call(rpc_methods::SESSION_PROVIDER_ADD, Some(wire_params))
8772            .await?;
8773        Ok(serde_json::from_value(_value)?)
8774    }
8775}
8776
8777/// `session.queue.*` RPCs.
8778#[derive(Clone, Copy)]
8779pub struct SessionRpcQueue<'a> {
8780    pub(crate) session: &'a Session,
8781}
8782
8783impl<'a> SessionRpcQueue<'a> {
8784    /// Returns the local session's pending user-facing queued items and steering messages.
8785    ///
8786    /// Wire method: `session.queue.pendingItems`.
8787    ///
8788    /// # Returns
8789    ///
8790    /// Snapshot of the session's pending queued items and immediate-steering messages.
8791    ///
8792    /// <div class="warning">
8793    ///
8794    /// **Experimental.** This API is part of an experimental wire-protocol surface
8795    /// and may change or be removed in future SDK or CLI releases. Pin both the
8796    /// SDK and CLI versions if your code depends on it.
8797    ///
8798    /// </div>
8799    pub async fn pending_items(&self) -> Result<QueuePendingItemsResult, Error> {
8800        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8801        let _value = self
8802            .session
8803            .client()
8804            .call(rpc_methods::SESSION_QUEUE_PENDINGITEMS, Some(wire_params))
8805            .await?;
8806        Ok(serde_json::from_value(_value)?)
8807    }
8808
8809    /// Returns the internal native queue snapshot for in-process session orchestration.
8810    ///
8811    /// Wire method: `session.queue.snapshot`.
8812    ///
8813    /// # Returns
8814    ///
8815    /// Internal snapshot of native queue state for local session orchestration.
8816    ///
8817    /// <div class="warning">
8818    ///
8819    /// **Experimental.** This API is part of an experimental wire-protocol surface
8820    /// and may change or be removed in future SDK or CLI releases. Pin both the
8821    /// SDK and CLI versions if your code depends on it.
8822    ///
8823    /// </div>
8824    pub(crate) async fn snapshot(&self) -> Result<QueueSnapshotResult, Error> {
8825        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8826        let _value = self
8827            .session
8828            .client()
8829            .call(rpc_methods::SESSION_QUEUE_SNAPSHOT, Some(wire_params))
8830            .await?;
8831        Ok(serde_json::from_value(_value)?)
8832    }
8833
8834    /// Moves an addressable queued item to a public visible position.
8835    ///
8836    /// Wire method: `session.queue.moveItem`.
8837    ///
8838    /// # Parameters
8839    ///
8840    /// * `params` - Parameters for moving a queued item by stable id.
8841    ///
8842    /// # Returns
8843    ///
8844    /// Result of moving a queued item.
8845    ///
8846    /// <div class="warning">
8847    ///
8848    /// **Experimental.** This API is part of an experimental wire-protocol surface
8849    /// and may change or be removed in future SDK or CLI releases. Pin both the
8850    /// SDK and CLI versions if your code depends on it.
8851    ///
8852    /// </div>
8853    pub async fn move_item(
8854        &self,
8855        params: QueueMoveItemRequest,
8856    ) -> Result<QueueMoveItemResult, Error> {
8857        let mut wire_params = serde_json::to_value(params)?;
8858        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8859        let _value = self
8860            .session
8861            .client()
8862            .call(rpc_methods::SESSION_QUEUE_MOVEITEM, Some(wire_params))
8863            .await?;
8864        Ok(serde_json::from_value(_value)?)
8865    }
8866
8867    /// Inserts a new queued message at a public visible position.
8868    ///
8869    /// Wire method: `session.queue.insertAt`.
8870    ///
8871    /// # Parameters
8872    ///
8873    /// * `params` - Parameters for inserting a queued message at a public visible position.
8874    ///
8875    /// # Returns
8876    ///
8877    /// Result of inserting a queued message.
8878    ///
8879    /// <div class="warning">
8880    ///
8881    /// **Experimental.** This API is part of an experimental wire-protocol surface
8882    /// and may change or be removed in future SDK or CLI releases. Pin both the
8883    /// SDK and CLI versions if your code depends on it.
8884    ///
8885    /// </div>
8886    pub async fn insert_at(
8887        &self,
8888        params: QueueInsertAtRequest,
8889    ) -> Result<QueueInsertAtResult, Error> {
8890        let mut wire_params = serde_json::to_value(params)?;
8891        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8892        let _value = self
8893            .session
8894            .client()
8895            .call(rpc_methods::SESSION_QUEUE_INSERTAT, Some(wire_params))
8896            .await?;
8897        Ok(serde_json::from_value(_value)?)
8898    }
8899
8900    /// Removes an addressable queued item by its stable id.
8901    ///
8902    /// Wire method: `session.queue.removeAt`.
8903    ///
8904    /// # Parameters
8905    ///
8906    /// * `params` - Parameters for removing a queued item by stable id.
8907    ///
8908    /// # Returns
8909    ///
8910    /// Result of removing a queued item.
8911    ///
8912    /// <div class="warning">
8913    ///
8914    /// **Experimental.** This API is part of an experimental wire-protocol surface
8915    /// and may change or be removed in future SDK or CLI releases. Pin both the
8916    /// SDK and CLI versions if your code depends on it.
8917    ///
8918    /// </div>
8919    pub async fn remove_at(
8920        &self,
8921        params: QueueRemoveAtRequest,
8922    ) -> Result<QueueRemoveAtResult, Error> {
8923        let mut wire_params = serde_json::to_value(params)?;
8924        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8925        let _value = self
8926            .session
8927            .client()
8928            .call(rpc_methods::SESSION_QUEUE_REMOVEAT, Some(wire_params))
8929            .await?;
8930        Ok(serde_json::from_value(_value)?)
8931    }
8932
8933    /// Updates the text of an addressable single-message queue item.
8934    ///
8935    /// Wire method: `session.queue.updateText`.
8936    ///
8937    /// # Parameters
8938    ///
8939    /// * `params` - Parameters for editing a single queued message.
8940    ///
8941    /// # Returns
8942    ///
8943    /// Result of editing a queued message.
8944    ///
8945    /// <div class="warning">
8946    ///
8947    /// **Experimental.** This API is part of an experimental wire-protocol surface
8948    /// and may change or be removed in future SDK or CLI releases. Pin both the
8949    /// SDK and CLI versions if your code depends on it.
8950    ///
8951    /// </div>
8952    pub async fn update_text(
8953        &self,
8954        params: QueueUpdateTextRequest,
8955    ) -> Result<QueueUpdateTextResult, Error> {
8956        let mut wire_params = serde_json::to_value(params)?;
8957        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8958        let _value = self
8959            .session
8960            .client()
8961            .call(rpc_methods::SESSION_QUEUE_UPDATETEXT, Some(wire_params))
8962            .await?;
8963        Ok(serde_json::from_value(_value)?)
8964    }
8965
8966    /// Duplicates an addressable queued item immediately after its source.
8967    ///
8968    /// Wire method: `session.queue.duplicateAt`.
8969    ///
8970    /// # Parameters
8971    ///
8972    /// * `params` - Parameters for duplicating a queued item.
8973    ///
8974    /// # Returns
8975    ///
8976    /// Result of duplicating a queued item.
8977    ///
8978    /// <div class="warning">
8979    ///
8980    /// **Experimental.** This API is part of an experimental wire-protocol surface
8981    /// and may change or be removed in future SDK or CLI releases. Pin both the
8982    /// SDK and CLI versions if your code depends on it.
8983    ///
8984    /// </div>
8985    pub async fn duplicate_at(
8986        &self,
8987        params: QueueDuplicateAtRequest,
8988    ) -> Result<QueueDuplicateAtResult, Error> {
8989        let mut wire_params = serde_json::to_value(params)?;
8990        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8991        let _value = self
8992            .session
8993            .client()
8994            .call(rpc_methods::SESSION_QUEUE_DUPLICATEAT, Some(wire_params))
8995            .await?;
8996        Ok(serde_json::from_value(_value)?)
8997    }
8998
8999    /// Acquires or releases the queued-lane drain pause.
9000    ///
9001    /// Wire method: `session.queue.setDrainPaused`.
9002    ///
9003    /// # Parameters
9004    ///
9005    /// * `params` - Parameters for acquiring or releasing the queued-lane drain pause. Acquisition is exclusive and non-idempotent: `paused: true` against an already-paused session fails with `queue_already_paused`. The pause is never released automatically — it is not tied to the caller's lifetime, so a client that exits without sending `paused: false` leaves the lane frozen. Release is unowned: `paused: false` clears the pause for any caller, including one that never acquired it.
9006    ///
9007    /// <div class="warning">
9008    ///
9009    /// **Experimental.** This API is part of an experimental wire-protocol surface
9010    /// and may change or be removed in future SDK or CLI releases. Pin both the
9011    /// SDK and CLI versions if your code depends on it.
9012    ///
9013    /// </div>
9014    pub async fn set_drain_paused(&self, params: QueueSetDrainPausedRequest) -> Result<(), Error> {
9015        let mut wire_params = serde_json::to_value(params)?;
9016        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9017        let _value = self
9018            .session
9019            .client()
9020            .call(rpc_methods::SESSION_QUEUE_SETDRAINPAUSED, Some(wire_params))
9021            .await?;
9022        Ok(())
9023    }
9024
9025    /// Moves an addressable queued message into the live turn's steering lane.
9026    ///
9027    /// Wire method: `session.queue.sendNow`.
9028    ///
9029    /// # Parameters
9030    ///
9031    /// * `params` - Parameters for steering a queued message into a live turn.
9032    ///
9033    /// # Returns
9034    ///
9035    /// Result of trying to steer a queued message into a live turn.
9036    ///
9037    /// <div class="warning">
9038    ///
9039    /// **Experimental.** This API is part of an experimental wire-protocol surface
9040    /// and may change or be removed in future SDK or CLI releases. Pin both the
9041    /// SDK and CLI versions if your code depends on it.
9042    ///
9043    /// </div>
9044    pub async fn send_now(&self, params: QueueSendNowRequest) -> Result<QueueSendNowResult, Error> {
9045        let mut wire_params = serde_json::to_value(params)?;
9046        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9047        let _value = self
9048            .session
9049            .client()
9050            .call(rpc_methods::SESSION_QUEUE_SENDNOW, Some(wire_params))
9051            .await?;
9052        Ok(serde_json::from_value(_value)?)
9053    }
9054
9055    /// Reports whether the local session has native queued work pending.
9056    ///
9057    /// Wire method: `session.queue.hasPending`.
9058    ///
9059    /// # Returns
9060    ///
9061    /// Whether the native queue has pending work.
9062    ///
9063    /// <div class="warning">
9064    ///
9065    /// **Experimental.** This API is part of an experimental wire-protocol surface
9066    /// and may change or be removed in future SDK or CLI releases. Pin both the
9067    /// SDK and CLI versions if your code depends on it.
9068    ///
9069    /// </div>
9070    pub(crate) async fn has_pending(&self) -> Result<QueueHasPendingResult, Error> {
9071        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9072        let _value = self
9073            .session
9074            .client()
9075            .call(rpc_methods::SESSION_QUEUE_HASPENDING, Some(wire_params))
9076            .await?;
9077        Ok(serde_json::from_value(_value)?)
9078    }
9079
9080    /// Begins a native deferred-idle drain when background work has quiesced.
9081    ///
9082    /// Wire method: `session.queue.beginDeferredIdleDrain`.
9083    ///
9084    /// # Parameters
9085    ///
9086    /// * `params` - Inputs for starting a deferred-idle drain.
9087    ///
9088    /// # Returns
9089    ///
9090    /// Whether a deferred-idle drain should run.
9091    ///
9092    /// <div class="warning">
9093    ///
9094    /// **Experimental.** This API is part of an experimental wire-protocol surface
9095    /// and may change or be removed in future SDK or CLI releases. Pin both the
9096    /// SDK and CLI versions if your code depends on it.
9097    ///
9098    /// </div>
9099    pub(crate) async fn begin_deferred_idle_drain(
9100        &self,
9101        params: QueueBeginDeferredIdleDrainRequest,
9102    ) -> Result<QueueBeginDeferredIdleDrainResult, Error> {
9103        let mut wire_params = serde_json::to_value(params)?;
9104        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9105        let _value = self
9106            .session
9107            .client()
9108            .call(
9109                rpc_methods::SESSION_QUEUE_BEGINDEFERREDIDLEDRAIN,
9110                Some(wire_params),
9111            )
9112            .await?;
9113        Ok(serde_json::from_value(_value)?)
9114    }
9115
9116    /// Finishes a native deferred-idle drain and reports whether to drain queue work or emit idle.
9117    ///
9118    /// Wire method: `session.queue.finishDeferredIdleDrain`.
9119    ///
9120    /// # Parameters
9121    ///
9122    /// * `params` - Inputs for completing a deferred-idle drain.
9123    ///
9124    /// # Returns
9125    ///
9126    /// Action selected by the native deferred-idle drain.
9127    ///
9128    /// <div class="warning">
9129    ///
9130    /// **Experimental.** This API is part of an experimental wire-protocol surface
9131    /// and may change or be removed in future SDK or CLI releases. Pin both the
9132    /// SDK and CLI versions if your code depends on it.
9133    ///
9134    /// </div>
9135    pub(crate) async fn finish_deferred_idle_drain(
9136        &self,
9137        params: QueueFinishDeferredIdleDrainRequest,
9138    ) -> Result<QueueFinishDeferredIdleDrainResult, Error> {
9139        let mut wire_params = serde_json::to_value(params)?;
9140        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9141        let _value = self
9142            .session
9143            .client()
9144            .call(
9145                rpc_methods::SESSION_QUEUE_FINISHDEFERREDIDLEDRAIN,
9146                Some(wire_params),
9147            )
9148            .await?;
9149        Ok(serde_json::from_value(_value)?)
9150    }
9151
9152    /// Marks session.idle as deferred by native background work state.
9153    ///
9154    /// Wire method: `session.queue.deferSessionIdle`.
9155    ///
9156    /// # Parameters
9157    ///
9158    /// * `params` - Inputs for marking session.idle deferred in native state.
9159    ///
9160    /// <div class="warning">
9161    ///
9162    /// **Experimental.** This API is part of an experimental wire-protocol surface
9163    /// and may change or be removed in future SDK or CLI releases. Pin both the
9164    /// SDK and CLI versions if your code depends on it.
9165    ///
9166    /// </div>
9167    pub(crate) async fn defer_session_idle(
9168        &self,
9169        params: QueueDeferSessionIdleRequest,
9170    ) -> Result<(), Error> {
9171        let mut wire_params = serde_json::to_value(params)?;
9172        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9173        let _value = self
9174            .session
9175            .client()
9176            .call(
9177                rpc_methods::SESSION_QUEUE_DEFERSESSIONIDLE,
9178                Some(wire_params),
9179            )
9180            .await?;
9181        Ok(())
9182    }
9183
9184    /// Removes the most recently queued user-facing item (LIFO).
9185    ///
9186    /// Wire method: `session.queue.removeMostRecent`.
9187    ///
9188    /// # Returns
9189    ///
9190    /// Indicates whether a user-facing pending item was removed.
9191    ///
9192    /// <div class="warning">
9193    ///
9194    /// **Experimental.** This API is part of an experimental wire-protocol surface
9195    /// and may change or be removed in future SDK or CLI releases. Pin both the
9196    /// SDK and CLI versions if your code depends on it.
9197    ///
9198    /// </div>
9199    pub async fn remove_most_recent(&self) -> Result<QueueRemoveMostRecentResult, Error> {
9200        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9201        let _value = self
9202            .session
9203            .client()
9204            .call(
9205                rpc_methods::SESSION_QUEUE_REMOVEMOSTRECENT,
9206                Some(wire_params),
9207            )
9208            .await?;
9209        Ok(serde_json::from_value(_value)?)
9210    }
9211
9212    /// Clears all pending queued items on the local session.
9213    ///
9214    /// Wire method: `session.queue.clear`.
9215    ///
9216    /// <div class="warning">
9217    ///
9218    /// **Experimental.** This API is part of an experimental wire-protocol surface
9219    /// and may change or be removed in future SDK or CLI releases. Pin both the
9220    /// SDK and CLI versions if your code depends on it.
9221    ///
9222    /// </div>
9223    pub async fn clear(&self) -> Result<(), Error> {
9224        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9225        let _value = self
9226            .session
9227            .client()
9228            .call(rpc_methods::SESSION_QUEUE_CLEAR, Some(wire_params))
9229            .await?;
9230        Ok(())
9231    }
9232
9233    /// Consumes queued native system notifications matching an internal filter.
9234    ///
9235    /// Wire method: `session.queue.consumeSystemNotifications`.
9236    ///
9237    /// # Parameters
9238    ///
9239    /// * `params` - Internal filter for consuming queued system notifications.
9240    ///
9241    /// # Returns
9242    ///
9243    /// Indicates whether a user-facing pending item was removed.
9244    ///
9245    /// <div class="warning">
9246    ///
9247    /// **Experimental.** This API is part of an experimental wire-protocol surface
9248    /// and may change or be removed in future SDK or CLI releases. Pin both the
9249    /// SDK and CLI versions if your code depends on it.
9250    ///
9251    /// </div>
9252    pub(crate) async fn consume_system_notifications(
9253        &self,
9254        params: QueueConsumeSystemNotificationsRequest,
9255    ) -> Result<QueueRemoveMostRecentResult, Error> {
9256        let mut wire_params = serde_json::to_value(params)?;
9257        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9258        let _value = self
9259            .session
9260            .client()
9261            .call(
9262                rpc_methods::SESSION_QUEUE_CONSUMESYSTEMNOTIFICATIONS,
9263                Some(wire_params),
9264            )
9265            .await?;
9266        Ok(serde_json::from_value(_value)?)
9267    }
9268
9269    /// Enqueues the internal resume-pending wake item when orphan handling needs a follow-up turn.
9270    ///
9271    /// Wire method: `session.queue.enqueueResumePending`.
9272    ///
9273    /// # Returns
9274    ///
9275    /// Result of enqueueing the resume-pending wake item.
9276    ///
9277    /// <div class="warning">
9278    ///
9279    /// **Experimental.** This API is part of an experimental wire-protocol surface
9280    /// and may change or be removed in future SDK or CLI releases. Pin both the
9281    /// SDK and CLI versions if your code depends on it.
9282    ///
9283    /// </div>
9284    pub(crate) async fn enqueue_resume_pending(
9285        &self,
9286    ) -> Result<QueueEnqueueResumePendingResult, Error> {
9287        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9288        let _value = self
9289            .session
9290            .client()
9291            .call(
9292                rpc_methods::SESSION_QUEUE_ENQUEUERESUMEPENDING,
9293                Some(wire_params),
9294            )
9295            .await?;
9296        Ok(serde_json::from_value(_value)?)
9297    }
9298
9299    /// Drains the native local-session work queue for in-process session orchestration.
9300    ///
9301    /// Wire method: `session.queue.process`.
9302    ///
9303    /// <div class="warning">
9304    ///
9305    /// **Experimental.** This API is part of an experimental wire-protocol surface
9306    /// and may change or be removed in future SDK or CLI releases. Pin both the
9307    /// SDK and CLI versions if your code depends on it.
9308    ///
9309    /// </div>
9310    pub(crate) async fn process(&self) -> Result<(), Error> {
9311        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9312        let _value = self
9313            .session
9314            .client()
9315            .call(rpc_methods::SESSION_QUEUE_PROCESS, Some(wire_params))
9316            .await?;
9317        Ok(())
9318    }
9319}
9320
9321/// `session.remote.*` RPCs.
9322#[derive(Clone, Copy)]
9323pub struct SessionRpcRemote<'a> {
9324    pub(crate) session: &'a Session,
9325}
9326
9327impl<'a> SessionRpcRemote<'a> {
9328    /// Enables remote session export or steering.
9329    ///
9330    /// Wire method: `session.remote.enable`.
9331    ///
9332    /// # Parameters
9333    ///
9334    /// * `params` - Optional remote session mode ("off", "export", or "on"); defaults to enabling both export and remote steering.
9335    ///
9336    /// # Returns
9337    ///
9338    /// GitHub URL for the session and a flag indicating whether remote steering is enabled.
9339    ///
9340    /// <div class="warning">
9341    ///
9342    /// **Experimental.** This API is part of an experimental wire-protocol surface
9343    /// and may change or be removed in future SDK or CLI releases. Pin both the
9344    /// SDK and CLI versions if your code depends on it.
9345    ///
9346    /// </div>
9347    pub async fn enable(&self, params: RemoteEnableRequest) -> Result<RemoteEnableResult, Error> {
9348        let mut wire_params = serde_json::to_value(params)?;
9349        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9350        let _value = self
9351            .session
9352            .client()
9353            .call(rpc_methods::SESSION_REMOTE_ENABLE, Some(wire_params))
9354            .await?;
9355        Ok(serde_json::from_value(_value)?)
9356    }
9357
9358    /// Disables remote session export and steering.
9359    ///
9360    /// Wire method: `session.remote.disable`.
9361    ///
9362    /// <div class="warning">
9363    ///
9364    /// **Experimental.** This API is part of an experimental wire-protocol surface
9365    /// and may change or be removed in future SDK or CLI releases. Pin both the
9366    /// SDK and CLI versions if your code depends on it.
9367    ///
9368    /// </div>
9369    pub async fn disable(&self) -> Result<(), Error> {
9370        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9371        let _value = self
9372            .session
9373            .client()
9374            .call(rpc_methods::SESSION_REMOTE_DISABLE, Some(wire_params))
9375            .await?;
9376        Ok(())
9377    }
9378
9379    /// Persists a remote-steerability change emitted by the host as a session event.
9380    ///
9381    /// Wire method: `session.remote.notifySteerableChanged`.
9382    ///
9383    /// # Parameters
9384    ///
9385    /// * `params` - New remote-steerability state to persist as a `session.remote_steerable_changed` event.
9386    ///
9387    /// # Returns
9388    ///
9389    /// 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.
9390    ///
9391    /// <div class="warning">
9392    ///
9393    /// **Experimental.** This API is part of an experimental wire-protocol surface
9394    /// and may change or be removed in future SDK or CLI releases. Pin both the
9395    /// SDK and CLI versions if your code depends on it.
9396    ///
9397    /// </div>
9398    pub async fn notify_steerable_changed(
9399        &self,
9400        params: RemoteNotifySteerableChangedRequest,
9401    ) -> Result<RemoteNotifySteerableChangedResult, Error> {
9402        let mut wire_params = serde_json::to_value(params)?;
9403        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9404        let _value = self
9405            .session
9406            .client()
9407            .call(
9408                rpc_methods::SESSION_REMOTE_NOTIFYSTEERABLECHANGED,
9409                Some(wire_params),
9410            )
9411            .await?;
9412        Ok(serde_json::from_value(_value)?)
9413    }
9414}
9415
9416/// `session.schedule.*` RPCs.
9417#[derive(Clone, Copy)]
9418pub struct SessionRpcSchedule<'a> {
9419    pub(crate) session: &'a Session,
9420}
9421
9422impl<'a> SessionRpcSchedule<'a> {
9423    /// Lists the session's currently active scheduled prompts.
9424    ///
9425    /// Wire method: `session.schedule.list`.
9426    ///
9427    /// # Returns
9428    ///
9429    /// Snapshot of the currently active recurring prompts for this session.
9430    ///
9431    /// <div class="warning">
9432    ///
9433    /// **Experimental.** This API is part of an experimental wire-protocol surface
9434    /// and may change or be removed in future SDK or CLI releases. Pin both the
9435    /// SDK and CLI versions if your code depends on it.
9436    ///
9437    /// </div>
9438    pub async fn list(&self) -> Result<ScheduleList, Error> {
9439        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9440        let _value = self
9441            .session
9442            .client()
9443            .call(rpc_methods::SESSION_SCHEDULE_LIST, Some(wire_params))
9444            .await?;
9445        Ok(serde_json::from_value(_value)?)
9446    }
9447
9448    /// Hydrates the native schedule registry from persisted session events.
9449    ///
9450    /// Wire method: `session.schedule.hydrate`.
9451    ///
9452    /// <div class="warning">
9453    ///
9454    /// **Experimental.** This API is part of an experimental wire-protocol surface
9455    /// and may change or be removed in future SDK or CLI releases. Pin both the
9456    /// SDK and CLI versions if your code depends on it.
9457    ///
9458    /// </div>
9459    pub(crate) async fn hydrate(&self) -> Result<(), Error> {
9460        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9461        let _value = self
9462            .session
9463            .client()
9464            .call(rpc_methods::SESSION_SCHEDULE_HYDRATE, Some(wire_params))
9465            .await?;
9466        Ok(())
9467    }
9468
9469    /// Reports whether the session has an active self-paced scheduled prompt.
9470    ///
9471    /// Wire method: `session.schedule.hasSelfPaced`.
9472    ///
9473    /// # Returns
9474    ///
9475    /// Whether the session currently has an active self-paced schedule.
9476    ///
9477    /// <div class="warning">
9478    ///
9479    /// **Experimental.** This API is part of an experimental wire-protocol surface
9480    /// and may change or be removed in future SDK or CLI releases. Pin both the
9481    /// SDK and CLI versions if your code depends on it.
9482    ///
9483    /// </div>
9484    pub(crate) async fn has_self_paced(&self) -> Result<ScheduleHasSelfPacedResult, Error> {
9485        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9486        let _value = self
9487            .session
9488            .client()
9489            .call(
9490                rpc_methods::SESSION_SCHEDULE_HASSELFPACED,
9491                Some(wire_params),
9492            )
9493            .await?;
9494        Ok(serde_json::from_value(_value)?)
9495    }
9496
9497    /// Registers a relative-interval scheduled prompt.
9498    ///
9499    /// Wire method: `session.schedule.add`.
9500    ///
9501    /// # Parameters
9502    ///
9503    /// * `params` - Register a relative-interval scheduled prompt.
9504    ///
9505    /// # Returns
9506    ///
9507    /// Result of registering or re-arming a scheduled prompt.
9508    ///
9509    /// <div class="warning">
9510    ///
9511    /// **Experimental.** This API is part of an experimental wire-protocol surface
9512    /// and may change or be removed in future SDK or CLI releases. Pin both the
9513    /// SDK and CLI versions if your code depends on it.
9514    ///
9515    /// </div>
9516    pub(crate) async fn add(&self, params: ScheduleAddRequest) -> Result<ScheduleAddResult, Error> {
9517        let mut wire_params = serde_json::to_value(params)?;
9518        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9519        let _value = self
9520            .session
9521            .client()
9522            .call(rpc_methods::SESSION_SCHEDULE_ADD, Some(wire_params))
9523            .await?;
9524        Ok(serde_json::from_value(_value)?)
9525    }
9526
9527    /// Registers a recurring cron scheduled prompt.
9528    ///
9529    /// Wire method: `session.schedule.addCron`.
9530    ///
9531    /// # Parameters
9532    ///
9533    /// * `params` - Register a cron scheduled prompt.
9534    ///
9535    /// # Returns
9536    ///
9537    /// Result of registering or re-arming a scheduled prompt.
9538    ///
9539    /// <div class="warning">
9540    ///
9541    /// **Experimental.** This API is part of an experimental wire-protocol surface
9542    /// and may change or be removed in future SDK or CLI releases. Pin both the
9543    /// SDK and CLI versions if your code depends on it.
9544    ///
9545    /// </div>
9546    pub(crate) async fn add_cron(
9547        &self,
9548        params: ScheduleAddCronRequest,
9549    ) -> Result<ScheduleAddResult, Error> {
9550        let mut wire_params = serde_json::to_value(params)?;
9551        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9552        let _value = self
9553            .session
9554            .client()
9555            .call(rpc_methods::SESSION_SCHEDULE_ADDCRON, Some(wire_params))
9556            .await?;
9557        Ok(serde_json::from_value(_value)?)
9558    }
9559
9560    /// Registers an absolute-time scheduled prompt.
9561    ///
9562    /// Wire method: `session.schedule.addAt`.
9563    ///
9564    /// # Parameters
9565    ///
9566    /// * `params` - Register an absolute-time scheduled prompt.
9567    ///
9568    /// # Returns
9569    ///
9570    /// Result of registering or re-arming a scheduled prompt.
9571    ///
9572    /// <div class="warning">
9573    ///
9574    /// **Experimental.** This API is part of an experimental wire-protocol surface
9575    /// and may change or be removed in future SDK or CLI releases. Pin both the
9576    /// SDK and CLI versions if your code depends on it.
9577    ///
9578    /// </div>
9579    pub(crate) async fn add_at(
9580        &self,
9581        params: ScheduleAddAtRequest,
9582    ) -> Result<ScheduleAddResult, Error> {
9583        let mut wire_params = serde_json::to_value(params)?;
9584        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9585        let _value = self
9586            .session
9587            .client()
9588            .call(rpc_methods::SESSION_SCHEDULE_ADDAT, Some(wire_params))
9589            .await?;
9590        Ok(serde_json::from_value(_value)?)
9591    }
9592
9593    /// Registers a self-paced scheduled prompt.
9594    ///
9595    /// Wire method: `session.schedule.addSelfPaced`.
9596    ///
9597    /// # Parameters
9598    ///
9599    /// * `params` - Register a self-paced scheduled prompt.
9600    ///
9601    /// # Returns
9602    ///
9603    /// Result of registering or re-arming a scheduled prompt.
9604    ///
9605    /// <div class="warning">
9606    ///
9607    /// **Experimental.** This API is part of an experimental wire-protocol surface
9608    /// and may change or be removed in future SDK or CLI releases. Pin both the
9609    /// SDK and CLI versions if your code depends on it.
9610    ///
9611    /// </div>
9612    pub(crate) async fn add_self_paced(
9613        &self,
9614        params: ScheduleAddSelfPacedRequest,
9615    ) -> Result<ScheduleAddResult, Error> {
9616        let mut wire_params = serde_json::to_value(params)?;
9617        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9618        let _value = self
9619            .session
9620            .client()
9621            .call(
9622                rpc_methods::SESSION_SCHEDULE_ADDSELFPACED,
9623                Some(wire_params),
9624            )
9625            .await?;
9626        Ok(serde_json::from_value(_value)?)
9627    }
9628
9629    /// Re-arms an active self-paced scheduled prompt.
9630    ///
9631    /// Wire method: `session.schedule.rearmSelfPaced`.
9632    ///
9633    /// # Parameters
9634    ///
9635    /// * `params` - Re-arm a self-paced scheduled prompt.
9636    ///
9637    /// # Returns
9638    ///
9639    /// Result of registering or re-arming a scheduled prompt.
9640    ///
9641    /// <div class="warning">
9642    ///
9643    /// **Experimental.** This API is part of an experimental wire-protocol surface
9644    /// and may change or be removed in future SDK or CLI releases. Pin both the
9645    /// SDK and CLI versions if your code depends on it.
9646    ///
9647    /// </div>
9648    pub(crate) async fn rearm_self_paced(
9649        &self,
9650        params: ScheduleRearmSelfPacedRequest,
9651    ) -> Result<ScheduleAddResult, Error> {
9652        let mut wire_params = serde_json::to_value(params)?;
9653        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9654        let _value = self
9655            .session
9656            .client()
9657            .call(
9658                rpc_methods::SESSION_SCHEDULE_REARMSELFPACED,
9659                Some(wire_params),
9660            )
9661            .await?;
9662        Ok(serde_json::from_value(_value)?)
9663    }
9664
9665    /// Removes a scheduled prompt by id.
9666    ///
9667    /// Wire method: `session.schedule.stop`.
9668    ///
9669    /// # Parameters
9670    ///
9671    /// * `params` - Identifier of the scheduled prompt to remove.
9672    ///
9673    /// # Returns
9674    ///
9675    /// Remove a scheduled prompt by id. The result entry is omitted if the id was unknown.
9676    ///
9677    /// <div class="warning">
9678    ///
9679    /// **Experimental.** This API is part of an experimental wire-protocol surface
9680    /// and may change or be removed in future SDK or CLI releases. Pin both the
9681    /// SDK and CLI versions if your code depends on it.
9682    ///
9683    /// </div>
9684    pub async fn stop(&self, params: ScheduleStopRequest) -> Result<ScheduleStopResult, Error> {
9685        let mut wire_params = serde_json::to_value(params)?;
9686        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9687        let _value = self
9688            .session
9689            .client()
9690            .call(rpc_methods::SESSION_SCHEDULE_STOP, Some(wire_params))
9691            .await?;
9692        Ok(serde_json::from_value(_value)?)
9693    }
9694}
9695
9696/// `session.settings.*` RPCs.
9697#[derive(Clone, Copy)]
9698pub struct SessionRpcSettings<'a> {
9699    pub(crate) session: &'a Session,
9700}
9701
9702impl<'a> SessionRpcSettings<'a> {
9703    /// 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.
9704    ///
9705    /// Wire method: `session.settings.snapshot`.
9706    ///
9707    /// # Returns
9708    ///
9709    /// Redacted, serializable view of session runtime settings for SDK boundary consumers. Secrets and raw feature flags are intentionally excluded.
9710    ///
9711    /// <div class="warning">
9712    ///
9713    /// **Experimental.** This API is part of an experimental wire-protocol surface
9714    /// and may change or be removed in future SDK or CLI releases. Pin both the
9715    /// SDK and CLI versions if your code depends on it.
9716    ///
9717    /// </div>
9718    pub(crate) async fn snapshot(&self) -> Result<SessionSettingsSnapshot, Error> {
9719        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9720        let _value = self
9721            .session
9722            .client()
9723            .call(rpc_methods::SESSION_SETTINGS_SNAPSHOT, Some(wire_params))
9724            .await?;
9725        Ok(serde_json::from_value(_value)?)
9726    }
9727
9728    /// 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.
9729    ///
9730    /// Wire method: `session.settings.evaluatePredicate`.
9731    ///
9732    /// # Parameters
9733    ///
9734    /// * `params` - Named Rust-owned settings predicate to evaluate for this session.
9735    ///
9736    /// # Returns
9737    ///
9738    /// Result of evaluating a Rust-owned settings predicate.
9739    ///
9740    /// <div class="warning">
9741    ///
9742    /// **Experimental.** This API is part of an experimental wire-protocol surface
9743    /// and may change or be removed in future SDK or CLI releases. Pin both the
9744    /// SDK and CLI versions if your code depends on it.
9745    ///
9746    /// </div>
9747    pub(crate) async fn evaluate_predicate(
9748        &self,
9749        params: SessionSettingsEvaluatePredicateRequest,
9750    ) -> Result<SessionSettingsEvaluatePredicateResult, Error> {
9751        let mut wire_params = serde_json::to_value(params)?;
9752        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9753        let _value = self
9754            .session
9755            .client()
9756            .call(
9757                rpc_methods::SESSION_SETTINGS_EVALUATEPREDICATE,
9758                Some(wire_params),
9759            )
9760            .await?;
9761        Ok(serde_json::from_value(_value)?)
9762    }
9763}
9764
9765/// `session.shell.*` RPCs.
9766#[derive(Clone, Copy)]
9767pub struct SessionRpcShell<'a> {
9768    pub(crate) session: &'a Session,
9769}
9770
9771impl<'a> SessionRpcShell<'a> {
9772    /// Starts a shell command and streams output through session notifications. The command runs as the leader of its own process group (POSIX) or in a dedicated job object (Windows), so a forced termination — via "shell.kill", the request timeout, or session disposal — signals that whole group/job rather than only the direct child. Two gaps are worth planning for: a command that exits on its own does not trigger that teardown, and on POSIX a descendant that moves itself into a new session or process group (for example via "setsid") leaves the signalled group, so either can leave a background process running.
9773    ///
9774    /// Wire method: `session.shell.exec`.
9775    ///
9776    /// # Parameters
9777    ///
9778    /// * `params` - Shell command to run, with optional working directory and timeout in milliseconds.
9779    ///
9780    /// # Returns
9781    ///
9782    /// Identifier of the spawned process, used to correlate streamed output and exit notifications.
9783    ///
9784    /// <div class="warning">
9785    ///
9786    /// **Experimental.** This API is part of an experimental wire-protocol surface
9787    /// and may change or be removed in future SDK or CLI releases. Pin both the
9788    /// SDK and CLI versions if your code depends on it.
9789    ///
9790    /// </div>
9791    pub async fn exec(&self, params: ShellExecRequest) -> Result<ShellExecResult, Error> {
9792        let mut wire_params = serde_json::to_value(params)?;
9793        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9794        let _value = self
9795            .session
9796            .client()
9797            .call(rpc_methods::SESSION_SHELL_EXEC, Some(wire_params))
9798            .await?;
9799        Ok(serde_json::from_value(_value)?)
9800    }
9801
9802    /// Sends a signal to a shell process previously started via "shell.exec". The signal targets the command's whole process group (POSIX) or job object (Windows), so descendants still in that group are signalled too, not just the direct child. On POSIX a descendant that moved itself into a new session or process group (for example via "setsid") is no longer in the signalled group and survives.
9803    ///
9804    /// Wire method: `session.shell.kill`.
9805    ///
9806    /// # Parameters
9807    ///
9808    /// * `params` - Identifier of a process previously returned by "shell.exec" and the signal to send.
9809    ///
9810    /// # Returns
9811    ///
9812    /// Indicates whether the signal was delivered; false if the process was unknown or already exited.
9813    ///
9814    /// <div class="warning">
9815    ///
9816    /// **Experimental.** This API is part of an experimental wire-protocol surface
9817    /// and may change or be removed in future SDK or CLI releases. Pin both the
9818    /// SDK and CLI versions if your code depends on it.
9819    ///
9820    /// </div>
9821    pub async fn kill(&self, params: ShellKillRequest) -> Result<ShellKillResult, Error> {
9822        let mut wire_params = serde_json::to_value(params)?;
9823        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9824        let _value = self
9825            .session
9826            .client()
9827            .call(rpc_methods::SESSION_SHELL_KILL, Some(wire_params))
9828            .await?;
9829        Ok(serde_json::from_value(_value)?)
9830    }
9831
9832    /// Executes a user-requested shell command through the session runtime.
9833    ///
9834    /// Wire method: `session.shell.executeUserRequested`.
9835    ///
9836    /// # Parameters
9837    ///
9838    /// * `params` - User-requested shell command and cancellation handle.
9839    ///
9840    /// # Returns
9841    ///
9842    /// Result of a user-requested shell command.
9843    ///
9844    /// <div class="warning">
9845    ///
9846    /// **Experimental.** This API is part of an experimental wire-protocol surface
9847    /// and may change or be removed in future SDK or CLI releases. Pin both the
9848    /// SDK and CLI versions if your code depends on it.
9849    ///
9850    /// </div>
9851    pub async fn execute_user_requested(
9852        &self,
9853        params: ShellExecuteUserRequestedRequest,
9854    ) -> Result<UserRequestedShellCommandResult, Error> {
9855        let mut wire_params = serde_json::to_value(params)?;
9856        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9857        let _value = self
9858            .session
9859            .client()
9860            .call(
9861                rpc_methods::SESSION_SHELL_EXECUTEUSERREQUESTED,
9862                Some(wire_params),
9863            )
9864            .await?;
9865        Ok(serde_json::from_value(_value)?)
9866    }
9867
9868    /// Cancels a user-requested shell command by request ID.
9869    ///
9870    /// Wire method: `session.shell.cancelUserRequested`.
9871    ///
9872    /// # Parameters
9873    ///
9874    /// * `params` - User-requested shell execution cancellation handle.
9875    ///
9876    /// # Returns
9877    ///
9878    /// Cancellation result for a user-requested shell command.
9879    ///
9880    /// <div class="warning">
9881    ///
9882    /// **Experimental.** This API is part of an experimental wire-protocol surface
9883    /// and may change or be removed in future SDK or CLI releases. Pin both the
9884    /// SDK and CLI versions if your code depends on it.
9885    ///
9886    /// </div>
9887    pub async fn cancel_user_requested(
9888        &self,
9889        params: ShellCancelUserRequestedRequest,
9890    ) -> Result<CancelUserRequestedShellCommandResult, Error> {
9891        let mut wire_params = serde_json::to_value(params)?;
9892        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9893        let _value = self
9894            .session
9895            .client()
9896            .call(
9897                rpc_methods::SESSION_SHELL_CANCELUSERREQUESTED,
9898                Some(wire_params),
9899            )
9900            .await?;
9901        Ok(serde_json::from_value(_value)?)
9902    }
9903}
9904
9905/// `session.skills.*` RPCs.
9906#[derive(Clone, Copy)]
9907pub struct SessionRpcSkills<'a> {
9908    pub(crate) session: &'a Session,
9909}
9910
9911impl<'a> SessionRpcSkills<'a> {
9912    /// Lists skills available to the session.
9913    ///
9914    /// Wire method: `session.skills.list`.
9915    ///
9916    /// # Returns
9917    ///
9918    /// Skills available to the session, with their enabled state.
9919    ///
9920    /// <div class="warning">
9921    ///
9922    /// **Experimental.** This API is part of an experimental wire-protocol surface
9923    /// and may change or be removed in future SDK or CLI releases. Pin both the
9924    /// SDK and CLI versions if your code depends on it.
9925    ///
9926    /// </div>
9927    pub async fn list(&self) -> Result<SkillList, Error> {
9928        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9929        let _value = self
9930            .session
9931            .client()
9932            .call(rpc_methods::SESSION_SKILLS_LIST, Some(wire_params))
9933            .await?;
9934        Ok(serde_json::from_value(_value)?)
9935    }
9936
9937    /// Returns the skills that have been invoked during this session.
9938    ///
9939    /// Wire method: `session.skills.getInvoked`.
9940    ///
9941    /// # Returns
9942    ///
9943    /// Skills invoked during this session, ordered by invocation time (most recent last).
9944    ///
9945    /// <div class="warning">
9946    ///
9947    /// **Experimental.** This API is part of an experimental wire-protocol surface
9948    /// and may change or be removed in future SDK or CLI releases. Pin both the
9949    /// SDK and CLI versions if your code depends on it.
9950    ///
9951    /// </div>
9952    pub async fn get_invoked(&self) -> Result<SkillsGetInvokedResult, Error> {
9953        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9954        let _value = self
9955            .session
9956            .client()
9957            .call(rpc_methods::SESSION_SKILLS_GETINVOKED, Some(wire_params))
9958            .await?;
9959        Ok(serde_json::from_value(_value)?)
9960    }
9961
9962    /// Enables a skill for the session.
9963    ///
9964    /// Wire method: `session.skills.enable`.
9965    ///
9966    /// # Parameters
9967    ///
9968    /// * `params` - Name of the skill to enable for the session.
9969    ///
9970    /// <div class="warning">
9971    ///
9972    /// **Experimental.** This API is part of an experimental wire-protocol surface
9973    /// and may change or be removed in future SDK or CLI releases. Pin both the
9974    /// SDK and CLI versions if your code depends on it.
9975    ///
9976    /// </div>
9977    pub async fn enable(&self, params: SkillsEnableRequest) -> Result<(), Error> {
9978        let mut wire_params = serde_json::to_value(params)?;
9979        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9980        let _value = self
9981            .session
9982            .client()
9983            .call(rpc_methods::SESSION_SKILLS_ENABLE, Some(wire_params))
9984            .await?;
9985        Ok(())
9986    }
9987
9988    /// Disables a skill for the session.
9989    ///
9990    /// Wire method: `session.skills.disable`.
9991    ///
9992    /// # Parameters
9993    ///
9994    /// * `params` - Name of the skill to disable for the session.
9995    ///
9996    /// <div class="warning">
9997    ///
9998    /// **Experimental.** This API is part of an experimental wire-protocol surface
9999    /// and may change or be removed in future SDK or CLI releases. Pin both the
10000    /// SDK and CLI versions if your code depends on it.
10001    ///
10002    /// </div>
10003    pub async fn disable(&self, params: SkillsDisableRequest) -> Result<(), Error> {
10004        let mut wire_params = serde_json::to_value(params)?;
10005        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10006        let _value = self
10007            .session
10008            .client()
10009            .call(rpc_methods::SESSION_SKILLS_DISABLE, Some(wire_params))
10010            .await?;
10011        Ok(())
10012    }
10013
10014    /// Reloads skill definitions for the session.
10015    ///
10016    /// Wire method: `session.skills.reload`.
10017    ///
10018    /// # Returns
10019    ///
10020    /// Diagnostics from reloading skill definitions, with warnings and errors as separate lists.
10021    ///
10022    /// <div class="warning">
10023    ///
10024    /// **Experimental.** This API is part of an experimental wire-protocol surface
10025    /// and may change or be removed in future SDK or CLI releases. Pin both the
10026    /// SDK and CLI versions if your code depends on it.
10027    ///
10028    /// </div>
10029    pub async fn reload(&self) -> Result<SkillsLoadDiagnostics, Error> {
10030        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10031        let _value = self
10032            .session
10033            .client()
10034            .call(rpc_methods::SESSION_SKILLS_RELOAD, Some(wire_params))
10035            .await?;
10036        Ok(serde_json::from_value(_value)?)
10037    }
10038
10039    /// Ensures the session's skill definitions have been loaded from disk.
10040    ///
10041    /// Wire method: `session.skills.ensureLoaded`.
10042    ///
10043    /// <div class="warning">
10044    ///
10045    /// **Experimental.** This API is part of an experimental wire-protocol surface
10046    /// and may change or be removed in future SDK or CLI releases. Pin both the
10047    /// SDK and CLI versions if your code depends on it.
10048    ///
10049    /// </div>
10050    pub async fn ensure_loaded(&self) -> Result<(), Error> {
10051        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10052        let _value = self
10053            .session
10054            .client()
10055            .call(rpc_methods::SESSION_SKILLS_ENSURELOADED, Some(wire_params))
10056            .await?;
10057        Ok(())
10058    }
10059}
10060
10061/// `session.tasks.*` RPCs.
10062#[derive(Clone, Copy)]
10063pub struct SessionRpcTasks<'a> {
10064    pub(crate) session: &'a Session,
10065}
10066
10067impl<'a> SessionRpcTasks<'a> {
10068    /// Starts a background agent task in the session.
10069    ///
10070    /// Wire method: `session.tasks.startAgent`.
10071    ///
10072    /// # Parameters
10073    ///
10074    /// * `params` - Agent type, prompt, name, and optional description and model override for the new task.
10075    ///
10076    /// # Returns
10077    ///
10078    /// Identifier assigned to the newly started background agent task.
10079    ///
10080    /// <div class="warning">
10081    ///
10082    /// **Experimental.** This API is part of an experimental wire-protocol surface
10083    /// and may change or be removed in future SDK or CLI releases. Pin both the
10084    /// SDK and CLI versions if your code depends on it.
10085    ///
10086    /// </div>
10087    pub async fn start_agent(
10088        &self,
10089        params: TasksStartAgentRequest,
10090    ) -> Result<TasksStartAgentResult, Error> {
10091        let mut wire_params = serde_json::to_value(params)?;
10092        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10093        let _value = self
10094            .session
10095            .client()
10096            .call(rpc_methods::SESSION_TASKS_STARTAGENT, Some(wire_params))
10097            .await?;
10098        Ok(serde_json::from_value(_value)?)
10099    }
10100
10101    /// Lists background tasks tracked by the session.
10102    ///
10103    /// Wire method: `session.tasks.list`.
10104    ///
10105    /// # Returns
10106    ///
10107    /// Background tasks currently tracked by the session.
10108    ///
10109    /// <div class="warning">
10110    ///
10111    /// **Experimental.** This API is part of an experimental wire-protocol surface
10112    /// and may change or be removed in future SDK or CLI releases. Pin both the
10113    /// SDK and CLI versions if your code depends on it.
10114    ///
10115    /// </div>
10116    pub async fn list(&self) -> Result<TaskList, Error> {
10117        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10118        let _value = self
10119            .session
10120            .client()
10121            .call(rpc_methods::SESSION_TASKS_LIST, Some(wire_params))
10122            .await?;
10123        Ok(serde_json::from_value(_value)?)
10124    }
10125
10126    /// Refreshes metadata for any detached background shells the runtime knows about.
10127    ///
10128    /// Wire method: `session.tasks.refresh`.
10129    ///
10130    /// # Returns
10131    ///
10132    /// 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.
10133    ///
10134    /// <div class="warning">
10135    ///
10136    /// **Experimental.** This API is part of an experimental wire-protocol surface
10137    /// and may change or be removed in future SDK or CLI releases. Pin both the
10138    /// SDK and CLI versions if your code depends on it.
10139    ///
10140    /// </div>
10141    pub async fn refresh(&self) -> Result<TasksRefreshResult, Error> {
10142        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10143        let _value = self
10144            .session
10145            .client()
10146            .call(rpc_methods::SESSION_TASKS_REFRESH, Some(wire_params))
10147            .await?;
10148        Ok(serde_json::from_value(_value)?)
10149    }
10150
10151    /// Waits for all in-flight background tasks and any follow-up turns to settle.
10152    ///
10153    /// Wire method: `session.tasks.waitForPending`.
10154    ///
10155    /// # Returns
10156    ///
10157    /// 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).
10158    ///
10159    /// <div class="warning">
10160    ///
10161    /// **Experimental.** This API is part of an experimental wire-protocol surface
10162    /// and may change or be removed in future SDK or CLI releases. Pin both the
10163    /// SDK and CLI versions if your code depends on it.
10164    ///
10165    /// </div>
10166    pub async fn wait_for_pending(&self) -> Result<TasksWaitForPendingResult, Error> {
10167        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10168        let _value = self
10169            .session
10170            .client()
10171            .call(rpc_methods::SESSION_TASKS_WAITFORPENDING, Some(wire_params))
10172            .await?;
10173        Ok(serde_json::from_value(_value)?)
10174    }
10175
10176    /// Returns progress information for a background task by ID.
10177    ///
10178    /// Wire method: `session.tasks.getProgress`.
10179    ///
10180    /// # Parameters
10181    ///
10182    /// * `params` - Identifier of the background task to fetch progress for.
10183    ///
10184    /// # Returns
10185    ///
10186    /// Progress information for the task, or null when no task with that ID is tracked.
10187    ///
10188    /// <div class="warning">
10189    ///
10190    /// **Experimental.** This API is part of an experimental wire-protocol surface
10191    /// and may change or be removed in future SDK or CLI releases. Pin both the
10192    /// SDK and CLI versions if your code depends on it.
10193    ///
10194    /// </div>
10195    pub async fn get_progress(
10196        &self,
10197        params: TasksGetProgressRequest,
10198    ) -> Result<TasksGetProgressResult, Error> {
10199        let mut wire_params = serde_json::to_value(params)?;
10200        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10201        let _value = self
10202            .session
10203            .client()
10204            .call(rpc_methods::SESSION_TASKS_GETPROGRESS, Some(wire_params))
10205            .await?;
10206        Ok(serde_json::from_value(_value)?)
10207    }
10208
10209    /// Returns the first sync-waiting task that can currently be promoted to background mode.
10210    ///
10211    /// Wire method: `session.tasks.getCurrentPromotable`.
10212    ///
10213    /// # Returns
10214    ///
10215    /// The first sync-waiting task that can currently be promoted to background mode.
10216    ///
10217    /// <div class="warning">
10218    ///
10219    /// **Experimental.** This API is part of an experimental wire-protocol surface
10220    /// and may change or be removed in future SDK or CLI releases. Pin both the
10221    /// SDK and CLI versions if your code depends on it.
10222    ///
10223    /// </div>
10224    pub async fn get_current_promotable(&self) -> Result<TasksGetCurrentPromotableResult, Error> {
10225        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10226        let _value = self
10227            .session
10228            .client()
10229            .call(
10230                rpc_methods::SESSION_TASKS_GETCURRENTPROMOTABLE,
10231                Some(wire_params),
10232            )
10233            .await?;
10234        Ok(serde_json::from_value(_value)?)
10235    }
10236
10237    /// Promotes an eligible synchronously-waited task so it continues running in the background.
10238    ///
10239    /// Wire method: `session.tasks.promoteToBackground`.
10240    ///
10241    /// # Parameters
10242    ///
10243    /// * `params` - Identifier of the task to promote to background mode.
10244    ///
10245    /// # Returns
10246    ///
10247    /// Indicates whether the task was successfully promoted to background mode.
10248    ///
10249    /// <div class="warning">
10250    ///
10251    /// **Experimental.** This API is part of an experimental wire-protocol surface
10252    /// and may change or be removed in future SDK or CLI releases. Pin both the
10253    /// SDK and CLI versions if your code depends on it.
10254    ///
10255    /// </div>
10256    pub async fn promote_to_background(
10257        &self,
10258        params: TasksPromoteToBackgroundRequest,
10259    ) -> Result<TasksPromoteToBackgroundResult, Error> {
10260        let mut wire_params = serde_json::to_value(params)?;
10261        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10262        let _value = self
10263            .session
10264            .client()
10265            .call(
10266                rpc_methods::SESSION_TASKS_PROMOTETOBACKGROUND,
10267                Some(wire_params),
10268            )
10269            .await?;
10270        Ok(serde_json::from_value(_value)?)
10271    }
10272
10273    /// Atomically promotes the first promotable sync-waiting task to background mode and returns it.
10274    ///
10275    /// Wire method: `session.tasks.promoteCurrentToBackground`.
10276    ///
10277    /// # Returns
10278    ///
10279    /// The promoted task as it now exists in background mode, omitted if no promotable task was waiting.
10280    ///
10281    /// <div class="warning">
10282    ///
10283    /// **Experimental.** This API is part of an experimental wire-protocol surface
10284    /// and may change or be removed in future SDK or CLI releases. Pin both the
10285    /// SDK and CLI versions if your code depends on it.
10286    ///
10287    /// </div>
10288    pub async fn promote_current_to_background(
10289        &self,
10290    ) -> Result<TasksPromoteCurrentToBackgroundResult, Error> {
10291        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10292        let _value = self
10293            .session
10294            .client()
10295            .call(
10296                rpc_methods::SESSION_TASKS_PROMOTECURRENTTOBACKGROUND,
10297                Some(wire_params),
10298            )
10299            .await?;
10300        Ok(serde_json::from_value(_value)?)
10301    }
10302
10303    /// Cancels a background task.
10304    ///
10305    /// Wire method: `session.tasks.cancel`.
10306    ///
10307    /// # Parameters
10308    ///
10309    /// * `params` - Identifier of the background task to cancel.
10310    ///
10311    /// # Returns
10312    ///
10313    /// Indicates whether the background task was successfully cancelled.
10314    ///
10315    /// <div class="warning">
10316    ///
10317    /// **Experimental.** This API is part of an experimental wire-protocol surface
10318    /// and may change or be removed in future SDK or CLI releases. Pin both the
10319    /// SDK and CLI versions if your code depends on it.
10320    ///
10321    /// </div>
10322    pub async fn cancel(&self, params: TasksCancelRequest) -> Result<TasksCancelResult, Error> {
10323        let mut wire_params = serde_json::to_value(params)?;
10324        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10325        let _value = self
10326            .session
10327            .client()
10328            .call(rpc_methods::SESSION_TASKS_CANCEL, Some(wire_params))
10329            .await?;
10330        Ok(serde_json::from_value(_value)?)
10331    }
10332
10333    /// Removes a completed or cancelled background task from tracking.
10334    ///
10335    /// Wire method: `session.tasks.remove`.
10336    ///
10337    /// # Parameters
10338    ///
10339    /// * `params` - Identifier of the completed or cancelled task to remove from tracking.
10340    ///
10341    /// # Returns
10342    ///
10343    /// Indicates whether the task was removed. False when the task does not exist or is still running/idle.
10344    ///
10345    /// <div class="warning">
10346    ///
10347    /// **Experimental.** This API is part of an experimental wire-protocol surface
10348    /// and may change or be removed in future SDK or CLI releases. Pin both the
10349    /// SDK and CLI versions if your code depends on it.
10350    ///
10351    /// </div>
10352    pub async fn remove(&self, params: TasksRemoveRequest) -> Result<TasksRemoveResult, Error> {
10353        let mut wire_params = serde_json::to_value(params)?;
10354        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10355        let _value = self
10356            .session
10357            .client()
10358            .call(rpc_methods::SESSION_TASKS_REMOVE, Some(wire_params))
10359            .await?;
10360        Ok(serde_json::from_value(_value)?)
10361    }
10362
10363    /// Sends a message to a background agent task.
10364    ///
10365    /// Wire method: `session.tasks.sendMessage`.
10366    ///
10367    /// # Parameters
10368    ///
10369    /// * `params` - Identifier of the target agent task, message content, and optional sender agent ID.
10370    ///
10371    /// # Returns
10372    ///
10373    /// Indicates whether the message was delivered, with an error message when delivery failed.
10374    ///
10375    /// <div class="warning">
10376    ///
10377    /// **Experimental.** This API is part of an experimental wire-protocol surface
10378    /// and may change or be removed in future SDK or CLI releases. Pin both the
10379    /// SDK and CLI versions if your code depends on it.
10380    ///
10381    /// </div>
10382    pub async fn send_message(
10383        &self,
10384        params: TasksSendMessageRequest,
10385    ) -> Result<TasksSendMessageResult, Error> {
10386        let mut wire_params = serde_json::to_value(params)?;
10387        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10388        let _value = self
10389            .session
10390            .client()
10391            .call(rpc_methods::SESSION_TASKS_SENDMESSAGE, Some(wire_params))
10392            .await?;
10393        Ok(serde_json::from_value(_value)?)
10394    }
10395}
10396
10397/// `session.telemetry.*` RPCs.
10398#[derive(Clone, Copy)]
10399pub struct SessionRpcTelemetry<'a> {
10400    pub(crate) session: &'a Session,
10401}
10402
10403impl<'a> SessionRpcTelemetry<'a> {
10404    /// Gets the telemetry engagement ID currently associated with the session, when available.
10405    ///
10406    /// Wire method: `session.telemetry.getEngagementId`.
10407    ///
10408    /// # Returns
10409    ///
10410    /// Telemetry engagement ID for the session, when available.
10411    ///
10412    /// <div class="warning">
10413    ///
10414    /// **Experimental.** This API is part of an experimental wire-protocol surface
10415    /// and may change or be removed in future SDK or CLI releases. Pin both the
10416    /// SDK and CLI versions if your code depends on it.
10417    ///
10418    /// </div>
10419    pub async fn get_engagement_id(&self) -> Result<SessionTelemetryEngagement, Error> {
10420        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10421        let _value = self
10422            .session
10423            .client()
10424            .call(
10425                rpc_methods::SESSION_TELEMETRY_GETENGAGEMENTID,
10426                Some(wire_params),
10427            )
10428            .await?;
10429        Ok(serde_json::from_value(_value)?)
10430    }
10431
10432    /// Sets feature override key/value pairs to attach to subsequent telemetry events for the session.
10433    ///
10434    /// Wire method: `session.telemetry.setFeatureOverrides`.
10435    ///
10436    /// # Parameters
10437    ///
10438    /// * `params` - Feature override key/value pairs to attach to subsequent telemetry events from this session.
10439    ///
10440    /// <div class="warning">
10441    ///
10442    /// **Experimental.** This API is part of an experimental wire-protocol surface
10443    /// and may change or be removed in future SDK or CLI releases. Pin both the
10444    /// SDK and CLI versions if your code depends on it.
10445    ///
10446    /// </div>
10447    pub async fn set_feature_overrides(
10448        &self,
10449        params: TelemetrySetFeatureOverridesRequest,
10450    ) -> Result<(), Error> {
10451        let mut wire_params = serde_json::to_value(params)?;
10452        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10453        let _value = self
10454            .session
10455            .client()
10456            .call(
10457                rpc_methods::SESSION_TELEMETRY_SETFEATUREOVERRIDES,
10458                Some(wire_params),
10459            )
10460            .await?;
10461        Ok(())
10462    }
10463}
10464
10465/// `session.tools.*` RPCs.
10466#[derive(Clone, Copy)]
10467pub struct SessionRpcTools<'a> {
10468    pub(crate) session: &'a Session,
10469}
10470
10471impl<'a> SessionRpcTools<'a> {
10472    /// Executes one tool from the session's currently offered tool set through the native invocation pipeline.
10473    ///
10474    /// Wire method: `session.tools.execute`.
10475    ///
10476    /// # Parameters
10477    ///
10478    /// * `params` - A tool name and arguments to execute through the session's native invocation pipeline.
10479    ///
10480    /// # Returns
10481    ///
10482    /// Canonical result returned by a session tool.
10483    ///
10484    /// <div class="warning">
10485    ///
10486    /// **Experimental.** This API is part of an experimental wire-protocol surface
10487    /// and may change or be removed in future SDK or CLI releases. Pin both the
10488    /// SDK and CLI versions if your code depends on it.
10489    ///
10490    /// </div>
10491    pub async fn execute(&self, params: ToolsExecuteRequest) -> Result<ToolResult, Error> {
10492        let mut wire_params = serde_json::to_value(params)?;
10493        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10494        let _value = self
10495            .session
10496            .client()
10497            .call(rpc_methods::SESSION_TOOLS_EXECUTE, Some(wire_params))
10498            .await?;
10499        Ok(serde_json::from_value(_value)?)
10500    }
10501
10502    /// Returns the Rust-owned built-in tool descriptors used to construct the session's offered tool set.
10503    ///
10504    /// Wire method: `session.tools.getBuiltinDescriptors`.
10505    ///
10506    /// # Parameters
10507    ///
10508    /// * `params` - Options controlling how Rust-owned built-in tool descriptors are materialized.
10509    ///
10510    /// # Returns
10511    ///
10512    /// Rust-owned built-in tool descriptors for the session.
10513    ///
10514    /// <div class="warning">
10515    ///
10516    /// **Experimental.** This API is part of an experimental wire-protocol surface
10517    /// and may change or be removed in future SDK or CLI releases. Pin both the
10518    /// SDK and CLI versions if your code depends on it.
10519    ///
10520    /// </div>
10521    pub async fn get_builtin_descriptors(
10522        &self,
10523        params: ToolsGetBuiltinDescriptorsRequest,
10524    ) -> Result<ToolsGetBuiltinDescriptorsResult, Error> {
10525        let mut wire_params = serde_json::to_value(params)?;
10526        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10527        let _value = self
10528            .session
10529            .client()
10530            .call(
10531                rpc_methods::SESSION_TOOLS_GETBUILTINDESCRIPTORS,
10532                Some(wire_params),
10533            )
10534            .await?;
10535        Ok(serde_json::from_value(_value)?)
10536    }
10537
10538    /// Projects a completed task_complete tool call into its label-safe session event payload.
10539    ///
10540    /// Wire method: `session.tools.taskCompleteEventData`.
10541    ///
10542    /// # Parameters
10543    ///
10544    /// * `params` - Task-completion tool arguments and final result used to build a label-safe session event payload.
10545    ///
10546    /// # Returns
10547    ///
10548    /// Task completion notification with summary from the agent
10549    ///
10550    /// <div class="warning">
10551    ///
10552    /// **Experimental.** This API is part of an experimental wire-protocol surface
10553    /// and may change or be removed in future SDK or CLI releases. Pin both the
10554    /// SDK and CLI versions if your code depends on it.
10555    ///
10556    /// </div>
10557    pub async fn task_complete_event_data(
10558        &self,
10559        params: ToolsTaskCompleteEventDataRequest,
10560    ) -> Result<TaskCompleteData, Error> {
10561        let mut wire_params = serde_json::to_value(params)?;
10562        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10563        let _value = self
10564            .session
10565            .client()
10566            .call(
10567                rpc_methods::SESSION_TOOLS_TASKCOMPLETEEVENTDATA,
10568                Some(wire_params),
10569            )
10570            .await?;
10571        Ok(serde_json::from_value(_value)?)
10572    }
10573
10574    /// Provides the result for a pending external tool call.
10575    ///
10576    /// Wire method: `session.tools.handlePendingToolCall`.
10577    ///
10578    /// # Parameters
10579    ///
10580    /// * `params` - Pending external tool call request ID, with the tool result or an error describing why it failed.
10581    ///
10582    /// # Returns
10583    ///
10584    /// Indicates whether the external tool call result was handled successfully.
10585    ///
10586    /// <div class="warning">
10587    ///
10588    /// **Experimental.** This API is part of an experimental wire-protocol surface
10589    /// and may change or be removed in future SDK or CLI releases. Pin both the
10590    /// SDK and CLI versions if your code depends on it.
10591    ///
10592    /// </div>
10593    pub async fn handle_pending_tool_call(
10594        &self,
10595        params: HandlePendingToolCallRequest,
10596    ) -> Result<HandlePendingToolCallResult, Error> {
10597        let mut wire_params = serde_json::to_value(params)?;
10598        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10599        let _value = self
10600            .session
10601            .client()
10602            .call(
10603                rpc_methods::SESSION_TOOLS_HANDLEPENDINGTOOLCALL,
10604                Some(wire_params),
10605            )
10606            .await?;
10607        Ok(serde_json::from_value(_value)?)
10608    }
10609
10610    /// Resolves, builds, and validates the runtime tool list for the session.
10611    ///
10612    /// Wire method: `session.tools.initializeAndValidate`.
10613    ///
10614    /// # Returns
10615    ///
10616    /// 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.
10617    ///
10618    /// <div class="warning">
10619    ///
10620    /// **Experimental.** This API is part of an experimental wire-protocol surface
10621    /// and may change or be removed in future SDK or CLI releases. Pin both the
10622    /// SDK and CLI versions if your code depends on it.
10623    ///
10624    /// </div>
10625    pub async fn initialize_and_validate(&self) -> Result<ToolsInitializeAndValidateResult, Error> {
10626        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10627        let _value = self
10628            .session
10629            .client()
10630            .call(
10631                rpc_methods::SESSION_TOOLS_INITIALIZEANDVALIDATE,
10632                Some(wire_params),
10633            )
10634            .await?;
10635        Ok(serde_json::from_value(_value)?)
10636    }
10637
10638    /// Returns lightweight metadata for the session's currently initialized tools.
10639    ///
10640    /// Wire method: `session.tools.getCurrentMetadata`.
10641    ///
10642    /// # Returns
10643    ///
10644    /// Current lightweight tool metadata snapshot for the session.
10645    ///
10646    /// <div class="warning">
10647    ///
10648    /// **Experimental.** This API is part of an experimental wire-protocol surface
10649    /// and may change or be removed in future SDK or CLI releases. Pin both the
10650    /// SDK and CLI versions if your code depends on it.
10651    ///
10652    /// </div>
10653    pub async fn get_current_metadata(&self) -> Result<ToolsGetCurrentMetadataResult, Error> {
10654        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10655        let _value = self
10656            .session
10657            .client()
10658            .call(
10659                rpc_methods::SESSION_TOOLS_GETCURRENTMETADATA,
10660                Some(wire_params),
10661            )
10662            .await?;
10663        Ok(serde_json::from_value(_value)?)
10664    }
10665
10666    /// Atomically replaces the complete externally implemented tool list supplied by the calling connection. Built-in, MCP/plugin, extension-discovered, subagent, and tools supplied by other connections remain unchanged.
10667    ///
10668    /// Wire method: `session.tools.set`.
10669    ///
10670    /// # Parameters
10671    ///
10672    /// * `params` - Complete externally implemented tool list for the calling connection. An empty list removes every tool previously supplied by that connection.
10673    ///
10674    /// # Returns
10675    ///
10676    /// Empty result after replacing the calling connection's externally implemented tools.
10677    ///
10678    /// <div class="warning">
10679    ///
10680    /// **Experimental.** This API is part of an experimental wire-protocol surface
10681    /// and may change or be removed in future SDK or CLI releases. Pin both the
10682    /// SDK and CLI versions if your code depends on it.
10683    ///
10684    /// </div>
10685    pub async fn set(&self, params: ToolsSetRequest) -> Result<ToolsSetResult, Error> {
10686        let mut wire_params = serde_json::to_value(params)?;
10687        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10688        let _value = self
10689            .session
10690            .client()
10691            .call(rpc_methods::SESSION_TOOLS_SET, Some(wire_params))
10692            .await?;
10693        Ok(serde_json::from_value(_value)?)
10694    }
10695
10696    /// Updates the current session's live subagent settings after user settings change. The persisted user settings remain the source of truth for future sessions.
10697    ///
10698    /// Wire method: `session.tools.updateSubagentSettings`.
10699    ///
10700    /// # Parameters
10701    ///
10702    /// * `params` - Subagent settings to apply to the current session
10703    ///
10704    /// # Returns
10705    ///
10706    /// Empty result after applying subagent settings
10707    ///
10708    /// <div class="warning">
10709    ///
10710    /// **Experimental.** This API is part of an experimental wire-protocol surface
10711    /// and may change or be removed in future SDK or CLI releases. Pin both the
10712    /// SDK and CLI versions if your code depends on it.
10713    ///
10714    /// </div>
10715    pub async fn update_subagent_settings(
10716        &self,
10717        params: UpdateSubagentSettingsRequest,
10718    ) -> Result<ToolsUpdateSubagentSettingsResult, Error> {
10719        let mut wire_params = serde_json::to_value(params)?;
10720        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10721        let _value = self
10722            .session
10723            .client()
10724            .call(
10725                rpc_methods::SESSION_TOOLS_UPDATESUBAGENTSETTINGS,
10726                Some(wire_params),
10727            )
10728            .await?;
10729        Ok(serde_json::from_value(_value)?)
10730    }
10731}
10732
10733/// `session.ui.*` RPCs.
10734#[derive(Clone, Copy)]
10735pub struct SessionRpcUi<'a> {
10736    pub(crate) session: &'a Session,
10737}
10738
10739impl<'a> SessionRpcUi<'a> {
10740    /// Runs a transient no-tools model query against the current conversation context.
10741    ///
10742    /// Wire method: `session.ui.ephemeralQuery`.
10743    ///
10744    /// # Parameters
10745    ///
10746    /// * `params` - Transient question to answer without adding it to conversation history.
10747    ///
10748    /// # Returns
10749    ///
10750    /// Completed transient query. Ordered chunks and the terminal outcome are also delivered through `ui.ephemeral_query` session events while it runs.
10751    ///
10752    /// <div class="warning">
10753    ///
10754    /// **Experimental.** This API is part of an experimental wire-protocol surface
10755    /// and may change or be removed in future SDK or CLI releases. Pin both the
10756    /// SDK and CLI versions if your code depends on it.
10757    ///
10758    /// </div>
10759    pub async fn ephemeral_query(
10760        &self,
10761        params: UIEphemeralQueryRequest,
10762    ) -> Result<UIEphemeralQueryResult, Error> {
10763        let mut wire_params = serde_json::to_value(params)?;
10764        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10765        let _value = self
10766            .session
10767            .client()
10768            .call(rpc_methods::SESSION_UI_EPHEMERALQUERY, Some(wire_params))
10769            .await?;
10770        Ok(serde_json::from_value(_value)?)
10771    }
10772
10773    /// Requests structured input from a UI-capable client.
10774    ///
10775    /// Wire method: `session.ui.elicitation`.
10776    ///
10777    /// # Parameters
10778    ///
10779    /// * `params` - Prompt message and JSON schema describing the form fields to elicit from the user.
10780    ///
10781    /// # Returns
10782    ///
10783    /// The elicitation response (accept with form values, decline, or cancel)
10784    ///
10785    /// <div class="warning">
10786    ///
10787    /// **Experimental.** This API is part of an experimental wire-protocol surface
10788    /// and may change or be removed in future SDK or CLI releases. Pin both the
10789    /// SDK and CLI versions if your code depends on it.
10790    ///
10791    /// </div>
10792    pub async fn elicitation(
10793        &self,
10794        params: UIElicitationRequest,
10795    ) -> Result<UIElicitationResponse, Error> {
10796        let mut wire_params = serde_json::to_value(params)?;
10797        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10798        let _value = self
10799            .session
10800            .client()
10801            .call(rpc_methods::SESSION_UI_ELICITATION, Some(wire_params))
10802            .await?;
10803        Ok(serde_json::from_value(_value)?)
10804    }
10805
10806    /// Provides the user response for a pending elicitation request.
10807    ///
10808    /// Wire method: `session.ui.handlePendingElicitation`.
10809    ///
10810    /// # Parameters
10811    ///
10812    /// * `params` - Pending elicitation request ID and the user's response (accept/decline/cancel + form values).
10813    ///
10814    /// # Returns
10815    ///
10816    /// Indicates whether the elicitation response was accepted; false if it was already resolved by another client.
10817    ///
10818    /// <div class="warning">
10819    ///
10820    /// **Experimental.** This API is part of an experimental wire-protocol surface
10821    /// and may change or be removed in future SDK or CLI releases. Pin both the
10822    /// SDK and CLI versions if your code depends on it.
10823    ///
10824    /// </div>
10825    pub async fn handle_pending_elicitation(
10826        &self,
10827        params: UIHandlePendingElicitationRequest,
10828    ) -> Result<UIElicitationResult, Error> {
10829        let mut wire_params = serde_json::to_value(params)?;
10830        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10831        let _value = self
10832            .session
10833            .client()
10834            .call(
10835                rpc_methods::SESSION_UI_HANDLEPENDINGELICITATION,
10836                Some(wire_params),
10837            )
10838            .await?;
10839        Ok(serde_json::from_value(_value)?)
10840    }
10841
10842    /// Resolves a pending `user_input.requested` event with the user's response.
10843    ///
10844    /// Wire method: `session.ui.handlePendingUserInput`.
10845    ///
10846    /// # Parameters
10847    ///
10848    /// * `params` - Request ID of a pending `user_input.requested` event and the user's response.
10849    ///
10850    /// # Returns
10851    ///
10852    /// Indicates whether the pending UI request was resolved by this call.
10853    ///
10854    /// <div class="warning">
10855    ///
10856    /// **Experimental.** This API is part of an experimental wire-protocol surface
10857    /// and may change or be removed in future SDK or CLI releases. Pin both the
10858    /// SDK and CLI versions if your code depends on it.
10859    ///
10860    /// </div>
10861    pub async fn handle_pending_user_input(
10862        &self,
10863        params: UIHandlePendingUserInputRequest,
10864    ) -> Result<UIHandlePendingResult, Error> {
10865        let mut wire_params = serde_json::to_value(params)?;
10866        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10867        let _value = self
10868            .session
10869            .client()
10870            .call(
10871                rpc_methods::SESSION_UI_HANDLEPENDINGUSERINPUT,
10872                Some(wire_params),
10873            )
10874            .await?;
10875        Ok(serde_json::from_value(_value)?)
10876    }
10877
10878    /// Resolves a pending `sampling.requested` event with a sampling result, or rejects it.
10879    ///
10880    /// Wire method: `session.ui.handlePendingSampling`.
10881    ///
10882    /// # Parameters
10883    ///
10884    /// * `params` - Request ID of a pending `sampling.requested` event and an optional sampling result payload (omit to reject).
10885    ///
10886    /// # Returns
10887    ///
10888    /// Indicates whether the pending UI request was resolved by this call.
10889    ///
10890    /// <div class="warning">
10891    ///
10892    /// **Experimental.** This API is part of an experimental wire-protocol surface
10893    /// and may change or be removed in future SDK or CLI releases. Pin both the
10894    /// SDK and CLI versions if your code depends on it.
10895    ///
10896    /// </div>
10897    pub async fn handle_pending_sampling(
10898        &self,
10899        params: UIHandlePendingSamplingRequest,
10900    ) -> Result<UIHandlePendingResult, Error> {
10901        let mut wire_params = serde_json::to_value(params)?;
10902        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10903        let _value = self
10904            .session
10905            .client()
10906            .call(
10907                rpc_methods::SESSION_UI_HANDLEPENDINGSAMPLING,
10908                Some(wire_params),
10909            )
10910            .await?;
10911        Ok(serde_json::from_value(_value)?)
10912    }
10913
10914    /// Resolves a pending `auto_mode_switch.requested` event with the user's accept/decline decision.
10915    ///
10916    /// Wire method: `session.ui.handlePendingAutoModeSwitch`.
10917    ///
10918    /// # Parameters
10919    ///
10920    /// * `params` - Request ID of a pending `auto_mode_switch.requested` event and the user's response.
10921    ///
10922    /// # Returns
10923    ///
10924    /// Indicates whether the pending UI request was resolved by this call.
10925    ///
10926    /// <div class="warning">
10927    ///
10928    /// **Experimental.** This API is part of an experimental wire-protocol surface
10929    /// and may change or be removed in future SDK or CLI releases. Pin both the
10930    /// SDK and CLI versions if your code depends on it.
10931    ///
10932    /// </div>
10933    pub async fn handle_pending_auto_mode_switch(
10934        &self,
10935        params: UIHandlePendingAutoModeSwitchRequest,
10936    ) -> Result<UIHandlePendingResult, Error> {
10937        let mut wire_params = serde_json::to_value(params)?;
10938        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10939        let _value = self
10940            .session
10941            .client()
10942            .call(
10943                rpc_methods::SESSION_UI_HANDLEPENDINGAUTOMODESWITCH,
10944                Some(wire_params),
10945            )
10946            .await?;
10947        Ok(serde_json::from_value(_value)?)
10948    }
10949
10950    /// Resolves a pending `session_limits_exhausted.requested` event with the user's selected limit action.
10951    ///
10952    /// Wire method: `session.ui.handlePendingSessionLimitsExhausted`.
10953    ///
10954    /// # Parameters
10955    ///
10956    /// * `params` - Request ID of a pending `session_limits_exhausted.requested` event and the user's selected limit action.
10957    ///
10958    /// # Returns
10959    ///
10960    /// Indicates whether the pending UI request was resolved by this call.
10961    ///
10962    /// <div class="warning">
10963    ///
10964    /// **Experimental.** This API is part of an experimental wire-protocol surface
10965    /// and may change or be removed in future SDK or CLI releases. Pin both the
10966    /// SDK and CLI versions if your code depends on it.
10967    ///
10968    /// </div>
10969    pub async fn handle_pending_session_limits_exhausted(
10970        &self,
10971        params: UIHandlePendingSessionLimitsExhaustedRequest,
10972    ) -> Result<UIHandlePendingResult, Error> {
10973        let mut wire_params = serde_json::to_value(params)?;
10974        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10975        let _value = self
10976            .session
10977            .client()
10978            .call(
10979                rpc_methods::SESSION_UI_HANDLEPENDINGSESSIONLIMITSEXHAUSTED,
10980                Some(wire_params),
10981            )
10982            .await?;
10983        Ok(serde_json::from_value(_value)?)
10984    }
10985
10986    /// Resolves a pending `exit_plan_mode.requested` event with the user's response.
10987    ///
10988    /// Wire method: `session.ui.handlePendingExitPlanMode`.
10989    ///
10990    /// # Parameters
10991    ///
10992    /// * `params` - Request ID of a pending `exit_plan_mode.requested` event and the user's response.
10993    ///
10994    /// # Returns
10995    ///
10996    /// Indicates whether the pending UI request was resolved by this call.
10997    ///
10998    /// <div class="warning">
10999    ///
11000    /// **Experimental.** This API is part of an experimental wire-protocol surface
11001    /// and may change or be removed in future SDK or CLI releases. Pin both the
11002    /// SDK and CLI versions if your code depends on it.
11003    ///
11004    /// </div>
11005    pub async fn handle_pending_exit_plan_mode(
11006        &self,
11007        params: UIHandlePendingExitPlanModeRequest,
11008    ) -> Result<UIHandlePendingResult, Error> {
11009        let mut wire_params = serde_json::to_value(params)?;
11010        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11011        let _value = self
11012            .session
11013            .client()
11014            .call(
11015                rpc_methods::SESSION_UI_HANDLEPENDINGEXITPLANMODE,
11016                Some(wire_params),
11017            )
11018            .await?;
11019        Ok(serde_json::from_value(_value)?)
11020    }
11021
11022    /// Registers an in-process handler for auto-mode-switch requests so the server bridge skips dispatch.
11023    ///
11024    /// Wire method: `session.ui.registerDirectAutoModeSwitchHandler`.
11025    ///
11026    /// # Returns
11027    ///
11028    /// 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).
11029    ///
11030    /// <div class="warning">
11031    ///
11032    /// **Experimental.** This API is part of an experimental wire-protocol surface
11033    /// and may change or be removed in future SDK or CLI releases. Pin both the
11034    /// SDK and CLI versions if your code depends on it.
11035    ///
11036    /// </div>
11037    pub async fn register_direct_auto_mode_switch_handler(
11038        &self,
11039    ) -> Result<UIRegisterDirectAutoModeSwitchHandlerResult, Error> {
11040        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
11041        let _value = self
11042            .session
11043            .client()
11044            .call(
11045                rpc_methods::SESSION_UI_REGISTERDIRECTAUTOMODESWITCHHANDLER,
11046                Some(wire_params),
11047            )
11048            .await?;
11049        Ok(serde_json::from_value(_value)?)
11050    }
11051
11052    /// Unregisters a previously-registered in-process auto-mode-switch handler by its opaque handle.
11053    ///
11054    /// Wire method: `session.ui.unregisterDirectAutoModeSwitchHandler`.
11055    ///
11056    /// # Parameters
11057    ///
11058    /// * `params` - Opaque handle previously returned by `registerDirectAutoModeSwitchHandler` to release.
11059    ///
11060    /// # Returns
11061    ///
11062    /// Indicates whether the handle was active and the registration count was decremented.
11063    ///
11064    /// <div class="warning">
11065    ///
11066    /// **Experimental.** This API is part of an experimental wire-protocol surface
11067    /// and may change or be removed in future SDK or CLI releases. Pin both the
11068    /// SDK and CLI versions if your code depends on it.
11069    ///
11070    /// </div>
11071    pub async fn unregister_direct_auto_mode_switch_handler(
11072        &self,
11073        params: UIUnregisterDirectAutoModeSwitchHandlerRequest,
11074    ) -> Result<UIUnregisterDirectAutoModeSwitchHandlerResult, Error> {
11075        let mut wire_params = serde_json::to_value(params)?;
11076        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11077        let _value = self
11078            .session
11079            .client()
11080            .call(
11081                rpc_methods::SESSION_UI_UNREGISTERDIRECTAUTOMODESWITCHHANDLER,
11082                Some(wire_params),
11083            )
11084            .await?;
11085        Ok(serde_json::from_value(_value)?)
11086    }
11087}
11088
11089/// `session.usage.*` RPCs.
11090#[derive(Clone, Copy)]
11091pub struct SessionRpcUsage<'a> {
11092    pub(crate) session: &'a Session,
11093}
11094
11095impl<'a> SessionRpcUsage<'a> {
11096    /// Gets accumulated usage metrics for the session.
11097    ///
11098    /// Wire method: `session.usage.getMetrics`.
11099    ///
11100    /// # Returns
11101    ///
11102    /// Accumulated session usage metrics, including premium request cost, token counts, model breakdown, and code-change totals.
11103    ///
11104    /// <div class="warning">
11105    ///
11106    /// **Experimental.** This API is part of an experimental wire-protocol surface
11107    /// and may change or be removed in future SDK or CLI releases. Pin both the
11108    /// SDK and CLI versions if your code depends on it.
11109    ///
11110    /// </div>
11111    pub async fn get_metrics(&self) -> Result<UsageGetMetricsResult, Error> {
11112        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
11113        let _value = self
11114            .session
11115            .client()
11116            .call(rpc_methods::SESSION_USAGE_GETMETRICS, Some(wire_params))
11117            .await?;
11118        Ok(serde_json::from_value(_value)?)
11119    }
11120}
11121
11122/// `session.visibility.*` RPCs.
11123#[derive(Clone, Copy)]
11124pub struct SessionRpcVisibility<'a> {
11125    pub(crate) session: &'a Session,
11126}
11127
11128impl<'a> SessionRpcVisibility<'a> {
11129    /// 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").
11130    ///
11131    /// Wire method: `session.visibility.get`.
11132    ///
11133    /// # Returns
11134    ///
11135    /// Current sharing status and shareable GitHub URL for a session.
11136    ///
11137    /// <div class="warning">
11138    ///
11139    /// **Experimental.** This API is part of an experimental wire-protocol surface
11140    /// and may change or be removed in future SDK or CLI releases. Pin both the
11141    /// SDK and CLI versions if your code depends on it.
11142    ///
11143    /// </div>
11144    pub async fn get(&self) -> Result<VisibilityGetResult, Error> {
11145        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
11146        let _value = self
11147            .session
11148            .client()
11149            .call(rpc_methods::SESSION_VISIBILITY_GET, Some(wire_params))
11150            .await?;
11151        Ok(serde_json::from_value(_value)?)
11152    }
11153
11154    /// 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.
11155    ///
11156    /// Wire method: `session.visibility.set`.
11157    ///
11158    /// # Parameters
11159    ///
11160    /// * `params` - Desired sharing status for the session.
11161    ///
11162    /// # Returns
11163    ///
11164    /// Effective sharing status and shareable GitHub URL after updating session visibility.
11165    ///
11166    /// <div class="warning">
11167    ///
11168    /// **Experimental.** This API is part of an experimental wire-protocol surface
11169    /// and may change or be removed in future SDK or CLI releases. Pin both the
11170    /// SDK and CLI versions if your code depends on it.
11171    ///
11172    /// </div>
11173    pub async fn set(&self, params: VisibilitySetRequest) -> Result<VisibilitySetResult, Error> {
11174        let mut wire_params = serde_json::to_value(params)?;
11175        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11176        let _value = self
11177            .session
11178            .client()
11179            .call(rpc_methods::SESSION_VISIBILITY_SET, Some(wire_params))
11180            .await?;
11181        Ok(serde_json::from_value(_value)?)
11182    }
11183}
11184
11185/// `session.workspaces.*` RPCs.
11186#[derive(Clone, Copy)]
11187pub struct SessionRpcWorkspaces<'a> {
11188    pub(crate) session: &'a Session,
11189}
11190
11191impl<'a> SessionRpcWorkspaces<'a> {
11192    /// Gets current workspace metadata for the session.
11193    ///
11194    /// Wire method: `session.workspaces.getWorkspace`.
11195    ///
11196    /// # Returns
11197    ///
11198    /// Current workspace metadata for the session, including its absolute filesystem path when available.
11199    ///
11200    /// <div class="warning">
11201    ///
11202    /// **Experimental.** This API is part of an experimental wire-protocol surface
11203    /// and may change or be removed in future SDK or CLI releases. Pin both the
11204    /// SDK and CLI versions if your code depends on it.
11205    ///
11206    /// </div>
11207    pub async fn get_workspace(&self) -> Result<WorkspacesGetWorkspaceResult, Error> {
11208        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
11209        let _value = self
11210            .session
11211            .client()
11212            .call(
11213                rpc_methods::SESSION_WORKSPACES_GETWORKSPACE,
11214                Some(wire_params),
11215            )
11216            .await?;
11217        Ok(serde_json::from_value(_value)?)
11218    }
11219
11220    /// Updates workspace metadata for a local session and returns the refreshed workspace.
11221    ///
11222    /// Wire method: `session.workspaces.updateMetadata`.
11223    ///
11224    /// # Parameters
11225    ///
11226    /// * `params` - Workspace metadata fields to update.
11227    ///
11228    /// # Returns
11229    ///
11230    /// Current workspace metadata for the session, including its absolute filesystem path when available.
11231    ///
11232    /// <div class="warning">
11233    ///
11234    /// **Experimental.** This API is part of an experimental wire-protocol surface
11235    /// and may change or be removed in future SDK or CLI releases. Pin both the
11236    /// SDK and CLI versions if your code depends on it.
11237    ///
11238    /// </div>
11239    pub async fn update_metadata(
11240        &self,
11241        params: WorkspacesUpdateMetadataRequest,
11242    ) -> Result<WorkspacesGetWorkspaceResult, Error> {
11243        let mut wire_params = serde_json::to_value(params)?;
11244        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11245        let _value = self
11246            .session
11247            .client()
11248            .call(
11249                rpc_methods::SESSION_WORKSPACES_UPDATEMETADATA,
11250                Some(wire_params),
11251            )
11252            .await?;
11253        Ok(serde_json::from_value(_value)?)
11254    }
11255
11256    /// Ensures a local session workspace exists and returns it.
11257    ///
11258    /// Wire method: `session.workspaces.ensure`.
11259    ///
11260    /// # Parameters
11261    ///
11262    /// * `params` - Optional session context used when creating a local workspace.
11263    ///
11264    /// # Returns
11265    ///
11266    /// Current workspace metadata for the session, including its absolute filesystem path when available.
11267    ///
11268    /// <div class="warning">
11269    ///
11270    /// **Experimental.** This API is part of an experimental wire-protocol surface
11271    /// and may change or be removed in future SDK or CLI releases. Pin both the
11272    /// SDK and CLI versions if your code depends on it.
11273    ///
11274    /// </div>
11275    pub async fn ensure(
11276        &self,
11277        params: WorkspacesEnsureRequest,
11278    ) -> Result<WorkspacesGetWorkspaceResult, Error> {
11279        let mut wire_params = serde_json::to_value(params)?;
11280        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11281        let _value = self
11282            .session
11283            .client()
11284            .call(rpc_methods::SESSION_WORKSPACES_ENSURE, Some(wire_params))
11285            .await?;
11286        Ok(serde_json::from_value(_value)?)
11287    }
11288
11289    /// Lists files stored in the session workspace files directory.
11290    ///
11291    /// Wire method: `session.workspaces.listFiles`.
11292    ///
11293    /// # Returns
11294    ///
11295    /// Relative paths of files stored in the session workspace files directory.
11296    ///
11297    /// <div class="warning">
11298    ///
11299    /// **Experimental.** This API is part of an experimental wire-protocol surface
11300    /// and may change or be removed in future SDK or CLI releases. Pin both the
11301    /// SDK and CLI versions if your code depends on it.
11302    ///
11303    /// </div>
11304    pub async fn list_files(&self) -> Result<WorkspacesListFilesResult, Error> {
11305        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
11306        let _value = self
11307            .session
11308            .client()
11309            .call(rpc_methods::SESSION_WORKSPACES_LISTFILES, Some(wire_params))
11310            .await?;
11311        Ok(serde_json::from_value(_value)?)
11312    }
11313
11314    /// Reads a file from the session workspace files directory.
11315    ///
11316    /// Wire method: `session.workspaces.readFile`.
11317    ///
11318    /// # Parameters
11319    ///
11320    /// * `params` - Relative path of the workspace file to read.
11321    ///
11322    /// # Returns
11323    ///
11324    /// Contents of the requested workspace file as a UTF-8 string.
11325    ///
11326    /// <div class="warning">
11327    ///
11328    /// **Experimental.** This API is part of an experimental wire-protocol surface
11329    /// and may change or be removed in future SDK or CLI releases. Pin both the
11330    /// SDK and CLI versions if your code depends on it.
11331    ///
11332    /// </div>
11333    pub async fn read_file(
11334        &self,
11335        params: WorkspacesReadFileRequest,
11336    ) -> Result<WorkspacesReadFileResult, Error> {
11337        let mut wire_params = serde_json::to_value(params)?;
11338        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11339        let _value = self
11340            .session
11341            .client()
11342            .call(rpc_methods::SESSION_WORKSPACES_READFILE, Some(wire_params))
11343            .await?;
11344        Ok(serde_json::from_value(_value)?)
11345    }
11346
11347    /// Creates or overwrites a file in the session workspace files directory.
11348    ///
11349    /// Wire method: `session.workspaces.createFile`.
11350    ///
11351    /// # Parameters
11352    ///
11353    /// * `params` - Relative path and UTF-8 content for the workspace file to create or overwrite.
11354    ///
11355    /// <div class="warning">
11356    ///
11357    /// **Experimental.** This API is part of an experimental wire-protocol surface
11358    /// and may change or be removed in future SDK or CLI releases. Pin both the
11359    /// SDK and CLI versions if your code depends on it.
11360    ///
11361    /// </div>
11362    pub async fn create_file(&self, params: WorkspacesCreateFileRequest) -> Result<(), Error> {
11363        let mut wire_params = serde_json::to_value(params)?;
11364        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11365        let _value = self
11366            .session
11367            .client()
11368            .call(
11369                rpc_methods::SESSION_WORKSPACES_CREATEFILE,
11370                Some(wire_params),
11371            )
11372            .await?;
11373        Ok(())
11374    }
11375
11376    /// Lists workspace checkpoints in chronological order.
11377    ///
11378    /// Wire method: `session.workspaces.listCheckpoints`.
11379    ///
11380    /// # Returns
11381    ///
11382    /// Workspace checkpoints in chronological order; empty when the workspace is not enabled.
11383    ///
11384    /// <div class="warning">
11385    ///
11386    /// **Experimental.** This API is part of an experimental wire-protocol surface
11387    /// and may change or be removed in future SDK or CLI releases. Pin both the
11388    /// SDK and CLI versions if your code depends on it.
11389    ///
11390    /// </div>
11391    pub async fn list_checkpoints(&self) -> Result<WorkspacesListCheckpointsResult, Error> {
11392        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
11393        let _value = self
11394            .session
11395            .client()
11396            .call(
11397                rpc_methods::SESSION_WORKSPACES_LISTCHECKPOINTS,
11398                Some(wire_params),
11399            )
11400            .await?;
11401        Ok(serde_json::from_value(_value)?)
11402    }
11403
11404    /// Reads the content of a workspace checkpoint by number.
11405    ///
11406    /// Wire method: `session.workspaces.readCheckpoint`.
11407    ///
11408    /// # Parameters
11409    ///
11410    /// * `params` - Checkpoint number to read.
11411    ///
11412    /// # Returns
11413    ///
11414    /// Checkpoint content as a UTF-8 string, or null when the checkpoint or workspace is missing.
11415    ///
11416    /// <div class="warning">
11417    ///
11418    /// **Experimental.** This API is part of an experimental wire-protocol surface
11419    /// and may change or be removed in future SDK or CLI releases. Pin both the
11420    /// SDK and CLI versions if your code depends on it.
11421    ///
11422    /// </div>
11423    pub async fn read_checkpoint(
11424        &self,
11425        params: WorkspacesReadCheckpointRequest,
11426    ) -> Result<WorkspacesReadCheckpointResult, Error> {
11427        let mut wire_params = serde_json::to_value(params)?;
11428        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11429        let _value = self
11430            .session
11431            .client()
11432            .call(
11433                rpc_methods::SESSION_WORKSPACES_READCHECKPOINT,
11434                Some(wire_params),
11435            )
11436            .await?;
11437        Ok(serde_json::from_value(_value)?)
11438    }
11439
11440    /// Adds a compaction summary checkpoint to the local session workspace.
11441    ///
11442    /// Wire method: `session.workspaces.addSummary`.
11443    ///
11444    /// # Parameters
11445    ///
11446    /// * `params` - Compaction summary checkpoint to persist.
11447    ///
11448    /// # Returns
11449    ///
11450    /// Persisted summary metadata and refreshed workspace metadata.
11451    ///
11452    /// <div class="warning">
11453    ///
11454    /// **Experimental.** This API is part of an experimental wire-protocol surface
11455    /// and may change or be removed in future SDK or CLI releases. Pin both the
11456    /// SDK and CLI versions if your code depends on it.
11457    ///
11458    /// </div>
11459    pub async fn add_summary(
11460        &self,
11461        params: WorkspacesAddSummaryRequest,
11462    ) -> Result<WorkspacesAddSummaryResult, Error> {
11463        let mut wire_params = serde_json::to_value(params)?;
11464        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11465        let _value = self
11466            .session
11467            .client()
11468            .call(
11469                rpc_methods::SESSION_WORKSPACES_ADDSUMMARY,
11470                Some(wire_params),
11471            )
11472            .await?;
11473        Ok(serde_json::from_value(_value)?)
11474    }
11475
11476    /// Truncates local workspace compaction summaries after a rollback.
11477    ///
11478    /// Wire method: `session.workspaces.truncateSummaries`.
11479    ///
11480    /// # Parameters
11481    ///
11482    /// * `params` - Rollback point for local workspace summaries.
11483    ///
11484    /// # Returns
11485    ///
11486    /// Current workspace metadata for the session, including its absolute filesystem path when available.
11487    ///
11488    /// <div class="warning">
11489    ///
11490    /// **Experimental.** This API is part of an experimental wire-protocol surface
11491    /// and may change or be removed in future SDK or CLI releases. Pin both the
11492    /// SDK and CLI versions if your code depends on it.
11493    ///
11494    /// </div>
11495    pub async fn truncate_summaries(
11496        &self,
11497        params: WorkspacesTruncateSummariesRequest,
11498    ) -> Result<WorkspacesGetWorkspaceResult, Error> {
11499        let mut wire_params = serde_json::to_value(params)?;
11500        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11501        let _value = self
11502            .session
11503            .client()
11504            .call(
11505                rpc_methods::SESSION_WORKSPACES_TRUNCATESUMMARIES,
11506                Some(wire_params),
11507            )
11508            .await?;
11509        Ok(serde_json::from_value(_value)?)
11510    }
11511
11512    /// Reads the autopilot objective state file from the local session workspace.
11513    ///
11514    /// Wire method: `session.workspaces.readAutopilotObjective`.
11515    ///
11516    /// # Returns
11517    ///
11518    /// Autopilot objective file content, or null when missing.
11519    ///
11520    /// <div class="warning">
11521    ///
11522    /// **Experimental.** This API is part of an experimental wire-protocol surface
11523    /// and may change or be removed in future SDK or CLI releases. Pin both the
11524    /// SDK and CLI versions if your code depends on it.
11525    ///
11526    /// </div>
11527    pub async fn read_autopilot_objective(
11528        &self,
11529    ) -> Result<WorkspacesReadAutopilotObjectiveResult, Error> {
11530        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
11531        let _value = self
11532            .session
11533            .client()
11534            .call(
11535                rpc_methods::SESSION_WORKSPACES_READAUTOPILOTOBJECTIVE,
11536                Some(wire_params),
11537            )
11538            .await?;
11539        Ok(serde_json::from_value(_value)?)
11540    }
11541
11542    /// Writes the autopilot objective state file in the local session workspace.
11543    ///
11544    /// Wire method: `session.workspaces.writeAutopilotObjective`.
11545    ///
11546    /// # Parameters
11547    ///
11548    /// * `params` - Autopilot objective file content to persist.
11549    ///
11550    /// # Returns
11551    ///
11552    /// Result of writing the autopilot objective file.
11553    ///
11554    /// <div class="warning">
11555    ///
11556    /// **Experimental.** This API is part of an experimental wire-protocol surface
11557    /// and may change or be removed in future SDK or CLI releases. Pin both the
11558    /// SDK and CLI versions if your code depends on it.
11559    ///
11560    /// </div>
11561    pub async fn write_autopilot_objective(
11562        &self,
11563        params: WorkspacesWriteAutopilotObjectiveRequest,
11564    ) -> Result<WorkspacesWriteAutopilotObjectiveResult, Error> {
11565        let mut wire_params = serde_json::to_value(params)?;
11566        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11567        let _value = self
11568            .session
11569            .client()
11570            .call(
11571                rpc_methods::SESSION_WORKSPACES_WRITEAUTOPILOTOBJECTIVE,
11572                Some(wire_params),
11573            )
11574            .await?;
11575        Ok(serde_json::from_value(_value)?)
11576    }
11577
11578    /// Deletes the autopilot objective state file from the local session workspace.
11579    ///
11580    /// Wire method: `session.workspaces.deleteAutopilotObjective`.
11581    ///
11582    /// # Returns
11583    ///
11584    /// Result of deleting the autopilot objective file.
11585    ///
11586    /// <div class="warning">
11587    ///
11588    /// **Experimental.** This API is part of an experimental wire-protocol surface
11589    /// and may change or be removed in future SDK or CLI releases. Pin both the
11590    /// SDK and CLI versions if your code depends on it.
11591    ///
11592    /// </div>
11593    pub async fn delete_autopilot_objective(
11594        &self,
11595    ) -> Result<WorkspacesDeleteAutopilotObjectiveResult, Error> {
11596        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
11597        let _value = self
11598            .session
11599            .client()
11600            .call(
11601                rpc_methods::SESSION_WORKSPACES_DELETEAUTOPILOTOBJECTIVE,
11602                Some(wire_params),
11603            )
11604            .await?;
11605        Ok(serde_json::from_value(_value)?)
11606    }
11607
11608    /// Checks whether the local session workspace has an autopilot objective state file.
11609    ///
11610    /// Wire method: `session.workspaces.autopilotObjectiveExists`.
11611    ///
11612    /// # Returns
11613    ///
11614    /// Whether the autopilot objective file exists.
11615    ///
11616    /// <div class="warning">
11617    ///
11618    /// **Experimental.** This API is part of an experimental wire-protocol surface
11619    /// and may change or be removed in future SDK or CLI releases. Pin both the
11620    /// SDK and CLI versions if your code depends on it.
11621    ///
11622    /// </div>
11623    pub async fn autopilot_objective_exists(
11624        &self,
11625    ) -> Result<WorkspacesAutopilotObjectiveExistsResult, Error> {
11626        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
11627        let _value = self
11628            .session
11629            .client()
11630            .call(
11631                rpc_methods::SESSION_WORKSPACES_AUTOPILOTOBJECTIVEEXISTS,
11632                Some(wire_params),
11633            )
11634            .await?;
11635        Ok(serde_json::from_value(_value)?)
11636    }
11637
11638    /// Saves pasted content as a UTF-8 file in the session workspace.
11639    ///
11640    /// Wire method: `session.workspaces.saveLargePaste`.
11641    ///
11642    /// # Parameters
11643    ///
11644    /// * `params` - Pasted content to save as a UTF-8 file in the session workspace.
11645    ///
11646    /// # Returns
11647    ///
11648    /// Descriptor for the saved paste file, or null when the workspace is unavailable.
11649    ///
11650    /// <div class="warning">
11651    ///
11652    /// **Experimental.** This API is part of an experimental wire-protocol surface
11653    /// and may change or be removed in future SDK or CLI releases. Pin both the
11654    /// SDK and CLI versions if your code depends on it.
11655    ///
11656    /// </div>
11657    pub async fn save_large_paste(
11658        &self,
11659        params: WorkspacesSaveLargePasteRequest,
11660    ) -> Result<WorkspacesSaveLargePasteResult, Error> {
11661        let mut wire_params = serde_json::to_value(params)?;
11662        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11663        let _value = self
11664            .session
11665            .client()
11666            .call(
11667                rpc_methods::SESSION_WORKSPACES_SAVELARGEPASTE,
11668                Some(wire_params),
11669            )
11670            .await?;
11671        Ok(serde_json::from_value(_value)?)
11672    }
11673
11674    /// Computes a diff for the session workspace. Never rejects for a busy session: a `session`-mode diff that cannot read the session's file-change captures falls back to an unstaged git diff with `isFallback: true` and reports why in `unavailableReason`.
11675    ///
11676    /// Wire method: `session.workspaces.diff`.
11677    ///
11678    /// # Parameters
11679    ///
11680    /// * `params` - Parameters for computing a workspace diff.
11681    ///
11682    /// # Returns
11683    ///
11684    /// Workspace diff result for the requested mode.
11685    ///
11686    /// <div class="warning">
11687    ///
11688    /// **Experimental.** This API is part of an experimental wire-protocol surface
11689    /// and may change or be removed in future SDK or CLI releases. Pin both the
11690    /// SDK and CLI versions if your code depends on it.
11691    ///
11692    /// </div>
11693    pub async fn diff(&self, params: WorkspacesDiffRequest) -> Result<WorkspaceDiffResult, Error> {
11694        let mut wire_params = serde_json::to_value(params)?;
11695        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11696        let _value = self
11697            .session
11698            .client()
11699            .call(rpc_methods::SESSION_WORKSPACES_DIFF, Some(wire_params))
11700            .await?;
11701        Ok(serde_json::from_value(_value)?)
11702    }
11703}