Skip to main content

github_copilot_sdk/generated/
rpc.rs

1//! Auto-generated typed JSON-RPC namespace — do not edit manually.
2//!
3//! Generated from `api.schema.json` by `scripts/codegen/rust.ts`. The
4//! [`ClientRpc`] and [`SessionRpc`] view structs let callers reach every
5//! protocol method through a typed namespace tree, so wire method names
6//! and request/response shapes live in exactly one place — this file.
7
8#![allow(missing_docs)]
9#![allow(clippy::too_many_arguments)]
10#![allow(deprecated)]
11#![allow(dead_code)]
12
13use super::api_types::{rpc_methods, *};
14use super::session_events::SessionMode;
15use crate::session::Session;
16use crate::{Client, Error};
17
18/// Typed view over the [`Client`]'s server-level RPC namespace.
19#[derive(Clone, Copy)]
20pub struct ClientRpc<'a> {
21    pub(crate) client: &'a Client,
22}
23
24impl<'a> ClientRpc<'a> {
25    /// `account.*` sub-namespace.
26    pub fn account(&self) -> ClientRpcAccount<'a> {
27        ClientRpcAccount {
28            client: self.client,
29        }
30    }
31
32    /// `agentRegistry.*` sub-namespace.
33    pub fn agent_registry(&self) -> ClientRpcAgentRegistry<'a> {
34        ClientRpcAgentRegistry {
35            client: self.client,
36        }
37    }
38
39    /// `agents.*` sub-namespace.
40    pub fn agents(&self) -> ClientRpcAgents<'a> {
41        ClientRpcAgents {
42            client: self.client,
43        }
44    }
45
46    /// `catalog.*` sub-namespace.
47    pub fn catalog(&self) -> ClientRpcCatalog<'a> {
48        ClientRpcCatalog {
49            client: self.client,
50        }
51    }
52
53    /// `commands.*` sub-namespace.
54    pub fn commands(&self) -> ClientRpcCommands<'a> {
55        ClientRpcCommands {
56            client: self.client,
57        }
58    }
59
60    /// `extensions.*` sub-namespace.
61    pub fn extensions(&self) -> ClientRpcExtensions<'a> {
62        ClientRpcExtensions {
63            client: self.client,
64        }
65    }
66
67    /// `hooks.*` sub-namespace.
68    pub fn hooks(&self) -> ClientRpcHooks<'a> {
69        ClientRpcHooks {
70            client: self.client,
71        }
72    }
73
74    /// `instructions.*` sub-namespace.
75    pub fn instructions(&self) -> ClientRpcInstructions<'a> {
76        ClientRpcInstructions {
77            client: self.client,
78        }
79    }
80
81    /// `llmInference.*` sub-namespace.
82    pub fn llm_inference(&self) -> ClientRpcLlmInference<'a> {
83        ClientRpcLlmInference {
84            client: self.client,
85        }
86    }
87
88    /// `managedSettings.*` sub-namespace.
89    pub fn managed_settings(&self) -> ClientRpcManagedSettings<'a> {
90        ClientRpcManagedSettings {
91            client: self.client,
92        }
93    }
94
95    /// `mcp.*` sub-namespace.
96    pub fn mcp(&self) -> ClientRpcMcp<'a> {
97        ClientRpcMcp {
98            client: self.client,
99        }
100    }
101
102    /// `models.*` sub-namespace.
103    pub fn models(&self) -> ClientRpcModels<'a> {
104        ClientRpcModels {
105            client: self.client,
106        }
107    }
108
109    /// `plugins.*` sub-namespace.
110    pub fn plugins(&self) -> ClientRpcPlugins<'a> {
111        ClientRpcPlugins {
112            client: self.client,
113        }
114    }
115
116    /// `runtime.*` sub-namespace.
117    pub fn runtime(&self) -> ClientRpcRuntime<'a> {
118        ClientRpcRuntime {
119            client: self.client,
120        }
121    }
122
123    /// `secrets.*` sub-namespace.
124    pub fn secrets(&self) -> ClientRpcSecrets<'a> {
125        ClientRpcSecrets {
126            client: self.client,
127        }
128    }
129
130    /// `sessionFs.*` sub-namespace.
131    pub fn session_fs(&self) -> ClientRpcSessionFs<'a> {
132        ClientRpcSessionFs {
133            client: self.client,
134        }
135    }
136
137    /// `sessions.*` sub-namespace.
138    pub fn sessions(&self) -> ClientRpcSessions<'a> {
139        ClientRpcSessions {
140            client: self.client,
141        }
142    }
143
144    /// `skills.*` sub-namespace.
145    pub fn skills(&self) -> ClientRpcSkills<'a> {
146        ClientRpcSkills {
147            client: self.client,
148        }
149    }
150
151    /// `tools.*` sub-namespace.
152    pub fn tools(&self) -> ClientRpcTools<'a> {
153        ClientRpcTools {
154            client: self.client,
155        }
156    }
157
158    /// `user.*` sub-namespace.
159    pub fn user(&self) -> ClientRpcUser<'a> {
160        ClientRpcUser {
161            client: self.client,
162        }
163    }
164
165    /// Checks server responsiveness and returns protocol information.
166    ///
167    /// Wire method: `ping`.
168    ///
169    /// # Parameters
170    ///
171    /// * `params` - Optional message to echo back to the caller.
172    ///
173    /// # Returns
174    ///
175    /// Server liveness response, including the echoed message, current server timestamp, and protocol version.
176    ///
177    /// <div class="warning">
178    ///
179    /// **Experimental.** This API is part of an experimental wire-protocol surface
180    /// and may change or be removed in future SDK or CLI releases. Pin both the
181    /// SDK and CLI versions if your code depends on it.
182    ///
183    /// </div>
184    pub async fn ping(&self, params: PingRequest) -> Result<PingResult, Error> {
185        let wire_params = serde_json::to_value(params)?;
186        let _value = self
187            .client
188            .call(rpc_methods::PING, Some(wire_params))
189            .await?;
190        Ok(serde_json::from_value(_value)?)
191    }
192
193    /// Performs the SDK server connection handshake and validates the optional connection token. Marked internal because this is JSON-RPC transport plumbing invoked automatically by an SDK client's own `connect()` wrapper, not a user-facing method. Stays internal as long as the SDK client owns the handshake; would only become public if the SDK ever exposed the raw schema surface to consumers without a connection wrapper.
194    ///
195    /// Wire method: `connect`.
196    ///
197    /// # Parameters
198    ///
199    /// * `params` - Connection-level opt-ins for the `server.connect` handshake. Transport authentication is consumed by the native protocol boundary before dispatch.
200    ///
201    /// # Returns
202    ///
203    /// Handshake result reporting the server's protocol version and package version on success.
204    ///
205    /// <div class="warning">
206    ///
207    /// **Experimental.** This API is part of an experimental wire-protocol surface
208    /// and may change or be removed in future SDK or CLI releases. Pin both the
209    /// SDK and CLI versions if your code depends on it.
210    ///
211    /// </div>
212    pub(crate) async fn connect(&self, params: ConnectRequest) -> Result<ConnectResult, Error> {
213        let wire_params = serde_json::to_value(params)?;
214        let _value = self
215            .client
216            .call(rpc_methods::CONNECT, Some(wire_params))
217            .await?;
218        Ok(serde_json::from_value(_value)?)
219    }
220
221    /// Registers the calling SDK client as the per-entrypoint extension launch provider. Call before creating any sessions. When omitted, the runtime uses its built-in extension launcher.
222    ///
223    /// Wire method: `registerExtensionLaunchProvider`.
224    ///
225    /// <div class="warning">
226    ///
227    /// **Experimental.** This API is part of an experimental wire-protocol surface
228    /// and may change or be removed in future SDK or CLI releases. Pin both the
229    /// SDK and CLI versions if your code depends on it.
230    ///
231    /// </div>
232    pub async fn register_extension_launch_provider(&self) -> Result<(), Error> {
233        let wire_params = serde_json::json!({});
234        let _value = self
235            .client
236            .call(
237                rpc_methods::REGISTEREXTENSIONLAUNCHPROVIDER,
238                Some(wire_params),
239            )
240            .await?;
241        Ok(())
242    }
243}
244
245/// `account.*` RPCs.
246#[derive(Clone, Copy)]
247pub struct ClientRpcAccount<'a> {
248    pub(crate) client: &'a Client,
249}
250
251impl<'a> ClientRpcAccount<'a> {
252    /// Gets Copilot quota usage for the current or opaquely selected authenticated user.
253    ///
254    /// Wire method: `account.getQuota`.
255    ///
256    /// # Returns
257    ///
258    /// Quota usage snapshots for the resolved user, keyed by quota type.
259    ///
260    /// <div class="warning">
261    ///
262    /// **Experimental.** This API is part of an experimental wire-protocol surface
263    /// and may change or be removed in future SDK or CLI releases. Pin both the
264    /// SDK and CLI versions if your code depends on it.
265    ///
266    /// </div>
267    pub async fn get_quota(&self) -> Result<AccountGetQuotaResult, Error> {
268        let wire_params = serde_json::json!({});
269        let _value = self
270            .client
271            .call(rpc_methods::ACCOUNT_GETQUOTA, Some(wire_params))
272            .await?;
273        Ok(serde_json::from_value(_value)?)
274    }
275
276    /// Gets Copilot quota usage for the current or opaquely selected authenticated user.
277    ///
278    /// Wire method: `account.getQuota`.
279    ///
280    /// # Parameters
281    ///
282    /// * `params` - Optional opaque account selection or compatibility GitHub token used to look up quota.
283    ///
284    /// # Returns
285    ///
286    /// Quota usage snapshots for the resolved user, keyed by quota type.
287    ///
288    /// <div class="warning">
289    ///
290    /// **Experimental.** This API is part of an experimental wire-protocol surface
291    /// and may change or be removed in future SDK or CLI releases. Pin both the
292    /// SDK and CLI versions if your code depends on it.
293    ///
294    /// </div>
295    pub async fn get_quota_with_params(
296        &self,
297        params: AccountGetQuotaRequest,
298    ) -> Result<AccountGetQuotaResult, Error> {
299        let wire_params = serde_json::to_value(params)?;
300        let _value = self
301            .client
302            .call(rpc_methods::ACCOUNT_GETQUOTA, Some(wire_params))
303            .await?;
304        Ok(serde_json::from_value(_value)?)
305    }
306
307    /// Gets the currently active authentication credentials from the global auth manager.
308    ///
309    /// Wire method: `account.getCurrentAuth`.
310    ///
311    /// # Returns
312    ///
313    /// Current authentication state
314    ///
315    /// <div class="warning">
316    ///
317    /// **Experimental.** This API is part of an experimental wire-protocol surface
318    /// and may change or be removed in future SDK or CLI releases. Pin both the
319    /// SDK and CLI versions if your code depends on it.
320    ///
321    /// </div>
322    pub async fn get_current_auth(&self) -> Result<AccountGetCurrentAuthResult, Error> {
323        let wire_params = serde_json::json!({});
324        let _value = self
325            .client
326            .call(rpc_methods::ACCOUNT_GETCURRENTAUTH, Some(wire_params))
327            .await?;
328        Ok(serde_json::from_value(_value)?)
329    }
330
331    /// Gets all authenticated users available for account switching.
332    ///
333    /// Wire method: `account.getAllUsers`.
334    ///
335    /// # Returns
336    ///
337    /// List of all authenticated users
338    ///
339    /// <div class="warning">
340    ///
341    /// **Experimental.** This API is part of an experimental wire-protocol surface
342    /// and may change or be removed in future SDK or CLI releases. Pin both the
343    /// SDK and CLI versions if your code depends on it.
344    ///
345    /// </div>
346    pub async fn get_all_users(&self) -> Result<AccountGetAllUsersResult, Error> {
347        let wire_params = serde_json::json!({});
348        let _value = self
349            .client
350            .call(rpc_methods::ACCOUNT_GETALLUSERS, Some(wire_params))
351            .await?;
352        Ok(serde_json::from_value(_value)?)
353    }
354
355    /// Validates and stores authentication credentials. When login is omitted, resolves the authenticated user from the token before persistence.
356    ///
357    /// Wire method: `account.login`.
358    ///
359    /// # Parameters
360    ///
361    /// * `params` - Credentials to validate and store. Omit login to resolve the authenticated user from the token.
362    ///
363    /// # Returns
364    ///
365    /// Result of a successful login; throws on failure
366    ///
367    /// <div class="warning">
368    ///
369    /// **Experimental.** This API is part of an experimental wire-protocol surface
370    /// and may change or be removed in future SDK or CLI releases. Pin both the
371    /// SDK and CLI versions if your code depends on it.
372    ///
373    /// </div>
374    pub async fn login(&self, params: AccountLoginRequest) -> Result<AccountLoginResult, Error> {
375        let wire_params = serde_json::to_value(params)?;
376        let _value = self
377            .client
378            .call(rpc_methods::ACCOUNT_LOGIN, Some(wire_params))
379            .await?;
380        Ok(serde_json::from_value(_value)?)
381    }
382
383    /// Removes user authentication from keychain and persisted state.
384    ///
385    /// Wire method: `account.logout`.
386    ///
387    /// # Parameters
388    ///
389    /// * `params` - User to log out
390    ///
391    /// # Returns
392    ///
393    /// Logout result indicating if more users remain
394    ///
395    /// <div class="warning">
396    ///
397    /// **Experimental.** This API is part of an experimental wire-protocol surface
398    /// and may change or be removed in future SDK or CLI releases. Pin both the
399    /// SDK and CLI versions if your code depends on it.
400    ///
401    /// </div>
402    pub async fn logout(&self, params: AccountLogoutRequest) -> Result<AccountLogoutResult, Error> {
403        let wire_params = serde_json::to_value(params)?;
404        let _value = self
405            .client
406            .call(rpc_methods::ACCOUNT_LOGOUT, Some(wire_params))
407            .await?;
408        Ok(serde_json::from_value(_value)?)
409    }
410}
411
412/// `agentRegistry.*` RPCs.
413#[derive(Clone, Copy)]
414pub struct ClientRpcAgentRegistry<'a> {
415    pub(crate) client: &'a Client,
416}
417
418impl<'a> ClientRpcAgentRegistry<'a> {
419    /// Spawns a managed-server child with the supplied configuration and returns a discriminated-union result. The caller (typically the CLI controller) is responsible for attaching to the spawned child and sending any follow-up prompt. When the controller-local spawn gate is closed the server returns JSON-RPC MethodNotFound.
420    ///
421    /// Wire method: `agentRegistry.spawn`.
422    ///
423    /// # Parameters
424    ///
425    /// * `params` - Inputs to spawn a managed-server child via the controller's spawn delegate.
426    ///
427    /// # Returns
428    ///
429    /// Outcome of an agentRegistry.spawn call.
430    ///
431    /// <div class="warning">
432    ///
433    /// **Experimental.** This API is part of an experimental wire-protocol surface
434    /// and may change or be removed in future SDK or CLI releases. Pin both the
435    /// SDK and CLI versions if your code depends on it.
436    ///
437    /// </div>
438    pub async fn spawn(
439        &self,
440        params: AgentRegistrySpawnRequest,
441    ) -> Result<AgentRegistrySpawnResult, Error> {
442        let wire_params = serde_json::to_value(params)?;
443        let _value = self
444            .client
445            .call(rpc_methods::AGENTREGISTRY_SPAWN, Some(wire_params))
446            .await?;
447        Ok(serde_json::from_value(_value)?)
448    }
449}
450
451/// `agents.*` RPCs.
452#[derive(Clone, Copy)]
453pub struct ClientRpcAgents<'a> {
454    pub(crate) client: &'a Client,
455}
456
457impl<'a> ClientRpcAgents<'a> {
458    /// Discovers custom agents across user, project, plugin, and remote sources.
459    ///
460    /// Wire method: `agents.discover`.
461    ///
462    /// # Parameters
463    ///
464    /// * `params` - Optional project paths to include in agent discovery.
465    ///
466    /// # Returns
467    ///
468    /// Agents discovered across user, project, plugin, and remote sources.
469    ///
470    /// <div class="warning">
471    ///
472    /// **Experimental.** This API is part of an experimental wire-protocol surface
473    /// and may change or be removed in future SDK or CLI releases. Pin both the
474    /// SDK and CLI versions if your code depends on it.
475    ///
476    /// </div>
477    pub async fn discover(&self, params: AgentsDiscoverRequest) -> Result<ServerAgentList, Error> {
478        let wire_params = serde_json::to_value(params)?;
479        let _value = self
480            .client
481            .call(rpc_methods::AGENTS_DISCOVER, Some(wire_params))
482            .await?;
483        Ok(serde_json::from_value(_value)?)
484    }
485
486    /// Returns the canonical directories where a client may create custom agents that the runtime will recognize, including ones that do not exist yet. Project directories become active once created.
487    ///
488    /// Wire method: `agents.getDiscoveryPaths`.
489    ///
490    /// # Parameters
491    ///
492    /// * `params` - Optional project paths to include when enumerating agent discovery directories.
493    ///
494    /// # Returns
495    ///
496    /// Canonical locations where custom agents can be created so the runtime will recognize them.
497    ///
498    /// <div class="warning">
499    ///
500    /// **Experimental.** This API is part of an experimental wire-protocol surface
501    /// and may change or be removed in future SDK or CLI releases. Pin both the
502    /// SDK and CLI versions if your code depends on it.
503    ///
504    /// </div>
505    pub async fn get_discovery_paths(
506        &self,
507        params: AgentsGetDiscoveryPathsRequest,
508    ) -> Result<AgentDiscoveryPathList, Error> {
509        let wire_params = serde_json::to_value(params)?;
510        let _value = self
511            .client
512            .call(rpc_methods::AGENTS_GETDISCOVERYPATHS, Some(wire_params))
513            .await?;
514        Ok(serde_json::from_value(_value)?)
515    }
516}
517
518/// `catalog.*` RPCs.
519#[derive(Clone, Copy)]
520pub struct ClientRpcCatalog<'a> {
521    pub(crate) client: &'a Client,
522}
523
524impl<'a> ClientRpcCatalog<'a> {
525    /// Requests a bounded catalog search. This host-implemented server method is available through SDK/TUI hosts; standalone and C-ABI runtimes whose host does not implement server-method dispatch return JSON-RPC MethodNotFound. A runtime with search available returns inert candidate summaries, each with an opaque single-use handle scoped to this runtime instance; a runtime without it returns the typed search-unavailable result. Public authorities may be searched anonymously, while an authority that requires credentials yields the typed authentication-required result. All returned text, URLs, and package metadata are untrusted external data and can never trigger instructions, tools, or installation. Read-only: nothing is installed, configured, or persisted.
526    ///
527    /// Wire method: `catalog.search`.
528    ///
529    /// # Parameters
530    ///
531    /// * `params` - A bounded catalog search. Both the query length and the result count are capped by the schema so a caller cannot request an unbounded scan.
532    ///
533    /// # Returns
534    ///
535    /// Outcome of a catalog.search call: either bounded inert candidates, or one typed refusal. Never a partial success.
536    ///
537    /// <div class="warning">
538    ///
539    /// **Experimental.** This API is part of an experimental wire-protocol surface
540    /// and may change or be removed in future SDK or CLI releases. Pin both the
541    /// SDK and CLI versions if your code depends on it.
542    ///
543    /// </div>
544    pub async fn search(&self, params: CatalogSearchRequest) -> Result<CatalogSearchResult, Error> {
545        let wire_params = serde_json::to_value(params)?;
546        let _value = self
547            .client
548            .call(rpc_methods::CATALOG_SEARCH, Some(wire_params))
549            .await?;
550        Ok(serde_json::from_value(_value)?)
551    }
552
553    /// Terminates one retained catalog selection group. A selected outcome returns the native host a fresh single-use candidate handle plus the original searchId for a later explicit mcp.planInstall call; non-selected outcomes release the group without producing a planning input. Candidate state, cards, URLs, credentials and private identifiers remain inside the runtime. The model-facing catalog_select tool projects the result separately and never exposes the candidate handle or searchId.
554    ///
555    /// Wire method: `catalog.select`.
556    ///
557    /// # Parameters
558    ///
559    /// * `params` - Terminates one retained catalog selection group through an opaque reference previously returned by the model-safe search projection.
560    ///
561    /// # Returns
562    ///
563    /// Typed outcome of catalog.select. Only the selected host result carries a fresh candidate handle; the model-facing projection removes both that handle and searchId.
564    ///
565    /// <div class="warning">
566    ///
567    /// **Experimental.** This API is part of an experimental wire-protocol surface
568    /// and may change or be removed in future SDK or CLI releases. Pin both the
569    /// SDK and CLI versions if your code depends on it.
570    ///
571    /// </div>
572    pub async fn select(
573        &self,
574        params: CatalogSelectionRequest,
575    ) -> Result<CatalogSelectionResult, Error> {
576        let wire_params = serde_json::to_value(params)?;
577        let _value = self
578            .client
579            .call(rpc_methods::CATALOG_SELECT, Some(wire_params))
580            .await?;
581        Ok(serde_json::from_value(_value)?)
582    }
583}
584
585/// `commands.*` RPCs.
586#[derive(Clone, Copy)]
587pub struct ClientRpcCommands<'a> {
588    pub(crate) client: &'a Client,
589}
590
591impl<'a> ClientRpcCommands<'a> {
592    /// Lists the well-known built-in slash commands that work as the first message in a new session (e.g. /plan, /env), without requiring an active session. Commands that depend on session state, authentication, or a synced session are omitted.
593    ///
594    /// Wire method: `commands.list`.
595    ///
596    /// # Returns
597    ///
598    /// Slash commands available in the session, after applying any include/exclude filters.
599    ///
600    /// <div class="warning">
601    ///
602    /// **Experimental.** This API is part of an experimental wire-protocol surface
603    /// and may change or be removed in future SDK or CLI releases. Pin both the
604    /// SDK and CLI versions if your code depends on it.
605    ///
606    /// </div>
607    pub async fn list(&self) -> Result<CommandList, Error> {
608        let wire_params = serde_json::json!({});
609        let _value = self
610            .client
611            .call(rpc_methods::COMMANDS_LIST, Some(wire_params))
612            .await?;
613        Ok(serde_json::from_value(_value)?)
614    }
615}
616
617/// `extensions.*` RPCs.
618#[derive(Clone, Copy)]
619pub struct ClientRpcExtensions<'a> {
620    pub(crate) client: &'a Client,
621}
622
623impl<'a> ClientRpcExtensions<'a> {
624    /// Discovers user and enabled installed-plugin extensions from persisted Copilot home state, including enablement preferences. Launch-scoped additional plugins are not included.
625    ///
626    /// Wire method: `extensions.discover`.
627    ///
628    /// # Returns
629    ///
630    /// Extensions discovered from persisted Copilot home state and their effective loading mode. Launch-scoped additional plugins are not included.
631    ///
632    /// <div class="warning">
633    ///
634    /// **Experimental.** This API is part of an experimental wire-protocol surface
635    /// and may change or be removed in future SDK or CLI releases. Pin both the
636    /// SDK and CLI versions if your code depends on it.
637    ///
638    /// </div>
639    pub async fn discover(&self) -> Result<DiscoveredExtensions, Error> {
640        let wire_params = serde_json::json!({});
641        let _value = self
642            .client
643            .call(rpc_methods::EXTENSIONS_DISCOVER, Some(wire_params))
644            .await?;
645        Ok(serde_json::from_value(_value)?)
646    }
647
648    /// Persistently enables extension IDs for future sessions. Active sessions are unchanged; use session.extensions.enable to update them.
649    ///
650    /// Wire method: `extensions.enable`.
651    ///
652    /// # Parameters
653    ///
654    /// * `params` - Source-qualified extension identifiers to persistently enable for future sessions.
655    ///
656    /// <div class="warning">
657    ///
658    /// **Experimental.** This API is part of an experimental wire-protocol surface
659    /// and may change or be removed in future SDK or CLI releases. Pin both the
660    /// SDK and CLI versions if your code depends on it.
661    ///
662    /// </div>
663    pub async fn enable(&self, params: DiscoveredExtensionsEnableRequest) -> Result<(), Error> {
664        let wire_params = serde_json::to_value(params)?;
665        let _value = self
666            .client
667            .call(rpc_methods::EXTENSIONS_ENABLE, Some(wire_params))
668            .await?;
669        Ok(())
670    }
671
672    /// Persistently disables extension IDs for future sessions. Active sessions are unchanged; use session.extensions.disable to update them.
673    ///
674    /// Wire method: `extensions.disable`.
675    ///
676    /// # Parameters
677    ///
678    /// * `params` - Source-qualified extension identifiers to persistently disable for future sessions.
679    ///
680    /// <div class="warning">
681    ///
682    /// **Experimental.** This API is part of an experimental wire-protocol surface
683    /// and may change or be removed in future SDK or CLI releases. Pin both the
684    /// SDK and CLI versions if your code depends on it.
685    ///
686    /// </div>
687    pub async fn disable(&self, params: DiscoveredExtensionsDisableRequest) -> Result<(), Error> {
688        let wire_params = serde_json::to_value(params)?;
689        let _value = self
690            .client
691            .call(rpc_methods::EXTENSIONS_DISABLE, Some(wire_params))
692            .await?;
693        Ok(())
694    }
695}
696
697/// `hooks.*` RPCs.
698#[derive(Clone, Copy)]
699pub struct ClientRpcHooks<'a> {
700    pub(crate) client: &'a Client,
701}
702
703impl<'a> ClientRpcHooks<'a> {
704    /// Discovers hook actions enabled under server-side discovery settings from user, repository, plugin, and managed-policy sources.
705    ///
706    /// Wire method: `hooks.discover`.
707    ///
708    /// # Parameters
709    ///
710    /// * `params` - Optional project paths and host-exclusion behavior for server-scoped hook discovery.
711    ///
712    /// # Returns
713    ///
714    /// Server-discovered hook actions and partial-load diagnostics from user, repository, plugin, and managed-policy sources. Concrete sessions may include additional session-specific hook sources.
715    ///
716    /// <div class="warning">
717    ///
718    /// **Experimental.** This API is part of an experimental wire-protocol surface
719    /// and may change or be removed in future SDK or CLI releases. Pin both the
720    /// SDK and CLI versions if your code depends on it.
721    ///
722    /// </div>
723    pub async fn discover(
724        &self,
725        params: HooksDiscoverRequest,
726    ) -> Result<HooksDiscoverResult, Error> {
727        let wire_params = serde_json::to_value(params)?;
728        let _value = self
729            .client
730            .call(rpc_methods::HOOKS_DISCOVER, Some(wire_params))
731            .await?;
732        Ok(serde_json::from_value(_value)?)
733    }
734}
735
736/// `instructions.*` RPCs.
737#[derive(Clone, Copy)]
738pub struct ClientRpcInstructions<'a> {
739    pub(crate) client: &'a Client,
740}
741
742impl<'a> ClientRpcInstructions<'a> {
743    /// Discovers instruction sources across user, repository, and plugin sources.
744    ///
745    /// Wire method: `instructions.discover`.
746    ///
747    /// # Parameters
748    ///
749    /// * `params` - Optional project paths to include in instruction discovery.
750    ///
751    /// # Returns
752    ///
753    /// Instruction sources discovered across user, repository, and plugin sources.
754    ///
755    /// <div class="warning">
756    ///
757    /// **Experimental.** This API is part of an experimental wire-protocol surface
758    /// and may change or be removed in future SDK or CLI releases. Pin both the
759    /// SDK and CLI versions if your code depends on it.
760    ///
761    /// </div>
762    pub async fn discover(
763        &self,
764        params: InstructionsDiscoverRequest,
765    ) -> Result<ServerInstructionSourceList, Error> {
766        let wire_params = serde_json::to_value(params)?;
767        let _value = self
768            .client
769            .call(rpc_methods::INSTRUCTIONS_DISCOVER, Some(wire_params))
770            .await?;
771        Ok(serde_json::from_value(_value)?)
772    }
773
774    /// 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.
775    ///
776    /// Wire method: `instructions.getDiscoveryPaths`.
777    ///
778    /// # Parameters
779    ///
780    /// * `params` - Optional project paths to include when enumerating instruction discovery targets.
781    ///
782    /// # Returns
783    ///
784    /// Canonical files and directories where custom instructions can be created so the runtime will recognize them.
785    ///
786    /// <div class="warning">
787    ///
788    /// **Experimental.** This API is part of an experimental wire-protocol surface
789    /// and may change or be removed in future SDK or CLI releases. Pin both the
790    /// SDK and CLI versions if your code depends on it.
791    ///
792    /// </div>
793    pub async fn get_discovery_paths(
794        &self,
795        params: InstructionsGetDiscoveryPathsRequest,
796    ) -> Result<InstructionDiscoveryPathList, Error> {
797        let wire_params = serde_json::to_value(params)?;
798        let _value = self
799            .client
800            .call(
801                rpc_methods::INSTRUCTIONS_GETDISCOVERYPATHS,
802                Some(wire_params),
803            )
804            .await?;
805        Ok(serde_json::from_value(_value)?)
806    }
807}
808
809/// `llmInference.*` RPCs.
810#[derive(Clone, Copy)]
811pub struct ClientRpcLlmInference<'a> {
812    pub(crate) client: &'a Client,
813}
814
815impl<'a> ClientRpcLlmInference<'a> {
816    /// Registers an SDK client as the LLM inference callback provider.
817    ///
818    /// Wire method: `llmInference.setProvider`.
819    ///
820    /// # Returns
821    ///
822    /// Indicates whether the calling client was registered as the LLM inference provider.
823    ///
824    /// <div class="warning">
825    ///
826    /// **Experimental.** This API is part of an experimental wire-protocol surface
827    /// and may change or be removed in future SDK or CLI releases. Pin both the
828    /// SDK and CLI versions if your code depends on it.
829    ///
830    /// </div>
831    pub async fn set_provider(&self) -> Result<LlmInferenceSetProviderResult, Error> {
832        let wire_params = serde_json::json!({});
833        let _value = self
834            .client
835            .call(rpc_methods::LLMINFERENCE_SETPROVIDER, Some(wire_params))
836            .await?;
837        Ok(serde_json::from_value(_value)?)
838    }
839
840    /// 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.
841    ///
842    /// Wire method: `llmInference.httpResponseStart`.
843    ///
844    /// # Parameters
845    ///
846    /// * `params` - Response head.
847    ///
848    /// # Returns
849    ///
850    /// Whether the start frame was accepted.
851    ///
852    /// <div class="warning">
853    ///
854    /// **Experimental.** This API is part of an experimental wire-protocol surface
855    /// and may change or be removed in future SDK or CLI releases. Pin both the
856    /// SDK and CLI versions if your code depends on it.
857    ///
858    /// </div>
859    pub async fn http_response_start(
860        &self,
861        params: LlmInferenceHttpResponseStartRequest,
862    ) -> Result<LlmInferenceHttpResponseStartResult, Error> {
863        let wire_params = serde_json::to_value(params)?;
864        let _value = self
865            .client
866            .call(
867                rpc_methods::LLMINFERENCE_HTTPRESPONSESTART,
868                Some(wire_params),
869            )
870            .await?;
871        Ok(serde_json::from_value(_value)?)
872    }
873
874    /// 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.
875    ///
876    /// Wire method: `llmInference.httpResponseChunk`.
877    ///
878    /// # Parameters
879    ///
880    /// * `params` - A response body chunk or terminal error.
881    ///
882    /// # Returns
883    ///
884    /// Whether the chunk was accepted.
885    ///
886    /// <div class="warning">
887    ///
888    /// **Experimental.** This API is part of an experimental wire-protocol surface
889    /// and may change or be removed in future SDK or CLI releases. Pin both the
890    /// SDK and CLI versions if your code depends on it.
891    ///
892    /// </div>
893    pub async fn http_response_chunk(
894        &self,
895        params: LlmInferenceHttpResponseChunkRequest,
896    ) -> Result<LlmInferenceHttpResponseChunkResult, Error> {
897        let wire_params = serde_json::to_value(params)?;
898        let _value = self
899            .client
900            .call(
901                rpc_methods::LLMINFERENCE_HTTPRESPONSECHUNK,
902                Some(wire_params),
903            )
904            .await?;
905        Ok(serde_json::from_value(_value)?)
906    }
907}
908
909/// `managedSettings.*` RPCs.
910#[derive(Clone, Copy)]
911pub struct ClientRpcManagedSettings<'a> {
912    pub(crate) client: &'a Client,
913}
914
915impl<'a> ClientRpcManagedSettings<'a> {
916    /// Discovers device-managed settings from production MDM and managed-file sources, validates them against the runtime-owned managed-settings schema, and returns the canonical JSON without requiring a session.
917    ///
918    /// Wire method: `managedSettings.read`.
919    ///
920    /// # Returns
921    ///
922    /// Validated device-managed settings discovered before a session exists.
923    ///
924    /// <div class="warning">
925    ///
926    /// **Experimental.** This API is part of an experimental wire-protocol surface
927    /// and may change or be removed in future SDK or CLI releases. Pin both the
928    /// SDK and CLI versions if your code depends on it.
929    ///
930    /// </div>
931    pub async fn read(&self) -> Result<ManagedSettingsReadResult, Error> {
932        let wire_params = serde_json::json!({});
933        let _value = self
934            .client
935            .call(rpc_methods::MANAGEDSETTINGS_READ, Some(wire_params))
936            .await?;
937        Ok(serde_json::from_value(_value)?)
938    }
939
940    /// Force-refreshes enterprise managed settings for every account: wipes the persistent server-policy cache (the whole `<cacheHome>/managed-settings` directory) and drops this runtime process's in-memory retained server policy. It does not itself fetch policy — the effect is that the next time a session resolves managed settings for an account, that resolution re-fetches the account's org policy from the network instead of serving a cached response. Note that `managedSettings.read` returns only device/MDM settings and never triggers the account server-policy fetch, so a host implementing "sync account policy" should start a fresh session resolution rather than treat a subsequent `managedSettings.read` as the refreshed org policy. Mirrors the invalidation a sign-out performs, broadened from the one signing-out account to all of them; device/MDM layers describe the machine, not the account, and are left untouched. Rejects if the on-disk cache cannot be removed.
941    ///
942    /// Wire method: `managedSettings.clearCache`.
943    ///
944    /// <div class="warning">
945    ///
946    /// **Experimental.** This API is part of an experimental wire-protocol surface
947    /// and may change or be removed in future SDK or CLI releases. Pin both the
948    /// SDK and CLI versions if your code depends on it.
949    ///
950    /// </div>
951    pub async fn clear_cache(&self) -> Result<(), Error> {
952        let wire_params = serde_json::json!({});
953        let _value = self
954            .client
955            .call(rpc_methods::MANAGEDSETTINGS_CLEARCACHE, Some(wire_params))
956            .await?;
957        Ok(())
958    }
959}
960
961/// `mcp.*` RPCs.
962#[derive(Clone, Copy)]
963pub struct ClientRpcMcp<'a> {
964    pub(crate) client: &'a Client,
965}
966
967impl<'a> ClientRpcMcp<'a> {
968    /// `mcp.config.*` sub-namespace.
969    pub fn config(&self) -> ClientRpcMcpConfig<'a> {
970        ClientRpcMcpConfig {
971            client: self.client,
972        }
973    }
974
975    /// Discovers MCP servers from user, workspace, plugin, and builtin sources.
976    ///
977    /// Wire method: `mcp.discover`.
978    ///
979    /// # Parameters
980    ///
981    /// * `params` - Optional working directory used as context for MCP server discovery.
982    ///
983    /// # Returns
984    ///
985    /// MCP servers discovered from user, workspace, plugin, and built-in sources.
986    ///
987    /// <div class="warning">
988    ///
989    /// **Experimental.** This API is part of an experimental wire-protocol surface
990    /// and may change or be removed in future SDK or CLI releases. Pin both the
991    /// SDK and CLI versions if your code depends on it.
992    ///
993    /// </div>
994    pub async fn discover(&self, params: McpDiscoverRequest) -> Result<McpDiscoverResult, Error> {
995        let wire_params = serde_json::to_value(params)?;
996        let _value = self
997            .client
998            .call(rpc_methods::MCP_DISCOVER, Some(wire_params))
999            .await?;
1000        Ok(serde_json::from_value(_value)?)
1001    }
1002
1003    /// Requests a side-effect-free MCP install plan from a catalog candidate handle or a caller-supplied card. This host-implemented server method is available through SDK/TUI hosts; standalone and C-ABI runtimes whose host does not implement server-method dispatch return JSON-RPC MethodNotFound. A runtime with planning available returns a normalised plan and opaque single-use plan handle; a runtime without it returns the typed planning-unavailable result. A completed plan reports resource identity, provenance, eligible transport choices, the user-scope target, required typed values and secret placeholders, the policy result, the configuration changes installing would make, and whether a reload would be needed. Planning never writes configuration, stores a secret, or reloads MCP servers, so abandoning a plan needs no call and leaves nothing behind.
1004    ///
1005    /// Wire method: `mcp.planInstall`.
1006    ///
1007    /// # Parameters
1008    ///
1009    /// * `params` - A side-effect-free request for an MCP install plan. Computing a plan never writes configuration, stores a secret, or reloads MCP servers.
1010    ///
1011    /// # Returns
1012    ///
1013    /// Outcome of an mcp.planInstall call: either a normalised plan, or one typed refusal. Nothing is written in either case.
1014    ///
1015    /// <div class="warning">
1016    ///
1017    /// **Experimental.** This API is part of an experimental wire-protocol surface
1018    /// and may change or be removed in future SDK or CLI releases. Pin both the
1019    /// SDK and CLI versions if your code depends on it.
1020    ///
1021    /// </div>
1022    pub async fn plan_install(
1023        &self,
1024        params: McpPlanInstallRequest,
1025    ) -> Result<McpPlanInstallResult, Error> {
1026        let wire_params = serde_json::to_value(params)?;
1027        let _value = self
1028            .client
1029            .call(rpc_methods::MCP_PLANINSTALL, Some(wire_params))
1030            .await?;
1031        Ok(serde_json::from_value(_value)?)
1032    }
1033}
1034
1035/// `mcp.config.*` RPCs.
1036#[derive(Clone, Copy)]
1037pub struct ClientRpcMcpConfig<'a> {
1038    pub(crate) client: &'a Client,
1039}
1040
1041impl<'a> ClientRpcMcpConfig<'a> {
1042    /// Lists MCP servers from user configuration.
1043    ///
1044    /// Wire method: `mcp.config.list`.
1045    ///
1046    /// # Returns
1047    ///
1048    /// User-configured MCP servers, keyed by server name.
1049    ///
1050    /// <div class="warning">
1051    ///
1052    /// **Experimental.** This API is part of an experimental wire-protocol surface
1053    /// and may change or be removed in future SDK or CLI releases. Pin both the
1054    /// SDK and CLI versions if your code depends on it.
1055    ///
1056    /// </div>
1057    pub async fn list(&self) -> Result<McpConfigList, Error> {
1058        let wire_params = serde_json::json!({});
1059        let _value = self
1060            .client
1061            .call(rpc_methods::MCP_CONFIG_LIST, Some(wire_params))
1062            .await?;
1063        Ok(serde_json::from_value(_value)?)
1064    }
1065
1066    /// Adds an MCP server to user configuration.
1067    ///
1068    /// Wire method: `mcp.config.add`.
1069    ///
1070    /// # Parameters
1071    ///
1072    /// * `params` - MCP server name and configuration to add to user configuration.
1073    ///
1074    /// <div class="warning">
1075    ///
1076    /// **Experimental.** This API is part of an experimental wire-protocol surface
1077    /// and may change or be removed in future SDK or CLI releases. Pin both the
1078    /// SDK and CLI versions if your code depends on it.
1079    ///
1080    /// </div>
1081    pub async fn add(&self, params: McpConfigAddRequest) -> Result<(), Error> {
1082        let wire_params = serde_json::to_value(params)?;
1083        let _value = self
1084            .client
1085            .call(rpc_methods::MCP_CONFIG_ADD, Some(wire_params))
1086            .await?;
1087        Ok(())
1088    }
1089
1090    /// Updates an MCP server in user configuration.
1091    ///
1092    /// Wire method: `mcp.config.update`.
1093    ///
1094    /// # Parameters
1095    ///
1096    /// * `params` - MCP server name and replacement configuration to write to user configuration.
1097    ///
1098    /// <div class="warning">
1099    ///
1100    /// **Experimental.** This API is part of an experimental wire-protocol surface
1101    /// and may change or be removed in future SDK or CLI releases. Pin both the
1102    /// SDK and CLI versions if your code depends on it.
1103    ///
1104    /// </div>
1105    pub async fn update(&self, params: McpConfigUpdateRequest) -> Result<(), Error> {
1106        let wire_params = serde_json::to_value(params)?;
1107        let _value = self
1108            .client
1109            .call(rpc_methods::MCP_CONFIG_UPDATE, Some(wire_params))
1110            .await?;
1111        Ok(())
1112    }
1113
1114    /// Removes an MCP server from user configuration.
1115    ///
1116    /// Wire method: `mcp.config.remove`.
1117    ///
1118    /// # Parameters
1119    ///
1120    /// * `params` - MCP server name to remove from user configuration.
1121    ///
1122    /// <div class="warning">
1123    ///
1124    /// **Experimental.** This API is part of an experimental wire-protocol surface
1125    /// and may change or be removed in future SDK or CLI releases. Pin both the
1126    /// SDK and CLI versions if your code depends on it.
1127    ///
1128    /// </div>
1129    pub async fn remove(&self, params: McpConfigRemoveRequest) -> Result<(), Error> {
1130        let wire_params = serde_json::to_value(params)?;
1131        let _value = self
1132            .client
1133            .call(rpc_methods::MCP_CONFIG_REMOVE, Some(wire_params))
1134            .await?;
1135        Ok(())
1136    }
1137
1138    /// Enables MCP servers in user configuration for new sessions.
1139    ///
1140    /// Wire method: `mcp.config.enable`.
1141    ///
1142    /// # Parameters
1143    ///
1144    /// * `params` - MCP server names to enable for new sessions.
1145    ///
1146    /// <div class="warning">
1147    ///
1148    /// **Experimental.** This API is part of an experimental wire-protocol surface
1149    /// and may change or be removed in future SDK or CLI releases. Pin both the
1150    /// SDK and CLI versions if your code depends on it.
1151    ///
1152    /// </div>
1153    pub async fn enable(&self, params: McpConfigEnableRequest) -> Result<(), Error> {
1154        let wire_params = serde_json::to_value(params)?;
1155        let _value = self
1156            .client
1157            .call(rpc_methods::MCP_CONFIG_ENABLE, Some(wire_params))
1158            .await?;
1159        Ok(())
1160    }
1161
1162    /// Disables MCP servers in user configuration for new sessions.
1163    ///
1164    /// Wire method: `mcp.config.disable`.
1165    ///
1166    /// # Parameters
1167    ///
1168    /// * `params` - MCP server names to disable for new sessions.
1169    ///
1170    /// <div class="warning">
1171    ///
1172    /// **Experimental.** This API is part of an experimental wire-protocol surface
1173    /// and may change or be removed in future SDK or CLI releases. Pin both the
1174    /// SDK and CLI versions if your code depends on it.
1175    ///
1176    /// </div>
1177    pub async fn disable(&self, params: McpConfigDisableRequest) -> Result<(), Error> {
1178        let wire_params = serde_json::to_value(params)?;
1179        let _value = self
1180            .client
1181            .call(rpc_methods::MCP_CONFIG_DISABLE, Some(wire_params))
1182            .await?;
1183        Ok(())
1184    }
1185
1186    /// Drops this runtime process's in-memory MCP server-definition cache so the next MCP config read observes disk.
1187    ///
1188    /// Wire method: `mcp.config.reload`.
1189    ///
1190    /// <div class="warning">
1191    ///
1192    /// **Experimental.** This API is part of an experimental wire-protocol surface
1193    /// and may change or be removed in future SDK or CLI releases. Pin both the
1194    /// SDK and CLI versions if your code depends on it.
1195    ///
1196    /// </div>
1197    pub async fn reload(&self) -> Result<(), Error> {
1198        let wire_params = serde_json::json!({});
1199        let _value = self
1200            .client
1201            .call(rpc_methods::MCP_CONFIG_RELOAD, Some(wire_params))
1202            .await?;
1203        Ok(())
1204    }
1205}
1206
1207/// `models.*` RPCs.
1208#[derive(Clone, Copy)]
1209pub struct ClientRpcModels<'a> {
1210    pub(crate) client: &'a Client,
1211}
1212
1213impl<'a> ClientRpcModels<'a> {
1214    /// Lists Copilot models available to the authenticated user.
1215    ///
1216    /// Wire method: `models.list`.
1217    ///
1218    /// # Returns
1219    ///
1220    /// List of Copilot models available to the resolved user, including capabilities and billing metadata.
1221    ///
1222    /// <div class="warning">
1223    ///
1224    /// **Experimental.** This API is part of an experimental wire-protocol surface
1225    /// and may change or be removed in future SDK or CLI releases. Pin both the
1226    /// SDK and CLI versions if your code depends on it.
1227    ///
1228    /// </div>
1229    pub async fn list(&self) -> Result<ModelList, Error> {
1230        let wire_params = serde_json::json!({});
1231        let _value = self
1232            .client
1233            .call(rpc_methods::MODELS_LIST, Some(wire_params))
1234            .await?;
1235        Ok(serde_json::from_value(_value)?)
1236    }
1237
1238    /// Lists Copilot models available to the authenticated user.
1239    ///
1240    /// Wire method: `models.list`.
1241    ///
1242    /// # Parameters
1243    ///
1244    /// * `params` - Optional opaque account selection or compatibility GitHub token used to list models.
1245    ///
1246    /// # Returns
1247    ///
1248    /// List of Copilot models available to the resolved user, including capabilities and billing metadata.
1249    ///
1250    /// <div class="warning">
1251    ///
1252    /// **Experimental.** This API is part of an experimental wire-protocol surface
1253    /// and may change or be removed in future SDK or CLI releases. Pin both the
1254    /// SDK and CLI versions if your code depends on it.
1255    ///
1256    /// </div>
1257    pub async fn list_with_params(&self, params: ModelsListRequest) -> Result<ModelList, Error> {
1258        let wire_params = serde_json::to_value(params)?;
1259        let _value = self
1260            .client
1261            .call(rpc_methods::MODELS_LIST, Some(wire_params))
1262            .await?;
1263        Ok(serde_json::from_value(_value)?)
1264    }
1265
1266    /// Returns the running runtime's complete catalog of well-known built-in model IDs without authentication or network access.
1267    ///
1268    /// Wire method: `models.getBuiltInCatalog`.
1269    ///
1270    /// # Returns
1271    ///
1272    /// The running runtime's complete catalog of well-known built-in model IDs, including supported models and additional IDs with built-in metadata.
1273    ///
1274    /// <div class="warning">
1275    ///
1276    /// **Experimental.** This API is part of an experimental wire-protocol surface
1277    /// and may change or be removed in future SDK or CLI releases. Pin both the
1278    /// SDK and CLI versions if your code depends on it.
1279    ///
1280    /// </div>
1281    pub async fn get_built_in_catalog(&self) -> Result<BuiltInModelCatalog, Error> {
1282        let wire_params = serde_json::json!({});
1283        let _value = self
1284            .client
1285            .call(rpc_methods::MODELS_GETBUILTINCATALOG, Some(wire_params))
1286            .await?;
1287        Ok(serde_json::from_value(_value)?)
1288    }
1289}
1290
1291/// `plugins.*` RPCs.
1292#[derive(Clone, Copy)]
1293pub struct ClientRpcPlugins<'a> {
1294    pub(crate) client: &'a Client,
1295}
1296
1297impl<'a> ClientRpcPlugins<'a> {
1298    /// `plugins.builtin.*` sub-namespace.
1299    pub fn builtin(&self) -> ClientRpcPluginsBuiltin<'a> {
1300        ClientRpcPluginsBuiltin {
1301            client: self.client,
1302        }
1303    }
1304
1305    /// `plugins.marketplaces.*` sub-namespace.
1306    pub fn marketplaces(&self) -> ClientRpcPluginsMarketplaces<'a> {
1307        ClientRpcPluginsMarketplaces {
1308            client: self.client,
1309        }
1310    }
1311
1312    /// Lists plugins installed in user/global state.
1313    ///
1314    /// Wire method: `plugins.list`.
1315    ///
1316    /// # Returns
1317    ///
1318    /// Plugins installed in user/global state.
1319    ///
1320    /// <div class="warning">
1321    ///
1322    /// **Experimental.** This API is part of an experimental wire-protocol surface
1323    /// and may change or be removed in future SDK or CLI releases. Pin both the
1324    /// SDK and CLI versions if your code depends on it.
1325    ///
1326    /// </div>
1327    pub async fn list(&self) -> Result<PluginListResult, Error> {
1328        let wire_params = serde_json::json!({});
1329        let _value = self
1330            .client
1331            .call(rpc_methods::PLUGINS_LIST, Some(wire_params))
1332            .await?;
1333        Ok(serde_json::from_value(_value)?)
1334    }
1335
1336    /// Installs a plugin from a marketplace, GitHub repo, URL, or local path.
1337    ///
1338    /// Wire method: `plugins.install`.
1339    ///
1340    /// # Parameters
1341    ///
1342    /// * `params` - Plugin source and optional working directory for relative-path resolution.
1343    ///
1344    /// # Returns
1345    ///
1346    /// Result of installing a plugin.
1347    ///
1348    /// <div class="warning">
1349    ///
1350    /// **Experimental.** This API is part of an experimental wire-protocol surface
1351    /// and may change or be removed in future SDK or CLI releases. Pin both the
1352    /// SDK and CLI versions if your code depends on it.
1353    ///
1354    /// </div>
1355    pub async fn install(
1356        &self,
1357        params: PluginsInstallRequest,
1358    ) -> Result<PluginInstallResult, Error> {
1359        let wire_params = serde_json::to_value(params)?;
1360        let _value = self
1361            .client
1362            .call(rpc_methods::PLUGINS_INSTALL, Some(wire_params))
1363            .await?;
1364        Ok(serde_json::from_value(_value)?)
1365    }
1366
1367    /// Uninstalls an installed plugin.
1368    ///
1369    /// Wire method: `plugins.uninstall`.
1370    ///
1371    /// # Parameters
1372    ///
1373    /// * `params` - Name (or spec) of the plugin to uninstall.
1374    ///
1375    /// <div class="warning">
1376    ///
1377    /// **Experimental.** This API is part of an experimental wire-protocol surface
1378    /// and may change or be removed in future SDK or CLI releases. Pin both the
1379    /// SDK and CLI versions if your code depends on it.
1380    ///
1381    /// </div>
1382    pub async fn uninstall(&self, params: PluginsUninstallRequest) -> Result<(), Error> {
1383        let wire_params = serde_json::to_value(params)?;
1384        let _value = self
1385            .client
1386            .call(rpc_methods::PLUGINS_UNINSTALL, Some(wire_params))
1387            .await?;
1388        Ok(())
1389    }
1390
1391    /// Updates an installed plugin to its latest published version.
1392    ///
1393    /// Wire method: `plugins.update`.
1394    ///
1395    /// # Parameters
1396    ///
1397    /// * `params` - Name (or spec) of the plugin to update.
1398    ///
1399    /// # Returns
1400    ///
1401    /// Result of updating a single plugin.
1402    ///
1403    /// <div class="warning">
1404    ///
1405    /// **Experimental.** This API is part of an experimental wire-protocol surface
1406    /// and may change or be removed in future SDK or CLI releases. Pin both the
1407    /// SDK and CLI versions if your code depends on it.
1408    ///
1409    /// </div>
1410    pub async fn update(&self, params: PluginsUpdateRequest) -> Result<PluginUpdateResult, Error> {
1411        let wire_params = serde_json::to_value(params)?;
1412        let _value = self
1413            .client
1414            .call(rpc_methods::PLUGINS_UPDATE, Some(wire_params))
1415            .await?;
1416        Ok(serde_json::from_value(_value)?)
1417    }
1418
1419    /// Updates every installed plugin to its latest published version.
1420    ///
1421    /// Wire method: `plugins.updateAll`.
1422    ///
1423    /// # Returns
1424    ///
1425    /// Result of updating all installed plugins.
1426    ///
1427    /// <div class="warning">
1428    ///
1429    /// **Experimental.** This API is part of an experimental wire-protocol surface
1430    /// and may change or be removed in future SDK or CLI releases. Pin both the
1431    /// SDK and CLI versions if your code depends on it.
1432    ///
1433    /// </div>
1434    pub async fn update_all(&self) -> Result<PluginUpdateAllResult, Error> {
1435        let wire_params = serde_json::json!({});
1436        let _value = self
1437            .client
1438            .call(rpc_methods::PLUGINS_UPDATEALL, Some(wire_params))
1439            .await?;
1440        Ok(serde_json::from_value(_value)?)
1441    }
1442
1443    /// Enables installed plugins for new sessions.
1444    ///
1445    /// Wire method: `plugins.enable`.
1446    ///
1447    /// # Parameters
1448    ///
1449    /// * `params` - Plugin names (or specs) to enable, plus the optional working directory the repository-controlled guard is evaluated against.
1450    ///
1451    /// <div class="warning">
1452    ///
1453    /// **Experimental.** This API is part of an experimental wire-protocol surface
1454    /// and may change or be removed in future SDK or CLI releases. Pin both the
1455    /// SDK and CLI versions if your code depends on it.
1456    ///
1457    /// </div>
1458    pub async fn enable(&self, params: PluginsEnableRequest) -> Result<(), Error> {
1459        let wire_params = serde_json::to_value(params)?;
1460        let _value = self
1461            .client
1462            .call(rpc_methods::PLUGINS_ENABLE, Some(wire_params))
1463            .await?;
1464        Ok(())
1465    }
1466
1467    /// Disables installed plugins for new sessions.
1468    ///
1469    /// Wire method: `plugins.disable`.
1470    ///
1471    /// # Parameters
1472    ///
1473    /// * `params` - Plugin names (or specs) to disable, plus the optional working directory the repository-controlled guard is evaluated against.
1474    ///
1475    /// <div class="warning">
1476    ///
1477    /// **Experimental.** This API is part of an experimental wire-protocol surface
1478    /// and may change or be removed in future SDK or CLI releases. Pin both the
1479    /// SDK and CLI versions if your code depends on it.
1480    ///
1481    /// </div>
1482    pub async fn disable(&self, params: PluginsDisableRequest) -> Result<(), Error> {
1483        let wire_params = serde_json::to_value(params)?;
1484        let _value = self
1485            .client
1486            .call(rpc_methods::PLUGINS_DISABLE, Some(wire_params))
1487            .await?;
1488        Ok(())
1489    }
1490}
1491
1492/// `plugins.builtin.*` RPCs.
1493#[derive(Clone, Copy)]
1494pub struct ClientRpcPluginsBuiltin<'a> {
1495    pub(crate) client: &'a Client,
1496}
1497
1498impl<'a> ClientRpcPluginsBuiltin<'a> {
1499    /// Replaces this server's trusted built-in plugin directories while no sessions are active.
1500    ///
1501    /// Wire method: `plugins.builtin.set`.
1502    ///
1503    /// # Parameters
1504    ///
1505    /// * `params` - Trusted built-in plugin directories to use for this runtime process.
1506    ///
1507    /// <div class="warning">
1508    ///
1509    /// **Experimental.** This API is part of an experimental wire-protocol surface
1510    /// and may change or be removed in future SDK or CLI releases. Pin both the
1511    /// SDK and CLI versions if your code depends on it.
1512    ///
1513    /// </div>
1514    pub async fn set(&self, params: PluginsBuiltinSetRequest) -> Result<(), Error> {
1515        let wire_params = serde_json::to_value(params)?;
1516        let _value = self
1517            .client
1518            .call(rpc_methods::PLUGINS_BUILTIN_SET, Some(wire_params))
1519            .await?;
1520        Ok(())
1521    }
1522}
1523
1524/// `plugins.marketplaces.*` RPCs.
1525#[derive(Clone, Copy)]
1526pub struct ClientRpcPluginsMarketplaces<'a> {
1527    pub(crate) client: &'a Client,
1528}
1529
1530impl<'a> ClientRpcPluginsMarketplaces<'a> {
1531    /// Lists all registered marketplaces (defaults + user-added).
1532    ///
1533    /// Wire method: `plugins.marketplaces.list`.
1534    ///
1535    /// # Returns
1536    ///
1537    /// All registered marketplaces, including built-in defaults.
1538    ///
1539    /// <div class="warning">
1540    ///
1541    /// **Experimental.** This API is part of an experimental wire-protocol surface
1542    /// and may change or be removed in future SDK or CLI releases. Pin both the
1543    /// SDK and CLI versions if your code depends on it.
1544    ///
1545    /// </div>
1546    pub async fn list(&self) -> Result<MarketplaceListResult, Error> {
1547        let wire_params = serde_json::json!({});
1548        let _value = self
1549            .client
1550            .call(rpc_methods::PLUGINS_MARKETPLACES_LIST, Some(wire_params))
1551            .await?;
1552        Ok(serde_json::from_value(_value)?)
1553    }
1554
1555    /// Registers a new marketplace from a source (owner/repo, URL, or local path).
1556    ///
1557    /// Wire method: `plugins.marketplaces.add`.
1558    ///
1559    /// # Parameters
1560    ///
1561    /// * `params` - Marketplace source and optional working directory for relative-path resolution.
1562    ///
1563    /// # Returns
1564    ///
1565    /// Result of registering a new marketplace.
1566    ///
1567    /// <div class="warning">
1568    ///
1569    /// **Experimental.** This API is part of an experimental wire-protocol surface
1570    /// and may change or be removed in future SDK or CLI releases. Pin both the
1571    /// SDK and CLI versions if your code depends on it.
1572    ///
1573    /// </div>
1574    pub async fn add(
1575        &self,
1576        params: PluginsMarketplacesAddRequest,
1577    ) -> Result<MarketplaceAddResult, Error> {
1578        let wire_params = serde_json::to_value(params)?;
1579        let _value = self
1580            .client
1581            .call(rpc_methods::PLUGINS_MARKETPLACES_ADD, Some(wire_params))
1582            .await?;
1583        Ok(serde_json::from_value(_value)?)
1584    }
1585
1586    /// 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`.
1587    ///
1588    /// Wire method: `plugins.marketplaces.remove`.
1589    ///
1590    /// # Parameters
1591    ///
1592    /// * `params` - Name of the marketplace to remove and an optional force flag.
1593    ///
1594    /// # Returns
1595    ///
1596    /// Outcome of the remove attempt, including dependent-plugin info when applicable.
1597    ///
1598    /// <div class="warning">
1599    ///
1600    /// **Experimental.** This API is part of an experimental wire-protocol surface
1601    /// and may change or be removed in future SDK or CLI releases. Pin both the
1602    /// SDK and CLI versions if your code depends on it.
1603    ///
1604    /// </div>
1605    pub async fn remove(
1606        &self,
1607        params: PluginsMarketplacesRemoveRequest,
1608    ) -> Result<MarketplaceRemoveResult, Error> {
1609        let wire_params = serde_json::to_value(params)?;
1610        let _value = self
1611            .client
1612            .call(rpc_methods::PLUGINS_MARKETPLACES_REMOVE, Some(wire_params))
1613            .await?;
1614        Ok(serde_json::from_value(_value)?)
1615    }
1616
1617    /// Lists plugins advertised by a registered marketplace.
1618    ///
1619    /// Wire method: `plugins.marketplaces.browse`.
1620    ///
1621    /// # Parameters
1622    ///
1623    /// * `params` - Name of the marketplace whose plugin catalog to fetch.
1624    ///
1625    /// # Returns
1626    ///
1627    /// Plugins advertised by the marketplace.
1628    ///
1629    /// <div class="warning">
1630    ///
1631    /// **Experimental.** This API is part of an experimental wire-protocol surface
1632    /// and may change or be removed in future SDK or CLI releases. Pin both the
1633    /// SDK and CLI versions if your code depends on it.
1634    ///
1635    /// </div>
1636    pub async fn browse(
1637        &self,
1638        params: PluginsMarketplacesBrowseRequest,
1639    ) -> Result<MarketplaceBrowseResult, Error> {
1640        let wire_params = serde_json::to_value(params)?;
1641        let _value = self
1642            .client
1643            .call(rpc_methods::PLUGINS_MARKETPLACES_BROWSE, Some(wire_params))
1644            .await?;
1645        Ok(serde_json::from_value(_value)?)
1646    }
1647
1648    /// Re-fetches one or all registered marketplace catalogs.
1649    ///
1650    /// Wire method: `plugins.marketplaces.refresh`.
1651    ///
1652    /// # Returns
1653    ///
1654    /// Result of refreshing one or more marketplace catalogs.
1655    ///
1656    /// <div class="warning">
1657    ///
1658    /// **Experimental.** This API is part of an experimental wire-protocol surface
1659    /// and may change or be removed in future SDK or CLI releases. Pin both the
1660    /// SDK and CLI versions if your code depends on it.
1661    ///
1662    /// </div>
1663    pub async fn refresh(&self) -> Result<MarketplaceRefreshResult, Error> {
1664        let wire_params = serde_json::json!({});
1665        let _value = self
1666            .client
1667            .call(rpc_methods::PLUGINS_MARKETPLACES_REFRESH, Some(wire_params))
1668            .await?;
1669        Ok(serde_json::from_value(_value)?)
1670    }
1671
1672    /// Re-fetches one or all registered marketplace catalogs.
1673    ///
1674    /// Wire method: `plugins.marketplaces.refresh`.
1675    ///
1676    /// # Parameters
1677    ///
1678    /// * `params` - Optional marketplace name; omit to refresh all.
1679    ///
1680    /// # Returns
1681    ///
1682    /// Result of refreshing one or more marketplace catalogs.
1683    ///
1684    /// <div class="warning">
1685    ///
1686    /// **Experimental.** This API is part of an experimental wire-protocol surface
1687    /// and may change or be removed in future SDK or CLI releases. Pin both the
1688    /// SDK and CLI versions if your code depends on it.
1689    ///
1690    /// </div>
1691    pub async fn refresh_with_params(
1692        &self,
1693        params: PluginsMarketplacesRefreshRequest,
1694    ) -> Result<MarketplaceRefreshResult, Error> {
1695        let wire_params = serde_json::to_value(params)?;
1696        let _value = self
1697            .client
1698            .call(rpc_methods::PLUGINS_MARKETPLACES_REFRESH, Some(wire_params))
1699            .await?;
1700        Ok(serde_json::from_value(_value)?)
1701    }
1702}
1703
1704/// `runtime.*` RPCs.
1705#[derive(Clone, Copy)]
1706pub struct ClientRpcRuntime<'a> {
1707    pub(crate) client: &'a Client,
1708}
1709
1710impl<'a> ClientRpcRuntime<'a> {
1711    /// Gracefully shuts down an SDK-owned runtime. The response is sent only after cleanup completes; callers may then terminate the owned runtime process.
1712    ///
1713    /// Wire method: `runtime.shutdown`.
1714    ///
1715    /// <div class="warning">
1716    ///
1717    /// **Experimental.** This API is part of an experimental wire-protocol surface
1718    /// and may change or be removed in future SDK or CLI releases. Pin both the
1719    /// SDK and CLI versions if your code depends on it.
1720    ///
1721    /// </div>
1722    pub async fn shutdown(&self) -> Result<(), Error> {
1723        let wire_params = serde_json::json!({});
1724        let _value = self
1725            .client
1726            .call(rpc_methods::RUNTIME_SHUTDOWN, Some(wire_params))
1727            .await?;
1728        Ok(())
1729    }
1730}
1731
1732/// `secrets.*` RPCs.
1733#[derive(Clone, Copy)]
1734pub struct ClientRpcSecrets<'a> {
1735    pub(crate) client: &'a Client,
1736}
1737
1738impl<'a> ClientRpcSecrets<'a> {
1739    /// Registers secret values for redaction in session logs and exports. The SDK calls this to inject dynamically generated secret values (e.g., OIDC tokens).
1740    ///
1741    /// Wire method: `secrets.addFilterValues`.
1742    ///
1743    /// # Parameters
1744    ///
1745    /// * `params` - Secret values to add to the redaction filter.
1746    ///
1747    /// # Returns
1748    ///
1749    /// Confirmation that the secret values were registered.
1750    ///
1751    /// <div class="warning">
1752    ///
1753    /// **Experimental.** This API is part of an experimental wire-protocol surface
1754    /// and may change or be removed in future SDK or CLI releases. Pin both the
1755    /// SDK and CLI versions if your code depends on it.
1756    ///
1757    /// </div>
1758    pub async fn add_filter_values(
1759        &self,
1760        params: SecretsAddFilterValuesRequest,
1761    ) -> Result<SecretsAddFilterValuesResult, Error> {
1762        let wire_params = serde_json::to_value(params)?;
1763        let _value = self
1764            .client
1765            .call(rpc_methods::SECRETS_ADDFILTERVALUES, Some(wire_params))
1766            .await?;
1767        Ok(serde_json::from_value(_value)?)
1768    }
1769}
1770
1771/// `sessionFs.*` RPCs.
1772#[derive(Clone, Copy)]
1773pub struct ClientRpcSessionFs<'a> {
1774    pub(crate) client: &'a Client,
1775}
1776
1777impl<'a> ClientRpcSessionFs<'a> {
1778    /// Registers an SDK client as the session filesystem provider.
1779    ///
1780    /// Wire method: `sessionFs.setProvider`.
1781    ///
1782    /// # Parameters
1783    ///
1784    /// * `params` - Initial working directory, session-state path layout, and path conventions used to register the calling SDK client as the session filesystem provider. A registered provider is authoritative for path interpretation and filesystem facts used by workspace permission validation. Paths are interpreted lexically; home-relative paths (`~` and `~/...`) and Windows drive-relative paths such as `C:foo` are unsupported. Until provider-side canonicalization is supported, providers must not expose symlinks inside allowed roots that escape those roots.
1785    ///
1786    /// # Returns
1787    ///
1788    /// Indicates whether the calling client was registered as the session filesystem provider.
1789    ///
1790    /// <div class="warning">
1791    ///
1792    /// **Experimental.** This API is part of an experimental wire-protocol surface
1793    /// and may change or be removed in future SDK or CLI releases. Pin both the
1794    /// SDK and CLI versions if your code depends on it.
1795    ///
1796    /// </div>
1797    pub async fn set_provider(
1798        &self,
1799        params: SessionFsSetProviderRequest,
1800    ) -> Result<SessionFsSetProviderResult, Error> {
1801        let wire_params = serde_json::to_value(params)?;
1802        let _value = self
1803            .client
1804            .call(rpc_methods::SESSIONFS_SETPROVIDER, Some(wire_params))
1805            .await?;
1806        Ok(serde_json::from_value(_value)?)
1807    }
1808}
1809
1810/// `sessions.*` RPCs.
1811#[derive(Clone, Copy)]
1812pub struct ClientRpcSessions<'a> {
1813    pub(crate) client: &'a Client,
1814}
1815
1816impl<'a> ClientRpcSessions<'a> {
1817    /// Creates or resumes a local session and returns the opened session ID.
1818    ///
1819    /// Wire method: `sessions.open`.
1820    ///
1821    /// # Returns
1822    ///
1823    /// Result of opening a session.
1824    ///
1825    /// <div class="warning">
1826    ///
1827    /// **Experimental.** This API is part of an experimental wire-protocol surface
1828    /// and may change or be removed in future SDK or CLI releases. Pin both the
1829    /// SDK and CLI versions if your code depends on it.
1830    ///
1831    /// </div>
1832    pub async fn open(&self) -> Result<SessionOpenResult, Error> {
1833        let wire_params = serde_json::json!({});
1834        let _value = self
1835            .client
1836            .call(rpc_methods::SESSIONS_OPEN, Some(wire_params))
1837            .await?;
1838        Ok(serde_json::from_value(_value)?)
1839    }
1840
1841    /// Creates a new session by forking persisted history from an existing session.
1842    ///
1843    /// Wire method: `sessions.fork`.
1844    ///
1845    /// # Parameters
1846    ///
1847    /// * `params` - Source session identifier to fork from, optional event-ID boundary, and optional friendly name for the new session.
1848    ///
1849    /// # Returns
1850    ///
1851    /// Identifier and optional friendly name assigned to the newly forked session.
1852    ///
1853    /// <div class="warning">
1854    ///
1855    /// **Experimental.** This API is part of an experimental wire-protocol surface
1856    /// and may change or be removed in future SDK or CLI releases. Pin both the
1857    /// SDK and CLI versions if your code depends on it.
1858    ///
1859    /// </div>
1860    pub async fn fork(&self, params: SessionsForkRequest) -> Result<SessionsForkResult, Error> {
1861        let wire_params = serde_json::to_value(params)?;
1862        let _value = self
1863            .client
1864            .call(rpc_methods::SESSIONS_FORK, Some(wire_params))
1865            .await?;
1866        Ok(serde_json::from_value(_value)?)
1867    }
1868
1869    /// Connects to an existing remote session and exposes it as an SDK session.
1870    ///
1871    /// Wire method: `sessions.connect`.
1872    ///
1873    /// # Parameters
1874    ///
1875    /// * `params` - Remote session connection parameters.
1876    ///
1877    /// # Returns
1878    ///
1879    /// Remote session connection result.
1880    ///
1881    /// <div class="warning">
1882    ///
1883    /// **Experimental.** This API is part of an experimental wire-protocol surface
1884    /// and may change or be removed in future SDK or CLI releases. Pin both the
1885    /// SDK and CLI versions if your code depends on it.
1886    ///
1887    /// </div>
1888    pub async fn connect(
1889        &self,
1890        params: ConnectRemoteSessionParams,
1891    ) -> Result<RemoteSessionConnectionResult, Error> {
1892        let wire_params = serde_json::to_value(params)?;
1893        let _value = self
1894            .client
1895            .call(rpc_methods::SESSIONS_CONNECT, Some(wire_params))
1896            .await?;
1897        Ok(serde_json::from_value(_value)?)
1898    }
1899
1900    /// 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.).
1901    ///
1902    /// Wire method: `sessions.list`.
1903    ///
1904    /// # Returns
1905    ///
1906    /// Sessions matching the filter, ordered most-recently-modified first.
1907    ///
1908    /// <div class="warning">
1909    ///
1910    /// **Experimental.** This API is part of an experimental wire-protocol surface
1911    /// and may change or be removed in future SDK or CLI releases. Pin both the
1912    /// SDK and CLI versions if your code depends on it.
1913    ///
1914    /// </div>
1915    pub async fn list(&self) -> Result<SessionList, Error> {
1916        let wire_params = serde_json::json!({});
1917        let _value = self
1918            .client
1919            .call(rpc_methods::SESSIONS_LIST, Some(wire_params))
1920            .await?;
1921        Ok(serde_json::from_value(_value)?)
1922    }
1923
1924    /// 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.).
1925    ///
1926    /// Wire method: `sessions.list`.
1927    ///
1928    /// # Parameters
1929    ///
1930    /// * `params` - Optional source filter, metadata-load limit, and context filter applied to the returned sessions.
1931    ///
1932    /// # Returns
1933    ///
1934    /// Sessions matching the filter, ordered most-recently-modified first.
1935    ///
1936    /// <div class="warning">
1937    ///
1938    /// **Experimental.** This API is part of an experimental wire-protocol surface
1939    /// and may change or be removed in future SDK or CLI releases. Pin both the
1940    /// SDK and CLI versions if your code depends on it.
1941    ///
1942    /// </div>
1943    pub async fn list_with_params(
1944        &self,
1945        params: SessionsListRequest,
1946    ) -> Result<SessionList, Error> {
1947        let wire_params = serde_json::to_value(params)?;
1948        let _value = self
1949            .client
1950            .call(rpc_methods::SESSIONS_LIST, Some(wire_params))
1951            .await?;
1952        Ok(serde_json::from_value(_value)?)
1953    }
1954
1955    /// Reads lightweight persisted metadata for one local session without opening it.
1956    ///
1957    /// Wire method: `sessions.getMetadata`.
1958    ///
1959    /// # Parameters
1960    ///
1961    /// * `params` - Session ID whose persisted metadata should be read.
1962    ///
1963    /// # Returns
1964    ///
1965    /// Persisted local session metadata when the session exists.
1966    ///
1967    /// <div class="warning">
1968    ///
1969    /// **Experimental.** This API is part of an experimental wire-protocol surface
1970    /// and may change or be removed in future SDK or CLI releases. Pin both the
1971    /// SDK and CLI versions if your code depends on it.
1972    ///
1973    /// </div>
1974    pub(crate) async fn get_metadata(
1975        &self,
1976        params: SessionsGetMetadataRequest,
1977    ) -> Result<SessionsGetMetadataResult, Error> {
1978        let wire_params = serde_json::to_value(params)?;
1979        let _value = self
1980            .client
1981            .call(rpc_methods::SESSIONS_GETMETADATA, Some(wire_params))
1982            .await?;
1983        Ok(serde_json::from_value(_value)?)
1984    }
1985
1986    /// Reads client-owned metadata for multiple persisted local sessions without opening them. Results preserve request order and report missing, corrupt, unsupported, or temporarily unavailable sessions independently.
1987    ///
1988    /// Wire method: `sessions.getClientMetadata`.
1989    ///
1990    /// # Parameters
1991    ///
1992    /// * `params` - Bounded batch request for client-owned metadata from persisted local sessions.
1993    ///
1994    /// # Returns
1995    ///
1996    /// Ordered client metadata outcomes for the requested local sessions.
1997    ///
1998    /// <div class="warning">
1999    ///
2000    /// **Experimental.** This API is part of an experimental wire-protocol surface
2001    /// and may change or be removed in future SDK or CLI releases. Pin both the
2002    /// SDK and CLI versions if your code depends on it.
2003    ///
2004    /// </div>
2005    pub async fn get_client_metadata(
2006        &self,
2007        params: SessionsGetClientMetadataRequest,
2008    ) -> Result<SessionsGetClientMetadataResult, Error> {
2009        let wire_params = serde_json::to_value(params)?;
2010        let _value = self
2011            .client
2012            .call(rpc_methods::SESSIONS_GETCLIENTMETADATA, Some(wire_params))
2013            .await?;
2014        Ok(serde_json::from_value(_value)?)
2015    }
2016
2017    /// Reads a page of durable events directly from a local session's persisted journal without creating, resuming, or activating the session. The first read pins the currently opened journal generation and its byte-length boundary; opaque cursor continuations remain on that generation across runtime-owned compaction, truncation, and rewrite operations, which replace the live path atomically, and events appended after the boundary are excluded. For cold hydration, await the first successful page before activation and establish lossless live-event buffering before resume; merge subsequent live events by ID, preserving persisted order and letting live payloads win. Continuations are process-local, single-use capabilities bound to the originating session and storage context and must be paged sequentially; concurrent or repeated use of the same cursor expires that duplicate read rather than reading the generation twice. A complete snapshot has cursorStatus 'ok' and hasMore false. Snapshots expire after five idle minutes, with at most eight retained per process and idle-only eviction under pressure; completion and cancelled-worker exit release their handles. No transcript copy is created, but retained handles may keep replaced files' disk blocks alive until release. Pages have a soft 1 MiB serialized event-array budget including resolved binary assets; one oversized event is returned alone to guarantee progress. Working memory also includes a record/lookahead and asset resolution; resolving the first binary reference may scan the full pinned generation to build a bounded offset index. If the snapshot expires, is evicted, is cancelled before a continuation is established, or becomes unreadable after an observable unsupported in-place shortening, the continuation returns cursorStatus 'expired' with an empty terminal page and never falls back to a different generation. A missing or initially unreadable journal is an RPC error. Persisted history excludes ephemeral events and may omit payloads that are reconstructed only for an active session; use the active session event stream for post-resume live events.
2018    ///
2019    /// Wire method: `sessions.readPersistedEvents`.
2020    ///
2021    /// # Parameters
2022    ///
2023    /// * `params` - Pagination options for reading an inactive or active local session's persisted event journal.
2024    ///
2025    /// # Returns
2026    ///
2027    /// Batch of session events returned by a read, with cursor and continuation metadata.
2028    ///
2029    /// <div class="warning">
2030    ///
2031    /// **Experimental.** This API is part of an experimental wire-protocol surface
2032    /// and may change or be removed in future SDK or CLI releases. Pin both the
2033    /// SDK and CLI versions if your code depends on it.
2034    ///
2035    /// </div>
2036    pub async fn read_persisted_events(
2037        &self,
2038        params: SessionsReadPersistedEventsRequest,
2039    ) -> Result<EventsReadResult, Error> {
2040        let wire_params = serde_json::to_value(params)?;
2041        let _value = self
2042            .client
2043            .call(rpc_methods::SESSIONS_READPERSISTEDEVENTS, Some(wire_params))
2044            .await?;
2045        Ok(serde_json::from_value(_value)?)
2046    }
2047
2048    /// Lists recent local session IDs that contain user-visible history, omitting housekeeping-only sessions.
2049    ///
2050    /// Wire method: `sessions.listNonEmptySessionIds`.
2051    ///
2052    /// # Parameters
2053    ///
2054    /// * `params` - Limit for non-empty local session IDs.
2055    ///
2056    /// # Returns
2057    ///
2058    /// Recent local session IDs that contain user-visible history.
2059    ///
2060    /// <div class="warning">
2061    ///
2062    /// **Experimental.** This API is part of an experimental wire-protocol surface
2063    /// and may change or be removed in future SDK or CLI releases. Pin both the
2064    /// SDK and CLI versions if your code depends on it.
2065    ///
2066    /// </div>
2067    pub(crate) async fn list_non_empty_session_ids(
2068        &self,
2069        params: SessionsListNonEmptySessionIdsRequest,
2070    ) -> Result<SessionsListNonEmptySessionIdsResult, Error> {
2071        let wire_params = serde_json::to_value(params)?;
2072        let _value = self
2073            .client
2074            .call(
2075                rpc_methods::SESSIONS_LISTNONEMPTYSESSIONIDS,
2076                Some(wire_params),
2077            )
2078            .await?;
2079        Ok(serde_json::from_value(_value)?)
2080    }
2081
2082    /// Finds the local session bound to a GitHub task ID, if any.
2083    ///
2084    /// Wire method: `sessions.findByTaskId`.
2085    ///
2086    /// # Parameters
2087    ///
2088    /// * `params` - GitHub task ID to look up.
2089    ///
2090    /// # Returns
2091    ///
2092    /// ID of the local session bound to the given GitHub task, or omitted when none.
2093    ///
2094    /// <div class="warning">
2095    ///
2096    /// **Experimental.** This API is part of an experimental wire-protocol surface
2097    /// and may change or be removed in future SDK or CLI releases. Pin both the
2098    /// SDK and CLI versions if your code depends on it.
2099    ///
2100    /// </div>
2101    pub async fn find_by_task_id(
2102        &self,
2103        params: SessionsFindByTaskIDRequest,
2104    ) -> Result<SessionsFindByTaskIDResult, Error> {
2105        let wire_params = serde_json::to_value(params)?;
2106        let _value = self
2107            .client
2108            .call(rpc_methods::SESSIONS_FINDBYTASKID, Some(wire_params))
2109            .await?;
2110        Ok(serde_json::from_value(_value)?)
2111    }
2112
2113    /// Resolves a UUID prefix to a unique session ID, if exactly one session matches.
2114    ///
2115    /// Wire method: `sessions.findByPrefix`.
2116    ///
2117    /// # Parameters
2118    ///
2119    /// * `params` - UUID prefix to resolve to a unique session ID.
2120    ///
2121    /// # Returns
2122    ///
2123    /// Session ID matching the prefix, omitted when no unique match exists.
2124    ///
2125    /// <div class="warning">
2126    ///
2127    /// **Experimental.** This API is part of an experimental wire-protocol surface
2128    /// and may change or be removed in future SDK or CLI releases. Pin both the
2129    /// SDK and CLI versions if your code depends on it.
2130    ///
2131    /// </div>
2132    pub async fn find_by_prefix(
2133        &self,
2134        params: SessionsFindByPrefixRequest,
2135    ) -> Result<SessionsFindByPrefixResult, Error> {
2136        let wire_params = serde_json::to_value(params)?;
2137        let _value = self
2138            .client
2139            .call(rpc_methods::SESSIONS_FINDBYPREFIX, Some(wire_params))
2140            .await?;
2141        Ok(serde_json::from_value(_value)?)
2142    }
2143
2144    /// Returns the most-relevant prior session for a given working-directory context.
2145    ///
2146    /// Wire method: `sessions.getLastForContext`.
2147    ///
2148    /// # Parameters
2149    ///
2150    /// * `params` - Optional working-directory context used to score session relevance.
2151    ///
2152    /// # Returns
2153    ///
2154    /// Most-relevant session ID for the supplied context, or omitted when no sessions exist.
2155    ///
2156    /// <div class="warning">
2157    ///
2158    /// **Experimental.** This API is part of an experimental wire-protocol surface
2159    /// and may change or be removed in future SDK or CLI releases. Pin both the
2160    /// SDK and CLI versions if your code depends on it.
2161    ///
2162    /// </div>
2163    pub async fn get_last_for_context(
2164        &self,
2165        params: SessionsGetLastForContextRequest,
2166    ) -> Result<SessionsGetLastForContextResult, Error> {
2167        let wire_params = serde_json::to_value(params)?;
2168        let _value = self
2169            .client
2170            .call(rpc_methods::SESSIONS_GETLASTFORCONTEXT, Some(wire_params))
2171            .await?;
2172        Ok(serde_json::from_value(_value)?)
2173    }
2174
2175    /// 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.
2176    ///
2177    /// Wire method: `sessions.getEventFilePath`.
2178    ///
2179    /// # Parameters
2180    ///
2181    /// * `params` - Session ID whose event-log file path to compute.
2182    ///
2183    /// # Returns
2184    ///
2185    /// Absolute path to the session's events.jsonl file on disk.
2186    ///
2187    /// <div class="warning">
2188    ///
2189    /// **Experimental.** This API is part of an experimental wire-protocol surface
2190    /// and may change or be removed in future SDK or CLI releases. Pin both the
2191    /// SDK and CLI versions if your code depends on it.
2192    ///
2193    /// </div>
2194    pub(crate) async fn get_event_file_path(
2195        &self,
2196        params: SessionsGetEventFilePathRequest,
2197    ) -> Result<SessionsGetEventFilePathResult, Error> {
2198        let wire_params = serde_json::to_value(params)?;
2199        let _value = self
2200            .client
2201            .call(rpc_methods::SESSIONS_GETEVENTFILEPATH, Some(wire_params))
2202            .await?;
2203        Ok(serde_json::from_value(_value)?)
2204    }
2205
2206    /// Returns the on-disk byte size of each session's workspace directory.
2207    ///
2208    /// Wire method: `sessions.getSizes`.
2209    ///
2210    /// # Returns
2211    ///
2212    /// Map of sessionId -> on-disk size in bytes for each session's workspace directory.
2213    ///
2214    /// <div class="warning">
2215    ///
2216    /// **Experimental.** This API is part of an experimental wire-protocol surface
2217    /// and may change or be removed in future SDK or CLI releases. Pin both the
2218    /// SDK and CLI versions if your code depends on it.
2219    ///
2220    /// </div>
2221    pub async fn get_sizes(&self) -> Result<SessionSizes, Error> {
2222        let wire_params = serde_json::json!({});
2223        let _value = self
2224            .client
2225            .call(rpc_methods::SESSIONS_GETSIZES, Some(wire_params))
2226            .await?;
2227        Ok(serde_json::from_value(_value)?)
2228    }
2229
2230    /// Returns the subset of the supplied session IDs that are currently held by another running process.
2231    ///
2232    /// Wire method: `sessions.checkInUse`.
2233    ///
2234    /// # Parameters
2235    ///
2236    /// * `params` - Session IDs to test for live in-use locks.
2237    ///
2238    /// # Returns
2239    ///
2240    /// Session IDs from the input set that are currently in use by another process.
2241    ///
2242    /// <div class="warning">
2243    ///
2244    /// **Experimental.** This API is part of an experimental wire-protocol surface
2245    /// and may change or be removed in future SDK or CLI releases. Pin both the
2246    /// SDK and CLI versions if your code depends on it.
2247    ///
2248    /// </div>
2249    pub async fn check_in_use(
2250        &self,
2251        params: SessionsCheckInUseRequest,
2252    ) -> Result<SessionsCheckInUseResult, Error> {
2253        let wire_params = serde_json::to_value(params)?;
2254        let _value = self
2255            .client
2256            .call(rpc_methods::SESSIONS_CHECKINUSE, Some(wire_params))
2257            .await?;
2258        Ok(serde_json::from_value(_value)?)
2259    }
2260
2261    /// 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.
2262    ///
2263    /// Wire method: `sessions.getPersistedRemoteSteerable`.
2264    ///
2265    /// # Parameters
2266    ///
2267    /// * `params` - Session ID to look up the persisted remote-steerable flag for.
2268    ///
2269    /// # Returns
2270    ///
2271    /// The session's persisted remote-steerable flag, or omitted when no value has been persisted.
2272    ///
2273    /// <div class="warning">
2274    ///
2275    /// **Experimental.** This API is part of an experimental wire-protocol surface
2276    /// and may change or be removed in future SDK or CLI releases. Pin both the
2277    /// SDK and CLI versions if your code depends on it.
2278    ///
2279    /// </div>
2280    pub(crate) async fn get_persisted_remote_steerable(
2281        &self,
2282        params: SessionsGetPersistedRemoteSteerableRequest,
2283    ) -> Result<SessionsGetPersistedRemoteSteerableResult, Error> {
2284        let wire_params = serde_json::to_value(params)?;
2285        let _value = self
2286            .client
2287            .call(
2288                rpc_methods::SESSIONS_GETPERSISTEDREMOTESTEERABLE,
2289                Some(wire_params),
2290            )
2291            .await?;
2292        Ok(serde_json::from_value(_value)?)
2293    }
2294
2295    /// Closes a session: emits shutdown, flushes pending events, releases the in-use lock, and disposes the active session.
2296    ///
2297    /// Wire method: `sessions.close`.
2298    ///
2299    /// # Parameters
2300    ///
2301    /// * `params` - Session ID to close.
2302    ///
2303    /// # Returns
2304    ///
2305    /// 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.
2306    ///
2307    /// <div class="warning">
2308    ///
2309    /// **Experimental.** This API is part of an experimental wire-protocol surface
2310    /// and may change or be removed in future SDK or CLI releases. Pin both the
2311    /// SDK and CLI versions if your code depends on it.
2312    ///
2313    /// </div>
2314    pub async fn close(&self, params: SessionsCloseRequest) -> Result<SessionsCloseResult, Error> {
2315        let wire_params = serde_json::to_value(params)?;
2316        let _value = self
2317            .client
2318            .call(rpc_methods::SESSIONS_CLOSE, Some(wire_params))
2319            .await?;
2320        Ok(serde_json::from_value(_value)?)
2321    }
2322
2323    /// Closes, deactivates, and deletes a set of sessions, returning the bytes freed per session.
2324    ///
2325    /// Wire method: `sessions.bulkDelete`.
2326    ///
2327    /// # Parameters
2328    ///
2329    /// * `params` - Session IDs to close, deactivate, and delete from disk.
2330    ///
2331    /// # Returns
2332    ///
2333    /// Map of sessionId -> bytes freed by removing the session's workspace directory.
2334    ///
2335    /// <div class="warning">
2336    ///
2337    /// **Experimental.** This API is part of an experimental wire-protocol surface
2338    /// and may change or be removed in future SDK or CLI releases. Pin both the
2339    /// SDK and CLI versions if your code depends on it.
2340    ///
2341    /// </div>
2342    pub async fn bulk_delete(
2343        &self,
2344        params: SessionsBulkDeleteRequest,
2345    ) -> Result<SessionBulkDeleteResult, Error> {
2346        let wire_params = serde_json::to_value(params)?;
2347        let _value = self
2348            .client
2349            .call(rpc_methods::SESSIONS_BULKDELETE, Some(wire_params))
2350            .await?;
2351        Ok(serde_json::from_value(_value)?)
2352    }
2353
2354    /// Deletes one local session from disk after running the same lifecycle hooks as the session manager.
2355    ///
2356    /// Wire method: `sessions.delete`.
2357    ///
2358    /// # Parameters
2359    ///
2360    /// * `params` - Session ID to delete from disk.
2361    ///
2362    /// <div class="warning">
2363    ///
2364    /// **Experimental.** This API is part of an experimental wire-protocol surface
2365    /// and may change or be removed in future SDK or CLI releases. Pin both the
2366    /// SDK and CLI versions if your code depends on it.
2367    ///
2368    /// </div>
2369    pub(crate) async fn delete(&self, params: SessionsDeleteRequest) -> Result<(), Error> {
2370        let wire_params = serde_json::to_value(params)?;
2371        let _value = self
2372            .client
2373            .call(rpc_methods::SESSIONS_DELETE, Some(wire_params))
2374            .await?;
2375        Ok(())
2376    }
2377
2378    /// Deletes sessions older than the given threshold, with optional dry-run and exclusion list.
2379    ///
2380    /// Wire method: `sessions.pruneOld`.
2381    ///
2382    /// # Parameters
2383    ///
2384    /// * `params` - Age threshold and optional flags controlling which old sessions are pruned (or simulated when dryRun is true).
2385    ///
2386    /// # Returns
2387    ///
2388    /// Outcome of the prune operation: deleted IDs, dry-run candidates, skipped IDs, total bytes freed, and the dry-run flag.
2389    ///
2390    /// <div class="warning">
2391    ///
2392    /// **Experimental.** This API is part of an experimental wire-protocol surface
2393    /// and may change or be removed in future SDK or CLI releases. Pin both the
2394    /// SDK and CLI versions if your code depends on it.
2395    ///
2396    /// </div>
2397    pub async fn prune_old(
2398        &self,
2399        params: SessionsPruneOldRequest,
2400    ) -> Result<SessionPruneResult, Error> {
2401        let wire_params = serde_json::to_value(params)?;
2402        let _value = self
2403            .client
2404            .call(rpc_methods::SESSIONS_PRUNEOLD, Some(wire_params))
2405            .await?;
2406        Ok(serde_json::from_value(_value)?)
2407    }
2408
2409    /// Flushes a session's pending events to disk.
2410    ///
2411    /// Wire method: `sessions.save`.
2412    ///
2413    /// # Parameters
2414    ///
2415    /// * `params` - Session ID whose pending events should be flushed to disk.
2416    ///
2417    /// # Returns
2418    ///
2419    /// Flush a session's pending events to disk. No-op when no writer exists for the session (e.g., already closed).
2420    ///
2421    /// <div class="warning">
2422    ///
2423    /// **Experimental.** This API is part of an experimental wire-protocol surface
2424    /// and may change or be removed in future SDK or CLI releases. Pin both the
2425    /// SDK and CLI versions if your code depends on it.
2426    ///
2427    /// </div>
2428    pub async fn save(&self, params: SessionsSaveRequest) -> Result<SessionsSaveResult, Error> {
2429        let wire_params = serde_json::to_value(params)?;
2430        let _value = self
2431            .client
2432            .call(rpc_methods::SESSIONS_SAVE, Some(wire_params))
2433            .await?;
2434        Ok(serde_json::from_value(_value)?)
2435    }
2436
2437    /// Releases the in-use lock held by this process for a session.
2438    ///
2439    /// Wire method: `sessions.releaseLock`.
2440    ///
2441    /// # Parameters
2442    ///
2443    /// * `params` - Session ID whose in-use lock should be released.
2444    ///
2445    /// # Returns
2446    ///
2447    /// 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.
2448    ///
2449    /// <div class="warning">
2450    ///
2451    /// **Experimental.** This API is part of an experimental wire-protocol surface
2452    /// and may change or be removed in future SDK or CLI releases. Pin both the
2453    /// SDK and CLI versions if your code depends on it.
2454    ///
2455    /// </div>
2456    pub async fn release_lock(
2457        &self,
2458        params: SessionsReleaseLockRequest,
2459    ) -> Result<SessionsReleaseLockResult, Error> {
2460        let wire_params = serde_json::to_value(params)?;
2461        let _value = self
2462            .client
2463            .call(rpc_methods::SESSIONS_RELEASELOCK, Some(wire_params))
2464            .await?;
2465        Ok(serde_json::from_value(_value)?)
2466    }
2467
2468    /// Backfills missing summary and context fields on the supplied session metadata records.
2469    ///
2470    /// Wire method: `sessions.enrichMetadata`.
2471    ///
2472    /// # Parameters
2473    ///
2474    /// * `params` - Session metadata records to enrich with summary and context information.
2475    ///
2476    /// # Returns
2477    ///
2478    /// The enriched metadata records, with summary and context fields backfilled where available. Sessions confirmed empty and unnamed are omitted.
2479    ///
2480    /// <div class="warning">
2481    ///
2482    /// **Experimental.** This API is part of an experimental wire-protocol surface
2483    /// and may change or be removed in future SDK or CLI releases. Pin both the
2484    /// SDK and CLI versions if your code depends on it.
2485    ///
2486    /// </div>
2487    pub async fn enrich_metadata(
2488        &self,
2489        params: SessionsEnrichMetadataRequest,
2490    ) -> Result<SessionEnrichMetadataResult, Error> {
2491        let wire_params = serde_json::to_value(params)?;
2492        let _value = self
2493            .client
2494            .call(rpc_methods::SESSIONS_ENRICHMETADATA, Some(wire_params))
2495            .await?;
2496        Ok(serde_json::from_value(_value)?)
2497    }
2498
2499    /// Reloads user, plugin, and (optionally) repo hooks on the active session.
2500    ///
2501    /// Wire method: `sessions.reloadPluginHooks`.
2502    ///
2503    /// # Parameters
2504    ///
2505    /// * `params` - Active session ID and an optional flag for deferring repo-level hooks until folder trust.
2506    ///
2507    /// # Returns
2508    ///
2509    /// 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.
2510    ///
2511    /// <div class="warning">
2512    ///
2513    /// **Experimental.** This API is part of an experimental wire-protocol surface
2514    /// and may change or be removed in future SDK or CLI releases. Pin both the
2515    /// SDK and CLI versions if your code depends on it.
2516    ///
2517    /// </div>
2518    pub async fn reload_plugin_hooks(
2519        &self,
2520        params: SessionsReloadPluginHooksRequest,
2521    ) -> Result<SessionsReloadPluginHooksResult, Error> {
2522        let wire_params = serde_json::to_value(params)?;
2523        let _value = self
2524            .client
2525            .call(rpc_methods::SESSIONS_RELOADPLUGINHOOKS, Some(wire_params))
2526            .await?;
2527        Ok(serde_json::from_value(_value)?)
2528    }
2529
2530    /// Loads previously-deferred repo-level hooks on the active session, returning queued startup prompts.
2531    ///
2532    /// Wire method: `sessions.loadDeferredRepoHooks`.
2533    ///
2534    /// # Parameters
2535    ///
2536    /// * `params` - Active session ID whose deferred repo-level hooks should be loaded.
2537    ///
2538    /// # Returns
2539    ///
2540    /// Queued repo-level startup prompts and the total hook command count after loading.
2541    ///
2542    /// <div class="warning">
2543    ///
2544    /// **Experimental.** This API is part of an experimental wire-protocol surface
2545    /// and may change or be removed in future SDK or CLI releases. Pin both the
2546    /// SDK and CLI versions if your code depends on it.
2547    ///
2548    /// </div>
2549    pub async fn load_deferred_repo_hooks(
2550        &self,
2551        params: SessionsLoadDeferredRepoHooksRequest,
2552    ) -> Result<SessionLoadDeferredRepoHooksResult, Error> {
2553        let wire_params = serde_json::to_value(params)?;
2554        let _value = self
2555            .client
2556            .call(
2557                rpc_methods::SESSIONS_LOADDEFERREDREPOHOOKS,
2558                Some(wire_params),
2559            )
2560            .await?;
2561        Ok(serde_json::from_value(_value)?)
2562    }
2563
2564    /// Replaces the manager-wide additional plugins registered with the session manager.
2565    ///
2566    /// Wire method: `sessions.setAdditionalPlugins`.
2567    ///
2568    /// # Parameters
2569    ///
2570    /// * `params` - Manager-wide additional plugins to register; replaces any previously-configured set.
2571    ///
2572    /// # Returns
2573    ///
2574    /// 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.
2575    ///
2576    /// <div class="warning">
2577    ///
2578    /// **Experimental.** This API is part of an experimental wire-protocol surface
2579    /// and may change or be removed in future SDK or CLI releases. Pin both the
2580    /// SDK and CLI versions if your code depends on it.
2581    ///
2582    /// </div>
2583    pub async fn set_additional_plugins(
2584        &self,
2585        params: SessionsSetAdditionalPluginsRequest,
2586    ) -> Result<SessionsSetAdditionalPluginsResult, Error> {
2587        let wire_params = serde_json::to_value(params)?;
2588        let _value = self
2589            .client
2590            .call(
2591                rpc_methods::SESSIONS_SETADDITIONALPLUGINS,
2592                Some(wire_params),
2593            )
2594            .await?;
2595        Ok(serde_json::from_value(_value)?)
2596    }
2597
2598    /// 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.
2599    ///
2600    /// Wire method: `sessions.getBoardEntryCount`.
2601    ///
2602    /// # Parameters
2603    ///
2604    /// * `params` - Session ID whose board entry count should be returned.
2605    ///
2606    /// # Returns
2607    ///
2608    /// Dynamic-context board entry count, when available.
2609    ///
2610    /// <div class="warning">
2611    ///
2612    /// **Experimental.** This API is part of an experimental wire-protocol surface
2613    /// and may change or be removed in future SDK or CLI releases. Pin both the
2614    /// SDK and CLI versions if your code depends on it.
2615    ///
2616    /// </div>
2617    pub(crate) async fn get_board_entry_count(
2618        &self,
2619        params: SessionsGetBoardEntryCountRequest,
2620    ) -> Result<SessionsGetBoardEntryCountResult, Error> {
2621        let wire_params = serde_json::to_value(params)?;
2622        let _value = self
2623            .client
2624            .call(rpc_methods::SESSIONS_GETBOARDENTRYCOUNT, Some(wire_params))
2625            .await?;
2626        Ok(serde_json::from_value(_value)?)
2627    }
2628
2629    /// 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.
2630    ///
2631    /// Wire method: `sessions.startRemoteControl`.
2632    ///
2633    /// # Parameters
2634    ///
2635    /// * `params` - Parameters for attaching the remote-control singleton to a session.
2636    ///
2637    /// # Returns
2638    ///
2639    /// Wrapper for the singleton's current status.
2640    ///
2641    /// <div class="warning">
2642    ///
2643    /// **Experimental.** This API is part of an experimental wire-protocol surface
2644    /// and may change or be removed in future SDK or CLI releases. Pin both the
2645    /// SDK and CLI versions if your code depends on it.
2646    ///
2647    /// </div>
2648    pub async fn start_remote_control(
2649        &self,
2650        params: SessionsStartRemoteControlRequest,
2651    ) -> Result<RemoteControlStatusResult, Error> {
2652        let wire_params = serde_json::to_value(params)?;
2653        let _value = self
2654            .client
2655            .call(rpc_methods::SESSIONS_STARTREMOTECONTROL, Some(wire_params))
2656            .await?;
2657        Ok(serde_json::from_value(_value)?)
2658    }
2659
2660    /// 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.
2661    ///
2662    /// Wire method: `sessions.transferRemoteControl`.
2663    ///
2664    /// # Parameters
2665    ///
2666    /// * `params` - Parameters for atomically rebinding the remote-control singleton.
2667    ///
2668    /// # Returns
2669    ///
2670    /// Outcome of a transferRemoteControl call.
2671    ///
2672    /// <div class="warning">
2673    ///
2674    /// **Experimental.** This API is part of an experimental wire-protocol surface
2675    /// and may change or be removed in future SDK or CLI releases. Pin both the
2676    /// SDK and CLI versions if your code depends on it.
2677    ///
2678    /// </div>
2679    pub async fn transfer_remote_control(
2680        &self,
2681        params: SessionsTransferRemoteControlRequest,
2682    ) -> Result<RemoteControlTransferResult, Error> {
2683        let wire_params = serde_json::to_value(params)?;
2684        let _value = self
2685            .client
2686            .call(
2687                rpc_methods::SESSIONS_TRANSFERREMOTECONTROL,
2688                Some(wire_params),
2689            )
2690            .await?;
2691        Ok(serde_json::from_value(_value)?)
2692    }
2693
2694    /// 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.
2695    ///
2696    /// Wire method: `sessions.setRemoteControlSteering`.
2697    ///
2698    /// # Parameters
2699    ///
2700    /// * `params` - Patch for the singleton's steering state.
2701    ///
2702    /// # Returns
2703    ///
2704    /// Wrapper for the singleton's current status.
2705    ///
2706    /// <div class="warning">
2707    ///
2708    /// **Experimental.** This API is part of an experimental wire-protocol surface
2709    /// and may change or be removed in future SDK or CLI releases. Pin both the
2710    /// SDK and CLI versions if your code depends on it.
2711    ///
2712    /// </div>
2713    pub async fn set_remote_control_steering(
2714        &self,
2715        params: SessionsSetRemoteControlSteeringRequest,
2716    ) -> Result<RemoteControlStatusResult, Error> {
2717        let wire_params = serde_json::to_value(params)?;
2718        let _value = self
2719            .client
2720            .call(
2721                rpc_methods::SESSIONS_SETREMOTECONTROLSTEERING,
2722                Some(wire_params),
2723            )
2724            .await?;
2725        Ok(serde_json::from_value(_value)?)
2726    }
2727
2728    /// 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).
2729    ///
2730    /// Wire method: `sessions.stopRemoteControl`.
2731    ///
2732    /// # Returns
2733    ///
2734    /// Outcome of a stopRemoteControl call.
2735    ///
2736    /// <div class="warning">
2737    ///
2738    /// **Experimental.** This API is part of an experimental wire-protocol surface
2739    /// and may change or be removed in future SDK or CLI releases. Pin both the
2740    /// SDK and CLI versions if your code depends on it.
2741    ///
2742    /// </div>
2743    pub async fn stop_remote_control(&self) -> Result<RemoteControlStopResult, Error> {
2744        let wire_params = serde_json::json!({});
2745        let _value = self
2746            .client
2747            .call(rpc_methods::SESSIONS_STOPREMOTECONTROL, Some(wire_params))
2748            .await?;
2749        Ok(serde_json::from_value(_value)?)
2750    }
2751
2752    /// 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).
2753    ///
2754    /// Wire method: `sessions.stopRemoteControl`.
2755    ///
2756    /// # Parameters
2757    ///
2758    /// * `params` - Parameters for stopping the remote-control singleton.
2759    ///
2760    /// # Returns
2761    ///
2762    /// Outcome of a stopRemoteControl call.
2763    ///
2764    /// <div class="warning">
2765    ///
2766    /// **Experimental.** This API is part of an experimental wire-protocol surface
2767    /// and may change or be removed in future SDK or CLI releases. Pin both the
2768    /// SDK and CLI versions if your code depends on it.
2769    ///
2770    /// </div>
2771    pub async fn stop_remote_control_with_params(
2772        &self,
2773        params: SessionsStopRemoteControlRequest,
2774    ) -> Result<RemoteControlStopResult, Error> {
2775        let wire_params = serde_json::to_value(params)?;
2776        let _value = self
2777            .client
2778            .call(rpc_methods::SESSIONS_STOPREMOTECONTROL, Some(wire_params))
2779            .await?;
2780        Ok(serde_json::from_value(_value)?)
2781    }
2782
2783    /// Returns the current state of the remote-control singleton, including the attached session id and frontend URL when active.
2784    ///
2785    /// Wire method: `sessions.getRemoteControlStatus`.
2786    ///
2787    /// # Returns
2788    ///
2789    /// Wrapper for the singleton's current status.
2790    ///
2791    /// <div class="warning">
2792    ///
2793    /// **Experimental.** This API is part of an experimental wire-protocol surface
2794    /// and may change or be removed in future SDK or CLI releases. Pin both the
2795    /// SDK and CLI versions if your code depends on it.
2796    ///
2797    /// </div>
2798    pub async fn get_remote_control_status(&self) -> Result<RemoteControlStatusResult, Error> {
2799        let wire_params = serde_json::json!({});
2800        let _value = self
2801            .client
2802            .call(
2803                rpc_methods::SESSIONS_GETREMOTECONTROLSTATUS,
2804                Some(wire_params),
2805            )
2806            .await?;
2807        Ok(serde_json::from_value(_value)?)
2808    }
2809
2810    /// Attaches (or detaches) an in-process ExtensionController delegate for the given session in a local host adapter. Pass `controller: undefined` to detach. Internal because the controller cannot cross the JSON-RPC boundary; the runtime manages its own session extension service.
2811    ///
2812    /// Wire method: `sessions.configureSessionExtensions`.
2813    ///
2814    /// # Parameters
2815    ///
2816    /// * `params` - Params to attach or detach an in-process ExtensionController delegate.
2817    ///
2818    /// <div class="warning">
2819    ///
2820    /// **Experimental.** This API is part of an experimental wire-protocol surface
2821    /// and may change or be removed in future SDK or CLI releases. Pin both the
2822    /// SDK and CLI versions if your code depends on it.
2823    ///
2824    /// </div>
2825    pub(crate) async fn configure_session_extensions(
2826        &self,
2827        params: ConfigureSessionExtensionsParams,
2828    ) -> Result<(), Error> {
2829        let wire_params = serde_json::to_value(params)?;
2830        let _value = self
2831            .client
2832            .call(
2833                rpc_methods::SESSIONS_CONFIGURESESSIONEXTENSIONS,
2834                Some(wire_params),
2835            )
2836            .await?;
2837        Ok(())
2838    }
2839}
2840
2841/// `skills.*` RPCs.
2842#[derive(Clone, Copy)]
2843pub struct ClientRpcSkills<'a> {
2844    pub(crate) client: &'a Client,
2845}
2846
2847impl<'a> ClientRpcSkills<'a> {
2848    /// `skills.config.*` sub-namespace.
2849    pub fn config(&self) -> ClientRpcSkillsConfig<'a> {
2850        ClientRpcSkillsConfig {
2851            client: self.client,
2852        }
2853    }
2854
2855    /// Discovers skills across global and project sources.
2856    ///
2857    /// Wire method: `skills.discover`.
2858    ///
2859    /// # Parameters
2860    ///
2861    /// * `params` - Optional project paths and additional skill directories to include in discovery.
2862    ///
2863    /// # Returns
2864    ///
2865    /// Skills discovered across global and project sources.
2866    ///
2867    /// <div class="warning">
2868    ///
2869    /// **Experimental.** This API is part of an experimental wire-protocol surface
2870    /// and may change or be removed in future SDK or CLI releases. Pin both the
2871    /// SDK and CLI versions if your code depends on it.
2872    ///
2873    /// </div>
2874    pub async fn discover(&self, params: SkillsDiscoverRequest) -> Result<ServerSkillList, Error> {
2875        let wire_params = serde_json::to_value(params)?;
2876        let _value = self
2877            .client
2878            .call(rpc_methods::SKILLS_DISCOVER, Some(wire_params))
2879            .await?;
2880        Ok(serde_json::from_value(_value)?)
2881    }
2882
2883    /// 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.
2884    ///
2885    /// Wire method: `skills.getDiscoveryPaths`.
2886    ///
2887    /// # Parameters
2888    ///
2889    /// * `params` - Optional project paths to enumerate.
2890    ///
2891    /// # Returns
2892    ///
2893    /// Canonical locations where skills can be created so the runtime will recognize them.
2894    ///
2895    /// <div class="warning">
2896    ///
2897    /// **Experimental.** This API is part of an experimental wire-protocol surface
2898    /// and may change or be removed in future SDK or CLI releases. Pin both the
2899    /// SDK and CLI versions if your code depends on it.
2900    ///
2901    /// </div>
2902    pub async fn get_discovery_paths(
2903        &self,
2904        params: SkillsGetDiscoveryPathsRequest,
2905    ) -> Result<SkillDiscoveryPathList, Error> {
2906        let wire_params = serde_json::to_value(params)?;
2907        let _value = self
2908            .client
2909            .call(rpc_methods::SKILLS_GETDISCOVERYPATHS, Some(wire_params))
2910            .await?;
2911        Ok(serde_json::from_value(_value)?)
2912    }
2913}
2914
2915/// `skills.config.*` RPCs.
2916#[derive(Clone, Copy)]
2917pub struct ClientRpcSkillsConfig<'a> {
2918    pub(crate) client: &'a Client,
2919}
2920
2921impl<'a> ClientRpcSkillsConfig<'a> {
2922    /// Replaces the global list of disabled skills.
2923    ///
2924    /// Wire method: `skills.config.setDisabledSkills`.
2925    ///
2926    /// # Parameters
2927    ///
2928    /// * `params` - Skill names to mark as disabled in global configuration, replacing any previous list.
2929    ///
2930    /// <div class="warning">
2931    ///
2932    /// **Experimental.** This API is part of an experimental wire-protocol surface
2933    /// and may change or be removed in future SDK or CLI releases. Pin both the
2934    /// SDK and CLI versions if your code depends on it.
2935    ///
2936    /// </div>
2937    pub async fn set_disabled_skills(
2938        &self,
2939        params: SkillsConfigSetDisabledSkillsRequest,
2940    ) -> Result<(), Error> {
2941        let wire_params = serde_json::to_value(params)?;
2942        let _value = self
2943            .client
2944            .call(
2945                rpc_methods::SKILLS_CONFIG_SETDISABLEDSKILLS,
2946                Some(wire_params),
2947            )
2948            .await?;
2949        Ok(())
2950    }
2951
2952    /// Atomically adds or removes one skill from the disabled list.
2953    ///
2954    /// Wire method: `skills.config.setSkillDisabled`.
2955    ///
2956    /// # Parameters
2957    ///
2958    /// * `params` - Adds or removes a single skill from the global disabled list, leaving every other entry untouched.
2959    ///
2960    /// <div class="warning">
2961    ///
2962    /// **Experimental.** This API is part of an experimental wire-protocol surface
2963    /// and may change or be removed in future SDK or CLI releases. Pin both the
2964    /// SDK and CLI versions if your code depends on it.
2965    ///
2966    /// </div>
2967    pub async fn set_skill_disabled(
2968        &self,
2969        params: SkillsConfigSetSkillDisabledRequest,
2970    ) -> Result<(), Error> {
2971        let wire_params = serde_json::to_value(params)?;
2972        let _value = self
2973            .client
2974            .call(
2975                rpc_methods::SKILLS_CONFIG_SETSKILLDISABLED,
2976                Some(wire_params),
2977            )
2978            .await?;
2979        Ok(())
2980    }
2981}
2982
2983/// `tools.*` RPCs.
2984#[derive(Clone, Copy)]
2985pub struct ClientRpcTools<'a> {
2986    pub(crate) client: &'a Client,
2987}
2988
2989impl<'a> ClientRpcTools<'a> {
2990    /// Lists built-in tools available for a model.
2991    ///
2992    /// Wire method: `tools.list`.
2993    ///
2994    /// # Parameters
2995    ///
2996    /// * `params` - Optional model identifier whose tool overrides should be applied to the listing.
2997    ///
2998    /// # Returns
2999    ///
3000    /// Built-in tools available for the requested model, with their parameters and instructions.
3001    ///
3002    /// <div class="warning">
3003    ///
3004    /// **Experimental.** This API is part of an experimental wire-protocol surface
3005    /// and may change or be removed in future SDK or CLI releases. Pin both the
3006    /// SDK and CLI versions if your code depends on it.
3007    ///
3008    /// </div>
3009    pub async fn list(&self, params: ToolsListRequest) -> Result<ToolList, Error> {
3010        let wire_params = serde_json::to_value(params)?;
3011        let _value = self
3012            .client
3013            .call(rpc_methods::TOOLS_LIST, Some(wire_params))
3014            .await?;
3015        Ok(serde_json::from_value(_value)?)
3016    }
3017}
3018
3019/// `user.*` RPCs.
3020#[derive(Clone, Copy)]
3021pub struct ClientRpcUser<'a> {
3022    pub(crate) client: &'a Client,
3023}
3024
3025impl<'a> ClientRpcUser<'a> {
3026    /// `user.settings.*` sub-namespace.
3027    pub fn settings(&self) -> ClientRpcUserSettings<'a> {
3028        ClientRpcUserSettings {
3029            client: self.client,
3030        }
3031    }
3032}
3033
3034/// `user.settings.*` RPCs.
3035#[derive(Clone, Copy)]
3036pub struct ClientRpcUserSettings<'a> {
3037    pub(crate) client: &'a Client,
3038}
3039
3040impl<'a> ClientRpcUserSettings<'a> {
3041    /// Drops this runtime process's in-memory user settings cache so the next settings read observes disk.
3042    ///
3043    /// Wire method: `user.settings.reload`.
3044    ///
3045    /// <div class="warning">
3046    ///
3047    /// **Experimental.** This API is part of an experimental wire-protocol surface
3048    /// and may change or be removed in future SDK or CLI releases. Pin both the
3049    /// SDK and CLI versions if your code depends on it.
3050    ///
3051    /// </div>
3052    pub async fn reload(&self) -> Result<(), Error> {
3053        let wire_params = serde_json::json!({});
3054        let _value = self
3055            .client
3056            .call(rpc_methods::USER_SETTINGS_RELOAD, Some(wire_params))
3057            .await?;
3058        Ok(())
3059    }
3060
3061    /// Lists every known user setting (settings.json overlaid with the legacy config.json, config.json wins), each with its effective value, its default, and whether it is at the default — so settings the user has never set still appear with their default value. Does not include repository- or enterprise-managed overrides that the runtime layers on top at session time.
3062    ///
3063    /// Wire method: `user.settings.get`.
3064    ///
3065    /// # Returns
3066    ///
3067    /// Per-key metadata for every known user setting (settings.json overlaid with the legacy config.json, config.json wins), including settings left at their default. Excludes repository- and enterprise-managed overrides.
3068    ///
3069    /// <div class="warning">
3070    ///
3071    /// **Experimental.** This API is part of an experimental wire-protocol surface
3072    /// and may change or be removed in future SDK or CLI releases. Pin both the
3073    /// SDK and CLI versions if your code depends on it.
3074    ///
3075    /// </div>
3076    pub async fn get(&self) -> Result<UserSettingsGetResult, Error> {
3077        let wire_params = serde_json::json!({});
3078        let _value = self
3079            .client
3080            .call(rpc_methods::USER_SETTINGS_GET, Some(wire_params))
3081            .await?;
3082        Ok(serde_json::from_value(_value)?)
3083    }
3084
3085    /// Writes one or more user settings to settings.json, replacing each provided top-level key. A key whose value is null is removed. Returns the keys whose new value is shadowed by a legacy config.json entry (config.json wins on read), which the runtime leaves in place — such writes do not take effect until the legacy value is removed.
3086    ///
3087    /// Wire method: `user.settings.set`.
3088    ///
3089    /// # Parameters
3090    ///
3091    /// * `params` - Partial user settings to write to settings.json. Each top-level key is written individually, replacing the existing value; a key whose value is null is removed.
3092    ///
3093    /// # Returns
3094    ///
3095    /// Outcome of writing user settings.
3096    ///
3097    /// <div class="warning">
3098    ///
3099    /// **Experimental.** This API is part of an experimental wire-protocol surface
3100    /// and may change or be removed in future SDK or CLI releases. Pin both the
3101    /// SDK and CLI versions if your code depends on it.
3102    ///
3103    /// </div>
3104    pub async fn set(
3105        &self,
3106        params: UserSettingsSetRequest,
3107    ) -> Result<UserSettingsSetResult, Error> {
3108        let wire_params = serde_json::to_value(params)?;
3109        let _value = self
3110            .client
3111            .call(rpc_methods::USER_SETTINGS_SET, Some(wire_params))
3112            .await?;
3113        Ok(serde_json::from_value(_value)?)
3114    }
3115}
3116
3117/// Typed view over a [`Session`]'s RPC namespace.
3118#[derive(Clone, Copy)]
3119pub struct SessionRpc<'a> {
3120    pub(crate) session: &'a Session,
3121}
3122
3123impl<'a> SessionRpc<'a> {
3124    /// `session.agent.*` sub-namespace.
3125    pub fn agent(&self) -> SessionRpcAgent<'a> {
3126        SessionRpcAgent {
3127            session: self.session,
3128        }
3129    }
3130
3131    /// `session.autopilotObjective.*` sub-namespace.
3132    pub fn autopilot_objective(&self) -> SessionRpcAutopilotObjective<'a> {
3133        SessionRpcAutopilotObjective {
3134            session: self.session,
3135        }
3136    }
3137
3138    /// `session.canvas.*` sub-namespace.
3139    pub fn canvas(&self) -> SessionRpcCanvas<'a> {
3140        SessionRpcCanvas {
3141            session: self.session,
3142        }
3143    }
3144
3145    /// `session.commands.*` sub-namespace.
3146    pub fn commands(&self) -> SessionRpcCommands<'a> {
3147        SessionRpcCommands {
3148            session: self.session,
3149        }
3150    }
3151
3152    /// `session.completions.*` sub-namespace.
3153    pub fn completions(&self) -> SessionRpcCompletions<'a> {
3154        SessionRpcCompletions {
3155            session: self.session,
3156        }
3157    }
3158
3159    /// `session.contentExclusion.*` sub-namespace.
3160    pub fn content_exclusion(&self) -> SessionRpcContentExclusion<'a> {
3161        SessionRpcContentExclusion {
3162            session: self.session,
3163        }
3164    }
3165
3166    /// `session.debug.*` sub-namespace.
3167    pub fn debug(&self) -> SessionRpcDebug<'a> {
3168        SessionRpcDebug {
3169            session: self.session,
3170        }
3171    }
3172
3173    /// `session.eventLog.*` sub-namespace.
3174    pub fn event_log(&self) -> SessionRpcEventLog<'a> {
3175        SessionRpcEventLog {
3176            session: self.session,
3177        }
3178    }
3179
3180    /// `session.extensions.*` sub-namespace.
3181    pub fn extensions(&self) -> SessionRpcExtensions<'a> {
3182        SessionRpcExtensions {
3183            session: self.session,
3184        }
3185    }
3186
3187    /// `session.factory.*` sub-namespace.
3188    pub fn factory(&self) -> SessionRpcFactory<'a> {
3189        SessionRpcFactory {
3190            session: self.session,
3191        }
3192    }
3193
3194    /// `session.fleet.*` sub-namespace.
3195    pub fn fleet(&self) -> SessionRpcFleet<'a> {
3196        SessionRpcFleet {
3197            session: self.session,
3198        }
3199    }
3200
3201    /// `session.gitHubAuth.*` sub-namespace.
3202    pub fn git_hub_auth(&self) -> SessionRpcGitHubAuth<'a> {
3203        SessionRpcGitHubAuth {
3204            session: self.session,
3205        }
3206    }
3207
3208    /// `session.history.*` sub-namespace.
3209    pub fn history(&self) -> SessionRpcHistory<'a> {
3210        SessionRpcHistory {
3211            session: self.session,
3212        }
3213    }
3214
3215    /// `session.instructions.*` sub-namespace.
3216    pub fn instructions(&self) -> SessionRpcInstructions<'a> {
3217        SessionRpcInstructions {
3218            session: self.session,
3219        }
3220    }
3221
3222    /// `session.limitPrediction.*` sub-namespace.
3223    pub fn limit_prediction(&self) -> SessionRpcLimitPrediction<'a> {
3224        SessionRpcLimitPrediction {
3225            session: self.session,
3226        }
3227    }
3228
3229    /// `session.lsp.*` sub-namespace.
3230    pub fn lsp(&self) -> SessionRpcLsp<'a> {
3231        SessionRpcLsp {
3232            session: self.session,
3233        }
3234    }
3235
3236    /// `session.managedSettings.*` sub-namespace.
3237    pub fn managed_settings(&self) -> SessionRpcManagedSettings<'a> {
3238        SessionRpcManagedSettings {
3239            session: self.session,
3240        }
3241    }
3242
3243    /// `session.mcp.*` sub-namespace.
3244    pub fn mcp(&self) -> SessionRpcMcp<'a> {
3245        SessionRpcMcp {
3246            session: self.session,
3247        }
3248    }
3249
3250    /// `session.metadata.*` sub-namespace.
3251    pub fn metadata(&self) -> SessionRpcMetadata<'a> {
3252        SessionRpcMetadata {
3253            session: self.session,
3254        }
3255    }
3256
3257    /// `session.mode.*` sub-namespace.
3258    pub fn mode(&self) -> SessionRpcMode<'a> {
3259        SessionRpcMode {
3260            session: self.session,
3261        }
3262    }
3263
3264    /// `session.model.*` sub-namespace.
3265    pub fn model(&self) -> SessionRpcModel<'a> {
3266        SessionRpcModel {
3267            session: self.session,
3268        }
3269    }
3270
3271    /// `session.name.*` sub-namespace.
3272    pub fn name(&self) -> SessionRpcName<'a> {
3273        SessionRpcName {
3274            session: self.session,
3275        }
3276    }
3277
3278    /// `session.options.*` sub-namespace.
3279    pub fn options(&self) -> SessionRpcOptions<'a> {
3280        SessionRpcOptions {
3281            session: self.session,
3282        }
3283    }
3284
3285    /// `session.permissions.*` sub-namespace.
3286    pub fn permissions(&self) -> SessionRpcPermissions<'a> {
3287        SessionRpcPermissions {
3288            session: self.session,
3289        }
3290    }
3291
3292    /// `session.plan.*` sub-namespace.
3293    pub fn plan(&self) -> SessionRpcPlan<'a> {
3294        SessionRpcPlan {
3295            session: self.session,
3296        }
3297    }
3298
3299    /// `session.plugins.*` sub-namespace.
3300    pub fn plugins(&self) -> SessionRpcPlugins<'a> {
3301        SessionRpcPlugins {
3302            session: self.session,
3303        }
3304    }
3305
3306    /// `session.provider.*` sub-namespace.
3307    pub fn provider(&self) -> SessionRpcProvider<'a> {
3308        SessionRpcProvider {
3309            session: self.session,
3310        }
3311    }
3312
3313    /// `session.queue.*` sub-namespace.
3314    pub fn queue(&self) -> SessionRpcQueue<'a> {
3315        SessionRpcQueue {
3316            session: self.session,
3317        }
3318    }
3319
3320    /// `session.remote.*` sub-namespace.
3321    pub fn remote(&self) -> SessionRpcRemote<'a> {
3322        SessionRpcRemote {
3323            session: self.session,
3324        }
3325    }
3326
3327    /// `session.sandbox.*` sub-namespace.
3328    pub fn sandbox(&self) -> SessionRpcSandbox<'a> {
3329        SessionRpcSandbox {
3330            session: self.session,
3331        }
3332    }
3333
3334    /// `session.schedule.*` sub-namespace.
3335    pub fn schedule(&self) -> SessionRpcSchedule<'a> {
3336        SessionRpcSchedule {
3337            session: self.session,
3338        }
3339    }
3340
3341    /// `session.settings.*` sub-namespace.
3342    pub fn settings(&self) -> SessionRpcSettings<'a> {
3343        SessionRpcSettings {
3344            session: self.session,
3345        }
3346    }
3347
3348    /// `session.shell.*` sub-namespace.
3349    pub fn shell(&self) -> SessionRpcShell<'a> {
3350        SessionRpcShell {
3351            session: self.session,
3352        }
3353    }
3354
3355    /// `session.skills.*` sub-namespace.
3356    pub fn skills(&self) -> SessionRpcSkills<'a> {
3357        SessionRpcSkills {
3358            session: self.session,
3359        }
3360    }
3361
3362    /// `session.tasks.*` sub-namespace.
3363    pub fn tasks(&self) -> SessionRpcTasks<'a> {
3364        SessionRpcTasks {
3365            session: self.session,
3366        }
3367    }
3368
3369    /// `session.telemetry.*` sub-namespace.
3370    pub fn telemetry(&self) -> SessionRpcTelemetry<'a> {
3371        SessionRpcTelemetry {
3372            session: self.session,
3373        }
3374    }
3375
3376    /// `session.tools.*` sub-namespace.
3377    pub fn tools(&self) -> SessionRpcTools<'a> {
3378        SessionRpcTools {
3379            session: self.session,
3380        }
3381    }
3382
3383    /// `session.ui.*` sub-namespace.
3384    pub fn ui(&self) -> SessionRpcUi<'a> {
3385        SessionRpcUi {
3386            session: self.session,
3387        }
3388    }
3389
3390    /// `session.usage.*` sub-namespace.
3391    pub fn usage(&self) -> SessionRpcUsage<'a> {
3392        SessionRpcUsage {
3393            session: self.session,
3394        }
3395    }
3396
3397    /// `session.visibility.*` sub-namespace.
3398    pub fn visibility(&self) -> SessionRpcVisibility<'a> {
3399        SessionRpcVisibility {
3400            session: self.session,
3401        }
3402    }
3403
3404    /// `session.workflow.*` sub-namespace.
3405    pub fn workflow(&self) -> SessionRpcWorkflow<'a> {
3406        SessionRpcWorkflow {
3407            session: self.session,
3408        }
3409    }
3410
3411    /// `session.workspaces.*` sub-namespace.
3412    pub fn workspaces(&self) -> SessionRpcWorkspaces<'a> {
3413        SessionRpcWorkspaces {
3414            session: self.session,
3415        }
3416    }
3417
3418    /// Suspends the session while preserving persisted state for later resume.
3419    ///
3420    /// Wire method: `session.suspend`.
3421    ///
3422    /// <div class="warning">
3423    ///
3424    /// **Experimental.** This API is part of an experimental wire-protocol surface
3425    /// and may change or be removed in future SDK or CLI releases. Pin both the
3426    /// SDK and CLI versions if your code depends on it.
3427    ///
3428    /// </div>
3429    pub async fn suspend(&self) -> Result<(), Error> {
3430        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3431        let _value = self
3432            .session
3433            .client()
3434            .call(rpc_methods::SESSION_SUSPEND, Some(wire_params))
3435            .await?;
3436        Ok(())
3437    }
3438
3439    /// Sends a user message to the session and returns its message ID.
3440    ///
3441    /// Wire method: `session.send`.
3442    ///
3443    /// # Parameters
3444    ///
3445    /// * `params` - Parameters for sending a user message to the session
3446    ///
3447    /// # Returns
3448    ///
3449    /// Result of sending a user message
3450    ///
3451    /// <div class="warning">
3452    ///
3453    /// **Experimental.** This API is part of an experimental wire-protocol surface
3454    /// and may change or be removed in future SDK or CLI releases. Pin both the
3455    /// SDK and CLI versions if your code depends on it.
3456    ///
3457    /// </div>
3458    pub async fn send(&self, params: SendRequest) -> Result<SendResult, Error> {
3459        let mut wire_params = serde_json::to_value(params)?;
3460        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3461        let _value = self
3462            .session
3463            .client()
3464            .call(rpc_methods::SESSION_SEND, Some(wire_params))
3465            .await?;
3466        Ok(serde_json::from_value(_value)?)
3467    }
3468
3469    /// Sends zero or more user messages to the session in a single turn and returns their message IDs. All provided messages are appended to the conversation in order, then exactly one agent turn runs over the resulting history. When the list is empty, one turn runs over the existing history with no new user message. Remote-backed (Mission Control) sessions do not support this method and will return an error.
3470    ///
3471    /// Wire method: `session.sendMessages`.
3472    ///
3473    /// # Parameters
3474    ///
3475    /// * `params` - Parameters for sending zero or more user messages to the session in a single turn. Remote-backed (Mission Control) sessions do not support this method and will return an error.
3476    ///
3477    /// # Returns
3478    ///
3479    /// Result of sending zero or more user messages
3480    ///
3481    /// <div class="warning">
3482    ///
3483    /// **Experimental.** This API is part of an experimental wire-protocol surface
3484    /// and may change or be removed in future SDK or CLI releases. Pin both the
3485    /// SDK and CLI versions if your code depends on it.
3486    ///
3487    /// </div>
3488    pub async fn send_messages(
3489        &self,
3490        params: SendMessagesRequest,
3491    ) -> Result<SendMessagesResult, Error> {
3492        let mut wire_params = serde_json::to_value(params)?;
3493        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3494        let _value = self
3495            .session
3496            .client()
3497            .call(rpc_methods::SESSION_SENDMESSAGES, Some(wire_params))
3498            .await?;
3499        Ok(serde_json::from_value(_value)?)
3500    }
3501
3502    /// Queues or sends an internal system notification to the session according to its passive policy.
3503    ///
3504    /// Wire method: `session.sendSystemNotification`.
3505    ///
3506    /// # Parameters
3507    ///
3508    /// * `params` - Internal request for sending a system notification.
3509    ///
3510    /// <div class="warning">
3511    ///
3512    /// **Experimental.** This API is part of an experimental wire-protocol surface
3513    /// and may change or be removed in future SDK or CLI releases. Pin both the
3514    /// SDK and CLI versions if your code depends on it.
3515    ///
3516    /// </div>
3517    pub(crate) async fn send_system_notification(
3518        &self,
3519        params: SendSystemNotificationRequest,
3520    ) -> Result<(), Error> {
3521        let mut wire_params = serde_json::to_value(params)?;
3522        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3523        let _value = self
3524            .session
3525            .client()
3526            .call(
3527                rpc_methods::SESSION_SENDSYSTEMNOTIFICATION,
3528                Some(wire_params),
3529            )
3530            .await?;
3531        Ok(())
3532    }
3533
3534    /// Aborts the current agent turn.
3535    ///
3536    /// Wire method: `session.abort`.
3537    ///
3538    /// # Parameters
3539    ///
3540    /// * `params` - Parameters for aborting the current turn
3541    ///
3542    /// # Returns
3543    ///
3544    /// Result of aborting the current turn
3545    ///
3546    /// <div class="warning">
3547    ///
3548    /// **Experimental.** This API is part of an experimental wire-protocol surface
3549    /// and may change or be removed in future SDK or CLI releases. Pin both the
3550    /// SDK and CLI versions if your code depends on it.
3551    ///
3552    /// </div>
3553    pub async fn abort(&self, params: AbortRequest) -> Result<AbortResult, Error> {
3554        let mut wire_params = serde_json::to_value(params)?;
3555        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3556        let _value = self
3557            .session
3558            .client()
3559            .call(rpc_methods::SESSION_ABORT, Some(wire_params))
3560            .await?;
3561        Ok(serde_json::from_value(_value)?)
3562    }
3563
3564    /// Interrupts the current main agent turn while leaving running background work (subagents, sidekicks, and promoted attached shells) alive. No-op when the main loop is not processing.
3565    ///
3566    /// Wire method: `session.interruptMainTurn`.
3567    ///
3568    /// # Parameters
3569    ///
3570    /// * `params` - Parameters for interrupting the main agent turn.
3571    ///
3572    /// # Returns
3573    ///
3574    /// Result of interrupting the main agent turn.
3575    ///
3576    /// <div class="warning">
3577    ///
3578    /// **Experimental.** This API is part of an experimental wire-protocol surface
3579    /// and may change or be removed in future SDK or CLI releases. Pin both the
3580    /// SDK and CLI versions if your code depends on it.
3581    ///
3582    /// </div>
3583    pub async fn interrupt_main_turn(
3584        &self,
3585        params: InterruptMainTurnRequest,
3586    ) -> Result<InterruptMainTurnResult, Error> {
3587        let mut wire_params = serde_json::to_value(params)?;
3588        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3589        let _value = self
3590            .session
3591            .client()
3592            .call(rpc_methods::SESSION_INTERRUPTMAINTURN, Some(wire_params))
3593            .await?;
3594        Ok(serde_json::from_value(_value)?)
3595    }
3596
3597    /// Cancels every running background agent (task-registry subagents plus sidekick agents) without interrupting the main agent loop. Promoted attached shells are left running.
3598    ///
3599    /// Wire method: `session.cancelAllBackgroundAgents`.
3600    ///
3601    /// # Returns
3602    ///
3603    /// The number of running background agents (task-registry agents) that were cancelled.
3604    ///
3605    /// <div class="warning">
3606    ///
3607    /// **Experimental.** This API is part of an experimental wire-protocol surface
3608    /// and may change or be removed in future SDK or CLI releases. Pin both the
3609    /// SDK and CLI versions if your code depends on it.
3610    ///
3611    /// </div>
3612    pub async fn cancel_all_background_agents(
3613        &self,
3614    ) -> Result<SessionCancelAllBackgroundAgentsResult, Error> {
3615        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3616        let _value = self
3617            .session
3618            .client()
3619            .call(
3620                rpc_methods::SESSION_CANCELALLBACKGROUNDAGENTS,
3621                Some(wire_params),
3622            )
3623            .await?;
3624        Ok(serde_json::from_value(_value)?)
3625    }
3626
3627    /// 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.
3628    ///
3629    /// Wire method: `session.shutdown`.
3630    ///
3631    /// # Parameters
3632    ///
3633    /// * `params` - Parameters for shutting down the session
3634    ///
3635    /// <div class="warning">
3636    ///
3637    /// **Experimental.** This API is part of an experimental wire-protocol surface
3638    /// and may change or be removed in future SDK or CLI releases. Pin both the
3639    /// SDK and CLI versions if your code depends on it.
3640    ///
3641    /// </div>
3642    pub async fn shutdown(&self, params: ShutdownRequest) -> Result<(), Error> {
3643        let mut wire_params = serde_json::to_value(params)?;
3644        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3645        let _value = self
3646            .session
3647            .client()
3648            .call(rpc_methods::SESSION_SHUTDOWN, Some(wire_params))
3649            .await?;
3650        Ok(())
3651    }
3652
3653    /// Emits a user-visible session log event.
3654    ///
3655    /// Wire method: `session.log`.
3656    ///
3657    /// # Parameters
3658    ///
3659    /// * `params` - Message text, optional severity level, persistence flag, optional follow-up URL, and optional tip.
3660    ///
3661    /// # Returns
3662    ///
3663    /// Identifier of the session event that was emitted for the log message.
3664    ///
3665    /// <div class="warning">
3666    ///
3667    /// **Experimental.** This API is part of an experimental wire-protocol surface
3668    /// and may change or be removed in future SDK or CLI releases. Pin both the
3669    /// SDK and CLI versions if your code depends on it.
3670    ///
3671    /// </div>
3672    pub async fn log(&self, params: LogRequest) -> Result<LogResult, Error> {
3673        let mut wire_params = serde_json::to_value(params)?;
3674        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3675        let _value = self
3676            .session
3677            .client()
3678            .call(rpc_methods::SESSION_LOG, Some(wire_params))
3679            .await?;
3680        Ok(serde_json::from_value(_value)?)
3681    }
3682}
3683
3684/// `session.agent.*` RPCs.
3685#[derive(Clone, Copy)]
3686pub struct SessionRpcAgent<'a> {
3687    pub(crate) session: &'a Session,
3688}
3689
3690impl<'a> SessionRpcAgent<'a> {
3691    /// Lists agents available to the session. Defaults to custom agents only; pass includeBuiltInAgents to include the effective built-in agents.
3692    ///
3693    /// Wire method: `session.agent.list`.
3694    ///
3695    /// # Returns
3696    ///
3697    /// Agents available to the session.
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 list(&self) -> Result<AgentList, Error> {
3707        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3708        let _value = self
3709            .session
3710            .client()
3711            .call(rpc_methods::SESSION_AGENT_LIST, Some(wire_params))
3712            .await?;
3713        Ok(serde_json::from_value(_value)?)
3714    }
3715
3716    /// Lists agents available to the session. Defaults to custom agents only; pass includeBuiltInAgents to include the effective built-in agents.
3717    ///
3718    /// Wire method: `session.agent.list`.
3719    ///
3720    /// # Parameters
3721    ///
3722    /// * `params` - Controls whether built-in agents and authored prompt text are included.
3723    ///
3724    /// # Returns
3725    ///
3726    /// Agents available to the session.
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 list_with_params(&self, params: AgentListRequest) -> Result<AgentList, Error> {
3736        let mut wire_params = serde_json::to_value(params)?;
3737        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3738        let _value = self
3739            .session
3740            .client()
3741            .call(rpc_methods::SESSION_AGENT_LIST, Some(wire_params))
3742            .await?;
3743        Ok(serde_json::from_value(_value)?)
3744    }
3745
3746    /// Sets an in-memory authored prompt override for an available agent. For built-in agents, this replaces only the static base prompt while preserving runtime-owned dynamic prompt composition and behavior. The special `general-purpose` agent is not overrideable. Overrides are not persisted; resumed and forked sessions start without them, so the host must re-apply them.
3747    ///
3748    /// Wire method: `session.agent.setPrompt`.
3749    ///
3750    /// # Parameters
3751    ///
3752    /// * `params` - An in-memory authored prompt override for an available agent.
3753    ///
3754    /// <div class="warning">
3755    ///
3756    /// **Experimental.** This API is part of an experimental wire-protocol surface
3757    /// and may change or be removed in future SDK or CLI releases. Pin both the
3758    /// SDK and CLI versions if your code depends on it.
3759    ///
3760    /// </div>
3761    pub async fn set_prompt(&self, params: AgentSetPromptRequest) -> Result<(), Error> {
3762        let mut wire_params = serde_json::to_value(params)?;
3763        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3764        let _value = self
3765            .session
3766            .client()
3767            .call(rpc_methods::SESSION_AGENT_SETPROMPT, Some(wire_params))
3768            .await?;
3769        Ok(())
3770    }
3771
3772    /// Gets the currently selected custom agent for the session.
3773    ///
3774    /// Wire method: `session.agent.getCurrent`.
3775    ///
3776    /// # Returns
3777    ///
3778    /// The currently selected custom agent, or null when using the default agent.
3779    ///
3780    /// <div class="warning">
3781    ///
3782    /// **Experimental.** This API is part of an experimental wire-protocol surface
3783    /// and may change or be removed in future SDK or CLI releases. Pin both the
3784    /// SDK and CLI versions if your code depends on it.
3785    ///
3786    /// </div>
3787    pub async fn get_current(&self) -> Result<AgentGetCurrentResult, Error> {
3788        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3789        let _value = self
3790            .session
3791            .client()
3792            .call(rpc_methods::SESSION_AGENT_GETCURRENT, Some(wire_params))
3793            .await?;
3794        Ok(serde_json::from_value(_value)?)
3795    }
3796
3797    /// Selects a custom agent for subsequent turns in the session.
3798    ///
3799    /// Wire method: `session.agent.select`.
3800    ///
3801    /// # Parameters
3802    ///
3803    /// * `params` - Name of the custom agent to select for subsequent turns.
3804    ///
3805    /// # Returns
3806    ///
3807    /// The newly selected custom agent.
3808    ///
3809    /// <div class="warning">
3810    ///
3811    /// **Experimental.** This API is part of an experimental wire-protocol surface
3812    /// and may change or be removed in future SDK or CLI releases. Pin both the
3813    /// SDK and CLI versions if your code depends on it.
3814    ///
3815    /// </div>
3816    pub async fn select(&self, params: AgentSelectRequest) -> Result<AgentSelectResult, Error> {
3817        let mut wire_params = serde_json::to_value(params)?;
3818        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3819        let _value = self
3820            .session
3821            .client()
3822            .call(rpc_methods::SESSION_AGENT_SELECT, Some(wire_params))
3823            .await?;
3824        Ok(serde_json::from_value(_value)?)
3825    }
3826
3827    /// Clears the selected custom agent and returns the session to the default agent.
3828    ///
3829    /// Wire method: `session.agent.deselect`.
3830    ///
3831    /// <div class="warning">
3832    ///
3833    /// **Experimental.** This API is part of an experimental wire-protocol surface
3834    /// and may change or be removed in future SDK or CLI releases. Pin both the
3835    /// SDK and CLI versions if your code depends on it.
3836    ///
3837    /// </div>
3838    pub async fn deselect(&self) -> Result<(), Error> {
3839        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3840        let _value = self
3841            .session
3842            .client()
3843            .call(rpc_methods::SESSION_AGENT_DESELECT, Some(wire_params))
3844            .await?;
3845        Ok(())
3846    }
3847
3848    /// Reloads custom agent definitions and returns the refreshed list.
3849    ///
3850    /// Wire method: `session.agent.reload`.
3851    ///
3852    /// # Returns
3853    ///
3854    /// Custom agents available to the session after reloading definitions from disk.
3855    ///
3856    /// <div class="warning">
3857    ///
3858    /// **Experimental.** This API is part of an experimental wire-protocol surface
3859    /// and may change or be removed in future SDK or CLI releases. Pin both the
3860    /// SDK and CLI versions if your code depends on it.
3861    ///
3862    /// </div>
3863    pub async fn reload(&self) -> Result<AgentReloadResult, Error> {
3864        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3865        let _value = self
3866            .session
3867            .client()
3868            .call(rpc_methods::SESSION_AGENT_RELOAD, Some(wire_params))
3869            .await?;
3870        Ok(serde_json::from_value(_value)?)
3871    }
3872}
3873
3874/// `session.autopilotObjective.*` RPCs.
3875#[derive(Clone, Copy)]
3876pub struct SessionRpcAutopilotObjective<'a> {
3877    pub(crate) session: &'a Session,
3878}
3879
3880impl<'a> SessionRpcAutopilotObjective<'a> {
3881    /// Reads the current canonical autopilot objective state for this session.
3882    ///
3883    /// Wire method: `session.autopilotObjective.getState`.
3884    ///
3885    /// # Returns
3886    ///
3887    /// Canonical runtime state for the session's current autopilot objective.
3888    ///
3889    /// <div class="warning">
3890    ///
3891    /// **Experimental.** This API is part of an experimental wire-protocol surface
3892    /// and may change or be removed in future SDK or CLI releases. Pin both the
3893    /// SDK and CLI versions if your code depends on it.
3894    ///
3895    /// </div>
3896    pub async fn get_state(&self) -> Result<AutopilotObjectiveGetStateResult, Error> {
3897        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3898        let _value = self
3899            .session
3900            .client()
3901            .call(
3902                rpc_methods::SESSION_AUTOPILOTOBJECTIVE_GETSTATE,
3903                Some(wire_params),
3904            )
3905            .await?;
3906        Ok(serde_json::from_value(_value)?)
3907    }
3908}
3909
3910/// `session.canvas.*` RPCs.
3911#[derive(Clone, Copy)]
3912pub struct SessionRpcCanvas<'a> {
3913    pub(crate) session: &'a Session,
3914}
3915
3916impl<'a> SessionRpcCanvas<'a> {
3917    /// `session.canvas.action.*` sub-namespace.
3918    pub fn action(&self) -> SessionRpcCanvasAction<'a> {
3919        SessionRpcCanvasAction {
3920            session: self.session,
3921        }
3922    }
3923
3924    /// `session.canvas.provider.*` sub-namespace.
3925    pub fn provider(&self) -> SessionRpcCanvasProvider<'a> {
3926        SessionRpcCanvasProvider {
3927            session: self.session,
3928        }
3929    }
3930
3931    /// Lists canvases declared for the session.
3932    ///
3933    /// Wire method: `session.canvas.list`.
3934    ///
3935    /// # Returns
3936    ///
3937    /// Declared canvases available in this session.
3938    ///
3939    /// <div class="warning">
3940    ///
3941    /// **Experimental.** This API is part of an experimental wire-protocol surface
3942    /// and may change or be removed in future SDK or CLI releases. Pin both the
3943    /// SDK and CLI versions if your code depends on it.
3944    ///
3945    /// </div>
3946    pub async fn list(&self) -> Result<CanvasList, Error> {
3947        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3948        let _value = self
3949            .session
3950            .client()
3951            .call(rpc_methods::SESSION_CANVAS_LIST, Some(wire_params))
3952            .await?;
3953        Ok(serde_json::from_value(_value)?)
3954    }
3955
3956    /// Lists currently open canvas instances for the live session.
3957    ///
3958    /// Wire method: `session.canvas.listOpen`.
3959    ///
3960    /// # Returns
3961    ///
3962    /// Live open-canvas snapshot.
3963    ///
3964    /// <div class="warning">
3965    ///
3966    /// **Experimental.** This API is part of an experimental wire-protocol surface
3967    /// and may change or be removed in future SDK or CLI releases. Pin both the
3968    /// SDK and CLI versions if your code depends on it.
3969    ///
3970    /// </div>
3971    pub async fn list_open(&self) -> Result<CanvasListOpenResult, Error> {
3972        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3973        let _value = self
3974            .session
3975            .client()
3976            .call(rpc_methods::SESSION_CANVAS_LISTOPEN, Some(wire_params))
3977            .await?;
3978        Ok(serde_json::from_value(_value)?)
3979    }
3980
3981    /// Opens or focuses a canvas instance.
3982    ///
3983    /// Wire method: `session.canvas.open`.
3984    ///
3985    /// # Parameters
3986    ///
3987    /// * `params` - Canvas open parameters.
3988    ///
3989    /// # Returns
3990    ///
3991    /// Open canvas instance snapshot.
3992    ///
3993    /// <div class="warning">
3994    ///
3995    /// **Experimental.** This API is part of an experimental wire-protocol surface
3996    /// and may change or be removed in future SDK or CLI releases. Pin both the
3997    /// SDK and CLI versions if your code depends on it.
3998    ///
3999    /// </div>
4000    pub async fn open(&self, params: CanvasOpenRequest) -> Result<OpenCanvasInstance, Error> {
4001        let mut wire_params = serde_json::to_value(params)?;
4002        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4003        let _value = self
4004            .session
4005            .client()
4006            .call(rpc_methods::SESSION_CANVAS_OPEN, Some(wire_params))
4007            .await?;
4008        Ok(serde_json::from_value(_value)?)
4009    }
4010
4011    /// Closes an open canvas instance.
4012    ///
4013    /// Wire method: `session.canvas.close`.
4014    ///
4015    /// # Parameters
4016    ///
4017    /// * `params` - Canvas close parameters.
4018    ///
4019    /// <div class="warning">
4020    ///
4021    /// **Experimental.** This API is part of an experimental wire-protocol surface
4022    /// and may change or be removed in future SDK or CLI releases. Pin both the
4023    /// SDK and CLI versions if your code depends on it.
4024    ///
4025    /// </div>
4026    pub async fn close(&self, params: CanvasCloseRequest) -> Result<(), Error> {
4027        let mut wire_params = serde_json::to_value(params)?;
4028        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4029        let _value = self
4030            .session
4031            .client()
4032            .call(rpc_methods::SESSION_CANVAS_CLOSE, Some(wire_params))
4033            .await?;
4034        Ok(())
4035    }
4036}
4037
4038/// `session.canvas.action.*` RPCs.
4039#[derive(Clone, Copy)]
4040pub struct SessionRpcCanvasAction<'a> {
4041    pub(crate) session: &'a Session,
4042}
4043
4044impl<'a> SessionRpcCanvasAction<'a> {
4045    /// Invokes an action on an open canvas instance.
4046    ///
4047    /// Wire method: `session.canvas.action.invoke`.
4048    ///
4049    /// # Parameters
4050    ///
4051    /// * `params` - Canvas action invocation parameters.
4052    ///
4053    /// # Returns
4054    ///
4055    /// Canvas action invocation result.
4056    ///
4057    /// <div class="warning">
4058    ///
4059    /// **Experimental.** This API is part of an experimental wire-protocol surface
4060    /// and may change or be removed in future SDK or CLI releases. Pin both the
4061    /// SDK and CLI versions if your code depends on it.
4062    ///
4063    /// </div>
4064    pub async fn invoke(
4065        &self,
4066        params: CanvasActionInvokeRequest,
4067    ) -> Result<CanvasActionInvokeResult, Error> {
4068        let mut wire_params = serde_json::to_value(params)?;
4069        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4070        let _value = self
4071            .session
4072            .client()
4073            .call(rpc_methods::SESSION_CANVAS_ACTION_INVOKE, Some(wire_params))
4074            .await?;
4075        Ok(serde_json::from_value(_value)?)
4076    }
4077}
4078
4079/// `session.canvas.provider.*` RPCs.
4080#[derive(Clone, Copy)]
4081pub struct SessionRpcCanvasProvider<'a> {
4082    pub(crate) session: &'a Session,
4083}
4084
4085impl<'a> SessionRpcCanvasProvider<'a> {
4086    /// Registers an internal canvas provider connection and its contributions.
4087    ///
4088    /// Wire method: `session.canvas.provider.register`.
4089    ///
4090    /// # Parameters
4091    ///
4092    /// * `params` - Internal canvas provider registration parameters.
4093    ///
4094    /// <div class="warning">
4095    ///
4096    /// **Experimental.** This API is part of an experimental wire-protocol surface
4097    /// and may change or be removed in future SDK or CLI releases. Pin both the
4098    /// SDK and CLI versions if your code depends on it.
4099    ///
4100    /// </div>
4101    pub(crate) async fn register(
4102        &self,
4103        params: CanvasProviderRegisterRequest,
4104    ) -> Result<(), Error> {
4105        let mut wire_params = serde_json::to_value(params)?;
4106        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4107        let _value = self
4108            .session
4109            .client()
4110            .call(
4111                rpc_methods::SESSION_CANVAS_PROVIDER_REGISTER,
4112                Some(wire_params),
4113            )
4114            .await?;
4115        Ok(())
4116    }
4117
4118    /// Unregisters an internal canvas provider connection.
4119    ///
4120    /// Wire method: `session.canvas.provider.unregister`.
4121    ///
4122    /// # Parameters
4123    ///
4124    /// * `params` - Internal canvas provider unregistration parameters.
4125    ///
4126    /// <div class="warning">
4127    ///
4128    /// **Experimental.** This API is part of an experimental wire-protocol surface
4129    /// and may change or be removed in future SDK or CLI releases. Pin both the
4130    /// SDK and CLI versions if your code depends on it.
4131    ///
4132    /// </div>
4133    pub(crate) async fn unregister(
4134        &self,
4135        params: CanvasProviderUnregisterRequest,
4136    ) -> Result<(), Error> {
4137        let mut wire_params = serde_json::to_value(params)?;
4138        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4139        let _value = self
4140            .session
4141            .client()
4142            .call(
4143                rpc_methods::SESSION_CANVAS_PROVIDER_UNREGISTER,
4144                Some(wire_params),
4145            )
4146            .await?;
4147        Ok(())
4148    }
4149}
4150
4151/// `session.commands.*` RPCs.
4152#[derive(Clone, Copy)]
4153pub struct SessionRpcCommands<'a> {
4154    pub(crate) session: &'a Session,
4155}
4156
4157impl<'a> SessionRpcCommands<'a> {
4158    /// Lists slash commands available in the session.
4159    ///
4160    /// Wire method: `session.commands.list`.
4161    ///
4162    /// # Returns
4163    ///
4164    /// Slash commands available in the session, after applying any include/exclude filters.
4165    ///
4166    /// <div class="warning">
4167    ///
4168    /// **Experimental.** This API is part of an experimental wire-protocol surface
4169    /// and may change or be removed in future SDK or CLI releases. Pin both the
4170    /// SDK and CLI versions if your code depends on it.
4171    ///
4172    /// </div>
4173    pub async fn list(&self) -> Result<CommandList, Error> {
4174        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
4175        let _value = self
4176            .session
4177            .client()
4178            .call(rpc_methods::SESSION_COMMANDS_LIST, Some(wire_params))
4179            .await?;
4180        Ok(serde_json::from_value(_value)?)
4181    }
4182
4183    /// Lists slash commands available in the session.
4184    ///
4185    /// Wire method: `session.commands.list`.
4186    ///
4187    /// # Parameters
4188    ///
4189    /// * `params` - Optional filters controlling which command sources to include in the listing.
4190    ///
4191    /// # Returns
4192    ///
4193    /// Slash commands available in the session, after applying any include/exclude filters.
4194    ///
4195    /// <div class="warning">
4196    ///
4197    /// **Experimental.** This API is part of an experimental wire-protocol surface
4198    /// and may change or be removed in future SDK or CLI releases. Pin both the
4199    /// SDK and CLI versions if your code depends on it.
4200    ///
4201    /// </div>
4202    pub async fn list_with_params(
4203        &self,
4204        params: CommandsListRequest,
4205    ) -> Result<CommandList, Error> {
4206        let mut wire_params = serde_json::to_value(params)?;
4207        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4208        let _value = self
4209            .session
4210            .client()
4211            .call(rpc_methods::SESSION_COMMANDS_LIST, Some(wire_params))
4212            .await?;
4213        Ok(serde_json::from_value(_value)?)
4214    }
4215
4216    /// Invokes a slash command in the session.
4217    ///
4218    /// Wire method: `session.commands.invoke`.
4219    ///
4220    /// # Parameters
4221    ///
4222    /// * `params` - Slash command name and optional raw input string to invoke.
4223    ///
4224    /// # Returns
4225    ///
4226    /// Result of invoking the slash command (text output, prompt to send to the agent, completion, or subcommand selection).
4227    ///
4228    /// <div class="warning">
4229    ///
4230    /// **Experimental.** This API is part of an experimental wire-protocol surface
4231    /// and may change or be removed in future SDK or CLI releases. Pin both the
4232    /// SDK and CLI versions if your code depends on it.
4233    ///
4234    /// </div>
4235    pub async fn invoke(
4236        &self,
4237        params: CommandsInvokeRequest,
4238    ) -> Result<SlashCommandInvocationResult, Error> {
4239        let mut wire_params = serde_json::to_value(params)?;
4240        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4241        let _value = self
4242            .session
4243            .client()
4244            .call(rpc_methods::SESSION_COMMANDS_INVOKE, Some(wire_params))
4245            .await?;
4246        Ok(serde_json::from_value(_value)?)
4247    }
4248
4249    /// Finalizes persistence associated with a client-applied slash-command effect.
4250    ///
4251    /// Wire method: `session.commands.finalizeInvocationEffect`.
4252    ///
4253    /// # Parameters
4254    ///
4255    /// * `params` - The pending slash-command invocation effect to finalize, plus whether the host applied or cancelled it.
4256    ///
4257    /// # Returns
4258    ///
4259    /// Whether finalizing the invocation effect succeeded, and the failure reason when it did not.
4260    ///
4261    /// <div class="warning">
4262    ///
4263    /// **Experimental.** This API is part of an experimental wire-protocol surface
4264    /// and may change or be removed in future SDK or CLI releases. Pin both the
4265    /// SDK and CLI versions if your code depends on it.
4266    ///
4267    /// </div>
4268    pub(crate) async fn finalize_invocation_effect(
4269        &self,
4270        params: CommandsFinalizeInvocationEffectRequest,
4271    ) -> Result<CommandsFinalizeInvocationEffectResult, Error> {
4272        let mut wire_params = serde_json::to_value(params)?;
4273        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4274        let _value = self
4275            .session
4276            .client()
4277            .call(
4278                rpc_methods::SESSION_COMMANDS_FINALIZEINVOCATIONEFFECT,
4279                Some(wire_params),
4280            )
4281            .await?;
4282        Ok(serde_json::from_value(_value)?)
4283    }
4284
4285    /// Reports completion of a pending client-handled slash command.
4286    ///
4287    /// Wire method: `session.commands.handlePendingCommand`.
4288    ///
4289    /// # Parameters
4290    ///
4291    /// * `params` - Pending command request ID and an optional error if the client handler failed.
4292    ///
4293    /// # Returns
4294    ///
4295    /// Indicates whether the pending client-handled command was completed successfully.
4296    ///
4297    /// <div class="warning">
4298    ///
4299    /// **Experimental.** This API is part of an experimental wire-protocol surface
4300    /// and may change or be removed in future SDK or CLI releases. Pin both the
4301    /// SDK and CLI versions if your code depends on it.
4302    ///
4303    /// </div>
4304    pub async fn handle_pending_command(
4305        &self,
4306        params: CommandsHandlePendingCommandRequest,
4307    ) -> Result<CommandsHandlePendingCommandResult, Error> {
4308        let mut wire_params = serde_json::to_value(params)?;
4309        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4310        let _value = self
4311            .session
4312            .client()
4313            .call(
4314                rpc_methods::SESSION_COMMANDS_HANDLEPENDINGCOMMAND,
4315                Some(wire_params),
4316            )
4317            .await?;
4318        Ok(serde_json::from_value(_value)?)
4319    }
4320
4321    /// Executes a slash command synchronously and returns any error.
4322    ///
4323    /// Wire method: `session.commands.execute`.
4324    ///
4325    /// # Parameters
4326    ///
4327    /// * `params` - Slash command name and argument string to execute synchronously.
4328    ///
4329    /// # Returns
4330    ///
4331    /// Error message produced while executing the command, if any.
4332    ///
4333    /// <div class="warning">
4334    ///
4335    /// **Experimental.** This API is part of an experimental wire-protocol surface
4336    /// and may change or be removed in future SDK or CLI releases. Pin both the
4337    /// SDK and CLI versions if your code depends on it.
4338    ///
4339    /// </div>
4340    pub async fn execute(
4341        &self,
4342        params: ExecuteCommandParams,
4343    ) -> Result<ExecuteCommandResult, Error> {
4344        let mut wire_params = serde_json::to_value(params)?;
4345        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4346        let _value = self
4347            .session
4348            .client()
4349            .call(rpc_methods::SESSION_COMMANDS_EXECUTE, Some(wire_params))
4350            .await?;
4351        Ok(serde_json::from_value(_value)?)
4352    }
4353
4354    /// Enqueues a slash command for FIFO processing on the local session.
4355    ///
4356    /// Wire method: `session.commands.enqueue`.
4357    ///
4358    /// # Parameters
4359    ///
4360    /// * `params` - Slash-prefixed command string to enqueue for FIFO processing.
4361    ///
4362    /// # Returns
4363    ///
4364    /// Indicates whether the command was accepted into the local execution queue.
4365    ///
4366    /// <div class="warning">
4367    ///
4368    /// **Experimental.** This API is part of an experimental wire-protocol surface
4369    /// and may change or be removed in future SDK or CLI releases. Pin both the
4370    /// SDK and CLI versions if your code depends on it.
4371    ///
4372    /// </div>
4373    pub async fn enqueue(
4374        &self,
4375        params: EnqueueCommandParams,
4376    ) -> Result<EnqueueCommandResult, Error> {
4377        let mut wire_params = serde_json::to_value(params)?;
4378        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4379        let _value = self
4380            .session
4381            .client()
4382            .call(rpc_methods::SESSION_COMMANDS_ENQUEUE, Some(wire_params))
4383            .await?;
4384        Ok(serde_json::from_value(_value)?)
4385    }
4386
4387    /// Reports whether the host actually executed a queued command and whether to continue processing.
4388    ///
4389    /// Wire method: `session.commands.respondToQueuedCommand`.
4390    ///
4391    /// # Parameters
4392    ///
4393    /// * `params` - Queued-command request ID and the result indicating whether the host executed it (and whether to stop processing further queued commands).
4394    ///
4395    /// # Returns
4396    ///
4397    /// Indicates whether the queued-command response was matched to a pending request.
4398    ///
4399    /// <div class="warning">
4400    ///
4401    /// **Experimental.** This API is part of an experimental wire-protocol surface
4402    /// and may change or be removed in future SDK or CLI releases. Pin both the
4403    /// SDK and CLI versions if your code depends on it.
4404    ///
4405    /// </div>
4406    pub async fn respond_to_queued_command(
4407        &self,
4408        params: CommandsRespondToQueuedCommandRequest,
4409    ) -> Result<CommandsRespondToQueuedCommandResult, Error> {
4410        let mut wire_params = serde_json::to_value(params)?;
4411        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4412        let _value = self
4413            .session
4414            .client()
4415            .call(
4416                rpc_methods::SESSION_COMMANDS_RESPONDTOQUEUEDCOMMAND,
4417                Some(wire_params),
4418            )
4419            .await?;
4420        Ok(serde_json::from_value(_value)?)
4421    }
4422}
4423
4424/// `session.completions.*` RPCs.
4425#[derive(Clone, Copy)]
4426pub struct SessionRpcCompletions<'a> {
4427    pub(crate) session: &'a Session,
4428}
4429
4430impl<'a> SessionRpcCompletions<'a> {
4431    /// Gets the characters that should trigger host-driven completions for the session. Empty disables host-driven completions (e.g. local sessions, or a relay host that does not advertise them).
4432    ///
4433    /// Wire method: `session.completions.getTriggerCharacters`.
4434    ///
4435    /// # Returns
4436    ///
4437    /// Characters that, when typed in the composer, should trigger a `completions.request`. Empty when the session has no host-driven completions (e.g. local sessions, or a relay host that does not advertise `completionTriggerCharacters`).
4438    ///
4439    /// <div class="warning">
4440    ///
4441    /// **Experimental.** This API is part of an experimental wire-protocol surface
4442    /// and may change or be removed in future SDK or CLI releases. Pin both the
4443    /// SDK and CLI versions if your code depends on it.
4444    ///
4445    /// </div>
4446    pub async fn get_trigger_characters(
4447        &self,
4448    ) -> Result<CompletionsGetTriggerCharactersResult, Error> {
4449        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
4450        let _value = self
4451            .session
4452            .client()
4453            .call(
4454                rpc_methods::SESSION_COMPLETIONS_GETTRIGGERCHARACTERS,
4455                Some(wire_params),
4456            )
4457            .await?;
4458        Ok(serde_json::from_value(_value)?)
4459    }
4460
4461    /// Requests host-driven completion items for the current composer input. Returns an empty list when the host has no items or does not support completions.
4462    ///
4463    /// Wire method: `session.completions.request`.
4464    ///
4465    /// # Parameters
4466    ///
4467    /// * `params` - Request host-driven completions for the current composer input.
4468    ///
4469    /// # Returns
4470    ///
4471    /// Host-driven completion items for the current composer input. Empty when the host returns no items or does not support completions.
4472    ///
4473    /// <div class="warning">
4474    ///
4475    /// **Experimental.** This API is part of an experimental wire-protocol surface
4476    /// and may change or be removed in future SDK or CLI releases. Pin both the
4477    /// SDK and CLI versions if your code depends on it.
4478    ///
4479    /// </div>
4480    pub async fn request(
4481        &self,
4482        params: CompletionsRequestRequest,
4483    ) -> Result<CompletionsRequestResult, Error> {
4484        let mut wire_params = serde_json::to_value(params)?;
4485        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4486        let _value = self
4487            .session
4488            .client()
4489            .call(rpc_methods::SESSION_COMPLETIONS_REQUEST, Some(wire_params))
4490            .await?;
4491        Ok(serde_json::from_value(_value)?)
4492    }
4493}
4494
4495/// `session.contentExclusion.*` RPCs.
4496#[derive(Clone, Copy)]
4497pub struct SessionRpcContentExclusion<'a> {
4498    pub(crate) session: &'a Session,
4499}
4500
4501impl<'a> SessionRpcContentExclusion<'a> {
4502    /// Checks local file system absolute paths within the session working directory against its content-exclusion policy. Results preserve input order. Unsupported paths/filesystems and unavailable policy evaluation return available false, and callers must treat every requested path as excluded.
4503    ///
4504    /// Wire method: `session.contentExclusion.checkPaths`.
4505    ///
4506    /// # Parameters
4507    ///
4508    /// * `params` - Local file system absolute paths within the session working directory to check against its content-exclusion policy.
4509    ///
4510    /// # Returns
4511    ///
4512    /// Batch content-exclusion result. Callers must fail closed when policy evaluation is unavailable.
4513    ///
4514    /// <div class="warning">
4515    ///
4516    /// **Experimental.** This API is part of an experimental wire-protocol surface
4517    /// and may change or be removed in future SDK or CLI releases. Pin both the
4518    /// SDK and CLI versions if your code depends on it.
4519    ///
4520    /// </div>
4521    pub async fn check_paths(
4522        &self,
4523        params: ContentExclusionCheckPathsRequest,
4524    ) -> Result<ContentExclusionCheckPathsResult, Error> {
4525        let mut wire_params = serde_json::to_value(params)?;
4526        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4527        let _value = self
4528            .session
4529            .client()
4530            .call(
4531                rpc_methods::SESSION_CONTENTEXCLUSION_CHECKPATHS,
4532                Some(wire_params),
4533            )
4534            .await?;
4535        Ok(serde_json::from_value(_value)?)
4536    }
4537}
4538
4539/// `session.debug.*` RPCs.
4540#[derive(Clone, Copy)]
4541pub struct SessionRpcDebug<'a> {
4542    pub(crate) session: &'a Session,
4543}
4544
4545impl<'a> SessionRpcDebug<'a> {
4546    /// Collects a session debug log bundle into a local archive or staging directory. Logs are redacted by default; redaction can be configured per caller-provided diagnostic entry. The runtime includes session-owned logs by default and accepts caller-provided diagnostic entries so host applications can add their own files without changing this API shape.
4547    ///
4548    /// Wire method: `session.debug.collectLogs`.
4549    ///
4550    /// # Parameters
4551    ///
4552    /// * `params` - Options for collecting a session debug bundle with configurable redaction.
4553    ///
4554    /// # Returns
4555    ///
4556    /// Result of collecting a session debug bundle.
4557    ///
4558    /// <div class="warning">
4559    ///
4560    /// **Experimental.** This API is part of an experimental wire-protocol surface
4561    /// and may change or be removed in future SDK or CLI releases. Pin both the
4562    /// SDK and CLI versions if your code depends on it.
4563    ///
4564    /// </div>
4565    pub async fn collect_logs(
4566        &self,
4567        params: DebugCollectLogsRequest,
4568    ) -> Result<DebugCollectLogsResult, Error> {
4569        let mut wire_params = serde_json::to_value(params)?;
4570        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4571        let _value = self
4572            .session
4573            .client()
4574            .call(rpc_methods::SESSION_DEBUG_COLLECTLOGS, Some(wire_params))
4575            .await?;
4576        Ok(serde_json::from_value(_value)?)
4577    }
4578}
4579
4580/// `session.eventLog.*` RPCs.
4581#[derive(Clone, Copy)]
4582pub struct SessionRpcEventLog<'a> {
4583    pub(crate) session: &'a Session,
4584}
4585
4586impl<'a> SessionRpcEventLog<'a> {
4587    /// Reads a batch of session events from a cursor, optionally waiting for new events. Supports tail-first reads via `direction: backward`.
4588    ///
4589    /// Wire method: `session.eventLog.read`.
4590    ///
4591    /// # Parameters
4592    ///
4593    /// * `params` - Cursor, batch size, and optional long-poll/filter parameters for reading session events.
4594    ///
4595    /// # Returns
4596    ///
4597    /// Batch of session events returned by a read, with cursor and continuation metadata.
4598    ///
4599    /// <div class="warning">
4600    ///
4601    /// **Experimental.** This API is part of an experimental wire-protocol surface
4602    /// and may change or be removed in future SDK or CLI releases. Pin both the
4603    /// SDK and CLI versions if your code depends on it.
4604    ///
4605    /// </div>
4606    pub async fn read(&self, params: EventLogReadRequest) -> Result<EventsReadResult, Error> {
4607        let mut wire_params = serde_json::to_value(params)?;
4608        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4609        let _value = self
4610            .session
4611            .client()
4612            .call(rpc_methods::SESSION_EVENTLOG_READ, Some(wire_params))
4613            .await?;
4614        Ok(serde_json::from_value(_value)?)
4615    }
4616
4617    /// Returns a snapshot of the current tail cursor without consuming events.
4618    ///
4619    /// Wire method: `session.eventLog.tail`.
4620    ///
4621    /// # Returns
4622    ///
4623    /// 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).
4624    ///
4625    /// <div class="warning">
4626    ///
4627    /// **Experimental.** This API is part of an experimental wire-protocol surface
4628    /// and may change or be removed in future SDK or CLI releases. Pin both the
4629    /// SDK and CLI versions if your code depends on it.
4630    ///
4631    /// </div>
4632    pub async fn tail(&self) -> Result<EventLogTailResult, Error> {
4633        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
4634        let _value = self
4635            .session
4636            .client()
4637            .call(rpc_methods::SESSION_EVENTLOG_TAIL, Some(wire_params))
4638            .await?;
4639        Ok(serde_json::from_value(_value)?)
4640    }
4641
4642    /// Registers consumer interest in an event type for runtime gating purposes.
4643    ///
4644    /// Wire method: `session.eventLog.registerInterest`.
4645    ///
4646    /// # Parameters
4647    ///
4648    /// * `params` - Event type to register consumer interest for, used by runtime gating logic.
4649    ///
4650    /// # Returns
4651    ///
4652    /// Opaque handle representing an event-type interest registration.
4653    ///
4654    /// <div class="warning">
4655    ///
4656    /// **Experimental.** This API is part of an experimental wire-protocol surface
4657    /// and may change or be removed in future SDK or CLI releases. Pin both the
4658    /// SDK and CLI versions if your code depends on it.
4659    ///
4660    /// </div>
4661    pub async fn register_interest(
4662        &self,
4663        params: RegisterEventInterestParams,
4664    ) -> Result<RegisterEventInterestResult, Error> {
4665        let mut wire_params = serde_json::to_value(params)?;
4666        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4667        let _value = self
4668            .session
4669            .client()
4670            .call(
4671                rpc_methods::SESSION_EVENTLOG_REGISTERINTEREST,
4672                Some(wire_params),
4673            )
4674            .await?;
4675        Ok(serde_json::from_value(_value)?)
4676    }
4677
4678    /// Releases a consumer's previously-registered interest in an event type.
4679    ///
4680    /// Wire method: `session.eventLog.releaseInterest`.
4681    ///
4682    /// # Parameters
4683    ///
4684    /// * `params` - Opaque handle previously returned by `registerInterest` to release.
4685    ///
4686    /// # Returns
4687    ///
4688    /// Indicates whether the operation succeeded.
4689    ///
4690    /// <div class="warning">
4691    ///
4692    /// **Experimental.** This API is part of an experimental wire-protocol surface
4693    /// and may change or be removed in future SDK or CLI releases. Pin both the
4694    /// SDK and CLI versions if your code depends on it.
4695    ///
4696    /// </div>
4697    pub async fn release_interest(
4698        &self,
4699        params: ReleaseEventInterestParams,
4700    ) -> Result<EventLogReleaseInterestResult, Error> {
4701        let mut wire_params = serde_json::to_value(params)?;
4702        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4703        let _value = self
4704            .session
4705            .client()
4706            .call(
4707                rpc_methods::SESSION_EVENTLOG_RELEASEINTEREST,
4708                Some(wire_params),
4709            )
4710            .await?;
4711        Ok(serde_json::from_value(_value)?)
4712    }
4713}
4714
4715/// `session.extensions.*` RPCs.
4716#[derive(Clone, Copy)]
4717pub struct SessionRpcExtensions<'a> {
4718    pub(crate) session: &'a Session,
4719}
4720
4721impl<'a> SessionRpcExtensions<'a> {
4722    /// Lists extensions discovered for the session and their current status.
4723    ///
4724    /// Wire method: `session.extensions.list`.
4725    ///
4726    /// # Returns
4727    ///
4728    /// Extensions discovered for the session, with their current status.
4729    ///
4730    /// <div class="warning">
4731    ///
4732    /// **Experimental.** This API is part of an experimental wire-protocol surface
4733    /// and may change or be removed in future SDK or CLI releases. Pin both the
4734    /// SDK and CLI versions if your code depends on it.
4735    ///
4736    /// </div>
4737    pub async fn list(&self) -> Result<ExtensionList, Error> {
4738        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
4739        let _value = self
4740            .session
4741            .client()
4742            .call(rpc_methods::SESSION_EXTENSIONS_LIST, Some(wire_params))
4743            .await?;
4744        Ok(serde_json::from_value(_value)?)
4745    }
4746
4747    /// Enables an extension for the session.
4748    ///
4749    /// Wire method: `session.extensions.enable`.
4750    ///
4751    /// # Parameters
4752    ///
4753    /// * `params` - Source-qualified extension identifier to enable for the session.
4754    ///
4755    /// <div class="warning">
4756    ///
4757    /// **Experimental.** This API is part of an experimental wire-protocol surface
4758    /// and may change or be removed in future SDK or CLI releases. Pin both the
4759    /// SDK and CLI versions if your code depends on it.
4760    ///
4761    /// </div>
4762    pub async fn enable(&self, params: ExtensionsEnableRequest) -> Result<(), Error> {
4763        let mut wire_params = serde_json::to_value(params)?;
4764        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4765        let _value = self
4766            .session
4767            .client()
4768            .call(rpc_methods::SESSION_EXTENSIONS_ENABLE, Some(wire_params))
4769            .await?;
4770        Ok(())
4771    }
4772
4773    /// Disables an extension for the session.
4774    ///
4775    /// Wire method: `session.extensions.disable`.
4776    ///
4777    /// # Parameters
4778    ///
4779    /// * `params` - Source-qualified extension identifier to disable for the session.
4780    ///
4781    /// <div class="warning">
4782    ///
4783    /// **Experimental.** This API is part of an experimental wire-protocol surface
4784    /// and may change or be removed in future SDK or CLI releases. Pin both the
4785    /// SDK and CLI versions if your code depends on it.
4786    ///
4787    /// </div>
4788    pub async fn disable(&self, params: ExtensionsDisableRequest) -> Result<(), Error> {
4789        let mut wire_params = serde_json::to_value(params)?;
4790        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4791        let _value = self
4792            .session
4793            .client()
4794            .call(rpc_methods::SESSION_EXTENSIONS_DISABLE, Some(wire_params))
4795            .await?;
4796        Ok(())
4797    }
4798
4799    /// Reloads extension definitions and processes for the session.
4800    ///
4801    /// Wire method: `session.extensions.reload`.
4802    ///
4803    /// <div class="warning">
4804    ///
4805    /// **Experimental.** This API is part of an experimental wire-protocol surface
4806    /// and may change or be removed in future SDK or CLI releases. Pin both the
4807    /// SDK and CLI versions if your code depends on it.
4808    ///
4809    /// </div>
4810    pub async fn reload(&self) -> Result<(), Error> {
4811        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
4812        let _value = self
4813            .session
4814            .client()
4815            .call(rpc_methods::SESSION_EXTENSIONS_RELOAD, Some(wire_params))
4816            .await?;
4817        Ok(())
4818    }
4819
4820    /// 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.
4821    ///
4822    /// Wire method: `session.extensions.sendAttachmentsToMessage`.
4823    ///
4824    /// # Parameters
4825    ///
4826    /// * `params` - Parameters for session.extensions.sendAttachmentsToMessage.
4827    ///
4828    /// <div class="warning">
4829    ///
4830    /// **Experimental.** This API is part of an experimental wire-protocol surface
4831    /// and may change or be removed in future SDK or CLI releases. Pin both the
4832    /// SDK and CLI versions if your code depends on it.
4833    ///
4834    /// </div>
4835    pub async fn send_attachments_to_message(
4836        &self,
4837        params: SendAttachmentsToMessageParams,
4838    ) -> Result<(), Error> {
4839        let mut wire_params = serde_json::to_value(params)?;
4840        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4841        let _value = self
4842            .session
4843            .client()
4844            .call(
4845                rpc_methods::SESSION_EXTENSIONS_SENDATTACHMENTSTOMESSAGE,
4846                Some(wire_params),
4847            )
4848            .await?;
4849        Ok(())
4850    }
4851}
4852
4853/// `session.factory.*` RPCs.
4854#[derive(Clone, Copy)]
4855pub struct SessionRpcFactory<'a> {
4856    pub(crate) session: &'a Session,
4857}
4858
4859impl<'a> SessionRpcFactory<'a> {
4860    /// `session.factory.journal.*` sub-namespace.
4861    pub fn journal(&self) -> SessionRpcFactoryJournal<'a> {
4862        SessionRpcFactoryJournal {
4863            session: self.session,
4864        }
4865    }
4866
4867    /// Runs a registered factory by name at the top level.
4868    ///
4869    /// Wire method: `session.factory.run`.
4870    ///
4871    /// # Parameters
4872    ///
4873    /// * `params` - Parameters for invoking a registered factory.
4874    ///
4875    /// # Returns
4876    ///
4877    /// Complete current or terminal factory run envelope.
4878    ///
4879    /// <div class="warning">
4880    ///
4881    /// **Experimental.** This API is part of an experimental wire-protocol surface
4882    /// and may change or be removed in future SDK or CLI releases. Pin both the
4883    /// SDK and CLI versions if your code depends on it.
4884    ///
4885    /// </div>
4886    pub async fn run(&self, params: FactoryRunRequest) -> Result<FactoryRunResult, Error> {
4887        let mut wire_params = serde_json::to_value(params)?;
4888        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4889        let _value = self
4890            .session
4891            .client()
4892            .call(rpc_methods::SESSION_FACTORY_RUN, Some(wire_params))
4893            .await?;
4894        Ok(serde_json::from_value(_value)?)
4895    }
4896
4897    /// Resumes a factory run using its persisted name, arguments, journal, and accounting.
4898    ///
4899    /// Wire method: `session.factory.resume`.
4900    ///
4901    /// # Parameters
4902    ///
4903    /// * `params` - Parameters for resuming a factory run from its persisted identity.
4904    ///
4905    /// # Returns
4906    ///
4907    /// Resolved persisted factory identity and resumed run envelope.
4908    ///
4909    /// <div class="warning">
4910    ///
4911    /// **Experimental.** This API is part of an experimental wire-protocol surface
4912    /// and may change or be removed in future SDK or CLI releases. Pin both the
4913    /// SDK and CLI versions if your code depends on it.
4914    ///
4915    /// </div>
4916    pub async fn resume(&self, params: FactoryResumeRequest) -> Result<FactoryResumeResult, Error> {
4917        let mut wire_params = serde_json::to_value(params)?;
4918        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4919        let _value = self
4920            .session
4921            .client()
4922            .call(rpc_methods::SESSION_FACTORY_RESUME, Some(wire_params))
4923            .await?;
4924        Ok(serde_json::from_value(_value)?)
4925    }
4926
4927    /// Internal tool-originated factory invocation.
4928    ///
4929    /// Wire method: `session.factory.runFromTool`.
4930    ///
4931    /// # Parameters
4932    ///
4933    /// * `params` - Internal parameters for invoking a registered factory from a tool.
4934    ///
4935    /// # Returns
4936    ///
4937    /// Complete current or terminal factory run envelope.
4938    ///
4939    /// <div class="warning">
4940    ///
4941    /// **Experimental.** This API is part of an experimental wire-protocol surface
4942    /// and may change or be removed in future SDK or CLI releases. Pin both the
4943    /// SDK and CLI versions if your code depends on it.
4944    ///
4945    /// </div>
4946    pub(crate) async fn run_from_tool(
4947        &self,
4948        params: FactoryToolRunRequest,
4949    ) -> Result<FactoryRunResult, Error> {
4950        let mut wire_params = serde_json::to_value(params)?;
4951        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4952        let _value = self
4953            .session
4954            .client()
4955            .call(rpc_methods::SESSION_FACTORY_RUNFROMTOOL, Some(wire_params))
4956            .await?;
4957        Ok(serde_json::from_value(_value)?)
4958    }
4959
4960    /// Internal tool-originated factory resume.
4961    ///
4962    /// Wire method: `session.factory.resumeFromTool`.
4963    ///
4964    /// # Parameters
4965    ///
4966    /// * `params` - Internal parameters for resuming a factory run from a tool.
4967    ///
4968    /// # Returns
4969    ///
4970    /// Resolved persisted factory identity and resumed run envelope.
4971    ///
4972    /// <div class="warning">
4973    ///
4974    /// **Experimental.** This API is part of an experimental wire-protocol surface
4975    /// and may change or be removed in future SDK or CLI releases. Pin both the
4976    /// SDK and CLI versions if your code depends on it.
4977    ///
4978    /// </div>
4979    pub(crate) async fn resume_from_tool(
4980        &self,
4981        params: FactoryToolResumeRequest,
4982    ) -> Result<FactoryResumeResult, Error> {
4983        let mut wire_params = serde_json::to_value(params)?;
4984        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4985        let _value = self
4986            .session
4987            .client()
4988            .call(
4989                rpc_methods::SESSION_FACTORY_RESUMEFROMTOOL,
4990                Some(wire_params),
4991            )
4992            .await?;
4993        Ok(serde_json::from_value(_value)?)
4994    }
4995
4996    /// Gets the current or settled envelope for a factory run.
4997    ///
4998    /// Wire method: `session.factory.getRun`.
4999    ///
5000    /// # Parameters
5001    ///
5002    /// * `params` - Parameters for retrieving a factory run.
5003    ///
5004    /// # Returns
5005    ///
5006    /// Complete current or terminal factory run envelope.
5007    ///
5008    /// <div class="warning">
5009    ///
5010    /// **Experimental.** This API is part of an experimental wire-protocol surface
5011    /// and may change or be removed in future SDK or CLI releases. Pin both the
5012    /// SDK and CLI versions if your code depends on it.
5013    ///
5014    /// </div>
5015    pub async fn get_run(&self, params: FactoryGetRunRequest) -> Result<FactoryRunResult, Error> {
5016        let mut wire_params = serde_json::to_value(params)?;
5017        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5018        let _value = self
5019            .session
5020            .client()
5021            .call(rpc_methods::SESSION_FACTORY_GETRUN, Some(wire_params))
5022            .await?;
5023        Ok(serde_json::from_value(_value)?)
5024    }
5025
5026    /// Lists durable factory runs for this session in creation order.
5027    ///
5028    /// Wire method: `session.factory.listRuns`.
5029    ///
5030    /// # Parameters
5031    ///
5032    /// * `params` - Parameters for paging factory runs.
5033    ///
5034    /// # Returns
5035    ///
5036    /// A page of factory runs in durable creation order.
5037    ///
5038    /// <div class="warning">
5039    ///
5040    /// **Experimental.** This API is part of an experimental wire-protocol surface
5041    /// and may change or be removed in future SDK or CLI releases. Pin both the
5042    /// SDK and CLI versions if your code depends on it.
5043    ///
5044    /// </div>
5045    pub async fn list_runs(
5046        &self,
5047        params: FactoryListRunsRequest,
5048    ) -> Result<FactoryListRunsResult, Error> {
5049        let mut wire_params = serde_json::to_value(params)?;
5050        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5051        let _value = self
5052            .session
5053            .client()
5054            .call(rpc_methods::SESSION_FACTORY_LISTRUNS, Some(wire_params))
5055            .await?;
5056        Ok(serde_json::from_value(_value)?)
5057    }
5058
5059    /// Gets durable and live observability detail for one factory run.
5060    ///
5061    /// Wire method: `session.factory.getRunDetail`.
5062    ///
5063    /// # Parameters
5064    ///
5065    /// * `params` - Parameters for retrieving a factory run.
5066    ///
5067    /// # Returns
5068    ///
5069    /// Full factory run observability detail.
5070    ///
5071    /// <div class="warning">
5072    ///
5073    /// **Experimental.** This API is part of an experimental wire-protocol surface
5074    /// and may change or be removed in future SDK or CLI releases. Pin both the
5075    /// SDK and CLI versions if your code depends on it.
5076    ///
5077    /// </div>
5078    pub async fn get_run_detail(
5079        &self,
5080        params: FactoryGetRunRequest,
5081    ) -> Result<FactoryRunDetail, Error> {
5082        let mut wire_params = serde_json::to_value(params)?;
5083        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5084        let _value = self
5085            .session
5086            .client()
5087            .call(rpc_methods::SESSION_FACTORY_GETRUNDETAIL, Some(wire_params))
5088            .await?;
5089        Ok(serde_json::from_value(_value)?)
5090    }
5091
5092    /// Pages durable progress for one factory run.
5093    ///
5094    /// Wire method: `session.factory.getRunProgress`.
5095    ///
5096    /// # Parameters
5097    ///
5098    /// * `params` - Parameters for paging factory progress.
5099    ///
5100    /// # Returns
5101    ///
5102    /// A bidirectional page of factory progress.
5103    ///
5104    /// <div class="warning">
5105    ///
5106    /// **Experimental.** This API is part of an experimental wire-protocol surface
5107    /// and may change or be removed in future SDK or CLI releases. Pin both the
5108    /// SDK and CLI versions if your code depends on it.
5109    ///
5110    /// </div>
5111    pub async fn get_run_progress(
5112        &self,
5113        params: FactoryGetRunProgressRequest,
5114    ) -> Result<FactoryProgressPage, Error> {
5115        let mut wire_params = serde_json::to_value(params)?;
5116        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5117        let _value = self
5118            .session
5119            .client()
5120            .call(
5121                rpc_methods::SESSION_FACTORY_GETRUNPROGRESS,
5122                Some(wire_params),
5123            )
5124            .await?;
5125        Ok(serde_json::from_value(_value)?)
5126    }
5127
5128    /// Requests cancellation of a factory run and returns its run envelope.
5129    ///
5130    /// Wire method: `session.factory.cancel`.
5131    ///
5132    /// # Parameters
5133    ///
5134    /// * `params` - Parameters for cancelling a factory run.
5135    ///
5136    /// # Returns
5137    ///
5138    /// Complete current or terminal factory run envelope.
5139    ///
5140    /// <div class="warning">
5141    ///
5142    /// **Experimental.** This API is part of an experimental wire-protocol surface
5143    /// and may change or be removed in future SDK or CLI releases. Pin both the
5144    /// SDK and CLI versions if your code depends on it.
5145    ///
5146    /// </div>
5147    pub async fn cancel(&self, params: FactoryCancelRequest) -> Result<FactoryRunResult, Error> {
5148        let mut wire_params = serde_json::to_value(params)?;
5149        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5150        let _value = self
5151            .session
5152            .client()
5153            .call(rpc_methods::SESSION_FACTORY_CANCEL, Some(wire_params))
5154            .await?;
5155        Ok(serde_json::from_value(_value)?)
5156    }
5157
5158    /// Pauses a running factory and returns its settled run envelope.
5159    ///
5160    /// Wire method: `session.factory.pause`.
5161    ///
5162    /// # Parameters
5163    ///
5164    /// * `params` - Parameters for pausing a running factory.
5165    ///
5166    /// # Returns
5167    ///
5168    /// Complete current or terminal factory run envelope.
5169    ///
5170    /// <div class="warning">
5171    ///
5172    /// **Experimental.** This API is part of an experimental wire-protocol surface
5173    /// and may change or be removed in future SDK or CLI releases. Pin both the
5174    /// SDK and CLI versions if your code depends on it.
5175    ///
5176    /// </div>
5177    pub async fn pause(&self, params: FactoryPauseRequest) -> Result<FactoryRunResult, Error> {
5178        let mut wire_params = serde_json::to_value(params)?;
5179        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5180        let _value = self
5181            .session
5182            .client()
5183            .call(rpc_methods::SESSION_FACTORY_PAUSE, Some(wire_params))
5184            .await?;
5185        Ok(serde_json::from_value(_value)?)
5186    }
5187
5188    /// Atomically pauses an owned factory attempt at a durable checkpoint.
5189    ///
5190    /// Wire method: `session.factory.pauseAtCheckpoint`.
5191    ///
5192    /// # Parameters
5193    ///
5194    /// * `params` - Parameters for an owned durable pause checkpoint.
5195    ///
5196    /// <div class="warning">
5197    ///
5198    /// **Experimental.** This API is part of an experimental wire-protocol surface
5199    /// and may change or be removed in future SDK or CLI releases. Pin both the
5200    /// SDK and CLI versions if your code depends on it.
5201    ///
5202    /// </div>
5203    pub(crate) async fn pause_at_checkpoint(
5204        &self,
5205        params: FactoryPauseCheckpointRequest,
5206    ) -> Result<FactoryPauseCheckpointResult, Error> {
5207        let mut wire_params = serde_json::to_value(params)?;
5208        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5209        let _value = self
5210            .session
5211            .client()
5212            .call(
5213                rpc_methods::SESSION_FACTORY_PAUSEATCHECKPOINT,
5214                Some(wire_params),
5215            )
5216            .await?;
5217        Ok(serde_json::from_value(_value)?)
5218    }
5219
5220    /// Records a batch of ordered factory progress lines.
5221    ///
5222    /// Wire method: `session.factory.log`.
5223    ///
5224    /// # Parameters
5225    ///
5226    /// * `params` - Parameters for recording factory progress.
5227    ///
5228    /// # Returns
5229    ///
5230    /// Acknowledgement that a factory request was accepted.
5231    ///
5232    /// <div class="warning">
5233    ///
5234    /// **Experimental.** This API is part of an experimental wire-protocol surface
5235    /// and may change or be removed in future SDK or CLI releases. Pin both the
5236    /// SDK and CLI versions if your code depends on it.
5237    ///
5238    /// </div>
5239    pub async fn log(&self, params: FactoryLogRequest) -> Result<FactoryAckResult, Error> {
5240        let mut wire_params = serde_json::to_value(params)?;
5241        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5242        let _value = self
5243            .session
5244            .client()
5245            .call(rpc_methods::SESSION_FACTORY_LOG, Some(wire_params))
5246            .await?;
5247        Ok(serde_json::from_value(_value)?)
5248    }
5249
5250    /// Runs one factory-scoped subagent and returns its result.
5251    ///
5252    /// Wire method: `session.factory.agent`.
5253    ///
5254    /// # Parameters
5255    ///
5256    /// * `params` - Parameters for one factory-scoped subagent call.
5257    ///
5258    /// # Returns
5259    ///
5260    /// Result of one factory-scoped subagent call.
5261    ///
5262    /// <div class="warning">
5263    ///
5264    /// **Experimental.** This API is part of an experimental wire-protocol surface
5265    /// and may change or be removed in future SDK or CLI releases. Pin both the
5266    /// SDK and CLI versions if your code depends on it.
5267    ///
5268    /// </div>
5269    pub async fn agent(&self, params: FactoryAgentRequest) -> Result<FactoryAgentResult, Error> {
5270        let mut wire_params = serde_json::to_value(params)?;
5271        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5272        let _value = self
5273            .session
5274            .client()
5275            .call(rpc_methods::SESSION_FACTORY_AGENT, Some(wire_params))
5276            .await?;
5277        Ok(serde_json::from_value(_value)?)
5278    }
5279}
5280
5281/// `session.factory.journal.*` RPCs.
5282#[derive(Clone, Copy)]
5283pub struct SessionRpcFactoryJournal<'a> {
5284    pub(crate) session: &'a Session,
5285}
5286
5287impl<'a> SessionRpcFactoryJournal<'a> {
5288    /// Reads a memoized factory journal entry.
5289    ///
5290    /// Wire method: `session.factory.journal.get`.
5291    ///
5292    /// # Parameters
5293    ///
5294    /// * `params` - Parameters for reading a factory journal entry.
5295    ///
5296    /// # Returns
5297    ///
5298    /// Result of reading a factory journal entry.
5299    ///
5300    /// <div class="warning">
5301    ///
5302    /// **Experimental.** This API is part of an experimental wire-protocol surface
5303    /// and may change or be removed in future SDK or CLI releases. Pin both the
5304    /// SDK and CLI versions if your code depends on it.
5305    ///
5306    /// </div>
5307    pub async fn get(
5308        &self,
5309        params: FactoryJournalGetRequest,
5310    ) -> Result<FactoryJournalGetResult, Error> {
5311        let mut wire_params = serde_json::to_value(params)?;
5312        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5313        let _value = self
5314            .session
5315            .client()
5316            .call(rpc_methods::SESSION_FACTORY_JOURNAL_GET, Some(wire_params))
5317            .await?;
5318        Ok(serde_json::from_value(_value)?)
5319    }
5320
5321    /// Stores a memoized factory journal entry.
5322    ///
5323    /// Wire method: `session.factory.journal.put`.
5324    ///
5325    /// # Parameters
5326    ///
5327    /// * `params` - Parameters for storing a factory journal entry.
5328    ///
5329    /// # Returns
5330    ///
5331    /// Acknowledgement that a factory request was accepted.
5332    ///
5333    /// <div class="warning">
5334    ///
5335    /// **Experimental.** This API is part of an experimental wire-protocol surface
5336    /// and may change or be removed in future SDK or CLI releases. Pin both the
5337    /// SDK and CLI versions if your code depends on it.
5338    ///
5339    /// </div>
5340    pub async fn put(&self, params: FactoryJournalPutRequest) -> Result<FactoryAckResult, Error> {
5341        let mut wire_params = serde_json::to_value(params)?;
5342        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5343        let _value = self
5344            .session
5345            .client()
5346            .call(rpc_methods::SESSION_FACTORY_JOURNAL_PUT, Some(wire_params))
5347            .await?;
5348        Ok(serde_json::from_value(_value)?)
5349    }
5350}
5351
5352/// `session.fleet.*` RPCs.
5353#[derive(Clone, Copy)]
5354pub struct SessionRpcFleet<'a> {
5355    pub(crate) session: &'a Session,
5356}
5357
5358impl<'a> SessionRpcFleet<'a> {
5359    /// Starts fleet mode by submitting the fleet orchestration prompt to the session.
5360    ///
5361    /// Wire method: `session.fleet.start`.
5362    ///
5363    /// # Parameters
5364    ///
5365    /// * `params` - Parameters for starting fleet orchestration: an optional user prompt combined with the fleet instructions, plus the send options forwarded to the resulting turn.
5366    ///
5367    /// # Returns
5368    ///
5369    /// Indicates whether fleet mode was successfully activated.
5370    ///
5371    /// <div class="warning">
5372    ///
5373    /// **Experimental.** This API is part of an experimental wire-protocol surface
5374    /// and may change or be removed in future SDK or CLI releases. Pin both the
5375    /// SDK and CLI versions if your code depends on it.
5376    ///
5377    /// </div>
5378    pub async fn start(&self, params: FleetStartRequest) -> Result<FleetStartResult, Error> {
5379        let mut wire_params = serde_json::to_value(params)?;
5380        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5381        let _value = self
5382            .session
5383            .client()
5384            .call(rpc_methods::SESSION_FLEET_START, Some(wire_params))
5385            .await?;
5386        Ok(serde_json::from_value(_value)?)
5387    }
5388}
5389
5390/// `session.gitHubAuth.*` RPCs.
5391#[derive(Clone, Copy)]
5392pub struct SessionRpcGitHubAuth<'a> {
5393    pub(crate) session: &'a Session,
5394}
5395
5396impl<'a> SessionRpcGitHubAuth<'a> {
5397    /// Gets authentication status and account metadata for the session.
5398    ///
5399    /// Wire method: `session.gitHubAuth.getStatus`.
5400    ///
5401    /// # Returns
5402    ///
5403    /// Authentication status and account metadata for the session.
5404    ///
5405    /// <div class="warning">
5406    ///
5407    /// **Experimental.** This API is part of an experimental wire-protocol surface
5408    /// and may change or be removed in future SDK or CLI releases. Pin both the
5409    /// SDK and CLI versions if your code depends on it.
5410    ///
5411    /// </div>
5412    pub async fn get_status(&self) -> Result<SessionAuthStatus, Error> {
5413        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5414        let _value = self
5415            .session
5416            .client()
5417            .call(rpc_methods::SESSION_GITHUBAUTH_GETSTATUS, Some(wire_params))
5418            .await?;
5419        Ok(serde_json::from_value(_value)?)
5420    }
5421
5422    /// Updates the session's auth credentials used for outbound model and API requests.
5423    ///
5424    /// Wire method: `session.gitHubAuth.setCredentials`.
5425    ///
5426    /// # Parameters
5427    ///
5428    /// * `params` - New auth credentials to install on the session. Omit to leave credentials unchanged.
5429    ///
5430    /// # Returns
5431    ///
5432    /// Indicates whether the credential update succeeded.
5433    ///
5434    /// <div class="warning">
5435    ///
5436    /// **Experimental.** This API is part of an experimental wire-protocol surface
5437    /// and may change or be removed in future SDK or CLI releases. Pin both the
5438    /// SDK and CLI versions if your code depends on it.
5439    ///
5440    /// </div>
5441    pub async fn set_credentials(
5442        &self,
5443        params: SessionSetCredentialsParams,
5444    ) -> Result<SessionSetCredentialsResult, Error> {
5445        let mut wire_params = serde_json::to_value(params)?;
5446        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5447        let _value = self
5448            .session
5449            .client()
5450            .call(
5451                rpc_methods::SESSION_GITHUBAUTH_SETCREDENTIALS,
5452                Some(wire_params),
5453            )
5454            .await?;
5455        Ok(serde_json::from_value(_value)?)
5456    }
5457
5458    /// Gets the current authentication information for internal session hosts.
5459    ///
5460    /// Wire method: `session.gitHubAuth.getCurrentAuthInfo`.
5461    ///
5462    /// # Returns
5463    ///
5464    /// Current authentication information, or null when no authentication is active.
5465    ///
5466    /// <div class="warning">
5467    ///
5468    /// **Experimental.** This API is part of an experimental wire-protocol surface
5469    /// and may change or be removed in future SDK or CLI releases. Pin both the
5470    /// SDK and CLI versions if your code depends on it.
5471    ///
5472    /// </div>
5473    pub(crate) async fn get_current_auth_info(&self) -> Result<SessionAuthInfoResult, Error> {
5474        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5475        let _value = self
5476            .session
5477            .client()
5478            .call(
5479                rpc_methods::SESSION_GITHUBAUTH_GETCURRENTAUTHINFO,
5480                Some(wire_params),
5481            )
5482            .await?;
5483        Ok(serde_json::from_value(_value)?)
5484    }
5485
5486    /// Gets all authentication accounts available to the internal session host.
5487    ///
5488    /// Wire method: `session.gitHubAuth.getAllAuthAvailable`.
5489    ///
5490    /// # Returns
5491    ///
5492    /// Authentication accounts available to the internal session host.
5493    ///
5494    /// <div class="warning">
5495    ///
5496    /// **Experimental.** This API is part of an experimental wire-protocol surface
5497    /// and may change or be removed in future SDK or CLI releases. Pin both the
5498    /// SDK and CLI versions if your code depends on it.
5499    ///
5500    /// </div>
5501    pub(crate) async fn get_all_auth_available(
5502        &self,
5503    ) -> Result<SessionGitHubAuthGetAllAuthAvailableResult, Error> {
5504        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5505        let _value = self
5506            .session
5507            .client()
5508            .call(
5509                rpc_methods::SESSION_GITHUBAUTH_GETALLAUTHAVAILABLE,
5510                Some(wire_params),
5511            )
5512            .await?;
5513        Ok(serde_json::from_value(_value)?)
5514    }
5515
5516    /// Refreshes Copilot account metadata for the current authentication.
5517    ///
5518    /// Wire method: `session.gitHubAuth.refreshCopilotUser`.
5519    ///
5520    /// # Returns
5521    ///
5522    /// Current authentication information, or null when no authentication is active.
5523    ///
5524    /// <div class="warning">
5525    ///
5526    /// **Experimental.** This API is part of an experimental wire-protocol surface
5527    /// and may change or be removed in future SDK or CLI releases. Pin both the
5528    /// SDK and CLI versions if your code depends on it.
5529    ///
5530    /// </div>
5531    pub(crate) async fn refresh_copilot_user(&self) -> Result<SessionAuthInfoResult, Error> {
5532        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5533        let _value = self
5534            .session
5535            .client()
5536            .call(
5537                rpc_methods::SESSION_GITHUBAUTH_REFRESHCOPILOTUSER,
5538                Some(wire_params),
5539            )
5540            .await?;
5541        Ok(serde_json::from_value(_value)?)
5542    }
5543
5544    /// Logs in a GitHub user through the internal session host.
5545    ///
5546    /// Wire method: `session.gitHubAuth.login`.
5547    ///
5548    /// # Parameters
5549    ///
5550    /// * `params` - Internal GitHub login parameters.
5551    ///
5552    /// # Returns
5553    ///
5554    /// Authentication credentials accepted only at native protocol ingress. Runtime outputs use credential-free `AuthIdentity` metadata.
5555    ///
5556    /// <div class="warning">
5557    ///
5558    /// **Experimental.** This API is part of an experimental wire-protocol surface
5559    /// and may change or be removed in future SDK or CLI releases. Pin both the
5560    /// SDK and CLI versions if your code depends on it.
5561    ///
5562    /// </div>
5563    pub(crate) async fn login(&self, params: SessionAuthLoginRequest) -> Result<AuthInfo, Error> {
5564        let mut wire_params = serde_json::to_value(params)?;
5565        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5566        let _value = self
5567            .session
5568            .client()
5569            .call(rpc_methods::SESSION_GITHUBAUTH_LOGIN, Some(wire_params))
5570            .await?;
5571        Ok(serde_json::from_value(_value)?)
5572    }
5573
5574    /// Switches the session to another available authentication.
5575    ///
5576    /// Wire method: `session.gitHubAuth.switchToAuth`.
5577    ///
5578    /// # Parameters
5579    ///
5580    /// * `params` - Parameters for switching the session's active authentication.
5581    ///
5582    /// <div class="warning">
5583    ///
5584    /// **Experimental.** This API is part of an experimental wire-protocol surface
5585    /// and may change or be removed in future SDK or CLI releases. Pin both the
5586    /// SDK and CLI versions if your code depends on it.
5587    ///
5588    /// </div>
5589    pub(crate) async fn switch_to_auth(
5590        &self,
5591        params: SessionAuthSwitchRequest,
5592    ) -> Result<(), Error> {
5593        let mut wire_params = serde_json::to_value(params)?;
5594        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5595        let _value = self
5596            .session
5597            .client()
5598            .call(
5599                rpc_methods::SESSION_GITHUBAUTH_SWITCHTOAUTH,
5600                Some(wire_params),
5601            )
5602            .await?;
5603        Ok(())
5604    }
5605
5606    /// Logs out the session's current GitHub authentication.
5607    ///
5608    /// Wire method: `session.gitHubAuth.logout`.
5609    ///
5610    /// # Returns
5611    ///
5612    /// Whether the current authentication was logged out.
5613    ///
5614    /// <div class="warning">
5615    ///
5616    /// **Experimental.** This API is part of an experimental wire-protocol surface
5617    /// and may change or be removed in future SDK or CLI releases. Pin both the
5618    /// SDK and CLI versions if your code depends on it.
5619    ///
5620    /// </div>
5621    pub(crate) async fn logout(&self) -> Result<SessionGitHubAuthLogoutResult, Error> {
5622        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5623        let _value = self
5624            .session
5625            .client()
5626            .call(rpc_methods::SESSION_GITHUBAUTH_LOGOUT, Some(wire_params))
5627            .await?;
5628        Ok(serde_json::from_value(_value)?)
5629    }
5630
5631    /// Logs out a specific GitHub authentication.
5632    ///
5633    /// Wire method: `session.gitHubAuth.logoutUser`.
5634    ///
5635    /// # Parameters
5636    ///
5637    /// * `params` - Parameters identifying a GitHub authentication to log out.
5638    ///
5639    /// # Returns
5640    ///
5641    /// Whether the requested authentication was logged out.
5642    ///
5643    /// <div class="warning">
5644    ///
5645    /// **Experimental.** This API is part of an experimental wire-protocol surface
5646    /// and may change or be removed in future SDK or CLI releases. Pin both the
5647    /// SDK and CLI versions if your code depends on it.
5648    ///
5649    /// </div>
5650    pub(crate) async fn logout_user(
5651        &self,
5652        params: SessionAuthLogoutUserRequest,
5653    ) -> Result<SessionGitHubAuthLogoutUserResult, Error> {
5654        let mut wire_params = serde_json::to_value(params)?;
5655        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5656        let _value = self
5657            .session
5658            .client()
5659            .call(
5660                rpc_methods::SESSION_GITHUBAUTH_LOGOUTUSER,
5661                Some(wire_params),
5662            )
5663            .await?;
5664        Ok(serde_json::from_value(_value)?)
5665    }
5666
5667    /// Gets validation errors from the most recent authentication attempt.
5668    ///
5669    /// Wire method: `session.gitHubAuth.lastAuthErrors`.
5670    ///
5671    /// # Returns
5672    ///
5673    /// Validation errors from the most recent authentication attempt.
5674    ///
5675    /// <div class="warning">
5676    ///
5677    /// **Experimental.** This API is part of an experimental wire-protocol surface
5678    /// and may change or be removed in future SDK or CLI releases. Pin both the
5679    /// SDK and CLI versions if your code depends on it.
5680    ///
5681    /// </div>
5682    pub(crate) async fn last_auth_errors(&self) -> Result<AuthValidationErrors, Error> {
5683        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5684        let _value = self
5685            .session
5686            .client()
5687            .call(
5688                rpc_methods::SESSION_GITHUBAUTH_LASTAUTHERRORS,
5689                Some(wire_params),
5690            )
5691            .await?;
5692        Ok(serde_json::from_value(_value)?)
5693    }
5694}
5695
5696/// `session.history.*` RPCs.
5697#[derive(Clone, Copy)]
5698pub struct SessionRpcHistory<'a> {
5699    pub(crate) session: &'a Session,
5700}
5701
5702impl<'a> SessionRpcHistory<'a> {
5703    /// Compacts the session history to reduce context usage.
5704    ///
5705    /// Wire method: `session.history.compact`.
5706    ///
5707    /// # Returns
5708    ///
5709    /// Compaction outcome with the number of tokens and messages removed, summary text, and the resulting context window breakdown.
5710    ///
5711    /// <div class="warning">
5712    ///
5713    /// **Experimental.** This API is part of an experimental wire-protocol surface
5714    /// and may change or be removed in future SDK or CLI releases. Pin both the
5715    /// SDK and CLI versions if your code depends on it.
5716    ///
5717    /// </div>
5718    pub async fn compact(&self) -> Result<HistoryCompactResult, Error> {
5719        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5720        let _value = self
5721            .session
5722            .client()
5723            .call(rpc_methods::SESSION_HISTORY_COMPACT, Some(wire_params))
5724            .await?;
5725        Ok(serde_json::from_value(_value)?)
5726    }
5727
5728    /// Compacts the session history to reduce context usage.
5729    ///
5730    /// Wire method: `session.history.compact`.
5731    ///
5732    /// # Parameters
5733    ///
5734    /// * `params` - Optional compaction parameters.
5735    ///
5736    /// # Returns
5737    ///
5738    /// Compaction outcome with the number of tokens and messages removed, summary text, and the resulting context window breakdown.
5739    ///
5740    /// <div class="warning">
5741    ///
5742    /// **Experimental.** This API is part of an experimental wire-protocol surface
5743    /// and may change or be removed in future SDK or CLI releases. Pin both the
5744    /// SDK and CLI versions if your code depends on it.
5745    ///
5746    /// </div>
5747    pub async fn compact_with_params(
5748        &self,
5749        params: HistoryCompactRequest,
5750    ) -> Result<HistoryCompactResult, Error> {
5751        let mut wire_params = serde_json::to_value(params)?;
5752        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5753        let _value = self
5754            .session
5755            .client()
5756            .call(rpc_methods::SESSION_HISTORY_COMPACT, Some(wire_params))
5757            .await?;
5758        Ok(serde_json::from_value(_value)?)
5759    }
5760
5761    /// Truncates persisted session history to a specific event.
5762    ///
5763    /// Wire method: `session.history.truncate`.
5764    ///
5765    /// # Parameters
5766    ///
5767    /// * `params` - Identifier of the event to truncate to; this event and all later events are removed.
5768    ///
5769    /// # Returns
5770    ///
5771    /// Number of events that were removed by the truncation.
5772    ///
5773    /// <div class="warning">
5774    ///
5775    /// **Experimental.** This API is part of an experimental wire-protocol surface
5776    /// and may change or be removed in future SDK or CLI releases. Pin both the
5777    /// SDK and CLI versions if your code depends on it.
5778    ///
5779    /// </div>
5780    pub async fn truncate(
5781        &self,
5782        params: HistoryTruncateRequest,
5783    ) -> Result<HistoryTruncateResult, Error> {
5784        let mut wire_params = serde_json::to_value(params)?;
5785        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5786        let _value = self
5787            .session
5788            .client()
5789            .call(rpc_methods::SESSION_HISTORY_TRUNCATE, Some(wire_params))
5790            .await?;
5791        Ok(serde_json::from_value(_value)?)
5792    }
5793
5794    /// Lists the user turns that the session can rewind to. Never rejects for a busy session: rewind reads need the session's file-change captures to be settled, so a session that still holds active work answers with `unavailableReason: "session-busy"` and no points, which the caller can retry.
5795    ///
5796    /// Wire method: `session.history.listRewindPoints`.
5797    ///
5798    /// # Returns
5799    ///
5800    /// Rewind points and file-change-tracking availability for the session.
5801    ///
5802    /// <div class="warning">
5803    ///
5804    /// **Experimental.** This API is part of an experimental wire-protocol surface
5805    /// and may change or be removed in future SDK or CLI releases. Pin both the
5806    /// SDK and CLI versions if your code depends on it.
5807    ///
5808    /// </div>
5809    pub async fn list_rewind_points(&self) -> Result<HistoryListRewindPointsResult, Error> {
5810        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5811        let _value = self
5812            .session
5813            .client()
5814            .call(
5815                rpc_methods::SESSION_HISTORY_LISTREWINDPOINTS,
5816                Some(wire_params),
5817            )
5818            .await?;
5819        Ok(serde_json::from_value(_value)?)
5820    }
5821
5822    /// Previews the files that a conversation-and-files rewind would restore.
5823    ///
5824    /// Wire method: `session.history.previewRewind`.
5825    ///
5826    /// # Parameters
5827    ///
5828    /// * `params` - Event boundary to preview for conversation-and-files rewind.
5829    ///
5830    /// # Returns
5831    ///
5832    /// Files and aggregate changes for a prospective rewind.
5833    ///
5834    /// <div class="warning">
5835    ///
5836    /// **Experimental.** This API is part of an experimental wire-protocol surface
5837    /// and may change or be removed in future SDK or CLI releases. Pin both the
5838    /// SDK and CLI versions if your code depends on it.
5839    ///
5840    /// </div>
5841    pub async fn preview_rewind(
5842        &self,
5843        params: HistoryPreviewRewindRequest,
5844    ) -> Result<HistoryPreviewRewindResult, Error> {
5845        let mut wire_params = serde_json::to_value(params)?;
5846        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5847        let _value = self
5848            .session
5849            .client()
5850            .call(
5851                rpc_methods::SESSION_HISTORY_PREVIEWREWIND,
5852                Some(wire_params),
5853            )
5854            .await?;
5855        Ok(serde_json::from_value(_value)?)
5856    }
5857
5858    /// Rewinds the session conversation, optionally restoring files changed by the discarded turns. Not crash-atomic: file restore and conversation truncation are separate stores, applied in that order, so a process crash between them can leave the workspace rewound while the conversation still contains the discarded turns. There is no recovery journal; re-running the same rewind is the recovery path for a crash before truncation lands, since file restore is idempotent (already-restored files are reported as skipped) and truncation is re-derived from the still-retained boundary event. After truncation lands that boundary no longer exists, so the same request is rejected; the only stage that can still be outstanding is snapshot pruning, whose failure leaves orphan snapshots the capture store tolerates. The reverse inconsistency cannot occur, because truncation is never applied before file restore succeeds.
5859    ///
5860    /// Wire method: `session.history.rewind`.
5861    ///
5862    /// # Parameters
5863    ///
5864    /// * `params` - Boundary and mode for rewinding session history.
5865    ///
5866    /// # Returns
5867    ///
5868    /// Structured outcome of a rewind request.
5869    ///
5870    /// <div class="warning">
5871    ///
5872    /// **Experimental.** This API is part of an experimental wire-protocol surface
5873    /// and may change or be removed in future SDK or CLI releases. Pin both the
5874    /// SDK and CLI versions if your code depends on it.
5875    ///
5876    /// </div>
5877    pub async fn rewind(&self, params: HistoryRewindRequest) -> Result<HistoryRewindResult, Error> {
5878        let mut wire_params = serde_json::to_value(params)?;
5879        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5880        let _value = self
5881            .session
5882            .client()
5883            .call(rpc_methods::SESSION_HISTORY_REWIND, Some(wire_params))
5884            .await?;
5885        Ok(serde_json::from_value(_value)?)
5886    }
5887
5888    /// Cancels any in-progress background compaction on a local session.
5889    ///
5890    /// Wire method: `session.history.cancelBackgroundCompaction`.
5891    ///
5892    /// # Returns
5893    ///
5894    /// Indicates whether an in-progress background compaction was cancelled.
5895    ///
5896    /// <div class="warning">
5897    ///
5898    /// **Experimental.** This API is part of an experimental wire-protocol surface
5899    /// and may change or be removed in future SDK or CLI releases. Pin both the
5900    /// SDK and CLI versions if your code depends on it.
5901    ///
5902    /// </div>
5903    pub async fn cancel_background_compaction(
5904        &self,
5905    ) -> Result<HistoryCancelBackgroundCompactionResult, Error> {
5906        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5907        let _value = self
5908            .session
5909            .client()
5910            .call(
5911                rpc_methods::SESSION_HISTORY_CANCELBACKGROUNDCOMPACTION,
5912                Some(wire_params),
5913            )
5914            .await?;
5915        Ok(serde_json::from_value(_value)?)
5916    }
5917
5918    /// Aborts any in-progress manual compaction on a local session.
5919    ///
5920    /// Wire method: `session.history.abortManualCompaction`.
5921    ///
5922    /// # Returns
5923    ///
5924    /// Indicates whether an in-progress manual compaction was aborted.
5925    ///
5926    /// <div class="warning">
5927    ///
5928    /// **Experimental.** This API is part of an experimental wire-protocol surface
5929    /// and may change or be removed in future SDK or CLI releases. Pin both the
5930    /// SDK and CLI versions if your code depends on it.
5931    ///
5932    /// </div>
5933    pub async fn abort_manual_compaction(
5934        &self,
5935    ) -> Result<HistoryAbortManualCompactionResult, Error> {
5936        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5937        let _value = self
5938            .session
5939            .client()
5940            .call(
5941                rpc_methods::SESSION_HISTORY_ABORTMANUALCOMPACTION,
5942                Some(wire_params),
5943            )
5944            .await?;
5945        Ok(serde_json::from_value(_value)?)
5946    }
5947
5948    /// Produces a markdown summary of the session's conversation context for hand-off scenarios.
5949    ///
5950    /// Wire method: `session.history.summarizeForHandoff`.
5951    ///
5952    /// # Returns
5953    ///
5954    /// Markdown summary of the conversation context (empty when not available).
5955    ///
5956    /// <div class="warning">
5957    ///
5958    /// **Experimental.** This API is part of an experimental wire-protocol surface
5959    /// and may change or be removed in future SDK or CLI releases. Pin both the
5960    /// SDK and CLI versions if your code depends on it.
5961    ///
5962    /// </div>
5963    pub async fn summarize_for_handoff(&self) -> Result<HistorySummarizeForHandoffResult, Error> {
5964        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5965        let _value = self
5966            .session
5967            .client()
5968            .call(
5969                rpc_methods::SESSION_HISTORY_SUMMARIZEFORHANDOFF,
5970                Some(wire_params),
5971            )
5972            .await?;
5973        Ok(serde_json::from_value(_value)?)
5974    }
5975
5976    /// Clears the session's conversation history, keeping only system and developer messages, and seeds the fresh context window with a first user message. Must be called from inside a tool handler: the clear has to drop the results of the tool calls its wipe orphans, and it rejects when no tool call is in flight.
5977    ///
5978    /// Wire method: `session.history.clearContext`.
5979    ///
5980    /// # Parameters
5981    ///
5982    /// * `params` - Parameters for clearing the conversation and seeding the window that replaces it.
5983    ///
5984    /// # Returns
5985    ///
5986    /// What a successful clear removed. A clear that could not be applied rejects instead of reporting a count.
5987    ///
5988    /// <div class="warning">
5989    ///
5990    /// **Experimental.** This API is part of an experimental wire-protocol surface
5991    /// and may change or be removed in future SDK or CLI releases. Pin both the
5992    /// SDK and CLI versions if your code depends on it.
5993    ///
5994    /// </div>
5995    pub async fn clear_context(
5996        &self,
5997        params: HistoryClearContextRequest,
5998    ) -> Result<HistoryClearContextResult, Error> {
5999        let mut wire_params = serde_json::to_value(params)?;
6000        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6001        let _value = self
6002            .session
6003            .client()
6004            .call(rpc_methods::SESSION_HISTORY_CLEARCONTEXT, Some(wire_params))
6005            .await?;
6006        Ok(serde_json::from_value(_value)?)
6007    }
6008}
6009
6010/// `session.instructions.*` RPCs.
6011#[derive(Clone, Copy)]
6012pub struct SessionRpcInstructions<'a> {
6013    pub(crate) session: &'a Session,
6014}
6015
6016impl<'a> SessionRpcInstructions<'a> {
6017    /// Gets instruction sources loaded for the session.
6018    ///
6019    /// Wire method: `session.instructions.getSources`.
6020    ///
6021    /// # Returns
6022    ///
6023    /// Instruction sources loaded for the session, in merge order.
6024    ///
6025    /// <div class="warning">
6026    ///
6027    /// **Experimental.** This API is part of an experimental wire-protocol surface
6028    /// and may change or be removed in future SDK or CLI releases. Pin both the
6029    /// SDK and CLI versions if your code depends on it.
6030    ///
6031    /// </div>
6032    pub async fn get_sources(&self) -> Result<InstructionsGetSourcesResult, Error> {
6033        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6034        let _value = self
6035            .session
6036            .client()
6037            .call(
6038                rpc_methods::SESSION_INSTRUCTIONS_GETSOURCES,
6039                Some(wire_params),
6040            )
6041            .await?;
6042        Ok(serde_json::from_value(_value)?)
6043    }
6044}
6045
6046/// `session.limitPrediction.*` RPCs.
6047#[derive(Clone, Copy)]
6048pub struct SessionRpcLimitPrediction<'a> {
6049    pub(crate) session: &'a Session,
6050}
6051
6052impl<'a> SessionRpcLimitPrediction<'a> {
6053    /// Predicts an AI-credit session limit for the session's resolved model. Returns an unavailable result instead of falling back when the current model is unresolved auto.
6054    ///
6055    /// Wire method: `session.limitPrediction.predict`.
6056    ///
6057    /// # Returns
6058    ///
6059    /// Prediction result. Available results include prediction details; unavailable results include an explicit reason.
6060    ///
6061    /// <div class="warning">
6062    ///
6063    /// **Experimental.** This API is part of an experimental wire-protocol surface
6064    /// and may change or be removed in future SDK or CLI releases. Pin both the
6065    /// SDK and CLI versions if your code depends on it.
6066    ///
6067    /// </div>
6068    pub async fn predict(&self) -> Result<SessionLimitPredictionResult, Error> {
6069        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6070        let _value = self
6071            .session
6072            .client()
6073            .call(
6074                rpc_methods::SESSION_LIMITPREDICTION_PREDICT,
6075                Some(wire_params),
6076            )
6077            .await?;
6078        Ok(serde_json::from_value(_value)?)
6079    }
6080
6081    /// Predicts an AI-credit session limit for the session's resolved model. Returns an unavailable result instead of falling back when the current model is unresolved auto.
6082    ///
6083    /// Wire method: `session.limitPrediction.predict`.
6084    ///
6085    /// # Parameters
6086    ///
6087    /// * `params` - Parameters for predicting an AI-credit session limit. Omitting `modelId` uses the session's currently selected model.
6088    ///
6089    /// # Returns
6090    ///
6091    /// Prediction result. Available results include prediction details; unavailable results include an explicit reason.
6092    ///
6093    /// <div class="warning">
6094    ///
6095    /// **Experimental.** This API is part of an experimental wire-protocol surface
6096    /// and may change or be removed in future SDK or CLI releases. Pin both the
6097    /// SDK and CLI versions if your code depends on it.
6098    ///
6099    /// </div>
6100    pub async fn predict_with_params(
6101        &self,
6102        params: SessionLimitPredictionRequest,
6103    ) -> Result<SessionLimitPredictionResult, Error> {
6104        let mut wire_params = serde_json::to_value(params)?;
6105        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6106        let _value = self
6107            .session
6108            .client()
6109            .call(
6110                rpc_methods::SESSION_LIMITPREDICTION_PREDICT,
6111                Some(wire_params),
6112            )
6113            .await?;
6114        Ok(serde_json::from_value(_value)?)
6115    }
6116}
6117
6118/// `session.lsp.*` RPCs.
6119#[derive(Clone, Copy)]
6120pub struct SessionRpcLsp<'a> {
6121    pub(crate) session: &'a Session,
6122}
6123
6124impl<'a> SessionRpcLsp<'a> {
6125    /// Loads the merged LSP configuration set for the session's working directory.
6126    ///
6127    /// Wire method: `session.lsp.initialize`.
6128    ///
6129    /// # Parameters
6130    ///
6131    /// * `params` - Parameters for (re)loading the merged LSP configuration set.
6132    ///
6133    /// <div class="warning">
6134    ///
6135    /// **Experimental.** This API is part of an experimental wire-protocol surface
6136    /// and may change or be removed in future SDK or CLI releases. Pin both the
6137    /// SDK and CLI versions if your code depends on it.
6138    ///
6139    /// </div>
6140    pub async fn initialize(&self, params: LspInitializeRequest) -> Result<(), Error> {
6141        let mut wire_params = serde_json::to_value(params)?;
6142        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6143        let _value = self
6144            .session
6145            .client()
6146            .call(rpc_methods::SESSION_LSP_INITIALIZE, Some(wire_params))
6147            .await?;
6148        Ok(())
6149    }
6150}
6151
6152/// `session.managedSettings.*` RPCs.
6153#[derive(Clone, Copy)]
6154pub struct SessionRpcManagedSettings<'a> {
6155    pub(crate) session: &'a Session,
6156}
6157
6158impl<'a> SessionRpcManagedSettings<'a> {
6159    /// Waits for the live session's in-flight managed-settings application, then returns the retained effective snapshot used by runtime enforcement and by `session.managed_settings_resolved`. It does not perform another account, device, or server resolution, and rejects when resolution has not produced a snapshot.
6160    ///
6161    /// Wire method: `session.managedSettings.get`.
6162    ///
6163    /// # Returns
6164    ///
6165    /// Enterprise managed-settings resolution: the effective managed settings the session applied and which channels contributed, so SDK clients can show users what is enterprise-managed. Fires whenever managed policy is (re)applied — at session start, on resume, and on account switch. This is an ephemeral live snapshot (delivered to subscribers but not persisted to the session event log), because at session start it resolves before `session.start` is emitted. Device values take precedence over server values, then the policy helper, per ordinary key, while permissions compose restrictively across device, server, policy-helper, and SDK-client layers. The account-scoped `getManagedSettings()` API does not include session-local client injection. Marked experimental while the managed-settings surface stabilizes.
6166    ///
6167    /// <div class="warning">
6168    ///
6169    /// **Experimental.** This API is part of an experimental wire-protocol surface
6170    /// and may change or be removed in future SDK or CLI releases. Pin both the
6171    /// SDK and CLI versions if your code depends on it.
6172    ///
6173    /// </div>
6174    pub async fn get(&self) -> Result<ManagedSettingsResolvedData, Error> {
6175        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6176        let _value = self
6177            .session
6178            .client()
6179            .call(rpc_methods::SESSION_MANAGEDSETTINGS_GET, Some(wire_params))
6180            .await?;
6181        Ok(serde_json::from_value(_value)?)
6182    }
6183}
6184
6185/// `session.mcp.*` RPCs.
6186#[derive(Clone, Copy)]
6187pub struct SessionRpcMcp<'a> {
6188    pub(crate) session: &'a Session,
6189}
6190
6191impl<'a> SessionRpcMcp<'a> {
6192    /// `session.mcp.apps.*` sub-namespace.
6193    pub fn apps(&self) -> SessionRpcMcpApps<'a> {
6194        SessionRpcMcpApps {
6195            session: self.session,
6196        }
6197    }
6198
6199    /// `session.mcp.headers.*` sub-namespace.
6200    pub fn headers(&self) -> SessionRpcMcpHeaders<'a> {
6201        SessionRpcMcpHeaders {
6202            session: self.session,
6203        }
6204    }
6205
6206    /// `session.mcp.oauth.*` sub-namespace.
6207    pub fn oauth(&self) -> SessionRpcMcpOauth<'a> {
6208        SessionRpcMcpOauth {
6209            session: self.session,
6210        }
6211    }
6212
6213    /// `session.mcp.resources.*` sub-namespace.
6214    pub fn resources(&self) -> SessionRpcMcpResources<'a> {
6215        SessionRpcMcpResources {
6216            session: self.session,
6217        }
6218    }
6219
6220    /// 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.
6221    ///
6222    /// Wire method: `session.mcp.list`.
6223    ///
6224    /// # Returns
6225    ///
6226    /// MCP servers configured for the session, with their connection status and host-level state.
6227    ///
6228    /// <div class="warning">
6229    ///
6230    /// **Experimental.** This API is part of an experimental wire-protocol surface
6231    /// and may change or be removed in future SDK or CLI releases. Pin both the
6232    /// SDK and CLI versions if your code depends on it.
6233    ///
6234    /// </div>
6235    pub async fn list(&self) -> Result<McpServerList, Error> {
6236        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6237        let _value = self
6238            .session
6239            .client()
6240            .call(rpc_methods::SESSION_MCP_LIST, Some(wire_params))
6241            .await?;
6242        Ok(serde_json::from_value(_value)?)
6243    }
6244
6245    /// Lists the tools exposed by a connected MCP server on this session's host. This performs a live `tools/list` request. Tool UI metadata is returned independently of whether MCP Apps rendering is enabled for the session.
6246    ///
6247    /// Wire method: `session.mcp.listTools`.
6248    ///
6249    /// # Parameters
6250    ///
6251    /// * `params` - Server name whose tool list should be returned.
6252    ///
6253    /// # Returns
6254    ///
6255    /// Tools exposed by the connected MCP server. Throws when the server is not connected.
6256    ///
6257    /// <div class="warning">
6258    ///
6259    /// **Experimental.** This API is part of an experimental wire-protocol surface
6260    /// and may change or be removed in future SDK or CLI releases. Pin both the
6261    /// SDK and CLI versions if your code depends on it.
6262    ///
6263    /// </div>
6264    pub async fn list_tools(
6265        &self,
6266        params: McpListToolsRequest,
6267    ) -> Result<McpListToolsResult, Error> {
6268        let mut wire_params = serde_json::to_value(params)?;
6269        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6270        let _value = self
6271            .session
6272            .client()
6273            .call(rpc_methods::SESSION_MCP_LISTTOOLS, Some(wire_params))
6274            .await?;
6275        Ok(serde_json::from_value(_value)?)
6276    }
6277
6278    /// Enables an MCP server for the session.
6279    ///
6280    /// Wire method: `session.mcp.enable`.
6281    ///
6282    /// # Parameters
6283    ///
6284    /// * `params` - Name of the MCP server to enable for the session.
6285    ///
6286    /// <div class="warning">
6287    ///
6288    /// **Experimental.** This API is part of an experimental wire-protocol surface
6289    /// and may change or be removed in future SDK or CLI releases. Pin both the
6290    /// SDK and CLI versions if your code depends on it.
6291    ///
6292    /// </div>
6293    pub async fn enable(&self, params: McpEnableRequest) -> Result<(), Error> {
6294        let mut wire_params = serde_json::to_value(params)?;
6295        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6296        let _value = self
6297            .session
6298            .client()
6299            .call(rpc_methods::SESSION_MCP_ENABLE, Some(wire_params))
6300            .await?;
6301        Ok(())
6302    }
6303
6304    /// Disables an MCP server for the session.
6305    ///
6306    /// Wire method: `session.mcp.disable`.
6307    ///
6308    /// # Parameters
6309    ///
6310    /// * `params` - Name of the MCP server to disable for the session.
6311    ///
6312    /// <div class="warning">
6313    ///
6314    /// **Experimental.** This API is part of an experimental wire-protocol surface
6315    /// and may change or be removed in future SDK or CLI releases. Pin both the
6316    /// SDK and CLI versions if your code depends on it.
6317    ///
6318    /// </div>
6319    pub async fn disable(&self, params: McpDisableRequest) -> Result<(), Error> {
6320        let mut wire_params = serde_json::to_value(params)?;
6321        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6322        let _value = self
6323            .session
6324            .client()
6325            .call(rpc_methods::SESSION_MCP_DISABLE, Some(wire_params))
6326            .await?;
6327        Ok(())
6328    }
6329
6330    /// Reloads MCP server connections for the session.
6331    ///
6332    /// Wire method: `session.mcp.reload`.
6333    ///
6334    /// <div class="warning">
6335    ///
6336    /// **Experimental.** This API is part of an experimental wire-protocol surface
6337    /// and may change or be removed in future SDK or CLI releases. Pin both the
6338    /// SDK and CLI versions if your code depends on it.
6339    ///
6340    /// </div>
6341    pub async fn reload(&self) -> Result<(), Error> {
6342        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6343        let _value = self
6344            .session
6345            .client()
6346            .call(rpc_methods::SESSION_MCP_RELOAD, Some(wire_params))
6347            .await?;
6348        Ok(())
6349    }
6350
6351    /// Releases any turns waiting on an in-flight MCP load without cancelling the load, letting the agent proceed while MCP servers finish connecting in the background. No-op when no MCP load is in flight or waiting turns were already released.
6352    ///
6353    /// Wire method: `session.mcp.moveLoadingToBackground`.
6354    ///
6355    /// # Returns
6356    ///
6357    /// Result of moving in-flight MCP loading to the background.
6358    ///
6359    /// <div class="warning">
6360    ///
6361    /// **Experimental.** This API is part of an experimental wire-protocol surface
6362    /// and may change or be removed in future SDK or CLI releases. Pin both the
6363    /// SDK and CLI versions if your code depends on it.
6364    ///
6365    /// </div>
6366    pub async fn move_loading_to_background(
6367        &self,
6368    ) -> Result<MoveMcpLoadingToBackgroundResult, Error> {
6369        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6370        let _value = self
6371            .session
6372            .client()
6373            .call(
6374                rpc_methods::SESSION_MCP_MOVELOADINGTOBACKGROUND,
6375                Some(wire_params),
6376            )
6377            .await?;
6378        Ok(serde_json::from_value(_value)?)
6379    }
6380
6381    /// Reloads MCP server connections for the session with an explicit host-provided configuration.
6382    ///
6383    /// Wire method: `session.mcp.reloadWithConfig`.
6384    ///
6385    /// # Parameters
6386    ///
6387    /// * `params` - Opaque MCP reload configuration.
6388    ///
6389    /// # Returns
6390    ///
6391    /// MCP server startup filtering result.
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(crate) async fn reload_with_config(
6401        &self,
6402        params: McpReloadWithConfigRequest,
6403    ) -> Result<McpStartServersResult, 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_MCP_RELOADWITHCONFIG, Some(wire_params))
6410            .await?;
6411        Ok(serde_json::from_value(_value)?)
6412    }
6413
6414    /// Runs an MCP sampling inference on behalf of an MCP server.
6415    ///
6416    /// Wire method: `session.mcp.executeSampling`.
6417    ///
6418    /// # Parameters
6419    ///
6420    /// * `params` - Identifiers and raw MCP CreateMessageRequest params used to run a sampling inference.
6421    ///
6422    /// # Returns
6423    ///
6424    /// Outcome of an MCP sampling execution: success result, failure error, or cancellation.
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 execute_sampling(
6434        &self,
6435        params: McpExecuteSamplingParams,
6436    ) -> Result<McpSamplingExecutionResult, Error> {
6437        let mut wire_params = serde_json::to_value(params)?;
6438        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6439        let _value = self
6440            .session
6441            .client()
6442            .call(rpc_methods::SESSION_MCP_EXECUTESAMPLING, Some(wire_params))
6443            .await?;
6444        Ok(serde_json::from_value(_value)?)
6445    }
6446
6447    /// Cancels an in-flight MCP sampling execution by request ID.
6448    ///
6449    /// Wire method: `session.mcp.cancelSamplingExecution`.
6450    ///
6451    /// # Parameters
6452    ///
6453    /// * `params` - The requestId previously passed to executeSampling that should be cancelled.
6454    ///
6455    /// # Returns
6456    ///
6457    /// Indicates whether an in-flight sampling execution with the given requestId was found and cancelled.
6458    ///
6459    /// <div class="warning">
6460    ///
6461    /// **Experimental.** This API is part of an experimental wire-protocol surface
6462    /// and may change or be removed in future SDK or CLI releases. Pin both the
6463    /// SDK and CLI versions if your code depends on it.
6464    ///
6465    /// </div>
6466    pub async fn cancel_sampling_execution(
6467        &self,
6468        params: McpCancelSamplingExecutionParams,
6469    ) -> Result<McpCancelSamplingExecutionResult, Error> {
6470        let mut wire_params = serde_json::to_value(params)?;
6471        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6472        let _value = self
6473            .session
6474            .client()
6475            .call(
6476                rpc_methods::SESSION_MCP_CANCELSAMPLINGEXECUTION,
6477                Some(wire_params),
6478            )
6479            .await?;
6480        Ok(serde_json::from_value(_value)?)
6481    }
6482
6483    /// Sets how environment-variable values supplied to MCP servers are resolved (direct or indirect).
6484    ///
6485    /// Wire method: `session.mcp.setEnvValueMode`.
6486    ///
6487    /// # Parameters
6488    ///
6489    /// * `params` - Mode controlling how MCP server env values are resolved (`direct` or `indirect`).
6490    ///
6491    /// # Returns
6492    ///
6493    /// Env-value mode recorded on the session after the update.
6494    ///
6495    /// <div class="warning">
6496    ///
6497    /// **Experimental.** This API is part of an experimental wire-protocol surface
6498    /// and may change or be removed in future SDK or CLI releases. Pin both the
6499    /// SDK and CLI versions if your code depends on it.
6500    ///
6501    /// </div>
6502    pub async fn set_env_value_mode(
6503        &self,
6504        params: McpSetEnvValueModeParams,
6505    ) -> Result<McpSetEnvValueModeResult, Error> {
6506        let mut wire_params = serde_json::to_value(params)?;
6507        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6508        let _value = self
6509            .session
6510            .client()
6511            .call(rpc_methods::SESSION_MCP_SETENVVALUEMODE, Some(wire_params))
6512            .await?;
6513        Ok(serde_json::from_value(_value)?)
6514    }
6515
6516    /// Removes the auto-managed `github` MCP server when present.
6517    ///
6518    /// Wire method: `session.mcp.removeGitHub`.
6519    ///
6520    /// # Returns
6521    ///
6522    /// Indicates whether the auto-managed `github` MCP server was removed (false when nothing to remove).
6523    ///
6524    /// <div class="warning">
6525    ///
6526    /// **Experimental.** This API is part of an experimental wire-protocol surface
6527    /// and may change or be removed in future SDK or CLI releases. Pin both the
6528    /// SDK and CLI versions if your code depends on it.
6529    ///
6530    /// </div>
6531    pub async fn remove_git_hub(&self) -> Result<McpRemoveGitHubResult, Error> {
6532        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6533        let _value = self
6534            .session
6535            .client()
6536            .call(rpc_methods::SESSION_MCP_REMOVEGITHUB, Some(wire_params))
6537            .await?;
6538        Ok(serde_json::from_value(_value)?)
6539    }
6540
6541    /// Configures the built-in GitHub MCP server for the session's current auth context.
6542    ///
6543    /// Wire method: `session.mcp.configureGitHub`.
6544    ///
6545    /// # Parameters
6546    ///
6547    /// * `params` - Credential-free authentication identity used to configure GitHub MCP.
6548    ///
6549    /// # Returns
6550    ///
6551    /// Result of configuring GitHub MCP.
6552    ///
6553    /// <div class="warning">
6554    ///
6555    /// **Experimental.** This API is part of an experimental wire-protocol surface
6556    /// and may change or be removed in future SDK or CLI releases. Pin both the
6557    /// SDK and CLI versions if your code depends on it.
6558    ///
6559    /// </div>
6560    pub(crate) async fn configure_git_hub(
6561        &self,
6562        params: McpConfigureGitHubRequest,
6563    ) -> Result<McpConfigureGitHubResult, Error> {
6564        let mut wire_params = serde_json::to_value(params)?;
6565        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6566        let _value = self
6567            .session
6568            .client()
6569            .call(rpc_methods::SESSION_MCP_CONFIGUREGITHUB, Some(wire_params))
6570            .await?;
6571        Ok(serde_json::from_value(_value)?)
6572    }
6573
6574    /// Starts an individual MCP server on the live session. Omit `config` for a config-free start-by-name of an already-configured server (reuses the server's already-registered configuration); supply `config` to start from a caller-supplied configuration. Session-scoped and ephemeral: the server is added to this session's running set only and is reaped when the session ends. Does NOT modify persistent user configuration (`mcp.config.*`), so it does not affect future sessions. The server surfaces through `session.mcp.list` and the `session.mcp_servers_loaded` / `session.mcp_server_status_changed` events like any other server.
6575    ///
6576    /// Wire method: `session.mcp.startServer`.
6577    ///
6578    /// # Parameters
6579    ///
6580    /// * `params` - Server name and optional configuration for an individual MCP server start. Omit `config` for a config-free start-by-name of an already-configured server.
6581    ///
6582    /// <div class="warning">
6583    ///
6584    /// **Experimental.** This API is part of an experimental wire-protocol surface
6585    /// and may change or be removed in future SDK or CLI releases. Pin both the
6586    /// SDK and CLI versions if your code depends on it.
6587    ///
6588    /// </div>
6589    pub async fn start_server(&self, params: McpStartServerRequest) -> Result<(), Error> {
6590        let mut wire_params = serde_json::to_value(params)?;
6591        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6592        let _value = self
6593            .session
6594            .client()
6595            .call(rpc_methods::SESSION_MCP_STARTSERVER, Some(wire_params))
6596            .await?;
6597        Ok(())
6598    }
6599
6600    /// Restarts an individual MCP server on the live session (stops then starts). Omit `config` for a config-free restart-by-name of an already-configured server; supply `config` to restart with a replacement configuration. Session-scoped and ephemeral: does NOT modify persistent user configuration (`mcp.config.*`).
6601    ///
6602    /// Wire method: `session.mcp.restartServer`.
6603    ///
6604    /// # Parameters
6605    ///
6606    /// * `params` - Server name and optional replacement configuration for an individual MCP server restart. Omit `config` for a config-free restart-by-name of an already-configured server.
6607    ///
6608    /// <div class="warning">
6609    ///
6610    /// **Experimental.** This API is part of an experimental wire-protocol surface
6611    /// and may change or be removed in future SDK or CLI releases. Pin both the
6612    /// SDK and CLI versions if your code depends on it.
6613    ///
6614    /// </div>
6615    pub async fn restart_server(&self, params: McpRestartServerRequest) -> Result<(), Error> {
6616        let mut wire_params = serde_json::to_value(params)?;
6617        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6618        let _value = self
6619            .session
6620            .client()
6621            .call(rpc_methods::SESSION_MCP_RESTARTSERVER, Some(wire_params))
6622            .await?;
6623        Ok(())
6624    }
6625
6626    /// Stops an individual MCP server on the session's host.
6627    ///
6628    /// Wire method: `session.mcp.stopServer`.
6629    ///
6630    /// # Parameters
6631    ///
6632    /// * `params` - Server name for an individual MCP server stop.
6633    ///
6634    /// <div class="warning">
6635    ///
6636    /// **Experimental.** This API is part of an experimental wire-protocol surface
6637    /// and may change or be removed in future SDK or CLI releases. Pin both the
6638    /// SDK and CLI versions if your code depends on it.
6639    ///
6640    /// </div>
6641    pub async fn stop_server(&self, params: McpStopServerRequest) -> Result<(), Error> {
6642        let mut wire_params = serde_json::to_value(params)?;
6643        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6644        let _value = self
6645            .session
6646            .client()
6647            .call(rpc_methods::SESSION_MCP_STOPSERVER, Some(wire_params))
6648            .await?;
6649        Ok(())
6650    }
6651
6652    /// 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.
6653    ///
6654    /// Wire method: `session.mcp.registerExternalClient`.
6655    ///
6656    /// # Parameters
6657    ///
6658    /// * `params` - Registration parameters for an external MCP client.
6659    ///
6660    /// <div class="warning">
6661    ///
6662    /// **Experimental.** This API is part of an experimental wire-protocol surface
6663    /// and may change or be removed in future SDK or CLI releases. Pin both the
6664    /// SDK and CLI versions if your code depends on it.
6665    ///
6666    /// </div>
6667    pub(crate) async fn register_external_client(
6668        &self,
6669        params: McpRegisterExternalClientRequest,
6670    ) -> Result<(), Error> {
6671        let mut wire_params = serde_json::to_value(params)?;
6672        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6673        let _value = self
6674            .session
6675            .client()
6676            .call(
6677                rpc_methods::SESSION_MCP_REGISTEREXTERNALCLIENT,
6678                Some(wire_params),
6679            )
6680            .await?;
6681        Ok(())
6682    }
6683
6684    /// 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.
6685    ///
6686    /// Wire method: `session.mcp.unregisterExternalClient`.
6687    ///
6688    /// # Parameters
6689    ///
6690    /// * `params` - Server name identifying the external client to remove.
6691    ///
6692    /// <div class="warning">
6693    ///
6694    /// **Experimental.** This API is part of an experimental wire-protocol surface
6695    /// and may change or be removed in future SDK or CLI releases. Pin both the
6696    /// SDK and CLI versions if your code depends on it.
6697    ///
6698    /// </div>
6699    pub(crate) async fn unregister_external_client(
6700        &self,
6701        params: McpUnregisterExternalClientRequest,
6702    ) -> Result<(), Error> {
6703        let mut wire_params = serde_json::to_value(params)?;
6704        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6705        let _value = self
6706            .session
6707            .client()
6708            .call(
6709                rpc_methods::SESSION_MCP_UNREGISTEREXTERNALCLIENT,
6710                Some(wire_params),
6711            )
6712            .await?;
6713        Ok(())
6714    }
6715
6716    /// Checks whether a named MCP server is currently running on the session's host.
6717    ///
6718    /// Wire method: `session.mcp.isServerRunning`.
6719    ///
6720    /// # Parameters
6721    ///
6722    /// * `params` - Server name to check running status for.
6723    ///
6724    /// # Returns
6725    ///
6726    /// Whether the named MCP server is running.
6727    ///
6728    /// <div class="warning">
6729    ///
6730    /// **Experimental.** This API is part of an experimental wire-protocol surface
6731    /// and may change or be removed in future SDK or CLI releases. Pin both the
6732    /// SDK and CLI versions if your code depends on it.
6733    ///
6734    /// </div>
6735    pub async fn is_server_running(
6736        &self,
6737        params: McpIsServerRunningRequest,
6738    ) -> Result<McpIsServerRunningResult, Error> {
6739        let mut wire_params = serde_json::to_value(params)?;
6740        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6741        let _value = self
6742            .session
6743            .client()
6744            .call(rpc_methods::SESSION_MCP_ISSERVERRUNNING, Some(wire_params))
6745            .await?;
6746        Ok(serde_json::from_value(_value)?)
6747    }
6748}
6749
6750/// `session.mcp.apps.*` RPCs.
6751#[derive(Clone, Copy)]
6752pub struct SessionRpcMcpApps<'a> {
6753    pub(crate) session: &'a Session,
6754}
6755
6756impl<'a> SessionRpcMcpApps<'a> {
6757    /// Fetch an MCP resource (typically a `ui://` MCP App bundle, per SEP-1865) from a connected server. Requires the `mcp-apps` session capability.
6758    ///
6759    /// Wire method: `session.mcp.apps.readResource`.
6760    ///
6761    /// # Parameters
6762    ///
6763    /// * `params` - MCP server and resource URI to fetch.
6764    ///
6765    /// # Returns
6766    ///
6767    /// Resource contents returned by the MCP server.
6768    ///
6769    /// <div class="warning">
6770    ///
6771    /// **Experimental.** This API is part of an experimental wire-protocol surface
6772    /// and may change or be removed in future SDK or CLI releases. Pin both the
6773    /// SDK and CLI versions if your code depends on it.
6774    ///
6775    /// </div>
6776    pub async fn read_resource(
6777        &self,
6778        params: McpAppsReadResourceRequest,
6779    ) -> Result<McpAppsReadResourceResult, Error> {
6780        let mut wire_params = serde_json::to_value(params)?;
6781        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6782        let _value = self
6783            .session
6784            .client()
6785            .call(
6786                rpc_methods::SESSION_MCP_APPS_READRESOURCE,
6787                Some(wire_params),
6788            )
6789            .await?;
6790        Ok(serde_json::from_value(_value)?)
6791    }
6792
6793    /// 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"`.
6794    ///
6795    /// Wire method: `session.mcp.apps.listTools`.
6796    ///
6797    /// # Parameters
6798    ///
6799    /// * `params` - MCP server to list app-callable tools for.
6800    ///
6801    /// # Returns
6802    ///
6803    /// App-callable tools from the named MCP server.
6804    ///
6805    /// <div class="warning">
6806    ///
6807    /// **Experimental.** This API is part of an experimental wire-protocol surface
6808    /// and may change or be removed in future SDK or CLI releases. Pin both the
6809    /// SDK and CLI versions if your code depends on it.
6810    ///
6811    /// </div>
6812    pub async fn list_tools(
6813        &self,
6814        params: McpAppsListToolsRequest,
6815    ) -> Result<McpAppsListToolsResult, Error> {
6816        let mut wire_params = serde_json::to_value(params)?;
6817        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6818        let _value = self
6819            .session
6820            .client()
6821            .call(rpc_methods::SESSION_MCP_APPS_LISTTOOLS, Some(wire_params))
6822            .await?;
6823        Ok(serde_json::from_value(_value)?)
6824    }
6825
6826    /// 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`.
6827    ///
6828    /// Wire method: `session.mcp.apps.callTool`.
6829    ///
6830    /// # Parameters
6831    ///
6832    /// * `params` - MCP server, tool name, and arguments to invoke from an MCP App view.
6833    ///
6834    /// # Returns
6835    ///
6836    /// Standard MCP CallToolResult
6837    ///
6838    /// <div class="warning">
6839    ///
6840    /// **Experimental.** This API is part of an experimental wire-protocol surface
6841    /// and may change or be removed in future SDK or CLI releases. Pin both the
6842    /// SDK and CLI versions if your code depends on it.
6843    ///
6844    /// </div>
6845    pub async fn call_tool(
6846        &self,
6847        params: McpAppsCallToolRequest,
6848    ) -> Result<SessionMcpAppsCallToolResult, Error> {
6849        let mut wire_params = serde_json::to_value(params)?;
6850        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6851        let _value = self
6852            .session
6853            .client()
6854            .call(rpc_methods::SESSION_MCP_APPS_CALLTOOL, Some(wire_params))
6855            .await?;
6856        Ok(serde_json::from_value(_value)?)
6857    }
6858
6859    /// 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.
6860    ///
6861    /// Wire method: `session.mcp.apps.setHostContext`.
6862    ///
6863    /// # Parameters
6864    ///
6865    /// * `params` - Host context to advertise to MCP App guests.
6866    ///
6867    /// <div class="warning">
6868    ///
6869    /// **Experimental.** This API is part of an experimental wire-protocol surface
6870    /// and may change or be removed in future SDK or CLI releases. Pin both the
6871    /// SDK and CLI versions if your code depends on it.
6872    ///
6873    /// </div>
6874    pub async fn set_host_context(
6875        &self,
6876        params: McpAppsSetHostContextRequest,
6877    ) -> Result<(), Error> {
6878        let mut wire_params = serde_json::to_value(params)?;
6879        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6880        let _value = self
6881            .session
6882            .client()
6883            .call(
6884                rpc_methods::SESSION_MCP_APPS_SETHOSTCONTEXT,
6885                Some(wire_params),
6886            )
6887            .await?;
6888        Ok(())
6889    }
6890
6891    /// Read the current host context advertised to MCP App guests.
6892    ///
6893    /// Wire method: `session.mcp.apps.getHostContext`.
6894    ///
6895    /// # Returns
6896    ///
6897    /// Current host context advertised to MCP App guests.
6898    ///
6899    /// <div class="warning">
6900    ///
6901    /// **Experimental.** This API is part of an experimental wire-protocol surface
6902    /// and may change or be removed in future SDK or CLI releases. Pin both the
6903    /// SDK and CLI versions if your code depends on it.
6904    ///
6905    /// </div>
6906    pub async fn get_host_context(&self) -> Result<McpAppsHostContext, Error> {
6907        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6908        let _value = self
6909            .session
6910            .client()
6911            .call(
6912                rpc_methods::SESSION_MCP_APPS_GETHOSTCONTEXT,
6913                Some(wire_params),
6914            )
6915            .await?;
6916        Ok(serde_json::from_value(_value)?)
6917    }
6918
6919    /// 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.
6920    ///
6921    /// Wire method: `session.mcp.apps.diagnose`.
6922    ///
6923    /// # Parameters
6924    ///
6925    /// * `params` - MCP server to diagnose MCP Apps wiring for.
6926    ///
6927    /// # Returns
6928    ///
6929    /// Diagnostic snapshot of MCP Apps wiring for the named server.
6930    ///
6931    /// <div class="warning">
6932    ///
6933    /// **Experimental.** This API is part of an experimental wire-protocol surface
6934    /// and may change or be removed in future SDK or CLI releases. Pin both the
6935    /// SDK and CLI versions if your code depends on it.
6936    ///
6937    /// </div>
6938    pub async fn diagnose(
6939        &self,
6940        params: McpAppsDiagnoseRequest,
6941    ) -> Result<McpAppsDiagnoseResult, Error> {
6942        let mut wire_params = serde_json::to_value(params)?;
6943        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6944        let _value = self
6945            .session
6946            .client()
6947            .call(rpc_methods::SESSION_MCP_APPS_DIAGNOSE, Some(wire_params))
6948            .await?;
6949        Ok(serde_json::from_value(_value)?)
6950    }
6951}
6952
6953/// `session.mcp.headers.*` RPCs.
6954#[derive(Clone, Copy)]
6955pub struct SessionRpcMcpHeaders<'a> {
6956    pub(crate) session: &'a Session,
6957}
6958
6959impl<'a> SessionRpcMcpHeaders<'a> {
6960    /// 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.
6961    ///
6962    /// Wire method: `session.mcp.headers.handlePendingHeadersRefreshRequest`.
6963    ///
6964    /// # Parameters
6965    ///
6966    /// * `params` - MCP headers refresh request id and the host response.
6967    ///
6968    /// # Returns
6969    ///
6970    /// Indicates whether the pending MCP headers refresh response was accepted.
6971    ///
6972    /// <div class="warning">
6973    ///
6974    /// **Experimental.** This API is part of an experimental wire-protocol surface
6975    /// and may change or be removed in future SDK or CLI releases. Pin both the
6976    /// SDK and CLI versions if your code depends on it.
6977    ///
6978    /// </div>
6979    pub async fn handle_pending_headers_refresh_request(
6980        &self,
6981        params: McpHeadersHandlePendingHeadersRefreshRequestRequest,
6982    ) -> Result<McpHeadersHandlePendingHeadersRefreshRequestResult, Error> {
6983        let mut wire_params = serde_json::to_value(params)?;
6984        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6985        let _value = self
6986            .session
6987            .client()
6988            .call(
6989                rpc_methods::SESSION_MCP_HEADERS_HANDLEPENDINGHEADERSREFRESHREQUEST,
6990                Some(wire_params),
6991            )
6992            .await?;
6993        Ok(serde_json::from_value(_value)?)
6994    }
6995}
6996
6997/// `session.mcp.oauth.*` RPCs.
6998#[derive(Clone, Copy)]
6999pub struct SessionRpcMcpOauth<'a> {
7000    pub(crate) session: &'a Session,
7001}
7002
7003impl<'a> SessionRpcMcpOauth<'a> {
7004    /// 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.
7005    ///
7006    /// Wire method: `session.mcp.oauth.handlePendingRequest`.
7007    ///
7008    /// # Parameters
7009    ///
7010    /// * `params` - Pending MCP OAuth request ID and host-provided token or cancellation response.
7011    ///
7012    /// # Returns
7013    ///
7014    /// Indicates whether the pending MCP OAuth response was accepted.
7015    ///
7016    /// <div class="warning">
7017    ///
7018    /// **Experimental.** This API is part of an experimental wire-protocol surface
7019    /// and may change or be removed in future SDK or CLI releases. Pin both the
7020    /// SDK and CLI versions if your code depends on it.
7021    ///
7022    /// </div>
7023    pub async fn handle_pending_request(
7024        &self,
7025        params: McpOauthHandlePendingRequest,
7026    ) -> Result<McpOauthHandlePendingResult, Error> {
7027        let mut wire_params = serde_json::to_value(params)?;
7028        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7029        let _value = self
7030            .session
7031            .client()
7032            .call(
7033                rpc_methods::SESSION_MCP_OAUTH_HANDLEPENDINGREQUEST,
7034                Some(wire_params),
7035            )
7036            .await?;
7037        Ok(serde_json::from_value(_value)?)
7038    }
7039
7040    /// Notifies the session that MCP OAuth authentication succeeded and updated credentials were persisted, so cached tool definitions can be refreshed.
7041    ///
7042    /// Wire method: `session.mcp.oauth.authenticationStateChanged`.
7043    ///
7044    /// # Parameters
7045    ///
7046    /// * `params` - Identifies the MCP server whose persisted OAuth credentials were updated.
7047    ///
7048    /// <div class="warning">
7049    ///
7050    /// **Experimental.** This API is part of an experimental wire-protocol surface
7051    /// and may change or be removed in future SDK or CLI releases. Pin both the
7052    /// SDK and CLI versions if your code depends on it.
7053    ///
7054    /// </div>
7055    pub async fn authentication_state_changed(
7056        &self,
7057        params: McpOauthAuthenticationStateChangedRequest,
7058    ) -> Result<(), Error> {
7059        let mut wire_params = serde_json::to_value(params)?;
7060        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7061        let _value = self
7062            .session
7063            .client()
7064            .call(
7065                rpc_methods::SESSION_MCP_OAUTH_AUTHENTICATIONSTATECHANGED,
7066                Some(wire_params),
7067            )
7068            .await?;
7069        Ok(())
7070    }
7071
7072    /// Starts OAuth authentication for a remote MCP server.
7073    ///
7074    /// Wire method: `session.mcp.oauth.login`.
7075    ///
7076    /// # Parameters
7077    ///
7078    /// * `params` - Remote MCP server name and optional overrides controlling reauthentication, OAuth client display name, callback success-page copy, and static OAuth client selection.
7079    ///
7080    /// # Returns
7081    ///
7082    /// OAuth authorization URL the caller should open, or empty when cached tokens already authenticated the server.
7083    ///
7084    /// <div class="warning">
7085    ///
7086    /// **Experimental.** This API is part of an experimental wire-protocol surface
7087    /// and may change or be removed in future SDK or CLI releases. Pin both the
7088    /// SDK and CLI versions if your code depends on it.
7089    ///
7090    /// </div>
7091    pub async fn login(&self, params: McpOauthLoginRequest) -> Result<McpOauthLoginResult, Error> {
7092        let mut wire_params = serde_json::to_value(params)?;
7093        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7094        let _value = self
7095            .session
7096            .client()
7097            .call(rpc_methods::SESSION_MCP_OAUTH_LOGIN, Some(wire_params))
7098            .await?;
7099        Ok(serde_json::from_value(_value)?)
7100    }
7101
7102    /// Passively probes a configured remote MCP server to classify whether OAuth is required or a cached/override token is accepted. Does not start OAuth, emit pending OAuth requests, or mutate MCP connection state.
7103    ///
7104    /// Wire method: `session.mcp.oauth.probe`.
7105    ///
7106    /// # Parameters
7107    ///
7108    /// * `params` - Remote MCP server name for a passive OAuth status probe.
7109    ///
7110    /// # Returns
7111    ///
7112    /// Passive MCP OAuth probe result. `authenticated` means the server accepted the probe request while an OAuth-origin access token was attached; it does not prove the server required or independently validated that token. The probe does not make a second unauthenticated request. Failed is an expected probe-domain outcome; JSON-RPC errors are reserved for API-call failures.
7113    ///
7114    /// <div class="warning">
7115    ///
7116    /// **Experimental.** This API is part of an experimental wire-protocol surface
7117    /// and may change or be removed in future SDK or CLI releases. Pin both the
7118    /// SDK and CLI versions if your code depends on it.
7119    ///
7120    /// </div>
7121    pub async fn probe(&self, params: McpOauthProbeRequest) -> Result<McpOauthProbeResult, Error> {
7122        let mut wire_params = serde_json::to_value(params)?;
7123        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7124        let _value = self
7125            .session
7126            .client()
7127            .call(rpc_methods::SESSION_MCP_OAUTH_PROBE, Some(wire_params))
7128            .await?;
7129        Ok(serde_json::from_value(_value)?)
7130    }
7131
7132    /// Responds to a pending MCP OAuth authorization request by its request id.
7133    ///
7134    /// Wire method: `session.mcp.oauth.respond`.
7135    ///
7136    /// # Parameters
7137    ///
7138    /// * `params` - Pending MCP OAuth request id to respond to.
7139    ///
7140    /// # Returns
7141    ///
7142    /// Indicates whether the pending MCP OAuth response was accepted.
7143    ///
7144    /// <div class="warning">
7145    ///
7146    /// **Experimental.** This API is part of an experimental wire-protocol surface
7147    /// and may change or be removed in future SDK or CLI releases. Pin both the
7148    /// SDK and CLI versions if your code depends on it.
7149    ///
7150    /// </div>
7151    pub async fn respond(
7152        &self,
7153        params: McpOauthRespondRequest,
7154    ) -> Result<McpOauthRespondResult, Error> {
7155        let mut wire_params = serde_json::to_value(params)?;
7156        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7157        let _value = self
7158            .session
7159            .client()
7160            .call(rpc_methods::SESSION_MCP_OAUTH_RESPOND, Some(wire_params))
7161            .await?;
7162        Ok(serde_json::from_value(_value)?)
7163    }
7164}
7165
7166/// `session.mcp.resources.*` RPCs.
7167#[derive(Clone, Copy)]
7168pub struct SessionRpcMcpResources<'a> {
7169    pub(crate) session: &'a Session,
7170}
7171
7172impl<'a> SessionRpcMcpResources<'a> {
7173    /// Fetch an MCP resource from a connected server by URI (proxies MCP `resources/read`).
7174    ///
7175    /// Wire method: `session.mcp.resources.read`.
7176    ///
7177    /// # Parameters
7178    ///
7179    /// * `params` - MCP server and resource URI to fetch.
7180    ///
7181    /// # Returns
7182    ///
7183    /// Resource contents returned by the MCP server.
7184    ///
7185    /// <div class="warning">
7186    ///
7187    /// **Experimental.** This API is part of an experimental wire-protocol surface
7188    /// and may change or be removed in future SDK or CLI releases. Pin both the
7189    /// SDK and CLI versions if your code depends on it.
7190    ///
7191    /// </div>
7192    pub async fn read(
7193        &self,
7194        params: McpResourcesReadRequest,
7195    ) -> Result<McpResourcesReadResult, Error> {
7196        let mut wire_params = serde_json::to_value(params)?;
7197        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7198        let _value = self
7199            .session
7200            .client()
7201            .call(rpc_methods::SESSION_MCP_RESOURCES_READ, Some(wire_params))
7202            .await?;
7203        Ok(serde_json::from_value(_value)?)
7204    }
7205
7206    /// Enumerate one page of resources a connected MCP server exposes (proxies MCP `resources/list`). Pass `cursor` to continue from a prior result's `nextCursor`.
7207    ///
7208    /// Wire method: `session.mcp.resources.list`.
7209    ///
7210    /// # Parameters
7211    ///
7212    /// * `params` - MCP server whose resources to enumerate.
7213    ///
7214    /// # Returns
7215    ///
7216    /// One page of resources advertised by the named MCP server.
7217    ///
7218    /// <div class="warning">
7219    ///
7220    /// **Experimental.** This API is part of an experimental wire-protocol surface
7221    /// and may change or be removed in future SDK or CLI releases. Pin both the
7222    /// SDK and CLI versions if your code depends on it.
7223    ///
7224    /// </div>
7225    pub async fn list(
7226        &self,
7227        params: McpResourcesListRequest,
7228    ) -> Result<McpResourcesListResult, Error> {
7229        let mut wire_params = serde_json::to_value(params)?;
7230        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7231        let _value = self
7232            .session
7233            .client()
7234            .call(rpc_methods::SESSION_MCP_RESOURCES_LIST, Some(wire_params))
7235            .await?;
7236        Ok(serde_json::from_value(_value)?)
7237    }
7238
7239    /// Enumerate one page of resource templates a connected MCP server exposes (proxies MCP `resources/templates/list`). Pass `cursor` to continue from a prior result's `nextCursor`.
7240    ///
7241    /// Wire method: `session.mcp.resources.listTemplates`.
7242    ///
7243    /// # Parameters
7244    ///
7245    /// * `params` - MCP server whose resource templates to enumerate.
7246    ///
7247    /// # Returns
7248    ///
7249    /// One page of resource templates advertised by the named MCP server.
7250    ///
7251    /// <div class="warning">
7252    ///
7253    /// **Experimental.** This API is part of an experimental wire-protocol surface
7254    /// and may change or be removed in future SDK or CLI releases. Pin both the
7255    /// SDK and CLI versions if your code depends on it.
7256    ///
7257    /// </div>
7258    pub async fn list_templates(
7259        &self,
7260        params: McpResourcesListTemplatesRequest,
7261    ) -> Result<McpResourcesListTemplatesResult, Error> {
7262        let mut wire_params = serde_json::to_value(params)?;
7263        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7264        let _value = self
7265            .session
7266            .client()
7267            .call(
7268                rpc_methods::SESSION_MCP_RESOURCES_LISTTEMPLATES,
7269                Some(wire_params),
7270            )
7271            .await?;
7272        Ok(serde_json::from_value(_value)?)
7273    }
7274}
7275
7276/// `session.metadata.*` RPCs.
7277#[derive(Clone, Copy)]
7278pub struct SessionRpcMetadata<'a> {
7279    pub(crate) session: &'a Session,
7280}
7281
7282impl<'a> SessionRpcMetadata<'a> {
7283    /// Returns a snapshot of the session's identifying metadata, mode, agent, and remote info.
7284    ///
7285    /// Wire method: `session.metadata.snapshot`.
7286    ///
7287    /// # Returns
7288    ///
7289    /// Point-in-time snapshot of slow-changing session identifier and state fields
7290    ///
7291    /// <div class="warning">
7292    ///
7293    /// **Experimental.** This API is part of an experimental wire-protocol surface
7294    /// and may change or be removed in future SDK or CLI releases. Pin both the
7295    /// SDK and CLI versions if your code depends on it.
7296    ///
7297    /// </div>
7298    pub async fn snapshot(&self) -> Result<SessionMetadataSnapshot, Error> {
7299        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7300        let _value = self
7301            .session
7302            .client()
7303            .call(rpc_methods::SESSION_METADATA_SNAPSHOT, Some(wire_params))
7304            .await?;
7305        Ok(serde_json::from_value(_value)?)
7306    }
7307
7308    /// Returns the client-owned string metadata persisted with this local session. The metadata is not included in model context, events, telemetry, snapshots, or remote exports.
7309    ///
7310    /// Wire method: `session.metadata.getClientMetadata`.
7311    ///
7312    /// # Returns
7313    ///
7314    /// Client-owned, case-sensitive string metadata persisted with a local session. Clients should namespace keys by owner. Keys must be non-empty and at most 256 UTF-8 bytes; keys under `copilot/` and `github/` are reserved. Values may contain at most 16 KiB of UTF-8 data. A bag may contain at most 128 entries and its serialized sidecar may contain at most 64 KiB. The runtime stores but never interprets these values.
7315    ///
7316    /// <div class="warning">
7317    ///
7318    /// **Experimental.** This API is part of an experimental wire-protocol surface
7319    /// and may change or be removed in future SDK or CLI releases. Pin both the
7320    /// SDK and CLI versions if your code depends on it.
7321    ///
7322    /// </div>
7323    pub async fn get_client_metadata(&self) -> Result<ClientMetadata, Error> {
7324        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7325        let _value = self
7326            .session
7327            .client()
7328            .call(
7329                rpc_methods::SESSION_METADATA_GETCLIENTMETADATA,
7330                Some(wire_params),
7331            )
7332            .await?;
7333        Ok(serde_json::from_value(_value)?)
7334    }
7335
7336    /// Atomically patches the client-owned string metadata persisted with this local session and returns the committed bag.
7337    ///
7338    /// Wire method: `session.metadata.updateClientMetadata`.
7339    ///
7340    /// # Parameters
7341    ///
7342    /// * `params` - Atomic patch for client-owned session metadata. Operations apply in clear, remove, then set order. The resulting bag must satisfy the ClientMetadata entry and serialized-size limits. Local storage coordinates concurrent runtime processes; custom SessionFs providers must serialize writers that access the same session from multiple processes.
7343    ///
7344    /// # Returns
7345    ///
7346    /// Client-owned, case-sensitive string metadata persisted with a local session. Clients should namespace keys by owner. Keys must be non-empty and at most 256 UTF-8 bytes; keys under `copilot/` and `github/` are reserved. Values may contain at most 16 KiB of UTF-8 data. A bag may contain at most 128 entries and its serialized sidecar may contain at most 64 KiB. The runtime stores but never interprets these values.
7347    ///
7348    /// <div class="warning">
7349    ///
7350    /// **Experimental.** This API is part of an experimental wire-protocol surface
7351    /// and may change or be removed in future SDK or CLI releases. Pin both the
7352    /// SDK and CLI versions if your code depends on it.
7353    ///
7354    /// </div>
7355    pub async fn update_client_metadata(
7356        &self,
7357        params: MetadataUpdateClientMetadataRequest,
7358    ) -> Result<ClientMetadata, Error> {
7359        let mut wire_params = serde_json::to_value(params)?;
7360        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7361        let _value = self
7362            .session
7363            .client()
7364            .call(
7365                rpc_methods::SESSION_METADATA_UPDATECLIENTMETADATA,
7366                Some(wire_params),
7367            )
7368            .await?;
7369        Ok(serde_json::from_value(_value)?)
7370    }
7371
7372    /// Reports whether the local session is currently processing user/agent messages.
7373    ///
7374    /// Wire method: `session.metadata.isProcessing`.
7375    ///
7376    /// # Returns
7377    ///
7378    /// Indicates whether the local session is currently processing a turn or background continuation.
7379    ///
7380    /// <div class="warning">
7381    ///
7382    /// **Experimental.** This API is part of an experimental wire-protocol surface
7383    /// and may change or be removed in future SDK or CLI releases. Pin both the
7384    /// SDK and CLI versions if your code depends on it.
7385    ///
7386    /// </div>
7387    pub async fn is_processing(&self) -> Result<MetadataIsProcessingResult, Error> {
7388        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7389        let _value = self
7390            .session
7391            .client()
7392            .call(
7393                rpc_methods::SESSION_METADATA_ISPROCESSING,
7394                Some(wire_params),
7395            )
7396            .await?;
7397        Ok(serde_json::from_value(_value)?)
7398    }
7399
7400    /// Returns a snapshot of activity flags for the session.
7401    ///
7402    /// Wire method: `session.metadata.activity`.
7403    ///
7404    /// # Returns
7405    ///
7406    /// Current activity flags for the session.
7407    ///
7408    /// <div class="warning">
7409    ///
7410    /// **Experimental.** This API is part of an experimental wire-protocol surface
7411    /// and may change or be removed in future SDK or CLI releases. Pin both the
7412    /// SDK and CLI versions if your code depends on it.
7413    ///
7414    /// </div>
7415    pub async fn activity(&self) -> Result<SessionActivity, Error> {
7416        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7417        let _value = self
7418            .session
7419            .client()
7420            .call(rpc_methods::SESSION_METADATA_ACTIVITY, Some(wire_params))
7421            .await?;
7422        Ok(serde_json::from_value(_value)?)
7423    }
7424
7425    /// Returns the token breakdown for the session's current context window for a given model.
7426    ///
7427    /// Wire method: `session.metadata.contextInfo`.
7428    ///
7429    /// # Parameters
7430    ///
7431    /// * `params` - Model identifier and token limits used to compute the context-info breakdown.
7432    ///
7433    /// # Returns
7434    ///
7435    /// Token breakdown for the session's current context window, or null if uninitialized.
7436    ///
7437    /// <div class="warning">
7438    ///
7439    /// **Experimental.** This API is part of an experimental wire-protocol surface
7440    /// and may change or be removed in future SDK or CLI releases. Pin both the
7441    /// SDK and CLI versions if your code depends on it.
7442    ///
7443    /// </div>
7444    pub async fn context_info(
7445        &self,
7446        params: MetadataContextInfoRequest,
7447    ) -> Result<MetadataContextInfoResult, Error> {
7448        let mut wire_params = serde_json::to_value(params)?;
7449        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7450        let _value = self
7451            .session
7452            .client()
7453            .call(rpc_methods::SESSION_METADATA_CONTEXTINFO, Some(wire_params))
7454            .await?;
7455        Ok(serde_json::from_value(_value)?)
7456    }
7457
7458    /// Returns the experimental per-source attribution breakdown of the session's current context window as a flat list of entries (skills, subagents, MCP servers, built-in tools, plugin rollups, system/tool-definition costs, with nesting via parentId), plus the successful compaction count. The heaviest individual messages are available separately via `metadata.getContextHeaviestMessages`. Returns null until the session has initialized its system prompt and tool metadata.
7459    ///
7460    /// Wire method: `session.metadata.getContextAttribution`.
7461    ///
7462    /// # Returns
7463    ///
7464    /// Per-source attribution breakdown for the session's current context window, or null if uninitialized.
7465    ///
7466    /// <div class="warning">
7467    ///
7468    /// **Experimental.** This API is part of an experimental wire-protocol surface
7469    /// and may change or be removed in future SDK or CLI releases. Pin both the
7470    /// SDK and CLI versions if your code depends on it.
7471    ///
7472    /// </div>
7473    pub async fn get_context_attribution(&self) -> Result<MetadataContextAttributionResult, Error> {
7474        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7475        let _value = self
7476            .session
7477            .client()
7478            .call(
7479                rpc_methods::SESSION_METADATA_GETCONTEXTATTRIBUTION,
7480                Some(wire_params),
7481            )
7482            .await?;
7483        Ok(serde_json::from_value(_value)?)
7484    }
7485
7486    /// Returns the largest individual messages currently in the session's context window, most-expensive first. Companion to `metadata.getContextAttribution`. Returns an empty list until the session has initialized.
7487    ///
7488    /// Wire method: `session.metadata.getContextHeaviestMessages`.
7489    ///
7490    /// # Parameters
7491    ///
7492    /// * `params` - Parameters for the heaviest-messages query.
7493    ///
7494    /// # Returns
7495    ///
7496    /// The heaviest individual messages in the session's context window, most-expensive first.
7497    ///
7498    /// <div class="warning">
7499    ///
7500    /// **Experimental.** This API is part of an experimental wire-protocol surface
7501    /// and may change or be removed in future SDK or CLI releases. Pin both the
7502    /// SDK and CLI versions if your code depends on it.
7503    ///
7504    /// </div>
7505    pub async fn get_context_heaviest_messages(
7506        &self,
7507        params: MetadataContextHeaviestMessagesRequest,
7508    ) -> Result<MetadataContextHeaviestMessagesResult, Error> {
7509        let mut wire_params = serde_json::to_value(params)?;
7510        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7511        let _value = self
7512            .session
7513            .client()
7514            .call(
7515                rpc_methods::SESSION_METADATA_GETCONTEXTHEAVIESTMESSAGES,
7516                Some(wire_params),
7517            )
7518            .await?;
7519        Ok(serde_json::from_value(_value)?)
7520    }
7521
7522    /// Records a working-directory/git context change and emits a `session.context_changed` event. For a local session, a report whose `cwd` diverges from the session's current working directory is ignored (the call still succeeds but records nothing and emits no event): a local session's working directory is authoritative and is moved via `metadata.setWorkingDirectory` (or an SDK `session.resume` that supplies a `workingDirectory`), not by this method.
7523    ///
7524    /// Wire method: `session.metadata.recordContextChange`.
7525    ///
7526    /// # Parameters
7527    ///
7528    /// * `params` - Updated working-directory/git context to record on the session.
7529    ///
7530    /// # Returns
7531    ///
7532    /// Notify the session that its working directory context has changed. Emits a `session.context_changed` event so consumers (telemetry, OTel tracker, ACP, the timeline UI) can react. Use this when the host has detected a cwd/branch/repo change outside the session's normal lifecycle (e.g., after a shell command in interactive mode). For a local session, a report whose `cwd` diverges from the session's current working directory is ignored (the call still succeeds but records nothing and emits no event); move a local session's working directory via `metadata.setWorkingDirectory` instead.
7533    ///
7534    /// <div class="warning">
7535    ///
7536    /// **Experimental.** This API is part of an experimental wire-protocol surface
7537    /// and may change or be removed in future SDK or CLI releases. Pin both the
7538    /// SDK and CLI versions if your code depends on it.
7539    ///
7540    /// </div>
7541    pub async fn record_context_change(
7542        &self,
7543        params: MetadataRecordContextChangeRequest,
7544    ) -> Result<MetadataRecordContextChangeResult, Error> {
7545        let mut wire_params = serde_json::to_value(params)?;
7546        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7547        let _value = self
7548            .session
7549            .client()
7550            .call(
7551                rpc_methods::SESSION_METADATA_RECORDCONTEXTCHANGE,
7552                Some(wire_params),
7553            )
7554            .await?;
7555        Ok(serde_json::from_value(_value)?)
7556    }
7557
7558    /// Updates the session's working directory. For local sessions the target is validated first (an absolute path that exists on disk) and the permission primary directory is re-based; a rejected validation fails the call before any session state changes.
7559    ///
7560    /// Wire method: `session.metadata.setWorkingDirectory`.
7561    ///
7562    /// # Parameters
7563    ///
7564    /// * `params` - Absolute path to set as the session's new working directory. For local sessions the path must be absolute and exist on disk: it is validated before any session state changes, and a failing validation rejects the call with nothing mutated, persisted, or emitted. Remote sessions record the path as-is.
7565    ///
7566    /// # Returns
7567    ///
7568    /// Update the session's working directory. Used by the host when the user explicitly changes cwd (e.g., the `/cd` slash command). The host is responsible for any related side-effects (file index, etc.); it does NOT change the process working directory (a session's cwd is per-session, not process-global). For local sessions the runtime validates the target first (an absolute path that exists on disk) and re-bases the permission primary directory; a rejected validation fails the call before anything is mutated, persisted, or emitted. Location-scoped permission rules are then re-keyed to the new directory (best-effort). Remote sessions only record the path.
7569    ///
7570    /// <div class="warning">
7571    ///
7572    /// **Experimental.** This API is part of an experimental wire-protocol surface
7573    /// and may change or be removed in future SDK or CLI releases. Pin both the
7574    /// SDK and CLI versions if your code depends on it.
7575    ///
7576    /// </div>
7577    pub async fn set_working_directory(
7578        &self,
7579        params: MetadataSetWorkingDirectoryRequest,
7580    ) -> Result<MetadataSetWorkingDirectoryResult, Error> {
7581        let mut wire_params = serde_json::to_value(params)?;
7582        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7583        let _value = self
7584            .session
7585            .client()
7586            .call(
7587                rpc_methods::SESSION_METADATA_SETWORKINGDIRECTORY,
7588                Some(wire_params),
7589            )
7590            .await?;
7591        Ok(serde_json::from_value(_value)?)
7592    }
7593
7594    /// Re-tokenizes the session's existing messages against a model and returns aggregate token totals.
7595    ///
7596    /// Wire method: `session.metadata.recomputeContextTokens`.
7597    ///
7598    /// # Parameters
7599    ///
7600    /// * `params` - Model identifier to use when re-tokenizing the session's existing messages.
7601    ///
7602    /// # Returns
7603    ///
7604    /// 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.
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 recompute_context_tokens(
7614        &self,
7615        params: MetadataRecomputeContextTokensRequest,
7616    ) -> Result<MetadataRecomputeContextTokensResult, 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_METADATA_RECOMPUTECONTEXTTOKENS,
7624                Some(wire_params),
7625            )
7626            .await?;
7627        Ok(serde_json::from_value(_value)?)
7628    }
7629}
7630
7631/// `session.mode.*` RPCs.
7632#[derive(Clone, Copy)]
7633pub struct SessionRpcMode<'a> {
7634    pub(crate) session: &'a Session,
7635}
7636
7637impl<'a> SessionRpcMode<'a> {
7638    /// Gets the current agent interaction mode.
7639    ///
7640    /// Wire method: `session.mode.get`.
7641    ///
7642    /// # Returns
7643    ///
7644    /// The session mode the agent is operating in
7645    ///
7646    /// <div class="warning">
7647    ///
7648    /// **Experimental.** This API is part of an experimental wire-protocol surface
7649    /// and may change or be removed in future SDK or CLI releases. Pin both the
7650    /// SDK and CLI versions if your code depends on it.
7651    ///
7652    /// </div>
7653    pub async fn get(&self) -> Result<SessionMode, Error> {
7654        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7655        let _value = self
7656            .session
7657            .client()
7658            .call(rpc_methods::SESSION_MODE_GET, Some(wire_params))
7659            .await?;
7660        Ok(serde_json::from_value(_value)?)
7661    }
7662
7663    /// Sets the current agent interaction mode.
7664    ///
7665    /// Wire method: `session.mode.set`.
7666    ///
7667    /// # Parameters
7668    ///
7669    /// * `params` - Agent interaction mode to apply to the session.
7670    ///
7671    /// # Returns
7672    ///
7673    /// Outcome of a session mode change, including any model switch it triggered and follow-up the host must perform.
7674    ///
7675    /// <div class="warning">
7676    ///
7677    /// **Experimental.** This API is part of an experimental wire-protocol surface
7678    /// and may change or be removed in future SDK or CLI releases. Pin both the
7679    /// SDK and CLI versions if your code depends on it.
7680    ///
7681    /// </div>
7682    pub async fn set(&self, params: ModeSetRequest) -> Result<ModeSetResult, Error> {
7683        let mut wire_params = serde_json::to_value(params)?;
7684        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7685        let _value = self
7686            .session
7687            .client()
7688            .call(rpc_methods::SESSION_MODE_SET, Some(wire_params))
7689            .await?;
7690        Ok(serde_json::from_value(_value)?)
7691    }
7692}
7693
7694/// `session.model.*` RPCs.
7695#[derive(Clone, Copy)]
7696pub struct SessionRpcModel<'a> {
7697    pub(crate) session: &'a Session,
7698}
7699
7700impl<'a> SessionRpcModel<'a> {
7701    /// Gets the session's authoritative model snapshot, including the committed Auto preference and any newer unclaimed Auto preference waiting for a future user turn.
7702    ///
7703    /// Wire method: `session.model.getCurrent`.
7704    ///
7705    /// # Returns
7706    ///
7707    /// The session's authoritative model snapshot. Auto preference fields are configuration for the virtual `auto` model and do not change the selected model identifier. The context tier reflects `Session.getContextTier()`, restored from the session journal on resume.
7708    ///
7709    /// <div class="warning">
7710    ///
7711    /// **Experimental.** This API is part of an experimental wire-protocol surface
7712    /// and may change or be removed in future SDK or CLI releases. Pin both the
7713    /// SDK and CLI versions if your code depends on it.
7714    ///
7715    /// </div>
7716    pub async fn get_current(&self) -> Result<CurrentModel, Error> {
7717        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7718        let _value = self
7719            .session
7720            .client()
7721            .call(rpc_methods::SESSION_MODEL_GETCURRENT, Some(wire_params))
7722            .await?;
7723        Ok(serde_json::from_value(_value)?)
7724    }
7725
7726    /// Switches the session to a model and optional reasoning configuration.
7727    ///
7728    /// Wire method: `session.model.switchTo`.
7729    ///
7730    /// # Parameters
7731    ///
7732    /// * `params` - Target model identifier and optional reasoning effort, summary, capability overrides, and context tier.
7733    ///
7734    /// # Returns
7735    ///
7736    /// The model identifier active on the session after the switch.
7737    ///
7738    /// <div class="warning">
7739    ///
7740    /// **Experimental.** This API is part of an experimental wire-protocol surface
7741    /// and may change or be removed in future SDK or CLI releases. Pin both the
7742    /// SDK and CLI versions if your code depends on it.
7743    ///
7744    /// </div>
7745    pub async fn switch_to(
7746        &self,
7747        params: ModelSwitchToRequest,
7748    ) -> Result<ModelSwitchToResult, Error> {
7749        let mut wire_params = serde_json::to_value(params)?;
7750        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7751        let _value = self
7752            .session
7753            .client()
7754            .call(rpc_methods::SESSION_MODEL_SWITCHTO, Some(wire_params))
7755            .await?;
7756        Ok(serde_json::from_value(_value)?)
7757    }
7758
7759    /// Requests an Auto preference change without changing the session's selected model. The latest unclaimed request wins; the runtime commits it only after a later prompt using the `auto` model mints a usable model and token pair. A `pending` response confirms that the request was accepted, not that it committed. Observe eventual success through `session.model_change`, failure through the ephemeral `session.auto_tier_switch_failed` event, or current unclaimed state through `session.model.getCurrent`.
7760    ///
7761    /// Wire method: `session.model.switchAutoTier`.
7762    ///
7763    /// # Parameters
7764    ///
7765    /// * `params` - An Auto preference request for the session. This updates Auto configuration only; it does not change the selected model to `auto`.
7766    ///
7767    /// # Returns
7768    ///
7769    /// Immediate acknowledgement and Auto preference snapshot after a switch request. This result never implies that a pending preference committed.
7770    ///
7771    /// <div class="warning">
7772    ///
7773    /// **Experimental.** This API is part of an experimental wire-protocol surface
7774    /// and may change or be removed in future SDK or CLI releases. Pin both the
7775    /// SDK and CLI versions if your code depends on it.
7776    ///
7777    /// </div>
7778    pub async fn switch_auto_tier(
7779        &self,
7780        params: ModelSwitchAutoTierRequest,
7781    ) -> Result<ModelSwitchAutoTierResult, Error> {
7782        let mut wire_params = serde_json::to_value(params)?;
7783        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7784        let _value = self
7785            .session
7786            .client()
7787            .call(rpc_methods::SESSION_MODEL_SWITCHAUTOTIER, Some(wire_params))
7788            .await?;
7789        Ok(serde_json::from_value(_value)?)
7790    }
7791
7792    /// Resolves and applies organization-managed and repository model overlays.
7793    ///
7794    /// Wire method: `session.model.applyStartupOverlay`.
7795    ///
7796    /// # Parameters
7797    ///
7798    /// * `params` - Managed, repository, and CLI model overrides to overlay onto the session at startup.
7799    ///
7800    /// # Returns
7801    ///
7802    /// The model identifier active on the session after the switch.
7803    ///
7804    /// <div class="warning">
7805    ///
7806    /// **Experimental.** This API is part of an experimental wire-protocol surface
7807    /// and may change or be removed in future SDK or CLI releases. Pin both the
7808    /// SDK and CLI versions if your code depends on it.
7809    ///
7810    /// </div>
7811    pub(crate) async fn apply_startup_overlay(
7812        &self,
7813        params: ModelApplyStartupOverlayRequest,
7814    ) -> Result<ModelSwitchToResult, Error> {
7815        let mut wire_params = serde_json::to_value(params)?;
7816        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7817        let _value = self
7818            .session
7819            .client()
7820            .call(
7821                rpc_methods::SESSION_MODEL_APPLYSTARTUPOVERLAY,
7822                Some(wire_params),
7823            )
7824            .await?;
7825        Ok(serde_json::from_value(_value)?)
7826    }
7827
7828    /// Replaces or clears the host-supplied model allowlist for a running session.
7829    ///
7830    /// Wire method: `session.model.setAllowedModels`.
7831    ///
7832    /// # Parameters
7833    ///
7834    /// * `params` - Host-supplied exact model selection IDs to allow for this running session. CAPI IDs are intersected with repository `.github/allowed_models.txt` policy; provider-qualified IDs remain exempt from repository-only policy but are restricted by this host list. Omit or pass null to clear the host restriction; an explicit empty or disjoint list is rejected. Validation and pre-selection fallback failures preserve the previous restriction. Failures after a fallback selection commits retain the new restriction and selected model; callers should inspect current session state after such an error.
7835    ///
7836    /// # Returns
7837    ///
7838    /// The applied host allowlist and effective session model policy after intersection.
7839    ///
7840    /// <div class="warning">
7841    ///
7842    /// **Experimental.** This API is part of an experimental wire-protocol surface
7843    /// and may change or be removed in future SDK or CLI releases. Pin both the
7844    /// SDK and CLI versions if your code depends on it.
7845    ///
7846    /// </div>
7847    pub async fn set_allowed_models(
7848        &self,
7849        params: ModelSetAllowedModelsRequest,
7850    ) -> Result<ModelSetAllowedModelsResult, Error> {
7851        let mut wire_params = serde_json::to_value(params)?;
7852        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7853        let _value = self
7854            .session
7855            .client()
7856            .call(
7857                rpc_methods::SESSION_MODEL_SETALLOWEDMODELS,
7858                Some(wire_params),
7859            )
7860            .await?;
7861        Ok(serde_json::from_value(_value)?)
7862    }
7863
7864    /// Updates the session's reasoning effort without changing the selected model.
7865    ///
7866    /// Wire method: `session.model.setReasoningEffort`.
7867    ///
7868    /// # Parameters
7869    ///
7870    /// * `params` - Reasoning effort level to apply to the currently selected model.
7871    ///
7872    /// # Returns
7873    ///
7874    /// 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.
7875    ///
7876    /// <div class="warning">
7877    ///
7878    /// **Experimental.** This API is part of an experimental wire-protocol surface
7879    /// and may change or be removed in future SDK or CLI releases. Pin both the
7880    /// SDK and CLI versions if your code depends on it.
7881    ///
7882    /// </div>
7883    pub async fn set_reasoning_effort(
7884        &self,
7885        params: ModelSetReasoningEffortRequest,
7886    ) -> Result<ModelSetReasoningEffortResult, Error> {
7887        let mut wire_params = serde_json::to_value(params)?;
7888        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7889        let _value = self
7890            .session
7891            .client()
7892            .call(
7893                rpc_methods::SESSION_MODEL_SETREASONINGEFFORT,
7894                Some(wire_params),
7895            )
7896            .await?;
7897        Ok(serde_json::from_value(_value)?)
7898    }
7899
7900    /// 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.
7901    ///
7902    /// Wire method: `session.model.list`.
7903    ///
7904    /// # Returns
7905    ///
7906    /// The list of models available to this session.
7907    ///
7908    /// <div class="warning">
7909    ///
7910    /// **Experimental.** This API is part of an experimental wire-protocol surface
7911    /// and may change or be removed in future SDK or CLI releases. Pin both the
7912    /// SDK and CLI versions if your code depends on it.
7913    ///
7914    /// </div>
7915    pub async fn list(&self) -> Result<SessionModelList, Error> {
7916        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7917        let _value = self
7918            .session
7919            .client()
7920            .call(rpc_methods::SESSION_MODEL_LIST, Some(wire_params))
7921            .await?;
7922        Ok(serde_json::from_value(_value)?)
7923    }
7924
7925    /// 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.
7926    ///
7927    /// Wire method: `session.model.list`.
7928    ///
7929    /// # Parameters
7930    ///
7931    /// * `params` - Optional listing options.
7932    ///
7933    /// # Returns
7934    ///
7935    /// The list of models available to this session.
7936    ///
7937    /// <div class="warning">
7938    ///
7939    /// **Experimental.** This API is part of an experimental wire-protocol surface
7940    /// and may change or be removed in future SDK or CLI releases. Pin both the
7941    /// SDK and CLI versions if your code depends on it.
7942    ///
7943    /// </div>
7944    pub async fn list_with_params(
7945        &self,
7946        params: ModelListRequest,
7947    ) -> Result<SessionModelList, Error> {
7948        let mut wire_params = serde_json::to_value(params)?;
7949        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7950        let _value = self
7951            .session
7952            .client()
7953            .call(rpc_methods::SESSION_MODEL_LIST, Some(wire_params))
7954            .await?;
7955        Ok(serde_json::from_value(_value)?)
7956    }
7957}
7958
7959/// `session.name.*` RPCs.
7960#[derive(Clone, Copy)]
7961pub struct SessionRpcName<'a> {
7962    pub(crate) session: &'a Session,
7963}
7964
7965impl<'a> SessionRpcName<'a> {
7966    /// Gets the session's friendly name.
7967    ///
7968    /// Wire method: `session.name.get`.
7969    ///
7970    /// # Returns
7971    ///
7972    /// The session's friendly name, or null when not yet set.
7973    ///
7974    /// <div class="warning">
7975    ///
7976    /// **Experimental.** This API is part of an experimental wire-protocol surface
7977    /// and may change or be removed in future SDK or CLI releases. Pin both the
7978    /// SDK and CLI versions if your code depends on it.
7979    ///
7980    /// </div>
7981    pub async fn get(&self) -> Result<NameGetResult, Error> {
7982        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7983        let _value = self
7984            .session
7985            .client()
7986            .call(rpc_methods::SESSION_NAME_GET, Some(wire_params))
7987            .await?;
7988        Ok(serde_json::from_value(_value)?)
7989    }
7990
7991    /// Sets the session's friendly name.
7992    ///
7993    /// Wire method: `session.name.set`.
7994    ///
7995    /// # Parameters
7996    ///
7997    /// * `params` - New friendly name to apply to the session.
7998    ///
7999    /// <div class="warning">
8000    ///
8001    /// **Experimental.** This API is part of an experimental wire-protocol surface
8002    /// and may change or be removed in future SDK or CLI releases. Pin both the
8003    /// SDK and CLI versions if your code depends on it.
8004    ///
8005    /// </div>
8006    pub async fn set(&self, params: NameSetRequest) -> Result<(), Error> {
8007        let mut wire_params = serde_json::to_value(params)?;
8008        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8009        let _value = self
8010            .session
8011            .client()
8012            .call(rpc_methods::SESSION_NAME_SET, Some(wire_params))
8013            .await?;
8014        Ok(())
8015    }
8016
8017    /// Persists an auto-generated session summary as the session's name when no user-set name exists.
8018    ///
8019    /// Wire method: `session.name.setAuto`.
8020    ///
8021    /// # Parameters
8022    ///
8023    /// * `params` - Auto-generated session summary to apply as the session's name when no user-set name exists.
8024    ///
8025    /// # Returns
8026    ///
8027    /// Indicates whether the auto-generated summary was applied as the session's name.
8028    ///
8029    /// <div class="warning">
8030    ///
8031    /// **Experimental.** This API is part of an experimental wire-protocol surface
8032    /// and may change or be removed in future SDK or CLI releases. Pin both the
8033    /// SDK and CLI versions if your code depends on it.
8034    ///
8035    /// </div>
8036    pub async fn set_auto(&self, params: NameSetAutoRequest) -> Result<NameSetAutoResult, Error> {
8037        let mut wire_params = serde_json::to_value(params)?;
8038        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8039        let _value = self
8040            .session
8041            .client()
8042            .call(rpc_methods::SESSION_NAME_SETAUTO, Some(wire_params))
8043            .await?;
8044        Ok(serde_json::from_value(_value)?)
8045    }
8046}
8047
8048/// `session.options.*` RPCs.
8049#[derive(Clone, Copy)]
8050pub struct SessionRpcOptions<'a> {
8051    pub(crate) session: &'a Session,
8052}
8053
8054impl<'a> SessionRpcOptions<'a> {
8055    /// Patches the genuinely-mutable subset of session options.
8056    ///
8057    /// Wire method: `session.options.update`.
8058    ///
8059    /// # Parameters
8060    ///
8061    /// * `params` - Patch of mutable session options to apply to the running session.
8062    ///
8063    /// # Returns
8064    ///
8065    /// Indicates whether the session options patch was applied successfully.
8066    ///
8067    /// <div class="warning">
8068    ///
8069    /// **Experimental.** This API is part of an experimental wire-protocol surface
8070    /// and may change or be removed in future SDK or CLI releases. Pin both the
8071    /// SDK and CLI versions if your code depends on it.
8072    ///
8073    /// </div>
8074    pub async fn update(
8075        &self,
8076        params: SessionUpdateOptionsParams,
8077    ) -> Result<SessionUpdateOptionsResult, Error> {
8078        let mut wire_params = serde_json::to_value(params)?;
8079        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8080        let _value = self
8081            .session
8082            .client()
8083            .call(rpc_methods::SESSION_OPTIONS_UPDATE, Some(wire_params))
8084            .await?;
8085        Ok(serde_json::from_value(_value)?)
8086    }
8087}
8088
8089/// `session.permissions.*` RPCs.
8090#[derive(Clone, Copy)]
8091pub struct SessionRpcPermissions<'a> {
8092    pub(crate) session: &'a Session,
8093}
8094
8095impl<'a> SessionRpcPermissions<'a> {
8096    /// `session.permissions.folderTrust.*` sub-namespace.
8097    pub fn folder_trust(&self) -> SessionRpcPermissionsFolderTrust<'a> {
8098        SessionRpcPermissionsFolderTrust {
8099            session: self.session,
8100        }
8101    }
8102
8103    /// `session.permissions.locations.*` sub-namespace.
8104    pub fn locations(&self) -> SessionRpcPermissionsLocations<'a> {
8105        SessionRpcPermissionsLocations {
8106            session: self.session,
8107        }
8108    }
8109
8110    /// `session.permissions.paths.*` sub-namespace.
8111    pub fn paths(&self) -> SessionRpcPermissionsPaths<'a> {
8112        SessionRpcPermissionsPaths {
8113            session: self.session,
8114        }
8115    }
8116
8117    /// `session.permissions.urls.*` sub-namespace.
8118    pub fn urls(&self) -> SessionRpcPermissionsUrls<'a> {
8119        SessionRpcPermissionsUrls {
8120            session: self.session,
8121        }
8122    }
8123
8124    /// Replaces selected permission policy fields (rules, paths, URLs, exclusions, allow-all flags) on the session.
8125    ///
8126    /// Wire method: `session.permissions.configure`.
8127    ///
8128    /// # Parameters
8129    ///
8130    /// * `params` - Patch of permission policy fields to apply (omit a field to leave it unchanged).
8131    ///
8132    /// # Returns
8133    ///
8134    /// Indicates whether the operation succeeded.
8135    ///
8136    /// <div class="warning">
8137    ///
8138    /// **Experimental.** This API is part of an experimental wire-protocol surface
8139    /// and may change or be removed in future SDK or CLI releases. Pin both the
8140    /// SDK and CLI versions if your code depends on it.
8141    ///
8142    /// </div>
8143    pub async fn configure(
8144        &self,
8145        params: PermissionsConfigureParams,
8146    ) -> Result<PermissionsConfigureResult, Error> {
8147        let mut wire_params = serde_json::to_value(params)?;
8148        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8149        let _value = self
8150            .session
8151            .client()
8152            .call(
8153                rpc_methods::SESSION_PERMISSIONS_CONFIGURE,
8154                Some(wire_params),
8155            )
8156            .await?;
8157        Ok(serde_json::from_value(_value)?)
8158    }
8159
8160    /// Provides a decision for a pending tool permission request.
8161    ///
8162    /// Wire method: `session.permissions.handlePendingPermissionRequest`.
8163    ///
8164    /// # Parameters
8165    ///
8166    /// * `params` - Pending permission request ID and the decision to apply (approve/reject and scope).
8167    ///
8168    /// # Returns
8169    ///
8170    /// Indicates whether the permission decision was applied; false when the request was already resolved.
8171    ///
8172    /// <div class="warning">
8173    ///
8174    /// **Experimental.** This API is part of an experimental wire-protocol surface
8175    /// and may change or be removed in future SDK or CLI releases. Pin both the
8176    /// SDK and CLI versions if your code depends on it.
8177    ///
8178    /// </div>
8179    pub async fn handle_pending_permission_request(
8180        &self,
8181        params: PermissionDecisionRequest,
8182    ) -> Result<PermissionRequestResult, Error> {
8183        let mut wire_params = serde_json::to_value(params)?;
8184        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8185        let _value = self
8186            .session
8187            .client()
8188            .call(
8189                rpc_methods::SESSION_PERMISSIONS_HANDLEPENDINGPERMISSIONREQUEST,
8190                Some(wire_params),
8191            )
8192            .await?;
8193        Ok(serde_json::from_value(_value)?)
8194    }
8195
8196    /// Reconstructs the set of pending tool permission requests from the session's event history.
8197    ///
8198    /// Wire method: `session.permissions.pendingRequests`.
8199    ///
8200    /// # Returns
8201    ///
8202    /// List of pending permission requests reconstructed from event history.
8203    ///
8204    /// <div class="warning">
8205    ///
8206    /// **Experimental.** This API is part of an experimental wire-protocol surface
8207    /// and may change or be removed in future SDK or CLI releases. Pin both the
8208    /// SDK and CLI versions if your code depends on it.
8209    ///
8210    /// </div>
8211    pub async fn pending_requests(&self) -> Result<PendingPermissionRequestList, Error> {
8212        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8213        let _value = self
8214            .session
8215            .client()
8216            .call(
8217                rpc_methods::SESSION_PERMISSIONS_PENDINGREQUESTS,
8218                Some(wire_params),
8219            )
8220            .await?;
8221        Ok(serde_json::from_value(_value)?)
8222    }
8223
8224    /// Enables or disables automatic approval of tool permission requests for the session.
8225    ///
8226    /// Wire method: `session.permissions.setApproveAll`.
8227    ///
8228    /// # Parameters
8229    ///
8230    /// * `params` - Allow-all toggle for tool permission requests, with an optional telemetry source.
8231    ///
8232    /// # Returns
8233    ///
8234    /// Indicates whether the operation succeeded.
8235    ///
8236    /// <div class="warning">
8237    ///
8238    /// **Experimental.** This API is part of an experimental wire-protocol surface
8239    /// and may change or be removed in future SDK or CLI releases. Pin both the
8240    /// SDK and CLI versions if your code depends on it.
8241    ///
8242    /// </div>
8243    pub async fn set_approve_all(
8244        &self,
8245        params: PermissionsSetApproveAllRequest,
8246    ) -> Result<PermissionsSetApproveAllResult, Error> {
8247        let mut wire_params = serde_json::to_value(params)?;
8248        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8249        let _value = self
8250            .session
8251            .client()
8252            .call(
8253                rpc_methods::SESSION_PERMISSIONS_SETAPPROVEALL,
8254                Some(wire_params),
8255            )
8256            .await?;
8257        Ok(serde_json::from_value(_value)?)
8258    }
8259
8260    /// Sets the permission mode for the session. `manual` follows the normal approval flow, `assisted` attaches LLM safety recommendations, and `allow-all` automatically approves permission requests. The result returns the authoritative post-mutation mode so callers can update local state without racing the `session.permissions_changed` notification.
8261    ///
8262    /// Wire method: `session.permissions.setMode`.
8263    ///
8264    /// # Parameters
8265    ///
8266    /// * `params` - Permission mode to apply for the session.
8267    ///
8268    /// # Returns
8269    ///
8270    /// Indicates whether the requested permission mode was applied and reports the authoritative post-mutation mode.
8271    ///
8272    /// <div class="warning">
8273    ///
8274    /// **Experimental.** This API is part of an experimental wire-protocol surface
8275    /// and may change or be removed in future SDK or CLI releases. Pin both the
8276    /// SDK and CLI versions if your code depends on it.
8277    ///
8278    /// </div>
8279    pub async fn set_mode(
8280        &self,
8281        params: PermissionsSetModeRequest,
8282    ) -> Result<PermissionsSetModeResult, Error> {
8283        let mut wire_params = serde_json::to_value(params)?;
8284        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8285        let _value = self
8286            .session
8287            .client()
8288            .call(rpc_methods::SESSION_PERMISSIONS_SETMODE, Some(wire_params))
8289            .await?;
8290        Ok(serde_json::from_value(_value)?)
8291    }
8292
8293    /// Returns the current permission mode for the session.
8294    ///
8295    /// Wire method: `session.permissions.getMode`.
8296    ///
8297    /// # Returns
8298    ///
8299    /// Current permission mode.
8300    ///
8301    /// <div class="warning">
8302    ///
8303    /// **Experimental.** This API is part of an experimental wire-protocol surface
8304    /// and may change or be removed in future SDK or CLI releases. Pin both the
8305    /// SDK and CLI versions if your code depends on it.
8306    ///
8307    /// </div>
8308    pub async fn get_mode(&self) -> Result<PermissionsGetModeResult, Error> {
8309        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8310        let _value = self
8311            .session
8312            .client()
8313            .call(rpc_methods::SESSION_PERMISSIONS_GETMODE, Some(wire_params))
8314            .await?;
8315        Ok(serde_json::from_value(_value)?)
8316    }
8317
8318    /// Adds or removes session-scoped or location-scoped permission rules.
8319    ///
8320    /// Wire method: `session.permissions.modifyRules`.
8321    ///
8322    /// # Parameters
8323    ///
8324    /// * `params` - Scope and add/remove instructions for modifying session- or location-scoped permission rules.
8325    ///
8326    /// # Returns
8327    ///
8328    /// Indicates whether the operation succeeded.
8329    ///
8330    /// <div class="warning">
8331    ///
8332    /// **Experimental.** This API is part of an experimental wire-protocol surface
8333    /// and may change or be removed in future SDK or CLI releases. Pin both the
8334    /// SDK and CLI versions if your code depends on it.
8335    ///
8336    /// </div>
8337    pub async fn modify_rules(
8338        &self,
8339        params: PermissionsModifyRulesParams,
8340    ) -> Result<PermissionsModifyRulesResult, Error> {
8341        let mut wire_params = serde_json::to_value(params)?;
8342        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8343        let _value = self
8344            .session
8345            .client()
8346            .call(
8347                rpc_methods::SESSION_PERMISSIONS_MODIFYRULES,
8348                Some(wire_params),
8349            )
8350            .await?;
8351        Ok(serde_json::from_value(_value)?)
8352    }
8353
8354    /// Sets whether the client wants permission prompts bridged into session events.
8355    ///
8356    /// Wire method: `session.permissions.setRequired`.
8357    ///
8358    /// # Parameters
8359    ///
8360    /// * `params` - Toggles whether permission prompts should be bridged into session events for this client.
8361    ///
8362    /// # Returns
8363    ///
8364    /// Indicates whether the operation succeeded.
8365    ///
8366    /// <div class="warning">
8367    ///
8368    /// **Experimental.** This API is part of an experimental wire-protocol surface
8369    /// and may change or be removed in future SDK or CLI releases. Pin both the
8370    /// SDK and CLI versions if your code depends on it.
8371    ///
8372    /// </div>
8373    pub async fn set_required(
8374        &self,
8375        params: PermissionsSetRequiredRequest,
8376    ) -> Result<PermissionsSetRequiredResult, Error> {
8377        let mut wire_params = serde_json::to_value(params)?;
8378        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8379        let _value = self
8380            .session
8381            .client()
8382            .call(
8383                rpc_methods::SESSION_PERMISSIONS_SETREQUIRED,
8384                Some(wire_params),
8385            )
8386            .await?;
8387        Ok(serde_json::from_value(_value)?)
8388    }
8389
8390    /// Clears session-scoped tool permission approvals.
8391    ///
8392    /// Wire method: `session.permissions.resetSessionApprovals`.
8393    ///
8394    /// # Parameters
8395    ///
8396    /// * `params` - Clears session-scoped tool permission approvals, and optionally the location-scoped ones.
8397    ///
8398    /// # Returns
8399    ///
8400    /// Indicates whether the operation succeeded.
8401    ///
8402    /// <div class="warning">
8403    ///
8404    /// **Experimental.** This API is part of an experimental wire-protocol surface
8405    /// and may change or be removed in future SDK or CLI releases. Pin both the
8406    /// SDK and CLI versions if your code depends on it.
8407    ///
8408    /// </div>
8409    pub async fn reset_session_approvals(
8410        &self,
8411        params: PermissionsResetSessionApprovalsRequest,
8412    ) -> Result<PermissionsResetSessionApprovalsResult, Error> {
8413        let mut wire_params = serde_json::to_value(params)?;
8414        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8415        let _value = self
8416            .session
8417            .client()
8418            .call(
8419                rpc_methods::SESSION_PERMISSIONS_RESETSESSIONAPPROVALS,
8420                Some(wire_params),
8421            )
8422            .await?;
8423        Ok(serde_json::from_value(_value)?)
8424    }
8425
8426    /// Notifies the runtime that a permission prompt UI has been shown to the user.
8427    ///
8428    /// Wire method: `session.permissions.notifyPromptShown`.
8429    ///
8430    /// # Parameters
8431    ///
8432    /// * `params` - Notification payload describing the permission prompt that the client just rendered.
8433    ///
8434    /// # Returns
8435    ///
8436    /// Indicates whether the operation succeeded.
8437    ///
8438    /// <div class="warning">
8439    ///
8440    /// **Experimental.** This API is part of an experimental wire-protocol surface
8441    /// and may change or be removed in future SDK or CLI releases. Pin both the
8442    /// SDK and CLI versions if your code depends on it.
8443    ///
8444    /// </div>
8445    pub async fn notify_prompt_shown(
8446        &self,
8447        params: PermissionPromptShownNotification,
8448    ) -> Result<PermissionsNotifyPromptShownResult, Error> {
8449        let mut wire_params = serde_json::to_value(params)?;
8450        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8451        let _value = self
8452            .session
8453            .client()
8454            .call(
8455                rpc_methods::SESSION_PERMISSIONS_NOTIFYPROMPTSHOWN,
8456                Some(wire_params),
8457            )
8458            .await?;
8459        Ok(serde_json::from_value(_value)?)
8460    }
8461}
8462
8463/// `session.permissions.folderTrust.*` RPCs.
8464#[derive(Clone, Copy)]
8465pub struct SessionRpcPermissionsFolderTrust<'a> {
8466    pub(crate) session: &'a Session,
8467}
8468
8469impl<'a> SessionRpcPermissionsFolderTrust<'a> {
8470    /// Reports whether a folder is trusted according to the user's folder trust state.
8471    ///
8472    /// Wire method: `session.permissions.folderTrust.isTrusted`.
8473    ///
8474    /// # Parameters
8475    ///
8476    /// * `params` - Folder path to check for trust.
8477    ///
8478    /// # Returns
8479    ///
8480    /// Folder trust check result.
8481    ///
8482    /// <div class="warning">
8483    ///
8484    /// **Experimental.** This API is part of an experimental wire-protocol surface
8485    /// and may change or be removed in future SDK or CLI releases. Pin both the
8486    /// SDK and CLI versions if your code depends on it.
8487    ///
8488    /// </div>
8489    pub async fn is_trusted(
8490        &self,
8491        params: FolderTrustCheckParams,
8492    ) -> Result<FolderTrustCheckResult, Error> {
8493        let mut wire_params = serde_json::to_value(params)?;
8494        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8495        let _value = self
8496            .session
8497            .client()
8498            .call(
8499                rpc_methods::SESSION_PERMISSIONS_FOLDERTRUST_ISTRUSTED,
8500                Some(wire_params),
8501            )
8502            .await?;
8503        Ok(serde_json::from_value(_value)?)
8504    }
8505
8506    /// Adds a folder to the user's trusted folders list.
8507    ///
8508    /// Wire method: `session.permissions.folderTrust.addTrusted`.
8509    ///
8510    /// # Parameters
8511    ///
8512    /// * `params` - Folder path to add to trusted folders.
8513    ///
8514    /// # Returns
8515    ///
8516    /// Indicates whether the operation succeeded.
8517    ///
8518    /// <div class="warning">
8519    ///
8520    /// **Experimental.** This API is part of an experimental wire-protocol surface
8521    /// and may change or be removed in future SDK or CLI releases. Pin both the
8522    /// SDK and CLI versions if your code depends on it.
8523    ///
8524    /// </div>
8525    pub async fn add_trusted(
8526        &self,
8527        params: FolderTrustAddParams,
8528    ) -> Result<PermissionsFolderTrustAddTrustedResult, Error> {
8529        let mut wire_params = serde_json::to_value(params)?;
8530        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8531        let _value = self
8532            .session
8533            .client()
8534            .call(
8535                rpc_methods::SESSION_PERMISSIONS_FOLDERTRUST_ADDTRUSTED,
8536                Some(wire_params),
8537            )
8538            .await?;
8539        Ok(serde_json::from_value(_value)?)
8540    }
8541}
8542
8543/// `session.permissions.locations.*` RPCs.
8544#[derive(Clone, Copy)]
8545pub struct SessionRpcPermissionsLocations<'a> {
8546    pub(crate) session: &'a Session,
8547}
8548
8549impl<'a> SessionRpcPermissionsLocations<'a> {
8550    /// Resolves the permission location key and type for a working directory.
8551    ///
8552    /// Wire method: `session.permissions.locations.resolve`.
8553    ///
8554    /// # Parameters
8555    ///
8556    /// * `params` - Working directory to resolve into a location-permissions key.
8557    ///
8558    /// # Returns
8559    ///
8560    /// Resolved location-permissions key and type.
8561    ///
8562    /// <div class="warning">
8563    ///
8564    /// **Experimental.** This API is part of an experimental wire-protocol surface
8565    /// and may change or be removed in future SDK or CLI releases. Pin both the
8566    /// SDK and CLI versions if your code depends on it.
8567    ///
8568    /// </div>
8569    pub async fn resolve(
8570        &self,
8571        params: PermissionLocationResolveParams,
8572    ) -> Result<PermissionLocationResolveResult, Error> {
8573        let mut wire_params = serde_json::to_value(params)?;
8574        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8575        let _value = self
8576            .session
8577            .client()
8578            .call(
8579                rpc_methods::SESSION_PERMISSIONS_LOCATIONS_RESOLVE,
8580                Some(wire_params),
8581            )
8582            .await?;
8583        Ok(serde_json::from_value(_value)?)
8584    }
8585
8586    /// Applies persisted location-scoped tool approvals and allowed directories for a working directory to this session's permission service.
8587    ///
8588    /// Wire method: `session.permissions.locations.apply`.
8589    ///
8590    /// # Parameters
8591    ///
8592    /// * `params` - Working directory to load persisted location permissions for.
8593    ///
8594    /// # Returns
8595    ///
8596    /// Summary of persisted location permissions applied to the session.
8597    ///
8598    /// <div class="warning">
8599    ///
8600    /// **Experimental.** This API is part of an experimental wire-protocol surface
8601    /// and may change or be removed in future SDK or CLI releases. Pin both the
8602    /// SDK and CLI versions if your code depends on it.
8603    ///
8604    /// </div>
8605    pub async fn apply(
8606        &self,
8607        params: PermissionLocationApplyParams,
8608    ) -> Result<PermissionLocationApplyResult, Error> {
8609        let mut wire_params = serde_json::to_value(params)?;
8610        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8611        let _value = self
8612            .session
8613            .client()
8614            .call(
8615                rpc_methods::SESSION_PERMISSIONS_LOCATIONS_APPLY,
8616                Some(wire_params),
8617            )
8618            .await?;
8619        Ok(serde_json::from_value(_value)?)
8620    }
8621
8622    /// Persists a tool approval for a permission location and applies its rules to this session's live permission service.
8623    ///
8624    /// Wire method: `session.permissions.locations.addToolApproval`.
8625    ///
8626    /// # Parameters
8627    ///
8628    /// * `params` - Location-scoped tool approval to persist.
8629    ///
8630    /// # Returns
8631    ///
8632    /// Indicates whether the operation succeeded.
8633    ///
8634    /// <div class="warning">
8635    ///
8636    /// **Experimental.** This API is part of an experimental wire-protocol surface
8637    /// and may change or be removed in future SDK or CLI releases. Pin both the
8638    /// SDK and CLI versions if your code depends on it.
8639    ///
8640    /// </div>
8641    pub async fn add_tool_approval(
8642        &self,
8643        params: PermissionLocationAddToolApprovalParams,
8644    ) -> Result<PermissionsLocationsAddToolApprovalResult, Error> {
8645        let mut wire_params = serde_json::to_value(params)?;
8646        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8647        let _value = self
8648            .session
8649            .client()
8650            .call(
8651                rpc_methods::SESSION_PERMISSIONS_LOCATIONS_ADDTOOLAPPROVAL,
8652                Some(wire_params),
8653            )
8654            .await?;
8655        Ok(serde_json::from_value(_value)?)
8656    }
8657}
8658
8659/// `session.permissions.paths.*` RPCs.
8660#[derive(Clone, Copy)]
8661pub struct SessionRpcPermissionsPaths<'a> {
8662    pub(crate) session: &'a Session,
8663}
8664
8665impl<'a> SessionRpcPermissionsPaths<'a> {
8666    /// Returns the session's allowed directories and primary working directory.
8667    ///
8668    /// Wire method: `session.permissions.paths.list`.
8669    ///
8670    /// # Returns
8671    ///
8672    /// Snapshot of the session's allow-listed directories and primary working directory.
8673    ///
8674    /// <div class="warning">
8675    ///
8676    /// **Experimental.** This API is part of an experimental wire-protocol surface
8677    /// and may change or be removed in future SDK or CLI releases. Pin both the
8678    /// SDK and CLI versions if your code depends on it.
8679    ///
8680    /// </div>
8681    pub async fn list(&self) -> Result<PermissionPathsList, Error> {
8682        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8683        let _value = self
8684            .session
8685            .client()
8686            .call(
8687                rpc_methods::SESSION_PERMISSIONS_PATHS_LIST,
8688                Some(wire_params),
8689            )
8690            .await?;
8691        Ok(serde_json::from_value(_value)?)
8692    }
8693
8694    /// Adds a directory to the session's allow-list and activates conventional skill and agent definitions under it.
8695    ///
8696    /// Wire method: `session.permissions.paths.add`.
8697    ///
8698    /// # Parameters
8699    ///
8700    /// * `params` - Directory path to add to the session's allowed directories.
8701    ///
8702    /// # Returns
8703    ///
8704    /// Indicates whether the operation succeeded.
8705    ///
8706    /// <div class="warning">
8707    ///
8708    /// **Experimental.** This API is part of an experimental wire-protocol surface
8709    /// and may change or be removed in future SDK or CLI releases. Pin both the
8710    /// SDK and CLI versions if your code depends on it.
8711    ///
8712    /// </div>
8713    pub async fn add(
8714        &self,
8715        params: PermissionPathsAddParams,
8716    ) -> Result<PermissionsPathsAddResult, Error> {
8717        let mut wire_params = serde_json::to_value(params)?;
8718        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8719        let _value = self
8720            .session
8721            .client()
8722            .call(
8723                rpc_methods::SESSION_PERMISSIONS_PATHS_ADD,
8724                Some(wire_params),
8725            )
8726            .await?;
8727        Ok(serde_json::from_value(_value)?)
8728    }
8729
8730    /// Updates the session's primary working directory used by the permission policy.
8731    ///
8732    /// Wire method: `session.permissions.paths.updatePrimary`.
8733    ///
8734    /// # Parameters
8735    ///
8736    /// * `params` - Directory path to set as the session's new primary working directory.
8737    ///
8738    /// # Returns
8739    ///
8740    /// Indicates whether the operation succeeded.
8741    ///
8742    /// <div class="warning">
8743    ///
8744    /// **Experimental.** This API is part of an experimental wire-protocol surface
8745    /// and may change or be removed in future SDK or CLI releases. Pin both the
8746    /// SDK and CLI versions if your code depends on it.
8747    ///
8748    /// </div>
8749    pub async fn update_primary(
8750        &self,
8751        params: PermissionPathsUpdatePrimaryParams,
8752    ) -> Result<PermissionsPathsUpdatePrimaryResult, Error> {
8753        let mut wire_params = serde_json::to_value(params)?;
8754        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8755        let _value = self
8756            .session
8757            .client()
8758            .call(
8759                rpc_methods::SESSION_PERMISSIONS_PATHS_UPDATEPRIMARY,
8760                Some(wire_params),
8761            )
8762            .await?;
8763        Ok(serde_json::from_value(_value)?)
8764    }
8765
8766    /// Reports whether a path falls within any of the session's allowed directories.
8767    ///
8768    /// Wire method: `session.permissions.paths.isPathWithinAllowedDirectories`.
8769    ///
8770    /// # Parameters
8771    ///
8772    /// * `params` - Path to evaluate against the session's allowed directories.
8773    ///
8774    /// # Returns
8775    ///
8776    /// Indicates whether the supplied path is within the session's allowed directories.
8777    ///
8778    /// <div class="warning">
8779    ///
8780    /// **Experimental.** This API is part of an experimental wire-protocol surface
8781    /// and may change or be removed in future SDK or CLI releases. Pin both the
8782    /// SDK and CLI versions if your code depends on it.
8783    ///
8784    /// </div>
8785    pub async fn is_path_within_allowed_directories(
8786        &self,
8787        params: PermissionPathsAllowedCheckParams,
8788    ) -> Result<PermissionPathsAllowedCheckResult, Error> {
8789        let mut wire_params = serde_json::to_value(params)?;
8790        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8791        let _value = self
8792            .session
8793            .client()
8794            .call(
8795                rpc_methods::SESSION_PERMISSIONS_PATHS_ISPATHWITHINALLOWEDDIRECTORIES,
8796                Some(wire_params),
8797            )
8798            .await?;
8799        Ok(serde_json::from_value(_value)?)
8800    }
8801
8802    /// Reports whether a path falls within the session's workspace (primary) directory.
8803    ///
8804    /// Wire method: `session.permissions.paths.isPathWithinWorkspace`.
8805    ///
8806    /// # Parameters
8807    ///
8808    /// * `params` - Path to evaluate against the session's workspace (primary) directory.
8809    ///
8810    /// # Returns
8811    ///
8812    /// Indicates whether the supplied path is within the session's workspace directory.
8813    ///
8814    /// <div class="warning">
8815    ///
8816    /// **Experimental.** This API is part of an experimental wire-protocol surface
8817    /// and may change or be removed in future SDK or CLI releases. Pin both the
8818    /// SDK and CLI versions if your code depends on it.
8819    ///
8820    /// </div>
8821    pub async fn is_path_within_workspace(
8822        &self,
8823        params: PermissionPathsWorkspaceCheckParams,
8824    ) -> Result<PermissionPathsWorkspaceCheckResult, Error> {
8825        let mut wire_params = serde_json::to_value(params)?;
8826        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8827        let _value = self
8828            .session
8829            .client()
8830            .call(
8831                rpc_methods::SESSION_PERMISSIONS_PATHS_ISPATHWITHINWORKSPACE,
8832                Some(wire_params),
8833            )
8834            .await?;
8835        Ok(serde_json::from_value(_value)?)
8836    }
8837}
8838
8839/// `session.permissions.urls.*` RPCs.
8840#[derive(Clone, Copy)]
8841pub struct SessionRpcPermissionsUrls<'a> {
8842    pub(crate) session: &'a Session,
8843}
8844
8845impl<'a> SessionRpcPermissionsUrls<'a> {
8846    /// Toggles the runtime's URL-permission policy between unrestricted and restricted modes.
8847    ///
8848    /// Wire method: `session.permissions.urls.setUnrestrictedMode`.
8849    ///
8850    /// # Parameters
8851    ///
8852    /// * `params` - Whether the URL-permission policy should run in unrestricted mode.
8853    ///
8854    /// # Returns
8855    ///
8856    /// Indicates whether the operation succeeded.
8857    ///
8858    /// <div class="warning">
8859    ///
8860    /// **Experimental.** This API is part of an experimental wire-protocol surface
8861    /// and may change or be removed in future SDK or CLI releases. Pin both the
8862    /// SDK and CLI versions if your code depends on it.
8863    ///
8864    /// </div>
8865    pub async fn set_unrestricted_mode(
8866        &self,
8867        params: PermissionUrlsSetUnrestrictedModeParams,
8868    ) -> Result<PermissionsUrlsSetUnrestrictedModeResult, Error> {
8869        let mut wire_params = serde_json::to_value(params)?;
8870        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8871        let _value = self
8872            .session
8873            .client()
8874            .call(
8875                rpc_methods::SESSION_PERMISSIONS_URLS_SETUNRESTRICTEDMODE,
8876                Some(wire_params),
8877            )
8878            .await?;
8879        Ok(serde_json::from_value(_value)?)
8880    }
8881}
8882
8883/// `session.plan.*` RPCs.
8884#[derive(Clone, Copy)]
8885pub struct SessionRpcPlan<'a> {
8886    pub(crate) session: &'a Session,
8887}
8888
8889impl<'a> SessionRpcPlan<'a> {
8890    /// Reads the session plan file from the workspace.
8891    ///
8892    /// Wire method: `session.plan.read`.
8893    ///
8894    /// # Returns
8895    ///
8896    /// Existence, contents, and resolved path of the session plan file.
8897    ///
8898    /// <div class="warning">
8899    ///
8900    /// **Experimental.** This API is part of an experimental wire-protocol surface
8901    /// and may change or be removed in future SDK or CLI releases. Pin both the
8902    /// SDK and CLI versions if your code depends on it.
8903    ///
8904    /// </div>
8905    pub async fn read(&self) -> Result<PlanReadResult, Error> {
8906        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8907        let _value = self
8908            .session
8909            .client()
8910            .call(rpc_methods::SESSION_PLAN_READ, Some(wire_params))
8911            .await?;
8912        Ok(serde_json::from_value(_value)?)
8913    }
8914
8915    /// Writes new content to the session plan file.
8916    ///
8917    /// Wire method: `session.plan.update`.
8918    ///
8919    /// # Parameters
8920    ///
8921    /// * `params` - Replacement contents to write to the session plan file.
8922    ///
8923    /// <div class="warning">
8924    ///
8925    /// **Experimental.** This API is part of an experimental wire-protocol surface
8926    /// and may change or be removed in future SDK or CLI releases. Pin both the
8927    /// SDK and CLI versions if your code depends on it.
8928    ///
8929    /// </div>
8930    pub async fn update(&self, params: PlanUpdateRequest) -> Result<(), Error> {
8931        let mut wire_params = serde_json::to_value(params)?;
8932        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8933        let _value = self
8934            .session
8935            .client()
8936            .call(rpc_methods::SESSION_PLAN_UPDATE, Some(wire_params))
8937            .await?;
8938        Ok(())
8939    }
8940
8941    /// Deletes the session plan file from the workspace.
8942    ///
8943    /// Wire method: `session.plan.delete`.
8944    ///
8945    /// <div class="warning">
8946    ///
8947    /// **Experimental.** This API is part of an experimental wire-protocol surface
8948    /// and may change or be removed in future SDK or CLI releases. Pin both the
8949    /// SDK and CLI versions if your code depends on it.
8950    ///
8951    /// </div>
8952    pub async fn delete(&self) -> Result<(), Error> {
8953        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8954        let _value = self
8955            .session
8956            .client()
8957            .call(rpc_methods::SESSION_PLAN_DELETE, Some(wire_params))
8958            .await?;
8959        Ok(())
8960    }
8961
8962    /// Reads todo rows from the session SQL database for plan rendering.
8963    ///
8964    /// Wire method: `session.plan.readSqlTodos`.
8965    ///
8966    /// # Returns
8967    ///
8968    /// Todo rows read from the session SQL database. Empty when no session database is available.
8969    ///
8970    /// <div class="warning">
8971    ///
8972    /// **Experimental.** This API is part of an experimental wire-protocol surface
8973    /// and may change or be removed in future SDK or CLI releases. Pin both the
8974    /// SDK and CLI versions if your code depends on it.
8975    ///
8976    /// </div>
8977    pub async fn read_sql_todos(&self) -> Result<PlanReadSqlTodosResult, Error> {
8978        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8979        let _value = self
8980            .session
8981            .client()
8982            .call(rpc_methods::SESSION_PLAN_READSQLTODOS, Some(wire_params))
8983            .await?;
8984        Ok(serde_json::from_value(_value)?)
8985    }
8986
8987    /// 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.
8988    ///
8989    /// Wire method: `session.plan.readSqlTodosWithDependencies`.
8990    ///
8991    /// # Returns
8992    ///
8993    /// Todo rows + dependency edges read from the session SQL database.
8994    ///
8995    /// <div class="warning">
8996    ///
8997    /// **Experimental.** This API is part of an experimental wire-protocol surface
8998    /// and may change or be removed in future SDK or CLI releases. Pin both the
8999    /// SDK and CLI versions if your code depends on it.
9000    ///
9001    /// </div>
9002    pub async fn read_sql_todos_with_dependencies(
9003        &self,
9004    ) -> Result<PlanReadSqlTodosWithDependenciesResult, Error> {
9005        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9006        let _value = self
9007            .session
9008            .client()
9009            .call(
9010                rpc_methods::SESSION_PLAN_READSQLTODOSWITHDEPENDENCIES,
9011                Some(wire_params),
9012            )
9013            .await?;
9014        Ok(serde_json::from_value(_value)?)
9015    }
9016}
9017
9018/// `session.plugins.*` RPCs.
9019#[derive(Clone, Copy)]
9020pub struct SessionRpcPlugins<'a> {
9021    pub(crate) session: &'a Session,
9022}
9023
9024impl<'a> SessionRpcPlugins<'a> {
9025    /// `session.plugins.marketplaces.*` sub-namespace.
9026    pub fn marketplaces(&self) -> SessionRpcPluginsMarketplaces<'a> {
9027        SessionRpcPluginsMarketplaces {
9028            session: self.session,
9029        }
9030    }
9031
9032    /// Lists globally installed, live, built-in, and enterprise-managed desired plugins using the live session's authoritative account, working directory, and retained managed policy.
9033    ///
9034    /// Wire method: `session.plugins.list`.
9035    ///
9036    /// # Returns
9037    ///
9038    /// Plugins installed for the session, with their enabled state and version metadata.
9039    ///
9040    /// <div class="warning">
9041    ///
9042    /// **Experimental.** This API is part of an experimental wire-protocol surface
9043    /// and may change or be removed in future SDK or CLI releases. Pin both the
9044    /// SDK and CLI versions if your code depends on it.
9045    ///
9046    /// </div>
9047    pub async fn list(&self) -> Result<PluginList, Error> {
9048        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9049        let _value = self
9050            .session
9051            .client()
9052            .call(rpc_methods::SESSION_PLUGINS_LIST, Some(wire_params))
9053            .await?;
9054        Ok(serde_json::from_value(_value)?)
9055    }
9056
9057    /// Installs a plugin using the live session's authoritative account, working directory, and retained managed policy.
9058    ///
9059    /// Wire method: `session.plugins.install`.
9060    ///
9061    /// # Parameters
9062    ///
9063    /// * `params` - Plugin source resolved relative to the session's authoritative working directory.
9064    ///
9065    /// # Returns
9066    ///
9067    /// Result of installing a plugin.
9068    ///
9069    /// <div class="warning">
9070    ///
9071    /// **Experimental.** This API is part of an experimental wire-protocol surface
9072    /// and may change or be removed in future SDK or CLI releases. Pin both the
9073    /// SDK and CLI versions if your code depends on it.
9074    ///
9075    /// </div>
9076    pub async fn install(
9077        &self,
9078        params: SessionPluginsInstallRequest,
9079    ) -> Result<PluginInstallResult, Error> {
9080        let mut wire_params = serde_json::to_value(params)?;
9081        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9082        let _value = self
9083            .session
9084            .client()
9085            .call(rpc_methods::SESSION_PLUGINS_INSTALL, Some(wire_params))
9086            .await?;
9087        Ok(serde_json::from_value(_value)?)
9088    }
9089
9090    /// Uninstalls a plugin when permitted by the live session's retained managed policy.
9091    ///
9092    /// Wire method: `session.plugins.uninstall`.
9093    ///
9094    /// # Parameters
9095    ///
9096    /// * `params` - Name (or spec) of the plugin to uninstall.
9097    ///
9098    /// <div class="warning">
9099    ///
9100    /// **Experimental.** This API is part of an experimental wire-protocol surface
9101    /// and may change or be removed in future SDK or CLI releases. Pin both the
9102    /// SDK and CLI versions if your code depends on it.
9103    ///
9104    /// </div>
9105    pub async fn uninstall(&self, params: PluginsUninstallRequest) -> Result<(), Error> {
9106        let mut wire_params = serde_json::to_value(params)?;
9107        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9108        let _value = self
9109            .session
9110            .client()
9111            .call(rpc_methods::SESSION_PLUGINS_UNINSTALL, Some(wire_params))
9112            .await?;
9113        Ok(())
9114    }
9115
9116    /// Updates an installed plugin using the live session's authoritative account, working directory, and retained managed policy.
9117    ///
9118    /// Wire method: `session.plugins.update`.
9119    ///
9120    /// # Parameters
9121    ///
9122    /// * `params` - Name (or spec) of the plugin to update.
9123    ///
9124    /// # Returns
9125    ///
9126    /// Result of updating a single plugin.
9127    ///
9128    /// <div class="warning">
9129    ///
9130    /// **Experimental.** This API is part of an experimental wire-protocol surface
9131    /// and may change or be removed in future SDK or CLI releases. Pin both the
9132    /// SDK and CLI versions if your code depends on it.
9133    ///
9134    /// </div>
9135    pub async fn update(&self, params: PluginsUpdateRequest) -> Result<PluginUpdateResult, Error> {
9136        let mut wire_params = serde_json::to_value(params)?;
9137        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9138        let _value = self
9139            .session
9140            .client()
9141            .call(rpc_methods::SESSION_PLUGINS_UPDATE, Some(wire_params))
9142            .await?;
9143        Ok(serde_json::from_value(_value)?)
9144    }
9145
9146    /// Enables installed plugins when permitted by the live session's retained managed policy.
9147    ///
9148    /// Wire method: `session.plugins.enable`.
9149    ///
9150    /// # Parameters
9151    ///
9152    /// * `params` - Plugin names (or specs) to enable in the session's authoritative working directory.
9153    ///
9154    /// <div class="warning">
9155    ///
9156    /// **Experimental.** This API is part of an experimental wire-protocol surface
9157    /// and may change or be removed in future SDK or CLI releases. Pin both the
9158    /// SDK and CLI versions if your code depends on it.
9159    ///
9160    /// </div>
9161    pub async fn enable(&self, params: SessionPluginsEnableRequest) -> Result<(), Error> {
9162        let mut wire_params = serde_json::to_value(params)?;
9163        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9164        let _value = self
9165            .session
9166            .client()
9167            .call(rpc_methods::SESSION_PLUGINS_ENABLE, Some(wire_params))
9168            .await?;
9169        Ok(())
9170    }
9171
9172    /// Disables installed plugins when permitted by the live session's retained managed policy.
9173    ///
9174    /// Wire method: `session.plugins.disable`.
9175    ///
9176    /// # Parameters
9177    ///
9178    /// * `params` - Plugin names (or specs) to disable in the session's authoritative working directory.
9179    ///
9180    /// <div class="warning">
9181    ///
9182    /// **Experimental.** This API is part of an experimental wire-protocol surface
9183    /// and may change or be removed in future SDK or CLI releases. Pin both the
9184    /// SDK and CLI versions if your code depends on it.
9185    ///
9186    /// </div>
9187    pub async fn disable(&self, params: SessionPluginsDisableRequest) -> Result<(), Error> {
9188        let mut wire_params = serde_json::to_value(params)?;
9189        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9190        let _value = self
9191            .session
9192            .client()
9193            .call(rpc_methods::SESSION_PLUGINS_DISABLE, Some(wire_params))
9194            .await?;
9195        Ok(())
9196    }
9197
9198    /// 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.
9199    ///
9200    /// Wire method: `session.plugins.reload`.
9201    ///
9202    /// <div class="warning">
9203    ///
9204    /// **Experimental.** This API is part of an experimental wire-protocol surface
9205    /// and may change or be removed in future SDK or CLI releases. Pin both the
9206    /// SDK and CLI versions if your code depends on it.
9207    ///
9208    /// </div>
9209    pub async fn reload(&self) -> Result<(), Error> {
9210        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9211        let _value = self
9212            .session
9213            .client()
9214            .call(rpc_methods::SESSION_PLUGINS_RELOAD, Some(wire_params))
9215            .await?;
9216        Ok(())
9217    }
9218
9219    /// 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.
9220    ///
9221    /// Wire method: `session.plugins.reload`.
9222    ///
9223    /// # Parameters
9224    ///
9225    /// * `params` - Optional flags controlling which side effects the reload performs.
9226    ///
9227    /// <div class="warning">
9228    ///
9229    /// **Experimental.** This API is part of an experimental wire-protocol surface
9230    /// and may change or be removed in future SDK or CLI releases. Pin both the
9231    /// SDK and CLI versions if your code depends on it.
9232    ///
9233    /// </div>
9234    pub async fn reload_with_params(&self, params: PluginsReloadRequest) -> Result<(), Error> {
9235        let mut wire_params = serde_json::to_value(params)?;
9236        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9237        let _value = self
9238            .session
9239            .client()
9240            .call(rpc_methods::SESSION_PLUGINS_RELOAD, Some(wire_params))
9241            .await?;
9242        Ok(())
9243    }
9244}
9245
9246/// `session.plugins.marketplaces.*` RPCs.
9247#[derive(Clone, Copy)]
9248pub struct SessionRpcPluginsMarketplaces<'a> {
9249    pub(crate) session: &'a Session,
9250}
9251
9252impl<'a> SessionRpcPluginsMarketplaces<'a> {
9253    /// Lists registered and enterprise-managed desired marketplaces using the live session's retained policy.
9254    ///
9255    /// Wire method: `session.plugins.marketplaces.list`.
9256    ///
9257    /// # Returns
9258    ///
9259    /// All registered marketplaces, including built-in defaults.
9260    ///
9261    /// <div class="warning">
9262    ///
9263    /// **Experimental.** This API is part of an experimental wire-protocol surface
9264    /// and may change or be removed in future SDK or CLI releases. Pin both the
9265    /// SDK and CLI versions if your code depends on it.
9266    ///
9267    /// </div>
9268    pub async fn list(&self) -> Result<MarketplaceListResult, Error> {
9269        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9270        let _value = self
9271            .session
9272            .client()
9273            .call(
9274                rpc_methods::SESSION_PLUGINS_MARKETPLACES_LIST,
9275                Some(wire_params),
9276            )
9277            .await?;
9278        Ok(serde_json::from_value(_value)?)
9279    }
9280
9281    /// Adds a marketplace when permitted by the live session's retained managed policy.
9282    ///
9283    /// Wire method: `session.plugins.marketplaces.add`.
9284    ///
9285    /// # Parameters
9286    ///
9287    /// * `params` - Marketplace source and optional working directory for relative-path resolution.
9288    ///
9289    /// # Returns
9290    ///
9291    /// Result of registering a new marketplace.
9292    ///
9293    /// <div class="warning">
9294    ///
9295    /// **Experimental.** This API is part of an experimental wire-protocol surface
9296    /// and may change or be removed in future SDK or CLI releases. Pin both the
9297    /// SDK and CLI versions if your code depends on it.
9298    ///
9299    /// </div>
9300    pub async fn add(
9301        &self,
9302        params: PluginsMarketplacesAddRequest,
9303    ) -> Result<MarketplaceAddResult, Error> {
9304        let mut wire_params = serde_json::to_value(params)?;
9305        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9306        let _value = self
9307            .session
9308            .client()
9309            .call(
9310                rpc_methods::SESSION_PLUGINS_MARKETPLACES_ADD,
9311                Some(wire_params),
9312            )
9313            .await?;
9314        Ok(serde_json::from_value(_value)?)
9315    }
9316
9317    /// Removes a marketplace when permitted by the live session's retained managed policy.
9318    ///
9319    /// Wire method: `session.plugins.marketplaces.remove`.
9320    ///
9321    /// # Parameters
9322    ///
9323    /// * `params` - Name of the marketplace to remove and an optional force flag.
9324    ///
9325    /// # Returns
9326    ///
9327    /// Outcome of the remove attempt, including dependent-plugin info when applicable.
9328    ///
9329    /// <div class="warning">
9330    ///
9331    /// **Experimental.** This API is part of an experimental wire-protocol surface
9332    /// and may change or be removed in future SDK or CLI releases. Pin both the
9333    /// SDK and CLI versions if your code depends on it.
9334    ///
9335    /// </div>
9336    pub async fn remove(
9337        &self,
9338        params: PluginsMarketplacesRemoveRequest,
9339    ) -> Result<MarketplaceRemoveResult, Error> {
9340        let mut wire_params = serde_json::to_value(params)?;
9341        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9342        let _value = self
9343            .session
9344            .client()
9345            .call(
9346                rpc_methods::SESSION_PLUGINS_MARKETPLACES_REMOVE,
9347                Some(wire_params),
9348            )
9349            .await?;
9350        Ok(serde_json::from_value(_value)?)
9351    }
9352
9353    /// Browses a marketplace resolved through the live session's working directory and retained managed policy.
9354    ///
9355    /// Wire method: `session.plugins.marketplaces.browse`.
9356    ///
9357    /// # Parameters
9358    ///
9359    /// * `params` - Name of the marketplace whose plugin catalog to fetch.
9360    ///
9361    /// # Returns
9362    ///
9363    /// Plugins advertised by the marketplace.
9364    ///
9365    /// <div class="warning">
9366    ///
9367    /// **Experimental.** This API is part of an experimental wire-protocol surface
9368    /// and may change or be removed in future SDK or CLI releases. Pin both the
9369    /// SDK and CLI versions if your code depends on it.
9370    ///
9371    /// </div>
9372    pub async fn browse(
9373        &self,
9374        params: PluginsMarketplacesBrowseRequest,
9375    ) -> Result<MarketplaceBrowseResult, Error> {
9376        let mut wire_params = serde_json::to_value(params)?;
9377        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9378        let _value = self
9379            .session
9380            .client()
9381            .call(
9382                rpc_methods::SESSION_PLUGINS_MARKETPLACES_BROWSE,
9383                Some(wire_params),
9384            )
9385            .await?;
9386        Ok(serde_json::from_value(_value)?)
9387    }
9388
9389    /// Refreshes marketplaces resolved through the live session's working directory and retained managed policy.
9390    ///
9391    /// Wire method: `session.plugins.marketplaces.refresh`.
9392    ///
9393    /// # Returns
9394    ///
9395    /// Result of refreshing one or more marketplace catalogs.
9396    ///
9397    /// <div class="warning">
9398    ///
9399    /// **Experimental.** This API is part of an experimental wire-protocol surface
9400    /// and may change or be removed in future SDK or CLI releases. Pin both the
9401    /// SDK and CLI versions if your code depends on it.
9402    ///
9403    /// </div>
9404    pub async fn refresh(&self) -> Result<MarketplaceRefreshResult, Error> {
9405        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9406        let _value = self
9407            .session
9408            .client()
9409            .call(
9410                rpc_methods::SESSION_PLUGINS_MARKETPLACES_REFRESH,
9411                Some(wire_params),
9412            )
9413            .await?;
9414        Ok(serde_json::from_value(_value)?)
9415    }
9416
9417    /// Refreshes marketplaces resolved through the live session's working directory and retained managed policy.
9418    ///
9419    /// Wire method: `session.plugins.marketplaces.refresh`.
9420    ///
9421    /// # Parameters
9422    ///
9423    /// * `params` - Optional marketplace name; omit to refresh all.
9424    ///
9425    /// # Returns
9426    ///
9427    /// Result of refreshing one or more marketplace catalogs.
9428    ///
9429    /// <div class="warning">
9430    ///
9431    /// **Experimental.** This API is part of an experimental wire-protocol surface
9432    /// and may change or be removed in future SDK or CLI releases. Pin both the
9433    /// SDK and CLI versions if your code depends on it.
9434    ///
9435    /// </div>
9436    pub async fn refresh_with_params(
9437        &self,
9438        params: PluginsMarketplacesRefreshRequest,
9439    ) -> Result<MarketplaceRefreshResult, Error> {
9440        let mut wire_params = serde_json::to_value(params)?;
9441        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9442        let _value = self
9443            .session
9444            .client()
9445            .call(
9446                rpc_methods::SESSION_PLUGINS_MARKETPLACES_REFRESH,
9447                Some(wire_params),
9448            )
9449            .await?;
9450        Ok(serde_json::from_value(_value)?)
9451    }
9452}
9453
9454/// `session.provider.*` RPCs.
9455#[derive(Clone, Copy)]
9456pub struct SessionRpcProvider<'a> {
9457    pub(crate) session: &'a Session,
9458}
9459
9460impl<'a> SessionRpcProvider<'a> {
9461    /// 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.
9462    ///
9463    /// Wire method: `session.provider.getEndpoint`.
9464    ///
9465    /// # Returns
9466    ///
9467    /// A snapshot of the provider endpoint the session is currently configured to talk to.
9468    ///
9469    /// <div class="warning">
9470    ///
9471    /// **Experimental.** This API is part of an experimental wire-protocol surface
9472    /// and may change or be removed in future SDK or CLI releases. Pin both the
9473    /// SDK and CLI versions if your code depends on it.
9474    ///
9475    /// </div>
9476    pub async fn get_endpoint(&self) -> Result<ProviderEndpoint, Error> {
9477        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9478        let _value = self
9479            .session
9480            .client()
9481            .call(rpc_methods::SESSION_PROVIDER_GETENDPOINT, Some(wire_params))
9482            .await?;
9483        Ok(serde_json::from_value(_value)?)
9484    }
9485
9486    /// 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.
9487    ///
9488    /// Wire method: `session.provider.getEndpoint`.
9489    ///
9490    /// # Parameters
9491    ///
9492    /// * `params` - Optional model identifier to scope the endpoint snapshot to.
9493    ///
9494    /// # Returns
9495    ///
9496    /// A snapshot of the provider endpoint the session is currently configured to talk to.
9497    ///
9498    /// <div class="warning">
9499    ///
9500    /// **Experimental.** This API is part of an experimental wire-protocol surface
9501    /// and may change or be removed in future SDK or CLI releases. Pin both the
9502    /// SDK and CLI versions if your code depends on it.
9503    ///
9504    /// </div>
9505    pub async fn get_endpoint_with_params(
9506        &self,
9507        params: ProviderGetEndpointRequest,
9508    ) -> Result<ProviderEndpoint, Error> {
9509        let mut wire_params = serde_json::to_value(params)?;
9510        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9511        let _value = self
9512            .session
9513            .client()
9514            .call(rpc_methods::SESSION_PROVIDER_GETENDPOINT, Some(wire_params))
9515            .await?;
9516        Ok(serde_json::from_value(_value)?)
9517    }
9518
9519    /// 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.
9520    ///
9521    /// Wire method: `session.provider.add`.
9522    ///
9523    /// # Parameters
9524    ///
9525    /// * `params` - BYOK providers and/or models to add to the session's registry at runtime. Both fields are optional; provide providers, models, or both.
9526    ///
9527    /// # Returns
9528    ///
9529    /// The selectable model entries synthesized for the models added by this call.
9530    ///
9531    /// <div class="warning">
9532    ///
9533    /// **Experimental.** This API is part of an experimental wire-protocol surface
9534    /// and may change or be removed in future SDK or CLI releases. Pin both the
9535    /// SDK and CLI versions if your code depends on it.
9536    ///
9537    /// </div>
9538    pub async fn add(&self, params: ProviderAddRequest) -> Result<ProviderAddResult, Error> {
9539        let mut wire_params = serde_json::to_value(params)?;
9540        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9541        let _value = self
9542            .session
9543            .client()
9544            .call(rpc_methods::SESSION_PROVIDER_ADD, Some(wire_params))
9545            .await?;
9546        Ok(serde_json::from_value(_value)?)
9547    }
9548}
9549
9550/// `session.queue.*` RPCs.
9551#[derive(Clone, Copy)]
9552pub struct SessionRpcQueue<'a> {
9553    pub(crate) session: &'a Session,
9554}
9555
9556impl<'a> SessionRpcQueue<'a> {
9557    /// Returns the local session's pending user-facing queued items and steering messages.
9558    ///
9559    /// Wire method: `session.queue.pendingItems`.
9560    ///
9561    /// # Returns
9562    ///
9563    /// Snapshot of the session's pending queued items and immediate-steering messages.
9564    ///
9565    /// <div class="warning">
9566    ///
9567    /// **Experimental.** This API is part of an experimental wire-protocol surface
9568    /// and may change or be removed in future SDK or CLI releases. Pin both the
9569    /// SDK and CLI versions if your code depends on it.
9570    ///
9571    /// </div>
9572    pub async fn pending_items(&self) -> Result<QueuePendingItemsResult, Error> {
9573        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9574        let _value = self
9575            .session
9576            .client()
9577            .call(rpc_methods::SESSION_QUEUE_PENDINGITEMS, Some(wire_params))
9578            .await?;
9579        Ok(serde_json::from_value(_value)?)
9580    }
9581
9582    /// Returns the internal native queue snapshot for in-process session orchestration.
9583    ///
9584    /// Wire method: `session.queue.snapshot`.
9585    ///
9586    /// # Returns
9587    ///
9588    /// Internal snapshot of native queue state for local session orchestration.
9589    ///
9590    /// <div class="warning">
9591    ///
9592    /// **Experimental.** This API is part of an experimental wire-protocol surface
9593    /// and may change or be removed in future SDK or CLI releases. Pin both the
9594    /// SDK and CLI versions if your code depends on it.
9595    ///
9596    /// </div>
9597    pub(crate) async fn snapshot(&self) -> Result<QueueSnapshotResult, Error> {
9598        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9599        let _value = self
9600            .session
9601            .client()
9602            .call(rpc_methods::SESSION_QUEUE_SNAPSHOT, Some(wire_params))
9603            .await?;
9604        Ok(serde_json::from_value(_value)?)
9605    }
9606
9607    /// Moves an addressable queued item to a public visible position.
9608    ///
9609    /// Wire method: `session.queue.moveItem`.
9610    ///
9611    /// # Parameters
9612    ///
9613    /// * `params` - Parameters for moving a queued item by stable id.
9614    ///
9615    /// # Returns
9616    ///
9617    /// Result of moving a queued item.
9618    ///
9619    /// <div class="warning">
9620    ///
9621    /// **Experimental.** This API is part of an experimental wire-protocol surface
9622    /// and may change or be removed in future SDK or CLI releases. Pin both the
9623    /// SDK and CLI versions if your code depends on it.
9624    ///
9625    /// </div>
9626    pub async fn move_item(
9627        &self,
9628        params: QueueMoveItemRequest,
9629    ) -> Result<QueueMoveItemResult, Error> {
9630        let mut wire_params = serde_json::to_value(params)?;
9631        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9632        let _value = self
9633            .session
9634            .client()
9635            .call(rpc_methods::SESSION_QUEUE_MOVEITEM, Some(wire_params))
9636            .await?;
9637        Ok(serde_json::from_value(_value)?)
9638    }
9639
9640    /// Inserts a new queued message at a public visible position.
9641    ///
9642    /// Wire method: `session.queue.insertAt`.
9643    ///
9644    /// # Parameters
9645    ///
9646    /// * `params` - Parameters for inserting a queued message at a public visible position.
9647    ///
9648    /// # Returns
9649    ///
9650    /// Result of inserting a queued message.
9651    ///
9652    /// <div class="warning">
9653    ///
9654    /// **Experimental.** This API is part of an experimental wire-protocol surface
9655    /// and may change or be removed in future SDK or CLI releases. Pin both the
9656    /// SDK and CLI versions if your code depends on it.
9657    ///
9658    /// </div>
9659    pub async fn insert_at(
9660        &self,
9661        params: QueueInsertAtRequest,
9662    ) -> Result<QueueInsertAtResult, Error> {
9663        let mut wire_params = serde_json::to_value(params)?;
9664        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9665        let _value = self
9666            .session
9667            .client()
9668            .call(rpc_methods::SESSION_QUEUE_INSERTAT, Some(wire_params))
9669            .await?;
9670        Ok(serde_json::from_value(_value)?)
9671    }
9672
9673    /// Removes an addressable queued item by its stable id.
9674    ///
9675    /// Wire method: `session.queue.removeAt`.
9676    ///
9677    /// # Parameters
9678    ///
9679    /// * `params` - Parameters for removing a queued item by stable id.
9680    ///
9681    /// # Returns
9682    ///
9683    /// Result of removing a queued item.
9684    ///
9685    /// <div class="warning">
9686    ///
9687    /// **Experimental.** This API is part of an experimental wire-protocol surface
9688    /// and may change or be removed in future SDK or CLI releases. Pin both the
9689    /// SDK and CLI versions if your code depends on it.
9690    ///
9691    /// </div>
9692    pub async fn remove_at(
9693        &self,
9694        params: QueueRemoveAtRequest,
9695    ) -> Result<QueueRemoveAtResult, Error> {
9696        let mut wire_params = serde_json::to_value(params)?;
9697        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9698        let _value = self
9699            .session
9700            .client()
9701            .call(rpc_methods::SESSION_QUEUE_REMOVEAT, Some(wire_params))
9702            .await?;
9703        Ok(serde_json::from_value(_value)?)
9704    }
9705
9706    /// Updates the text of an addressable single-message queue item.
9707    ///
9708    /// Wire method: `session.queue.updateText`.
9709    ///
9710    /// # Parameters
9711    ///
9712    /// * `params` - Parameters for editing a single queued message.
9713    ///
9714    /// # Returns
9715    ///
9716    /// Result of editing a queued message.
9717    ///
9718    /// <div class="warning">
9719    ///
9720    /// **Experimental.** This API is part of an experimental wire-protocol surface
9721    /// and may change or be removed in future SDK or CLI releases. Pin both the
9722    /// SDK and CLI versions if your code depends on it.
9723    ///
9724    /// </div>
9725    pub async fn update_text(
9726        &self,
9727        params: QueueUpdateTextRequest,
9728    ) -> Result<QueueUpdateTextResult, Error> {
9729        let mut wire_params = serde_json::to_value(params)?;
9730        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9731        let _value = self
9732            .session
9733            .client()
9734            .call(rpc_methods::SESSION_QUEUE_UPDATETEXT, Some(wire_params))
9735            .await?;
9736        Ok(serde_json::from_value(_value)?)
9737    }
9738
9739    /// Atomically withdraws an unchanged, unconsumed user message from the local queued or steering lane. A client retaining the original draft may restore it only when removed is true. Does not interrupt the running turn.
9740    ///
9741    /// Wire method: `session.queue.withdrawMessage`.
9742    ///
9743    /// # Parameters
9744    ///
9745    /// * `params` - Conditional withdrawal of a single user message, before the runtime claims it for delivery.
9746    ///
9747    /// # Returns
9748    ///
9749    /// Result of removing a queued item.
9750    ///
9751    /// <div class="warning">
9752    ///
9753    /// **Experimental.** This API is part of an experimental wire-protocol surface
9754    /// and may change or be removed in future SDK or CLI releases. Pin both the
9755    /// SDK and CLI versions if your code depends on it.
9756    ///
9757    /// </div>
9758    pub async fn withdraw_message(
9759        &self,
9760        params: QueueWithdrawMessageRequest,
9761    ) -> Result<QueueRemoveAtResult, Error> {
9762        let mut wire_params = serde_json::to_value(params)?;
9763        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9764        let _value = self
9765            .session
9766            .client()
9767            .call(
9768                rpc_methods::SESSION_QUEUE_WITHDRAWMESSAGE,
9769                Some(wire_params),
9770            )
9771            .await?;
9772        Ok(serde_json::from_value(_value)?)
9773    }
9774
9775    /// Atomically appends text and attachments to an unchanged, unconsumed local steering message. Returns updated=false if delivery or withdrawal already claimed the message.
9776    ///
9777    /// Wire method: `session.queue.appendSteering`.
9778    ///
9779    /// # Parameters
9780    ///
9781    /// * `params` - Append to one pending steering message without changing its identity or delivery position.
9782    ///
9783    /// # Returns
9784    ///
9785    /// Result of editing a queued message.
9786    ///
9787    /// <div class="warning">
9788    ///
9789    /// **Experimental.** This API is part of an experimental wire-protocol surface
9790    /// and may change or be removed in future SDK or CLI releases. Pin both the
9791    /// SDK and CLI versions if your code depends on it.
9792    ///
9793    /// </div>
9794    pub async fn append_steering(
9795        &self,
9796        params: QueueAppendSteeringRequest,
9797    ) -> Result<QueueUpdateTextResult, Error> {
9798        let mut wire_params = serde_json::to_value(params)?;
9799        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9800        let _value = self
9801            .session
9802            .client()
9803            .call(rpc_methods::SESSION_QUEUE_APPENDSTEERING, Some(wire_params))
9804            .await?;
9805        Ok(serde_json::from_value(_value)?)
9806    }
9807
9808    /// Duplicates an addressable queued item immediately after its source.
9809    ///
9810    /// Wire method: `session.queue.duplicateAt`.
9811    ///
9812    /// # Parameters
9813    ///
9814    /// * `params` - Parameters for duplicating a queued item.
9815    ///
9816    /// # Returns
9817    ///
9818    /// Result of duplicating a queued item.
9819    ///
9820    /// <div class="warning">
9821    ///
9822    /// **Experimental.** This API is part of an experimental wire-protocol surface
9823    /// and may change or be removed in future SDK or CLI releases. Pin both the
9824    /// SDK and CLI versions if your code depends on it.
9825    ///
9826    /// </div>
9827    pub async fn duplicate_at(
9828        &self,
9829        params: QueueDuplicateAtRequest,
9830    ) -> Result<QueueDuplicateAtResult, Error> {
9831        let mut wire_params = serde_json::to_value(params)?;
9832        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9833        let _value = self
9834            .session
9835            .client()
9836            .call(rpc_methods::SESSION_QUEUE_DUPLICATEAT, Some(wire_params))
9837            .await?;
9838        Ok(serde_json::from_value(_value)?)
9839    }
9840
9841    /// Acquires or releases the queued-lane drain pause.
9842    ///
9843    /// Wire method: `session.queue.setDrainPaused`.
9844    ///
9845    /// # Parameters
9846    ///
9847    /// * `params` - Parameters for acquiring or releasing the queued-lane drain pause. Acquisition is exclusive and non-idempotent: `paused: true` against an already-paused session fails with `queue_already_paused`. The pause is never released automatically — it is not tied to the caller's lifetime, so a client that exits without sending `paused: false` leaves the lane frozen. Release is unowned: `paused: false` clears the pause for any caller, including one that never acquired it.
9848    ///
9849    /// <div class="warning">
9850    ///
9851    /// **Experimental.** This API is part of an experimental wire-protocol surface
9852    /// and may change or be removed in future SDK or CLI releases. Pin both the
9853    /// SDK and CLI versions if your code depends on it.
9854    ///
9855    /// </div>
9856    pub async fn set_drain_paused(&self, params: QueueSetDrainPausedRequest) -> Result<(), Error> {
9857        let mut wire_params = serde_json::to_value(params)?;
9858        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9859        let _value = self
9860            .session
9861            .client()
9862            .call(rpc_methods::SESSION_QUEUE_SETDRAINPAUSED, Some(wire_params))
9863            .await?;
9864        Ok(())
9865    }
9866
9867    /// Moves an addressable queued message into the live turn's steering lane.
9868    ///
9869    /// Wire method: `session.queue.sendNow`.
9870    ///
9871    /// # Parameters
9872    ///
9873    /// * `params` - Parameters for steering a queued message into a live turn.
9874    ///
9875    /// # Returns
9876    ///
9877    /// Result of trying to steer a queued message into a live turn.
9878    ///
9879    /// <div class="warning">
9880    ///
9881    /// **Experimental.** This API is part of an experimental wire-protocol surface
9882    /// and may change or be removed in future SDK or CLI releases. Pin both the
9883    /// SDK and CLI versions if your code depends on it.
9884    ///
9885    /// </div>
9886    pub async fn send_now(&self, params: QueueSendNowRequest) -> Result<QueueSendNowResult, Error> {
9887        let mut wire_params = serde_json::to_value(params)?;
9888        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9889        let _value = self
9890            .session
9891            .client()
9892            .call(rpc_methods::SESSION_QUEUE_SENDNOW, Some(wire_params))
9893            .await?;
9894        Ok(serde_json::from_value(_value)?)
9895    }
9896
9897    /// Reports whether the local session has native queued work pending.
9898    ///
9899    /// Wire method: `session.queue.hasPending`.
9900    ///
9901    /// # Returns
9902    ///
9903    /// Whether the native queue has pending work.
9904    ///
9905    /// <div class="warning">
9906    ///
9907    /// **Experimental.** This API is part of an experimental wire-protocol surface
9908    /// and may change or be removed in future SDK or CLI releases. Pin both the
9909    /// SDK and CLI versions if your code depends on it.
9910    ///
9911    /// </div>
9912    pub(crate) async fn has_pending(&self) -> Result<QueueHasPendingResult, Error> {
9913        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9914        let _value = self
9915            .session
9916            .client()
9917            .call(rpc_methods::SESSION_QUEUE_HASPENDING, Some(wire_params))
9918            .await?;
9919        Ok(serde_json::from_value(_value)?)
9920    }
9921
9922    /// Begins a native deferred-idle drain when background work has quiesced.
9923    ///
9924    /// Wire method: `session.queue.beginDeferredIdleDrain`.
9925    ///
9926    /// # Parameters
9927    ///
9928    /// * `params` - Inputs for starting a deferred-idle drain.
9929    ///
9930    /// # Returns
9931    ///
9932    /// Whether a deferred-idle drain should run.
9933    ///
9934    /// <div class="warning">
9935    ///
9936    /// **Experimental.** This API is part of an experimental wire-protocol surface
9937    /// and may change or be removed in future SDK or CLI releases. Pin both the
9938    /// SDK and CLI versions if your code depends on it.
9939    ///
9940    /// </div>
9941    pub(crate) async fn begin_deferred_idle_drain(
9942        &self,
9943        params: QueueBeginDeferredIdleDrainRequest,
9944    ) -> Result<QueueBeginDeferredIdleDrainResult, Error> {
9945        let mut wire_params = serde_json::to_value(params)?;
9946        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9947        let _value = self
9948            .session
9949            .client()
9950            .call(
9951                rpc_methods::SESSION_QUEUE_BEGINDEFERREDIDLEDRAIN,
9952                Some(wire_params),
9953            )
9954            .await?;
9955        Ok(serde_json::from_value(_value)?)
9956    }
9957
9958    /// Finishes a native deferred-idle drain and reports whether to drain queue work or emit idle.
9959    ///
9960    /// Wire method: `session.queue.finishDeferredIdleDrain`.
9961    ///
9962    /// # Parameters
9963    ///
9964    /// * `params` - Inputs for completing a deferred-idle drain.
9965    ///
9966    /// # Returns
9967    ///
9968    /// Action selected by the native deferred-idle drain.
9969    ///
9970    /// <div class="warning">
9971    ///
9972    /// **Experimental.** This API is part of an experimental wire-protocol surface
9973    /// and may change or be removed in future SDK or CLI releases. Pin both the
9974    /// SDK and CLI versions if your code depends on it.
9975    ///
9976    /// </div>
9977    pub(crate) async fn finish_deferred_idle_drain(
9978        &self,
9979        params: QueueFinishDeferredIdleDrainRequest,
9980    ) -> Result<QueueFinishDeferredIdleDrainResult, Error> {
9981        let mut wire_params = serde_json::to_value(params)?;
9982        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9983        let _value = self
9984            .session
9985            .client()
9986            .call(
9987                rpc_methods::SESSION_QUEUE_FINISHDEFERREDIDLEDRAIN,
9988                Some(wire_params),
9989            )
9990            .await?;
9991        Ok(serde_json::from_value(_value)?)
9992    }
9993
9994    /// Marks session.idle as deferred by native background work state.
9995    ///
9996    /// Wire method: `session.queue.deferSessionIdle`.
9997    ///
9998    /// # Parameters
9999    ///
10000    /// * `params` - Inputs for marking session.idle deferred in native state.
10001    ///
10002    /// <div class="warning">
10003    ///
10004    /// **Experimental.** This API is part of an experimental wire-protocol surface
10005    /// and may change or be removed in future SDK or CLI releases. Pin both the
10006    /// SDK and CLI versions if your code depends on it.
10007    ///
10008    /// </div>
10009    pub(crate) async fn defer_session_idle(
10010        &self,
10011        params: QueueDeferSessionIdleRequest,
10012    ) -> Result<(), Error> {
10013        let mut wire_params = serde_json::to_value(params)?;
10014        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10015        let _value = self
10016            .session
10017            .client()
10018            .call(
10019                rpc_methods::SESSION_QUEUE_DEFERSESSIONIDLE,
10020                Some(wire_params),
10021            )
10022            .await?;
10023        Ok(())
10024    }
10025
10026    /// Removes the most recently queued user-facing item (LIFO).
10027    ///
10028    /// Wire method: `session.queue.removeMostRecent`.
10029    ///
10030    /// # Returns
10031    ///
10032    /// Indicates whether a user-facing pending item was removed.
10033    ///
10034    /// <div class="warning">
10035    ///
10036    /// **Experimental.** This API is part of an experimental wire-protocol surface
10037    /// and may change or be removed in future SDK or CLI releases. Pin both the
10038    /// SDK and CLI versions if your code depends on it.
10039    ///
10040    /// </div>
10041    pub async fn remove_most_recent(&self) -> Result<QueueRemoveMostRecentResult, Error> {
10042        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10043        let _value = self
10044            .session
10045            .client()
10046            .call(
10047                rpc_methods::SESSION_QUEUE_REMOVEMOSTRECENT,
10048                Some(wire_params),
10049            )
10050            .await?;
10051        Ok(serde_json::from_value(_value)?)
10052    }
10053
10054    /// Clears all pending queued items on the local session.
10055    ///
10056    /// Wire method: `session.queue.clear`.
10057    ///
10058    /// <div class="warning">
10059    ///
10060    /// **Experimental.** This API is part of an experimental wire-protocol surface
10061    /// and may change or be removed in future SDK or CLI releases. Pin both the
10062    /// SDK and CLI versions if your code depends on it.
10063    ///
10064    /// </div>
10065    pub async fn clear(&self) -> Result<(), Error> {
10066        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10067        let _value = self
10068            .session
10069            .client()
10070            .call(rpc_methods::SESSION_QUEUE_CLEAR, Some(wire_params))
10071            .await?;
10072        Ok(())
10073    }
10074
10075    /// Consumes queued native system notifications matching an internal filter.
10076    ///
10077    /// Wire method: `session.queue.consumeSystemNotifications`.
10078    ///
10079    /// # Parameters
10080    ///
10081    /// * `params` - Internal filter for consuming queued system notifications.
10082    ///
10083    /// # Returns
10084    ///
10085    /// Indicates whether a user-facing pending item was removed.
10086    ///
10087    /// <div class="warning">
10088    ///
10089    /// **Experimental.** This API is part of an experimental wire-protocol surface
10090    /// and may change or be removed in future SDK or CLI releases. Pin both the
10091    /// SDK and CLI versions if your code depends on it.
10092    ///
10093    /// </div>
10094    pub(crate) async fn consume_system_notifications(
10095        &self,
10096        params: QueueConsumeSystemNotificationsRequest,
10097    ) -> Result<QueueRemoveMostRecentResult, Error> {
10098        let mut wire_params = serde_json::to_value(params)?;
10099        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10100        let _value = self
10101            .session
10102            .client()
10103            .call(
10104                rpc_methods::SESSION_QUEUE_CONSUMESYSTEMNOTIFICATIONS,
10105                Some(wire_params),
10106            )
10107            .await?;
10108        Ok(serde_json::from_value(_value)?)
10109    }
10110
10111    /// Enqueues the internal resume-pending wake item when orphan handling needs a follow-up turn.
10112    ///
10113    /// Wire method: `session.queue.enqueueResumePending`.
10114    ///
10115    /// # Returns
10116    ///
10117    /// Result of enqueueing the resume-pending wake item.
10118    ///
10119    /// <div class="warning">
10120    ///
10121    /// **Experimental.** This API is part of an experimental wire-protocol surface
10122    /// and may change or be removed in future SDK or CLI releases. Pin both the
10123    /// SDK and CLI versions if your code depends on it.
10124    ///
10125    /// </div>
10126    pub(crate) async fn enqueue_resume_pending(
10127        &self,
10128    ) -> Result<QueueEnqueueResumePendingResult, Error> {
10129        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10130        let _value = self
10131            .session
10132            .client()
10133            .call(
10134                rpc_methods::SESSION_QUEUE_ENQUEUERESUMEPENDING,
10135                Some(wire_params),
10136            )
10137            .await?;
10138        Ok(serde_json::from_value(_value)?)
10139    }
10140
10141    /// Drains the native local-session work queue for in-process session orchestration.
10142    ///
10143    /// Wire method: `session.queue.process`.
10144    ///
10145    /// <div class="warning">
10146    ///
10147    /// **Experimental.** This API is part of an experimental wire-protocol surface
10148    /// and may change or be removed in future SDK or CLI releases. Pin both the
10149    /// SDK and CLI versions if your code depends on it.
10150    ///
10151    /// </div>
10152    pub(crate) async fn process(&self) -> Result<(), Error> {
10153        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10154        let _value = self
10155            .session
10156            .client()
10157            .call(rpc_methods::SESSION_QUEUE_PROCESS, Some(wire_params))
10158            .await?;
10159        Ok(())
10160    }
10161}
10162
10163/// `session.remote.*` RPCs.
10164#[derive(Clone, Copy)]
10165pub struct SessionRpcRemote<'a> {
10166    pub(crate) session: &'a Session,
10167}
10168
10169impl<'a> SessionRpcRemote<'a> {
10170    /// Enables remote session export or steering.
10171    ///
10172    /// Wire method: `session.remote.enable`.
10173    ///
10174    /// # Parameters
10175    ///
10176    /// * `params` - Optional remote session mode ("off", "export", or "on"); defaults to enabling both export and remote steering.
10177    ///
10178    /// # Returns
10179    ///
10180    /// GitHub URL for the session and a flag indicating whether remote steering is enabled.
10181    ///
10182    /// <div class="warning">
10183    ///
10184    /// **Experimental.** This API is part of an experimental wire-protocol surface
10185    /// and may change or be removed in future SDK or CLI releases. Pin both the
10186    /// SDK and CLI versions if your code depends on it.
10187    ///
10188    /// </div>
10189    pub async fn enable(&self, params: RemoteEnableRequest) -> Result<RemoteEnableResult, Error> {
10190        let mut wire_params = serde_json::to_value(params)?;
10191        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10192        let _value = self
10193            .session
10194            .client()
10195            .call(rpc_methods::SESSION_REMOTE_ENABLE, Some(wire_params))
10196            .await?;
10197        Ok(serde_json::from_value(_value)?)
10198    }
10199
10200    /// Disables remote session export and steering.
10201    ///
10202    /// Wire method: `session.remote.disable`.
10203    ///
10204    /// <div class="warning">
10205    ///
10206    /// **Experimental.** This API is part of an experimental wire-protocol surface
10207    /// and may change or be removed in future SDK or CLI releases. Pin both the
10208    /// SDK and CLI versions if your code depends on it.
10209    ///
10210    /// </div>
10211    pub async fn disable(&self) -> Result<(), Error> {
10212        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10213        let _value = self
10214            .session
10215            .client()
10216            .call(rpc_methods::SESSION_REMOTE_DISABLE, Some(wire_params))
10217            .await?;
10218        Ok(())
10219    }
10220
10221    /// Persists a remote-steerability change emitted by the host as a session event.
10222    ///
10223    /// Wire method: `session.remote.notifySteerableChanged`.
10224    ///
10225    /// # Parameters
10226    ///
10227    /// * `params` - New remote-steerability state to persist as a `session.remote_steerable_changed` event.
10228    ///
10229    /// # Returns
10230    ///
10231    /// 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.
10232    ///
10233    /// <div class="warning">
10234    ///
10235    /// **Experimental.** This API is part of an experimental wire-protocol surface
10236    /// and may change or be removed in future SDK or CLI releases. Pin both the
10237    /// SDK and CLI versions if your code depends on it.
10238    ///
10239    /// </div>
10240    pub async fn notify_steerable_changed(
10241        &self,
10242        params: RemoteNotifySteerableChangedRequest,
10243    ) -> Result<RemoteNotifySteerableChangedResult, Error> {
10244        let mut wire_params = serde_json::to_value(params)?;
10245        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10246        let _value = self
10247            .session
10248            .client()
10249            .call(
10250                rpc_methods::SESSION_REMOTE_NOTIFYSTEERABLECHANGED,
10251                Some(wire_params),
10252            )
10253            .await?;
10254        Ok(serde_json::from_value(_value)?)
10255    }
10256}
10257
10258/// `session.sandbox.*` RPCs.
10259#[derive(Clone, Copy)]
10260pub struct SessionRpcSandbox<'a> {
10261    pub(crate) session: &'a Session,
10262}
10263
10264impl<'a> SessionRpcSandbox<'a> {
10265    /// Returns whether managed policy requires sandbox enforcement and whether an enforcement failure has permanently blocked the session.
10266    ///
10267    /// Wire method: `session.sandbox.getEnforcementStatus`.
10268    ///
10269    /// # Returns
10270    ///
10271    /// Managed sandbox enforcement state for a session.
10272    ///
10273    /// <div class="warning">
10274    ///
10275    /// **Experimental.** This API is part of an experimental wire-protocol surface
10276    /// and may change or be removed in future SDK or CLI releases. Pin both the
10277    /// SDK and CLI versions if your code depends on it.
10278    ///
10279    /// </div>
10280    pub async fn get_enforcement_status(&self) -> Result<SandboxEnforcementStatus, Error> {
10281        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10282        let _value = self
10283            .session
10284            .client()
10285            .call(
10286                rpc_methods::SESSION_SANDBOX_GETENFORCEMENTSTATUS,
10287                Some(wire_params),
10288            )
10289            .await?;
10290        Ok(serde_json::from_value(_value)?)
10291    }
10292
10293    /// Disables sandboxing for the remainder of the current session and approves the referenced pending sandbox-bypass permission request. The request is rejected unless the exact request is still pending and the effective sandbox policy permits bypass.
10294    ///
10295    /// Wire method: `session.sandbox.disableForSession`.
10296    ///
10297    /// # Parameters
10298    ///
10299    /// * `params` - Request to disable sandboxing for the current session while resolving an active sandbox-bypass permission prompt.
10300    ///
10301    /// # Returns
10302    ///
10303    /// Result of attempting to disable sandboxing for the current session.
10304    ///
10305    /// <div class="warning">
10306    ///
10307    /// **Experimental.** This API is part of an experimental wire-protocol surface
10308    /// and may change or be removed in future SDK or CLI releases. Pin both the
10309    /// SDK and CLI versions if your code depends on it.
10310    ///
10311    /// </div>
10312    pub async fn disable_for_session(
10313        &self,
10314        params: SandboxDisableForSessionRequest,
10315    ) -> Result<SandboxDisableForSessionResult, Error> {
10316        let mut wire_params = serde_json::to_value(params)?;
10317        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10318        let _value = self
10319            .session
10320            .client()
10321            .call(
10322                rpc_methods::SESSION_SANDBOX_DISABLEFORSESSION,
10323                Some(wire_params),
10324            )
10325            .await?;
10326        Ok(serde_json::from_value(_value)?)
10327    }
10328}
10329
10330/// `session.schedule.*` RPCs.
10331#[derive(Clone, Copy)]
10332pub struct SessionRpcSchedule<'a> {
10333    pub(crate) session: &'a Session,
10334}
10335
10336impl<'a> SessionRpcSchedule<'a> {
10337    /// Lists the session's currently active scheduled prompts.
10338    ///
10339    /// Wire method: `session.schedule.list`.
10340    ///
10341    /// # Returns
10342    ///
10343    /// Snapshot of the currently active recurring prompts for this session.
10344    ///
10345    /// <div class="warning">
10346    ///
10347    /// **Experimental.** This API is part of an experimental wire-protocol surface
10348    /// and may change or be removed in future SDK or CLI releases. Pin both the
10349    /// SDK and CLI versions if your code depends on it.
10350    ///
10351    /// </div>
10352    pub async fn list(&self) -> Result<ScheduleList, Error> {
10353        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10354        let _value = self
10355            .session
10356            .client()
10357            .call(rpc_methods::SESSION_SCHEDULE_LIST, Some(wire_params))
10358            .await?;
10359        Ok(serde_json::from_value(_value)?)
10360    }
10361
10362    /// Hydrates the native schedule registry from persisted session events.
10363    ///
10364    /// Wire method: `session.schedule.hydrate`.
10365    ///
10366    /// <div class="warning">
10367    ///
10368    /// **Experimental.** This API is part of an experimental wire-protocol surface
10369    /// and may change or be removed in future SDK or CLI releases. Pin both the
10370    /// SDK and CLI versions if your code depends on it.
10371    ///
10372    /// </div>
10373    pub(crate) async fn hydrate(&self) -> Result<(), Error> {
10374        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10375        let _value = self
10376            .session
10377            .client()
10378            .call(rpc_methods::SESSION_SCHEDULE_HYDRATE, Some(wire_params))
10379            .await?;
10380        Ok(())
10381    }
10382
10383    /// Reports whether the session has an active self-paced scheduled prompt.
10384    ///
10385    /// Wire method: `session.schedule.hasSelfPaced`.
10386    ///
10387    /// # Returns
10388    ///
10389    /// Whether the session currently has an active self-paced schedule.
10390    ///
10391    /// <div class="warning">
10392    ///
10393    /// **Experimental.** This API is part of an experimental wire-protocol surface
10394    /// and may change or be removed in future SDK or CLI releases. Pin both the
10395    /// SDK and CLI versions if your code depends on it.
10396    ///
10397    /// </div>
10398    pub(crate) async fn has_self_paced(&self) -> Result<ScheduleHasSelfPacedResult, Error> {
10399        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10400        let _value = self
10401            .session
10402            .client()
10403            .call(
10404                rpc_methods::SESSION_SCHEDULE_HASSELFPACED,
10405                Some(wire_params),
10406            )
10407            .await?;
10408        Ok(serde_json::from_value(_value)?)
10409    }
10410
10411    /// Registers a relative-interval scheduled prompt.
10412    ///
10413    /// Wire method: `session.schedule.add`.
10414    ///
10415    /// # Parameters
10416    ///
10417    /// * `params` - Register a relative-interval scheduled prompt.
10418    ///
10419    /// # Returns
10420    ///
10421    /// Result of registering or re-arming a scheduled prompt.
10422    ///
10423    /// <div class="warning">
10424    ///
10425    /// **Experimental.** This API is part of an experimental wire-protocol surface
10426    /// and may change or be removed in future SDK or CLI releases. Pin both the
10427    /// SDK and CLI versions if your code depends on it.
10428    ///
10429    /// </div>
10430    pub(crate) async fn add(&self, params: ScheduleAddRequest) -> Result<ScheduleAddResult, Error> {
10431        let mut wire_params = serde_json::to_value(params)?;
10432        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10433        let _value = self
10434            .session
10435            .client()
10436            .call(rpc_methods::SESSION_SCHEDULE_ADD, Some(wire_params))
10437            .await?;
10438        Ok(serde_json::from_value(_value)?)
10439    }
10440
10441    /// Registers a recurring cron scheduled prompt.
10442    ///
10443    /// Wire method: `session.schedule.addCron`.
10444    ///
10445    /// # Parameters
10446    ///
10447    /// * `params` - Register a cron scheduled prompt.
10448    ///
10449    /// # Returns
10450    ///
10451    /// Result of registering or re-arming a scheduled prompt.
10452    ///
10453    /// <div class="warning">
10454    ///
10455    /// **Experimental.** This API is part of an experimental wire-protocol surface
10456    /// and may change or be removed in future SDK or CLI releases. Pin both the
10457    /// SDK and CLI versions if your code depends on it.
10458    ///
10459    /// </div>
10460    pub(crate) async fn add_cron(
10461        &self,
10462        params: ScheduleAddCronRequest,
10463    ) -> Result<ScheduleAddResult, Error> {
10464        let mut wire_params = serde_json::to_value(params)?;
10465        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10466        let _value = self
10467            .session
10468            .client()
10469            .call(rpc_methods::SESSION_SCHEDULE_ADDCRON, Some(wire_params))
10470            .await?;
10471        Ok(serde_json::from_value(_value)?)
10472    }
10473
10474    /// Registers an absolute-time scheduled prompt.
10475    ///
10476    /// Wire method: `session.schedule.addAt`.
10477    ///
10478    /// # Parameters
10479    ///
10480    /// * `params` - Register an absolute-time scheduled prompt.
10481    ///
10482    /// # Returns
10483    ///
10484    /// Result of registering or re-arming a scheduled prompt.
10485    ///
10486    /// <div class="warning">
10487    ///
10488    /// **Experimental.** This API is part of an experimental wire-protocol surface
10489    /// and may change or be removed in future SDK or CLI releases. Pin both the
10490    /// SDK and CLI versions if your code depends on it.
10491    ///
10492    /// </div>
10493    pub(crate) async fn add_at(
10494        &self,
10495        params: ScheduleAddAtRequest,
10496    ) -> Result<ScheduleAddResult, Error> {
10497        let mut wire_params = serde_json::to_value(params)?;
10498        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10499        let _value = self
10500            .session
10501            .client()
10502            .call(rpc_methods::SESSION_SCHEDULE_ADDAT, Some(wire_params))
10503            .await?;
10504        Ok(serde_json::from_value(_value)?)
10505    }
10506
10507    /// Registers a self-paced scheduled prompt.
10508    ///
10509    /// Wire method: `session.schedule.addSelfPaced`.
10510    ///
10511    /// # Parameters
10512    ///
10513    /// * `params` - Register a self-paced scheduled prompt.
10514    ///
10515    /// # Returns
10516    ///
10517    /// Result of registering or re-arming a scheduled prompt.
10518    ///
10519    /// <div class="warning">
10520    ///
10521    /// **Experimental.** This API is part of an experimental wire-protocol surface
10522    /// and may change or be removed in future SDK or CLI releases. Pin both the
10523    /// SDK and CLI versions if your code depends on it.
10524    ///
10525    /// </div>
10526    pub(crate) async fn add_self_paced(
10527        &self,
10528        params: ScheduleAddSelfPacedRequest,
10529    ) -> Result<ScheduleAddResult, Error> {
10530        let mut wire_params = serde_json::to_value(params)?;
10531        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10532        let _value = self
10533            .session
10534            .client()
10535            .call(
10536                rpc_methods::SESSION_SCHEDULE_ADDSELFPACED,
10537                Some(wire_params),
10538            )
10539            .await?;
10540        Ok(serde_json::from_value(_value)?)
10541    }
10542
10543    /// Re-arms an active self-paced scheduled prompt.
10544    ///
10545    /// Wire method: `session.schedule.rearmSelfPaced`.
10546    ///
10547    /// # Parameters
10548    ///
10549    /// * `params` - Re-arm a self-paced scheduled prompt.
10550    ///
10551    /// # Returns
10552    ///
10553    /// Result of registering or re-arming a scheduled prompt.
10554    ///
10555    /// <div class="warning">
10556    ///
10557    /// **Experimental.** This API is part of an experimental wire-protocol surface
10558    /// and may change or be removed in future SDK or CLI releases. Pin both the
10559    /// SDK and CLI versions if your code depends on it.
10560    ///
10561    /// </div>
10562    pub(crate) async fn rearm_self_paced(
10563        &self,
10564        params: ScheduleRearmSelfPacedRequest,
10565    ) -> Result<ScheduleAddResult, Error> {
10566        let mut wire_params = serde_json::to_value(params)?;
10567        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10568        let _value = self
10569            .session
10570            .client()
10571            .call(
10572                rpc_methods::SESSION_SCHEDULE_REARMSELFPACED,
10573                Some(wire_params),
10574            )
10575            .await?;
10576        Ok(serde_json::from_value(_value)?)
10577    }
10578
10579    /// Removes a scheduled prompt by id.
10580    ///
10581    /// Wire method: `session.schedule.stop`.
10582    ///
10583    /// # Parameters
10584    ///
10585    /// * `params` - Identifier of the scheduled prompt to remove.
10586    ///
10587    /// # Returns
10588    ///
10589    /// Remove a scheduled prompt by id. The result entry is omitted if the id was unknown.
10590    ///
10591    /// <div class="warning">
10592    ///
10593    /// **Experimental.** This API is part of an experimental wire-protocol surface
10594    /// and may change or be removed in future SDK or CLI releases. Pin both the
10595    /// SDK and CLI versions if your code depends on it.
10596    ///
10597    /// </div>
10598    pub async fn stop(&self, params: ScheduleStopRequest) -> Result<ScheduleStopResult, Error> {
10599        let mut wire_params = serde_json::to_value(params)?;
10600        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10601        let _value = self
10602            .session
10603            .client()
10604            .call(rpc_methods::SESSION_SCHEDULE_STOP, Some(wire_params))
10605            .await?;
10606        Ok(serde_json::from_value(_value)?)
10607    }
10608}
10609
10610/// `session.settings.*` RPCs.
10611#[derive(Clone, Copy)]
10612pub struct SessionRpcSettings<'a> {
10613    pub(crate) session: &'a Session,
10614}
10615
10616impl<'a> SessionRpcSettings<'a> {
10617    /// Returns a redacted snapshot of session runtime settings, with secrets and raw feature flags excluded. Internal: the runtime settings shape is a runtime-internal surface and is deliberately kept out of the public SDK, because consumers should not depend on the runtime's internal settings layout. It remains callable in-process and is expected to be reworked as the runtime internals are consolidated.
10618    ///
10619    /// Wire method: `session.settings.snapshot`.
10620    ///
10621    /// # Returns
10622    ///
10623    /// Redacted, serializable view of session runtime settings for SDK boundary consumers. Secrets and raw feature flags are intentionally excluded.
10624    ///
10625    /// <div class="warning">
10626    ///
10627    /// **Experimental.** This API is part of an experimental wire-protocol surface
10628    /// and may change or be removed in future SDK or CLI releases. Pin both the
10629    /// SDK and CLI versions if your code depends on it.
10630    ///
10631    /// </div>
10632    pub(crate) async fn snapshot(&self) -> Result<SessionSettingsSnapshot, Error> {
10633        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10634        let _value = self
10635            .session
10636            .client()
10637            .call(rpc_methods::SESSION_SETTINGS_SNAPSHOT, Some(wire_params))
10638            .await?;
10639        Ok(serde_json::from_value(_value)?)
10640    }
10641
10642    /// Evaluates a named Rust-owned settings predicate without exposing raw feature flags. Internal: the raw feature-flag names and composition are runtime-internal, so this predicate-evaluation helper is kept out of the public SDK surface and is callable in-process only.
10643    ///
10644    /// Wire method: `session.settings.evaluatePredicate`.
10645    ///
10646    /// # Parameters
10647    ///
10648    /// * `params` - Named Rust-owned settings predicate to evaluate for this session.
10649    ///
10650    /// # Returns
10651    ///
10652    /// Result of evaluating a Rust-owned settings predicate.
10653    ///
10654    /// <div class="warning">
10655    ///
10656    /// **Experimental.** This API is part of an experimental wire-protocol surface
10657    /// and may change or be removed in future SDK or CLI releases. Pin both the
10658    /// SDK and CLI versions if your code depends on it.
10659    ///
10660    /// </div>
10661    pub(crate) async fn evaluate_predicate(
10662        &self,
10663        params: SessionSettingsEvaluatePredicateRequest,
10664    ) -> Result<SessionSettingsEvaluatePredicateResult, Error> {
10665        let mut wire_params = serde_json::to_value(params)?;
10666        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10667        let _value = self
10668            .session
10669            .client()
10670            .call(
10671                rpc_methods::SESSION_SETTINGS_EVALUATEPREDICATE,
10672                Some(wire_params),
10673            )
10674            .await?;
10675        Ok(serde_json::from_value(_value)?)
10676    }
10677}
10678
10679/// `session.shell.*` RPCs.
10680#[derive(Clone, Copy)]
10681pub struct SessionRpcShell<'a> {
10682    pub(crate) session: &'a Session,
10683}
10684
10685impl<'a> SessionRpcShell<'a> {
10686    /// Starts a shell command and streams output through session notifications. The command runs as the leader of its own process group (POSIX) or in a dedicated job object (Windows), so a forced termination — via "shell.kill", the request timeout, or session disposal — signals that whole group/job rather than only the direct child. Two gaps are worth planning for: a command that exits on its own does not trigger that teardown, and on POSIX a descendant that moves itself into a new session or process group (for example via "setsid") leaves the signalled group, so either can leave a background process running.
10687    ///
10688    /// Wire method: `session.shell.exec`.
10689    ///
10690    /// # Parameters
10691    ///
10692    /// * `params` - Shell command to run, with optional working directory and timeout in milliseconds.
10693    ///
10694    /// # Returns
10695    ///
10696    /// Identifier of the spawned process, used to correlate streamed output and exit notifications.
10697    ///
10698    /// <div class="warning">
10699    ///
10700    /// **Experimental.** This API is part of an experimental wire-protocol surface
10701    /// and may change or be removed in future SDK or CLI releases. Pin both the
10702    /// SDK and CLI versions if your code depends on it.
10703    ///
10704    /// </div>
10705    pub async fn exec(&self, params: ShellExecRequest) -> Result<ShellExecResult, Error> {
10706        let mut wire_params = serde_json::to_value(params)?;
10707        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10708        let _value = self
10709            .session
10710            .client()
10711            .call(rpc_methods::SESSION_SHELL_EXEC, Some(wire_params))
10712            .await?;
10713        Ok(serde_json::from_value(_value)?)
10714    }
10715
10716    /// Sends a signal to a shell process previously started via "shell.exec". The signal targets the command's whole process group (POSIX) or job object (Windows), so descendants still in that group are signalled too, not just the direct child. On POSIX a descendant that moved itself into a new session or process group (for example via "setsid") is no longer in the signalled group and survives.
10717    ///
10718    /// Wire method: `session.shell.kill`.
10719    ///
10720    /// # Parameters
10721    ///
10722    /// * `params` - Identifier of a process previously returned by "shell.exec" and the signal to send.
10723    ///
10724    /// # Returns
10725    ///
10726    /// Indicates whether the signal was delivered; false if the process was unknown or already exited.
10727    ///
10728    /// <div class="warning">
10729    ///
10730    /// **Experimental.** This API is part of an experimental wire-protocol surface
10731    /// and may change or be removed in future SDK or CLI releases. Pin both the
10732    /// SDK and CLI versions if your code depends on it.
10733    ///
10734    /// </div>
10735    pub async fn kill(&self, params: ShellKillRequest) -> Result<ShellKillResult, Error> {
10736        let mut wire_params = serde_json::to_value(params)?;
10737        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10738        let _value = self
10739            .session
10740            .client()
10741            .call(rpc_methods::SESSION_SHELL_KILL, Some(wire_params))
10742            .await?;
10743        Ok(serde_json::from_value(_value)?)
10744    }
10745
10746    /// Executes a user-requested shell command through the session runtime.
10747    ///
10748    /// Wire method: `session.shell.executeUserRequested`.
10749    ///
10750    /// # Parameters
10751    ///
10752    /// * `params` - User-requested shell command and cancellation handle.
10753    ///
10754    /// # Returns
10755    ///
10756    /// Result of a user-requested shell command.
10757    ///
10758    /// <div class="warning">
10759    ///
10760    /// **Experimental.** This API is part of an experimental wire-protocol surface
10761    /// and may change or be removed in future SDK or CLI releases. Pin both the
10762    /// SDK and CLI versions if your code depends on it.
10763    ///
10764    /// </div>
10765    pub async fn execute_user_requested(
10766        &self,
10767        params: ShellExecuteUserRequestedRequest,
10768    ) -> Result<UserRequestedShellCommandResult, Error> {
10769        let mut wire_params = serde_json::to_value(params)?;
10770        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10771        let _value = self
10772            .session
10773            .client()
10774            .call(
10775                rpc_methods::SESSION_SHELL_EXECUTEUSERREQUESTED,
10776                Some(wire_params),
10777            )
10778            .await?;
10779        Ok(serde_json::from_value(_value)?)
10780    }
10781
10782    /// Cancels a user-requested shell command by request ID.
10783    ///
10784    /// Wire method: `session.shell.cancelUserRequested`.
10785    ///
10786    /// # Parameters
10787    ///
10788    /// * `params` - User-requested shell execution cancellation handle.
10789    ///
10790    /// # Returns
10791    ///
10792    /// Cancellation result for a user-requested shell command.
10793    ///
10794    /// <div class="warning">
10795    ///
10796    /// **Experimental.** This API is part of an experimental wire-protocol surface
10797    /// and may change or be removed in future SDK or CLI releases. Pin both the
10798    /// SDK and CLI versions if your code depends on it.
10799    ///
10800    /// </div>
10801    pub async fn cancel_user_requested(
10802        &self,
10803        params: ShellCancelUserRequestedRequest,
10804    ) -> Result<CancelUserRequestedShellCommandResult, Error> {
10805        let mut wire_params = serde_json::to_value(params)?;
10806        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10807        let _value = self
10808            .session
10809            .client()
10810            .call(
10811                rpc_methods::SESSION_SHELL_CANCELUSERREQUESTED,
10812                Some(wire_params),
10813            )
10814            .await?;
10815        Ok(serde_json::from_value(_value)?)
10816    }
10817}
10818
10819/// `session.skills.*` RPCs.
10820#[derive(Clone, Copy)]
10821pub struct SessionRpcSkills<'a> {
10822    pub(crate) session: &'a Session,
10823}
10824
10825impl<'a> SessionRpcSkills<'a> {
10826    /// Lists skills available to the session.
10827    ///
10828    /// Wire method: `session.skills.list`.
10829    ///
10830    /// # Returns
10831    ///
10832    /// Skills available to the session, with their enabled state.
10833    ///
10834    /// <div class="warning">
10835    ///
10836    /// **Experimental.** This API is part of an experimental wire-protocol surface
10837    /// and may change or be removed in future SDK or CLI releases. Pin both the
10838    /// SDK and CLI versions if your code depends on it.
10839    ///
10840    /// </div>
10841    pub async fn list(&self) -> Result<SkillList, Error> {
10842        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10843        let _value = self
10844            .session
10845            .client()
10846            .call(rpc_methods::SESSION_SKILLS_LIST, Some(wire_params))
10847            .await?;
10848        Ok(serde_json::from_value(_value)?)
10849    }
10850
10851    /// Returns the skills that have been invoked during this session.
10852    ///
10853    /// Wire method: `session.skills.getInvoked`.
10854    ///
10855    /// # Returns
10856    ///
10857    /// Skills invoked during this session, ordered by invocation time (most recent last).
10858    ///
10859    /// <div class="warning">
10860    ///
10861    /// **Experimental.** This API is part of an experimental wire-protocol surface
10862    /// and may change or be removed in future SDK or CLI releases. Pin both the
10863    /// SDK and CLI versions if your code depends on it.
10864    ///
10865    /// </div>
10866    pub async fn get_invoked(&self) -> Result<SkillsGetInvokedResult, Error> {
10867        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10868        let _value = self
10869            .session
10870            .client()
10871            .call(rpc_methods::SESSION_SKILLS_GETINVOKED, Some(wire_params))
10872            .await?;
10873        Ok(serde_json::from_value(_value)?)
10874    }
10875
10876    /// Enables a skill for the session.
10877    ///
10878    /// Wire method: `session.skills.enable`.
10879    ///
10880    /// # Parameters
10881    ///
10882    /// * `params` - Name of the skill to enable for the session.
10883    ///
10884    /// <div class="warning">
10885    ///
10886    /// **Experimental.** This API is part of an experimental wire-protocol surface
10887    /// and may change or be removed in future SDK or CLI releases. Pin both the
10888    /// SDK and CLI versions if your code depends on it.
10889    ///
10890    /// </div>
10891    pub async fn enable(&self, params: SkillsEnableRequest) -> Result<(), Error> {
10892        let mut wire_params = serde_json::to_value(params)?;
10893        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10894        let _value = self
10895            .session
10896            .client()
10897            .call(rpc_methods::SESSION_SKILLS_ENABLE, Some(wire_params))
10898            .await?;
10899        Ok(())
10900    }
10901
10902    /// Disables a skill for the session.
10903    ///
10904    /// Wire method: `session.skills.disable`.
10905    ///
10906    /// # Parameters
10907    ///
10908    /// * `params` - Name of the skill to disable for the session.
10909    ///
10910    /// <div class="warning">
10911    ///
10912    /// **Experimental.** This API is part of an experimental wire-protocol surface
10913    /// and may change or be removed in future SDK or CLI releases. Pin both the
10914    /// SDK and CLI versions if your code depends on it.
10915    ///
10916    /// </div>
10917    pub async fn disable(&self, params: SkillsDisableRequest) -> Result<(), Error> {
10918        let mut wire_params = serde_json::to_value(params)?;
10919        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10920        let _value = self
10921            .session
10922            .client()
10923            .call(rpc_methods::SESSION_SKILLS_DISABLE, Some(wire_params))
10924            .await?;
10925        Ok(())
10926    }
10927
10928    /// Reloads skill definitions for the session.
10929    ///
10930    /// Wire method: `session.skills.reload`.
10931    ///
10932    /// # Returns
10933    ///
10934    /// Diagnostics from reloading skill definitions, with warnings and errors as separate lists.
10935    ///
10936    /// <div class="warning">
10937    ///
10938    /// **Experimental.** This API is part of an experimental wire-protocol surface
10939    /// and may change or be removed in future SDK or CLI releases. Pin both the
10940    /// SDK and CLI versions if your code depends on it.
10941    ///
10942    /// </div>
10943    pub async fn reload(&self) -> Result<SkillsLoadDiagnostics, Error> {
10944        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10945        let _value = self
10946            .session
10947            .client()
10948            .call(rpc_methods::SESSION_SKILLS_RELOAD, Some(wire_params))
10949            .await?;
10950        Ok(serde_json::from_value(_value)?)
10951    }
10952
10953    /// Ensures the session's skill definitions have been loaded from disk.
10954    ///
10955    /// Wire method: `session.skills.ensureLoaded`.
10956    ///
10957    /// <div class="warning">
10958    ///
10959    /// **Experimental.** This API is part of an experimental wire-protocol surface
10960    /// and may change or be removed in future SDK or CLI releases. Pin both the
10961    /// SDK and CLI versions if your code depends on it.
10962    ///
10963    /// </div>
10964    pub async fn ensure_loaded(&self) -> Result<(), Error> {
10965        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10966        let _value = self
10967            .session
10968            .client()
10969            .call(rpc_methods::SESSION_SKILLS_ENSURELOADED, Some(wire_params))
10970            .await?;
10971        Ok(())
10972    }
10973}
10974
10975/// `session.tasks.*` RPCs.
10976#[derive(Clone, Copy)]
10977pub struct SessionRpcTasks<'a> {
10978    pub(crate) session: &'a Session,
10979}
10980
10981impl<'a> SessionRpcTasks<'a> {
10982    /// Starts a background agent task in the session.
10983    ///
10984    /// Wire method: `session.tasks.startAgent`.
10985    ///
10986    /// # Parameters
10987    ///
10988    /// * `params` - Agent type, prompt, name, and optional description and model override for the new task.
10989    ///
10990    /// # Returns
10991    ///
10992    /// Identifier assigned to the newly started background agent task.
10993    ///
10994    /// <div class="warning">
10995    ///
10996    /// **Experimental.** This API is part of an experimental wire-protocol surface
10997    /// and may change or be removed in future SDK or CLI releases. Pin both the
10998    /// SDK and CLI versions if your code depends on it.
10999    ///
11000    /// </div>
11001    pub async fn start_agent(
11002        &self,
11003        params: TasksStartAgentRequest,
11004    ) -> Result<TasksStartAgentResult, Error> {
11005        let mut wire_params = serde_json::to_value(params)?;
11006        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11007        let _value = self
11008            .session
11009            .client()
11010            .call(rpc_methods::SESSION_TASKS_STARTAGENT, Some(wire_params))
11011            .await?;
11012        Ok(serde_json::from_value(_value)?)
11013    }
11014
11015    /// Lists background tasks tracked by the session.
11016    ///
11017    /// Wire method: `session.tasks.list`.
11018    ///
11019    /// # Returns
11020    ///
11021    /// Background tasks currently tracked by the session.
11022    ///
11023    /// <div class="warning">
11024    ///
11025    /// **Experimental.** This API is part of an experimental wire-protocol surface
11026    /// and may change or be removed in future SDK or CLI releases. Pin both the
11027    /// SDK and CLI versions if your code depends on it.
11028    ///
11029    /// </div>
11030    pub async fn list(&self) -> Result<TaskList, Error> {
11031        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
11032        let _value = self
11033            .session
11034            .client()
11035            .call(rpc_methods::SESSION_TASKS_LIST, Some(wire_params))
11036            .await?;
11037        Ok(serde_json::from_value(_value)?)
11038    }
11039
11040    /// Registers a client-owned task, or reclaims an orphaned task belonging to the same extension principal.
11041    ///
11042    /// Wire method: `session.tasks.register`.
11043    ///
11044    /// # Parameters
11045    ///
11046    /// * `params` - Registers or reclaims a client-owned task.
11047    ///
11048    /// # Returns
11049    ///
11050    /// Result of registering or reclaiming a client-owned task.
11051    ///
11052    /// <div class="warning">
11053    ///
11054    /// **Experimental.** This API is part of an experimental wire-protocol surface
11055    /// and may change or be removed in future SDK or CLI releases. Pin both the
11056    /// SDK and CLI versions if your code depends on it.
11057    ///
11058    /// </div>
11059    pub async fn register(
11060        &self,
11061        params: TasksRegisterRequest,
11062    ) -> Result<TasksRegisterResult, Error> {
11063        let mut wire_params = serde_json::to_value(params)?;
11064        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11065        let _value = self
11066            .session
11067            .client()
11068            .call(rpc_methods::SESSION_TASKS_REGISTER, Some(wire_params))
11069            .await?;
11070        Ok(serde_json::from_value(_value)?)
11071    }
11072
11073    /// Publishes generic progress or a terminal outcome for a client-owned task.
11074    ///
11075    /// Wire method: `session.tasks.update`.
11076    ///
11077    /// # Parameters
11078    ///
11079    /// * `params` - Updates a client-owned task.
11080    ///
11081    /// # Returns
11082    ///
11083    /// Result of publishing a client-owned task update.
11084    ///
11085    /// <div class="warning">
11086    ///
11087    /// **Experimental.** This API is part of an experimental wire-protocol surface
11088    /// and may change or be removed in future SDK or CLI releases. Pin both the
11089    /// SDK and CLI versions if your code depends on it.
11090    ///
11091    /// </div>
11092    pub async fn update(&self, params: TasksUpdateRequest) -> Result<TasksUpdateResult, Error> {
11093        let mut wire_params = serde_json::to_value(params)?;
11094        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11095        let _value = self
11096            .session
11097            .client()
11098            .call(rpc_methods::SESSION_TASKS_UPDATE, Some(wire_params))
11099            .await?;
11100        Ok(serde_json::from_value(_value)?)
11101    }
11102
11103    /// Refreshes metadata for any detached background shells the runtime knows about.
11104    ///
11105    /// Wire method: `session.tasks.refresh`.
11106    ///
11107    /// # Returns
11108    ///
11109    /// 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.
11110    ///
11111    /// <div class="warning">
11112    ///
11113    /// **Experimental.** This API is part of an experimental wire-protocol surface
11114    /// and may change or be removed in future SDK or CLI releases. Pin both the
11115    /// SDK and CLI versions if your code depends on it.
11116    ///
11117    /// </div>
11118    pub async fn refresh(&self) -> Result<TasksRefreshResult, Error> {
11119        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
11120        let _value = self
11121            .session
11122            .client()
11123            .call(rpc_methods::SESSION_TASKS_REFRESH, Some(wire_params))
11124            .await?;
11125        Ok(serde_json::from_value(_value)?)
11126    }
11127
11128    /// Waits for all in-flight background tasks and any follow-up turns to settle.
11129    ///
11130    /// Wire method: `session.tasks.waitForPending`.
11131    ///
11132    /// # Returns
11133    ///
11134    /// 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).
11135    ///
11136    /// <div class="warning">
11137    ///
11138    /// **Experimental.** This API is part of an experimental wire-protocol surface
11139    /// and may change or be removed in future SDK or CLI releases. Pin both the
11140    /// SDK and CLI versions if your code depends on it.
11141    ///
11142    /// </div>
11143    pub async fn wait_for_pending(&self) -> Result<TasksWaitForPendingResult, Error> {
11144        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
11145        let _value = self
11146            .session
11147            .client()
11148            .call(rpc_methods::SESSION_TASKS_WAITFORPENDING, Some(wire_params))
11149            .await?;
11150        Ok(serde_json::from_value(_value)?)
11151    }
11152
11153    /// Returns progress information for a background task by ID.
11154    ///
11155    /// Wire method: `session.tasks.getProgress`.
11156    ///
11157    /// # Parameters
11158    ///
11159    /// * `params` - Identifier of the background task to fetch progress for.
11160    ///
11161    /// # Returns
11162    ///
11163    /// Progress information for the task, or null when no task with that ID is tracked.
11164    ///
11165    /// <div class="warning">
11166    ///
11167    /// **Experimental.** This API is part of an experimental wire-protocol surface
11168    /// and may change or be removed in future SDK or CLI releases. Pin both the
11169    /// SDK and CLI versions if your code depends on it.
11170    ///
11171    /// </div>
11172    pub async fn get_progress(
11173        &self,
11174        params: TasksGetProgressRequest,
11175    ) -> Result<TasksGetProgressResult, Error> {
11176        let mut wire_params = serde_json::to_value(params)?;
11177        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11178        let _value = self
11179            .session
11180            .client()
11181            .call(rpc_methods::SESSION_TASKS_GETPROGRESS, Some(wire_params))
11182            .await?;
11183        Ok(serde_json::from_value(_value)?)
11184    }
11185
11186    /// Returns the first sync-waiting task that can currently be promoted to background mode.
11187    ///
11188    /// Wire method: `session.tasks.getCurrentPromotable`.
11189    ///
11190    /// # Returns
11191    ///
11192    /// The first sync-waiting task that can currently be promoted to background mode.
11193    ///
11194    /// <div class="warning">
11195    ///
11196    /// **Experimental.** This API is part of an experimental wire-protocol surface
11197    /// and may change or be removed in future SDK or CLI releases. Pin both the
11198    /// SDK and CLI versions if your code depends on it.
11199    ///
11200    /// </div>
11201    pub async fn get_current_promotable(&self) -> Result<TasksGetCurrentPromotableResult, Error> {
11202        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
11203        let _value = self
11204            .session
11205            .client()
11206            .call(
11207                rpc_methods::SESSION_TASKS_GETCURRENTPROMOTABLE,
11208                Some(wire_params),
11209            )
11210            .await?;
11211        Ok(serde_json::from_value(_value)?)
11212    }
11213
11214    /// Promotes an eligible synchronously-waited task so it continues running in the background.
11215    ///
11216    /// Wire method: `session.tasks.promoteToBackground`.
11217    ///
11218    /// # Parameters
11219    ///
11220    /// * `params` - Identifier of the task to promote to background mode.
11221    ///
11222    /// # Returns
11223    ///
11224    /// Indicates whether the task was successfully promoted to background mode.
11225    ///
11226    /// <div class="warning">
11227    ///
11228    /// **Experimental.** This API is part of an experimental wire-protocol surface
11229    /// and may change or be removed in future SDK or CLI releases. Pin both the
11230    /// SDK and CLI versions if your code depends on it.
11231    ///
11232    /// </div>
11233    pub async fn promote_to_background(
11234        &self,
11235        params: TasksPromoteToBackgroundRequest,
11236    ) -> Result<TasksPromoteToBackgroundResult, Error> {
11237        let mut wire_params = serde_json::to_value(params)?;
11238        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11239        let _value = self
11240            .session
11241            .client()
11242            .call(
11243                rpc_methods::SESSION_TASKS_PROMOTETOBACKGROUND,
11244                Some(wire_params),
11245            )
11246            .await?;
11247        Ok(serde_json::from_value(_value)?)
11248    }
11249
11250    /// Atomically promotes the first promotable sync-waiting task to background mode and returns it.
11251    ///
11252    /// Wire method: `session.tasks.promoteCurrentToBackground`.
11253    ///
11254    /// # Returns
11255    ///
11256    /// The promoted task as it now exists in background mode, omitted if no promotable task was waiting.
11257    ///
11258    /// <div class="warning">
11259    ///
11260    /// **Experimental.** This API is part of an experimental wire-protocol surface
11261    /// and may change or be removed in future SDK or CLI releases. Pin both the
11262    /// SDK and CLI versions if your code depends on it.
11263    ///
11264    /// </div>
11265    pub async fn promote_current_to_background(
11266        &self,
11267    ) -> Result<TasksPromoteCurrentToBackgroundResult, Error> {
11268        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
11269        let _value = self
11270            .session
11271            .client()
11272            .call(
11273                rpc_methods::SESSION_TASKS_PROMOTECURRENTTOBACKGROUND,
11274                Some(wire_params),
11275            )
11276            .await?;
11277        Ok(serde_json::from_value(_value)?)
11278    }
11279
11280    /// Cancels a background task.
11281    ///
11282    /// Wire method: `session.tasks.cancel`.
11283    ///
11284    /// # Parameters
11285    ///
11286    /// * `params` - Identifier of the background task to cancel.
11287    ///
11288    /// # Returns
11289    ///
11290    /// Indicates whether the background task was successfully cancelled.
11291    ///
11292    /// <div class="warning">
11293    ///
11294    /// **Experimental.** This API is part of an experimental wire-protocol surface
11295    /// and may change or be removed in future SDK or CLI releases. Pin both the
11296    /// SDK and CLI versions if your code depends on it.
11297    ///
11298    /// </div>
11299    pub async fn cancel(&self, params: TasksCancelRequest) -> Result<TasksCancelResult, Error> {
11300        let mut wire_params = serde_json::to_value(params)?;
11301        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11302        let _value = self
11303            .session
11304            .client()
11305            .call(rpc_methods::SESSION_TASKS_CANCEL, Some(wire_params))
11306            .await?;
11307        Ok(serde_json::from_value(_value)?)
11308    }
11309
11310    /// Removes a completed or cancelled background task from tracking.
11311    ///
11312    /// Wire method: `session.tasks.remove`.
11313    ///
11314    /// # Parameters
11315    ///
11316    /// * `params` - Identifier of the completed or cancelled task to remove from tracking.
11317    ///
11318    /// # Returns
11319    ///
11320    /// Indicates whether the task was removed. False when the task does not exist or is still running/idle.
11321    ///
11322    /// <div class="warning">
11323    ///
11324    /// **Experimental.** This API is part of an experimental wire-protocol surface
11325    /// and may change or be removed in future SDK or CLI releases. Pin both the
11326    /// SDK and CLI versions if your code depends on it.
11327    ///
11328    /// </div>
11329    pub async fn remove(&self, params: TasksRemoveRequest) -> Result<TasksRemoveResult, Error> {
11330        let mut wire_params = serde_json::to_value(params)?;
11331        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11332        let _value = self
11333            .session
11334            .client()
11335            .call(rpc_methods::SESSION_TASKS_REMOVE, Some(wire_params))
11336            .await?;
11337        Ok(serde_json::from_value(_value)?)
11338    }
11339
11340    /// Sends a message to a background agent task.
11341    ///
11342    /// Wire method: `session.tasks.sendMessage`.
11343    ///
11344    /// # Parameters
11345    ///
11346    /// * `params` - Identifier of the target agent task, message content, and optional sender agent ID.
11347    ///
11348    /// # Returns
11349    ///
11350    /// Indicates whether the message was delivered, with an error message when delivery failed.
11351    ///
11352    /// <div class="warning">
11353    ///
11354    /// **Experimental.** This API is part of an experimental wire-protocol surface
11355    /// and may change or be removed in future SDK or CLI releases. Pin both the
11356    /// SDK and CLI versions if your code depends on it.
11357    ///
11358    /// </div>
11359    pub async fn send_message(
11360        &self,
11361        params: TasksSendMessageRequest,
11362    ) -> Result<TasksSendMessageResult, Error> {
11363        let mut wire_params = serde_json::to_value(params)?;
11364        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11365        let _value = self
11366            .session
11367            .client()
11368            .call(rpc_methods::SESSION_TASKS_SENDMESSAGE, Some(wire_params))
11369            .await?;
11370        Ok(serde_json::from_value(_value)?)
11371    }
11372}
11373
11374/// `session.telemetry.*` RPCs.
11375#[derive(Clone, Copy)]
11376pub struct SessionRpcTelemetry<'a> {
11377    pub(crate) session: &'a Session,
11378}
11379
11380impl<'a> SessionRpcTelemetry<'a> {
11381    /// Gets the telemetry engagement ID currently associated with the session, when available.
11382    ///
11383    /// Wire method: `session.telemetry.getEngagementId`.
11384    ///
11385    /// # Returns
11386    ///
11387    /// Telemetry engagement ID for the session, when available.
11388    ///
11389    /// <div class="warning">
11390    ///
11391    /// **Experimental.** This API is part of an experimental wire-protocol surface
11392    /// and may change or be removed in future SDK or CLI releases. Pin both the
11393    /// SDK and CLI versions if your code depends on it.
11394    ///
11395    /// </div>
11396    pub async fn get_engagement_id(&self) -> Result<SessionTelemetryEngagement, Error> {
11397        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
11398        let _value = self
11399            .session
11400            .client()
11401            .call(
11402                rpc_methods::SESSION_TELEMETRY_GETENGAGEMENTID,
11403                Some(wire_params),
11404            )
11405            .await?;
11406        Ok(serde_json::from_value(_value)?)
11407    }
11408
11409    /// Sets feature override key/value pairs to attach to subsequent telemetry events for the session.
11410    ///
11411    /// Wire method: `session.telemetry.setFeatureOverrides`.
11412    ///
11413    /// # Parameters
11414    ///
11415    /// * `params` - Feature override key/value pairs to attach to subsequent telemetry events from this session.
11416    ///
11417    /// <div class="warning">
11418    ///
11419    /// **Experimental.** This API is part of an experimental wire-protocol surface
11420    /// and may change or be removed in future SDK or CLI releases. Pin both the
11421    /// SDK and CLI versions if your code depends on it.
11422    ///
11423    /// </div>
11424    pub async fn set_feature_overrides(
11425        &self,
11426        params: TelemetrySetFeatureOverridesRequest,
11427    ) -> Result<(), Error> {
11428        let mut wire_params = serde_json::to_value(params)?;
11429        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11430        let _value = self
11431            .session
11432            .client()
11433            .call(
11434                rpc_methods::SESSION_TELEMETRY_SETFEATUREOVERRIDES,
11435                Some(wire_params),
11436            )
11437            .await?;
11438        Ok(())
11439    }
11440}
11441
11442/// `session.tools.*` RPCs.
11443#[derive(Clone, Copy)]
11444pub struct SessionRpcTools<'a> {
11445    pub(crate) session: &'a Session,
11446}
11447
11448impl<'a> SessionRpcTools<'a> {
11449    /// Executes one tool from the session's currently offered tool set through the native invocation pipeline.
11450    ///
11451    /// Wire method: `session.tools.execute`.
11452    ///
11453    /// # Parameters
11454    ///
11455    /// * `params` - A tool name and arguments to execute through the session's native invocation pipeline.
11456    ///
11457    /// # Returns
11458    ///
11459    /// Canonical result returned by a session tool.
11460    ///
11461    /// <div class="warning">
11462    ///
11463    /// **Experimental.** This API is part of an experimental wire-protocol surface
11464    /// and may change or be removed in future SDK or CLI releases. Pin both the
11465    /// SDK and CLI versions if your code depends on it.
11466    ///
11467    /// </div>
11468    pub async fn execute(&self, params: ToolsExecuteRequest) -> Result<ToolResult, Error> {
11469        let mut wire_params = serde_json::to_value(params)?;
11470        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11471        let _value = self
11472            .session
11473            .client()
11474            .call(rpc_methods::SESSION_TOOLS_EXECUTE, Some(wire_params))
11475            .await?;
11476        Ok(serde_json::from_value(_value)?)
11477    }
11478
11479    /// Returns the Rust-owned built-in tool descriptors used to construct the session's offered tool set.
11480    ///
11481    /// Wire method: `session.tools.getBuiltinDescriptors`.
11482    ///
11483    /// # Parameters
11484    ///
11485    /// * `params` - Options controlling how Rust-owned built-in tool descriptors are materialized.
11486    ///
11487    /// # Returns
11488    ///
11489    /// Rust-owned built-in tool descriptors for the session.
11490    ///
11491    /// <div class="warning">
11492    ///
11493    /// **Experimental.** This API is part of an experimental wire-protocol surface
11494    /// and may change or be removed in future SDK or CLI releases. Pin both the
11495    /// SDK and CLI versions if your code depends on it.
11496    ///
11497    /// </div>
11498    pub async fn get_builtin_descriptors(
11499        &self,
11500        params: ToolsGetBuiltinDescriptorsRequest,
11501    ) -> Result<ToolsGetBuiltinDescriptorsResult, Error> {
11502        let mut wire_params = serde_json::to_value(params)?;
11503        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11504        let _value = self
11505            .session
11506            .client()
11507            .call(
11508                rpc_methods::SESSION_TOOLS_GETBUILTINDESCRIPTORS,
11509                Some(wire_params),
11510            )
11511            .await?;
11512        Ok(serde_json::from_value(_value)?)
11513    }
11514
11515    /// Projects a completed task_complete tool call into its label-safe session event payload.
11516    ///
11517    /// Wire method: `session.tools.taskCompleteEventData`.
11518    ///
11519    /// # Parameters
11520    ///
11521    /// * `params` - Task-completion tool arguments and final result used to build a label-safe session event payload.
11522    ///
11523    /// # Returns
11524    ///
11525    /// Task completion notification with summary from the agent
11526    ///
11527    /// <div class="warning">
11528    ///
11529    /// **Experimental.** This API is part of an experimental wire-protocol surface
11530    /// and may change or be removed in future SDK or CLI releases. Pin both the
11531    /// SDK and CLI versions if your code depends on it.
11532    ///
11533    /// </div>
11534    pub async fn task_complete_event_data(
11535        &self,
11536        params: ToolsTaskCompleteEventDataRequest,
11537    ) -> Result<TaskCompleteData, Error> {
11538        let mut wire_params = serde_json::to_value(params)?;
11539        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11540        let _value = self
11541            .session
11542            .client()
11543            .call(
11544                rpc_methods::SESSION_TOOLS_TASKCOMPLETEEVENTDATA,
11545                Some(wire_params),
11546            )
11547            .await?;
11548        Ok(serde_json::from_value(_value)?)
11549    }
11550
11551    /// Provides the result for a pending external tool call.
11552    ///
11553    /// Wire method: `session.tools.handlePendingToolCall`.
11554    ///
11555    /// # Parameters
11556    ///
11557    /// * `params` - Pending external tool call request ID, with the tool result or an error describing why it failed.
11558    ///
11559    /// # Returns
11560    ///
11561    /// Indicates whether the external tool call result was handled successfully.
11562    ///
11563    /// <div class="warning">
11564    ///
11565    /// **Experimental.** This API is part of an experimental wire-protocol surface
11566    /// and may change or be removed in future SDK or CLI releases. Pin both the
11567    /// SDK and CLI versions if your code depends on it.
11568    ///
11569    /// </div>
11570    pub async fn handle_pending_tool_call(
11571        &self,
11572        params: HandlePendingToolCallRequest,
11573    ) -> Result<HandlePendingToolCallResult, Error> {
11574        let mut wire_params = serde_json::to_value(params)?;
11575        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11576        let _value = self
11577            .session
11578            .client()
11579            .call(
11580                rpc_methods::SESSION_TOOLS_HANDLEPENDINGTOOLCALL,
11581                Some(wire_params),
11582            )
11583            .await?;
11584        Ok(serde_json::from_value(_value)?)
11585    }
11586
11587    /// Resolves, builds, and validates the runtime tool list for the session.
11588    ///
11589    /// Wire method: `session.tools.initializeAndValidate`.
11590    ///
11591    /// # Returns
11592    ///
11593    /// 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.
11594    ///
11595    /// <div class="warning">
11596    ///
11597    /// **Experimental.** This API is part of an experimental wire-protocol surface
11598    /// and may change or be removed in future SDK or CLI releases. Pin both the
11599    /// SDK and CLI versions if your code depends on it.
11600    ///
11601    /// </div>
11602    pub async fn initialize_and_validate(&self) -> Result<ToolsInitializeAndValidateResult, Error> {
11603        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
11604        let _value = self
11605            .session
11606            .client()
11607            .call(
11608                rpc_methods::SESSION_TOOLS_INITIALIZEANDVALIDATE,
11609                Some(wire_params),
11610            )
11611            .await?;
11612        Ok(serde_json::from_value(_value)?)
11613    }
11614
11615    /// Returns lightweight metadata for the session's currently initialized tools.
11616    ///
11617    /// Wire method: `session.tools.getCurrentMetadata`.
11618    ///
11619    /// # Returns
11620    ///
11621    /// Current lightweight tool metadata snapshot for the session.
11622    ///
11623    /// <div class="warning">
11624    ///
11625    /// **Experimental.** This API is part of an experimental wire-protocol surface
11626    /// and may change or be removed in future SDK or CLI releases. Pin both the
11627    /// SDK and CLI versions if your code depends on it.
11628    ///
11629    /// </div>
11630    pub async fn get_current_metadata(&self) -> Result<ToolsGetCurrentMetadataResult, Error> {
11631        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
11632        let _value = self
11633            .session
11634            .client()
11635            .call(
11636                rpc_methods::SESSION_TOOLS_GETCURRENTMETADATA,
11637                Some(wire_params),
11638            )
11639            .await?;
11640        Ok(serde_json::from_value(_value)?)
11641    }
11642
11643    /// Atomically replaces the complete externally implemented tool list supplied by the calling connection. Built-in, MCP/plugin, extension-discovered, subagent, and tools supplied by other connections remain unchanged.
11644    ///
11645    /// Wire method: `session.tools.set`.
11646    ///
11647    /// # Parameters
11648    ///
11649    /// * `params` - Complete externally implemented tool list for the calling connection. An empty list removes every tool previously supplied by that connection.
11650    ///
11651    /// # Returns
11652    ///
11653    /// Empty result after replacing the calling connection's externally implemented tools.
11654    ///
11655    /// <div class="warning">
11656    ///
11657    /// **Experimental.** This API is part of an experimental wire-protocol surface
11658    /// and may change or be removed in future SDK or CLI releases. Pin both the
11659    /// SDK and CLI versions if your code depends on it.
11660    ///
11661    /// </div>
11662    pub async fn set(&self, params: ToolsSetRequest) -> Result<ToolsSetResult, Error> {
11663        let mut wire_params = serde_json::to_value(params)?;
11664        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11665        let _value = self
11666            .session
11667            .client()
11668            .call(rpc_methods::SESSION_TOOLS_SET, Some(wire_params))
11669            .await?;
11670        Ok(serde_json::from_value(_value)?)
11671    }
11672
11673    /// Sets the current session's live subagent settings override, which takes precedence over persisted user settings until cleared. Persisted user settings remain the source of truth for future sessions.
11674    ///
11675    /// Wire method: `session.tools.updateSubagentSettings`.
11676    ///
11677    /// # Parameters
11678    ///
11679    /// * `params` - Subagent settings to apply to the current session
11680    ///
11681    /// # Returns
11682    ///
11683    /// Empty result after applying subagent settings
11684    ///
11685    /// <div class="warning">
11686    ///
11687    /// **Experimental.** This API is part of an experimental wire-protocol surface
11688    /// and may change or be removed in future SDK or CLI releases. Pin both the
11689    /// SDK and CLI versions if your code depends on it.
11690    ///
11691    /// </div>
11692    pub async fn update_subagent_settings(
11693        &self,
11694        params: UpdateSubagentSettingsRequest,
11695    ) -> Result<ToolsUpdateSubagentSettingsResult, Error> {
11696        let mut wire_params = serde_json::to_value(params)?;
11697        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11698        let _value = self
11699            .session
11700            .client()
11701            .call(
11702                rpc_methods::SESSION_TOOLS_UPDATESUBAGENTSETTINGS,
11703                Some(wire_params),
11704            )
11705            .await?;
11706        Ok(serde_json::from_value(_value)?)
11707    }
11708}
11709
11710/// `session.ui.*` RPCs.
11711#[derive(Clone, Copy)]
11712pub struct SessionRpcUi<'a> {
11713    pub(crate) session: &'a Session,
11714}
11715
11716impl<'a> SessionRpcUi<'a> {
11717    /// Runs a transient no-tools model query against the current conversation context.
11718    ///
11719    /// Wire method: `session.ui.ephemeralQuery`.
11720    ///
11721    /// # Parameters
11722    ///
11723    /// * `params` - Transient question to answer without adding it to conversation history.
11724    ///
11725    /// # Returns
11726    ///
11727    /// Completed transient query. Ordered chunks and the terminal outcome are also delivered through `ui.ephemeral_query` session events while it runs.
11728    ///
11729    /// <div class="warning">
11730    ///
11731    /// **Experimental.** This API is part of an experimental wire-protocol surface
11732    /// and may change or be removed in future SDK or CLI releases. Pin both the
11733    /// SDK and CLI versions if your code depends on it.
11734    ///
11735    /// </div>
11736    pub async fn ephemeral_query(
11737        &self,
11738        params: UIEphemeralQueryRequest,
11739    ) -> Result<UIEphemeralQueryResult, Error> {
11740        let mut wire_params = serde_json::to_value(params)?;
11741        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11742        let _value = self
11743            .session
11744            .client()
11745            .call(rpc_methods::SESSION_UI_EPHEMERALQUERY, Some(wire_params))
11746            .await?;
11747        Ok(serde_json::from_value(_value)?)
11748    }
11749
11750    /// Requests structured input from a UI-capable client.
11751    ///
11752    /// Wire method: `session.ui.elicitation`.
11753    ///
11754    /// # Parameters
11755    ///
11756    /// * `params` - Prompt message and JSON schema describing the form fields to elicit from the user.
11757    ///
11758    /// # Returns
11759    ///
11760    /// The elicitation response (accept with form values, decline, or cancel)
11761    ///
11762    /// <div class="warning">
11763    ///
11764    /// **Experimental.** This API is part of an experimental wire-protocol surface
11765    /// and may change or be removed in future SDK or CLI releases. Pin both the
11766    /// SDK and CLI versions if your code depends on it.
11767    ///
11768    /// </div>
11769    pub async fn elicitation(
11770        &self,
11771        params: UIElicitationRequest,
11772    ) -> Result<UIElicitationResponse, Error> {
11773        let mut wire_params = serde_json::to_value(params)?;
11774        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11775        let _value = self
11776            .session
11777            .client()
11778            .call(rpc_methods::SESSION_UI_ELICITATION, Some(wire_params))
11779            .await?;
11780        Ok(serde_json::from_value(_value)?)
11781    }
11782
11783    /// Provides the user response for a pending elicitation request.
11784    ///
11785    /// Wire method: `session.ui.handlePendingElicitation`.
11786    ///
11787    /// # Parameters
11788    ///
11789    /// * `params` - Pending elicitation request ID and the user's response (accept/decline/cancel + form values).
11790    ///
11791    /// # Returns
11792    ///
11793    /// Indicates whether the elicitation response was accepted; false if it was already resolved by another client.
11794    ///
11795    /// <div class="warning">
11796    ///
11797    /// **Experimental.** This API is part of an experimental wire-protocol surface
11798    /// and may change or be removed in future SDK or CLI releases. Pin both the
11799    /// SDK and CLI versions if your code depends on it.
11800    ///
11801    /// </div>
11802    pub async fn handle_pending_elicitation(
11803        &self,
11804        params: UIHandlePendingElicitationRequest,
11805    ) -> Result<UIElicitationResult, Error> {
11806        let mut wire_params = serde_json::to_value(params)?;
11807        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11808        let _value = self
11809            .session
11810            .client()
11811            .call(
11812                rpc_methods::SESSION_UI_HANDLEPENDINGELICITATION,
11813                Some(wire_params),
11814            )
11815            .await?;
11816        Ok(serde_json::from_value(_value)?)
11817    }
11818
11819    /// Resolves a pending `user_input.requested` event with the user's response.
11820    ///
11821    /// Wire method: `session.ui.handlePendingUserInput`.
11822    ///
11823    /// # Parameters
11824    ///
11825    /// * `params` - Request ID of a pending `user_input.requested` event and the user's response.
11826    ///
11827    /// # Returns
11828    ///
11829    /// Indicates whether the pending UI request was resolved by this call.
11830    ///
11831    /// <div class="warning">
11832    ///
11833    /// **Experimental.** This API is part of an experimental wire-protocol surface
11834    /// and may change or be removed in future SDK or CLI releases. Pin both the
11835    /// SDK and CLI versions if your code depends on it.
11836    ///
11837    /// </div>
11838    pub async fn handle_pending_user_input(
11839        &self,
11840        params: UIHandlePendingUserInputRequest,
11841    ) -> Result<UIHandlePendingResult, Error> {
11842        let mut wire_params = serde_json::to_value(params)?;
11843        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11844        let _value = self
11845            .session
11846            .client()
11847            .call(
11848                rpc_methods::SESSION_UI_HANDLEPENDINGUSERINPUT,
11849                Some(wire_params),
11850            )
11851            .await?;
11852        Ok(serde_json::from_value(_value)?)
11853    }
11854
11855    /// Resolves a pending `sampling.requested` event with a sampling result, or rejects it.
11856    ///
11857    /// Wire method: `session.ui.handlePendingSampling`.
11858    ///
11859    /// # Parameters
11860    ///
11861    /// * `params` - Request ID of a pending `sampling.requested` event and an optional sampling result payload (omit to reject).
11862    ///
11863    /// # Returns
11864    ///
11865    /// Indicates whether the pending UI request was resolved by this call.
11866    ///
11867    /// <div class="warning">
11868    ///
11869    /// **Experimental.** This API is part of an experimental wire-protocol surface
11870    /// and may change or be removed in future SDK or CLI releases. Pin both the
11871    /// SDK and CLI versions if your code depends on it.
11872    ///
11873    /// </div>
11874    pub async fn handle_pending_sampling(
11875        &self,
11876        params: UIHandlePendingSamplingRequest,
11877    ) -> Result<UIHandlePendingResult, Error> {
11878        let mut wire_params = serde_json::to_value(params)?;
11879        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11880        let _value = self
11881            .session
11882            .client()
11883            .call(
11884                rpc_methods::SESSION_UI_HANDLEPENDINGSAMPLING,
11885                Some(wire_params),
11886            )
11887            .await?;
11888        Ok(serde_json::from_value(_value)?)
11889    }
11890
11891    /// Resolves a pending `auto_mode_switch.requested` event with the user's accept/decline decision.
11892    ///
11893    /// Wire method: `session.ui.handlePendingAutoModeSwitch`.
11894    ///
11895    /// # Parameters
11896    ///
11897    /// * `params` - Request ID of a pending `auto_mode_switch.requested` event and the user's response.
11898    ///
11899    /// # Returns
11900    ///
11901    /// Indicates whether the pending UI request was resolved by this call.
11902    ///
11903    /// <div class="warning">
11904    ///
11905    /// **Experimental.** This API is part of an experimental wire-protocol surface
11906    /// and may change or be removed in future SDK or CLI releases. Pin both the
11907    /// SDK and CLI versions if your code depends on it.
11908    ///
11909    /// </div>
11910    pub async fn handle_pending_auto_mode_switch(
11911        &self,
11912        params: UIHandlePendingAutoModeSwitchRequest,
11913    ) -> Result<UIHandlePendingResult, Error> {
11914        let mut wire_params = serde_json::to_value(params)?;
11915        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11916        let _value = self
11917            .session
11918            .client()
11919            .call(
11920                rpc_methods::SESSION_UI_HANDLEPENDINGAUTOMODESWITCH,
11921                Some(wire_params),
11922            )
11923            .await?;
11924        Ok(serde_json::from_value(_value)?)
11925    }
11926
11927    /// Resolves a pending `session_limits_exhausted.requested` event with the user's selected limit action.
11928    ///
11929    /// Wire method: `session.ui.handlePendingSessionLimitsExhausted`.
11930    ///
11931    /// # Parameters
11932    ///
11933    /// * `params` - Request ID of a pending `session_limits_exhausted.requested` event and the user's selected limit action.
11934    ///
11935    /// # Returns
11936    ///
11937    /// Indicates whether the pending UI request was resolved by this call.
11938    ///
11939    /// <div class="warning">
11940    ///
11941    /// **Experimental.** This API is part of an experimental wire-protocol surface
11942    /// and may change or be removed in future SDK or CLI releases. Pin both the
11943    /// SDK and CLI versions if your code depends on it.
11944    ///
11945    /// </div>
11946    pub async fn handle_pending_session_limits_exhausted(
11947        &self,
11948        params: UIHandlePendingSessionLimitsExhaustedRequest,
11949    ) -> Result<UIHandlePendingResult, Error> {
11950        let mut wire_params = serde_json::to_value(params)?;
11951        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11952        let _value = self
11953            .session
11954            .client()
11955            .call(
11956                rpc_methods::SESSION_UI_HANDLEPENDINGSESSIONLIMITSEXHAUSTED,
11957                Some(wire_params),
11958            )
11959            .await?;
11960        Ok(serde_json::from_value(_value)?)
11961    }
11962
11963    /// Resolves a pending `exit_plan_mode.requested` event with the user's response.
11964    ///
11965    /// Wire method: `session.ui.handlePendingExitPlanMode`.
11966    ///
11967    /// # Parameters
11968    ///
11969    /// * `params` - Request ID of a pending `exit_plan_mode.requested` event and the user's response.
11970    ///
11971    /// # Returns
11972    ///
11973    /// Indicates whether the pending UI request was resolved by this call.
11974    ///
11975    /// <div class="warning">
11976    ///
11977    /// **Experimental.** This API is part of an experimental wire-protocol surface
11978    /// and may change or be removed in future SDK or CLI releases. Pin both the
11979    /// SDK and CLI versions if your code depends on it.
11980    ///
11981    /// </div>
11982    pub async fn handle_pending_exit_plan_mode(
11983        &self,
11984        params: UIHandlePendingExitPlanModeRequest,
11985    ) -> Result<UIHandlePendingResult, Error> {
11986        let mut wire_params = serde_json::to_value(params)?;
11987        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11988        let _value = self
11989            .session
11990            .client()
11991            .call(
11992                rpc_methods::SESSION_UI_HANDLEPENDINGEXITPLANMODE,
11993                Some(wire_params),
11994            )
11995            .await?;
11996        Ok(serde_json::from_value(_value)?)
11997    }
11998
11999    /// Registers an in-process handler for auto-mode-switch requests so the server bridge skips dispatch.
12000    ///
12001    /// Wire method: `session.ui.registerDirectAutoModeSwitchHandler`.
12002    ///
12003    /// # Returns
12004    ///
12005    /// 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).
12006    ///
12007    /// <div class="warning">
12008    ///
12009    /// **Experimental.** This API is part of an experimental wire-protocol surface
12010    /// and may change or be removed in future SDK or CLI releases. Pin both the
12011    /// SDK and CLI versions if your code depends on it.
12012    ///
12013    /// </div>
12014    pub async fn register_direct_auto_mode_switch_handler(
12015        &self,
12016    ) -> Result<UIRegisterDirectAutoModeSwitchHandlerResult, Error> {
12017        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
12018        let _value = self
12019            .session
12020            .client()
12021            .call(
12022                rpc_methods::SESSION_UI_REGISTERDIRECTAUTOMODESWITCHHANDLER,
12023                Some(wire_params),
12024            )
12025            .await?;
12026        Ok(serde_json::from_value(_value)?)
12027    }
12028
12029    /// Unregisters a previously-registered in-process auto-mode-switch handler by its opaque handle.
12030    ///
12031    /// Wire method: `session.ui.unregisterDirectAutoModeSwitchHandler`.
12032    ///
12033    /// # Parameters
12034    ///
12035    /// * `params` - Opaque handle previously returned by `registerDirectAutoModeSwitchHandler` to release.
12036    ///
12037    /// # Returns
12038    ///
12039    /// Indicates whether the handle was active and the registration count was decremented.
12040    ///
12041    /// <div class="warning">
12042    ///
12043    /// **Experimental.** This API is part of an experimental wire-protocol surface
12044    /// and may change or be removed in future SDK or CLI releases. Pin both the
12045    /// SDK and CLI versions if your code depends on it.
12046    ///
12047    /// </div>
12048    pub async fn unregister_direct_auto_mode_switch_handler(
12049        &self,
12050        params: UIUnregisterDirectAutoModeSwitchHandlerRequest,
12051    ) -> Result<UIUnregisterDirectAutoModeSwitchHandlerResult, Error> {
12052        let mut wire_params = serde_json::to_value(params)?;
12053        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
12054        let _value = self
12055            .session
12056            .client()
12057            .call(
12058                rpc_methods::SESSION_UI_UNREGISTERDIRECTAUTOMODESWITCHHANDLER,
12059                Some(wire_params),
12060            )
12061            .await?;
12062        Ok(serde_json::from_value(_value)?)
12063    }
12064}
12065
12066/// `session.usage.*` RPCs.
12067#[derive(Clone, Copy)]
12068pub struct SessionRpcUsage<'a> {
12069    pub(crate) session: &'a Session,
12070}
12071
12072impl<'a> SessionRpcUsage<'a> {
12073    /// Gets accumulated usage metrics for the session.
12074    ///
12075    /// Wire method: `session.usage.getMetrics`.
12076    ///
12077    /// # Returns
12078    ///
12079    /// Accumulated session usage metrics, including premium request cost, token counts, model breakdown, and code-change totals.
12080    ///
12081    /// <div class="warning">
12082    ///
12083    /// **Experimental.** This API is part of an experimental wire-protocol surface
12084    /// and may change or be removed in future SDK or CLI releases. Pin both the
12085    /// SDK and CLI versions if your code depends on it.
12086    ///
12087    /// </div>
12088    pub async fn get_metrics(&self) -> Result<UsageGetMetricsResult, Error> {
12089        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
12090        let _value = self
12091            .session
12092            .client()
12093            .call(rpc_methods::SESSION_USAGE_GETMETRICS, Some(wire_params))
12094            .await?;
12095        Ok(serde_json::from_value(_value)?)
12096    }
12097}
12098
12099/// `session.visibility.*` RPCs.
12100#[derive(Clone, Copy)]
12101pub struct SessionRpcVisibility<'a> {
12102    pub(crate) session: &'a Session,
12103}
12104
12105impl<'a> SessionRpcVisibility<'a> {
12106    /// Returns the session's current Mission Control sharing status and shareable GitHub URL. Reflects whether the synced session is visible to repository readers ("repo") or restricted to its creator and collaborators ("unshared").
12107    ///
12108    /// Wire method: `session.visibility.get`.
12109    ///
12110    /// # Returns
12111    ///
12112    /// Current sharing status and shareable GitHub URL for a session.
12113    ///
12114    /// <div class="warning">
12115    ///
12116    /// **Experimental.** This API is part of an experimental wire-protocol surface
12117    /// and may change or be removed in future SDK or CLI releases. Pin both the
12118    /// SDK and CLI versions if your code depends on it.
12119    ///
12120    /// </div>
12121    pub async fn get(&self) -> Result<VisibilityGetResult, Error> {
12122        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
12123        let _value = self
12124            .session
12125            .client()
12126            .call(rpc_methods::SESSION_VISIBILITY_GET, Some(wire_params))
12127            .await?;
12128        Ok(serde_json::from_value(_value)?)
12129    }
12130
12131    /// Sets the session's Mission Control sharing status, controlling whether the synced session is visible to repository readers. Returns the effective status and shareable GitHub URL after the change.
12132    ///
12133    /// Wire method: `session.visibility.set`.
12134    ///
12135    /// # Parameters
12136    ///
12137    /// * `params` - Desired sharing status for the session.
12138    ///
12139    /// # Returns
12140    ///
12141    /// Effective sharing status and shareable GitHub URL after updating session visibility.
12142    ///
12143    /// <div class="warning">
12144    ///
12145    /// **Experimental.** This API is part of an experimental wire-protocol surface
12146    /// and may change or be removed in future SDK or CLI releases. Pin both the
12147    /// SDK and CLI versions if your code depends on it.
12148    ///
12149    /// </div>
12150    pub async fn set(&self, params: VisibilitySetRequest) -> Result<VisibilitySetResult, Error> {
12151        let mut wire_params = serde_json::to_value(params)?;
12152        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
12153        let _value = self
12154            .session
12155            .client()
12156            .call(rpc_methods::SESSION_VISIBILITY_SET, Some(wire_params))
12157            .await?;
12158        Ok(serde_json::from_value(_value)?)
12159    }
12160}
12161
12162/// `session.workflow.*` RPCs.
12163#[derive(Clone, Copy)]
12164pub struct SessionRpcWorkflow<'a> {
12165    pub(crate) session: &'a Session,
12166}
12167
12168impl<'a> SessionRpcWorkflow<'a> {
12169    /// `session.workflow.journal.*` sub-namespace.
12170    pub fn journal(&self) -> SessionRpcWorkflowJournal<'a> {
12171        SessionRpcWorkflowJournal {
12172            session: self.session,
12173        }
12174    }
12175
12176    /// Runs a registered dynamic workflow by name at the top level.
12177    ///
12178    /// Wire method: `session.workflow.run`.
12179    ///
12180    /// # Parameters
12181    ///
12182    /// * `params` - Parameters for invoking a registered workflow.
12183    ///
12184    /// # Returns
12185    ///
12186    /// Complete current or terminal workflow run envelope.
12187    ///
12188    /// <div class="warning">
12189    ///
12190    /// **Experimental.** This API is part of an experimental wire-protocol surface
12191    /// and may change or be removed in future SDK or CLI releases. Pin both the
12192    /// SDK and CLI versions if your code depends on it.
12193    ///
12194    /// </div>
12195    pub async fn run(&self, params: WorkflowRunRequest) -> Result<WorkflowRunResult, Error> {
12196        let mut wire_params = serde_json::to_value(params)?;
12197        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
12198        let _value = self
12199            .session
12200            .client()
12201            .call(rpc_methods::SESSION_WORKFLOW_RUN, Some(wire_params))
12202            .await?;
12203        Ok(serde_json::from_value(_value)?)
12204    }
12205
12206    /// Resumes a dynamic workflow run using its persisted name, arguments, journal, and accounting.
12207    ///
12208    /// Wire method: `session.workflow.resume`.
12209    ///
12210    /// # Parameters
12211    ///
12212    /// * `params` - Parameters for resuming a workflow run from its persisted identity.
12213    ///
12214    /// # Returns
12215    ///
12216    /// Resolved persisted workflow identity and resumed run envelope.
12217    ///
12218    /// <div class="warning">
12219    ///
12220    /// **Experimental.** This API is part of an experimental wire-protocol surface
12221    /// and may change or be removed in future SDK or CLI releases. Pin both the
12222    /// SDK and CLI versions if your code depends on it.
12223    ///
12224    /// </div>
12225    pub async fn resume(
12226        &self,
12227        params: WorkflowResumeRequest,
12228    ) -> Result<WorkflowResumeResult, Error> {
12229        let mut wire_params = serde_json::to_value(params)?;
12230        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
12231        let _value = self
12232            .session
12233            .client()
12234            .call(rpc_methods::SESSION_WORKFLOW_RESUME, Some(wire_params))
12235            .await?;
12236        Ok(serde_json::from_value(_value)?)
12237    }
12238
12239    /// Internal tool-originated dynamic workflow invocation.
12240    ///
12241    /// Wire method: `session.workflow.runFromTool`.
12242    ///
12243    /// # Parameters
12244    ///
12245    /// * `params` - Internal parameters for invoking a registered workflow from a tool.
12246    ///
12247    /// # Returns
12248    ///
12249    /// Complete current or terminal workflow run envelope.
12250    ///
12251    /// <div class="warning">
12252    ///
12253    /// **Experimental.** This API is part of an experimental wire-protocol surface
12254    /// and may change or be removed in future SDK or CLI releases. Pin both the
12255    /// SDK and CLI versions if your code depends on it.
12256    ///
12257    /// </div>
12258    pub(crate) async fn run_from_tool(
12259        &self,
12260        params: WorkflowToolRunRequest,
12261    ) -> Result<WorkflowRunResult, Error> {
12262        let mut wire_params = serde_json::to_value(params)?;
12263        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
12264        let _value = self
12265            .session
12266            .client()
12267            .call(rpc_methods::SESSION_WORKFLOW_RUNFROMTOOL, Some(wire_params))
12268            .await?;
12269        Ok(serde_json::from_value(_value)?)
12270    }
12271
12272    /// Internal tool-originated dynamic workflow resume.
12273    ///
12274    /// Wire method: `session.workflow.resumeFromTool`.
12275    ///
12276    /// # Parameters
12277    ///
12278    /// * `params` - Internal parameters for resuming a workflow run from a tool.
12279    ///
12280    /// # Returns
12281    ///
12282    /// Resolved persisted workflow identity and resumed run envelope.
12283    ///
12284    /// <div class="warning">
12285    ///
12286    /// **Experimental.** This API is part of an experimental wire-protocol surface
12287    /// and may change or be removed in future SDK or CLI releases. Pin both the
12288    /// SDK and CLI versions if your code depends on it.
12289    ///
12290    /// </div>
12291    pub(crate) async fn resume_from_tool(
12292        &self,
12293        params: WorkflowToolResumeRequest,
12294    ) -> Result<WorkflowResumeResult, Error> {
12295        let mut wire_params = serde_json::to_value(params)?;
12296        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
12297        let _value = self
12298            .session
12299            .client()
12300            .call(
12301                rpc_methods::SESSION_WORKFLOW_RESUMEFROMTOOL,
12302                Some(wire_params),
12303            )
12304            .await?;
12305        Ok(serde_json::from_value(_value)?)
12306    }
12307
12308    /// Gets the current or settled envelope for a dynamic workflow run.
12309    ///
12310    /// Wire method: `session.workflow.getRun`.
12311    ///
12312    /// # Parameters
12313    ///
12314    /// * `params` - Parameters for retrieving a workflow run.
12315    ///
12316    /// # Returns
12317    ///
12318    /// Complete current or terminal workflow run envelope.
12319    ///
12320    /// <div class="warning">
12321    ///
12322    /// **Experimental.** This API is part of an experimental wire-protocol surface
12323    /// and may change or be removed in future SDK or CLI releases. Pin both the
12324    /// SDK and CLI versions if your code depends on it.
12325    ///
12326    /// </div>
12327    pub async fn get_run(&self, params: WorkflowGetRunRequest) -> Result<WorkflowRunResult, Error> {
12328        let mut wire_params = serde_json::to_value(params)?;
12329        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
12330        let _value = self
12331            .session
12332            .client()
12333            .call(rpc_methods::SESSION_WORKFLOW_GETRUN, Some(wire_params))
12334            .await?;
12335        Ok(serde_json::from_value(_value)?)
12336    }
12337
12338    /// Lists durable dynamic workflow runs for this session in creation order.
12339    ///
12340    /// Wire method: `session.workflow.listRuns`.
12341    ///
12342    /// # Parameters
12343    ///
12344    /// * `params` - Parameters for paging workflow runs.
12345    ///
12346    /// # Returns
12347    ///
12348    /// A page of workflow runs in durable creation order.
12349    ///
12350    /// <div class="warning">
12351    ///
12352    /// **Experimental.** This API is part of an experimental wire-protocol surface
12353    /// and may change or be removed in future SDK or CLI releases. Pin both the
12354    /// SDK and CLI versions if your code depends on it.
12355    ///
12356    /// </div>
12357    pub async fn list_runs(
12358        &self,
12359        params: WorkflowListRunsRequest,
12360    ) -> Result<WorkflowListRunsResult, Error> {
12361        let mut wire_params = serde_json::to_value(params)?;
12362        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
12363        let _value = self
12364            .session
12365            .client()
12366            .call(rpc_methods::SESSION_WORKFLOW_LISTRUNS, Some(wire_params))
12367            .await?;
12368        Ok(serde_json::from_value(_value)?)
12369    }
12370
12371    /// Gets durable and live observability detail for one dynamic workflow run.
12372    ///
12373    /// Wire method: `session.workflow.getRunDetail`.
12374    ///
12375    /// # Parameters
12376    ///
12377    /// * `params` - Parameters for retrieving a workflow run.
12378    ///
12379    /// # Returns
12380    ///
12381    /// Full workflow run observability detail.
12382    ///
12383    /// <div class="warning">
12384    ///
12385    /// **Experimental.** This API is part of an experimental wire-protocol surface
12386    /// and may change or be removed in future SDK or CLI releases. Pin both the
12387    /// SDK and CLI versions if your code depends on it.
12388    ///
12389    /// </div>
12390    pub async fn get_run_detail(
12391        &self,
12392        params: WorkflowGetRunRequest,
12393    ) -> Result<WorkflowRunDetail, Error> {
12394        let mut wire_params = serde_json::to_value(params)?;
12395        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
12396        let _value = self
12397            .session
12398            .client()
12399            .call(
12400                rpc_methods::SESSION_WORKFLOW_GETRUNDETAIL,
12401                Some(wire_params),
12402            )
12403            .await?;
12404        Ok(serde_json::from_value(_value)?)
12405    }
12406
12407    /// Pages durable progress for one dynamic workflow run.
12408    ///
12409    /// Wire method: `session.workflow.getRunProgress`.
12410    ///
12411    /// # Parameters
12412    ///
12413    /// * `params` - Parameters for paging workflow progress.
12414    ///
12415    /// # Returns
12416    ///
12417    /// A bidirectional page of workflow progress.
12418    ///
12419    /// <div class="warning">
12420    ///
12421    /// **Experimental.** This API is part of an experimental wire-protocol surface
12422    /// and may change or be removed in future SDK or CLI releases. Pin both the
12423    /// SDK and CLI versions if your code depends on it.
12424    ///
12425    /// </div>
12426    pub async fn get_run_progress(
12427        &self,
12428        params: WorkflowGetRunProgressRequest,
12429    ) -> Result<WorkflowProgressPage, Error> {
12430        let mut wire_params = serde_json::to_value(params)?;
12431        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
12432        let _value = self
12433            .session
12434            .client()
12435            .call(
12436                rpc_methods::SESSION_WORKFLOW_GETRUNPROGRESS,
12437                Some(wire_params),
12438            )
12439            .await?;
12440        Ok(serde_json::from_value(_value)?)
12441    }
12442
12443    /// Requests cancellation of a dynamic workflow run and returns its run envelope.
12444    ///
12445    /// Wire method: `session.workflow.cancel`.
12446    ///
12447    /// # Parameters
12448    ///
12449    /// * `params` - Parameters for cancelling a workflow run.
12450    ///
12451    /// # Returns
12452    ///
12453    /// Complete current or terminal workflow run envelope.
12454    ///
12455    /// <div class="warning">
12456    ///
12457    /// **Experimental.** This API is part of an experimental wire-protocol surface
12458    /// and may change or be removed in future SDK or CLI releases. Pin both the
12459    /// SDK and CLI versions if your code depends on it.
12460    ///
12461    /// </div>
12462    pub async fn cancel(&self, params: WorkflowCancelRequest) -> Result<WorkflowRunResult, Error> {
12463        let mut wire_params = serde_json::to_value(params)?;
12464        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
12465        let _value = self
12466            .session
12467            .client()
12468            .call(rpc_methods::SESSION_WORKFLOW_CANCEL, Some(wire_params))
12469            .await?;
12470        Ok(serde_json::from_value(_value)?)
12471    }
12472
12473    /// Pauses a running dynamic workflow and returns its settled run envelope.
12474    ///
12475    /// Wire method: `session.workflow.pause`.
12476    ///
12477    /// # Parameters
12478    ///
12479    /// * `params` - Parameters for pausing a running workflow.
12480    ///
12481    /// # Returns
12482    ///
12483    /// Complete current or terminal workflow run envelope.
12484    ///
12485    /// <div class="warning">
12486    ///
12487    /// **Experimental.** This API is part of an experimental wire-protocol surface
12488    /// and may change or be removed in future SDK or CLI releases. Pin both the
12489    /// SDK and CLI versions if your code depends on it.
12490    ///
12491    /// </div>
12492    pub async fn pause(&self, params: WorkflowPauseRequest) -> Result<WorkflowRunResult, Error> {
12493        let mut wire_params = serde_json::to_value(params)?;
12494        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
12495        let _value = self
12496            .session
12497            .client()
12498            .call(rpc_methods::SESSION_WORKFLOW_PAUSE, Some(wire_params))
12499            .await?;
12500        Ok(serde_json::from_value(_value)?)
12501    }
12502
12503    /// Atomically pauses an owned dynamic workflow attempt at a durable checkpoint.
12504    ///
12505    /// Wire method: `session.workflow.pauseAtCheckpoint`.
12506    ///
12507    /// # Parameters
12508    ///
12509    /// * `params` - Parameters for an owned durable pause checkpoint.
12510    ///
12511    /// <div class="warning">
12512    ///
12513    /// **Experimental.** This API is part of an experimental wire-protocol surface
12514    /// and may change or be removed in future SDK or CLI releases. Pin both the
12515    /// SDK and CLI versions if your code depends on it.
12516    ///
12517    /// </div>
12518    pub(crate) async fn pause_at_checkpoint(
12519        &self,
12520        params: WorkflowPauseCheckpointRequest,
12521    ) -> Result<WorkflowPauseCheckpointResult, Error> {
12522        let mut wire_params = serde_json::to_value(params)?;
12523        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
12524        let _value = self
12525            .session
12526            .client()
12527            .call(
12528                rpc_methods::SESSION_WORKFLOW_PAUSEATCHECKPOINT,
12529                Some(wire_params),
12530            )
12531            .await?;
12532        Ok(serde_json::from_value(_value)?)
12533    }
12534
12535    /// Records a batch of ordered dynamic workflow progress lines.
12536    ///
12537    /// Wire method: `session.workflow.log`.
12538    ///
12539    /// # Parameters
12540    ///
12541    /// * `params` - Parameters for recording workflow progress.
12542    ///
12543    /// # Returns
12544    ///
12545    /// Acknowledgement that a workflow request was accepted.
12546    ///
12547    /// <div class="warning">
12548    ///
12549    /// **Experimental.** This API is part of an experimental wire-protocol surface
12550    /// and may change or be removed in future SDK or CLI releases. Pin both the
12551    /// SDK and CLI versions if your code depends on it.
12552    ///
12553    /// </div>
12554    pub async fn log(&self, params: WorkflowLogRequest) -> Result<WorkflowAckResult, Error> {
12555        let mut wire_params = serde_json::to_value(params)?;
12556        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
12557        let _value = self
12558            .session
12559            .client()
12560            .call(rpc_methods::SESSION_WORKFLOW_LOG, Some(wire_params))
12561            .await?;
12562        Ok(serde_json::from_value(_value)?)
12563    }
12564
12565    /// Runs one dynamic-workflow-scoped subagent and returns its result.
12566    ///
12567    /// Wire method: `session.workflow.agent`.
12568    ///
12569    /// # Parameters
12570    ///
12571    /// * `params` - Parameters for one workflow-scoped subagent call.
12572    ///
12573    /// # Returns
12574    ///
12575    /// Result of one workflow-scoped subagent call.
12576    ///
12577    /// <div class="warning">
12578    ///
12579    /// **Experimental.** This API is part of an experimental wire-protocol surface
12580    /// and may change or be removed in future SDK or CLI releases. Pin both the
12581    /// SDK and CLI versions if your code depends on it.
12582    ///
12583    /// </div>
12584    pub async fn agent(&self, params: WorkflowAgentRequest) -> Result<WorkflowAgentResult, Error> {
12585        let mut wire_params = serde_json::to_value(params)?;
12586        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
12587        let _value = self
12588            .session
12589            .client()
12590            .call(rpc_methods::SESSION_WORKFLOW_AGENT, Some(wire_params))
12591            .await?;
12592        Ok(serde_json::from_value(_value)?)
12593    }
12594}
12595
12596/// `session.workflow.journal.*` RPCs.
12597#[derive(Clone, Copy)]
12598pub struct SessionRpcWorkflowJournal<'a> {
12599    pub(crate) session: &'a Session,
12600}
12601
12602impl<'a> SessionRpcWorkflowJournal<'a> {
12603    /// Reads a memoized dynamic workflow journal entry.
12604    ///
12605    /// Wire method: `session.workflow.journal.get`.
12606    ///
12607    /// # Parameters
12608    ///
12609    /// * `params` - Parameters for reading a workflow journal entry.
12610    ///
12611    /// # Returns
12612    ///
12613    /// Result of reading a workflow journal entry.
12614    ///
12615    /// <div class="warning">
12616    ///
12617    /// **Experimental.** This API is part of an experimental wire-protocol surface
12618    /// and may change or be removed in future SDK or CLI releases. Pin both the
12619    /// SDK and CLI versions if your code depends on it.
12620    ///
12621    /// </div>
12622    pub async fn get(
12623        &self,
12624        params: WorkflowJournalGetRequest,
12625    ) -> Result<WorkflowJournalGetResult, Error> {
12626        let mut wire_params = serde_json::to_value(params)?;
12627        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
12628        let _value = self
12629            .session
12630            .client()
12631            .call(rpc_methods::SESSION_WORKFLOW_JOURNAL_GET, Some(wire_params))
12632            .await?;
12633        Ok(serde_json::from_value(_value)?)
12634    }
12635
12636    /// Stores a memoized dynamic workflow journal entry.
12637    ///
12638    /// Wire method: `session.workflow.journal.put`.
12639    ///
12640    /// # Parameters
12641    ///
12642    /// * `params` - Parameters for storing a workflow journal entry.
12643    ///
12644    /// # Returns
12645    ///
12646    /// Acknowledgement that a workflow request was accepted.
12647    ///
12648    /// <div class="warning">
12649    ///
12650    /// **Experimental.** This API is part of an experimental wire-protocol surface
12651    /// and may change or be removed in future SDK or CLI releases. Pin both the
12652    /// SDK and CLI versions if your code depends on it.
12653    ///
12654    /// </div>
12655    pub async fn put(&self, params: WorkflowJournalPutRequest) -> Result<WorkflowAckResult, Error> {
12656        let mut wire_params = serde_json::to_value(params)?;
12657        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
12658        let _value = self
12659            .session
12660            .client()
12661            .call(rpc_methods::SESSION_WORKFLOW_JOURNAL_PUT, Some(wire_params))
12662            .await?;
12663        Ok(serde_json::from_value(_value)?)
12664    }
12665}
12666
12667/// `session.workspaces.*` RPCs.
12668#[derive(Clone, Copy)]
12669pub struct SessionRpcWorkspaces<'a> {
12670    pub(crate) session: &'a Session,
12671}
12672
12673impl<'a> SessionRpcWorkspaces<'a> {
12674    /// Gets current workspace metadata for the session.
12675    ///
12676    /// Wire method: `session.workspaces.getWorkspace`.
12677    ///
12678    /// # Returns
12679    ///
12680    /// Current workspace metadata for the session, including its absolute filesystem path when available.
12681    ///
12682    /// <div class="warning">
12683    ///
12684    /// **Experimental.** This API is part of an experimental wire-protocol surface
12685    /// and may change or be removed in future SDK or CLI releases. Pin both the
12686    /// SDK and CLI versions if your code depends on it.
12687    ///
12688    /// </div>
12689    pub async fn get_workspace(&self) -> Result<WorkspacesGetWorkspaceResult, Error> {
12690        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
12691        let _value = self
12692            .session
12693            .client()
12694            .call(
12695                rpc_methods::SESSION_WORKSPACES_GETWORKSPACE,
12696                Some(wire_params),
12697            )
12698            .await?;
12699        Ok(serde_json::from_value(_value)?)
12700    }
12701
12702    /// Updates workspace metadata for a local session and returns the refreshed workspace.
12703    ///
12704    /// Wire method: `session.workspaces.updateMetadata`.
12705    ///
12706    /// # Parameters
12707    ///
12708    /// * `params` - Workspace metadata fields to update.
12709    ///
12710    /// # Returns
12711    ///
12712    /// Current workspace metadata for the session, including its absolute filesystem path when available.
12713    ///
12714    /// <div class="warning">
12715    ///
12716    /// **Experimental.** This API is part of an experimental wire-protocol surface
12717    /// and may change or be removed in future SDK or CLI releases. Pin both the
12718    /// SDK and CLI versions if your code depends on it.
12719    ///
12720    /// </div>
12721    pub async fn update_metadata(
12722        &self,
12723        params: WorkspacesUpdateMetadataRequest,
12724    ) -> Result<WorkspacesGetWorkspaceResult, Error> {
12725        let mut wire_params = serde_json::to_value(params)?;
12726        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
12727        let _value = self
12728            .session
12729            .client()
12730            .call(
12731                rpc_methods::SESSION_WORKSPACES_UPDATEMETADATA,
12732                Some(wire_params),
12733            )
12734            .await?;
12735        Ok(serde_json::from_value(_value)?)
12736    }
12737
12738    /// Ensures a local session workspace exists and returns it.
12739    ///
12740    /// Wire method: `session.workspaces.ensure`.
12741    ///
12742    /// # Parameters
12743    ///
12744    /// * `params` - Optional session context used when creating a local workspace.
12745    ///
12746    /// # Returns
12747    ///
12748    /// Current workspace metadata for the session, including its absolute filesystem path when available.
12749    ///
12750    /// <div class="warning">
12751    ///
12752    /// **Experimental.** This API is part of an experimental wire-protocol surface
12753    /// and may change or be removed in future SDK or CLI releases. Pin both the
12754    /// SDK and CLI versions if your code depends on it.
12755    ///
12756    /// </div>
12757    pub async fn ensure(
12758        &self,
12759        params: WorkspacesEnsureRequest,
12760    ) -> Result<WorkspacesGetWorkspaceResult, Error> {
12761        let mut wire_params = serde_json::to_value(params)?;
12762        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
12763        let _value = self
12764            .session
12765            .client()
12766            .call(rpc_methods::SESSION_WORKSPACES_ENSURE, Some(wire_params))
12767            .await?;
12768        Ok(serde_json::from_value(_value)?)
12769    }
12770
12771    /// Lists files stored in the session workspace files directory.
12772    ///
12773    /// Wire method: `session.workspaces.listFiles`.
12774    ///
12775    /// # Returns
12776    ///
12777    /// Relative paths of files stored in the session workspace files directory.
12778    ///
12779    /// <div class="warning">
12780    ///
12781    /// **Experimental.** This API is part of an experimental wire-protocol surface
12782    /// and may change or be removed in future SDK or CLI releases. Pin both the
12783    /// SDK and CLI versions if your code depends on it.
12784    ///
12785    /// </div>
12786    pub async fn list_files(&self) -> Result<WorkspacesListFilesResult, Error> {
12787        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
12788        let _value = self
12789            .session
12790            .client()
12791            .call(rpc_methods::SESSION_WORKSPACES_LISTFILES, Some(wire_params))
12792            .await?;
12793        Ok(serde_json::from_value(_value)?)
12794    }
12795
12796    /// Reads a file from the session workspace files directory.
12797    ///
12798    /// Wire method: `session.workspaces.readFile`.
12799    ///
12800    /// # Parameters
12801    ///
12802    /// * `params` - Relative path of the workspace file to read.
12803    ///
12804    /// # Returns
12805    ///
12806    /// Contents of the requested workspace file as a UTF-8 string.
12807    ///
12808    /// <div class="warning">
12809    ///
12810    /// **Experimental.** This API is part of an experimental wire-protocol surface
12811    /// and may change or be removed in future SDK or CLI releases. Pin both the
12812    /// SDK and CLI versions if your code depends on it.
12813    ///
12814    /// </div>
12815    pub async fn read_file(
12816        &self,
12817        params: WorkspacesReadFileRequest,
12818    ) -> Result<WorkspacesReadFileResult, Error> {
12819        let mut wire_params = serde_json::to_value(params)?;
12820        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
12821        let _value = self
12822            .session
12823            .client()
12824            .call(rpc_methods::SESSION_WORKSPACES_READFILE, Some(wire_params))
12825            .await?;
12826        Ok(serde_json::from_value(_value)?)
12827    }
12828
12829    /// Creates or overwrites a file in the session workspace files directory.
12830    ///
12831    /// Wire method: `session.workspaces.createFile`.
12832    ///
12833    /// # Parameters
12834    ///
12835    /// * `params` - Relative path and UTF-8 content for the workspace file to create or overwrite.
12836    ///
12837    /// <div class="warning">
12838    ///
12839    /// **Experimental.** This API is part of an experimental wire-protocol surface
12840    /// and may change or be removed in future SDK or CLI releases. Pin both the
12841    /// SDK and CLI versions if your code depends on it.
12842    ///
12843    /// </div>
12844    pub async fn create_file(&self, params: WorkspacesCreateFileRequest) -> Result<(), Error> {
12845        let mut wire_params = serde_json::to_value(params)?;
12846        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
12847        let _value = self
12848            .session
12849            .client()
12850            .call(
12851                rpc_methods::SESSION_WORKSPACES_CREATEFILE,
12852                Some(wire_params),
12853            )
12854            .await?;
12855        Ok(())
12856    }
12857
12858    /// Returns metadata for a file or directory in the session workspace files directory.
12859    ///
12860    /// Wire method: `session.workspaces.statFile`.
12861    ///
12862    /// # Parameters
12863    ///
12864    /// * `params` - Relative path of the workspace file or directory to inspect.
12865    ///
12866    /// # Returns
12867    ///
12868    /// Filesystem metadata for a path in the session workspace files directory.
12869    ///
12870    /// <div class="warning">
12871    ///
12872    /// **Experimental.** This API is part of an experimental wire-protocol surface
12873    /// and may change or be removed in future SDK or CLI releases. Pin both the
12874    /// SDK and CLI versions if your code depends on it.
12875    ///
12876    /// </div>
12877    pub async fn stat_file(
12878        &self,
12879        params: WorkspacesStatFileRequest,
12880    ) -> Result<WorkspacesStatFileResult, Error> {
12881        let mut wire_params = serde_json::to_value(params)?;
12882        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
12883        let _value = self
12884            .session
12885            .client()
12886            .call(rpc_methods::SESSION_WORKSPACES_STATFILE, Some(wire_params))
12887            .await?;
12888        Ok(serde_json::from_value(_value)?)
12889    }
12890
12891    /// Creates a directory in the session workspace files directory.
12892    ///
12893    /// Wire method: `session.workspaces.createDirectory`.
12894    ///
12895    /// # Parameters
12896    ///
12897    /// * `params` - Directory to create within the session workspace files directory.
12898    ///
12899    /// <div class="warning">
12900    ///
12901    /// **Experimental.** This API is part of an experimental wire-protocol surface
12902    /// and may change or be removed in future SDK or CLI releases. Pin both the
12903    /// SDK and CLI versions if your code depends on it.
12904    ///
12905    /// </div>
12906    pub async fn create_directory(
12907        &self,
12908        params: WorkspacesCreateDirectoryRequest,
12909    ) -> Result<(), Error> {
12910        let mut wire_params = serde_json::to_value(params)?;
12911        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
12912        let _value = self
12913            .session
12914            .client()
12915            .call(
12916                rpc_methods::SESSION_WORKSPACES_CREATEDIRECTORY,
12917                Some(wire_params),
12918            )
12919            .await?;
12920        Ok(())
12921    }
12922
12923    /// Removes a file or directory from the session workspace files directory.
12924    ///
12925    /// Wire method: `session.workspaces.removePath`.
12926    ///
12927    /// # Parameters
12928    ///
12929    /// * `params` - File or directory to remove from the session workspace files directory.
12930    ///
12931    /// <div class="warning">
12932    ///
12933    /// **Experimental.** This API is part of an experimental wire-protocol surface
12934    /// and may change or be removed in future SDK or CLI releases. Pin both the
12935    /// SDK and CLI versions if your code depends on it.
12936    ///
12937    /// </div>
12938    pub async fn remove_path(&self, params: WorkspacesRemovePathRequest) -> Result<(), Error> {
12939        let mut wire_params = serde_json::to_value(params)?;
12940        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
12941        let _value = self
12942            .session
12943            .client()
12944            .call(
12945                rpc_methods::SESSION_WORKSPACES_REMOVEPATH,
12946                Some(wire_params),
12947            )
12948            .await?;
12949        Ok(())
12950    }
12951
12952    /// Renames a file or directory within the session workspace files directory.
12953    ///
12954    /// Wire method: `session.workspaces.renamePath`.
12955    ///
12956    /// # Parameters
12957    ///
12958    /// * `params` - Source and destination paths for a rename within the session workspace files directory.
12959    ///
12960    /// <div class="warning">
12961    ///
12962    /// **Experimental.** This API is part of an experimental wire-protocol surface
12963    /// and may change or be removed in future SDK or CLI releases. Pin both the
12964    /// SDK and CLI versions if your code depends on it.
12965    ///
12966    /// </div>
12967    pub async fn rename_path(&self, params: WorkspacesRenamePathRequest) -> Result<(), Error> {
12968        let mut wire_params = serde_json::to_value(params)?;
12969        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
12970        let _value = self
12971            .session
12972            .client()
12973            .call(
12974                rpc_methods::SESSION_WORKSPACES_RENAMEPATH,
12975                Some(wire_params),
12976            )
12977            .await?;
12978        Ok(())
12979    }
12980
12981    /// Lists workspace checkpoints in chronological order.
12982    ///
12983    /// Wire method: `session.workspaces.listCheckpoints`.
12984    ///
12985    /// # Returns
12986    ///
12987    /// Workspace checkpoints in chronological order; empty when the workspace is not enabled.
12988    ///
12989    /// <div class="warning">
12990    ///
12991    /// **Experimental.** This API is part of an experimental wire-protocol surface
12992    /// and may change or be removed in future SDK or CLI releases. Pin both the
12993    /// SDK and CLI versions if your code depends on it.
12994    ///
12995    /// </div>
12996    pub async fn list_checkpoints(&self) -> Result<WorkspacesListCheckpointsResult, Error> {
12997        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
12998        let _value = self
12999            .session
13000            .client()
13001            .call(
13002                rpc_methods::SESSION_WORKSPACES_LISTCHECKPOINTS,
13003                Some(wire_params),
13004            )
13005            .await?;
13006        Ok(serde_json::from_value(_value)?)
13007    }
13008
13009    /// Reads the content of a workspace checkpoint by number.
13010    ///
13011    /// Wire method: `session.workspaces.readCheckpoint`.
13012    ///
13013    /// # Parameters
13014    ///
13015    /// * `params` - Checkpoint number to read.
13016    ///
13017    /// # Returns
13018    ///
13019    /// Checkpoint content as a UTF-8 string, or null when the checkpoint or workspace is missing.
13020    ///
13021    /// <div class="warning">
13022    ///
13023    /// **Experimental.** This API is part of an experimental wire-protocol surface
13024    /// and may change or be removed in future SDK or CLI releases. Pin both the
13025    /// SDK and CLI versions if your code depends on it.
13026    ///
13027    /// </div>
13028    pub async fn read_checkpoint(
13029        &self,
13030        params: WorkspacesReadCheckpointRequest,
13031    ) -> Result<WorkspacesReadCheckpointResult, Error> {
13032        let mut wire_params = serde_json::to_value(params)?;
13033        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
13034        let _value = self
13035            .session
13036            .client()
13037            .call(
13038                rpc_methods::SESSION_WORKSPACES_READCHECKPOINT,
13039                Some(wire_params),
13040            )
13041            .await?;
13042        Ok(serde_json::from_value(_value)?)
13043    }
13044
13045    /// Adds a compaction summary checkpoint to the local session workspace.
13046    ///
13047    /// Wire method: `session.workspaces.addSummary`.
13048    ///
13049    /// # Parameters
13050    ///
13051    /// * `params` - Compaction summary checkpoint to persist.
13052    ///
13053    /// # Returns
13054    ///
13055    /// Persisted summary metadata and refreshed workspace metadata.
13056    ///
13057    /// <div class="warning">
13058    ///
13059    /// **Experimental.** This API is part of an experimental wire-protocol surface
13060    /// and may change or be removed in future SDK or CLI releases. Pin both the
13061    /// SDK and CLI versions if your code depends on it.
13062    ///
13063    /// </div>
13064    pub async fn add_summary(
13065        &self,
13066        params: WorkspacesAddSummaryRequest,
13067    ) -> Result<WorkspacesAddSummaryResult, Error> {
13068        let mut wire_params = serde_json::to_value(params)?;
13069        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
13070        let _value = self
13071            .session
13072            .client()
13073            .call(
13074                rpc_methods::SESSION_WORKSPACES_ADDSUMMARY,
13075                Some(wire_params),
13076            )
13077            .await?;
13078        Ok(serde_json::from_value(_value)?)
13079    }
13080
13081    /// Truncates local workspace compaction summaries after a rollback.
13082    ///
13083    /// Wire method: `session.workspaces.truncateSummaries`.
13084    ///
13085    /// # Parameters
13086    ///
13087    /// * `params` - Rollback point for local workspace summaries.
13088    ///
13089    /// # Returns
13090    ///
13091    /// Current workspace metadata for the session, including its absolute filesystem path when available.
13092    ///
13093    /// <div class="warning">
13094    ///
13095    /// **Experimental.** This API is part of an experimental wire-protocol surface
13096    /// and may change or be removed in future SDK or CLI releases. Pin both the
13097    /// SDK and CLI versions if your code depends on it.
13098    ///
13099    /// </div>
13100    pub async fn truncate_summaries(
13101        &self,
13102        params: WorkspacesTruncateSummariesRequest,
13103    ) -> Result<WorkspacesGetWorkspaceResult, Error> {
13104        let mut wire_params = serde_json::to_value(params)?;
13105        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
13106        let _value = self
13107            .session
13108            .client()
13109            .call(
13110                rpc_methods::SESSION_WORKSPACES_TRUNCATESUMMARIES,
13111                Some(wire_params),
13112            )
13113            .await?;
13114        Ok(serde_json::from_value(_value)?)
13115    }
13116
13117    /// Reads the autopilot objective state file from the local session workspace.
13118    ///
13119    /// Wire method: `session.workspaces.readAutopilotObjective`.
13120    ///
13121    /// # Returns
13122    ///
13123    /// Autopilot objective file content, or null when missing.
13124    ///
13125    /// <div class="warning">
13126    ///
13127    /// **Experimental.** This API is part of an experimental wire-protocol surface
13128    /// and may change or be removed in future SDK or CLI releases. Pin both the
13129    /// SDK and CLI versions if your code depends on it.
13130    ///
13131    /// </div>
13132    pub async fn read_autopilot_objective(
13133        &self,
13134    ) -> Result<WorkspacesReadAutopilotObjectiveResult, Error> {
13135        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
13136        let _value = self
13137            .session
13138            .client()
13139            .call(
13140                rpc_methods::SESSION_WORKSPACES_READAUTOPILOTOBJECTIVE,
13141                Some(wire_params),
13142            )
13143            .await?;
13144        Ok(serde_json::from_value(_value)?)
13145    }
13146
13147    /// Writes the autopilot objective state file in the local session workspace.
13148    ///
13149    /// Wire method: `session.workspaces.writeAutopilotObjective`.
13150    ///
13151    /// # Parameters
13152    ///
13153    /// * `params` - Autopilot objective file content to persist.
13154    ///
13155    /// # Returns
13156    ///
13157    /// Result of writing the autopilot objective file.
13158    ///
13159    /// <div class="warning">
13160    ///
13161    /// **Experimental.** This API is part of an experimental wire-protocol surface
13162    /// and may change or be removed in future SDK or CLI releases. Pin both the
13163    /// SDK and CLI versions if your code depends on it.
13164    ///
13165    /// </div>
13166    pub async fn write_autopilot_objective(
13167        &self,
13168        params: WorkspacesWriteAutopilotObjectiveRequest,
13169    ) -> Result<WorkspacesWriteAutopilotObjectiveResult, Error> {
13170        let mut wire_params = serde_json::to_value(params)?;
13171        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
13172        let _value = self
13173            .session
13174            .client()
13175            .call(
13176                rpc_methods::SESSION_WORKSPACES_WRITEAUTOPILOTOBJECTIVE,
13177                Some(wire_params),
13178            )
13179            .await?;
13180        Ok(serde_json::from_value(_value)?)
13181    }
13182
13183    /// Deletes the autopilot objective state file from the local session workspace.
13184    ///
13185    /// Wire method: `session.workspaces.deleteAutopilotObjective`.
13186    ///
13187    /// # Returns
13188    ///
13189    /// Result of deleting the autopilot objective file.
13190    ///
13191    /// <div class="warning">
13192    ///
13193    /// **Experimental.** This API is part of an experimental wire-protocol surface
13194    /// and may change or be removed in future SDK or CLI releases. Pin both the
13195    /// SDK and CLI versions if your code depends on it.
13196    ///
13197    /// </div>
13198    pub async fn delete_autopilot_objective(
13199        &self,
13200    ) -> Result<WorkspacesDeleteAutopilotObjectiveResult, Error> {
13201        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
13202        let _value = self
13203            .session
13204            .client()
13205            .call(
13206                rpc_methods::SESSION_WORKSPACES_DELETEAUTOPILOTOBJECTIVE,
13207                Some(wire_params),
13208            )
13209            .await?;
13210        Ok(serde_json::from_value(_value)?)
13211    }
13212
13213    /// Checks whether the local session workspace has an autopilot objective state file.
13214    ///
13215    /// Wire method: `session.workspaces.autopilotObjectiveExists`.
13216    ///
13217    /// # Returns
13218    ///
13219    /// Whether the autopilot objective file exists.
13220    ///
13221    /// <div class="warning">
13222    ///
13223    /// **Experimental.** This API is part of an experimental wire-protocol surface
13224    /// and may change or be removed in future SDK or CLI releases. Pin both the
13225    /// SDK and CLI versions if your code depends on it.
13226    ///
13227    /// </div>
13228    pub async fn autopilot_objective_exists(
13229        &self,
13230    ) -> Result<WorkspacesAutopilotObjectiveExistsResult, Error> {
13231        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
13232        let _value = self
13233            .session
13234            .client()
13235            .call(
13236                rpc_methods::SESSION_WORKSPACES_AUTOPILOTOBJECTIVEEXISTS,
13237                Some(wire_params),
13238            )
13239            .await?;
13240        Ok(serde_json::from_value(_value)?)
13241    }
13242
13243    /// Saves pasted content as a UTF-8 file in the session workspace.
13244    ///
13245    /// Wire method: `session.workspaces.saveLargePaste`.
13246    ///
13247    /// # Parameters
13248    ///
13249    /// * `params` - Pasted content to save as a UTF-8 file in the session workspace.
13250    ///
13251    /// # Returns
13252    ///
13253    /// Descriptor for the saved paste file, or null when the workspace is unavailable.
13254    ///
13255    /// <div class="warning">
13256    ///
13257    /// **Experimental.** This API is part of an experimental wire-protocol surface
13258    /// and may change or be removed in future SDK or CLI releases. Pin both the
13259    /// SDK and CLI versions if your code depends on it.
13260    ///
13261    /// </div>
13262    pub async fn save_large_paste(
13263        &self,
13264        params: WorkspacesSaveLargePasteRequest,
13265    ) -> Result<WorkspacesSaveLargePasteResult, Error> {
13266        let mut wire_params = serde_json::to_value(params)?;
13267        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
13268        let _value = self
13269            .session
13270            .client()
13271            .call(
13272                rpc_methods::SESSION_WORKSPACES_SAVELARGEPASTE,
13273                Some(wire_params),
13274            )
13275            .await?;
13276        Ok(serde_json::from_value(_value)?)
13277    }
13278
13279    /// Computes a diff for the session workspace. Never rejects for a busy session: a `session`-mode diff that cannot read the session's file-change captures falls back to an unstaged git diff with `isFallback: true` and reports why in `unavailableReason`.
13280    ///
13281    /// Wire method: `session.workspaces.diff`.
13282    ///
13283    /// # Parameters
13284    ///
13285    /// * `params` - Parameters for computing a workspace diff.
13286    ///
13287    /// # Returns
13288    ///
13289    /// Workspace diff result for the requested mode.
13290    ///
13291    /// <div class="warning">
13292    ///
13293    /// **Experimental.** This API is part of an experimental wire-protocol surface
13294    /// and may change or be removed in future SDK or CLI releases. Pin both the
13295    /// SDK and CLI versions if your code depends on it.
13296    ///
13297    /// </div>
13298    pub async fn diff(&self, params: WorkspacesDiffRequest) -> Result<WorkspaceDiffResult, Error> {
13299        let mut wire_params = serde_json::to_value(params)?;
13300        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
13301        let _value = self
13302            .session
13303            .client()
13304            .call(rpc_methods::SESSION_WORKSPACES_DIFF, Some(wire_params))
13305            .await?;
13306        Ok(serde_json::from_value(_value)?)
13307    }
13308}