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