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    /// Force-refreshes enterprise managed settings for every account: wipes the persistent server-policy cache (the whole `<cacheHome>/managed-settings` directory) and drops this runtime process's in-memory retained server policy. It does not itself fetch policy — the effect is that the next time a session resolves managed settings for an account, that resolution re-fetches the account's org policy from the network instead of serving a cached response. Note that `managedSettings.read` returns only device/MDM settings and never triggers the account server-policy fetch, so a host implementing "sync account policy" should start a fresh session resolution rather than treat a subsequent `managedSettings.read` as the refreshed org policy. Mirrors the invalidation a sign-out performs, broadened from the one signing-out account to all of them; device/MDM layers describe the machine, not the account, and are left untouched. Rejects if the on-disk cache cannot be removed.
910    ///
911    /// Wire method: `managedSettings.clearCache`.
912    ///
913    /// <div class="warning">
914    ///
915    /// **Experimental.** This API is part of an experimental wire-protocol surface
916    /// and may change or be removed in future SDK or CLI releases. Pin both the
917    /// SDK and CLI versions if your code depends on it.
918    ///
919    /// </div>
920    pub async fn clear_cache(&self) -> Result<(), Error> {
921        let wire_params = serde_json::json!({});
922        let _value = self
923            .client
924            .call(rpc_methods::MANAGEDSETTINGS_CLEARCACHE, Some(wire_params))
925            .await?;
926        Ok(())
927    }
928}
929
930/// `mcp.*` RPCs.
931#[derive(Clone, Copy)]
932pub struct ClientRpcMcp<'a> {
933    pub(crate) client: &'a Client,
934}
935
936impl<'a> ClientRpcMcp<'a> {
937    /// `mcp.config.*` sub-namespace.
938    pub fn config(&self) -> ClientRpcMcpConfig<'a> {
939        ClientRpcMcpConfig {
940            client: self.client,
941        }
942    }
943
944    /// Discovers MCP servers from user, workspace, plugin, and builtin sources.
945    ///
946    /// Wire method: `mcp.discover`.
947    ///
948    /// # Parameters
949    ///
950    /// * `params` - Optional working directory used as context for MCP server discovery.
951    ///
952    /// # Returns
953    ///
954    /// MCP servers discovered from user, workspace, plugin, and built-in sources.
955    ///
956    /// <div class="warning">
957    ///
958    /// **Experimental.** This API is part of an experimental wire-protocol surface
959    /// and may change or be removed in future SDK or CLI releases. Pin both the
960    /// SDK and CLI versions if your code depends on it.
961    ///
962    /// </div>
963    pub async fn discover(&self, params: McpDiscoverRequest) -> Result<McpDiscoverResult, Error> {
964        let wire_params = serde_json::to_value(params)?;
965        let _value = self
966            .client
967            .call(rpc_methods::MCP_DISCOVER, Some(wire_params))
968            .await?;
969        Ok(serde_json::from_value(_value)?)
970    }
971
972    /// 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.
973    ///
974    /// Wire method: `mcp.planInstall`.
975    ///
976    /// # Parameters
977    ///
978    /// * `params` - A side-effect-free request for an MCP install plan. Computing a plan never writes configuration, stores a secret, or reloads MCP servers.
979    ///
980    /// # Returns
981    ///
982    /// Outcome of an mcp.planInstall call: either a normalised plan, or one typed refusal. Nothing is written in either case.
983    ///
984    /// <div class="warning">
985    ///
986    /// **Experimental.** This API is part of an experimental wire-protocol surface
987    /// and may change or be removed in future SDK or CLI releases. Pin both the
988    /// SDK and CLI versions if your code depends on it.
989    ///
990    /// </div>
991    pub async fn plan_install(
992        &self,
993        params: McpPlanInstallRequest,
994    ) -> Result<McpPlanInstallResult, Error> {
995        let wire_params = serde_json::to_value(params)?;
996        let _value = self
997            .client
998            .call(rpc_methods::MCP_PLANINSTALL, Some(wire_params))
999            .await?;
1000        Ok(serde_json::from_value(_value)?)
1001    }
1002}
1003
1004/// `mcp.config.*` RPCs.
1005#[derive(Clone, Copy)]
1006pub struct ClientRpcMcpConfig<'a> {
1007    pub(crate) client: &'a Client,
1008}
1009
1010impl<'a> ClientRpcMcpConfig<'a> {
1011    /// Lists MCP servers from user configuration.
1012    ///
1013    /// Wire method: `mcp.config.list`.
1014    ///
1015    /// # Returns
1016    ///
1017    /// User-configured MCP servers, keyed by server name.
1018    ///
1019    /// <div class="warning">
1020    ///
1021    /// **Experimental.** This API is part of an experimental wire-protocol surface
1022    /// and may change or be removed in future SDK or CLI releases. Pin both the
1023    /// SDK and CLI versions if your code depends on it.
1024    ///
1025    /// </div>
1026    pub async fn list(&self) -> Result<McpConfigList, Error> {
1027        let wire_params = serde_json::json!({});
1028        let _value = self
1029            .client
1030            .call(rpc_methods::MCP_CONFIG_LIST, Some(wire_params))
1031            .await?;
1032        Ok(serde_json::from_value(_value)?)
1033    }
1034
1035    /// Adds an MCP server to user configuration.
1036    ///
1037    /// Wire method: `mcp.config.add`.
1038    ///
1039    /// # Parameters
1040    ///
1041    /// * `params` - MCP server name and configuration to add to user configuration.
1042    ///
1043    /// <div class="warning">
1044    ///
1045    /// **Experimental.** This API is part of an experimental wire-protocol surface
1046    /// and may change or be removed in future SDK or CLI releases. Pin both the
1047    /// SDK and CLI versions if your code depends on it.
1048    ///
1049    /// </div>
1050    pub async fn add(&self, params: McpConfigAddRequest) -> Result<(), Error> {
1051        let wire_params = serde_json::to_value(params)?;
1052        let _value = self
1053            .client
1054            .call(rpc_methods::MCP_CONFIG_ADD, Some(wire_params))
1055            .await?;
1056        Ok(())
1057    }
1058
1059    /// Updates an MCP server in user configuration.
1060    ///
1061    /// Wire method: `mcp.config.update`.
1062    ///
1063    /// # Parameters
1064    ///
1065    /// * `params` - MCP server name and replacement configuration to write to user configuration.
1066    ///
1067    /// <div class="warning">
1068    ///
1069    /// **Experimental.** This API is part of an experimental wire-protocol surface
1070    /// and may change or be removed in future SDK or CLI releases. Pin both the
1071    /// SDK and CLI versions if your code depends on it.
1072    ///
1073    /// </div>
1074    pub async fn update(&self, params: McpConfigUpdateRequest) -> Result<(), Error> {
1075        let wire_params = serde_json::to_value(params)?;
1076        let _value = self
1077            .client
1078            .call(rpc_methods::MCP_CONFIG_UPDATE, Some(wire_params))
1079            .await?;
1080        Ok(())
1081    }
1082
1083    /// Removes an MCP server from user configuration.
1084    ///
1085    /// Wire method: `mcp.config.remove`.
1086    ///
1087    /// # Parameters
1088    ///
1089    /// * `params` - MCP server name to remove from user configuration.
1090    ///
1091    /// <div class="warning">
1092    ///
1093    /// **Experimental.** This API is part of an experimental wire-protocol surface
1094    /// and may change or be removed in future SDK or CLI releases. Pin both the
1095    /// SDK and CLI versions if your code depends on it.
1096    ///
1097    /// </div>
1098    pub async fn remove(&self, params: McpConfigRemoveRequest) -> Result<(), Error> {
1099        let wire_params = serde_json::to_value(params)?;
1100        let _value = self
1101            .client
1102            .call(rpc_methods::MCP_CONFIG_REMOVE, Some(wire_params))
1103            .await?;
1104        Ok(())
1105    }
1106
1107    /// Enables MCP servers in user configuration for new sessions.
1108    ///
1109    /// Wire method: `mcp.config.enable`.
1110    ///
1111    /// # Parameters
1112    ///
1113    /// * `params` - MCP server names to enable for new sessions.
1114    ///
1115    /// <div class="warning">
1116    ///
1117    /// **Experimental.** This API is part of an experimental wire-protocol surface
1118    /// and may change or be removed in future SDK or CLI releases. Pin both the
1119    /// SDK and CLI versions if your code depends on it.
1120    ///
1121    /// </div>
1122    pub async fn enable(&self, params: McpConfigEnableRequest) -> Result<(), Error> {
1123        let wire_params = serde_json::to_value(params)?;
1124        let _value = self
1125            .client
1126            .call(rpc_methods::MCP_CONFIG_ENABLE, Some(wire_params))
1127            .await?;
1128        Ok(())
1129    }
1130
1131    /// Disables MCP servers in user configuration for new sessions.
1132    ///
1133    /// Wire method: `mcp.config.disable`.
1134    ///
1135    /// # Parameters
1136    ///
1137    /// * `params` - MCP server names to disable for new sessions.
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 disable(&self, params: McpConfigDisableRequest) -> Result<(), Error> {
1147        let wire_params = serde_json::to_value(params)?;
1148        let _value = self
1149            .client
1150            .call(rpc_methods::MCP_CONFIG_DISABLE, Some(wire_params))
1151            .await?;
1152        Ok(())
1153    }
1154
1155    /// Drops this runtime process's in-memory MCP server-definition cache so the next MCP config read observes disk.
1156    ///
1157    /// Wire method: `mcp.config.reload`.
1158    ///
1159    /// <div class="warning">
1160    ///
1161    /// **Experimental.** This API is part of an experimental wire-protocol surface
1162    /// and may change or be removed in future SDK or CLI releases. Pin both the
1163    /// SDK and CLI versions if your code depends on it.
1164    ///
1165    /// </div>
1166    pub async fn reload(&self) -> Result<(), Error> {
1167        let wire_params = serde_json::json!({});
1168        let _value = self
1169            .client
1170            .call(rpc_methods::MCP_CONFIG_RELOAD, Some(wire_params))
1171            .await?;
1172        Ok(())
1173    }
1174}
1175
1176/// `models.*` RPCs.
1177#[derive(Clone, Copy)]
1178pub struct ClientRpcModels<'a> {
1179    pub(crate) client: &'a Client,
1180}
1181
1182impl<'a> ClientRpcModels<'a> {
1183    /// Lists Copilot models available to the authenticated user.
1184    ///
1185    /// Wire method: `models.list`.
1186    ///
1187    /// # Returns
1188    ///
1189    /// List of Copilot models available to the resolved user, including capabilities and billing metadata.
1190    ///
1191    /// <div class="warning">
1192    ///
1193    /// **Experimental.** This API is part of an experimental wire-protocol surface
1194    /// and may change or be removed in future SDK or CLI releases. Pin both the
1195    /// SDK and CLI versions if your code depends on it.
1196    ///
1197    /// </div>
1198    pub async fn list(&self) -> Result<ModelList, Error> {
1199        let wire_params = serde_json::json!({});
1200        let _value = self
1201            .client
1202            .call(rpc_methods::MODELS_LIST, Some(wire_params))
1203            .await?;
1204        Ok(serde_json::from_value(_value)?)
1205    }
1206
1207    /// Lists Copilot models available to the authenticated user.
1208    ///
1209    /// Wire method: `models.list`.
1210    ///
1211    /// # Parameters
1212    ///
1213    /// * `params` - Optional opaque account selection or compatibility GitHub token used to list models.
1214    ///
1215    /// # Returns
1216    ///
1217    /// List of Copilot models available to the resolved user, including capabilities and billing metadata.
1218    ///
1219    /// <div class="warning">
1220    ///
1221    /// **Experimental.** This API is part of an experimental wire-protocol surface
1222    /// and may change or be removed in future SDK or CLI releases. Pin both the
1223    /// SDK and CLI versions if your code depends on it.
1224    ///
1225    /// </div>
1226    pub async fn list_with_params(&self, params: ModelsListRequest) -> Result<ModelList, Error> {
1227        let wire_params = serde_json::to_value(params)?;
1228        let _value = self
1229            .client
1230            .call(rpc_methods::MODELS_LIST, Some(wire_params))
1231            .await?;
1232        Ok(serde_json::from_value(_value)?)
1233    }
1234
1235    /// Returns the running runtime's complete catalog of well-known built-in model IDs without authentication or network access.
1236    ///
1237    /// Wire method: `models.getBuiltInCatalog`.
1238    ///
1239    /// # Returns
1240    ///
1241    /// The running runtime's complete catalog of well-known built-in model IDs, including supported models and additional IDs with built-in metadata.
1242    ///
1243    /// <div class="warning">
1244    ///
1245    /// **Experimental.** This API is part of an experimental wire-protocol surface
1246    /// and may change or be removed in future SDK or CLI releases. Pin both the
1247    /// SDK and CLI versions if your code depends on it.
1248    ///
1249    /// </div>
1250    pub async fn get_built_in_catalog(&self) -> Result<BuiltInModelCatalog, Error> {
1251        let wire_params = serde_json::json!({});
1252        let _value = self
1253            .client
1254            .call(rpc_methods::MODELS_GETBUILTINCATALOG, Some(wire_params))
1255            .await?;
1256        Ok(serde_json::from_value(_value)?)
1257    }
1258}
1259
1260/// `plugins.*` RPCs.
1261#[derive(Clone, Copy)]
1262pub struct ClientRpcPlugins<'a> {
1263    pub(crate) client: &'a Client,
1264}
1265
1266impl<'a> ClientRpcPlugins<'a> {
1267    /// `plugins.builtin.*` sub-namespace.
1268    pub fn builtin(&self) -> ClientRpcPluginsBuiltin<'a> {
1269        ClientRpcPluginsBuiltin {
1270            client: self.client,
1271        }
1272    }
1273
1274    /// `plugins.marketplaces.*` sub-namespace.
1275    pub fn marketplaces(&self) -> ClientRpcPluginsMarketplaces<'a> {
1276        ClientRpcPluginsMarketplaces {
1277            client: self.client,
1278        }
1279    }
1280
1281    /// Lists plugins installed in user/global state.
1282    ///
1283    /// Wire method: `plugins.list`.
1284    ///
1285    /// # Returns
1286    ///
1287    /// Plugins installed in user/global state.
1288    ///
1289    /// <div class="warning">
1290    ///
1291    /// **Experimental.** This API is part of an experimental wire-protocol surface
1292    /// and may change or be removed in future SDK or CLI releases. Pin both the
1293    /// SDK and CLI versions if your code depends on it.
1294    ///
1295    /// </div>
1296    pub async fn list(&self) -> Result<PluginListResult, Error> {
1297        let wire_params = serde_json::json!({});
1298        let _value = self
1299            .client
1300            .call(rpc_methods::PLUGINS_LIST, Some(wire_params))
1301            .await?;
1302        Ok(serde_json::from_value(_value)?)
1303    }
1304
1305    /// Installs a plugin from a marketplace, GitHub repo, URL, or local path.
1306    ///
1307    /// Wire method: `plugins.install`.
1308    ///
1309    /// # Parameters
1310    ///
1311    /// * `params` - Plugin source and optional working directory for relative-path resolution.
1312    ///
1313    /// # Returns
1314    ///
1315    /// Result of installing a plugin.
1316    ///
1317    /// <div class="warning">
1318    ///
1319    /// **Experimental.** This API is part of an experimental wire-protocol surface
1320    /// and may change or be removed in future SDK or CLI releases. Pin both the
1321    /// SDK and CLI versions if your code depends on it.
1322    ///
1323    /// </div>
1324    pub async fn install(
1325        &self,
1326        params: PluginsInstallRequest,
1327    ) -> Result<PluginInstallResult, Error> {
1328        let wire_params = serde_json::to_value(params)?;
1329        let _value = self
1330            .client
1331            .call(rpc_methods::PLUGINS_INSTALL, Some(wire_params))
1332            .await?;
1333        Ok(serde_json::from_value(_value)?)
1334    }
1335
1336    /// Uninstalls an installed plugin.
1337    ///
1338    /// Wire method: `plugins.uninstall`.
1339    ///
1340    /// # Parameters
1341    ///
1342    /// * `params` - Name (or spec) of the plugin to uninstall.
1343    ///
1344    /// <div class="warning">
1345    ///
1346    /// **Experimental.** This API is part of an experimental wire-protocol surface
1347    /// and may change or be removed in future SDK or CLI releases. Pin both the
1348    /// SDK and CLI versions if your code depends on it.
1349    ///
1350    /// </div>
1351    pub async fn uninstall(&self, params: PluginsUninstallRequest) -> Result<(), Error> {
1352        let wire_params = serde_json::to_value(params)?;
1353        let _value = self
1354            .client
1355            .call(rpc_methods::PLUGINS_UNINSTALL, Some(wire_params))
1356            .await?;
1357        Ok(())
1358    }
1359
1360    /// Updates an installed plugin to its latest published version.
1361    ///
1362    /// Wire method: `plugins.update`.
1363    ///
1364    /// # Parameters
1365    ///
1366    /// * `params` - Name (or spec) of the plugin to update.
1367    ///
1368    /// # Returns
1369    ///
1370    /// Result of updating a single plugin.
1371    ///
1372    /// <div class="warning">
1373    ///
1374    /// **Experimental.** This API is part of an experimental wire-protocol surface
1375    /// and may change or be removed in future SDK or CLI releases. Pin both the
1376    /// SDK and CLI versions if your code depends on it.
1377    ///
1378    /// </div>
1379    pub async fn update(&self, params: PluginsUpdateRequest) -> Result<PluginUpdateResult, Error> {
1380        let wire_params = serde_json::to_value(params)?;
1381        let _value = self
1382            .client
1383            .call(rpc_methods::PLUGINS_UPDATE, Some(wire_params))
1384            .await?;
1385        Ok(serde_json::from_value(_value)?)
1386    }
1387
1388    /// Updates every installed plugin to its latest published version.
1389    ///
1390    /// Wire method: `plugins.updateAll`.
1391    ///
1392    /// # Returns
1393    ///
1394    /// Result of updating all installed plugins.
1395    ///
1396    /// <div class="warning">
1397    ///
1398    /// **Experimental.** This API is part of an experimental wire-protocol surface
1399    /// and may change or be removed in future SDK or CLI releases. Pin both the
1400    /// SDK and CLI versions if your code depends on it.
1401    ///
1402    /// </div>
1403    pub async fn update_all(&self) -> Result<PluginUpdateAllResult, Error> {
1404        let wire_params = serde_json::json!({});
1405        let _value = self
1406            .client
1407            .call(rpc_methods::PLUGINS_UPDATEALL, Some(wire_params))
1408            .await?;
1409        Ok(serde_json::from_value(_value)?)
1410    }
1411
1412    /// Enables installed plugins for new sessions.
1413    ///
1414    /// Wire method: `plugins.enable`.
1415    ///
1416    /// # Parameters
1417    ///
1418    /// * `params` - Plugin names (or specs) to enable, plus the optional working directory the repository-controlled guard is evaluated against.
1419    ///
1420    /// <div class="warning">
1421    ///
1422    /// **Experimental.** This API is part of an experimental wire-protocol surface
1423    /// and may change or be removed in future SDK or CLI releases. Pin both the
1424    /// SDK and CLI versions if your code depends on it.
1425    ///
1426    /// </div>
1427    pub async fn enable(&self, params: PluginsEnableRequest) -> Result<(), Error> {
1428        let wire_params = serde_json::to_value(params)?;
1429        let _value = self
1430            .client
1431            .call(rpc_methods::PLUGINS_ENABLE, Some(wire_params))
1432            .await?;
1433        Ok(())
1434    }
1435
1436    /// Disables installed plugins for new sessions.
1437    ///
1438    /// Wire method: `plugins.disable`.
1439    ///
1440    /// # Parameters
1441    ///
1442    /// * `params` - Plugin names (or specs) to disable, plus the optional working directory the repository-controlled guard is evaluated against.
1443    ///
1444    /// <div class="warning">
1445    ///
1446    /// **Experimental.** This API is part of an experimental wire-protocol surface
1447    /// and may change or be removed in future SDK or CLI releases. Pin both the
1448    /// SDK and CLI versions if your code depends on it.
1449    ///
1450    /// </div>
1451    pub async fn disable(&self, params: PluginsDisableRequest) -> Result<(), Error> {
1452        let wire_params = serde_json::to_value(params)?;
1453        let _value = self
1454            .client
1455            .call(rpc_methods::PLUGINS_DISABLE, Some(wire_params))
1456            .await?;
1457        Ok(())
1458    }
1459}
1460
1461/// `plugins.builtin.*` RPCs.
1462#[derive(Clone, Copy)]
1463pub struct ClientRpcPluginsBuiltin<'a> {
1464    pub(crate) client: &'a Client,
1465}
1466
1467impl<'a> ClientRpcPluginsBuiltin<'a> {
1468    /// Replaces this server's trusted built-in plugin directories while no sessions are active.
1469    ///
1470    /// Wire method: `plugins.builtin.set`.
1471    ///
1472    /// # Parameters
1473    ///
1474    /// * `params` - Trusted built-in plugin directories to use for this runtime process.
1475    ///
1476    /// <div class="warning">
1477    ///
1478    /// **Experimental.** This API is part of an experimental wire-protocol surface
1479    /// and may change or be removed in future SDK or CLI releases. Pin both the
1480    /// SDK and CLI versions if your code depends on it.
1481    ///
1482    /// </div>
1483    pub async fn set(&self, params: PluginsBuiltinSetRequest) -> Result<(), Error> {
1484        let wire_params = serde_json::to_value(params)?;
1485        let _value = self
1486            .client
1487            .call(rpc_methods::PLUGINS_BUILTIN_SET, Some(wire_params))
1488            .await?;
1489        Ok(())
1490    }
1491}
1492
1493/// `plugins.marketplaces.*` RPCs.
1494#[derive(Clone, Copy)]
1495pub struct ClientRpcPluginsMarketplaces<'a> {
1496    pub(crate) client: &'a Client,
1497}
1498
1499impl<'a> ClientRpcPluginsMarketplaces<'a> {
1500    /// Lists all registered marketplaces (defaults + user-added).
1501    ///
1502    /// Wire method: `plugins.marketplaces.list`.
1503    ///
1504    /// # Returns
1505    ///
1506    /// All registered marketplaces, including built-in defaults.
1507    ///
1508    /// <div class="warning">
1509    ///
1510    /// **Experimental.** This API is part of an experimental wire-protocol surface
1511    /// and may change or be removed in future SDK or CLI releases. Pin both the
1512    /// SDK and CLI versions if your code depends on it.
1513    ///
1514    /// </div>
1515    pub async fn list(&self) -> Result<MarketplaceListResult, Error> {
1516        let wire_params = serde_json::json!({});
1517        let _value = self
1518            .client
1519            .call(rpc_methods::PLUGINS_MARKETPLACES_LIST, Some(wire_params))
1520            .await?;
1521        Ok(serde_json::from_value(_value)?)
1522    }
1523
1524    /// Registers a new marketplace from a source (owner/repo, URL, or local path).
1525    ///
1526    /// Wire method: `plugins.marketplaces.add`.
1527    ///
1528    /// # Parameters
1529    ///
1530    /// * `params` - Marketplace source and optional working directory for relative-path resolution.
1531    ///
1532    /// # Returns
1533    ///
1534    /// Result of registering a new marketplace.
1535    ///
1536    /// <div class="warning">
1537    ///
1538    /// **Experimental.** This API is part of an experimental wire-protocol surface
1539    /// and may change or be removed in future SDK or CLI releases. Pin both the
1540    /// SDK and CLI versions if your code depends on it.
1541    ///
1542    /// </div>
1543    pub async fn add(
1544        &self,
1545        params: PluginsMarketplacesAddRequest,
1546    ) -> Result<MarketplaceAddResult, Error> {
1547        let wire_params = serde_json::to_value(params)?;
1548        let _value = self
1549            .client
1550            .call(rpc_methods::PLUGINS_MARKETPLACES_ADD, Some(wire_params))
1551            .await?;
1552        Ok(serde_json::from_value(_value)?)
1553    }
1554
1555    /// 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`.
1556    ///
1557    /// Wire method: `plugins.marketplaces.remove`.
1558    ///
1559    /// # Parameters
1560    ///
1561    /// * `params` - Name of the marketplace to remove and an optional force flag.
1562    ///
1563    /// # Returns
1564    ///
1565    /// Outcome of the remove attempt, including dependent-plugin info when applicable.
1566    ///
1567    /// <div class="warning">
1568    ///
1569    /// **Experimental.** This API is part of an experimental wire-protocol surface
1570    /// and may change or be removed in future SDK or CLI releases. Pin both the
1571    /// SDK and CLI versions if your code depends on it.
1572    ///
1573    /// </div>
1574    pub async fn remove(
1575        &self,
1576        params: PluginsMarketplacesRemoveRequest,
1577    ) -> Result<MarketplaceRemoveResult, Error> {
1578        let wire_params = serde_json::to_value(params)?;
1579        let _value = self
1580            .client
1581            .call(rpc_methods::PLUGINS_MARKETPLACES_REMOVE, Some(wire_params))
1582            .await?;
1583        Ok(serde_json::from_value(_value)?)
1584    }
1585
1586    /// Lists plugins advertised by a registered marketplace.
1587    ///
1588    /// Wire method: `plugins.marketplaces.browse`.
1589    ///
1590    /// # Parameters
1591    ///
1592    /// * `params` - Name of the marketplace whose plugin catalog to fetch.
1593    ///
1594    /// # Returns
1595    ///
1596    /// Plugins advertised by the marketplace.
1597    ///
1598    /// <div class="warning">
1599    ///
1600    /// **Experimental.** This API is part of an experimental wire-protocol surface
1601    /// and may change or be removed in future SDK or CLI releases. Pin both the
1602    /// SDK and CLI versions if your code depends on it.
1603    ///
1604    /// </div>
1605    pub async fn browse(
1606        &self,
1607        params: PluginsMarketplacesBrowseRequest,
1608    ) -> Result<MarketplaceBrowseResult, Error> {
1609        let wire_params = serde_json::to_value(params)?;
1610        let _value = self
1611            .client
1612            .call(rpc_methods::PLUGINS_MARKETPLACES_BROWSE, Some(wire_params))
1613            .await?;
1614        Ok(serde_json::from_value(_value)?)
1615    }
1616
1617    /// Re-fetches one or all registered marketplace catalogs.
1618    ///
1619    /// Wire method: `plugins.marketplaces.refresh`.
1620    ///
1621    /// # Returns
1622    ///
1623    /// Result of refreshing one or more marketplace catalogs.
1624    ///
1625    /// <div class="warning">
1626    ///
1627    /// **Experimental.** This API is part of an experimental wire-protocol surface
1628    /// and may change or be removed in future SDK or CLI releases. Pin both the
1629    /// SDK and CLI versions if your code depends on it.
1630    ///
1631    /// </div>
1632    pub async fn refresh(&self) -> Result<MarketplaceRefreshResult, Error> {
1633        let wire_params = serde_json::json!({});
1634        let _value = self
1635            .client
1636            .call(rpc_methods::PLUGINS_MARKETPLACES_REFRESH, Some(wire_params))
1637            .await?;
1638        Ok(serde_json::from_value(_value)?)
1639    }
1640
1641    /// Re-fetches one or all registered marketplace catalogs.
1642    ///
1643    /// Wire method: `plugins.marketplaces.refresh`.
1644    ///
1645    /// # Parameters
1646    ///
1647    /// * `params` - Optional marketplace name; omit to refresh all.
1648    ///
1649    /// # Returns
1650    ///
1651    /// Result of refreshing one or more marketplace catalogs.
1652    ///
1653    /// <div class="warning">
1654    ///
1655    /// **Experimental.** This API is part of an experimental wire-protocol surface
1656    /// and may change or be removed in future SDK or CLI releases. Pin both the
1657    /// SDK and CLI versions if your code depends on it.
1658    ///
1659    /// </div>
1660    pub async fn refresh_with_params(
1661        &self,
1662        params: PluginsMarketplacesRefreshRequest,
1663    ) -> Result<MarketplaceRefreshResult, Error> {
1664        let wire_params = serde_json::to_value(params)?;
1665        let _value = self
1666            .client
1667            .call(rpc_methods::PLUGINS_MARKETPLACES_REFRESH, Some(wire_params))
1668            .await?;
1669        Ok(serde_json::from_value(_value)?)
1670    }
1671}
1672
1673/// `runtime.*` RPCs.
1674#[derive(Clone, Copy)]
1675pub struct ClientRpcRuntime<'a> {
1676    pub(crate) client: &'a Client,
1677}
1678
1679impl<'a> ClientRpcRuntime<'a> {
1680    /// Gracefully shuts down an SDK-owned runtime. The response is sent only after cleanup completes; callers may then terminate the owned runtime process.
1681    ///
1682    /// Wire method: `runtime.shutdown`.
1683    ///
1684    /// <div class="warning">
1685    ///
1686    /// **Experimental.** This API is part of an experimental wire-protocol surface
1687    /// and may change or be removed in future SDK or CLI releases. Pin both the
1688    /// SDK and CLI versions if your code depends on it.
1689    ///
1690    /// </div>
1691    pub async fn shutdown(&self) -> Result<(), Error> {
1692        let wire_params = serde_json::json!({});
1693        let _value = self
1694            .client
1695            .call(rpc_methods::RUNTIME_SHUTDOWN, Some(wire_params))
1696            .await?;
1697        Ok(())
1698    }
1699}
1700
1701/// `secrets.*` RPCs.
1702#[derive(Clone, Copy)]
1703pub struct ClientRpcSecrets<'a> {
1704    pub(crate) client: &'a Client,
1705}
1706
1707impl<'a> ClientRpcSecrets<'a> {
1708    /// Registers secret values for redaction in session logs and exports. The SDK calls this to inject dynamically generated secret values (e.g., OIDC tokens).
1709    ///
1710    /// Wire method: `secrets.addFilterValues`.
1711    ///
1712    /// # Parameters
1713    ///
1714    /// * `params` - Secret values to add to the redaction filter.
1715    ///
1716    /// # Returns
1717    ///
1718    /// Confirmation that the secret values were registered.
1719    ///
1720    /// <div class="warning">
1721    ///
1722    /// **Experimental.** This API is part of an experimental wire-protocol surface
1723    /// and may change or be removed in future SDK or CLI releases. Pin both the
1724    /// SDK and CLI versions if your code depends on it.
1725    ///
1726    /// </div>
1727    pub async fn add_filter_values(
1728        &self,
1729        params: SecretsAddFilterValuesRequest,
1730    ) -> Result<SecretsAddFilterValuesResult, Error> {
1731        let wire_params = serde_json::to_value(params)?;
1732        let _value = self
1733            .client
1734            .call(rpc_methods::SECRETS_ADDFILTERVALUES, Some(wire_params))
1735            .await?;
1736        Ok(serde_json::from_value(_value)?)
1737    }
1738}
1739
1740/// `sessionFs.*` RPCs.
1741#[derive(Clone, Copy)]
1742pub struct ClientRpcSessionFs<'a> {
1743    pub(crate) client: &'a Client,
1744}
1745
1746impl<'a> ClientRpcSessionFs<'a> {
1747    /// Registers an SDK client as the session filesystem provider.
1748    ///
1749    /// Wire method: `sessionFs.setProvider`.
1750    ///
1751    /// # Parameters
1752    ///
1753    /// * `params` - Initial working directory, session-state path layout, and path conventions used to register the calling SDK client as the session filesystem provider.
1754    ///
1755    /// # Returns
1756    ///
1757    /// Indicates whether the calling client was registered as the session filesystem provider.
1758    ///
1759    /// <div class="warning">
1760    ///
1761    /// **Experimental.** This API is part of an experimental wire-protocol surface
1762    /// and may change or be removed in future SDK or CLI releases. Pin both the
1763    /// SDK and CLI versions if your code depends on it.
1764    ///
1765    /// </div>
1766    pub async fn set_provider(
1767        &self,
1768        params: SessionFsSetProviderRequest,
1769    ) -> Result<SessionFsSetProviderResult, Error> {
1770        let wire_params = serde_json::to_value(params)?;
1771        let _value = self
1772            .client
1773            .call(rpc_methods::SESSIONFS_SETPROVIDER, Some(wire_params))
1774            .await?;
1775        Ok(serde_json::from_value(_value)?)
1776    }
1777}
1778
1779/// `sessions.*` RPCs.
1780#[derive(Clone, Copy)]
1781pub struct ClientRpcSessions<'a> {
1782    pub(crate) client: &'a Client,
1783}
1784
1785impl<'a> ClientRpcSessions<'a> {
1786    /// Creates or resumes a local session and returns the opened session ID.
1787    ///
1788    /// Wire method: `sessions.open`.
1789    ///
1790    /// # Returns
1791    ///
1792    /// Result of opening a session.
1793    ///
1794    /// <div class="warning">
1795    ///
1796    /// **Experimental.** This API is part of an experimental wire-protocol surface
1797    /// and may change or be removed in future SDK or CLI releases. Pin both the
1798    /// SDK and CLI versions if your code depends on it.
1799    ///
1800    /// </div>
1801    pub async fn open(&self) -> Result<SessionOpenResult, Error> {
1802        let wire_params = serde_json::json!({});
1803        let _value = self
1804            .client
1805            .call(rpc_methods::SESSIONS_OPEN, Some(wire_params))
1806            .await?;
1807        Ok(serde_json::from_value(_value)?)
1808    }
1809
1810    /// Creates a new session by forking persisted history from an existing session.
1811    ///
1812    /// Wire method: `sessions.fork`.
1813    ///
1814    /// # Parameters
1815    ///
1816    /// * `params` - Source session identifier to fork from, optional event-ID boundary, and optional friendly name for the new session.
1817    ///
1818    /// # Returns
1819    ///
1820    /// Identifier and optional friendly name assigned to the newly forked session.
1821    ///
1822    /// <div class="warning">
1823    ///
1824    /// **Experimental.** This API is part of an experimental wire-protocol surface
1825    /// and may change or be removed in future SDK or CLI releases. Pin both the
1826    /// SDK and CLI versions if your code depends on it.
1827    ///
1828    /// </div>
1829    pub async fn fork(&self, params: SessionsForkRequest) -> Result<SessionsForkResult, Error> {
1830        let wire_params = serde_json::to_value(params)?;
1831        let _value = self
1832            .client
1833            .call(rpc_methods::SESSIONS_FORK, Some(wire_params))
1834            .await?;
1835        Ok(serde_json::from_value(_value)?)
1836    }
1837
1838    /// Connects to an existing remote session and exposes it as an SDK session.
1839    ///
1840    /// Wire method: `sessions.connect`.
1841    ///
1842    /// # Parameters
1843    ///
1844    /// * `params` - Remote session connection parameters.
1845    ///
1846    /// # Returns
1847    ///
1848    /// Remote session connection result.
1849    ///
1850    /// <div class="warning">
1851    ///
1852    /// **Experimental.** This API is part of an experimental wire-protocol surface
1853    /// and may change or be removed in future SDK or CLI releases. Pin both the
1854    /// SDK and CLI versions if your code depends on it.
1855    ///
1856    /// </div>
1857    pub async fn connect(
1858        &self,
1859        params: ConnectRemoteSessionParams,
1860    ) -> Result<RemoteSessionConnectionResult, Error> {
1861        let wire_params = serde_json::to_value(params)?;
1862        let _value = self
1863            .client
1864            .call(rpc_methods::SESSIONS_CONNECT, Some(wire_params))
1865            .await?;
1866        Ok(serde_json::from_value(_value)?)
1867    }
1868
1869    /// 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.).
1870    ///
1871    /// Wire method: `sessions.list`.
1872    ///
1873    /// # Returns
1874    ///
1875    /// Sessions matching the filter, ordered most-recently-modified first.
1876    ///
1877    /// <div class="warning">
1878    ///
1879    /// **Experimental.** This API is part of an experimental wire-protocol surface
1880    /// and may change or be removed in future SDK or CLI releases. Pin both the
1881    /// SDK and CLI versions if your code depends on it.
1882    ///
1883    /// </div>
1884    pub async fn list(&self) -> Result<SessionList, Error> {
1885        let wire_params = serde_json::json!({});
1886        let _value = self
1887            .client
1888            .call(rpc_methods::SESSIONS_LIST, Some(wire_params))
1889            .await?;
1890        Ok(serde_json::from_value(_value)?)
1891    }
1892
1893    /// 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.).
1894    ///
1895    /// Wire method: `sessions.list`.
1896    ///
1897    /// # Parameters
1898    ///
1899    /// * `params` - Optional source filter, metadata-load limit, and context filter applied to the returned sessions.
1900    ///
1901    /// # Returns
1902    ///
1903    /// Sessions matching the filter, ordered most-recently-modified first.
1904    ///
1905    /// <div class="warning">
1906    ///
1907    /// **Experimental.** This API is part of an experimental wire-protocol surface
1908    /// and may change or be removed in future SDK or CLI releases. Pin both the
1909    /// SDK and CLI versions if your code depends on it.
1910    ///
1911    /// </div>
1912    pub async fn list_with_params(
1913        &self,
1914        params: SessionsListRequest,
1915    ) -> Result<SessionList, Error> {
1916        let wire_params = serde_json::to_value(params)?;
1917        let _value = self
1918            .client
1919            .call(rpc_methods::SESSIONS_LIST, Some(wire_params))
1920            .await?;
1921        Ok(serde_json::from_value(_value)?)
1922    }
1923
1924    /// Reads lightweight persisted metadata for one local session without opening it.
1925    ///
1926    /// Wire method: `sessions.getMetadata`.
1927    ///
1928    /// # Parameters
1929    ///
1930    /// * `params` - Session ID whose persisted metadata should be read.
1931    ///
1932    /// # Returns
1933    ///
1934    /// Persisted local session metadata when the session exists.
1935    ///
1936    /// <div class="warning">
1937    ///
1938    /// **Experimental.** This API is part of an experimental wire-protocol surface
1939    /// and may change or be removed in future SDK or CLI releases. Pin both the
1940    /// SDK and CLI versions if your code depends on it.
1941    ///
1942    /// </div>
1943    pub(crate) async fn get_metadata(
1944        &self,
1945        params: SessionsGetMetadataRequest,
1946    ) -> Result<SessionsGetMetadataResult, Error> {
1947        let wire_params = serde_json::to_value(params)?;
1948        let _value = self
1949            .client
1950            .call(rpc_methods::SESSIONS_GETMETADATA, Some(wire_params))
1951            .await?;
1952        Ok(serde_json::from_value(_value)?)
1953    }
1954
1955    /// Reads client-owned metadata for multiple persisted local sessions without opening them. Results preserve request order and report missing, corrupt, unsupported, or temporarily unavailable sessions independently.
1956    ///
1957    /// Wire method: `sessions.getClientMetadata`.
1958    ///
1959    /// # Parameters
1960    ///
1961    /// * `params` - Bounded batch request for client-owned metadata from persisted local sessions.
1962    ///
1963    /// # Returns
1964    ///
1965    /// Ordered client metadata outcomes for the requested local sessions.
1966    ///
1967    /// <div class="warning">
1968    ///
1969    /// **Experimental.** This API is part of an experimental wire-protocol surface
1970    /// and may change or be removed in future SDK or CLI releases. Pin both the
1971    /// SDK and CLI versions if your code depends on it.
1972    ///
1973    /// </div>
1974    pub async fn get_client_metadata(
1975        &self,
1976        params: SessionsGetClientMetadataRequest,
1977    ) -> Result<SessionsGetClientMetadataResult, Error> {
1978        let wire_params = serde_json::to_value(params)?;
1979        let _value = self
1980            .client
1981            .call(rpc_methods::SESSIONS_GETCLIENTMETADATA, Some(wire_params))
1982            .await?;
1983        Ok(serde_json::from_value(_value)?)
1984    }
1985
1986    /// Reads a page of durable events directly from a local session's persisted journal without creating, resuming, or activating the session. The first read pins the currently opened journal generation and its byte-length boundary; opaque cursor continuations remain on that generation across runtime-owned compaction, truncation, and rewrite operations, which replace the live path atomically, and events appended after the boundary are excluded. For cold hydration, await the first successful page before activation and establish lossless live-event buffering before resume; merge subsequent live events by ID, preserving persisted order and letting live payloads win. Continuations are process-local, single-use capabilities bound to the originating session and storage context and must be paged sequentially; concurrent or repeated use of the same cursor expires that duplicate read rather than reading the generation twice. A complete snapshot has cursorStatus 'ok' and hasMore false. Snapshots expire after five idle minutes, with at most eight retained per process and idle-only eviction under pressure; completion and cancelled-worker exit release their handles. No transcript copy is created, but retained handles may keep replaced files' disk blocks alive until release. Pages have a soft 1 MiB serialized event-array budget including resolved binary assets; one oversized event is returned alone to guarantee progress. Working memory also includes a record/lookahead and asset resolution; resolving the first binary reference may scan the full pinned generation to build a bounded offset index. If the snapshot expires, is evicted, is cancelled before a continuation is established, or becomes unreadable after an observable unsupported in-place shortening, the continuation returns cursorStatus 'expired' with an empty terminal page and never falls back to a different generation. A missing or initially unreadable journal is an RPC error. Persisted history excludes ephemeral events and may omit payloads that are reconstructed only for an active session; use the active session event stream for post-resume live events.
1987    ///
1988    /// Wire method: `sessions.readPersistedEvents`.
1989    ///
1990    /// # Parameters
1991    ///
1992    /// * `params` - Pagination options for reading an inactive or active local session's persisted event journal.
1993    ///
1994    /// # Returns
1995    ///
1996    /// Batch of session events returned by a read, with cursor and continuation metadata.
1997    ///
1998    /// <div class="warning">
1999    ///
2000    /// **Experimental.** This API is part of an experimental wire-protocol surface
2001    /// and may change or be removed in future SDK or CLI releases. Pin both the
2002    /// SDK and CLI versions if your code depends on it.
2003    ///
2004    /// </div>
2005    pub async fn read_persisted_events(
2006        &self,
2007        params: SessionsReadPersistedEventsRequest,
2008    ) -> Result<EventsReadResult, Error> {
2009        let wire_params = serde_json::to_value(params)?;
2010        let _value = self
2011            .client
2012            .call(rpc_methods::SESSIONS_READPERSISTEDEVENTS, Some(wire_params))
2013            .await?;
2014        Ok(serde_json::from_value(_value)?)
2015    }
2016
2017    /// Lists recent local session IDs that contain user-visible history, omitting housekeeping-only sessions.
2018    ///
2019    /// Wire method: `sessions.listNonEmptySessionIds`.
2020    ///
2021    /// # Parameters
2022    ///
2023    /// * `params` - Limit for non-empty local session IDs.
2024    ///
2025    /// # Returns
2026    ///
2027    /// Recent local session IDs that contain user-visible history.
2028    ///
2029    /// <div class="warning">
2030    ///
2031    /// **Experimental.** This API is part of an experimental wire-protocol surface
2032    /// and may change or be removed in future SDK or CLI releases. Pin both the
2033    /// SDK and CLI versions if your code depends on it.
2034    ///
2035    /// </div>
2036    pub(crate) async fn list_non_empty_session_ids(
2037        &self,
2038        params: SessionsListNonEmptySessionIdsRequest,
2039    ) -> Result<SessionsListNonEmptySessionIdsResult, Error> {
2040        let wire_params = serde_json::to_value(params)?;
2041        let _value = self
2042            .client
2043            .call(
2044                rpc_methods::SESSIONS_LISTNONEMPTYSESSIONIDS,
2045                Some(wire_params),
2046            )
2047            .await?;
2048        Ok(serde_json::from_value(_value)?)
2049    }
2050
2051    /// Finds the local session bound to a GitHub task ID, if any.
2052    ///
2053    /// Wire method: `sessions.findByTaskId`.
2054    ///
2055    /// # Parameters
2056    ///
2057    /// * `params` - GitHub task ID to look up.
2058    ///
2059    /// # Returns
2060    ///
2061    /// ID of the local session bound to the given GitHub task, or omitted when none.
2062    ///
2063    /// <div class="warning">
2064    ///
2065    /// **Experimental.** This API is part of an experimental wire-protocol surface
2066    /// and may change or be removed in future SDK or CLI releases. Pin both the
2067    /// SDK and CLI versions if your code depends on it.
2068    ///
2069    /// </div>
2070    pub async fn find_by_task_id(
2071        &self,
2072        params: SessionsFindByTaskIDRequest,
2073    ) -> Result<SessionsFindByTaskIDResult, Error> {
2074        let wire_params = serde_json::to_value(params)?;
2075        let _value = self
2076            .client
2077            .call(rpc_methods::SESSIONS_FINDBYTASKID, Some(wire_params))
2078            .await?;
2079        Ok(serde_json::from_value(_value)?)
2080    }
2081
2082    /// Resolves a UUID prefix to a unique session ID, if exactly one session matches.
2083    ///
2084    /// Wire method: `sessions.findByPrefix`.
2085    ///
2086    /// # Parameters
2087    ///
2088    /// * `params` - UUID prefix to resolve to a unique session ID.
2089    ///
2090    /// # Returns
2091    ///
2092    /// Session ID matching the prefix, omitted when no unique match exists.
2093    ///
2094    /// <div class="warning">
2095    ///
2096    /// **Experimental.** This API is part of an experimental wire-protocol surface
2097    /// and may change or be removed in future SDK or CLI releases. Pin both the
2098    /// SDK and CLI versions if your code depends on it.
2099    ///
2100    /// </div>
2101    pub async fn find_by_prefix(
2102        &self,
2103        params: SessionsFindByPrefixRequest,
2104    ) -> Result<SessionsFindByPrefixResult, Error> {
2105        let wire_params = serde_json::to_value(params)?;
2106        let _value = self
2107            .client
2108            .call(rpc_methods::SESSIONS_FINDBYPREFIX, Some(wire_params))
2109            .await?;
2110        Ok(serde_json::from_value(_value)?)
2111    }
2112
2113    /// Returns the most-relevant prior session for a given working-directory context.
2114    ///
2115    /// Wire method: `sessions.getLastForContext`.
2116    ///
2117    /// # Parameters
2118    ///
2119    /// * `params` - Optional working-directory context used to score session relevance.
2120    ///
2121    /// # Returns
2122    ///
2123    /// Most-relevant session ID for the supplied context, or omitted when no sessions exist.
2124    ///
2125    /// <div class="warning">
2126    ///
2127    /// **Experimental.** This API is part of an experimental wire-protocol surface
2128    /// and may change or be removed in future SDK or CLI releases. Pin both the
2129    /// SDK and CLI versions if your code depends on it.
2130    ///
2131    /// </div>
2132    pub async fn get_last_for_context(
2133        &self,
2134        params: SessionsGetLastForContextRequest,
2135    ) -> Result<SessionsGetLastForContextResult, Error> {
2136        let wire_params = serde_json::to_value(params)?;
2137        let _value = self
2138            .client
2139            .call(rpc_methods::SESSIONS_GETLASTFORCONTEXT, Some(wire_params))
2140            .await?;
2141        Ok(serde_json::from_value(_value)?)
2142    }
2143
2144    /// 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.
2145    ///
2146    /// Wire method: `sessions.getEventFilePath`.
2147    ///
2148    /// # Parameters
2149    ///
2150    /// * `params` - Session ID whose event-log file path to compute.
2151    ///
2152    /// # Returns
2153    ///
2154    /// Absolute path to the session's events.jsonl file on disk.
2155    ///
2156    /// <div class="warning">
2157    ///
2158    /// **Experimental.** This API is part of an experimental wire-protocol surface
2159    /// and may change or be removed in future SDK or CLI releases. Pin both the
2160    /// SDK and CLI versions if your code depends on it.
2161    ///
2162    /// </div>
2163    pub(crate) async fn get_event_file_path(
2164        &self,
2165        params: SessionsGetEventFilePathRequest,
2166    ) -> Result<SessionsGetEventFilePathResult, Error> {
2167        let wire_params = serde_json::to_value(params)?;
2168        let _value = self
2169            .client
2170            .call(rpc_methods::SESSIONS_GETEVENTFILEPATH, Some(wire_params))
2171            .await?;
2172        Ok(serde_json::from_value(_value)?)
2173    }
2174
2175    /// Returns the on-disk byte size of each session's workspace directory.
2176    ///
2177    /// Wire method: `sessions.getSizes`.
2178    ///
2179    /// # Returns
2180    ///
2181    /// Map of sessionId -> on-disk size in bytes for each session's workspace directory.
2182    ///
2183    /// <div class="warning">
2184    ///
2185    /// **Experimental.** This API is part of an experimental wire-protocol surface
2186    /// and may change or be removed in future SDK or CLI releases. Pin both the
2187    /// SDK and CLI versions if your code depends on it.
2188    ///
2189    /// </div>
2190    pub async fn get_sizes(&self) -> Result<SessionSizes, Error> {
2191        let wire_params = serde_json::json!({});
2192        let _value = self
2193            .client
2194            .call(rpc_methods::SESSIONS_GETSIZES, Some(wire_params))
2195            .await?;
2196        Ok(serde_json::from_value(_value)?)
2197    }
2198
2199    /// Returns the subset of the supplied session IDs that are currently held by another running process.
2200    ///
2201    /// Wire method: `sessions.checkInUse`.
2202    ///
2203    /// # Parameters
2204    ///
2205    /// * `params` - Session IDs to test for live in-use locks.
2206    ///
2207    /// # Returns
2208    ///
2209    /// Session IDs from the input set that are currently in use by another process.
2210    ///
2211    /// <div class="warning">
2212    ///
2213    /// **Experimental.** This API is part of an experimental wire-protocol surface
2214    /// and may change or be removed in future SDK or CLI releases. Pin both the
2215    /// SDK and CLI versions if your code depends on it.
2216    ///
2217    /// </div>
2218    pub async fn check_in_use(
2219        &self,
2220        params: SessionsCheckInUseRequest,
2221    ) -> Result<SessionsCheckInUseResult, Error> {
2222        let wire_params = serde_json::to_value(params)?;
2223        let _value = self
2224            .client
2225            .call(rpc_methods::SESSIONS_CHECKINUSE, Some(wire_params))
2226            .await?;
2227        Ok(serde_json::from_value(_value)?)
2228    }
2229
2230    /// 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.
2231    ///
2232    /// Wire method: `sessions.getPersistedRemoteSteerable`.
2233    ///
2234    /// # Parameters
2235    ///
2236    /// * `params` - Session ID to look up the persisted remote-steerable flag for.
2237    ///
2238    /// # Returns
2239    ///
2240    /// The session's persisted remote-steerable flag, or omitted when no value has been persisted.
2241    ///
2242    /// <div class="warning">
2243    ///
2244    /// **Experimental.** This API is part of an experimental wire-protocol surface
2245    /// and may change or be removed in future SDK or CLI releases. Pin both the
2246    /// SDK and CLI versions if your code depends on it.
2247    ///
2248    /// </div>
2249    pub(crate) async fn get_persisted_remote_steerable(
2250        &self,
2251        params: SessionsGetPersistedRemoteSteerableRequest,
2252    ) -> Result<SessionsGetPersistedRemoteSteerableResult, Error> {
2253        let wire_params = serde_json::to_value(params)?;
2254        let _value = self
2255            .client
2256            .call(
2257                rpc_methods::SESSIONS_GETPERSISTEDREMOTESTEERABLE,
2258                Some(wire_params),
2259            )
2260            .await?;
2261        Ok(serde_json::from_value(_value)?)
2262    }
2263
2264    /// Closes a session: emits shutdown, flushes pending events, releases the in-use lock, and disposes the active session.
2265    ///
2266    /// Wire method: `sessions.close`.
2267    ///
2268    /// # Parameters
2269    ///
2270    /// * `params` - Session ID to close.
2271    ///
2272    /// # Returns
2273    ///
2274    /// 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.
2275    ///
2276    /// <div class="warning">
2277    ///
2278    /// **Experimental.** This API is part of an experimental wire-protocol surface
2279    /// and may change or be removed in future SDK or CLI releases. Pin both the
2280    /// SDK and CLI versions if your code depends on it.
2281    ///
2282    /// </div>
2283    pub async fn close(&self, params: SessionsCloseRequest) -> Result<SessionsCloseResult, Error> {
2284        let wire_params = serde_json::to_value(params)?;
2285        let _value = self
2286            .client
2287            .call(rpc_methods::SESSIONS_CLOSE, Some(wire_params))
2288            .await?;
2289        Ok(serde_json::from_value(_value)?)
2290    }
2291
2292    /// Closes, deactivates, and deletes a set of sessions, returning the bytes freed per session.
2293    ///
2294    /// Wire method: `sessions.bulkDelete`.
2295    ///
2296    /// # Parameters
2297    ///
2298    /// * `params` - Session IDs to close, deactivate, and delete from disk.
2299    ///
2300    /// # Returns
2301    ///
2302    /// Map of sessionId -> bytes freed by removing the session's workspace directory.
2303    ///
2304    /// <div class="warning">
2305    ///
2306    /// **Experimental.** This API is part of an experimental wire-protocol surface
2307    /// and may change or be removed in future SDK or CLI releases. Pin both the
2308    /// SDK and CLI versions if your code depends on it.
2309    ///
2310    /// </div>
2311    pub async fn bulk_delete(
2312        &self,
2313        params: SessionsBulkDeleteRequest,
2314    ) -> Result<SessionBulkDeleteResult, Error> {
2315        let wire_params = serde_json::to_value(params)?;
2316        let _value = self
2317            .client
2318            .call(rpc_methods::SESSIONS_BULKDELETE, Some(wire_params))
2319            .await?;
2320        Ok(serde_json::from_value(_value)?)
2321    }
2322
2323    /// Deletes one local session from disk after running the same lifecycle hooks as the session manager.
2324    ///
2325    /// Wire method: `sessions.delete`.
2326    ///
2327    /// # Parameters
2328    ///
2329    /// * `params` - Session ID to delete from disk.
2330    ///
2331    /// <div class="warning">
2332    ///
2333    /// **Experimental.** This API is part of an experimental wire-protocol surface
2334    /// and may change or be removed in future SDK or CLI releases. Pin both the
2335    /// SDK and CLI versions if your code depends on it.
2336    ///
2337    /// </div>
2338    pub(crate) async fn delete(&self, params: SessionsDeleteRequest) -> Result<(), Error> {
2339        let wire_params = serde_json::to_value(params)?;
2340        let _value = self
2341            .client
2342            .call(rpc_methods::SESSIONS_DELETE, Some(wire_params))
2343            .await?;
2344        Ok(())
2345    }
2346
2347    /// Deletes sessions older than the given threshold, with optional dry-run and exclusion list.
2348    ///
2349    /// Wire method: `sessions.pruneOld`.
2350    ///
2351    /// # Parameters
2352    ///
2353    /// * `params` - Age threshold and optional flags controlling which old sessions are pruned (or simulated when dryRun is true).
2354    ///
2355    /// # Returns
2356    ///
2357    /// Outcome of the prune operation: deleted IDs, dry-run candidates, skipped IDs, total bytes freed, and the dry-run flag.
2358    ///
2359    /// <div class="warning">
2360    ///
2361    /// **Experimental.** This API is part of an experimental wire-protocol surface
2362    /// and may change or be removed in future SDK or CLI releases. Pin both the
2363    /// SDK and CLI versions if your code depends on it.
2364    ///
2365    /// </div>
2366    pub async fn prune_old(
2367        &self,
2368        params: SessionsPruneOldRequest,
2369    ) -> Result<SessionPruneResult, Error> {
2370        let wire_params = serde_json::to_value(params)?;
2371        let _value = self
2372            .client
2373            .call(rpc_methods::SESSIONS_PRUNEOLD, Some(wire_params))
2374            .await?;
2375        Ok(serde_json::from_value(_value)?)
2376    }
2377
2378    /// Flushes a session's pending events to disk.
2379    ///
2380    /// Wire method: `sessions.save`.
2381    ///
2382    /// # Parameters
2383    ///
2384    /// * `params` - Session ID whose pending events should be flushed to disk.
2385    ///
2386    /// # Returns
2387    ///
2388    /// Flush a session's pending events to disk. No-op when no writer exists for the session (e.g., already closed).
2389    ///
2390    /// <div class="warning">
2391    ///
2392    /// **Experimental.** This API is part of an experimental wire-protocol surface
2393    /// and may change or be removed in future SDK or CLI releases. Pin both the
2394    /// SDK and CLI versions if your code depends on it.
2395    ///
2396    /// </div>
2397    pub async fn save(&self, params: SessionsSaveRequest) -> Result<SessionsSaveResult, Error> {
2398        let wire_params = serde_json::to_value(params)?;
2399        let _value = self
2400            .client
2401            .call(rpc_methods::SESSIONS_SAVE, Some(wire_params))
2402            .await?;
2403        Ok(serde_json::from_value(_value)?)
2404    }
2405
2406    /// Releases the in-use lock held by this process for a session.
2407    ///
2408    /// Wire method: `sessions.releaseLock`.
2409    ///
2410    /// # Parameters
2411    ///
2412    /// * `params` - Session ID whose in-use lock should be released.
2413    ///
2414    /// # Returns
2415    ///
2416    /// 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.
2417    ///
2418    /// <div class="warning">
2419    ///
2420    /// **Experimental.** This API is part of an experimental wire-protocol surface
2421    /// and may change or be removed in future SDK or CLI releases. Pin both the
2422    /// SDK and CLI versions if your code depends on it.
2423    ///
2424    /// </div>
2425    pub async fn release_lock(
2426        &self,
2427        params: SessionsReleaseLockRequest,
2428    ) -> Result<SessionsReleaseLockResult, Error> {
2429        let wire_params = serde_json::to_value(params)?;
2430        let _value = self
2431            .client
2432            .call(rpc_methods::SESSIONS_RELEASELOCK, Some(wire_params))
2433            .await?;
2434        Ok(serde_json::from_value(_value)?)
2435    }
2436
2437    /// Backfills missing summary and context fields on the supplied session metadata records.
2438    ///
2439    /// Wire method: `sessions.enrichMetadata`.
2440    ///
2441    /// # Parameters
2442    ///
2443    /// * `params` - Session metadata records to enrich with summary and context information.
2444    ///
2445    /// # Returns
2446    ///
2447    /// The enriched metadata records, with summary and context fields backfilled where available. Sessions confirmed empty and unnamed are omitted.
2448    ///
2449    /// <div class="warning">
2450    ///
2451    /// **Experimental.** This API is part of an experimental wire-protocol surface
2452    /// and may change or be removed in future SDK or CLI releases. Pin both the
2453    /// SDK and CLI versions if your code depends on it.
2454    ///
2455    /// </div>
2456    pub async fn enrich_metadata(
2457        &self,
2458        params: SessionsEnrichMetadataRequest,
2459    ) -> Result<SessionEnrichMetadataResult, Error> {
2460        let wire_params = serde_json::to_value(params)?;
2461        let _value = self
2462            .client
2463            .call(rpc_methods::SESSIONS_ENRICHMETADATA, Some(wire_params))
2464            .await?;
2465        Ok(serde_json::from_value(_value)?)
2466    }
2467
2468    /// Reloads user, plugin, and (optionally) repo hooks on the active session.
2469    ///
2470    /// Wire method: `sessions.reloadPluginHooks`.
2471    ///
2472    /// # Parameters
2473    ///
2474    /// * `params` - Active session ID and an optional flag for deferring repo-level hooks until folder trust.
2475    ///
2476    /// # Returns
2477    ///
2478    /// 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.
2479    ///
2480    /// <div class="warning">
2481    ///
2482    /// **Experimental.** This API is part of an experimental wire-protocol surface
2483    /// and may change or be removed in future SDK or CLI releases. Pin both the
2484    /// SDK and CLI versions if your code depends on it.
2485    ///
2486    /// </div>
2487    pub async fn reload_plugin_hooks(
2488        &self,
2489        params: SessionsReloadPluginHooksRequest,
2490    ) -> Result<SessionsReloadPluginHooksResult, Error> {
2491        let wire_params = serde_json::to_value(params)?;
2492        let _value = self
2493            .client
2494            .call(rpc_methods::SESSIONS_RELOADPLUGINHOOKS, Some(wire_params))
2495            .await?;
2496        Ok(serde_json::from_value(_value)?)
2497    }
2498
2499    /// Loads previously-deferred repo-level hooks on the active session, returning queued startup prompts.
2500    ///
2501    /// Wire method: `sessions.loadDeferredRepoHooks`.
2502    ///
2503    /// # Parameters
2504    ///
2505    /// * `params` - Active session ID whose deferred repo-level hooks should be loaded.
2506    ///
2507    /// # Returns
2508    ///
2509    /// Queued repo-level startup prompts and the total hook command count after loading.
2510    ///
2511    /// <div class="warning">
2512    ///
2513    /// **Experimental.** This API is part of an experimental wire-protocol surface
2514    /// and may change or be removed in future SDK or CLI releases. Pin both the
2515    /// SDK and CLI versions if your code depends on it.
2516    ///
2517    /// </div>
2518    pub async fn load_deferred_repo_hooks(
2519        &self,
2520        params: SessionsLoadDeferredRepoHooksRequest,
2521    ) -> Result<SessionLoadDeferredRepoHooksResult, Error> {
2522        let wire_params = serde_json::to_value(params)?;
2523        let _value = self
2524            .client
2525            .call(
2526                rpc_methods::SESSIONS_LOADDEFERREDREPOHOOKS,
2527                Some(wire_params),
2528            )
2529            .await?;
2530        Ok(serde_json::from_value(_value)?)
2531    }
2532
2533    /// Replaces the manager-wide additional plugins registered with the session manager.
2534    ///
2535    /// Wire method: `sessions.setAdditionalPlugins`.
2536    ///
2537    /// # Parameters
2538    ///
2539    /// * `params` - Manager-wide additional plugins to register; replaces any previously-configured set.
2540    ///
2541    /// # Returns
2542    ///
2543    /// 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.
2544    ///
2545    /// <div class="warning">
2546    ///
2547    /// **Experimental.** This API is part of an experimental wire-protocol surface
2548    /// and may change or be removed in future SDK or CLI releases. Pin both the
2549    /// SDK and CLI versions if your code depends on it.
2550    ///
2551    /// </div>
2552    pub async fn set_additional_plugins(
2553        &self,
2554        params: SessionsSetAdditionalPluginsRequest,
2555    ) -> Result<SessionsSetAdditionalPluginsResult, Error> {
2556        let wire_params = serde_json::to_value(params)?;
2557        let _value = self
2558            .client
2559            .call(
2560                rpc_methods::SESSIONS_SETADDITIONALPLUGINS,
2561                Some(wire_params),
2562            )
2563            .await?;
2564        Ok(serde_json::from_value(_value)?)
2565    }
2566
2567    /// 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.
2568    ///
2569    /// Wire method: `sessions.getBoardEntryCount`.
2570    ///
2571    /// # Parameters
2572    ///
2573    /// * `params` - Session ID whose board entry count should be returned.
2574    ///
2575    /// # Returns
2576    ///
2577    /// Dynamic-context board entry count, when available.
2578    ///
2579    /// <div class="warning">
2580    ///
2581    /// **Experimental.** This API is part of an experimental wire-protocol surface
2582    /// and may change or be removed in future SDK or CLI releases. Pin both the
2583    /// SDK and CLI versions if your code depends on it.
2584    ///
2585    /// </div>
2586    pub(crate) async fn get_board_entry_count(
2587        &self,
2588        params: SessionsGetBoardEntryCountRequest,
2589    ) -> Result<SessionsGetBoardEntryCountResult, Error> {
2590        let wire_params = serde_json::to_value(params)?;
2591        let _value = self
2592            .client
2593            .call(rpc_methods::SESSIONS_GETBOARDENTRYCOUNT, Some(wire_params))
2594            .await?;
2595        Ok(serde_json::from_value(_value)?)
2596    }
2597
2598    /// 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.
2599    ///
2600    /// Wire method: `sessions.startRemoteControl`.
2601    ///
2602    /// # Parameters
2603    ///
2604    /// * `params` - Parameters for attaching the remote-control singleton to a session.
2605    ///
2606    /// # Returns
2607    ///
2608    /// Wrapper for the singleton's current status.
2609    ///
2610    /// <div class="warning">
2611    ///
2612    /// **Experimental.** This API is part of an experimental wire-protocol surface
2613    /// and may change or be removed in future SDK or CLI releases. Pin both the
2614    /// SDK and CLI versions if your code depends on it.
2615    ///
2616    /// </div>
2617    pub async fn start_remote_control(
2618        &self,
2619        params: SessionsStartRemoteControlRequest,
2620    ) -> Result<RemoteControlStatusResult, Error> {
2621        let wire_params = serde_json::to_value(params)?;
2622        let _value = self
2623            .client
2624            .call(rpc_methods::SESSIONS_STARTREMOTECONTROL, Some(wire_params))
2625            .await?;
2626        Ok(serde_json::from_value(_value)?)
2627    }
2628
2629    /// 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.
2630    ///
2631    /// Wire method: `sessions.transferRemoteControl`.
2632    ///
2633    /// # Parameters
2634    ///
2635    /// * `params` - Parameters for atomically rebinding the remote-control singleton.
2636    ///
2637    /// # Returns
2638    ///
2639    /// Outcome of a transferRemoteControl call.
2640    ///
2641    /// <div class="warning">
2642    ///
2643    /// **Experimental.** This API is part of an experimental wire-protocol surface
2644    /// and may change or be removed in future SDK or CLI releases. Pin both the
2645    /// SDK and CLI versions if your code depends on it.
2646    ///
2647    /// </div>
2648    pub async fn transfer_remote_control(
2649        &self,
2650        params: SessionsTransferRemoteControlRequest,
2651    ) -> Result<RemoteControlTransferResult, Error> {
2652        let wire_params = serde_json::to_value(params)?;
2653        let _value = self
2654            .client
2655            .call(
2656                rpc_methods::SESSIONS_TRANSFERREMOTECONTROL,
2657                Some(wire_params),
2658            )
2659            .await?;
2660        Ok(serde_json::from_value(_value)?)
2661    }
2662
2663    /// 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.
2664    ///
2665    /// Wire method: `sessions.setRemoteControlSteering`.
2666    ///
2667    /// # Parameters
2668    ///
2669    /// * `params` - Patch for the singleton's steering state.
2670    ///
2671    /// # Returns
2672    ///
2673    /// Wrapper for the singleton's current status.
2674    ///
2675    /// <div class="warning">
2676    ///
2677    /// **Experimental.** This API is part of an experimental wire-protocol surface
2678    /// and may change or be removed in future SDK or CLI releases. Pin both the
2679    /// SDK and CLI versions if your code depends on it.
2680    ///
2681    /// </div>
2682    pub async fn set_remote_control_steering(
2683        &self,
2684        params: SessionsSetRemoteControlSteeringRequest,
2685    ) -> Result<RemoteControlStatusResult, Error> {
2686        let wire_params = serde_json::to_value(params)?;
2687        let _value = self
2688            .client
2689            .call(
2690                rpc_methods::SESSIONS_SETREMOTECONTROLSTEERING,
2691                Some(wire_params),
2692            )
2693            .await?;
2694        Ok(serde_json::from_value(_value)?)
2695    }
2696
2697    /// 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).
2698    ///
2699    /// Wire method: `sessions.stopRemoteControl`.
2700    ///
2701    /// # Returns
2702    ///
2703    /// Outcome of a stopRemoteControl call.
2704    ///
2705    /// <div class="warning">
2706    ///
2707    /// **Experimental.** This API is part of an experimental wire-protocol surface
2708    /// and may change or be removed in future SDK or CLI releases. Pin both the
2709    /// SDK and CLI versions if your code depends on it.
2710    ///
2711    /// </div>
2712    pub async fn stop_remote_control(&self) -> Result<RemoteControlStopResult, Error> {
2713        let wire_params = serde_json::json!({});
2714        let _value = self
2715            .client
2716            .call(rpc_methods::SESSIONS_STOPREMOTECONTROL, Some(wire_params))
2717            .await?;
2718        Ok(serde_json::from_value(_value)?)
2719    }
2720
2721    /// 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).
2722    ///
2723    /// Wire method: `sessions.stopRemoteControl`.
2724    ///
2725    /// # Parameters
2726    ///
2727    /// * `params` - Parameters for stopping the remote-control singleton.
2728    ///
2729    /// # Returns
2730    ///
2731    /// Outcome of a stopRemoteControl call.
2732    ///
2733    /// <div class="warning">
2734    ///
2735    /// **Experimental.** This API is part of an experimental wire-protocol surface
2736    /// and may change or be removed in future SDK or CLI releases. Pin both the
2737    /// SDK and CLI versions if your code depends on it.
2738    ///
2739    /// </div>
2740    pub async fn stop_remote_control_with_params(
2741        &self,
2742        params: SessionsStopRemoteControlRequest,
2743    ) -> Result<RemoteControlStopResult, Error> {
2744        let wire_params = serde_json::to_value(params)?;
2745        let _value = self
2746            .client
2747            .call(rpc_methods::SESSIONS_STOPREMOTECONTROL, Some(wire_params))
2748            .await?;
2749        Ok(serde_json::from_value(_value)?)
2750    }
2751
2752    /// Returns the current state of the remote-control singleton, including the attached session id and frontend URL when active.
2753    ///
2754    /// Wire method: `sessions.getRemoteControlStatus`.
2755    ///
2756    /// # Returns
2757    ///
2758    /// Wrapper for the singleton's current status.
2759    ///
2760    /// <div class="warning">
2761    ///
2762    /// **Experimental.** This API is part of an experimental wire-protocol surface
2763    /// and may change or be removed in future SDK or CLI releases. Pin both the
2764    /// SDK and CLI versions if your code depends on it.
2765    ///
2766    /// </div>
2767    pub async fn get_remote_control_status(&self) -> Result<RemoteControlStatusResult, Error> {
2768        let wire_params = serde_json::json!({});
2769        let _value = self
2770            .client
2771            .call(
2772                rpc_methods::SESSIONS_GETREMOTECONTROLSTATUS,
2773                Some(wire_params),
2774            )
2775            .await?;
2776        Ok(serde_json::from_value(_value)?)
2777    }
2778
2779    /// 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.
2780    ///
2781    /// Wire method: `sessions.registerExtensionToolsOnSession`.
2782    ///
2783    /// # Parameters
2784    ///
2785    /// * `params` - Params to attach an extension loader's tools to a session.
2786    ///
2787    /// # Returns
2788    ///
2789    /// Handle for releasing the extension tool registration.
2790    ///
2791    /// <div class="warning">
2792    ///
2793    /// **Experimental.** This API is part of an experimental wire-protocol surface
2794    /// and may change or be removed in future SDK or CLI releases. Pin both the
2795    /// SDK and CLI versions if your code depends on it.
2796    ///
2797    /// </div>
2798    pub(crate) async fn register_extension_tools_on_session(
2799        &self,
2800        params: RegisterExtensionToolsParams,
2801    ) -> Result<RegisterExtensionToolsResult, Error> {
2802        let wire_params = serde_json::to_value(params)?;
2803        let _value = self
2804            .client
2805            .call(
2806                rpc_methods::SESSIONS_REGISTEREXTENSIONTOOLSONSESSION,
2807                Some(wire_params),
2808            )
2809            .await?;
2810        Ok(serde_json::from_value(_value)?)
2811    }
2812
2813    /// 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.
2814    ///
2815    /// Wire method: `sessions.configureSessionExtensions`.
2816    ///
2817    /// # Parameters
2818    ///
2819    /// * `params` - Params to attach or detach an in-process ExtensionController delegate.
2820    ///
2821    /// <div class="warning">
2822    ///
2823    /// **Experimental.** This API is part of an experimental wire-protocol surface
2824    /// and may change or be removed in future SDK or CLI releases. Pin both the
2825    /// SDK and CLI versions if your code depends on it.
2826    ///
2827    /// </div>
2828    pub(crate) async fn configure_session_extensions(
2829        &self,
2830        params: ConfigureSessionExtensionsParams,
2831    ) -> Result<(), Error> {
2832        let wire_params = serde_json::to_value(params)?;
2833        let _value = self
2834            .client
2835            .call(
2836                rpc_methods::SESSIONS_CONFIGURESESSIONEXTENSIONS,
2837                Some(wire_params),
2838            )
2839            .await?;
2840        Ok(())
2841    }
2842}
2843
2844/// `skills.*` RPCs.
2845#[derive(Clone, Copy)]
2846pub struct ClientRpcSkills<'a> {
2847    pub(crate) client: &'a Client,
2848}
2849
2850impl<'a> ClientRpcSkills<'a> {
2851    /// `skills.config.*` sub-namespace.
2852    pub fn config(&self) -> ClientRpcSkillsConfig<'a> {
2853        ClientRpcSkillsConfig {
2854            client: self.client,
2855        }
2856    }
2857
2858    /// Discovers skills across global and project sources.
2859    ///
2860    /// Wire method: `skills.discover`.
2861    ///
2862    /// # Parameters
2863    ///
2864    /// * `params` - Optional project paths and additional skill directories to include in discovery.
2865    ///
2866    /// # Returns
2867    ///
2868    /// Skills discovered across global and project sources.
2869    ///
2870    /// <div class="warning">
2871    ///
2872    /// **Experimental.** This API is part of an experimental wire-protocol surface
2873    /// and may change or be removed in future SDK or CLI releases. Pin both the
2874    /// SDK and CLI versions if your code depends on it.
2875    ///
2876    /// </div>
2877    pub async fn discover(&self, params: SkillsDiscoverRequest) -> Result<ServerSkillList, Error> {
2878        let wire_params = serde_json::to_value(params)?;
2879        let _value = self
2880            .client
2881            .call(rpc_methods::SKILLS_DISCOVER, Some(wire_params))
2882            .await?;
2883        Ok(serde_json::from_value(_value)?)
2884    }
2885
2886    /// 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.
2887    ///
2888    /// Wire method: `skills.getDiscoveryPaths`.
2889    ///
2890    /// # Parameters
2891    ///
2892    /// * `params` - Optional project paths to enumerate.
2893    ///
2894    /// # Returns
2895    ///
2896    /// Canonical locations where skills can be created so the runtime will recognize them.
2897    ///
2898    /// <div class="warning">
2899    ///
2900    /// **Experimental.** This API is part of an experimental wire-protocol surface
2901    /// and may change or be removed in future SDK or CLI releases. Pin both the
2902    /// SDK and CLI versions if your code depends on it.
2903    ///
2904    /// </div>
2905    pub async fn get_discovery_paths(
2906        &self,
2907        params: SkillsGetDiscoveryPathsRequest,
2908    ) -> Result<SkillDiscoveryPathList, Error> {
2909        let wire_params = serde_json::to_value(params)?;
2910        let _value = self
2911            .client
2912            .call(rpc_methods::SKILLS_GETDISCOVERYPATHS, Some(wire_params))
2913            .await?;
2914        Ok(serde_json::from_value(_value)?)
2915    }
2916}
2917
2918/// `skills.config.*` RPCs.
2919#[derive(Clone, Copy)]
2920pub struct ClientRpcSkillsConfig<'a> {
2921    pub(crate) client: &'a Client,
2922}
2923
2924impl<'a> ClientRpcSkillsConfig<'a> {
2925    /// Replaces the global list of disabled skills.
2926    ///
2927    /// Wire method: `skills.config.setDisabledSkills`.
2928    ///
2929    /// # Parameters
2930    ///
2931    /// * `params` - Skill names to mark as disabled in global configuration, replacing any previous list.
2932    ///
2933    /// <div class="warning">
2934    ///
2935    /// **Experimental.** This API is part of an experimental wire-protocol surface
2936    /// and may change or be removed in future SDK or CLI releases. Pin both the
2937    /// SDK and CLI versions if your code depends on it.
2938    ///
2939    /// </div>
2940    pub async fn set_disabled_skills(
2941        &self,
2942        params: SkillsConfigSetDisabledSkillsRequest,
2943    ) -> Result<(), Error> {
2944        let wire_params = serde_json::to_value(params)?;
2945        let _value = self
2946            .client
2947            .call(
2948                rpc_methods::SKILLS_CONFIG_SETDISABLEDSKILLS,
2949                Some(wire_params),
2950            )
2951            .await?;
2952        Ok(())
2953    }
2954
2955    /// Atomically adds or removes one skill from the disabled list.
2956    ///
2957    /// Wire method: `skills.config.setSkillDisabled`.
2958    ///
2959    /// # Parameters
2960    ///
2961    /// * `params` - Adds or removes a single skill from the global disabled list, leaving every other entry untouched.
2962    ///
2963    /// <div class="warning">
2964    ///
2965    /// **Experimental.** This API is part of an experimental wire-protocol surface
2966    /// and may change or be removed in future SDK or CLI releases. Pin both the
2967    /// SDK and CLI versions if your code depends on it.
2968    ///
2969    /// </div>
2970    pub async fn set_skill_disabled(
2971        &self,
2972        params: SkillsConfigSetSkillDisabledRequest,
2973    ) -> Result<(), Error> {
2974        let wire_params = serde_json::to_value(params)?;
2975        let _value = self
2976            .client
2977            .call(
2978                rpc_methods::SKILLS_CONFIG_SETSKILLDISABLED,
2979                Some(wire_params),
2980            )
2981            .await?;
2982        Ok(())
2983    }
2984}
2985
2986/// `tools.*` RPCs.
2987#[derive(Clone, Copy)]
2988pub struct ClientRpcTools<'a> {
2989    pub(crate) client: &'a Client,
2990}
2991
2992impl<'a> ClientRpcTools<'a> {
2993    /// Lists built-in tools available for a model.
2994    ///
2995    /// Wire method: `tools.list`.
2996    ///
2997    /// # Parameters
2998    ///
2999    /// * `params` - Optional model identifier whose tool overrides should be applied to the listing.
3000    ///
3001    /// # Returns
3002    ///
3003    /// Built-in tools available for the requested model, with their parameters and instructions.
3004    ///
3005    /// <div class="warning">
3006    ///
3007    /// **Experimental.** This API is part of an experimental wire-protocol surface
3008    /// and may change or be removed in future SDK or CLI releases. Pin both the
3009    /// SDK and CLI versions if your code depends on it.
3010    ///
3011    /// </div>
3012    pub async fn list(&self, params: ToolsListRequest) -> Result<ToolList, Error> {
3013        let wire_params = serde_json::to_value(params)?;
3014        let _value = self
3015            .client
3016            .call(rpc_methods::TOOLS_LIST, Some(wire_params))
3017            .await?;
3018        Ok(serde_json::from_value(_value)?)
3019    }
3020}
3021
3022/// `user.*` RPCs.
3023#[derive(Clone, Copy)]
3024pub struct ClientRpcUser<'a> {
3025    pub(crate) client: &'a Client,
3026}
3027
3028impl<'a> ClientRpcUser<'a> {
3029    /// `user.settings.*` sub-namespace.
3030    pub fn settings(&self) -> ClientRpcUserSettings<'a> {
3031        ClientRpcUserSettings {
3032            client: self.client,
3033        }
3034    }
3035}
3036
3037/// `user.settings.*` RPCs.
3038#[derive(Clone, Copy)]
3039pub struct ClientRpcUserSettings<'a> {
3040    pub(crate) client: &'a Client,
3041}
3042
3043impl<'a> ClientRpcUserSettings<'a> {
3044    /// Drops this runtime process's in-memory user settings cache so the next settings read observes disk.
3045    ///
3046    /// Wire method: `user.settings.reload`.
3047    ///
3048    /// <div class="warning">
3049    ///
3050    /// **Experimental.** This API is part of an experimental wire-protocol surface
3051    /// and may change or be removed in future SDK or CLI releases. Pin both the
3052    /// SDK and CLI versions if your code depends on it.
3053    ///
3054    /// </div>
3055    pub async fn reload(&self) -> Result<(), Error> {
3056        let wire_params = serde_json::json!({});
3057        let _value = self
3058            .client
3059            .call(rpc_methods::USER_SETTINGS_RELOAD, Some(wire_params))
3060            .await?;
3061        Ok(())
3062    }
3063
3064    /// 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.
3065    ///
3066    /// Wire method: `user.settings.get`.
3067    ///
3068    /// # Returns
3069    ///
3070    /// 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.
3071    ///
3072    /// <div class="warning">
3073    ///
3074    /// **Experimental.** This API is part of an experimental wire-protocol surface
3075    /// and may change or be removed in future SDK or CLI releases. Pin both the
3076    /// SDK and CLI versions if your code depends on it.
3077    ///
3078    /// </div>
3079    pub async fn get(&self) -> Result<UserSettingsGetResult, Error> {
3080        let wire_params = serde_json::json!({});
3081        let _value = self
3082            .client
3083            .call(rpc_methods::USER_SETTINGS_GET, Some(wire_params))
3084            .await?;
3085        Ok(serde_json::from_value(_value)?)
3086    }
3087
3088    /// 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.
3089    ///
3090    /// Wire method: `user.settings.set`.
3091    ///
3092    /// # Parameters
3093    ///
3094    /// * `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.
3095    ///
3096    /// # Returns
3097    ///
3098    /// Outcome of writing user settings.
3099    ///
3100    /// <div class="warning">
3101    ///
3102    /// **Experimental.** This API is part of an experimental wire-protocol surface
3103    /// and may change or be removed in future SDK or CLI releases. Pin both the
3104    /// SDK and CLI versions if your code depends on it.
3105    ///
3106    /// </div>
3107    pub async fn set(
3108        &self,
3109        params: UserSettingsSetRequest,
3110    ) -> Result<UserSettingsSetResult, Error> {
3111        let wire_params = serde_json::to_value(params)?;
3112        let _value = self
3113            .client
3114            .call(rpc_methods::USER_SETTINGS_SET, Some(wire_params))
3115            .await?;
3116        Ok(serde_json::from_value(_value)?)
3117    }
3118}
3119
3120/// Typed view over a [`Session`]'s RPC namespace.
3121#[derive(Clone, Copy)]
3122pub struct SessionRpc<'a> {
3123    pub(crate) session: &'a Session,
3124}
3125
3126impl<'a> SessionRpc<'a> {
3127    /// `session.agent.*` sub-namespace.
3128    pub fn agent(&self) -> SessionRpcAgent<'a> {
3129        SessionRpcAgent {
3130            session: self.session,
3131        }
3132    }
3133
3134    /// `session.autopilotObjective.*` sub-namespace.
3135    pub fn autopilot_objective(&self) -> SessionRpcAutopilotObjective<'a> {
3136        SessionRpcAutopilotObjective {
3137            session: self.session,
3138        }
3139    }
3140
3141    /// `session.canvas.*` sub-namespace.
3142    pub fn canvas(&self) -> SessionRpcCanvas<'a> {
3143        SessionRpcCanvas {
3144            session: self.session,
3145        }
3146    }
3147
3148    /// `session.commands.*` sub-namespace.
3149    pub fn commands(&self) -> SessionRpcCommands<'a> {
3150        SessionRpcCommands {
3151            session: self.session,
3152        }
3153    }
3154
3155    /// `session.completions.*` sub-namespace.
3156    pub fn completions(&self) -> SessionRpcCompletions<'a> {
3157        SessionRpcCompletions {
3158            session: self.session,
3159        }
3160    }
3161
3162    /// `session.contentExclusion.*` sub-namespace.
3163    pub fn content_exclusion(&self) -> SessionRpcContentExclusion<'a> {
3164        SessionRpcContentExclusion {
3165            session: self.session,
3166        }
3167    }
3168
3169    /// `session.debug.*` sub-namespace.
3170    pub fn debug(&self) -> SessionRpcDebug<'a> {
3171        SessionRpcDebug {
3172            session: self.session,
3173        }
3174    }
3175
3176    /// `session.eventLog.*` sub-namespace.
3177    pub fn event_log(&self) -> SessionRpcEventLog<'a> {
3178        SessionRpcEventLog {
3179            session: self.session,
3180        }
3181    }
3182
3183    /// `session.extensions.*` sub-namespace.
3184    pub fn extensions(&self) -> SessionRpcExtensions<'a> {
3185        SessionRpcExtensions {
3186            session: self.session,
3187        }
3188    }
3189
3190    /// `session.factory.*` sub-namespace.
3191    pub fn factory(&self) -> SessionRpcFactory<'a> {
3192        SessionRpcFactory {
3193            session: self.session,
3194        }
3195    }
3196
3197    /// `session.fleet.*` sub-namespace.
3198    pub fn fleet(&self) -> SessionRpcFleet<'a> {
3199        SessionRpcFleet {
3200            session: self.session,
3201        }
3202    }
3203
3204    /// `session.gitHubAuth.*` sub-namespace.
3205    pub fn git_hub_auth(&self) -> SessionRpcGitHubAuth<'a> {
3206        SessionRpcGitHubAuth {
3207            session: self.session,
3208        }
3209    }
3210
3211    /// `session.history.*` sub-namespace.
3212    pub fn history(&self) -> SessionRpcHistory<'a> {
3213        SessionRpcHistory {
3214            session: self.session,
3215        }
3216    }
3217
3218    /// `session.instructions.*` sub-namespace.
3219    pub fn instructions(&self) -> SessionRpcInstructions<'a> {
3220        SessionRpcInstructions {
3221            session: self.session,
3222        }
3223    }
3224
3225    /// `session.limitPrediction.*` sub-namespace.
3226    pub fn limit_prediction(&self) -> SessionRpcLimitPrediction<'a> {
3227        SessionRpcLimitPrediction {
3228            session: self.session,
3229        }
3230    }
3231
3232    /// `session.lsp.*` sub-namespace.
3233    pub fn lsp(&self) -> SessionRpcLsp<'a> {
3234        SessionRpcLsp {
3235            session: self.session,
3236        }
3237    }
3238
3239    /// `session.mcp.*` sub-namespace.
3240    pub fn mcp(&self) -> SessionRpcMcp<'a> {
3241        SessionRpcMcp {
3242            session: self.session,
3243        }
3244    }
3245
3246    /// `session.metadata.*` sub-namespace.
3247    pub fn metadata(&self) -> SessionRpcMetadata<'a> {
3248        SessionRpcMetadata {
3249            session: self.session,
3250        }
3251    }
3252
3253    /// `session.mode.*` sub-namespace.
3254    pub fn mode(&self) -> SessionRpcMode<'a> {
3255        SessionRpcMode {
3256            session: self.session,
3257        }
3258    }
3259
3260    /// `session.model.*` sub-namespace.
3261    pub fn model(&self) -> SessionRpcModel<'a> {
3262        SessionRpcModel {
3263            session: self.session,
3264        }
3265    }
3266
3267    /// `session.name.*` sub-namespace.
3268    pub fn name(&self) -> SessionRpcName<'a> {
3269        SessionRpcName {
3270            session: self.session,
3271        }
3272    }
3273
3274    /// `session.options.*` sub-namespace.
3275    pub fn options(&self) -> SessionRpcOptions<'a> {
3276        SessionRpcOptions {
3277            session: self.session,
3278        }
3279    }
3280
3281    /// `session.permissions.*` sub-namespace.
3282    pub fn permissions(&self) -> SessionRpcPermissions<'a> {
3283        SessionRpcPermissions {
3284            session: self.session,
3285        }
3286    }
3287
3288    /// `session.plan.*` sub-namespace.
3289    pub fn plan(&self) -> SessionRpcPlan<'a> {
3290        SessionRpcPlan {
3291            session: self.session,
3292        }
3293    }
3294
3295    /// `session.plugins.*` sub-namespace.
3296    pub fn plugins(&self) -> SessionRpcPlugins<'a> {
3297        SessionRpcPlugins {
3298            session: self.session,
3299        }
3300    }
3301
3302    /// `session.provider.*` sub-namespace.
3303    pub fn provider(&self) -> SessionRpcProvider<'a> {
3304        SessionRpcProvider {
3305            session: self.session,
3306        }
3307    }
3308
3309    /// `session.queue.*` sub-namespace.
3310    pub fn queue(&self) -> SessionRpcQueue<'a> {
3311        SessionRpcQueue {
3312            session: self.session,
3313        }
3314    }
3315
3316    /// `session.remote.*` sub-namespace.
3317    pub fn remote(&self) -> SessionRpcRemote<'a> {
3318        SessionRpcRemote {
3319            session: self.session,
3320        }
3321    }
3322
3323    /// `session.sandbox.*` sub-namespace.
3324    pub fn sandbox(&self) -> SessionRpcSandbox<'a> {
3325        SessionRpcSandbox {
3326            session: self.session,
3327        }
3328    }
3329
3330    /// `session.schedule.*` sub-namespace.
3331    pub fn schedule(&self) -> SessionRpcSchedule<'a> {
3332        SessionRpcSchedule {
3333            session: self.session,
3334        }
3335    }
3336
3337    /// `session.settings.*` sub-namespace.
3338    pub fn settings(&self) -> SessionRpcSettings<'a> {
3339        SessionRpcSettings {
3340            session: self.session,
3341        }
3342    }
3343
3344    /// `session.shell.*` sub-namespace.
3345    pub fn shell(&self) -> SessionRpcShell<'a> {
3346        SessionRpcShell {
3347            session: self.session,
3348        }
3349    }
3350
3351    /// `session.skills.*` sub-namespace.
3352    pub fn skills(&self) -> SessionRpcSkills<'a> {
3353        SessionRpcSkills {
3354            session: self.session,
3355        }
3356    }
3357
3358    /// `session.tasks.*` sub-namespace.
3359    pub fn tasks(&self) -> SessionRpcTasks<'a> {
3360        SessionRpcTasks {
3361            session: self.session,
3362        }
3363    }
3364
3365    /// `session.telemetry.*` sub-namespace.
3366    pub fn telemetry(&self) -> SessionRpcTelemetry<'a> {
3367        SessionRpcTelemetry {
3368            session: self.session,
3369        }
3370    }
3371
3372    /// `session.tools.*` sub-namespace.
3373    pub fn tools(&self) -> SessionRpcTools<'a> {
3374        SessionRpcTools {
3375            session: self.session,
3376        }
3377    }
3378
3379    /// `session.ui.*` sub-namespace.
3380    pub fn ui(&self) -> SessionRpcUi<'a> {
3381        SessionRpcUi {
3382            session: self.session,
3383        }
3384    }
3385
3386    /// `session.usage.*` sub-namespace.
3387    pub fn usage(&self) -> SessionRpcUsage<'a> {
3388        SessionRpcUsage {
3389            session: self.session,
3390        }
3391    }
3392
3393    /// `session.visibility.*` sub-namespace.
3394    pub fn visibility(&self) -> SessionRpcVisibility<'a> {
3395        SessionRpcVisibility {
3396            session: self.session,
3397        }
3398    }
3399
3400    /// `session.workspaces.*` sub-namespace.
3401    pub fn workspaces(&self) -> SessionRpcWorkspaces<'a> {
3402        SessionRpcWorkspaces {
3403            session: self.session,
3404        }
3405    }
3406
3407    /// Suspends the session while preserving persisted state for later resume.
3408    ///
3409    /// Wire method: `session.suspend`.
3410    ///
3411    /// <div class="warning">
3412    ///
3413    /// **Experimental.** This API is part of an experimental wire-protocol surface
3414    /// and may change or be removed in future SDK or CLI releases. Pin both the
3415    /// SDK and CLI versions if your code depends on it.
3416    ///
3417    /// </div>
3418    pub async fn suspend(&self) -> Result<(), Error> {
3419        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3420        let _value = self
3421            .session
3422            .client()
3423            .call(rpc_methods::SESSION_SUSPEND, Some(wire_params))
3424            .await?;
3425        Ok(())
3426    }
3427
3428    /// Sends a user message to the session and returns its message ID.
3429    ///
3430    /// Wire method: `session.send`.
3431    ///
3432    /// # Parameters
3433    ///
3434    /// * `params` - Parameters for sending a user message to the session
3435    ///
3436    /// # Returns
3437    ///
3438    /// Result of sending a user message
3439    ///
3440    /// <div class="warning">
3441    ///
3442    /// **Experimental.** This API is part of an experimental wire-protocol surface
3443    /// and may change or be removed in future SDK or CLI releases. Pin both the
3444    /// SDK and CLI versions if your code depends on it.
3445    ///
3446    /// </div>
3447    pub async fn send(&self, params: SendRequest) -> Result<SendResult, Error> {
3448        let mut wire_params = serde_json::to_value(params)?;
3449        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3450        let _value = self
3451            .session
3452            .client()
3453            .call(rpc_methods::SESSION_SEND, Some(wire_params))
3454            .await?;
3455        Ok(serde_json::from_value(_value)?)
3456    }
3457
3458    /// 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.
3459    ///
3460    /// Wire method: `session.sendMessages`.
3461    ///
3462    /// # Parameters
3463    ///
3464    /// * `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.
3465    ///
3466    /// # Returns
3467    ///
3468    /// Result of sending zero or more user messages
3469    ///
3470    /// <div class="warning">
3471    ///
3472    /// **Experimental.** This API is part of an experimental wire-protocol surface
3473    /// and may change or be removed in future SDK or CLI releases. Pin both the
3474    /// SDK and CLI versions if your code depends on it.
3475    ///
3476    /// </div>
3477    pub async fn send_messages(
3478        &self,
3479        params: SendMessagesRequest,
3480    ) -> Result<SendMessagesResult, Error> {
3481        let mut wire_params = serde_json::to_value(params)?;
3482        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3483        let _value = self
3484            .session
3485            .client()
3486            .call(rpc_methods::SESSION_SENDMESSAGES, Some(wire_params))
3487            .await?;
3488        Ok(serde_json::from_value(_value)?)
3489    }
3490
3491    /// Queues or sends an internal system notification to the session according to its passive policy.
3492    ///
3493    /// Wire method: `session.sendSystemNotification`.
3494    ///
3495    /// # Parameters
3496    ///
3497    /// * `params` - Internal request for sending a system notification.
3498    ///
3499    /// <div class="warning">
3500    ///
3501    /// **Experimental.** This API is part of an experimental wire-protocol surface
3502    /// and may change or be removed in future SDK or CLI releases. Pin both the
3503    /// SDK and CLI versions if your code depends on it.
3504    ///
3505    /// </div>
3506    pub(crate) async fn send_system_notification(
3507        &self,
3508        params: SendSystemNotificationRequest,
3509    ) -> Result<(), Error> {
3510        let mut wire_params = serde_json::to_value(params)?;
3511        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3512        let _value = self
3513            .session
3514            .client()
3515            .call(
3516                rpc_methods::SESSION_SENDSYSTEMNOTIFICATION,
3517                Some(wire_params),
3518            )
3519            .await?;
3520        Ok(())
3521    }
3522
3523    /// Aborts the current agent turn.
3524    ///
3525    /// Wire method: `session.abort`.
3526    ///
3527    /// # Parameters
3528    ///
3529    /// * `params` - Parameters for aborting the current turn
3530    ///
3531    /// # Returns
3532    ///
3533    /// Result of aborting the current turn
3534    ///
3535    /// <div class="warning">
3536    ///
3537    /// **Experimental.** This API is part of an experimental wire-protocol surface
3538    /// and may change or be removed in future SDK or CLI releases. Pin both the
3539    /// SDK and CLI versions if your code depends on it.
3540    ///
3541    /// </div>
3542    pub async fn abort(&self, params: AbortRequest) -> Result<AbortResult, Error> {
3543        let mut wire_params = serde_json::to_value(params)?;
3544        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3545        let _value = self
3546            .session
3547            .client()
3548            .call(rpc_methods::SESSION_ABORT, Some(wire_params))
3549            .await?;
3550        Ok(serde_json::from_value(_value)?)
3551    }
3552
3553    /// 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.
3554    ///
3555    /// Wire method: `session.interruptMainTurn`.
3556    ///
3557    /// # Parameters
3558    ///
3559    /// * `params` - Parameters for interrupting the main agent turn.
3560    ///
3561    /// # Returns
3562    ///
3563    /// Result of interrupting the main agent turn.
3564    ///
3565    /// <div class="warning">
3566    ///
3567    /// **Experimental.** This API is part of an experimental wire-protocol surface
3568    /// and may change or be removed in future SDK or CLI releases. Pin both the
3569    /// SDK and CLI versions if your code depends on it.
3570    ///
3571    /// </div>
3572    pub async fn interrupt_main_turn(
3573        &self,
3574        params: InterruptMainTurnRequest,
3575    ) -> Result<InterruptMainTurnResult, Error> {
3576        let mut wire_params = serde_json::to_value(params)?;
3577        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3578        let _value = self
3579            .session
3580            .client()
3581            .call(rpc_methods::SESSION_INTERRUPTMAINTURN, Some(wire_params))
3582            .await?;
3583        Ok(serde_json::from_value(_value)?)
3584    }
3585
3586    /// Cancels every running background agent (task-registry subagents plus sidekick agents) without interrupting the main agent loop. Promoted attached shells are left running.
3587    ///
3588    /// Wire method: `session.cancelAllBackgroundAgents`.
3589    ///
3590    /// # Returns
3591    ///
3592    /// The number of running background agents (task-registry agents) that were cancelled.
3593    ///
3594    /// <div class="warning">
3595    ///
3596    /// **Experimental.** This API is part of an experimental wire-protocol surface
3597    /// and may change or be removed in future SDK or CLI releases. Pin both the
3598    /// SDK and CLI versions if your code depends on it.
3599    ///
3600    /// </div>
3601    pub async fn cancel_all_background_agents(
3602        &self,
3603    ) -> Result<SessionCancelAllBackgroundAgentsResult, Error> {
3604        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3605        let _value = self
3606            .session
3607            .client()
3608            .call(
3609                rpc_methods::SESSION_CANCELALLBACKGROUNDAGENTS,
3610                Some(wire_params),
3611            )
3612            .await?;
3613        Ok(serde_json::from_value(_value)?)
3614    }
3615
3616    /// 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.
3617    ///
3618    /// Wire method: `session.shutdown`.
3619    ///
3620    /// # Parameters
3621    ///
3622    /// * `params` - Parameters for shutting down the session
3623    ///
3624    /// <div class="warning">
3625    ///
3626    /// **Experimental.** This API is part of an experimental wire-protocol surface
3627    /// and may change or be removed in future SDK or CLI releases. Pin both the
3628    /// SDK and CLI versions if your code depends on it.
3629    ///
3630    /// </div>
3631    pub async fn shutdown(&self, params: ShutdownRequest) -> Result<(), Error> {
3632        let mut wire_params = serde_json::to_value(params)?;
3633        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3634        let _value = self
3635            .session
3636            .client()
3637            .call(rpc_methods::SESSION_SHUTDOWN, Some(wire_params))
3638            .await?;
3639        Ok(())
3640    }
3641
3642    /// Emits a user-visible session log event.
3643    ///
3644    /// Wire method: `session.log`.
3645    ///
3646    /// # Parameters
3647    ///
3648    /// * `params` - Message text, optional severity level, persistence flag, optional follow-up URL, and optional tip.
3649    ///
3650    /// # Returns
3651    ///
3652    /// Identifier of the session event that was emitted for the log message.
3653    ///
3654    /// <div class="warning">
3655    ///
3656    /// **Experimental.** This API is part of an experimental wire-protocol surface
3657    /// and may change or be removed in future SDK or CLI releases. Pin both the
3658    /// SDK and CLI versions if your code depends on it.
3659    ///
3660    /// </div>
3661    pub async fn log(&self, params: LogRequest) -> Result<LogResult, Error> {
3662        let mut wire_params = serde_json::to_value(params)?;
3663        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3664        let _value = self
3665            .session
3666            .client()
3667            .call(rpc_methods::SESSION_LOG, Some(wire_params))
3668            .await?;
3669        Ok(serde_json::from_value(_value)?)
3670    }
3671}
3672
3673/// `session.agent.*` RPCs.
3674#[derive(Clone, Copy)]
3675pub struct SessionRpcAgent<'a> {
3676    pub(crate) session: &'a Session,
3677}
3678
3679impl<'a> SessionRpcAgent<'a> {
3680    /// Lists agents available to the session. Defaults to custom agents only; pass includeBuiltInAgents to include the effective built-in agents.
3681    ///
3682    /// Wire method: `session.agent.list`.
3683    ///
3684    /// # Returns
3685    ///
3686    /// Agents available to the session.
3687    ///
3688    /// <div class="warning">
3689    ///
3690    /// **Experimental.** This API is part of an experimental wire-protocol surface
3691    /// and may change or be removed in future SDK or CLI releases. Pin both the
3692    /// SDK and CLI versions if your code depends on it.
3693    ///
3694    /// </div>
3695    pub async fn list(&self) -> Result<AgentList, Error> {
3696        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3697        let _value = self
3698            .session
3699            .client()
3700            .call(rpc_methods::SESSION_AGENT_LIST, Some(wire_params))
3701            .await?;
3702        Ok(serde_json::from_value(_value)?)
3703    }
3704
3705    /// Lists agents available to the session. Defaults to custom agents only; pass includeBuiltInAgents to include the effective built-in agents.
3706    ///
3707    /// Wire method: `session.agent.list`.
3708    ///
3709    /// # Parameters
3710    ///
3711    /// * `params` - Controls whether built-in agents and authored prompt text are included.
3712    ///
3713    /// # Returns
3714    ///
3715    /// Agents available to the session.
3716    ///
3717    /// <div class="warning">
3718    ///
3719    /// **Experimental.** This API is part of an experimental wire-protocol surface
3720    /// and may change or be removed in future SDK or CLI releases. Pin both the
3721    /// SDK and CLI versions if your code depends on it.
3722    ///
3723    /// </div>
3724    pub async fn list_with_params(&self, params: AgentListRequest) -> Result<AgentList, Error> {
3725        let mut wire_params = serde_json::to_value(params)?;
3726        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3727        let _value = self
3728            .session
3729            .client()
3730            .call(rpc_methods::SESSION_AGENT_LIST, Some(wire_params))
3731            .await?;
3732        Ok(serde_json::from_value(_value)?)
3733    }
3734
3735    /// 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.
3736    ///
3737    /// Wire method: `session.agent.setPrompt`.
3738    ///
3739    /// # Parameters
3740    ///
3741    /// * `params` - An in-memory authored prompt override for an available agent.
3742    ///
3743    /// <div class="warning">
3744    ///
3745    /// **Experimental.** This API is part of an experimental wire-protocol surface
3746    /// and may change or be removed in future SDK or CLI releases. Pin both the
3747    /// SDK and CLI versions if your code depends on it.
3748    ///
3749    /// </div>
3750    pub async fn set_prompt(&self, params: AgentSetPromptRequest) -> Result<(), Error> {
3751        let mut wire_params = serde_json::to_value(params)?;
3752        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3753        let _value = self
3754            .session
3755            .client()
3756            .call(rpc_methods::SESSION_AGENT_SETPROMPT, Some(wire_params))
3757            .await?;
3758        Ok(())
3759    }
3760
3761    /// Gets the currently selected custom agent for the session.
3762    ///
3763    /// Wire method: `session.agent.getCurrent`.
3764    ///
3765    /// # Returns
3766    ///
3767    /// The currently selected custom agent, or null when using the default agent.
3768    ///
3769    /// <div class="warning">
3770    ///
3771    /// **Experimental.** This API is part of an experimental wire-protocol surface
3772    /// and may change or be removed in future SDK or CLI releases. Pin both the
3773    /// SDK and CLI versions if your code depends on it.
3774    ///
3775    /// </div>
3776    pub async fn get_current(&self) -> Result<AgentGetCurrentResult, Error> {
3777        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3778        let _value = self
3779            .session
3780            .client()
3781            .call(rpc_methods::SESSION_AGENT_GETCURRENT, Some(wire_params))
3782            .await?;
3783        Ok(serde_json::from_value(_value)?)
3784    }
3785
3786    /// Selects a custom agent for subsequent turns in the session.
3787    ///
3788    /// Wire method: `session.agent.select`.
3789    ///
3790    /// # Parameters
3791    ///
3792    /// * `params` - Name of the custom agent to select for subsequent turns.
3793    ///
3794    /// # Returns
3795    ///
3796    /// The newly selected custom agent.
3797    ///
3798    /// <div class="warning">
3799    ///
3800    /// **Experimental.** This API is part of an experimental wire-protocol surface
3801    /// and may change or be removed in future SDK or CLI releases. Pin both the
3802    /// SDK and CLI versions if your code depends on it.
3803    ///
3804    /// </div>
3805    pub async fn select(&self, params: AgentSelectRequest) -> Result<AgentSelectResult, Error> {
3806        let mut wire_params = serde_json::to_value(params)?;
3807        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3808        let _value = self
3809            .session
3810            .client()
3811            .call(rpc_methods::SESSION_AGENT_SELECT, Some(wire_params))
3812            .await?;
3813        Ok(serde_json::from_value(_value)?)
3814    }
3815
3816    /// Clears the selected custom agent and returns the session to the default agent.
3817    ///
3818    /// Wire method: `session.agent.deselect`.
3819    ///
3820    /// <div class="warning">
3821    ///
3822    /// **Experimental.** This API is part of an experimental wire-protocol surface
3823    /// and may change or be removed in future SDK or CLI releases. Pin both the
3824    /// SDK and CLI versions if your code depends on it.
3825    ///
3826    /// </div>
3827    pub async fn deselect(&self) -> Result<(), Error> {
3828        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3829        let _value = self
3830            .session
3831            .client()
3832            .call(rpc_methods::SESSION_AGENT_DESELECT, Some(wire_params))
3833            .await?;
3834        Ok(())
3835    }
3836
3837    /// Reloads custom agent definitions and returns the refreshed list.
3838    ///
3839    /// Wire method: `session.agent.reload`.
3840    ///
3841    /// # Returns
3842    ///
3843    /// Custom agents available to the session after reloading definitions from disk.
3844    ///
3845    /// <div class="warning">
3846    ///
3847    /// **Experimental.** This API is part of an experimental wire-protocol surface
3848    /// and may change or be removed in future SDK or CLI releases. Pin both the
3849    /// SDK and CLI versions if your code depends on it.
3850    ///
3851    /// </div>
3852    pub async fn reload(&self) -> Result<AgentReloadResult, Error> {
3853        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3854        let _value = self
3855            .session
3856            .client()
3857            .call(rpc_methods::SESSION_AGENT_RELOAD, Some(wire_params))
3858            .await?;
3859        Ok(serde_json::from_value(_value)?)
3860    }
3861}
3862
3863/// `session.autopilotObjective.*` RPCs.
3864#[derive(Clone, Copy)]
3865pub struct SessionRpcAutopilotObjective<'a> {
3866    pub(crate) session: &'a Session,
3867}
3868
3869impl<'a> SessionRpcAutopilotObjective<'a> {
3870    /// Reads the current canonical autopilot objective state for this session.
3871    ///
3872    /// Wire method: `session.autopilotObjective.getState`.
3873    ///
3874    /// # Returns
3875    ///
3876    /// Canonical runtime state for the session's current autopilot objective.
3877    ///
3878    /// <div class="warning">
3879    ///
3880    /// **Experimental.** This API is part of an experimental wire-protocol surface
3881    /// and may change or be removed in future SDK or CLI releases. Pin both the
3882    /// SDK and CLI versions if your code depends on it.
3883    ///
3884    /// </div>
3885    pub async fn get_state(&self) -> Result<AutopilotObjectiveGetStateResult, Error> {
3886        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3887        let _value = self
3888            .session
3889            .client()
3890            .call(
3891                rpc_methods::SESSION_AUTOPILOTOBJECTIVE_GETSTATE,
3892                Some(wire_params),
3893            )
3894            .await?;
3895        Ok(serde_json::from_value(_value)?)
3896    }
3897}
3898
3899/// `session.canvas.*` RPCs.
3900#[derive(Clone, Copy)]
3901pub struct SessionRpcCanvas<'a> {
3902    pub(crate) session: &'a Session,
3903}
3904
3905impl<'a> SessionRpcCanvas<'a> {
3906    /// `session.canvas.action.*` sub-namespace.
3907    pub fn action(&self) -> SessionRpcCanvasAction<'a> {
3908        SessionRpcCanvasAction {
3909            session: self.session,
3910        }
3911    }
3912
3913    /// `session.canvas.provider.*` sub-namespace.
3914    pub fn provider(&self) -> SessionRpcCanvasProvider<'a> {
3915        SessionRpcCanvasProvider {
3916            session: self.session,
3917        }
3918    }
3919
3920    /// Lists canvases declared for the session.
3921    ///
3922    /// Wire method: `session.canvas.list`.
3923    ///
3924    /// # Returns
3925    ///
3926    /// Declared canvases available in this session.
3927    ///
3928    /// <div class="warning">
3929    ///
3930    /// **Experimental.** This API is part of an experimental wire-protocol surface
3931    /// and may change or be removed in future SDK or CLI releases. Pin both the
3932    /// SDK and CLI versions if your code depends on it.
3933    ///
3934    /// </div>
3935    pub async fn list(&self) -> Result<CanvasList, Error> {
3936        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3937        let _value = self
3938            .session
3939            .client()
3940            .call(rpc_methods::SESSION_CANVAS_LIST, Some(wire_params))
3941            .await?;
3942        Ok(serde_json::from_value(_value)?)
3943    }
3944
3945    /// Lists currently open canvas instances for the live session.
3946    ///
3947    /// Wire method: `session.canvas.listOpen`.
3948    ///
3949    /// # Returns
3950    ///
3951    /// Live open-canvas snapshot.
3952    ///
3953    /// <div class="warning">
3954    ///
3955    /// **Experimental.** This API is part of an experimental wire-protocol surface
3956    /// and may change or be removed in future SDK or CLI releases. Pin both the
3957    /// SDK and CLI versions if your code depends on it.
3958    ///
3959    /// </div>
3960    pub async fn list_open(&self) -> Result<CanvasListOpenResult, Error> {
3961        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3962        let _value = self
3963            .session
3964            .client()
3965            .call(rpc_methods::SESSION_CANVAS_LISTOPEN, Some(wire_params))
3966            .await?;
3967        Ok(serde_json::from_value(_value)?)
3968    }
3969
3970    /// Opens or focuses a canvas instance.
3971    ///
3972    /// Wire method: `session.canvas.open`.
3973    ///
3974    /// # Parameters
3975    ///
3976    /// * `params` - Canvas open parameters.
3977    ///
3978    /// # Returns
3979    ///
3980    /// Open canvas instance snapshot.
3981    ///
3982    /// <div class="warning">
3983    ///
3984    /// **Experimental.** This API is part of an experimental wire-protocol surface
3985    /// and may change or be removed in future SDK or CLI releases. Pin both the
3986    /// SDK and CLI versions if your code depends on it.
3987    ///
3988    /// </div>
3989    pub async fn open(&self, params: CanvasOpenRequest) -> Result<OpenCanvasInstance, Error> {
3990        let mut wire_params = serde_json::to_value(params)?;
3991        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3992        let _value = self
3993            .session
3994            .client()
3995            .call(rpc_methods::SESSION_CANVAS_OPEN, Some(wire_params))
3996            .await?;
3997        Ok(serde_json::from_value(_value)?)
3998    }
3999
4000    /// Closes an open canvas instance.
4001    ///
4002    /// Wire method: `session.canvas.close`.
4003    ///
4004    /// # Parameters
4005    ///
4006    /// * `params` - Canvas close parameters.
4007    ///
4008    /// <div class="warning">
4009    ///
4010    /// **Experimental.** This API is part of an experimental wire-protocol surface
4011    /// and may change or be removed in future SDK or CLI releases. Pin both the
4012    /// SDK and CLI versions if your code depends on it.
4013    ///
4014    /// </div>
4015    pub async fn close(&self, params: CanvasCloseRequest) -> Result<(), Error> {
4016        let mut wire_params = serde_json::to_value(params)?;
4017        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4018        let _value = self
4019            .session
4020            .client()
4021            .call(rpc_methods::SESSION_CANVAS_CLOSE, Some(wire_params))
4022            .await?;
4023        Ok(())
4024    }
4025}
4026
4027/// `session.canvas.action.*` RPCs.
4028#[derive(Clone, Copy)]
4029pub struct SessionRpcCanvasAction<'a> {
4030    pub(crate) session: &'a Session,
4031}
4032
4033impl<'a> SessionRpcCanvasAction<'a> {
4034    /// Invokes an action on an open canvas instance.
4035    ///
4036    /// Wire method: `session.canvas.action.invoke`.
4037    ///
4038    /// # Parameters
4039    ///
4040    /// * `params` - Canvas action invocation parameters.
4041    ///
4042    /// # Returns
4043    ///
4044    /// Canvas action invocation result.
4045    ///
4046    /// <div class="warning">
4047    ///
4048    /// **Experimental.** This API is part of an experimental wire-protocol surface
4049    /// and may change or be removed in future SDK or CLI releases. Pin both the
4050    /// SDK and CLI versions if your code depends on it.
4051    ///
4052    /// </div>
4053    pub async fn invoke(
4054        &self,
4055        params: CanvasActionInvokeRequest,
4056    ) -> Result<CanvasActionInvokeResult, Error> {
4057        let mut wire_params = serde_json::to_value(params)?;
4058        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4059        let _value = self
4060            .session
4061            .client()
4062            .call(rpc_methods::SESSION_CANVAS_ACTION_INVOKE, Some(wire_params))
4063            .await?;
4064        Ok(serde_json::from_value(_value)?)
4065    }
4066}
4067
4068/// `session.canvas.provider.*` RPCs.
4069#[derive(Clone, Copy)]
4070pub struct SessionRpcCanvasProvider<'a> {
4071    pub(crate) session: &'a Session,
4072}
4073
4074impl<'a> SessionRpcCanvasProvider<'a> {
4075    /// Registers an internal canvas provider connection and its contributions.
4076    ///
4077    /// Wire method: `session.canvas.provider.register`.
4078    ///
4079    /// # Parameters
4080    ///
4081    /// * `params` - Internal canvas provider registration parameters.
4082    ///
4083    /// <div class="warning">
4084    ///
4085    /// **Experimental.** This API is part of an experimental wire-protocol surface
4086    /// and may change or be removed in future SDK or CLI releases. Pin both the
4087    /// SDK and CLI versions if your code depends on it.
4088    ///
4089    /// </div>
4090    pub(crate) async fn register(
4091        &self,
4092        params: CanvasProviderRegisterRequest,
4093    ) -> Result<(), Error> {
4094        let mut wire_params = serde_json::to_value(params)?;
4095        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4096        let _value = self
4097            .session
4098            .client()
4099            .call(
4100                rpc_methods::SESSION_CANVAS_PROVIDER_REGISTER,
4101                Some(wire_params),
4102            )
4103            .await?;
4104        Ok(())
4105    }
4106
4107    /// Unregisters an internal canvas provider connection.
4108    ///
4109    /// Wire method: `session.canvas.provider.unregister`.
4110    ///
4111    /// # Parameters
4112    ///
4113    /// * `params` - Internal canvas provider unregistration parameters.
4114    ///
4115    /// <div class="warning">
4116    ///
4117    /// **Experimental.** This API is part of an experimental wire-protocol surface
4118    /// and may change or be removed in future SDK or CLI releases. Pin both the
4119    /// SDK and CLI versions if your code depends on it.
4120    ///
4121    /// </div>
4122    pub(crate) async fn unregister(
4123        &self,
4124        params: CanvasProviderUnregisterRequest,
4125    ) -> Result<(), Error> {
4126        let mut wire_params = serde_json::to_value(params)?;
4127        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4128        let _value = self
4129            .session
4130            .client()
4131            .call(
4132                rpc_methods::SESSION_CANVAS_PROVIDER_UNREGISTER,
4133                Some(wire_params),
4134            )
4135            .await?;
4136        Ok(())
4137    }
4138}
4139
4140/// `session.commands.*` RPCs.
4141#[derive(Clone, Copy)]
4142pub struct SessionRpcCommands<'a> {
4143    pub(crate) session: &'a Session,
4144}
4145
4146impl<'a> SessionRpcCommands<'a> {
4147    /// Lists slash commands available in the session.
4148    ///
4149    /// Wire method: `session.commands.list`.
4150    ///
4151    /// # Returns
4152    ///
4153    /// Slash commands available in the session, after applying any include/exclude filters.
4154    ///
4155    /// <div class="warning">
4156    ///
4157    /// **Experimental.** This API is part of an experimental wire-protocol surface
4158    /// and may change or be removed in future SDK or CLI releases. Pin both the
4159    /// SDK and CLI versions if your code depends on it.
4160    ///
4161    /// </div>
4162    pub async fn list(&self) -> Result<CommandList, Error> {
4163        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
4164        let _value = self
4165            .session
4166            .client()
4167            .call(rpc_methods::SESSION_COMMANDS_LIST, Some(wire_params))
4168            .await?;
4169        Ok(serde_json::from_value(_value)?)
4170    }
4171
4172    /// Lists slash commands available in the session.
4173    ///
4174    /// Wire method: `session.commands.list`.
4175    ///
4176    /// # Parameters
4177    ///
4178    /// * `params` - Optional filters controlling which command sources to include in the listing.
4179    ///
4180    /// # Returns
4181    ///
4182    /// Slash commands available in the session, after applying any include/exclude filters.
4183    ///
4184    /// <div class="warning">
4185    ///
4186    /// **Experimental.** This API is part of an experimental wire-protocol surface
4187    /// and may change or be removed in future SDK or CLI releases. Pin both the
4188    /// SDK and CLI versions if your code depends on it.
4189    ///
4190    /// </div>
4191    pub async fn list_with_params(
4192        &self,
4193        params: CommandsListRequest,
4194    ) -> Result<CommandList, Error> {
4195        let mut wire_params = serde_json::to_value(params)?;
4196        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4197        let _value = self
4198            .session
4199            .client()
4200            .call(rpc_methods::SESSION_COMMANDS_LIST, Some(wire_params))
4201            .await?;
4202        Ok(serde_json::from_value(_value)?)
4203    }
4204
4205    /// Invokes a slash command in the session.
4206    ///
4207    /// Wire method: `session.commands.invoke`.
4208    ///
4209    /// # Parameters
4210    ///
4211    /// * `params` - Slash command name and optional raw input string to invoke.
4212    ///
4213    /// # Returns
4214    ///
4215    /// Result of invoking the slash command (text output, prompt to send to the agent, completion, or subcommand selection).
4216    ///
4217    /// <div class="warning">
4218    ///
4219    /// **Experimental.** This API is part of an experimental wire-protocol surface
4220    /// and may change or be removed in future SDK or CLI releases. Pin both the
4221    /// SDK and CLI versions if your code depends on it.
4222    ///
4223    /// </div>
4224    pub async fn invoke(
4225        &self,
4226        params: CommandsInvokeRequest,
4227    ) -> Result<SlashCommandInvocationResult, Error> {
4228        let mut wire_params = serde_json::to_value(params)?;
4229        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4230        let _value = self
4231            .session
4232            .client()
4233            .call(rpc_methods::SESSION_COMMANDS_INVOKE, Some(wire_params))
4234            .await?;
4235        Ok(serde_json::from_value(_value)?)
4236    }
4237
4238    /// Finalizes persistence associated with a client-applied slash-command effect.
4239    ///
4240    /// Wire method: `session.commands.finalizeInvocationEffect`.
4241    ///
4242    /// # Parameters
4243    ///
4244    /// * `params` - The pending slash-command invocation effect to finalize, plus whether the host applied or cancelled it.
4245    ///
4246    /// # Returns
4247    ///
4248    /// Whether finalizing the invocation effect succeeded, and the failure reason when it did not.
4249    ///
4250    /// <div class="warning">
4251    ///
4252    /// **Experimental.** This API is part of an experimental wire-protocol surface
4253    /// and may change or be removed in future SDK or CLI releases. Pin both the
4254    /// SDK and CLI versions if your code depends on it.
4255    ///
4256    /// </div>
4257    pub(crate) async fn finalize_invocation_effect(
4258        &self,
4259        params: CommandsFinalizeInvocationEffectRequest,
4260    ) -> Result<CommandsFinalizeInvocationEffectResult, Error> {
4261        let mut wire_params = serde_json::to_value(params)?;
4262        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4263        let _value = self
4264            .session
4265            .client()
4266            .call(
4267                rpc_methods::SESSION_COMMANDS_FINALIZEINVOCATIONEFFECT,
4268                Some(wire_params),
4269            )
4270            .await?;
4271        Ok(serde_json::from_value(_value)?)
4272    }
4273
4274    /// Reports completion of a pending client-handled slash command.
4275    ///
4276    /// Wire method: `session.commands.handlePendingCommand`.
4277    ///
4278    /// # Parameters
4279    ///
4280    /// * `params` - Pending command request ID and an optional error if the client handler failed.
4281    ///
4282    /// # Returns
4283    ///
4284    /// Indicates whether the pending client-handled command was completed successfully.
4285    ///
4286    /// <div class="warning">
4287    ///
4288    /// **Experimental.** This API is part of an experimental wire-protocol surface
4289    /// and may change or be removed in future SDK or CLI releases. Pin both the
4290    /// SDK and CLI versions if your code depends on it.
4291    ///
4292    /// </div>
4293    pub async fn handle_pending_command(
4294        &self,
4295        params: CommandsHandlePendingCommandRequest,
4296    ) -> Result<CommandsHandlePendingCommandResult, Error> {
4297        let mut wire_params = serde_json::to_value(params)?;
4298        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4299        let _value = self
4300            .session
4301            .client()
4302            .call(
4303                rpc_methods::SESSION_COMMANDS_HANDLEPENDINGCOMMAND,
4304                Some(wire_params),
4305            )
4306            .await?;
4307        Ok(serde_json::from_value(_value)?)
4308    }
4309
4310    /// Executes a slash command synchronously and returns any error.
4311    ///
4312    /// Wire method: `session.commands.execute`.
4313    ///
4314    /// # Parameters
4315    ///
4316    /// * `params` - Slash command name and argument string to execute synchronously.
4317    ///
4318    /// # Returns
4319    ///
4320    /// Error message produced while executing the command, if any.
4321    ///
4322    /// <div class="warning">
4323    ///
4324    /// **Experimental.** This API is part of an experimental wire-protocol surface
4325    /// and may change or be removed in future SDK or CLI releases. Pin both the
4326    /// SDK and CLI versions if your code depends on it.
4327    ///
4328    /// </div>
4329    pub async fn execute(
4330        &self,
4331        params: ExecuteCommandParams,
4332    ) -> Result<ExecuteCommandResult, Error> {
4333        let mut wire_params = serde_json::to_value(params)?;
4334        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4335        let _value = self
4336            .session
4337            .client()
4338            .call(rpc_methods::SESSION_COMMANDS_EXECUTE, Some(wire_params))
4339            .await?;
4340        Ok(serde_json::from_value(_value)?)
4341    }
4342
4343    /// Enqueues a slash command for FIFO processing on the local session.
4344    ///
4345    /// Wire method: `session.commands.enqueue`.
4346    ///
4347    /// # Parameters
4348    ///
4349    /// * `params` - Slash-prefixed command string to enqueue for FIFO processing.
4350    ///
4351    /// # Returns
4352    ///
4353    /// Indicates whether the command was accepted into the local execution queue.
4354    ///
4355    /// <div class="warning">
4356    ///
4357    /// **Experimental.** This API is part of an experimental wire-protocol surface
4358    /// and may change or be removed in future SDK or CLI releases. Pin both the
4359    /// SDK and CLI versions if your code depends on it.
4360    ///
4361    /// </div>
4362    pub async fn enqueue(
4363        &self,
4364        params: EnqueueCommandParams,
4365    ) -> Result<EnqueueCommandResult, Error> {
4366        let mut wire_params = serde_json::to_value(params)?;
4367        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4368        let _value = self
4369            .session
4370            .client()
4371            .call(rpc_methods::SESSION_COMMANDS_ENQUEUE, Some(wire_params))
4372            .await?;
4373        Ok(serde_json::from_value(_value)?)
4374    }
4375
4376    /// Reports whether the host actually executed a queued command and whether to continue processing.
4377    ///
4378    /// Wire method: `session.commands.respondToQueuedCommand`.
4379    ///
4380    /// # Parameters
4381    ///
4382    /// * `params` - Queued-command request ID and the result indicating whether the host executed it (and whether to stop processing further queued commands).
4383    ///
4384    /// # Returns
4385    ///
4386    /// Indicates whether the queued-command response was matched to a pending request.
4387    ///
4388    /// <div class="warning">
4389    ///
4390    /// **Experimental.** This API is part of an experimental wire-protocol surface
4391    /// and may change or be removed in future SDK or CLI releases. Pin both the
4392    /// SDK and CLI versions if your code depends on it.
4393    ///
4394    /// </div>
4395    pub async fn respond_to_queued_command(
4396        &self,
4397        params: CommandsRespondToQueuedCommandRequest,
4398    ) -> Result<CommandsRespondToQueuedCommandResult, Error> {
4399        let mut wire_params = serde_json::to_value(params)?;
4400        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4401        let _value = self
4402            .session
4403            .client()
4404            .call(
4405                rpc_methods::SESSION_COMMANDS_RESPONDTOQUEUEDCOMMAND,
4406                Some(wire_params),
4407            )
4408            .await?;
4409        Ok(serde_json::from_value(_value)?)
4410    }
4411}
4412
4413/// `session.completions.*` RPCs.
4414#[derive(Clone, Copy)]
4415pub struct SessionRpcCompletions<'a> {
4416    pub(crate) session: &'a Session,
4417}
4418
4419impl<'a> SessionRpcCompletions<'a> {
4420    /// 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).
4421    ///
4422    /// Wire method: `session.completions.getTriggerCharacters`.
4423    ///
4424    /// # Returns
4425    ///
4426    /// 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`).
4427    ///
4428    /// <div class="warning">
4429    ///
4430    /// **Experimental.** This API is part of an experimental wire-protocol surface
4431    /// and may change or be removed in future SDK or CLI releases. Pin both the
4432    /// SDK and CLI versions if your code depends on it.
4433    ///
4434    /// </div>
4435    pub async fn get_trigger_characters(
4436        &self,
4437    ) -> Result<CompletionsGetTriggerCharactersResult, Error> {
4438        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
4439        let _value = self
4440            .session
4441            .client()
4442            .call(
4443                rpc_methods::SESSION_COMPLETIONS_GETTRIGGERCHARACTERS,
4444                Some(wire_params),
4445            )
4446            .await?;
4447        Ok(serde_json::from_value(_value)?)
4448    }
4449
4450    /// 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.
4451    ///
4452    /// Wire method: `session.completions.request`.
4453    ///
4454    /// # Parameters
4455    ///
4456    /// * `params` - Request host-driven completions for the current composer input.
4457    ///
4458    /// # Returns
4459    ///
4460    /// Host-driven completion items for the current composer input. Empty when the host returns no items or does not support completions.
4461    ///
4462    /// <div class="warning">
4463    ///
4464    /// **Experimental.** This API is part of an experimental wire-protocol surface
4465    /// and may change or be removed in future SDK or CLI releases. Pin both the
4466    /// SDK and CLI versions if your code depends on it.
4467    ///
4468    /// </div>
4469    pub async fn request(
4470        &self,
4471        params: CompletionsRequestRequest,
4472    ) -> Result<CompletionsRequestResult, Error> {
4473        let mut wire_params = serde_json::to_value(params)?;
4474        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4475        let _value = self
4476            .session
4477            .client()
4478            .call(rpc_methods::SESSION_COMPLETIONS_REQUEST, Some(wire_params))
4479            .await?;
4480        Ok(serde_json::from_value(_value)?)
4481    }
4482}
4483
4484/// `session.contentExclusion.*` RPCs.
4485#[derive(Clone, Copy)]
4486pub struct SessionRpcContentExclusion<'a> {
4487    pub(crate) session: &'a Session,
4488}
4489
4490impl<'a> SessionRpcContentExclusion<'a> {
4491    /// 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.
4492    ///
4493    /// Wire method: `session.contentExclusion.checkPaths`.
4494    ///
4495    /// # Parameters
4496    ///
4497    /// * `params` - Local file system absolute paths within the session working directory to check against its content-exclusion policy.
4498    ///
4499    /// # Returns
4500    ///
4501    /// Batch content-exclusion result. Callers must fail closed when policy evaluation is unavailable.
4502    ///
4503    /// <div class="warning">
4504    ///
4505    /// **Experimental.** This API is part of an experimental wire-protocol surface
4506    /// and may change or be removed in future SDK or CLI releases. Pin both the
4507    /// SDK and CLI versions if your code depends on it.
4508    ///
4509    /// </div>
4510    pub async fn check_paths(
4511        &self,
4512        params: ContentExclusionCheckPathsRequest,
4513    ) -> Result<ContentExclusionCheckPathsResult, Error> {
4514        let mut wire_params = serde_json::to_value(params)?;
4515        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4516        let _value = self
4517            .session
4518            .client()
4519            .call(
4520                rpc_methods::SESSION_CONTENTEXCLUSION_CHECKPATHS,
4521                Some(wire_params),
4522            )
4523            .await?;
4524        Ok(serde_json::from_value(_value)?)
4525    }
4526}
4527
4528/// `session.debug.*` RPCs.
4529#[derive(Clone, Copy)]
4530pub struct SessionRpcDebug<'a> {
4531    pub(crate) session: &'a Session,
4532}
4533
4534impl<'a> SessionRpcDebug<'a> {
4535    /// 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.
4536    ///
4537    /// Wire method: `session.debug.collectLogs`.
4538    ///
4539    /// # Parameters
4540    ///
4541    /// * `params` - Options for collecting a redacted session debug bundle.
4542    ///
4543    /// # Returns
4544    ///
4545    /// Result of collecting a redacted debug bundle.
4546    ///
4547    /// <div class="warning">
4548    ///
4549    /// **Experimental.** This API is part of an experimental wire-protocol surface
4550    /// and may change or be removed in future SDK or CLI releases. Pin both the
4551    /// SDK and CLI versions if your code depends on it.
4552    ///
4553    /// </div>
4554    pub async fn collect_logs(
4555        &self,
4556        params: DebugCollectLogsRequest,
4557    ) -> Result<DebugCollectLogsResult, Error> {
4558        let mut wire_params = serde_json::to_value(params)?;
4559        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4560        let _value = self
4561            .session
4562            .client()
4563            .call(rpc_methods::SESSION_DEBUG_COLLECTLOGS, Some(wire_params))
4564            .await?;
4565        Ok(serde_json::from_value(_value)?)
4566    }
4567}
4568
4569/// `session.eventLog.*` RPCs.
4570#[derive(Clone, Copy)]
4571pub struct SessionRpcEventLog<'a> {
4572    pub(crate) session: &'a Session,
4573}
4574
4575impl<'a> SessionRpcEventLog<'a> {
4576    /// Reads a batch of session events from a cursor, optionally waiting for new events. Supports tail-first reads via `direction: backward`.
4577    ///
4578    /// Wire method: `session.eventLog.read`.
4579    ///
4580    /// # Parameters
4581    ///
4582    /// * `params` - Cursor, batch size, and optional long-poll/filter parameters for reading session events.
4583    ///
4584    /// # Returns
4585    ///
4586    /// Batch of session events returned by a read, with cursor and continuation metadata.
4587    ///
4588    /// <div class="warning">
4589    ///
4590    /// **Experimental.** This API is part of an experimental wire-protocol surface
4591    /// and may change or be removed in future SDK or CLI releases. Pin both the
4592    /// SDK and CLI versions if your code depends on it.
4593    ///
4594    /// </div>
4595    pub async fn read(&self, params: EventLogReadRequest) -> Result<EventsReadResult, 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(rpc_methods::SESSION_EVENTLOG_READ, Some(wire_params))
4602            .await?;
4603        Ok(serde_json::from_value(_value)?)
4604    }
4605
4606    /// Returns a snapshot of the current tail cursor without consuming events.
4607    ///
4608    /// Wire method: `session.eventLog.tail`.
4609    ///
4610    /// # Returns
4611    ///
4612    /// 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).
4613    ///
4614    /// <div class="warning">
4615    ///
4616    /// **Experimental.** This API is part of an experimental wire-protocol surface
4617    /// and may change or be removed in future SDK or CLI releases. Pin both the
4618    /// SDK and CLI versions if your code depends on it.
4619    ///
4620    /// </div>
4621    pub async fn tail(&self) -> Result<EventLogTailResult, Error> {
4622        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
4623        let _value = self
4624            .session
4625            .client()
4626            .call(rpc_methods::SESSION_EVENTLOG_TAIL, Some(wire_params))
4627            .await?;
4628        Ok(serde_json::from_value(_value)?)
4629    }
4630
4631    /// Registers consumer interest in an event type for runtime gating purposes.
4632    ///
4633    /// Wire method: `session.eventLog.registerInterest`.
4634    ///
4635    /// # Parameters
4636    ///
4637    /// * `params` - Event type to register consumer interest for, used by runtime gating logic.
4638    ///
4639    /// # Returns
4640    ///
4641    /// Opaque handle representing an event-type interest registration.
4642    ///
4643    /// <div class="warning">
4644    ///
4645    /// **Experimental.** This API is part of an experimental wire-protocol surface
4646    /// and may change or be removed in future SDK or CLI releases. Pin both the
4647    /// SDK and CLI versions if your code depends on it.
4648    ///
4649    /// </div>
4650    pub async fn register_interest(
4651        &self,
4652        params: RegisterEventInterestParams,
4653    ) -> Result<RegisterEventInterestResult, Error> {
4654        let mut wire_params = serde_json::to_value(params)?;
4655        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4656        let _value = self
4657            .session
4658            .client()
4659            .call(
4660                rpc_methods::SESSION_EVENTLOG_REGISTERINTEREST,
4661                Some(wire_params),
4662            )
4663            .await?;
4664        Ok(serde_json::from_value(_value)?)
4665    }
4666
4667    /// Releases a consumer's previously-registered interest in an event type.
4668    ///
4669    /// Wire method: `session.eventLog.releaseInterest`.
4670    ///
4671    /// # Parameters
4672    ///
4673    /// * `params` - Opaque handle previously returned by `registerInterest` to release.
4674    ///
4675    /// # Returns
4676    ///
4677    /// Indicates whether the operation succeeded.
4678    ///
4679    /// <div class="warning">
4680    ///
4681    /// **Experimental.** This API is part of an experimental wire-protocol surface
4682    /// and may change or be removed in future SDK or CLI releases. Pin both the
4683    /// SDK and CLI versions if your code depends on it.
4684    ///
4685    /// </div>
4686    pub async fn release_interest(
4687        &self,
4688        params: ReleaseEventInterestParams,
4689    ) -> Result<EventLogReleaseInterestResult, Error> {
4690        let mut wire_params = serde_json::to_value(params)?;
4691        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4692        let _value = self
4693            .session
4694            .client()
4695            .call(
4696                rpc_methods::SESSION_EVENTLOG_RELEASEINTEREST,
4697                Some(wire_params),
4698            )
4699            .await?;
4700        Ok(serde_json::from_value(_value)?)
4701    }
4702}
4703
4704/// `session.extensions.*` RPCs.
4705#[derive(Clone, Copy)]
4706pub struct SessionRpcExtensions<'a> {
4707    pub(crate) session: &'a Session,
4708}
4709
4710impl<'a> SessionRpcExtensions<'a> {
4711    /// Lists extensions discovered for the session and their current status.
4712    ///
4713    /// Wire method: `session.extensions.list`.
4714    ///
4715    /// # Returns
4716    ///
4717    /// Extensions discovered for the session, with their current status.
4718    ///
4719    /// <div class="warning">
4720    ///
4721    /// **Experimental.** This API is part of an experimental wire-protocol surface
4722    /// and may change or be removed in future SDK or CLI releases. Pin both the
4723    /// SDK and CLI versions if your code depends on it.
4724    ///
4725    /// </div>
4726    pub async fn list(&self) -> Result<ExtensionList, Error> {
4727        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
4728        let _value = self
4729            .session
4730            .client()
4731            .call(rpc_methods::SESSION_EXTENSIONS_LIST, Some(wire_params))
4732            .await?;
4733        Ok(serde_json::from_value(_value)?)
4734    }
4735
4736    /// Enables an extension for the session.
4737    ///
4738    /// Wire method: `session.extensions.enable`.
4739    ///
4740    /// # Parameters
4741    ///
4742    /// * `params` - Source-qualified extension identifier to enable for the session.
4743    ///
4744    /// <div class="warning">
4745    ///
4746    /// **Experimental.** This API is part of an experimental wire-protocol surface
4747    /// and may change or be removed in future SDK or CLI releases. Pin both the
4748    /// SDK and CLI versions if your code depends on it.
4749    ///
4750    /// </div>
4751    pub async fn enable(&self, params: ExtensionsEnableRequest) -> Result<(), Error> {
4752        let mut wire_params = serde_json::to_value(params)?;
4753        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4754        let _value = self
4755            .session
4756            .client()
4757            .call(rpc_methods::SESSION_EXTENSIONS_ENABLE, Some(wire_params))
4758            .await?;
4759        Ok(())
4760    }
4761
4762    /// Disables an extension for the session.
4763    ///
4764    /// Wire method: `session.extensions.disable`.
4765    ///
4766    /// # Parameters
4767    ///
4768    /// * `params` - Source-qualified extension identifier to disable for the session.
4769    ///
4770    /// <div class="warning">
4771    ///
4772    /// **Experimental.** This API is part of an experimental wire-protocol surface
4773    /// and may change or be removed in future SDK or CLI releases. Pin both the
4774    /// SDK and CLI versions if your code depends on it.
4775    ///
4776    /// </div>
4777    pub async fn disable(&self, params: ExtensionsDisableRequest) -> Result<(), Error> {
4778        let mut wire_params = serde_json::to_value(params)?;
4779        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4780        let _value = self
4781            .session
4782            .client()
4783            .call(rpc_methods::SESSION_EXTENSIONS_DISABLE, Some(wire_params))
4784            .await?;
4785        Ok(())
4786    }
4787
4788    /// Reloads extension definitions and processes for the session.
4789    ///
4790    /// Wire method: `session.extensions.reload`.
4791    ///
4792    /// <div class="warning">
4793    ///
4794    /// **Experimental.** This API is part of an experimental wire-protocol surface
4795    /// and may change or be removed in future SDK or CLI releases. Pin both the
4796    /// SDK and CLI versions if your code depends on it.
4797    ///
4798    /// </div>
4799    pub async fn reload(&self) -> Result<(), Error> {
4800        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
4801        let _value = self
4802            .session
4803            .client()
4804            .call(rpc_methods::SESSION_EXTENSIONS_RELOAD, Some(wire_params))
4805            .await?;
4806        Ok(())
4807    }
4808
4809    /// 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.
4810    ///
4811    /// Wire method: `session.extensions.sendAttachmentsToMessage`.
4812    ///
4813    /// # Parameters
4814    ///
4815    /// * `params` - Parameters for session.extensions.sendAttachmentsToMessage.
4816    ///
4817    /// <div class="warning">
4818    ///
4819    /// **Experimental.** This API is part of an experimental wire-protocol surface
4820    /// and may change or be removed in future SDK or CLI releases. Pin both the
4821    /// SDK and CLI versions if your code depends on it.
4822    ///
4823    /// </div>
4824    pub async fn send_attachments_to_message(
4825        &self,
4826        params: SendAttachmentsToMessageParams,
4827    ) -> Result<(), Error> {
4828        let mut wire_params = serde_json::to_value(params)?;
4829        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4830        let _value = self
4831            .session
4832            .client()
4833            .call(
4834                rpc_methods::SESSION_EXTENSIONS_SENDATTACHMENTSTOMESSAGE,
4835                Some(wire_params),
4836            )
4837            .await?;
4838        Ok(())
4839    }
4840}
4841
4842/// `session.factory.*` RPCs.
4843#[derive(Clone, Copy)]
4844pub struct SessionRpcFactory<'a> {
4845    pub(crate) session: &'a Session,
4846}
4847
4848impl<'a> SessionRpcFactory<'a> {
4849    /// `session.factory.journal.*` sub-namespace.
4850    pub fn journal(&self) -> SessionRpcFactoryJournal<'a> {
4851        SessionRpcFactoryJournal {
4852            session: self.session,
4853        }
4854    }
4855
4856    /// Runs a registered factory by name at the top level.
4857    ///
4858    /// Wire method: `session.factory.run`.
4859    ///
4860    /// # Parameters
4861    ///
4862    /// * `params` - Parameters for invoking a registered factory.
4863    ///
4864    /// # Returns
4865    ///
4866    /// Complete current or terminal factory run envelope.
4867    ///
4868    /// <div class="warning">
4869    ///
4870    /// **Experimental.** This API is part of an experimental wire-protocol surface
4871    /// and may change or be removed in future SDK or CLI releases. Pin both the
4872    /// SDK and CLI versions if your code depends on it.
4873    ///
4874    /// </div>
4875    pub async fn run(&self, params: FactoryRunRequest) -> Result<FactoryRunResult, Error> {
4876        let mut wire_params = serde_json::to_value(params)?;
4877        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4878        let _value = self
4879            .session
4880            .client()
4881            .call(rpc_methods::SESSION_FACTORY_RUN, Some(wire_params))
4882            .await?;
4883        Ok(serde_json::from_value(_value)?)
4884    }
4885
4886    /// Resumes a factory run using its persisted name, arguments, journal, and accounting.
4887    ///
4888    /// Wire method: `session.factory.resume`.
4889    ///
4890    /// # Parameters
4891    ///
4892    /// * `params` - Parameters for resuming a factory run from its persisted identity.
4893    ///
4894    /// # Returns
4895    ///
4896    /// Resolved persisted factory identity and resumed run envelope.
4897    ///
4898    /// <div class="warning">
4899    ///
4900    /// **Experimental.** This API is part of an experimental wire-protocol surface
4901    /// and may change or be removed in future SDK or CLI releases. Pin both the
4902    /// SDK and CLI versions if your code depends on it.
4903    ///
4904    /// </div>
4905    pub async fn resume(&self, params: FactoryResumeRequest) -> Result<FactoryResumeResult, Error> {
4906        let mut wire_params = serde_json::to_value(params)?;
4907        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4908        let _value = self
4909            .session
4910            .client()
4911            .call(rpc_methods::SESSION_FACTORY_RESUME, Some(wire_params))
4912            .await?;
4913        Ok(serde_json::from_value(_value)?)
4914    }
4915
4916    /// Internal tool-originated factory invocation.
4917    ///
4918    /// Wire method: `session.factory.runFromTool`.
4919    ///
4920    /// # Parameters
4921    ///
4922    /// * `params` - Internal parameters for invoking a registered factory from a tool.
4923    ///
4924    /// # Returns
4925    ///
4926    /// Complete current or terminal factory run envelope.
4927    ///
4928    /// <div class="warning">
4929    ///
4930    /// **Experimental.** This API is part of an experimental wire-protocol surface
4931    /// and may change or be removed in future SDK or CLI releases. Pin both the
4932    /// SDK and CLI versions if your code depends on it.
4933    ///
4934    /// </div>
4935    pub(crate) async fn run_from_tool(
4936        &self,
4937        params: FactoryToolRunRequest,
4938    ) -> Result<FactoryRunResult, Error> {
4939        let mut wire_params = serde_json::to_value(params)?;
4940        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4941        let _value = self
4942            .session
4943            .client()
4944            .call(rpc_methods::SESSION_FACTORY_RUNFROMTOOL, Some(wire_params))
4945            .await?;
4946        Ok(serde_json::from_value(_value)?)
4947    }
4948
4949    /// Internal tool-originated factory resume.
4950    ///
4951    /// Wire method: `session.factory.resumeFromTool`.
4952    ///
4953    /// # Parameters
4954    ///
4955    /// * `params` - Internal parameters for resuming a factory run from a tool.
4956    ///
4957    /// # Returns
4958    ///
4959    /// Resolved persisted factory identity and resumed run envelope.
4960    ///
4961    /// <div class="warning">
4962    ///
4963    /// **Experimental.** This API is part of an experimental wire-protocol surface
4964    /// and may change or be removed in future SDK or CLI releases. Pin both the
4965    /// SDK and CLI versions if your code depends on it.
4966    ///
4967    /// </div>
4968    pub(crate) async fn resume_from_tool(
4969        &self,
4970        params: FactoryToolResumeRequest,
4971    ) -> Result<FactoryResumeResult, Error> {
4972        let mut wire_params = serde_json::to_value(params)?;
4973        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4974        let _value = self
4975            .session
4976            .client()
4977            .call(
4978                rpc_methods::SESSION_FACTORY_RESUMEFROMTOOL,
4979                Some(wire_params),
4980            )
4981            .await?;
4982        Ok(serde_json::from_value(_value)?)
4983    }
4984
4985    /// Gets the current or settled envelope for a factory run.
4986    ///
4987    /// Wire method: `session.factory.getRun`.
4988    ///
4989    /// # Parameters
4990    ///
4991    /// * `params` - Parameters for retrieving a factory run.
4992    ///
4993    /// # Returns
4994    ///
4995    /// Complete current or terminal factory run envelope.
4996    ///
4997    /// <div class="warning">
4998    ///
4999    /// **Experimental.** This API is part of an experimental wire-protocol surface
5000    /// and may change or be removed in future SDK or CLI releases. Pin both the
5001    /// SDK and CLI versions if your code depends on it.
5002    ///
5003    /// </div>
5004    pub async fn get_run(&self, params: FactoryGetRunRequest) -> Result<FactoryRunResult, Error> {
5005        let mut wire_params = serde_json::to_value(params)?;
5006        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5007        let _value = self
5008            .session
5009            .client()
5010            .call(rpc_methods::SESSION_FACTORY_GETRUN, Some(wire_params))
5011            .await?;
5012        Ok(serde_json::from_value(_value)?)
5013    }
5014
5015    /// Lists durable factory runs for this session in creation order.
5016    ///
5017    /// Wire method: `session.factory.listRuns`.
5018    ///
5019    /// # Parameters
5020    ///
5021    /// * `params` - Parameters for paging factory runs.
5022    ///
5023    /// # Returns
5024    ///
5025    /// A page of factory runs in durable creation order.
5026    ///
5027    /// <div class="warning">
5028    ///
5029    /// **Experimental.** This API is part of an experimental wire-protocol surface
5030    /// and may change or be removed in future SDK or CLI releases. Pin both the
5031    /// SDK and CLI versions if your code depends on it.
5032    ///
5033    /// </div>
5034    pub async fn list_runs(
5035        &self,
5036        params: FactoryListRunsRequest,
5037    ) -> Result<FactoryListRunsResult, Error> {
5038        let mut wire_params = serde_json::to_value(params)?;
5039        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5040        let _value = self
5041            .session
5042            .client()
5043            .call(rpc_methods::SESSION_FACTORY_LISTRUNS, Some(wire_params))
5044            .await?;
5045        Ok(serde_json::from_value(_value)?)
5046    }
5047
5048    /// Gets durable and live observability detail for one factory run.
5049    ///
5050    /// Wire method: `session.factory.getRunDetail`.
5051    ///
5052    /// # Parameters
5053    ///
5054    /// * `params` - Parameters for retrieving a factory run.
5055    ///
5056    /// # Returns
5057    ///
5058    /// Full factory run observability detail.
5059    ///
5060    /// <div class="warning">
5061    ///
5062    /// **Experimental.** This API is part of an experimental wire-protocol surface
5063    /// and may change or be removed in future SDK or CLI releases. Pin both the
5064    /// SDK and CLI versions if your code depends on it.
5065    ///
5066    /// </div>
5067    pub async fn get_run_detail(
5068        &self,
5069        params: FactoryGetRunRequest,
5070    ) -> Result<FactoryRunDetail, Error> {
5071        let mut wire_params = serde_json::to_value(params)?;
5072        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5073        let _value = self
5074            .session
5075            .client()
5076            .call(rpc_methods::SESSION_FACTORY_GETRUNDETAIL, Some(wire_params))
5077            .await?;
5078        Ok(serde_json::from_value(_value)?)
5079    }
5080
5081    /// Pages durable progress for one factory run.
5082    ///
5083    /// Wire method: `session.factory.getRunProgress`.
5084    ///
5085    /// # Parameters
5086    ///
5087    /// * `params` - Parameters for paging factory progress.
5088    ///
5089    /// # Returns
5090    ///
5091    /// A bidirectional page of factory progress.
5092    ///
5093    /// <div class="warning">
5094    ///
5095    /// **Experimental.** This API is part of an experimental wire-protocol surface
5096    /// and may change or be removed in future SDK or CLI releases. Pin both the
5097    /// SDK and CLI versions if your code depends on it.
5098    ///
5099    /// </div>
5100    pub async fn get_run_progress(
5101        &self,
5102        params: FactoryGetRunProgressRequest,
5103    ) -> Result<FactoryProgressPage, Error> {
5104        let mut wire_params = serde_json::to_value(params)?;
5105        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5106        let _value = self
5107            .session
5108            .client()
5109            .call(
5110                rpc_methods::SESSION_FACTORY_GETRUNPROGRESS,
5111                Some(wire_params),
5112            )
5113            .await?;
5114        Ok(serde_json::from_value(_value)?)
5115    }
5116
5117    /// Requests cancellation of a factory run and returns its run envelope.
5118    ///
5119    /// Wire method: `session.factory.cancel`.
5120    ///
5121    /// # Parameters
5122    ///
5123    /// * `params` - Parameters for cancelling a factory run.
5124    ///
5125    /// # Returns
5126    ///
5127    /// Complete current or terminal factory run envelope.
5128    ///
5129    /// <div class="warning">
5130    ///
5131    /// **Experimental.** This API is part of an experimental wire-protocol surface
5132    /// and may change or be removed in future SDK or CLI releases. Pin both the
5133    /// SDK and CLI versions if your code depends on it.
5134    ///
5135    /// </div>
5136    pub async fn cancel(&self, params: FactoryCancelRequest) -> Result<FactoryRunResult, Error> {
5137        let mut wire_params = serde_json::to_value(params)?;
5138        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5139        let _value = self
5140            .session
5141            .client()
5142            .call(rpc_methods::SESSION_FACTORY_CANCEL, Some(wire_params))
5143            .await?;
5144        Ok(serde_json::from_value(_value)?)
5145    }
5146
5147    /// Pauses a running factory and returns its settled run envelope.
5148    ///
5149    /// Wire method: `session.factory.pause`.
5150    ///
5151    /// # Parameters
5152    ///
5153    /// * `params` - Parameters for pausing a running factory.
5154    ///
5155    /// # Returns
5156    ///
5157    /// Complete current or terminal factory run envelope.
5158    ///
5159    /// <div class="warning">
5160    ///
5161    /// **Experimental.** This API is part of an experimental wire-protocol surface
5162    /// and may change or be removed in future SDK or CLI releases. Pin both the
5163    /// SDK and CLI versions if your code depends on it.
5164    ///
5165    /// </div>
5166    pub async fn pause(&self, params: FactoryPauseRequest) -> Result<FactoryRunResult, Error> {
5167        let mut wire_params = serde_json::to_value(params)?;
5168        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5169        let _value = self
5170            .session
5171            .client()
5172            .call(rpc_methods::SESSION_FACTORY_PAUSE, Some(wire_params))
5173            .await?;
5174        Ok(serde_json::from_value(_value)?)
5175    }
5176
5177    /// Atomically pauses an owned factory attempt at a durable checkpoint.
5178    ///
5179    /// Wire method: `session.factory.pauseAtCheckpoint`.
5180    ///
5181    /// # Parameters
5182    ///
5183    /// * `params` - Parameters for an owned durable pause checkpoint.
5184    ///
5185    /// <div class="warning">
5186    ///
5187    /// **Experimental.** This API is part of an experimental wire-protocol surface
5188    /// and may change or be removed in future SDK or CLI releases. Pin both the
5189    /// SDK and CLI versions if your code depends on it.
5190    ///
5191    /// </div>
5192    pub(crate) async fn pause_at_checkpoint(
5193        &self,
5194        params: FactoryPauseCheckpointRequest,
5195    ) -> Result<FactoryPauseCheckpointResult, Error> {
5196        let mut wire_params = serde_json::to_value(params)?;
5197        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5198        let _value = self
5199            .session
5200            .client()
5201            .call(
5202                rpc_methods::SESSION_FACTORY_PAUSEATCHECKPOINT,
5203                Some(wire_params),
5204            )
5205            .await?;
5206        Ok(serde_json::from_value(_value)?)
5207    }
5208
5209    /// Records a batch of ordered factory progress lines.
5210    ///
5211    /// Wire method: `session.factory.log`.
5212    ///
5213    /// # Parameters
5214    ///
5215    /// * `params` - Parameters for recording factory progress.
5216    ///
5217    /// # Returns
5218    ///
5219    /// Acknowledgement that a factory request was accepted.
5220    ///
5221    /// <div class="warning">
5222    ///
5223    /// **Experimental.** This API is part of an experimental wire-protocol surface
5224    /// and may change or be removed in future SDK or CLI releases. Pin both the
5225    /// SDK and CLI versions if your code depends on it.
5226    ///
5227    /// </div>
5228    pub async fn log(&self, params: FactoryLogRequest) -> Result<FactoryAckResult, Error> {
5229        let mut wire_params = serde_json::to_value(params)?;
5230        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5231        let _value = self
5232            .session
5233            .client()
5234            .call(rpc_methods::SESSION_FACTORY_LOG, Some(wire_params))
5235            .await?;
5236        Ok(serde_json::from_value(_value)?)
5237    }
5238
5239    /// Runs one factory-scoped subagent and returns its result.
5240    ///
5241    /// Wire method: `session.factory.agent`.
5242    ///
5243    /// # Parameters
5244    ///
5245    /// * `params` - Parameters for one factory-scoped subagent call.
5246    ///
5247    /// # Returns
5248    ///
5249    /// Result of one factory-scoped subagent call.
5250    ///
5251    /// <div class="warning">
5252    ///
5253    /// **Experimental.** This API is part of an experimental wire-protocol surface
5254    /// and may change or be removed in future SDK or CLI releases. Pin both the
5255    /// SDK and CLI versions if your code depends on it.
5256    ///
5257    /// </div>
5258    pub async fn agent(&self, params: FactoryAgentRequest) -> Result<FactoryAgentResult, Error> {
5259        let mut wire_params = serde_json::to_value(params)?;
5260        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5261        let _value = self
5262            .session
5263            .client()
5264            .call(rpc_methods::SESSION_FACTORY_AGENT, Some(wire_params))
5265            .await?;
5266        Ok(serde_json::from_value(_value)?)
5267    }
5268}
5269
5270/// `session.factory.journal.*` RPCs.
5271#[derive(Clone, Copy)]
5272pub struct SessionRpcFactoryJournal<'a> {
5273    pub(crate) session: &'a Session,
5274}
5275
5276impl<'a> SessionRpcFactoryJournal<'a> {
5277    /// Reads a memoized factory journal entry.
5278    ///
5279    /// Wire method: `session.factory.journal.get`.
5280    ///
5281    /// # Parameters
5282    ///
5283    /// * `params` - Parameters for reading a factory journal entry.
5284    ///
5285    /// # Returns
5286    ///
5287    /// Result of reading a factory journal entry.
5288    ///
5289    /// <div class="warning">
5290    ///
5291    /// **Experimental.** This API is part of an experimental wire-protocol surface
5292    /// and may change or be removed in future SDK or CLI releases. Pin both the
5293    /// SDK and CLI versions if your code depends on it.
5294    ///
5295    /// </div>
5296    pub async fn get(
5297        &self,
5298        params: FactoryJournalGetRequest,
5299    ) -> Result<FactoryJournalGetResult, Error> {
5300        let mut wire_params = serde_json::to_value(params)?;
5301        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5302        let _value = self
5303            .session
5304            .client()
5305            .call(rpc_methods::SESSION_FACTORY_JOURNAL_GET, Some(wire_params))
5306            .await?;
5307        Ok(serde_json::from_value(_value)?)
5308    }
5309
5310    /// Stores a memoized factory journal entry.
5311    ///
5312    /// Wire method: `session.factory.journal.put`.
5313    ///
5314    /// # Parameters
5315    ///
5316    /// * `params` - Parameters for storing a factory journal entry.
5317    ///
5318    /// # Returns
5319    ///
5320    /// Acknowledgement that a factory request was accepted.
5321    ///
5322    /// <div class="warning">
5323    ///
5324    /// **Experimental.** This API is part of an experimental wire-protocol surface
5325    /// and may change or be removed in future SDK or CLI releases. Pin both the
5326    /// SDK and CLI versions if your code depends on it.
5327    ///
5328    /// </div>
5329    pub async fn put(&self, params: FactoryJournalPutRequest) -> Result<FactoryAckResult, Error> {
5330        let mut wire_params = serde_json::to_value(params)?;
5331        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5332        let _value = self
5333            .session
5334            .client()
5335            .call(rpc_methods::SESSION_FACTORY_JOURNAL_PUT, Some(wire_params))
5336            .await?;
5337        Ok(serde_json::from_value(_value)?)
5338    }
5339}
5340
5341/// `session.fleet.*` RPCs.
5342#[derive(Clone, Copy)]
5343pub struct SessionRpcFleet<'a> {
5344    pub(crate) session: &'a Session,
5345}
5346
5347impl<'a> SessionRpcFleet<'a> {
5348    /// Starts fleet mode by submitting the fleet orchestration prompt to the session.
5349    ///
5350    /// Wire method: `session.fleet.start`.
5351    ///
5352    /// # Parameters
5353    ///
5354    /// * `params` - Parameters for starting fleet orchestration: an optional user prompt combined with the fleet instructions, plus the send options forwarded to the resulting turn.
5355    ///
5356    /// # Returns
5357    ///
5358    /// Indicates whether fleet mode was successfully activated.
5359    ///
5360    /// <div class="warning">
5361    ///
5362    /// **Experimental.** This API is part of an experimental wire-protocol surface
5363    /// and may change or be removed in future SDK or CLI releases. Pin both the
5364    /// SDK and CLI versions if your code depends on it.
5365    ///
5366    /// </div>
5367    pub async fn start(&self, params: FleetStartRequest) -> Result<FleetStartResult, Error> {
5368        let mut wire_params = serde_json::to_value(params)?;
5369        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5370        let _value = self
5371            .session
5372            .client()
5373            .call(rpc_methods::SESSION_FLEET_START, Some(wire_params))
5374            .await?;
5375        Ok(serde_json::from_value(_value)?)
5376    }
5377}
5378
5379/// `session.gitHubAuth.*` RPCs.
5380#[derive(Clone, Copy)]
5381pub struct SessionRpcGitHubAuth<'a> {
5382    pub(crate) session: &'a Session,
5383}
5384
5385impl<'a> SessionRpcGitHubAuth<'a> {
5386    /// Gets authentication status and account metadata for the session.
5387    ///
5388    /// Wire method: `session.gitHubAuth.getStatus`.
5389    ///
5390    /// # Returns
5391    ///
5392    /// Authentication status and account metadata for the session.
5393    ///
5394    /// <div class="warning">
5395    ///
5396    /// **Experimental.** This API is part of an experimental wire-protocol surface
5397    /// and may change or be removed in future SDK or CLI releases. Pin both the
5398    /// SDK and CLI versions if your code depends on it.
5399    ///
5400    /// </div>
5401    pub async fn get_status(&self) -> Result<SessionAuthStatus, Error> {
5402        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5403        let _value = self
5404            .session
5405            .client()
5406            .call(rpc_methods::SESSION_GITHUBAUTH_GETSTATUS, Some(wire_params))
5407            .await?;
5408        Ok(serde_json::from_value(_value)?)
5409    }
5410
5411    /// Updates the session's auth credentials used for outbound model and API requests.
5412    ///
5413    /// Wire method: `session.gitHubAuth.setCredentials`.
5414    ///
5415    /// # Parameters
5416    ///
5417    /// * `params` - New auth credentials to install on the session. Omit to leave credentials unchanged.
5418    ///
5419    /// # Returns
5420    ///
5421    /// Indicates whether the credential update succeeded.
5422    ///
5423    /// <div class="warning">
5424    ///
5425    /// **Experimental.** This API is part of an experimental wire-protocol surface
5426    /// and may change or be removed in future SDK or CLI releases. Pin both the
5427    /// SDK and CLI versions if your code depends on it.
5428    ///
5429    /// </div>
5430    pub async fn set_credentials(
5431        &self,
5432        params: SessionSetCredentialsParams,
5433    ) -> Result<SessionSetCredentialsResult, Error> {
5434        let mut wire_params = serde_json::to_value(params)?;
5435        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5436        let _value = self
5437            .session
5438            .client()
5439            .call(
5440                rpc_methods::SESSION_GITHUBAUTH_SETCREDENTIALS,
5441                Some(wire_params),
5442            )
5443            .await?;
5444        Ok(serde_json::from_value(_value)?)
5445    }
5446
5447    /// Gets the current authentication information for internal session hosts.
5448    ///
5449    /// Wire method: `session.gitHubAuth.getCurrentAuthInfo`.
5450    ///
5451    /// # Returns
5452    ///
5453    /// Current authentication information, or null when no authentication is active.
5454    ///
5455    /// <div class="warning">
5456    ///
5457    /// **Experimental.** This API is part of an experimental wire-protocol surface
5458    /// and may change or be removed in future SDK or CLI releases. Pin both the
5459    /// SDK and CLI versions if your code depends on it.
5460    ///
5461    /// </div>
5462    pub(crate) async fn get_current_auth_info(&self) -> Result<SessionAuthInfoResult, Error> {
5463        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5464        let _value = self
5465            .session
5466            .client()
5467            .call(
5468                rpc_methods::SESSION_GITHUBAUTH_GETCURRENTAUTHINFO,
5469                Some(wire_params),
5470            )
5471            .await?;
5472        Ok(serde_json::from_value(_value)?)
5473    }
5474
5475    /// Gets all authentication accounts available to the internal session host.
5476    ///
5477    /// Wire method: `session.gitHubAuth.getAllAuthAvailable`.
5478    ///
5479    /// # Returns
5480    ///
5481    /// Authentication accounts available to the internal session host.
5482    ///
5483    /// <div class="warning">
5484    ///
5485    /// **Experimental.** This API is part of an experimental wire-protocol surface
5486    /// and may change or be removed in future SDK or CLI releases. Pin both the
5487    /// SDK and CLI versions if your code depends on it.
5488    ///
5489    /// </div>
5490    pub(crate) async fn get_all_auth_available(
5491        &self,
5492    ) -> Result<SessionGitHubAuthGetAllAuthAvailableResult, Error> {
5493        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5494        let _value = self
5495            .session
5496            .client()
5497            .call(
5498                rpc_methods::SESSION_GITHUBAUTH_GETALLAUTHAVAILABLE,
5499                Some(wire_params),
5500            )
5501            .await?;
5502        Ok(serde_json::from_value(_value)?)
5503    }
5504
5505    /// Refreshes Copilot account metadata for the current authentication.
5506    ///
5507    /// Wire method: `session.gitHubAuth.refreshCopilotUser`.
5508    ///
5509    /// # Returns
5510    ///
5511    /// Current authentication information, or null when no authentication is active.
5512    ///
5513    /// <div class="warning">
5514    ///
5515    /// **Experimental.** This API is part of an experimental wire-protocol surface
5516    /// and may change or be removed in future SDK or CLI releases. Pin both the
5517    /// SDK and CLI versions if your code depends on it.
5518    ///
5519    /// </div>
5520    pub(crate) async fn refresh_copilot_user(&self) -> Result<SessionAuthInfoResult, Error> {
5521        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5522        let _value = self
5523            .session
5524            .client()
5525            .call(
5526                rpc_methods::SESSION_GITHUBAUTH_REFRESHCOPILOTUSER,
5527                Some(wire_params),
5528            )
5529            .await?;
5530        Ok(serde_json::from_value(_value)?)
5531    }
5532
5533    /// Logs in a GitHub user through the internal session host.
5534    ///
5535    /// Wire method: `session.gitHubAuth.login`.
5536    ///
5537    /// # Parameters
5538    ///
5539    /// * `params` - Internal GitHub login parameters.
5540    ///
5541    /// # Returns
5542    ///
5543    /// Authentication credentials accepted only at native protocol ingress. Runtime outputs use credential-free `AuthIdentity` metadata.
5544    ///
5545    /// <div class="warning">
5546    ///
5547    /// **Experimental.** This API is part of an experimental wire-protocol surface
5548    /// and may change or be removed in future SDK or CLI releases. Pin both the
5549    /// SDK and CLI versions if your code depends on it.
5550    ///
5551    /// </div>
5552    pub(crate) async fn login(&self, params: SessionAuthLoginRequest) -> Result<AuthInfo, Error> {
5553        let mut wire_params = serde_json::to_value(params)?;
5554        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5555        let _value = self
5556            .session
5557            .client()
5558            .call(rpc_methods::SESSION_GITHUBAUTH_LOGIN, Some(wire_params))
5559            .await?;
5560        Ok(serde_json::from_value(_value)?)
5561    }
5562
5563    /// Switches the session to another available authentication.
5564    ///
5565    /// Wire method: `session.gitHubAuth.switchToAuth`.
5566    ///
5567    /// # Parameters
5568    ///
5569    /// * `params` - Parameters for switching the session's active authentication.
5570    ///
5571    /// <div class="warning">
5572    ///
5573    /// **Experimental.** This API is part of an experimental wire-protocol surface
5574    /// and may change or be removed in future SDK or CLI releases. Pin both the
5575    /// SDK and CLI versions if your code depends on it.
5576    ///
5577    /// </div>
5578    pub(crate) async fn switch_to_auth(
5579        &self,
5580        params: SessionAuthSwitchRequest,
5581    ) -> Result<(), Error> {
5582        let mut wire_params = serde_json::to_value(params)?;
5583        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5584        let _value = self
5585            .session
5586            .client()
5587            .call(
5588                rpc_methods::SESSION_GITHUBAUTH_SWITCHTOAUTH,
5589                Some(wire_params),
5590            )
5591            .await?;
5592        Ok(())
5593    }
5594
5595    /// Logs out the session's current GitHub authentication.
5596    ///
5597    /// Wire method: `session.gitHubAuth.logout`.
5598    ///
5599    /// # Returns
5600    ///
5601    /// Whether the current authentication was logged out.
5602    ///
5603    /// <div class="warning">
5604    ///
5605    /// **Experimental.** This API is part of an experimental wire-protocol surface
5606    /// and may change or be removed in future SDK or CLI releases. Pin both the
5607    /// SDK and CLI versions if your code depends on it.
5608    ///
5609    /// </div>
5610    pub(crate) async fn logout(&self) -> Result<SessionGitHubAuthLogoutResult, Error> {
5611        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5612        let _value = self
5613            .session
5614            .client()
5615            .call(rpc_methods::SESSION_GITHUBAUTH_LOGOUT, Some(wire_params))
5616            .await?;
5617        Ok(serde_json::from_value(_value)?)
5618    }
5619
5620    /// Logs out a specific GitHub authentication.
5621    ///
5622    /// Wire method: `session.gitHubAuth.logoutUser`.
5623    ///
5624    /// # Parameters
5625    ///
5626    /// * `params` - Parameters identifying a GitHub authentication to log out.
5627    ///
5628    /// # Returns
5629    ///
5630    /// Whether the requested authentication was logged out.
5631    ///
5632    /// <div class="warning">
5633    ///
5634    /// **Experimental.** This API is part of an experimental wire-protocol surface
5635    /// and may change or be removed in future SDK or CLI releases. Pin both the
5636    /// SDK and CLI versions if your code depends on it.
5637    ///
5638    /// </div>
5639    pub(crate) async fn logout_user(
5640        &self,
5641        params: SessionAuthLogoutUserRequest,
5642    ) -> Result<SessionGitHubAuthLogoutUserResult, Error> {
5643        let mut wire_params = serde_json::to_value(params)?;
5644        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5645        let _value = self
5646            .session
5647            .client()
5648            .call(
5649                rpc_methods::SESSION_GITHUBAUTH_LOGOUTUSER,
5650                Some(wire_params),
5651            )
5652            .await?;
5653        Ok(serde_json::from_value(_value)?)
5654    }
5655
5656    /// Gets validation errors from the most recent authentication attempt.
5657    ///
5658    /// Wire method: `session.gitHubAuth.lastAuthErrors`.
5659    ///
5660    /// # Returns
5661    ///
5662    /// Validation errors from the most recent authentication attempt.
5663    ///
5664    /// <div class="warning">
5665    ///
5666    /// **Experimental.** This API is part of an experimental wire-protocol surface
5667    /// and may change or be removed in future SDK or CLI releases. Pin both the
5668    /// SDK and CLI versions if your code depends on it.
5669    ///
5670    /// </div>
5671    pub(crate) async fn last_auth_errors(&self) -> Result<AuthValidationErrors, Error> {
5672        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5673        let _value = self
5674            .session
5675            .client()
5676            .call(
5677                rpc_methods::SESSION_GITHUBAUTH_LASTAUTHERRORS,
5678                Some(wire_params),
5679            )
5680            .await?;
5681        Ok(serde_json::from_value(_value)?)
5682    }
5683}
5684
5685/// `session.history.*` RPCs.
5686#[derive(Clone, Copy)]
5687pub struct SessionRpcHistory<'a> {
5688    pub(crate) session: &'a Session,
5689}
5690
5691impl<'a> SessionRpcHistory<'a> {
5692    /// Compacts the session history to reduce context usage.
5693    ///
5694    /// Wire method: `session.history.compact`.
5695    ///
5696    /// # Returns
5697    ///
5698    /// Compaction outcome with the number of tokens and messages removed, summary text, and the resulting context window breakdown.
5699    ///
5700    /// <div class="warning">
5701    ///
5702    /// **Experimental.** This API is part of an experimental wire-protocol surface
5703    /// and may change or be removed in future SDK or CLI releases. Pin both the
5704    /// SDK and CLI versions if your code depends on it.
5705    ///
5706    /// </div>
5707    pub async fn compact(&self) -> Result<HistoryCompactResult, Error> {
5708        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5709        let _value = self
5710            .session
5711            .client()
5712            .call(rpc_methods::SESSION_HISTORY_COMPACT, Some(wire_params))
5713            .await?;
5714        Ok(serde_json::from_value(_value)?)
5715    }
5716
5717    /// Compacts the session history to reduce context usage.
5718    ///
5719    /// Wire method: `session.history.compact`.
5720    ///
5721    /// # Parameters
5722    ///
5723    /// * `params` - Optional compaction parameters.
5724    ///
5725    /// # Returns
5726    ///
5727    /// Compaction outcome with the number of tokens and messages removed, summary text, and the resulting context window breakdown.
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 compact_with_params(
5737        &self,
5738        params: HistoryCompactRequest,
5739    ) -> Result<HistoryCompactResult, Error> {
5740        let mut wire_params = serde_json::to_value(params)?;
5741        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5742        let _value = self
5743            .session
5744            .client()
5745            .call(rpc_methods::SESSION_HISTORY_COMPACT, Some(wire_params))
5746            .await?;
5747        Ok(serde_json::from_value(_value)?)
5748    }
5749
5750    /// Truncates persisted session history to a specific event.
5751    ///
5752    /// Wire method: `session.history.truncate`.
5753    ///
5754    /// # Parameters
5755    ///
5756    /// * `params` - Identifier of the event to truncate to; this event and all later events are removed.
5757    ///
5758    /// # Returns
5759    ///
5760    /// Number of events that were removed by the truncation.
5761    ///
5762    /// <div class="warning">
5763    ///
5764    /// **Experimental.** This API is part of an experimental wire-protocol surface
5765    /// and may change or be removed in future SDK or CLI releases. Pin both the
5766    /// SDK and CLI versions if your code depends on it.
5767    ///
5768    /// </div>
5769    pub async fn truncate(
5770        &self,
5771        params: HistoryTruncateRequest,
5772    ) -> Result<HistoryTruncateResult, Error> {
5773        let mut wire_params = serde_json::to_value(params)?;
5774        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5775        let _value = self
5776            .session
5777            .client()
5778            .call(rpc_methods::SESSION_HISTORY_TRUNCATE, Some(wire_params))
5779            .await?;
5780        Ok(serde_json::from_value(_value)?)
5781    }
5782
5783    /// 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.
5784    ///
5785    /// Wire method: `session.history.listRewindPoints`.
5786    ///
5787    /// # Returns
5788    ///
5789    /// Rewind points and file-change-tracking availability for the session.
5790    ///
5791    /// <div class="warning">
5792    ///
5793    /// **Experimental.** This API is part of an experimental wire-protocol surface
5794    /// and may change or be removed in future SDK or CLI releases. Pin both the
5795    /// SDK and CLI versions if your code depends on it.
5796    ///
5797    /// </div>
5798    pub async fn list_rewind_points(&self) -> Result<HistoryListRewindPointsResult, Error> {
5799        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5800        let _value = self
5801            .session
5802            .client()
5803            .call(
5804                rpc_methods::SESSION_HISTORY_LISTREWINDPOINTS,
5805                Some(wire_params),
5806            )
5807            .await?;
5808        Ok(serde_json::from_value(_value)?)
5809    }
5810
5811    /// Previews the files that a conversation-and-files rewind would restore.
5812    ///
5813    /// Wire method: `session.history.previewRewind`.
5814    ///
5815    /// # Parameters
5816    ///
5817    /// * `params` - Event boundary to preview for conversation-and-files rewind.
5818    ///
5819    /// # Returns
5820    ///
5821    /// Files and aggregate changes for a prospective rewind.
5822    ///
5823    /// <div class="warning">
5824    ///
5825    /// **Experimental.** This API is part of an experimental wire-protocol surface
5826    /// and may change or be removed in future SDK or CLI releases. Pin both the
5827    /// SDK and CLI versions if your code depends on it.
5828    ///
5829    /// </div>
5830    pub async fn preview_rewind(
5831        &self,
5832        params: HistoryPreviewRewindRequest,
5833    ) -> Result<HistoryPreviewRewindResult, Error> {
5834        let mut wire_params = serde_json::to_value(params)?;
5835        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5836        let _value = self
5837            .session
5838            .client()
5839            .call(
5840                rpc_methods::SESSION_HISTORY_PREVIEWREWIND,
5841                Some(wire_params),
5842            )
5843            .await?;
5844        Ok(serde_json::from_value(_value)?)
5845    }
5846
5847    /// 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.
5848    ///
5849    /// Wire method: `session.history.rewind`.
5850    ///
5851    /// # Parameters
5852    ///
5853    /// * `params` - Boundary and mode for rewinding session history.
5854    ///
5855    /// # Returns
5856    ///
5857    /// Structured outcome of a rewind request.
5858    ///
5859    /// <div class="warning">
5860    ///
5861    /// **Experimental.** This API is part of an experimental wire-protocol surface
5862    /// and may change or be removed in future SDK or CLI releases. Pin both the
5863    /// SDK and CLI versions if your code depends on it.
5864    ///
5865    /// </div>
5866    pub async fn rewind(&self, params: HistoryRewindRequest) -> Result<HistoryRewindResult, Error> {
5867        let mut wire_params = serde_json::to_value(params)?;
5868        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5869        let _value = self
5870            .session
5871            .client()
5872            .call(rpc_methods::SESSION_HISTORY_REWIND, Some(wire_params))
5873            .await?;
5874        Ok(serde_json::from_value(_value)?)
5875    }
5876
5877    /// Cancels any in-progress background compaction on a local session.
5878    ///
5879    /// Wire method: `session.history.cancelBackgroundCompaction`.
5880    ///
5881    /// # Returns
5882    ///
5883    /// Indicates whether an in-progress background compaction was cancelled.
5884    ///
5885    /// <div class="warning">
5886    ///
5887    /// **Experimental.** This API is part of an experimental wire-protocol surface
5888    /// and may change or be removed in future SDK or CLI releases. Pin both the
5889    /// SDK and CLI versions if your code depends on it.
5890    ///
5891    /// </div>
5892    pub async fn cancel_background_compaction(
5893        &self,
5894    ) -> Result<HistoryCancelBackgroundCompactionResult, Error> {
5895        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5896        let _value = self
5897            .session
5898            .client()
5899            .call(
5900                rpc_methods::SESSION_HISTORY_CANCELBACKGROUNDCOMPACTION,
5901                Some(wire_params),
5902            )
5903            .await?;
5904        Ok(serde_json::from_value(_value)?)
5905    }
5906
5907    /// Aborts any in-progress manual compaction on a local session.
5908    ///
5909    /// Wire method: `session.history.abortManualCompaction`.
5910    ///
5911    /// # Returns
5912    ///
5913    /// Indicates whether an in-progress manual compaction was aborted.
5914    ///
5915    /// <div class="warning">
5916    ///
5917    /// **Experimental.** This API is part of an experimental wire-protocol surface
5918    /// and may change or be removed in future SDK or CLI releases. Pin both the
5919    /// SDK and CLI versions if your code depends on it.
5920    ///
5921    /// </div>
5922    pub async fn abort_manual_compaction(
5923        &self,
5924    ) -> Result<HistoryAbortManualCompactionResult, Error> {
5925        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5926        let _value = self
5927            .session
5928            .client()
5929            .call(
5930                rpc_methods::SESSION_HISTORY_ABORTMANUALCOMPACTION,
5931                Some(wire_params),
5932            )
5933            .await?;
5934        Ok(serde_json::from_value(_value)?)
5935    }
5936
5937    /// Produces a markdown summary of the session's conversation context for hand-off scenarios.
5938    ///
5939    /// Wire method: `session.history.summarizeForHandoff`.
5940    ///
5941    /// # Returns
5942    ///
5943    /// Markdown summary of the conversation context (empty when not available).
5944    ///
5945    /// <div class="warning">
5946    ///
5947    /// **Experimental.** This API is part of an experimental wire-protocol surface
5948    /// and may change or be removed in future SDK or CLI releases. Pin both the
5949    /// SDK and CLI versions if your code depends on it.
5950    ///
5951    /// </div>
5952    pub async fn summarize_for_handoff(&self) -> Result<HistorySummarizeForHandoffResult, Error> {
5953        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5954        let _value = self
5955            .session
5956            .client()
5957            .call(
5958                rpc_methods::SESSION_HISTORY_SUMMARIZEFORHANDOFF,
5959                Some(wire_params),
5960            )
5961            .await?;
5962        Ok(serde_json::from_value(_value)?)
5963    }
5964
5965    /// 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.
5966    ///
5967    /// Wire method: `session.history.clearContext`.
5968    ///
5969    /// # Parameters
5970    ///
5971    /// * `params` - Parameters for clearing the conversation and seeding the window that replaces it.
5972    ///
5973    /// # Returns
5974    ///
5975    /// What a successful clear removed. A clear that could not be applied rejects instead of reporting a count.
5976    ///
5977    /// <div class="warning">
5978    ///
5979    /// **Experimental.** This API is part of an experimental wire-protocol surface
5980    /// and may change or be removed in future SDK or CLI releases. Pin both the
5981    /// SDK and CLI versions if your code depends on it.
5982    ///
5983    /// </div>
5984    pub async fn clear_context(
5985        &self,
5986        params: HistoryClearContextRequest,
5987    ) -> Result<HistoryClearContextResult, Error> {
5988        let mut wire_params = serde_json::to_value(params)?;
5989        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5990        let _value = self
5991            .session
5992            .client()
5993            .call(rpc_methods::SESSION_HISTORY_CLEARCONTEXT, Some(wire_params))
5994            .await?;
5995        Ok(serde_json::from_value(_value)?)
5996    }
5997}
5998
5999/// `session.instructions.*` RPCs.
6000#[derive(Clone, Copy)]
6001pub struct SessionRpcInstructions<'a> {
6002    pub(crate) session: &'a Session,
6003}
6004
6005impl<'a> SessionRpcInstructions<'a> {
6006    /// Gets instruction sources loaded for the session.
6007    ///
6008    /// Wire method: `session.instructions.getSources`.
6009    ///
6010    /// # Returns
6011    ///
6012    /// Instruction sources loaded for the session, in merge order.
6013    ///
6014    /// <div class="warning">
6015    ///
6016    /// **Experimental.** This API is part of an experimental wire-protocol surface
6017    /// and may change or be removed in future SDK or CLI releases. Pin both the
6018    /// SDK and CLI versions if your code depends on it.
6019    ///
6020    /// </div>
6021    pub async fn get_sources(&self) -> Result<InstructionsGetSourcesResult, Error> {
6022        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6023        let _value = self
6024            .session
6025            .client()
6026            .call(
6027                rpc_methods::SESSION_INSTRUCTIONS_GETSOURCES,
6028                Some(wire_params),
6029            )
6030            .await?;
6031        Ok(serde_json::from_value(_value)?)
6032    }
6033}
6034
6035/// `session.limitPrediction.*` RPCs.
6036#[derive(Clone, Copy)]
6037pub struct SessionRpcLimitPrediction<'a> {
6038    pub(crate) session: &'a Session,
6039}
6040
6041impl<'a> SessionRpcLimitPrediction<'a> {
6042    /// 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.
6043    ///
6044    /// Wire method: `session.limitPrediction.predict`.
6045    ///
6046    /// # Returns
6047    ///
6048    /// Prediction result. Available results include prediction details; unavailable results include an explicit reason.
6049    ///
6050    /// <div class="warning">
6051    ///
6052    /// **Experimental.** This API is part of an experimental wire-protocol surface
6053    /// and may change or be removed in future SDK or CLI releases. Pin both the
6054    /// SDK and CLI versions if your code depends on it.
6055    ///
6056    /// </div>
6057    pub async fn predict(&self) -> Result<SessionLimitPredictionResult, Error> {
6058        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6059        let _value = self
6060            .session
6061            .client()
6062            .call(
6063                rpc_methods::SESSION_LIMITPREDICTION_PREDICT,
6064                Some(wire_params),
6065            )
6066            .await?;
6067        Ok(serde_json::from_value(_value)?)
6068    }
6069
6070    /// 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.
6071    ///
6072    /// Wire method: `session.limitPrediction.predict`.
6073    ///
6074    /// # Parameters
6075    ///
6076    /// * `params` - Parameters for predicting an AI-credit session limit. Omitting `modelId` uses the session's currently selected model.
6077    ///
6078    /// # Returns
6079    ///
6080    /// Prediction result. Available results include prediction details; unavailable results include an explicit reason.
6081    ///
6082    /// <div class="warning">
6083    ///
6084    /// **Experimental.** This API is part of an experimental wire-protocol surface
6085    /// and may change or be removed in future SDK or CLI releases. Pin both the
6086    /// SDK and CLI versions if your code depends on it.
6087    ///
6088    /// </div>
6089    pub async fn predict_with_params(
6090        &self,
6091        params: SessionLimitPredictionRequest,
6092    ) -> Result<SessionLimitPredictionResult, Error> {
6093        let mut wire_params = serde_json::to_value(params)?;
6094        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6095        let _value = self
6096            .session
6097            .client()
6098            .call(
6099                rpc_methods::SESSION_LIMITPREDICTION_PREDICT,
6100                Some(wire_params),
6101            )
6102            .await?;
6103        Ok(serde_json::from_value(_value)?)
6104    }
6105}
6106
6107/// `session.lsp.*` RPCs.
6108#[derive(Clone, Copy)]
6109pub struct SessionRpcLsp<'a> {
6110    pub(crate) session: &'a Session,
6111}
6112
6113impl<'a> SessionRpcLsp<'a> {
6114    /// Loads the merged LSP configuration set for the session's working directory.
6115    ///
6116    /// Wire method: `session.lsp.initialize`.
6117    ///
6118    /// # Parameters
6119    ///
6120    /// * `params` - Parameters for (re)loading the merged LSP configuration set.
6121    ///
6122    /// <div class="warning">
6123    ///
6124    /// **Experimental.** This API is part of an experimental wire-protocol surface
6125    /// and may change or be removed in future SDK or CLI releases. Pin both the
6126    /// SDK and CLI versions if your code depends on it.
6127    ///
6128    /// </div>
6129    pub async fn initialize(&self, params: LspInitializeRequest) -> Result<(), Error> {
6130        let mut wire_params = serde_json::to_value(params)?;
6131        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6132        let _value = self
6133            .session
6134            .client()
6135            .call(rpc_methods::SESSION_LSP_INITIALIZE, Some(wire_params))
6136            .await?;
6137        Ok(())
6138    }
6139}
6140
6141/// `session.mcp.*` RPCs.
6142#[derive(Clone, Copy)]
6143pub struct SessionRpcMcp<'a> {
6144    pub(crate) session: &'a Session,
6145}
6146
6147impl<'a> SessionRpcMcp<'a> {
6148    /// `session.mcp.apps.*` sub-namespace.
6149    pub fn apps(&self) -> SessionRpcMcpApps<'a> {
6150        SessionRpcMcpApps {
6151            session: self.session,
6152        }
6153    }
6154
6155    /// `session.mcp.headers.*` sub-namespace.
6156    pub fn headers(&self) -> SessionRpcMcpHeaders<'a> {
6157        SessionRpcMcpHeaders {
6158            session: self.session,
6159        }
6160    }
6161
6162    /// `session.mcp.oauth.*` sub-namespace.
6163    pub fn oauth(&self) -> SessionRpcMcpOauth<'a> {
6164        SessionRpcMcpOauth {
6165            session: self.session,
6166        }
6167    }
6168
6169    /// `session.mcp.resources.*` sub-namespace.
6170    pub fn resources(&self) -> SessionRpcMcpResources<'a> {
6171        SessionRpcMcpResources {
6172            session: self.session,
6173        }
6174    }
6175
6176    /// 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.
6177    ///
6178    /// Wire method: `session.mcp.list`.
6179    ///
6180    /// # Returns
6181    ///
6182    /// MCP servers configured for the session, with their connection status and host-level state.
6183    ///
6184    /// <div class="warning">
6185    ///
6186    /// **Experimental.** This API is part of an experimental wire-protocol surface
6187    /// and may change or be removed in future SDK or CLI releases. Pin both the
6188    /// SDK and CLI versions if your code depends on it.
6189    ///
6190    /// </div>
6191    pub async fn list(&self) -> Result<McpServerList, Error> {
6192        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6193        let _value = self
6194            .session
6195            .client()
6196            .call(rpc_methods::SESSION_MCP_LIST, Some(wire_params))
6197            .await?;
6198        Ok(serde_json::from_value(_value)?)
6199    }
6200
6201    /// 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.
6202    ///
6203    /// Wire method: `session.mcp.listTools`.
6204    ///
6205    /// # Parameters
6206    ///
6207    /// * `params` - Server name whose tool list should be returned.
6208    ///
6209    /// # Returns
6210    ///
6211    /// Tools exposed by the connected MCP server. Throws when the server is not connected.
6212    ///
6213    /// <div class="warning">
6214    ///
6215    /// **Experimental.** This API is part of an experimental wire-protocol surface
6216    /// and may change or be removed in future SDK or CLI releases. Pin both the
6217    /// SDK and CLI versions if your code depends on it.
6218    ///
6219    /// </div>
6220    pub async fn list_tools(
6221        &self,
6222        params: McpListToolsRequest,
6223    ) -> Result<McpListToolsResult, Error> {
6224        let mut wire_params = serde_json::to_value(params)?;
6225        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6226        let _value = self
6227            .session
6228            .client()
6229            .call(rpc_methods::SESSION_MCP_LISTTOOLS, Some(wire_params))
6230            .await?;
6231        Ok(serde_json::from_value(_value)?)
6232    }
6233
6234    /// Enables an MCP server for the session.
6235    ///
6236    /// Wire method: `session.mcp.enable`.
6237    ///
6238    /// # Parameters
6239    ///
6240    /// * `params` - Name of the MCP server to enable for the session.
6241    ///
6242    /// <div class="warning">
6243    ///
6244    /// **Experimental.** This API is part of an experimental wire-protocol surface
6245    /// and may change or be removed in future SDK or CLI releases. Pin both the
6246    /// SDK and CLI versions if your code depends on it.
6247    ///
6248    /// </div>
6249    pub async fn enable(&self, params: McpEnableRequest) -> Result<(), Error> {
6250        let mut wire_params = serde_json::to_value(params)?;
6251        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6252        let _value = self
6253            .session
6254            .client()
6255            .call(rpc_methods::SESSION_MCP_ENABLE, Some(wire_params))
6256            .await?;
6257        Ok(())
6258    }
6259
6260    /// Disables an MCP server for the session.
6261    ///
6262    /// Wire method: `session.mcp.disable`.
6263    ///
6264    /// # Parameters
6265    ///
6266    /// * `params` - Name of the MCP server to disable for the session.
6267    ///
6268    /// <div class="warning">
6269    ///
6270    /// **Experimental.** This API is part of an experimental wire-protocol surface
6271    /// and may change or be removed in future SDK or CLI releases. Pin both the
6272    /// SDK and CLI versions if your code depends on it.
6273    ///
6274    /// </div>
6275    pub async fn disable(&self, params: McpDisableRequest) -> Result<(), Error> {
6276        let mut wire_params = serde_json::to_value(params)?;
6277        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6278        let _value = self
6279            .session
6280            .client()
6281            .call(rpc_methods::SESSION_MCP_DISABLE, Some(wire_params))
6282            .await?;
6283        Ok(())
6284    }
6285
6286    /// Reloads MCP server connections for the session.
6287    ///
6288    /// Wire method: `session.mcp.reload`.
6289    ///
6290    /// <div class="warning">
6291    ///
6292    /// **Experimental.** This API is part of an experimental wire-protocol surface
6293    /// and may change or be removed in future SDK or CLI releases. Pin both the
6294    /// SDK and CLI versions if your code depends on it.
6295    ///
6296    /// </div>
6297    pub async fn reload(&self) -> Result<(), Error> {
6298        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6299        let _value = self
6300            .session
6301            .client()
6302            .call(rpc_methods::SESSION_MCP_RELOAD, Some(wire_params))
6303            .await?;
6304        Ok(())
6305    }
6306
6307    /// 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.
6308    ///
6309    /// Wire method: `session.mcp.moveLoadingToBackground`.
6310    ///
6311    /// # Returns
6312    ///
6313    /// Result of moving in-flight MCP loading to the background.
6314    ///
6315    /// <div class="warning">
6316    ///
6317    /// **Experimental.** This API is part of an experimental wire-protocol surface
6318    /// and may change or be removed in future SDK or CLI releases. Pin both the
6319    /// SDK and CLI versions if your code depends on it.
6320    ///
6321    /// </div>
6322    pub async fn move_loading_to_background(
6323        &self,
6324    ) -> Result<MoveMcpLoadingToBackgroundResult, Error> {
6325        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6326        let _value = self
6327            .session
6328            .client()
6329            .call(
6330                rpc_methods::SESSION_MCP_MOVELOADINGTOBACKGROUND,
6331                Some(wire_params),
6332            )
6333            .await?;
6334        Ok(serde_json::from_value(_value)?)
6335    }
6336
6337    /// Reloads MCP server connections for the session with an explicit host-provided configuration.
6338    ///
6339    /// Wire method: `session.mcp.reloadWithConfig`.
6340    ///
6341    /// # Parameters
6342    ///
6343    /// * `params` - Opaque MCP reload configuration.
6344    ///
6345    /// # Returns
6346    ///
6347    /// MCP server startup filtering result.
6348    ///
6349    /// <div class="warning">
6350    ///
6351    /// **Experimental.** This API is part of an experimental wire-protocol surface
6352    /// and may change or be removed in future SDK or CLI releases. Pin both the
6353    /// SDK and CLI versions if your code depends on it.
6354    ///
6355    /// </div>
6356    pub(crate) async fn reload_with_config(
6357        &self,
6358        params: McpReloadWithConfigRequest,
6359    ) -> Result<McpStartServersResult, Error> {
6360        let mut wire_params = serde_json::to_value(params)?;
6361        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6362        let _value = self
6363            .session
6364            .client()
6365            .call(rpc_methods::SESSION_MCP_RELOADWITHCONFIG, Some(wire_params))
6366            .await?;
6367        Ok(serde_json::from_value(_value)?)
6368    }
6369
6370    /// Runs an MCP sampling inference on behalf of an MCP server.
6371    ///
6372    /// Wire method: `session.mcp.executeSampling`.
6373    ///
6374    /// # Parameters
6375    ///
6376    /// * `params` - Identifiers and raw MCP CreateMessageRequest params used to run a sampling inference.
6377    ///
6378    /// # Returns
6379    ///
6380    /// Outcome of an MCP sampling execution: success result, failure error, or cancellation.
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 execute_sampling(
6390        &self,
6391        params: McpExecuteSamplingParams,
6392    ) -> Result<McpSamplingExecutionResult, Error> {
6393        let mut wire_params = serde_json::to_value(params)?;
6394        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6395        let _value = self
6396            .session
6397            .client()
6398            .call(rpc_methods::SESSION_MCP_EXECUTESAMPLING, Some(wire_params))
6399            .await?;
6400        Ok(serde_json::from_value(_value)?)
6401    }
6402
6403    /// Cancels an in-flight MCP sampling execution by request ID.
6404    ///
6405    /// Wire method: `session.mcp.cancelSamplingExecution`.
6406    ///
6407    /// # Parameters
6408    ///
6409    /// * `params` - The requestId previously passed to executeSampling that should be cancelled.
6410    ///
6411    /// # Returns
6412    ///
6413    /// Indicates whether an in-flight sampling execution with the given requestId was found and cancelled.
6414    ///
6415    /// <div class="warning">
6416    ///
6417    /// **Experimental.** This API is part of an experimental wire-protocol surface
6418    /// and may change or be removed in future SDK or CLI releases. Pin both the
6419    /// SDK and CLI versions if your code depends on it.
6420    ///
6421    /// </div>
6422    pub async fn cancel_sampling_execution(
6423        &self,
6424        params: McpCancelSamplingExecutionParams,
6425    ) -> Result<McpCancelSamplingExecutionResult, Error> {
6426        let mut wire_params = serde_json::to_value(params)?;
6427        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6428        let _value = self
6429            .session
6430            .client()
6431            .call(
6432                rpc_methods::SESSION_MCP_CANCELSAMPLINGEXECUTION,
6433                Some(wire_params),
6434            )
6435            .await?;
6436        Ok(serde_json::from_value(_value)?)
6437    }
6438
6439    /// Sets how environment-variable values supplied to MCP servers are resolved (direct or indirect).
6440    ///
6441    /// Wire method: `session.mcp.setEnvValueMode`.
6442    ///
6443    /// # Parameters
6444    ///
6445    /// * `params` - Mode controlling how MCP server env values are resolved (`direct` or `indirect`).
6446    ///
6447    /// # Returns
6448    ///
6449    /// Env-value mode recorded on the session after the update.
6450    ///
6451    /// <div class="warning">
6452    ///
6453    /// **Experimental.** This API is part of an experimental wire-protocol surface
6454    /// and may change or be removed in future SDK or CLI releases. Pin both the
6455    /// SDK and CLI versions if your code depends on it.
6456    ///
6457    /// </div>
6458    pub async fn set_env_value_mode(
6459        &self,
6460        params: McpSetEnvValueModeParams,
6461    ) -> Result<McpSetEnvValueModeResult, Error> {
6462        let mut wire_params = serde_json::to_value(params)?;
6463        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6464        let _value = self
6465            .session
6466            .client()
6467            .call(rpc_methods::SESSION_MCP_SETENVVALUEMODE, Some(wire_params))
6468            .await?;
6469        Ok(serde_json::from_value(_value)?)
6470    }
6471
6472    /// Removes the auto-managed `github` MCP server when present.
6473    ///
6474    /// Wire method: `session.mcp.removeGitHub`.
6475    ///
6476    /// # Returns
6477    ///
6478    /// Indicates whether the auto-managed `github` MCP server was removed (false when nothing to remove).
6479    ///
6480    /// <div class="warning">
6481    ///
6482    /// **Experimental.** This API is part of an experimental wire-protocol surface
6483    /// and may change or be removed in future SDK or CLI releases. Pin both the
6484    /// SDK and CLI versions if your code depends on it.
6485    ///
6486    /// </div>
6487    pub async fn remove_git_hub(&self) -> Result<McpRemoveGitHubResult, Error> {
6488        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6489        let _value = self
6490            .session
6491            .client()
6492            .call(rpc_methods::SESSION_MCP_REMOVEGITHUB, Some(wire_params))
6493            .await?;
6494        Ok(serde_json::from_value(_value)?)
6495    }
6496
6497    /// Configures the built-in GitHub MCP server for the session's current auth context.
6498    ///
6499    /// Wire method: `session.mcp.configureGitHub`.
6500    ///
6501    /// # Parameters
6502    ///
6503    /// * `params` - Credential-free authentication identity used to configure GitHub MCP.
6504    ///
6505    /// # Returns
6506    ///
6507    /// Result of configuring GitHub MCP.
6508    ///
6509    /// <div class="warning">
6510    ///
6511    /// **Experimental.** This API is part of an experimental wire-protocol surface
6512    /// and may change or be removed in future SDK or CLI releases. Pin both the
6513    /// SDK and CLI versions if your code depends on it.
6514    ///
6515    /// </div>
6516    pub(crate) async fn configure_git_hub(
6517        &self,
6518        params: McpConfigureGitHubRequest,
6519    ) -> Result<McpConfigureGitHubResult, Error> {
6520        let mut wire_params = serde_json::to_value(params)?;
6521        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6522        let _value = self
6523            .session
6524            .client()
6525            .call(rpc_methods::SESSION_MCP_CONFIGUREGITHUB, Some(wire_params))
6526            .await?;
6527        Ok(serde_json::from_value(_value)?)
6528    }
6529
6530    /// 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.
6531    ///
6532    /// Wire method: `session.mcp.startServer`.
6533    ///
6534    /// # Parameters
6535    ///
6536    /// * `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.
6537    ///
6538    /// <div class="warning">
6539    ///
6540    /// **Experimental.** This API is part of an experimental wire-protocol surface
6541    /// and may change or be removed in future SDK or CLI releases. Pin both the
6542    /// SDK and CLI versions if your code depends on it.
6543    ///
6544    /// </div>
6545    pub async fn start_server(&self, params: McpStartServerRequest) -> Result<(), Error> {
6546        let mut wire_params = serde_json::to_value(params)?;
6547        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6548        let _value = self
6549            .session
6550            .client()
6551            .call(rpc_methods::SESSION_MCP_STARTSERVER, Some(wire_params))
6552            .await?;
6553        Ok(())
6554    }
6555
6556    /// 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.*`).
6557    ///
6558    /// Wire method: `session.mcp.restartServer`.
6559    ///
6560    /// # Parameters
6561    ///
6562    /// * `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.
6563    ///
6564    /// <div class="warning">
6565    ///
6566    /// **Experimental.** This API is part of an experimental wire-protocol surface
6567    /// and may change or be removed in future SDK or CLI releases. Pin both the
6568    /// SDK and CLI versions if your code depends on it.
6569    ///
6570    /// </div>
6571    pub async fn restart_server(&self, params: McpRestartServerRequest) -> Result<(), Error> {
6572        let mut wire_params = serde_json::to_value(params)?;
6573        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6574        let _value = self
6575            .session
6576            .client()
6577            .call(rpc_methods::SESSION_MCP_RESTARTSERVER, Some(wire_params))
6578            .await?;
6579        Ok(())
6580    }
6581
6582    /// Stops an individual MCP server on the session's host.
6583    ///
6584    /// Wire method: `session.mcp.stopServer`.
6585    ///
6586    /// # Parameters
6587    ///
6588    /// * `params` - Server name for an individual MCP server stop.
6589    ///
6590    /// <div class="warning">
6591    ///
6592    /// **Experimental.** This API is part of an experimental wire-protocol surface
6593    /// and may change or be removed in future SDK or CLI releases. Pin both the
6594    /// SDK and CLI versions if your code depends on it.
6595    ///
6596    /// </div>
6597    pub async fn stop_server(&self, params: McpStopServerRequest) -> Result<(), Error> {
6598        let mut wire_params = serde_json::to_value(params)?;
6599        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6600        let _value = self
6601            .session
6602            .client()
6603            .call(rpc_methods::SESSION_MCP_STOPSERVER, Some(wire_params))
6604            .await?;
6605        Ok(())
6606    }
6607
6608    /// 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.
6609    ///
6610    /// Wire method: `session.mcp.registerExternalClient`.
6611    ///
6612    /// # Parameters
6613    ///
6614    /// * `params` - Registration parameters for an external MCP client.
6615    ///
6616    /// <div class="warning">
6617    ///
6618    /// **Experimental.** This API is part of an experimental wire-protocol surface
6619    /// and may change or be removed in future SDK or CLI releases. Pin both the
6620    /// SDK and CLI versions if your code depends on it.
6621    ///
6622    /// </div>
6623    pub(crate) async fn register_external_client(
6624        &self,
6625        params: McpRegisterExternalClientRequest,
6626    ) -> Result<(), Error> {
6627        let mut wire_params = serde_json::to_value(params)?;
6628        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6629        let _value = self
6630            .session
6631            .client()
6632            .call(
6633                rpc_methods::SESSION_MCP_REGISTEREXTERNALCLIENT,
6634                Some(wire_params),
6635            )
6636            .await?;
6637        Ok(())
6638    }
6639
6640    /// 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.
6641    ///
6642    /// Wire method: `session.mcp.unregisterExternalClient`.
6643    ///
6644    /// # Parameters
6645    ///
6646    /// * `params` - Server name identifying the external client to remove.
6647    ///
6648    /// <div class="warning">
6649    ///
6650    /// **Experimental.** This API is part of an experimental wire-protocol surface
6651    /// and may change or be removed in future SDK or CLI releases. Pin both the
6652    /// SDK and CLI versions if your code depends on it.
6653    ///
6654    /// </div>
6655    pub(crate) async fn unregister_external_client(
6656        &self,
6657        params: McpUnregisterExternalClientRequest,
6658    ) -> Result<(), Error> {
6659        let mut wire_params = serde_json::to_value(params)?;
6660        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6661        let _value = self
6662            .session
6663            .client()
6664            .call(
6665                rpc_methods::SESSION_MCP_UNREGISTEREXTERNALCLIENT,
6666                Some(wire_params),
6667            )
6668            .await?;
6669        Ok(())
6670    }
6671
6672    /// Checks whether a named MCP server is currently running on the session's host.
6673    ///
6674    /// Wire method: `session.mcp.isServerRunning`.
6675    ///
6676    /// # Parameters
6677    ///
6678    /// * `params` - Server name to check running status for.
6679    ///
6680    /// # Returns
6681    ///
6682    /// Whether the named MCP server is running.
6683    ///
6684    /// <div class="warning">
6685    ///
6686    /// **Experimental.** This API is part of an experimental wire-protocol surface
6687    /// and may change or be removed in future SDK or CLI releases. Pin both the
6688    /// SDK and CLI versions if your code depends on it.
6689    ///
6690    /// </div>
6691    pub async fn is_server_running(
6692        &self,
6693        params: McpIsServerRunningRequest,
6694    ) -> Result<McpIsServerRunningResult, Error> {
6695        let mut wire_params = serde_json::to_value(params)?;
6696        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6697        let _value = self
6698            .session
6699            .client()
6700            .call(rpc_methods::SESSION_MCP_ISSERVERRUNNING, Some(wire_params))
6701            .await?;
6702        Ok(serde_json::from_value(_value)?)
6703    }
6704}
6705
6706/// `session.mcp.apps.*` RPCs.
6707#[derive(Clone, Copy)]
6708pub struct SessionRpcMcpApps<'a> {
6709    pub(crate) session: &'a Session,
6710}
6711
6712impl<'a> SessionRpcMcpApps<'a> {
6713    /// Fetch an MCP resource (typically a `ui://` MCP App bundle, per SEP-1865) from a connected server. Requires the `mcp-apps` session capability.
6714    ///
6715    /// Wire method: `session.mcp.apps.readResource`.
6716    ///
6717    /// # Parameters
6718    ///
6719    /// * `params` - MCP server and resource URI to fetch.
6720    ///
6721    /// # Returns
6722    ///
6723    /// Resource contents returned by the MCP server.
6724    ///
6725    /// <div class="warning">
6726    ///
6727    /// **Experimental.** This API is part of an experimental wire-protocol surface
6728    /// and may change or be removed in future SDK or CLI releases. Pin both the
6729    /// SDK and CLI versions if your code depends on it.
6730    ///
6731    /// </div>
6732    pub async fn read_resource(
6733        &self,
6734        params: McpAppsReadResourceRequest,
6735    ) -> Result<McpAppsReadResourceResult, Error> {
6736        let mut wire_params = serde_json::to_value(params)?;
6737        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6738        let _value = self
6739            .session
6740            .client()
6741            .call(
6742                rpc_methods::SESSION_MCP_APPS_READRESOURCE,
6743                Some(wire_params),
6744            )
6745            .await?;
6746        Ok(serde_json::from_value(_value)?)
6747    }
6748
6749    /// 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"`.
6750    ///
6751    /// Wire method: `session.mcp.apps.listTools`.
6752    ///
6753    /// # Parameters
6754    ///
6755    /// * `params` - MCP server to list app-callable tools for.
6756    ///
6757    /// # Returns
6758    ///
6759    /// App-callable tools from the named MCP server.
6760    ///
6761    /// <div class="warning">
6762    ///
6763    /// **Experimental.** This API is part of an experimental wire-protocol surface
6764    /// and may change or be removed in future SDK or CLI releases. Pin both the
6765    /// SDK and CLI versions if your code depends on it.
6766    ///
6767    /// </div>
6768    pub async fn list_tools(
6769        &self,
6770        params: McpAppsListToolsRequest,
6771    ) -> Result<McpAppsListToolsResult, Error> {
6772        let mut wire_params = serde_json::to_value(params)?;
6773        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6774        let _value = self
6775            .session
6776            .client()
6777            .call(rpc_methods::SESSION_MCP_APPS_LISTTOOLS, Some(wire_params))
6778            .await?;
6779        Ok(serde_json::from_value(_value)?)
6780    }
6781
6782    /// 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`.
6783    ///
6784    /// Wire method: `session.mcp.apps.callTool`.
6785    ///
6786    /// # Parameters
6787    ///
6788    /// * `params` - MCP server, tool name, and arguments to invoke from an MCP App view.
6789    ///
6790    /// # Returns
6791    ///
6792    /// Standard MCP CallToolResult
6793    ///
6794    /// <div class="warning">
6795    ///
6796    /// **Experimental.** This API is part of an experimental wire-protocol surface
6797    /// and may change or be removed in future SDK or CLI releases. Pin both the
6798    /// SDK and CLI versions if your code depends on it.
6799    ///
6800    /// </div>
6801    pub async fn call_tool(
6802        &self,
6803        params: McpAppsCallToolRequest,
6804    ) -> Result<SessionMcpAppsCallToolResult, Error> {
6805        let mut wire_params = serde_json::to_value(params)?;
6806        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6807        let _value = self
6808            .session
6809            .client()
6810            .call(rpc_methods::SESSION_MCP_APPS_CALLTOOL, Some(wire_params))
6811            .await?;
6812        Ok(serde_json::from_value(_value)?)
6813    }
6814
6815    /// 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.
6816    ///
6817    /// Wire method: `session.mcp.apps.setHostContext`.
6818    ///
6819    /// # Parameters
6820    ///
6821    /// * `params` - Host context to advertise to MCP App guests.
6822    ///
6823    /// <div class="warning">
6824    ///
6825    /// **Experimental.** This API is part of an experimental wire-protocol surface
6826    /// and may change or be removed in future SDK or CLI releases. Pin both the
6827    /// SDK and CLI versions if your code depends on it.
6828    ///
6829    /// </div>
6830    pub async fn set_host_context(
6831        &self,
6832        params: McpAppsSetHostContextRequest,
6833    ) -> Result<(), Error> {
6834        let mut wire_params = serde_json::to_value(params)?;
6835        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6836        let _value = self
6837            .session
6838            .client()
6839            .call(
6840                rpc_methods::SESSION_MCP_APPS_SETHOSTCONTEXT,
6841                Some(wire_params),
6842            )
6843            .await?;
6844        Ok(())
6845    }
6846
6847    /// Read the current host context advertised to MCP App guests.
6848    ///
6849    /// Wire method: `session.mcp.apps.getHostContext`.
6850    ///
6851    /// # Returns
6852    ///
6853    /// Current host context advertised to MCP App guests.
6854    ///
6855    /// <div class="warning">
6856    ///
6857    /// **Experimental.** This API is part of an experimental wire-protocol surface
6858    /// and may change or be removed in future SDK or CLI releases. Pin both the
6859    /// SDK and CLI versions if your code depends on it.
6860    ///
6861    /// </div>
6862    pub async fn get_host_context(&self) -> Result<McpAppsHostContext, Error> {
6863        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6864        let _value = self
6865            .session
6866            .client()
6867            .call(
6868                rpc_methods::SESSION_MCP_APPS_GETHOSTCONTEXT,
6869                Some(wire_params),
6870            )
6871            .await?;
6872        Ok(serde_json::from_value(_value)?)
6873    }
6874
6875    /// 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.
6876    ///
6877    /// Wire method: `session.mcp.apps.diagnose`.
6878    ///
6879    /// # Parameters
6880    ///
6881    /// * `params` - MCP server to diagnose MCP Apps wiring for.
6882    ///
6883    /// # Returns
6884    ///
6885    /// Diagnostic snapshot of MCP Apps wiring for the named server.
6886    ///
6887    /// <div class="warning">
6888    ///
6889    /// **Experimental.** This API is part of an experimental wire-protocol surface
6890    /// and may change or be removed in future SDK or CLI releases. Pin both the
6891    /// SDK and CLI versions if your code depends on it.
6892    ///
6893    /// </div>
6894    pub async fn diagnose(
6895        &self,
6896        params: McpAppsDiagnoseRequest,
6897    ) -> Result<McpAppsDiagnoseResult, Error> {
6898        let mut wire_params = serde_json::to_value(params)?;
6899        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6900        let _value = self
6901            .session
6902            .client()
6903            .call(rpc_methods::SESSION_MCP_APPS_DIAGNOSE, Some(wire_params))
6904            .await?;
6905        Ok(serde_json::from_value(_value)?)
6906    }
6907}
6908
6909/// `session.mcp.headers.*` RPCs.
6910#[derive(Clone, Copy)]
6911pub struct SessionRpcMcpHeaders<'a> {
6912    pub(crate) session: &'a Session,
6913}
6914
6915impl<'a> SessionRpcMcpHeaders<'a> {
6916    /// 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.
6917    ///
6918    /// Wire method: `session.mcp.headers.handlePendingHeadersRefreshRequest`.
6919    ///
6920    /// # Parameters
6921    ///
6922    /// * `params` - MCP headers refresh request id and the host response.
6923    ///
6924    /// # Returns
6925    ///
6926    /// Indicates whether the pending MCP headers refresh response was accepted.
6927    ///
6928    /// <div class="warning">
6929    ///
6930    /// **Experimental.** This API is part of an experimental wire-protocol surface
6931    /// and may change or be removed in future SDK or CLI releases. Pin both the
6932    /// SDK and CLI versions if your code depends on it.
6933    ///
6934    /// </div>
6935    pub async fn handle_pending_headers_refresh_request(
6936        &self,
6937        params: McpHeadersHandlePendingHeadersRefreshRequestRequest,
6938    ) -> Result<McpHeadersHandlePendingHeadersRefreshRequestResult, Error> {
6939        let mut wire_params = serde_json::to_value(params)?;
6940        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6941        let _value = self
6942            .session
6943            .client()
6944            .call(
6945                rpc_methods::SESSION_MCP_HEADERS_HANDLEPENDINGHEADERSREFRESHREQUEST,
6946                Some(wire_params),
6947            )
6948            .await?;
6949        Ok(serde_json::from_value(_value)?)
6950    }
6951}
6952
6953/// `session.mcp.oauth.*` RPCs.
6954#[derive(Clone, Copy)]
6955pub struct SessionRpcMcpOauth<'a> {
6956    pub(crate) session: &'a Session,
6957}
6958
6959impl<'a> SessionRpcMcpOauth<'a> {
6960    /// 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.
6961    ///
6962    /// Wire method: `session.mcp.oauth.handlePendingRequest`.
6963    ///
6964    /// # Parameters
6965    ///
6966    /// * `params` - Pending MCP OAuth request ID and host-provided token or cancellation response.
6967    ///
6968    /// # Returns
6969    ///
6970    /// Indicates whether the pending MCP OAuth response was accepted.
6971    ///
6972    /// <div class="warning">
6973    ///
6974    /// **Experimental.** This API is part of an experimental wire-protocol surface
6975    /// and may change or be removed in future SDK or CLI releases. Pin both the
6976    /// SDK and CLI versions if your code depends on it.
6977    ///
6978    /// </div>
6979    pub async fn handle_pending_request(
6980        &self,
6981        params: McpOauthHandlePendingRequest,
6982    ) -> Result<McpOauthHandlePendingResult, Error> {
6983        let mut wire_params = serde_json::to_value(params)?;
6984        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6985        let _value = self
6986            .session
6987            .client()
6988            .call(
6989                rpc_methods::SESSION_MCP_OAUTH_HANDLEPENDINGREQUEST,
6990                Some(wire_params),
6991            )
6992            .await?;
6993        Ok(serde_json::from_value(_value)?)
6994    }
6995
6996    /// Notifies the session that MCP OAuth authentication succeeded and updated credentials were persisted, so cached tool definitions can be refreshed.
6997    ///
6998    /// Wire method: `session.mcp.oauth.authenticationStateChanged`.
6999    ///
7000    /// # Parameters
7001    ///
7002    /// * `params` - Identifies the MCP server whose persisted OAuth credentials were updated.
7003    ///
7004    /// <div class="warning">
7005    ///
7006    /// **Experimental.** This API is part of an experimental wire-protocol surface
7007    /// and may change or be removed in future SDK or CLI releases. Pin both the
7008    /// SDK and CLI versions if your code depends on it.
7009    ///
7010    /// </div>
7011    pub async fn authentication_state_changed(
7012        &self,
7013        params: McpOauthAuthenticationStateChangedRequest,
7014    ) -> Result<(), Error> {
7015        let mut wire_params = serde_json::to_value(params)?;
7016        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7017        let _value = self
7018            .session
7019            .client()
7020            .call(
7021                rpc_methods::SESSION_MCP_OAUTH_AUTHENTICATIONSTATECHANGED,
7022                Some(wire_params),
7023            )
7024            .await?;
7025        Ok(())
7026    }
7027
7028    /// Starts OAuth authentication for a remote MCP server.
7029    ///
7030    /// Wire method: `session.mcp.oauth.login`.
7031    ///
7032    /// # Parameters
7033    ///
7034    /// * `params` - Remote MCP server name and optional overrides controlling reauthentication, OAuth client display name, callback success-page copy, and static OAuth client selection.
7035    ///
7036    /// # Returns
7037    ///
7038    /// OAuth authorization URL the caller should open, or empty when cached tokens already authenticated the server.
7039    ///
7040    /// <div class="warning">
7041    ///
7042    /// **Experimental.** This API is part of an experimental wire-protocol surface
7043    /// and may change or be removed in future SDK or CLI releases. Pin both the
7044    /// SDK and CLI versions if your code depends on it.
7045    ///
7046    /// </div>
7047    pub async fn login(&self, params: McpOauthLoginRequest) -> Result<McpOauthLoginResult, Error> {
7048        let mut wire_params = serde_json::to_value(params)?;
7049        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7050        let _value = self
7051            .session
7052            .client()
7053            .call(rpc_methods::SESSION_MCP_OAUTH_LOGIN, Some(wire_params))
7054            .await?;
7055        Ok(serde_json::from_value(_value)?)
7056    }
7057
7058    /// 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.
7059    ///
7060    /// Wire method: `session.mcp.oauth.probe`.
7061    ///
7062    /// # Parameters
7063    ///
7064    /// * `params` - Remote MCP server name for a passive OAuth status probe.
7065    ///
7066    /// # Returns
7067    ///
7068    /// 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.
7069    ///
7070    /// <div class="warning">
7071    ///
7072    /// **Experimental.** This API is part of an experimental wire-protocol surface
7073    /// and may change or be removed in future SDK or CLI releases. Pin both the
7074    /// SDK and CLI versions if your code depends on it.
7075    ///
7076    /// </div>
7077    pub async fn probe(&self, params: McpOauthProbeRequest) -> Result<McpOauthProbeResult, Error> {
7078        let mut wire_params = serde_json::to_value(params)?;
7079        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7080        let _value = self
7081            .session
7082            .client()
7083            .call(rpc_methods::SESSION_MCP_OAUTH_PROBE, Some(wire_params))
7084            .await?;
7085        Ok(serde_json::from_value(_value)?)
7086    }
7087
7088    /// Responds to a pending MCP OAuth authorization request by its request id.
7089    ///
7090    /// Wire method: `session.mcp.oauth.respond`.
7091    ///
7092    /// # Parameters
7093    ///
7094    /// * `params` - Pending MCP OAuth request id to respond to.
7095    ///
7096    /// # Returns
7097    ///
7098    /// Indicates whether the pending MCP OAuth response was accepted.
7099    ///
7100    /// <div class="warning">
7101    ///
7102    /// **Experimental.** This API is part of an experimental wire-protocol surface
7103    /// and may change or be removed in future SDK or CLI releases. Pin both the
7104    /// SDK and CLI versions if your code depends on it.
7105    ///
7106    /// </div>
7107    pub async fn respond(
7108        &self,
7109        params: McpOauthRespondRequest,
7110    ) -> Result<McpOauthRespondResult, Error> {
7111        let mut wire_params = serde_json::to_value(params)?;
7112        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7113        let _value = self
7114            .session
7115            .client()
7116            .call(rpc_methods::SESSION_MCP_OAUTH_RESPOND, Some(wire_params))
7117            .await?;
7118        Ok(serde_json::from_value(_value)?)
7119    }
7120}
7121
7122/// `session.mcp.resources.*` RPCs.
7123#[derive(Clone, Copy)]
7124pub struct SessionRpcMcpResources<'a> {
7125    pub(crate) session: &'a Session,
7126}
7127
7128impl<'a> SessionRpcMcpResources<'a> {
7129    /// Fetch an MCP resource from a connected server by URI (proxies MCP `resources/read`).
7130    ///
7131    /// Wire method: `session.mcp.resources.read`.
7132    ///
7133    /// # Parameters
7134    ///
7135    /// * `params` - MCP server and resource URI to fetch.
7136    ///
7137    /// # Returns
7138    ///
7139    /// Resource contents returned by the MCP server.
7140    ///
7141    /// <div class="warning">
7142    ///
7143    /// **Experimental.** This API is part of an experimental wire-protocol surface
7144    /// and may change or be removed in future SDK or CLI releases. Pin both the
7145    /// SDK and CLI versions if your code depends on it.
7146    ///
7147    /// </div>
7148    pub async fn read(
7149        &self,
7150        params: McpResourcesReadRequest,
7151    ) -> Result<McpResourcesReadResult, Error> {
7152        let mut wire_params = serde_json::to_value(params)?;
7153        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7154        let _value = self
7155            .session
7156            .client()
7157            .call(rpc_methods::SESSION_MCP_RESOURCES_READ, Some(wire_params))
7158            .await?;
7159        Ok(serde_json::from_value(_value)?)
7160    }
7161
7162    /// Enumerate one page of resources a connected MCP server exposes (proxies MCP `resources/list`). Pass `cursor` to continue from a prior result's `nextCursor`.
7163    ///
7164    /// Wire method: `session.mcp.resources.list`.
7165    ///
7166    /// # Parameters
7167    ///
7168    /// * `params` - MCP server whose resources to enumerate.
7169    ///
7170    /// # Returns
7171    ///
7172    /// One page of resources advertised by the named MCP server.
7173    ///
7174    /// <div class="warning">
7175    ///
7176    /// **Experimental.** This API is part of an experimental wire-protocol surface
7177    /// and may change or be removed in future SDK or CLI releases. Pin both the
7178    /// SDK and CLI versions if your code depends on it.
7179    ///
7180    /// </div>
7181    pub async fn list(
7182        &self,
7183        params: McpResourcesListRequest,
7184    ) -> Result<McpResourcesListResult, Error> {
7185        let mut wire_params = serde_json::to_value(params)?;
7186        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7187        let _value = self
7188            .session
7189            .client()
7190            .call(rpc_methods::SESSION_MCP_RESOURCES_LIST, Some(wire_params))
7191            .await?;
7192        Ok(serde_json::from_value(_value)?)
7193    }
7194
7195    /// 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`.
7196    ///
7197    /// Wire method: `session.mcp.resources.listTemplates`.
7198    ///
7199    /// # Parameters
7200    ///
7201    /// * `params` - MCP server whose resource templates to enumerate.
7202    ///
7203    /// # Returns
7204    ///
7205    /// One page of resource templates advertised by the named MCP server.
7206    ///
7207    /// <div class="warning">
7208    ///
7209    /// **Experimental.** This API is part of an experimental wire-protocol surface
7210    /// and may change or be removed in future SDK or CLI releases. Pin both the
7211    /// SDK and CLI versions if your code depends on it.
7212    ///
7213    /// </div>
7214    pub async fn list_templates(
7215        &self,
7216        params: McpResourcesListTemplatesRequest,
7217    ) -> Result<McpResourcesListTemplatesResult, Error> {
7218        let mut wire_params = serde_json::to_value(params)?;
7219        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7220        let _value = self
7221            .session
7222            .client()
7223            .call(
7224                rpc_methods::SESSION_MCP_RESOURCES_LISTTEMPLATES,
7225                Some(wire_params),
7226            )
7227            .await?;
7228        Ok(serde_json::from_value(_value)?)
7229    }
7230}
7231
7232/// `session.metadata.*` RPCs.
7233#[derive(Clone, Copy)]
7234pub struct SessionRpcMetadata<'a> {
7235    pub(crate) session: &'a Session,
7236}
7237
7238impl<'a> SessionRpcMetadata<'a> {
7239    /// Returns a snapshot of the session's identifying metadata, mode, agent, and remote info.
7240    ///
7241    /// Wire method: `session.metadata.snapshot`.
7242    ///
7243    /// # Returns
7244    ///
7245    /// Point-in-time snapshot of slow-changing session identifier and state fields
7246    ///
7247    /// <div class="warning">
7248    ///
7249    /// **Experimental.** This API is part of an experimental wire-protocol surface
7250    /// and may change or be removed in future SDK or CLI releases. Pin both the
7251    /// SDK and CLI versions if your code depends on it.
7252    ///
7253    /// </div>
7254    pub async fn snapshot(&self) -> Result<SessionMetadataSnapshot, Error> {
7255        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7256        let _value = self
7257            .session
7258            .client()
7259            .call(rpc_methods::SESSION_METADATA_SNAPSHOT, Some(wire_params))
7260            .await?;
7261        Ok(serde_json::from_value(_value)?)
7262    }
7263
7264    /// Returns the client-owned string metadata persisted with this local session. The metadata is not included in model context, events, telemetry, snapshots, or remote exports.
7265    ///
7266    /// Wire method: `session.metadata.getClientMetadata`.
7267    ///
7268    /// # Returns
7269    ///
7270    /// Client-owned, case-sensitive string metadata persisted with a local session. Clients should namespace keys by owner. Keys must be non-empty and at most 256 UTF-8 bytes; keys under `copilot/` and `github/` are reserved. Values may contain at most 16 KiB of UTF-8 data. A bag may contain at most 128 entries and its serialized sidecar may contain at most 64 KiB. The runtime stores but never interprets these values.
7271    ///
7272    /// <div class="warning">
7273    ///
7274    /// **Experimental.** This API is part of an experimental wire-protocol surface
7275    /// and may change or be removed in future SDK or CLI releases. Pin both the
7276    /// SDK and CLI versions if your code depends on it.
7277    ///
7278    /// </div>
7279    pub async fn get_client_metadata(&self) -> Result<ClientMetadata, Error> {
7280        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7281        let _value = self
7282            .session
7283            .client()
7284            .call(
7285                rpc_methods::SESSION_METADATA_GETCLIENTMETADATA,
7286                Some(wire_params),
7287            )
7288            .await?;
7289        Ok(serde_json::from_value(_value)?)
7290    }
7291
7292    /// Atomically patches the client-owned string metadata persisted with this local session and returns the committed bag.
7293    ///
7294    /// Wire method: `session.metadata.updateClientMetadata`.
7295    ///
7296    /// # Parameters
7297    ///
7298    /// * `params` - Atomic patch for client-owned session metadata. Operations apply in clear, remove, then set order. The resulting bag must satisfy the ClientMetadata entry and serialized-size limits. Local storage coordinates concurrent runtime processes; custom SessionFs providers must serialize writers that access the same session from multiple processes.
7299    ///
7300    /// # Returns
7301    ///
7302    /// Client-owned, case-sensitive string metadata persisted with a local session. Clients should namespace keys by owner. Keys must be non-empty and at most 256 UTF-8 bytes; keys under `copilot/` and `github/` are reserved. Values may contain at most 16 KiB of UTF-8 data. A bag may contain at most 128 entries and its serialized sidecar may contain at most 64 KiB. The runtime stores but never interprets these values.
7303    ///
7304    /// <div class="warning">
7305    ///
7306    /// **Experimental.** This API is part of an experimental wire-protocol surface
7307    /// and may change or be removed in future SDK or CLI releases. Pin both the
7308    /// SDK and CLI versions if your code depends on it.
7309    ///
7310    /// </div>
7311    pub async fn update_client_metadata(
7312        &self,
7313        params: MetadataUpdateClientMetadataRequest,
7314    ) -> Result<ClientMetadata, Error> {
7315        let mut wire_params = serde_json::to_value(params)?;
7316        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7317        let _value = self
7318            .session
7319            .client()
7320            .call(
7321                rpc_methods::SESSION_METADATA_UPDATECLIENTMETADATA,
7322                Some(wire_params),
7323            )
7324            .await?;
7325        Ok(serde_json::from_value(_value)?)
7326    }
7327
7328    /// Reports whether the local session is currently processing user/agent messages.
7329    ///
7330    /// Wire method: `session.metadata.isProcessing`.
7331    ///
7332    /// # Returns
7333    ///
7334    /// Indicates whether the local session is currently processing a turn or background continuation.
7335    ///
7336    /// <div class="warning">
7337    ///
7338    /// **Experimental.** This API is part of an experimental wire-protocol surface
7339    /// and may change or be removed in future SDK or CLI releases. Pin both the
7340    /// SDK and CLI versions if your code depends on it.
7341    ///
7342    /// </div>
7343    pub async fn is_processing(&self) -> Result<MetadataIsProcessingResult, Error> {
7344        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7345        let _value = self
7346            .session
7347            .client()
7348            .call(
7349                rpc_methods::SESSION_METADATA_ISPROCESSING,
7350                Some(wire_params),
7351            )
7352            .await?;
7353        Ok(serde_json::from_value(_value)?)
7354    }
7355
7356    /// Returns a snapshot of activity flags for the session.
7357    ///
7358    /// Wire method: `session.metadata.activity`.
7359    ///
7360    /// # Returns
7361    ///
7362    /// Current activity flags for the session.
7363    ///
7364    /// <div class="warning">
7365    ///
7366    /// **Experimental.** This API is part of an experimental wire-protocol surface
7367    /// and may change or be removed in future SDK or CLI releases. Pin both the
7368    /// SDK and CLI versions if your code depends on it.
7369    ///
7370    /// </div>
7371    pub async fn activity(&self) -> Result<SessionActivity, Error> {
7372        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7373        let _value = self
7374            .session
7375            .client()
7376            .call(rpc_methods::SESSION_METADATA_ACTIVITY, Some(wire_params))
7377            .await?;
7378        Ok(serde_json::from_value(_value)?)
7379    }
7380
7381    /// Returns the token breakdown for the session's current context window for a given model.
7382    ///
7383    /// Wire method: `session.metadata.contextInfo`.
7384    ///
7385    /// # Parameters
7386    ///
7387    /// * `params` - Model identifier and token limits used to compute the context-info breakdown.
7388    ///
7389    /// # Returns
7390    ///
7391    /// Token breakdown for the session's current context window, or null if uninitialized.
7392    ///
7393    /// <div class="warning">
7394    ///
7395    /// **Experimental.** This API is part of an experimental wire-protocol surface
7396    /// and may change or be removed in future SDK or CLI releases. Pin both the
7397    /// SDK and CLI versions if your code depends on it.
7398    ///
7399    /// </div>
7400    pub async fn context_info(
7401        &self,
7402        params: MetadataContextInfoRequest,
7403    ) -> Result<MetadataContextInfoResult, Error> {
7404        let mut wire_params = serde_json::to_value(params)?;
7405        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7406        let _value = self
7407            .session
7408            .client()
7409            .call(rpc_methods::SESSION_METADATA_CONTEXTINFO, Some(wire_params))
7410            .await?;
7411        Ok(serde_json::from_value(_value)?)
7412    }
7413
7414    /// 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.
7415    ///
7416    /// Wire method: `session.metadata.getContextAttribution`.
7417    ///
7418    /// # Returns
7419    ///
7420    /// Per-source attribution breakdown for the session's current context window, or null if uninitialized.
7421    ///
7422    /// <div class="warning">
7423    ///
7424    /// **Experimental.** This API is part of an experimental wire-protocol surface
7425    /// and may change or be removed in future SDK or CLI releases. Pin both the
7426    /// SDK and CLI versions if your code depends on it.
7427    ///
7428    /// </div>
7429    pub async fn get_context_attribution(&self) -> Result<MetadataContextAttributionResult, Error> {
7430        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7431        let _value = self
7432            .session
7433            .client()
7434            .call(
7435                rpc_methods::SESSION_METADATA_GETCONTEXTATTRIBUTION,
7436                Some(wire_params),
7437            )
7438            .await?;
7439        Ok(serde_json::from_value(_value)?)
7440    }
7441
7442    /// 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.
7443    ///
7444    /// Wire method: `session.metadata.getContextHeaviestMessages`.
7445    ///
7446    /// # Parameters
7447    ///
7448    /// * `params` - Parameters for the heaviest-messages query.
7449    ///
7450    /// # Returns
7451    ///
7452    /// The heaviest individual messages in the session's context window, most-expensive first.
7453    ///
7454    /// <div class="warning">
7455    ///
7456    /// **Experimental.** This API is part of an experimental wire-protocol surface
7457    /// and may change or be removed in future SDK or CLI releases. Pin both the
7458    /// SDK and CLI versions if your code depends on it.
7459    ///
7460    /// </div>
7461    pub async fn get_context_heaviest_messages(
7462        &self,
7463        params: MetadataContextHeaviestMessagesRequest,
7464    ) -> Result<MetadataContextHeaviestMessagesResult, Error> {
7465        let mut wire_params = serde_json::to_value(params)?;
7466        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7467        let _value = self
7468            .session
7469            .client()
7470            .call(
7471                rpc_methods::SESSION_METADATA_GETCONTEXTHEAVIESTMESSAGES,
7472                Some(wire_params),
7473            )
7474            .await?;
7475        Ok(serde_json::from_value(_value)?)
7476    }
7477
7478    /// 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.
7479    ///
7480    /// Wire method: `session.metadata.recordContextChange`.
7481    ///
7482    /// # Parameters
7483    ///
7484    /// * `params` - Updated working-directory/git context to record on the session.
7485    ///
7486    /// # Returns
7487    ///
7488    /// 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.
7489    ///
7490    /// <div class="warning">
7491    ///
7492    /// **Experimental.** This API is part of an experimental wire-protocol surface
7493    /// and may change or be removed in future SDK or CLI releases. Pin both the
7494    /// SDK and CLI versions if your code depends on it.
7495    ///
7496    /// </div>
7497    pub async fn record_context_change(
7498        &self,
7499        params: MetadataRecordContextChangeRequest,
7500    ) -> Result<MetadataRecordContextChangeResult, Error> {
7501        let mut wire_params = serde_json::to_value(params)?;
7502        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7503        let _value = self
7504            .session
7505            .client()
7506            .call(
7507                rpc_methods::SESSION_METADATA_RECORDCONTEXTCHANGE,
7508                Some(wire_params),
7509            )
7510            .await?;
7511        Ok(serde_json::from_value(_value)?)
7512    }
7513
7514    /// 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.
7515    ///
7516    /// Wire method: `session.metadata.setWorkingDirectory`.
7517    ///
7518    /// # Parameters
7519    ///
7520    /// * `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.
7521    ///
7522    /// # Returns
7523    ///
7524    /// 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.
7525    ///
7526    /// <div class="warning">
7527    ///
7528    /// **Experimental.** This API is part of an experimental wire-protocol surface
7529    /// and may change or be removed in future SDK or CLI releases. Pin both the
7530    /// SDK and CLI versions if your code depends on it.
7531    ///
7532    /// </div>
7533    pub async fn set_working_directory(
7534        &self,
7535        params: MetadataSetWorkingDirectoryRequest,
7536    ) -> Result<MetadataSetWorkingDirectoryResult, Error> {
7537        let mut wire_params = serde_json::to_value(params)?;
7538        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7539        let _value = self
7540            .session
7541            .client()
7542            .call(
7543                rpc_methods::SESSION_METADATA_SETWORKINGDIRECTORY,
7544                Some(wire_params),
7545            )
7546            .await?;
7547        Ok(serde_json::from_value(_value)?)
7548    }
7549
7550    /// Re-tokenizes the session's existing messages against a model and returns aggregate token totals.
7551    ///
7552    /// Wire method: `session.metadata.recomputeContextTokens`.
7553    ///
7554    /// # Parameters
7555    ///
7556    /// * `params` - Model identifier to use when re-tokenizing the session's existing messages.
7557    ///
7558    /// # Returns
7559    ///
7560    /// 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.
7561    ///
7562    /// <div class="warning">
7563    ///
7564    /// **Experimental.** This API is part of an experimental wire-protocol surface
7565    /// and may change or be removed in future SDK or CLI releases. Pin both the
7566    /// SDK and CLI versions if your code depends on it.
7567    ///
7568    /// </div>
7569    pub async fn recompute_context_tokens(
7570        &self,
7571        params: MetadataRecomputeContextTokensRequest,
7572    ) -> Result<MetadataRecomputeContextTokensResult, Error> {
7573        let mut wire_params = serde_json::to_value(params)?;
7574        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7575        let _value = self
7576            .session
7577            .client()
7578            .call(
7579                rpc_methods::SESSION_METADATA_RECOMPUTECONTEXTTOKENS,
7580                Some(wire_params),
7581            )
7582            .await?;
7583        Ok(serde_json::from_value(_value)?)
7584    }
7585}
7586
7587/// `session.mode.*` RPCs.
7588#[derive(Clone, Copy)]
7589pub struct SessionRpcMode<'a> {
7590    pub(crate) session: &'a Session,
7591}
7592
7593impl<'a> SessionRpcMode<'a> {
7594    /// Gets the current agent interaction mode.
7595    ///
7596    /// Wire method: `session.mode.get`.
7597    ///
7598    /// # Returns
7599    ///
7600    /// The session mode the agent is operating in
7601    ///
7602    /// <div class="warning">
7603    ///
7604    /// **Experimental.** This API is part of an experimental wire-protocol surface
7605    /// and may change or be removed in future SDK or CLI releases. Pin both the
7606    /// SDK and CLI versions if your code depends on it.
7607    ///
7608    /// </div>
7609    pub async fn get(&self) -> Result<SessionMode, Error> {
7610        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7611        let _value = self
7612            .session
7613            .client()
7614            .call(rpc_methods::SESSION_MODE_GET, Some(wire_params))
7615            .await?;
7616        Ok(serde_json::from_value(_value)?)
7617    }
7618
7619    /// Sets the current agent interaction mode.
7620    ///
7621    /// Wire method: `session.mode.set`.
7622    ///
7623    /// # Parameters
7624    ///
7625    /// * `params` - Agent interaction mode to apply to the session.
7626    ///
7627    /// # Returns
7628    ///
7629    /// Outcome of a session mode change, including any model switch it triggered and follow-up the host must perform.
7630    ///
7631    /// <div class="warning">
7632    ///
7633    /// **Experimental.** This API is part of an experimental wire-protocol surface
7634    /// and may change or be removed in future SDK or CLI releases. Pin both the
7635    /// SDK and CLI versions if your code depends on it.
7636    ///
7637    /// </div>
7638    pub async fn set(&self, params: ModeSetRequest) -> Result<ModeSetResult, Error> {
7639        let mut wire_params = serde_json::to_value(params)?;
7640        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7641        let _value = self
7642            .session
7643            .client()
7644            .call(rpc_methods::SESSION_MODE_SET, Some(wire_params))
7645            .await?;
7646        Ok(serde_json::from_value(_value)?)
7647    }
7648}
7649
7650/// `session.model.*` RPCs.
7651#[derive(Clone, Copy)]
7652pub struct SessionRpcModel<'a> {
7653    pub(crate) session: &'a Session,
7654}
7655
7656impl<'a> SessionRpcModel<'a> {
7657    /// Gets the session's authoritative model snapshot, including the committed Auto preference and any newer unclaimed Auto preference waiting for a future user turn.
7658    ///
7659    /// Wire method: `session.model.getCurrent`.
7660    ///
7661    /// # Returns
7662    ///
7663    /// The session's authoritative model snapshot. Auto preference fields are configuration for the virtual `auto` model and do not change the selected model identifier. The context tier reflects `Session.getContextTier()`, restored from the session journal on resume.
7664    ///
7665    /// <div class="warning">
7666    ///
7667    /// **Experimental.** This API is part of an experimental wire-protocol surface
7668    /// and may change or be removed in future SDK or CLI releases. Pin both the
7669    /// SDK and CLI versions if your code depends on it.
7670    ///
7671    /// </div>
7672    pub async fn get_current(&self) -> Result<CurrentModel, Error> {
7673        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7674        let _value = self
7675            .session
7676            .client()
7677            .call(rpc_methods::SESSION_MODEL_GETCURRENT, Some(wire_params))
7678            .await?;
7679        Ok(serde_json::from_value(_value)?)
7680    }
7681
7682    /// Switches the session to a model and optional reasoning configuration.
7683    ///
7684    /// Wire method: `session.model.switchTo`.
7685    ///
7686    /// # Parameters
7687    ///
7688    /// * `params` - Target model identifier and optional reasoning effort, summary, capability overrides, and context tier.
7689    ///
7690    /// # Returns
7691    ///
7692    /// The model identifier active on the session after the switch.
7693    ///
7694    /// <div class="warning">
7695    ///
7696    /// **Experimental.** This API is part of an experimental wire-protocol surface
7697    /// and may change or be removed in future SDK or CLI releases. Pin both the
7698    /// SDK and CLI versions if your code depends on it.
7699    ///
7700    /// </div>
7701    pub async fn switch_to(
7702        &self,
7703        params: ModelSwitchToRequest,
7704    ) -> Result<ModelSwitchToResult, Error> {
7705        let mut wire_params = serde_json::to_value(params)?;
7706        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7707        let _value = self
7708            .session
7709            .client()
7710            .call(rpc_methods::SESSION_MODEL_SWITCHTO, Some(wire_params))
7711            .await?;
7712        Ok(serde_json::from_value(_value)?)
7713    }
7714
7715    /// Requests an Auto preference change without changing the session's selected model. The latest unclaimed request wins; the runtime commits it only after a later prompt using the `auto` model mints a usable model and token pair. A `pending` response confirms that the request was accepted, not that it committed. Observe eventual success through `session.model_change`, failure through the ephemeral `session.auto_tier_switch_failed` event, or current unclaimed state through `session.model.getCurrent`.
7716    ///
7717    /// Wire method: `session.model.switchAutoTier`.
7718    ///
7719    /// # Parameters
7720    ///
7721    /// * `params` - An Auto preference request for the session. This updates Auto configuration only; it does not change the selected model to `auto`.
7722    ///
7723    /// # Returns
7724    ///
7725    /// Immediate acknowledgement and Auto preference snapshot after a switch request. This result never implies that a pending preference committed.
7726    ///
7727    /// <div class="warning">
7728    ///
7729    /// **Experimental.** This API is part of an experimental wire-protocol surface
7730    /// and may change or be removed in future SDK or CLI releases. Pin both the
7731    /// SDK and CLI versions if your code depends on it.
7732    ///
7733    /// </div>
7734    pub async fn switch_auto_tier(
7735        &self,
7736        params: ModelSwitchAutoTierRequest,
7737    ) -> Result<ModelSwitchAutoTierResult, Error> {
7738        let mut wire_params = serde_json::to_value(params)?;
7739        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7740        let _value = self
7741            .session
7742            .client()
7743            .call(rpc_methods::SESSION_MODEL_SWITCHAUTOTIER, Some(wire_params))
7744            .await?;
7745        Ok(serde_json::from_value(_value)?)
7746    }
7747
7748    /// Resolves and applies organization-managed and repository model overlays.
7749    ///
7750    /// Wire method: `session.model.applyStartupOverlay`.
7751    ///
7752    /// # Parameters
7753    ///
7754    /// * `params` - Managed, repository, and CLI model overrides to overlay onto the session at startup.
7755    ///
7756    /// # Returns
7757    ///
7758    /// The model identifier active on the session after the switch.
7759    ///
7760    /// <div class="warning">
7761    ///
7762    /// **Experimental.** This API is part of an experimental wire-protocol surface
7763    /// and may change or be removed in future SDK or CLI releases. Pin both the
7764    /// SDK and CLI versions if your code depends on it.
7765    ///
7766    /// </div>
7767    pub(crate) async fn apply_startup_overlay(
7768        &self,
7769        params: ModelApplyStartupOverlayRequest,
7770    ) -> Result<ModelSwitchToResult, Error> {
7771        let mut wire_params = serde_json::to_value(params)?;
7772        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7773        let _value = self
7774            .session
7775            .client()
7776            .call(
7777                rpc_methods::SESSION_MODEL_APPLYSTARTUPOVERLAY,
7778                Some(wire_params),
7779            )
7780            .await?;
7781        Ok(serde_json::from_value(_value)?)
7782    }
7783
7784    /// Replaces or clears the host-supplied model allowlist for a running session.
7785    ///
7786    /// Wire method: `session.model.setAllowedModels`.
7787    ///
7788    /// # Parameters
7789    ///
7790    /// * `params` - Host-supplied exact model selection IDs to allow for this running session. CAPI IDs are intersected with repository `.github/allowed_models.txt` policy; provider-qualified IDs remain exempt from repository-only policy but are restricted by this host list. Omit or pass null to clear the host restriction; an explicit empty or disjoint list is rejected. Validation and pre-selection fallback failures preserve the previous restriction. Failures after a fallback selection commits retain the new restriction and selected model; callers should inspect current session state after such an error.
7791    ///
7792    /// # Returns
7793    ///
7794    /// The applied host allowlist and effective session model policy after intersection.
7795    ///
7796    /// <div class="warning">
7797    ///
7798    /// **Experimental.** This API is part of an experimental wire-protocol surface
7799    /// and may change or be removed in future SDK or CLI releases. Pin both the
7800    /// SDK and CLI versions if your code depends on it.
7801    ///
7802    /// </div>
7803    pub async fn set_allowed_models(
7804        &self,
7805        params: ModelSetAllowedModelsRequest,
7806    ) -> Result<ModelSetAllowedModelsResult, Error> {
7807        let mut wire_params = serde_json::to_value(params)?;
7808        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7809        let _value = self
7810            .session
7811            .client()
7812            .call(
7813                rpc_methods::SESSION_MODEL_SETALLOWEDMODELS,
7814                Some(wire_params),
7815            )
7816            .await?;
7817        Ok(serde_json::from_value(_value)?)
7818    }
7819
7820    /// Updates the session's reasoning effort without changing the selected model.
7821    ///
7822    /// Wire method: `session.model.setReasoningEffort`.
7823    ///
7824    /// # Parameters
7825    ///
7826    /// * `params` - Reasoning effort level to apply to the currently selected model.
7827    ///
7828    /// # Returns
7829    ///
7830    /// 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.
7831    ///
7832    /// <div class="warning">
7833    ///
7834    /// **Experimental.** This API is part of an experimental wire-protocol surface
7835    /// and may change or be removed in future SDK or CLI releases. Pin both the
7836    /// SDK and CLI versions if your code depends on it.
7837    ///
7838    /// </div>
7839    pub async fn set_reasoning_effort(
7840        &self,
7841        params: ModelSetReasoningEffortRequest,
7842    ) -> Result<ModelSetReasoningEffortResult, Error> {
7843        let mut wire_params = serde_json::to_value(params)?;
7844        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7845        let _value = self
7846            .session
7847            .client()
7848            .call(
7849                rpc_methods::SESSION_MODEL_SETREASONINGEFFORT,
7850                Some(wire_params),
7851            )
7852            .await?;
7853        Ok(serde_json::from_value(_value)?)
7854    }
7855
7856    /// 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.
7857    ///
7858    /// Wire method: `session.model.list`.
7859    ///
7860    /// # Returns
7861    ///
7862    /// The list of models available to this session.
7863    ///
7864    /// <div class="warning">
7865    ///
7866    /// **Experimental.** This API is part of an experimental wire-protocol surface
7867    /// and may change or be removed in future SDK or CLI releases. Pin both the
7868    /// SDK and CLI versions if your code depends on it.
7869    ///
7870    /// </div>
7871    pub async fn list(&self) -> Result<SessionModelList, Error> {
7872        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7873        let _value = self
7874            .session
7875            .client()
7876            .call(rpc_methods::SESSION_MODEL_LIST, Some(wire_params))
7877            .await?;
7878        Ok(serde_json::from_value(_value)?)
7879    }
7880
7881    /// 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.
7882    ///
7883    /// Wire method: `session.model.list`.
7884    ///
7885    /// # Parameters
7886    ///
7887    /// * `params` - Optional listing options.
7888    ///
7889    /// # Returns
7890    ///
7891    /// The list of models available to this session.
7892    ///
7893    /// <div class="warning">
7894    ///
7895    /// **Experimental.** This API is part of an experimental wire-protocol surface
7896    /// and may change or be removed in future SDK or CLI releases. Pin both the
7897    /// SDK and CLI versions if your code depends on it.
7898    ///
7899    /// </div>
7900    pub async fn list_with_params(
7901        &self,
7902        params: ModelListRequest,
7903    ) -> Result<SessionModelList, Error> {
7904        let mut wire_params = serde_json::to_value(params)?;
7905        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7906        let _value = self
7907            .session
7908            .client()
7909            .call(rpc_methods::SESSION_MODEL_LIST, Some(wire_params))
7910            .await?;
7911        Ok(serde_json::from_value(_value)?)
7912    }
7913}
7914
7915/// `session.name.*` RPCs.
7916#[derive(Clone, Copy)]
7917pub struct SessionRpcName<'a> {
7918    pub(crate) session: &'a Session,
7919}
7920
7921impl<'a> SessionRpcName<'a> {
7922    /// Gets the session's friendly name.
7923    ///
7924    /// Wire method: `session.name.get`.
7925    ///
7926    /// # Returns
7927    ///
7928    /// The session's friendly name, or null when not yet set.
7929    ///
7930    /// <div class="warning">
7931    ///
7932    /// **Experimental.** This API is part of an experimental wire-protocol surface
7933    /// and may change or be removed in future SDK or CLI releases. Pin both the
7934    /// SDK and CLI versions if your code depends on it.
7935    ///
7936    /// </div>
7937    pub async fn get(&self) -> Result<NameGetResult, Error> {
7938        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7939        let _value = self
7940            .session
7941            .client()
7942            .call(rpc_methods::SESSION_NAME_GET, Some(wire_params))
7943            .await?;
7944        Ok(serde_json::from_value(_value)?)
7945    }
7946
7947    /// Sets the session's friendly name.
7948    ///
7949    /// Wire method: `session.name.set`.
7950    ///
7951    /// # Parameters
7952    ///
7953    /// * `params` - New friendly name to apply to the session.
7954    ///
7955    /// <div class="warning">
7956    ///
7957    /// **Experimental.** This API is part of an experimental wire-protocol surface
7958    /// and may change or be removed in future SDK or CLI releases. Pin both the
7959    /// SDK and CLI versions if your code depends on it.
7960    ///
7961    /// </div>
7962    pub async fn set(&self, params: NameSetRequest) -> Result<(), Error> {
7963        let mut wire_params = serde_json::to_value(params)?;
7964        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7965        let _value = self
7966            .session
7967            .client()
7968            .call(rpc_methods::SESSION_NAME_SET, Some(wire_params))
7969            .await?;
7970        Ok(())
7971    }
7972
7973    /// Persists an auto-generated session summary as the session's name when no user-set name exists.
7974    ///
7975    /// Wire method: `session.name.setAuto`.
7976    ///
7977    /// # Parameters
7978    ///
7979    /// * `params` - Auto-generated session summary to apply as the session's name when no user-set name exists.
7980    ///
7981    /// # Returns
7982    ///
7983    /// Indicates whether the auto-generated summary was applied as the session's name.
7984    ///
7985    /// <div class="warning">
7986    ///
7987    /// **Experimental.** This API is part of an experimental wire-protocol surface
7988    /// and may change or be removed in future SDK or CLI releases. Pin both the
7989    /// SDK and CLI versions if your code depends on it.
7990    ///
7991    /// </div>
7992    pub async fn set_auto(&self, params: NameSetAutoRequest) -> Result<NameSetAutoResult, Error> {
7993        let mut wire_params = serde_json::to_value(params)?;
7994        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7995        let _value = self
7996            .session
7997            .client()
7998            .call(rpc_methods::SESSION_NAME_SETAUTO, Some(wire_params))
7999            .await?;
8000        Ok(serde_json::from_value(_value)?)
8001    }
8002}
8003
8004/// `session.options.*` RPCs.
8005#[derive(Clone, Copy)]
8006pub struct SessionRpcOptions<'a> {
8007    pub(crate) session: &'a Session,
8008}
8009
8010impl<'a> SessionRpcOptions<'a> {
8011    /// Patches the genuinely-mutable subset of session options.
8012    ///
8013    /// Wire method: `session.options.update`.
8014    ///
8015    /// # Parameters
8016    ///
8017    /// * `params` - Patch of mutable session options to apply to the running session.
8018    ///
8019    /// # Returns
8020    ///
8021    /// Indicates whether the session options patch was applied successfully.
8022    ///
8023    /// <div class="warning">
8024    ///
8025    /// **Experimental.** This API is part of an experimental wire-protocol surface
8026    /// and may change or be removed in future SDK or CLI releases. Pin both the
8027    /// SDK and CLI versions if your code depends on it.
8028    ///
8029    /// </div>
8030    pub async fn update(
8031        &self,
8032        params: SessionUpdateOptionsParams,
8033    ) -> Result<SessionUpdateOptionsResult, Error> {
8034        let mut wire_params = serde_json::to_value(params)?;
8035        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8036        let _value = self
8037            .session
8038            .client()
8039            .call(rpc_methods::SESSION_OPTIONS_UPDATE, Some(wire_params))
8040            .await?;
8041        Ok(serde_json::from_value(_value)?)
8042    }
8043}
8044
8045/// `session.permissions.*` RPCs.
8046#[derive(Clone, Copy)]
8047pub struct SessionRpcPermissions<'a> {
8048    pub(crate) session: &'a Session,
8049}
8050
8051impl<'a> SessionRpcPermissions<'a> {
8052    /// `session.permissions.folderTrust.*` sub-namespace.
8053    pub fn folder_trust(&self) -> SessionRpcPermissionsFolderTrust<'a> {
8054        SessionRpcPermissionsFolderTrust {
8055            session: self.session,
8056        }
8057    }
8058
8059    /// `session.permissions.locations.*` sub-namespace.
8060    pub fn locations(&self) -> SessionRpcPermissionsLocations<'a> {
8061        SessionRpcPermissionsLocations {
8062            session: self.session,
8063        }
8064    }
8065
8066    /// `session.permissions.paths.*` sub-namespace.
8067    pub fn paths(&self) -> SessionRpcPermissionsPaths<'a> {
8068        SessionRpcPermissionsPaths {
8069            session: self.session,
8070        }
8071    }
8072
8073    /// `session.permissions.urls.*` sub-namespace.
8074    pub fn urls(&self) -> SessionRpcPermissionsUrls<'a> {
8075        SessionRpcPermissionsUrls {
8076            session: self.session,
8077        }
8078    }
8079
8080    /// Replaces selected permission policy fields (rules, paths, URLs, exclusions, allow-all flags) on the session.
8081    ///
8082    /// Wire method: `session.permissions.configure`.
8083    ///
8084    /// # Parameters
8085    ///
8086    /// * `params` - Patch of permission policy fields to apply (omit a field to leave it unchanged).
8087    ///
8088    /// # Returns
8089    ///
8090    /// Indicates whether the operation succeeded.
8091    ///
8092    /// <div class="warning">
8093    ///
8094    /// **Experimental.** This API is part of an experimental wire-protocol surface
8095    /// and may change or be removed in future SDK or CLI releases. Pin both the
8096    /// SDK and CLI versions if your code depends on it.
8097    ///
8098    /// </div>
8099    pub async fn configure(
8100        &self,
8101        params: PermissionsConfigureParams,
8102    ) -> Result<PermissionsConfigureResult, Error> {
8103        let mut wire_params = serde_json::to_value(params)?;
8104        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8105        let _value = self
8106            .session
8107            .client()
8108            .call(
8109                rpc_methods::SESSION_PERMISSIONS_CONFIGURE,
8110                Some(wire_params),
8111            )
8112            .await?;
8113        Ok(serde_json::from_value(_value)?)
8114    }
8115
8116    /// Provides a decision for a pending tool permission request.
8117    ///
8118    /// Wire method: `session.permissions.handlePendingPermissionRequest`.
8119    ///
8120    /// # Parameters
8121    ///
8122    /// * `params` - Pending permission request ID and the decision to apply (approve/reject and scope).
8123    ///
8124    /// # Returns
8125    ///
8126    /// Indicates whether the permission decision was applied; false when the request was already resolved.
8127    ///
8128    /// <div class="warning">
8129    ///
8130    /// **Experimental.** This API is part of an experimental wire-protocol surface
8131    /// and may change or be removed in future SDK or CLI releases. Pin both the
8132    /// SDK and CLI versions if your code depends on it.
8133    ///
8134    /// </div>
8135    pub async fn handle_pending_permission_request(
8136        &self,
8137        params: PermissionDecisionRequest,
8138    ) -> Result<PermissionRequestResult, Error> {
8139        let mut wire_params = serde_json::to_value(params)?;
8140        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8141        let _value = self
8142            .session
8143            .client()
8144            .call(
8145                rpc_methods::SESSION_PERMISSIONS_HANDLEPENDINGPERMISSIONREQUEST,
8146                Some(wire_params),
8147            )
8148            .await?;
8149        Ok(serde_json::from_value(_value)?)
8150    }
8151
8152    /// Reconstructs the set of pending tool permission requests from the session's event history.
8153    ///
8154    /// Wire method: `session.permissions.pendingRequests`.
8155    ///
8156    /// # Returns
8157    ///
8158    /// List of pending permission requests reconstructed from event history.
8159    ///
8160    /// <div class="warning">
8161    ///
8162    /// **Experimental.** This API is part of an experimental wire-protocol surface
8163    /// and may change or be removed in future SDK or CLI releases. Pin both the
8164    /// SDK and CLI versions if your code depends on it.
8165    ///
8166    /// </div>
8167    pub async fn pending_requests(&self) -> Result<PendingPermissionRequestList, Error> {
8168        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8169        let _value = self
8170            .session
8171            .client()
8172            .call(
8173                rpc_methods::SESSION_PERMISSIONS_PENDINGREQUESTS,
8174                Some(wire_params),
8175            )
8176            .await?;
8177        Ok(serde_json::from_value(_value)?)
8178    }
8179
8180    /// Enables or disables automatic approval of tool permission requests for the session.
8181    ///
8182    /// Wire method: `session.permissions.setApproveAll`.
8183    ///
8184    /// # Parameters
8185    ///
8186    /// * `params` - Allow-all toggle for tool permission requests, with an optional telemetry source.
8187    ///
8188    /// # Returns
8189    ///
8190    /// Indicates whether the operation succeeded.
8191    ///
8192    /// <div class="warning">
8193    ///
8194    /// **Experimental.** This API is part of an experimental wire-protocol surface
8195    /// and may change or be removed in future SDK or CLI releases. Pin both the
8196    /// SDK and CLI versions if your code depends on it.
8197    ///
8198    /// </div>
8199    pub async fn set_approve_all(
8200        &self,
8201        params: PermissionsSetApproveAllRequest,
8202    ) -> Result<PermissionsSetApproveAllResult, Error> {
8203        let mut wire_params = serde_json::to_value(params)?;
8204        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8205        let _value = self
8206            .session
8207            .client()
8208            .call(
8209                rpc_methods::SESSION_PERMISSIONS_SETAPPROVEALL,
8210                Some(wire_params),
8211            )
8212            .await?;
8213        Ok(serde_json::from_value(_value)?)
8214    }
8215
8216    /// 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.
8217    ///
8218    /// Wire method: `session.permissions.setMode`.
8219    ///
8220    /// # Parameters
8221    ///
8222    /// * `params` - Permission mode to apply for the session.
8223    ///
8224    /// # Returns
8225    ///
8226    /// Indicates whether the requested permission mode was applied and reports the authoritative post-mutation mode.
8227    ///
8228    /// <div class="warning">
8229    ///
8230    /// **Experimental.** This API is part of an experimental wire-protocol surface
8231    /// and may change or be removed in future SDK or CLI releases. Pin both the
8232    /// SDK and CLI versions if your code depends on it.
8233    ///
8234    /// </div>
8235    pub async fn set_mode(
8236        &self,
8237        params: PermissionsSetModeRequest,
8238    ) -> Result<PermissionsSetModeResult, Error> {
8239        let mut wire_params = serde_json::to_value(params)?;
8240        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8241        let _value = self
8242            .session
8243            .client()
8244            .call(rpc_methods::SESSION_PERMISSIONS_SETMODE, Some(wire_params))
8245            .await?;
8246        Ok(serde_json::from_value(_value)?)
8247    }
8248
8249    /// Returns the current permission mode for the session.
8250    ///
8251    /// Wire method: `session.permissions.getMode`.
8252    ///
8253    /// # Returns
8254    ///
8255    /// Current permission mode.
8256    ///
8257    /// <div class="warning">
8258    ///
8259    /// **Experimental.** This API is part of an experimental wire-protocol surface
8260    /// and may change or be removed in future SDK or CLI releases. Pin both the
8261    /// SDK and CLI versions if your code depends on it.
8262    ///
8263    /// </div>
8264    pub async fn get_mode(&self) -> Result<PermissionsGetModeResult, Error> {
8265        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8266        let _value = self
8267            .session
8268            .client()
8269            .call(rpc_methods::SESSION_PERMISSIONS_GETMODE, Some(wire_params))
8270            .await?;
8271        Ok(serde_json::from_value(_value)?)
8272    }
8273
8274    /// Adds or removes session-scoped or location-scoped permission rules.
8275    ///
8276    /// Wire method: `session.permissions.modifyRules`.
8277    ///
8278    /// # Parameters
8279    ///
8280    /// * `params` - Scope and add/remove instructions for modifying session- or location-scoped permission rules.
8281    ///
8282    /// # Returns
8283    ///
8284    /// Indicates whether the operation succeeded.
8285    ///
8286    /// <div class="warning">
8287    ///
8288    /// **Experimental.** This API is part of an experimental wire-protocol surface
8289    /// and may change or be removed in future SDK or CLI releases. Pin both the
8290    /// SDK and CLI versions if your code depends on it.
8291    ///
8292    /// </div>
8293    pub async fn modify_rules(
8294        &self,
8295        params: PermissionsModifyRulesParams,
8296    ) -> Result<PermissionsModifyRulesResult, Error> {
8297        let mut wire_params = serde_json::to_value(params)?;
8298        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8299        let _value = self
8300            .session
8301            .client()
8302            .call(
8303                rpc_methods::SESSION_PERMISSIONS_MODIFYRULES,
8304                Some(wire_params),
8305            )
8306            .await?;
8307        Ok(serde_json::from_value(_value)?)
8308    }
8309
8310    /// Sets whether the client wants permission prompts bridged into session events.
8311    ///
8312    /// Wire method: `session.permissions.setRequired`.
8313    ///
8314    /// # Parameters
8315    ///
8316    /// * `params` - Toggles whether permission prompts should be bridged into session events for this client.
8317    ///
8318    /// # Returns
8319    ///
8320    /// Indicates whether the operation succeeded.
8321    ///
8322    /// <div class="warning">
8323    ///
8324    /// **Experimental.** This API is part of an experimental wire-protocol surface
8325    /// and may change or be removed in future SDK or CLI releases. Pin both the
8326    /// SDK and CLI versions if your code depends on it.
8327    ///
8328    /// </div>
8329    pub async fn set_required(
8330        &self,
8331        params: PermissionsSetRequiredRequest,
8332    ) -> Result<PermissionsSetRequiredResult, Error> {
8333        let mut wire_params = serde_json::to_value(params)?;
8334        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8335        let _value = self
8336            .session
8337            .client()
8338            .call(
8339                rpc_methods::SESSION_PERMISSIONS_SETREQUIRED,
8340                Some(wire_params),
8341            )
8342            .await?;
8343        Ok(serde_json::from_value(_value)?)
8344    }
8345
8346    /// Clears session-scoped tool permission approvals.
8347    ///
8348    /// Wire method: `session.permissions.resetSessionApprovals`.
8349    ///
8350    /// # Parameters
8351    ///
8352    /// * `params` - Clears session-scoped tool permission approvals, and optionally the location-scoped ones.
8353    ///
8354    /// # Returns
8355    ///
8356    /// Indicates whether the operation succeeded.
8357    ///
8358    /// <div class="warning">
8359    ///
8360    /// **Experimental.** This API is part of an experimental wire-protocol surface
8361    /// and may change or be removed in future SDK or CLI releases. Pin both the
8362    /// SDK and CLI versions if your code depends on it.
8363    ///
8364    /// </div>
8365    pub async fn reset_session_approvals(
8366        &self,
8367        params: PermissionsResetSessionApprovalsRequest,
8368    ) -> Result<PermissionsResetSessionApprovalsResult, Error> {
8369        let mut wire_params = serde_json::to_value(params)?;
8370        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8371        let _value = self
8372            .session
8373            .client()
8374            .call(
8375                rpc_methods::SESSION_PERMISSIONS_RESETSESSIONAPPROVALS,
8376                Some(wire_params),
8377            )
8378            .await?;
8379        Ok(serde_json::from_value(_value)?)
8380    }
8381
8382    /// Notifies the runtime that a permission prompt UI has been shown to the user.
8383    ///
8384    /// Wire method: `session.permissions.notifyPromptShown`.
8385    ///
8386    /// # Parameters
8387    ///
8388    /// * `params` - Notification payload describing the permission prompt that the client just rendered.
8389    ///
8390    /// # Returns
8391    ///
8392    /// Indicates whether the operation succeeded.
8393    ///
8394    /// <div class="warning">
8395    ///
8396    /// **Experimental.** This API is part of an experimental wire-protocol surface
8397    /// and may change or be removed in future SDK or CLI releases. Pin both the
8398    /// SDK and CLI versions if your code depends on it.
8399    ///
8400    /// </div>
8401    pub async fn notify_prompt_shown(
8402        &self,
8403        params: PermissionPromptShownNotification,
8404    ) -> Result<PermissionsNotifyPromptShownResult, Error> {
8405        let mut wire_params = serde_json::to_value(params)?;
8406        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8407        let _value = self
8408            .session
8409            .client()
8410            .call(
8411                rpc_methods::SESSION_PERMISSIONS_NOTIFYPROMPTSHOWN,
8412                Some(wire_params),
8413            )
8414            .await?;
8415        Ok(serde_json::from_value(_value)?)
8416    }
8417}
8418
8419/// `session.permissions.folderTrust.*` RPCs.
8420#[derive(Clone, Copy)]
8421pub struct SessionRpcPermissionsFolderTrust<'a> {
8422    pub(crate) session: &'a Session,
8423}
8424
8425impl<'a> SessionRpcPermissionsFolderTrust<'a> {
8426    /// Reports whether a folder is trusted according to the user's folder trust state.
8427    ///
8428    /// Wire method: `session.permissions.folderTrust.isTrusted`.
8429    ///
8430    /// # Parameters
8431    ///
8432    /// * `params` - Folder path to check for trust.
8433    ///
8434    /// # Returns
8435    ///
8436    /// Folder trust check result.
8437    ///
8438    /// <div class="warning">
8439    ///
8440    /// **Experimental.** This API is part of an experimental wire-protocol surface
8441    /// and may change or be removed in future SDK or CLI releases. Pin both the
8442    /// SDK and CLI versions if your code depends on it.
8443    ///
8444    /// </div>
8445    pub async fn is_trusted(
8446        &self,
8447        params: FolderTrustCheckParams,
8448    ) -> Result<FolderTrustCheckResult, Error> {
8449        let mut wire_params = serde_json::to_value(params)?;
8450        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8451        let _value = self
8452            .session
8453            .client()
8454            .call(
8455                rpc_methods::SESSION_PERMISSIONS_FOLDERTRUST_ISTRUSTED,
8456                Some(wire_params),
8457            )
8458            .await?;
8459        Ok(serde_json::from_value(_value)?)
8460    }
8461
8462    /// Adds a folder to the user's trusted folders list.
8463    ///
8464    /// Wire method: `session.permissions.folderTrust.addTrusted`.
8465    ///
8466    /// # Parameters
8467    ///
8468    /// * `params` - Folder path to add to trusted folders.
8469    ///
8470    /// # Returns
8471    ///
8472    /// Indicates whether the operation succeeded.
8473    ///
8474    /// <div class="warning">
8475    ///
8476    /// **Experimental.** This API is part of an experimental wire-protocol surface
8477    /// and may change or be removed in future SDK or CLI releases. Pin both the
8478    /// SDK and CLI versions if your code depends on it.
8479    ///
8480    /// </div>
8481    pub async fn add_trusted(
8482        &self,
8483        params: FolderTrustAddParams,
8484    ) -> Result<PermissionsFolderTrustAddTrustedResult, Error> {
8485        let mut wire_params = serde_json::to_value(params)?;
8486        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8487        let _value = self
8488            .session
8489            .client()
8490            .call(
8491                rpc_methods::SESSION_PERMISSIONS_FOLDERTRUST_ADDTRUSTED,
8492                Some(wire_params),
8493            )
8494            .await?;
8495        Ok(serde_json::from_value(_value)?)
8496    }
8497}
8498
8499/// `session.permissions.locations.*` RPCs.
8500#[derive(Clone, Copy)]
8501pub struct SessionRpcPermissionsLocations<'a> {
8502    pub(crate) session: &'a Session,
8503}
8504
8505impl<'a> SessionRpcPermissionsLocations<'a> {
8506    /// Resolves the permission location key and type for a working directory.
8507    ///
8508    /// Wire method: `session.permissions.locations.resolve`.
8509    ///
8510    /// # Parameters
8511    ///
8512    /// * `params` - Working directory to resolve into a location-permissions key.
8513    ///
8514    /// # Returns
8515    ///
8516    /// Resolved location-permissions key and type.
8517    ///
8518    /// <div class="warning">
8519    ///
8520    /// **Experimental.** This API is part of an experimental wire-protocol surface
8521    /// and may change or be removed in future SDK or CLI releases. Pin both the
8522    /// SDK and CLI versions if your code depends on it.
8523    ///
8524    /// </div>
8525    pub async fn resolve(
8526        &self,
8527        params: PermissionLocationResolveParams,
8528    ) -> Result<PermissionLocationResolveResult, Error> {
8529        let mut wire_params = serde_json::to_value(params)?;
8530        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8531        let _value = self
8532            .session
8533            .client()
8534            .call(
8535                rpc_methods::SESSION_PERMISSIONS_LOCATIONS_RESOLVE,
8536                Some(wire_params),
8537            )
8538            .await?;
8539        Ok(serde_json::from_value(_value)?)
8540    }
8541
8542    /// Applies persisted location-scoped tool approvals and allowed directories for a working directory to this session's permission service.
8543    ///
8544    /// Wire method: `session.permissions.locations.apply`.
8545    ///
8546    /// # Parameters
8547    ///
8548    /// * `params` - Working directory to load persisted location permissions for.
8549    ///
8550    /// # Returns
8551    ///
8552    /// Summary of persisted location permissions applied to the session.
8553    ///
8554    /// <div class="warning">
8555    ///
8556    /// **Experimental.** This API is part of an experimental wire-protocol surface
8557    /// and may change or be removed in future SDK or CLI releases. Pin both the
8558    /// SDK and CLI versions if your code depends on it.
8559    ///
8560    /// </div>
8561    pub async fn apply(
8562        &self,
8563        params: PermissionLocationApplyParams,
8564    ) -> Result<PermissionLocationApplyResult, Error> {
8565        let mut wire_params = serde_json::to_value(params)?;
8566        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8567        let _value = self
8568            .session
8569            .client()
8570            .call(
8571                rpc_methods::SESSION_PERMISSIONS_LOCATIONS_APPLY,
8572                Some(wire_params),
8573            )
8574            .await?;
8575        Ok(serde_json::from_value(_value)?)
8576    }
8577
8578    /// Persists a tool approval for a permission location and applies its rules to this session's live permission service.
8579    ///
8580    /// Wire method: `session.permissions.locations.addToolApproval`.
8581    ///
8582    /// # Parameters
8583    ///
8584    /// * `params` - Location-scoped tool approval to persist.
8585    ///
8586    /// # Returns
8587    ///
8588    /// Indicates whether the operation succeeded.
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 add_tool_approval(
8598        &self,
8599        params: PermissionLocationAddToolApprovalParams,
8600    ) -> Result<PermissionsLocationsAddToolApprovalResult, Error> {
8601        let mut wire_params = serde_json::to_value(params)?;
8602        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8603        let _value = self
8604            .session
8605            .client()
8606            .call(
8607                rpc_methods::SESSION_PERMISSIONS_LOCATIONS_ADDTOOLAPPROVAL,
8608                Some(wire_params),
8609            )
8610            .await?;
8611        Ok(serde_json::from_value(_value)?)
8612    }
8613}
8614
8615/// `session.permissions.paths.*` RPCs.
8616#[derive(Clone, Copy)]
8617pub struct SessionRpcPermissionsPaths<'a> {
8618    pub(crate) session: &'a Session,
8619}
8620
8621impl<'a> SessionRpcPermissionsPaths<'a> {
8622    /// Returns the session's allowed directories and primary working directory.
8623    ///
8624    /// Wire method: `session.permissions.paths.list`.
8625    ///
8626    /// # Returns
8627    ///
8628    /// Snapshot of the session's allow-listed directories and primary working directory.
8629    ///
8630    /// <div class="warning">
8631    ///
8632    /// **Experimental.** This API is part of an experimental wire-protocol surface
8633    /// and may change or be removed in future SDK or CLI releases. Pin both the
8634    /// SDK and CLI versions if your code depends on it.
8635    ///
8636    /// </div>
8637    pub async fn list(&self) -> Result<PermissionPathsList, Error> {
8638        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8639        let _value = self
8640            .session
8641            .client()
8642            .call(
8643                rpc_methods::SESSION_PERMISSIONS_PATHS_LIST,
8644                Some(wire_params),
8645            )
8646            .await?;
8647        Ok(serde_json::from_value(_value)?)
8648    }
8649
8650    /// Adds a directory to the session's allow-list and activates conventional skill and agent definitions under it.
8651    ///
8652    /// Wire method: `session.permissions.paths.add`.
8653    ///
8654    /// # Parameters
8655    ///
8656    /// * `params` - Directory path to add to the session's allowed directories.
8657    ///
8658    /// # Returns
8659    ///
8660    /// Indicates whether the operation succeeded.
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 add(
8670        &self,
8671        params: PermissionPathsAddParams,
8672    ) -> Result<PermissionsPathsAddResult, Error> {
8673        let mut wire_params = serde_json::to_value(params)?;
8674        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8675        let _value = self
8676            .session
8677            .client()
8678            .call(
8679                rpc_methods::SESSION_PERMISSIONS_PATHS_ADD,
8680                Some(wire_params),
8681            )
8682            .await?;
8683        Ok(serde_json::from_value(_value)?)
8684    }
8685
8686    /// Updates the session's primary working directory used by the permission policy.
8687    ///
8688    /// Wire method: `session.permissions.paths.updatePrimary`.
8689    ///
8690    /// # Parameters
8691    ///
8692    /// * `params` - Directory path to set as the session's new primary working directory.
8693    ///
8694    /// # Returns
8695    ///
8696    /// Indicates whether the operation succeeded.
8697    ///
8698    /// <div class="warning">
8699    ///
8700    /// **Experimental.** This API is part of an experimental wire-protocol surface
8701    /// and may change or be removed in future SDK or CLI releases. Pin both the
8702    /// SDK and CLI versions if your code depends on it.
8703    ///
8704    /// </div>
8705    pub async fn update_primary(
8706        &self,
8707        params: PermissionPathsUpdatePrimaryParams,
8708    ) -> Result<PermissionsPathsUpdatePrimaryResult, Error> {
8709        let mut wire_params = serde_json::to_value(params)?;
8710        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8711        let _value = self
8712            .session
8713            .client()
8714            .call(
8715                rpc_methods::SESSION_PERMISSIONS_PATHS_UPDATEPRIMARY,
8716                Some(wire_params),
8717            )
8718            .await?;
8719        Ok(serde_json::from_value(_value)?)
8720    }
8721
8722    /// Reports whether a path falls within any of the session's allowed directories.
8723    ///
8724    /// Wire method: `session.permissions.paths.isPathWithinAllowedDirectories`.
8725    ///
8726    /// # Parameters
8727    ///
8728    /// * `params` - Path to evaluate against the session's allowed directories.
8729    ///
8730    /// # Returns
8731    ///
8732    /// Indicates whether the supplied path is within the session's allowed directories.
8733    ///
8734    /// <div class="warning">
8735    ///
8736    /// **Experimental.** This API is part of an experimental wire-protocol surface
8737    /// and may change or be removed in future SDK or CLI releases. Pin both the
8738    /// SDK and CLI versions if your code depends on it.
8739    ///
8740    /// </div>
8741    pub async fn is_path_within_allowed_directories(
8742        &self,
8743        params: PermissionPathsAllowedCheckParams,
8744    ) -> Result<PermissionPathsAllowedCheckResult, Error> {
8745        let mut wire_params = serde_json::to_value(params)?;
8746        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8747        let _value = self
8748            .session
8749            .client()
8750            .call(
8751                rpc_methods::SESSION_PERMISSIONS_PATHS_ISPATHWITHINALLOWEDDIRECTORIES,
8752                Some(wire_params),
8753            )
8754            .await?;
8755        Ok(serde_json::from_value(_value)?)
8756    }
8757
8758    /// Reports whether a path falls within the session's workspace (primary) directory.
8759    ///
8760    /// Wire method: `session.permissions.paths.isPathWithinWorkspace`.
8761    ///
8762    /// # Parameters
8763    ///
8764    /// * `params` - Path to evaluate against the session's workspace (primary) directory.
8765    ///
8766    /// # Returns
8767    ///
8768    /// Indicates whether the supplied path is within the session's workspace directory.
8769    ///
8770    /// <div class="warning">
8771    ///
8772    /// **Experimental.** This API is part of an experimental wire-protocol surface
8773    /// and may change or be removed in future SDK or CLI releases. Pin both the
8774    /// SDK and CLI versions if your code depends on it.
8775    ///
8776    /// </div>
8777    pub async fn is_path_within_workspace(
8778        &self,
8779        params: PermissionPathsWorkspaceCheckParams,
8780    ) -> Result<PermissionPathsWorkspaceCheckResult, Error> {
8781        let mut wire_params = serde_json::to_value(params)?;
8782        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8783        let _value = self
8784            .session
8785            .client()
8786            .call(
8787                rpc_methods::SESSION_PERMISSIONS_PATHS_ISPATHWITHINWORKSPACE,
8788                Some(wire_params),
8789            )
8790            .await?;
8791        Ok(serde_json::from_value(_value)?)
8792    }
8793}
8794
8795/// `session.permissions.urls.*` RPCs.
8796#[derive(Clone, Copy)]
8797pub struct SessionRpcPermissionsUrls<'a> {
8798    pub(crate) session: &'a Session,
8799}
8800
8801impl<'a> SessionRpcPermissionsUrls<'a> {
8802    /// Toggles the runtime's URL-permission policy between unrestricted and restricted modes.
8803    ///
8804    /// Wire method: `session.permissions.urls.setUnrestrictedMode`.
8805    ///
8806    /// # Parameters
8807    ///
8808    /// * `params` - Whether the URL-permission policy should run in unrestricted mode.
8809    ///
8810    /// # Returns
8811    ///
8812    /// Indicates whether the operation succeeded.
8813    ///
8814    /// <div class="warning">
8815    ///
8816    /// **Experimental.** This API is part of an experimental wire-protocol surface
8817    /// and may change or be removed in future SDK or CLI releases. Pin both the
8818    /// SDK and CLI versions if your code depends on it.
8819    ///
8820    /// </div>
8821    pub async fn set_unrestricted_mode(
8822        &self,
8823        params: PermissionUrlsSetUnrestrictedModeParams,
8824    ) -> Result<PermissionsUrlsSetUnrestrictedModeResult, Error> {
8825        let mut wire_params = serde_json::to_value(params)?;
8826        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8827        let _value = self
8828            .session
8829            .client()
8830            .call(
8831                rpc_methods::SESSION_PERMISSIONS_URLS_SETUNRESTRICTEDMODE,
8832                Some(wire_params),
8833            )
8834            .await?;
8835        Ok(serde_json::from_value(_value)?)
8836    }
8837}
8838
8839/// `session.plan.*` RPCs.
8840#[derive(Clone, Copy)]
8841pub struct SessionRpcPlan<'a> {
8842    pub(crate) session: &'a Session,
8843}
8844
8845impl<'a> SessionRpcPlan<'a> {
8846    /// Reads the session plan file from the workspace.
8847    ///
8848    /// Wire method: `session.plan.read`.
8849    ///
8850    /// # Returns
8851    ///
8852    /// Existence, contents, and resolved path of the session plan file.
8853    ///
8854    /// <div class="warning">
8855    ///
8856    /// **Experimental.** This API is part of an experimental wire-protocol surface
8857    /// and may change or be removed in future SDK or CLI releases. Pin both the
8858    /// SDK and CLI versions if your code depends on it.
8859    ///
8860    /// </div>
8861    pub async fn read(&self) -> Result<PlanReadResult, Error> {
8862        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8863        let _value = self
8864            .session
8865            .client()
8866            .call(rpc_methods::SESSION_PLAN_READ, Some(wire_params))
8867            .await?;
8868        Ok(serde_json::from_value(_value)?)
8869    }
8870
8871    /// Writes new content to the session plan file.
8872    ///
8873    /// Wire method: `session.plan.update`.
8874    ///
8875    /// # Parameters
8876    ///
8877    /// * `params` - Replacement contents to write to the session plan file.
8878    ///
8879    /// <div class="warning">
8880    ///
8881    /// **Experimental.** This API is part of an experimental wire-protocol surface
8882    /// and may change or be removed in future SDK or CLI releases. Pin both the
8883    /// SDK and CLI versions if your code depends on it.
8884    ///
8885    /// </div>
8886    pub async fn update(&self, params: PlanUpdateRequest) -> Result<(), Error> {
8887        let mut wire_params = serde_json::to_value(params)?;
8888        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8889        let _value = self
8890            .session
8891            .client()
8892            .call(rpc_methods::SESSION_PLAN_UPDATE, Some(wire_params))
8893            .await?;
8894        Ok(())
8895    }
8896
8897    /// Deletes the session plan file from the workspace.
8898    ///
8899    /// Wire method: `session.plan.delete`.
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 async fn delete(&self) -> Result<(), 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_PLAN_DELETE, Some(wire_params))
8914            .await?;
8915        Ok(())
8916    }
8917
8918    /// Reads todo rows from the session SQL database for plan rendering.
8919    ///
8920    /// Wire method: `session.plan.readSqlTodos`.
8921    ///
8922    /// # Returns
8923    ///
8924    /// Todo rows read from the session SQL database. Empty when no session database is available.
8925    ///
8926    /// <div class="warning">
8927    ///
8928    /// **Experimental.** This API is part of an experimental wire-protocol surface
8929    /// and may change or be removed in future SDK or CLI releases. Pin both the
8930    /// SDK and CLI versions if your code depends on it.
8931    ///
8932    /// </div>
8933    pub async fn read_sql_todos(&self) -> Result<PlanReadSqlTodosResult, Error> {
8934        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8935        let _value = self
8936            .session
8937            .client()
8938            .call(rpc_methods::SESSION_PLAN_READSQLTODOS, Some(wire_params))
8939            .await?;
8940        Ok(serde_json::from_value(_value)?)
8941    }
8942
8943    /// 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.
8944    ///
8945    /// Wire method: `session.plan.readSqlTodosWithDependencies`.
8946    ///
8947    /// # Returns
8948    ///
8949    /// Todo rows + dependency edges read from the session SQL database.
8950    ///
8951    /// <div class="warning">
8952    ///
8953    /// **Experimental.** This API is part of an experimental wire-protocol surface
8954    /// and may change or be removed in future SDK or CLI releases. Pin both the
8955    /// SDK and CLI versions if your code depends on it.
8956    ///
8957    /// </div>
8958    pub async fn read_sql_todos_with_dependencies(
8959        &self,
8960    ) -> Result<PlanReadSqlTodosWithDependenciesResult, Error> {
8961        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8962        let _value = self
8963            .session
8964            .client()
8965            .call(
8966                rpc_methods::SESSION_PLAN_READSQLTODOSWITHDEPENDENCIES,
8967                Some(wire_params),
8968            )
8969            .await?;
8970        Ok(serde_json::from_value(_value)?)
8971    }
8972}
8973
8974/// `session.plugins.*` RPCs.
8975#[derive(Clone, Copy)]
8976pub struct SessionRpcPlugins<'a> {
8977    pub(crate) session: &'a Session,
8978}
8979
8980impl<'a> SessionRpcPlugins<'a> {
8981    /// Lists plugins installed for the session.
8982    ///
8983    /// Wire method: `session.plugins.list`.
8984    ///
8985    /// # Returns
8986    ///
8987    /// Plugins installed for the session, with their enabled state and version metadata.
8988    ///
8989    /// <div class="warning">
8990    ///
8991    /// **Experimental.** This API is part of an experimental wire-protocol surface
8992    /// and may change or be removed in future SDK or CLI releases. Pin both the
8993    /// SDK and CLI versions if your code depends on it.
8994    ///
8995    /// </div>
8996    pub async fn list(&self) -> Result<PluginList, Error> {
8997        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8998        let _value = self
8999            .session
9000            .client()
9001            .call(rpc_methods::SESSION_PLUGINS_LIST, Some(wire_params))
9002            .await?;
9003        Ok(serde_json::from_value(_value)?)
9004    }
9005
9006    /// 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.
9007    ///
9008    /// Wire method: `session.plugins.reload`.
9009    ///
9010    /// <div class="warning">
9011    ///
9012    /// **Experimental.** This API is part of an experimental wire-protocol surface
9013    /// and may change or be removed in future SDK or CLI releases. Pin both the
9014    /// SDK and CLI versions if your code depends on it.
9015    ///
9016    /// </div>
9017    pub async fn reload(&self) -> Result<(), Error> {
9018        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9019        let _value = self
9020            .session
9021            .client()
9022            .call(rpc_methods::SESSION_PLUGINS_RELOAD, Some(wire_params))
9023            .await?;
9024        Ok(())
9025    }
9026
9027    /// 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.
9028    ///
9029    /// Wire method: `session.plugins.reload`.
9030    ///
9031    /// # Parameters
9032    ///
9033    /// * `params` - Optional flags controlling which side effects the reload performs.
9034    ///
9035    /// <div class="warning">
9036    ///
9037    /// **Experimental.** This API is part of an experimental wire-protocol surface
9038    /// and may change or be removed in future SDK or CLI releases. Pin both the
9039    /// SDK and CLI versions if your code depends on it.
9040    ///
9041    /// </div>
9042    pub async fn reload_with_params(&self, params: PluginsReloadRequest) -> Result<(), Error> {
9043        let mut wire_params = serde_json::to_value(params)?;
9044        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9045        let _value = self
9046            .session
9047            .client()
9048            .call(rpc_methods::SESSION_PLUGINS_RELOAD, Some(wire_params))
9049            .await?;
9050        Ok(())
9051    }
9052}
9053
9054/// `session.provider.*` RPCs.
9055#[derive(Clone, Copy)]
9056pub struct SessionRpcProvider<'a> {
9057    pub(crate) session: &'a Session,
9058}
9059
9060impl<'a> SessionRpcProvider<'a> {
9061    /// 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.
9062    ///
9063    /// Wire method: `session.provider.getEndpoint`.
9064    ///
9065    /// # Returns
9066    ///
9067    /// A snapshot of the provider endpoint the session is currently configured to talk to.
9068    ///
9069    /// <div class="warning">
9070    ///
9071    /// **Experimental.** This API is part of an experimental wire-protocol surface
9072    /// and may change or be removed in future SDK or CLI releases. Pin both the
9073    /// SDK and CLI versions if your code depends on it.
9074    ///
9075    /// </div>
9076    pub async fn get_endpoint(&self) -> Result<ProviderEndpoint, Error> {
9077        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9078        let _value = self
9079            .session
9080            .client()
9081            .call(rpc_methods::SESSION_PROVIDER_GETENDPOINT, Some(wire_params))
9082            .await?;
9083        Ok(serde_json::from_value(_value)?)
9084    }
9085
9086    /// 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.
9087    ///
9088    /// Wire method: `session.provider.getEndpoint`.
9089    ///
9090    /// # Parameters
9091    ///
9092    /// * `params` - Optional model identifier to scope the endpoint snapshot to.
9093    ///
9094    /// # Returns
9095    ///
9096    /// A snapshot of the provider endpoint the session is currently configured to talk to.
9097    ///
9098    /// <div class="warning">
9099    ///
9100    /// **Experimental.** This API is part of an experimental wire-protocol surface
9101    /// and may change or be removed in future SDK or CLI releases. Pin both the
9102    /// SDK and CLI versions if your code depends on it.
9103    ///
9104    /// </div>
9105    pub async fn get_endpoint_with_params(
9106        &self,
9107        params: ProviderGetEndpointRequest,
9108    ) -> Result<ProviderEndpoint, Error> {
9109        let mut wire_params = serde_json::to_value(params)?;
9110        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9111        let _value = self
9112            .session
9113            .client()
9114            .call(rpc_methods::SESSION_PROVIDER_GETENDPOINT, Some(wire_params))
9115            .await?;
9116        Ok(serde_json::from_value(_value)?)
9117    }
9118
9119    /// 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.
9120    ///
9121    /// Wire method: `session.provider.add`.
9122    ///
9123    /// # Parameters
9124    ///
9125    /// * `params` - BYOK providers and/or models to add to the session's registry at runtime. Both fields are optional; provide providers, models, or both.
9126    ///
9127    /// # Returns
9128    ///
9129    /// The selectable model entries synthesized for the models added by this call.
9130    ///
9131    /// <div class="warning">
9132    ///
9133    /// **Experimental.** This API is part of an experimental wire-protocol surface
9134    /// and may change or be removed in future SDK or CLI releases. Pin both the
9135    /// SDK and CLI versions if your code depends on it.
9136    ///
9137    /// </div>
9138    pub async fn add(&self, params: ProviderAddRequest) -> Result<ProviderAddResult, Error> {
9139        let mut wire_params = serde_json::to_value(params)?;
9140        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9141        let _value = self
9142            .session
9143            .client()
9144            .call(rpc_methods::SESSION_PROVIDER_ADD, Some(wire_params))
9145            .await?;
9146        Ok(serde_json::from_value(_value)?)
9147    }
9148}
9149
9150/// `session.queue.*` RPCs.
9151#[derive(Clone, Copy)]
9152pub struct SessionRpcQueue<'a> {
9153    pub(crate) session: &'a Session,
9154}
9155
9156impl<'a> SessionRpcQueue<'a> {
9157    /// Returns the local session's pending user-facing queued items and steering messages.
9158    ///
9159    /// Wire method: `session.queue.pendingItems`.
9160    ///
9161    /// # Returns
9162    ///
9163    /// Snapshot of the session's pending queued items and immediate-steering messages.
9164    ///
9165    /// <div class="warning">
9166    ///
9167    /// **Experimental.** This API is part of an experimental wire-protocol surface
9168    /// and may change or be removed in future SDK or CLI releases. Pin both the
9169    /// SDK and CLI versions if your code depends on it.
9170    ///
9171    /// </div>
9172    pub async fn pending_items(&self) -> Result<QueuePendingItemsResult, Error> {
9173        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9174        let _value = self
9175            .session
9176            .client()
9177            .call(rpc_methods::SESSION_QUEUE_PENDINGITEMS, Some(wire_params))
9178            .await?;
9179        Ok(serde_json::from_value(_value)?)
9180    }
9181
9182    /// Returns the internal native queue snapshot for in-process session orchestration.
9183    ///
9184    /// Wire method: `session.queue.snapshot`.
9185    ///
9186    /// # Returns
9187    ///
9188    /// Internal snapshot of native queue state for local session orchestration.
9189    ///
9190    /// <div class="warning">
9191    ///
9192    /// **Experimental.** This API is part of an experimental wire-protocol surface
9193    /// and may change or be removed in future SDK or CLI releases. Pin both the
9194    /// SDK and CLI versions if your code depends on it.
9195    ///
9196    /// </div>
9197    pub(crate) async fn snapshot(&self) -> Result<QueueSnapshotResult, Error> {
9198        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9199        let _value = self
9200            .session
9201            .client()
9202            .call(rpc_methods::SESSION_QUEUE_SNAPSHOT, Some(wire_params))
9203            .await?;
9204        Ok(serde_json::from_value(_value)?)
9205    }
9206
9207    /// Moves an addressable queued item to a public visible position.
9208    ///
9209    /// Wire method: `session.queue.moveItem`.
9210    ///
9211    /// # Parameters
9212    ///
9213    /// * `params` - Parameters for moving a queued item by stable id.
9214    ///
9215    /// # Returns
9216    ///
9217    /// Result of moving a queued item.
9218    ///
9219    /// <div class="warning">
9220    ///
9221    /// **Experimental.** This API is part of an experimental wire-protocol surface
9222    /// and may change or be removed in future SDK or CLI releases. Pin both the
9223    /// SDK and CLI versions if your code depends on it.
9224    ///
9225    /// </div>
9226    pub async fn move_item(
9227        &self,
9228        params: QueueMoveItemRequest,
9229    ) -> Result<QueueMoveItemResult, Error> {
9230        let mut wire_params = serde_json::to_value(params)?;
9231        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9232        let _value = self
9233            .session
9234            .client()
9235            .call(rpc_methods::SESSION_QUEUE_MOVEITEM, Some(wire_params))
9236            .await?;
9237        Ok(serde_json::from_value(_value)?)
9238    }
9239
9240    /// Inserts a new queued message at a public visible position.
9241    ///
9242    /// Wire method: `session.queue.insertAt`.
9243    ///
9244    /// # Parameters
9245    ///
9246    /// * `params` - Parameters for inserting a queued message at a public visible position.
9247    ///
9248    /// # Returns
9249    ///
9250    /// Result of inserting a queued message.
9251    ///
9252    /// <div class="warning">
9253    ///
9254    /// **Experimental.** This API is part of an experimental wire-protocol surface
9255    /// and may change or be removed in future SDK or CLI releases. Pin both the
9256    /// SDK and CLI versions if your code depends on it.
9257    ///
9258    /// </div>
9259    pub async fn insert_at(
9260        &self,
9261        params: QueueInsertAtRequest,
9262    ) -> Result<QueueInsertAtResult, Error> {
9263        let mut wire_params = serde_json::to_value(params)?;
9264        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9265        let _value = self
9266            .session
9267            .client()
9268            .call(rpc_methods::SESSION_QUEUE_INSERTAT, Some(wire_params))
9269            .await?;
9270        Ok(serde_json::from_value(_value)?)
9271    }
9272
9273    /// Removes an addressable queued item by its stable id.
9274    ///
9275    /// Wire method: `session.queue.removeAt`.
9276    ///
9277    /// # Parameters
9278    ///
9279    /// * `params` - Parameters for removing a queued item by stable id.
9280    ///
9281    /// # Returns
9282    ///
9283    /// Result of removing a queued item.
9284    ///
9285    /// <div class="warning">
9286    ///
9287    /// **Experimental.** This API is part of an experimental wire-protocol surface
9288    /// and may change or be removed in future SDK or CLI releases. Pin both the
9289    /// SDK and CLI versions if your code depends on it.
9290    ///
9291    /// </div>
9292    pub async fn remove_at(
9293        &self,
9294        params: QueueRemoveAtRequest,
9295    ) -> Result<QueueRemoveAtResult, Error> {
9296        let mut wire_params = serde_json::to_value(params)?;
9297        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9298        let _value = self
9299            .session
9300            .client()
9301            .call(rpc_methods::SESSION_QUEUE_REMOVEAT, Some(wire_params))
9302            .await?;
9303        Ok(serde_json::from_value(_value)?)
9304    }
9305
9306    /// Updates the text of an addressable single-message queue item.
9307    ///
9308    /// Wire method: `session.queue.updateText`.
9309    ///
9310    /// # Parameters
9311    ///
9312    /// * `params` - Parameters for editing a single queued message.
9313    ///
9314    /// # Returns
9315    ///
9316    /// Result of editing a queued message.
9317    ///
9318    /// <div class="warning">
9319    ///
9320    /// **Experimental.** This API is part of an experimental wire-protocol surface
9321    /// and may change or be removed in future SDK or CLI releases. Pin both the
9322    /// SDK and CLI versions if your code depends on it.
9323    ///
9324    /// </div>
9325    pub async fn update_text(
9326        &self,
9327        params: QueueUpdateTextRequest,
9328    ) -> Result<QueueUpdateTextResult, Error> {
9329        let mut wire_params = serde_json::to_value(params)?;
9330        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9331        let _value = self
9332            .session
9333            .client()
9334            .call(rpc_methods::SESSION_QUEUE_UPDATETEXT, Some(wire_params))
9335            .await?;
9336        Ok(serde_json::from_value(_value)?)
9337    }
9338
9339    /// Duplicates an addressable queued item immediately after its source.
9340    ///
9341    /// Wire method: `session.queue.duplicateAt`.
9342    ///
9343    /// # Parameters
9344    ///
9345    /// * `params` - Parameters for duplicating a queued item.
9346    ///
9347    /// # Returns
9348    ///
9349    /// Result of duplicating a queued item.
9350    ///
9351    /// <div class="warning">
9352    ///
9353    /// **Experimental.** This API is part of an experimental wire-protocol surface
9354    /// and may change or be removed in future SDK or CLI releases. Pin both the
9355    /// SDK and CLI versions if your code depends on it.
9356    ///
9357    /// </div>
9358    pub async fn duplicate_at(
9359        &self,
9360        params: QueueDuplicateAtRequest,
9361    ) -> Result<QueueDuplicateAtResult, Error> {
9362        let mut wire_params = serde_json::to_value(params)?;
9363        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9364        let _value = self
9365            .session
9366            .client()
9367            .call(rpc_methods::SESSION_QUEUE_DUPLICATEAT, Some(wire_params))
9368            .await?;
9369        Ok(serde_json::from_value(_value)?)
9370    }
9371
9372    /// Acquires or releases the queued-lane drain pause.
9373    ///
9374    /// Wire method: `session.queue.setDrainPaused`.
9375    ///
9376    /// # Parameters
9377    ///
9378    /// * `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.
9379    ///
9380    /// <div class="warning">
9381    ///
9382    /// **Experimental.** This API is part of an experimental wire-protocol surface
9383    /// and may change or be removed in future SDK or CLI releases. Pin both the
9384    /// SDK and CLI versions if your code depends on it.
9385    ///
9386    /// </div>
9387    pub async fn set_drain_paused(&self, params: QueueSetDrainPausedRequest) -> Result<(), Error> {
9388        let mut wire_params = serde_json::to_value(params)?;
9389        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9390        let _value = self
9391            .session
9392            .client()
9393            .call(rpc_methods::SESSION_QUEUE_SETDRAINPAUSED, Some(wire_params))
9394            .await?;
9395        Ok(())
9396    }
9397
9398    /// Moves an addressable queued message into the live turn's steering lane.
9399    ///
9400    /// Wire method: `session.queue.sendNow`.
9401    ///
9402    /// # Parameters
9403    ///
9404    /// * `params` - Parameters for steering a queued message into a live turn.
9405    ///
9406    /// # Returns
9407    ///
9408    /// Result of trying to steer a queued message into a live turn.
9409    ///
9410    /// <div class="warning">
9411    ///
9412    /// **Experimental.** This API is part of an experimental wire-protocol surface
9413    /// and may change or be removed in future SDK or CLI releases. Pin both the
9414    /// SDK and CLI versions if your code depends on it.
9415    ///
9416    /// </div>
9417    pub async fn send_now(&self, params: QueueSendNowRequest) -> Result<QueueSendNowResult, Error> {
9418        let mut wire_params = serde_json::to_value(params)?;
9419        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9420        let _value = self
9421            .session
9422            .client()
9423            .call(rpc_methods::SESSION_QUEUE_SENDNOW, Some(wire_params))
9424            .await?;
9425        Ok(serde_json::from_value(_value)?)
9426    }
9427
9428    /// Reports whether the local session has native queued work pending.
9429    ///
9430    /// Wire method: `session.queue.hasPending`.
9431    ///
9432    /// # Returns
9433    ///
9434    /// Whether the native queue has pending work.
9435    ///
9436    /// <div class="warning">
9437    ///
9438    /// **Experimental.** This API is part of an experimental wire-protocol surface
9439    /// and may change or be removed in future SDK or CLI releases. Pin both the
9440    /// SDK and CLI versions if your code depends on it.
9441    ///
9442    /// </div>
9443    pub(crate) async fn has_pending(&self) -> Result<QueueHasPendingResult, Error> {
9444        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9445        let _value = self
9446            .session
9447            .client()
9448            .call(rpc_methods::SESSION_QUEUE_HASPENDING, Some(wire_params))
9449            .await?;
9450        Ok(serde_json::from_value(_value)?)
9451    }
9452
9453    /// Begins a native deferred-idle drain when background work has quiesced.
9454    ///
9455    /// Wire method: `session.queue.beginDeferredIdleDrain`.
9456    ///
9457    /// # Parameters
9458    ///
9459    /// * `params` - Inputs for starting a deferred-idle drain.
9460    ///
9461    /// # Returns
9462    ///
9463    /// Whether a deferred-idle drain should run.
9464    ///
9465    /// <div class="warning">
9466    ///
9467    /// **Experimental.** This API is part of an experimental wire-protocol surface
9468    /// and may change or be removed in future SDK or CLI releases. Pin both the
9469    /// SDK and CLI versions if your code depends on it.
9470    ///
9471    /// </div>
9472    pub(crate) async fn begin_deferred_idle_drain(
9473        &self,
9474        params: QueueBeginDeferredIdleDrainRequest,
9475    ) -> Result<QueueBeginDeferredIdleDrainResult, Error> {
9476        let mut wire_params = serde_json::to_value(params)?;
9477        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9478        let _value = self
9479            .session
9480            .client()
9481            .call(
9482                rpc_methods::SESSION_QUEUE_BEGINDEFERREDIDLEDRAIN,
9483                Some(wire_params),
9484            )
9485            .await?;
9486        Ok(serde_json::from_value(_value)?)
9487    }
9488
9489    /// Finishes a native deferred-idle drain and reports whether to drain queue work or emit idle.
9490    ///
9491    /// Wire method: `session.queue.finishDeferredIdleDrain`.
9492    ///
9493    /// # Parameters
9494    ///
9495    /// * `params` - Inputs for completing a deferred-idle drain.
9496    ///
9497    /// # Returns
9498    ///
9499    /// Action selected by the native deferred-idle drain.
9500    ///
9501    /// <div class="warning">
9502    ///
9503    /// **Experimental.** This API is part of an experimental wire-protocol surface
9504    /// and may change or be removed in future SDK or CLI releases. Pin both the
9505    /// SDK and CLI versions if your code depends on it.
9506    ///
9507    /// </div>
9508    pub(crate) async fn finish_deferred_idle_drain(
9509        &self,
9510        params: QueueFinishDeferredIdleDrainRequest,
9511    ) -> Result<QueueFinishDeferredIdleDrainResult, Error> {
9512        let mut wire_params = serde_json::to_value(params)?;
9513        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9514        let _value = self
9515            .session
9516            .client()
9517            .call(
9518                rpc_methods::SESSION_QUEUE_FINISHDEFERREDIDLEDRAIN,
9519                Some(wire_params),
9520            )
9521            .await?;
9522        Ok(serde_json::from_value(_value)?)
9523    }
9524
9525    /// Marks session.idle as deferred by native background work state.
9526    ///
9527    /// Wire method: `session.queue.deferSessionIdle`.
9528    ///
9529    /// # Parameters
9530    ///
9531    /// * `params` - Inputs for marking session.idle deferred in native state.
9532    ///
9533    /// <div class="warning">
9534    ///
9535    /// **Experimental.** This API is part of an experimental wire-protocol surface
9536    /// and may change or be removed in future SDK or CLI releases. Pin both the
9537    /// SDK and CLI versions if your code depends on it.
9538    ///
9539    /// </div>
9540    pub(crate) async fn defer_session_idle(
9541        &self,
9542        params: QueueDeferSessionIdleRequest,
9543    ) -> Result<(), Error> {
9544        let mut wire_params = serde_json::to_value(params)?;
9545        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9546        let _value = self
9547            .session
9548            .client()
9549            .call(
9550                rpc_methods::SESSION_QUEUE_DEFERSESSIONIDLE,
9551                Some(wire_params),
9552            )
9553            .await?;
9554        Ok(())
9555    }
9556
9557    /// Removes the most recently queued user-facing item (LIFO).
9558    ///
9559    /// Wire method: `session.queue.removeMostRecent`.
9560    ///
9561    /// # Returns
9562    ///
9563    /// Indicates whether a user-facing pending item was removed.
9564    ///
9565    /// <div class="warning">
9566    ///
9567    /// **Experimental.** This API is part of an experimental wire-protocol surface
9568    /// and may change or be removed in future SDK or CLI releases. Pin both the
9569    /// SDK and CLI versions if your code depends on it.
9570    ///
9571    /// </div>
9572    pub async fn remove_most_recent(&self) -> Result<QueueRemoveMostRecentResult, Error> {
9573        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9574        let _value = self
9575            .session
9576            .client()
9577            .call(
9578                rpc_methods::SESSION_QUEUE_REMOVEMOSTRECENT,
9579                Some(wire_params),
9580            )
9581            .await?;
9582        Ok(serde_json::from_value(_value)?)
9583    }
9584
9585    /// Clears all pending queued items on the local session.
9586    ///
9587    /// Wire method: `session.queue.clear`.
9588    ///
9589    /// <div class="warning">
9590    ///
9591    /// **Experimental.** This API is part of an experimental wire-protocol surface
9592    /// and may change or be removed in future SDK or CLI releases. Pin both the
9593    /// SDK and CLI versions if your code depends on it.
9594    ///
9595    /// </div>
9596    pub async fn clear(&self) -> Result<(), Error> {
9597        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9598        let _value = self
9599            .session
9600            .client()
9601            .call(rpc_methods::SESSION_QUEUE_CLEAR, Some(wire_params))
9602            .await?;
9603        Ok(())
9604    }
9605
9606    /// Consumes queued native system notifications matching an internal filter.
9607    ///
9608    /// Wire method: `session.queue.consumeSystemNotifications`.
9609    ///
9610    /// # Parameters
9611    ///
9612    /// * `params` - Internal filter for consuming queued system notifications.
9613    ///
9614    /// # Returns
9615    ///
9616    /// Indicates whether a user-facing pending item was removed.
9617    ///
9618    /// <div class="warning">
9619    ///
9620    /// **Experimental.** This API is part of an experimental wire-protocol surface
9621    /// and may change or be removed in future SDK or CLI releases. Pin both the
9622    /// SDK and CLI versions if your code depends on it.
9623    ///
9624    /// </div>
9625    pub(crate) async fn consume_system_notifications(
9626        &self,
9627        params: QueueConsumeSystemNotificationsRequest,
9628    ) -> Result<QueueRemoveMostRecentResult, Error> {
9629        let mut wire_params = serde_json::to_value(params)?;
9630        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9631        let _value = self
9632            .session
9633            .client()
9634            .call(
9635                rpc_methods::SESSION_QUEUE_CONSUMESYSTEMNOTIFICATIONS,
9636                Some(wire_params),
9637            )
9638            .await?;
9639        Ok(serde_json::from_value(_value)?)
9640    }
9641
9642    /// Enqueues the internal resume-pending wake item when orphan handling needs a follow-up turn.
9643    ///
9644    /// Wire method: `session.queue.enqueueResumePending`.
9645    ///
9646    /// # Returns
9647    ///
9648    /// Result of enqueueing the resume-pending wake item.
9649    ///
9650    /// <div class="warning">
9651    ///
9652    /// **Experimental.** This API is part of an experimental wire-protocol surface
9653    /// and may change or be removed in future SDK or CLI releases. Pin both the
9654    /// SDK and CLI versions if your code depends on it.
9655    ///
9656    /// </div>
9657    pub(crate) async fn enqueue_resume_pending(
9658        &self,
9659    ) -> Result<QueueEnqueueResumePendingResult, Error> {
9660        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9661        let _value = self
9662            .session
9663            .client()
9664            .call(
9665                rpc_methods::SESSION_QUEUE_ENQUEUERESUMEPENDING,
9666                Some(wire_params),
9667            )
9668            .await?;
9669        Ok(serde_json::from_value(_value)?)
9670    }
9671
9672    /// Drains the native local-session work queue for in-process session orchestration.
9673    ///
9674    /// Wire method: `session.queue.process`.
9675    ///
9676    /// <div class="warning">
9677    ///
9678    /// **Experimental.** This API is part of an experimental wire-protocol surface
9679    /// and may change or be removed in future SDK or CLI releases. Pin both the
9680    /// SDK and CLI versions if your code depends on it.
9681    ///
9682    /// </div>
9683    pub(crate) async fn process(&self) -> Result<(), Error> {
9684        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9685        let _value = self
9686            .session
9687            .client()
9688            .call(rpc_methods::SESSION_QUEUE_PROCESS, Some(wire_params))
9689            .await?;
9690        Ok(())
9691    }
9692}
9693
9694/// `session.remote.*` RPCs.
9695#[derive(Clone, Copy)]
9696pub struct SessionRpcRemote<'a> {
9697    pub(crate) session: &'a Session,
9698}
9699
9700impl<'a> SessionRpcRemote<'a> {
9701    /// Enables remote session export or steering.
9702    ///
9703    /// Wire method: `session.remote.enable`.
9704    ///
9705    /// # Parameters
9706    ///
9707    /// * `params` - Optional remote session mode ("off", "export", or "on"); defaults to enabling both export and remote steering.
9708    ///
9709    /// # Returns
9710    ///
9711    /// GitHub URL for the session and a flag indicating whether remote steering is enabled.
9712    ///
9713    /// <div class="warning">
9714    ///
9715    /// **Experimental.** This API is part of an experimental wire-protocol surface
9716    /// and may change or be removed in future SDK or CLI releases. Pin both the
9717    /// SDK and CLI versions if your code depends on it.
9718    ///
9719    /// </div>
9720    pub async fn enable(&self, params: RemoteEnableRequest) -> Result<RemoteEnableResult, Error> {
9721        let mut wire_params = serde_json::to_value(params)?;
9722        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9723        let _value = self
9724            .session
9725            .client()
9726            .call(rpc_methods::SESSION_REMOTE_ENABLE, Some(wire_params))
9727            .await?;
9728        Ok(serde_json::from_value(_value)?)
9729    }
9730
9731    /// Disables remote session export and steering.
9732    ///
9733    /// Wire method: `session.remote.disable`.
9734    ///
9735    /// <div class="warning">
9736    ///
9737    /// **Experimental.** This API is part of an experimental wire-protocol surface
9738    /// and may change or be removed in future SDK or CLI releases. Pin both the
9739    /// SDK and CLI versions if your code depends on it.
9740    ///
9741    /// </div>
9742    pub async fn disable(&self) -> Result<(), Error> {
9743        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9744        let _value = self
9745            .session
9746            .client()
9747            .call(rpc_methods::SESSION_REMOTE_DISABLE, Some(wire_params))
9748            .await?;
9749        Ok(())
9750    }
9751
9752    /// Persists a remote-steerability change emitted by the host as a session event.
9753    ///
9754    /// Wire method: `session.remote.notifySteerableChanged`.
9755    ///
9756    /// # Parameters
9757    ///
9758    /// * `params` - New remote-steerability state to persist as a `session.remote_steerable_changed` event.
9759    ///
9760    /// # Returns
9761    ///
9762    /// 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.
9763    ///
9764    /// <div class="warning">
9765    ///
9766    /// **Experimental.** This API is part of an experimental wire-protocol surface
9767    /// and may change or be removed in future SDK or CLI releases. Pin both the
9768    /// SDK and CLI versions if your code depends on it.
9769    ///
9770    /// </div>
9771    pub async fn notify_steerable_changed(
9772        &self,
9773        params: RemoteNotifySteerableChangedRequest,
9774    ) -> Result<RemoteNotifySteerableChangedResult, Error> {
9775        let mut wire_params = serde_json::to_value(params)?;
9776        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9777        let _value = self
9778            .session
9779            .client()
9780            .call(
9781                rpc_methods::SESSION_REMOTE_NOTIFYSTEERABLECHANGED,
9782                Some(wire_params),
9783            )
9784            .await?;
9785        Ok(serde_json::from_value(_value)?)
9786    }
9787}
9788
9789/// `session.sandbox.*` RPCs.
9790#[derive(Clone, Copy)]
9791pub struct SessionRpcSandbox<'a> {
9792    pub(crate) session: &'a Session,
9793}
9794
9795impl<'a> SessionRpcSandbox<'a> {
9796    /// Returns whether managed policy requires sandbox enforcement and whether an enforcement failure has permanently blocked the session.
9797    ///
9798    /// Wire method: `session.sandbox.getEnforcementStatus`.
9799    ///
9800    /// # Returns
9801    ///
9802    /// Managed sandbox enforcement state for a session.
9803    ///
9804    /// <div class="warning">
9805    ///
9806    /// **Experimental.** This API is part of an experimental wire-protocol surface
9807    /// and may change or be removed in future SDK or CLI releases. Pin both the
9808    /// SDK and CLI versions if your code depends on it.
9809    ///
9810    /// </div>
9811    pub async fn get_enforcement_status(&self) -> Result<SandboxEnforcementStatus, Error> {
9812        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9813        let _value = self
9814            .session
9815            .client()
9816            .call(
9817                rpc_methods::SESSION_SANDBOX_GETENFORCEMENTSTATUS,
9818                Some(wire_params),
9819            )
9820            .await?;
9821        Ok(serde_json::from_value(_value)?)
9822    }
9823
9824    /// Disables sandboxing for the remainder of the current session and approves the referenced pending sandbox-bypass permission request. The request is rejected unless the exact request is still pending and the effective sandbox policy permits bypass.
9825    ///
9826    /// Wire method: `session.sandbox.disableForSession`.
9827    ///
9828    /// # Parameters
9829    ///
9830    /// * `params` - Request to disable sandboxing for the current session while resolving an active sandbox-bypass permission prompt.
9831    ///
9832    /// # Returns
9833    ///
9834    /// Result of attempting to disable sandboxing for the current session.
9835    ///
9836    /// <div class="warning">
9837    ///
9838    /// **Experimental.** This API is part of an experimental wire-protocol surface
9839    /// and may change or be removed in future SDK or CLI releases. Pin both the
9840    /// SDK and CLI versions if your code depends on it.
9841    ///
9842    /// </div>
9843    pub async fn disable_for_session(
9844        &self,
9845        params: SandboxDisableForSessionRequest,
9846    ) -> Result<SandboxDisableForSessionResult, Error> {
9847        let mut wire_params = serde_json::to_value(params)?;
9848        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9849        let _value = self
9850            .session
9851            .client()
9852            .call(
9853                rpc_methods::SESSION_SANDBOX_DISABLEFORSESSION,
9854                Some(wire_params),
9855            )
9856            .await?;
9857        Ok(serde_json::from_value(_value)?)
9858    }
9859}
9860
9861/// `session.schedule.*` RPCs.
9862#[derive(Clone, Copy)]
9863pub struct SessionRpcSchedule<'a> {
9864    pub(crate) session: &'a Session,
9865}
9866
9867impl<'a> SessionRpcSchedule<'a> {
9868    /// Lists the session's currently active scheduled prompts.
9869    ///
9870    /// Wire method: `session.schedule.list`.
9871    ///
9872    /// # Returns
9873    ///
9874    /// Snapshot of the currently active recurring prompts for this session.
9875    ///
9876    /// <div class="warning">
9877    ///
9878    /// **Experimental.** This API is part of an experimental wire-protocol surface
9879    /// and may change or be removed in future SDK or CLI releases. Pin both the
9880    /// SDK and CLI versions if your code depends on it.
9881    ///
9882    /// </div>
9883    pub async fn list(&self) -> Result<ScheduleList, Error> {
9884        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9885        let _value = self
9886            .session
9887            .client()
9888            .call(rpc_methods::SESSION_SCHEDULE_LIST, Some(wire_params))
9889            .await?;
9890        Ok(serde_json::from_value(_value)?)
9891    }
9892
9893    /// Hydrates the native schedule registry from persisted session events.
9894    ///
9895    /// Wire method: `session.schedule.hydrate`.
9896    ///
9897    /// <div class="warning">
9898    ///
9899    /// **Experimental.** This API is part of an experimental wire-protocol surface
9900    /// and may change or be removed in future SDK or CLI releases. Pin both the
9901    /// SDK and CLI versions if your code depends on it.
9902    ///
9903    /// </div>
9904    pub(crate) async fn hydrate(&self) -> Result<(), Error> {
9905        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9906        let _value = self
9907            .session
9908            .client()
9909            .call(rpc_methods::SESSION_SCHEDULE_HYDRATE, Some(wire_params))
9910            .await?;
9911        Ok(())
9912    }
9913
9914    /// Reports whether the session has an active self-paced scheduled prompt.
9915    ///
9916    /// Wire method: `session.schedule.hasSelfPaced`.
9917    ///
9918    /// # Returns
9919    ///
9920    /// Whether the session currently has an active self-paced schedule.
9921    ///
9922    /// <div class="warning">
9923    ///
9924    /// **Experimental.** This API is part of an experimental wire-protocol surface
9925    /// and may change or be removed in future SDK or CLI releases. Pin both the
9926    /// SDK and CLI versions if your code depends on it.
9927    ///
9928    /// </div>
9929    pub(crate) async fn has_self_paced(&self) -> Result<ScheduleHasSelfPacedResult, Error> {
9930        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9931        let _value = self
9932            .session
9933            .client()
9934            .call(
9935                rpc_methods::SESSION_SCHEDULE_HASSELFPACED,
9936                Some(wire_params),
9937            )
9938            .await?;
9939        Ok(serde_json::from_value(_value)?)
9940    }
9941
9942    /// Registers a relative-interval scheduled prompt.
9943    ///
9944    /// Wire method: `session.schedule.add`.
9945    ///
9946    /// # Parameters
9947    ///
9948    /// * `params` - Register a relative-interval scheduled prompt.
9949    ///
9950    /// # Returns
9951    ///
9952    /// Result of registering or re-arming a scheduled prompt.
9953    ///
9954    /// <div class="warning">
9955    ///
9956    /// **Experimental.** This API is part of an experimental wire-protocol surface
9957    /// and may change or be removed in future SDK or CLI releases. Pin both the
9958    /// SDK and CLI versions if your code depends on it.
9959    ///
9960    /// </div>
9961    pub(crate) async fn add(&self, params: ScheduleAddRequest) -> Result<ScheduleAddResult, Error> {
9962        let mut wire_params = serde_json::to_value(params)?;
9963        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9964        let _value = self
9965            .session
9966            .client()
9967            .call(rpc_methods::SESSION_SCHEDULE_ADD, Some(wire_params))
9968            .await?;
9969        Ok(serde_json::from_value(_value)?)
9970    }
9971
9972    /// Registers a recurring cron scheduled prompt.
9973    ///
9974    /// Wire method: `session.schedule.addCron`.
9975    ///
9976    /// # Parameters
9977    ///
9978    /// * `params` - Register a cron scheduled prompt.
9979    ///
9980    /// # Returns
9981    ///
9982    /// Result of registering or re-arming a scheduled prompt.
9983    ///
9984    /// <div class="warning">
9985    ///
9986    /// **Experimental.** This API is part of an experimental wire-protocol surface
9987    /// and may change or be removed in future SDK or CLI releases. Pin both the
9988    /// SDK and CLI versions if your code depends on it.
9989    ///
9990    /// </div>
9991    pub(crate) async fn add_cron(
9992        &self,
9993        params: ScheduleAddCronRequest,
9994    ) -> Result<ScheduleAddResult, Error> {
9995        let mut wire_params = serde_json::to_value(params)?;
9996        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9997        let _value = self
9998            .session
9999            .client()
10000            .call(rpc_methods::SESSION_SCHEDULE_ADDCRON, Some(wire_params))
10001            .await?;
10002        Ok(serde_json::from_value(_value)?)
10003    }
10004
10005    /// Registers an absolute-time scheduled prompt.
10006    ///
10007    /// Wire method: `session.schedule.addAt`.
10008    ///
10009    /// # Parameters
10010    ///
10011    /// * `params` - Register an absolute-time scheduled prompt.
10012    ///
10013    /// # Returns
10014    ///
10015    /// Result of registering or re-arming a scheduled prompt.
10016    ///
10017    /// <div class="warning">
10018    ///
10019    /// **Experimental.** This API is part of an experimental wire-protocol surface
10020    /// and may change or be removed in future SDK or CLI releases. Pin both the
10021    /// SDK and CLI versions if your code depends on it.
10022    ///
10023    /// </div>
10024    pub(crate) async fn add_at(
10025        &self,
10026        params: ScheduleAddAtRequest,
10027    ) -> Result<ScheduleAddResult, Error> {
10028        let mut wire_params = serde_json::to_value(params)?;
10029        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10030        let _value = self
10031            .session
10032            .client()
10033            .call(rpc_methods::SESSION_SCHEDULE_ADDAT, Some(wire_params))
10034            .await?;
10035        Ok(serde_json::from_value(_value)?)
10036    }
10037
10038    /// Registers a self-paced scheduled prompt.
10039    ///
10040    /// Wire method: `session.schedule.addSelfPaced`.
10041    ///
10042    /// # Parameters
10043    ///
10044    /// * `params` - Register a self-paced scheduled prompt.
10045    ///
10046    /// # Returns
10047    ///
10048    /// Result of registering or re-arming a scheduled prompt.
10049    ///
10050    /// <div class="warning">
10051    ///
10052    /// **Experimental.** This API is part of an experimental wire-protocol surface
10053    /// and may change or be removed in future SDK or CLI releases. Pin both the
10054    /// SDK and CLI versions if your code depends on it.
10055    ///
10056    /// </div>
10057    pub(crate) async fn add_self_paced(
10058        &self,
10059        params: ScheduleAddSelfPacedRequest,
10060    ) -> Result<ScheduleAddResult, Error> {
10061        let mut wire_params = serde_json::to_value(params)?;
10062        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10063        let _value = self
10064            .session
10065            .client()
10066            .call(
10067                rpc_methods::SESSION_SCHEDULE_ADDSELFPACED,
10068                Some(wire_params),
10069            )
10070            .await?;
10071        Ok(serde_json::from_value(_value)?)
10072    }
10073
10074    /// Re-arms an active self-paced scheduled prompt.
10075    ///
10076    /// Wire method: `session.schedule.rearmSelfPaced`.
10077    ///
10078    /// # Parameters
10079    ///
10080    /// * `params` - Re-arm a self-paced scheduled prompt.
10081    ///
10082    /// # Returns
10083    ///
10084    /// Result of registering or re-arming a scheduled prompt.
10085    ///
10086    /// <div class="warning">
10087    ///
10088    /// **Experimental.** This API is part of an experimental wire-protocol surface
10089    /// and may change or be removed in future SDK or CLI releases. Pin both the
10090    /// SDK and CLI versions if your code depends on it.
10091    ///
10092    /// </div>
10093    pub(crate) async fn rearm_self_paced(
10094        &self,
10095        params: ScheduleRearmSelfPacedRequest,
10096    ) -> Result<ScheduleAddResult, Error> {
10097        let mut wire_params = serde_json::to_value(params)?;
10098        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10099        let _value = self
10100            .session
10101            .client()
10102            .call(
10103                rpc_methods::SESSION_SCHEDULE_REARMSELFPACED,
10104                Some(wire_params),
10105            )
10106            .await?;
10107        Ok(serde_json::from_value(_value)?)
10108    }
10109
10110    /// Removes a scheduled prompt by id.
10111    ///
10112    /// Wire method: `session.schedule.stop`.
10113    ///
10114    /// # Parameters
10115    ///
10116    /// * `params` - Identifier of the scheduled prompt to remove.
10117    ///
10118    /// # Returns
10119    ///
10120    /// Remove a scheduled prompt by id. The result entry is omitted if the id was unknown.
10121    ///
10122    /// <div class="warning">
10123    ///
10124    /// **Experimental.** This API is part of an experimental wire-protocol surface
10125    /// and may change or be removed in future SDK or CLI releases. Pin both the
10126    /// SDK and CLI versions if your code depends on it.
10127    ///
10128    /// </div>
10129    pub async fn stop(&self, params: ScheduleStopRequest) -> Result<ScheduleStopResult, Error> {
10130        let mut wire_params = serde_json::to_value(params)?;
10131        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10132        let _value = self
10133            .session
10134            .client()
10135            .call(rpc_methods::SESSION_SCHEDULE_STOP, Some(wire_params))
10136            .await?;
10137        Ok(serde_json::from_value(_value)?)
10138    }
10139}
10140
10141/// `session.settings.*` RPCs.
10142#[derive(Clone, Copy)]
10143pub struct SessionRpcSettings<'a> {
10144    pub(crate) session: &'a Session,
10145}
10146
10147impl<'a> SessionRpcSettings<'a> {
10148    /// 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.
10149    ///
10150    /// Wire method: `session.settings.snapshot`.
10151    ///
10152    /// # Returns
10153    ///
10154    /// Redacted, serializable view of session runtime settings for SDK boundary consumers. Secrets and raw feature flags are intentionally excluded.
10155    ///
10156    /// <div class="warning">
10157    ///
10158    /// **Experimental.** This API is part of an experimental wire-protocol surface
10159    /// and may change or be removed in future SDK or CLI releases. Pin both the
10160    /// SDK and CLI versions if your code depends on it.
10161    ///
10162    /// </div>
10163    pub(crate) async fn snapshot(&self) -> Result<SessionSettingsSnapshot, Error> {
10164        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10165        let _value = self
10166            .session
10167            .client()
10168            .call(rpc_methods::SESSION_SETTINGS_SNAPSHOT, Some(wire_params))
10169            .await?;
10170        Ok(serde_json::from_value(_value)?)
10171    }
10172
10173    /// 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.
10174    ///
10175    /// Wire method: `session.settings.evaluatePredicate`.
10176    ///
10177    /// # Parameters
10178    ///
10179    /// * `params` - Named Rust-owned settings predicate to evaluate for this session.
10180    ///
10181    /// # Returns
10182    ///
10183    /// Result of evaluating a Rust-owned settings predicate.
10184    ///
10185    /// <div class="warning">
10186    ///
10187    /// **Experimental.** This API is part of an experimental wire-protocol surface
10188    /// and may change or be removed in future SDK or CLI releases. Pin both the
10189    /// SDK and CLI versions if your code depends on it.
10190    ///
10191    /// </div>
10192    pub(crate) async fn evaluate_predicate(
10193        &self,
10194        params: SessionSettingsEvaluatePredicateRequest,
10195    ) -> Result<SessionSettingsEvaluatePredicateResult, Error> {
10196        let mut wire_params = serde_json::to_value(params)?;
10197        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10198        let _value = self
10199            .session
10200            .client()
10201            .call(
10202                rpc_methods::SESSION_SETTINGS_EVALUATEPREDICATE,
10203                Some(wire_params),
10204            )
10205            .await?;
10206        Ok(serde_json::from_value(_value)?)
10207    }
10208}
10209
10210/// `session.shell.*` RPCs.
10211#[derive(Clone, Copy)]
10212pub struct SessionRpcShell<'a> {
10213    pub(crate) session: &'a Session,
10214}
10215
10216impl<'a> SessionRpcShell<'a> {
10217    /// 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.
10218    ///
10219    /// Wire method: `session.shell.exec`.
10220    ///
10221    /// # Parameters
10222    ///
10223    /// * `params` - Shell command to run, with optional working directory and timeout in milliseconds.
10224    ///
10225    /// # Returns
10226    ///
10227    /// Identifier of the spawned process, used to correlate streamed output and exit notifications.
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 exec(&self, params: ShellExecRequest) -> Result<ShellExecResult, Error> {
10237        let mut wire_params = serde_json::to_value(params)?;
10238        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10239        let _value = self
10240            .session
10241            .client()
10242            .call(rpc_methods::SESSION_SHELL_EXEC, Some(wire_params))
10243            .await?;
10244        Ok(serde_json::from_value(_value)?)
10245    }
10246
10247    /// 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.
10248    ///
10249    /// Wire method: `session.shell.kill`.
10250    ///
10251    /// # Parameters
10252    ///
10253    /// * `params` - Identifier of a process previously returned by "shell.exec" and the signal to send.
10254    ///
10255    /// # Returns
10256    ///
10257    /// Indicates whether the signal was delivered; false if the process was unknown or already exited.
10258    ///
10259    /// <div class="warning">
10260    ///
10261    /// **Experimental.** This API is part of an experimental wire-protocol surface
10262    /// and may change or be removed in future SDK or CLI releases. Pin both the
10263    /// SDK and CLI versions if your code depends on it.
10264    ///
10265    /// </div>
10266    pub async fn kill(&self, params: ShellKillRequest) -> Result<ShellKillResult, Error> {
10267        let mut wire_params = serde_json::to_value(params)?;
10268        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10269        let _value = self
10270            .session
10271            .client()
10272            .call(rpc_methods::SESSION_SHELL_KILL, Some(wire_params))
10273            .await?;
10274        Ok(serde_json::from_value(_value)?)
10275    }
10276
10277    /// Executes a user-requested shell command through the session runtime.
10278    ///
10279    /// Wire method: `session.shell.executeUserRequested`.
10280    ///
10281    /// # Parameters
10282    ///
10283    /// * `params` - User-requested shell command and cancellation handle.
10284    ///
10285    /// # Returns
10286    ///
10287    /// Result of a user-requested shell command.
10288    ///
10289    /// <div class="warning">
10290    ///
10291    /// **Experimental.** This API is part of an experimental wire-protocol surface
10292    /// and may change or be removed in future SDK or CLI releases. Pin both the
10293    /// SDK and CLI versions if your code depends on it.
10294    ///
10295    /// </div>
10296    pub async fn execute_user_requested(
10297        &self,
10298        params: ShellExecuteUserRequestedRequest,
10299    ) -> Result<UserRequestedShellCommandResult, Error> {
10300        let mut wire_params = serde_json::to_value(params)?;
10301        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10302        let _value = self
10303            .session
10304            .client()
10305            .call(
10306                rpc_methods::SESSION_SHELL_EXECUTEUSERREQUESTED,
10307                Some(wire_params),
10308            )
10309            .await?;
10310        Ok(serde_json::from_value(_value)?)
10311    }
10312
10313    /// Cancels a user-requested shell command by request ID.
10314    ///
10315    /// Wire method: `session.shell.cancelUserRequested`.
10316    ///
10317    /// # Parameters
10318    ///
10319    /// * `params` - User-requested shell execution cancellation handle.
10320    ///
10321    /// # Returns
10322    ///
10323    /// Cancellation result for a user-requested shell command.
10324    ///
10325    /// <div class="warning">
10326    ///
10327    /// **Experimental.** This API is part of an experimental wire-protocol surface
10328    /// and may change or be removed in future SDK or CLI releases. Pin both the
10329    /// SDK and CLI versions if your code depends on it.
10330    ///
10331    /// </div>
10332    pub async fn cancel_user_requested(
10333        &self,
10334        params: ShellCancelUserRequestedRequest,
10335    ) -> Result<CancelUserRequestedShellCommandResult, Error> {
10336        let mut wire_params = serde_json::to_value(params)?;
10337        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10338        let _value = self
10339            .session
10340            .client()
10341            .call(
10342                rpc_methods::SESSION_SHELL_CANCELUSERREQUESTED,
10343                Some(wire_params),
10344            )
10345            .await?;
10346        Ok(serde_json::from_value(_value)?)
10347    }
10348}
10349
10350/// `session.skills.*` RPCs.
10351#[derive(Clone, Copy)]
10352pub struct SessionRpcSkills<'a> {
10353    pub(crate) session: &'a Session,
10354}
10355
10356impl<'a> SessionRpcSkills<'a> {
10357    /// Lists skills available to the session.
10358    ///
10359    /// Wire method: `session.skills.list`.
10360    ///
10361    /// # Returns
10362    ///
10363    /// Skills available to the session, with their enabled state.
10364    ///
10365    /// <div class="warning">
10366    ///
10367    /// **Experimental.** This API is part of an experimental wire-protocol surface
10368    /// and may change or be removed in future SDK or CLI releases. Pin both the
10369    /// SDK and CLI versions if your code depends on it.
10370    ///
10371    /// </div>
10372    pub async fn list(&self) -> Result<SkillList, Error> {
10373        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10374        let _value = self
10375            .session
10376            .client()
10377            .call(rpc_methods::SESSION_SKILLS_LIST, Some(wire_params))
10378            .await?;
10379        Ok(serde_json::from_value(_value)?)
10380    }
10381
10382    /// Returns the skills that have been invoked during this session.
10383    ///
10384    /// Wire method: `session.skills.getInvoked`.
10385    ///
10386    /// # Returns
10387    ///
10388    /// Skills invoked during this session, ordered by invocation time (most recent last).
10389    ///
10390    /// <div class="warning">
10391    ///
10392    /// **Experimental.** This API is part of an experimental wire-protocol surface
10393    /// and may change or be removed in future SDK or CLI releases. Pin both the
10394    /// SDK and CLI versions if your code depends on it.
10395    ///
10396    /// </div>
10397    pub async fn get_invoked(&self) -> Result<SkillsGetInvokedResult, Error> {
10398        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10399        let _value = self
10400            .session
10401            .client()
10402            .call(rpc_methods::SESSION_SKILLS_GETINVOKED, Some(wire_params))
10403            .await?;
10404        Ok(serde_json::from_value(_value)?)
10405    }
10406
10407    /// Enables a skill for the session.
10408    ///
10409    /// Wire method: `session.skills.enable`.
10410    ///
10411    /// # Parameters
10412    ///
10413    /// * `params` - Name of the skill to enable for the session.
10414    ///
10415    /// <div class="warning">
10416    ///
10417    /// **Experimental.** This API is part of an experimental wire-protocol surface
10418    /// and may change or be removed in future SDK or CLI releases. Pin both the
10419    /// SDK and CLI versions if your code depends on it.
10420    ///
10421    /// </div>
10422    pub async fn enable(&self, params: SkillsEnableRequest) -> Result<(), Error> {
10423        let mut wire_params = serde_json::to_value(params)?;
10424        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10425        let _value = self
10426            .session
10427            .client()
10428            .call(rpc_methods::SESSION_SKILLS_ENABLE, Some(wire_params))
10429            .await?;
10430        Ok(())
10431    }
10432
10433    /// Disables a skill for the session.
10434    ///
10435    /// Wire method: `session.skills.disable`.
10436    ///
10437    /// # Parameters
10438    ///
10439    /// * `params` - Name of the skill to disable for the session.
10440    ///
10441    /// <div class="warning">
10442    ///
10443    /// **Experimental.** This API is part of an experimental wire-protocol surface
10444    /// and may change or be removed in future SDK or CLI releases. Pin both the
10445    /// SDK and CLI versions if your code depends on it.
10446    ///
10447    /// </div>
10448    pub async fn disable(&self, params: SkillsDisableRequest) -> Result<(), Error> {
10449        let mut wire_params = serde_json::to_value(params)?;
10450        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10451        let _value = self
10452            .session
10453            .client()
10454            .call(rpc_methods::SESSION_SKILLS_DISABLE, Some(wire_params))
10455            .await?;
10456        Ok(())
10457    }
10458
10459    /// Reloads skill definitions for the session.
10460    ///
10461    /// Wire method: `session.skills.reload`.
10462    ///
10463    /// # Returns
10464    ///
10465    /// Diagnostics from reloading skill definitions, with warnings and errors as separate lists.
10466    ///
10467    /// <div class="warning">
10468    ///
10469    /// **Experimental.** This API is part of an experimental wire-protocol surface
10470    /// and may change or be removed in future SDK or CLI releases. Pin both the
10471    /// SDK and CLI versions if your code depends on it.
10472    ///
10473    /// </div>
10474    pub async fn reload(&self) -> Result<SkillsLoadDiagnostics, Error> {
10475        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10476        let _value = self
10477            .session
10478            .client()
10479            .call(rpc_methods::SESSION_SKILLS_RELOAD, Some(wire_params))
10480            .await?;
10481        Ok(serde_json::from_value(_value)?)
10482    }
10483
10484    /// Ensures the session's skill definitions have been loaded from disk.
10485    ///
10486    /// Wire method: `session.skills.ensureLoaded`.
10487    ///
10488    /// <div class="warning">
10489    ///
10490    /// **Experimental.** This API is part of an experimental wire-protocol surface
10491    /// and may change or be removed in future SDK or CLI releases. Pin both the
10492    /// SDK and CLI versions if your code depends on it.
10493    ///
10494    /// </div>
10495    pub async fn ensure_loaded(&self) -> Result<(), Error> {
10496        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10497        let _value = self
10498            .session
10499            .client()
10500            .call(rpc_methods::SESSION_SKILLS_ENSURELOADED, Some(wire_params))
10501            .await?;
10502        Ok(())
10503    }
10504}
10505
10506/// `session.tasks.*` RPCs.
10507#[derive(Clone, Copy)]
10508pub struct SessionRpcTasks<'a> {
10509    pub(crate) session: &'a Session,
10510}
10511
10512impl<'a> SessionRpcTasks<'a> {
10513    /// Starts a background agent task in the session.
10514    ///
10515    /// Wire method: `session.tasks.startAgent`.
10516    ///
10517    /// # Parameters
10518    ///
10519    /// * `params` - Agent type, prompt, name, and optional description and model override for the new task.
10520    ///
10521    /// # Returns
10522    ///
10523    /// Identifier assigned to the newly started background agent task.
10524    ///
10525    /// <div class="warning">
10526    ///
10527    /// **Experimental.** This API is part of an experimental wire-protocol surface
10528    /// and may change or be removed in future SDK or CLI releases. Pin both the
10529    /// SDK and CLI versions if your code depends on it.
10530    ///
10531    /// </div>
10532    pub async fn start_agent(
10533        &self,
10534        params: TasksStartAgentRequest,
10535    ) -> Result<TasksStartAgentResult, Error> {
10536        let mut wire_params = serde_json::to_value(params)?;
10537        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10538        let _value = self
10539            .session
10540            .client()
10541            .call(rpc_methods::SESSION_TASKS_STARTAGENT, Some(wire_params))
10542            .await?;
10543        Ok(serde_json::from_value(_value)?)
10544    }
10545
10546    /// Lists background tasks tracked by the session.
10547    ///
10548    /// Wire method: `session.tasks.list`.
10549    ///
10550    /// # Returns
10551    ///
10552    /// Background tasks currently tracked by the session.
10553    ///
10554    /// <div class="warning">
10555    ///
10556    /// **Experimental.** This API is part of an experimental wire-protocol surface
10557    /// and may change or be removed in future SDK or CLI releases. Pin both the
10558    /// SDK and CLI versions if your code depends on it.
10559    ///
10560    /// </div>
10561    pub async fn list(&self) -> Result<TaskList, Error> {
10562        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10563        let _value = self
10564            .session
10565            .client()
10566            .call(rpc_methods::SESSION_TASKS_LIST, Some(wire_params))
10567            .await?;
10568        Ok(serde_json::from_value(_value)?)
10569    }
10570
10571    /// Registers a client-owned task, or reclaims an orphaned task belonging to the same extension principal.
10572    ///
10573    /// Wire method: `session.tasks.register`.
10574    ///
10575    /// # Parameters
10576    ///
10577    /// * `params` - Registers or reclaims a client-owned task.
10578    ///
10579    /// # Returns
10580    ///
10581    /// Result of registering or reclaiming a client-owned task.
10582    ///
10583    /// <div class="warning">
10584    ///
10585    /// **Experimental.** This API is part of an experimental wire-protocol surface
10586    /// and may change or be removed in future SDK or CLI releases. Pin both the
10587    /// SDK and CLI versions if your code depends on it.
10588    ///
10589    /// </div>
10590    pub async fn register(
10591        &self,
10592        params: TasksRegisterRequest,
10593    ) -> Result<TasksRegisterResult, Error> {
10594        let mut wire_params = serde_json::to_value(params)?;
10595        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10596        let _value = self
10597            .session
10598            .client()
10599            .call(rpc_methods::SESSION_TASKS_REGISTER, Some(wire_params))
10600            .await?;
10601        Ok(serde_json::from_value(_value)?)
10602    }
10603
10604    /// Publishes generic progress or a terminal outcome for a client-owned task.
10605    ///
10606    /// Wire method: `session.tasks.update`.
10607    ///
10608    /// # Parameters
10609    ///
10610    /// * `params` - Updates a client-owned task.
10611    ///
10612    /// # Returns
10613    ///
10614    /// Result of publishing a client-owned task update.
10615    ///
10616    /// <div class="warning">
10617    ///
10618    /// **Experimental.** This API is part of an experimental wire-protocol surface
10619    /// and may change or be removed in future SDK or CLI releases. Pin both the
10620    /// SDK and CLI versions if your code depends on it.
10621    ///
10622    /// </div>
10623    pub async fn update(&self, params: TasksUpdateRequest) -> Result<TasksUpdateResult, Error> {
10624        let mut wire_params = serde_json::to_value(params)?;
10625        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10626        let _value = self
10627            .session
10628            .client()
10629            .call(rpc_methods::SESSION_TASKS_UPDATE, Some(wire_params))
10630            .await?;
10631        Ok(serde_json::from_value(_value)?)
10632    }
10633
10634    /// Refreshes metadata for any detached background shells the runtime knows about.
10635    ///
10636    /// Wire method: `session.tasks.refresh`.
10637    ///
10638    /// # Returns
10639    ///
10640    /// 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.
10641    ///
10642    /// <div class="warning">
10643    ///
10644    /// **Experimental.** This API is part of an experimental wire-protocol surface
10645    /// and may change or be removed in future SDK or CLI releases. Pin both the
10646    /// SDK and CLI versions if your code depends on it.
10647    ///
10648    /// </div>
10649    pub async fn refresh(&self) -> Result<TasksRefreshResult, Error> {
10650        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10651        let _value = self
10652            .session
10653            .client()
10654            .call(rpc_methods::SESSION_TASKS_REFRESH, Some(wire_params))
10655            .await?;
10656        Ok(serde_json::from_value(_value)?)
10657    }
10658
10659    /// Waits for all in-flight background tasks and any follow-up turns to settle.
10660    ///
10661    /// Wire method: `session.tasks.waitForPending`.
10662    ///
10663    /// # Returns
10664    ///
10665    /// 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).
10666    ///
10667    /// <div class="warning">
10668    ///
10669    /// **Experimental.** This API is part of an experimental wire-protocol surface
10670    /// and may change or be removed in future SDK or CLI releases. Pin both the
10671    /// SDK and CLI versions if your code depends on it.
10672    ///
10673    /// </div>
10674    pub async fn wait_for_pending(&self) -> Result<TasksWaitForPendingResult, Error> {
10675        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10676        let _value = self
10677            .session
10678            .client()
10679            .call(rpc_methods::SESSION_TASKS_WAITFORPENDING, Some(wire_params))
10680            .await?;
10681        Ok(serde_json::from_value(_value)?)
10682    }
10683
10684    /// Returns progress information for a background task by ID.
10685    ///
10686    /// Wire method: `session.tasks.getProgress`.
10687    ///
10688    /// # Parameters
10689    ///
10690    /// * `params` - Identifier of the background task to fetch progress for.
10691    ///
10692    /// # Returns
10693    ///
10694    /// Progress information for the task, or null when no task with that ID is tracked.
10695    ///
10696    /// <div class="warning">
10697    ///
10698    /// **Experimental.** This API is part of an experimental wire-protocol surface
10699    /// and may change or be removed in future SDK or CLI releases. Pin both the
10700    /// SDK and CLI versions if your code depends on it.
10701    ///
10702    /// </div>
10703    pub async fn get_progress(
10704        &self,
10705        params: TasksGetProgressRequest,
10706    ) -> Result<TasksGetProgressResult, Error> {
10707        let mut wire_params = serde_json::to_value(params)?;
10708        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10709        let _value = self
10710            .session
10711            .client()
10712            .call(rpc_methods::SESSION_TASKS_GETPROGRESS, Some(wire_params))
10713            .await?;
10714        Ok(serde_json::from_value(_value)?)
10715    }
10716
10717    /// Returns the first sync-waiting task that can currently be promoted to background mode.
10718    ///
10719    /// Wire method: `session.tasks.getCurrentPromotable`.
10720    ///
10721    /// # Returns
10722    ///
10723    /// The first sync-waiting task that can currently be promoted to background mode.
10724    ///
10725    /// <div class="warning">
10726    ///
10727    /// **Experimental.** This API is part of an experimental wire-protocol surface
10728    /// and may change or be removed in future SDK or CLI releases. Pin both the
10729    /// SDK and CLI versions if your code depends on it.
10730    ///
10731    /// </div>
10732    pub async fn get_current_promotable(&self) -> Result<TasksGetCurrentPromotableResult, Error> {
10733        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10734        let _value = self
10735            .session
10736            .client()
10737            .call(
10738                rpc_methods::SESSION_TASKS_GETCURRENTPROMOTABLE,
10739                Some(wire_params),
10740            )
10741            .await?;
10742        Ok(serde_json::from_value(_value)?)
10743    }
10744
10745    /// Promotes an eligible synchronously-waited task so it continues running in the background.
10746    ///
10747    /// Wire method: `session.tasks.promoteToBackground`.
10748    ///
10749    /// # Parameters
10750    ///
10751    /// * `params` - Identifier of the task to promote to background mode.
10752    ///
10753    /// # Returns
10754    ///
10755    /// Indicates whether the task was successfully promoted to background mode.
10756    ///
10757    /// <div class="warning">
10758    ///
10759    /// **Experimental.** This API is part of an experimental wire-protocol surface
10760    /// and may change or be removed in future SDK or CLI releases. Pin both the
10761    /// SDK and CLI versions if your code depends on it.
10762    ///
10763    /// </div>
10764    pub async fn promote_to_background(
10765        &self,
10766        params: TasksPromoteToBackgroundRequest,
10767    ) -> Result<TasksPromoteToBackgroundResult, Error> {
10768        let mut wire_params = serde_json::to_value(params)?;
10769        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10770        let _value = self
10771            .session
10772            .client()
10773            .call(
10774                rpc_methods::SESSION_TASKS_PROMOTETOBACKGROUND,
10775                Some(wire_params),
10776            )
10777            .await?;
10778        Ok(serde_json::from_value(_value)?)
10779    }
10780
10781    /// Atomically promotes the first promotable sync-waiting task to background mode and returns it.
10782    ///
10783    /// Wire method: `session.tasks.promoteCurrentToBackground`.
10784    ///
10785    /// # Returns
10786    ///
10787    /// The promoted task as it now exists in background mode, omitted if no promotable task was waiting.
10788    ///
10789    /// <div class="warning">
10790    ///
10791    /// **Experimental.** This API is part of an experimental wire-protocol surface
10792    /// and may change or be removed in future SDK or CLI releases. Pin both the
10793    /// SDK and CLI versions if your code depends on it.
10794    ///
10795    /// </div>
10796    pub async fn promote_current_to_background(
10797        &self,
10798    ) -> Result<TasksPromoteCurrentToBackgroundResult, Error> {
10799        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10800        let _value = self
10801            .session
10802            .client()
10803            .call(
10804                rpc_methods::SESSION_TASKS_PROMOTECURRENTTOBACKGROUND,
10805                Some(wire_params),
10806            )
10807            .await?;
10808        Ok(serde_json::from_value(_value)?)
10809    }
10810
10811    /// Cancels a background task.
10812    ///
10813    /// Wire method: `session.tasks.cancel`.
10814    ///
10815    /// # Parameters
10816    ///
10817    /// * `params` - Identifier of the background task to cancel.
10818    ///
10819    /// # Returns
10820    ///
10821    /// Indicates whether the background task was successfully cancelled.
10822    ///
10823    /// <div class="warning">
10824    ///
10825    /// **Experimental.** This API is part of an experimental wire-protocol surface
10826    /// and may change or be removed in future SDK or CLI releases. Pin both the
10827    /// SDK and CLI versions if your code depends on it.
10828    ///
10829    /// </div>
10830    pub async fn cancel(&self, params: TasksCancelRequest) -> Result<TasksCancelResult, Error> {
10831        let mut wire_params = serde_json::to_value(params)?;
10832        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10833        let _value = self
10834            .session
10835            .client()
10836            .call(rpc_methods::SESSION_TASKS_CANCEL, Some(wire_params))
10837            .await?;
10838        Ok(serde_json::from_value(_value)?)
10839    }
10840
10841    /// Removes a completed or cancelled background task from tracking.
10842    ///
10843    /// Wire method: `session.tasks.remove`.
10844    ///
10845    /// # Parameters
10846    ///
10847    /// * `params` - Identifier of the completed or cancelled task to remove from tracking.
10848    ///
10849    /// # Returns
10850    ///
10851    /// Indicates whether the task was removed. False when the task does not exist or is still running/idle.
10852    ///
10853    /// <div class="warning">
10854    ///
10855    /// **Experimental.** This API is part of an experimental wire-protocol surface
10856    /// and may change or be removed in future SDK or CLI releases. Pin both the
10857    /// SDK and CLI versions if your code depends on it.
10858    ///
10859    /// </div>
10860    pub async fn remove(&self, params: TasksRemoveRequest) -> Result<TasksRemoveResult, Error> {
10861        let mut wire_params = serde_json::to_value(params)?;
10862        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10863        let _value = self
10864            .session
10865            .client()
10866            .call(rpc_methods::SESSION_TASKS_REMOVE, Some(wire_params))
10867            .await?;
10868        Ok(serde_json::from_value(_value)?)
10869    }
10870
10871    /// Sends a message to a background agent task.
10872    ///
10873    /// Wire method: `session.tasks.sendMessage`.
10874    ///
10875    /// # Parameters
10876    ///
10877    /// * `params` - Identifier of the target agent task, message content, and optional sender agent ID.
10878    ///
10879    /// # Returns
10880    ///
10881    /// Indicates whether the message was delivered, with an error message when delivery failed.
10882    ///
10883    /// <div class="warning">
10884    ///
10885    /// **Experimental.** This API is part of an experimental wire-protocol surface
10886    /// and may change or be removed in future SDK or CLI releases. Pin both the
10887    /// SDK and CLI versions if your code depends on it.
10888    ///
10889    /// </div>
10890    pub async fn send_message(
10891        &self,
10892        params: TasksSendMessageRequest,
10893    ) -> Result<TasksSendMessageResult, Error> {
10894        let mut wire_params = serde_json::to_value(params)?;
10895        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10896        let _value = self
10897            .session
10898            .client()
10899            .call(rpc_methods::SESSION_TASKS_SENDMESSAGE, Some(wire_params))
10900            .await?;
10901        Ok(serde_json::from_value(_value)?)
10902    }
10903}
10904
10905/// `session.telemetry.*` RPCs.
10906#[derive(Clone, Copy)]
10907pub struct SessionRpcTelemetry<'a> {
10908    pub(crate) session: &'a Session,
10909}
10910
10911impl<'a> SessionRpcTelemetry<'a> {
10912    /// Gets the telemetry engagement ID currently associated with the session, when available.
10913    ///
10914    /// Wire method: `session.telemetry.getEngagementId`.
10915    ///
10916    /// # Returns
10917    ///
10918    /// Telemetry engagement ID for the session, when available.
10919    ///
10920    /// <div class="warning">
10921    ///
10922    /// **Experimental.** This API is part of an experimental wire-protocol surface
10923    /// and may change or be removed in future SDK or CLI releases. Pin both the
10924    /// SDK and CLI versions if your code depends on it.
10925    ///
10926    /// </div>
10927    pub async fn get_engagement_id(&self) -> Result<SessionTelemetryEngagement, Error> {
10928        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10929        let _value = self
10930            .session
10931            .client()
10932            .call(
10933                rpc_methods::SESSION_TELEMETRY_GETENGAGEMENTID,
10934                Some(wire_params),
10935            )
10936            .await?;
10937        Ok(serde_json::from_value(_value)?)
10938    }
10939
10940    /// Sets feature override key/value pairs to attach to subsequent telemetry events for the session.
10941    ///
10942    /// Wire method: `session.telemetry.setFeatureOverrides`.
10943    ///
10944    /// # Parameters
10945    ///
10946    /// * `params` - Feature override key/value pairs to attach to subsequent telemetry events from this session.
10947    ///
10948    /// <div class="warning">
10949    ///
10950    /// **Experimental.** This API is part of an experimental wire-protocol surface
10951    /// and may change or be removed in future SDK or CLI releases. Pin both the
10952    /// SDK and CLI versions if your code depends on it.
10953    ///
10954    /// </div>
10955    pub async fn set_feature_overrides(
10956        &self,
10957        params: TelemetrySetFeatureOverridesRequest,
10958    ) -> Result<(), Error> {
10959        let mut wire_params = serde_json::to_value(params)?;
10960        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10961        let _value = self
10962            .session
10963            .client()
10964            .call(
10965                rpc_methods::SESSION_TELEMETRY_SETFEATUREOVERRIDES,
10966                Some(wire_params),
10967            )
10968            .await?;
10969        Ok(())
10970    }
10971}
10972
10973/// `session.tools.*` RPCs.
10974#[derive(Clone, Copy)]
10975pub struct SessionRpcTools<'a> {
10976    pub(crate) session: &'a Session,
10977}
10978
10979impl<'a> SessionRpcTools<'a> {
10980    /// Executes one tool from the session's currently offered tool set through the native invocation pipeline.
10981    ///
10982    /// Wire method: `session.tools.execute`.
10983    ///
10984    /// # Parameters
10985    ///
10986    /// * `params` - A tool name and arguments to execute through the session's native invocation pipeline.
10987    ///
10988    /// # Returns
10989    ///
10990    /// Canonical result returned by a session tool.
10991    ///
10992    /// <div class="warning">
10993    ///
10994    /// **Experimental.** This API is part of an experimental wire-protocol surface
10995    /// and may change or be removed in future SDK or CLI releases. Pin both the
10996    /// SDK and CLI versions if your code depends on it.
10997    ///
10998    /// </div>
10999    pub async fn execute(&self, params: ToolsExecuteRequest) -> Result<ToolResult, Error> {
11000        let mut wire_params = serde_json::to_value(params)?;
11001        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11002        let _value = self
11003            .session
11004            .client()
11005            .call(rpc_methods::SESSION_TOOLS_EXECUTE, Some(wire_params))
11006            .await?;
11007        Ok(serde_json::from_value(_value)?)
11008    }
11009
11010    /// Returns the Rust-owned built-in tool descriptors used to construct the session's offered tool set.
11011    ///
11012    /// Wire method: `session.tools.getBuiltinDescriptors`.
11013    ///
11014    /// # Parameters
11015    ///
11016    /// * `params` - Options controlling how Rust-owned built-in tool descriptors are materialized.
11017    ///
11018    /// # Returns
11019    ///
11020    /// Rust-owned built-in tool descriptors for the session.
11021    ///
11022    /// <div class="warning">
11023    ///
11024    /// **Experimental.** This API is part of an experimental wire-protocol surface
11025    /// and may change or be removed in future SDK or CLI releases. Pin both the
11026    /// SDK and CLI versions if your code depends on it.
11027    ///
11028    /// </div>
11029    pub async fn get_builtin_descriptors(
11030        &self,
11031        params: ToolsGetBuiltinDescriptorsRequest,
11032    ) -> Result<ToolsGetBuiltinDescriptorsResult, Error> {
11033        let mut wire_params = serde_json::to_value(params)?;
11034        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11035        let _value = self
11036            .session
11037            .client()
11038            .call(
11039                rpc_methods::SESSION_TOOLS_GETBUILTINDESCRIPTORS,
11040                Some(wire_params),
11041            )
11042            .await?;
11043        Ok(serde_json::from_value(_value)?)
11044    }
11045
11046    /// Projects a completed task_complete tool call into its label-safe session event payload.
11047    ///
11048    /// Wire method: `session.tools.taskCompleteEventData`.
11049    ///
11050    /// # Parameters
11051    ///
11052    /// * `params` - Task-completion tool arguments and final result used to build a label-safe session event payload.
11053    ///
11054    /// # Returns
11055    ///
11056    /// Task completion notification with summary from the agent
11057    ///
11058    /// <div class="warning">
11059    ///
11060    /// **Experimental.** This API is part of an experimental wire-protocol surface
11061    /// and may change or be removed in future SDK or CLI releases. Pin both the
11062    /// SDK and CLI versions if your code depends on it.
11063    ///
11064    /// </div>
11065    pub async fn task_complete_event_data(
11066        &self,
11067        params: ToolsTaskCompleteEventDataRequest,
11068    ) -> Result<TaskCompleteData, Error> {
11069        let mut wire_params = serde_json::to_value(params)?;
11070        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11071        let _value = self
11072            .session
11073            .client()
11074            .call(
11075                rpc_methods::SESSION_TOOLS_TASKCOMPLETEEVENTDATA,
11076                Some(wire_params),
11077            )
11078            .await?;
11079        Ok(serde_json::from_value(_value)?)
11080    }
11081
11082    /// Provides the result for a pending external tool call.
11083    ///
11084    /// Wire method: `session.tools.handlePendingToolCall`.
11085    ///
11086    /// # Parameters
11087    ///
11088    /// * `params` - Pending external tool call request ID, with the tool result or an error describing why it failed.
11089    ///
11090    /// # Returns
11091    ///
11092    /// Indicates whether the external tool call result was handled successfully.
11093    ///
11094    /// <div class="warning">
11095    ///
11096    /// **Experimental.** This API is part of an experimental wire-protocol surface
11097    /// and may change or be removed in future SDK or CLI releases. Pin both the
11098    /// SDK and CLI versions if your code depends on it.
11099    ///
11100    /// </div>
11101    pub async fn handle_pending_tool_call(
11102        &self,
11103        params: HandlePendingToolCallRequest,
11104    ) -> Result<HandlePendingToolCallResult, Error> {
11105        let mut wire_params = serde_json::to_value(params)?;
11106        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11107        let _value = self
11108            .session
11109            .client()
11110            .call(
11111                rpc_methods::SESSION_TOOLS_HANDLEPENDINGTOOLCALL,
11112                Some(wire_params),
11113            )
11114            .await?;
11115        Ok(serde_json::from_value(_value)?)
11116    }
11117
11118    /// Resolves, builds, and validates the runtime tool list for the session.
11119    ///
11120    /// Wire method: `session.tools.initializeAndValidate`.
11121    ///
11122    /// # Returns
11123    ///
11124    /// 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.
11125    ///
11126    /// <div class="warning">
11127    ///
11128    /// **Experimental.** This API is part of an experimental wire-protocol surface
11129    /// and may change or be removed in future SDK or CLI releases. Pin both the
11130    /// SDK and CLI versions if your code depends on it.
11131    ///
11132    /// </div>
11133    pub async fn initialize_and_validate(&self) -> Result<ToolsInitializeAndValidateResult, Error> {
11134        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
11135        let _value = self
11136            .session
11137            .client()
11138            .call(
11139                rpc_methods::SESSION_TOOLS_INITIALIZEANDVALIDATE,
11140                Some(wire_params),
11141            )
11142            .await?;
11143        Ok(serde_json::from_value(_value)?)
11144    }
11145
11146    /// Returns lightweight metadata for the session's currently initialized tools.
11147    ///
11148    /// Wire method: `session.tools.getCurrentMetadata`.
11149    ///
11150    /// # Returns
11151    ///
11152    /// Current lightweight tool metadata snapshot for the session.
11153    ///
11154    /// <div class="warning">
11155    ///
11156    /// **Experimental.** This API is part of an experimental wire-protocol surface
11157    /// and may change or be removed in future SDK or CLI releases. Pin both the
11158    /// SDK and CLI versions if your code depends on it.
11159    ///
11160    /// </div>
11161    pub async fn get_current_metadata(&self) -> Result<ToolsGetCurrentMetadataResult, Error> {
11162        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
11163        let _value = self
11164            .session
11165            .client()
11166            .call(
11167                rpc_methods::SESSION_TOOLS_GETCURRENTMETADATA,
11168                Some(wire_params),
11169            )
11170            .await?;
11171        Ok(serde_json::from_value(_value)?)
11172    }
11173
11174    /// 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.
11175    ///
11176    /// Wire method: `session.tools.set`.
11177    ///
11178    /// # Parameters
11179    ///
11180    /// * `params` - Complete externally implemented tool list for the calling connection. An empty list removes every tool previously supplied by that connection.
11181    ///
11182    /// # Returns
11183    ///
11184    /// Empty result after replacing the calling connection's externally implemented tools.
11185    ///
11186    /// <div class="warning">
11187    ///
11188    /// **Experimental.** This API is part of an experimental wire-protocol surface
11189    /// and may change or be removed in future SDK or CLI releases. Pin both the
11190    /// SDK and CLI versions if your code depends on it.
11191    ///
11192    /// </div>
11193    pub async fn set(&self, params: ToolsSetRequest) -> Result<ToolsSetResult, Error> {
11194        let mut wire_params = serde_json::to_value(params)?;
11195        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11196        let _value = self
11197            .session
11198            .client()
11199            .call(rpc_methods::SESSION_TOOLS_SET, Some(wire_params))
11200            .await?;
11201        Ok(serde_json::from_value(_value)?)
11202    }
11203
11204    /// Sets the current session's live subagent settings override, which takes precedence over persisted user settings until cleared. Persisted user settings remain the source of truth for future sessions.
11205    ///
11206    /// Wire method: `session.tools.updateSubagentSettings`.
11207    ///
11208    /// # Parameters
11209    ///
11210    /// * `params` - Subagent settings to apply to the current session
11211    ///
11212    /// # Returns
11213    ///
11214    /// Empty result after applying subagent settings
11215    ///
11216    /// <div class="warning">
11217    ///
11218    /// **Experimental.** This API is part of an experimental wire-protocol surface
11219    /// and may change or be removed in future SDK or CLI releases. Pin both the
11220    /// SDK and CLI versions if your code depends on it.
11221    ///
11222    /// </div>
11223    pub async fn update_subagent_settings(
11224        &self,
11225        params: UpdateSubagentSettingsRequest,
11226    ) -> Result<ToolsUpdateSubagentSettingsResult, Error> {
11227        let mut wire_params = serde_json::to_value(params)?;
11228        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11229        let _value = self
11230            .session
11231            .client()
11232            .call(
11233                rpc_methods::SESSION_TOOLS_UPDATESUBAGENTSETTINGS,
11234                Some(wire_params),
11235            )
11236            .await?;
11237        Ok(serde_json::from_value(_value)?)
11238    }
11239}
11240
11241/// `session.ui.*` RPCs.
11242#[derive(Clone, Copy)]
11243pub struct SessionRpcUi<'a> {
11244    pub(crate) session: &'a Session,
11245}
11246
11247impl<'a> SessionRpcUi<'a> {
11248    /// Runs a transient no-tools model query against the current conversation context.
11249    ///
11250    /// Wire method: `session.ui.ephemeralQuery`.
11251    ///
11252    /// # Parameters
11253    ///
11254    /// * `params` - Transient question to answer without adding it to conversation history.
11255    ///
11256    /// # Returns
11257    ///
11258    /// Completed transient query. Ordered chunks and the terminal outcome are also delivered through `ui.ephemeral_query` session events while it runs.
11259    ///
11260    /// <div class="warning">
11261    ///
11262    /// **Experimental.** This API is part of an experimental wire-protocol surface
11263    /// and may change or be removed in future SDK or CLI releases. Pin both the
11264    /// SDK and CLI versions if your code depends on it.
11265    ///
11266    /// </div>
11267    pub async fn ephemeral_query(
11268        &self,
11269        params: UIEphemeralQueryRequest,
11270    ) -> Result<UIEphemeralQueryResult, Error> {
11271        let mut wire_params = serde_json::to_value(params)?;
11272        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11273        let _value = self
11274            .session
11275            .client()
11276            .call(rpc_methods::SESSION_UI_EPHEMERALQUERY, Some(wire_params))
11277            .await?;
11278        Ok(serde_json::from_value(_value)?)
11279    }
11280
11281    /// Requests structured input from a UI-capable client.
11282    ///
11283    /// Wire method: `session.ui.elicitation`.
11284    ///
11285    /// # Parameters
11286    ///
11287    /// * `params` - Prompt message and JSON schema describing the form fields to elicit from the user.
11288    ///
11289    /// # Returns
11290    ///
11291    /// The elicitation response (accept with form values, decline, or cancel)
11292    ///
11293    /// <div class="warning">
11294    ///
11295    /// **Experimental.** This API is part of an experimental wire-protocol surface
11296    /// and may change or be removed in future SDK or CLI releases. Pin both the
11297    /// SDK and CLI versions if your code depends on it.
11298    ///
11299    /// </div>
11300    pub async fn elicitation(
11301        &self,
11302        params: UIElicitationRequest,
11303    ) -> Result<UIElicitationResponse, Error> {
11304        let mut wire_params = serde_json::to_value(params)?;
11305        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11306        let _value = self
11307            .session
11308            .client()
11309            .call(rpc_methods::SESSION_UI_ELICITATION, Some(wire_params))
11310            .await?;
11311        Ok(serde_json::from_value(_value)?)
11312    }
11313
11314    /// Provides the user response for a pending elicitation request.
11315    ///
11316    /// Wire method: `session.ui.handlePendingElicitation`.
11317    ///
11318    /// # Parameters
11319    ///
11320    /// * `params` - Pending elicitation request ID and the user's response (accept/decline/cancel + form values).
11321    ///
11322    /// # Returns
11323    ///
11324    /// Indicates whether the elicitation response was accepted; false if it was already resolved by another client.
11325    ///
11326    /// <div class="warning">
11327    ///
11328    /// **Experimental.** This API is part of an experimental wire-protocol surface
11329    /// and may change or be removed in future SDK or CLI releases. Pin both the
11330    /// SDK and CLI versions if your code depends on it.
11331    ///
11332    /// </div>
11333    pub async fn handle_pending_elicitation(
11334        &self,
11335        params: UIHandlePendingElicitationRequest,
11336    ) -> Result<UIElicitationResult, Error> {
11337        let mut wire_params = serde_json::to_value(params)?;
11338        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11339        let _value = self
11340            .session
11341            .client()
11342            .call(
11343                rpc_methods::SESSION_UI_HANDLEPENDINGELICITATION,
11344                Some(wire_params),
11345            )
11346            .await?;
11347        Ok(serde_json::from_value(_value)?)
11348    }
11349
11350    /// Resolves a pending `user_input.requested` event with the user's response.
11351    ///
11352    /// Wire method: `session.ui.handlePendingUserInput`.
11353    ///
11354    /// # Parameters
11355    ///
11356    /// * `params` - Request ID of a pending `user_input.requested` event and the user's response.
11357    ///
11358    /// # Returns
11359    ///
11360    /// Indicates whether the pending UI request was resolved by this call.
11361    ///
11362    /// <div class="warning">
11363    ///
11364    /// **Experimental.** This API is part of an experimental wire-protocol surface
11365    /// and may change or be removed in future SDK or CLI releases. Pin both the
11366    /// SDK and CLI versions if your code depends on it.
11367    ///
11368    /// </div>
11369    pub async fn handle_pending_user_input(
11370        &self,
11371        params: UIHandlePendingUserInputRequest,
11372    ) -> Result<UIHandlePendingResult, Error> {
11373        let mut wire_params = serde_json::to_value(params)?;
11374        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11375        let _value = self
11376            .session
11377            .client()
11378            .call(
11379                rpc_methods::SESSION_UI_HANDLEPENDINGUSERINPUT,
11380                Some(wire_params),
11381            )
11382            .await?;
11383        Ok(serde_json::from_value(_value)?)
11384    }
11385
11386    /// Resolves a pending `sampling.requested` event with a sampling result, or rejects it.
11387    ///
11388    /// Wire method: `session.ui.handlePendingSampling`.
11389    ///
11390    /// # Parameters
11391    ///
11392    /// * `params` - Request ID of a pending `sampling.requested` event and an optional sampling result payload (omit to reject).
11393    ///
11394    /// # Returns
11395    ///
11396    /// Indicates whether the pending UI request was resolved by this call.
11397    ///
11398    /// <div class="warning">
11399    ///
11400    /// **Experimental.** This API is part of an experimental wire-protocol surface
11401    /// and may change or be removed in future SDK or CLI releases. Pin both the
11402    /// SDK and CLI versions if your code depends on it.
11403    ///
11404    /// </div>
11405    pub async fn handle_pending_sampling(
11406        &self,
11407        params: UIHandlePendingSamplingRequest,
11408    ) -> Result<UIHandlePendingResult, Error> {
11409        let mut wire_params = serde_json::to_value(params)?;
11410        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11411        let _value = self
11412            .session
11413            .client()
11414            .call(
11415                rpc_methods::SESSION_UI_HANDLEPENDINGSAMPLING,
11416                Some(wire_params),
11417            )
11418            .await?;
11419        Ok(serde_json::from_value(_value)?)
11420    }
11421
11422    /// Resolves a pending `auto_mode_switch.requested` event with the user's accept/decline decision.
11423    ///
11424    /// Wire method: `session.ui.handlePendingAutoModeSwitch`.
11425    ///
11426    /// # Parameters
11427    ///
11428    /// * `params` - Request ID of a pending `auto_mode_switch.requested` event and the user's response.
11429    ///
11430    /// # Returns
11431    ///
11432    /// Indicates whether the pending UI request was resolved by this call.
11433    ///
11434    /// <div class="warning">
11435    ///
11436    /// **Experimental.** This API is part of an experimental wire-protocol surface
11437    /// and may change or be removed in future SDK or CLI releases. Pin both the
11438    /// SDK and CLI versions if your code depends on it.
11439    ///
11440    /// </div>
11441    pub async fn handle_pending_auto_mode_switch(
11442        &self,
11443        params: UIHandlePendingAutoModeSwitchRequest,
11444    ) -> Result<UIHandlePendingResult, Error> {
11445        let mut wire_params = serde_json::to_value(params)?;
11446        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11447        let _value = self
11448            .session
11449            .client()
11450            .call(
11451                rpc_methods::SESSION_UI_HANDLEPENDINGAUTOMODESWITCH,
11452                Some(wire_params),
11453            )
11454            .await?;
11455        Ok(serde_json::from_value(_value)?)
11456    }
11457
11458    /// Resolves a pending `session_limits_exhausted.requested` event with the user's selected limit action.
11459    ///
11460    /// Wire method: `session.ui.handlePendingSessionLimitsExhausted`.
11461    ///
11462    /// # Parameters
11463    ///
11464    /// * `params` - Request ID of a pending `session_limits_exhausted.requested` event and the user's selected limit action.
11465    ///
11466    /// # Returns
11467    ///
11468    /// Indicates whether the pending UI request was resolved by this call.
11469    ///
11470    /// <div class="warning">
11471    ///
11472    /// **Experimental.** This API is part of an experimental wire-protocol surface
11473    /// and may change or be removed in future SDK or CLI releases. Pin both the
11474    /// SDK and CLI versions if your code depends on it.
11475    ///
11476    /// </div>
11477    pub async fn handle_pending_session_limits_exhausted(
11478        &self,
11479        params: UIHandlePendingSessionLimitsExhaustedRequest,
11480    ) -> Result<UIHandlePendingResult, Error> {
11481        let mut wire_params = serde_json::to_value(params)?;
11482        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11483        let _value = self
11484            .session
11485            .client()
11486            .call(
11487                rpc_methods::SESSION_UI_HANDLEPENDINGSESSIONLIMITSEXHAUSTED,
11488                Some(wire_params),
11489            )
11490            .await?;
11491        Ok(serde_json::from_value(_value)?)
11492    }
11493
11494    /// Resolves a pending `exit_plan_mode.requested` event with the user's response.
11495    ///
11496    /// Wire method: `session.ui.handlePendingExitPlanMode`.
11497    ///
11498    /// # Parameters
11499    ///
11500    /// * `params` - Request ID of a pending `exit_plan_mode.requested` event and the user's response.
11501    ///
11502    /// # Returns
11503    ///
11504    /// Indicates whether the pending UI request was resolved by this call.
11505    ///
11506    /// <div class="warning">
11507    ///
11508    /// **Experimental.** This API is part of an experimental wire-protocol surface
11509    /// and may change or be removed in future SDK or CLI releases. Pin both the
11510    /// SDK and CLI versions if your code depends on it.
11511    ///
11512    /// </div>
11513    pub async fn handle_pending_exit_plan_mode(
11514        &self,
11515        params: UIHandlePendingExitPlanModeRequest,
11516    ) -> Result<UIHandlePendingResult, Error> {
11517        let mut wire_params = serde_json::to_value(params)?;
11518        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11519        let _value = self
11520            .session
11521            .client()
11522            .call(
11523                rpc_methods::SESSION_UI_HANDLEPENDINGEXITPLANMODE,
11524                Some(wire_params),
11525            )
11526            .await?;
11527        Ok(serde_json::from_value(_value)?)
11528    }
11529
11530    /// Registers an in-process handler for auto-mode-switch requests so the server bridge skips dispatch.
11531    ///
11532    /// Wire method: `session.ui.registerDirectAutoModeSwitchHandler`.
11533    ///
11534    /// # Returns
11535    ///
11536    /// 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).
11537    ///
11538    /// <div class="warning">
11539    ///
11540    /// **Experimental.** This API is part of an experimental wire-protocol surface
11541    /// and may change or be removed in future SDK or CLI releases. Pin both the
11542    /// SDK and CLI versions if your code depends on it.
11543    ///
11544    /// </div>
11545    pub async fn register_direct_auto_mode_switch_handler(
11546        &self,
11547    ) -> Result<UIRegisterDirectAutoModeSwitchHandlerResult, Error> {
11548        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
11549        let _value = self
11550            .session
11551            .client()
11552            .call(
11553                rpc_methods::SESSION_UI_REGISTERDIRECTAUTOMODESWITCHHANDLER,
11554                Some(wire_params),
11555            )
11556            .await?;
11557        Ok(serde_json::from_value(_value)?)
11558    }
11559
11560    /// Unregisters a previously-registered in-process auto-mode-switch handler by its opaque handle.
11561    ///
11562    /// Wire method: `session.ui.unregisterDirectAutoModeSwitchHandler`.
11563    ///
11564    /// # Parameters
11565    ///
11566    /// * `params` - Opaque handle previously returned by `registerDirectAutoModeSwitchHandler` to release.
11567    ///
11568    /// # Returns
11569    ///
11570    /// Indicates whether the handle was active and the registration count was decremented.
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 unregister_direct_auto_mode_switch_handler(
11580        &self,
11581        params: UIUnregisterDirectAutoModeSwitchHandlerRequest,
11582    ) -> Result<UIUnregisterDirectAutoModeSwitchHandlerResult, 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_UI_UNREGISTERDIRECTAUTOMODESWITCHHANDLER,
11590                Some(wire_params),
11591            )
11592            .await?;
11593        Ok(serde_json::from_value(_value)?)
11594    }
11595}
11596
11597/// `session.usage.*` RPCs.
11598#[derive(Clone, Copy)]
11599pub struct SessionRpcUsage<'a> {
11600    pub(crate) session: &'a Session,
11601}
11602
11603impl<'a> SessionRpcUsage<'a> {
11604    /// Gets accumulated usage metrics for the session.
11605    ///
11606    /// Wire method: `session.usage.getMetrics`.
11607    ///
11608    /// # Returns
11609    ///
11610    /// Accumulated session usage metrics, including premium request cost, token counts, model breakdown, and code-change totals.
11611    ///
11612    /// <div class="warning">
11613    ///
11614    /// **Experimental.** This API is part of an experimental wire-protocol surface
11615    /// and may change or be removed in future SDK or CLI releases. Pin both the
11616    /// SDK and CLI versions if your code depends on it.
11617    ///
11618    /// </div>
11619    pub async fn get_metrics(&self) -> Result<UsageGetMetricsResult, Error> {
11620        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
11621        let _value = self
11622            .session
11623            .client()
11624            .call(rpc_methods::SESSION_USAGE_GETMETRICS, Some(wire_params))
11625            .await?;
11626        Ok(serde_json::from_value(_value)?)
11627    }
11628}
11629
11630/// `session.visibility.*` RPCs.
11631#[derive(Clone, Copy)]
11632pub struct SessionRpcVisibility<'a> {
11633    pub(crate) session: &'a Session,
11634}
11635
11636impl<'a> SessionRpcVisibility<'a> {
11637    /// 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").
11638    ///
11639    /// Wire method: `session.visibility.get`.
11640    ///
11641    /// # Returns
11642    ///
11643    /// Current sharing status and shareable GitHub URL for a session.
11644    ///
11645    /// <div class="warning">
11646    ///
11647    /// **Experimental.** This API is part of an experimental wire-protocol surface
11648    /// and may change or be removed in future SDK or CLI releases. Pin both the
11649    /// SDK and CLI versions if your code depends on it.
11650    ///
11651    /// </div>
11652    pub async fn get(&self) -> Result<VisibilityGetResult, Error> {
11653        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
11654        let _value = self
11655            .session
11656            .client()
11657            .call(rpc_methods::SESSION_VISIBILITY_GET, Some(wire_params))
11658            .await?;
11659        Ok(serde_json::from_value(_value)?)
11660    }
11661
11662    /// 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.
11663    ///
11664    /// Wire method: `session.visibility.set`.
11665    ///
11666    /// # Parameters
11667    ///
11668    /// * `params` - Desired sharing status for the session.
11669    ///
11670    /// # Returns
11671    ///
11672    /// Effective sharing status and shareable GitHub URL after updating session visibility.
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 set(&self, params: VisibilitySetRequest) -> Result<VisibilitySetResult, Error> {
11682        let mut wire_params = serde_json::to_value(params)?;
11683        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11684        let _value = self
11685            .session
11686            .client()
11687            .call(rpc_methods::SESSION_VISIBILITY_SET, Some(wire_params))
11688            .await?;
11689        Ok(serde_json::from_value(_value)?)
11690    }
11691}
11692
11693/// `session.workspaces.*` RPCs.
11694#[derive(Clone, Copy)]
11695pub struct SessionRpcWorkspaces<'a> {
11696    pub(crate) session: &'a Session,
11697}
11698
11699impl<'a> SessionRpcWorkspaces<'a> {
11700    /// Gets current workspace metadata for the session.
11701    ///
11702    /// Wire method: `session.workspaces.getWorkspace`.
11703    ///
11704    /// # Returns
11705    ///
11706    /// Current workspace metadata for the session, including its absolute filesystem path when available.
11707    ///
11708    /// <div class="warning">
11709    ///
11710    /// **Experimental.** This API is part of an experimental wire-protocol surface
11711    /// and may change or be removed in future SDK or CLI releases. Pin both the
11712    /// SDK and CLI versions if your code depends on it.
11713    ///
11714    /// </div>
11715    pub async fn get_workspace(&self) -> Result<WorkspacesGetWorkspaceResult, 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_GETWORKSPACE,
11722                Some(wire_params),
11723            )
11724            .await?;
11725        Ok(serde_json::from_value(_value)?)
11726    }
11727
11728    /// Updates workspace metadata for a local session and returns the refreshed workspace.
11729    ///
11730    /// Wire method: `session.workspaces.updateMetadata`.
11731    ///
11732    /// # Parameters
11733    ///
11734    /// * `params` - Workspace metadata fields to update.
11735    ///
11736    /// # Returns
11737    ///
11738    /// Current workspace metadata for the session, including its absolute filesystem path when available.
11739    ///
11740    /// <div class="warning">
11741    ///
11742    /// **Experimental.** This API is part of an experimental wire-protocol surface
11743    /// and may change or be removed in future SDK or CLI releases. Pin both the
11744    /// SDK and CLI versions if your code depends on it.
11745    ///
11746    /// </div>
11747    pub async fn update_metadata(
11748        &self,
11749        params: WorkspacesUpdateMetadataRequest,
11750    ) -> Result<WorkspacesGetWorkspaceResult, Error> {
11751        let mut wire_params = serde_json::to_value(params)?;
11752        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11753        let _value = self
11754            .session
11755            .client()
11756            .call(
11757                rpc_methods::SESSION_WORKSPACES_UPDATEMETADATA,
11758                Some(wire_params),
11759            )
11760            .await?;
11761        Ok(serde_json::from_value(_value)?)
11762    }
11763
11764    /// Ensures a local session workspace exists and returns it.
11765    ///
11766    /// Wire method: `session.workspaces.ensure`.
11767    ///
11768    /// # Parameters
11769    ///
11770    /// * `params` - Optional session context used when creating a local workspace.
11771    ///
11772    /// # Returns
11773    ///
11774    /// Current workspace metadata for the session, including its absolute filesystem path when available.
11775    ///
11776    /// <div class="warning">
11777    ///
11778    /// **Experimental.** This API is part of an experimental wire-protocol surface
11779    /// and may change or be removed in future SDK or CLI releases. Pin both the
11780    /// SDK and CLI versions if your code depends on it.
11781    ///
11782    /// </div>
11783    pub async fn ensure(
11784        &self,
11785        params: WorkspacesEnsureRequest,
11786    ) -> Result<WorkspacesGetWorkspaceResult, Error> {
11787        let mut wire_params = serde_json::to_value(params)?;
11788        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11789        let _value = self
11790            .session
11791            .client()
11792            .call(rpc_methods::SESSION_WORKSPACES_ENSURE, Some(wire_params))
11793            .await?;
11794        Ok(serde_json::from_value(_value)?)
11795    }
11796
11797    /// Lists files stored in the session workspace files directory.
11798    ///
11799    /// Wire method: `session.workspaces.listFiles`.
11800    ///
11801    /// # Returns
11802    ///
11803    /// Relative paths of files stored in the session workspace files directory.
11804    ///
11805    /// <div class="warning">
11806    ///
11807    /// **Experimental.** This API is part of an experimental wire-protocol surface
11808    /// and may change or be removed in future SDK or CLI releases. Pin both the
11809    /// SDK and CLI versions if your code depends on it.
11810    ///
11811    /// </div>
11812    pub async fn list_files(&self) -> Result<WorkspacesListFilesResult, Error> {
11813        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
11814        let _value = self
11815            .session
11816            .client()
11817            .call(rpc_methods::SESSION_WORKSPACES_LISTFILES, Some(wire_params))
11818            .await?;
11819        Ok(serde_json::from_value(_value)?)
11820    }
11821
11822    /// Reads a file from the session workspace files directory.
11823    ///
11824    /// Wire method: `session.workspaces.readFile`.
11825    ///
11826    /// # Parameters
11827    ///
11828    /// * `params` - Relative path of the workspace file to read.
11829    ///
11830    /// # Returns
11831    ///
11832    /// Contents of the requested workspace file as a UTF-8 string.
11833    ///
11834    /// <div class="warning">
11835    ///
11836    /// **Experimental.** This API is part of an experimental wire-protocol surface
11837    /// and may change or be removed in future SDK or CLI releases. Pin both the
11838    /// SDK and CLI versions if your code depends on it.
11839    ///
11840    /// </div>
11841    pub async fn read_file(
11842        &self,
11843        params: WorkspacesReadFileRequest,
11844    ) -> Result<WorkspacesReadFileResult, Error> {
11845        let mut wire_params = serde_json::to_value(params)?;
11846        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11847        let _value = self
11848            .session
11849            .client()
11850            .call(rpc_methods::SESSION_WORKSPACES_READFILE, Some(wire_params))
11851            .await?;
11852        Ok(serde_json::from_value(_value)?)
11853    }
11854
11855    /// Creates or overwrites a file in the session workspace files directory.
11856    ///
11857    /// Wire method: `session.workspaces.createFile`.
11858    ///
11859    /// # Parameters
11860    ///
11861    /// * `params` - Relative path and UTF-8 content for the workspace file to create or overwrite.
11862    ///
11863    /// <div class="warning">
11864    ///
11865    /// **Experimental.** This API is part of an experimental wire-protocol surface
11866    /// and may change or be removed in future SDK or CLI releases. Pin both the
11867    /// SDK and CLI versions if your code depends on it.
11868    ///
11869    /// </div>
11870    pub async fn create_file(&self, params: WorkspacesCreateFileRequest) -> Result<(), Error> {
11871        let mut wire_params = serde_json::to_value(params)?;
11872        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11873        let _value = self
11874            .session
11875            .client()
11876            .call(
11877                rpc_methods::SESSION_WORKSPACES_CREATEFILE,
11878                Some(wire_params),
11879            )
11880            .await?;
11881        Ok(())
11882    }
11883
11884    /// Lists workspace checkpoints in chronological order.
11885    ///
11886    /// Wire method: `session.workspaces.listCheckpoints`.
11887    ///
11888    /// # Returns
11889    ///
11890    /// Workspace checkpoints in chronological order; empty when the workspace is not enabled.
11891    ///
11892    /// <div class="warning">
11893    ///
11894    /// **Experimental.** This API is part of an experimental wire-protocol surface
11895    /// and may change or be removed in future SDK or CLI releases. Pin both the
11896    /// SDK and CLI versions if your code depends on it.
11897    ///
11898    /// </div>
11899    pub async fn list_checkpoints(&self) -> Result<WorkspacesListCheckpointsResult, Error> {
11900        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
11901        let _value = self
11902            .session
11903            .client()
11904            .call(
11905                rpc_methods::SESSION_WORKSPACES_LISTCHECKPOINTS,
11906                Some(wire_params),
11907            )
11908            .await?;
11909        Ok(serde_json::from_value(_value)?)
11910    }
11911
11912    /// Reads the content of a workspace checkpoint by number.
11913    ///
11914    /// Wire method: `session.workspaces.readCheckpoint`.
11915    ///
11916    /// # Parameters
11917    ///
11918    /// * `params` - Checkpoint number to read.
11919    ///
11920    /// # Returns
11921    ///
11922    /// Checkpoint content as a UTF-8 string, or null when the checkpoint or workspace is missing.
11923    ///
11924    /// <div class="warning">
11925    ///
11926    /// **Experimental.** This API is part of an experimental wire-protocol surface
11927    /// and may change or be removed in future SDK or CLI releases. Pin both the
11928    /// SDK and CLI versions if your code depends on it.
11929    ///
11930    /// </div>
11931    pub async fn read_checkpoint(
11932        &self,
11933        params: WorkspacesReadCheckpointRequest,
11934    ) -> Result<WorkspacesReadCheckpointResult, Error> {
11935        let mut wire_params = serde_json::to_value(params)?;
11936        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11937        let _value = self
11938            .session
11939            .client()
11940            .call(
11941                rpc_methods::SESSION_WORKSPACES_READCHECKPOINT,
11942                Some(wire_params),
11943            )
11944            .await?;
11945        Ok(serde_json::from_value(_value)?)
11946    }
11947
11948    /// Adds a compaction summary checkpoint to the local session workspace.
11949    ///
11950    /// Wire method: `session.workspaces.addSummary`.
11951    ///
11952    /// # Parameters
11953    ///
11954    /// * `params` - Compaction summary checkpoint to persist.
11955    ///
11956    /// # Returns
11957    ///
11958    /// Persisted summary metadata and refreshed workspace metadata.
11959    ///
11960    /// <div class="warning">
11961    ///
11962    /// **Experimental.** This API is part of an experimental wire-protocol surface
11963    /// and may change or be removed in future SDK or CLI releases. Pin both the
11964    /// SDK and CLI versions if your code depends on it.
11965    ///
11966    /// </div>
11967    pub async fn add_summary(
11968        &self,
11969        params: WorkspacesAddSummaryRequest,
11970    ) -> Result<WorkspacesAddSummaryResult, Error> {
11971        let mut wire_params = serde_json::to_value(params)?;
11972        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11973        let _value = self
11974            .session
11975            .client()
11976            .call(
11977                rpc_methods::SESSION_WORKSPACES_ADDSUMMARY,
11978                Some(wire_params),
11979            )
11980            .await?;
11981        Ok(serde_json::from_value(_value)?)
11982    }
11983
11984    /// Truncates local workspace compaction summaries after a rollback.
11985    ///
11986    /// Wire method: `session.workspaces.truncateSummaries`.
11987    ///
11988    /// # Parameters
11989    ///
11990    /// * `params` - Rollback point for local workspace summaries.
11991    ///
11992    /// # Returns
11993    ///
11994    /// Current workspace metadata for the session, including its absolute filesystem path when available.
11995    ///
11996    /// <div class="warning">
11997    ///
11998    /// **Experimental.** This API is part of an experimental wire-protocol surface
11999    /// and may change or be removed in future SDK or CLI releases. Pin both the
12000    /// SDK and CLI versions if your code depends on it.
12001    ///
12002    /// </div>
12003    pub async fn truncate_summaries(
12004        &self,
12005        params: WorkspacesTruncateSummariesRequest,
12006    ) -> Result<WorkspacesGetWorkspaceResult, Error> {
12007        let mut wire_params = serde_json::to_value(params)?;
12008        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
12009        let _value = self
12010            .session
12011            .client()
12012            .call(
12013                rpc_methods::SESSION_WORKSPACES_TRUNCATESUMMARIES,
12014                Some(wire_params),
12015            )
12016            .await?;
12017        Ok(serde_json::from_value(_value)?)
12018    }
12019
12020    /// Reads the autopilot objective state file from the local session workspace.
12021    ///
12022    /// Wire method: `session.workspaces.readAutopilotObjective`.
12023    ///
12024    /// # Returns
12025    ///
12026    /// Autopilot objective file content, or null when missing.
12027    ///
12028    /// <div class="warning">
12029    ///
12030    /// **Experimental.** This API is part of an experimental wire-protocol surface
12031    /// and may change or be removed in future SDK or CLI releases. Pin both the
12032    /// SDK and CLI versions if your code depends on it.
12033    ///
12034    /// </div>
12035    pub async fn read_autopilot_objective(
12036        &self,
12037    ) -> Result<WorkspacesReadAutopilotObjectiveResult, Error> {
12038        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
12039        let _value = self
12040            .session
12041            .client()
12042            .call(
12043                rpc_methods::SESSION_WORKSPACES_READAUTOPILOTOBJECTIVE,
12044                Some(wire_params),
12045            )
12046            .await?;
12047        Ok(serde_json::from_value(_value)?)
12048    }
12049
12050    /// Writes the autopilot objective state file in the local session workspace.
12051    ///
12052    /// Wire method: `session.workspaces.writeAutopilotObjective`.
12053    ///
12054    /// # Parameters
12055    ///
12056    /// * `params` - Autopilot objective file content to persist.
12057    ///
12058    /// # Returns
12059    ///
12060    /// Result of writing the autopilot objective file.
12061    ///
12062    /// <div class="warning">
12063    ///
12064    /// **Experimental.** This API is part of an experimental wire-protocol surface
12065    /// and may change or be removed in future SDK or CLI releases. Pin both the
12066    /// SDK and CLI versions if your code depends on it.
12067    ///
12068    /// </div>
12069    pub async fn write_autopilot_objective(
12070        &self,
12071        params: WorkspacesWriteAutopilotObjectiveRequest,
12072    ) -> Result<WorkspacesWriteAutopilotObjectiveResult, Error> {
12073        let mut wire_params = serde_json::to_value(params)?;
12074        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
12075        let _value = self
12076            .session
12077            .client()
12078            .call(
12079                rpc_methods::SESSION_WORKSPACES_WRITEAUTOPILOTOBJECTIVE,
12080                Some(wire_params),
12081            )
12082            .await?;
12083        Ok(serde_json::from_value(_value)?)
12084    }
12085
12086    /// Deletes the autopilot objective state file from the local session workspace.
12087    ///
12088    /// Wire method: `session.workspaces.deleteAutopilotObjective`.
12089    ///
12090    /// # Returns
12091    ///
12092    /// Result of deleting the autopilot objective file.
12093    ///
12094    /// <div class="warning">
12095    ///
12096    /// **Experimental.** This API is part of an experimental wire-protocol surface
12097    /// and may change or be removed in future SDK or CLI releases. Pin both the
12098    /// SDK and CLI versions if your code depends on it.
12099    ///
12100    /// </div>
12101    pub async fn delete_autopilot_objective(
12102        &self,
12103    ) -> Result<WorkspacesDeleteAutopilotObjectiveResult, Error> {
12104        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
12105        let _value = self
12106            .session
12107            .client()
12108            .call(
12109                rpc_methods::SESSION_WORKSPACES_DELETEAUTOPILOTOBJECTIVE,
12110                Some(wire_params),
12111            )
12112            .await?;
12113        Ok(serde_json::from_value(_value)?)
12114    }
12115
12116    /// Checks whether the local session workspace has an autopilot objective state file.
12117    ///
12118    /// Wire method: `session.workspaces.autopilotObjectiveExists`.
12119    ///
12120    /// # Returns
12121    ///
12122    /// Whether the autopilot objective file exists.
12123    ///
12124    /// <div class="warning">
12125    ///
12126    /// **Experimental.** This API is part of an experimental wire-protocol surface
12127    /// and may change or be removed in future SDK or CLI releases. Pin both the
12128    /// SDK and CLI versions if your code depends on it.
12129    ///
12130    /// </div>
12131    pub async fn autopilot_objective_exists(
12132        &self,
12133    ) -> Result<WorkspacesAutopilotObjectiveExistsResult, Error> {
12134        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
12135        let _value = self
12136            .session
12137            .client()
12138            .call(
12139                rpc_methods::SESSION_WORKSPACES_AUTOPILOTOBJECTIVEEXISTS,
12140                Some(wire_params),
12141            )
12142            .await?;
12143        Ok(serde_json::from_value(_value)?)
12144    }
12145
12146    /// Saves pasted content as a UTF-8 file in the session workspace.
12147    ///
12148    /// Wire method: `session.workspaces.saveLargePaste`.
12149    ///
12150    /// # Parameters
12151    ///
12152    /// * `params` - Pasted content to save as a UTF-8 file in the session workspace.
12153    ///
12154    /// # Returns
12155    ///
12156    /// Descriptor for the saved paste file, or null when the workspace is unavailable.
12157    ///
12158    /// <div class="warning">
12159    ///
12160    /// **Experimental.** This API is part of an experimental wire-protocol surface
12161    /// and may change or be removed in future SDK or CLI releases. Pin both the
12162    /// SDK and CLI versions if your code depends on it.
12163    ///
12164    /// </div>
12165    pub async fn save_large_paste(
12166        &self,
12167        params: WorkspacesSaveLargePasteRequest,
12168    ) -> Result<WorkspacesSaveLargePasteResult, Error> {
12169        let mut wire_params = serde_json::to_value(params)?;
12170        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
12171        let _value = self
12172            .session
12173            .client()
12174            .call(
12175                rpc_methods::SESSION_WORKSPACES_SAVELARGEPASTE,
12176                Some(wire_params),
12177            )
12178            .await?;
12179        Ok(serde_json::from_value(_value)?)
12180    }
12181
12182    /// 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`.
12183    ///
12184    /// Wire method: `session.workspaces.diff`.
12185    ///
12186    /// # Parameters
12187    ///
12188    /// * `params` - Parameters for computing a workspace diff.
12189    ///
12190    /// # Returns
12191    ///
12192    /// Workspace diff result for the requested mode.
12193    ///
12194    /// <div class="warning">
12195    ///
12196    /// **Experimental.** This API is part of an experimental wire-protocol surface
12197    /// and may change or be removed in future SDK or CLI releases. Pin both the
12198    /// SDK and CLI versions if your code depends on it.
12199    ///
12200    /// </div>
12201    pub async fn diff(&self, params: WorkspacesDiffRequest) -> Result<WorkspaceDiffResult, Error> {
12202        let mut wire_params = serde_json::to_value(params)?;
12203        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
12204        let _value = self
12205            .session
12206            .client()
12207            .call(rpc_methods::SESSION_WORKSPACES_DIFF, Some(wire_params))
12208            .await?;
12209        Ok(serde_json::from_value(_value)?)
12210    }
12211}