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