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    /// `hooks.*` sub-namespace.
68    pub fn hooks(&self) -> ClientRpcHooks<'a> {
69        ClientRpcHooks {
70            client: self.client,
71        }
72    }
73
74    /// `instructions.*` sub-namespace.
75    pub fn instructions(&self) -> ClientRpcInstructions<'a> {
76        ClientRpcInstructions {
77            client: self.client,
78        }
79    }
80
81    /// `llmInference.*` sub-namespace.
82    pub fn llm_inference(&self) -> ClientRpcLlmInference<'a> {
83        ClientRpcLlmInference {
84            client: self.client,
85        }
86    }
87
88    /// `managedSettings.*` sub-namespace.
89    pub fn managed_settings(&self) -> ClientRpcManagedSettings<'a> {
90        ClientRpcManagedSettings {
91            client: self.client,
92        }
93    }
94
95    /// `mcp.*` sub-namespace.
96    pub fn mcp(&self) -> ClientRpcMcp<'a> {
97        ClientRpcMcp {
98            client: self.client,
99        }
100    }
101
102    /// `models.*` sub-namespace.
103    pub fn models(&self) -> ClientRpcModels<'a> {
104        ClientRpcModels {
105            client: self.client,
106        }
107    }
108
109    /// `plugins.*` sub-namespace.
110    pub fn plugins(&self) -> ClientRpcPlugins<'a> {
111        ClientRpcPlugins {
112            client: self.client,
113        }
114    }
115
116    /// `runtime.*` sub-namespace.
117    pub fn runtime(&self) -> ClientRpcRuntime<'a> {
118        ClientRpcRuntime {
119            client: self.client,
120        }
121    }
122
123    /// `secrets.*` sub-namespace.
124    pub fn secrets(&self) -> ClientRpcSecrets<'a> {
125        ClientRpcSecrets {
126            client: self.client,
127        }
128    }
129
130    /// `sessionFs.*` sub-namespace.
131    pub fn session_fs(&self) -> ClientRpcSessionFs<'a> {
132        ClientRpcSessionFs {
133            client: self.client,
134        }
135    }
136
137    /// `sessions.*` sub-namespace.
138    pub fn sessions(&self) -> ClientRpcSessions<'a> {
139        ClientRpcSessions {
140            client: self.client,
141        }
142    }
143
144    /// `skills.*` sub-namespace.
145    pub fn skills(&self) -> ClientRpcSkills<'a> {
146        ClientRpcSkills {
147            client: self.client,
148        }
149    }
150
151    /// `tools.*` sub-namespace.
152    pub fn tools(&self) -> ClientRpcTools<'a> {
153        ClientRpcTools {
154            client: self.client,
155        }
156    }
157
158    /// `user.*` sub-namespace.
159    pub fn user(&self) -> ClientRpcUser<'a> {
160        ClientRpcUser {
161            client: self.client,
162        }
163    }
164
165    /// Checks server responsiveness and returns protocol information.
166    ///
167    /// Wire method: `ping`.
168    ///
169    /// # Parameters
170    ///
171    /// * `params` - Optional message to echo back to the caller.
172    ///
173    /// # Returns
174    ///
175    /// Server liveness response, including the echoed message, current server timestamp, and protocol version.
176    ///
177    /// <div class="warning">
178    ///
179    /// **Experimental.** This API is part of an experimental wire-protocol surface
180    /// and may change or be removed in future SDK or CLI releases. Pin both the
181    /// SDK and CLI versions if your code depends on it.
182    ///
183    /// </div>
184    pub async fn ping(&self, params: PingRequest) -> Result<PingResult, Error> {
185        let wire_params = serde_json::to_value(params)?;
186        let _value = self
187            .client
188            .call(rpc_methods::PING, Some(wire_params))
189            .await?;
190        Ok(serde_json::from_value(_value)?)
191    }
192
193    /// 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.
194    ///
195    /// Wire method: `connect`.
196    ///
197    /// # Parameters
198    ///
199    /// * `params` - Connection-level opt-ins for the `server.connect` handshake. Transport authentication is consumed by the native protocol boundary before dispatch.
200    ///
201    /// # Returns
202    ///
203    /// Handshake result reporting the server's protocol version and package version on success.
204    ///
205    /// <div class="warning">
206    ///
207    /// **Experimental.** This API is part of an experimental wire-protocol surface
208    /// and may change or be removed in future SDK or CLI releases. Pin both the
209    /// SDK and CLI versions if your code depends on it.
210    ///
211    /// </div>
212    pub(crate) async fn connect(&self, params: ConnectRequest) -> Result<ConnectResult, Error> {
213        let wire_params = serde_json::to_value(params)?;
214        let _value = self
215            .client
216            .call(rpc_methods::CONNECT, Some(wire_params))
217            .await?;
218        Ok(serde_json::from_value(_value)?)
219    }
220
221    /// Registers the calling SDK client as the per-entrypoint extension launch provider. Call before creating any sessions. When omitted, the runtime uses its built-in extension launcher.
222    ///
223    /// Wire method: `registerExtensionLaunchProvider`.
224    ///
225    /// <div class="warning">
226    ///
227    /// **Experimental.** This API is part of an experimental wire-protocol surface
228    /// and may change or be removed in future SDK or CLI releases. Pin both the
229    /// SDK and CLI versions if your code depends on it.
230    ///
231    /// </div>
232    pub async fn register_extension_launch_provider(&self) -> Result<(), Error> {
233        let wire_params = serde_json::json!({});
234        let _value = self
235            .client
236            .call(
237                rpc_methods::REGISTEREXTENSIONLAUNCHPROVIDER,
238                Some(wire_params),
239            )
240            .await?;
241        Ok(())
242    }
243}
244
245/// `account.*` RPCs.
246#[derive(Clone, Copy)]
247pub struct ClientRpcAccount<'a> {
248    pub(crate) client: &'a Client,
249}
250
251impl<'a> ClientRpcAccount<'a> {
252    /// Gets Copilot quota usage for the current or opaquely selected authenticated user.
253    ///
254    /// Wire method: `account.getQuota`.
255    ///
256    /// # Returns
257    ///
258    /// Quota usage snapshots for the resolved user, keyed by quota type.
259    ///
260    /// <div class="warning">
261    ///
262    /// **Experimental.** This API is part of an experimental wire-protocol surface
263    /// and may change or be removed in future SDK or CLI releases. Pin both the
264    /// SDK and CLI versions if your code depends on it.
265    ///
266    /// </div>
267    pub async fn get_quota(&self) -> Result<AccountGetQuotaResult, Error> {
268        let wire_params = serde_json::json!({});
269        let _value = self
270            .client
271            .call(rpc_methods::ACCOUNT_GETQUOTA, Some(wire_params))
272            .await?;
273        Ok(serde_json::from_value(_value)?)
274    }
275
276    /// Gets Copilot quota usage for the current or opaquely selected authenticated user.
277    ///
278    /// Wire method: `account.getQuota`.
279    ///
280    /// # Parameters
281    ///
282    /// * `params` - Optional opaque account selection or compatibility GitHub token used to look up quota.
283    ///
284    /// # Returns
285    ///
286    /// Quota usage snapshots for the resolved user, keyed by quota type.
287    ///
288    /// <div class="warning">
289    ///
290    /// **Experimental.** This API is part of an experimental wire-protocol surface
291    /// and may change or be removed in future SDK or CLI releases. Pin both the
292    /// SDK and CLI versions if your code depends on it.
293    ///
294    /// </div>
295    pub async fn get_quota_with_params(
296        &self,
297        params: AccountGetQuotaRequest,
298    ) -> Result<AccountGetQuotaResult, Error> {
299        let wire_params = serde_json::to_value(params)?;
300        let _value = self
301            .client
302            .call(rpc_methods::ACCOUNT_GETQUOTA, Some(wire_params))
303            .await?;
304        Ok(serde_json::from_value(_value)?)
305    }
306
307    /// Gets the currently active authentication credentials from the global auth manager.
308    ///
309    /// Wire method: `account.getCurrentAuth`.
310    ///
311    /// # Returns
312    ///
313    /// Current authentication state
314    ///
315    /// <div class="warning">
316    ///
317    /// **Experimental.** This API is part of an experimental wire-protocol surface
318    /// and may change or be removed in future SDK or CLI releases. Pin both the
319    /// SDK and CLI versions if your code depends on it.
320    ///
321    /// </div>
322    pub async fn get_current_auth(&self) -> Result<AccountGetCurrentAuthResult, Error> {
323        let wire_params = serde_json::json!({});
324        let _value = self
325            .client
326            .call(rpc_methods::ACCOUNT_GETCURRENTAUTH, Some(wire_params))
327            .await?;
328        Ok(serde_json::from_value(_value)?)
329    }
330
331    /// Gets all authenticated users available for account switching.
332    ///
333    /// Wire method: `account.getAllUsers`.
334    ///
335    /// # Returns
336    ///
337    /// List of all authenticated users
338    ///
339    /// <div class="warning">
340    ///
341    /// **Experimental.** This API is part of an experimental wire-protocol surface
342    /// and may change or be removed in future SDK or CLI releases. Pin both the
343    /// SDK and CLI versions if your code depends on it.
344    ///
345    /// </div>
346    pub async fn get_all_users(&self) -> Result<AccountGetAllUsersResult, Error> {
347        let wire_params = serde_json::json!({});
348        let _value = self
349            .client
350            .call(rpc_methods::ACCOUNT_GETALLUSERS, Some(wire_params))
351            .await?;
352        Ok(serde_json::from_value(_value)?)
353    }
354
355    /// Validates and stores authentication credentials. When login is omitted, resolves the authenticated user from the token before persistence.
356    ///
357    /// Wire method: `account.login`.
358    ///
359    /// # Parameters
360    ///
361    /// * `params` - Credentials to validate and store. Omit login to resolve the authenticated user from the token.
362    ///
363    /// # Returns
364    ///
365    /// Result of a successful login; throws on failure
366    ///
367    /// <div class="warning">
368    ///
369    /// **Experimental.** This API is part of an experimental wire-protocol surface
370    /// and may change or be removed in future SDK or CLI releases. Pin both the
371    /// SDK and CLI versions if your code depends on it.
372    ///
373    /// </div>
374    pub async fn login(&self, params: AccountLoginRequest) -> Result<AccountLoginResult, Error> {
375        let wire_params = serde_json::to_value(params)?;
376        let _value = self
377            .client
378            .call(rpc_methods::ACCOUNT_LOGIN, Some(wire_params))
379            .await?;
380        Ok(serde_json::from_value(_value)?)
381    }
382
383    /// Removes user authentication from keychain and persisted state.
384    ///
385    /// Wire method: `account.logout`.
386    ///
387    /// # Parameters
388    ///
389    /// * `params` - User to log out
390    ///
391    /// # Returns
392    ///
393    /// Logout result indicating if more users remain
394    ///
395    /// <div class="warning">
396    ///
397    /// **Experimental.** This API is part of an experimental wire-protocol surface
398    /// and may change or be removed in future SDK or CLI releases. Pin both the
399    /// SDK and CLI versions if your code depends on it.
400    ///
401    /// </div>
402    pub async fn logout(&self, params: AccountLogoutRequest) -> Result<AccountLogoutResult, Error> {
403        let wire_params = serde_json::to_value(params)?;
404        let _value = self
405            .client
406            .call(rpc_methods::ACCOUNT_LOGOUT, Some(wire_params))
407            .await?;
408        Ok(serde_json::from_value(_value)?)
409    }
410}
411
412/// `agentRegistry.*` RPCs.
413#[derive(Clone, Copy)]
414pub struct ClientRpcAgentRegistry<'a> {
415    pub(crate) client: &'a Client,
416}
417
418impl<'a> ClientRpcAgentRegistry<'a> {
419    /// 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.
420    ///
421    /// Wire method: `agentRegistry.spawn`.
422    ///
423    /// # Parameters
424    ///
425    /// * `params` - Inputs to spawn a managed-server child via the controller's spawn delegate.
426    ///
427    /// # Returns
428    ///
429    /// Outcome of an agentRegistry.spawn call.
430    ///
431    /// <div class="warning">
432    ///
433    /// **Experimental.** This API is part of an experimental wire-protocol surface
434    /// and may change or be removed in future SDK or CLI releases. Pin both the
435    /// SDK and CLI versions if your code depends on it.
436    ///
437    /// </div>
438    pub async fn spawn(
439        &self,
440        params: AgentRegistrySpawnRequest,
441    ) -> Result<AgentRegistrySpawnResult, Error> {
442        let wire_params = serde_json::to_value(params)?;
443        let _value = self
444            .client
445            .call(rpc_methods::AGENTREGISTRY_SPAWN, Some(wire_params))
446            .await?;
447        Ok(serde_json::from_value(_value)?)
448    }
449}
450
451/// `agents.*` RPCs.
452#[derive(Clone, Copy)]
453pub struct ClientRpcAgents<'a> {
454    pub(crate) client: &'a Client,
455}
456
457impl<'a> ClientRpcAgents<'a> {
458    /// Discovers custom agents across user, project, plugin, and remote sources.
459    ///
460    /// Wire method: `agents.discover`.
461    ///
462    /// # Parameters
463    ///
464    /// * `params` - Optional project paths to include in agent discovery.
465    ///
466    /// # Returns
467    ///
468    /// Agents discovered across user, project, plugin, and remote sources.
469    ///
470    /// <div class="warning">
471    ///
472    /// **Experimental.** This API is part of an experimental wire-protocol surface
473    /// and may change or be removed in future SDK or CLI releases. Pin both the
474    /// SDK and CLI versions if your code depends on it.
475    ///
476    /// </div>
477    pub async fn discover(&self, params: AgentsDiscoverRequest) -> Result<ServerAgentList, Error> {
478        let wire_params = serde_json::to_value(params)?;
479        let _value = self
480            .client
481            .call(rpc_methods::AGENTS_DISCOVER, Some(wire_params))
482            .await?;
483        Ok(serde_json::from_value(_value)?)
484    }
485
486    /// 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.
487    ///
488    /// Wire method: `agents.getDiscoveryPaths`.
489    ///
490    /// # Parameters
491    ///
492    /// * `params` - Optional project paths to include when enumerating agent discovery directories.
493    ///
494    /// # Returns
495    ///
496    /// Canonical locations where custom agents can be created so the runtime will recognize them.
497    ///
498    /// <div class="warning">
499    ///
500    /// **Experimental.** This API is part of an experimental wire-protocol surface
501    /// and may change or be removed in future SDK or CLI releases. Pin both the
502    /// SDK and CLI versions if your code depends on it.
503    ///
504    /// </div>
505    pub async fn get_discovery_paths(
506        &self,
507        params: AgentsGetDiscoveryPathsRequest,
508    ) -> Result<AgentDiscoveryPathList, Error> {
509        let wire_params = serde_json::to_value(params)?;
510        let _value = self
511            .client
512            .call(rpc_methods::AGENTS_GETDISCOVERYPATHS, Some(wire_params))
513            .await?;
514        Ok(serde_json::from_value(_value)?)
515    }
516}
517
518/// `catalog.*` RPCs.
519#[derive(Clone, Copy)]
520pub struct ClientRpcCatalog<'a> {
521    pub(crate) client: &'a Client,
522}
523
524impl<'a> ClientRpcCatalog<'a> {
525    /// 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.
526    ///
527    /// Wire method: `catalog.search`.
528    ///
529    /// # Parameters
530    ///
531    /// * `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.
532    ///
533    /// # Returns
534    ///
535    /// Outcome of a catalog.search call: either bounded inert candidates, or one typed refusal. Never a partial success.
536    ///
537    /// <div class="warning">
538    ///
539    /// **Experimental.** This API is part of an experimental wire-protocol surface
540    /// and may change or be removed in future SDK or CLI releases. Pin both the
541    /// SDK and CLI versions if your code depends on it.
542    ///
543    /// </div>
544    pub async fn search(&self, params: CatalogSearchRequest) -> Result<CatalogSearchResult, Error> {
545        let wire_params = serde_json::to_value(params)?;
546        let _value = self
547            .client
548            .call(rpc_methods::CATALOG_SEARCH, Some(wire_params))
549            .await?;
550        Ok(serde_json::from_value(_value)?)
551    }
552}
553
554/// `commands.*` RPCs.
555#[derive(Clone, Copy)]
556pub struct ClientRpcCommands<'a> {
557    pub(crate) client: &'a Client,
558}
559
560impl<'a> ClientRpcCommands<'a> {
561    /// 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.
562    ///
563    /// Wire method: `commands.list`.
564    ///
565    /// # Returns
566    ///
567    /// Slash commands available in the session, after applying any include/exclude filters.
568    ///
569    /// <div class="warning">
570    ///
571    /// **Experimental.** This API is part of an experimental wire-protocol surface
572    /// and may change or be removed in future SDK or CLI releases. Pin both the
573    /// SDK and CLI versions if your code depends on it.
574    ///
575    /// </div>
576    pub async fn list(&self) -> Result<CommandList, Error> {
577        let wire_params = serde_json::json!({});
578        let _value = self
579            .client
580            .call(rpc_methods::COMMANDS_LIST, Some(wire_params))
581            .await?;
582        Ok(serde_json::from_value(_value)?)
583    }
584}
585
586/// `extensions.*` RPCs.
587#[derive(Clone, Copy)]
588pub struct ClientRpcExtensions<'a> {
589    pub(crate) client: &'a Client,
590}
591
592impl<'a> ClientRpcExtensions<'a> {
593    /// Discovers user and enabled installed-plugin extensions from persisted Copilot home state, including enablement preferences. Launch-scoped additional plugins are not included.
594    ///
595    /// Wire method: `extensions.discover`.
596    ///
597    /// # Returns
598    ///
599    /// Extensions discovered from persisted Copilot home state and their effective loading mode. Launch-scoped additional plugins are not included.
600    ///
601    /// <div class="warning">
602    ///
603    /// **Experimental.** This API is part of an experimental wire-protocol surface
604    /// and may change or be removed in future SDK or CLI releases. Pin both the
605    /// SDK and CLI versions if your code depends on it.
606    ///
607    /// </div>
608    pub async fn discover(&self) -> Result<DiscoveredExtensions, Error> {
609        let wire_params = serde_json::json!({});
610        let _value = self
611            .client
612            .call(rpc_methods::EXTENSIONS_DISCOVER, Some(wire_params))
613            .await?;
614        Ok(serde_json::from_value(_value)?)
615    }
616
617    /// Persistently enables extension IDs for future sessions. Active sessions are unchanged; use session.extensions.enable to update them.
618    ///
619    /// Wire method: `extensions.enable`.
620    ///
621    /// # Parameters
622    ///
623    /// * `params` - Source-qualified extension identifiers to persistently enable for future sessions.
624    ///
625    /// <div class="warning">
626    ///
627    /// **Experimental.** This API is part of an experimental wire-protocol surface
628    /// and may change or be removed in future SDK or CLI releases. Pin both the
629    /// SDK and CLI versions if your code depends on it.
630    ///
631    /// </div>
632    pub async fn enable(&self, params: DiscoveredExtensionsEnableRequest) -> Result<(), Error> {
633        let wire_params = serde_json::to_value(params)?;
634        let _value = self
635            .client
636            .call(rpc_methods::EXTENSIONS_ENABLE, Some(wire_params))
637            .await?;
638        Ok(())
639    }
640
641    /// Persistently disables extension IDs for future sessions. Active sessions are unchanged; use session.extensions.disable to update them.
642    ///
643    /// Wire method: `extensions.disable`.
644    ///
645    /// # Parameters
646    ///
647    /// * `params` - Source-qualified extension identifiers to persistently disable for future sessions.
648    ///
649    /// <div class="warning">
650    ///
651    /// **Experimental.** This API is part of an experimental wire-protocol surface
652    /// and may change or be removed in future SDK or CLI releases. Pin both the
653    /// SDK and CLI versions if your code depends on it.
654    ///
655    /// </div>
656    pub async fn disable(&self, params: DiscoveredExtensionsDisableRequest) -> Result<(), Error> {
657        let wire_params = serde_json::to_value(params)?;
658        let _value = self
659            .client
660            .call(rpc_methods::EXTENSIONS_DISABLE, Some(wire_params))
661            .await?;
662        Ok(())
663    }
664}
665
666/// `hooks.*` RPCs.
667#[derive(Clone, Copy)]
668pub struct ClientRpcHooks<'a> {
669    pub(crate) client: &'a Client,
670}
671
672impl<'a> ClientRpcHooks<'a> {
673    /// Discovers hook actions enabled under server-side discovery settings from user, repository, plugin, and managed-policy sources.
674    ///
675    /// Wire method: `hooks.discover`.
676    ///
677    /// # Parameters
678    ///
679    /// * `params` - Optional project paths and host-exclusion behavior for server-scoped hook discovery.
680    ///
681    /// # Returns
682    ///
683    /// Server-discovered hook actions and partial-load diagnostics from user, repository, plugin, and managed-policy sources. Concrete sessions may include additional session-specific hook sources.
684    ///
685    /// <div class="warning">
686    ///
687    /// **Experimental.** This API is part of an experimental wire-protocol surface
688    /// and may change or be removed in future SDK or CLI releases. Pin both the
689    /// SDK and CLI versions if your code depends on it.
690    ///
691    /// </div>
692    pub async fn discover(
693        &self,
694        params: HooksDiscoverRequest,
695    ) -> Result<HooksDiscoverResult, Error> {
696        let wire_params = serde_json::to_value(params)?;
697        let _value = self
698            .client
699            .call(rpc_methods::HOOKS_DISCOVER, Some(wire_params))
700            .await?;
701        Ok(serde_json::from_value(_value)?)
702    }
703}
704
705/// `instructions.*` RPCs.
706#[derive(Clone, Copy)]
707pub struct ClientRpcInstructions<'a> {
708    pub(crate) client: &'a Client,
709}
710
711impl<'a> ClientRpcInstructions<'a> {
712    /// Discovers instruction sources across user, repository, and plugin sources.
713    ///
714    /// Wire method: `instructions.discover`.
715    ///
716    /// # Parameters
717    ///
718    /// * `params` - Optional project paths to include in instruction discovery.
719    ///
720    /// # Returns
721    ///
722    /// Instruction sources discovered across user, repository, and plugin sources.
723    ///
724    /// <div class="warning">
725    ///
726    /// **Experimental.** This API is part of an experimental wire-protocol surface
727    /// and may change or be removed in future SDK or CLI releases. Pin both the
728    /// SDK and CLI versions if your code depends on it.
729    ///
730    /// </div>
731    pub async fn discover(
732        &self,
733        params: InstructionsDiscoverRequest,
734    ) -> Result<ServerInstructionSourceList, Error> {
735        let wire_params = serde_json::to_value(params)?;
736        let _value = self
737            .client
738            .call(rpc_methods::INSTRUCTIONS_DISCOVER, Some(wire_params))
739            .await?;
740        Ok(serde_json::from_value(_value)?)
741    }
742
743    /// 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.
744    ///
745    /// Wire method: `instructions.getDiscoveryPaths`.
746    ///
747    /// # Parameters
748    ///
749    /// * `params` - Optional project paths to include when enumerating instruction discovery targets.
750    ///
751    /// # Returns
752    ///
753    /// Canonical files and directories where custom instructions can be created so the runtime will recognize them.
754    ///
755    /// <div class="warning">
756    ///
757    /// **Experimental.** This API is part of an experimental wire-protocol surface
758    /// and may change or be removed in future SDK or CLI releases. Pin both the
759    /// SDK and CLI versions if your code depends on it.
760    ///
761    /// </div>
762    pub async fn get_discovery_paths(
763        &self,
764        params: InstructionsGetDiscoveryPathsRequest,
765    ) -> Result<InstructionDiscoveryPathList, Error> {
766        let wire_params = serde_json::to_value(params)?;
767        let _value = self
768            .client
769            .call(
770                rpc_methods::INSTRUCTIONS_GETDISCOVERYPATHS,
771                Some(wire_params),
772            )
773            .await?;
774        Ok(serde_json::from_value(_value)?)
775    }
776}
777
778/// `llmInference.*` RPCs.
779#[derive(Clone, Copy)]
780pub struct ClientRpcLlmInference<'a> {
781    pub(crate) client: &'a Client,
782}
783
784impl<'a> ClientRpcLlmInference<'a> {
785    /// Registers an SDK client as the LLM inference callback provider.
786    ///
787    /// Wire method: `llmInference.setProvider`.
788    ///
789    /// # Returns
790    ///
791    /// Indicates whether the calling client was registered as the LLM inference provider.
792    ///
793    /// <div class="warning">
794    ///
795    /// **Experimental.** This API is part of an experimental wire-protocol surface
796    /// and may change or be removed in future SDK or CLI releases. Pin both the
797    /// SDK and CLI versions if your code depends on it.
798    ///
799    /// </div>
800    pub async fn set_provider(&self) -> Result<LlmInferenceSetProviderResult, Error> {
801        let wire_params = serde_json::json!({});
802        let _value = self
803            .client
804            .call(rpc_methods::LLMINFERENCE_SETPROVIDER, Some(wire_params))
805            .await?;
806        Ok(serde_json::from_value(_value)?)
807    }
808
809    /// 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.
810    ///
811    /// Wire method: `llmInference.httpResponseStart`.
812    ///
813    /// # Parameters
814    ///
815    /// * `params` - Response head.
816    ///
817    /// # Returns
818    ///
819    /// Whether the start frame was accepted.
820    ///
821    /// <div class="warning">
822    ///
823    /// **Experimental.** This API is part of an experimental wire-protocol surface
824    /// and may change or be removed in future SDK or CLI releases. Pin both the
825    /// SDK and CLI versions if your code depends on it.
826    ///
827    /// </div>
828    pub async fn http_response_start(
829        &self,
830        params: LlmInferenceHttpResponseStartRequest,
831    ) -> Result<LlmInferenceHttpResponseStartResult, Error> {
832        let wire_params = serde_json::to_value(params)?;
833        let _value = self
834            .client
835            .call(
836                rpc_methods::LLMINFERENCE_HTTPRESPONSESTART,
837                Some(wire_params),
838            )
839            .await?;
840        Ok(serde_json::from_value(_value)?)
841    }
842
843    /// 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.
844    ///
845    /// Wire method: `llmInference.httpResponseChunk`.
846    ///
847    /// # Parameters
848    ///
849    /// * `params` - A response body chunk or terminal error.
850    ///
851    /// # Returns
852    ///
853    /// Whether the chunk was accepted.
854    ///
855    /// <div class="warning">
856    ///
857    /// **Experimental.** This API is part of an experimental wire-protocol surface
858    /// and may change or be removed in future SDK or CLI releases. Pin both the
859    /// SDK and CLI versions if your code depends on it.
860    ///
861    /// </div>
862    pub async fn http_response_chunk(
863        &self,
864        params: LlmInferenceHttpResponseChunkRequest,
865    ) -> Result<LlmInferenceHttpResponseChunkResult, Error> {
866        let wire_params = serde_json::to_value(params)?;
867        let _value = self
868            .client
869            .call(
870                rpc_methods::LLMINFERENCE_HTTPRESPONSECHUNK,
871                Some(wire_params),
872            )
873            .await?;
874        Ok(serde_json::from_value(_value)?)
875    }
876}
877
878/// `managedSettings.*` RPCs.
879#[derive(Clone, Copy)]
880pub struct ClientRpcManagedSettings<'a> {
881    pub(crate) client: &'a Client,
882}
883
884impl<'a> ClientRpcManagedSettings<'a> {
885    /// 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.
886    ///
887    /// Wire method: `managedSettings.read`.
888    ///
889    /// # Returns
890    ///
891    /// Validated device-managed settings discovered before a session exists.
892    ///
893    /// <div class="warning">
894    ///
895    /// **Experimental.** This API is part of an experimental wire-protocol surface
896    /// and may change or be removed in future SDK or CLI releases. Pin both the
897    /// SDK and CLI versions if your code depends on it.
898    ///
899    /// </div>
900    pub async fn read(&self) -> Result<ManagedSettingsReadResult, Error> {
901        let wire_params = serde_json::json!({});
902        let _value = self
903            .client
904            .call(rpc_methods::MANAGEDSETTINGS_READ, Some(wire_params))
905            .await?;
906        Ok(serde_json::from_value(_value)?)
907    }
908}
909
910/// `mcp.*` RPCs.
911#[derive(Clone, Copy)]
912pub struct ClientRpcMcp<'a> {
913    pub(crate) client: &'a Client,
914}
915
916impl<'a> ClientRpcMcp<'a> {
917    /// `mcp.config.*` sub-namespace.
918    pub fn config(&self) -> ClientRpcMcpConfig<'a> {
919        ClientRpcMcpConfig {
920            client: self.client,
921        }
922    }
923
924    /// Discovers MCP servers from user, workspace, plugin, and builtin sources.
925    ///
926    /// Wire method: `mcp.discover`.
927    ///
928    /// # Parameters
929    ///
930    /// * `params` - Optional working directory used as context for MCP server discovery.
931    ///
932    /// # Returns
933    ///
934    /// MCP servers discovered from user, workspace, plugin, and built-in sources.
935    ///
936    /// <div class="warning">
937    ///
938    /// **Experimental.** This API is part of an experimental wire-protocol surface
939    /// and may change or be removed in future SDK or CLI releases. Pin both the
940    /// SDK and CLI versions if your code depends on it.
941    ///
942    /// </div>
943    pub async fn discover(&self, params: McpDiscoverRequest) -> Result<McpDiscoverResult, Error> {
944        let wire_params = serde_json::to_value(params)?;
945        let _value = self
946            .client
947            .call(rpc_methods::MCP_DISCOVER, Some(wire_params))
948            .await?;
949        Ok(serde_json::from_value(_value)?)
950    }
951
952    /// 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.
953    ///
954    /// Wire method: `mcp.planInstall`.
955    ///
956    /// # Parameters
957    ///
958    /// * `params` - A side-effect-free request for an MCP install plan. Computing a plan never writes configuration, stores a secret, or reloads MCP servers.
959    ///
960    /// # Returns
961    ///
962    /// Outcome of an mcp.planInstall call: either a normalised plan, or one typed refusal. Nothing is written in either case.
963    ///
964    /// <div class="warning">
965    ///
966    /// **Experimental.** This API is part of an experimental wire-protocol surface
967    /// and may change or be removed in future SDK or CLI releases. Pin both the
968    /// SDK and CLI versions if your code depends on it.
969    ///
970    /// </div>
971    pub async fn plan_install(
972        &self,
973        params: McpPlanInstallRequest,
974    ) -> Result<McpPlanInstallResult, Error> {
975        let wire_params = serde_json::to_value(params)?;
976        let _value = self
977            .client
978            .call(rpc_methods::MCP_PLANINSTALL, Some(wire_params))
979            .await?;
980        Ok(serde_json::from_value(_value)?)
981    }
982}
983
984/// `mcp.config.*` RPCs.
985#[derive(Clone, Copy)]
986pub struct ClientRpcMcpConfig<'a> {
987    pub(crate) client: &'a Client,
988}
989
990impl<'a> ClientRpcMcpConfig<'a> {
991    /// Lists MCP servers from user configuration.
992    ///
993    /// Wire method: `mcp.config.list`.
994    ///
995    /// # Returns
996    ///
997    /// User-configured MCP servers, keyed by server name.
998    ///
999    /// <div class="warning">
1000    ///
1001    /// **Experimental.** This API is part of an experimental wire-protocol surface
1002    /// and may change or be removed in future SDK or CLI releases. Pin both the
1003    /// SDK and CLI versions if your code depends on it.
1004    ///
1005    /// </div>
1006    pub async fn list(&self) -> Result<McpConfigList, Error> {
1007        let wire_params = serde_json::json!({});
1008        let _value = self
1009            .client
1010            .call(rpc_methods::MCP_CONFIG_LIST, Some(wire_params))
1011            .await?;
1012        Ok(serde_json::from_value(_value)?)
1013    }
1014
1015    /// Adds an MCP server to user configuration.
1016    ///
1017    /// Wire method: `mcp.config.add`.
1018    ///
1019    /// # Parameters
1020    ///
1021    /// * `params` - MCP server name and configuration to add to user configuration.
1022    ///
1023    /// <div class="warning">
1024    ///
1025    /// **Experimental.** This API is part of an experimental wire-protocol surface
1026    /// and may change or be removed in future SDK or CLI releases. Pin both the
1027    /// SDK and CLI versions if your code depends on it.
1028    ///
1029    /// </div>
1030    pub async fn add(&self, params: McpConfigAddRequest) -> Result<(), Error> {
1031        let wire_params = serde_json::to_value(params)?;
1032        let _value = self
1033            .client
1034            .call(rpc_methods::MCP_CONFIG_ADD, Some(wire_params))
1035            .await?;
1036        Ok(())
1037    }
1038
1039    /// Updates an MCP server in user configuration.
1040    ///
1041    /// Wire method: `mcp.config.update`.
1042    ///
1043    /// # Parameters
1044    ///
1045    /// * `params` - MCP server name and replacement configuration to write to user configuration.
1046    ///
1047    /// <div class="warning">
1048    ///
1049    /// **Experimental.** This API is part of an experimental wire-protocol surface
1050    /// and may change or be removed in future SDK or CLI releases. Pin both the
1051    /// SDK and CLI versions if your code depends on it.
1052    ///
1053    /// </div>
1054    pub async fn update(&self, params: McpConfigUpdateRequest) -> Result<(), Error> {
1055        let wire_params = serde_json::to_value(params)?;
1056        let _value = self
1057            .client
1058            .call(rpc_methods::MCP_CONFIG_UPDATE, Some(wire_params))
1059            .await?;
1060        Ok(())
1061    }
1062
1063    /// Removes an MCP server from user configuration.
1064    ///
1065    /// Wire method: `mcp.config.remove`.
1066    ///
1067    /// # Parameters
1068    ///
1069    /// * `params` - MCP server name to remove from user configuration.
1070    ///
1071    /// <div class="warning">
1072    ///
1073    /// **Experimental.** This API is part of an experimental wire-protocol surface
1074    /// and may change or be removed in future SDK or CLI releases. Pin both the
1075    /// SDK and CLI versions if your code depends on it.
1076    ///
1077    /// </div>
1078    pub async fn remove(&self, params: McpConfigRemoveRequest) -> Result<(), Error> {
1079        let wire_params = serde_json::to_value(params)?;
1080        let _value = self
1081            .client
1082            .call(rpc_methods::MCP_CONFIG_REMOVE, Some(wire_params))
1083            .await?;
1084        Ok(())
1085    }
1086
1087    /// Enables MCP servers in user configuration for new sessions.
1088    ///
1089    /// Wire method: `mcp.config.enable`.
1090    ///
1091    /// # Parameters
1092    ///
1093    /// * `params` - MCP server names to enable for new sessions.
1094    ///
1095    /// <div class="warning">
1096    ///
1097    /// **Experimental.** This API is part of an experimental wire-protocol surface
1098    /// and may change or be removed in future SDK or CLI releases. Pin both the
1099    /// SDK and CLI versions if your code depends on it.
1100    ///
1101    /// </div>
1102    pub async fn enable(&self, params: McpConfigEnableRequest) -> Result<(), Error> {
1103        let wire_params = serde_json::to_value(params)?;
1104        let _value = self
1105            .client
1106            .call(rpc_methods::MCP_CONFIG_ENABLE, Some(wire_params))
1107            .await?;
1108        Ok(())
1109    }
1110
1111    /// Disables MCP servers in user configuration for new sessions.
1112    ///
1113    /// Wire method: `mcp.config.disable`.
1114    ///
1115    /// # Parameters
1116    ///
1117    /// * `params` - MCP server names to disable for new sessions.
1118    ///
1119    /// <div class="warning">
1120    ///
1121    /// **Experimental.** This API is part of an experimental wire-protocol surface
1122    /// and may change or be removed in future SDK or CLI releases. Pin both the
1123    /// SDK and CLI versions if your code depends on it.
1124    ///
1125    /// </div>
1126    pub async fn disable(&self, params: McpConfigDisableRequest) -> Result<(), Error> {
1127        let wire_params = serde_json::to_value(params)?;
1128        let _value = self
1129            .client
1130            .call(rpc_methods::MCP_CONFIG_DISABLE, Some(wire_params))
1131            .await?;
1132        Ok(())
1133    }
1134
1135    /// Drops this runtime process's in-memory MCP server-definition cache so the next MCP config read observes disk.
1136    ///
1137    /// Wire method: `mcp.config.reload`.
1138    ///
1139    /// <div class="warning">
1140    ///
1141    /// **Experimental.** This API is part of an experimental wire-protocol surface
1142    /// and may change or be removed in future SDK or CLI releases. Pin both the
1143    /// SDK and CLI versions if your code depends on it.
1144    ///
1145    /// </div>
1146    pub async fn reload(&self) -> Result<(), Error> {
1147        let wire_params = serde_json::json!({});
1148        let _value = self
1149            .client
1150            .call(rpc_methods::MCP_CONFIG_RELOAD, Some(wire_params))
1151            .await?;
1152        Ok(())
1153    }
1154}
1155
1156/// `models.*` RPCs.
1157#[derive(Clone, Copy)]
1158pub struct ClientRpcModels<'a> {
1159    pub(crate) client: &'a Client,
1160}
1161
1162impl<'a> ClientRpcModels<'a> {
1163    /// Lists Copilot models available to the authenticated user.
1164    ///
1165    /// Wire method: `models.list`.
1166    ///
1167    /// # Returns
1168    ///
1169    /// List of Copilot models available to the resolved user, including capabilities and billing metadata.
1170    ///
1171    /// <div class="warning">
1172    ///
1173    /// **Experimental.** This API is part of an experimental wire-protocol surface
1174    /// and may change or be removed in future SDK or CLI releases. Pin both the
1175    /// SDK and CLI versions if your code depends on it.
1176    ///
1177    /// </div>
1178    pub async fn list(&self) -> Result<ModelList, Error> {
1179        let wire_params = serde_json::json!({});
1180        let _value = self
1181            .client
1182            .call(rpc_methods::MODELS_LIST, Some(wire_params))
1183            .await?;
1184        Ok(serde_json::from_value(_value)?)
1185    }
1186
1187    /// Lists Copilot models available to the authenticated user.
1188    ///
1189    /// Wire method: `models.list`.
1190    ///
1191    /// # Parameters
1192    ///
1193    /// * `params` - Optional opaque account selection or compatibility GitHub token used to list models.
1194    ///
1195    /// # Returns
1196    ///
1197    /// List of Copilot models available to the resolved user, including capabilities and billing metadata.
1198    ///
1199    /// <div class="warning">
1200    ///
1201    /// **Experimental.** This API is part of an experimental wire-protocol surface
1202    /// and may change or be removed in future SDK or CLI releases. Pin both the
1203    /// SDK and CLI versions if your code depends on it.
1204    ///
1205    /// </div>
1206    pub async fn list_with_params(&self, params: ModelsListRequest) -> Result<ModelList, Error> {
1207        let wire_params = serde_json::to_value(params)?;
1208        let _value = self
1209            .client
1210            .call(rpc_methods::MODELS_LIST, Some(wire_params))
1211            .await?;
1212        Ok(serde_json::from_value(_value)?)
1213    }
1214
1215    /// Returns the running runtime's complete catalog of well-known built-in model IDs without authentication or network access.
1216    ///
1217    /// Wire method: `models.getBuiltInCatalog`.
1218    ///
1219    /// # Returns
1220    ///
1221    /// The running runtime's complete catalog of well-known built-in model IDs, including supported models and additional IDs with built-in metadata.
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 get_built_in_catalog(&self) -> Result<BuiltInModelCatalog, Error> {
1231        let wire_params = serde_json::json!({});
1232        let _value = self
1233            .client
1234            .call(rpc_methods::MODELS_GETBUILTINCATALOG, Some(wire_params))
1235            .await?;
1236        Ok(serde_json::from_value(_value)?)
1237    }
1238}
1239
1240/// `plugins.*` RPCs.
1241#[derive(Clone, Copy)]
1242pub struct ClientRpcPlugins<'a> {
1243    pub(crate) client: &'a Client,
1244}
1245
1246impl<'a> ClientRpcPlugins<'a> {
1247    /// `plugins.builtin.*` sub-namespace.
1248    pub fn builtin(&self) -> ClientRpcPluginsBuiltin<'a> {
1249        ClientRpcPluginsBuiltin {
1250            client: self.client,
1251        }
1252    }
1253
1254    /// `plugins.marketplaces.*` sub-namespace.
1255    pub fn marketplaces(&self) -> ClientRpcPluginsMarketplaces<'a> {
1256        ClientRpcPluginsMarketplaces {
1257            client: self.client,
1258        }
1259    }
1260
1261    /// Lists plugins installed in user/global state.
1262    ///
1263    /// Wire method: `plugins.list`.
1264    ///
1265    /// # Returns
1266    ///
1267    /// Plugins installed in user/global state.
1268    ///
1269    /// <div class="warning">
1270    ///
1271    /// **Experimental.** This API is part of an experimental wire-protocol surface
1272    /// and may change or be removed in future SDK or CLI releases. Pin both the
1273    /// SDK and CLI versions if your code depends on it.
1274    ///
1275    /// </div>
1276    pub async fn list(&self) -> Result<PluginListResult, Error> {
1277        let wire_params = serde_json::json!({});
1278        let _value = self
1279            .client
1280            .call(rpc_methods::PLUGINS_LIST, Some(wire_params))
1281            .await?;
1282        Ok(serde_json::from_value(_value)?)
1283    }
1284
1285    /// Installs a plugin from a marketplace, GitHub repo, URL, or local path.
1286    ///
1287    /// Wire method: `plugins.install`.
1288    ///
1289    /// # Parameters
1290    ///
1291    /// * `params` - Plugin source and optional working directory for relative-path resolution.
1292    ///
1293    /// # Returns
1294    ///
1295    /// Result of installing a plugin.
1296    ///
1297    /// <div class="warning">
1298    ///
1299    /// **Experimental.** This API is part of an experimental wire-protocol surface
1300    /// and may change or be removed in future SDK or CLI releases. Pin both the
1301    /// SDK and CLI versions if your code depends on it.
1302    ///
1303    /// </div>
1304    pub async fn install(
1305        &self,
1306        params: PluginsInstallRequest,
1307    ) -> Result<PluginInstallResult, Error> {
1308        let wire_params = serde_json::to_value(params)?;
1309        let _value = self
1310            .client
1311            .call(rpc_methods::PLUGINS_INSTALL, Some(wire_params))
1312            .await?;
1313        Ok(serde_json::from_value(_value)?)
1314    }
1315
1316    /// Uninstalls an installed plugin.
1317    ///
1318    /// Wire method: `plugins.uninstall`.
1319    ///
1320    /// # Parameters
1321    ///
1322    /// * `params` - Name (or spec) of the plugin to uninstall.
1323    ///
1324    /// <div class="warning">
1325    ///
1326    /// **Experimental.** This API is part of an experimental wire-protocol surface
1327    /// and may change or be removed in future SDK or CLI releases. Pin both the
1328    /// SDK and CLI versions if your code depends on it.
1329    ///
1330    /// </div>
1331    pub async fn uninstall(&self, params: PluginsUninstallRequest) -> Result<(), Error> {
1332        let wire_params = serde_json::to_value(params)?;
1333        let _value = self
1334            .client
1335            .call(rpc_methods::PLUGINS_UNINSTALL, Some(wire_params))
1336            .await?;
1337        Ok(())
1338    }
1339
1340    /// Updates an installed plugin to its latest published version.
1341    ///
1342    /// Wire method: `plugins.update`.
1343    ///
1344    /// # Parameters
1345    ///
1346    /// * `params` - Name (or spec) of the plugin to update.
1347    ///
1348    /// # Returns
1349    ///
1350    /// Result of updating a single plugin.
1351    ///
1352    /// <div class="warning">
1353    ///
1354    /// **Experimental.** This API is part of an experimental wire-protocol surface
1355    /// and may change or be removed in future SDK or CLI releases. Pin both the
1356    /// SDK and CLI versions if your code depends on it.
1357    ///
1358    /// </div>
1359    pub async fn update(&self, params: PluginsUpdateRequest) -> Result<PluginUpdateResult, Error> {
1360        let wire_params = serde_json::to_value(params)?;
1361        let _value = self
1362            .client
1363            .call(rpc_methods::PLUGINS_UPDATE, Some(wire_params))
1364            .await?;
1365        Ok(serde_json::from_value(_value)?)
1366    }
1367
1368    /// Updates every installed plugin to its latest published version.
1369    ///
1370    /// Wire method: `plugins.updateAll`.
1371    ///
1372    /// # Returns
1373    ///
1374    /// Result of updating all installed plugins.
1375    ///
1376    /// <div class="warning">
1377    ///
1378    /// **Experimental.** This API is part of an experimental wire-protocol surface
1379    /// and may change or be removed in future SDK or CLI releases. Pin both the
1380    /// SDK and CLI versions if your code depends on it.
1381    ///
1382    /// </div>
1383    pub async fn update_all(&self) -> Result<PluginUpdateAllResult, Error> {
1384        let wire_params = serde_json::json!({});
1385        let _value = self
1386            .client
1387            .call(rpc_methods::PLUGINS_UPDATEALL, Some(wire_params))
1388            .await?;
1389        Ok(serde_json::from_value(_value)?)
1390    }
1391
1392    /// Enables installed plugins for new sessions.
1393    ///
1394    /// Wire method: `plugins.enable`.
1395    ///
1396    /// # Parameters
1397    ///
1398    /// * `params` - Plugin names (or specs) to enable.
1399    ///
1400    /// <div class="warning">
1401    ///
1402    /// **Experimental.** This API is part of an experimental wire-protocol surface
1403    /// and may change or be removed in future SDK or CLI releases. Pin both the
1404    /// SDK and CLI versions if your code depends on it.
1405    ///
1406    /// </div>
1407    pub async fn enable(&self, params: PluginsEnableRequest) -> Result<(), Error> {
1408        let wire_params = serde_json::to_value(params)?;
1409        let _value = self
1410            .client
1411            .call(rpc_methods::PLUGINS_ENABLE, Some(wire_params))
1412            .await?;
1413        Ok(())
1414    }
1415
1416    /// Disables installed plugins for new sessions.
1417    ///
1418    /// Wire method: `plugins.disable`.
1419    ///
1420    /// # Parameters
1421    ///
1422    /// * `params` - Plugin names (or specs) to disable.
1423    ///
1424    /// <div class="warning">
1425    ///
1426    /// **Experimental.** This API is part of an experimental wire-protocol surface
1427    /// and may change or be removed in future SDK or CLI releases. Pin both the
1428    /// SDK and CLI versions if your code depends on it.
1429    ///
1430    /// </div>
1431    pub async fn disable(&self, params: PluginsDisableRequest) -> Result<(), Error> {
1432        let wire_params = serde_json::to_value(params)?;
1433        let _value = self
1434            .client
1435            .call(rpc_methods::PLUGINS_DISABLE, Some(wire_params))
1436            .await?;
1437        Ok(())
1438    }
1439}
1440
1441/// `plugins.builtin.*` RPCs.
1442#[derive(Clone, Copy)]
1443pub struct ClientRpcPluginsBuiltin<'a> {
1444    pub(crate) client: &'a Client,
1445}
1446
1447impl<'a> ClientRpcPluginsBuiltin<'a> {
1448    /// Replaces this server's trusted built-in plugin directories while no sessions are active.
1449    ///
1450    /// Wire method: `plugins.builtin.set`.
1451    ///
1452    /// # Parameters
1453    ///
1454    /// * `params` - Trusted built-in plugin directories to use for this runtime process.
1455    ///
1456    /// <div class="warning">
1457    ///
1458    /// **Experimental.** This API is part of an experimental wire-protocol surface
1459    /// and may change or be removed in future SDK or CLI releases. Pin both the
1460    /// SDK and CLI versions if your code depends on it.
1461    ///
1462    /// </div>
1463    pub async fn set(&self, params: PluginsBuiltinSetRequest) -> Result<(), Error> {
1464        let wire_params = serde_json::to_value(params)?;
1465        let _value = self
1466            .client
1467            .call(rpc_methods::PLUGINS_BUILTIN_SET, Some(wire_params))
1468            .await?;
1469        Ok(())
1470    }
1471}
1472
1473/// `plugins.marketplaces.*` RPCs.
1474#[derive(Clone, Copy)]
1475pub struct ClientRpcPluginsMarketplaces<'a> {
1476    pub(crate) client: &'a Client,
1477}
1478
1479impl<'a> ClientRpcPluginsMarketplaces<'a> {
1480    /// Lists all registered marketplaces (defaults + user-added).
1481    ///
1482    /// Wire method: `plugins.marketplaces.list`.
1483    ///
1484    /// # Returns
1485    ///
1486    /// All registered marketplaces, including built-in defaults.
1487    ///
1488    /// <div class="warning">
1489    ///
1490    /// **Experimental.** This API is part of an experimental wire-protocol surface
1491    /// and may change or be removed in future SDK or CLI releases. Pin both the
1492    /// SDK and CLI versions if your code depends on it.
1493    ///
1494    /// </div>
1495    pub async fn list(&self) -> Result<MarketplaceListResult, Error> {
1496        let wire_params = serde_json::json!({});
1497        let _value = self
1498            .client
1499            .call(rpc_methods::PLUGINS_MARKETPLACES_LIST, Some(wire_params))
1500            .await?;
1501        Ok(serde_json::from_value(_value)?)
1502    }
1503
1504    /// Registers a new marketplace from a source (owner/repo, URL, or local path).
1505    ///
1506    /// Wire method: `plugins.marketplaces.add`.
1507    ///
1508    /// # Parameters
1509    ///
1510    /// * `params` - Marketplace source and optional working directory for relative-path resolution.
1511    ///
1512    /// # Returns
1513    ///
1514    /// Result of registering a new marketplace.
1515    ///
1516    /// <div class="warning">
1517    ///
1518    /// **Experimental.** This API is part of an experimental wire-protocol surface
1519    /// and may change or be removed in future SDK or CLI releases. Pin both the
1520    /// SDK and CLI versions if your code depends on it.
1521    ///
1522    /// </div>
1523    pub async fn add(
1524        &self,
1525        params: PluginsMarketplacesAddRequest,
1526    ) -> Result<MarketplaceAddResult, Error> {
1527        let wire_params = serde_json::to_value(params)?;
1528        let _value = self
1529            .client
1530            .call(rpc_methods::PLUGINS_MARKETPLACES_ADD, Some(wire_params))
1531            .await?;
1532        Ok(serde_json::from_value(_value)?)
1533    }
1534
1535    /// 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`.
1536    ///
1537    /// Wire method: `plugins.marketplaces.remove`.
1538    ///
1539    /// # Parameters
1540    ///
1541    /// * `params` - Name of the marketplace to remove and an optional force flag.
1542    ///
1543    /// # Returns
1544    ///
1545    /// Outcome of the remove attempt, including dependent-plugin info when applicable.
1546    ///
1547    /// <div class="warning">
1548    ///
1549    /// **Experimental.** This API is part of an experimental wire-protocol surface
1550    /// and may change or be removed in future SDK or CLI releases. Pin both the
1551    /// SDK and CLI versions if your code depends on it.
1552    ///
1553    /// </div>
1554    pub async fn remove(
1555        &self,
1556        params: PluginsMarketplacesRemoveRequest,
1557    ) -> Result<MarketplaceRemoveResult, Error> {
1558        let wire_params = serde_json::to_value(params)?;
1559        let _value = self
1560            .client
1561            .call(rpc_methods::PLUGINS_MARKETPLACES_REMOVE, Some(wire_params))
1562            .await?;
1563        Ok(serde_json::from_value(_value)?)
1564    }
1565
1566    /// Lists plugins advertised by a registered marketplace.
1567    ///
1568    /// Wire method: `plugins.marketplaces.browse`.
1569    ///
1570    /// # Parameters
1571    ///
1572    /// * `params` - Name of the marketplace whose plugin catalog to fetch.
1573    ///
1574    /// # Returns
1575    ///
1576    /// Plugins advertised by the marketplace.
1577    ///
1578    /// <div class="warning">
1579    ///
1580    /// **Experimental.** This API is part of an experimental wire-protocol surface
1581    /// and may change or be removed in future SDK or CLI releases. Pin both the
1582    /// SDK and CLI versions if your code depends on it.
1583    ///
1584    /// </div>
1585    pub async fn browse(
1586        &self,
1587        params: PluginsMarketplacesBrowseRequest,
1588    ) -> Result<MarketplaceBrowseResult, Error> {
1589        let wire_params = serde_json::to_value(params)?;
1590        let _value = self
1591            .client
1592            .call(rpc_methods::PLUGINS_MARKETPLACES_BROWSE, Some(wire_params))
1593            .await?;
1594        Ok(serde_json::from_value(_value)?)
1595    }
1596
1597    /// Re-fetches one or all registered marketplace catalogs.
1598    ///
1599    /// Wire method: `plugins.marketplaces.refresh`.
1600    ///
1601    /// # Returns
1602    ///
1603    /// Result of refreshing one or more marketplace catalogs.
1604    ///
1605    /// <div class="warning">
1606    ///
1607    /// **Experimental.** This API is part of an experimental wire-protocol surface
1608    /// and may change or be removed in future SDK or CLI releases. Pin both the
1609    /// SDK and CLI versions if your code depends on it.
1610    ///
1611    /// </div>
1612    pub async fn refresh(&self) -> Result<MarketplaceRefreshResult, Error> {
1613        let wire_params = serde_json::json!({});
1614        let _value = self
1615            .client
1616            .call(rpc_methods::PLUGINS_MARKETPLACES_REFRESH, Some(wire_params))
1617            .await?;
1618        Ok(serde_json::from_value(_value)?)
1619    }
1620
1621    /// Re-fetches one or all registered marketplace catalogs.
1622    ///
1623    /// Wire method: `plugins.marketplaces.refresh`.
1624    ///
1625    /// # Parameters
1626    ///
1627    /// * `params` - Optional marketplace name; omit to refresh all.
1628    ///
1629    /// # Returns
1630    ///
1631    /// Result of refreshing one or more marketplace catalogs.
1632    ///
1633    /// <div class="warning">
1634    ///
1635    /// **Experimental.** This API is part of an experimental wire-protocol surface
1636    /// and may change or be removed in future SDK or CLI releases. Pin both the
1637    /// SDK and CLI versions if your code depends on it.
1638    ///
1639    /// </div>
1640    pub async fn refresh_with_params(
1641        &self,
1642        params: PluginsMarketplacesRefreshRequest,
1643    ) -> Result<MarketplaceRefreshResult, Error> {
1644        let wire_params = serde_json::to_value(params)?;
1645        let _value = self
1646            .client
1647            .call(rpc_methods::PLUGINS_MARKETPLACES_REFRESH, Some(wire_params))
1648            .await?;
1649        Ok(serde_json::from_value(_value)?)
1650    }
1651}
1652
1653/// `runtime.*` RPCs.
1654#[derive(Clone, Copy)]
1655pub struct ClientRpcRuntime<'a> {
1656    pub(crate) client: &'a Client,
1657}
1658
1659impl<'a> ClientRpcRuntime<'a> {
1660    /// Gracefully shuts down an SDK-owned runtime. The response is sent only after cleanup completes; callers may then terminate the owned runtime process.
1661    ///
1662    /// Wire method: `runtime.shutdown`.
1663    ///
1664    /// <div class="warning">
1665    ///
1666    /// **Experimental.** This API is part of an experimental wire-protocol surface
1667    /// and may change or be removed in future SDK or CLI releases. Pin both the
1668    /// SDK and CLI versions if your code depends on it.
1669    ///
1670    /// </div>
1671    pub async fn shutdown(&self) -> Result<(), Error> {
1672        let wire_params = serde_json::json!({});
1673        let _value = self
1674            .client
1675            .call(rpc_methods::RUNTIME_SHUTDOWN, Some(wire_params))
1676            .await?;
1677        Ok(())
1678    }
1679}
1680
1681/// `secrets.*` RPCs.
1682#[derive(Clone, Copy)]
1683pub struct ClientRpcSecrets<'a> {
1684    pub(crate) client: &'a Client,
1685}
1686
1687impl<'a> ClientRpcSecrets<'a> {
1688    /// Registers secret values for redaction in session logs and exports. The SDK calls this to inject dynamically generated secret values (e.g., OIDC tokens).
1689    ///
1690    /// Wire method: `secrets.addFilterValues`.
1691    ///
1692    /// # Parameters
1693    ///
1694    /// * `params` - Secret values to add to the redaction filter.
1695    ///
1696    /// # Returns
1697    ///
1698    /// Confirmation that the secret values were registered.
1699    ///
1700    /// <div class="warning">
1701    ///
1702    /// **Experimental.** This API is part of an experimental wire-protocol surface
1703    /// and may change or be removed in future SDK or CLI releases. Pin both the
1704    /// SDK and CLI versions if your code depends on it.
1705    ///
1706    /// </div>
1707    pub async fn add_filter_values(
1708        &self,
1709        params: SecretsAddFilterValuesRequest,
1710    ) -> Result<SecretsAddFilterValuesResult, Error> {
1711        let wire_params = serde_json::to_value(params)?;
1712        let _value = self
1713            .client
1714            .call(rpc_methods::SECRETS_ADDFILTERVALUES, Some(wire_params))
1715            .await?;
1716        Ok(serde_json::from_value(_value)?)
1717    }
1718}
1719
1720/// `sessionFs.*` RPCs.
1721#[derive(Clone, Copy)]
1722pub struct ClientRpcSessionFs<'a> {
1723    pub(crate) client: &'a Client,
1724}
1725
1726impl<'a> ClientRpcSessionFs<'a> {
1727    /// Registers an SDK client as the session filesystem provider.
1728    ///
1729    /// Wire method: `sessionFs.setProvider`.
1730    ///
1731    /// # Parameters
1732    ///
1733    /// * `params` - Initial working directory, session-state path layout, and path conventions used to register the calling SDK client as the session filesystem provider.
1734    ///
1735    /// # Returns
1736    ///
1737    /// Indicates whether the calling client was registered as the session filesystem provider.
1738    ///
1739    /// <div class="warning">
1740    ///
1741    /// **Experimental.** This API is part of an experimental wire-protocol surface
1742    /// and may change or be removed in future SDK or CLI releases. Pin both the
1743    /// SDK and CLI versions if your code depends on it.
1744    ///
1745    /// </div>
1746    pub async fn set_provider(
1747        &self,
1748        params: SessionFsSetProviderRequest,
1749    ) -> Result<SessionFsSetProviderResult, Error> {
1750        let wire_params = serde_json::to_value(params)?;
1751        let _value = self
1752            .client
1753            .call(rpc_methods::SESSIONFS_SETPROVIDER, Some(wire_params))
1754            .await?;
1755        Ok(serde_json::from_value(_value)?)
1756    }
1757}
1758
1759/// `sessions.*` RPCs.
1760#[derive(Clone, Copy)]
1761pub struct ClientRpcSessions<'a> {
1762    pub(crate) client: &'a Client,
1763}
1764
1765impl<'a> ClientRpcSessions<'a> {
1766    /// Creates or resumes a local session and returns the opened session ID.
1767    ///
1768    /// Wire method: `sessions.open`.
1769    ///
1770    /// # Returns
1771    ///
1772    /// Result of opening a session.
1773    ///
1774    /// <div class="warning">
1775    ///
1776    /// **Experimental.** This API is part of an experimental wire-protocol surface
1777    /// and may change or be removed in future SDK or CLI releases. Pin both the
1778    /// SDK and CLI versions if your code depends on it.
1779    ///
1780    /// </div>
1781    pub async fn open(&self) -> Result<SessionOpenResult, Error> {
1782        let wire_params = serde_json::json!({});
1783        let _value = self
1784            .client
1785            .call(rpc_methods::SESSIONS_OPEN, Some(wire_params))
1786            .await?;
1787        Ok(serde_json::from_value(_value)?)
1788    }
1789
1790    /// Creates a new session by forking persisted history from an existing session.
1791    ///
1792    /// Wire method: `sessions.fork`.
1793    ///
1794    /// # Parameters
1795    ///
1796    /// * `params` - Source session identifier to fork from, optional event-ID boundary, and optional friendly name for the new session.
1797    ///
1798    /// # Returns
1799    ///
1800    /// Identifier and optional friendly name assigned to the newly forked session.
1801    ///
1802    /// <div class="warning">
1803    ///
1804    /// **Experimental.** This API is part of an experimental wire-protocol surface
1805    /// and may change or be removed in future SDK or CLI releases. Pin both the
1806    /// SDK and CLI versions if your code depends on it.
1807    ///
1808    /// </div>
1809    pub async fn fork(&self, params: SessionsForkRequest) -> Result<SessionsForkResult, Error> {
1810        let wire_params = serde_json::to_value(params)?;
1811        let _value = self
1812            .client
1813            .call(rpc_methods::SESSIONS_FORK, Some(wire_params))
1814            .await?;
1815        Ok(serde_json::from_value(_value)?)
1816    }
1817
1818    /// Connects to an existing remote session and exposes it as an SDK session.
1819    ///
1820    /// Wire method: `sessions.connect`.
1821    ///
1822    /// # Parameters
1823    ///
1824    /// * `params` - Remote session connection parameters.
1825    ///
1826    /// # Returns
1827    ///
1828    /// Remote session connection result.
1829    ///
1830    /// <div class="warning">
1831    ///
1832    /// **Experimental.** This API is part of an experimental wire-protocol surface
1833    /// and may change or be removed in future SDK or CLI releases. Pin both the
1834    /// SDK and CLI versions if your code depends on it.
1835    ///
1836    /// </div>
1837    pub async fn connect(
1838        &self,
1839        params: ConnectRemoteSessionParams,
1840    ) -> Result<RemoteSessionConnectionResult, Error> {
1841        let wire_params = serde_json::to_value(params)?;
1842        let _value = self
1843            .client
1844            .call(rpc_methods::SESSIONS_CONNECT, Some(wire_params))
1845            .await?;
1846        Ok(serde_json::from_value(_value)?)
1847    }
1848
1849    /// 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.).
1850    ///
1851    /// Wire method: `sessions.list`.
1852    ///
1853    /// # Returns
1854    ///
1855    /// Sessions matching the filter, ordered most-recently-modified first.
1856    ///
1857    /// <div class="warning">
1858    ///
1859    /// **Experimental.** This API is part of an experimental wire-protocol surface
1860    /// and may change or be removed in future SDK or CLI releases. Pin both the
1861    /// SDK and CLI versions if your code depends on it.
1862    ///
1863    /// </div>
1864    pub async fn list(&self) -> Result<SessionList, Error> {
1865        let wire_params = serde_json::json!({});
1866        let _value = self
1867            .client
1868            .call(rpc_methods::SESSIONS_LIST, Some(wire_params))
1869            .await?;
1870        Ok(serde_json::from_value(_value)?)
1871    }
1872
1873    /// 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.).
1874    ///
1875    /// Wire method: `sessions.list`.
1876    ///
1877    /// # Parameters
1878    ///
1879    /// * `params` - Optional source filter, metadata-load limit, and context filter applied to the returned sessions.
1880    ///
1881    /// # Returns
1882    ///
1883    /// Sessions matching the filter, ordered most-recently-modified first.
1884    ///
1885    /// <div class="warning">
1886    ///
1887    /// **Experimental.** This API is part of an experimental wire-protocol surface
1888    /// and may change or be removed in future SDK or CLI releases. Pin both the
1889    /// SDK and CLI versions if your code depends on it.
1890    ///
1891    /// </div>
1892    pub async fn list_with_params(
1893        &self,
1894        params: SessionsListRequest,
1895    ) -> Result<SessionList, Error> {
1896        let wire_params = serde_json::to_value(params)?;
1897        let _value = self
1898            .client
1899            .call(rpc_methods::SESSIONS_LIST, Some(wire_params))
1900            .await?;
1901        Ok(serde_json::from_value(_value)?)
1902    }
1903
1904    /// Reads lightweight persisted metadata for one local session without opening it.
1905    ///
1906    /// Wire method: `sessions.getMetadata`.
1907    ///
1908    /// # Parameters
1909    ///
1910    /// * `params` - Session ID whose persisted metadata should be read.
1911    ///
1912    /// # Returns
1913    ///
1914    /// Persisted local session metadata when the session exists.
1915    ///
1916    /// <div class="warning">
1917    ///
1918    /// **Experimental.** This API is part of an experimental wire-protocol surface
1919    /// and may change or be removed in future SDK or CLI releases. Pin both the
1920    /// SDK and CLI versions if your code depends on it.
1921    ///
1922    /// </div>
1923    pub(crate) async fn get_metadata(
1924        &self,
1925        params: SessionsGetMetadataRequest,
1926    ) -> Result<SessionsGetMetadataResult, Error> {
1927        let wire_params = serde_json::to_value(params)?;
1928        let _value = self
1929            .client
1930            .call(rpc_methods::SESSIONS_GETMETADATA, Some(wire_params))
1931            .await?;
1932        Ok(serde_json::from_value(_value)?)
1933    }
1934
1935    /// Reads a page of durable events directly from a local session's persisted journal without creating, resuming, or activating the session. The initial backward read uses a bounded tail scan for fast first paint; cursor continuations preserve the session event-log paging semantics. Persisted events may omit payloads that are reconstructed only for an active session.
1936    ///
1937    /// Wire method: `sessions.readPersistedEvents`.
1938    ///
1939    /// # Parameters
1940    ///
1941    /// * `params` - Pagination options for reading an inactive or active local session's persisted event journal.
1942    ///
1943    /// # Returns
1944    ///
1945    /// Batch of session events returned by a read, with cursor and continuation metadata.
1946    ///
1947    /// <div class="warning">
1948    ///
1949    /// **Experimental.** This API is part of an experimental wire-protocol surface
1950    /// and may change or be removed in future SDK or CLI releases. Pin both the
1951    /// SDK and CLI versions if your code depends on it.
1952    ///
1953    /// </div>
1954    pub async fn read_persisted_events(
1955        &self,
1956        params: SessionsReadPersistedEventsRequest,
1957    ) -> Result<EventsReadResult, Error> {
1958        let wire_params = serde_json::to_value(params)?;
1959        let _value = self
1960            .client
1961            .call(rpc_methods::SESSIONS_READPERSISTEDEVENTS, Some(wire_params))
1962            .await?;
1963        Ok(serde_json::from_value(_value)?)
1964    }
1965
1966    /// Lists recent local session IDs that contain user-visible history, omitting housekeeping-only sessions.
1967    ///
1968    /// Wire method: `sessions.listNonEmptySessionIds`.
1969    ///
1970    /// # Parameters
1971    ///
1972    /// * `params` - Limit for non-empty local session IDs.
1973    ///
1974    /// # Returns
1975    ///
1976    /// Recent local session IDs that contain user-visible history.
1977    ///
1978    /// <div class="warning">
1979    ///
1980    /// **Experimental.** This API is part of an experimental wire-protocol surface
1981    /// and may change or be removed in future SDK or CLI releases. Pin both the
1982    /// SDK and CLI versions if your code depends on it.
1983    ///
1984    /// </div>
1985    pub(crate) async fn list_non_empty_session_ids(
1986        &self,
1987        params: SessionsListNonEmptySessionIdsRequest,
1988    ) -> Result<SessionsListNonEmptySessionIdsResult, Error> {
1989        let wire_params = serde_json::to_value(params)?;
1990        let _value = self
1991            .client
1992            .call(
1993                rpc_methods::SESSIONS_LISTNONEMPTYSESSIONIDS,
1994                Some(wire_params),
1995            )
1996            .await?;
1997        Ok(serde_json::from_value(_value)?)
1998    }
1999
2000    /// Finds the local session bound to a GitHub task ID, if any.
2001    ///
2002    /// Wire method: `sessions.findByTaskId`.
2003    ///
2004    /// # Parameters
2005    ///
2006    /// * `params` - GitHub task ID to look up.
2007    ///
2008    /// # Returns
2009    ///
2010    /// ID of the local session bound to the given GitHub task, or omitted when none.
2011    ///
2012    /// <div class="warning">
2013    ///
2014    /// **Experimental.** This API is part of an experimental wire-protocol surface
2015    /// and may change or be removed in future SDK or CLI releases. Pin both the
2016    /// SDK and CLI versions if your code depends on it.
2017    ///
2018    /// </div>
2019    pub async fn find_by_task_id(
2020        &self,
2021        params: SessionsFindByTaskIDRequest,
2022    ) -> Result<SessionsFindByTaskIDResult, Error> {
2023        let wire_params = serde_json::to_value(params)?;
2024        let _value = self
2025            .client
2026            .call(rpc_methods::SESSIONS_FINDBYTASKID, Some(wire_params))
2027            .await?;
2028        Ok(serde_json::from_value(_value)?)
2029    }
2030
2031    /// Resolves a UUID prefix to a unique session ID, if exactly one session matches.
2032    ///
2033    /// Wire method: `sessions.findByPrefix`.
2034    ///
2035    /// # Parameters
2036    ///
2037    /// * `params` - UUID prefix to resolve to a unique session ID.
2038    ///
2039    /// # Returns
2040    ///
2041    /// Session ID matching the prefix, omitted when no unique match exists.
2042    ///
2043    /// <div class="warning">
2044    ///
2045    /// **Experimental.** This API is part of an experimental wire-protocol surface
2046    /// and may change or be removed in future SDK or CLI releases. Pin both the
2047    /// SDK and CLI versions if your code depends on it.
2048    ///
2049    /// </div>
2050    pub async fn find_by_prefix(
2051        &self,
2052        params: SessionsFindByPrefixRequest,
2053    ) -> Result<SessionsFindByPrefixResult, Error> {
2054        let wire_params = serde_json::to_value(params)?;
2055        let _value = self
2056            .client
2057            .call(rpc_methods::SESSIONS_FINDBYPREFIX, Some(wire_params))
2058            .await?;
2059        Ok(serde_json::from_value(_value)?)
2060    }
2061
2062    /// Returns the most-relevant prior session for a given working-directory context.
2063    ///
2064    /// Wire method: `sessions.getLastForContext`.
2065    ///
2066    /// # Parameters
2067    ///
2068    /// * `params` - Optional working-directory context used to score session relevance.
2069    ///
2070    /// # Returns
2071    ///
2072    /// Most-relevant session ID for the supplied context, or omitted when no sessions exist.
2073    ///
2074    /// <div class="warning">
2075    ///
2076    /// **Experimental.** This API is part of an experimental wire-protocol surface
2077    /// and may change or be removed in future SDK or CLI releases. Pin both the
2078    /// SDK and CLI versions if your code depends on it.
2079    ///
2080    /// </div>
2081    pub async fn get_last_for_context(
2082        &self,
2083        params: SessionsGetLastForContextRequest,
2084    ) -> Result<SessionsGetLastForContextResult, Error> {
2085        let wire_params = serde_json::to_value(params)?;
2086        let _value = self
2087            .client
2088            .call(rpc_methods::SESSIONS_GETLASTFORCONTEXT, Some(wire_params))
2089            .await?;
2090        Ok(serde_json::from_value(_value)?)
2091    }
2092
2093    /// 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.
2094    ///
2095    /// Wire method: `sessions.getEventFilePath`.
2096    ///
2097    /// # Parameters
2098    ///
2099    /// * `params` - Session ID whose event-log file path to compute.
2100    ///
2101    /// # Returns
2102    ///
2103    /// Absolute path to the session's events.jsonl file on disk.
2104    ///
2105    /// <div class="warning">
2106    ///
2107    /// **Experimental.** This API is part of an experimental wire-protocol surface
2108    /// and may change or be removed in future SDK or CLI releases. Pin both the
2109    /// SDK and CLI versions if your code depends on it.
2110    ///
2111    /// </div>
2112    pub(crate) async fn get_event_file_path(
2113        &self,
2114        params: SessionsGetEventFilePathRequest,
2115    ) -> Result<SessionsGetEventFilePathResult, Error> {
2116        let wire_params = serde_json::to_value(params)?;
2117        let _value = self
2118            .client
2119            .call(rpc_methods::SESSIONS_GETEVENTFILEPATH, Some(wire_params))
2120            .await?;
2121        Ok(serde_json::from_value(_value)?)
2122    }
2123
2124    /// Returns the on-disk byte size of each session's workspace directory.
2125    ///
2126    /// Wire method: `sessions.getSizes`.
2127    ///
2128    /// # Returns
2129    ///
2130    /// Map of sessionId -> on-disk size in bytes for each session's workspace directory.
2131    ///
2132    /// <div class="warning">
2133    ///
2134    /// **Experimental.** This API is part of an experimental wire-protocol surface
2135    /// and may change or be removed in future SDK or CLI releases. Pin both the
2136    /// SDK and CLI versions if your code depends on it.
2137    ///
2138    /// </div>
2139    pub async fn get_sizes(&self) -> Result<SessionSizes, Error> {
2140        let wire_params = serde_json::json!({});
2141        let _value = self
2142            .client
2143            .call(rpc_methods::SESSIONS_GETSIZES, Some(wire_params))
2144            .await?;
2145        Ok(serde_json::from_value(_value)?)
2146    }
2147
2148    /// Returns the subset of the supplied session IDs that are currently held by another running process.
2149    ///
2150    /// Wire method: `sessions.checkInUse`.
2151    ///
2152    /// # Parameters
2153    ///
2154    /// * `params` - Session IDs to test for live in-use locks.
2155    ///
2156    /// # Returns
2157    ///
2158    /// Session IDs from the input set that are currently in use by another process.
2159    ///
2160    /// <div class="warning">
2161    ///
2162    /// **Experimental.** This API is part of an experimental wire-protocol surface
2163    /// and may change or be removed in future SDK or CLI releases. Pin both the
2164    /// SDK and CLI versions if your code depends on it.
2165    ///
2166    /// </div>
2167    pub async fn check_in_use(
2168        &self,
2169        params: SessionsCheckInUseRequest,
2170    ) -> Result<SessionsCheckInUseResult, Error> {
2171        let wire_params = serde_json::to_value(params)?;
2172        let _value = self
2173            .client
2174            .call(rpc_methods::SESSIONS_CHECKINUSE, Some(wire_params))
2175            .await?;
2176        Ok(serde_json::from_value(_value)?)
2177    }
2178
2179    /// 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.
2180    ///
2181    /// Wire method: `sessions.getPersistedRemoteSteerable`.
2182    ///
2183    /// # Parameters
2184    ///
2185    /// * `params` - Session ID to look up the persisted remote-steerable flag for.
2186    ///
2187    /// # Returns
2188    ///
2189    /// The session's persisted remote-steerable flag, or omitted when no value has been persisted.
2190    ///
2191    /// <div class="warning">
2192    ///
2193    /// **Experimental.** This API is part of an experimental wire-protocol surface
2194    /// and may change or be removed in future SDK or CLI releases. Pin both the
2195    /// SDK and CLI versions if your code depends on it.
2196    ///
2197    /// </div>
2198    pub(crate) async fn get_persisted_remote_steerable(
2199        &self,
2200        params: SessionsGetPersistedRemoteSteerableRequest,
2201    ) -> Result<SessionsGetPersistedRemoteSteerableResult, Error> {
2202        let wire_params = serde_json::to_value(params)?;
2203        let _value = self
2204            .client
2205            .call(
2206                rpc_methods::SESSIONS_GETPERSISTEDREMOTESTEERABLE,
2207                Some(wire_params),
2208            )
2209            .await?;
2210        Ok(serde_json::from_value(_value)?)
2211    }
2212
2213    /// Closes a session: emits shutdown, flushes pending events, releases the in-use lock, and disposes the active session.
2214    ///
2215    /// Wire method: `sessions.close`.
2216    ///
2217    /// # Parameters
2218    ///
2219    /// * `params` - Session ID to close.
2220    ///
2221    /// # Returns
2222    ///
2223    /// 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.
2224    ///
2225    /// <div class="warning">
2226    ///
2227    /// **Experimental.** This API is part of an experimental wire-protocol surface
2228    /// and may change or be removed in future SDK or CLI releases. Pin both the
2229    /// SDK and CLI versions if your code depends on it.
2230    ///
2231    /// </div>
2232    pub async fn close(&self, params: SessionsCloseRequest) -> Result<SessionsCloseResult, Error> {
2233        let wire_params = serde_json::to_value(params)?;
2234        let _value = self
2235            .client
2236            .call(rpc_methods::SESSIONS_CLOSE, Some(wire_params))
2237            .await?;
2238        Ok(serde_json::from_value(_value)?)
2239    }
2240
2241    /// Closes, deactivates, and deletes a set of sessions, returning the bytes freed per session.
2242    ///
2243    /// Wire method: `sessions.bulkDelete`.
2244    ///
2245    /// # Parameters
2246    ///
2247    /// * `params` - Session IDs to close, deactivate, and delete from disk.
2248    ///
2249    /// # Returns
2250    ///
2251    /// Map of sessionId -> bytes freed by removing the session's workspace directory.
2252    ///
2253    /// <div class="warning">
2254    ///
2255    /// **Experimental.** This API is part of an experimental wire-protocol surface
2256    /// and may change or be removed in future SDK or CLI releases. Pin both the
2257    /// SDK and CLI versions if your code depends on it.
2258    ///
2259    /// </div>
2260    pub async fn bulk_delete(
2261        &self,
2262        params: SessionsBulkDeleteRequest,
2263    ) -> Result<SessionBulkDeleteResult, Error> {
2264        let wire_params = serde_json::to_value(params)?;
2265        let _value = self
2266            .client
2267            .call(rpc_methods::SESSIONS_BULKDELETE, Some(wire_params))
2268            .await?;
2269        Ok(serde_json::from_value(_value)?)
2270    }
2271
2272    /// Deletes one local session from disk after running the same lifecycle hooks as the session manager.
2273    ///
2274    /// Wire method: `sessions.delete`.
2275    ///
2276    /// # Parameters
2277    ///
2278    /// * `params` - Session ID to delete from disk.
2279    ///
2280    /// <div class="warning">
2281    ///
2282    /// **Experimental.** This API is part of an experimental wire-protocol surface
2283    /// and may change or be removed in future SDK or CLI releases. Pin both the
2284    /// SDK and CLI versions if your code depends on it.
2285    ///
2286    /// </div>
2287    pub(crate) async fn delete(&self, params: SessionsDeleteRequest) -> Result<(), Error> {
2288        let wire_params = serde_json::to_value(params)?;
2289        let _value = self
2290            .client
2291            .call(rpc_methods::SESSIONS_DELETE, Some(wire_params))
2292            .await?;
2293        Ok(())
2294    }
2295
2296    /// Deletes sessions older than the given threshold, with optional dry-run and exclusion list.
2297    ///
2298    /// Wire method: `sessions.pruneOld`.
2299    ///
2300    /// # Parameters
2301    ///
2302    /// * `params` - Age threshold and optional flags controlling which old sessions are pruned (or simulated when dryRun is true).
2303    ///
2304    /// # Returns
2305    ///
2306    /// Outcome of the prune operation: deleted IDs, dry-run candidates, skipped IDs, total bytes freed, and the dry-run flag.
2307    ///
2308    /// <div class="warning">
2309    ///
2310    /// **Experimental.** This API is part of an experimental wire-protocol surface
2311    /// and may change or be removed in future SDK or CLI releases. Pin both the
2312    /// SDK and CLI versions if your code depends on it.
2313    ///
2314    /// </div>
2315    pub async fn prune_old(
2316        &self,
2317        params: SessionsPruneOldRequest,
2318    ) -> Result<SessionPruneResult, Error> {
2319        let wire_params = serde_json::to_value(params)?;
2320        let _value = self
2321            .client
2322            .call(rpc_methods::SESSIONS_PRUNEOLD, Some(wire_params))
2323            .await?;
2324        Ok(serde_json::from_value(_value)?)
2325    }
2326
2327    /// Flushes a session's pending events to disk.
2328    ///
2329    /// Wire method: `sessions.save`.
2330    ///
2331    /// # Parameters
2332    ///
2333    /// * `params` - Session ID whose pending events should be flushed to disk.
2334    ///
2335    /// # Returns
2336    ///
2337    /// Flush a session's pending events to disk. No-op when no writer exists for the session (e.g., already closed).
2338    ///
2339    /// <div class="warning">
2340    ///
2341    /// **Experimental.** This API is part of an experimental wire-protocol surface
2342    /// and may change or be removed in future SDK or CLI releases. Pin both the
2343    /// SDK and CLI versions if your code depends on it.
2344    ///
2345    /// </div>
2346    pub async fn save(&self, params: SessionsSaveRequest) -> Result<SessionsSaveResult, Error> {
2347        let wire_params = serde_json::to_value(params)?;
2348        let _value = self
2349            .client
2350            .call(rpc_methods::SESSIONS_SAVE, Some(wire_params))
2351            .await?;
2352        Ok(serde_json::from_value(_value)?)
2353    }
2354
2355    /// Releases the in-use lock held by this process for a session.
2356    ///
2357    /// Wire method: `sessions.releaseLock`.
2358    ///
2359    /// # Parameters
2360    ///
2361    /// * `params` - Session ID whose in-use lock should be released.
2362    ///
2363    /// # Returns
2364    ///
2365    /// 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.
2366    ///
2367    /// <div class="warning">
2368    ///
2369    /// **Experimental.** This API is part of an experimental wire-protocol surface
2370    /// and may change or be removed in future SDK or CLI releases. Pin both the
2371    /// SDK and CLI versions if your code depends on it.
2372    ///
2373    /// </div>
2374    pub async fn release_lock(
2375        &self,
2376        params: SessionsReleaseLockRequest,
2377    ) -> Result<SessionsReleaseLockResult, Error> {
2378        let wire_params = serde_json::to_value(params)?;
2379        let _value = self
2380            .client
2381            .call(rpc_methods::SESSIONS_RELEASELOCK, Some(wire_params))
2382            .await?;
2383        Ok(serde_json::from_value(_value)?)
2384    }
2385
2386    /// Backfills missing summary and context fields on the supplied session metadata records.
2387    ///
2388    /// Wire method: `sessions.enrichMetadata`.
2389    ///
2390    /// # Parameters
2391    ///
2392    /// * `params` - Session metadata records to enrich with summary and context information.
2393    ///
2394    /// # Returns
2395    ///
2396    /// The enriched metadata records, with summary and context fields backfilled where available. Sessions confirmed empty and unnamed are omitted.
2397    ///
2398    /// <div class="warning">
2399    ///
2400    /// **Experimental.** This API is part of an experimental wire-protocol surface
2401    /// and may change or be removed in future SDK or CLI releases. Pin both the
2402    /// SDK and CLI versions if your code depends on it.
2403    ///
2404    /// </div>
2405    pub async fn enrich_metadata(
2406        &self,
2407        params: SessionsEnrichMetadataRequest,
2408    ) -> Result<SessionEnrichMetadataResult, Error> {
2409        let wire_params = serde_json::to_value(params)?;
2410        let _value = self
2411            .client
2412            .call(rpc_methods::SESSIONS_ENRICHMETADATA, Some(wire_params))
2413            .await?;
2414        Ok(serde_json::from_value(_value)?)
2415    }
2416
2417    /// Reloads user, plugin, and (optionally) repo hooks on the active session.
2418    ///
2419    /// Wire method: `sessions.reloadPluginHooks`.
2420    ///
2421    /// # Parameters
2422    ///
2423    /// * `params` - Active session ID and an optional flag for deferring repo-level hooks until folder trust.
2424    ///
2425    /// # Returns
2426    ///
2427    /// 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.
2428    ///
2429    /// <div class="warning">
2430    ///
2431    /// **Experimental.** This API is part of an experimental wire-protocol surface
2432    /// and may change or be removed in future SDK or CLI releases. Pin both the
2433    /// SDK and CLI versions if your code depends on it.
2434    ///
2435    /// </div>
2436    pub async fn reload_plugin_hooks(
2437        &self,
2438        params: SessionsReloadPluginHooksRequest,
2439    ) -> Result<SessionsReloadPluginHooksResult, Error> {
2440        let wire_params = serde_json::to_value(params)?;
2441        let _value = self
2442            .client
2443            .call(rpc_methods::SESSIONS_RELOADPLUGINHOOKS, Some(wire_params))
2444            .await?;
2445        Ok(serde_json::from_value(_value)?)
2446    }
2447
2448    /// Loads previously-deferred repo-level hooks on the active session, returning queued startup prompts.
2449    ///
2450    /// Wire method: `sessions.loadDeferredRepoHooks`.
2451    ///
2452    /// # Parameters
2453    ///
2454    /// * `params` - Active session ID whose deferred repo-level hooks should be loaded.
2455    ///
2456    /// # Returns
2457    ///
2458    /// Queued repo-level startup prompts and the total hook command count after loading.
2459    ///
2460    /// <div class="warning">
2461    ///
2462    /// **Experimental.** This API is part of an experimental wire-protocol surface
2463    /// and may change or be removed in future SDK or CLI releases. Pin both the
2464    /// SDK and CLI versions if your code depends on it.
2465    ///
2466    /// </div>
2467    pub async fn load_deferred_repo_hooks(
2468        &self,
2469        params: SessionsLoadDeferredRepoHooksRequest,
2470    ) -> Result<SessionLoadDeferredRepoHooksResult, Error> {
2471        let wire_params = serde_json::to_value(params)?;
2472        let _value = self
2473            .client
2474            .call(
2475                rpc_methods::SESSIONS_LOADDEFERREDREPOHOOKS,
2476                Some(wire_params),
2477            )
2478            .await?;
2479        Ok(serde_json::from_value(_value)?)
2480    }
2481
2482    /// Replaces the manager-wide additional plugins registered with the session manager.
2483    ///
2484    /// Wire method: `sessions.setAdditionalPlugins`.
2485    ///
2486    /// # Parameters
2487    ///
2488    /// * `params` - Manager-wide additional plugins to register; replaces any previously-configured set.
2489    ///
2490    /// # Returns
2491    ///
2492    /// 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.
2493    ///
2494    /// <div class="warning">
2495    ///
2496    /// **Experimental.** This API is part of an experimental wire-protocol surface
2497    /// and may change or be removed in future SDK or CLI releases. Pin both the
2498    /// SDK and CLI versions if your code depends on it.
2499    ///
2500    /// </div>
2501    pub async fn set_additional_plugins(
2502        &self,
2503        params: SessionsSetAdditionalPluginsRequest,
2504    ) -> Result<SessionsSetAdditionalPluginsResult, Error> {
2505        let wire_params = serde_json::to_value(params)?;
2506        let _value = self
2507            .client
2508            .call(
2509                rpc_methods::SESSIONS_SETADDITIONALPLUGINS,
2510                Some(wire_params),
2511            )
2512            .await?;
2513        Ok(serde_json::from_value(_value)?)
2514    }
2515
2516    /// 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.
2517    ///
2518    /// Wire method: `sessions.getBoardEntryCount`.
2519    ///
2520    /// # Parameters
2521    ///
2522    /// * `params` - Session ID whose board entry count should be returned.
2523    ///
2524    /// # Returns
2525    ///
2526    /// Dynamic-context board entry count, when available.
2527    ///
2528    /// <div class="warning">
2529    ///
2530    /// **Experimental.** This API is part of an experimental wire-protocol surface
2531    /// and may change or be removed in future SDK or CLI releases. Pin both the
2532    /// SDK and CLI versions if your code depends on it.
2533    ///
2534    /// </div>
2535    pub(crate) async fn get_board_entry_count(
2536        &self,
2537        params: SessionsGetBoardEntryCountRequest,
2538    ) -> Result<SessionsGetBoardEntryCountResult, Error> {
2539        let wire_params = serde_json::to_value(params)?;
2540        let _value = self
2541            .client
2542            .call(rpc_methods::SESSIONS_GETBOARDENTRYCOUNT, Some(wire_params))
2543            .await?;
2544        Ok(serde_json::from_value(_value)?)
2545    }
2546
2547    /// 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.
2548    ///
2549    /// Wire method: `sessions.startRemoteControl`.
2550    ///
2551    /// # Parameters
2552    ///
2553    /// * `params` - Parameters for attaching the remote-control singleton to a session.
2554    ///
2555    /// # Returns
2556    ///
2557    /// Wrapper for the singleton's current status.
2558    ///
2559    /// <div class="warning">
2560    ///
2561    /// **Experimental.** This API is part of an experimental wire-protocol surface
2562    /// and may change or be removed in future SDK or CLI releases. Pin both the
2563    /// SDK and CLI versions if your code depends on it.
2564    ///
2565    /// </div>
2566    pub async fn start_remote_control(
2567        &self,
2568        params: SessionsStartRemoteControlRequest,
2569    ) -> Result<RemoteControlStatusResult, Error> {
2570        let wire_params = serde_json::to_value(params)?;
2571        let _value = self
2572            .client
2573            .call(rpc_methods::SESSIONS_STARTREMOTECONTROL, Some(wire_params))
2574            .await?;
2575        Ok(serde_json::from_value(_value)?)
2576    }
2577
2578    /// 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.
2579    ///
2580    /// Wire method: `sessions.transferRemoteControl`.
2581    ///
2582    /// # Parameters
2583    ///
2584    /// * `params` - Parameters for atomically rebinding the remote-control singleton.
2585    ///
2586    /// # Returns
2587    ///
2588    /// Outcome of a transferRemoteControl call.
2589    ///
2590    /// <div class="warning">
2591    ///
2592    /// **Experimental.** This API is part of an experimental wire-protocol surface
2593    /// and may change or be removed in future SDK or CLI releases. Pin both the
2594    /// SDK and CLI versions if your code depends on it.
2595    ///
2596    /// </div>
2597    pub async fn transfer_remote_control(
2598        &self,
2599        params: SessionsTransferRemoteControlRequest,
2600    ) -> Result<RemoteControlTransferResult, Error> {
2601        let wire_params = serde_json::to_value(params)?;
2602        let _value = self
2603            .client
2604            .call(
2605                rpc_methods::SESSIONS_TRANSFERREMOTECONTROL,
2606                Some(wire_params),
2607            )
2608            .await?;
2609        Ok(serde_json::from_value(_value)?)
2610    }
2611
2612    /// 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.
2613    ///
2614    /// Wire method: `sessions.setRemoteControlSteering`.
2615    ///
2616    /// # Parameters
2617    ///
2618    /// * `params` - Patch for the singleton's steering state.
2619    ///
2620    /// # Returns
2621    ///
2622    /// Wrapper for the singleton's current status.
2623    ///
2624    /// <div class="warning">
2625    ///
2626    /// **Experimental.** This API is part of an experimental wire-protocol surface
2627    /// and may change or be removed in future SDK or CLI releases. Pin both the
2628    /// SDK and CLI versions if your code depends on it.
2629    ///
2630    /// </div>
2631    pub async fn set_remote_control_steering(
2632        &self,
2633        params: SessionsSetRemoteControlSteeringRequest,
2634    ) -> Result<RemoteControlStatusResult, Error> {
2635        let wire_params = serde_json::to_value(params)?;
2636        let _value = self
2637            .client
2638            .call(
2639                rpc_methods::SESSIONS_SETREMOTECONTROLSTEERING,
2640                Some(wire_params),
2641            )
2642            .await?;
2643        Ok(serde_json::from_value(_value)?)
2644    }
2645
2646    /// 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).
2647    ///
2648    /// Wire method: `sessions.stopRemoteControl`.
2649    ///
2650    /// # Returns
2651    ///
2652    /// Outcome of a stopRemoteControl call.
2653    ///
2654    /// <div class="warning">
2655    ///
2656    /// **Experimental.** This API is part of an experimental wire-protocol surface
2657    /// and may change or be removed in future SDK or CLI releases. Pin both the
2658    /// SDK and CLI versions if your code depends on it.
2659    ///
2660    /// </div>
2661    pub async fn stop_remote_control(&self) -> Result<RemoteControlStopResult, Error> {
2662        let wire_params = serde_json::json!({});
2663        let _value = self
2664            .client
2665            .call(rpc_methods::SESSIONS_STOPREMOTECONTROL, Some(wire_params))
2666            .await?;
2667        Ok(serde_json::from_value(_value)?)
2668    }
2669
2670    /// 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).
2671    ///
2672    /// Wire method: `sessions.stopRemoteControl`.
2673    ///
2674    /// # Parameters
2675    ///
2676    /// * `params` - Parameters for stopping the remote-control singleton.
2677    ///
2678    /// # Returns
2679    ///
2680    /// Outcome of a stopRemoteControl call.
2681    ///
2682    /// <div class="warning">
2683    ///
2684    /// **Experimental.** This API is part of an experimental wire-protocol surface
2685    /// and may change or be removed in future SDK or CLI releases. Pin both the
2686    /// SDK and CLI versions if your code depends on it.
2687    ///
2688    /// </div>
2689    pub async fn stop_remote_control_with_params(
2690        &self,
2691        params: SessionsStopRemoteControlRequest,
2692    ) -> Result<RemoteControlStopResult, Error> {
2693        let wire_params = serde_json::to_value(params)?;
2694        let _value = self
2695            .client
2696            .call(rpc_methods::SESSIONS_STOPREMOTECONTROL, Some(wire_params))
2697            .await?;
2698        Ok(serde_json::from_value(_value)?)
2699    }
2700
2701    /// Returns the current state of the remote-control singleton, including the attached session id and frontend URL when active.
2702    ///
2703    /// Wire method: `sessions.getRemoteControlStatus`.
2704    ///
2705    /// # Returns
2706    ///
2707    /// Wrapper for the singleton's current status.
2708    ///
2709    /// <div class="warning">
2710    ///
2711    /// **Experimental.** This API is part of an experimental wire-protocol surface
2712    /// and may change or be removed in future SDK or CLI releases. Pin both the
2713    /// SDK and CLI versions if your code depends on it.
2714    ///
2715    /// </div>
2716    pub async fn get_remote_control_status(&self) -> Result<RemoteControlStatusResult, Error> {
2717        let wire_params = serde_json::json!({});
2718        let _value = self
2719            .client
2720            .call(
2721                rpc_methods::SESSIONS_GETREMOTECONTROLSTATUS,
2722                Some(wire_params),
2723            )
2724            .await?;
2725        Ok(serde_json::from_value(_value)?)
2726    }
2727
2728    /// 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.
2729    ///
2730    /// Wire method: `sessions.registerExtensionToolsOnSession`.
2731    ///
2732    /// # Parameters
2733    ///
2734    /// * `params` - Params to attach an extension loader's tools to a session.
2735    ///
2736    /// # Returns
2737    ///
2738    /// Handle for releasing the extension tool registration.
2739    ///
2740    /// <div class="warning">
2741    ///
2742    /// **Experimental.** This API is part of an experimental wire-protocol surface
2743    /// and may change or be removed in future SDK or CLI releases. Pin both the
2744    /// SDK and CLI versions if your code depends on it.
2745    ///
2746    /// </div>
2747    pub(crate) async fn register_extension_tools_on_session(
2748        &self,
2749        params: RegisterExtensionToolsParams,
2750    ) -> Result<RegisterExtensionToolsResult, Error> {
2751        let wire_params = serde_json::to_value(params)?;
2752        let _value = self
2753            .client
2754            .call(
2755                rpc_methods::SESSIONS_REGISTEREXTENSIONTOOLSONSESSION,
2756                Some(wire_params),
2757            )
2758            .await?;
2759        Ok(serde_json::from_value(_value)?)
2760    }
2761
2762    /// 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.
2763    ///
2764    /// Wire method: `sessions.configureSessionExtensions`.
2765    ///
2766    /// # Parameters
2767    ///
2768    /// * `params` - Params to attach or detach an in-process ExtensionController delegate.
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(crate) async fn configure_session_extensions(
2778        &self,
2779        params: ConfigureSessionExtensionsParams,
2780    ) -> Result<(), Error> {
2781        let wire_params = serde_json::to_value(params)?;
2782        let _value = self
2783            .client
2784            .call(
2785                rpc_methods::SESSIONS_CONFIGURESESSIONEXTENSIONS,
2786                Some(wire_params),
2787            )
2788            .await?;
2789        Ok(())
2790    }
2791}
2792
2793/// `skills.*` RPCs.
2794#[derive(Clone, Copy)]
2795pub struct ClientRpcSkills<'a> {
2796    pub(crate) client: &'a Client,
2797}
2798
2799impl<'a> ClientRpcSkills<'a> {
2800    /// `skills.config.*` sub-namespace.
2801    pub fn config(&self) -> ClientRpcSkillsConfig<'a> {
2802        ClientRpcSkillsConfig {
2803            client: self.client,
2804        }
2805    }
2806
2807    /// Discovers skills across global and project sources.
2808    ///
2809    /// Wire method: `skills.discover`.
2810    ///
2811    /// # Parameters
2812    ///
2813    /// * `params` - Optional project paths and additional skill directories to include in discovery.
2814    ///
2815    /// # Returns
2816    ///
2817    /// Skills discovered across global and project sources.
2818    ///
2819    /// <div class="warning">
2820    ///
2821    /// **Experimental.** This API is part of an experimental wire-protocol surface
2822    /// and may change or be removed in future SDK or CLI releases. Pin both the
2823    /// SDK and CLI versions if your code depends on it.
2824    ///
2825    /// </div>
2826    pub async fn discover(&self, params: SkillsDiscoverRequest) -> Result<ServerSkillList, Error> {
2827        let wire_params = serde_json::to_value(params)?;
2828        let _value = self
2829            .client
2830            .call(rpc_methods::SKILLS_DISCOVER, Some(wire_params))
2831            .await?;
2832        Ok(serde_json::from_value(_value)?)
2833    }
2834
2835    /// 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.
2836    ///
2837    /// Wire method: `skills.getDiscoveryPaths`.
2838    ///
2839    /// # Parameters
2840    ///
2841    /// * `params` - Optional project paths to enumerate.
2842    ///
2843    /// # Returns
2844    ///
2845    /// Canonical locations where skills can be created so the runtime will recognize them.
2846    ///
2847    /// <div class="warning">
2848    ///
2849    /// **Experimental.** This API is part of an experimental wire-protocol surface
2850    /// and may change or be removed in future SDK or CLI releases. Pin both the
2851    /// SDK and CLI versions if your code depends on it.
2852    ///
2853    /// </div>
2854    pub async fn get_discovery_paths(
2855        &self,
2856        params: SkillsGetDiscoveryPathsRequest,
2857    ) -> Result<SkillDiscoveryPathList, Error> {
2858        let wire_params = serde_json::to_value(params)?;
2859        let _value = self
2860            .client
2861            .call(rpc_methods::SKILLS_GETDISCOVERYPATHS, Some(wire_params))
2862            .await?;
2863        Ok(serde_json::from_value(_value)?)
2864    }
2865}
2866
2867/// `skills.config.*` RPCs.
2868#[derive(Clone, Copy)]
2869pub struct ClientRpcSkillsConfig<'a> {
2870    pub(crate) client: &'a Client,
2871}
2872
2873impl<'a> ClientRpcSkillsConfig<'a> {
2874    /// Replaces the global list of disabled skills.
2875    ///
2876    /// Wire method: `skills.config.setDisabledSkills`.
2877    ///
2878    /// # Parameters
2879    ///
2880    /// * `params` - Skill names to mark as disabled in global configuration, replacing any previous list.
2881    ///
2882    /// <div class="warning">
2883    ///
2884    /// **Experimental.** This API is part of an experimental wire-protocol surface
2885    /// and may change or be removed in future SDK or CLI releases. Pin both the
2886    /// SDK and CLI versions if your code depends on it.
2887    ///
2888    /// </div>
2889    pub async fn set_disabled_skills(
2890        &self,
2891        params: SkillsConfigSetDisabledSkillsRequest,
2892    ) -> Result<(), Error> {
2893        let wire_params = serde_json::to_value(params)?;
2894        let _value = self
2895            .client
2896            .call(
2897                rpc_methods::SKILLS_CONFIG_SETDISABLEDSKILLS,
2898                Some(wire_params),
2899            )
2900            .await?;
2901        Ok(())
2902    }
2903
2904    /// Atomically adds or removes one skill from the disabled list.
2905    ///
2906    /// Wire method: `skills.config.setSkillDisabled`.
2907    ///
2908    /// # Parameters
2909    ///
2910    /// * `params` - Adds or removes a single skill from the global disabled list, leaving every other entry untouched.
2911    ///
2912    /// <div class="warning">
2913    ///
2914    /// **Experimental.** This API is part of an experimental wire-protocol surface
2915    /// and may change or be removed in future SDK or CLI releases. Pin both the
2916    /// SDK and CLI versions if your code depends on it.
2917    ///
2918    /// </div>
2919    pub async fn set_skill_disabled(
2920        &self,
2921        params: SkillsConfigSetSkillDisabledRequest,
2922    ) -> Result<(), Error> {
2923        let wire_params = serde_json::to_value(params)?;
2924        let _value = self
2925            .client
2926            .call(
2927                rpc_methods::SKILLS_CONFIG_SETSKILLDISABLED,
2928                Some(wire_params),
2929            )
2930            .await?;
2931        Ok(())
2932    }
2933}
2934
2935/// `tools.*` RPCs.
2936#[derive(Clone, Copy)]
2937pub struct ClientRpcTools<'a> {
2938    pub(crate) client: &'a Client,
2939}
2940
2941impl<'a> ClientRpcTools<'a> {
2942    /// Lists built-in tools available for a model.
2943    ///
2944    /// Wire method: `tools.list`.
2945    ///
2946    /// # Parameters
2947    ///
2948    /// * `params` - Optional model identifier whose tool overrides should be applied to the listing.
2949    ///
2950    /// # Returns
2951    ///
2952    /// Built-in tools available for the requested model, with their parameters and instructions.
2953    ///
2954    /// <div class="warning">
2955    ///
2956    /// **Experimental.** This API is part of an experimental wire-protocol surface
2957    /// and may change or be removed in future SDK or CLI releases. Pin both the
2958    /// SDK and CLI versions if your code depends on it.
2959    ///
2960    /// </div>
2961    pub async fn list(&self, params: ToolsListRequest) -> Result<ToolList, Error> {
2962        let wire_params = serde_json::to_value(params)?;
2963        let _value = self
2964            .client
2965            .call(rpc_methods::TOOLS_LIST, Some(wire_params))
2966            .await?;
2967        Ok(serde_json::from_value(_value)?)
2968    }
2969}
2970
2971/// `user.*` RPCs.
2972#[derive(Clone, Copy)]
2973pub struct ClientRpcUser<'a> {
2974    pub(crate) client: &'a Client,
2975}
2976
2977impl<'a> ClientRpcUser<'a> {
2978    /// `user.settings.*` sub-namespace.
2979    pub fn settings(&self) -> ClientRpcUserSettings<'a> {
2980        ClientRpcUserSettings {
2981            client: self.client,
2982        }
2983    }
2984}
2985
2986/// `user.settings.*` RPCs.
2987#[derive(Clone, Copy)]
2988pub struct ClientRpcUserSettings<'a> {
2989    pub(crate) client: &'a Client,
2990}
2991
2992impl<'a> ClientRpcUserSettings<'a> {
2993    /// Drops this runtime process's in-memory user settings cache so the next settings read observes disk.
2994    ///
2995    /// Wire method: `user.settings.reload`.
2996    ///
2997    /// <div class="warning">
2998    ///
2999    /// **Experimental.** This API is part of an experimental wire-protocol surface
3000    /// and may change or be removed in future SDK or CLI releases. Pin both the
3001    /// SDK and CLI versions if your code depends on it.
3002    ///
3003    /// </div>
3004    pub async fn reload(&self) -> Result<(), Error> {
3005        let wire_params = serde_json::json!({});
3006        let _value = self
3007            .client
3008            .call(rpc_methods::USER_SETTINGS_RELOAD, Some(wire_params))
3009            .await?;
3010        Ok(())
3011    }
3012
3013    /// 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.
3014    ///
3015    /// Wire method: `user.settings.get`.
3016    ///
3017    /// # Returns
3018    ///
3019    /// 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.
3020    ///
3021    /// <div class="warning">
3022    ///
3023    /// **Experimental.** This API is part of an experimental wire-protocol surface
3024    /// and may change or be removed in future SDK or CLI releases. Pin both the
3025    /// SDK and CLI versions if your code depends on it.
3026    ///
3027    /// </div>
3028    pub async fn get(&self) -> Result<UserSettingsGetResult, Error> {
3029        let wire_params = serde_json::json!({});
3030        let _value = self
3031            .client
3032            .call(rpc_methods::USER_SETTINGS_GET, Some(wire_params))
3033            .await?;
3034        Ok(serde_json::from_value(_value)?)
3035    }
3036
3037    /// 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.
3038    ///
3039    /// Wire method: `user.settings.set`.
3040    ///
3041    /// # Parameters
3042    ///
3043    /// * `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.
3044    ///
3045    /// # Returns
3046    ///
3047    /// Outcome of writing user settings.
3048    ///
3049    /// <div class="warning">
3050    ///
3051    /// **Experimental.** This API is part of an experimental wire-protocol surface
3052    /// and may change or be removed in future SDK or CLI releases. Pin both the
3053    /// SDK and CLI versions if your code depends on it.
3054    ///
3055    /// </div>
3056    pub async fn set(
3057        &self,
3058        params: UserSettingsSetRequest,
3059    ) -> Result<UserSettingsSetResult, Error> {
3060        let wire_params = serde_json::to_value(params)?;
3061        let _value = self
3062            .client
3063            .call(rpc_methods::USER_SETTINGS_SET, Some(wire_params))
3064            .await?;
3065        Ok(serde_json::from_value(_value)?)
3066    }
3067}
3068
3069/// Typed view over a [`Session`]'s RPC namespace.
3070#[derive(Clone, Copy)]
3071pub struct SessionRpc<'a> {
3072    pub(crate) session: &'a Session,
3073}
3074
3075impl<'a> SessionRpc<'a> {
3076    /// `session.agent.*` sub-namespace.
3077    pub fn agent(&self) -> SessionRpcAgent<'a> {
3078        SessionRpcAgent {
3079            session: self.session,
3080        }
3081    }
3082
3083    /// `session.canvas.*` sub-namespace.
3084    pub fn canvas(&self) -> SessionRpcCanvas<'a> {
3085        SessionRpcCanvas {
3086            session: self.session,
3087        }
3088    }
3089
3090    /// `session.commands.*` sub-namespace.
3091    pub fn commands(&self) -> SessionRpcCommands<'a> {
3092        SessionRpcCommands {
3093            session: self.session,
3094        }
3095    }
3096
3097    /// `session.completions.*` sub-namespace.
3098    pub fn completions(&self) -> SessionRpcCompletions<'a> {
3099        SessionRpcCompletions {
3100            session: self.session,
3101        }
3102    }
3103
3104    /// `session.contentExclusion.*` sub-namespace.
3105    pub fn content_exclusion(&self) -> SessionRpcContentExclusion<'a> {
3106        SessionRpcContentExclusion {
3107            session: self.session,
3108        }
3109    }
3110
3111    /// `session.debug.*` sub-namespace.
3112    pub fn debug(&self) -> SessionRpcDebug<'a> {
3113        SessionRpcDebug {
3114            session: self.session,
3115        }
3116    }
3117
3118    /// `session.eventLog.*` sub-namespace.
3119    pub fn event_log(&self) -> SessionRpcEventLog<'a> {
3120        SessionRpcEventLog {
3121            session: self.session,
3122        }
3123    }
3124
3125    /// `session.extensions.*` sub-namespace.
3126    pub fn extensions(&self) -> SessionRpcExtensions<'a> {
3127        SessionRpcExtensions {
3128            session: self.session,
3129        }
3130    }
3131
3132    /// `session.factory.*` sub-namespace.
3133    pub fn factory(&self) -> SessionRpcFactory<'a> {
3134        SessionRpcFactory {
3135            session: self.session,
3136        }
3137    }
3138
3139    /// `session.fleet.*` sub-namespace.
3140    pub fn fleet(&self) -> SessionRpcFleet<'a> {
3141        SessionRpcFleet {
3142            session: self.session,
3143        }
3144    }
3145
3146    /// `session.gitHubAuth.*` sub-namespace.
3147    pub fn git_hub_auth(&self) -> SessionRpcGitHubAuth<'a> {
3148        SessionRpcGitHubAuth {
3149            session: self.session,
3150        }
3151    }
3152
3153    /// `session.history.*` sub-namespace.
3154    pub fn history(&self) -> SessionRpcHistory<'a> {
3155        SessionRpcHistory {
3156            session: self.session,
3157        }
3158    }
3159
3160    /// `session.instructions.*` sub-namespace.
3161    pub fn instructions(&self) -> SessionRpcInstructions<'a> {
3162        SessionRpcInstructions {
3163            session: self.session,
3164        }
3165    }
3166
3167    /// `session.limitPrediction.*` sub-namespace.
3168    pub fn limit_prediction(&self) -> SessionRpcLimitPrediction<'a> {
3169        SessionRpcLimitPrediction {
3170            session: self.session,
3171        }
3172    }
3173
3174    /// `session.lsp.*` sub-namespace.
3175    pub fn lsp(&self) -> SessionRpcLsp<'a> {
3176        SessionRpcLsp {
3177            session: self.session,
3178        }
3179    }
3180
3181    /// `session.mcp.*` sub-namespace.
3182    pub fn mcp(&self) -> SessionRpcMcp<'a> {
3183        SessionRpcMcp {
3184            session: self.session,
3185        }
3186    }
3187
3188    /// `session.metadata.*` sub-namespace.
3189    pub fn metadata(&self) -> SessionRpcMetadata<'a> {
3190        SessionRpcMetadata {
3191            session: self.session,
3192        }
3193    }
3194
3195    /// `session.mode.*` sub-namespace.
3196    pub fn mode(&self) -> SessionRpcMode<'a> {
3197        SessionRpcMode {
3198            session: self.session,
3199        }
3200    }
3201
3202    /// `session.model.*` sub-namespace.
3203    pub fn model(&self) -> SessionRpcModel<'a> {
3204        SessionRpcModel {
3205            session: self.session,
3206        }
3207    }
3208
3209    /// `session.name.*` sub-namespace.
3210    pub fn name(&self) -> SessionRpcName<'a> {
3211        SessionRpcName {
3212            session: self.session,
3213        }
3214    }
3215
3216    /// `session.options.*` sub-namespace.
3217    pub fn options(&self) -> SessionRpcOptions<'a> {
3218        SessionRpcOptions {
3219            session: self.session,
3220        }
3221    }
3222
3223    /// `session.permissions.*` sub-namespace.
3224    pub fn permissions(&self) -> SessionRpcPermissions<'a> {
3225        SessionRpcPermissions {
3226            session: self.session,
3227        }
3228    }
3229
3230    /// `session.plan.*` sub-namespace.
3231    pub fn plan(&self) -> SessionRpcPlan<'a> {
3232        SessionRpcPlan {
3233            session: self.session,
3234        }
3235    }
3236
3237    /// `session.plugins.*` sub-namespace.
3238    pub fn plugins(&self) -> SessionRpcPlugins<'a> {
3239        SessionRpcPlugins {
3240            session: self.session,
3241        }
3242    }
3243
3244    /// `session.provider.*` sub-namespace.
3245    pub fn provider(&self) -> SessionRpcProvider<'a> {
3246        SessionRpcProvider {
3247            session: self.session,
3248        }
3249    }
3250
3251    /// `session.queue.*` sub-namespace.
3252    pub fn queue(&self) -> SessionRpcQueue<'a> {
3253        SessionRpcQueue {
3254            session: self.session,
3255        }
3256    }
3257
3258    /// `session.remote.*` sub-namespace.
3259    pub fn remote(&self) -> SessionRpcRemote<'a> {
3260        SessionRpcRemote {
3261            session: self.session,
3262        }
3263    }
3264
3265    /// `session.sandbox.*` sub-namespace.
3266    pub fn sandbox(&self) -> SessionRpcSandbox<'a> {
3267        SessionRpcSandbox {
3268            session: self.session,
3269        }
3270    }
3271
3272    /// `session.schedule.*` sub-namespace.
3273    pub fn schedule(&self) -> SessionRpcSchedule<'a> {
3274        SessionRpcSchedule {
3275            session: self.session,
3276        }
3277    }
3278
3279    /// `session.settings.*` sub-namespace.
3280    pub fn settings(&self) -> SessionRpcSettings<'a> {
3281        SessionRpcSettings {
3282            session: self.session,
3283        }
3284    }
3285
3286    /// `session.shell.*` sub-namespace.
3287    pub fn shell(&self) -> SessionRpcShell<'a> {
3288        SessionRpcShell {
3289            session: self.session,
3290        }
3291    }
3292
3293    /// `session.skills.*` sub-namespace.
3294    pub fn skills(&self) -> SessionRpcSkills<'a> {
3295        SessionRpcSkills {
3296            session: self.session,
3297        }
3298    }
3299
3300    /// `session.tasks.*` sub-namespace.
3301    pub fn tasks(&self) -> SessionRpcTasks<'a> {
3302        SessionRpcTasks {
3303            session: self.session,
3304        }
3305    }
3306
3307    /// `session.telemetry.*` sub-namespace.
3308    pub fn telemetry(&self) -> SessionRpcTelemetry<'a> {
3309        SessionRpcTelemetry {
3310            session: self.session,
3311        }
3312    }
3313
3314    /// `session.tools.*` sub-namespace.
3315    pub fn tools(&self) -> SessionRpcTools<'a> {
3316        SessionRpcTools {
3317            session: self.session,
3318        }
3319    }
3320
3321    /// `session.ui.*` sub-namespace.
3322    pub fn ui(&self) -> SessionRpcUi<'a> {
3323        SessionRpcUi {
3324            session: self.session,
3325        }
3326    }
3327
3328    /// `session.usage.*` sub-namespace.
3329    pub fn usage(&self) -> SessionRpcUsage<'a> {
3330        SessionRpcUsage {
3331            session: self.session,
3332        }
3333    }
3334
3335    /// `session.visibility.*` sub-namespace.
3336    pub fn visibility(&self) -> SessionRpcVisibility<'a> {
3337        SessionRpcVisibility {
3338            session: self.session,
3339        }
3340    }
3341
3342    /// `session.workspaces.*` sub-namespace.
3343    pub fn workspaces(&self) -> SessionRpcWorkspaces<'a> {
3344        SessionRpcWorkspaces {
3345            session: self.session,
3346        }
3347    }
3348
3349    /// Suspends the session while preserving persisted state for later resume.
3350    ///
3351    /// Wire method: `session.suspend`.
3352    ///
3353    /// <div class="warning">
3354    ///
3355    /// **Experimental.** This API is part of an experimental wire-protocol surface
3356    /// and may change or be removed in future SDK or CLI releases. Pin both the
3357    /// SDK and CLI versions if your code depends on it.
3358    ///
3359    /// </div>
3360    pub async fn suspend(&self) -> Result<(), Error> {
3361        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3362        let _value = self
3363            .session
3364            .client()
3365            .call(rpc_methods::SESSION_SUSPEND, Some(wire_params))
3366            .await?;
3367        Ok(())
3368    }
3369
3370    /// Sends a user message to the session and returns its message ID.
3371    ///
3372    /// Wire method: `session.send`.
3373    ///
3374    /// # Parameters
3375    ///
3376    /// * `params` - Parameters for sending a user message to the session
3377    ///
3378    /// # Returns
3379    ///
3380    /// Result of sending a user message
3381    ///
3382    /// <div class="warning">
3383    ///
3384    /// **Experimental.** This API is part of an experimental wire-protocol surface
3385    /// and may change or be removed in future SDK or CLI releases. Pin both the
3386    /// SDK and CLI versions if your code depends on it.
3387    ///
3388    /// </div>
3389    pub async fn send(&self, params: SendRequest) -> Result<SendResult, Error> {
3390        let mut wire_params = serde_json::to_value(params)?;
3391        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3392        let _value = self
3393            .session
3394            .client()
3395            .call(rpc_methods::SESSION_SEND, Some(wire_params))
3396            .await?;
3397        Ok(serde_json::from_value(_value)?)
3398    }
3399
3400    /// 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.
3401    ///
3402    /// Wire method: `session.sendMessages`.
3403    ///
3404    /// # Parameters
3405    ///
3406    /// * `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.
3407    ///
3408    /// # Returns
3409    ///
3410    /// Result of sending zero or more user messages
3411    ///
3412    /// <div class="warning">
3413    ///
3414    /// **Experimental.** This API is part of an experimental wire-protocol surface
3415    /// and may change or be removed in future SDK or CLI releases. Pin both the
3416    /// SDK and CLI versions if your code depends on it.
3417    ///
3418    /// </div>
3419    pub async fn send_messages(
3420        &self,
3421        params: SendMessagesRequest,
3422    ) -> Result<SendMessagesResult, Error> {
3423        let mut wire_params = serde_json::to_value(params)?;
3424        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3425        let _value = self
3426            .session
3427            .client()
3428            .call(rpc_methods::SESSION_SENDMESSAGES, Some(wire_params))
3429            .await?;
3430        Ok(serde_json::from_value(_value)?)
3431    }
3432
3433    /// Queues or sends an internal system notification to the session according to its passive policy.
3434    ///
3435    /// Wire method: `session.sendSystemNotification`.
3436    ///
3437    /// # Parameters
3438    ///
3439    /// * `params` - Internal request for sending a system notification.
3440    ///
3441    /// <div class="warning">
3442    ///
3443    /// **Experimental.** This API is part of an experimental wire-protocol surface
3444    /// and may change or be removed in future SDK or CLI releases. Pin both the
3445    /// SDK and CLI versions if your code depends on it.
3446    ///
3447    /// </div>
3448    pub(crate) async fn send_system_notification(
3449        &self,
3450        params: SendSystemNotificationRequest,
3451    ) -> Result<(), Error> {
3452        let mut wire_params = serde_json::to_value(params)?;
3453        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3454        let _value = self
3455            .session
3456            .client()
3457            .call(
3458                rpc_methods::SESSION_SENDSYSTEMNOTIFICATION,
3459                Some(wire_params),
3460            )
3461            .await?;
3462        Ok(())
3463    }
3464
3465    /// Aborts the current agent turn.
3466    ///
3467    /// Wire method: `session.abort`.
3468    ///
3469    /// # Parameters
3470    ///
3471    /// * `params` - Parameters for aborting the current turn
3472    ///
3473    /// # Returns
3474    ///
3475    /// Result of aborting the current turn
3476    ///
3477    /// <div class="warning">
3478    ///
3479    /// **Experimental.** This API is part of an experimental wire-protocol surface
3480    /// and may change or be removed in future SDK or CLI releases. Pin both the
3481    /// SDK and CLI versions if your code depends on it.
3482    ///
3483    /// </div>
3484    pub async fn abort(&self, params: AbortRequest) -> Result<AbortResult, Error> {
3485        let mut wire_params = serde_json::to_value(params)?;
3486        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3487        let _value = self
3488            .session
3489            .client()
3490            .call(rpc_methods::SESSION_ABORT, Some(wire_params))
3491            .await?;
3492        Ok(serde_json::from_value(_value)?)
3493    }
3494
3495    /// 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.
3496    ///
3497    /// Wire method: `session.interruptMainTurn`.
3498    ///
3499    /// # Parameters
3500    ///
3501    /// * `params` - Parameters for interrupting the main agent turn.
3502    ///
3503    /// # Returns
3504    ///
3505    /// Result of interrupting the main agent turn.
3506    ///
3507    /// <div class="warning">
3508    ///
3509    /// **Experimental.** This API is part of an experimental wire-protocol surface
3510    /// and may change or be removed in future SDK or CLI releases. Pin both the
3511    /// SDK and CLI versions if your code depends on it.
3512    ///
3513    /// </div>
3514    pub async fn interrupt_main_turn(
3515        &self,
3516        params: InterruptMainTurnRequest,
3517    ) -> Result<InterruptMainTurnResult, Error> {
3518        let mut wire_params = serde_json::to_value(params)?;
3519        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3520        let _value = self
3521            .session
3522            .client()
3523            .call(rpc_methods::SESSION_INTERRUPTMAINTURN, Some(wire_params))
3524            .await?;
3525        Ok(serde_json::from_value(_value)?)
3526    }
3527
3528    /// Cancels every running background agent (task-registry subagents plus sidekick agents) without interrupting the main agent loop. Promoted attached shells are left running.
3529    ///
3530    /// Wire method: `session.cancelAllBackgroundAgents`.
3531    ///
3532    /// # Returns
3533    ///
3534    /// The number of running background agents (task-registry agents) that were cancelled.
3535    ///
3536    /// <div class="warning">
3537    ///
3538    /// **Experimental.** This API is part of an experimental wire-protocol surface
3539    /// and may change or be removed in future SDK or CLI releases. Pin both the
3540    /// SDK and CLI versions if your code depends on it.
3541    ///
3542    /// </div>
3543    pub async fn cancel_all_background_agents(
3544        &self,
3545    ) -> Result<SessionCancelAllBackgroundAgentsResult, Error> {
3546        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3547        let _value = self
3548            .session
3549            .client()
3550            .call(
3551                rpc_methods::SESSION_CANCELALLBACKGROUNDAGENTS,
3552                Some(wire_params),
3553            )
3554            .await?;
3555        Ok(serde_json::from_value(_value)?)
3556    }
3557
3558    /// 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.
3559    ///
3560    /// Wire method: `session.shutdown`.
3561    ///
3562    /// # Parameters
3563    ///
3564    /// * `params` - Parameters for shutting down the session
3565    ///
3566    /// <div class="warning">
3567    ///
3568    /// **Experimental.** This API is part of an experimental wire-protocol surface
3569    /// and may change or be removed in future SDK or CLI releases. Pin both the
3570    /// SDK and CLI versions if your code depends on it.
3571    ///
3572    /// </div>
3573    pub async fn shutdown(&self, params: ShutdownRequest) -> Result<(), Error> {
3574        let mut wire_params = serde_json::to_value(params)?;
3575        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3576        let _value = self
3577            .session
3578            .client()
3579            .call(rpc_methods::SESSION_SHUTDOWN, Some(wire_params))
3580            .await?;
3581        Ok(())
3582    }
3583
3584    /// Emits a user-visible session log event.
3585    ///
3586    /// Wire method: `session.log`.
3587    ///
3588    /// # Parameters
3589    ///
3590    /// * `params` - Message text, optional severity level, persistence flag, optional follow-up URL, and optional tip.
3591    ///
3592    /// # Returns
3593    ///
3594    /// Identifier of the session event that was emitted for the log message.
3595    ///
3596    /// <div class="warning">
3597    ///
3598    /// **Experimental.** This API is part of an experimental wire-protocol surface
3599    /// and may change or be removed in future SDK or CLI releases. Pin both the
3600    /// SDK and CLI versions if your code depends on it.
3601    ///
3602    /// </div>
3603    pub async fn log(&self, params: LogRequest) -> Result<LogResult, Error> {
3604        let mut wire_params = serde_json::to_value(params)?;
3605        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3606        let _value = self
3607            .session
3608            .client()
3609            .call(rpc_methods::SESSION_LOG, Some(wire_params))
3610            .await?;
3611        Ok(serde_json::from_value(_value)?)
3612    }
3613}
3614
3615/// `session.agent.*` RPCs.
3616#[derive(Clone, Copy)]
3617pub struct SessionRpcAgent<'a> {
3618    pub(crate) session: &'a Session,
3619}
3620
3621impl<'a> SessionRpcAgent<'a> {
3622    /// Lists agents available to the session. Defaults to custom agents only; pass includeBuiltInAgents to include the effective built-in agents.
3623    ///
3624    /// Wire method: `session.agent.list`.
3625    ///
3626    /// # Returns
3627    ///
3628    /// Agents available to the session.
3629    ///
3630    /// <div class="warning">
3631    ///
3632    /// **Experimental.** This API is part of an experimental wire-protocol surface
3633    /// and may change or be removed in future SDK or CLI releases. Pin both the
3634    /// SDK and CLI versions if your code depends on it.
3635    ///
3636    /// </div>
3637    pub async fn list(&self) -> Result<AgentList, Error> {
3638        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3639        let _value = self
3640            .session
3641            .client()
3642            .call(rpc_methods::SESSION_AGENT_LIST, Some(wire_params))
3643            .await?;
3644        Ok(serde_json::from_value(_value)?)
3645    }
3646
3647    /// Lists agents available to the session. Defaults to custom agents only; pass includeBuiltInAgents to include the effective built-in agents.
3648    ///
3649    /// Wire method: `session.agent.list`.
3650    ///
3651    /// # Parameters
3652    ///
3653    /// * `params` - Controls whether built-in agents and authored prompt text are included.
3654    ///
3655    /// # Returns
3656    ///
3657    /// Agents available to the session.
3658    ///
3659    /// <div class="warning">
3660    ///
3661    /// **Experimental.** This API is part of an experimental wire-protocol surface
3662    /// and may change or be removed in future SDK or CLI releases. Pin both the
3663    /// SDK and CLI versions if your code depends on it.
3664    ///
3665    /// </div>
3666    pub async fn list_with_params(&self, params: AgentListRequest) -> Result<AgentList, Error> {
3667        let mut wire_params = serde_json::to_value(params)?;
3668        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3669        let _value = self
3670            .session
3671            .client()
3672            .call(rpc_methods::SESSION_AGENT_LIST, Some(wire_params))
3673            .await?;
3674        Ok(serde_json::from_value(_value)?)
3675    }
3676
3677    /// 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.
3678    ///
3679    /// Wire method: `session.agent.setPrompt`.
3680    ///
3681    /// # Parameters
3682    ///
3683    /// * `params` - An in-memory authored prompt override for an available agent.
3684    ///
3685    /// <div class="warning">
3686    ///
3687    /// **Experimental.** This API is part of an experimental wire-protocol surface
3688    /// and may change or be removed in future SDK or CLI releases. Pin both the
3689    /// SDK and CLI versions if your code depends on it.
3690    ///
3691    /// </div>
3692    pub async fn set_prompt(&self, params: AgentSetPromptRequest) -> Result<(), Error> {
3693        let mut wire_params = serde_json::to_value(params)?;
3694        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3695        let _value = self
3696            .session
3697            .client()
3698            .call(rpc_methods::SESSION_AGENT_SETPROMPT, Some(wire_params))
3699            .await?;
3700        Ok(())
3701    }
3702
3703    /// Gets the currently selected custom agent for the session.
3704    ///
3705    /// Wire method: `session.agent.getCurrent`.
3706    ///
3707    /// # Returns
3708    ///
3709    /// The currently selected custom agent, or null when using the default agent.
3710    ///
3711    /// <div class="warning">
3712    ///
3713    /// **Experimental.** This API is part of an experimental wire-protocol surface
3714    /// and may change or be removed in future SDK or CLI releases. Pin both the
3715    /// SDK and CLI versions if your code depends on it.
3716    ///
3717    /// </div>
3718    pub async fn get_current(&self) -> Result<AgentGetCurrentResult, Error> {
3719        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3720        let _value = self
3721            .session
3722            .client()
3723            .call(rpc_methods::SESSION_AGENT_GETCURRENT, Some(wire_params))
3724            .await?;
3725        Ok(serde_json::from_value(_value)?)
3726    }
3727
3728    /// Selects a custom agent for subsequent turns in the session.
3729    ///
3730    /// Wire method: `session.agent.select`.
3731    ///
3732    /// # Parameters
3733    ///
3734    /// * `params` - Name of the custom agent to select for subsequent turns.
3735    ///
3736    /// # Returns
3737    ///
3738    /// The newly selected custom agent.
3739    ///
3740    /// <div class="warning">
3741    ///
3742    /// **Experimental.** This API is part of an experimental wire-protocol surface
3743    /// and may change or be removed in future SDK or CLI releases. Pin both the
3744    /// SDK and CLI versions if your code depends on it.
3745    ///
3746    /// </div>
3747    pub async fn select(&self, params: AgentSelectRequest) -> Result<AgentSelectResult, Error> {
3748        let mut wire_params = serde_json::to_value(params)?;
3749        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3750        let _value = self
3751            .session
3752            .client()
3753            .call(rpc_methods::SESSION_AGENT_SELECT, Some(wire_params))
3754            .await?;
3755        Ok(serde_json::from_value(_value)?)
3756    }
3757
3758    /// Clears the selected custom agent and returns the session to the default agent.
3759    ///
3760    /// Wire method: `session.agent.deselect`.
3761    ///
3762    /// <div class="warning">
3763    ///
3764    /// **Experimental.** This API is part of an experimental wire-protocol surface
3765    /// and may change or be removed in future SDK or CLI releases. Pin both the
3766    /// SDK and CLI versions if your code depends on it.
3767    ///
3768    /// </div>
3769    pub async fn deselect(&self) -> Result<(), Error> {
3770        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3771        let _value = self
3772            .session
3773            .client()
3774            .call(rpc_methods::SESSION_AGENT_DESELECT, Some(wire_params))
3775            .await?;
3776        Ok(())
3777    }
3778
3779    /// Reloads custom agent definitions and returns the refreshed list.
3780    ///
3781    /// Wire method: `session.agent.reload`.
3782    ///
3783    /// # Returns
3784    ///
3785    /// Custom agents available to the session after reloading definitions from disk.
3786    ///
3787    /// <div class="warning">
3788    ///
3789    /// **Experimental.** This API is part of an experimental wire-protocol surface
3790    /// and may change or be removed in future SDK or CLI releases. Pin both the
3791    /// SDK and CLI versions if your code depends on it.
3792    ///
3793    /// </div>
3794    pub async fn reload(&self) -> Result<AgentReloadResult, Error> {
3795        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3796        let _value = self
3797            .session
3798            .client()
3799            .call(rpc_methods::SESSION_AGENT_RELOAD, Some(wire_params))
3800            .await?;
3801        Ok(serde_json::from_value(_value)?)
3802    }
3803}
3804
3805/// `session.canvas.*` RPCs.
3806#[derive(Clone, Copy)]
3807pub struct SessionRpcCanvas<'a> {
3808    pub(crate) session: &'a Session,
3809}
3810
3811impl<'a> SessionRpcCanvas<'a> {
3812    /// `session.canvas.action.*` sub-namespace.
3813    pub fn action(&self) -> SessionRpcCanvasAction<'a> {
3814        SessionRpcCanvasAction {
3815            session: self.session,
3816        }
3817    }
3818
3819    /// `session.canvas.provider.*` sub-namespace.
3820    pub fn provider(&self) -> SessionRpcCanvasProvider<'a> {
3821        SessionRpcCanvasProvider {
3822            session: self.session,
3823        }
3824    }
3825
3826    /// Lists canvases declared for the session.
3827    ///
3828    /// Wire method: `session.canvas.list`.
3829    ///
3830    /// # Returns
3831    ///
3832    /// Declared canvases available in this session.
3833    ///
3834    /// <div class="warning">
3835    ///
3836    /// **Experimental.** This API is part of an experimental wire-protocol surface
3837    /// and may change or be removed in future SDK or CLI releases. Pin both the
3838    /// SDK and CLI versions if your code depends on it.
3839    ///
3840    /// </div>
3841    pub async fn list(&self) -> Result<CanvasList, Error> {
3842        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3843        let _value = self
3844            .session
3845            .client()
3846            .call(rpc_methods::SESSION_CANVAS_LIST, Some(wire_params))
3847            .await?;
3848        Ok(serde_json::from_value(_value)?)
3849    }
3850
3851    /// Lists currently open canvas instances for the live session.
3852    ///
3853    /// Wire method: `session.canvas.listOpen`.
3854    ///
3855    /// # Returns
3856    ///
3857    /// Live open-canvas snapshot.
3858    ///
3859    /// <div class="warning">
3860    ///
3861    /// **Experimental.** This API is part of an experimental wire-protocol surface
3862    /// and may change or be removed in future SDK or CLI releases. Pin both the
3863    /// SDK and CLI versions if your code depends on it.
3864    ///
3865    /// </div>
3866    pub async fn list_open(&self) -> Result<CanvasListOpenResult, Error> {
3867        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3868        let _value = self
3869            .session
3870            .client()
3871            .call(rpc_methods::SESSION_CANVAS_LISTOPEN, Some(wire_params))
3872            .await?;
3873        Ok(serde_json::from_value(_value)?)
3874    }
3875
3876    /// Opens or focuses a canvas instance.
3877    ///
3878    /// Wire method: `session.canvas.open`.
3879    ///
3880    /// # Parameters
3881    ///
3882    /// * `params` - Canvas open parameters.
3883    ///
3884    /// # Returns
3885    ///
3886    /// Open canvas instance snapshot.
3887    ///
3888    /// <div class="warning">
3889    ///
3890    /// **Experimental.** This API is part of an experimental wire-protocol surface
3891    /// and may change or be removed in future SDK or CLI releases. Pin both the
3892    /// SDK and CLI versions if your code depends on it.
3893    ///
3894    /// </div>
3895    pub async fn open(&self, params: CanvasOpenRequest) -> Result<OpenCanvasInstance, Error> {
3896        let mut wire_params = serde_json::to_value(params)?;
3897        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3898        let _value = self
3899            .session
3900            .client()
3901            .call(rpc_methods::SESSION_CANVAS_OPEN, Some(wire_params))
3902            .await?;
3903        Ok(serde_json::from_value(_value)?)
3904    }
3905
3906    /// Closes an open canvas instance.
3907    ///
3908    /// Wire method: `session.canvas.close`.
3909    ///
3910    /// # Parameters
3911    ///
3912    /// * `params` - Canvas close parameters.
3913    ///
3914    /// <div class="warning">
3915    ///
3916    /// **Experimental.** This API is part of an experimental wire-protocol surface
3917    /// and may change or be removed in future SDK or CLI releases. Pin both the
3918    /// SDK and CLI versions if your code depends on it.
3919    ///
3920    /// </div>
3921    pub async fn close(&self, params: CanvasCloseRequest) -> Result<(), Error> {
3922        let mut wire_params = serde_json::to_value(params)?;
3923        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3924        let _value = self
3925            .session
3926            .client()
3927            .call(rpc_methods::SESSION_CANVAS_CLOSE, Some(wire_params))
3928            .await?;
3929        Ok(())
3930    }
3931}
3932
3933/// `session.canvas.action.*` RPCs.
3934#[derive(Clone, Copy)]
3935pub struct SessionRpcCanvasAction<'a> {
3936    pub(crate) session: &'a Session,
3937}
3938
3939impl<'a> SessionRpcCanvasAction<'a> {
3940    /// Invokes an action on an open canvas instance.
3941    ///
3942    /// Wire method: `session.canvas.action.invoke`.
3943    ///
3944    /// # Parameters
3945    ///
3946    /// * `params` - Canvas action invocation parameters.
3947    ///
3948    /// # Returns
3949    ///
3950    /// Canvas action invocation result.
3951    ///
3952    /// <div class="warning">
3953    ///
3954    /// **Experimental.** This API is part of an experimental wire-protocol surface
3955    /// and may change or be removed in future SDK or CLI releases. Pin both the
3956    /// SDK and CLI versions if your code depends on it.
3957    ///
3958    /// </div>
3959    pub async fn invoke(
3960        &self,
3961        params: CanvasActionInvokeRequest,
3962    ) -> Result<CanvasActionInvokeResult, Error> {
3963        let mut wire_params = serde_json::to_value(params)?;
3964        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3965        let _value = self
3966            .session
3967            .client()
3968            .call(rpc_methods::SESSION_CANVAS_ACTION_INVOKE, Some(wire_params))
3969            .await?;
3970        Ok(serde_json::from_value(_value)?)
3971    }
3972}
3973
3974/// `session.canvas.provider.*` RPCs.
3975#[derive(Clone, Copy)]
3976pub struct SessionRpcCanvasProvider<'a> {
3977    pub(crate) session: &'a Session,
3978}
3979
3980impl<'a> SessionRpcCanvasProvider<'a> {
3981    /// Registers an internal canvas provider connection and its contributions.
3982    ///
3983    /// Wire method: `session.canvas.provider.register`.
3984    ///
3985    /// # Parameters
3986    ///
3987    /// * `params` - Internal canvas provider registration parameters.
3988    ///
3989    /// <div class="warning">
3990    ///
3991    /// **Experimental.** This API is part of an experimental wire-protocol surface
3992    /// and may change or be removed in future SDK or CLI releases. Pin both the
3993    /// SDK and CLI versions if your code depends on it.
3994    ///
3995    /// </div>
3996    pub(crate) async fn register(
3997        &self,
3998        params: CanvasProviderRegisterRequest,
3999    ) -> Result<(), Error> {
4000        let mut wire_params = serde_json::to_value(params)?;
4001        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4002        let _value = self
4003            .session
4004            .client()
4005            .call(
4006                rpc_methods::SESSION_CANVAS_PROVIDER_REGISTER,
4007                Some(wire_params),
4008            )
4009            .await?;
4010        Ok(())
4011    }
4012
4013    /// Unregisters an internal canvas provider connection.
4014    ///
4015    /// Wire method: `session.canvas.provider.unregister`.
4016    ///
4017    /// # Parameters
4018    ///
4019    /// * `params` - Internal canvas provider unregistration parameters.
4020    ///
4021    /// <div class="warning">
4022    ///
4023    /// **Experimental.** This API is part of an experimental wire-protocol surface
4024    /// and may change or be removed in future SDK or CLI releases. Pin both the
4025    /// SDK and CLI versions if your code depends on it.
4026    ///
4027    /// </div>
4028    pub(crate) async fn unregister(
4029        &self,
4030        params: CanvasProviderUnregisterRequest,
4031    ) -> Result<(), Error> {
4032        let mut wire_params = serde_json::to_value(params)?;
4033        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4034        let _value = self
4035            .session
4036            .client()
4037            .call(
4038                rpc_methods::SESSION_CANVAS_PROVIDER_UNREGISTER,
4039                Some(wire_params),
4040            )
4041            .await?;
4042        Ok(())
4043    }
4044}
4045
4046/// `session.commands.*` RPCs.
4047#[derive(Clone, Copy)]
4048pub struct SessionRpcCommands<'a> {
4049    pub(crate) session: &'a Session,
4050}
4051
4052impl<'a> SessionRpcCommands<'a> {
4053    /// Lists slash commands available in the session.
4054    ///
4055    /// Wire method: `session.commands.list`.
4056    ///
4057    /// # Returns
4058    ///
4059    /// Slash commands available in the session, after applying any include/exclude filters.
4060    ///
4061    /// <div class="warning">
4062    ///
4063    /// **Experimental.** This API is part of an experimental wire-protocol surface
4064    /// and may change or be removed in future SDK or CLI releases. Pin both the
4065    /// SDK and CLI versions if your code depends on it.
4066    ///
4067    /// </div>
4068    pub async fn list(&self) -> Result<CommandList, Error> {
4069        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
4070        let _value = self
4071            .session
4072            .client()
4073            .call(rpc_methods::SESSION_COMMANDS_LIST, Some(wire_params))
4074            .await?;
4075        Ok(serde_json::from_value(_value)?)
4076    }
4077
4078    /// Lists slash commands available in the session.
4079    ///
4080    /// Wire method: `session.commands.list`.
4081    ///
4082    /// # Parameters
4083    ///
4084    /// * `params` - Optional filters controlling which command sources to include in the listing.
4085    ///
4086    /// # Returns
4087    ///
4088    /// Slash commands available in the session, after applying any include/exclude filters.
4089    ///
4090    /// <div class="warning">
4091    ///
4092    /// **Experimental.** This API is part of an experimental wire-protocol surface
4093    /// and may change or be removed in future SDK or CLI releases. Pin both the
4094    /// SDK and CLI versions if your code depends on it.
4095    ///
4096    /// </div>
4097    pub async fn list_with_params(
4098        &self,
4099        params: CommandsListRequest,
4100    ) -> Result<CommandList, Error> {
4101        let mut wire_params = serde_json::to_value(params)?;
4102        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4103        let _value = self
4104            .session
4105            .client()
4106            .call(rpc_methods::SESSION_COMMANDS_LIST, Some(wire_params))
4107            .await?;
4108        Ok(serde_json::from_value(_value)?)
4109    }
4110
4111    /// Invokes a slash command in the session.
4112    ///
4113    /// Wire method: `session.commands.invoke`.
4114    ///
4115    /// # Parameters
4116    ///
4117    /// * `params` - Slash command name and optional raw input string to invoke.
4118    ///
4119    /// # Returns
4120    ///
4121    /// Result of invoking the slash command (text output, prompt to send to the agent, completion, or subcommand selection).
4122    ///
4123    /// <div class="warning">
4124    ///
4125    /// **Experimental.** This API is part of an experimental wire-protocol surface
4126    /// and may change or be removed in future SDK or CLI releases. Pin both the
4127    /// SDK and CLI versions if your code depends on it.
4128    ///
4129    /// </div>
4130    pub async fn invoke(
4131        &self,
4132        params: CommandsInvokeRequest,
4133    ) -> Result<SlashCommandInvocationResult, Error> {
4134        let mut wire_params = serde_json::to_value(params)?;
4135        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4136        let _value = self
4137            .session
4138            .client()
4139            .call(rpc_methods::SESSION_COMMANDS_INVOKE, Some(wire_params))
4140            .await?;
4141        Ok(serde_json::from_value(_value)?)
4142    }
4143
4144    /// Finalizes persistence associated with a client-applied slash-command effect.
4145    ///
4146    /// Wire method: `session.commands.finalizeInvocationEffect`.
4147    ///
4148    /// # Parameters
4149    ///
4150    /// * `params` - The pending slash-command invocation effect to finalize, plus whether the host applied or cancelled it.
4151    ///
4152    /// # Returns
4153    ///
4154    /// Whether finalizing the invocation effect succeeded, and the failure reason when it did not.
4155    ///
4156    /// <div class="warning">
4157    ///
4158    /// **Experimental.** This API is part of an experimental wire-protocol surface
4159    /// and may change or be removed in future SDK or CLI releases. Pin both the
4160    /// SDK and CLI versions if your code depends on it.
4161    ///
4162    /// </div>
4163    pub(crate) async fn finalize_invocation_effect(
4164        &self,
4165        params: CommandsFinalizeInvocationEffectRequest,
4166    ) -> Result<CommandsFinalizeInvocationEffectResult, Error> {
4167        let mut wire_params = serde_json::to_value(params)?;
4168        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4169        let _value = self
4170            .session
4171            .client()
4172            .call(
4173                rpc_methods::SESSION_COMMANDS_FINALIZEINVOCATIONEFFECT,
4174                Some(wire_params),
4175            )
4176            .await?;
4177        Ok(serde_json::from_value(_value)?)
4178    }
4179
4180    /// Reports completion of a pending client-handled slash command.
4181    ///
4182    /// Wire method: `session.commands.handlePendingCommand`.
4183    ///
4184    /// # Parameters
4185    ///
4186    /// * `params` - Pending command request ID and an optional error if the client handler failed.
4187    ///
4188    /// # Returns
4189    ///
4190    /// Indicates whether the pending client-handled command was completed successfully.
4191    ///
4192    /// <div class="warning">
4193    ///
4194    /// **Experimental.** This API is part of an experimental wire-protocol surface
4195    /// and may change or be removed in future SDK or CLI releases. Pin both the
4196    /// SDK and CLI versions if your code depends on it.
4197    ///
4198    /// </div>
4199    pub async fn handle_pending_command(
4200        &self,
4201        params: CommandsHandlePendingCommandRequest,
4202    ) -> Result<CommandsHandlePendingCommandResult, Error> {
4203        let mut wire_params = serde_json::to_value(params)?;
4204        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4205        let _value = self
4206            .session
4207            .client()
4208            .call(
4209                rpc_methods::SESSION_COMMANDS_HANDLEPENDINGCOMMAND,
4210                Some(wire_params),
4211            )
4212            .await?;
4213        Ok(serde_json::from_value(_value)?)
4214    }
4215
4216    /// Executes a slash command synchronously and returns any error.
4217    ///
4218    /// Wire method: `session.commands.execute`.
4219    ///
4220    /// # Parameters
4221    ///
4222    /// * `params` - Slash command name and argument string to execute synchronously.
4223    ///
4224    /// # Returns
4225    ///
4226    /// Error message produced while executing the command, if any.
4227    ///
4228    /// <div class="warning">
4229    ///
4230    /// **Experimental.** This API is part of an experimental wire-protocol surface
4231    /// and may change or be removed in future SDK or CLI releases. Pin both the
4232    /// SDK and CLI versions if your code depends on it.
4233    ///
4234    /// </div>
4235    pub async fn execute(
4236        &self,
4237        params: ExecuteCommandParams,
4238    ) -> Result<ExecuteCommandResult, Error> {
4239        let mut wire_params = serde_json::to_value(params)?;
4240        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4241        let _value = self
4242            .session
4243            .client()
4244            .call(rpc_methods::SESSION_COMMANDS_EXECUTE, Some(wire_params))
4245            .await?;
4246        Ok(serde_json::from_value(_value)?)
4247    }
4248
4249    /// Enqueues a slash command for FIFO processing on the local session.
4250    ///
4251    /// Wire method: `session.commands.enqueue`.
4252    ///
4253    /// # Parameters
4254    ///
4255    /// * `params` - Slash-prefixed command string to enqueue for FIFO processing.
4256    ///
4257    /// # Returns
4258    ///
4259    /// Indicates whether the command was accepted into the local execution queue.
4260    ///
4261    /// <div class="warning">
4262    ///
4263    /// **Experimental.** This API is part of an experimental wire-protocol surface
4264    /// and may change or be removed in future SDK or CLI releases. Pin both the
4265    /// SDK and CLI versions if your code depends on it.
4266    ///
4267    /// </div>
4268    pub async fn enqueue(
4269        &self,
4270        params: EnqueueCommandParams,
4271    ) -> Result<EnqueueCommandResult, Error> {
4272        let mut wire_params = serde_json::to_value(params)?;
4273        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4274        let _value = self
4275            .session
4276            .client()
4277            .call(rpc_methods::SESSION_COMMANDS_ENQUEUE, Some(wire_params))
4278            .await?;
4279        Ok(serde_json::from_value(_value)?)
4280    }
4281
4282    /// Reports whether the host actually executed a queued command and whether to continue processing.
4283    ///
4284    /// Wire method: `session.commands.respondToQueuedCommand`.
4285    ///
4286    /// # Parameters
4287    ///
4288    /// * `params` - Queued-command request ID and the result indicating whether the host executed it (and whether to stop processing further queued commands).
4289    ///
4290    /// # Returns
4291    ///
4292    /// Indicates whether the queued-command response was matched to a pending request.
4293    ///
4294    /// <div class="warning">
4295    ///
4296    /// **Experimental.** This API is part of an experimental wire-protocol surface
4297    /// and may change or be removed in future SDK or CLI releases. Pin both the
4298    /// SDK and CLI versions if your code depends on it.
4299    ///
4300    /// </div>
4301    pub async fn respond_to_queued_command(
4302        &self,
4303        params: CommandsRespondToQueuedCommandRequest,
4304    ) -> Result<CommandsRespondToQueuedCommandResult, Error> {
4305        let mut wire_params = serde_json::to_value(params)?;
4306        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4307        let _value = self
4308            .session
4309            .client()
4310            .call(
4311                rpc_methods::SESSION_COMMANDS_RESPONDTOQUEUEDCOMMAND,
4312                Some(wire_params),
4313            )
4314            .await?;
4315        Ok(serde_json::from_value(_value)?)
4316    }
4317}
4318
4319/// `session.completions.*` RPCs.
4320#[derive(Clone, Copy)]
4321pub struct SessionRpcCompletions<'a> {
4322    pub(crate) session: &'a Session,
4323}
4324
4325impl<'a> SessionRpcCompletions<'a> {
4326    /// 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).
4327    ///
4328    /// Wire method: `session.completions.getTriggerCharacters`.
4329    ///
4330    /// # Returns
4331    ///
4332    /// 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`).
4333    ///
4334    /// <div class="warning">
4335    ///
4336    /// **Experimental.** This API is part of an experimental wire-protocol surface
4337    /// and may change or be removed in future SDK or CLI releases. Pin both the
4338    /// SDK and CLI versions if your code depends on it.
4339    ///
4340    /// </div>
4341    pub async fn get_trigger_characters(
4342        &self,
4343    ) -> Result<CompletionsGetTriggerCharactersResult, Error> {
4344        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
4345        let _value = self
4346            .session
4347            .client()
4348            .call(
4349                rpc_methods::SESSION_COMPLETIONS_GETTRIGGERCHARACTERS,
4350                Some(wire_params),
4351            )
4352            .await?;
4353        Ok(serde_json::from_value(_value)?)
4354    }
4355
4356    /// 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.
4357    ///
4358    /// Wire method: `session.completions.request`.
4359    ///
4360    /// # Parameters
4361    ///
4362    /// * `params` - Request host-driven completions for the current composer input.
4363    ///
4364    /// # Returns
4365    ///
4366    /// Host-driven completion items for the current composer input. Empty when the host returns no items or does not support completions.
4367    ///
4368    /// <div class="warning">
4369    ///
4370    /// **Experimental.** This API is part of an experimental wire-protocol surface
4371    /// and may change or be removed in future SDK or CLI releases. Pin both the
4372    /// SDK and CLI versions if your code depends on it.
4373    ///
4374    /// </div>
4375    pub async fn request(
4376        &self,
4377        params: CompletionsRequestRequest,
4378    ) -> Result<CompletionsRequestResult, Error> {
4379        let mut wire_params = serde_json::to_value(params)?;
4380        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4381        let _value = self
4382            .session
4383            .client()
4384            .call(rpc_methods::SESSION_COMPLETIONS_REQUEST, Some(wire_params))
4385            .await?;
4386        Ok(serde_json::from_value(_value)?)
4387    }
4388}
4389
4390/// `session.contentExclusion.*` RPCs.
4391#[derive(Clone, Copy)]
4392pub struct SessionRpcContentExclusion<'a> {
4393    pub(crate) session: &'a Session,
4394}
4395
4396impl<'a> SessionRpcContentExclusion<'a> {
4397    /// 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.
4398    ///
4399    /// Wire method: `session.contentExclusion.checkPaths`.
4400    ///
4401    /// # Parameters
4402    ///
4403    /// * `params` - Local file system absolute paths within the session working directory to check against its content-exclusion policy.
4404    ///
4405    /// # Returns
4406    ///
4407    /// Batch content-exclusion result. Callers must fail closed when policy evaluation is unavailable.
4408    ///
4409    /// <div class="warning">
4410    ///
4411    /// **Experimental.** This API is part of an experimental wire-protocol surface
4412    /// and may change or be removed in future SDK or CLI releases. Pin both the
4413    /// SDK and CLI versions if your code depends on it.
4414    ///
4415    /// </div>
4416    pub async fn check_paths(
4417        &self,
4418        params: ContentExclusionCheckPathsRequest,
4419    ) -> Result<ContentExclusionCheckPathsResult, Error> {
4420        let mut wire_params = serde_json::to_value(params)?;
4421        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4422        let _value = self
4423            .session
4424            .client()
4425            .call(
4426                rpc_methods::SESSION_CONTENTEXCLUSION_CHECKPATHS,
4427                Some(wire_params),
4428            )
4429            .await?;
4430        Ok(serde_json::from_value(_value)?)
4431    }
4432}
4433
4434/// `session.debug.*` RPCs.
4435#[derive(Clone, Copy)]
4436pub struct SessionRpcDebug<'a> {
4437    pub(crate) session: &'a Session,
4438}
4439
4440impl<'a> SessionRpcDebug<'a> {
4441    /// 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.
4442    ///
4443    /// Wire method: `session.debug.collectLogs`.
4444    ///
4445    /// # Parameters
4446    ///
4447    /// * `params` - Options for collecting a redacted session debug bundle.
4448    ///
4449    /// # Returns
4450    ///
4451    /// Result of collecting a redacted debug bundle.
4452    ///
4453    /// <div class="warning">
4454    ///
4455    /// **Experimental.** This API is part of an experimental wire-protocol surface
4456    /// and may change or be removed in future SDK or CLI releases. Pin both the
4457    /// SDK and CLI versions if your code depends on it.
4458    ///
4459    /// </div>
4460    pub async fn collect_logs(
4461        &self,
4462        params: DebugCollectLogsRequest,
4463    ) -> Result<DebugCollectLogsResult, Error> {
4464        let mut wire_params = serde_json::to_value(params)?;
4465        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4466        let _value = self
4467            .session
4468            .client()
4469            .call(rpc_methods::SESSION_DEBUG_COLLECTLOGS, Some(wire_params))
4470            .await?;
4471        Ok(serde_json::from_value(_value)?)
4472    }
4473}
4474
4475/// `session.eventLog.*` RPCs.
4476#[derive(Clone, Copy)]
4477pub struct SessionRpcEventLog<'a> {
4478    pub(crate) session: &'a Session,
4479}
4480
4481impl<'a> SessionRpcEventLog<'a> {
4482    /// Reads a batch of session events from a cursor, optionally waiting for new events. Supports tail-first reads via `direction: backward`.
4483    ///
4484    /// Wire method: `session.eventLog.read`.
4485    ///
4486    /// # Parameters
4487    ///
4488    /// * `params` - Cursor, batch size, and optional long-poll/filter parameters for reading session events.
4489    ///
4490    /// # Returns
4491    ///
4492    /// Batch of session events returned by a read, with cursor and continuation metadata.
4493    ///
4494    /// <div class="warning">
4495    ///
4496    /// **Experimental.** This API is part of an experimental wire-protocol surface
4497    /// and may change or be removed in future SDK or CLI releases. Pin both the
4498    /// SDK and CLI versions if your code depends on it.
4499    ///
4500    /// </div>
4501    pub async fn read(&self, params: EventLogReadRequest) -> Result<EventsReadResult, Error> {
4502        let mut wire_params = serde_json::to_value(params)?;
4503        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4504        let _value = self
4505            .session
4506            .client()
4507            .call(rpc_methods::SESSION_EVENTLOG_READ, Some(wire_params))
4508            .await?;
4509        Ok(serde_json::from_value(_value)?)
4510    }
4511
4512    /// Returns a snapshot of the current tail cursor without consuming events.
4513    ///
4514    /// Wire method: `session.eventLog.tail`.
4515    ///
4516    /// # Returns
4517    ///
4518    /// 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).
4519    ///
4520    /// <div class="warning">
4521    ///
4522    /// **Experimental.** This API is part of an experimental wire-protocol surface
4523    /// and may change or be removed in future SDK or CLI releases. Pin both the
4524    /// SDK and CLI versions if your code depends on it.
4525    ///
4526    /// </div>
4527    pub async fn tail(&self) -> Result<EventLogTailResult, Error> {
4528        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
4529        let _value = self
4530            .session
4531            .client()
4532            .call(rpc_methods::SESSION_EVENTLOG_TAIL, Some(wire_params))
4533            .await?;
4534        Ok(serde_json::from_value(_value)?)
4535    }
4536
4537    /// Registers consumer interest in an event type for runtime gating purposes.
4538    ///
4539    /// Wire method: `session.eventLog.registerInterest`.
4540    ///
4541    /// # Parameters
4542    ///
4543    /// * `params` - Event type to register consumer interest for, used by runtime gating logic.
4544    ///
4545    /// # Returns
4546    ///
4547    /// Opaque handle representing an event-type interest registration.
4548    ///
4549    /// <div class="warning">
4550    ///
4551    /// **Experimental.** This API is part of an experimental wire-protocol surface
4552    /// and may change or be removed in future SDK or CLI releases. Pin both the
4553    /// SDK and CLI versions if your code depends on it.
4554    ///
4555    /// </div>
4556    pub async fn register_interest(
4557        &self,
4558        params: RegisterEventInterestParams,
4559    ) -> Result<RegisterEventInterestResult, Error> {
4560        let mut wire_params = serde_json::to_value(params)?;
4561        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4562        let _value = self
4563            .session
4564            .client()
4565            .call(
4566                rpc_methods::SESSION_EVENTLOG_REGISTERINTEREST,
4567                Some(wire_params),
4568            )
4569            .await?;
4570        Ok(serde_json::from_value(_value)?)
4571    }
4572
4573    /// Releases a consumer's previously-registered interest in an event type.
4574    ///
4575    /// Wire method: `session.eventLog.releaseInterest`.
4576    ///
4577    /// # Parameters
4578    ///
4579    /// * `params` - Opaque handle previously returned by `registerInterest` to release.
4580    ///
4581    /// # Returns
4582    ///
4583    /// Indicates whether the operation succeeded.
4584    ///
4585    /// <div class="warning">
4586    ///
4587    /// **Experimental.** This API is part of an experimental wire-protocol surface
4588    /// and may change or be removed in future SDK or CLI releases. Pin both the
4589    /// SDK and CLI versions if your code depends on it.
4590    ///
4591    /// </div>
4592    pub async fn release_interest(
4593        &self,
4594        params: ReleaseEventInterestParams,
4595    ) -> Result<EventLogReleaseInterestResult, Error> {
4596        let mut wire_params = serde_json::to_value(params)?;
4597        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4598        let _value = self
4599            .session
4600            .client()
4601            .call(
4602                rpc_methods::SESSION_EVENTLOG_RELEASEINTEREST,
4603                Some(wire_params),
4604            )
4605            .await?;
4606        Ok(serde_json::from_value(_value)?)
4607    }
4608}
4609
4610/// `session.extensions.*` RPCs.
4611#[derive(Clone, Copy)]
4612pub struct SessionRpcExtensions<'a> {
4613    pub(crate) session: &'a Session,
4614}
4615
4616impl<'a> SessionRpcExtensions<'a> {
4617    /// Lists extensions discovered for the session and their current status.
4618    ///
4619    /// Wire method: `session.extensions.list`.
4620    ///
4621    /// # Returns
4622    ///
4623    /// Extensions discovered for the session, with their current status.
4624    ///
4625    /// <div class="warning">
4626    ///
4627    /// **Experimental.** This API is part of an experimental wire-protocol surface
4628    /// and may change or be removed in future SDK or CLI releases. Pin both the
4629    /// SDK and CLI versions if your code depends on it.
4630    ///
4631    /// </div>
4632    pub async fn list(&self) -> Result<ExtensionList, Error> {
4633        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
4634        let _value = self
4635            .session
4636            .client()
4637            .call(rpc_methods::SESSION_EXTENSIONS_LIST, Some(wire_params))
4638            .await?;
4639        Ok(serde_json::from_value(_value)?)
4640    }
4641
4642    /// Enables an extension for the session.
4643    ///
4644    /// Wire method: `session.extensions.enable`.
4645    ///
4646    /// # Parameters
4647    ///
4648    /// * `params` - Source-qualified extension identifier to enable for the session.
4649    ///
4650    /// <div class="warning">
4651    ///
4652    /// **Experimental.** This API is part of an experimental wire-protocol surface
4653    /// and may change or be removed in future SDK or CLI releases. Pin both the
4654    /// SDK and CLI versions if your code depends on it.
4655    ///
4656    /// </div>
4657    pub async fn enable(&self, params: ExtensionsEnableRequest) -> Result<(), Error> {
4658        let mut wire_params = serde_json::to_value(params)?;
4659        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4660        let _value = self
4661            .session
4662            .client()
4663            .call(rpc_methods::SESSION_EXTENSIONS_ENABLE, Some(wire_params))
4664            .await?;
4665        Ok(())
4666    }
4667
4668    /// Disables an extension for the session.
4669    ///
4670    /// Wire method: `session.extensions.disable`.
4671    ///
4672    /// # Parameters
4673    ///
4674    /// * `params` - Source-qualified extension identifier to disable for the session.
4675    ///
4676    /// <div class="warning">
4677    ///
4678    /// **Experimental.** This API is part of an experimental wire-protocol surface
4679    /// and may change or be removed in future SDK or CLI releases. Pin both the
4680    /// SDK and CLI versions if your code depends on it.
4681    ///
4682    /// </div>
4683    pub async fn disable(&self, params: ExtensionsDisableRequest) -> Result<(), Error> {
4684        let mut wire_params = serde_json::to_value(params)?;
4685        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4686        let _value = self
4687            .session
4688            .client()
4689            .call(rpc_methods::SESSION_EXTENSIONS_DISABLE, Some(wire_params))
4690            .await?;
4691        Ok(())
4692    }
4693
4694    /// Reloads extension definitions and processes for the session.
4695    ///
4696    /// Wire method: `session.extensions.reload`.
4697    ///
4698    /// <div class="warning">
4699    ///
4700    /// **Experimental.** This API is part of an experimental wire-protocol surface
4701    /// and may change or be removed in future SDK or CLI releases. Pin both the
4702    /// SDK and CLI versions if your code depends on it.
4703    ///
4704    /// </div>
4705    pub async fn reload(&self) -> Result<(), Error> {
4706        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
4707        let _value = self
4708            .session
4709            .client()
4710            .call(rpc_methods::SESSION_EXTENSIONS_RELOAD, Some(wire_params))
4711            .await?;
4712        Ok(())
4713    }
4714
4715    /// 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.
4716    ///
4717    /// Wire method: `session.extensions.sendAttachmentsToMessage`.
4718    ///
4719    /// # Parameters
4720    ///
4721    /// * `params` - Parameters for session.extensions.sendAttachmentsToMessage.
4722    ///
4723    /// <div class="warning">
4724    ///
4725    /// **Experimental.** This API is part of an experimental wire-protocol surface
4726    /// and may change or be removed in future SDK or CLI releases. Pin both the
4727    /// SDK and CLI versions if your code depends on it.
4728    ///
4729    /// </div>
4730    pub async fn send_attachments_to_message(
4731        &self,
4732        params: SendAttachmentsToMessageParams,
4733    ) -> Result<(), Error> {
4734        let mut wire_params = serde_json::to_value(params)?;
4735        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4736        let _value = self
4737            .session
4738            .client()
4739            .call(
4740                rpc_methods::SESSION_EXTENSIONS_SENDATTACHMENTSTOMESSAGE,
4741                Some(wire_params),
4742            )
4743            .await?;
4744        Ok(())
4745    }
4746}
4747
4748/// `session.factory.*` RPCs.
4749#[derive(Clone, Copy)]
4750pub struct SessionRpcFactory<'a> {
4751    pub(crate) session: &'a Session,
4752}
4753
4754impl<'a> SessionRpcFactory<'a> {
4755    /// `session.factory.journal.*` sub-namespace.
4756    pub fn journal(&self) -> SessionRpcFactoryJournal<'a> {
4757        SessionRpcFactoryJournal {
4758            session: self.session,
4759        }
4760    }
4761
4762    /// Runs a registered factory by name at the top level.
4763    ///
4764    /// Wire method: `session.factory.run`.
4765    ///
4766    /// # Parameters
4767    ///
4768    /// * `params` - Parameters for invoking a registered factory.
4769    ///
4770    /// # Returns
4771    ///
4772    /// Complete current or terminal factory run envelope.
4773    ///
4774    /// <div class="warning">
4775    ///
4776    /// **Experimental.** This API is part of an experimental wire-protocol surface
4777    /// and may change or be removed in future SDK or CLI releases. Pin both the
4778    /// SDK and CLI versions if your code depends on it.
4779    ///
4780    /// </div>
4781    pub async fn run(&self, params: FactoryRunRequest) -> Result<FactoryRunResult, Error> {
4782        let mut wire_params = serde_json::to_value(params)?;
4783        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4784        let _value = self
4785            .session
4786            .client()
4787            .call(rpc_methods::SESSION_FACTORY_RUN, Some(wire_params))
4788            .await?;
4789        Ok(serde_json::from_value(_value)?)
4790    }
4791
4792    /// Resumes a factory run using its persisted name, arguments, journal, and accounting.
4793    ///
4794    /// Wire method: `session.factory.resume`.
4795    ///
4796    /// # Parameters
4797    ///
4798    /// * `params` - Parameters for resuming a factory run from its persisted identity.
4799    ///
4800    /// # Returns
4801    ///
4802    /// Resolved persisted factory identity and resumed run envelope.
4803    ///
4804    /// <div class="warning">
4805    ///
4806    /// **Experimental.** This API is part of an experimental wire-protocol surface
4807    /// and may change or be removed in future SDK or CLI releases. Pin both the
4808    /// SDK and CLI versions if your code depends on it.
4809    ///
4810    /// </div>
4811    pub async fn resume(&self, params: FactoryResumeRequest) -> Result<FactoryResumeResult, Error> {
4812        let mut wire_params = serde_json::to_value(params)?;
4813        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4814        let _value = self
4815            .session
4816            .client()
4817            .call(rpc_methods::SESSION_FACTORY_RESUME, Some(wire_params))
4818            .await?;
4819        Ok(serde_json::from_value(_value)?)
4820    }
4821
4822    /// Internal tool-originated factory invocation.
4823    ///
4824    /// Wire method: `session.factory.runFromTool`.
4825    ///
4826    /// # Parameters
4827    ///
4828    /// * `params` - Internal parameters for invoking a registered factory from a tool.
4829    ///
4830    /// # Returns
4831    ///
4832    /// Complete current or terminal factory run envelope.
4833    ///
4834    /// <div class="warning">
4835    ///
4836    /// **Experimental.** This API is part of an experimental wire-protocol surface
4837    /// and may change or be removed in future SDK or CLI releases. Pin both the
4838    /// SDK and CLI versions if your code depends on it.
4839    ///
4840    /// </div>
4841    pub(crate) async fn run_from_tool(
4842        &self,
4843        params: FactoryToolRunRequest,
4844    ) -> Result<FactoryRunResult, Error> {
4845        let mut wire_params = serde_json::to_value(params)?;
4846        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4847        let _value = self
4848            .session
4849            .client()
4850            .call(rpc_methods::SESSION_FACTORY_RUNFROMTOOL, Some(wire_params))
4851            .await?;
4852        Ok(serde_json::from_value(_value)?)
4853    }
4854
4855    /// Internal tool-originated factory resume.
4856    ///
4857    /// Wire method: `session.factory.resumeFromTool`.
4858    ///
4859    /// # Parameters
4860    ///
4861    /// * `params` - Internal parameters for resuming a factory run from a tool.
4862    ///
4863    /// # Returns
4864    ///
4865    /// Resolved persisted factory identity and resumed run envelope.
4866    ///
4867    /// <div class="warning">
4868    ///
4869    /// **Experimental.** This API is part of an experimental wire-protocol surface
4870    /// and may change or be removed in future SDK or CLI releases. Pin both the
4871    /// SDK and CLI versions if your code depends on it.
4872    ///
4873    /// </div>
4874    pub(crate) async fn resume_from_tool(
4875        &self,
4876        params: FactoryToolResumeRequest,
4877    ) -> Result<FactoryResumeResult, Error> {
4878        let mut wire_params = serde_json::to_value(params)?;
4879        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4880        let _value = self
4881            .session
4882            .client()
4883            .call(
4884                rpc_methods::SESSION_FACTORY_RESUMEFROMTOOL,
4885                Some(wire_params),
4886            )
4887            .await?;
4888        Ok(serde_json::from_value(_value)?)
4889    }
4890
4891    /// Gets the current or settled envelope for a factory run.
4892    ///
4893    /// Wire method: `session.factory.getRun`.
4894    ///
4895    /// # Parameters
4896    ///
4897    /// * `params` - Parameters for retrieving a factory run.
4898    ///
4899    /// # Returns
4900    ///
4901    /// Complete current or terminal factory run envelope.
4902    ///
4903    /// <div class="warning">
4904    ///
4905    /// **Experimental.** This API is part of an experimental wire-protocol surface
4906    /// and may change or be removed in future SDK or CLI releases. Pin both the
4907    /// SDK and CLI versions if your code depends on it.
4908    ///
4909    /// </div>
4910    pub async fn get_run(&self, params: FactoryGetRunRequest) -> Result<FactoryRunResult, Error> {
4911        let mut wire_params = serde_json::to_value(params)?;
4912        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4913        let _value = self
4914            .session
4915            .client()
4916            .call(rpc_methods::SESSION_FACTORY_GETRUN, Some(wire_params))
4917            .await?;
4918        Ok(serde_json::from_value(_value)?)
4919    }
4920
4921    /// Lists durable factory runs for this session in creation order.
4922    ///
4923    /// Wire method: `session.factory.listRuns`.
4924    ///
4925    /// # Parameters
4926    ///
4927    /// * `params` - Parameters for paging factory runs.
4928    ///
4929    /// # Returns
4930    ///
4931    /// A page of factory runs in durable creation order.
4932    ///
4933    /// <div class="warning">
4934    ///
4935    /// **Experimental.** This API is part of an experimental wire-protocol surface
4936    /// and may change or be removed in future SDK or CLI releases. Pin both the
4937    /// SDK and CLI versions if your code depends on it.
4938    ///
4939    /// </div>
4940    pub async fn list_runs(
4941        &self,
4942        params: FactoryListRunsRequest,
4943    ) -> Result<FactoryListRunsResult, Error> {
4944        let mut wire_params = serde_json::to_value(params)?;
4945        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4946        let _value = self
4947            .session
4948            .client()
4949            .call(rpc_methods::SESSION_FACTORY_LISTRUNS, Some(wire_params))
4950            .await?;
4951        Ok(serde_json::from_value(_value)?)
4952    }
4953
4954    /// Gets durable and live observability detail for one factory run.
4955    ///
4956    /// Wire method: `session.factory.getRunDetail`.
4957    ///
4958    /// # Parameters
4959    ///
4960    /// * `params` - Parameters for retrieving a factory run.
4961    ///
4962    /// # Returns
4963    ///
4964    /// Full factory run observability detail.
4965    ///
4966    /// <div class="warning">
4967    ///
4968    /// **Experimental.** This API is part of an experimental wire-protocol surface
4969    /// and may change or be removed in future SDK or CLI releases. Pin both the
4970    /// SDK and CLI versions if your code depends on it.
4971    ///
4972    /// </div>
4973    pub async fn get_run_detail(
4974        &self,
4975        params: FactoryGetRunRequest,
4976    ) -> Result<FactoryRunDetail, Error> {
4977        let mut wire_params = serde_json::to_value(params)?;
4978        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4979        let _value = self
4980            .session
4981            .client()
4982            .call(rpc_methods::SESSION_FACTORY_GETRUNDETAIL, Some(wire_params))
4983            .await?;
4984        Ok(serde_json::from_value(_value)?)
4985    }
4986
4987    /// Pages durable progress for one factory run.
4988    ///
4989    /// Wire method: `session.factory.getRunProgress`.
4990    ///
4991    /// # Parameters
4992    ///
4993    /// * `params` - Parameters for paging factory progress.
4994    ///
4995    /// # Returns
4996    ///
4997    /// A bidirectional page of factory progress.
4998    ///
4999    /// <div class="warning">
5000    ///
5001    /// **Experimental.** This API is part of an experimental wire-protocol surface
5002    /// and may change or be removed in future SDK or CLI releases. Pin both the
5003    /// SDK and CLI versions if your code depends on it.
5004    ///
5005    /// </div>
5006    pub async fn get_run_progress(
5007        &self,
5008        params: FactoryGetRunProgressRequest,
5009    ) -> Result<FactoryProgressPage, Error> {
5010        let mut wire_params = serde_json::to_value(params)?;
5011        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5012        let _value = self
5013            .session
5014            .client()
5015            .call(
5016                rpc_methods::SESSION_FACTORY_GETRUNPROGRESS,
5017                Some(wire_params),
5018            )
5019            .await?;
5020        Ok(serde_json::from_value(_value)?)
5021    }
5022
5023    /// Requests cancellation of a factory run and returns its run envelope.
5024    ///
5025    /// Wire method: `session.factory.cancel`.
5026    ///
5027    /// # Parameters
5028    ///
5029    /// * `params` - Parameters for cancelling a factory run.
5030    ///
5031    /// # Returns
5032    ///
5033    /// Complete current or terminal factory run envelope.
5034    ///
5035    /// <div class="warning">
5036    ///
5037    /// **Experimental.** This API is part of an experimental wire-protocol surface
5038    /// and may change or be removed in future SDK or CLI releases. Pin both the
5039    /// SDK and CLI versions if your code depends on it.
5040    ///
5041    /// </div>
5042    pub async fn cancel(&self, params: FactoryCancelRequest) -> Result<FactoryRunResult, Error> {
5043        let mut wire_params = serde_json::to_value(params)?;
5044        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5045        let _value = self
5046            .session
5047            .client()
5048            .call(rpc_methods::SESSION_FACTORY_CANCEL, Some(wire_params))
5049            .await?;
5050        Ok(serde_json::from_value(_value)?)
5051    }
5052
5053    /// Records a batch of ordered factory progress lines.
5054    ///
5055    /// Wire method: `session.factory.log`.
5056    ///
5057    /// # Parameters
5058    ///
5059    /// * `params` - Parameters for recording factory progress.
5060    ///
5061    /// # Returns
5062    ///
5063    /// Acknowledgement that a factory request was accepted.
5064    ///
5065    /// <div class="warning">
5066    ///
5067    /// **Experimental.** This API is part of an experimental wire-protocol surface
5068    /// and may change or be removed in future SDK or CLI releases. Pin both the
5069    /// SDK and CLI versions if your code depends on it.
5070    ///
5071    /// </div>
5072    pub async fn log(&self, params: FactoryLogRequest) -> Result<FactoryAckResult, Error> {
5073        let mut wire_params = serde_json::to_value(params)?;
5074        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5075        let _value = self
5076            .session
5077            .client()
5078            .call(rpc_methods::SESSION_FACTORY_LOG, Some(wire_params))
5079            .await?;
5080        Ok(serde_json::from_value(_value)?)
5081    }
5082
5083    /// Runs one factory-scoped subagent and returns its result.
5084    ///
5085    /// Wire method: `session.factory.agent`.
5086    ///
5087    /// # Parameters
5088    ///
5089    /// * `params` - Parameters for one factory-scoped subagent call.
5090    ///
5091    /// # Returns
5092    ///
5093    /// Result of one factory-scoped subagent call.
5094    ///
5095    /// <div class="warning">
5096    ///
5097    /// **Experimental.** This API is part of an experimental wire-protocol surface
5098    /// and may change or be removed in future SDK or CLI releases. Pin both the
5099    /// SDK and CLI versions if your code depends on it.
5100    ///
5101    /// </div>
5102    pub async fn agent(&self, params: FactoryAgentRequest) -> Result<FactoryAgentResult, Error> {
5103        let mut wire_params = serde_json::to_value(params)?;
5104        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5105        let _value = self
5106            .session
5107            .client()
5108            .call(rpc_methods::SESSION_FACTORY_AGENT, Some(wire_params))
5109            .await?;
5110        Ok(serde_json::from_value(_value)?)
5111    }
5112}
5113
5114/// `session.factory.journal.*` RPCs.
5115#[derive(Clone, Copy)]
5116pub struct SessionRpcFactoryJournal<'a> {
5117    pub(crate) session: &'a Session,
5118}
5119
5120impl<'a> SessionRpcFactoryJournal<'a> {
5121    /// Reads a memoized factory journal entry.
5122    ///
5123    /// Wire method: `session.factory.journal.get`.
5124    ///
5125    /// # Parameters
5126    ///
5127    /// * `params` - Parameters for reading a factory journal entry.
5128    ///
5129    /// # Returns
5130    ///
5131    /// Result of reading a factory journal entry.
5132    ///
5133    /// <div class="warning">
5134    ///
5135    /// **Experimental.** This API is part of an experimental wire-protocol surface
5136    /// and may change or be removed in future SDK or CLI releases. Pin both the
5137    /// SDK and CLI versions if your code depends on it.
5138    ///
5139    /// </div>
5140    pub async fn get(
5141        &self,
5142        params: FactoryJournalGetRequest,
5143    ) -> Result<FactoryJournalGetResult, Error> {
5144        let mut wire_params = serde_json::to_value(params)?;
5145        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5146        let _value = self
5147            .session
5148            .client()
5149            .call(rpc_methods::SESSION_FACTORY_JOURNAL_GET, Some(wire_params))
5150            .await?;
5151        Ok(serde_json::from_value(_value)?)
5152    }
5153
5154    /// Stores a memoized factory journal entry.
5155    ///
5156    /// Wire method: `session.factory.journal.put`.
5157    ///
5158    /// # Parameters
5159    ///
5160    /// * `params` - Parameters for storing a factory journal entry.
5161    ///
5162    /// # Returns
5163    ///
5164    /// Acknowledgement that a factory request was accepted.
5165    ///
5166    /// <div class="warning">
5167    ///
5168    /// **Experimental.** This API is part of an experimental wire-protocol surface
5169    /// and may change or be removed in future SDK or CLI releases. Pin both the
5170    /// SDK and CLI versions if your code depends on it.
5171    ///
5172    /// </div>
5173    pub async fn put(&self, params: FactoryJournalPutRequest) -> Result<FactoryAckResult, Error> {
5174        let mut wire_params = serde_json::to_value(params)?;
5175        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5176        let _value = self
5177            .session
5178            .client()
5179            .call(rpc_methods::SESSION_FACTORY_JOURNAL_PUT, Some(wire_params))
5180            .await?;
5181        Ok(serde_json::from_value(_value)?)
5182    }
5183}
5184
5185/// `session.fleet.*` RPCs.
5186#[derive(Clone, Copy)]
5187pub struct SessionRpcFleet<'a> {
5188    pub(crate) session: &'a Session,
5189}
5190
5191impl<'a> SessionRpcFleet<'a> {
5192    /// Starts fleet mode by submitting the fleet orchestration prompt to the session.
5193    ///
5194    /// Wire method: `session.fleet.start`.
5195    ///
5196    /// # Parameters
5197    ///
5198    /// * `params` - Optional user prompt to combine with the fleet orchestration instructions.
5199    ///
5200    /// # Returns
5201    ///
5202    /// Indicates whether fleet mode was successfully activated.
5203    ///
5204    /// <div class="warning">
5205    ///
5206    /// **Experimental.** This API is part of an experimental wire-protocol surface
5207    /// and may change or be removed in future SDK or CLI releases. Pin both the
5208    /// SDK and CLI versions if your code depends on it.
5209    ///
5210    /// </div>
5211    pub async fn start(&self, params: FleetStartRequest) -> Result<FleetStartResult, Error> {
5212        let mut wire_params = serde_json::to_value(params)?;
5213        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5214        let _value = self
5215            .session
5216            .client()
5217            .call(rpc_methods::SESSION_FLEET_START, Some(wire_params))
5218            .await?;
5219        Ok(serde_json::from_value(_value)?)
5220    }
5221}
5222
5223/// `session.gitHubAuth.*` RPCs.
5224#[derive(Clone, Copy)]
5225pub struct SessionRpcGitHubAuth<'a> {
5226    pub(crate) session: &'a Session,
5227}
5228
5229impl<'a> SessionRpcGitHubAuth<'a> {
5230    /// Gets authentication status and account metadata for the session.
5231    ///
5232    /// Wire method: `session.gitHubAuth.getStatus`.
5233    ///
5234    /// # Returns
5235    ///
5236    /// Authentication status and account metadata for the session.
5237    ///
5238    /// <div class="warning">
5239    ///
5240    /// **Experimental.** This API is part of an experimental wire-protocol surface
5241    /// and may change or be removed in future SDK or CLI releases. Pin both the
5242    /// SDK and CLI versions if your code depends on it.
5243    ///
5244    /// </div>
5245    pub async fn get_status(&self) -> Result<SessionAuthStatus, Error> {
5246        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5247        let _value = self
5248            .session
5249            .client()
5250            .call(rpc_methods::SESSION_GITHUBAUTH_GETSTATUS, Some(wire_params))
5251            .await?;
5252        Ok(serde_json::from_value(_value)?)
5253    }
5254
5255    /// Updates the session's auth credentials used for outbound model and API requests.
5256    ///
5257    /// Wire method: `session.gitHubAuth.setCredentials`.
5258    ///
5259    /// # Parameters
5260    ///
5261    /// * `params` - New auth credentials to install on the session. Omit to leave credentials unchanged.
5262    ///
5263    /// # Returns
5264    ///
5265    /// Indicates whether the credential update succeeded.
5266    ///
5267    /// <div class="warning">
5268    ///
5269    /// **Experimental.** This API is part of an experimental wire-protocol surface
5270    /// and may change or be removed in future SDK or CLI releases. Pin both the
5271    /// SDK and CLI versions if your code depends on it.
5272    ///
5273    /// </div>
5274    pub async fn set_credentials(
5275        &self,
5276        params: SessionSetCredentialsParams,
5277    ) -> Result<SessionSetCredentialsResult, Error> {
5278        let mut wire_params = serde_json::to_value(params)?;
5279        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5280        let _value = self
5281            .session
5282            .client()
5283            .call(
5284                rpc_methods::SESSION_GITHUBAUTH_SETCREDENTIALS,
5285                Some(wire_params),
5286            )
5287            .await?;
5288        Ok(serde_json::from_value(_value)?)
5289    }
5290
5291    /// Gets the current authentication information for internal session hosts.
5292    ///
5293    /// Wire method: `session.gitHubAuth.getCurrentAuthInfo`.
5294    ///
5295    /// # Returns
5296    ///
5297    /// Current authentication information, or null when no authentication is active.
5298    ///
5299    /// <div class="warning">
5300    ///
5301    /// **Experimental.** This API is part of an experimental wire-protocol surface
5302    /// and may change or be removed in future SDK or CLI releases. Pin both the
5303    /// SDK and CLI versions if your code depends on it.
5304    ///
5305    /// </div>
5306    pub(crate) async fn get_current_auth_info(&self) -> Result<SessionAuthInfoResult, Error> {
5307        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5308        let _value = self
5309            .session
5310            .client()
5311            .call(
5312                rpc_methods::SESSION_GITHUBAUTH_GETCURRENTAUTHINFO,
5313                Some(wire_params),
5314            )
5315            .await?;
5316        Ok(serde_json::from_value(_value)?)
5317    }
5318
5319    /// Gets all authentication accounts available to the internal session host.
5320    ///
5321    /// Wire method: `session.gitHubAuth.getAllAuthAvailable`.
5322    ///
5323    /// # Returns
5324    ///
5325    /// Authentication accounts available to the internal session host.
5326    ///
5327    /// <div class="warning">
5328    ///
5329    /// **Experimental.** This API is part of an experimental wire-protocol surface
5330    /// and may change or be removed in future SDK or CLI releases. Pin both the
5331    /// SDK and CLI versions if your code depends on it.
5332    ///
5333    /// </div>
5334    pub(crate) async fn get_all_auth_available(
5335        &self,
5336    ) -> Result<SessionGitHubAuthGetAllAuthAvailableResult, Error> {
5337        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5338        let _value = self
5339            .session
5340            .client()
5341            .call(
5342                rpc_methods::SESSION_GITHUBAUTH_GETALLAUTHAVAILABLE,
5343                Some(wire_params),
5344            )
5345            .await?;
5346        Ok(serde_json::from_value(_value)?)
5347    }
5348
5349    /// Refreshes Copilot account metadata for the current authentication.
5350    ///
5351    /// Wire method: `session.gitHubAuth.refreshCopilotUser`.
5352    ///
5353    /// # Returns
5354    ///
5355    /// Current authentication information, or null when no authentication is active.
5356    ///
5357    /// <div class="warning">
5358    ///
5359    /// **Experimental.** This API is part of an experimental wire-protocol surface
5360    /// and may change or be removed in future SDK or CLI releases. Pin both the
5361    /// SDK and CLI versions if your code depends on it.
5362    ///
5363    /// </div>
5364    pub(crate) async fn refresh_copilot_user(&self) -> Result<SessionAuthInfoResult, Error> {
5365        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5366        let _value = self
5367            .session
5368            .client()
5369            .call(
5370                rpc_methods::SESSION_GITHUBAUTH_REFRESHCOPILOTUSER,
5371                Some(wire_params),
5372            )
5373            .await?;
5374        Ok(serde_json::from_value(_value)?)
5375    }
5376
5377    /// Logs in a GitHub user through the internal session host.
5378    ///
5379    /// Wire method: `session.gitHubAuth.login`.
5380    ///
5381    /// # Parameters
5382    ///
5383    /// * `params` - Internal GitHub login parameters.
5384    ///
5385    /// # Returns
5386    ///
5387    /// Authentication credentials accepted only at native protocol ingress. Runtime outputs use credential-free `AuthIdentity` metadata.
5388    ///
5389    /// <div class="warning">
5390    ///
5391    /// **Experimental.** This API is part of an experimental wire-protocol surface
5392    /// and may change or be removed in future SDK or CLI releases. Pin both the
5393    /// SDK and CLI versions if your code depends on it.
5394    ///
5395    /// </div>
5396    pub(crate) async fn login(&self, params: SessionAuthLoginRequest) -> Result<AuthInfo, Error> {
5397        let mut wire_params = serde_json::to_value(params)?;
5398        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5399        let _value = self
5400            .session
5401            .client()
5402            .call(rpc_methods::SESSION_GITHUBAUTH_LOGIN, Some(wire_params))
5403            .await?;
5404        Ok(serde_json::from_value(_value)?)
5405    }
5406
5407    /// Switches the session to another available authentication.
5408    ///
5409    /// Wire method: `session.gitHubAuth.switchToAuth`.
5410    ///
5411    /// # Parameters
5412    ///
5413    /// * `params` - Parameters for switching the session's active authentication.
5414    ///
5415    /// <div class="warning">
5416    ///
5417    /// **Experimental.** This API is part of an experimental wire-protocol surface
5418    /// and may change or be removed in future SDK or CLI releases. Pin both the
5419    /// SDK and CLI versions if your code depends on it.
5420    ///
5421    /// </div>
5422    pub(crate) async fn switch_to_auth(
5423        &self,
5424        params: SessionAuthSwitchRequest,
5425    ) -> Result<(), Error> {
5426        let mut wire_params = serde_json::to_value(params)?;
5427        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5428        let _value = self
5429            .session
5430            .client()
5431            .call(
5432                rpc_methods::SESSION_GITHUBAUTH_SWITCHTOAUTH,
5433                Some(wire_params),
5434            )
5435            .await?;
5436        Ok(())
5437    }
5438
5439    /// Logs out the session's current GitHub authentication.
5440    ///
5441    /// Wire method: `session.gitHubAuth.logout`.
5442    ///
5443    /// # Returns
5444    ///
5445    /// Whether the current authentication was logged out.
5446    ///
5447    /// <div class="warning">
5448    ///
5449    /// **Experimental.** This API is part of an experimental wire-protocol surface
5450    /// and may change or be removed in future SDK or CLI releases. Pin both the
5451    /// SDK and CLI versions if your code depends on it.
5452    ///
5453    /// </div>
5454    pub(crate) async fn logout(&self) -> Result<SessionGitHubAuthLogoutResult, Error> {
5455        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5456        let _value = self
5457            .session
5458            .client()
5459            .call(rpc_methods::SESSION_GITHUBAUTH_LOGOUT, Some(wire_params))
5460            .await?;
5461        Ok(serde_json::from_value(_value)?)
5462    }
5463
5464    /// Logs out a specific GitHub authentication.
5465    ///
5466    /// Wire method: `session.gitHubAuth.logoutUser`.
5467    ///
5468    /// # Parameters
5469    ///
5470    /// * `params` - Parameters identifying a GitHub authentication to log out.
5471    ///
5472    /// # Returns
5473    ///
5474    /// Whether the requested authentication was logged out.
5475    ///
5476    /// <div class="warning">
5477    ///
5478    /// **Experimental.** This API is part of an experimental wire-protocol surface
5479    /// and may change or be removed in future SDK or CLI releases. Pin both the
5480    /// SDK and CLI versions if your code depends on it.
5481    ///
5482    /// </div>
5483    pub(crate) async fn logout_user(
5484        &self,
5485        params: SessionAuthLogoutUserRequest,
5486    ) -> Result<SessionGitHubAuthLogoutUserResult, Error> {
5487        let mut wire_params = serde_json::to_value(params)?;
5488        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5489        let _value = self
5490            .session
5491            .client()
5492            .call(
5493                rpc_methods::SESSION_GITHUBAUTH_LOGOUTUSER,
5494                Some(wire_params),
5495            )
5496            .await?;
5497        Ok(serde_json::from_value(_value)?)
5498    }
5499
5500    /// Gets validation errors from the most recent authentication attempt.
5501    ///
5502    /// Wire method: `session.gitHubAuth.lastAuthErrors`.
5503    ///
5504    /// # Returns
5505    ///
5506    /// Validation errors from the most recent authentication attempt.
5507    ///
5508    /// <div class="warning">
5509    ///
5510    /// **Experimental.** This API is part of an experimental wire-protocol surface
5511    /// and may change or be removed in future SDK or CLI releases. Pin both the
5512    /// SDK and CLI versions if your code depends on it.
5513    ///
5514    /// </div>
5515    pub(crate) async fn last_auth_errors(&self) -> Result<AuthValidationErrors, Error> {
5516        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5517        let _value = self
5518            .session
5519            .client()
5520            .call(
5521                rpc_methods::SESSION_GITHUBAUTH_LASTAUTHERRORS,
5522                Some(wire_params),
5523            )
5524            .await?;
5525        Ok(serde_json::from_value(_value)?)
5526    }
5527}
5528
5529/// `session.history.*` RPCs.
5530#[derive(Clone, Copy)]
5531pub struct SessionRpcHistory<'a> {
5532    pub(crate) session: &'a Session,
5533}
5534
5535impl<'a> SessionRpcHistory<'a> {
5536    /// Compacts the session history to reduce context usage.
5537    ///
5538    /// Wire method: `session.history.compact`.
5539    ///
5540    /// # Returns
5541    ///
5542    /// Compaction outcome with the number of tokens and messages removed, summary text, and the resulting context window breakdown.
5543    ///
5544    /// <div class="warning">
5545    ///
5546    /// **Experimental.** This API is part of an experimental wire-protocol surface
5547    /// and may change or be removed in future SDK or CLI releases. Pin both the
5548    /// SDK and CLI versions if your code depends on it.
5549    ///
5550    /// </div>
5551    pub async fn compact(&self) -> Result<HistoryCompactResult, Error> {
5552        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5553        let _value = self
5554            .session
5555            .client()
5556            .call(rpc_methods::SESSION_HISTORY_COMPACT, Some(wire_params))
5557            .await?;
5558        Ok(serde_json::from_value(_value)?)
5559    }
5560
5561    /// Compacts the session history to reduce context usage.
5562    ///
5563    /// Wire method: `session.history.compact`.
5564    ///
5565    /// # Parameters
5566    ///
5567    /// * `params` - Optional compaction parameters.
5568    ///
5569    /// # Returns
5570    ///
5571    /// Compaction outcome with the number of tokens and messages removed, summary text, and the resulting context window breakdown.
5572    ///
5573    /// <div class="warning">
5574    ///
5575    /// **Experimental.** This API is part of an experimental wire-protocol surface
5576    /// and may change or be removed in future SDK or CLI releases. Pin both the
5577    /// SDK and CLI versions if your code depends on it.
5578    ///
5579    /// </div>
5580    pub async fn compact_with_params(
5581        &self,
5582        params: HistoryCompactRequest,
5583    ) -> Result<HistoryCompactResult, Error> {
5584        let mut wire_params = serde_json::to_value(params)?;
5585        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5586        let _value = self
5587            .session
5588            .client()
5589            .call(rpc_methods::SESSION_HISTORY_COMPACT, Some(wire_params))
5590            .await?;
5591        Ok(serde_json::from_value(_value)?)
5592    }
5593
5594    /// Truncates persisted session history to a specific event.
5595    ///
5596    /// Wire method: `session.history.truncate`.
5597    ///
5598    /// # Parameters
5599    ///
5600    /// * `params` - Identifier of the event to truncate to; this event and all later events are removed.
5601    ///
5602    /// # Returns
5603    ///
5604    /// Number of events that were removed by the truncation.
5605    ///
5606    /// <div class="warning">
5607    ///
5608    /// **Experimental.** This API is part of an experimental wire-protocol surface
5609    /// and may change or be removed in future SDK or CLI releases. Pin both the
5610    /// SDK and CLI versions if your code depends on it.
5611    ///
5612    /// </div>
5613    pub async fn truncate(
5614        &self,
5615        params: HistoryTruncateRequest,
5616    ) -> Result<HistoryTruncateResult, Error> {
5617        let mut wire_params = serde_json::to_value(params)?;
5618        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5619        let _value = self
5620            .session
5621            .client()
5622            .call(rpc_methods::SESSION_HISTORY_TRUNCATE, Some(wire_params))
5623            .await?;
5624        Ok(serde_json::from_value(_value)?)
5625    }
5626
5627    /// 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.
5628    ///
5629    /// Wire method: `session.history.listRewindPoints`.
5630    ///
5631    /// # Returns
5632    ///
5633    /// Rewind points and file-change-tracking availability for the session.
5634    ///
5635    /// <div class="warning">
5636    ///
5637    /// **Experimental.** This API is part of an experimental wire-protocol surface
5638    /// and may change or be removed in future SDK or CLI releases. Pin both the
5639    /// SDK and CLI versions if your code depends on it.
5640    ///
5641    /// </div>
5642    pub async fn list_rewind_points(&self) -> Result<HistoryListRewindPointsResult, Error> {
5643        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5644        let _value = self
5645            .session
5646            .client()
5647            .call(
5648                rpc_methods::SESSION_HISTORY_LISTREWINDPOINTS,
5649                Some(wire_params),
5650            )
5651            .await?;
5652        Ok(serde_json::from_value(_value)?)
5653    }
5654
5655    /// Previews the files that a conversation-and-files rewind would restore.
5656    ///
5657    /// Wire method: `session.history.previewRewind`.
5658    ///
5659    /// # Parameters
5660    ///
5661    /// * `params` - Event boundary to preview for conversation-and-files rewind.
5662    ///
5663    /// # Returns
5664    ///
5665    /// Files and aggregate changes for a prospective rewind.
5666    ///
5667    /// <div class="warning">
5668    ///
5669    /// **Experimental.** This API is part of an experimental wire-protocol surface
5670    /// and may change or be removed in future SDK or CLI releases. Pin both the
5671    /// SDK and CLI versions if your code depends on it.
5672    ///
5673    /// </div>
5674    pub async fn preview_rewind(
5675        &self,
5676        params: HistoryPreviewRewindRequest,
5677    ) -> Result<HistoryPreviewRewindResult, Error> {
5678        let mut wire_params = serde_json::to_value(params)?;
5679        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5680        let _value = self
5681            .session
5682            .client()
5683            .call(
5684                rpc_methods::SESSION_HISTORY_PREVIEWREWIND,
5685                Some(wire_params),
5686            )
5687            .await?;
5688        Ok(serde_json::from_value(_value)?)
5689    }
5690
5691    /// 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.
5692    ///
5693    /// Wire method: `session.history.rewind`.
5694    ///
5695    /// # Parameters
5696    ///
5697    /// * `params` - Boundary and mode for rewinding session history.
5698    ///
5699    /// # Returns
5700    ///
5701    /// Structured outcome of a rewind request.
5702    ///
5703    /// <div class="warning">
5704    ///
5705    /// **Experimental.** This API is part of an experimental wire-protocol surface
5706    /// and may change or be removed in future SDK or CLI releases. Pin both the
5707    /// SDK and CLI versions if your code depends on it.
5708    ///
5709    /// </div>
5710    pub async fn rewind(&self, params: HistoryRewindRequest) -> Result<HistoryRewindResult, Error> {
5711        let mut wire_params = serde_json::to_value(params)?;
5712        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5713        let _value = self
5714            .session
5715            .client()
5716            .call(rpc_methods::SESSION_HISTORY_REWIND, Some(wire_params))
5717            .await?;
5718        Ok(serde_json::from_value(_value)?)
5719    }
5720
5721    /// Cancels any in-progress background compaction on a local session.
5722    ///
5723    /// Wire method: `session.history.cancelBackgroundCompaction`.
5724    ///
5725    /// # Returns
5726    ///
5727    /// Indicates whether an in-progress background compaction was cancelled.
5728    ///
5729    /// <div class="warning">
5730    ///
5731    /// **Experimental.** This API is part of an experimental wire-protocol surface
5732    /// and may change or be removed in future SDK or CLI releases. Pin both the
5733    /// SDK and CLI versions if your code depends on it.
5734    ///
5735    /// </div>
5736    pub async fn cancel_background_compaction(
5737        &self,
5738    ) -> Result<HistoryCancelBackgroundCompactionResult, Error> {
5739        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5740        let _value = self
5741            .session
5742            .client()
5743            .call(
5744                rpc_methods::SESSION_HISTORY_CANCELBACKGROUNDCOMPACTION,
5745                Some(wire_params),
5746            )
5747            .await?;
5748        Ok(serde_json::from_value(_value)?)
5749    }
5750
5751    /// Aborts any in-progress manual compaction on a local session.
5752    ///
5753    /// Wire method: `session.history.abortManualCompaction`.
5754    ///
5755    /// # Returns
5756    ///
5757    /// Indicates whether an in-progress manual compaction was aborted.
5758    ///
5759    /// <div class="warning">
5760    ///
5761    /// **Experimental.** This API is part of an experimental wire-protocol surface
5762    /// and may change or be removed in future SDK or CLI releases. Pin both the
5763    /// SDK and CLI versions if your code depends on it.
5764    ///
5765    /// </div>
5766    pub async fn abort_manual_compaction(
5767        &self,
5768    ) -> Result<HistoryAbortManualCompactionResult, Error> {
5769        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5770        let _value = self
5771            .session
5772            .client()
5773            .call(
5774                rpc_methods::SESSION_HISTORY_ABORTMANUALCOMPACTION,
5775                Some(wire_params),
5776            )
5777            .await?;
5778        Ok(serde_json::from_value(_value)?)
5779    }
5780
5781    /// Produces a markdown summary of the session's conversation context for hand-off scenarios.
5782    ///
5783    /// Wire method: `session.history.summarizeForHandoff`.
5784    ///
5785    /// # Returns
5786    ///
5787    /// Markdown summary of the conversation context (empty when not available).
5788    ///
5789    /// <div class="warning">
5790    ///
5791    /// **Experimental.** This API is part of an experimental wire-protocol surface
5792    /// and may change or be removed in future SDK or CLI releases. Pin both the
5793    /// SDK and CLI versions if your code depends on it.
5794    ///
5795    /// </div>
5796    pub async fn summarize_for_handoff(&self) -> Result<HistorySummarizeForHandoffResult, Error> {
5797        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5798        let _value = self
5799            .session
5800            .client()
5801            .call(
5802                rpc_methods::SESSION_HISTORY_SUMMARIZEFORHANDOFF,
5803                Some(wire_params),
5804            )
5805            .await?;
5806        Ok(serde_json::from_value(_value)?)
5807    }
5808
5809    /// 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.
5810    ///
5811    /// Wire method: `session.history.clearContext`.
5812    ///
5813    /// # Parameters
5814    ///
5815    /// * `params` - Parameters for clearing the conversation and seeding the window that replaces it.
5816    ///
5817    /// # Returns
5818    ///
5819    /// What a successful clear removed. A clear that could not be applied rejects instead of reporting a count.
5820    ///
5821    /// <div class="warning">
5822    ///
5823    /// **Experimental.** This API is part of an experimental wire-protocol surface
5824    /// and may change or be removed in future SDK or CLI releases. Pin both the
5825    /// SDK and CLI versions if your code depends on it.
5826    ///
5827    /// </div>
5828    pub async fn clear_context(
5829        &self,
5830        params: HistoryClearContextRequest,
5831    ) -> Result<HistoryClearContextResult, Error> {
5832        let mut wire_params = serde_json::to_value(params)?;
5833        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5834        let _value = self
5835            .session
5836            .client()
5837            .call(rpc_methods::SESSION_HISTORY_CLEARCONTEXT, Some(wire_params))
5838            .await?;
5839        Ok(serde_json::from_value(_value)?)
5840    }
5841}
5842
5843/// `session.instructions.*` RPCs.
5844#[derive(Clone, Copy)]
5845pub struct SessionRpcInstructions<'a> {
5846    pub(crate) session: &'a Session,
5847}
5848
5849impl<'a> SessionRpcInstructions<'a> {
5850    /// Gets instruction sources loaded for the session.
5851    ///
5852    /// Wire method: `session.instructions.getSources`.
5853    ///
5854    /// # Returns
5855    ///
5856    /// Instruction sources loaded for the session, in merge order.
5857    ///
5858    /// <div class="warning">
5859    ///
5860    /// **Experimental.** This API is part of an experimental wire-protocol surface
5861    /// and may change or be removed in future SDK or CLI releases. Pin both the
5862    /// SDK and CLI versions if your code depends on it.
5863    ///
5864    /// </div>
5865    pub async fn get_sources(&self) -> Result<InstructionsGetSourcesResult, Error> {
5866        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5867        let _value = self
5868            .session
5869            .client()
5870            .call(
5871                rpc_methods::SESSION_INSTRUCTIONS_GETSOURCES,
5872                Some(wire_params),
5873            )
5874            .await?;
5875        Ok(serde_json::from_value(_value)?)
5876    }
5877}
5878
5879/// `session.limitPrediction.*` RPCs.
5880#[derive(Clone, Copy)]
5881pub struct SessionRpcLimitPrediction<'a> {
5882    pub(crate) session: &'a Session,
5883}
5884
5885impl<'a> SessionRpcLimitPrediction<'a> {
5886    /// 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.
5887    ///
5888    /// Wire method: `session.limitPrediction.predict`.
5889    ///
5890    /// # Returns
5891    ///
5892    /// Prediction result. Available results include prediction details; unavailable results include an explicit reason.
5893    ///
5894    /// <div class="warning">
5895    ///
5896    /// **Experimental.** This API is part of an experimental wire-protocol surface
5897    /// and may change or be removed in future SDK or CLI releases. Pin both the
5898    /// SDK and CLI versions if your code depends on it.
5899    ///
5900    /// </div>
5901    pub async fn predict(&self) -> Result<SessionLimitPredictionResult, Error> {
5902        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5903        let _value = self
5904            .session
5905            .client()
5906            .call(
5907                rpc_methods::SESSION_LIMITPREDICTION_PREDICT,
5908                Some(wire_params),
5909            )
5910            .await?;
5911        Ok(serde_json::from_value(_value)?)
5912    }
5913
5914    /// 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.
5915    ///
5916    /// Wire method: `session.limitPrediction.predict`.
5917    ///
5918    /// # Parameters
5919    ///
5920    /// * `params` - Parameters for predicting an AI-credit session limit. Omitting `modelId` uses the session's currently selected model.
5921    ///
5922    /// # Returns
5923    ///
5924    /// Prediction result. Available results include prediction details; unavailable results include an explicit reason.
5925    ///
5926    /// <div class="warning">
5927    ///
5928    /// **Experimental.** This API is part of an experimental wire-protocol surface
5929    /// and may change or be removed in future SDK or CLI releases. Pin both the
5930    /// SDK and CLI versions if your code depends on it.
5931    ///
5932    /// </div>
5933    pub async fn predict_with_params(
5934        &self,
5935        params: SessionLimitPredictionRequest,
5936    ) -> Result<SessionLimitPredictionResult, Error> {
5937        let mut wire_params = serde_json::to_value(params)?;
5938        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5939        let _value = self
5940            .session
5941            .client()
5942            .call(
5943                rpc_methods::SESSION_LIMITPREDICTION_PREDICT,
5944                Some(wire_params),
5945            )
5946            .await?;
5947        Ok(serde_json::from_value(_value)?)
5948    }
5949}
5950
5951/// `session.lsp.*` RPCs.
5952#[derive(Clone, Copy)]
5953pub struct SessionRpcLsp<'a> {
5954    pub(crate) session: &'a Session,
5955}
5956
5957impl<'a> SessionRpcLsp<'a> {
5958    /// Loads the merged LSP configuration set for the session's working directory.
5959    ///
5960    /// Wire method: `session.lsp.initialize`.
5961    ///
5962    /// # Parameters
5963    ///
5964    /// * `params` - Parameters for (re)loading the merged LSP configuration set.
5965    ///
5966    /// <div class="warning">
5967    ///
5968    /// **Experimental.** This API is part of an experimental wire-protocol surface
5969    /// and may change or be removed in future SDK or CLI releases. Pin both the
5970    /// SDK and CLI versions if your code depends on it.
5971    ///
5972    /// </div>
5973    pub async fn initialize(&self, params: LspInitializeRequest) -> Result<(), Error> {
5974        let mut wire_params = serde_json::to_value(params)?;
5975        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5976        let _value = self
5977            .session
5978            .client()
5979            .call(rpc_methods::SESSION_LSP_INITIALIZE, Some(wire_params))
5980            .await?;
5981        Ok(())
5982    }
5983}
5984
5985/// `session.mcp.*` RPCs.
5986#[derive(Clone, Copy)]
5987pub struct SessionRpcMcp<'a> {
5988    pub(crate) session: &'a Session,
5989}
5990
5991impl<'a> SessionRpcMcp<'a> {
5992    /// `session.mcp.apps.*` sub-namespace.
5993    pub fn apps(&self) -> SessionRpcMcpApps<'a> {
5994        SessionRpcMcpApps {
5995            session: self.session,
5996        }
5997    }
5998
5999    /// `session.mcp.headers.*` sub-namespace.
6000    pub fn headers(&self) -> SessionRpcMcpHeaders<'a> {
6001        SessionRpcMcpHeaders {
6002            session: self.session,
6003        }
6004    }
6005
6006    /// `session.mcp.oauth.*` sub-namespace.
6007    pub fn oauth(&self) -> SessionRpcMcpOauth<'a> {
6008        SessionRpcMcpOauth {
6009            session: self.session,
6010        }
6011    }
6012
6013    /// `session.mcp.resources.*` sub-namespace.
6014    pub fn resources(&self) -> SessionRpcMcpResources<'a> {
6015        SessionRpcMcpResources {
6016            session: self.session,
6017        }
6018    }
6019
6020    /// 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.
6021    ///
6022    /// Wire method: `session.mcp.list`.
6023    ///
6024    /// # Returns
6025    ///
6026    /// MCP servers configured for the session, with their connection status and host-level state.
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 list(&self) -> Result<McpServerList, Error> {
6036        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6037        let _value = self
6038            .session
6039            .client()
6040            .call(rpc_methods::SESSION_MCP_LIST, Some(wire_params))
6041            .await?;
6042        Ok(serde_json::from_value(_value)?)
6043    }
6044
6045    /// 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.
6046    ///
6047    /// Wire method: `session.mcp.listTools`.
6048    ///
6049    /// # Parameters
6050    ///
6051    /// * `params` - Server name whose tool list should be returned.
6052    ///
6053    /// # Returns
6054    ///
6055    /// Tools exposed by the connected MCP server. Throws when the server is not connected.
6056    ///
6057    /// <div class="warning">
6058    ///
6059    /// **Experimental.** This API is part of an experimental wire-protocol surface
6060    /// and may change or be removed in future SDK or CLI releases. Pin both the
6061    /// SDK and CLI versions if your code depends on it.
6062    ///
6063    /// </div>
6064    pub async fn list_tools(
6065        &self,
6066        params: McpListToolsRequest,
6067    ) -> Result<McpListToolsResult, Error> {
6068        let mut wire_params = serde_json::to_value(params)?;
6069        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6070        let _value = self
6071            .session
6072            .client()
6073            .call(rpc_methods::SESSION_MCP_LISTTOOLS, Some(wire_params))
6074            .await?;
6075        Ok(serde_json::from_value(_value)?)
6076    }
6077
6078    /// Enables an MCP server for the session.
6079    ///
6080    /// Wire method: `session.mcp.enable`.
6081    ///
6082    /// # Parameters
6083    ///
6084    /// * `params` - Name of the MCP server to enable for the session.
6085    ///
6086    /// <div class="warning">
6087    ///
6088    /// **Experimental.** This API is part of an experimental wire-protocol surface
6089    /// and may change or be removed in future SDK or CLI releases. Pin both the
6090    /// SDK and CLI versions if your code depends on it.
6091    ///
6092    /// </div>
6093    pub async fn enable(&self, params: McpEnableRequest) -> Result<(), Error> {
6094        let mut wire_params = serde_json::to_value(params)?;
6095        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6096        let _value = self
6097            .session
6098            .client()
6099            .call(rpc_methods::SESSION_MCP_ENABLE, Some(wire_params))
6100            .await?;
6101        Ok(())
6102    }
6103
6104    /// Disables an MCP server for the session.
6105    ///
6106    /// Wire method: `session.mcp.disable`.
6107    ///
6108    /// # Parameters
6109    ///
6110    /// * `params` - Name of the MCP server to disable for the session.
6111    ///
6112    /// <div class="warning">
6113    ///
6114    /// **Experimental.** This API is part of an experimental wire-protocol surface
6115    /// and may change or be removed in future SDK or CLI releases. Pin both the
6116    /// SDK and CLI versions if your code depends on it.
6117    ///
6118    /// </div>
6119    pub async fn disable(&self, params: McpDisableRequest) -> Result<(), 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_DISABLE, Some(wire_params))
6126            .await?;
6127        Ok(())
6128    }
6129
6130    /// Reloads MCP server connections for the session.
6131    ///
6132    /// Wire method: `session.mcp.reload`.
6133    ///
6134    /// <div class="warning">
6135    ///
6136    /// **Experimental.** This API is part of an experimental wire-protocol surface
6137    /// and may change or be removed in future SDK or CLI releases. Pin both the
6138    /// SDK and CLI versions if your code depends on it.
6139    ///
6140    /// </div>
6141    pub async fn reload(&self) -> Result<(), Error> {
6142        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6143        let _value = self
6144            .session
6145            .client()
6146            .call(rpc_methods::SESSION_MCP_RELOAD, Some(wire_params))
6147            .await?;
6148        Ok(())
6149    }
6150
6151    /// 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.
6152    ///
6153    /// Wire method: `session.mcp.moveLoadingToBackground`.
6154    ///
6155    /// # Returns
6156    ///
6157    /// Result of moving in-flight MCP loading to the background.
6158    ///
6159    /// <div class="warning">
6160    ///
6161    /// **Experimental.** This API is part of an experimental wire-protocol surface
6162    /// and may change or be removed in future SDK or CLI releases. Pin both the
6163    /// SDK and CLI versions if your code depends on it.
6164    ///
6165    /// </div>
6166    pub async fn move_loading_to_background(
6167        &self,
6168    ) -> Result<MoveMcpLoadingToBackgroundResult, Error> {
6169        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6170        let _value = self
6171            .session
6172            .client()
6173            .call(
6174                rpc_methods::SESSION_MCP_MOVELOADINGTOBACKGROUND,
6175                Some(wire_params),
6176            )
6177            .await?;
6178        Ok(serde_json::from_value(_value)?)
6179    }
6180
6181    /// Reloads MCP server connections for the session with an explicit host-provided configuration.
6182    ///
6183    /// Wire method: `session.mcp.reloadWithConfig`.
6184    ///
6185    /// # Parameters
6186    ///
6187    /// * `params` - Opaque MCP reload configuration.
6188    ///
6189    /// # Returns
6190    ///
6191    /// MCP server startup filtering result.
6192    ///
6193    /// <div class="warning">
6194    ///
6195    /// **Experimental.** This API is part of an experimental wire-protocol surface
6196    /// and may change or be removed in future SDK or CLI releases. Pin both the
6197    /// SDK and CLI versions if your code depends on it.
6198    ///
6199    /// </div>
6200    pub(crate) async fn reload_with_config(
6201        &self,
6202        params: McpReloadWithConfigRequest,
6203    ) -> Result<McpStartServersResult, Error> {
6204        let mut wire_params = serde_json::to_value(params)?;
6205        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6206        let _value = self
6207            .session
6208            .client()
6209            .call(rpc_methods::SESSION_MCP_RELOADWITHCONFIG, Some(wire_params))
6210            .await?;
6211        Ok(serde_json::from_value(_value)?)
6212    }
6213
6214    /// Runs an MCP sampling inference on behalf of an MCP server.
6215    ///
6216    /// Wire method: `session.mcp.executeSampling`.
6217    ///
6218    /// # Parameters
6219    ///
6220    /// * `params` - Identifiers and raw MCP CreateMessageRequest params used to run a sampling inference.
6221    ///
6222    /// # Returns
6223    ///
6224    /// Outcome of an MCP sampling execution: success result, failure error, or cancellation.
6225    ///
6226    /// <div class="warning">
6227    ///
6228    /// **Experimental.** This API is part of an experimental wire-protocol surface
6229    /// and may change or be removed in future SDK or CLI releases. Pin both the
6230    /// SDK and CLI versions if your code depends on it.
6231    ///
6232    /// </div>
6233    pub async fn execute_sampling(
6234        &self,
6235        params: McpExecuteSamplingParams,
6236    ) -> Result<McpSamplingExecutionResult, Error> {
6237        let mut wire_params = serde_json::to_value(params)?;
6238        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6239        let _value = self
6240            .session
6241            .client()
6242            .call(rpc_methods::SESSION_MCP_EXECUTESAMPLING, Some(wire_params))
6243            .await?;
6244        Ok(serde_json::from_value(_value)?)
6245    }
6246
6247    /// Cancels an in-flight MCP sampling execution by request ID.
6248    ///
6249    /// Wire method: `session.mcp.cancelSamplingExecution`.
6250    ///
6251    /// # Parameters
6252    ///
6253    /// * `params` - The requestId previously passed to executeSampling that should be cancelled.
6254    ///
6255    /// # Returns
6256    ///
6257    /// Indicates whether an in-flight sampling execution with the given requestId was found and cancelled.
6258    ///
6259    /// <div class="warning">
6260    ///
6261    /// **Experimental.** This API is part of an experimental wire-protocol surface
6262    /// and may change or be removed in future SDK or CLI releases. Pin both the
6263    /// SDK and CLI versions if your code depends on it.
6264    ///
6265    /// </div>
6266    pub async fn cancel_sampling_execution(
6267        &self,
6268        params: McpCancelSamplingExecutionParams,
6269    ) -> Result<McpCancelSamplingExecutionResult, Error> {
6270        let mut wire_params = serde_json::to_value(params)?;
6271        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6272        let _value = self
6273            .session
6274            .client()
6275            .call(
6276                rpc_methods::SESSION_MCP_CANCELSAMPLINGEXECUTION,
6277                Some(wire_params),
6278            )
6279            .await?;
6280        Ok(serde_json::from_value(_value)?)
6281    }
6282
6283    /// Sets how environment-variable values supplied to MCP servers are resolved (direct or indirect).
6284    ///
6285    /// Wire method: `session.mcp.setEnvValueMode`.
6286    ///
6287    /// # Parameters
6288    ///
6289    /// * `params` - Mode controlling how MCP server env values are resolved (`direct` or `indirect`).
6290    ///
6291    /// # Returns
6292    ///
6293    /// Env-value mode recorded on the session after the update.
6294    ///
6295    /// <div class="warning">
6296    ///
6297    /// **Experimental.** This API is part of an experimental wire-protocol surface
6298    /// and may change or be removed in future SDK or CLI releases. Pin both the
6299    /// SDK and CLI versions if your code depends on it.
6300    ///
6301    /// </div>
6302    pub async fn set_env_value_mode(
6303        &self,
6304        params: McpSetEnvValueModeParams,
6305    ) -> Result<McpSetEnvValueModeResult, 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_SETENVVALUEMODE, Some(wire_params))
6312            .await?;
6313        Ok(serde_json::from_value(_value)?)
6314    }
6315
6316    /// Removes the auto-managed `github` MCP server when present.
6317    ///
6318    /// Wire method: `session.mcp.removeGitHub`.
6319    ///
6320    /// # Returns
6321    ///
6322    /// Indicates whether the auto-managed `github` MCP server was removed (false when nothing to remove).
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 remove_git_hub(&self) -> Result<McpRemoveGitHubResult, Error> {
6332        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6333        let _value = self
6334            .session
6335            .client()
6336            .call(rpc_methods::SESSION_MCP_REMOVEGITHUB, Some(wire_params))
6337            .await?;
6338        Ok(serde_json::from_value(_value)?)
6339    }
6340
6341    /// Configures the built-in GitHub MCP server for the session's current auth context.
6342    ///
6343    /// Wire method: `session.mcp.configureGitHub`.
6344    ///
6345    /// # Parameters
6346    ///
6347    /// * `params` - Credential-free authentication identity used to configure GitHub MCP.
6348    ///
6349    /// # Returns
6350    ///
6351    /// Result of configuring GitHub MCP.
6352    ///
6353    /// <div class="warning">
6354    ///
6355    /// **Experimental.** This API is part of an experimental wire-protocol surface
6356    /// and may change or be removed in future SDK or CLI releases. Pin both the
6357    /// SDK and CLI versions if your code depends on it.
6358    ///
6359    /// </div>
6360    pub(crate) async fn configure_git_hub(
6361        &self,
6362        params: McpConfigureGitHubRequest,
6363    ) -> Result<McpConfigureGitHubResult, Error> {
6364        let mut wire_params = serde_json::to_value(params)?;
6365        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6366        let _value = self
6367            .session
6368            .client()
6369            .call(rpc_methods::SESSION_MCP_CONFIGUREGITHUB, Some(wire_params))
6370            .await?;
6371        Ok(serde_json::from_value(_value)?)
6372    }
6373
6374    /// 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.
6375    ///
6376    /// Wire method: `session.mcp.startServer`.
6377    ///
6378    /// # Parameters
6379    ///
6380    /// * `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.
6381    ///
6382    /// <div class="warning">
6383    ///
6384    /// **Experimental.** This API is part of an experimental wire-protocol surface
6385    /// and may change or be removed in future SDK or CLI releases. Pin both the
6386    /// SDK and CLI versions if your code depends on it.
6387    ///
6388    /// </div>
6389    pub async fn start_server(&self, params: McpStartServerRequest) -> Result<(), Error> {
6390        let mut wire_params = serde_json::to_value(params)?;
6391        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6392        let _value = self
6393            .session
6394            .client()
6395            .call(rpc_methods::SESSION_MCP_STARTSERVER, Some(wire_params))
6396            .await?;
6397        Ok(())
6398    }
6399
6400    /// 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.*`).
6401    ///
6402    /// Wire method: `session.mcp.restartServer`.
6403    ///
6404    /// # Parameters
6405    ///
6406    /// * `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.
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 async fn restart_server(&self, params: McpRestartServerRequest) -> Result<(), Error> {
6416        let mut wire_params = serde_json::to_value(params)?;
6417        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6418        let _value = self
6419            .session
6420            .client()
6421            .call(rpc_methods::SESSION_MCP_RESTARTSERVER, Some(wire_params))
6422            .await?;
6423        Ok(())
6424    }
6425
6426    /// Stops an individual MCP server on the session's host.
6427    ///
6428    /// Wire method: `session.mcp.stopServer`.
6429    ///
6430    /// # Parameters
6431    ///
6432    /// * `params` - Server name for an individual MCP server stop.
6433    ///
6434    /// <div class="warning">
6435    ///
6436    /// **Experimental.** This API is part of an experimental wire-protocol surface
6437    /// and may change or be removed in future SDK or CLI releases. Pin both the
6438    /// SDK and CLI versions if your code depends on it.
6439    ///
6440    /// </div>
6441    pub async fn stop_server(&self, params: McpStopServerRequest) -> Result<(), Error> {
6442        let mut wire_params = serde_json::to_value(params)?;
6443        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6444        let _value = self
6445            .session
6446            .client()
6447            .call(rpc_methods::SESSION_MCP_STOPSERVER, Some(wire_params))
6448            .await?;
6449        Ok(())
6450    }
6451
6452    /// 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.
6453    ///
6454    /// Wire method: `session.mcp.registerExternalClient`.
6455    ///
6456    /// # Parameters
6457    ///
6458    /// * `params` - Registration parameters for an external MCP client.
6459    ///
6460    /// <div class="warning">
6461    ///
6462    /// **Experimental.** This API is part of an experimental wire-protocol surface
6463    /// and may change or be removed in future SDK or CLI releases. Pin both the
6464    /// SDK and CLI versions if your code depends on it.
6465    ///
6466    /// </div>
6467    pub(crate) async fn register_external_client(
6468        &self,
6469        params: McpRegisterExternalClientRequest,
6470    ) -> Result<(), Error> {
6471        let mut wire_params = serde_json::to_value(params)?;
6472        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6473        let _value = self
6474            .session
6475            .client()
6476            .call(
6477                rpc_methods::SESSION_MCP_REGISTEREXTERNALCLIENT,
6478                Some(wire_params),
6479            )
6480            .await?;
6481        Ok(())
6482    }
6483
6484    /// 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.
6485    ///
6486    /// Wire method: `session.mcp.unregisterExternalClient`.
6487    ///
6488    /// # Parameters
6489    ///
6490    /// * `params` - Server name identifying the external client to remove.
6491    ///
6492    /// <div class="warning">
6493    ///
6494    /// **Experimental.** This API is part of an experimental wire-protocol surface
6495    /// and may change or be removed in future SDK or CLI releases. Pin both the
6496    /// SDK and CLI versions if your code depends on it.
6497    ///
6498    /// </div>
6499    pub(crate) async fn unregister_external_client(
6500        &self,
6501        params: McpUnregisterExternalClientRequest,
6502    ) -> Result<(), Error> {
6503        let mut wire_params = serde_json::to_value(params)?;
6504        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6505        let _value = self
6506            .session
6507            .client()
6508            .call(
6509                rpc_methods::SESSION_MCP_UNREGISTEREXTERNALCLIENT,
6510                Some(wire_params),
6511            )
6512            .await?;
6513        Ok(())
6514    }
6515
6516    /// Checks whether a named MCP server is currently running on the session's host.
6517    ///
6518    /// Wire method: `session.mcp.isServerRunning`.
6519    ///
6520    /// # Parameters
6521    ///
6522    /// * `params` - Server name to check running status for.
6523    ///
6524    /// # Returns
6525    ///
6526    /// Whether the named MCP server is running.
6527    ///
6528    /// <div class="warning">
6529    ///
6530    /// **Experimental.** This API is part of an experimental wire-protocol surface
6531    /// and may change or be removed in future SDK or CLI releases. Pin both the
6532    /// SDK and CLI versions if your code depends on it.
6533    ///
6534    /// </div>
6535    pub async fn is_server_running(
6536        &self,
6537        params: McpIsServerRunningRequest,
6538    ) -> Result<McpIsServerRunningResult, Error> {
6539        let mut wire_params = serde_json::to_value(params)?;
6540        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6541        let _value = self
6542            .session
6543            .client()
6544            .call(rpc_methods::SESSION_MCP_ISSERVERRUNNING, Some(wire_params))
6545            .await?;
6546        Ok(serde_json::from_value(_value)?)
6547    }
6548}
6549
6550/// `session.mcp.apps.*` RPCs.
6551#[derive(Clone, Copy)]
6552pub struct SessionRpcMcpApps<'a> {
6553    pub(crate) session: &'a Session,
6554}
6555
6556impl<'a> SessionRpcMcpApps<'a> {
6557    /// Fetch an MCP resource (typically a `ui://` MCP App bundle, per SEP-1865) from a connected server. Requires the `mcp-apps` session capability.
6558    ///
6559    /// Wire method: `session.mcp.apps.readResource`.
6560    ///
6561    /// # Parameters
6562    ///
6563    /// * `params` - MCP server and resource URI to fetch.
6564    ///
6565    /// # Returns
6566    ///
6567    /// Resource contents returned by the MCP server.
6568    ///
6569    /// <div class="warning">
6570    ///
6571    /// **Experimental.** This API is part of an experimental wire-protocol surface
6572    /// and may change or be removed in future SDK or CLI releases. Pin both the
6573    /// SDK and CLI versions if your code depends on it.
6574    ///
6575    /// </div>
6576    pub async fn read_resource(
6577        &self,
6578        params: McpAppsReadResourceRequest,
6579    ) -> Result<McpAppsReadResourceResult, Error> {
6580        let mut wire_params = serde_json::to_value(params)?;
6581        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6582        let _value = self
6583            .session
6584            .client()
6585            .call(
6586                rpc_methods::SESSION_MCP_APPS_READRESOURCE,
6587                Some(wire_params),
6588            )
6589            .await?;
6590        Ok(serde_json::from_value(_value)?)
6591    }
6592
6593    /// 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"`.
6594    ///
6595    /// Wire method: `session.mcp.apps.listTools`.
6596    ///
6597    /// # Parameters
6598    ///
6599    /// * `params` - MCP server to list app-callable tools for.
6600    ///
6601    /// # Returns
6602    ///
6603    /// App-callable tools from the named MCP server.
6604    ///
6605    /// <div class="warning">
6606    ///
6607    /// **Experimental.** This API is part of an experimental wire-protocol surface
6608    /// and may change or be removed in future SDK or CLI releases. Pin both the
6609    /// SDK and CLI versions if your code depends on it.
6610    ///
6611    /// </div>
6612    pub async fn list_tools(
6613        &self,
6614        params: McpAppsListToolsRequest,
6615    ) -> Result<McpAppsListToolsResult, Error> {
6616        let mut wire_params = serde_json::to_value(params)?;
6617        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6618        let _value = self
6619            .session
6620            .client()
6621            .call(rpc_methods::SESSION_MCP_APPS_LISTTOOLS, Some(wire_params))
6622            .await?;
6623        Ok(serde_json::from_value(_value)?)
6624    }
6625
6626    /// 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`.
6627    ///
6628    /// Wire method: `session.mcp.apps.callTool`.
6629    ///
6630    /// # Parameters
6631    ///
6632    /// * `params` - MCP server, tool name, and arguments to invoke from an MCP App view.
6633    ///
6634    /// # Returns
6635    ///
6636    /// Standard MCP CallToolResult
6637    ///
6638    /// <div class="warning">
6639    ///
6640    /// **Experimental.** This API is part of an experimental wire-protocol surface
6641    /// and may change or be removed in future SDK or CLI releases. Pin both the
6642    /// SDK and CLI versions if your code depends on it.
6643    ///
6644    /// </div>
6645    pub async fn call_tool(
6646        &self,
6647        params: McpAppsCallToolRequest,
6648    ) -> Result<SessionMcpAppsCallToolResult, Error> {
6649        let mut wire_params = serde_json::to_value(params)?;
6650        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6651        let _value = self
6652            .session
6653            .client()
6654            .call(rpc_methods::SESSION_MCP_APPS_CALLTOOL, Some(wire_params))
6655            .await?;
6656        Ok(serde_json::from_value(_value)?)
6657    }
6658
6659    /// 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.
6660    ///
6661    /// Wire method: `session.mcp.apps.setHostContext`.
6662    ///
6663    /// # Parameters
6664    ///
6665    /// * `params` - Host context to advertise to MCP App guests.
6666    ///
6667    /// <div class="warning">
6668    ///
6669    /// **Experimental.** This API is part of an experimental wire-protocol surface
6670    /// and may change or be removed in future SDK or CLI releases. Pin both the
6671    /// SDK and CLI versions if your code depends on it.
6672    ///
6673    /// </div>
6674    pub async fn set_host_context(
6675        &self,
6676        params: McpAppsSetHostContextRequest,
6677    ) -> Result<(), Error> {
6678        let mut wire_params = serde_json::to_value(params)?;
6679        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6680        let _value = self
6681            .session
6682            .client()
6683            .call(
6684                rpc_methods::SESSION_MCP_APPS_SETHOSTCONTEXT,
6685                Some(wire_params),
6686            )
6687            .await?;
6688        Ok(())
6689    }
6690
6691    /// Read the current host context advertised to MCP App guests.
6692    ///
6693    /// Wire method: `session.mcp.apps.getHostContext`.
6694    ///
6695    /// # Returns
6696    ///
6697    /// Current host context advertised to MCP App guests.
6698    ///
6699    /// <div class="warning">
6700    ///
6701    /// **Experimental.** This API is part of an experimental wire-protocol surface
6702    /// and may change or be removed in future SDK or CLI releases. Pin both the
6703    /// SDK and CLI versions if your code depends on it.
6704    ///
6705    /// </div>
6706    pub async fn get_host_context(&self) -> Result<McpAppsHostContext, Error> {
6707        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6708        let _value = self
6709            .session
6710            .client()
6711            .call(
6712                rpc_methods::SESSION_MCP_APPS_GETHOSTCONTEXT,
6713                Some(wire_params),
6714            )
6715            .await?;
6716        Ok(serde_json::from_value(_value)?)
6717    }
6718
6719    /// 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.
6720    ///
6721    /// Wire method: `session.mcp.apps.diagnose`.
6722    ///
6723    /// # Parameters
6724    ///
6725    /// * `params` - MCP server to diagnose MCP Apps wiring for.
6726    ///
6727    /// # Returns
6728    ///
6729    /// Diagnostic snapshot of MCP Apps wiring for the named server.
6730    ///
6731    /// <div class="warning">
6732    ///
6733    /// **Experimental.** This API is part of an experimental wire-protocol surface
6734    /// and may change or be removed in future SDK or CLI releases. Pin both the
6735    /// SDK and CLI versions if your code depends on it.
6736    ///
6737    /// </div>
6738    pub async fn diagnose(
6739        &self,
6740        params: McpAppsDiagnoseRequest,
6741    ) -> Result<McpAppsDiagnoseResult, Error> {
6742        let mut wire_params = serde_json::to_value(params)?;
6743        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6744        let _value = self
6745            .session
6746            .client()
6747            .call(rpc_methods::SESSION_MCP_APPS_DIAGNOSE, Some(wire_params))
6748            .await?;
6749        Ok(serde_json::from_value(_value)?)
6750    }
6751}
6752
6753/// `session.mcp.headers.*` RPCs.
6754#[derive(Clone, Copy)]
6755pub struct SessionRpcMcpHeaders<'a> {
6756    pub(crate) session: &'a Session,
6757}
6758
6759impl<'a> SessionRpcMcpHeaders<'a> {
6760    /// 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.
6761    ///
6762    /// Wire method: `session.mcp.headers.handlePendingHeadersRefreshRequest`.
6763    ///
6764    /// # Parameters
6765    ///
6766    /// * `params` - MCP headers refresh request id and the host response.
6767    ///
6768    /// # Returns
6769    ///
6770    /// Indicates whether the pending MCP headers refresh response was accepted.
6771    ///
6772    /// <div class="warning">
6773    ///
6774    /// **Experimental.** This API is part of an experimental wire-protocol surface
6775    /// and may change or be removed in future SDK or CLI releases. Pin both the
6776    /// SDK and CLI versions if your code depends on it.
6777    ///
6778    /// </div>
6779    pub async fn handle_pending_headers_refresh_request(
6780        &self,
6781        params: McpHeadersHandlePendingHeadersRefreshRequestRequest,
6782    ) -> Result<McpHeadersHandlePendingHeadersRefreshRequestResult, Error> {
6783        let mut wire_params = serde_json::to_value(params)?;
6784        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6785        let _value = self
6786            .session
6787            .client()
6788            .call(
6789                rpc_methods::SESSION_MCP_HEADERS_HANDLEPENDINGHEADERSREFRESHREQUEST,
6790                Some(wire_params),
6791            )
6792            .await?;
6793        Ok(serde_json::from_value(_value)?)
6794    }
6795}
6796
6797/// `session.mcp.oauth.*` RPCs.
6798#[derive(Clone, Copy)]
6799pub struct SessionRpcMcpOauth<'a> {
6800    pub(crate) session: &'a Session,
6801}
6802
6803impl<'a> SessionRpcMcpOauth<'a> {
6804    /// 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.
6805    ///
6806    /// Wire method: `session.mcp.oauth.handlePendingRequest`.
6807    ///
6808    /// # Parameters
6809    ///
6810    /// * `params` - Pending MCP OAuth request ID and host-provided token or cancellation response.
6811    ///
6812    /// # Returns
6813    ///
6814    /// Indicates whether the pending MCP OAuth response was accepted.
6815    ///
6816    /// <div class="warning">
6817    ///
6818    /// **Experimental.** This API is part of an experimental wire-protocol surface
6819    /// and may change or be removed in future SDK or CLI releases. Pin both the
6820    /// SDK and CLI versions if your code depends on it.
6821    ///
6822    /// </div>
6823    pub async fn handle_pending_request(
6824        &self,
6825        params: McpOauthHandlePendingRequest,
6826    ) -> Result<McpOauthHandlePendingResult, Error> {
6827        let mut wire_params = serde_json::to_value(params)?;
6828        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6829        let _value = self
6830            .session
6831            .client()
6832            .call(
6833                rpc_methods::SESSION_MCP_OAUTH_HANDLEPENDINGREQUEST,
6834                Some(wire_params),
6835            )
6836            .await?;
6837        Ok(serde_json::from_value(_value)?)
6838    }
6839
6840    /// Notifies the session that MCP OAuth authentication succeeded and updated credentials were persisted, so cached tool definitions can be refreshed.
6841    ///
6842    /// Wire method: `session.mcp.oauth.authenticationStateChanged`.
6843    ///
6844    /// # Parameters
6845    ///
6846    /// * `params` - Identifies the MCP server whose persisted OAuth credentials were updated.
6847    ///
6848    /// <div class="warning">
6849    ///
6850    /// **Experimental.** This API is part of an experimental wire-protocol surface
6851    /// and may change or be removed in future SDK or CLI releases. Pin both the
6852    /// SDK and CLI versions if your code depends on it.
6853    ///
6854    /// </div>
6855    pub async fn authentication_state_changed(
6856        &self,
6857        params: McpOauthAuthenticationStateChangedRequest,
6858    ) -> Result<(), Error> {
6859        let mut wire_params = serde_json::to_value(params)?;
6860        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6861        let _value = self
6862            .session
6863            .client()
6864            .call(
6865                rpc_methods::SESSION_MCP_OAUTH_AUTHENTICATIONSTATECHANGED,
6866                Some(wire_params),
6867            )
6868            .await?;
6869        Ok(())
6870    }
6871
6872    /// Starts OAuth authentication for a remote MCP server.
6873    ///
6874    /// Wire method: `session.mcp.oauth.login`.
6875    ///
6876    /// # Parameters
6877    ///
6878    /// * `params` - Remote MCP server name and optional overrides controlling reauthentication, OAuth client display name, callback success-page copy, and static OAuth client selection.
6879    ///
6880    /// # Returns
6881    ///
6882    /// OAuth authorization URL the caller should open, or empty when cached tokens already authenticated the server.
6883    ///
6884    /// <div class="warning">
6885    ///
6886    /// **Experimental.** This API is part of an experimental wire-protocol surface
6887    /// and may change or be removed in future SDK or CLI releases. Pin both the
6888    /// SDK and CLI versions if your code depends on it.
6889    ///
6890    /// </div>
6891    pub async fn login(&self, params: McpOauthLoginRequest) -> Result<McpOauthLoginResult, Error> {
6892        let mut wire_params = serde_json::to_value(params)?;
6893        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6894        let _value = self
6895            .session
6896            .client()
6897            .call(rpc_methods::SESSION_MCP_OAUTH_LOGIN, Some(wire_params))
6898            .await?;
6899        Ok(serde_json::from_value(_value)?)
6900    }
6901
6902    /// 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.
6903    ///
6904    /// Wire method: `session.mcp.oauth.probe`.
6905    ///
6906    /// # Parameters
6907    ///
6908    /// * `params` - Remote MCP server name for a passive OAuth status probe.
6909    ///
6910    /// # Returns
6911    ///
6912    /// 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.
6913    ///
6914    /// <div class="warning">
6915    ///
6916    /// **Experimental.** This API is part of an experimental wire-protocol surface
6917    /// and may change or be removed in future SDK or CLI releases. Pin both the
6918    /// SDK and CLI versions if your code depends on it.
6919    ///
6920    /// </div>
6921    pub async fn probe(&self, params: McpOauthProbeRequest) -> Result<McpOauthProbeResult, Error> {
6922        let mut wire_params = serde_json::to_value(params)?;
6923        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6924        let _value = self
6925            .session
6926            .client()
6927            .call(rpc_methods::SESSION_MCP_OAUTH_PROBE, Some(wire_params))
6928            .await?;
6929        Ok(serde_json::from_value(_value)?)
6930    }
6931
6932    /// Responds to a pending MCP OAuth authorization request by its request id.
6933    ///
6934    /// Wire method: `session.mcp.oauth.respond`.
6935    ///
6936    /// # Parameters
6937    ///
6938    /// * `params` - Pending MCP OAuth request id to respond to.
6939    ///
6940    /// # Returns
6941    ///
6942    /// Indicates whether the pending MCP OAuth response was accepted.
6943    ///
6944    /// <div class="warning">
6945    ///
6946    /// **Experimental.** This API is part of an experimental wire-protocol surface
6947    /// and may change or be removed in future SDK or CLI releases. Pin both the
6948    /// SDK and CLI versions if your code depends on it.
6949    ///
6950    /// </div>
6951    pub async fn respond(
6952        &self,
6953        params: McpOauthRespondRequest,
6954    ) -> Result<McpOauthRespondResult, Error> {
6955        let mut wire_params = serde_json::to_value(params)?;
6956        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6957        let _value = self
6958            .session
6959            .client()
6960            .call(rpc_methods::SESSION_MCP_OAUTH_RESPOND, Some(wire_params))
6961            .await?;
6962        Ok(serde_json::from_value(_value)?)
6963    }
6964}
6965
6966/// `session.mcp.resources.*` RPCs.
6967#[derive(Clone, Copy)]
6968pub struct SessionRpcMcpResources<'a> {
6969    pub(crate) session: &'a Session,
6970}
6971
6972impl<'a> SessionRpcMcpResources<'a> {
6973    /// Fetch an MCP resource from a connected server by URI (proxies MCP `resources/read`).
6974    ///
6975    /// Wire method: `session.mcp.resources.read`.
6976    ///
6977    /// # Parameters
6978    ///
6979    /// * `params` - MCP server and resource URI to fetch.
6980    ///
6981    /// # Returns
6982    ///
6983    /// Resource contents returned by the MCP server.
6984    ///
6985    /// <div class="warning">
6986    ///
6987    /// **Experimental.** This API is part of an experimental wire-protocol surface
6988    /// and may change or be removed in future SDK or CLI releases. Pin both the
6989    /// SDK and CLI versions if your code depends on it.
6990    ///
6991    /// </div>
6992    pub async fn read(
6993        &self,
6994        params: McpResourcesReadRequest,
6995    ) -> Result<McpResourcesReadResult, Error> {
6996        let mut wire_params = serde_json::to_value(params)?;
6997        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6998        let _value = self
6999            .session
7000            .client()
7001            .call(rpc_methods::SESSION_MCP_RESOURCES_READ, Some(wire_params))
7002            .await?;
7003        Ok(serde_json::from_value(_value)?)
7004    }
7005
7006    /// Enumerate one page of resources a connected MCP server exposes (proxies MCP `resources/list`). Pass `cursor` to continue from a prior result's `nextCursor`.
7007    ///
7008    /// Wire method: `session.mcp.resources.list`.
7009    ///
7010    /// # Parameters
7011    ///
7012    /// * `params` - MCP server whose resources to enumerate.
7013    ///
7014    /// # Returns
7015    ///
7016    /// One page of resources advertised by the named MCP server.
7017    ///
7018    /// <div class="warning">
7019    ///
7020    /// **Experimental.** This API is part of an experimental wire-protocol surface
7021    /// and may change or be removed in future SDK or CLI releases. Pin both the
7022    /// SDK and CLI versions if your code depends on it.
7023    ///
7024    /// </div>
7025    pub async fn list(
7026        &self,
7027        params: McpResourcesListRequest,
7028    ) -> Result<McpResourcesListResult, Error> {
7029        let mut wire_params = serde_json::to_value(params)?;
7030        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7031        let _value = self
7032            .session
7033            .client()
7034            .call(rpc_methods::SESSION_MCP_RESOURCES_LIST, Some(wire_params))
7035            .await?;
7036        Ok(serde_json::from_value(_value)?)
7037    }
7038
7039    /// 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`.
7040    ///
7041    /// Wire method: `session.mcp.resources.listTemplates`.
7042    ///
7043    /// # Parameters
7044    ///
7045    /// * `params` - MCP server whose resource templates to enumerate.
7046    ///
7047    /// # Returns
7048    ///
7049    /// One page of resource templates advertised by the named MCP server.
7050    ///
7051    /// <div class="warning">
7052    ///
7053    /// **Experimental.** This API is part of an experimental wire-protocol surface
7054    /// and may change or be removed in future SDK or CLI releases. Pin both the
7055    /// SDK and CLI versions if your code depends on it.
7056    ///
7057    /// </div>
7058    pub async fn list_templates(
7059        &self,
7060        params: McpResourcesListTemplatesRequest,
7061    ) -> Result<McpResourcesListTemplatesResult, Error> {
7062        let mut wire_params = serde_json::to_value(params)?;
7063        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7064        let _value = self
7065            .session
7066            .client()
7067            .call(
7068                rpc_methods::SESSION_MCP_RESOURCES_LISTTEMPLATES,
7069                Some(wire_params),
7070            )
7071            .await?;
7072        Ok(serde_json::from_value(_value)?)
7073    }
7074}
7075
7076/// `session.metadata.*` RPCs.
7077#[derive(Clone, Copy)]
7078pub struct SessionRpcMetadata<'a> {
7079    pub(crate) session: &'a Session,
7080}
7081
7082impl<'a> SessionRpcMetadata<'a> {
7083    /// Returns a snapshot of the session's identifying metadata, mode, agent, and remote info.
7084    ///
7085    /// Wire method: `session.metadata.snapshot`.
7086    ///
7087    /// # Returns
7088    ///
7089    /// Point-in-time snapshot of slow-changing session identifier and state fields
7090    ///
7091    /// <div class="warning">
7092    ///
7093    /// **Experimental.** This API is part of an experimental wire-protocol surface
7094    /// and may change or be removed in future SDK or CLI releases. Pin both the
7095    /// SDK and CLI versions if your code depends on it.
7096    ///
7097    /// </div>
7098    pub async fn snapshot(&self) -> Result<SessionMetadataSnapshot, Error> {
7099        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7100        let _value = self
7101            .session
7102            .client()
7103            .call(rpc_methods::SESSION_METADATA_SNAPSHOT, Some(wire_params))
7104            .await?;
7105        Ok(serde_json::from_value(_value)?)
7106    }
7107
7108    /// Reports whether the local session is currently processing user/agent messages.
7109    ///
7110    /// Wire method: `session.metadata.isProcessing`.
7111    ///
7112    /// # Returns
7113    ///
7114    /// Indicates whether the local session is currently processing a turn or background continuation.
7115    ///
7116    /// <div class="warning">
7117    ///
7118    /// **Experimental.** This API is part of an experimental wire-protocol surface
7119    /// and may change or be removed in future SDK or CLI releases. Pin both the
7120    /// SDK and CLI versions if your code depends on it.
7121    ///
7122    /// </div>
7123    pub async fn is_processing(&self) -> Result<MetadataIsProcessingResult, Error> {
7124        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7125        let _value = self
7126            .session
7127            .client()
7128            .call(
7129                rpc_methods::SESSION_METADATA_ISPROCESSING,
7130                Some(wire_params),
7131            )
7132            .await?;
7133        Ok(serde_json::from_value(_value)?)
7134    }
7135
7136    /// Returns a snapshot of activity flags for the session.
7137    ///
7138    /// Wire method: `session.metadata.activity`.
7139    ///
7140    /// # Returns
7141    ///
7142    /// Current activity flags for the session.
7143    ///
7144    /// <div class="warning">
7145    ///
7146    /// **Experimental.** This API is part of an experimental wire-protocol surface
7147    /// and may change or be removed in future SDK or CLI releases. Pin both the
7148    /// SDK and CLI versions if your code depends on it.
7149    ///
7150    /// </div>
7151    pub async fn activity(&self) -> Result<SessionActivity, Error> {
7152        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7153        let _value = self
7154            .session
7155            .client()
7156            .call(rpc_methods::SESSION_METADATA_ACTIVITY, Some(wire_params))
7157            .await?;
7158        Ok(serde_json::from_value(_value)?)
7159    }
7160
7161    /// Returns the token breakdown for the session's current context window for a given model.
7162    ///
7163    /// Wire method: `session.metadata.contextInfo`.
7164    ///
7165    /// # Parameters
7166    ///
7167    /// * `params` - Model identifier and token limits used to compute the context-info breakdown.
7168    ///
7169    /// # Returns
7170    ///
7171    /// Token breakdown for the session's current context window, or null if uninitialized.
7172    ///
7173    /// <div class="warning">
7174    ///
7175    /// **Experimental.** This API is part of an experimental wire-protocol surface
7176    /// and may change or be removed in future SDK or CLI releases. Pin both the
7177    /// SDK and CLI versions if your code depends on it.
7178    ///
7179    /// </div>
7180    pub async fn context_info(
7181        &self,
7182        params: MetadataContextInfoRequest,
7183    ) -> Result<MetadataContextInfoResult, Error> {
7184        let mut wire_params = serde_json::to_value(params)?;
7185        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7186        let _value = self
7187            .session
7188            .client()
7189            .call(rpc_methods::SESSION_METADATA_CONTEXTINFO, Some(wire_params))
7190            .await?;
7191        Ok(serde_json::from_value(_value)?)
7192    }
7193
7194    /// 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.
7195    ///
7196    /// Wire method: `session.metadata.getContextAttribution`.
7197    ///
7198    /// # Returns
7199    ///
7200    /// Per-source attribution breakdown for the session's current context window, or null if uninitialized.
7201    ///
7202    /// <div class="warning">
7203    ///
7204    /// **Experimental.** This API is part of an experimental wire-protocol surface
7205    /// and may change or be removed in future SDK or CLI releases. Pin both the
7206    /// SDK and CLI versions if your code depends on it.
7207    ///
7208    /// </div>
7209    pub async fn get_context_attribution(&self) -> Result<MetadataContextAttributionResult, Error> {
7210        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7211        let _value = self
7212            .session
7213            .client()
7214            .call(
7215                rpc_methods::SESSION_METADATA_GETCONTEXTATTRIBUTION,
7216                Some(wire_params),
7217            )
7218            .await?;
7219        Ok(serde_json::from_value(_value)?)
7220    }
7221
7222    /// 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.
7223    ///
7224    /// Wire method: `session.metadata.getContextHeaviestMessages`.
7225    ///
7226    /// # Parameters
7227    ///
7228    /// * `params` - Parameters for the heaviest-messages query.
7229    ///
7230    /// # Returns
7231    ///
7232    /// The heaviest individual messages in the session's context window, most-expensive first.
7233    ///
7234    /// <div class="warning">
7235    ///
7236    /// **Experimental.** This API is part of an experimental wire-protocol surface
7237    /// and may change or be removed in future SDK or CLI releases. Pin both the
7238    /// SDK and CLI versions if your code depends on it.
7239    ///
7240    /// </div>
7241    pub async fn get_context_heaviest_messages(
7242        &self,
7243        params: MetadataContextHeaviestMessagesRequest,
7244    ) -> Result<MetadataContextHeaviestMessagesResult, Error> {
7245        let mut wire_params = serde_json::to_value(params)?;
7246        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7247        let _value = self
7248            .session
7249            .client()
7250            .call(
7251                rpc_methods::SESSION_METADATA_GETCONTEXTHEAVIESTMESSAGES,
7252                Some(wire_params),
7253            )
7254            .await?;
7255        Ok(serde_json::from_value(_value)?)
7256    }
7257
7258    /// 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.
7259    ///
7260    /// Wire method: `session.metadata.recordContextChange`.
7261    ///
7262    /// # Parameters
7263    ///
7264    /// * `params` - Updated working-directory/git context to record on the session.
7265    ///
7266    /// # Returns
7267    ///
7268    /// 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.
7269    ///
7270    /// <div class="warning">
7271    ///
7272    /// **Experimental.** This API is part of an experimental wire-protocol surface
7273    /// and may change or be removed in future SDK or CLI releases. Pin both the
7274    /// SDK and CLI versions if your code depends on it.
7275    ///
7276    /// </div>
7277    pub async fn record_context_change(
7278        &self,
7279        params: MetadataRecordContextChangeRequest,
7280    ) -> Result<MetadataRecordContextChangeResult, Error> {
7281        let mut wire_params = serde_json::to_value(params)?;
7282        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7283        let _value = self
7284            .session
7285            .client()
7286            .call(
7287                rpc_methods::SESSION_METADATA_RECORDCONTEXTCHANGE,
7288                Some(wire_params),
7289            )
7290            .await?;
7291        Ok(serde_json::from_value(_value)?)
7292    }
7293
7294    /// 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.
7295    ///
7296    /// Wire method: `session.metadata.setWorkingDirectory`.
7297    ///
7298    /// # Parameters
7299    ///
7300    /// * `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.
7301    ///
7302    /// # Returns
7303    ///
7304    /// 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.
7305    ///
7306    /// <div class="warning">
7307    ///
7308    /// **Experimental.** This API is part of an experimental wire-protocol surface
7309    /// and may change or be removed in future SDK or CLI releases. Pin both the
7310    /// SDK and CLI versions if your code depends on it.
7311    ///
7312    /// </div>
7313    pub async fn set_working_directory(
7314        &self,
7315        params: MetadataSetWorkingDirectoryRequest,
7316    ) -> Result<MetadataSetWorkingDirectoryResult, Error> {
7317        let mut wire_params = serde_json::to_value(params)?;
7318        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7319        let _value = self
7320            .session
7321            .client()
7322            .call(
7323                rpc_methods::SESSION_METADATA_SETWORKINGDIRECTORY,
7324                Some(wire_params),
7325            )
7326            .await?;
7327        Ok(serde_json::from_value(_value)?)
7328    }
7329
7330    /// Re-tokenizes the session's existing messages against a model and returns aggregate token totals.
7331    ///
7332    /// Wire method: `session.metadata.recomputeContextTokens`.
7333    ///
7334    /// # Parameters
7335    ///
7336    /// * `params` - Model identifier to use when re-tokenizing the session's existing messages.
7337    ///
7338    /// # Returns
7339    ///
7340    /// 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.
7341    ///
7342    /// <div class="warning">
7343    ///
7344    /// **Experimental.** This API is part of an experimental wire-protocol surface
7345    /// and may change or be removed in future SDK or CLI releases. Pin both the
7346    /// SDK and CLI versions if your code depends on it.
7347    ///
7348    /// </div>
7349    pub async fn recompute_context_tokens(
7350        &self,
7351        params: MetadataRecomputeContextTokensRequest,
7352    ) -> Result<MetadataRecomputeContextTokensResult, Error> {
7353        let mut wire_params = serde_json::to_value(params)?;
7354        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7355        let _value = self
7356            .session
7357            .client()
7358            .call(
7359                rpc_methods::SESSION_METADATA_RECOMPUTECONTEXTTOKENS,
7360                Some(wire_params),
7361            )
7362            .await?;
7363        Ok(serde_json::from_value(_value)?)
7364    }
7365}
7366
7367/// `session.mode.*` RPCs.
7368#[derive(Clone, Copy)]
7369pub struct SessionRpcMode<'a> {
7370    pub(crate) session: &'a Session,
7371}
7372
7373impl<'a> SessionRpcMode<'a> {
7374    /// Gets the current agent interaction mode.
7375    ///
7376    /// Wire method: `session.mode.get`.
7377    ///
7378    /// # Returns
7379    ///
7380    /// The session mode the agent is operating in
7381    ///
7382    /// <div class="warning">
7383    ///
7384    /// **Experimental.** This API is part of an experimental wire-protocol surface
7385    /// and may change or be removed in future SDK or CLI releases. Pin both the
7386    /// SDK and CLI versions if your code depends on it.
7387    ///
7388    /// </div>
7389    pub async fn get(&self) -> Result<SessionMode, Error> {
7390        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7391        let _value = self
7392            .session
7393            .client()
7394            .call(rpc_methods::SESSION_MODE_GET, Some(wire_params))
7395            .await?;
7396        Ok(serde_json::from_value(_value)?)
7397    }
7398
7399    /// Sets the current agent interaction mode.
7400    ///
7401    /// Wire method: `session.mode.set`.
7402    ///
7403    /// # Parameters
7404    ///
7405    /// * `params` - Agent interaction mode to apply to the session.
7406    ///
7407    /// # Returns
7408    ///
7409    /// Outcome of a session mode change, including any model switch it triggered and follow-up the host must perform.
7410    ///
7411    /// <div class="warning">
7412    ///
7413    /// **Experimental.** This API is part of an experimental wire-protocol surface
7414    /// and may change or be removed in future SDK or CLI releases. Pin both the
7415    /// SDK and CLI versions if your code depends on it.
7416    ///
7417    /// </div>
7418    pub async fn set(&self, params: ModeSetRequest) -> Result<ModeSetResult, Error> {
7419        let mut wire_params = serde_json::to_value(params)?;
7420        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7421        let _value = self
7422            .session
7423            .client()
7424            .call(rpc_methods::SESSION_MODE_SET, Some(wire_params))
7425            .await?;
7426        Ok(serde_json::from_value(_value)?)
7427    }
7428}
7429
7430/// `session.model.*` RPCs.
7431#[derive(Clone, Copy)]
7432pub struct SessionRpcModel<'a> {
7433    pub(crate) session: &'a Session,
7434}
7435
7436impl<'a> SessionRpcModel<'a> {
7437    /// Gets the currently selected model for the session.
7438    ///
7439    /// Wire method: `session.model.getCurrent`.
7440    ///
7441    /// # Returns
7442    ///
7443    /// 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.
7444    ///
7445    /// <div class="warning">
7446    ///
7447    /// **Experimental.** This API is part of an experimental wire-protocol surface
7448    /// and may change or be removed in future SDK or CLI releases. Pin both the
7449    /// SDK and CLI versions if your code depends on it.
7450    ///
7451    /// </div>
7452    pub async fn get_current(&self) -> Result<CurrentModel, Error> {
7453        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7454        let _value = self
7455            .session
7456            .client()
7457            .call(rpc_methods::SESSION_MODEL_GETCURRENT, Some(wire_params))
7458            .await?;
7459        Ok(serde_json::from_value(_value)?)
7460    }
7461
7462    /// Switches the session to a model and optional reasoning configuration.
7463    ///
7464    /// Wire method: `session.model.switchTo`.
7465    ///
7466    /// # Parameters
7467    ///
7468    /// * `params` - Target model identifier and optional reasoning effort, summary, capability overrides, and context tier.
7469    ///
7470    /// # Returns
7471    ///
7472    /// The model identifier active on the session after the switch.
7473    ///
7474    /// <div class="warning">
7475    ///
7476    /// **Experimental.** This API is part of an experimental wire-protocol surface
7477    /// and may change or be removed in future SDK or CLI releases. Pin both the
7478    /// SDK and CLI versions if your code depends on it.
7479    ///
7480    /// </div>
7481    pub async fn switch_to(
7482        &self,
7483        params: ModelSwitchToRequest,
7484    ) -> Result<ModelSwitchToResult, Error> {
7485        let mut wire_params = serde_json::to_value(params)?;
7486        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7487        let _value = self
7488            .session
7489            .client()
7490            .call(rpc_methods::SESSION_MODEL_SWITCHTO, Some(wire_params))
7491            .await?;
7492        Ok(serde_json::from_value(_value)?)
7493    }
7494
7495    /// Resolves and applies organization-managed and repository model overlays.
7496    ///
7497    /// Wire method: `session.model.applyStartupOverlay`.
7498    ///
7499    /// # Parameters
7500    ///
7501    /// * `params` - Managed, repository, and CLI model overrides to overlay onto the session at startup.
7502    ///
7503    /// # Returns
7504    ///
7505    /// The model identifier active on the session after the switch.
7506    ///
7507    /// <div class="warning">
7508    ///
7509    /// **Experimental.** This API is part of an experimental wire-protocol surface
7510    /// and may change or be removed in future SDK or CLI releases. Pin both the
7511    /// SDK and CLI versions if your code depends on it.
7512    ///
7513    /// </div>
7514    pub(crate) async fn apply_startup_overlay(
7515        &self,
7516        params: ModelApplyStartupOverlayRequest,
7517    ) -> Result<ModelSwitchToResult, Error> {
7518        let mut wire_params = serde_json::to_value(params)?;
7519        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7520        let _value = self
7521            .session
7522            .client()
7523            .call(
7524                rpc_methods::SESSION_MODEL_APPLYSTARTUPOVERLAY,
7525                Some(wire_params),
7526            )
7527            .await?;
7528        Ok(serde_json::from_value(_value)?)
7529    }
7530
7531    /// Updates the session's reasoning effort without changing the selected model.
7532    ///
7533    /// Wire method: `session.model.setReasoningEffort`.
7534    ///
7535    /// # Parameters
7536    ///
7537    /// * `params` - Reasoning effort level to apply to the currently selected model.
7538    ///
7539    /// # Returns
7540    ///
7541    /// 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.
7542    ///
7543    /// <div class="warning">
7544    ///
7545    /// **Experimental.** This API is part of an experimental wire-protocol surface
7546    /// and may change or be removed in future SDK or CLI releases. Pin both the
7547    /// SDK and CLI versions if your code depends on it.
7548    ///
7549    /// </div>
7550    pub async fn set_reasoning_effort(
7551        &self,
7552        params: ModelSetReasoningEffortRequest,
7553    ) -> Result<ModelSetReasoningEffortResult, Error> {
7554        let mut wire_params = serde_json::to_value(params)?;
7555        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7556        let _value = self
7557            .session
7558            .client()
7559            .call(
7560                rpc_methods::SESSION_MODEL_SETREASONINGEFFORT,
7561                Some(wire_params),
7562            )
7563            .await?;
7564        Ok(serde_json::from_value(_value)?)
7565    }
7566
7567    /// 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.
7568    ///
7569    /// Wire method: `session.model.list`.
7570    ///
7571    /// # Returns
7572    ///
7573    /// The list of models available to this session.
7574    ///
7575    /// <div class="warning">
7576    ///
7577    /// **Experimental.** This API is part of an experimental wire-protocol surface
7578    /// and may change or be removed in future SDK or CLI releases. Pin both the
7579    /// SDK and CLI versions if your code depends on it.
7580    ///
7581    /// </div>
7582    pub async fn list(&self) -> Result<SessionModelList, Error> {
7583        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7584        let _value = self
7585            .session
7586            .client()
7587            .call(rpc_methods::SESSION_MODEL_LIST, Some(wire_params))
7588            .await?;
7589        Ok(serde_json::from_value(_value)?)
7590    }
7591
7592    /// 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.
7593    ///
7594    /// Wire method: `session.model.list`.
7595    ///
7596    /// # Parameters
7597    ///
7598    /// * `params` - Optional listing options.
7599    ///
7600    /// # Returns
7601    ///
7602    /// The list of models available to this session.
7603    ///
7604    /// <div class="warning">
7605    ///
7606    /// **Experimental.** This API is part of an experimental wire-protocol surface
7607    /// and may change or be removed in future SDK or CLI releases. Pin both the
7608    /// SDK and CLI versions if your code depends on it.
7609    ///
7610    /// </div>
7611    pub async fn list_with_params(
7612        &self,
7613        params: ModelListRequest,
7614    ) -> Result<SessionModelList, Error> {
7615        let mut wire_params = serde_json::to_value(params)?;
7616        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7617        let _value = self
7618            .session
7619            .client()
7620            .call(rpc_methods::SESSION_MODEL_LIST, Some(wire_params))
7621            .await?;
7622        Ok(serde_json::from_value(_value)?)
7623    }
7624}
7625
7626/// `session.name.*` RPCs.
7627#[derive(Clone, Copy)]
7628pub struct SessionRpcName<'a> {
7629    pub(crate) session: &'a Session,
7630}
7631
7632impl<'a> SessionRpcName<'a> {
7633    /// Gets the session's friendly name.
7634    ///
7635    /// Wire method: `session.name.get`.
7636    ///
7637    /// # Returns
7638    ///
7639    /// The session's friendly name, or null when not yet set.
7640    ///
7641    /// <div class="warning">
7642    ///
7643    /// **Experimental.** This API is part of an experimental wire-protocol surface
7644    /// and may change or be removed in future SDK or CLI releases. Pin both the
7645    /// SDK and CLI versions if your code depends on it.
7646    ///
7647    /// </div>
7648    pub async fn get(&self) -> Result<NameGetResult, Error> {
7649        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7650        let _value = self
7651            .session
7652            .client()
7653            .call(rpc_methods::SESSION_NAME_GET, Some(wire_params))
7654            .await?;
7655        Ok(serde_json::from_value(_value)?)
7656    }
7657
7658    /// Sets the session's friendly name.
7659    ///
7660    /// Wire method: `session.name.set`.
7661    ///
7662    /// # Parameters
7663    ///
7664    /// * `params` - New friendly name to apply to the session.
7665    ///
7666    /// <div class="warning">
7667    ///
7668    /// **Experimental.** This API is part of an experimental wire-protocol surface
7669    /// and may change or be removed in future SDK or CLI releases. Pin both the
7670    /// SDK and CLI versions if your code depends on it.
7671    ///
7672    /// </div>
7673    pub async fn set(&self, params: NameSetRequest) -> Result<(), Error> {
7674        let mut wire_params = serde_json::to_value(params)?;
7675        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7676        let _value = self
7677            .session
7678            .client()
7679            .call(rpc_methods::SESSION_NAME_SET, Some(wire_params))
7680            .await?;
7681        Ok(())
7682    }
7683
7684    /// Persists an auto-generated session summary as the session's name when no user-set name exists.
7685    ///
7686    /// Wire method: `session.name.setAuto`.
7687    ///
7688    /// # Parameters
7689    ///
7690    /// * `params` - Auto-generated session summary to apply as the session's name when no user-set name exists.
7691    ///
7692    /// # Returns
7693    ///
7694    /// Indicates whether the auto-generated summary was applied as the session's name.
7695    ///
7696    /// <div class="warning">
7697    ///
7698    /// **Experimental.** This API is part of an experimental wire-protocol surface
7699    /// and may change or be removed in future SDK or CLI releases. Pin both the
7700    /// SDK and CLI versions if your code depends on it.
7701    ///
7702    /// </div>
7703    pub async fn set_auto(&self, params: NameSetAutoRequest) -> Result<NameSetAutoResult, Error> {
7704        let mut wire_params = serde_json::to_value(params)?;
7705        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7706        let _value = self
7707            .session
7708            .client()
7709            .call(rpc_methods::SESSION_NAME_SETAUTO, Some(wire_params))
7710            .await?;
7711        Ok(serde_json::from_value(_value)?)
7712    }
7713}
7714
7715/// `session.options.*` RPCs.
7716#[derive(Clone, Copy)]
7717pub struct SessionRpcOptions<'a> {
7718    pub(crate) session: &'a Session,
7719}
7720
7721impl<'a> SessionRpcOptions<'a> {
7722    /// Patches the genuinely-mutable subset of session options.
7723    ///
7724    /// Wire method: `session.options.update`.
7725    ///
7726    /// # Parameters
7727    ///
7728    /// * `params` - Patch of mutable session options to apply to the running session.
7729    ///
7730    /// # Returns
7731    ///
7732    /// Indicates whether the session options patch was applied successfully.
7733    ///
7734    /// <div class="warning">
7735    ///
7736    /// **Experimental.** This API is part of an experimental wire-protocol surface
7737    /// and may change or be removed in future SDK or CLI releases. Pin both the
7738    /// SDK and CLI versions if your code depends on it.
7739    ///
7740    /// </div>
7741    pub async fn update(
7742        &self,
7743        params: SessionUpdateOptionsParams,
7744    ) -> Result<SessionUpdateOptionsResult, Error> {
7745        let mut wire_params = serde_json::to_value(params)?;
7746        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7747        let _value = self
7748            .session
7749            .client()
7750            .call(rpc_methods::SESSION_OPTIONS_UPDATE, Some(wire_params))
7751            .await?;
7752        Ok(serde_json::from_value(_value)?)
7753    }
7754}
7755
7756/// `session.permissions.*` RPCs.
7757#[derive(Clone, Copy)]
7758pub struct SessionRpcPermissions<'a> {
7759    pub(crate) session: &'a Session,
7760}
7761
7762impl<'a> SessionRpcPermissions<'a> {
7763    /// `session.permissions.folderTrust.*` sub-namespace.
7764    pub fn folder_trust(&self) -> SessionRpcPermissionsFolderTrust<'a> {
7765        SessionRpcPermissionsFolderTrust {
7766            session: self.session,
7767        }
7768    }
7769
7770    /// `session.permissions.locations.*` sub-namespace.
7771    pub fn locations(&self) -> SessionRpcPermissionsLocations<'a> {
7772        SessionRpcPermissionsLocations {
7773            session: self.session,
7774        }
7775    }
7776
7777    /// `session.permissions.paths.*` sub-namespace.
7778    pub fn paths(&self) -> SessionRpcPermissionsPaths<'a> {
7779        SessionRpcPermissionsPaths {
7780            session: self.session,
7781        }
7782    }
7783
7784    /// `session.permissions.urls.*` sub-namespace.
7785    pub fn urls(&self) -> SessionRpcPermissionsUrls<'a> {
7786        SessionRpcPermissionsUrls {
7787            session: self.session,
7788        }
7789    }
7790
7791    /// Replaces selected permission policy fields (rules, paths, URLs, exclusions, allow-all flags) on the session.
7792    ///
7793    /// Wire method: `session.permissions.configure`.
7794    ///
7795    /// # Parameters
7796    ///
7797    /// * `params` - Patch of permission policy fields to apply (omit a field to leave it unchanged).
7798    ///
7799    /// # Returns
7800    ///
7801    /// Indicates whether the operation succeeded.
7802    ///
7803    /// <div class="warning">
7804    ///
7805    /// **Experimental.** This API is part of an experimental wire-protocol surface
7806    /// and may change or be removed in future SDK or CLI releases. Pin both the
7807    /// SDK and CLI versions if your code depends on it.
7808    ///
7809    /// </div>
7810    pub async fn configure(
7811        &self,
7812        params: PermissionsConfigureParams,
7813    ) -> Result<PermissionsConfigureResult, Error> {
7814        let mut wire_params = serde_json::to_value(params)?;
7815        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7816        let _value = self
7817            .session
7818            .client()
7819            .call(
7820                rpc_methods::SESSION_PERMISSIONS_CONFIGURE,
7821                Some(wire_params),
7822            )
7823            .await?;
7824        Ok(serde_json::from_value(_value)?)
7825    }
7826
7827    /// Provides a decision for a pending tool permission request.
7828    ///
7829    /// Wire method: `session.permissions.handlePendingPermissionRequest`.
7830    ///
7831    /// # Parameters
7832    ///
7833    /// * `params` - Pending permission request ID and the decision to apply (approve/reject and scope).
7834    ///
7835    /// # Returns
7836    ///
7837    /// Indicates whether the permission decision was applied; false when the request was already resolved.
7838    ///
7839    /// <div class="warning">
7840    ///
7841    /// **Experimental.** This API is part of an experimental wire-protocol surface
7842    /// and may change or be removed in future SDK or CLI releases. Pin both the
7843    /// SDK and CLI versions if your code depends on it.
7844    ///
7845    /// </div>
7846    pub async fn handle_pending_permission_request(
7847        &self,
7848        params: PermissionDecisionRequest,
7849    ) -> Result<PermissionRequestResult, Error> {
7850        let mut wire_params = serde_json::to_value(params)?;
7851        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7852        let _value = self
7853            .session
7854            .client()
7855            .call(
7856                rpc_methods::SESSION_PERMISSIONS_HANDLEPENDINGPERMISSIONREQUEST,
7857                Some(wire_params),
7858            )
7859            .await?;
7860        Ok(serde_json::from_value(_value)?)
7861    }
7862
7863    /// Reconstructs the set of pending tool permission requests from the session's event history.
7864    ///
7865    /// Wire method: `session.permissions.pendingRequests`.
7866    ///
7867    /// # Returns
7868    ///
7869    /// List of pending permission requests reconstructed from event history.
7870    ///
7871    /// <div class="warning">
7872    ///
7873    /// **Experimental.** This API is part of an experimental wire-protocol surface
7874    /// and may change or be removed in future SDK or CLI releases. Pin both the
7875    /// SDK and CLI versions if your code depends on it.
7876    ///
7877    /// </div>
7878    pub async fn pending_requests(&self) -> Result<PendingPermissionRequestList, Error> {
7879        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7880        let _value = self
7881            .session
7882            .client()
7883            .call(
7884                rpc_methods::SESSION_PERMISSIONS_PENDINGREQUESTS,
7885                Some(wire_params),
7886            )
7887            .await?;
7888        Ok(serde_json::from_value(_value)?)
7889    }
7890
7891    /// Enables or disables automatic approval of tool permission requests for the session.
7892    ///
7893    /// Wire method: `session.permissions.setApproveAll`.
7894    ///
7895    /// # Parameters
7896    ///
7897    /// * `params` - Allow-all toggle for tool permission requests, with an optional telemetry source.
7898    ///
7899    /// # Returns
7900    ///
7901    /// Indicates whether the operation succeeded.
7902    ///
7903    /// <div class="warning">
7904    ///
7905    /// **Experimental.** This API is part of an experimental wire-protocol surface
7906    /// and may change or be removed in future SDK or CLI releases. Pin both the
7907    /// SDK and CLI versions if your code depends on it.
7908    ///
7909    /// </div>
7910    pub async fn set_approve_all(
7911        &self,
7912        params: PermissionsSetApproveAllRequest,
7913    ) -> Result<PermissionsSetApproveAllResult, Error> {
7914        let mut wire_params = serde_json::to_value(params)?;
7915        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7916        let _value = self
7917            .session
7918            .client()
7919            .call(
7920                rpc_methods::SESSION_PERMISSIONS_SETAPPROVEALL,
7921                Some(wire_params),
7922            )
7923            .await?;
7924        Ok(serde_json::from_value(_value)?)
7925    }
7926
7927    /// 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.
7928    ///
7929    /// Wire method: `session.permissions.setMode`.
7930    ///
7931    /// # Parameters
7932    ///
7933    /// * `params` - Permission mode to apply for the session.
7934    ///
7935    /// # Returns
7936    ///
7937    /// Indicates whether the requested permission mode was applied and reports the authoritative post-mutation mode.
7938    ///
7939    /// <div class="warning">
7940    ///
7941    /// **Experimental.** This API is part of an experimental wire-protocol surface
7942    /// and may change or be removed in future SDK or CLI releases. Pin both the
7943    /// SDK and CLI versions if your code depends on it.
7944    ///
7945    /// </div>
7946    pub async fn set_mode(
7947        &self,
7948        params: PermissionsSetModeRequest,
7949    ) -> Result<PermissionsSetModeResult, Error> {
7950        let mut wire_params = serde_json::to_value(params)?;
7951        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7952        let _value = self
7953            .session
7954            .client()
7955            .call(rpc_methods::SESSION_PERMISSIONS_SETMODE, Some(wire_params))
7956            .await?;
7957        Ok(serde_json::from_value(_value)?)
7958    }
7959
7960    /// Returns the current permission mode for the session.
7961    ///
7962    /// Wire method: `session.permissions.getMode`.
7963    ///
7964    /// # Returns
7965    ///
7966    /// Current permission mode.
7967    ///
7968    /// <div class="warning">
7969    ///
7970    /// **Experimental.** This API is part of an experimental wire-protocol surface
7971    /// and may change or be removed in future SDK or CLI releases. Pin both the
7972    /// SDK and CLI versions if your code depends on it.
7973    ///
7974    /// </div>
7975    pub async fn get_mode(&self) -> Result<PermissionsGetModeResult, Error> {
7976        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7977        let _value = self
7978            .session
7979            .client()
7980            .call(rpc_methods::SESSION_PERMISSIONS_GETMODE, Some(wire_params))
7981            .await?;
7982        Ok(serde_json::from_value(_value)?)
7983    }
7984
7985    /// Adds or removes session-scoped or location-scoped permission rules.
7986    ///
7987    /// Wire method: `session.permissions.modifyRules`.
7988    ///
7989    /// # Parameters
7990    ///
7991    /// * `params` - Scope and add/remove instructions for modifying session- or location-scoped permission rules.
7992    ///
7993    /// # Returns
7994    ///
7995    /// Indicates whether the operation succeeded.
7996    ///
7997    /// <div class="warning">
7998    ///
7999    /// **Experimental.** This API is part of an experimental wire-protocol surface
8000    /// and may change or be removed in future SDK or CLI releases. Pin both the
8001    /// SDK and CLI versions if your code depends on it.
8002    ///
8003    /// </div>
8004    pub async fn modify_rules(
8005        &self,
8006        params: PermissionsModifyRulesParams,
8007    ) -> Result<PermissionsModifyRulesResult, Error> {
8008        let mut wire_params = serde_json::to_value(params)?;
8009        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8010        let _value = self
8011            .session
8012            .client()
8013            .call(
8014                rpc_methods::SESSION_PERMISSIONS_MODIFYRULES,
8015                Some(wire_params),
8016            )
8017            .await?;
8018        Ok(serde_json::from_value(_value)?)
8019    }
8020
8021    /// Sets whether the client wants permission prompts bridged into session events.
8022    ///
8023    /// Wire method: `session.permissions.setRequired`.
8024    ///
8025    /// # Parameters
8026    ///
8027    /// * `params` - Toggles whether permission prompts should be bridged into session events for this client.
8028    ///
8029    /// # Returns
8030    ///
8031    /// Indicates whether the operation succeeded.
8032    ///
8033    /// <div class="warning">
8034    ///
8035    /// **Experimental.** This API is part of an experimental wire-protocol surface
8036    /// and may change or be removed in future SDK or CLI releases. Pin both the
8037    /// SDK and CLI versions if your code depends on it.
8038    ///
8039    /// </div>
8040    pub async fn set_required(
8041        &self,
8042        params: PermissionsSetRequiredRequest,
8043    ) -> Result<PermissionsSetRequiredResult, Error> {
8044        let mut wire_params = serde_json::to_value(params)?;
8045        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8046        let _value = self
8047            .session
8048            .client()
8049            .call(
8050                rpc_methods::SESSION_PERMISSIONS_SETREQUIRED,
8051                Some(wire_params),
8052            )
8053            .await?;
8054        Ok(serde_json::from_value(_value)?)
8055    }
8056
8057    /// Clears session-scoped tool permission approvals.
8058    ///
8059    /// Wire method: `session.permissions.resetSessionApprovals`.
8060    ///
8061    /// # Parameters
8062    ///
8063    /// * `params` - Clears session-scoped tool permission approvals, and optionally the location-scoped ones.
8064    ///
8065    /// # Returns
8066    ///
8067    /// Indicates whether the operation succeeded.
8068    ///
8069    /// <div class="warning">
8070    ///
8071    /// **Experimental.** This API is part of an experimental wire-protocol surface
8072    /// and may change or be removed in future SDK or CLI releases. Pin both the
8073    /// SDK and CLI versions if your code depends on it.
8074    ///
8075    /// </div>
8076    pub async fn reset_session_approvals(
8077        &self,
8078        params: PermissionsResetSessionApprovalsRequest,
8079    ) -> Result<PermissionsResetSessionApprovalsResult, Error> {
8080        let mut wire_params = serde_json::to_value(params)?;
8081        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8082        let _value = self
8083            .session
8084            .client()
8085            .call(
8086                rpc_methods::SESSION_PERMISSIONS_RESETSESSIONAPPROVALS,
8087                Some(wire_params),
8088            )
8089            .await?;
8090        Ok(serde_json::from_value(_value)?)
8091    }
8092
8093    /// Notifies the runtime that a permission prompt UI has been shown to the user.
8094    ///
8095    /// Wire method: `session.permissions.notifyPromptShown`.
8096    ///
8097    /// # Parameters
8098    ///
8099    /// * `params` - Notification payload describing the permission prompt that the client just rendered.
8100    ///
8101    /// # Returns
8102    ///
8103    /// Indicates whether the operation succeeded.
8104    ///
8105    /// <div class="warning">
8106    ///
8107    /// **Experimental.** This API is part of an experimental wire-protocol surface
8108    /// and may change or be removed in future SDK or CLI releases. Pin both the
8109    /// SDK and CLI versions if your code depends on it.
8110    ///
8111    /// </div>
8112    pub async fn notify_prompt_shown(
8113        &self,
8114        params: PermissionPromptShownNotification,
8115    ) -> Result<PermissionsNotifyPromptShownResult, Error> {
8116        let mut wire_params = serde_json::to_value(params)?;
8117        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8118        let _value = self
8119            .session
8120            .client()
8121            .call(
8122                rpc_methods::SESSION_PERMISSIONS_NOTIFYPROMPTSHOWN,
8123                Some(wire_params),
8124            )
8125            .await?;
8126        Ok(serde_json::from_value(_value)?)
8127    }
8128}
8129
8130/// `session.permissions.folderTrust.*` RPCs.
8131#[derive(Clone, Copy)]
8132pub struct SessionRpcPermissionsFolderTrust<'a> {
8133    pub(crate) session: &'a Session,
8134}
8135
8136impl<'a> SessionRpcPermissionsFolderTrust<'a> {
8137    /// Reports whether a folder is trusted according to the user's folder trust state.
8138    ///
8139    /// Wire method: `session.permissions.folderTrust.isTrusted`.
8140    ///
8141    /// # Parameters
8142    ///
8143    /// * `params` - Folder path to check for trust.
8144    ///
8145    /// # Returns
8146    ///
8147    /// Folder trust check result.
8148    ///
8149    /// <div class="warning">
8150    ///
8151    /// **Experimental.** This API is part of an experimental wire-protocol surface
8152    /// and may change or be removed in future SDK or CLI releases. Pin both the
8153    /// SDK and CLI versions if your code depends on it.
8154    ///
8155    /// </div>
8156    pub async fn is_trusted(
8157        &self,
8158        params: FolderTrustCheckParams,
8159    ) -> Result<FolderTrustCheckResult, Error> {
8160        let mut wire_params = serde_json::to_value(params)?;
8161        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8162        let _value = self
8163            .session
8164            .client()
8165            .call(
8166                rpc_methods::SESSION_PERMISSIONS_FOLDERTRUST_ISTRUSTED,
8167                Some(wire_params),
8168            )
8169            .await?;
8170        Ok(serde_json::from_value(_value)?)
8171    }
8172
8173    /// Adds a folder to the user's trusted folders list.
8174    ///
8175    /// Wire method: `session.permissions.folderTrust.addTrusted`.
8176    ///
8177    /// # Parameters
8178    ///
8179    /// * `params` - Folder path to add to trusted folders.
8180    ///
8181    /// # Returns
8182    ///
8183    /// Indicates whether the operation succeeded.
8184    ///
8185    /// <div class="warning">
8186    ///
8187    /// **Experimental.** This API is part of an experimental wire-protocol surface
8188    /// and may change or be removed in future SDK or CLI releases. Pin both the
8189    /// SDK and CLI versions if your code depends on it.
8190    ///
8191    /// </div>
8192    pub async fn add_trusted(
8193        &self,
8194        params: FolderTrustAddParams,
8195    ) -> Result<PermissionsFolderTrustAddTrustedResult, Error> {
8196        let mut wire_params = serde_json::to_value(params)?;
8197        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8198        let _value = self
8199            .session
8200            .client()
8201            .call(
8202                rpc_methods::SESSION_PERMISSIONS_FOLDERTRUST_ADDTRUSTED,
8203                Some(wire_params),
8204            )
8205            .await?;
8206        Ok(serde_json::from_value(_value)?)
8207    }
8208}
8209
8210/// `session.permissions.locations.*` RPCs.
8211#[derive(Clone, Copy)]
8212pub struct SessionRpcPermissionsLocations<'a> {
8213    pub(crate) session: &'a Session,
8214}
8215
8216impl<'a> SessionRpcPermissionsLocations<'a> {
8217    /// Resolves the permission location key and type for a working directory.
8218    ///
8219    /// Wire method: `session.permissions.locations.resolve`.
8220    ///
8221    /// # Parameters
8222    ///
8223    /// * `params` - Working directory to resolve into a location-permissions key.
8224    ///
8225    /// # Returns
8226    ///
8227    /// Resolved location-permissions key and type.
8228    ///
8229    /// <div class="warning">
8230    ///
8231    /// **Experimental.** This API is part of an experimental wire-protocol surface
8232    /// and may change or be removed in future SDK or CLI releases. Pin both the
8233    /// SDK and CLI versions if your code depends on it.
8234    ///
8235    /// </div>
8236    pub async fn resolve(
8237        &self,
8238        params: PermissionLocationResolveParams,
8239    ) -> Result<PermissionLocationResolveResult, Error> {
8240        let mut wire_params = serde_json::to_value(params)?;
8241        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8242        let _value = self
8243            .session
8244            .client()
8245            .call(
8246                rpc_methods::SESSION_PERMISSIONS_LOCATIONS_RESOLVE,
8247                Some(wire_params),
8248            )
8249            .await?;
8250        Ok(serde_json::from_value(_value)?)
8251    }
8252
8253    /// Applies persisted location-scoped tool approvals and allowed directories for a working directory to this session's permission service.
8254    ///
8255    /// Wire method: `session.permissions.locations.apply`.
8256    ///
8257    /// # Parameters
8258    ///
8259    /// * `params` - Working directory to load persisted location permissions for.
8260    ///
8261    /// # Returns
8262    ///
8263    /// Summary of persisted location permissions applied to the session.
8264    ///
8265    /// <div class="warning">
8266    ///
8267    /// **Experimental.** This API is part of an experimental wire-protocol surface
8268    /// and may change or be removed in future SDK or CLI releases. Pin both the
8269    /// SDK and CLI versions if your code depends on it.
8270    ///
8271    /// </div>
8272    pub async fn apply(
8273        &self,
8274        params: PermissionLocationApplyParams,
8275    ) -> Result<PermissionLocationApplyResult, Error> {
8276        let mut wire_params = serde_json::to_value(params)?;
8277        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8278        let _value = self
8279            .session
8280            .client()
8281            .call(
8282                rpc_methods::SESSION_PERMISSIONS_LOCATIONS_APPLY,
8283                Some(wire_params),
8284            )
8285            .await?;
8286        Ok(serde_json::from_value(_value)?)
8287    }
8288
8289    /// Persists a tool approval for a permission location and applies its rules to this session's live permission service.
8290    ///
8291    /// Wire method: `session.permissions.locations.addToolApproval`.
8292    ///
8293    /// # Parameters
8294    ///
8295    /// * `params` - Location-scoped tool approval to persist.
8296    ///
8297    /// # Returns
8298    ///
8299    /// Indicates whether the operation succeeded.
8300    ///
8301    /// <div class="warning">
8302    ///
8303    /// **Experimental.** This API is part of an experimental wire-protocol surface
8304    /// and may change or be removed in future SDK or CLI releases. Pin both the
8305    /// SDK and CLI versions if your code depends on it.
8306    ///
8307    /// </div>
8308    pub async fn add_tool_approval(
8309        &self,
8310        params: PermissionLocationAddToolApprovalParams,
8311    ) -> Result<PermissionsLocationsAddToolApprovalResult, Error> {
8312        let mut wire_params = serde_json::to_value(params)?;
8313        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8314        let _value = self
8315            .session
8316            .client()
8317            .call(
8318                rpc_methods::SESSION_PERMISSIONS_LOCATIONS_ADDTOOLAPPROVAL,
8319                Some(wire_params),
8320            )
8321            .await?;
8322        Ok(serde_json::from_value(_value)?)
8323    }
8324}
8325
8326/// `session.permissions.paths.*` RPCs.
8327#[derive(Clone, Copy)]
8328pub struct SessionRpcPermissionsPaths<'a> {
8329    pub(crate) session: &'a Session,
8330}
8331
8332impl<'a> SessionRpcPermissionsPaths<'a> {
8333    /// Returns the session's allowed directories and primary working directory.
8334    ///
8335    /// Wire method: `session.permissions.paths.list`.
8336    ///
8337    /// # Returns
8338    ///
8339    /// Snapshot of the session's allow-listed directories and primary working directory.
8340    ///
8341    /// <div class="warning">
8342    ///
8343    /// **Experimental.** This API is part of an experimental wire-protocol surface
8344    /// and may change or be removed in future SDK or CLI releases. Pin both the
8345    /// SDK and CLI versions if your code depends on it.
8346    ///
8347    /// </div>
8348    pub async fn list(&self) -> Result<PermissionPathsList, Error> {
8349        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8350        let _value = self
8351            .session
8352            .client()
8353            .call(
8354                rpc_methods::SESSION_PERMISSIONS_PATHS_LIST,
8355                Some(wire_params),
8356            )
8357            .await?;
8358        Ok(serde_json::from_value(_value)?)
8359    }
8360
8361    /// Adds a directory to the session's allow-list and activates conventional skill and agent definitions under it.
8362    ///
8363    /// Wire method: `session.permissions.paths.add`.
8364    ///
8365    /// # Parameters
8366    ///
8367    /// * `params` - Directory path to add to the session's allowed directories.
8368    ///
8369    /// # Returns
8370    ///
8371    /// Indicates whether the operation succeeded.
8372    ///
8373    /// <div class="warning">
8374    ///
8375    /// **Experimental.** This API is part of an experimental wire-protocol surface
8376    /// and may change or be removed in future SDK or CLI releases. Pin both the
8377    /// SDK and CLI versions if your code depends on it.
8378    ///
8379    /// </div>
8380    pub async fn add(
8381        &self,
8382        params: PermissionPathsAddParams,
8383    ) -> Result<PermissionsPathsAddResult, Error> {
8384        let mut wire_params = serde_json::to_value(params)?;
8385        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8386        let _value = self
8387            .session
8388            .client()
8389            .call(
8390                rpc_methods::SESSION_PERMISSIONS_PATHS_ADD,
8391                Some(wire_params),
8392            )
8393            .await?;
8394        Ok(serde_json::from_value(_value)?)
8395    }
8396
8397    /// Updates the session's primary working directory used by the permission policy.
8398    ///
8399    /// Wire method: `session.permissions.paths.updatePrimary`.
8400    ///
8401    /// # Parameters
8402    ///
8403    /// * `params` - Directory path to set as the session's new primary working directory.
8404    ///
8405    /// # Returns
8406    ///
8407    /// Indicates whether the operation succeeded.
8408    ///
8409    /// <div class="warning">
8410    ///
8411    /// **Experimental.** This API is part of an experimental wire-protocol surface
8412    /// and may change or be removed in future SDK or CLI releases. Pin both the
8413    /// SDK and CLI versions if your code depends on it.
8414    ///
8415    /// </div>
8416    pub async fn update_primary(
8417        &self,
8418        params: PermissionPathsUpdatePrimaryParams,
8419    ) -> Result<PermissionsPathsUpdatePrimaryResult, Error> {
8420        let mut wire_params = serde_json::to_value(params)?;
8421        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8422        let _value = self
8423            .session
8424            .client()
8425            .call(
8426                rpc_methods::SESSION_PERMISSIONS_PATHS_UPDATEPRIMARY,
8427                Some(wire_params),
8428            )
8429            .await?;
8430        Ok(serde_json::from_value(_value)?)
8431    }
8432
8433    /// Reports whether a path falls within any of the session's allowed directories.
8434    ///
8435    /// Wire method: `session.permissions.paths.isPathWithinAllowedDirectories`.
8436    ///
8437    /// # Parameters
8438    ///
8439    /// * `params` - Path to evaluate against the session's allowed directories.
8440    ///
8441    /// # Returns
8442    ///
8443    /// Indicates whether the supplied path is within the session's allowed directories.
8444    ///
8445    /// <div class="warning">
8446    ///
8447    /// **Experimental.** This API is part of an experimental wire-protocol surface
8448    /// and may change or be removed in future SDK or CLI releases. Pin both the
8449    /// SDK and CLI versions if your code depends on it.
8450    ///
8451    /// </div>
8452    pub async fn is_path_within_allowed_directories(
8453        &self,
8454        params: PermissionPathsAllowedCheckParams,
8455    ) -> Result<PermissionPathsAllowedCheckResult, Error> {
8456        let mut wire_params = serde_json::to_value(params)?;
8457        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8458        let _value = self
8459            .session
8460            .client()
8461            .call(
8462                rpc_methods::SESSION_PERMISSIONS_PATHS_ISPATHWITHINALLOWEDDIRECTORIES,
8463                Some(wire_params),
8464            )
8465            .await?;
8466        Ok(serde_json::from_value(_value)?)
8467    }
8468
8469    /// Reports whether a path falls within the session's workspace (primary) directory.
8470    ///
8471    /// Wire method: `session.permissions.paths.isPathWithinWorkspace`.
8472    ///
8473    /// # Parameters
8474    ///
8475    /// * `params` - Path to evaluate against the session's workspace (primary) directory.
8476    ///
8477    /// # Returns
8478    ///
8479    /// Indicates whether the supplied path is within the session's workspace directory.
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 is_path_within_workspace(
8489        &self,
8490        params: PermissionPathsWorkspaceCheckParams,
8491    ) -> Result<PermissionPathsWorkspaceCheckResult, Error> {
8492        let mut wire_params = serde_json::to_value(params)?;
8493        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8494        let _value = self
8495            .session
8496            .client()
8497            .call(
8498                rpc_methods::SESSION_PERMISSIONS_PATHS_ISPATHWITHINWORKSPACE,
8499                Some(wire_params),
8500            )
8501            .await?;
8502        Ok(serde_json::from_value(_value)?)
8503    }
8504}
8505
8506/// `session.permissions.urls.*` RPCs.
8507#[derive(Clone, Copy)]
8508pub struct SessionRpcPermissionsUrls<'a> {
8509    pub(crate) session: &'a Session,
8510}
8511
8512impl<'a> SessionRpcPermissionsUrls<'a> {
8513    /// Toggles the runtime's URL-permission policy between unrestricted and restricted modes.
8514    ///
8515    /// Wire method: `session.permissions.urls.setUnrestrictedMode`.
8516    ///
8517    /// # Parameters
8518    ///
8519    /// * `params` - Whether the URL-permission policy should run in unrestricted mode.
8520    ///
8521    /// # Returns
8522    ///
8523    /// Indicates whether the operation succeeded.
8524    ///
8525    /// <div class="warning">
8526    ///
8527    /// **Experimental.** This API is part of an experimental wire-protocol surface
8528    /// and may change or be removed in future SDK or CLI releases. Pin both the
8529    /// SDK and CLI versions if your code depends on it.
8530    ///
8531    /// </div>
8532    pub async fn set_unrestricted_mode(
8533        &self,
8534        params: PermissionUrlsSetUnrestrictedModeParams,
8535    ) -> Result<PermissionsUrlsSetUnrestrictedModeResult, Error> {
8536        let mut wire_params = serde_json::to_value(params)?;
8537        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8538        let _value = self
8539            .session
8540            .client()
8541            .call(
8542                rpc_methods::SESSION_PERMISSIONS_URLS_SETUNRESTRICTEDMODE,
8543                Some(wire_params),
8544            )
8545            .await?;
8546        Ok(serde_json::from_value(_value)?)
8547    }
8548}
8549
8550/// `session.plan.*` RPCs.
8551#[derive(Clone, Copy)]
8552pub struct SessionRpcPlan<'a> {
8553    pub(crate) session: &'a Session,
8554}
8555
8556impl<'a> SessionRpcPlan<'a> {
8557    /// Reads the session plan file from the workspace.
8558    ///
8559    /// Wire method: `session.plan.read`.
8560    ///
8561    /// # Returns
8562    ///
8563    /// Existence, contents, and resolved path of the session plan file.
8564    ///
8565    /// <div class="warning">
8566    ///
8567    /// **Experimental.** This API is part of an experimental wire-protocol surface
8568    /// and may change or be removed in future SDK or CLI releases. Pin both the
8569    /// SDK and CLI versions if your code depends on it.
8570    ///
8571    /// </div>
8572    pub async fn read(&self) -> Result<PlanReadResult, Error> {
8573        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8574        let _value = self
8575            .session
8576            .client()
8577            .call(rpc_methods::SESSION_PLAN_READ, Some(wire_params))
8578            .await?;
8579        Ok(serde_json::from_value(_value)?)
8580    }
8581
8582    /// Writes new content to the session plan file.
8583    ///
8584    /// Wire method: `session.plan.update`.
8585    ///
8586    /// # Parameters
8587    ///
8588    /// * `params` - Replacement contents to write to the session plan file.
8589    ///
8590    /// <div class="warning">
8591    ///
8592    /// **Experimental.** This API is part of an experimental wire-protocol surface
8593    /// and may change or be removed in future SDK or CLI releases. Pin both the
8594    /// SDK and CLI versions if your code depends on it.
8595    ///
8596    /// </div>
8597    pub async fn update(&self, params: PlanUpdateRequest) -> Result<(), Error> {
8598        let mut wire_params = serde_json::to_value(params)?;
8599        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8600        let _value = self
8601            .session
8602            .client()
8603            .call(rpc_methods::SESSION_PLAN_UPDATE, Some(wire_params))
8604            .await?;
8605        Ok(())
8606    }
8607
8608    /// Deletes the session plan file from the workspace.
8609    ///
8610    /// Wire method: `session.plan.delete`.
8611    ///
8612    /// <div class="warning">
8613    ///
8614    /// **Experimental.** This API is part of an experimental wire-protocol surface
8615    /// and may change or be removed in future SDK or CLI releases. Pin both the
8616    /// SDK and CLI versions if your code depends on it.
8617    ///
8618    /// </div>
8619    pub async fn delete(&self) -> Result<(), Error> {
8620        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8621        let _value = self
8622            .session
8623            .client()
8624            .call(rpc_methods::SESSION_PLAN_DELETE, Some(wire_params))
8625            .await?;
8626        Ok(())
8627    }
8628
8629    /// Reads todo rows from the session SQL database for plan rendering.
8630    ///
8631    /// Wire method: `session.plan.readSqlTodos`.
8632    ///
8633    /// # Returns
8634    ///
8635    /// Todo rows read from the session SQL database. Empty when no session database is available.
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 read_sql_todos(&self) -> Result<PlanReadSqlTodosResult, 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_PLAN_READSQLTODOS, Some(wire_params))
8650            .await?;
8651        Ok(serde_json::from_value(_value)?)
8652    }
8653
8654    /// 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.
8655    ///
8656    /// Wire method: `session.plan.readSqlTodosWithDependencies`.
8657    ///
8658    /// # Returns
8659    ///
8660    /// Todo rows + dependency edges read from the session SQL database.
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 read_sql_todos_with_dependencies(
8670        &self,
8671    ) -> Result<PlanReadSqlTodosWithDependenciesResult, Error> {
8672        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8673        let _value = self
8674            .session
8675            .client()
8676            .call(
8677                rpc_methods::SESSION_PLAN_READSQLTODOSWITHDEPENDENCIES,
8678                Some(wire_params),
8679            )
8680            .await?;
8681        Ok(serde_json::from_value(_value)?)
8682    }
8683}
8684
8685/// `session.plugins.*` RPCs.
8686#[derive(Clone, Copy)]
8687pub struct SessionRpcPlugins<'a> {
8688    pub(crate) session: &'a Session,
8689}
8690
8691impl<'a> SessionRpcPlugins<'a> {
8692    /// Lists plugins installed for the session.
8693    ///
8694    /// Wire method: `session.plugins.list`.
8695    ///
8696    /// # Returns
8697    ///
8698    /// Plugins installed for the session, with their enabled state and version metadata.
8699    ///
8700    /// <div class="warning">
8701    ///
8702    /// **Experimental.** This API is part of an experimental wire-protocol surface
8703    /// and may change or be removed in future SDK or CLI releases. Pin both the
8704    /// SDK and CLI versions if your code depends on it.
8705    ///
8706    /// </div>
8707    pub async fn list(&self) -> Result<PluginList, Error> {
8708        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8709        let _value = self
8710            .session
8711            .client()
8712            .call(rpc_methods::SESSION_PLUGINS_LIST, Some(wire_params))
8713            .await?;
8714        Ok(serde_json::from_value(_value)?)
8715    }
8716
8717    /// 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.
8718    ///
8719    /// Wire method: `session.plugins.reload`.
8720    ///
8721    /// <div class="warning">
8722    ///
8723    /// **Experimental.** This API is part of an experimental wire-protocol surface
8724    /// and may change or be removed in future SDK or CLI releases. Pin both the
8725    /// SDK and CLI versions if your code depends on it.
8726    ///
8727    /// </div>
8728    pub async fn reload(&self) -> Result<(), Error> {
8729        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8730        let _value = self
8731            .session
8732            .client()
8733            .call(rpc_methods::SESSION_PLUGINS_RELOAD, Some(wire_params))
8734            .await?;
8735        Ok(())
8736    }
8737
8738    /// 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.
8739    ///
8740    /// Wire method: `session.plugins.reload`.
8741    ///
8742    /// # Parameters
8743    ///
8744    /// * `params` - Optional flags controlling which side effects the reload performs.
8745    ///
8746    /// <div class="warning">
8747    ///
8748    /// **Experimental.** This API is part of an experimental wire-protocol surface
8749    /// and may change or be removed in future SDK or CLI releases. Pin both the
8750    /// SDK and CLI versions if your code depends on it.
8751    ///
8752    /// </div>
8753    pub async fn reload_with_params(&self, params: PluginsReloadRequest) -> Result<(), Error> {
8754        let mut wire_params = serde_json::to_value(params)?;
8755        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8756        let _value = self
8757            .session
8758            .client()
8759            .call(rpc_methods::SESSION_PLUGINS_RELOAD, Some(wire_params))
8760            .await?;
8761        Ok(())
8762    }
8763}
8764
8765/// `session.provider.*` RPCs.
8766#[derive(Clone, Copy)]
8767pub struct SessionRpcProvider<'a> {
8768    pub(crate) session: &'a Session,
8769}
8770
8771impl<'a> SessionRpcProvider<'a> {
8772    /// 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.
8773    ///
8774    /// Wire method: `session.provider.getEndpoint`.
8775    ///
8776    /// # Returns
8777    ///
8778    /// A snapshot of the provider endpoint the session is currently configured to talk to.
8779    ///
8780    /// <div class="warning">
8781    ///
8782    /// **Experimental.** This API is part of an experimental wire-protocol surface
8783    /// and may change or be removed in future SDK or CLI releases. Pin both the
8784    /// SDK and CLI versions if your code depends on it.
8785    ///
8786    /// </div>
8787    pub async fn get_endpoint(&self) -> Result<ProviderEndpoint, Error> {
8788        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8789        let _value = self
8790            .session
8791            .client()
8792            .call(rpc_methods::SESSION_PROVIDER_GETENDPOINT, Some(wire_params))
8793            .await?;
8794        Ok(serde_json::from_value(_value)?)
8795    }
8796
8797    /// 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.
8798    ///
8799    /// Wire method: `session.provider.getEndpoint`.
8800    ///
8801    /// # Parameters
8802    ///
8803    /// * `params` - Optional model identifier to scope the endpoint snapshot to.
8804    ///
8805    /// # Returns
8806    ///
8807    /// A snapshot of the provider endpoint the session is currently configured to talk to.
8808    ///
8809    /// <div class="warning">
8810    ///
8811    /// **Experimental.** This API is part of an experimental wire-protocol surface
8812    /// and may change or be removed in future SDK or CLI releases. Pin both the
8813    /// SDK and CLI versions if your code depends on it.
8814    ///
8815    /// </div>
8816    pub async fn get_endpoint_with_params(
8817        &self,
8818        params: ProviderGetEndpointRequest,
8819    ) -> Result<ProviderEndpoint, Error> {
8820        let mut wire_params = serde_json::to_value(params)?;
8821        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8822        let _value = self
8823            .session
8824            .client()
8825            .call(rpc_methods::SESSION_PROVIDER_GETENDPOINT, Some(wire_params))
8826            .await?;
8827        Ok(serde_json::from_value(_value)?)
8828    }
8829
8830    /// 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.
8831    ///
8832    /// Wire method: `session.provider.add`.
8833    ///
8834    /// # Parameters
8835    ///
8836    /// * `params` - BYOK providers and/or models to add to the session's registry at runtime. Both fields are optional; provide providers, models, or both.
8837    ///
8838    /// # Returns
8839    ///
8840    /// The selectable model entries synthesized for the models added by this call.
8841    ///
8842    /// <div class="warning">
8843    ///
8844    /// **Experimental.** This API is part of an experimental wire-protocol surface
8845    /// and may change or be removed in future SDK or CLI releases. Pin both the
8846    /// SDK and CLI versions if your code depends on it.
8847    ///
8848    /// </div>
8849    pub async fn add(&self, params: ProviderAddRequest) -> Result<ProviderAddResult, Error> {
8850        let mut wire_params = serde_json::to_value(params)?;
8851        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8852        let _value = self
8853            .session
8854            .client()
8855            .call(rpc_methods::SESSION_PROVIDER_ADD, Some(wire_params))
8856            .await?;
8857        Ok(serde_json::from_value(_value)?)
8858    }
8859}
8860
8861/// `session.queue.*` RPCs.
8862#[derive(Clone, Copy)]
8863pub struct SessionRpcQueue<'a> {
8864    pub(crate) session: &'a Session,
8865}
8866
8867impl<'a> SessionRpcQueue<'a> {
8868    /// Returns the local session's pending user-facing queued items and steering messages.
8869    ///
8870    /// Wire method: `session.queue.pendingItems`.
8871    ///
8872    /// # Returns
8873    ///
8874    /// Snapshot of the session's pending queued items and immediate-steering messages.
8875    ///
8876    /// <div class="warning">
8877    ///
8878    /// **Experimental.** This API is part of an experimental wire-protocol surface
8879    /// and may change or be removed in future SDK or CLI releases. Pin both the
8880    /// SDK and CLI versions if your code depends on it.
8881    ///
8882    /// </div>
8883    pub async fn pending_items(&self) -> Result<QueuePendingItemsResult, Error> {
8884        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8885        let _value = self
8886            .session
8887            .client()
8888            .call(rpc_methods::SESSION_QUEUE_PENDINGITEMS, Some(wire_params))
8889            .await?;
8890        Ok(serde_json::from_value(_value)?)
8891    }
8892
8893    /// Returns the internal native queue snapshot for in-process session orchestration.
8894    ///
8895    /// Wire method: `session.queue.snapshot`.
8896    ///
8897    /// # Returns
8898    ///
8899    /// Internal snapshot of native queue state for local session orchestration.
8900    ///
8901    /// <div class="warning">
8902    ///
8903    /// **Experimental.** This API is part of an experimental wire-protocol surface
8904    /// and may change or be removed in future SDK or CLI releases. Pin both the
8905    /// SDK and CLI versions if your code depends on it.
8906    ///
8907    /// </div>
8908    pub(crate) async fn snapshot(&self) -> Result<QueueSnapshotResult, Error> {
8909        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8910        let _value = self
8911            .session
8912            .client()
8913            .call(rpc_methods::SESSION_QUEUE_SNAPSHOT, Some(wire_params))
8914            .await?;
8915        Ok(serde_json::from_value(_value)?)
8916    }
8917
8918    /// Moves an addressable queued item to a public visible position.
8919    ///
8920    /// Wire method: `session.queue.moveItem`.
8921    ///
8922    /// # Parameters
8923    ///
8924    /// * `params` - Parameters for moving a queued item by stable id.
8925    ///
8926    /// # Returns
8927    ///
8928    /// Result of moving a queued item.
8929    ///
8930    /// <div class="warning">
8931    ///
8932    /// **Experimental.** This API is part of an experimental wire-protocol surface
8933    /// and may change or be removed in future SDK or CLI releases. Pin both the
8934    /// SDK and CLI versions if your code depends on it.
8935    ///
8936    /// </div>
8937    pub async fn move_item(
8938        &self,
8939        params: QueueMoveItemRequest,
8940    ) -> Result<QueueMoveItemResult, Error> {
8941        let mut wire_params = serde_json::to_value(params)?;
8942        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8943        let _value = self
8944            .session
8945            .client()
8946            .call(rpc_methods::SESSION_QUEUE_MOVEITEM, Some(wire_params))
8947            .await?;
8948        Ok(serde_json::from_value(_value)?)
8949    }
8950
8951    /// Inserts a new queued message at a public visible position.
8952    ///
8953    /// Wire method: `session.queue.insertAt`.
8954    ///
8955    /// # Parameters
8956    ///
8957    /// * `params` - Parameters for inserting a queued message at a public visible position.
8958    ///
8959    /// # Returns
8960    ///
8961    /// Result of inserting a queued message.
8962    ///
8963    /// <div class="warning">
8964    ///
8965    /// **Experimental.** This API is part of an experimental wire-protocol surface
8966    /// and may change or be removed in future SDK or CLI releases. Pin both the
8967    /// SDK and CLI versions if your code depends on it.
8968    ///
8969    /// </div>
8970    pub async fn insert_at(
8971        &self,
8972        params: QueueInsertAtRequest,
8973    ) -> Result<QueueInsertAtResult, Error> {
8974        let mut wire_params = serde_json::to_value(params)?;
8975        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8976        let _value = self
8977            .session
8978            .client()
8979            .call(rpc_methods::SESSION_QUEUE_INSERTAT, Some(wire_params))
8980            .await?;
8981        Ok(serde_json::from_value(_value)?)
8982    }
8983
8984    /// Removes an addressable queued item by its stable id.
8985    ///
8986    /// Wire method: `session.queue.removeAt`.
8987    ///
8988    /// # Parameters
8989    ///
8990    /// * `params` - Parameters for removing a queued item by stable id.
8991    ///
8992    /// # Returns
8993    ///
8994    /// Result of removing a queued item.
8995    ///
8996    /// <div class="warning">
8997    ///
8998    /// **Experimental.** This API is part of an experimental wire-protocol surface
8999    /// and may change or be removed in future SDK or CLI releases. Pin both the
9000    /// SDK and CLI versions if your code depends on it.
9001    ///
9002    /// </div>
9003    pub async fn remove_at(
9004        &self,
9005        params: QueueRemoveAtRequest,
9006    ) -> Result<QueueRemoveAtResult, Error> {
9007        let mut wire_params = serde_json::to_value(params)?;
9008        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9009        let _value = self
9010            .session
9011            .client()
9012            .call(rpc_methods::SESSION_QUEUE_REMOVEAT, Some(wire_params))
9013            .await?;
9014        Ok(serde_json::from_value(_value)?)
9015    }
9016
9017    /// Updates the text of an addressable single-message queue item.
9018    ///
9019    /// Wire method: `session.queue.updateText`.
9020    ///
9021    /// # Parameters
9022    ///
9023    /// * `params` - Parameters for editing a single queued message.
9024    ///
9025    /// # Returns
9026    ///
9027    /// Result of editing a queued message.
9028    ///
9029    /// <div class="warning">
9030    ///
9031    /// **Experimental.** This API is part of an experimental wire-protocol surface
9032    /// and may change or be removed in future SDK or CLI releases. Pin both the
9033    /// SDK and CLI versions if your code depends on it.
9034    ///
9035    /// </div>
9036    pub async fn update_text(
9037        &self,
9038        params: QueueUpdateTextRequest,
9039    ) -> Result<QueueUpdateTextResult, Error> {
9040        let mut wire_params = serde_json::to_value(params)?;
9041        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9042        let _value = self
9043            .session
9044            .client()
9045            .call(rpc_methods::SESSION_QUEUE_UPDATETEXT, Some(wire_params))
9046            .await?;
9047        Ok(serde_json::from_value(_value)?)
9048    }
9049
9050    /// Duplicates an addressable queued item immediately after its source.
9051    ///
9052    /// Wire method: `session.queue.duplicateAt`.
9053    ///
9054    /// # Parameters
9055    ///
9056    /// * `params` - Parameters for duplicating a queued item.
9057    ///
9058    /// # Returns
9059    ///
9060    /// Result of duplicating a queued item.
9061    ///
9062    /// <div class="warning">
9063    ///
9064    /// **Experimental.** This API is part of an experimental wire-protocol surface
9065    /// and may change or be removed in future SDK or CLI releases. Pin both the
9066    /// SDK and CLI versions if your code depends on it.
9067    ///
9068    /// </div>
9069    pub async fn duplicate_at(
9070        &self,
9071        params: QueueDuplicateAtRequest,
9072    ) -> Result<QueueDuplicateAtResult, Error> {
9073        let mut wire_params = serde_json::to_value(params)?;
9074        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9075        let _value = self
9076            .session
9077            .client()
9078            .call(rpc_methods::SESSION_QUEUE_DUPLICATEAT, Some(wire_params))
9079            .await?;
9080        Ok(serde_json::from_value(_value)?)
9081    }
9082
9083    /// Acquires or releases the queued-lane drain pause.
9084    ///
9085    /// Wire method: `session.queue.setDrainPaused`.
9086    ///
9087    /// # Parameters
9088    ///
9089    /// * `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.
9090    ///
9091    /// <div class="warning">
9092    ///
9093    /// **Experimental.** This API is part of an experimental wire-protocol surface
9094    /// and may change or be removed in future SDK or CLI releases. Pin both the
9095    /// SDK and CLI versions if your code depends on it.
9096    ///
9097    /// </div>
9098    pub async fn set_drain_paused(&self, params: QueueSetDrainPausedRequest) -> Result<(), Error> {
9099        let mut wire_params = serde_json::to_value(params)?;
9100        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9101        let _value = self
9102            .session
9103            .client()
9104            .call(rpc_methods::SESSION_QUEUE_SETDRAINPAUSED, Some(wire_params))
9105            .await?;
9106        Ok(())
9107    }
9108
9109    /// Moves an addressable queued message into the live turn's steering lane.
9110    ///
9111    /// Wire method: `session.queue.sendNow`.
9112    ///
9113    /// # Parameters
9114    ///
9115    /// * `params` - Parameters for steering a queued message into a live turn.
9116    ///
9117    /// # Returns
9118    ///
9119    /// Result of trying to steer a queued message into a live turn.
9120    ///
9121    /// <div class="warning">
9122    ///
9123    /// **Experimental.** This API is part of an experimental wire-protocol surface
9124    /// and may change or be removed in future SDK or CLI releases. Pin both the
9125    /// SDK and CLI versions if your code depends on it.
9126    ///
9127    /// </div>
9128    pub async fn send_now(&self, params: QueueSendNowRequest) -> Result<QueueSendNowResult, Error> {
9129        let mut wire_params = serde_json::to_value(params)?;
9130        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9131        let _value = self
9132            .session
9133            .client()
9134            .call(rpc_methods::SESSION_QUEUE_SENDNOW, Some(wire_params))
9135            .await?;
9136        Ok(serde_json::from_value(_value)?)
9137    }
9138
9139    /// Reports whether the local session has native queued work pending.
9140    ///
9141    /// Wire method: `session.queue.hasPending`.
9142    ///
9143    /// # Returns
9144    ///
9145    /// Whether the native queue has pending work.
9146    ///
9147    /// <div class="warning">
9148    ///
9149    /// **Experimental.** This API is part of an experimental wire-protocol surface
9150    /// and may change or be removed in future SDK or CLI releases. Pin both the
9151    /// SDK and CLI versions if your code depends on it.
9152    ///
9153    /// </div>
9154    pub(crate) async fn has_pending(&self) -> Result<QueueHasPendingResult, Error> {
9155        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9156        let _value = self
9157            .session
9158            .client()
9159            .call(rpc_methods::SESSION_QUEUE_HASPENDING, Some(wire_params))
9160            .await?;
9161        Ok(serde_json::from_value(_value)?)
9162    }
9163
9164    /// Begins a native deferred-idle drain when background work has quiesced.
9165    ///
9166    /// Wire method: `session.queue.beginDeferredIdleDrain`.
9167    ///
9168    /// # Parameters
9169    ///
9170    /// * `params` - Inputs for starting a deferred-idle drain.
9171    ///
9172    /// # Returns
9173    ///
9174    /// Whether a deferred-idle drain should run.
9175    ///
9176    /// <div class="warning">
9177    ///
9178    /// **Experimental.** This API is part of an experimental wire-protocol surface
9179    /// and may change or be removed in future SDK or CLI releases. Pin both the
9180    /// SDK and CLI versions if your code depends on it.
9181    ///
9182    /// </div>
9183    pub(crate) async fn begin_deferred_idle_drain(
9184        &self,
9185        params: QueueBeginDeferredIdleDrainRequest,
9186    ) -> Result<QueueBeginDeferredIdleDrainResult, Error> {
9187        let mut wire_params = serde_json::to_value(params)?;
9188        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9189        let _value = self
9190            .session
9191            .client()
9192            .call(
9193                rpc_methods::SESSION_QUEUE_BEGINDEFERREDIDLEDRAIN,
9194                Some(wire_params),
9195            )
9196            .await?;
9197        Ok(serde_json::from_value(_value)?)
9198    }
9199
9200    /// Finishes a native deferred-idle drain and reports whether to drain queue work or emit idle.
9201    ///
9202    /// Wire method: `session.queue.finishDeferredIdleDrain`.
9203    ///
9204    /// # Parameters
9205    ///
9206    /// * `params` - Inputs for completing a deferred-idle drain.
9207    ///
9208    /// # Returns
9209    ///
9210    /// Action selected by the native deferred-idle drain.
9211    ///
9212    /// <div class="warning">
9213    ///
9214    /// **Experimental.** This API is part of an experimental wire-protocol surface
9215    /// and may change or be removed in future SDK or CLI releases. Pin both the
9216    /// SDK and CLI versions if your code depends on it.
9217    ///
9218    /// </div>
9219    pub(crate) async fn finish_deferred_idle_drain(
9220        &self,
9221        params: QueueFinishDeferredIdleDrainRequest,
9222    ) -> Result<QueueFinishDeferredIdleDrainResult, Error> {
9223        let mut wire_params = serde_json::to_value(params)?;
9224        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9225        let _value = self
9226            .session
9227            .client()
9228            .call(
9229                rpc_methods::SESSION_QUEUE_FINISHDEFERREDIDLEDRAIN,
9230                Some(wire_params),
9231            )
9232            .await?;
9233        Ok(serde_json::from_value(_value)?)
9234    }
9235
9236    /// Marks session.idle as deferred by native background work state.
9237    ///
9238    /// Wire method: `session.queue.deferSessionIdle`.
9239    ///
9240    /// # Parameters
9241    ///
9242    /// * `params` - Inputs for marking session.idle deferred in native state.
9243    ///
9244    /// <div class="warning">
9245    ///
9246    /// **Experimental.** This API is part of an experimental wire-protocol surface
9247    /// and may change or be removed in future SDK or CLI releases. Pin both the
9248    /// SDK and CLI versions if your code depends on it.
9249    ///
9250    /// </div>
9251    pub(crate) async fn defer_session_idle(
9252        &self,
9253        params: QueueDeferSessionIdleRequest,
9254    ) -> Result<(), Error> {
9255        let mut wire_params = serde_json::to_value(params)?;
9256        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9257        let _value = self
9258            .session
9259            .client()
9260            .call(
9261                rpc_methods::SESSION_QUEUE_DEFERSESSIONIDLE,
9262                Some(wire_params),
9263            )
9264            .await?;
9265        Ok(())
9266    }
9267
9268    /// Removes the most recently queued user-facing item (LIFO).
9269    ///
9270    /// Wire method: `session.queue.removeMostRecent`.
9271    ///
9272    /// # Returns
9273    ///
9274    /// Indicates whether a user-facing pending item was removed.
9275    ///
9276    /// <div class="warning">
9277    ///
9278    /// **Experimental.** This API is part of an experimental wire-protocol surface
9279    /// and may change or be removed in future SDK or CLI releases. Pin both the
9280    /// SDK and CLI versions if your code depends on it.
9281    ///
9282    /// </div>
9283    pub async fn remove_most_recent(&self) -> Result<QueueRemoveMostRecentResult, Error> {
9284        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9285        let _value = self
9286            .session
9287            .client()
9288            .call(
9289                rpc_methods::SESSION_QUEUE_REMOVEMOSTRECENT,
9290                Some(wire_params),
9291            )
9292            .await?;
9293        Ok(serde_json::from_value(_value)?)
9294    }
9295
9296    /// Clears all pending queued items on the local session.
9297    ///
9298    /// Wire method: `session.queue.clear`.
9299    ///
9300    /// <div class="warning">
9301    ///
9302    /// **Experimental.** This API is part of an experimental wire-protocol surface
9303    /// and may change or be removed in future SDK or CLI releases. Pin both the
9304    /// SDK and CLI versions if your code depends on it.
9305    ///
9306    /// </div>
9307    pub async fn clear(&self) -> Result<(), Error> {
9308        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9309        let _value = self
9310            .session
9311            .client()
9312            .call(rpc_methods::SESSION_QUEUE_CLEAR, Some(wire_params))
9313            .await?;
9314        Ok(())
9315    }
9316
9317    /// Consumes queued native system notifications matching an internal filter.
9318    ///
9319    /// Wire method: `session.queue.consumeSystemNotifications`.
9320    ///
9321    /// # Parameters
9322    ///
9323    /// * `params` - Internal filter for consuming queued system notifications.
9324    ///
9325    /// # Returns
9326    ///
9327    /// Indicates whether a user-facing pending item was removed.
9328    ///
9329    /// <div class="warning">
9330    ///
9331    /// **Experimental.** This API is part of an experimental wire-protocol surface
9332    /// and may change or be removed in future SDK or CLI releases. Pin both the
9333    /// SDK and CLI versions if your code depends on it.
9334    ///
9335    /// </div>
9336    pub(crate) async fn consume_system_notifications(
9337        &self,
9338        params: QueueConsumeSystemNotificationsRequest,
9339    ) -> Result<QueueRemoveMostRecentResult, Error> {
9340        let mut wire_params = serde_json::to_value(params)?;
9341        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9342        let _value = self
9343            .session
9344            .client()
9345            .call(
9346                rpc_methods::SESSION_QUEUE_CONSUMESYSTEMNOTIFICATIONS,
9347                Some(wire_params),
9348            )
9349            .await?;
9350        Ok(serde_json::from_value(_value)?)
9351    }
9352
9353    /// Enqueues the internal resume-pending wake item when orphan handling needs a follow-up turn.
9354    ///
9355    /// Wire method: `session.queue.enqueueResumePending`.
9356    ///
9357    /// # Returns
9358    ///
9359    /// Result of enqueueing the resume-pending wake item.
9360    ///
9361    /// <div class="warning">
9362    ///
9363    /// **Experimental.** This API is part of an experimental wire-protocol surface
9364    /// and may change or be removed in future SDK or CLI releases. Pin both the
9365    /// SDK and CLI versions if your code depends on it.
9366    ///
9367    /// </div>
9368    pub(crate) async fn enqueue_resume_pending(
9369        &self,
9370    ) -> Result<QueueEnqueueResumePendingResult, Error> {
9371        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9372        let _value = self
9373            .session
9374            .client()
9375            .call(
9376                rpc_methods::SESSION_QUEUE_ENQUEUERESUMEPENDING,
9377                Some(wire_params),
9378            )
9379            .await?;
9380        Ok(serde_json::from_value(_value)?)
9381    }
9382
9383    /// Drains the native local-session work queue for in-process session orchestration.
9384    ///
9385    /// Wire method: `session.queue.process`.
9386    ///
9387    /// <div class="warning">
9388    ///
9389    /// **Experimental.** This API is part of an experimental wire-protocol surface
9390    /// and may change or be removed in future SDK or CLI releases. Pin both the
9391    /// SDK and CLI versions if your code depends on it.
9392    ///
9393    /// </div>
9394    pub(crate) async fn process(&self) -> Result<(), Error> {
9395        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9396        let _value = self
9397            .session
9398            .client()
9399            .call(rpc_methods::SESSION_QUEUE_PROCESS, Some(wire_params))
9400            .await?;
9401        Ok(())
9402    }
9403}
9404
9405/// `session.remote.*` RPCs.
9406#[derive(Clone, Copy)]
9407pub struct SessionRpcRemote<'a> {
9408    pub(crate) session: &'a Session,
9409}
9410
9411impl<'a> SessionRpcRemote<'a> {
9412    /// Enables remote session export or steering.
9413    ///
9414    /// Wire method: `session.remote.enable`.
9415    ///
9416    /// # Parameters
9417    ///
9418    /// * `params` - Optional remote session mode ("off", "export", or "on"); defaults to enabling both export and remote steering.
9419    ///
9420    /// # Returns
9421    ///
9422    /// GitHub URL for the session and a flag indicating whether remote steering is enabled.
9423    ///
9424    /// <div class="warning">
9425    ///
9426    /// **Experimental.** This API is part of an experimental wire-protocol surface
9427    /// and may change or be removed in future SDK or CLI releases. Pin both the
9428    /// SDK and CLI versions if your code depends on it.
9429    ///
9430    /// </div>
9431    pub async fn enable(&self, params: RemoteEnableRequest) -> Result<RemoteEnableResult, Error> {
9432        let mut wire_params = serde_json::to_value(params)?;
9433        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9434        let _value = self
9435            .session
9436            .client()
9437            .call(rpc_methods::SESSION_REMOTE_ENABLE, Some(wire_params))
9438            .await?;
9439        Ok(serde_json::from_value(_value)?)
9440    }
9441
9442    /// Disables remote session export and steering.
9443    ///
9444    /// Wire method: `session.remote.disable`.
9445    ///
9446    /// <div class="warning">
9447    ///
9448    /// **Experimental.** This API is part of an experimental wire-protocol surface
9449    /// and may change or be removed in future SDK or CLI releases. Pin both the
9450    /// SDK and CLI versions if your code depends on it.
9451    ///
9452    /// </div>
9453    pub async fn disable(&self) -> Result<(), Error> {
9454        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9455        let _value = self
9456            .session
9457            .client()
9458            .call(rpc_methods::SESSION_REMOTE_DISABLE, Some(wire_params))
9459            .await?;
9460        Ok(())
9461    }
9462
9463    /// Persists a remote-steerability change emitted by the host as a session event.
9464    ///
9465    /// Wire method: `session.remote.notifySteerableChanged`.
9466    ///
9467    /// # Parameters
9468    ///
9469    /// * `params` - New remote-steerability state to persist as a `session.remote_steerable_changed` event.
9470    ///
9471    /// # Returns
9472    ///
9473    /// 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.
9474    ///
9475    /// <div class="warning">
9476    ///
9477    /// **Experimental.** This API is part of an experimental wire-protocol surface
9478    /// and may change or be removed in future SDK or CLI releases. Pin both the
9479    /// SDK and CLI versions if your code depends on it.
9480    ///
9481    /// </div>
9482    pub async fn notify_steerable_changed(
9483        &self,
9484        params: RemoteNotifySteerableChangedRequest,
9485    ) -> Result<RemoteNotifySteerableChangedResult, Error> {
9486        let mut wire_params = serde_json::to_value(params)?;
9487        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9488        let _value = self
9489            .session
9490            .client()
9491            .call(
9492                rpc_methods::SESSION_REMOTE_NOTIFYSTEERABLECHANGED,
9493                Some(wire_params),
9494            )
9495            .await?;
9496        Ok(serde_json::from_value(_value)?)
9497    }
9498}
9499
9500/// `session.sandbox.*` RPCs.
9501#[derive(Clone, Copy)]
9502pub struct SessionRpcSandbox<'a> {
9503    pub(crate) session: &'a Session,
9504}
9505
9506impl<'a> SessionRpcSandbox<'a> {
9507    /// Returns whether managed policy requires sandbox enforcement and whether an enforcement failure has permanently blocked the session.
9508    ///
9509    /// Wire method: `session.sandbox.getEnforcementStatus`.
9510    ///
9511    /// # Returns
9512    ///
9513    /// Managed sandbox enforcement state for a session.
9514    ///
9515    /// <div class="warning">
9516    ///
9517    /// **Experimental.** This API is part of an experimental wire-protocol surface
9518    /// and may change or be removed in future SDK or CLI releases. Pin both the
9519    /// SDK and CLI versions if your code depends on it.
9520    ///
9521    /// </div>
9522    pub async fn get_enforcement_status(&self) -> Result<SandboxEnforcementStatus, Error> {
9523        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9524        let _value = self
9525            .session
9526            .client()
9527            .call(
9528                rpc_methods::SESSION_SANDBOX_GETENFORCEMENTSTATUS,
9529                Some(wire_params),
9530            )
9531            .await?;
9532        Ok(serde_json::from_value(_value)?)
9533    }
9534}
9535
9536/// `session.schedule.*` RPCs.
9537#[derive(Clone, Copy)]
9538pub struct SessionRpcSchedule<'a> {
9539    pub(crate) session: &'a Session,
9540}
9541
9542impl<'a> SessionRpcSchedule<'a> {
9543    /// Lists the session's currently active scheduled prompts.
9544    ///
9545    /// Wire method: `session.schedule.list`.
9546    ///
9547    /// # Returns
9548    ///
9549    /// Snapshot of the currently active recurring prompts for this session.
9550    ///
9551    /// <div class="warning">
9552    ///
9553    /// **Experimental.** This API is part of an experimental wire-protocol surface
9554    /// and may change or be removed in future SDK or CLI releases. Pin both the
9555    /// SDK and CLI versions if your code depends on it.
9556    ///
9557    /// </div>
9558    pub async fn list(&self) -> Result<ScheduleList, Error> {
9559        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9560        let _value = self
9561            .session
9562            .client()
9563            .call(rpc_methods::SESSION_SCHEDULE_LIST, Some(wire_params))
9564            .await?;
9565        Ok(serde_json::from_value(_value)?)
9566    }
9567
9568    /// Hydrates the native schedule registry from persisted session events.
9569    ///
9570    /// Wire method: `session.schedule.hydrate`.
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 hydrate(&self) -> Result<(), Error> {
9580        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9581        let _value = self
9582            .session
9583            .client()
9584            .call(rpc_methods::SESSION_SCHEDULE_HYDRATE, Some(wire_params))
9585            .await?;
9586        Ok(())
9587    }
9588
9589    /// Reports whether the session has an active self-paced scheduled prompt.
9590    ///
9591    /// Wire method: `session.schedule.hasSelfPaced`.
9592    ///
9593    /// # Returns
9594    ///
9595    /// Whether the session currently has an active self-paced schedule.
9596    ///
9597    /// <div class="warning">
9598    ///
9599    /// **Experimental.** This API is part of an experimental wire-protocol surface
9600    /// and may change or be removed in future SDK or CLI releases. Pin both the
9601    /// SDK and CLI versions if your code depends on it.
9602    ///
9603    /// </div>
9604    pub(crate) async fn has_self_paced(&self) -> Result<ScheduleHasSelfPacedResult, Error> {
9605        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9606        let _value = self
9607            .session
9608            .client()
9609            .call(
9610                rpc_methods::SESSION_SCHEDULE_HASSELFPACED,
9611                Some(wire_params),
9612            )
9613            .await?;
9614        Ok(serde_json::from_value(_value)?)
9615    }
9616
9617    /// Registers a relative-interval scheduled prompt.
9618    ///
9619    /// Wire method: `session.schedule.add`.
9620    ///
9621    /// # Parameters
9622    ///
9623    /// * `params` - Register a relative-interval scheduled prompt.
9624    ///
9625    /// # Returns
9626    ///
9627    /// Result of registering or re-arming a scheduled prompt.
9628    ///
9629    /// <div class="warning">
9630    ///
9631    /// **Experimental.** This API is part of an experimental wire-protocol surface
9632    /// and may change or be removed in future SDK or CLI releases. Pin both the
9633    /// SDK and CLI versions if your code depends on it.
9634    ///
9635    /// </div>
9636    pub(crate) async fn add(&self, params: ScheduleAddRequest) -> Result<ScheduleAddResult, Error> {
9637        let mut wire_params = serde_json::to_value(params)?;
9638        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9639        let _value = self
9640            .session
9641            .client()
9642            .call(rpc_methods::SESSION_SCHEDULE_ADD, Some(wire_params))
9643            .await?;
9644        Ok(serde_json::from_value(_value)?)
9645    }
9646
9647    /// Registers a recurring cron scheduled prompt.
9648    ///
9649    /// Wire method: `session.schedule.addCron`.
9650    ///
9651    /// # Parameters
9652    ///
9653    /// * `params` - Register a cron scheduled prompt.
9654    ///
9655    /// # Returns
9656    ///
9657    /// Result of registering or re-arming a scheduled prompt.
9658    ///
9659    /// <div class="warning">
9660    ///
9661    /// **Experimental.** This API is part of an experimental wire-protocol surface
9662    /// and may change or be removed in future SDK or CLI releases. Pin both the
9663    /// SDK and CLI versions if your code depends on it.
9664    ///
9665    /// </div>
9666    pub(crate) async fn add_cron(
9667        &self,
9668        params: ScheduleAddCronRequest,
9669    ) -> Result<ScheduleAddResult, Error> {
9670        let mut wire_params = serde_json::to_value(params)?;
9671        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9672        let _value = self
9673            .session
9674            .client()
9675            .call(rpc_methods::SESSION_SCHEDULE_ADDCRON, Some(wire_params))
9676            .await?;
9677        Ok(serde_json::from_value(_value)?)
9678    }
9679
9680    /// Registers an absolute-time scheduled prompt.
9681    ///
9682    /// Wire method: `session.schedule.addAt`.
9683    ///
9684    /// # Parameters
9685    ///
9686    /// * `params` - Register an absolute-time scheduled prompt.
9687    ///
9688    /// # Returns
9689    ///
9690    /// Result of registering or re-arming a scheduled prompt.
9691    ///
9692    /// <div class="warning">
9693    ///
9694    /// **Experimental.** This API is part of an experimental wire-protocol surface
9695    /// and may change or be removed in future SDK or CLI releases. Pin both the
9696    /// SDK and CLI versions if your code depends on it.
9697    ///
9698    /// </div>
9699    pub(crate) async fn add_at(
9700        &self,
9701        params: ScheduleAddAtRequest,
9702    ) -> Result<ScheduleAddResult, Error> {
9703        let mut wire_params = serde_json::to_value(params)?;
9704        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9705        let _value = self
9706            .session
9707            .client()
9708            .call(rpc_methods::SESSION_SCHEDULE_ADDAT, Some(wire_params))
9709            .await?;
9710        Ok(serde_json::from_value(_value)?)
9711    }
9712
9713    /// Registers a self-paced scheduled prompt.
9714    ///
9715    /// Wire method: `session.schedule.addSelfPaced`.
9716    ///
9717    /// # Parameters
9718    ///
9719    /// * `params` - Register a self-paced scheduled prompt.
9720    ///
9721    /// # Returns
9722    ///
9723    /// Result of registering or re-arming a scheduled prompt.
9724    ///
9725    /// <div class="warning">
9726    ///
9727    /// **Experimental.** This API is part of an experimental wire-protocol surface
9728    /// and may change or be removed in future SDK or CLI releases. Pin both the
9729    /// SDK and CLI versions if your code depends on it.
9730    ///
9731    /// </div>
9732    pub(crate) async fn add_self_paced(
9733        &self,
9734        params: ScheduleAddSelfPacedRequest,
9735    ) -> Result<ScheduleAddResult, Error> {
9736        let mut wire_params = serde_json::to_value(params)?;
9737        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9738        let _value = self
9739            .session
9740            .client()
9741            .call(
9742                rpc_methods::SESSION_SCHEDULE_ADDSELFPACED,
9743                Some(wire_params),
9744            )
9745            .await?;
9746        Ok(serde_json::from_value(_value)?)
9747    }
9748
9749    /// Re-arms an active self-paced scheduled prompt.
9750    ///
9751    /// Wire method: `session.schedule.rearmSelfPaced`.
9752    ///
9753    /// # Parameters
9754    ///
9755    /// * `params` - Re-arm a self-paced scheduled prompt.
9756    ///
9757    /// # Returns
9758    ///
9759    /// Result of registering or re-arming a scheduled prompt.
9760    ///
9761    /// <div class="warning">
9762    ///
9763    /// **Experimental.** This API is part of an experimental wire-protocol surface
9764    /// and may change or be removed in future SDK or CLI releases. Pin both the
9765    /// SDK and CLI versions if your code depends on it.
9766    ///
9767    /// </div>
9768    pub(crate) async fn rearm_self_paced(
9769        &self,
9770        params: ScheduleRearmSelfPacedRequest,
9771    ) -> Result<ScheduleAddResult, Error> {
9772        let mut wire_params = serde_json::to_value(params)?;
9773        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9774        let _value = self
9775            .session
9776            .client()
9777            .call(
9778                rpc_methods::SESSION_SCHEDULE_REARMSELFPACED,
9779                Some(wire_params),
9780            )
9781            .await?;
9782        Ok(serde_json::from_value(_value)?)
9783    }
9784
9785    /// Removes a scheduled prompt by id.
9786    ///
9787    /// Wire method: `session.schedule.stop`.
9788    ///
9789    /// # Parameters
9790    ///
9791    /// * `params` - Identifier of the scheduled prompt to remove.
9792    ///
9793    /// # Returns
9794    ///
9795    /// Remove a scheduled prompt by id. The result entry is omitted if the id was unknown.
9796    ///
9797    /// <div class="warning">
9798    ///
9799    /// **Experimental.** This API is part of an experimental wire-protocol surface
9800    /// and may change or be removed in future SDK or CLI releases. Pin both the
9801    /// SDK and CLI versions if your code depends on it.
9802    ///
9803    /// </div>
9804    pub async fn stop(&self, params: ScheduleStopRequest) -> Result<ScheduleStopResult, Error> {
9805        let mut wire_params = serde_json::to_value(params)?;
9806        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9807        let _value = self
9808            .session
9809            .client()
9810            .call(rpc_methods::SESSION_SCHEDULE_STOP, Some(wire_params))
9811            .await?;
9812        Ok(serde_json::from_value(_value)?)
9813    }
9814}
9815
9816/// `session.settings.*` RPCs.
9817#[derive(Clone, Copy)]
9818pub struct SessionRpcSettings<'a> {
9819    pub(crate) session: &'a Session,
9820}
9821
9822impl<'a> SessionRpcSettings<'a> {
9823    /// 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.
9824    ///
9825    /// Wire method: `session.settings.snapshot`.
9826    ///
9827    /// # Returns
9828    ///
9829    /// Redacted, serializable view of session runtime settings for SDK boundary consumers. Secrets and raw feature flags are intentionally excluded.
9830    ///
9831    /// <div class="warning">
9832    ///
9833    /// **Experimental.** This API is part of an experimental wire-protocol surface
9834    /// and may change or be removed in future SDK or CLI releases. Pin both the
9835    /// SDK and CLI versions if your code depends on it.
9836    ///
9837    /// </div>
9838    pub(crate) async fn snapshot(&self) -> Result<SessionSettingsSnapshot, Error> {
9839        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9840        let _value = self
9841            .session
9842            .client()
9843            .call(rpc_methods::SESSION_SETTINGS_SNAPSHOT, Some(wire_params))
9844            .await?;
9845        Ok(serde_json::from_value(_value)?)
9846    }
9847
9848    /// 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.
9849    ///
9850    /// Wire method: `session.settings.evaluatePredicate`.
9851    ///
9852    /// # Parameters
9853    ///
9854    /// * `params` - Named Rust-owned settings predicate to evaluate for this session.
9855    ///
9856    /// # Returns
9857    ///
9858    /// Result of evaluating a Rust-owned settings predicate.
9859    ///
9860    /// <div class="warning">
9861    ///
9862    /// **Experimental.** This API is part of an experimental wire-protocol surface
9863    /// and may change or be removed in future SDK or CLI releases. Pin both the
9864    /// SDK and CLI versions if your code depends on it.
9865    ///
9866    /// </div>
9867    pub(crate) async fn evaluate_predicate(
9868        &self,
9869        params: SessionSettingsEvaluatePredicateRequest,
9870    ) -> Result<SessionSettingsEvaluatePredicateResult, Error> {
9871        let mut wire_params = serde_json::to_value(params)?;
9872        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9873        let _value = self
9874            .session
9875            .client()
9876            .call(
9877                rpc_methods::SESSION_SETTINGS_EVALUATEPREDICATE,
9878                Some(wire_params),
9879            )
9880            .await?;
9881        Ok(serde_json::from_value(_value)?)
9882    }
9883}
9884
9885/// `session.shell.*` RPCs.
9886#[derive(Clone, Copy)]
9887pub struct SessionRpcShell<'a> {
9888    pub(crate) session: &'a Session,
9889}
9890
9891impl<'a> SessionRpcShell<'a> {
9892    /// 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.
9893    ///
9894    /// Wire method: `session.shell.exec`.
9895    ///
9896    /// # Parameters
9897    ///
9898    /// * `params` - Shell command to run, with optional working directory and timeout in milliseconds.
9899    ///
9900    /// # Returns
9901    ///
9902    /// Identifier of the spawned process, used to correlate streamed output and exit notifications.
9903    ///
9904    /// <div class="warning">
9905    ///
9906    /// **Experimental.** This API is part of an experimental wire-protocol surface
9907    /// and may change or be removed in future SDK or CLI releases. Pin both the
9908    /// SDK and CLI versions if your code depends on it.
9909    ///
9910    /// </div>
9911    pub async fn exec(&self, params: ShellExecRequest) -> Result<ShellExecResult, Error> {
9912        let mut wire_params = serde_json::to_value(params)?;
9913        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9914        let _value = self
9915            .session
9916            .client()
9917            .call(rpc_methods::SESSION_SHELL_EXEC, Some(wire_params))
9918            .await?;
9919        Ok(serde_json::from_value(_value)?)
9920    }
9921
9922    /// 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.
9923    ///
9924    /// Wire method: `session.shell.kill`.
9925    ///
9926    /// # Parameters
9927    ///
9928    /// * `params` - Identifier of a process previously returned by "shell.exec" and the signal to send.
9929    ///
9930    /// # Returns
9931    ///
9932    /// Indicates whether the signal was delivered; false if the process was unknown or already exited.
9933    ///
9934    /// <div class="warning">
9935    ///
9936    /// **Experimental.** This API is part of an experimental wire-protocol surface
9937    /// and may change or be removed in future SDK or CLI releases. Pin both the
9938    /// SDK and CLI versions if your code depends on it.
9939    ///
9940    /// </div>
9941    pub async fn kill(&self, params: ShellKillRequest) -> Result<ShellKillResult, Error> {
9942        let mut wire_params = serde_json::to_value(params)?;
9943        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9944        let _value = self
9945            .session
9946            .client()
9947            .call(rpc_methods::SESSION_SHELL_KILL, Some(wire_params))
9948            .await?;
9949        Ok(serde_json::from_value(_value)?)
9950    }
9951
9952    /// Executes a user-requested shell command through the session runtime.
9953    ///
9954    /// Wire method: `session.shell.executeUserRequested`.
9955    ///
9956    /// # Parameters
9957    ///
9958    /// * `params` - User-requested shell command and cancellation handle.
9959    ///
9960    /// # Returns
9961    ///
9962    /// Result of a user-requested shell command.
9963    ///
9964    /// <div class="warning">
9965    ///
9966    /// **Experimental.** This API is part of an experimental wire-protocol surface
9967    /// and may change or be removed in future SDK or CLI releases. Pin both the
9968    /// SDK and CLI versions if your code depends on it.
9969    ///
9970    /// </div>
9971    pub async fn execute_user_requested(
9972        &self,
9973        params: ShellExecuteUserRequestedRequest,
9974    ) -> Result<UserRequestedShellCommandResult, Error> {
9975        let mut wire_params = serde_json::to_value(params)?;
9976        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9977        let _value = self
9978            .session
9979            .client()
9980            .call(
9981                rpc_methods::SESSION_SHELL_EXECUTEUSERREQUESTED,
9982                Some(wire_params),
9983            )
9984            .await?;
9985        Ok(serde_json::from_value(_value)?)
9986    }
9987
9988    /// Cancels a user-requested shell command by request ID.
9989    ///
9990    /// Wire method: `session.shell.cancelUserRequested`.
9991    ///
9992    /// # Parameters
9993    ///
9994    /// * `params` - User-requested shell execution cancellation handle.
9995    ///
9996    /// # Returns
9997    ///
9998    /// Cancellation result for a user-requested shell command.
9999    ///
10000    /// <div class="warning">
10001    ///
10002    /// **Experimental.** This API is part of an experimental wire-protocol surface
10003    /// and may change or be removed in future SDK or CLI releases. Pin both the
10004    /// SDK and CLI versions if your code depends on it.
10005    ///
10006    /// </div>
10007    pub async fn cancel_user_requested(
10008        &self,
10009        params: ShellCancelUserRequestedRequest,
10010    ) -> Result<CancelUserRequestedShellCommandResult, Error> {
10011        let mut wire_params = serde_json::to_value(params)?;
10012        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10013        let _value = self
10014            .session
10015            .client()
10016            .call(
10017                rpc_methods::SESSION_SHELL_CANCELUSERREQUESTED,
10018                Some(wire_params),
10019            )
10020            .await?;
10021        Ok(serde_json::from_value(_value)?)
10022    }
10023}
10024
10025/// `session.skills.*` RPCs.
10026#[derive(Clone, Copy)]
10027pub struct SessionRpcSkills<'a> {
10028    pub(crate) session: &'a Session,
10029}
10030
10031impl<'a> SessionRpcSkills<'a> {
10032    /// Lists skills available to the session.
10033    ///
10034    /// Wire method: `session.skills.list`.
10035    ///
10036    /// # Returns
10037    ///
10038    /// Skills available to the session, with their enabled state.
10039    ///
10040    /// <div class="warning">
10041    ///
10042    /// **Experimental.** This API is part of an experimental wire-protocol surface
10043    /// and may change or be removed in future SDK or CLI releases. Pin both the
10044    /// SDK and CLI versions if your code depends on it.
10045    ///
10046    /// </div>
10047    pub async fn list(&self) -> Result<SkillList, Error> {
10048        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10049        let _value = self
10050            .session
10051            .client()
10052            .call(rpc_methods::SESSION_SKILLS_LIST, Some(wire_params))
10053            .await?;
10054        Ok(serde_json::from_value(_value)?)
10055    }
10056
10057    /// Returns the skills that have been invoked during this session.
10058    ///
10059    /// Wire method: `session.skills.getInvoked`.
10060    ///
10061    /// # Returns
10062    ///
10063    /// Skills invoked during this session, ordered by invocation time (most recent last).
10064    ///
10065    /// <div class="warning">
10066    ///
10067    /// **Experimental.** This API is part of an experimental wire-protocol surface
10068    /// and may change or be removed in future SDK or CLI releases. Pin both the
10069    /// SDK and CLI versions if your code depends on it.
10070    ///
10071    /// </div>
10072    pub async fn get_invoked(&self) -> Result<SkillsGetInvokedResult, Error> {
10073        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10074        let _value = self
10075            .session
10076            .client()
10077            .call(rpc_methods::SESSION_SKILLS_GETINVOKED, Some(wire_params))
10078            .await?;
10079        Ok(serde_json::from_value(_value)?)
10080    }
10081
10082    /// Enables a skill for the session.
10083    ///
10084    /// Wire method: `session.skills.enable`.
10085    ///
10086    /// # Parameters
10087    ///
10088    /// * `params` - Name of the skill to enable for the session.
10089    ///
10090    /// <div class="warning">
10091    ///
10092    /// **Experimental.** This API is part of an experimental wire-protocol surface
10093    /// and may change or be removed in future SDK or CLI releases. Pin both the
10094    /// SDK and CLI versions if your code depends on it.
10095    ///
10096    /// </div>
10097    pub async fn enable(&self, params: SkillsEnableRequest) -> Result<(), Error> {
10098        let mut wire_params = serde_json::to_value(params)?;
10099        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10100        let _value = self
10101            .session
10102            .client()
10103            .call(rpc_methods::SESSION_SKILLS_ENABLE, Some(wire_params))
10104            .await?;
10105        Ok(())
10106    }
10107
10108    /// Disables a skill for the session.
10109    ///
10110    /// Wire method: `session.skills.disable`.
10111    ///
10112    /// # Parameters
10113    ///
10114    /// * `params` - Name of the skill to disable for the session.
10115    ///
10116    /// <div class="warning">
10117    ///
10118    /// **Experimental.** This API is part of an experimental wire-protocol surface
10119    /// and may change or be removed in future SDK or CLI releases. Pin both the
10120    /// SDK and CLI versions if your code depends on it.
10121    ///
10122    /// </div>
10123    pub async fn disable(&self, params: SkillsDisableRequest) -> Result<(), Error> {
10124        let mut wire_params = serde_json::to_value(params)?;
10125        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10126        let _value = self
10127            .session
10128            .client()
10129            .call(rpc_methods::SESSION_SKILLS_DISABLE, Some(wire_params))
10130            .await?;
10131        Ok(())
10132    }
10133
10134    /// Reloads skill definitions for the session.
10135    ///
10136    /// Wire method: `session.skills.reload`.
10137    ///
10138    /// # Returns
10139    ///
10140    /// Diagnostics from reloading skill definitions, with warnings and errors as separate lists.
10141    ///
10142    /// <div class="warning">
10143    ///
10144    /// **Experimental.** This API is part of an experimental wire-protocol surface
10145    /// and may change or be removed in future SDK or CLI releases. Pin both the
10146    /// SDK and CLI versions if your code depends on it.
10147    ///
10148    /// </div>
10149    pub async fn reload(&self) -> Result<SkillsLoadDiagnostics, Error> {
10150        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10151        let _value = self
10152            .session
10153            .client()
10154            .call(rpc_methods::SESSION_SKILLS_RELOAD, Some(wire_params))
10155            .await?;
10156        Ok(serde_json::from_value(_value)?)
10157    }
10158
10159    /// Ensures the session's skill definitions have been loaded from disk.
10160    ///
10161    /// Wire method: `session.skills.ensureLoaded`.
10162    ///
10163    /// <div class="warning">
10164    ///
10165    /// **Experimental.** This API is part of an experimental wire-protocol surface
10166    /// and may change or be removed in future SDK or CLI releases. Pin both the
10167    /// SDK and CLI versions if your code depends on it.
10168    ///
10169    /// </div>
10170    pub async fn ensure_loaded(&self) -> Result<(), Error> {
10171        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10172        let _value = self
10173            .session
10174            .client()
10175            .call(rpc_methods::SESSION_SKILLS_ENSURELOADED, Some(wire_params))
10176            .await?;
10177        Ok(())
10178    }
10179}
10180
10181/// `session.tasks.*` RPCs.
10182#[derive(Clone, Copy)]
10183pub struct SessionRpcTasks<'a> {
10184    pub(crate) session: &'a Session,
10185}
10186
10187impl<'a> SessionRpcTasks<'a> {
10188    /// Starts a background agent task in the session.
10189    ///
10190    /// Wire method: `session.tasks.startAgent`.
10191    ///
10192    /// # Parameters
10193    ///
10194    /// * `params` - Agent type, prompt, name, and optional description and model override for the new task.
10195    ///
10196    /// # Returns
10197    ///
10198    /// Identifier assigned to the newly started background agent task.
10199    ///
10200    /// <div class="warning">
10201    ///
10202    /// **Experimental.** This API is part of an experimental wire-protocol surface
10203    /// and may change or be removed in future SDK or CLI releases. Pin both the
10204    /// SDK and CLI versions if your code depends on it.
10205    ///
10206    /// </div>
10207    pub async fn start_agent(
10208        &self,
10209        params: TasksStartAgentRequest,
10210    ) -> Result<TasksStartAgentResult, Error> {
10211        let mut wire_params = serde_json::to_value(params)?;
10212        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10213        let _value = self
10214            .session
10215            .client()
10216            .call(rpc_methods::SESSION_TASKS_STARTAGENT, Some(wire_params))
10217            .await?;
10218        Ok(serde_json::from_value(_value)?)
10219    }
10220
10221    /// Lists background tasks tracked by the session.
10222    ///
10223    /// Wire method: `session.tasks.list`.
10224    ///
10225    /// # Returns
10226    ///
10227    /// Background tasks currently tracked by the session.
10228    ///
10229    /// <div class="warning">
10230    ///
10231    /// **Experimental.** This API is part of an experimental wire-protocol surface
10232    /// and may change or be removed in future SDK or CLI releases. Pin both the
10233    /// SDK and CLI versions if your code depends on it.
10234    ///
10235    /// </div>
10236    pub async fn list(&self) -> Result<TaskList, Error> {
10237        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10238        let _value = self
10239            .session
10240            .client()
10241            .call(rpc_methods::SESSION_TASKS_LIST, Some(wire_params))
10242            .await?;
10243        Ok(serde_json::from_value(_value)?)
10244    }
10245
10246    /// Refreshes metadata for any detached background shells the runtime knows about.
10247    ///
10248    /// Wire method: `session.tasks.refresh`.
10249    ///
10250    /// # Returns
10251    ///
10252    /// 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.
10253    ///
10254    /// <div class="warning">
10255    ///
10256    /// **Experimental.** This API is part of an experimental wire-protocol surface
10257    /// and may change or be removed in future SDK or CLI releases. Pin both the
10258    /// SDK and CLI versions if your code depends on it.
10259    ///
10260    /// </div>
10261    pub async fn refresh(&self) -> Result<TasksRefreshResult, Error> {
10262        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10263        let _value = self
10264            .session
10265            .client()
10266            .call(rpc_methods::SESSION_TASKS_REFRESH, Some(wire_params))
10267            .await?;
10268        Ok(serde_json::from_value(_value)?)
10269    }
10270
10271    /// Waits for all in-flight background tasks and any follow-up turns to settle.
10272    ///
10273    /// Wire method: `session.tasks.waitForPending`.
10274    ///
10275    /// # Returns
10276    ///
10277    /// 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).
10278    ///
10279    /// <div class="warning">
10280    ///
10281    /// **Experimental.** This API is part of an experimental wire-protocol surface
10282    /// and may change or be removed in future SDK or CLI releases. Pin both the
10283    /// SDK and CLI versions if your code depends on it.
10284    ///
10285    /// </div>
10286    pub async fn wait_for_pending(&self) -> Result<TasksWaitForPendingResult, Error> {
10287        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10288        let _value = self
10289            .session
10290            .client()
10291            .call(rpc_methods::SESSION_TASKS_WAITFORPENDING, Some(wire_params))
10292            .await?;
10293        Ok(serde_json::from_value(_value)?)
10294    }
10295
10296    /// Returns progress information for a background task by ID.
10297    ///
10298    /// Wire method: `session.tasks.getProgress`.
10299    ///
10300    /// # Parameters
10301    ///
10302    /// * `params` - Identifier of the background task to fetch progress for.
10303    ///
10304    /// # Returns
10305    ///
10306    /// Progress information for the task, or null when no task with that ID is tracked.
10307    ///
10308    /// <div class="warning">
10309    ///
10310    /// **Experimental.** This API is part of an experimental wire-protocol surface
10311    /// and may change or be removed in future SDK or CLI releases. Pin both the
10312    /// SDK and CLI versions if your code depends on it.
10313    ///
10314    /// </div>
10315    pub async fn get_progress(
10316        &self,
10317        params: TasksGetProgressRequest,
10318    ) -> Result<TasksGetProgressResult, Error> {
10319        let mut wire_params = serde_json::to_value(params)?;
10320        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10321        let _value = self
10322            .session
10323            .client()
10324            .call(rpc_methods::SESSION_TASKS_GETPROGRESS, Some(wire_params))
10325            .await?;
10326        Ok(serde_json::from_value(_value)?)
10327    }
10328
10329    /// Returns the first sync-waiting task that can currently be promoted to background mode.
10330    ///
10331    /// Wire method: `session.tasks.getCurrentPromotable`.
10332    ///
10333    /// # Returns
10334    ///
10335    /// The first sync-waiting task that can currently be promoted to background mode.
10336    ///
10337    /// <div class="warning">
10338    ///
10339    /// **Experimental.** This API is part of an experimental wire-protocol surface
10340    /// and may change or be removed in future SDK or CLI releases. Pin both the
10341    /// SDK and CLI versions if your code depends on it.
10342    ///
10343    /// </div>
10344    pub async fn get_current_promotable(&self) -> Result<TasksGetCurrentPromotableResult, Error> {
10345        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10346        let _value = self
10347            .session
10348            .client()
10349            .call(
10350                rpc_methods::SESSION_TASKS_GETCURRENTPROMOTABLE,
10351                Some(wire_params),
10352            )
10353            .await?;
10354        Ok(serde_json::from_value(_value)?)
10355    }
10356
10357    /// Promotes an eligible synchronously-waited task so it continues running in the background.
10358    ///
10359    /// Wire method: `session.tasks.promoteToBackground`.
10360    ///
10361    /// # Parameters
10362    ///
10363    /// * `params` - Identifier of the task to promote to background mode.
10364    ///
10365    /// # Returns
10366    ///
10367    /// Indicates whether the task was successfully promoted to background mode.
10368    ///
10369    /// <div class="warning">
10370    ///
10371    /// **Experimental.** This API is part of an experimental wire-protocol surface
10372    /// and may change or be removed in future SDK or CLI releases. Pin both the
10373    /// SDK and CLI versions if your code depends on it.
10374    ///
10375    /// </div>
10376    pub async fn promote_to_background(
10377        &self,
10378        params: TasksPromoteToBackgroundRequest,
10379    ) -> Result<TasksPromoteToBackgroundResult, Error> {
10380        let mut wire_params = serde_json::to_value(params)?;
10381        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10382        let _value = self
10383            .session
10384            .client()
10385            .call(
10386                rpc_methods::SESSION_TASKS_PROMOTETOBACKGROUND,
10387                Some(wire_params),
10388            )
10389            .await?;
10390        Ok(serde_json::from_value(_value)?)
10391    }
10392
10393    /// Atomically promotes the first promotable sync-waiting task to background mode and returns it.
10394    ///
10395    /// Wire method: `session.tasks.promoteCurrentToBackground`.
10396    ///
10397    /// # Returns
10398    ///
10399    /// The promoted task as it now exists in background mode, omitted if no promotable task was waiting.
10400    ///
10401    /// <div class="warning">
10402    ///
10403    /// **Experimental.** This API is part of an experimental wire-protocol surface
10404    /// and may change or be removed in future SDK or CLI releases. Pin both the
10405    /// SDK and CLI versions if your code depends on it.
10406    ///
10407    /// </div>
10408    pub async fn promote_current_to_background(
10409        &self,
10410    ) -> Result<TasksPromoteCurrentToBackgroundResult, Error> {
10411        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10412        let _value = self
10413            .session
10414            .client()
10415            .call(
10416                rpc_methods::SESSION_TASKS_PROMOTECURRENTTOBACKGROUND,
10417                Some(wire_params),
10418            )
10419            .await?;
10420        Ok(serde_json::from_value(_value)?)
10421    }
10422
10423    /// Cancels a background task.
10424    ///
10425    /// Wire method: `session.tasks.cancel`.
10426    ///
10427    /// # Parameters
10428    ///
10429    /// * `params` - Identifier of the background task to cancel.
10430    ///
10431    /// # Returns
10432    ///
10433    /// Indicates whether the background task was successfully cancelled.
10434    ///
10435    /// <div class="warning">
10436    ///
10437    /// **Experimental.** This API is part of an experimental wire-protocol surface
10438    /// and may change or be removed in future SDK or CLI releases. Pin both the
10439    /// SDK and CLI versions if your code depends on it.
10440    ///
10441    /// </div>
10442    pub async fn cancel(&self, params: TasksCancelRequest) -> Result<TasksCancelResult, Error> {
10443        let mut wire_params = serde_json::to_value(params)?;
10444        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10445        let _value = self
10446            .session
10447            .client()
10448            .call(rpc_methods::SESSION_TASKS_CANCEL, Some(wire_params))
10449            .await?;
10450        Ok(serde_json::from_value(_value)?)
10451    }
10452
10453    /// Removes a completed or cancelled background task from tracking.
10454    ///
10455    /// Wire method: `session.tasks.remove`.
10456    ///
10457    /// # Parameters
10458    ///
10459    /// * `params` - Identifier of the completed or cancelled task to remove from tracking.
10460    ///
10461    /// # Returns
10462    ///
10463    /// Indicates whether the task was removed. False when the task does not exist or is still running/idle.
10464    ///
10465    /// <div class="warning">
10466    ///
10467    /// **Experimental.** This API is part of an experimental wire-protocol surface
10468    /// and may change or be removed in future SDK or CLI releases. Pin both the
10469    /// SDK and CLI versions if your code depends on it.
10470    ///
10471    /// </div>
10472    pub async fn remove(&self, params: TasksRemoveRequest) -> Result<TasksRemoveResult, Error> {
10473        let mut wire_params = serde_json::to_value(params)?;
10474        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10475        let _value = self
10476            .session
10477            .client()
10478            .call(rpc_methods::SESSION_TASKS_REMOVE, Some(wire_params))
10479            .await?;
10480        Ok(serde_json::from_value(_value)?)
10481    }
10482
10483    /// Sends a message to a background agent task.
10484    ///
10485    /// Wire method: `session.tasks.sendMessage`.
10486    ///
10487    /// # Parameters
10488    ///
10489    /// * `params` - Identifier of the target agent task, message content, and optional sender agent ID.
10490    ///
10491    /// # Returns
10492    ///
10493    /// Indicates whether the message was delivered, with an error message when delivery failed.
10494    ///
10495    /// <div class="warning">
10496    ///
10497    /// **Experimental.** This API is part of an experimental wire-protocol surface
10498    /// and may change or be removed in future SDK or CLI releases. Pin both the
10499    /// SDK and CLI versions if your code depends on it.
10500    ///
10501    /// </div>
10502    pub async fn send_message(
10503        &self,
10504        params: TasksSendMessageRequest,
10505    ) -> Result<TasksSendMessageResult, Error> {
10506        let mut wire_params = serde_json::to_value(params)?;
10507        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10508        let _value = self
10509            .session
10510            .client()
10511            .call(rpc_methods::SESSION_TASKS_SENDMESSAGE, Some(wire_params))
10512            .await?;
10513        Ok(serde_json::from_value(_value)?)
10514    }
10515}
10516
10517/// `session.telemetry.*` RPCs.
10518#[derive(Clone, Copy)]
10519pub struct SessionRpcTelemetry<'a> {
10520    pub(crate) session: &'a Session,
10521}
10522
10523impl<'a> SessionRpcTelemetry<'a> {
10524    /// Gets the telemetry engagement ID currently associated with the session, when available.
10525    ///
10526    /// Wire method: `session.telemetry.getEngagementId`.
10527    ///
10528    /// # Returns
10529    ///
10530    /// Telemetry engagement ID for the session, when available.
10531    ///
10532    /// <div class="warning">
10533    ///
10534    /// **Experimental.** This API is part of an experimental wire-protocol surface
10535    /// and may change or be removed in future SDK or CLI releases. Pin both the
10536    /// SDK and CLI versions if your code depends on it.
10537    ///
10538    /// </div>
10539    pub async fn get_engagement_id(&self) -> Result<SessionTelemetryEngagement, Error> {
10540        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10541        let _value = self
10542            .session
10543            .client()
10544            .call(
10545                rpc_methods::SESSION_TELEMETRY_GETENGAGEMENTID,
10546                Some(wire_params),
10547            )
10548            .await?;
10549        Ok(serde_json::from_value(_value)?)
10550    }
10551
10552    /// Sets feature override key/value pairs to attach to subsequent telemetry events for the session.
10553    ///
10554    /// Wire method: `session.telemetry.setFeatureOverrides`.
10555    ///
10556    /// # Parameters
10557    ///
10558    /// * `params` - Feature override key/value pairs to attach to subsequent telemetry events from this session.
10559    ///
10560    /// <div class="warning">
10561    ///
10562    /// **Experimental.** This API is part of an experimental wire-protocol surface
10563    /// and may change or be removed in future SDK or CLI releases. Pin both the
10564    /// SDK and CLI versions if your code depends on it.
10565    ///
10566    /// </div>
10567    pub async fn set_feature_overrides(
10568        &self,
10569        params: TelemetrySetFeatureOverridesRequest,
10570    ) -> Result<(), Error> {
10571        let mut wire_params = serde_json::to_value(params)?;
10572        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10573        let _value = self
10574            .session
10575            .client()
10576            .call(
10577                rpc_methods::SESSION_TELEMETRY_SETFEATUREOVERRIDES,
10578                Some(wire_params),
10579            )
10580            .await?;
10581        Ok(())
10582    }
10583}
10584
10585/// `session.tools.*` RPCs.
10586#[derive(Clone, Copy)]
10587pub struct SessionRpcTools<'a> {
10588    pub(crate) session: &'a Session,
10589}
10590
10591impl<'a> SessionRpcTools<'a> {
10592    /// Executes one tool from the session's currently offered tool set through the native invocation pipeline.
10593    ///
10594    /// Wire method: `session.tools.execute`.
10595    ///
10596    /// # Parameters
10597    ///
10598    /// * `params` - A tool name and arguments to execute through the session's native invocation pipeline.
10599    ///
10600    /// # Returns
10601    ///
10602    /// Canonical result returned by a session tool.
10603    ///
10604    /// <div class="warning">
10605    ///
10606    /// **Experimental.** This API is part of an experimental wire-protocol surface
10607    /// and may change or be removed in future SDK or CLI releases. Pin both the
10608    /// SDK and CLI versions if your code depends on it.
10609    ///
10610    /// </div>
10611    pub async fn execute(&self, params: ToolsExecuteRequest) -> Result<ToolResult, Error> {
10612        let mut wire_params = serde_json::to_value(params)?;
10613        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10614        let _value = self
10615            .session
10616            .client()
10617            .call(rpc_methods::SESSION_TOOLS_EXECUTE, Some(wire_params))
10618            .await?;
10619        Ok(serde_json::from_value(_value)?)
10620    }
10621
10622    /// Returns the Rust-owned built-in tool descriptors used to construct the session's offered tool set.
10623    ///
10624    /// Wire method: `session.tools.getBuiltinDescriptors`.
10625    ///
10626    /// # Parameters
10627    ///
10628    /// * `params` - Options controlling how Rust-owned built-in tool descriptors are materialized.
10629    ///
10630    /// # Returns
10631    ///
10632    /// Rust-owned built-in tool descriptors for the session.
10633    ///
10634    /// <div class="warning">
10635    ///
10636    /// **Experimental.** This API is part of an experimental wire-protocol surface
10637    /// and may change or be removed in future SDK or CLI releases. Pin both the
10638    /// SDK and CLI versions if your code depends on it.
10639    ///
10640    /// </div>
10641    pub async fn get_builtin_descriptors(
10642        &self,
10643        params: ToolsGetBuiltinDescriptorsRequest,
10644    ) -> Result<ToolsGetBuiltinDescriptorsResult, Error> {
10645        let mut wire_params = serde_json::to_value(params)?;
10646        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10647        let _value = self
10648            .session
10649            .client()
10650            .call(
10651                rpc_methods::SESSION_TOOLS_GETBUILTINDESCRIPTORS,
10652                Some(wire_params),
10653            )
10654            .await?;
10655        Ok(serde_json::from_value(_value)?)
10656    }
10657
10658    /// Projects a completed task_complete tool call into its label-safe session event payload.
10659    ///
10660    /// Wire method: `session.tools.taskCompleteEventData`.
10661    ///
10662    /// # Parameters
10663    ///
10664    /// * `params` - Task-completion tool arguments and final result used to build a label-safe session event payload.
10665    ///
10666    /// # Returns
10667    ///
10668    /// Task completion notification with summary from the agent
10669    ///
10670    /// <div class="warning">
10671    ///
10672    /// **Experimental.** This API is part of an experimental wire-protocol surface
10673    /// and may change or be removed in future SDK or CLI releases. Pin both the
10674    /// SDK and CLI versions if your code depends on it.
10675    ///
10676    /// </div>
10677    pub async fn task_complete_event_data(
10678        &self,
10679        params: ToolsTaskCompleteEventDataRequest,
10680    ) -> Result<TaskCompleteData, Error> {
10681        let mut wire_params = serde_json::to_value(params)?;
10682        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10683        let _value = self
10684            .session
10685            .client()
10686            .call(
10687                rpc_methods::SESSION_TOOLS_TASKCOMPLETEEVENTDATA,
10688                Some(wire_params),
10689            )
10690            .await?;
10691        Ok(serde_json::from_value(_value)?)
10692    }
10693
10694    /// Provides the result for a pending external tool call.
10695    ///
10696    /// Wire method: `session.tools.handlePendingToolCall`.
10697    ///
10698    /// # Parameters
10699    ///
10700    /// * `params` - Pending external tool call request ID, with the tool result or an error describing why it failed.
10701    ///
10702    /// # Returns
10703    ///
10704    /// Indicates whether the external tool call result was handled successfully.
10705    ///
10706    /// <div class="warning">
10707    ///
10708    /// **Experimental.** This API is part of an experimental wire-protocol surface
10709    /// and may change or be removed in future SDK or CLI releases. Pin both the
10710    /// SDK and CLI versions if your code depends on it.
10711    ///
10712    /// </div>
10713    pub async fn handle_pending_tool_call(
10714        &self,
10715        params: HandlePendingToolCallRequest,
10716    ) -> Result<HandlePendingToolCallResult, Error> {
10717        let mut wire_params = serde_json::to_value(params)?;
10718        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10719        let _value = self
10720            .session
10721            .client()
10722            .call(
10723                rpc_methods::SESSION_TOOLS_HANDLEPENDINGTOOLCALL,
10724                Some(wire_params),
10725            )
10726            .await?;
10727        Ok(serde_json::from_value(_value)?)
10728    }
10729
10730    /// Resolves, builds, and validates the runtime tool list for the session.
10731    ///
10732    /// Wire method: `session.tools.initializeAndValidate`.
10733    ///
10734    /// # Returns
10735    ///
10736    /// 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.
10737    ///
10738    /// <div class="warning">
10739    ///
10740    /// **Experimental.** This API is part of an experimental wire-protocol surface
10741    /// and may change or be removed in future SDK or CLI releases. Pin both the
10742    /// SDK and CLI versions if your code depends on it.
10743    ///
10744    /// </div>
10745    pub async fn initialize_and_validate(&self) -> Result<ToolsInitializeAndValidateResult, Error> {
10746        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10747        let _value = self
10748            .session
10749            .client()
10750            .call(
10751                rpc_methods::SESSION_TOOLS_INITIALIZEANDVALIDATE,
10752                Some(wire_params),
10753            )
10754            .await?;
10755        Ok(serde_json::from_value(_value)?)
10756    }
10757
10758    /// Returns lightweight metadata for the session's currently initialized tools.
10759    ///
10760    /// Wire method: `session.tools.getCurrentMetadata`.
10761    ///
10762    /// # Returns
10763    ///
10764    /// Current lightweight tool metadata snapshot for the session.
10765    ///
10766    /// <div class="warning">
10767    ///
10768    /// **Experimental.** This API is part of an experimental wire-protocol surface
10769    /// and may change or be removed in future SDK or CLI releases. Pin both the
10770    /// SDK and CLI versions if your code depends on it.
10771    ///
10772    /// </div>
10773    pub async fn get_current_metadata(&self) -> Result<ToolsGetCurrentMetadataResult, Error> {
10774        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10775        let _value = self
10776            .session
10777            .client()
10778            .call(
10779                rpc_methods::SESSION_TOOLS_GETCURRENTMETADATA,
10780                Some(wire_params),
10781            )
10782            .await?;
10783        Ok(serde_json::from_value(_value)?)
10784    }
10785
10786    /// 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.
10787    ///
10788    /// Wire method: `session.tools.set`.
10789    ///
10790    /// # Parameters
10791    ///
10792    /// * `params` - Complete externally implemented tool list for the calling connection. An empty list removes every tool previously supplied by that connection.
10793    ///
10794    /// # Returns
10795    ///
10796    /// Empty result after replacing the calling connection's externally implemented tools.
10797    ///
10798    /// <div class="warning">
10799    ///
10800    /// **Experimental.** This API is part of an experimental wire-protocol surface
10801    /// and may change or be removed in future SDK or CLI releases. Pin both the
10802    /// SDK and CLI versions if your code depends on it.
10803    ///
10804    /// </div>
10805    pub async fn set(&self, params: ToolsSetRequest) -> Result<ToolsSetResult, Error> {
10806        let mut wire_params = serde_json::to_value(params)?;
10807        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10808        let _value = self
10809            .session
10810            .client()
10811            .call(rpc_methods::SESSION_TOOLS_SET, Some(wire_params))
10812            .await?;
10813        Ok(serde_json::from_value(_value)?)
10814    }
10815
10816    /// Updates the current session's live subagent settings after user settings change. The persisted user settings remain the source of truth for future sessions.
10817    ///
10818    /// Wire method: `session.tools.updateSubagentSettings`.
10819    ///
10820    /// # Parameters
10821    ///
10822    /// * `params` - Subagent settings to apply to the current session
10823    ///
10824    /// # Returns
10825    ///
10826    /// Empty result after applying subagent settings
10827    ///
10828    /// <div class="warning">
10829    ///
10830    /// **Experimental.** This API is part of an experimental wire-protocol surface
10831    /// and may change or be removed in future SDK or CLI releases. Pin both the
10832    /// SDK and CLI versions if your code depends on it.
10833    ///
10834    /// </div>
10835    pub async fn update_subagent_settings(
10836        &self,
10837        params: UpdateSubagentSettingsRequest,
10838    ) -> Result<ToolsUpdateSubagentSettingsResult, Error> {
10839        let mut wire_params = serde_json::to_value(params)?;
10840        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10841        let _value = self
10842            .session
10843            .client()
10844            .call(
10845                rpc_methods::SESSION_TOOLS_UPDATESUBAGENTSETTINGS,
10846                Some(wire_params),
10847            )
10848            .await?;
10849        Ok(serde_json::from_value(_value)?)
10850    }
10851}
10852
10853/// `session.ui.*` RPCs.
10854#[derive(Clone, Copy)]
10855pub struct SessionRpcUi<'a> {
10856    pub(crate) session: &'a Session,
10857}
10858
10859impl<'a> SessionRpcUi<'a> {
10860    /// Runs a transient no-tools model query against the current conversation context.
10861    ///
10862    /// Wire method: `session.ui.ephemeralQuery`.
10863    ///
10864    /// # Parameters
10865    ///
10866    /// * `params` - Transient question to answer without adding it to conversation history.
10867    ///
10868    /// # Returns
10869    ///
10870    /// Completed transient query. Ordered chunks and the terminal outcome are also delivered through `ui.ephemeral_query` session events while it runs.
10871    ///
10872    /// <div class="warning">
10873    ///
10874    /// **Experimental.** This API is part of an experimental wire-protocol surface
10875    /// and may change or be removed in future SDK or CLI releases. Pin both the
10876    /// SDK and CLI versions if your code depends on it.
10877    ///
10878    /// </div>
10879    pub async fn ephemeral_query(
10880        &self,
10881        params: UIEphemeralQueryRequest,
10882    ) -> Result<UIEphemeralQueryResult, Error> {
10883        let mut wire_params = serde_json::to_value(params)?;
10884        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10885        let _value = self
10886            .session
10887            .client()
10888            .call(rpc_methods::SESSION_UI_EPHEMERALQUERY, Some(wire_params))
10889            .await?;
10890        Ok(serde_json::from_value(_value)?)
10891    }
10892
10893    /// Requests structured input from a UI-capable client.
10894    ///
10895    /// Wire method: `session.ui.elicitation`.
10896    ///
10897    /// # Parameters
10898    ///
10899    /// * `params` - Prompt message and JSON schema describing the form fields to elicit from the user.
10900    ///
10901    /// # Returns
10902    ///
10903    /// The elicitation response (accept with form values, decline, or cancel)
10904    ///
10905    /// <div class="warning">
10906    ///
10907    /// **Experimental.** This API is part of an experimental wire-protocol surface
10908    /// and may change or be removed in future SDK or CLI releases. Pin both the
10909    /// SDK and CLI versions if your code depends on it.
10910    ///
10911    /// </div>
10912    pub async fn elicitation(
10913        &self,
10914        params: UIElicitationRequest,
10915    ) -> Result<UIElicitationResponse, Error> {
10916        let mut wire_params = serde_json::to_value(params)?;
10917        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10918        let _value = self
10919            .session
10920            .client()
10921            .call(rpc_methods::SESSION_UI_ELICITATION, Some(wire_params))
10922            .await?;
10923        Ok(serde_json::from_value(_value)?)
10924    }
10925
10926    /// Provides the user response for a pending elicitation request.
10927    ///
10928    /// Wire method: `session.ui.handlePendingElicitation`.
10929    ///
10930    /// # Parameters
10931    ///
10932    /// * `params` - Pending elicitation request ID and the user's response (accept/decline/cancel + form values).
10933    ///
10934    /// # Returns
10935    ///
10936    /// Indicates whether the elicitation response was accepted; false if it was already resolved by another client.
10937    ///
10938    /// <div class="warning">
10939    ///
10940    /// **Experimental.** This API is part of an experimental wire-protocol surface
10941    /// and may change or be removed in future SDK or CLI releases. Pin both the
10942    /// SDK and CLI versions if your code depends on it.
10943    ///
10944    /// </div>
10945    pub async fn handle_pending_elicitation(
10946        &self,
10947        params: UIHandlePendingElicitationRequest,
10948    ) -> Result<UIElicitationResult, Error> {
10949        let mut wire_params = serde_json::to_value(params)?;
10950        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10951        let _value = self
10952            .session
10953            .client()
10954            .call(
10955                rpc_methods::SESSION_UI_HANDLEPENDINGELICITATION,
10956                Some(wire_params),
10957            )
10958            .await?;
10959        Ok(serde_json::from_value(_value)?)
10960    }
10961
10962    /// Resolves a pending `user_input.requested` event with the user's response.
10963    ///
10964    /// Wire method: `session.ui.handlePendingUserInput`.
10965    ///
10966    /// # Parameters
10967    ///
10968    /// * `params` - Request ID of a pending `user_input.requested` event and the user's response.
10969    ///
10970    /// # Returns
10971    ///
10972    /// Indicates whether the pending UI request was resolved by this call.
10973    ///
10974    /// <div class="warning">
10975    ///
10976    /// **Experimental.** This API is part of an experimental wire-protocol surface
10977    /// and may change or be removed in future SDK or CLI releases. Pin both the
10978    /// SDK and CLI versions if your code depends on it.
10979    ///
10980    /// </div>
10981    pub async fn handle_pending_user_input(
10982        &self,
10983        params: UIHandlePendingUserInputRequest,
10984    ) -> Result<UIHandlePendingResult, Error> {
10985        let mut wire_params = serde_json::to_value(params)?;
10986        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10987        let _value = self
10988            .session
10989            .client()
10990            .call(
10991                rpc_methods::SESSION_UI_HANDLEPENDINGUSERINPUT,
10992                Some(wire_params),
10993            )
10994            .await?;
10995        Ok(serde_json::from_value(_value)?)
10996    }
10997
10998    /// Resolves a pending `sampling.requested` event with a sampling result, or rejects it.
10999    ///
11000    /// Wire method: `session.ui.handlePendingSampling`.
11001    ///
11002    /// # Parameters
11003    ///
11004    /// * `params` - Request ID of a pending `sampling.requested` event and an optional sampling result payload (omit to reject).
11005    ///
11006    /// # Returns
11007    ///
11008    /// Indicates whether the pending UI request was resolved by this call.
11009    ///
11010    /// <div class="warning">
11011    ///
11012    /// **Experimental.** This API is part of an experimental wire-protocol surface
11013    /// and may change or be removed in future SDK or CLI releases. Pin both the
11014    /// SDK and CLI versions if your code depends on it.
11015    ///
11016    /// </div>
11017    pub async fn handle_pending_sampling(
11018        &self,
11019        params: UIHandlePendingSamplingRequest,
11020    ) -> Result<UIHandlePendingResult, Error> {
11021        let mut wire_params = serde_json::to_value(params)?;
11022        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11023        let _value = self
11024            .session
11025            .client()
11026            .call(
11027                rpc_methods::SESSION_UI_HANDLEPENDINGSAMPLING,
11028                Some(wire_params),
11029            )
11030            .await?;
11031        Ok(serde_json::from_value(_value)?)
11032    }
11033
11034    /// Resolves a pending `auto_mode_switch.requested` event with the user's accept/decline decision.
11035    ///
11036    /// Wire method: `session.ui.handlePendingAutoModeSwitch`.
11037    ///
11038    /// # Parameters
11039    ///
11040    /// * `params` - Request ID of a pending `auto_mode_switch.requested` event and the user's response.
11041    ///
11042    /// # Returns
11043    ///
11044    /// Indicates whether the pending UI request was resolved by this call.
11045    ///
11046    /// <div class="warning">
11047    ///
11048    /// **Experimental.** This API is part of an experimental wire-protocol surface
11049    /// and may change or be removed in future SDK or CLI releases. Pin both the
11050    /// SDK and CLI versions if your code depends on it.
11051    ///
11052    /// </div>
11053    pub async fn handle_pending_auto_mode_switch(
11054        &self,
11055        params: UIHandlePendingAutoModeSwitchRequest,
11056    ) -> Result<UIHandlePendingResult, Error> {
11057        let mut wire_params = serde_json::to_value(params)?;
11058        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11059        let _value = self
11060            .session
11061            .client()
11062            .call(
11063                rpc_methods::SESSION_UI_HANDLEPENDINGAUTOMODESWITCH,
11064                Some(wire_params),
11065            )
11066            .await?;
11067        Ok(serde_json::from_value(_value)?)
11068    }
11069
11070    /// Resolves a pending `session_limits_exhausted.requested` event with the user's selected limit action.
11071    ///
11072    /// Wire method: `session.ui.handlePendingSessionLimitsExhausted`.
11073    ///
11074    /// # Parameters
11075    ///
11076    /// * `params` - Request ID of a pending `session_limits_exhausted.requested` event and the user's selected limit action.
11077    ///
11078    /// # Returns
11079    ///
11080    /// Indicates whether the pending UI request was resolved by this call.
11081    ///
11082    /// <div class="warning">
11083    ///
11084    /// **Experimental.** This API is part of an experimental wire-protocol surface
11085    /// and may change or be removed in future SDK or CLI releases. Pin both the
11086    /// SDK and CLI versions if your code depends on it.
11087    ///
11088    /// </div>
11089    pub async fn handle_pending_session_limits_exhausted(
11090        &self,
11091        params: UIHandlePendingSessionLimitsExhaustedRequest,
11092    ) -> Result<UIHandlePendingResult, Error> {
11093        let mut wire_params = serde_json::to_value(params)?;
11094        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11095        let _value = self
11096            .session
11097            .client()
11098            .call(
11099                rpc_methods::SESSION_UI_HANDLEPENDINGSESSIONLIMITSEXHAUSTED,
11100                Some(wire_params),
11101            )
11102            .await?;
11103        Ok(serde_json::from_value(_value)?)
11104    }
11105
11106    /// Resolves a pending `exit_plan_mode.requested` event with the user's response.
11107    ///
11108    /// Wire method: `session.ui.handlePendingExitPlanMode`.
11109    ///
11110    /// # Parameters
11111    ///
11112    /// * `params` - Request ID of a pending `exit_plan_mode.requested` event and the user's response.
11113    ///
11114    /// # Returns
11115    ///
11116    /// Indicates whether the pending UI request was resolved by this call.
11117    ///
11118    /// <div class="warning">
11119    ///
11120    /// **Experimental.** This API is part of an experimental wire-protocol surface
11121    /// and may change or be removed in future SDK or CLI releases. Pin both the
11122    /// SDK and CLI versions if your code depends on it.
11123    ///
11124    /// </div>
11125    pub async fn handle_pending_exit_plan_mode(
11126        &self,
11127        params: UIHandlePendingExitPlanModeRequest,
11128    ) -> Result<UIHandlePendingResult, Error> {
11129        let mut wire_params = serde_json::to_value(params)?;
11130        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11131        let _value = self
11132            .session
11133            .client()
11134            .call(
11135                rpc_methods::SESSION_UI_HANDLEPENDINGEXITPLANMODE,
11136                Some(wire_params),
11137            )
11138            .await?;
11139        Ok(serde_json::from_value(_value)?)
11140    }
11141
11142    /// Registers an in-process handler for auto-mode-switch requests so the server bridge skips dispatch.
11143    ///
11144    /// Wire method: `session.ui.registerDirectAutoModeSwitchHandler`.
11145    ///
11146    /// # Returns
11147    ///
11148    /// 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).
11149    ///
11150    /// <div class="warning">
11151    ///
11152    /// **Experimental.** This API is part of an experimental wire-protocol surface
11153    /// and may change or be removed in future SDK or CLI releases. Pin both the
11154    /// SDK and CLI versions if your code depends on it.
11155    ///
11156    /// </div>
11157    pub async fn register_direct_auto_mode_switch_handler(
11158        &self,
11159    ) -> Result<UIRegisterDirectAutoModeSwitchHandlerResult, Error> {
11160        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
11161        let _value = self
11162            .session
11163            .client()
11164            .call(
11165                rpc_methods::SESSION_UI_REGISTERDIRECTAUTOMODESWITCHHANDLER,
11166                Some(wire_params),
11167            )
11168            .await?;
11169        Ok(serde_json::from_value(_value)?)
11170    }
11171
11172    /// Unregisters a previously-registered in-process auto-mode-switch handler by its opaque handle.
11173    ///
11174    /// Wire method: `session.ui.unregisterDirectAutoModeSwitchHandler`.
11175    ///
11176    /// # Parameters
11177    ///
11178    /// * `params` - Opaque handle previously returned by `registerDirectAutoModeSwitchHandler` to release.
11179    ///
11180    /// # Returns
11181    ///
11182    /// Indicates whether the handle was active and the registration count was decremented.
11183    ///
11184    /// <div class="warning">
11185    ///
11186    /// **Experimental.** This API is part of an experimental wire-protocol surface
11187    /// and may change or be removed in future SDK or CLI releases. Pin both the
11188    /// SDK and CLI versions if your code depends on it.
11189    ///
11190    /// </div>
11191    pub async fn unregister_direct_auto_mode_switch_handler(
11192        &self,
11193        params: UIUnregisterDirectAutoModeSwitchHandlerRequest,
11194    ) -> Result<UIUnregisterDirectAutoModeSwitchHandlerResult, Error> {
11195        let mut wire_params = serde_json::to_value(params)?;
11196        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11197        let _value = self
11198            .session
11199            .client()
11200            .call(
11201                rpc_methods::SESSION_UI_UNREGISTERDIRECTAUTOMODESWITCHHANDLER,
11202                Some(wire_params),
11203            )
11204            .await?;
11205        Ok(serde_json::from_value(_value)?)
11206    }
11207}
11208
11209/// `session.usage.*` RPCs.
11210#[derive(Clone, Copy)]
11211pub struct SessionRpcUsage<'a> {
11212    pub(crate) session: &'a Session,
11213}
11214
11215impl<'a> SessionRpcUsage<'a> {
11216    /// Gets accumulated usage metrics for the session.
11217    ///
11218    /// Wire method: `session.usage.getMetrics`.
11219    ///
11220    /// # Returns
11221    ///
11222    /// Accumulated session usage metrics, including premium request cost, token counts, model breakdown, and code-change totals.
11223    ///
11224    /// <div class="warning">
11225    ///
11226    /// **Experimental.** This API is part of an experimental wire-protocol surface
11227    /// and may change or be removed in future SDK or CLI releases. Pin both the
11228    /// SDK and CLI versions if your code depends on it.
11229    ///
11230    /// </div>
11231    pub async fn get_metrics(&self) -> Result<UsageGetMetricsResult, Error> {
11232        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
11233        let _value = self
11234            .session
11235            .client()
11236            .call(rpc_methods::SESSION_USAGE_GETMETRICS, Some(wire_params))
11237            .await?;
11238        Ok(serde_json::from_value(_value)?)
11239    }
11240}
11241
11242/// `session.visibility.*` RPCs.
11243#[derive(Clone, Copy)]
11244pub struct SessionRpcVisibility<'a> {
11245    pub(crate) session: &'a Session,
11246}
11247
11248impl<'a> SessionRpcVisibility<'a> {
11249    /// 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").
11250    ///
11251    /// Wire method: `session.visibility.get`.
11252    ///
11253    /// # Returns
11254    ///
11255    /// Current sharing status and shareable GitHub URL for a session.
11256    ///
11257    /// <div class="warning">
11258    ///
11259    /// **Experimental.** This API is part of an experimental wire-protocol surface
11260    /// and may change or be removed in future SDK or CLI releases. Pin both the
11261    /// SDK and CLI versions if your code depends on it.
11262    ///
11263    /// </div>
11264    pub async fn get(&self) -> Result<VisibilityGetResult, Error> {
11265        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
11266        let _value = self
11267            .session
11268            .client()
11269            .call(rpc_methods::SESSION_VISIBILITY_GET, Some(wire_params))
11270            .await?;
11271        Ok(serde_json::from_value(_value)?)
11272    }
11273
11274    /// 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.
11275    ///
11276    /// Wire method: `session.visibility.set`.
11277    ///
11278    /// # Parameters
11279    ///
11280    /// * `params` - Desired sharing status for the session.
11281    ///
11282    /// # Returns
11283    ///
11284    /// Effective sharing status and shareable GitHub URL after updating session visibility.
11285    ///
11286    /// <div class="warning">
11287    ///
11288    /// **Experimental.** This API is part of an experimental wire-protocol surface
11289    /// and may change or be removed in future SDK or CLI releases. Pin both the
11290    /// SDK and CLI versions if your code depends on it.
11291    ///
11292    /// </div>
11293    pub async fn set(&self, params: VisibilitySetRequest) -> Result<VisibilitySetResult, Error> {
11294        let mut wire_params = serde_json::to_value(params)?;
11295        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11296        let _value = self
11297            .session
11298            .client()
11299            .call(rpc_methods::SESSION_VISIBILITY_SET, Some(wire_params))
11300            .await?;
11301        Ok(serde_json::from_value(_value)?)
11302    }
11303}
11304
11305/// `session.workspaces.*` RPCs.
11306#[derive(Clone, Copy)]
11307pub struct SessionRpcWorkspaces<'a> {
11308    pub(crate) session: &'a Session,
11309}
11310
11311impl<'a> SessionRpcWorkspaces<'a> {
11312    /// Gets current workspace metadata for the session.
11313    ///
11314    /// Wire method: `session.workspaces.getWorkspace`.
11315    ///
11316    /// # Returns
11317    ///
11318    /// Current workspace metadata for the session, including its absolute filesystem path when available.
11319    ///
11320    /// <div class="warning">
11321    ///
11322    /// **Experimental.** This API is part of an experimental wire-protocol surface
11323    /// and may change or be removed in future SDK or CLI releases. Pin both the
11324    /// SDK and CLI versions if your code depends on it.
11325    ///
11326    /// </div>
11327    pub async fn get_workspace(&self) -> Result<WorkspacesGetWorkspaceResult, Error> {
11328        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
11329        let _value = self
11330            .session
11331            .client()
11332            .call(
11333                rpc_methods::SESSION_WORKSPACES_GETWORKSPACE,
11334                Some(wire_params),
11335            )
11336            .await?;
11337        Ok(serde_json::from_value(_value)?)
11338    }
11339
11340    /// Updates workspace metadata for a local session and returns the refreshed workspace.
11341    ///
11342    /// Wire method: `session.workspaces.updateMetadata`.
11343    ///
11344    /// # Parameters
11345    ///
11346    /// * `params` - Workspace metadata fields to update.
11347    ///
11348    /// # Returns
11349    ///
11350    /// Current workspace metadata for the session, including its absolute filesystem path when available.
11351    ///
11352    /// <div class="warning">
11353    ///
11354    /// **Experimental.** This API is part of an experimental wire-protocol surface
11355    /// and may change or be removed in future SDK or CLI releases. Pin both the
11356    /// SDK and CLI versions if your code depends on it.
11357    ///
11358    /// </div>
11359    pub async fn update_metadata(
11360        &self,
11361        params: WorkspacesUpdateMetadataRequest,
11362    ) -> Result<WorkspacesGetWorkspaceResult, 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_UPDATEMETADATA,
11370                Some(wire_params),
11371            )
11372            .await?;
11373        Ok(serde_json::from_value(_value)?)
11374    }
11375
11376    /// Ensures a local session workspace exists and returns it.
11377    ///
11378    /// Wire method: `session.workspaces.ensure`.
11379    ///
11380    /// # Parameters
11381    ///
11382    /// * `params` - Optional session context used when creating a local workspace.
11383    ///
11384    /// # Returns
11385    ///
11386    /// Current workspace metadata for the session, including its absolute filesystem path when available.
11387    ///
11388    /// <div class="warning">
11389    ///
11390    /// **Experimental.** This API is part of an experimental wire-protocol surface
11391    /// and may change or be removed in future SDK or CLI releases. Pin both the
11392    /// SDK and CLI versions if your code depends on it.
11393    ///
11394    /// </div>
11395    pub async fn ensure(
11396        &self,
11397        params: WorkspacesEnsureRequest,
11398    ) -> Result<WorkspacesGetWorkspaceResult, Error> {
11399        let mut wire_params = serde_json::to_value(params)?;
11400        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11401        let _value = self
11402            .session
11403            .client()
11404            .call(rpc_methods::SESSION_WORKSPACES_ENSURE, Some(wire_params))
11405            .await?;
11406        Ok(serde_json::from_value(_value)?)
11407    }
11408
11409    /// Lists files stored in the session workspace files directory.
11410    ///
11411    /// Wire method: `session.workspaces.listFiles`.
11412    ///
11413    /// # Returns
11414    ///
11415    /// Relative paths of files stored in the session workspace files directory.
11416    ///
11417    /// <div class="warning">
11418    ///
11419    /// **Experimental.** This API is part of an experimental wire-protocol surface
11420    /// and may change or be removed in future SDK or CLI releases. Pin both the
11421    /// SDK and CLI versions if your code depends on it.
11422    ///
11423    /// </div>
11424    pub async fn list_files(&self) -> Result<WorkspacesListFilesResult, Error> {
11425        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
11426        let _value = self
11427            .session
11428            .client()
11429            .call(rpc_methods::SESSION_WORKSPACES_LISTFILES, Some(wire_params))
11430            .await?;
11431        Ok(serde_json::from_value(_value)?)
11432    }
11433
11434    /// Reads a file from the session workspace files directory.
11435    ///
11436    /// Wire method: `session.workspaces.readFile`.
11437    ///
11438    /// # Parameters
11439    ///
11440    /// * `params` - Relative path of the workspace file to read.
11441    ///
11442    /// # Returns
11443    ///
11444    /// Contents of the requested workspace file as a UTF-8 string.
11445    ///
11446    /// <div class="warning">
11447    ///
11448    /// **Experimental.** This API is part of an experimental wire-protocol surface
11449    /// and may change or be removed in future SDK or CLI releases. Pin both the
11450    /// SDK and CLI versions if your code depends on it.
11451    ///
11452    /// </div>
11453    pub async fn read_file(
11454        &self,
11455        params: WorkspacesReadFileRequest,
11456    ) -> Result<WorkspacesReadFileResult, Error> {
11457        let mut wire_params = serde_json::to_value(params)?;
11458        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11459        let _value = self
11460            .session
11461            .client()
11462            .call(rpc_methods::SESSION_WORKSPACES_READFILE, Some(wire_params))
11463            .await?;
11464        Ok(serde_json::from_value(_value)?)
11465    }
11466
11467    /// Creates or overwrites a file in the session workspace files directory.
11468    ///
11469    /// Wire method: `session.workspaces.createFile`.
11470    ///
11471    /// # Parameters
11472    ///
11473    /// * `params` - Relative path and UTF-8 content for the workspace file to create or overwrite.
11474    ///
11475    /// <div class="warning">
11476    ///
11477    /// **Experimental.** This API is part of an experimental wire-protocol surface
11478    /// and may change or be removed in future SDK or CLI releases. Pin both the
11479    /// SDK and CLI versions if your code depends on it.
11480    ///
11481    /// </div>
11482    pub async fn create_file(&self, params: WorkspacesCreateFileRequest) -> Result<(), Error> {
11483        let mut wire_params = serde_json::to_value(params)?;
11484        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11485        let _value = self
11486            .session
11487            .client()
11488            .call(
11489                rpc_methods::SESSION_WORKSPACES_CREATEFILE,
11490                Some(wire_params),
11491            )
11492            .await?;
11493        Ok(())
11494    }
11495
11496    /// Lists workspace checkpoints in chronological order.
11497    ///
11498    /// Wire method: `session.workspaces.listCheckpoints`.
11499    ///
11500    /// # Returns
11501    ///
11502    /// Workspace checkpoints in chronological order; empty when the workspace is not enabled.
11503    ///
11504    /// <div class="warning">
11505    ///
11506    /// **Experimental.** This API is part of an experimental wire-protocol surface
11507    /// and may change or be removed in future SDK or CLI releases. Pin both the
11508    /// SDK and CLI versions if your code depends on it.
11509    ///
11510    /// </div>
11511    pub async fn list_checkpoints(&self) -> Result<WorkspacesListCheckpointsResult, Error> {
11512        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
11513        let _value = self
11514            .session
11515            .client()
11516            .call(
11517                rpc_methods::SESSION_WORKSPACES_LISTCHECKPOINTS,
11518                Some(wire_params),
11519            )
11520            .await?;
11521        Ok(serde_json::from_value(_value)?)
11522    }
11523
11524    /// Reads the content of a workspace checkpoint by number.
11525    ///
11526    /// Wire method: `session.workspaces.readCheckpoint`.
11527    ///
11528    /// # Parameters
11529    ///
11530    /// * `params` - Checkpoint number to read.
11531    ///
11532    /// # Returns
11533    ///
11534    /// Checkpoint content as a UTF-8 string, or null when the checkpoint or workspace is missing.
11535    ///
11536    /// <div class="warning">
11537    ///
11538    /// **Experimental.** This API is part of an experimental wire-protocol surface
11539    /// and may change or be removed in future SDK or CLI releases. Pin both the
11540    /// SDK and CLI versions if your code depends on it.
11541    ///
11542    /// </div>
11543    pub async fn read_checkpoint(
11544        &self,
11545        params: WorkspacesReadCheckpointRequest,
11546    ) -> Result<WorkspacesReadCheckpointResult, Error> {
11547        let mut wire_params = serde_json::to_value(params)?;
11548        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11549        let _value = self
11550            .session
11551            .client()
11552            .call(
11553                rpc_methods::SESSION_WORKSPACES_READCHECKPOINT,
11554                Some(wire_params),
11555            )
11556            .await?;
11557        Ok(serde_json::from_value(_value)?)
11558    }
11559
11560    /// Adds a compaction summary checkpoint to the local session workspace.
11561    ///
11562    /// Wire method: `session.workspaces.addSummary`.
11563    ///
11564    /// # Parameters
11565    ///
11566    /// * `params` - Compaction summary checkpoint to persist.
11567    ///
11568    /// # Returns
11569    ///
11570    /// Persisted summary metadata and refreshed workspace metadata.
11571    ///
11572    /// <div class="warning">
11573    ///
11574    /// **Experimental.** This API is part of an experimental wire-protocol surface
11575    /// and may change or be removed in future SDK or CLI releases. Pin both the
11576    /// SDK and CLI versions if your code depends on it.
11577    ///
11578    /// </div>
11579    pub async fn add_summary(
11580        &self,
11581        params: WorkspacesAddSummaryRequest,
11582    ) -> Result<WorkspacesAddSummaryResult, Error> {
11583        let mut wire_params = serde_json::to_value(params)?;
11584        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11585        let _value = self
11586            .session
11587            .client()
11588            .call(
11589                rpc_methods::SESSION_WORKSPACES_ADDSUMMARY,
11590                Some(wire_params),
11591            )
11592            .await?;
11593        Ok(serde_json::from_value(_value)?)
11594    }
11595
11596    /// Truncates local workspace compaction summaries after a rollback.
11597    ///
11598    /// Wire method: `session.workspaces.truncateSummaries`.
11599    ///
11600    /// # Parameters
11601    ///
11602    /// * `params` - Rollback point for local workspace summaries.
11603    ///
11604    /// # Returns
11605    ///
11606    /// Current workspace metadata for the session, including its absolute filesystem path when available.
11607    ///
11608    /// <div class="warning">
11609    ///
11610    /// **Experimental.** This API is part of an experimental wire-protocol surface
11611    /// and may change or be removed in future SDK or CLI releases. Pin both the
11612    /// SDK and CLI versions if your code depends on it.
11613    ///
11614    /// </div>
11615    pub async fn truncate_summaries(
11616        &self,
11617        params: WorkspacesTruncateSummariesRequest,
11618    ) -> Result<WorkspacesGetWorkspaceResult, Error> {
11619        let mut wire_params = serde_json::to_value(params)?;
11620        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11621        let _value = self
11622            .session
11623            .client()
11624            .call(
11625                rpc_methods::SESSION_WORKSPACES_TRUNCATESUMMARIES,
11626                Some(wire_params),
11627            )
11628            .await?;
11629        Ok(serde_json::from_value(_value)?)
11630    }
11631
11632    /// Reads the autopilot objective state file from the local session workspace.
11633    ///
11634    /// Wire method: `session.workspaces.readAutopilotObjective`.
11635    ///
11636    /// # Returns
11637    ///
11638    /// Autopilot objective file content, or null when missing.
11639    ///
11640    /// <div class="warning">
11641    ///
11642    /// **Experimental.** This API is part of an experimental wire-protocol surface
11643    /// and may change or be removed in future SDK or CLI releases. Pin both the
11644    /// SDK and CLI versions if your code depends on it.
11645    ///
11646    /// </div>
11647    pub async fn read_autopilot_objective(
11648        &self,
11649    ) -> Result<WorkspacesReadAutopilotObjectiveResult, Error> {
11650        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
11651        let _value = self
11652            .session
11653            .client()
11654            .call(
11655                rpc_methods::SESSION_WORKSPACES_READAUTOPILOTOBJECTIVE,
11656                Some(wire_params),
11657            )
11658            .await?;
11659        Ok(serde_json::from_value(_value)?)
11660    }
11661
11662    /// Writes the autopilot objective state file in the local session workspace.
11663    ///
11664    /// Wire method: `session.workspaces.writeAutopilotObjective`.
11665    ///
11666    /// # Parameters
11667    ///
11668    /// * `params` - Autopilot objective file content to persist.
11669    ///
11670    /// # Returns
11671    ///
11672    /// Result of writing the autopilot objective file.
11673    ///
11674    /// <div class="warning">
11675    ///
11676    /// **Experimental.** This API is part of an experimental wire-protocol surface
11677    /// and may change or be removed in future SDK or CLI releases. Pin both the
11678    /// SDK and CLI versions if your code depends on it.
11679    ///
11680    /// </div>
11681    pub async fn write_autopilot_objective(
11682        &self,
11683        params: WorkspacesWriteAutopilotObjectiveRequest,
11684    ) -> Result<WorkspacesWriteAutopilotObjectiveResult, Error> {
11685        let mut wire_params = serde_json::to_value(params)?;
11686        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11687        let _value = self
11688            .session
11689            .client()
11690            .call(
11691                rpc_methods::SESSION_WORKSPACES_WRITEAUTOPILOTOBJECTIVE,
11692                Some(wire_params),
11693            )
11694            .await?;
11695        Ok(serde_json::from_value(_value)?)
11696    }
11697
11698    /// Deletes the autopilot objective state file from the local session workspace.
11699    ///
11700    /// Wire method: `session.workspaces.deleteAutopilotObjective`.
11701    ///
11702    /// # Returns
11703    ///
11704    /// Result of deleting the autopilot objective file.
11705    ///
11706    /// <div class="warning">
11707    ///
11708    /// **Experimental.** This API is part of an experimental wire-protocol surface
11709    /// and may change or be removed in future SDK or CLI releases. Pin both the
11710    /// SDK and CLI versions if your code depends on it.
11711    ///
11712    /// </div>
11713    pub async fn delete_autopilot_objective(
11714        &self,
11715    ) -> Result<WorkspacesDeleteAutopilotObjectiveResult, Error> {
11716        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
11717        let _value = self
11718            .session
11719            .client()
11720            .call(
11721                rpc_methods::SESSION_WORKSPACES_DELETEAUTOPILOTOBJECTIVE,
11722                Some(wire_params),
11723            )
11724            .await?;
11725        Ok(serde_json::from_value(_value)?)
11726    }
11727
11728    /// Checks whether the local session workspace has an autopilot objective state file.
11729    ///
11730    /// Wire method: `session.workspaces.autopilotObjectiveExists`.
11731    ///
11732    /// # Returns
11733    ///
11734    /// Whether the autopilot objective file exists.
11735    ///
11736    /// <div class="warning">
11737    ///
11738    /// **Experimental.** This API is part of an experimental wire-protocol surface
11739    /// and may change or be removed in future SDK or CLI releases. Pin both the
11740    /// SDK and CLI versions if your code depends on it.
11741    ///
11742    /// </div>
11743    pub async fn autopilot_objective_exists(
11744        &self,
11745    ) -> Result<WorkspacesAutopilotObjectiveExistsResult, Error> {
11746        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
11747        let _value = self
11748            .session
11749            .client()
11750            .call(
11751                rpc_methods::SESSION_WORKSPACES_AUTOPILOTOBJECTIVEEXISTS,
11752                Some(wire_params),
11753            )
11754            .await?;
11755        Ok(serde_json::from_value(_value)?)
11756    }
11757
11758    /// Saves pasted content as a UTF-8 file in the session workspace.
11759    ///
11760    /// Wire method: `session.workspaces.saveLargePaste`.
11761    ///
11762    /// # Parameters
11763    ///
11764    /// * `params` - Pasted content to save as a UTF-8 file in the session workspace.
11765    ///
11766    /// # Returns
11767    ///
11768    /// Descriptor for the saved paste file, or null when the workspace is unavailable.
11769    ///
11770    /// <div class="warning">
11771    ///
11772    /// **Experimental.** This API is part of an experimental wire-protocol surface
11773    /// and may change or be removed in future SDK or CLI releases. Pin both the
11774    /// SDK and CLI versions if your code depends on it.
11775    ///
11776    /// </div>
11777    pub async fn save_large_paste(
11778        &self,
11779        params: WorkspacesSaveLargePasteRequest,
11780    ) -> Result<WorkspacesSaveLargePasteResult, Error> {
11781        let mut wire_params = serde_json::to_value(params)?;
11782        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11783        let _value = self
11784            .session
11785            .client()
11786            .call(
11787                rpc_methods::SESSION_WORKSPACES_SAVELARGEPASTE,
11788                Some(wire_params),
11789            )
11790            .await?;
11791        Ok(serde_json::from_value(_value)?)
11792    }
11793
11794    /// 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`.
11795    ///
11796    /// Wire method: `session.workspaces.diff`.
11797    ///
11798    /// # Parameters
11799    ///
11800    /// * `params` - Parameters for computing a workspace diff.
11801    ///
11802    /// # Returns
11803    ///
11804    /// Workspace diff result for the requested mode.
11805    ///
11806    /// <div class="warning">
11807    ///
11808    /// **Experimental.** This API is part of an experimental wire-protocol surface
11809    /// and may change or be removed in future SDK or CLI releases. Pin both the
11810    /// SDK and CLI versions if your code depends on it.
11811    ///
11812    /// </div>
11813    pub async fn diff(&self, params: WorkspacesDiffRequest) -> Result<WorkspaceDiffResult, Error> {
11814        let mut wire_params = serde_json::to_value(params)?;
11815        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11816        let _value = self
11817            .session
11818            .client()
11819            .call(rpc_methods::SESSION_WORKSPACES_DIFF, Some(wire_params))
11820            .await?;
11821        Ok(serde_json::from_value(_value)?)
11822    }
11823}