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