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    /// `sandbox.*` sub-namespace.
124    pub fn sandbox(&self) -> ClientRpcSandbox<'a> {
125        ClientRpcSandbox {
126            client: self.client,
127        }
128    }
129
130    /// `secrets.*` sub-namespace.
131    pub fn secrets(&self) -> ClientRpcSecrets<'a> {
132        ClientRpcSecrets {
133            client: self.client,
134        }
135    }
136
137    /// `sessionFs.*` sub-namespace.
138    pub fn session_fs(&self) -> ClientRpcSessionFs<'a> {
139        ClientRpcSessionFs {
140            client: self.client,
141        }
142    }
143
144    /// `sessions.*` sub-namespace.
145    pub fn sessions(&self) -> ClientRpcSessions<'a> {
146        ClientRpcSessions {
147            client: self.client,
148        }
149    }
150
151    /// `skills.*` sub-namespace.
152    pub fn skills(&self) -> ClientRpcSkills<'a> {
153        ClientRpcSkills {
154            client: self.client,
155        }
156    }
157
158    /// `tools.*` sub-namespace.
159    pub fn tools(&self) -> ClientRpcTools<'a> {
160        ClientRpcTools {
161            client: self.client,
162        }
163    }
164
165    /// `user.*` sub-namespace.
166    pub fn user(&self) -> ClientRpcUser<'a> {
167        ClientRpcUser {
168            client: self.client,
169        }
170    }
171
172    /// Checks server responsiveness and returns protocol information.
173    ///
174    /// Wire method: `ping`.
175    ///
176    /// # Parameters
177    ///
178    /// * `params` - Optional message to echo back to the caller.
179    ///
180    /// # Returns
181    ///
182    /// Server liveness response, including the echoed message, current server timestamp, and protocol version.
183    ///
184    /// <div class="warning">
185    ///
186    /// **Experimental.** This API is part of an experimental wire-protocol surface
187    /// and may change or be removed in future SDK or CLI releases. Pin both the
188    /// SDK and CLI versions if your code depends on it.
189    ///
190    /// </div>
191    pub async fn ping(&self, params: PingRequest) -> Result<PingResult, Error> {
192        let wire_params = serde_json::to_value(params)?;
193        let _value = self
194            .client
195            .call(rpc_methods::PING, Some(wire_params))
196            .await?;
197        Ok(serde_json::from_value(_value)?)
198    }
199
200    /// 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.
201    ///
202    /// Wire method: `connect`.
203    ///
204    /// # Parameters
205    ///
206    /// * `params` - Connection-level opt-ins for the `server.connect` handshake. Transport authentication is consumed by the native protocol boundary before dispatch.
207    ///
208    /// # Returns
209    ///
210    /// Handshake result reporting the server's protocol version and package version on success.
211    ///
212    /// <div class="warning">
213    ///
214    /// **Experimental.** This API is part of an experimental wire-protocol surface
215    /// and may change or be removed in future SDK or CLI releases. Pin both the
216    /// SDK and CLI versions if your code depends on it.
217    ///
218    /// </div>
219    pub(crate) async fn connect(&self, params: ConnectRequest) -> Result<ConnectResult, Error> {
220        let wire_params = serde_json::to_value(params)?;
221        let _value = self
222            .client
223            .call(rpc_methods::CONNECT, Some(wire_params))
224            .await?;
225        Ok(serde_json::from_value(_value)?)
226    }
227
228    /// 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.
229    ///
230    /// Wire method: `registerExtensionLaunchProvider`.
231    ///
232    /// <div class="warning">
233    ///
234    /// **Experimental.** This API is part of an experimental wire-protocol surface
235    /// and may change or be removed in future SDK or CLI releases. Pin both the
236    /// SDK and CLI versions if your code depends on it.
237    ///
238    /// </div>
239    pub async fn register_extension_launch_provider(&self) -> Result<(), Error> {
240        let wire_params = serde_json::json!({});
241        let _value = self
242            .client
243            .call(
244                rpc_methods::REGISTEREXTENSIONLAUNCHPROVIDER,
245                Some(wire_params),
246            )
247            .await?;
248        Ok(())
249    }
250}
251
252/// `account.*` RPCs.
253#[derive(Clone, Copy)]
254pub struct ClientRpcAccount<'a> {
255    pub(crate) client: &'a Client,
256}
257
258impl<'a> ClientRpcAccount<'a> {
259    /// Gets Copilot quota usage for the current or opaquely selected authenticated user.
260    ///
261    /// Wire method: `account.getQuota`.
262    ///
263    /// # Returns
264    ///
265    /// Quota usage snapshots for the resolved user, keyed by quota type.
266    ///
267    /// <div class="warning">
268    ///
269    /// **Experimental.** This API is part of an experimental wire-protocol surface
270    /// and may change or be removed in future SDK or CLI releases. Pin both the
271    /// SDK and CLI versions if your code depends on it.
272    ///
273    /// </div>
274    pub async fn get_quota(&self) -> Result<AccountGetQuotaResult, Error> {
275        let wire_params = serde_json::json!({});
276        let _value = self
277            .client
278            .call(rpc_methods::ACCOUNT_GETQUOTA, Some(wire_params))
279            .await?;
280        Ok(serde_json::from_value(_value)?)
281    }
282
283    /// Gets Copilot quota usage for the current or opaquely selected authenticated user.
284    ///
285    /// Wire method: `account.getQuota`.
286    ///
287    /// # Parameters
288    ///
289    /// * `params` - Optional opaque account selection or compatibility GitHub token used to look up quota.
290    ///
291    /// # Returns
292    ///
293    /// Quota usage snapshots for the resolved user, keyed by quota type.
294    ///
295    /// <div class="warning">
296    ///
297    /// **Experimental.** This API is part of an experimental wire-protocol surface
298    /// and may change or be removed in future SDK or CLI releases. Pin both the
299    /// SDK and CLI versions if your code depends on it.
300    ///
301    /// </div>
302    pub async fn get_quota_with_params(
303        &self,
304        params: AccountGetQuotaRequest,
305    ) -> Result<AccountGetQuotaResult, Error> {
306        let wire_params = serde_json::to_value(params)?;
307        let _value = self
308            .client
309            .call(rpc_methods::ACCOUNT_GETQUOTA, Some(wire_params))
310            .await?;
311        Ok(serde_json::from_value(_value)?)
312    }
313
314    /// Gets the currently active authentication credentials from the global auth manager.
315    ///
316    /// Wire method: `account.getCurrentAuth`.
317    ///
318    /// # Returns
319    ///
320    /// Current authentication state
321    ///
322    /// <div class="warning">
323    ///
324    /// **Experimental.** This API is part of an experimental wire-protocol surface
325    /// and may change or be removed in future SDK or CLI releases. Pin both the
326    /// SDK and CLI versions if your code depends on it.
327    ///
328    /// </div>
329    pub async fn get_current_auth(&self) -> Result<AccountGetCurrentAuthResult, Error> {
330        let wire_params = serde_json::json!({});
331        let _value = self
332            .client
333            .call(rpc_methods::ACCOUNT_GETCURRENTAUTH, Some(wire_params))
334            .await?;
335        Ok(serde_json::from_value(_value)?)
336    }
337
338    /// Gets all authenticated users available for account switching.
339    ///
340    /// Wire method: `account.getAllUsers`.
341    ///
342    /// # Returns
343    ///
344    /// List of all authenticated users
345    ///
346    /// <div class="warning">
347    ///
348    /// **Experimental.** This API is part of an experimental wire-protocol surface
349    /// and may change or be removed in future SDK or CLI releases. Pin both the
350    /// SDK and CLI versions if your code depends on it.
351    ///
352    /// </div>
353    pub async fn get_all_users(&self) -> Result<AccountGetAllUsersResult, Error> {
354        let wire_params = serde_json::json!({});
355        let _value = self
356            .client
357            .call(rpc_methods::ACCOUNT_GETALLUSERS, Some(wire_params))
358            .await?;
359        Ok(serde_json::from_value(_value)?)
360    }
361
362    /// Validates and stores authentication credentials. When login is omitted, resolves the authenticated user from the token before persistence.
363    ///
364    /// Wire method: `account.login`.
365    ///
366    /// # Parameters
367    ///
368    /// * `params` - Credentials to validate and store. Omit login to resolve the authenticated user from the token.
369    ///
370    /// # Returns
371    ///
372    /// Result of a successful login; throws on failure
373    ///
374    /// <div class="warning">
375    ///
376    /// **Experimental.** This API is part of an experimental wire-protocol surface
377    /// and may change or be removed in future SDK or CLI releases. Pin both the
378    /// SDK and CLI versions if your code depends on it.
379    ///
380    /// </div>
381    pub async fn login(&self, params: AccountLoginRequest) -> Result<AccountLoginResult, Error> {
382        let wire_params = serde_json::to_value(params)?;
383        let _value = self
384            .client
385            .call(rpc_methods::ACCOUNT_LOGIN, Some(wire_params))
386            .await?;
387        Ok(serde_json::from_value(_value)?)
388    }
389
390    /// Removes user authentication from keychain and persisted state.
391    ///
392    /// Wire method: `account.logout`.
393    ///
394    /// # Parameters
395    ///
396    /// * `params` - User to log out
397    ///
398    /// # Returns
399    ///
400    /// Logout result indicating if more users remain
401    ///
402    /// <div class="warning">
403    ///
404    /// **Experimental.** This API is part of an experimental wire-protocol surface
405    /// and may change or be removed in future SDK or CLI releases. Pin both the
406    /// SDK and CLI versions if your code depends on it.
407    ///
408    /// </div>
409    pub async fn logout(&self, params: AccountLogoutRequest) -> Result<AccountLogoutResult, Error> {
410        let wire_params = serde_json::to_value(params)?;
411        let _value = self
412            .client
413            .call(rpc_methods::ACCOUNT_LOGOUT, Some(wire_params))
414            .await?;
415        Ok(serde_json::from_value(_value)?)
416    }
417}
418
419/// `agentRegistry.*` RPCs.
420#[derive(Clone, Copy)]
421pub struct ClientRpcAgentRegistry<'a> {
422    pub(crate) client: &'a Client,
423}
424
425impl<'a> ClientRpcAgentRegistry<'a> {
426    /// 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.
427    ///
428    /// Wire method: `agentRegistry.spawn`.
429    ///
430    /// # Parameters
431    ///
432    /// * `params` - Inputs to spawn a managed-server child via the controller's spawn delegate.
433    ///
434    /// # Returns
435    ///
436    /// Outcome of an agentRegistry.spawn call.
437    ///
438    /// <div class="warning">
439    ///
440    /// **Experimental.** This API is part of an experimental wire-protocol surface
441    /// and may change or be removed in future SDK or CLI releases. Pin both the
442    /// SDK and CLI versions if your code depends on it.
443    ///
444    /// </div>
445    pub async fn spawn(
446        &self,
447        params: AgentRegistrySpawnRequest,
448    ) -> Result<AgentRegistrySpawnResult, Error> {
449        let wire_params = serde_json::to_value(params)?;
450        let _value = self
451            .client
452            .call(rpc_methods::AGENTREGISTRY_SPAWN, Some(wire_params))
453            .await?;
454        Ok(serde_json::from_value(_value)?)
455    }
456}
457
458/// `agents.*` RPCs.
459#[derive(Clone, Copy)]
460pub struct ClientRpcAgents<'a> {
461    pub(crate) client: &'a Client,
462}
463
464impl<'a> ClientRpcAgents<'a> {
465    /// Discovers custom agents across user, project, plugin, and remote sources.
466    ///
467    /// Wire method: `agents.discover`.
468    ///
469    /// # Parameters
470    ///
471    /// * `params` - Optional project paths to include in agent discovery.
472    ///
473    /// # Returns
474    ///
475    /// Agents discovered across user, project, plugin, and remote sources.
476    ///
477    /// <div class="warning">
478    ///
479    /// **Experimental.** This API is part of an experimental wire-protocol surface
480    /// and may change or be removed in future SDK or CLI releases. Pin both the
481    /// SDK and CLI versions if your code depends on it.
482    ///
483    /// </div>
484    pub async fn discover(&self, params: AgentsDiscoverRequest) -> Result<ServerAgentList, Error> {
485        let wire_params = serde_json::to_value(params)?;
486        let _value = self
487            .client
488            .call(rpc_methods::AGENTS_DISCOVER, Some(wire_params))
489            .await?;
490        Ok(serde_json::from_value(_value)?)
491    }
492
493    /// 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.
494    ///
495    /// Wire method: `agents.getDiscoveryPaths`.
496    ///
497    /// # Parameters
498    ///
499    /// * `params` - Optional project paths to include when enumerating agent discovery directories.
500    ///
501    /// # Returns
502    ///
503    /// Canonical locations where custom agents can be created so the runtime will recognize them.
504    ///
505    /// <div class="warning">
506    ///
507    /// **Experimental.** This API is part of an experimental wire-protocol surface
508    /// and may change or be removed in future SDK or CLI releases. Pin both the
509    /// SDK and CLI versions if your code depends on it.
510    ///
511    /// </div>
512    pub async fn get_discovery_paths(
513        &self,
514        params: AgentsGetDiscoveryPathsRequest,
515    ) -> Result<AgentDiscoveryPathList, Error> {
516        let wire_params = serde_json::to_value(params)?;
517        let _value = self
518            .client
519            .call(rpc_methods::AGENTS_GETDISCOVERYPATHS, Some(wire_params))
520            .await?;
521        Ok(serde_json::from_value(_value)?)
522    }
523}
524
525/// `catalog.*` RPCs.
526#[derive(Clone, Copy)]
527pub struct ClientRpcCatalog<'a> {
528    pub(crate) client: &'a Client,
529}
530
531impl<'a> ClientRpcCatalog<'a> {
532    /// 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.
533    ///
534    /// Wire method: `catalog.search`.
535    ///
536    /// # Parameters
537    ///
538    /// * `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.
539    ///
540    /// # Returns
541    ///
542    /// Outcome of a catalog.search call: either bounded inert candidates, or one typed refusal. Never a partial success.
543    ///
544    /// <div class="warning">
545    ///
546    /// **Experimental.** This API is part of an experimental wire-protocol surface
547    /// and may change or be removed in future SDK or CLI releases. Pin both the
548    /// SDK and CLI versions if your code depends on it.
549    ///
550    /// </div>
551    pub async fn search(&self, params: CatalogSearchRequest) -> Result<CatalogSearchResult, Error> {
552        let wire_params = serde_json::to_value(params)?;
553        let _value = self
554            .client
555            .call(rpc_methods::CATALOG_SEARCH, Some(wire_params))
556            .await?;
557        Ok(serde_json::from_value(_value)?)
558    }
559
560    /// 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.
561    ///
562    /// Wire method: `catalog.select`.
563    ///
564    /// # Parameters
565    ///
566    /// * `params` - Terminates one retained catalog selection group through an opaque reference previously returned by the model-safe search projection.
567    ///
568    /// # Returns
569    ///
570    /// 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.
571    ///
572    /// <div class="warning">
573    ///
574    /// **Experimental.** This API is part of an experimental wire-protocol surface
575    /// and may change or be removed in future SDK or CLI releases. Pin both the
576    /// SDK and CLI versions if your code depends on it.
577    ///
578    /// </div>
579    pub async fn select(
580        &self,
581        params: CatalogSelectionRequest,
582    ) -> Result<CatalogSelectionResult, Error> {
583        let wire_params = serde_json::to_value(params)?;
584        let _value = self
585            .client
586            .call(rpc_methods::CATALOG_SELECT, Some(wire_params))
587            .await?;
588        Ok(serde_json::from_value(_value)?)
589    }
590}
591
592/// `commands.*` RPCs.
593#[derive(Clone, Copy)]
594pub struct ClientRpcCommands<'a> {
595    pub(crate) client: &'a Client,
596}
597
598impl<'a> ClientRpcCommands<'a> {
599    /// 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.
600    ///
601    /// Wire method: `commands.list`.
602    ///
603    /// # Returns
604    ///
605    /// Slash commands available in the session, after applying any include/exclude filters.
606    ///
607    /// <div class="warning">
608    ///
609    /// **Experimental.** This API is part of an experimental wire-protocol surface
610    /// and may change or be removed in future SDK or CLI releases. Pin both the
611    /// SDK and CLI versions if your code depends on it.
612    ///
613    /// </div>
614    pub async fn list(&self) -> Result<CommandList, Error> {
615        let wire_params = serde_json::json!({});
616        let _value = self
617            .client
618            .call(rpc_methods::COMMANDS_LIST, Some(wire_params))
619            .await?;
620        Ok(serde_json::from_value(_value)?)
621    }
622}
623
624/// `extensions.*` RPCs.
625#[derive(Clone, Copy)]
626pub struct ClientRpcExtensions<'a> {
627    pub(crate) client: &'a Client,
628}
629
630impl<'a> ClientRpcExtensions<'a> {
631    /// Discovers user and enabled installed-plugin extensions from persisted Copilot home state, including enablement preferences. Launch-scoped additional plugins are not included.
632    ///
633    /// Wire method: `extensions.discover`.
634    ///
635    /// # Returns
636    ///
637    /// Extensions discovered from persisted Copilot home state and their effective loading mode. Launch-scoped additional plugins are not included.
638    ///
639    /// <div class="warning">
640    ///
641    /// **Experimental.** This API is part of an experimental wire-protocol surface
642    /// and may change or be removed in future SDK or CLI releases. Pin both the
643    /// SDK and CLI versions if your code depends on it.
644    ///
645    /// </div>
646    pub async fn discover(&self) -> Result<DiscoveredExtensions, Error> {
647        let wire_params = serde_json::json!({});
648        let _value = self
649            .client
650            .call(rpc_methods::EXTENSIONS_DISCOVER, Some(wire_params))
651            .await?;
652        Ok(serde_json::from_value(_value)?)
653    }
654
655    /// Persistently enables extension IDs for future sessions. Active sessions are unchanged; use session.extensions.enable to update them.
656    ///
657    /// Wire method: `extensions.enable`.
658    ///
659    /// # Parameters
660    ///
661    /// * `params` - Source-qualified extension identifiers to persistently enable for future sessions.
662    ///
663    /// <div class="warning">
664    ///
665    /// **Experimental.** This API is part of an experimental wire-protocol surface
666    /// and may change or be removed in future SDK or CLI releases. Pin both the
667    /// SDK and CLI versions if your code depends on it.
668    ///
669    /// </div>
670    pub async fn enable(&self, params: DiscoveredExtensionsEnableRequest) -> Result<(), Error> {
671        let wire_params = serde_json::to_value(params)?;
672        let _value = self
673            .client
674            .call(rpc_methods::EXTENSIONS_ENABLE, Some(wire_params))
675            .await?;
676        Ok(())
677    }
678
679    /// Persistently disables extension IDs for future sessions. Active sessions are unchanged; use session.extensions.disable to update them.
680    ///
681    /// Wire method: `extensions.disable`.
682    ///
683    /// # Parameters
684    ///
685    /// * `params` - Source-qualified extension identifiers to persistently disable for future sessions.
686    ///
687    /// <div class="warning">
688    ///
689    /// **Experimental.** This API is part of an experimental wire-protocol surface
690    /// and may change or be removed in future SDK or CLI releases. Pin both the
691    /// SDK and CLI versions if your code depends on it.
692    ///
693    /// </div>
694    pub async fn disable(&self, params: DiscoveredExtensionsDisableRequest) -> Result<(), Error> {
695        let wire_params = serde_json::to_value(params)?;
696        let _value = self
697            .client
698            .call(rpc_methods::EXTENSIONS_DISABLE, Some(wire_params))
699            .await?;
700        Ok(())
701    }
702}
703
704/// `hooks.*` RPCs.
705#[derive(Clone, Copy)]
706pub struct ClientRpcHooks<'a> {
707    pub(crate) client: &'a Client,
708}
709
710impl<'a> ClientRpcHooks<'a> {
711    /// Discovers hook actions enabled under server-side discovery settings from user, repository, plugin, and managed-policy sources.
712    ///
713    /// Wire method: `hooks.discover`.
714    ///
715    /// # Parameters
716    ///
717    /// * `params` - Optional project paths and host-exclusion behavior for server-scoped hook discovery.
718    ///
719    /// # Returns
720    ///
721    /// 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.
722    ///
723    /// <div class="warning">
724    ///
725    /// **Experimental.** This API is part of an experimental wire-protocol surface
726    /// and may change or be removed in future SDK or CLI releases. Pin both the
727    /// SDK and CLI versions if your code depends on it.
728    ///
729    /// </div>
730    pub async fn discover(
731        &self,
732        params: HooksDiscoverRequest,
733    ) -> Result<HooksDiscoverResult, Error> {
734        let wire_params = serde_json::to_value(params)?;
735        let _value = self
736            .client
737            .call(rpc_methods::HOOKS_DISCOVER, Some(wire_params))
738            .await?;
739        Ok(serde_json::from_value(_value)?)
740    }
741}
742
743/// `instructions.*` RPCs.
744#[derive(Clone, Copy)]
745pub struct ClientRpcInstructions<'a> {
746    pub(crate) client: &'a Client,
747}
748
749impl<'a> ClientRpcInstructions<'a> {
750    /// Discovers instruction sources across user, repository, and plugin sources.
751    ///
752    /// Wire method: `instructions.discover`.
753    ///
754    /// # Parameters
755    ///
756    /// * `params` - Optional project paths to include in instruction discovery.
757    ///
758    /// # Returns
759    ///
760    /// Instruction sources discovered across user, repository, and plugin sources.
761    ///
762    /// <div class="warning">
763    ///
764    /// **Experimental.** This API is part of an experimental wire-protocol surface
765    /// and may change or be removed in future SDK or CLI releases. Pin both the
766    /// SDK and CLI versions if your code depends on it.
767    ///
768    /// </div>
769    pub async fn discover(
770        &self,
771        params: InstructionsDiscoverRequest,
772    ) -> Result<ServerInstructionSourceList, Error> {
773        let wire_params = serde_json::to_value(params)?;
774        let _value = self
775            .client
776            .call(rpc_methods::INSTRUCTIONS_DISCOVER, Some(wire_params))
777            .await?;
778        Ok(serde_json::from_value(_value)?)
779    }
780
781    /// 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.
782    ///
783    /// Wire method: `instructions.getDiscoveryPaths`.
784    ///
785    /// # Parameters
786    ///
787    /// * `params` - Optional project paths to include when enumerating instruction discovery targets.
788    ///
789    /// # Returns
790    ///
791    /// Canonical files and directories where custom instructions can be created so the runtime will recognize them.
792    ///
793    /// <div class="warning">
794    ///
795    /// **Experimental.** This API is part of an experimental wire-protocol surface
796    /// and may change or be removed in future SDK or CLI releases. Pin both the
797    /// SDK and CLI versions if your code depends on it.
798    ///
799    /// </div>
800    pub async fn get_discovery_paths(
801        &self,
802        params: InstructionsGetDiscoveryPathsRequest,
803    ) -> Result<InstructionDiscoveryPathList, Error> {
804        let wire_params = serde_json::to_value(params)?;
805        let _value = self
806            .client
807            .call(
808                rpc_methods::INSTRUCTIONS_GETDISCOVERYPATHS,
809                Some(wire_params),
810            )
811            .await?;
812        Ok(serde_json::from_value(_value)?)
813    }
814}
815
816/// `llmInference.*` RPCs.
817#[derive(Clone, Copy)]
818pub struct ClientRpcLlmInference<'a> {
819    pub(crate) client: &'a Client,
820}
821
822impl<'a> ClientRpcLlmInference<'a> {
823    /// Registers an SDK client as the LLM inference callback provider.
824    ///
825    /// Wire method: `llmInference.setProvider`.
826    ///
827    /// # Returns
828    ///
829    /// Indicates whether the calling client was registered as the LLM inference provider.
830    ///
831    /// <div class="warning">
832    ///
833    /// **Experimental.** This API is part of an experimental wire-protocol surface
834    /// and may change or be removed in future SDK or CLI releases. Pin both the
835    /// SDK and CLI versions if your code depends on it.
836    ///
837    /// </div>
838    pub async fn set_provider(&self) -> Result<LlmInferenceSetProviderResult, Error> {
839        let wire_params = serde_json::json!({});
840        let _value = self
841            .client
842            .call(rpc_methods::LLMINFERENCE_SETPROVIDER, Some(wire_params))
843            .await?;
844        Ok(serde_json::from_value(_value)?)
845    }
846
847    /// 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.
848    ///
849    /// Wire method: `llmInference.httpResponseStart`.
850    ///
851    /// # Parameters
852    ///
853    /// * `params` - Response head.
854    ///
855    /// # Returns
856    ///
857    /// Whether the start frame was accepted.
858    ///
859    /// <div class="warning">
860    ///
861    /// **Experimental.** This API is part of an experimental wire-protocol surface
862    /// and may change or be removed in future SDK or CLI releases. Pin both the
863    /// SDK and CLI versions if your code depends on it.
864    ///
865    /// </div>
866    pub async fn http_response_start(
867        &self,
868        params: LlmInferenceHttpResponseStartRequest,
869    ) -> Result<LlmInferenceHttpResponseStartResult, Error> {
870        let wire_params = serde_json::to_value(params)?;
871        let _value = self
872            .client
873            .call(
874                rpc_methods::LLMINFERENCE_HTTPRESPONSESTART,
875                Some(wire_params),
876            )
877            .await?;
878        Ok(serde_json::from_value(_value)?)
879    }
880
881    /// 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.
882    ///
883    /// Wire method: `llmInference.httpResponseChunk`.
884    ///
885    /// # Parameters
886    ///
887    /// * `params` - A response body chunk or terminal error.
888    ///
889    /// # Returns
890    ///
891    /// Whether the chunk was accepted.
892    ///
893    /// <div class="warning">
894    ///
895    /// **Experimental.** This API is part of an experimental wire-protocol surface
896    /// and may change or be removed in future SDK or CLI releases. Pin both the
897    /// SDK and CLI versions if your code depends on it.
898    ///
899    /// </div>
900    pub async fn http_response_chunk(
901        &self,
902        params: LlmInferenceHttpResponseChunkRequest,
903    ) -> Result<LlmInferenceHttpResponseChunkResult, Error> {
904        let wire_params = serde_json::to_value(params)?;
905        let _value = self
906            .client
907            .call(
908                rpc_methods::LLMINFERENCE_HTTPRESPONSECHUNK,
909                Some(wire_params),
910            )
911            .await?;
912        Ok(serde_json::from_value(_value)?)
913    }
914}
915
916/// `managedSettings.*` RPCs.
917#[derive(Clone, Copy)]
918pub struct ClientRpcManagedSettings<'a> {
919    pub(crate) client: &'a Client,
920}
921
922impl<'a> ClientRpcManagedSettings<'a> {
923    /// 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.
924    ///
925    /// Wire method: `managedSettings.read`.
926    ///
927    /// # Returns
928    ///
929    /// Validated device-managed settings discovered before a session exists.
930    ///
931    /// <div class="warning">
932    ///
933    /// **Experimental.** This API is part of an experimental wire-protocol surface
934    /// and may change or be removed in future SDK or CLI releases. Pin both the
935    /// SDK and CLI versions if your code depends on it.
936    ///
937    /// </div>
938    pub async fn read(&self) -> Result<ManagedSettingsReadResult, Error> {
939        let wire_params = serde_json::json!({});
940        let _value = self
941            .client
942            .call(rpc_methods::MANAGEDSETTINGS_READ, Some(wire_params))
943            .await?;
944        Ok(serde_json::from_value(_value)?)
945    }
946
947    /// 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.
948    ///
949    /// Wire method: `managedSettings.clearCache`.
950    ///
951    /// <div class="warning">
952    ///
953    /// **Experimental.** This API is part of an experimental wire-protocol surface
954    /// and may change or be removed in future SDK or CLI releases. Pin both the
955    /// SDK and CLI versions if your code depends on it.
956    ///
957    /// </div>
958    pub async fn clear_cache(&self) -> Result<(), Error> {
959        let wire_params = serde_json::json!({});
960        let _value = self
961            .client
962            .call(rpc_methods::MANAGEDSETTINGS_CLEARCACHE, Some(wire_params))
963            .await?;
964        Ok(())
965    }
966}
967
968/// `mcp.*` RPCs.
969#[derive(Clone, Copy)]
970pub struct ClientRpcMcp<'a> {
971    pub(crate) client: &'a Client,
972}
973
974impl<'a> ClientRpcMcp<'a> {
975    /// `mcp.config.*` sub-namespace.
976    pub fn config(&self) -> ClientRpcMcpConfig<'a> {
977        ClientRpcMcpConfig {
978            client: self.client,
979        }
980    }
981
982    /// Discovers MCP servers from user, workspace, plugin, and builtin sources.
983    ///
984    /// Wire method: `mcp.discover`.
985    ///
986    /// # Parameters
987    ///
988    /// * `params` - Optional working directory used as context for MCP server discovery.
989    ///
990    /// # Returns
991    ///
992    /// MCP servers discovered from user, workspace, plugin, and built-in sources.
993    ///
994    /// <div class="warning">
995    ///
996    /// **Experimental.** This API is part of an experimental wire-protocol surface
997    /// and may change or be removed in future SDK or CLI releases. Pin both the
998    /// SDK and CLI versions if your code depends on it.
999    ///
1000    /// </div>
1001    pub async fn discover(&self, params: McpDiscoverRequest) -> Result<McpDiscoverResult, Error> {
1002        let wire_params = serde_json::to_value(params)?;
1003        let _value = self
1004            .client
1005            .call(rpc_methods::MCP_DISCOVER, Some(wire_params))
1006            .await?;
1007        Ok(serde_json::from_value(_value)?)
1008    }
1009
1010    /// 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.
1011    ///
1012    /// Wire method: `mcp.planInstall`.
1013    ///
1014    /// # Parameters
1015    ///
1016    /// * `params` - A side-effect-free request for an MCP install plan. Computing a plan never writes configuration, stores a secret, or reloads MCP servers.
1017    ///
1018    /// # Returns
1019    ///
1020    /// Outcome of an mcp.planInstall call: either a normalised plan, or one typed refusal. Nothing is written in either case.
1021    ///
1022    /// <div class="warning">
1023    ///
1024    /// **Experimental.** This API is part of an experimental wire-protocol surface
1025    /// and may change or be removed in future SDK or CLI releases. Pin both the
1026    /// SDK and CLI versions if your code depends on it.
1027    ///
1028    /// </div>
1029    pub async fn plan_install(
1030        &self,
1031        params: McpPlanInstallRequest,
1032    ) -> Result<McpPlanInstallResult, Error> {
1033        let wire_params = serde_json::to_value(params)?;
1034        let _value = self
1035            .client
1036            .call(rpc_methods::MCP_PLANINSTALL, Some(wire_params))
1037            .await?;
1038        Ok(serde_json::from_value(_value)?)
1039    }
1040}
1041
1042/// `mcp.config.*` RPCs.
1043#[derive(Clone, Copy)]
1044pub struct ClientRpcMcpConfig<'a> {
1045    pub(crate) client: &'a Client,
1046}
1047
1048impl<'a> ClientRpcMcpConfig<'a> {
1049    /// Lists MCP servers from user configuration.
1050    ///
1051    /// Wire method: `mcp.config.list`.
1052    ///
1053    /// # Returns
1054    ///
1055    /// User-configured MCP servers, keyed by server name.
1056    ///
1057    /// <div class="warning">
1058    ///
1059    /// **Experimental.** This API is part of an experimental wire-protocol surface
1060    /// and may change or be removed in future SDK or CLI releases. Pin both the
1061    /// SDK and CLI versions if your code depends on it.
1062    ///
1063    /// </div>
1064    pub async fn list(&self) -> Result<McpConfigList, Error> {
1065        let wire_params = serde_json::json!({});
1066        let _value = self
1067            .client
1068            .call(rpc_methods::MCP_CONFIG_LIST, Some(wire_params))
1069            .await?;
1070        Ok(serde_json::from_value(_value)?)
1071    }
1072
1073    /// Adds an MCP server to user configuration.
1074    ///
1075    /// Wire method: `mcp.config.add`.
1076    ///
1077    /// # Parameters
1078    ///
1079    /// * `params` - MCP server name and configuration to add to user configuration.
1080    ///
1081    /// <div class="warning">
1082    ///
1083    /// **Experimental.** This API is part of an experimental wire-protocol surface
1084    /// and may change or be removed in future SDK or CLI releases. Pin both the
1085    /// SDK and CLI versions if your code depends on it.
1086    ///
1087    /// </div>
1088    pub async fn add(&self, params: McpConfigAddRequest) -> Result<(), Error> {
1089        let wire_params = serde_json::to_value(params)?;
1090        let _value = self
1091            .client
1092            .call(rpc_methods::MCP_CONFIG_ADD, Some(wire_params))
1093            .await?;
1094        Ok(())
1095    }
1096
1097    /// Updates an MCP server in user configuration.
1098    ///
1099    /// Wire method: `mcp.config.update`.
1100    ///
1101    /// # Parameters
1102    ///
1103    /// * `params` - MCP server name and replacement configuration to write to user configuration.
1104    ///
1105    /// <div class="warning">
1106    ///
1107    /// **Experimental.** This API is part of an experimental wire-protocol surface
1108    /// and may change or be removed in future SDK or CLI releases. Pin both the
1109    /// SDK and CLI versions if your code depends on it.
1110    ///
1111    /// </div>
1112    pub async fn update(&self, params: McpConfigUpdateRequest) -> Result<(), Error> {
1113        let wire_params = serde_json::to_value(params)?;
1114        let _value = self
1115            .client
1116            .call(rpc_methods::MCP_CONFIG_UPDATE, Some(wire_params))
1117            .await?;
1118        Ok(())
1119    }
1120
1121    /// Removes an MCP server from user configuration.
1122    ///
1123    /// Wire method: `mcp.config.remove`.
1124    ///
1125    /// # Parameters
1126    ///
1127    /// * `params` - MCP server name to remove from user configuration.
1128    ///
1129    /// <div class="warning">
1130    ///
1131    /// **Experimental.** This API is part of an experimental wire-protocol surface
1132    /// and may change or be removed in future SDK or CLI releases. Pin both the
1133    /// SDK and CLI versions if your code depends on it.
1134    ///
1135    /// </div>
1136    pub async fn remove(&self, params: McpConfigRemoveRequest) -> Result<(), Error> {
1137        let wire_params = serde_json::to_value(params)?;
1138        let _value = self
1139            .client
1140            .call(rpc_methods::MCP_CONFIG_REMOVE, Some(wire_params))
1141            .await?;
1142        Ok(())
1143    }
1144
1145    /// Enables MCP servers in user configuration for new sessions.
1146    ///
1147    /// Wire method: `mcp.config.enable`.
1148    ///
1149    /// # Parameters
1150    ///
1151    /// * `params` - MCP server names to enable for new sessions.
1152    ///
1153    /// <div class="warning">
1154    ///
1155    /// **Experimental.** This API is part of an experimental wire-protocol surface
1156    /// and may change or be removed in future SDK or CLI releases. Pin both the
1157    /// SDK and CLI versions if your code depends on it.
1158    ///
1159    /// </div>
1160    pub async fn enable(&self, params: McpConfigEnableRequest) -> Result<(), Error> {
1161        let wire_params = serde_json::to_value(params)?;
1162        let _value = self
1163            .client
1164            .call(rpc_methods::MCP_CONFIG_ENABLE, Some(wire_params))
1165            .await?;
1166        Ok(())
1167    }
1168
1169    /// Disables MCP servers in user configuration for new sessions.
1170    ///
1171    /// Wire method: `mcp.config.disable`.
1172    ///
1173    /// # Parameters
1174    ///
1175    /// * `params` - MCP server names to disable for new sessions.
1176    ///
1177    /// <div class="warning">
1178    ///
1179    /// **Experimental.** This API is part of an experimental wire-protocol surface
1180    /// and may change or be removed in future SDK or CLI releases. Pin both the
1181    /// SDK and CLI versions if your code depends on it.
1182    ///
1183    /// </div>
1184    pub async fn disable(&self, params: McpConfigDisableRequest) -> Result<(), Error> {
1185        let wire_params = serde_json::to_value(params)?;
1186        let _value = self
1187            .client
1188            .call(rpc_methods::MCP_CONFIG_DISABLE, Some(wire_params))
1189            .await?;
1190        Ok(())
1191    }
1192
1193    /// Drops this runtime process's in-memory MCP server-definition cache so the next MCP config read observes disk.
1194    ///
1195    /// Wire method: `mcp.config.reload`.
1196    ///
1197    /// <div class="warning">
1198    ///
1199    /// **Experimental.** This API is part of an experimental wire-protocol surface
1200    /// and may change or be removed in future SDK or CLI releases. Pin both the
1201    /// SDK and CLI versions if your code depends on it.
1202    ///
1203    /// </div>
1204    pub async fn reload(&self) -> Result<(), Error> {
1205        let wire_params = serde_json::json!({});
1206        let _value = self
1207            .client
1208            .call(rpc_methods::MCP_CONFIG_RELOAD, Some(wire_params))
1209            .await?;
1210        Ok(())
1211    }
1212}
1213
1214/// `models.*` RPCs.
1215#[derive(Clone, Copy)]
1216pub struct ClientRpcModels<'a> {
1217    pub(crate) client: &'a Client,
1218}
1219
1220impl<'a> ClientRpcModels<'a> {
1221    /// Lists Copilot models available to the authenticated user.
1222    ///
1223    /// Wire method: `models.list`.
1224    ///
1225    /// # Returns
1226    ///
1227    /// List of Copilot models available to the resolved user, including capabilities and billing metadata.
1228    ///
1229    /// <div class="warning">
1230    ///
1231    /// **Experimental.** This API is part of an experimental wire-protocol surface
1232    /// and may change or be removed in future SDK or CLI releases. Pin both the
1233    /// SDK and CLI versions if your code depends on it.
1234    ///
1235    /// </div>
1236    pub async fn list(&self) -> Result<ModelList, Error> {
1237        let wire_params = serde_json::json!({});
1238        let _value = self
1239            .client
1240            .call(rpc_methods::MODELS_LIST, Some(wire_params))
1241            .await?;
1242        Ok(serde_json::from_value(_value)?)
1243    }
1244
1245    /// Lists Copilot models available to the authenticated user.
1246    ///
1247    /// Wire method: `models.list`.
1248    ///
1249    /// # Parameters
1250    ///
1251    /// * `params` - Optional opaque account selection or compatibility GitHub token used to list models.
1252    ///
1253    /// # Returns
1254    ///
1255    /// List of Copilot models available to the resolved user, including capabilities and billing metadata.
1256    ///
1257    /// <div class="warning">
1258    ///
1259    /// **Experimental.** This API is part of an experimental wire-protocol surface
1260    /// and may change or be removed in future SDK or CLI releases. Pin both the
1261    /// SDK and CLI versions if your code depends on it.
1262    ///
1263    /// </div>
1264    pub async fn list_with_params(&self, params: ModelsListRequest) -> Result<ModelList, Error> {
1265        let wire_params = serde_json::to_value(params)?;
1266        let _value = self
1267            .client
1268            .call(rpc_methods::MODELS_LIST, Some(wire_params))
1269            .await?;
1270        Ok(serde_json::from_value(_value)?)
1271    }
1272
1273    /// Returns the running runtime's complete catalog of well-known built-in model IDs without authentication or network access.
1274    ///
1275    /// Wire method: `models.getBuiltInCatalog`.
1276    ///
1277    /// # Returns
1278    ///
1279    /// The running runtime's complete catalog of well-known built-in model IDs, including supported models and additional IDs with built-in metadata.
1280    ///
1281    /// <div class="warning">
1282    ///
1283    /// **Experimental.** This API is part of an experimental wire-protocol surface
1284    /// and may change or be removed in future SDK or CLI releases. Pin both the
1285    /// SDK and CLI versions if your code depends on it.
1286    ///
1287    /// </div>
1288    pub async fn get_built_in_catalog(&self) -> Result<BuiltInModelCatalog, Error> {
1289        let wire_params = serde_json::json!({});
1290        let _value = self
1291            .client
1292            .call(rpc_methods::MODELS_GETBUILTINCATALOG, Some(wire_params))
1293            .await?;
1294        Ok(serde_json::from_value(_value)?)
1295    }
1296}
1297
1298/// `plugins.*` RPCs.
1299#[derive(Clone, Copy)]
1300pub struct ClientRpcPlugins<'a> {
1301    pub(crate) client: &'a Client,
1302}
1303
1304impl<'a> ClientRpcPlugins<'a> {
1305    /// `plugins.builtin.*` sub-namespace.
1306    pub fn builtin(&self) -> ClientRpcPluginsBuiltin<'a> {
1307        ClientRpcPluginsBuiltin {
1308            client: self.client,
1309        }
1310    }
1311
1312    /// `plugins.marketplaces.*` sub-namespace.
1313    pub fn marketplaces(&self) -> ClientRpcPluginsMarketplaces<'a> {
1314        ClientRpcPluginsMarketplaces {
1315            client: self.client,
1316        }
1317    }
1318
1319    /// Lists plugins installed in user/global state.
1320    ///
1321    /// Wire method: `plugins.list`.
1322    ///
1323    /// # Returns
1324    ///
1325    /// Plugins installed in user/global state.
1326    ///
1327    /// <div class="warning">
1328    ///
1329    /// **Experimental.** This API is part of an experimental wire-protocol surface
1330    /// and may change or be removed in future SDK or CLI releases. Pin both the
1331    /// SDK and CLI versions if your code depends on it.
1332    ///
1333    /// </div>
1334    pub async fn list(&self) -> Result<PluginListResult, Error> {
1335        let wire_params = serde_json::json!({});
1336        let _value = self
1337            .client
1338            .call(rpc_methods::PLUGINS_LIST, Some(wire_params))
1339            .await?;
1340        Ok(serde_json::from_value(_value)?)
1341    }
1342
1343    /// Installs a plugin from a marketplace, GitHub repo, URL, or local path.
1344    ///
1345    /// Wire method: `plugins.install`.
1346    ///
1347    /// # Parameters
1348    ///
1349    /// * `params` - Plugin source and optional working directory for relative-path resolution.
1350    ///
1351    /// # Returns
1352    ///
1353    /// Result of installing a plugin.
1354    ///
1355    /// <div class="warning">
1356    ///
1357    /// **Experimental.** This API is part of an experimental wire-protocol surface
1358    /// and may change or be removed in future SDK or CLI releases. Pin both the
1359    /// SDK and CLI versions if your code depends on it.
1360    ///
1361    /// </div>
1362    pub async fn install(
1363        &self,
1364        params: PluginsInstallRequest,
1365    ) -> Result<PluginInstallResult, Error> {
1366        let wire_params = serde_json::to_value(params)?;
1367        let _value = self
1368            .client
1369            .call(rpc_methods::PLUGINS_INSTALL, Some(wire_params))
1370            .await?;
1371        Ok(serde_json::from_value(_value)?)
1372    }
1373
1374    /// Uninstalls an installed plugin.
1375    ///
1376    /// Wire method: `plugins.uninstall`.
1377    ///
1378    /// # Parameters
1379    ///
1380    /// * `params` - Name (or spec) of the plugin to uninstall.
1381    ///
1382    /// <div class="warning">
1383    ///
1384    /// **Experimental.** This API is part of an experimental wire-protocol surface
1385    /// and may change or be removed in future SDK or CLI releases. Pin both the
1386    /// SDK and CLI versions if your code depends on it.
1387    ///
1388    /// </div>
1389    pub async fn uninstall(&self, params: PluginsUninstallRequest) -> Result<(), Error> {
1390        let wire_params = serde_json::to_value(params)?;
1391        let _value = self
1392            .client
1393            .call(rpc_methods::PLUGINS_UNINSTALL, Some(wire_params))
1394            .await?;
1395        Ok(())
1396    }
1397
1398    /// Updates an installed plugin to its latest published version.
1399    ///
1400    /// Wire method: `plugins.update`.
1401    ///
1402    /// # Parameters
1403    ///
1404    /// * `params` - Name (or spec) of the plugin to update.
1405    ///
1406    /// # Returns
1407    ///
1408    /// Result of updating a single plugin.
1409    ///
1410    /// <div class="warning">
1411    ///
1412    /// **Experimental.** This API is part of an experimental wire-protocol surface
1413    /// and may change or be removed in future SDK or CLI releases. Pin both the
1414    /// SDK and CLI versions if your code depends on it.
1415    ///
1416    /// </div>
1417    pub async fn update(&self, params: PluginsUpdateRequest) -> Result<PluginUpdateResult, Error> {
1418        let wire_params = serde_json::to_value(params)?;
1419        let _value = self
1420            .client
1421            .call(rpc_methods::PLUGINS_UPDATE, Some(wire_params))
1422            .await?;
1423        Ok(serde_json::from_value(_value)?)
1424    }
1425
1426    /// Updates every installed plugin to its latest published version.
1427    ///
1428    /// Wire method: `plugins.updateAll`.
1429    ///
1430    /// # Returns
1431    ///
1432    /// Result of updating all installed plugins.
1433    ///
1434    /// <div class="warning">
1435    ///
1436    /// **Experimental.** This API is part of an experimental wire-protocol surface
1437    /// and may change or be removed in future SDK or CLI releases. Pin both the
1438    /// SDK and CLI versions if your code depends on it.
1439    ///
1440    /// </div>
1441    pub async fn update_all(&self) -> Result<PluginUpdateAllResult, Error> {
1442        let wire_params = serde_json::json!({});
1443        let _value = self
1444            .client
1445            .call(rpc_methods::PLUGINS_UPDATEALL, Some(wire_params))
1446            .await?;
1447        Ok(serde_json::from_value(_value)?)
1448    }
1449
1450    /// Enables installed plugins for new sessions.
1451    ///
1452    /// Wire method: `plugins.enable`.
1453    ///
1454    /// # Parameters
1455    ///
1456    /// * `params` - Plugin names (or specs) to enable, plus the optional working directory the repository-controlled guard is evaluated against.
1457    ///
1458    /// <div class="warning">
1459    ///
1460    /// **Experimental.** This API is part of an experimental wire-protocol surface
1461    /// and may change or be removed in future SDK or CLI releases. Pin both the
1462    /// SDK and CLI versions if your code depends on it.
1463    ///
1464    /// </div>
1465    pub async fn enable(&self, params: PluginsEnableRequest) -> Result<(), Error> {
1466        let wire_params = serde_json::to_value(params)?;
1467        let _value = self
1468            .client
1469            .call(rpc_methods::PLUGINS_ENABLE, Some(wire_params))
1470            .await?;
1471        Ok(())
1472    }
1473
1474    /// Disables installed plugins for new sessions.
1475    ///
1476    /// Wire method: `plugins.disable`.
1477    ///
1478    /// # Parameters
1479    ///
1480    /// * `params` - Plugin names (or specs) to disable, plus the optional working directory the repository-controlled guard is evaluated against.
1481    ///
1482    /// <div class="warning">
1483    ///
1484    /// **Experimental.** This API is part of an experimental wire-protocol surface
1485    /// and may change or be removed in future SDK or CLI releases. Pin both the
1486    /// SDK and CLI versions if your code depends on it.
1487    ///
1488    /// </div>
1489    pub async fn disable(&self, params: PluginsDisableRequest) -> Result<(), Error> {
1490        let wire_params = serde_json::to_value(params)?;
1491        let _value = self
1492            .client
1493            .call(rpc_methods::PLUGINS_DISABLE, Some(wire_params))
1494            .await?;
1495        Ok(())
1496    }
1497}
1498
1499/// `plugins.builtin.*` RPCs.
1500#[derive(Clone, Copy)]
1501pub struct ClientRpcPluginsBuiltin<'a> {
1502    pub(crate) client: &'a Client,
1503}
1504
1505impl<'a> ClientRpcPluginsBuiltin<'a> {
1506    /// Replaces this server's trusted built-in plugin directories while no sessions are active.
1507    ///
1508    /// Wire method: `plugins.builtin.set`.
1509    ///
1510    /// # Parameters
1511    ///
1512    /// * `params` - Trusted built-in plugin directories to use for this runtime process.
1513    ///
1514    /// <div class="warning">
1515    ///
1516    /// **Experimental.** This API is part of an experimental wire-protocol surface
1517    /// and may change or be removed in future SDK or CLI releases. Pin both the
1518    /// SDK and CLI versions if your code depends on it.
1519    ///
1520    /// </div>
1521    pub async fn set(&self, params: PluginsBuiltinSetRequest) -> Result<(), Error> {
1522        let wire_params = serde_json::to_value(params)?;
1523        let _value = self
1524            .client
1525            .call(rpc_methods::PLUGINS_BUILTIN_SET, Some(wire_params))
1526            .await?;
1527        Ok(())
1528    }
1529}
1530
1531/// `plugins.marketplaces.*` RPCs.
1532#[derive(Clone, Copy)]
1533pub struct ClientRpcPluginsMarketplaces<'a> {
1534    pub(crate) client: &'a Client,
1535}
1536
1537impl<'a> ClientRpcPluginsMarketplaces<'a> {
1538    /// Lists all registered marketplaces (defaults + user-added).
1539    ///
1540    /// Wire method: `plugins.marketplaces.list`.
1541    ///
1542    /// # Returns
1543    ///
1544    /// All registered marketplaces, including built-in defaults.
1545    ///
1546    /// <div class="warning">
1547    ///
1548    /// **Experimental.** This API is part of an experimental wire-protocol surface
1549    /// and may change or be removed in future SDK or CLI releases. Pin both the
1550    /// SDK and CLI versions if your code depends on it.
1551    ///
1552    /// </div>
1553    pub async fn list(&self) -> Result<MarketplaceListResult, Error> {
1554        let wire_params = serde_json::json!({});
1555        let _value = self
1556            .client
1557            .call(rpc_methods::PLUGINS_MARKETPLACES_LIST, Some(wire_params))
1558            .await?;
1559        Ok(serde_json::from_value(_value)?)
1560    }
1561
1562    /// Registers a new marketplace from a source (owner/repo, URL, or local path).
1563    ///
1564    /// Wire method: `plugins.marketplaces.add`.
1565    ///
1566    /// # Parameters
1567    ///
1568    /// * `params` - Marketplace source and optional working directory for relative-path resolution.
1569    ///
1570    /// # Returns
1571    ///
1572    /// Result of registering a new marketplace.
1573    ///
1574    /// <div class="warning">
1575    ///
1576    /// **Experimental.** This API is part of an experimental wire-protocol surface
1577    /// and may change or be removed in future SDK or CLI releases. Pin both the
1578    /// SDK and CLI versions if your code depends on it.
1579    ///
1580    /// </div>
1581    pub async fn add(
1582        &self,
1583        params: PluginsMarketplacesAddRequest,
1584    ) -> Result<MarketplaceAddResult, Error> {
1585        let wire_params = serde_json::to_value(params)?;
1586        let _value = self
1587            .client
1588            .call(rpc_methods::PLUGINS_MARKETPLACES_ADD, Some(wire_params))
1589            .await?;
1590        Ok(serde_json::from_value(_value)?)
1591    }
1592
1593    /// 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`.
1594    ///
1595    /// Wire method: `plugins.marketplaces.remove`.
1596    ///
1597    /// # Parameters
1598    ///
1599    /// * `params` - Name of the marketplace to remove and an optional force flag.
1600    ///
1601    /// # Returns
1602    ///
1603    /// Outcome of the remove attempt, including dependent-plugin info when applicable.
1604    ///
1605    /// <div class="warning">
1606    ///
1607    /// **Experimental.** This API is part of an experimental wire-protocol surface
1608    /// and may change or be removed in future SDK or CLI releases. Pin both the
1609    /// SDK and CLI versions if your code depends on it.
1610    ///
1611    /// </div>
1612    pub async fn remove(
1613        &self,
1614        params: PluginsMarketplacesRemoveRequest,
1615    ) -> Result<MarketplaceRemoveResult, Error> {
1616        let wire_params = serde_json::to_value(params)?;
1617        let _value = self
1618            .client
1619            .call(rpc_methods::PLUGINS_MARKETPLACES_REMOVE, Some(wire_params))
1620            .await?;
1621        Ok(serde_json::from_value(_value)?)
1622    }
1623
1624    /// Lists plugins advertised by a registered marketplace.
1625    ///
1626    /// Wire method: `plugins.marketplaces.browse`.
1627    ///
1628    /// # Parameters
1629    ///
1630    /// * `params` - Name of the marketplace whose plugin catalog to fetch.
1631    ///
1632    /// # Returns
1633    ///
1634    /// Plugins advertised by the marketplace.
1635    ///
1636    /// <div class="warning">
1637    ///
1638    /// **Experimental.** This API is part of an experimental wire-protocol surface
1639    /// and may change or be removed in future SDK or CLI releases. Pin both the
1640    /// SDK and CLI versions if your code depends on it.
1641    ///
1642    /// </div>
1643    pub async fn browse(
1644        &self,
1645        params: PluginsMarketplacesBrowseRequest,
1646    ) -> Result<MarketplaceBrowseResult, Error> {
1647        let wire_params = serde_json::to_value(params)?;
1648        let _value = self
1649            .client
1650            .call(rpc_methods::PLUGINS_MARKETPLACES_BROWSE, Some(wire_params))
1651            .await?;
1652        Ok(serde_json::from_value(_value)?)
1653    }
1654
1655    /// Re-fetches one or all registered marketplace catalogs.
1656    ///
1657    /// Wire method: `plugins.marketplaces.refresh`.
1658    ///
1659    /// # Returns
1660    ///
1661    /// Result of refreshing one or more marketplace catalogs.
1662    ///
1663    /// <div class="warning">
1664    ///
1665    /// **Experimental.** This API is part of an experimental wire-protocol surface
1666    /// and may change or be removed in future SDK or CLI releases. Pin both the
1667    /// SDK and CLI versions if your code depends on it.
1668    ///
1669    /// </div>
1670    pub async fn refresh(&self) -> Result<MarketplaceRefreshResult, Error> {
1671        let wire_params = serde_json::json!({});
1672        let _value = self
1673            .client
1674            .call(rpc_methods::PLUGINS_MARKETPLACES_REFRESH, Some(wire_params))
1675            .await?;
1676        Ok(serde_json::from_value(_value)?)
1677    }
1678
1679    /// Re-fetches one or all registered marketplace catalogs.
1680    ///
1681    /// Wire method: `plugins.marketplaces.refresh`.
1682    ///
1683    /// # Parameters
1684    ///
1685    /// * `params` - Optional marketplace name; omit to refresh all.
1686    ///
1687    /// # Returns
1688    ///
1689    /// Result of refreshing one or more marketplace catalogs.
1690    ///
1691    /// <div class="warning">
1692    ///
1693    /// **Experimental.** This API is part of an experimental wire-protocol surface
1694    /// and may change or be removed in future SDK or CLI releases. Pin both the
1695    /// SDK and CLI versions if your code depends on it.
1696    ///
1697    /// </div>
1698    pub async fn refresh_with_params(
1699        &self,
1700        params: PluginsMarketplacesRefreshRequest,
1701    ) -> Result<MarketplaceRefreshResult, Error> {
1702        let wire_params = serde_json::to_value(params)?;
1703        let _value = self
1704            .client
1705            .call(rpc_methods::PLUGINS_MARKETPLACES_REFRESH, Some(wire_params))
1706            .await?;
1707        Ok(serde_json::from_value(_value)?)
1708    }
1709}
1710
1711/// `runtime.*` RPCs.
1712#[derive(Clone, Copy)]
1713pub struct ClientRpcRuntime<'a> {
1714    pub(crate) client: &'a Client,
1715}
1716
1717impl<'a> ClientRpcRuntime<'a> {
1718    /// Gracefully shuts down an SDK-owned runtime. The response is sent only after cleanup completes; callers may then terminate the owned runtime process.
1719    ///
1720    /// Wire method: `runtime.shutdown`.
1721    ///
1722    /// <div class="warning">
1723    ///
1724    /// **Experimental.** This API is part of an experimental wire-protocol surface
1725    /// and may change or be removed in future SDK or CLI releases. Pin both the
1726    /// SDK and CLI versions if your code depends on it.
1727    ///
1728    /// </div>
1729    pub async fn shutdown(&self) -> Result<(), Error> {
1730        let wire_params = serde_json::json!({});
1731        let _value = self
1732            .client
1733            .call(rpc_methods::RUNTIME_SHUTDOWN, Some(wire_params))
1734            .await?;
1735        Ok(())
1736    }
1737}
1738
1739/// `sandbox.*` RPCs.
1740#[derive(Clone, Copy)]
1741pub struct ClientRpcSandbox<'a> {
1742    pub(crate) client: &'a Client,
1743}
1744
1745impl<'a> ClientRpcSandbox<'a> {
1746    /// Reports whether the host running this runtime can run the command sandbox, without starting a session or spawning a sandboxed command.
1747    ///
1748    /// Wire method: `sandbox.getHostSupport`.
1749    ///
1750    /// # Returns
1751    ///
1752    /// Whether the host running this runtime can run the command sandbox. The runtime checks `supported` once per process. A capability answer can change while the process runs, for example after the user installs a missing package.
1753    ///
1754    /// <div class="warning">
1755    ///
1756    /// **Experimental.** This API is part of an experimental wire-protocol surface
1757    /// and may change or be removed in future SDK or CLI releases. Pin both the
1758    /// SDK and CLI versions if your code depends on it.
1759    ///
1760    /// </div>
1761    pub async fn get_host_support(&self) -> Result<SandboxHostSupport, Error> {
1762        let wire_params = serde_json::json!({});
1763        let _value = self
1764            .client
1765            .call(rpc_methods::SANDBOX_GETHOSTSUPPORT, Some(wire_params))
1766            .await?;
1767        Ok(serde_json::from_value(_value)?)
1768    }
1769}
1770
1771/// `secrets.*` RPCs.
1772#[derive(Clone, Copy)]
1773pub struct ClientRpcSecrets<'a> {
1774    pub(crate) client: &'a Client,
1775}
1776
1777impl<'a> ClientRpcSecrets<'a> {
1778    /// Registers secret values for redaction in session logs and exports. The SDK calls this to inject dynamically generated secret values (e.g., OIDC tokens).
1779    ///
1780    /// Wire method: `secrets.addFilterValues`.
1781    ///
1782    /// # Parameters
1783    ///
1784    /// * `params` - Secret values to add to the redaction filter.
1785    ///
1786    /// # Returns
1787    ///
1788    /// Confirmation that the secret values were registered.
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 add_filter_values(
1798        &self,
1799        params: SecretsAddFilterValuesRequest,
1800    ) -> Result<SecretsAddFilterValuesResult, Error> {
1801        let wire_params = serde_json::to_value(params)?;
1802        let _value = self
1803            .client
1804            .call(rpc_methods::SECRETS_ADDFILTERVALUES, Some(wire_params))
1805            .await?;
1806        Ok(serde_json::from_value(_value)?)
1807    }
1808}
1809
1810/// `sessionFs.*` RPCs.
1811#[derive(Clone, Copy)]
1812pub struct ClientRpcSessionFs<'a> {
1813    pub(crate) client: &'a Client,
1814}
1815
1816impl<'a> ClientRpcSessionFs<'a> {
1817    /// Registers an SDK client as the session filesystem provider.
1818    ///
1819    /// Wire method: `sessionFs.setProvider`.
1820    ///
1821    /// # Parameters
1822    ///
1823    /// * `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.
1824    ///
1825    /// # Returns
1826    ///
1827    /// Indicates whether the calling client was registered as the session filesystem provider.
1828    ///
1829    /// <div class="warning">
1830    ///
1831    /// **Experimental.** This API is part of an experimental wire-protocol surface
1832    /// and may change or be removed in future SDK or CLI releases. Pin both the
1833    /// SDK and CLI versions if your code depends on it.
1834    ///
1835    /// </div>
1836    pub async fn set_provider(
1837        &self,
1838        params: SessionFsSetProviderRequest,
1839    ) -> Result<SessionFsSetProviderResult, Error> {
1840        let wire_params = serde_json::to_value(params)?;
1841        let _value = self
1842            .client
1843            .call(rpc_methods::SESSIONFS_SETPROVIDER, Some(wire_params))
1844            .await?;
1845        Ok(serde_json::from_value(_value)?)
1846    }
1847}
1848
1849/// `sessions.*` RPCs.
1850#[derive(Clone, Copy)]
1851pub struct ClientRpcSessions<'a> {
1852    pub(crate) client: &'a Client,
1853}
1854
1855impl<'a> ClientRpcSessions<'a> {
1856    /// Creates or resumes a local session and returns the opened session ID.
1857    ///
1858    /// Wire method: `sessions.open`.
1859    ///
1860    /// # Returns
1861    ///
1862    /// Result of opening a session.
1863    ///
1864    /// <div class="warning">
1865    ///
1866    /// **Experimental.** This API is part of an experimental wire-protocol surface
1867    /// and may change or be removed in future SDK or CLI releases. Pin both the
1868    /// SDK and CLI versions if your code depends on it.
1869    ///
1870    /// </div>
1871    pub async fn open(&self) -> Result<SessionOpenResult, Error> {
1872        let wire_params = serde_json::json!({});
1873        let _value = self
1874            .client
1875            .call(rpc_methods::SESSIONS_OPEN, Some(wire_params))
1876            .await?;
1877        Ok(serde_json::from_value(_value)?)
1878    }
1879
1880    /// Creates a new session by forking persisted history from an existing session.
1881    ///
1882    /// Wire method: `sessions.fork`.
1883    ///
1884    /// # Parameters
1885    ///
1886    /// * `params` - Source session identifier to fork from, optional event-ID boundary, and optional friendly name for the new session.
1887    ///
1888    /// # Returns
1889    ///
1890    /// Identifier and optional friendly name assigned to the newly forked session.
1891    ///
1892    /// <div class="warning">
1893    ///
1894    /// **Experimental.** This API is part of an experimental wire-protocol surface
1895    /// and may change or be removed in future SDK or CLI releases. Pin both the
1896    /// SDK and CLI versions if your code depends on it.
1897    ///
1898    /// </div>
1899    pub async fn fork(&self, params: SessionsForkRequest) -> Result<SessionsForkResult, Error> {
1900        let wire_params = serde_json::to_value(params)?;
1901        let _value = self
1902            .client
1903            .call(rpc_methods::SESSIONS_FORK, Some(wire_params))
1904            .await?;
1905        Ok(serde_json::from_value(_value)?)
1906    }
1907
1908    /// Connects to an existing remote session and exposes it as an SDK session.
1909    ///
1910    /// Wire method: `sessions.connect`.
1911    ///
1912    /// # Parameters
1913    ///
1914    /// * `params` - Remote session connection parameters.
1915    ///
1916    /// # Returns
1917    ///
1918    /// Remote session connection result.
1919    ///
1920    /// <div class="warning">
1921    ///
1922    /// **Experimental.** This API is part of an experimental wire-protocol surface
1923    /// and may change or be removed in future SDK or CLI releases. Pin both the
1924    /// SDK and CLI versions if your code depends on it.
1925    ///
1926    /// </div>
1927    pub async fn connect(
1928        &self,
1929        params: ConnectRemoteSessionParams,
1930    ) -> Result<RemoteSessionConnectionResult, Error> {
1931        let wire_params = serde_json::to_value(params)?;
1932        let _value = self
1933            .client
1934            .call(rpc_methods::SESSIONS_CONNECT, Some(wire_params))
1935            .await?;
1936        Ok(serde_json::from_value(_value)?)
1937    }
1938
1939    /// 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.).
1940    ///
1941    /// Wire method: `sessions.list`.
1942    ///
1943    /// # Returns
1944    ///
1945    /// Sessions matching the filter, ordered most-recently-modified first.
1946    ///
1947    /// <div class="warning">
1948    ///
1949    /// **Experimental.** This API is part of an experimental wire-protocol surface
1950    /// and may change or be removed in future SDK or CLI releases. Pin both the
1951    /// SDK and CLI versions if your code depends on it.
1952    ///
1953    /// </div>
1954    pub async fn list(&self) -> Result<SessionList, Error> {
1955        let wire_params = serde_json::json!({});
1956        let _value = self
1957            .client
1958            .call(rpc_methods::SESSIONS_LIST, Some(wire_params))
1959            .await?;
1960        Ok(serde_json::from_value(_value)?)
1961    }
1962
1963    /// 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.).
1964    ///
1965    /// Wire method: `sessions.list`.
1966    ///
1967    /// # Parameters
1968    ///
1969    /// * `params` - Optional source filter, metadata-load limit, and context filter applied to the returned sessions.
1970    ///
1971    /// # Returns
1972    ///
1973    /// Sessions matching the filter, ordered most-recently-modified first.
1974    ///
1975    /// <div class="warning">
1976    ///
1977    /// **Experimental.** This API is part of an experimental wire-protocol surface
1978    /// and may change or be removed in future SDK or CLI releases. Pin both the
1979    /// SDK and CLI versions if your code depends on it.
1980    ///
1981    /// </div>
1982    pub async fn list_with_params(
1983        &self,
1984        params: SessionsListRequest,
1985    ) -> Result<SessionList, Error> {
1986        let wire_params = serde_json::to_value(params)?;
1987        let _value = self
1988            .client
1989            .call(rpc_methods::SESSIONS_LIST, Some(wire_params))
1990            .await?;
1991        Ok(serde_json::from_value(_value)?)
1992    }
1993
1994    /// Reads lightweight persisted metadata for one local session without opening it.
1995    ///
1996    /// Wire method: `sessions.getMetadata`.
1997    ///
1998    /// # Parameters
1999    ///
2000    /// * `params` - Session ID whose persisted metadata should be read.
2001    ///
2002    /// # Returns
2003    ///
2004    /// Persisted local session metadata when the session exists.
2005    ///
2006    /// <div class="warning">
2007    ///
2008    /// **Experimental.** This API is part of an experimental wire-protocol surface
2009    /// and may change or be removed in future SDK or CLI releases. Pin both the
2010    /// SDK and CLI versions if your code depends on it.
2011    ///
2012    /// </div>
2013    pub(crate) async fn get_metadata(
2014        &self,
2015        params: SessionsGetMetadataRequest,
2016    ) -> Result<SessionsGetMetadataResult, Error> {
2017        let wire_params = serde_json::to_value(params)?;
2018        let _value = self
2019            .client
2020            .call(rpc_methods::SESSIONS_GETMETADATA, Some(wire_params))
2021            .await?;
2022        Ok(serde_json::from_value(_value)?)
2023    }
2024
2025    /// 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.
2026    ///
2027    /// Wire method: `sessions.getClientMetadata`.
2028    ///
2029    /// # Parameters
2030    ///
2031    /// * `params` - Bounded batch request for client-owned metadata from persisted local sessions.
2032    ///
2033    /// # Returns
2034    ///
2035    /// Ordered client metadata outcomes for the requested local sessions.
2036    ///
2037    /// <div class="warning">
2038    ///
2039    /// **Experimental.** This API is part of an experimental wire-protocol surface
2040    /// and may change or be removed in future SDK or CLI releases. Pin both the
2041    /// SDK and CLI versions if your code depends on it.
2042    ///
2043    /// </div>
2044    pub async fn get_client_metadata(
2045        &self,
2046        params: SessionsGetClientMetadataRequest,
2047    ) -> Result<SessionsGetClientMetadataResult, Error> {
2048        let wire_params = serde_json::to_value(params)?;
2049        let _value = self
2050            .client
2051            .call(rpc_methods::SESSIONS_GETCLIENTMETADATA, Some(wire_params))
2052            .await?;
2053        Ok(serde_json::from_value(_value)?)
2054    }
2055
2056    /// 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.
2057    ///
2058    /// Wire method: `sessions.readPersistedEvents`.
2059    ///
2060    /// # Parameters
2061    ///
2062    /// * `params` - Pagination options for reading an inactive or active local session's persisted event journal.
2063    ///
2064    /// # Returns
2065    ///
2066    /// Batch of session events returned by a read, with cursor and continuation metadata.
2067    ///
2068    /// <div class="warning">
2069    ///
2070    /// **Experimental.** This API is part of an experimental wire-protocol surface
2071    /// and may change or be removed in future SDK or CLI releases. Pin both the
2072    /// SDK and CLI versions if your code depends on it.
2073    ///
2074    /// </div>
2075    pub async fn read_persisted_events(
2076        &self,
2077        params: SessionsReadPersistedEventsRequest,
2078    ) -> Result<EventsReadResult, Error> {
2079        let wire_params = serde_json::to_value(params)?;
2080        let _value = self
2081            .client
2082            .call(rpc_methods::SESSIONS_READPERSISTEDEVENTS, Some(wire_params))
2083            .await?;
2084        Ok(serde_json::from_value(_value)?)
2085    }
2086
2087    /// Lists recent local session IDs that contain user-visible history, omitting housekeeping-only sessions.
2088    ///
2089    /// Wire method: `sessions.listNonEmptySessionIds`.
2090    ///
2091    /// # Parameters
2092    ///
2093    /// * `params` - Limit for non-empty local session IDs.
2094    ///
2095    /// # Returns
2096    ///
2097    /// Recent local session IDs that contain user-visible history.
2098    ///
2099    /// <div class="warning">
2100    ///
2101    /// **Experimental.** This API is part of an experimental wire-protocol surface
2102    /// and may change or be removed in future SDK or CLI releases. Pin both the
2103    /// SDK and CLI versions if your code depends on it.
2104    ///
2105    /// </div>
2106    pub(crate) async fn list_non_empty_session_ids(
2107        &self,
2108        params: SessionsListNonEmptySessionIdsRequest,
2109    ) -> Result<SessionsListNonEmptySessionIdsResult, Error> {
2110        let wire_params = serde_json::to_value(params)?;
2111        let _value = self
2112            .client
2113            .call(
2114                rpc_methods::SESSIONS_LISTNONEMPTYSESSIONIDS,
2115                Some(wire_params),
2116            )
2117            .await?;
2118        Ok(serde_json::from_value(_value)?)
2119    }
2120
2121    /// Finds the local session bound to a GitHub task ID, if any.
2122    ///
2123    /// Wire method: `sessions.findByTaskId`.
2124    ///
2125    /// # Parameters
2126    ///
2127    /// * `params` - GitHub task ID to look up.
2128    ///
2129    /// # Returns
2130    ///
2131    /// ID of the local session bound to the given GitHub task, or omitted when none.
2132    ///
2133    /// <div class="warning">
2134    ///
2135    /// **Experimental.** This API is part of an experimental wire-protocol surface
2136    /// and may change or be removed in future SDK or CLI releases. Pin both the
2137    /// SDK and CLI versions if your code depends on it.
2138    ///
2139    /// </div>
2140    pub async fn find_by_task_id(
2141        &self,
2142        params: SessionsFindByTaskIDRequest,
2143    ) -> Result<SessionsFindByTaskIDResult, Error> {
2144        let wire_params = serde_json::to_value(params)?;
2145        let _value = self
2146            .client
2147            .call(rpc_methods::SESSIONS_FINDBYTASKID, Some(wire_params))
2148            .await?;
2149        Ok(serde_json::from_value(_value)?)
2150    }
2151
2152    /// Resolves a UUID prefix to a unique session ID, if exactly one session matches.
2153    ///
2154    /// Wire method: `sessions.findByPrefix`.
2155    ///
2156    /// # Parameters
2157    ///
2158    /// * `params` - UUID prefix to resolve to a unique session ID.
2159    ///
2160    /// # Returns
2161    ///
2162    /// Session ID matching the prefix, omitted when no unique match exists.
2163    ///
2164    /// <div class="warning">
2165    ///
2166    /// **Experimental.** This API is part of an experimental wire-protocol surface
2167    /// and may change or be removed in future SDK or CLI releases. Pin both the
2168    /// SDK and CLI versions if your code depends on it.
2169    ///
2170    /// </div>
2171    pub async fn find_by_prefix(
2172        &self,
2173        params: SessionsFindByPrefixRequest,
2174    ) -> Result<SessionsFindByPrefixResult, Error> {
2175        let wire_params = serde_json::to_value(params)?;
2176        let _value = self
2177            .client
2178            .call(rpc_methods::SESSIONS_FINDBYPREFIX, Some(wire_params))
2179            .await?;
2180        Ok(serde_json::from_value(_value)?)
2181    }
2182
2183    /// Returns the most-relevant prior session for a given working-directory context.
2184    ///
2185    /// Wire method: `sessions.getLastForContext`.
2186    ///
2187    /// # Parameters
2188    ///
2189    /// * `params` - Optional working-directory context used to score session relevance.
2190    ///
2191    /// # Returns
2192    ///
2193    /// Most-relevant session ID for the supplied context, or omitted when no sessions exist.
2194    ///
2195    /// <div class="warning">
2196    ///
2197    /// **Experimental.** This API is part of an experimental wire-protocol surface
2198    /// and may change or be removed in future SDK or CLI releases. Pin both the
2199    /// SDK and CLI versions if your code depends on it.
2200    ///
2201    /// </div>
2202    pub async fn get_last_for_context(
2203        &self,
2204        params: SessionsGetLastForContextRequest,
2205    ) -> Result<SessionsGetLastForContextResult, Error> {
2206        let wire_params = serde_json::to_value(params)?;
2207        let _value = self
2208            .client
2209            .call(rpc_methods::SESSIONS_GETLASTFORCONTEXT, Some(wire_params))
2210            .await?;
2211        Ok(serde_json::from_value(_value)?)
2212    }
2213
2214    /// 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.
2215    ///
2216    /// Wire method: `sessions.getEventFilePath`.
2217    ///
2218    /// # Parameters
2219    ///
2220    /// * `params` - Session ID whose event-log file path to compute.
2221    ///
2222    /// # Returns
2223    ///
2224    /// Absolute path to the session's events.jsonl file on disk.
2225    ///
2226    /// <div class="warning">
2227    ///
2228    /// **Experimental.** This API is part of an experimental wire-protocol surface
2229    /// and may change or be removed in future SDK or CLI releases. Pin both the
2230    /// SDK and CLI versions if your code depends on it.
2231    ///
2232    /// </div>
2233    pub(crate) async fn get_event_file_path(
2234        &self,
2235        params: SessionsGetEventFilePathRequest,
2236    ) -> Result<SessionsGetEventFilePathResult, Error> {
2237        let wire_params = serde_json::to_value(params)?;
2238        let _value = self
2239            .client
2240            .call(rpc_methods::SESSIONS_GETEVENTFILEPATH, Some(wire_params))
2241            .await?;
2242        Ok(serde_json::from_value(_value)?)
2243    }
2244
2245    /// Returns the on-disk byte size of each session's workspace directory.
2246    ///
2247    /// Wire method: `sessions.getSizes`.
2248    ///
2249    /// # Returns
2250    ///
2251    /// Map of sessionId -> on-disk size in bytes for each session's workspace directory.
2252    ///
2253    /// <div class="warning">
2254    ///
2255    /// **Experimental.** This API is part of an experimental wire-protocol surface
2256    /// and may change or be removed in future SDK or CLI releases. Pin both the
2257    /// SDK and CLI versions if your code depends on it.
2258    ///
2259    /// </div>
2260    pub async fn get_sizes(&self) -> Result<SessionSizes, Error> {
2261        let wire_params = serde_json::json!({});
2262        let _value = self
2263            .client
2264            .call(rpc_methods::SESSIONS_GETSIZES, Some(wire_params))
2265            .await?;
2266        Ok(serde_json::from_value(_value)?)
2267    }
2268
2269    /// Returns the subset of the supplied session IDs that are currently held by another running process.
2270    ///
2271    /// Wire method: `sessions.checkInUse`.
2272    ///
2273    /// # Parameters
2274    ///
2275    /// * `params` - Session IDs to test for live in-use locks.
2276    ///
2277    /// # Returns
2278    ///
2279    /// Session IDs from the input set that are currently in use by another process.
2280    ///
2281    /// <div class="warning">
2282    ///
2283    /// **Experimental.** This API is part of an experimental wire-protocol surface
2284    /// and may change or be removed in future SDK or CLI releases. Pin both the
2285    /// SDK and CLI versions if your code depends on it.
2286    ///
2287    /// </div>
2288    pub async fn check_in_use(
2289        &self,
2290        params: SessionsCheckInUseRequest,
2291    ) -> Result<SessionsCheckInUseResult, Error> {
2292        let wire_params = serde_json::to_value(params)?;
2293        let _value = self
2294            .client
2295            .call(rpc_methods::SESSIONS_CHECKINUSE, Some(wire_params))
2296            .await?;
2297        Ok(serde_json::from_value(_value)?)
2298    }
2299
2300    /// 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.
2301    ///
2302    /// Wire method: `sessions.getPersistedRemoteSteerable`.
2303    ///
2304    /// # Parameters
2305    ///
2306    /// * `params` - Session ID to look up the persisted remote-steerable flag for.
2307    ///
2308    /// # Returns
2309    ///
2310    /// The session's persisted remote-steerable flag, or omitted when no value has been persisted.
2311    ///
2312    /// <div class="warning">
2313    ///
2314    /// **Experimental.** This API is part of an experimental wire-protocol surface
2315    /// and may change or be removed in future SDK or CLI releases. Pin both the
2316    /// SDK and CLI versions if your code depends on it.
2317    ///
2318    /// </div>
2319    pub(crate) async fn get_persisted_remote_steerable(
2320        &self,
2321        params: SessionsGetPersistedRemoteSteerableRequest,
2322    ) -> Result<SessionsGetPersistedRemoteSteerableResult, Error> {
2323        let wire_params = serde_json::to_value(params)?;
2324        let _value = self
2325            .client
2326            .call(
2327                rpc_methods::SESSIONS_GETPERSISTEDREMOTESTEERABLE,
2328                Some(wire_params),
2329            )
2330            .await?;
2331        Ok(serde_json::from_value(_value)?)
2332    }
2333
2334    /// Closes a session: emits shutdown, flushes pending events, releases the in-use lock, and disposes the active session.
2335    ///
2336    /// Wire method: `sessions.close`.
2337    ///
2338    /// # Parameters
2339    ///
2340    /// * `params` - Session ID to close.
2341    ///
2342    /// # Returns
2343    ///
2344    /// 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.
2345    ///
2346    /// <div class="warning">
2347    ///
2348    /// **Experimental.** This API is part of an experimental wire-protocol surface
2349    /// and may change or be removed in future SDK or CLI releases. Pin both the
2350    /// SDK and CLI versions if your code depends on it.
2351    ///
2352    /// </div>
2353    pub async fn close(&self, params: SessionsCloseRequest) -> Result<SessionsCloseResult, Error> {
2354        let wire_params = serde_json::to_value(params)?;
2355        let _value = self
2356            .client
2357            .call(rpc_methods::SESSIONS_CLOSE, Some(wire_params))
2358            .await?;
2359        Ok(serde_json::from_value(_value)?)
2360    }
2361
2362    /// Closes, deactivates, and deletes a set of sessions, returning the bytes freed per session.
2363    ///
2364    /// Wire method: `sessions.bulkDelete`.
2365    ///
2366    /// # Parameters
2367    ///
2368    /// * `params` - Session IDs to close, deactivate, and delete from disk.
2369    ///
2370    /// # Returns
2371    ///
2372    /// Map of sessionId -> bytes freed by removing the session's workspace directory.
2373    ///
2374    /// <div class="warning">
2375    ///
2376    /// **Experimental.** This API is part of an experimental wire-protocol surface
2377    /// and may change or be removed in future SDK or CLI releases. Pin both the
2378    /// SDK and CLI versions if your code depends on it.
2379    ///
2380    /// </div>
2381    pub async fn bulk_delete(
2382        &self,
2383        params: SessionsBulkDeleteRequest,
2384    ) -> Result<SessionBulkDeleteResult, Error> {
2385        let wire_params = serde_json::to_value(params)?;
2386        let _value = self
2387            .client
2388            .call(rpc_methods::SESSIONS_BULKDELETE, Some(wire_params))
2389            .await?;
2390        Ok(serde_json::from_value(_value)?)
2391    }
2392
2393    /// Deletes one local session from disk after running the same lifecycle hooks as the session manager.
2394    ///
2395    /// Wire method: `sessions.delete`.
2396    ///
2397    /// # Parameters
2398    ///
2399    /// * `params` - Session ID to delete from disk.
2400    ///
2401    /// <div class="warning">
2402    ///
2403    /// **Experimental.** This API is part of an experimental wire-protocol surface
2404    /// and may change or be removed in future SDK or CLI releases. Pin both the
2405    /// SDK and CLI versions if your code depends on it.
2406    ///
2407    /// </div>
2408    pub(crate) async fn delete(&self, params: SessionsDeleteRequest) -> Result<(), Error> {
2409        let wire_params = serde_json::to_value(params)?;
2410        let _value = self
2411            .client
2412            .call(rpc_methods::SESSIONS_DELETE, Some(wire_params))
2413            .await?;
2414        Ok(())
2415    }
2416
2417    /// Deletes sessions older than the given threshold, with optional dry-run and exclusion list.
2418    ///
2419    /// Wire method: `sessions.pruneOld`.
2420    ///
2421    /// # Parameters
2422    ///
2423    /// * `params` - Age threshold and optional flags controlling which old sessions are pruned (or simulated when dryRun is true).
2424    ///
2425    /// # Returns
2426    ///
2427    /// Outcome of the prune operation: deleted IDs, dry-run candidates, skipped IDs, total bytes freed, and the dry-run flag.
2428    ///
2429    /// <div class="warning">
2430    ///
2431    /// **Experimental.** This API is part of an experimental wire-protocol surface
2432    /// and may change or be removed in future SDK or CLI releases. Pin both the
2433    /// SDK and CLI versions if your code depends on it.
2434    ///
2435    /// </div>
2436    pub async fn prune_old(
2437        &self,
2438        params: SessionsPruneOldRequest,
2439    ) -> Result<SessionPruneResult, Error> {
2440        let wire_params = serde_json::to_value(params)?;
2441        let _value = self
2442            .client
2443            .call(rpc_methods::SESSIONS_PRUNEOLD, Some(wire_params))
2444            .await?;
2445        Ok(serde_json::from_value(_value)?)
2446    }
2447
2448    /// Flushes a session's pending events to disk.
2449    ///
2450    /// Wire method: `sessions.save`.
2451    ///
2452    /// # Parameters
2453    ///
2454    /// * `params` - Session ID whose pending events should be flushed to disk.
2455    ///
2456    /// # Returns
2457    ///
2458    /// Flush a session's pending events to disk. No-op when no writer exists for the session (e.g., already closed).
2459    ///
2460    /// <div class="warning">
2461    ///
2462    /// **Experimental.** This API is part of an experimental wire-protocol surface
2463    /// and may change or be removed in future SDK or CLI releases. Pin both the
2464    /// SDK and CLI versions if your code depends on it.
2465    ///
2466    /// </div>
2467    pub async fn save(&self, params: SessionsSaveRequest) -> Result<SessionsSaveResult, Error> {
2468        let wire_params = serde_json::to_value(params)?;
2469        let _value = self
2470            .client
2471            .call(rpc_methods::SESSIONS_SAVE, Some(wire_params))
2472            .await?;
2473        Ok(serde_json::from_value(_value)?)
2474    }
2475
2476    /// Releases the in-use lock held by this process for a session.
2477    ///
2478    /// Wire method: `sessions.releaseLock`.
2479    ///
2480    /// # Parameters
2481    ///
2482    /// * `params` - Session ID whose in-use lock should be released.
2483    ///
2484    /// # Returns
2485    ///
2486    /// 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.
2487    ///
2488    /// <div class="warning">
2489    ///
2490    /// **Experimental.** This API is part of an experimental wire-protocol surface
2491    /// and may change or be removed in future SDK or CLI releases. Pin both the
2492    /// SDK and CLI versions if your code depends on it.
2493    ///
2494    /// </div>
2495    pub async fn release_lock(
2496        &self,
2497        params: SessionsReleaseLockRequest,
2498    ) -> Result<SessionsReleaseLockResult, Error> {
2499        let wire_params = serde_json::to_value(params)?;
2500        let _value = self
2501            .client
2502            .call(rpc_methods::SESSIONS_RELEASELOCK, Some(wire_params))
2503            .await?;
2504        Ok(serde_json::from_value(_value)?)
2505    }
2506
2507    /// Backfills missing summary and context fields on the supplied session metadata records.
2508    ///
2509    /// Wire method: `sessions.enrichMetadata`.
2510    ///
2511    /// # Parameters
2512    ///
2513    /// * `params` - Session metadata records to enrich with summary and context information.
2514    ///
2515    /// # Returns
2516    ///
2517    /// The enriched metadata records, with summary and context fields backfilled where available. Sessions confirmed empty and unnamed are omitted.
2518    ///
2519    /// <div class="warning">
2520    ///
2521    /// **Experimental.** This API is part of an experimental wire-protocol surface
2522    /// and may change or be removed in future SDK or CLI releases. Pin both the
2523    /// SDK and CLI versions if your code depends on it.
2524    ///
2525    /// </div>
2526    pub async fn enrich_metadata(
2527        &self,
2528        params: SessionsEnrichMetadataRequest,
2529    ) -> Result<SessionEnrichMetadataResult, Error> {
2530        let wire_params = serde_json::to_value(params)?;
2531        let _value = self
2532            .client
2533            .call(rpc_methods::SESSIONS_ENRICHMETADATA, Some(wire_params))
2534            .await?;
2535        Ok(serde_json::from_value(_value)?)
2536    }
2537
2538    /// Reloads user, plugin, and (optionally) repo hooks on the active session.
2539    ///
2540    /// Wire method: `sessions.reloadPluginHooks`.
2541    ///
2542    /// # Parameters
2543    ///
2544    /// * `params` - Active session ID and an optional flag for deferring repo-level hooks until folder trust.
2545    ///
2546    /// # Returns
2547    ///
2548    /// 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.
2549    ///
2550    /// <div class="warning">
2551    ///
2552    /// **Experimental.** This API is part of an experimental wire-protocol surface
2553    /// and may change or be removed in future SDK or CLI releases. Pin both the
2554    /// SDK and CLI versions if your code depends on it.
2555    ///
2556    /// </div>
2557    pub async fn reload_plugin_hooks(
2558        &self,
2559        params: SessionsReloadPluginHooksRequest,
2560    ) -> Result<SessionsReloadPluginHooksResult, Error> {
2561        let wire_params = serde_json::to_value(params)?;
2562        let _value = self
2563            .client
2564            .call(rpc_methods::SESSIONS_RELOADPLUGINHOOKS, Some(wire_params))
2565            .await?;
2566        Ok(serde_json::from_value(_value)?)
2567    }
2568
2569    /// Loads previously-deferred repo-level hooks on the active session, returning queued startup prompts.
2570    ///
2571    /// Wire method: `sessions.loadDeferredRepoHooks`.
2572    ///
2573    /// # Parameters
2574    ///
2575    /// * `params` - Active session ID whose deferred repo-level hooks should be loaded.
2576    ///
2577    /// # Returns
2578    ///
2579    /// Queued repo-level startup prompts and the total hook command count after loading.
2580    ///
2581    /// <div class="warning">
2582    ///
2583    /// **Experimental.** This API is part of an experimental wire-protocol surface
2584    /// and may change or be removed in future SDK or CLI releases. Pin both the
2585    /// SDK and CLI versions if your code depends on it.
2586    ///
2587    /// </div>
2588    pub async fn load_deferred_repo_hooks(
2589        &self,
2590        params: SessionsLoadDeferredRepoHooksRequest,
2591    ) -> Result<SessionLoadDeferredRepoHooksResult, Error> {
2592        let wire_params = serde_json::to_value(params)?;
2593        let _value = self
2594            .client
2595            .call(
2596                rpc_methods::SESSIONS_LOADDEFERREDREPOHOOKS,
2597                Some(wire_params),
2598            )
2599            .await?;
2600        Ok(serde_json::from_value(_value)?)
2601    }
2602
2603    /// Replaces the manager-wide additional plugins registered with the session manager.
2604    ///
2605    /// Wire method: `sessions.setAdditionalPlugins`.
2606    ///
2607    /// # Parameters
2608    ///
2609    /// * `params` - Manager-wide additional plugins to register; replaces any previously-configured set.
2610    ///
2611    /// # Returns
2612    ///
2613    /// 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.
2614    ///
2615    /// <div class="warning">
2616    ///
2617    /// **Experimental.** This API is part of an experimental wire-protocol surface
2618    /// and may change or be removed in future SDK or CLI releases. Pin both the
2619    /// SDK and CLI versions if your code depends on it.
2620    ///
2621    /// </div>
2622    pub async fn set_additional_plugins(
2623        &self,
2624        params: SessionsSetAdditionalPluginsRequest,
2625    ) -> Result<SessionsSetAdditionalPluginsResult, Error> {
2626        let wire_params = serde_json::to_value(params)?;
2627        let _value = self
2628            .client
2629            .call(
2630                rpc_methods::SESSIONS_SETADDITIONALPLUGINS,
2631                Some(wire_params),
2632            )
2633            .await?;
2634        Ok(serde_json::from_value(_value)?)
2635    }
2636
2637    /// 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.
2638    ///
2639    /// Wire method: `sessions.getBoardEntryCount`.
2640    ///
2641    /// # Parameters
2642    ///
2643    /// * `params` - Session ID whose board entry count should be returned.
2644    ///
2645    /// # Returns
2646    ///
2647    /// Dynamic-context board entry count, when available.
2648    ///
2649    /// <div class="warning">
2650    ///
2651    /// **Experimental.** This API is part of an experimental wire-protocol surface
2652    /// and may change or be removed in future SDK or CLI releases. Pin both the
2653    /// SDK and CLI versions if your code depends on it.
2654    ///
2655    /// </div>
2656    pub(crate) async fn get_board_entry_count(
2657        &self,
2658        params: SessionsGetBoardEntryCountRequest,
2659    ) -> Result<SessionsGetBoardEntryCountResult, Error> {
2660        let wire_params = serde_json::to_value(params)?;
2661        let _value = self
2662            .client
2663            .call(rpc_methods::SESSIONS_GETBOARDENTRYCOUNT, Some(wire_params))
2664            .await?;
2665        Ok(serde_json::from_value(_value)?)
2666    }
2667
2668    /// 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.
2669    ///
2670    /// Wire method: `sessions.startRemoteControl`.
2671    ///
2672    /// # Parameters
2673    ///
2674    /// * `params` - Parameters for attaching the remote-control singleton to a session.
2675    ///
2676    /// # Returns
2677    ///
2678    /// Wrapper for the singleton's current status.
2679    ///
2680    /// <div class="warning">
2681    ///
2682    /// **Experimental.** This API is part of an experimental wire-protocol surface
2683    /// and may change or be removed in future SDK or CLI releases. Pin both the
2684    /// SDK and CLI versions if your code depends on it.
2685    ///
2686    /// </div>
2687    pub async fn start_remote_control(
2688        &self,
2689        params: SessionsStartRemoteControlRequest,
2690    ) -> Result<RemoteControlStatusResult, Error> {
2691        let wire_params = serde_json::to_value(params)?;
2692        let _value = self
2693            .client
2694            .call(rpc_methods::SESSIONS_STARTREMOTECONTROL, Some(wire_params))
2695            .await?;
2696        Ok(serde_json::from_value(_value)?)
2697    }
2698
2699    /// 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.
2700    ///
2701    /// Wire method: `sessions.transferRemoteControl`.
2702    ///
2703    /// # Parameters
2704    ///
2705    /// * `params` - Parameters for atomically rebinding the remote-control singleton.
2706    ///
2707    /// # Returns
2708    ///
2709    /// Outcome of a transferRemoteControl call.
2710    ///
2711    /// <div class="warning">
2712    ///
2713    /// **Experimental.** This API is part of an experimental wire-protocol surface
2714    /// and may change or be removed in future SDK or CLI releases. Pin both the
2715    /// SDK and CLI versions if your code depends on it.
2716    ///
2717    /// </div>
2718    pub async fn transfer_remote_control(
2719        &self,
2720        params: SessionsTransferRemoteControlRequest,
2721    ) -> Result<RemoteControlTransferResult, Error> {
2722        let wire_params = serde_json::to_value(params)?;
2723        let _value = self
2724            .client
2725            .call(
2726                rpc_methods::SESSIONS_TRANSFERREMOTECONTROL,
2727                Some(wire_params),
2728            )
2729            .await?;
2730        Ok(serde_json::from_value(_value)?)
2731    }
2732
2733    /// 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.
2734    ///
2735    /// Wire method: `sessions.setRemoteControlSteering`.
2736    ///
2737    /// # Parameters
2738    ///
2739    /// * `params` - Patch for the singleton's steering state.
2740    ///
2741    /// # Returns
2742    ///
2743    /// Wrapper for the singleton's current status.
2744    ///
2745    /// <div class="warning">
2746    ///
2747    /// **Experimental.** This API is part of an experimental wire-protocol surface
2748    /// and may change or be removed in future SDK or CLI releases. Pin both the
2749    /// SDK and CLI versions if your code depends on it.
2750    ///
2751    /// </div>
2752    pub async fn set_remote_control_steering(
2753        &self,
2754        params: SessionsSetRemoteControlSteeringRequest,
2755    ) -> Result<RemoteControlStatusResult, Error> {
2756        let wire_params = serde_json::to_value(params)?;
2757        let _value = self
2758            .client
2759            .call(
2760                rpc_methods::SESSIONS_SETREMOTECONTROLSTEERING,
2761                Some(wire_params),
2762            )
2763            .await?;
2764        Ok(serde_json::from_value(_value)?)
2765    }
2766
2767    /// 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).
2768    ///
2769    /// Wire method: `sessions.stopRemoteControl`.
2770    ///
2771    /// # Returns
2772    ///
2773    /// Outcome of a stopRemoteControl call.
2774    ///
2775    /// <div class="warning">
2776    ///
2777    /// **Experimental.** This API is part of an experimental wire-protocol surface
2778    /// and may change or be removed in future SDK or CLI releases. Pin both the
2779    /// SDK and CLI versions if your code depends on it.
2780    ///
2781    /// </div>
2782    pub async fn stop_remote_control(&self) -> Result<RemoteControlStopResult, Error> {
2783        let wire_params = serde_json::json!({});
2784        let _value = self
2785            .client
2786            .call(rpc_methods::SESSIONS_STOPREMOTECONTROL, Some(wire_params))
2787            .await?;
2788        Ok(serde_json::from_value(_value)?)
2789    }
2790
2791    /// 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).
2792    ///
2793    /// Wire method: `sessions.stopRemoteControl`.
2794    ///
2795    /// # Parameters
2796    ///
2797    /// * `params` - Parameters for stopping the remote-control singleton.
2798    ///
2799    /// # Returns
2800    ///
2801    /// Outcome of a stopRemoteControl call.
2802    ///
2803    /// <div class="warning">
2804    ///
2805    /// **Experimental.** This API is part of an experimental wire-protocol surface
2806    /// and may change or be removed in future SDK or CLI releases. Pin both the
2807    /// SDK and CLI versions if your code depends on it.
2808    ///
2809    /// </div>
2810    pub async fn stop_remote_control_with_params(
2811        &self,
2812        params: SessionsStopRemoteControlRequest,
2813    ) -> Result<RemoteControlStopResult, Error> {
2814        let wire_params = serde_json::to_value(params)?;
2815        let _value = self
2816            .client
2817            .call(rpc_methods::SESSIONS_STOPREMOTECONTROL, Some(wire_params))
2818            .await?;
2819        Ok(serde_json::from_value(_value)?)
2820    }
2821
2822    /// Returns the current state of the remote-control singleton, including the attached session id and frontend URL when active.
2823    ///
2824    /// Wire method: `sessions.getRemoteControlStatus`.
2825    ///
2826    /// # Returns
2827    ///
2828    /// Wrapper for the singleton's current status.
2829    ///
2830    /// <div class="warning">
2831    ///
2832    /// **Experimental.** This API is part of an experimental wire-protocol surface
2833    /// and may change or be removed in future SDK or CLI releases. Pin both the
2834    /// SDK and CLI versions if your code depends on it.
2835    ///
2836    /// </div>
2837    pub async fn get_remote_control_status(&self) -> Result<RemoteControlStatusResult, Error> {
2838        let wire_params = serde_json::json!({});
2839        let _value = self
2840            .client
2841            .call(
2842                rpc_methods::SESSIONS_GETREMOTECONTROLSTATUS,
2843                Some(wire_params),
2844            )
2845            .await?;
2846        Ok(serde_json::from_value(_value)?)
2847    }
2848
2849    /// 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.
2850    ///
2851    /// Wire method: `sessions.configureSessionExtensions`.
2852    ///
2853    /// # Parameters
2854    ///
2855    /// * `params` - Params to attach or detach an in-process ExtensionController delegate.
2856    ///
2857    /// <div class="warning">
2858    ///
2859    /// **Experimental.** This API is part of an experimental wire-protocol surface
2860    /// and may change or be removed in future SDK or CLI releases. Pin both the
2861    /// SDK and CLI versions if your code depends on it.
2862    ///
2863    /// </div>
2864    pub(crate) async fn configure_session_extensions(
2865        &self,
2866        params: ConfigureSessionExtensionsParams,
2867    ) -> Result<(), Error> {
2868        let wire_params = serde_json::to_value(params)?;
2869        let _value = self
2870            .client
2871            .call(
2872                rpc_methods::SESSIONS_CONFIGURESESSIONEXTENSIONS,
2873                Some(wire_params),
2874            )
2875            .await?;
2876        Ok(())
2877    }
2878}
2879
2880/// `skills.*` RPCs.
2881#[derive(Clone, Copy)]
2882pub struct ClientRpcSkills<'a> {
2883    pub(crate) client: &'a Client,
2884}
2885
2886impl<'a> ClientRpcSkills<'a> {
2887    /// `skills.config.*` sub-namespace.
2888    pub fn config(&self) -> ClientRpcSkillsConfig<'a> {
2889        ClientRpcSkillsConfig {
2890            client: self.client,
2891        }
2892    }
2893
2894    /// Discovers skills across global and project sources.
2895    ///
2896    /// Wire method: `skills.discover`.
2897    ///
2898    /// # Parameters
2899    ///
2900    /// * `params` - Optional project paths and additional skill directories to include in discovery.
2901    ///
2902    /// # Returns
2903    ///
2904    /// Skills discovered across global and project sources.
2905    ///
2906    /// <div class="warning">
2907    ///
2908    /// **Experimental.** This API is part of an experimental wire-protocol surface
2909    /// and may change or be removed in future SDK or CLI releases. Pin both the
2910    /// SDK and CLI versions if your code depends on it.
2911    ///
2912    /// </div>
2913    pub async fn discover(&self, params: SkillsDiscoverRequest) -> Result<ServerSkillList, Error> {
2914        let wire_params = serde_json::to_value(params)?;
2915        let _value = self
2916            .client
2917            .call(rpc_methods::SKILLS_DISCOVER, Some(wire_params))
2918            .await?;
2919        Ok(serde_json::from_value(_value)?)
2920    }
2921
2922    /// 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.
2923    ///
2924    /// Wire method: `skills.getDiscoveryPaths`.
2925    ///
2926    /// # Parameters
2927    ///
2928    /// * `params` - Optional project paths to enumerate.
2929    ///
2930    /// # Returns
2931    ///
2932    /// Canonical locations where skills can be created so the runtime will recognize them.
2933    ///
2934    /// <div class="warning">
2935    ///
2936    /// **Experimental.** This API is part of an experimental wire-protocol surface
2937    /// and may change or be removed in future SDK or CLI releases. Pin both the
2938    /// SDK and CLI versions if your code depends on it.
2939    ///
2940    /// </div>
2941    pub async fn get_discovery_paths(
2942        &self,
2943        params: SkillsGetDiscoveryPathsRequest,
2944    ) -> Result<SkillDiscoveryPathList, Error> {
2945        let wire_params = serde_json::to_value(params)?;
2946        let _value = self
2947            .client
2948            .call(rpc_methods::SKILLS_GETDISCOVERYPATHS, Some(wire_params))
2949            .await?;
2950        Ok(serde_json::from_value(_value)?)
2951    }
2952}
2953
2954/// `skills.config.*` RPCs.
2955#[derive(Clone, Copy)]
2956pub struct ClientRpcSkillsConfig<'a> {
2957    pub(crate) client: &'a Client,
2958}
2959
2960impl<'a> ClientRpcSkillsConfig<'a> {
2961    /// Replaces the global list of disabled skills.
2962    ///
2963    /// Wire method: `skills.config.setDisabledSkills`.
2964    ///
2965    /// # Parameters
2966    ///
2967    /// * `params` - Skill names to mark as disabled in global configuration, replacing any previous list.
2968    ///
2969    /// <div class="warning">
2970    ///
2971    /// **Experimental.** This API is part of an experimental wire-protocol surface
2972    /// and may change or be removed in future SDK or CLI releases. Pin both the
2973    /// SDK and CLI versions if your code depends on it.
2974    ///
2975    /// </div>
2976    pub async fn set_disabled_skills(
2977        &self,
2978        params: SkillsConfigSetDisabledSkillsRequest,
2979    ) -> Result<(), Error> {
2980        let wire_params = serde_json::to_value(params)?;
2981        let _value = self
2982            .client
2983            .call(
2984                rpc_methods::SKILLS_CONFIG_SETDISABLEDSKILLS,
2985                Some(wire_params),
2986            )
2987            .await?;
2988        Ok(())
2989    }
2990
2991    /// Atomically adds or removes one skill from the disabled list.
2992    ///
2993    /// Wire method: `skills.config.setSkillDisabled`.
2994    ///
2995    /// # Parameters
2996    ///
2997    /// * `params` - Adds or removes a single skill from the global disabled list, leaving every other entry untouched.
2998    ///
2999    /// <div class="warning">
3000    ///
3001    /// **Experimental.** This API is part of an experimental wire-protocol surface
3002    /// and may change or be removed in future SDK or CLI releases. Pin both the
3003    /// SDK and CLI versions if your code depends on it.
3004    ///
3005    /// </div>
3006    pub async fn set_skill_disabled(
3007        &self,
3008        params: SkillsConfigSetSkillDisabledRequest,
3009    ) -> Result<(), Error> {
3010        let wire_params = serde_json::to_value(params)?;
3011        let _value = self
3012            .client
3013            .call(
3014                rpc_methods::SKILLS_CONFIG_SETSKILLDISABLED,
3015                Some(wire_params),
3016            )
3017            .await?;
3018        Ok(())
3019    }
3020}
3021
3022/// `tools.*` RPCs.
3023#[derive(Clone, Copy)]
3024pub struct ClientRpcTools<'a> {
3025    pub(crate) client: &'a Client,
3026}
3027
3028impl<'a> ClientRpcTools<'a> {
3029    /// Lists built-in tools available for a model.
3030    ///
3031    /// Wire method: `tools.list`.
3032    ///
3033    /// # Parameters
3034    ///
3035    /// * `params` - Optional model identifier whose tool overrides should be applied to the listing.
3036    ///
3037    /// # Returns
3038    ///
3039    /// Built-in tools available for the requested model, with their parameters and instructions.
3040    ///
3041    /// <div class="warning">
3042    ///
3043    /// **Experimental.** This API is part of an experimental wire-protocol surface
3044    /// and may change or be removed in future SDK or CLI releases. Pin both the
3045    /// SDK and CLI versions if your code depends on it.
3046    ///
3047    /// </div>
3048    pub async fn list(&self, params: ToolsListRequest) -> Result<ToolList, Error> {
3049        let wire_params = serde_json::to_value(params)?;
3050        let _value = self
3051            .client
3052            .call(rpc_methods::TOOLS_LIST, Some(wire_params))
3053            .await?;
3054        Ok(serde_json::from_value(_value)?)
3055    }
3056}
3057
3058/// `user.*` RPCs.
3059#[derive(Clone, Copy)]
3060pub struct ClientRpcUser<'a> {
3061    pub(crate) client: &'a Client,
3062}
3063
3064impl<'a> ClientRpcUser<'a> {
3065    /// `user.settings.*` sub-namespace.
3066    pub fn settings(&self) -> ClientRpcUserSettings<'a> {
3067        ClientRpcUserSettings {
3068            client: self.client,
3069        }
3070    }
3071}
3072
3073/// `user.settings.*` RPCs.
3074#[derive(Clone, Copy)]
3075pub struct ClientRpcUserSettings<'a> {
3076    pub(crate) client: &'a Client,
3077}
3078
3079impl<'a> ClientRpcUserSettings<'a> {
3080    /// Drops this runtime process's in-memory user settings cache so the next settings read observes disk.
3081    ///
3082    /// Wire method: `user.settings.reload`.
3083    ///
3084    /// <div class="warning">
3085    ///
3086    /// **Experimental.** This API is part of an experimental wire-protocol surface
3087    /// and may change or be removed in future SDK or CLI releases. Pin both the
3088    /// SDK and CLI versions if your code depends on it.
3089    ///
3090    /// </div>
3091    pub async fn reload(&self) -> Result<(), Error> {
3092        let wire_params = serde_json::json!({});
3093        let _value = self
3094            .client
3095            .call(rpc_methods::USER_SETTINGS_RELOAD, Some(wire_params))
3096            .await?;
3097        Ok(())
3098    }
3099
3100    /// 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.
3101    ///
3102    /// Wire method: `user.settings.get`.
3103    ///
3104    /// # Returns
3105    ///
3106    /// 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.
3107    ///
3108    /// <div class="warning">
3109    ///
3110    /// **Experimental.** This API is part of an experimental wire-protocol surface
3111    /// and may change or be removed in future SDK or CLI releases. Pin both the
3112    /// SDK and CLI versions if your code depends on it.
3113    ///
3114    /// </div>
3115    pub async fn get(&self) -> Result<UserSettingsGetResult, Error> {
3116        let wire_params = serde_json::json!({});
3117        let _value = self
3118            .client
3119            .call(rpc_methods::USER_SETTINGS_GET, Some(wire_params))
3120            .await?;
3121        Ok(serde_json::from_value(_value)?)
3122    }
3123
3124    /// 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.
3125    ///
3126    /// Wire method: `user.settings.set`.
3127    ///
3128    /// # Parameters
3129    ///
3130    /// * `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.
3131    ///
3132    /// # Returns
3133    ///
3134    /// Outcome of writing user settings.
3135    ///
3136    /// <div class="warning">
3137    ///
3138    /// **Experimental.** This API is part of an experimental wire-protocol surface
3139    /// and may change or be removed in future SDK or CLI releases. Pin both the
3140    /// SDK and CLI versions if your code depends on it.
3141    ///
3142    /// </div>
3143    pub async fn set(
3144        &self,
3145        params: UserSettingsSetRequest,
3146    ) -> Result<UserSettingsSetResult, Error> {
3147        let wire_params = serde_json::to_value(params)?;
3148        let _value = self
3149            .client
3150            .call(rpc_methods::USER_SETTINGS_SET, Some(wire_params))
3151            .await?;
3152        Ok(serde_json::from_value(_value)?)
3153    }
3154}
3155
3156/// Typed view over a [`Session`]'s RPC namespace.
3157#[derive(Clone, Copy)]
3158pub struct SessionRpc<'a> {
3159    pub(crate) session: &'a Session,
3160}
3161
3162impl<'a> SessionRpc<'a> {
3163    /// `session.agent.*` sub-namespace.
3164    pub fn agent(&self) -> SessionRpcAgent<'a> {
3165        SessionRpcAgent {
3166            session: self.session,
3167        }
3168    }
3169
3170    /// `session.autopilotObjective.*` sub-namespace.
3171    pub fn autopilot_objective(&self) -> SessionRpcAutopilotObjective<'a> {
3172        SessionRpcAutopilotObjective {
3173            session: self.session,
3174        }
3175    }
3176
3177    /// `session.canvas.*` sub-namespace.
3178    pub fn canvas(&self) -> SessionRpcCanvas<'a> {
3179        SessionRpcCanvas {
3180            session: self.session,
3181        }
3182    }
3183
3184    /// `session.commands.*` sub-namespace.
3185    pub fn commands(&self) -> SessionRpcCommands<'a> {
3186        SessionRpcCommands {
3187            session: self.session,
3188        }
3189    }
3190
3191    /// `session.completions.*` sub-namespace.
3192    pub fn completions(&self) -> SessionRpcCompletions<'a> {
3193        SessionRpcCompletions {
3194            session: self.session,
3195        }
3196    }
3197
3198    /// `session.connectors.*` sub-namespace.
3199    pub fn connectors(&self) -> SessionRpcConnectors<'a> {
3200        SessionRpcConnectors {
3201            session: self.session,
3202        }
3203    }
3204
3205    /// `session.contentExclusion.*` sub-namespace.
3206    pub fn content_exclusion(&self) -> SessionRpcContentExclusion<'a> {
3207        SessionRpcContentExclusion {
3208            session: self.session,
3209        }
3210    }
3211
3212    /// `session.customizations.*` sub-namespace.
3213    pub fn customizations(&self) -> SessionRpcCustomizations<'a> {
3214        SessionRpcCustomizations {
3215            session: self.session,
3216        }
3217    }
3218
3219    /// `session.debug.*` sub-namespace.
3220    pub fn debug(&self) -> SessionRpcDebug<'a> {
3221        SessionRpcDebug {
3222            session: self.session,
3223        }
3224    }
3225
3226    /// `session.diagnostics.*` sub-namespace.
3227    pub fn diagnostics(&self) -> SessionRpcDiagnostics<'a> {
3228        SessionRpcDiagnostics {
3229            session: self.session,
3230        }
3231    }
3232
3233    /// `session.eventLog.*` sub-namespace.
3234    pub fn event_log(&self) -> SessionRpcEventLog<'a> {
3235        SessionRpcEventLog {
3236            session: self.session,
3237        }
3238    }
3239
3240    /// `session.extensions.*` sub-namespace.
3241    pub fn extensions(&self) -> SessionRpcExtensions<'a> {
3242        SessionRpcExtensions {
3243            session: self.session,
3244        }
3245    }
3246
3247    /// `session.factory.*` sub-namespace.
3248    pub fn factory(&self) -> SessionRpcFactory<'a> {
3249        SessionRpcFactory {
3250            session: self.session,
3251        }
3252    }
3253
3254    /// `session.fleet.*` sub-namespace.
3255    pub fn fleet(&self) -> SessionRpcFleet<'a> {
3256        SessionRpcFleet {
3257            session: self.session,
3258        }
3259    }
3260
3261    /// `session.gitHubAuth.*` sub-namespace.
3262    pub fn git_hub_auth(&self) -> SessionRpcGitHubAuth<'a> {
3263        SessionRpcGitHubAuth {
3264            session: self.session,
3265        }
3266    }
3267
3268    /// `session.history.*` sub-namespace.
3269    pub fn history(&self) -> SessionRpcHistory<'a> {
3270        SessionRpcHistory {
3271            session: self.session,
3272        }
3273    }
3274
3275    /// `session.instructions.*` sub-namespace.
3276    pub fn instructions(&self) -> SessionRpcInstructions<'a> {
3277        SessionRpcInstructions {
3278            session: self.session,
3279        }
3280    }
3281
3282    /// `session.limitPrediction.*` sub-namespace.
3283    pub fn limit_prediction(&self) -> SessionRpcLimitPrediction<'a> {
3284        SessionRpcLimitPrediction {
3285            session: self.session,
3286        }
3287    }
3288
3289    /// `session.lsp.*` sub-namespace.
3290    pub fn lsp(&self) -> SessionRpcLsp<'a> {
3291        SessionRpcLsp {
3292            session: self.session,
3293        }
3294    }
3295
3296    /// `session.managedSettings.*` sub-namespace.
3297    pub fn managed_settings(&self) -> SessionRpcManagedSettings<'a> {
3298        SessionRpcManagedSettings {
3299            session: self.session,
3300        }
3301    }
3302
3303    /// `session.mcp.*` sub-namespace.
3304    pub fn mcp(&self) -> SessionRpcMcp<'a> {
3305        SessionRpcMcp {
3306            session: self.session,
3307        }
3308    }
3309
3310    /// `session.metadata.*` sub-namespace.
3311    pub fn metadata(&self) -> SessionRpcMetadata<'a> {
3312        SessionRpcMetadata {
3313            session: self.session,
3314        }
3315    }
3316
3317    /// `session.mode.*` sub-namespace.
3318    pub fn mode(&self) -> SessionRpcMode<'a> {
3319        SessionRpcMode {
3320            session: self.session,
3321        }
3322    }
3323
3324    /// `session.model.*` sub-namespace.
3325    pub fn model(&self) -> SessionRpcModel<'a> {
3326        SessionRpcModel {
3327            session: self.session,
3328        }
3329    }
3330
3331    /// `session.name.*` sub-namespace.
3332    pub fn name(&self) -> SessionRpcName<'a> {
3333        SessionRpcName {
3334            session: self.session,
3335        }
3336    }
3337
3338    /// `session.options.*` sub-namespace.
3339    pub fn options(&self) -> SessionRpcOptions<'a> {
3340        SessionRpcOptions {
3341            session: self.session,
3342        }
3343    }
3344
3345    /// `session.permissions.*` sub-namespace.
3346    pub fn permissions(&self) -> SessionRpcPermissions<'a> {
3347        SessionRpcPermissions {
3348            session: self.session,
3349        }
3350    }
3351
3352    /// `session.plan.*` sub-namespace.
3353    pub fn plan(&self) -> SessionRpcPlan<'a> {
3354        SessionRpcPlan {
3355            session: self.session,
3356        }
3357    }
3358
3359    /// `session.plugins.*` sub-namespace.
3360    pub fn plugins(&self) -> SessionRpcPlugins<'a> {
3361        SessionRpcPlugins {
3362            session: self.session,
3363        }
3364    }
3365
3366    /// `session.provider.*` sub-namespace.
3367    pub fn provider(&self) -> SessionRpcProvider<'a> {
3368        SessionRpcProvider {
3369            session: self.session,
3370        }
3371    }
3372
3373    /// `session.queue.*` sub-namespace.
3374    pub fn queue(&self) -> SessionRpcQueue<'a> {
3375        SessionRpcQueue {
3376            session: self.session,
3377        }
3378    }
3379
3380    /// `session.remote.*` sub-namespace.
3381    pub fn remote(&self) -> SessionRpcRemote<'a> {
3382        SessionRpcRemote {
3383            session: self.session,
3384        }
3385    }
3386
3387    /// `session.sandbox.*` sub-namespace.
3388    pub fn sandbox(&self) -> SessionRpcSandbox<'a> {
3389        SessionRpcSandbox {
3390            session: self.session,
3391        }
3392    }
3393
3394    /// `session.schedule.*` sub-namespace.
3395    pub fn schedule(&self) -> SessionRpcSchedule<'a> {
3396        SessionRpcSchedule {
3397            session: self.session,
3398        }
3399    }
3400
3401    /// `session.settings.*` sub-namespace.
3402    pub fn settings(&self) -> SessionRpcSettings<'a> {
3403        SessionRpcSettings {
3404            session: self.session,
3405        }
3406    }
3407
3408    /// `session.shell.*` sub-namespace.
3409    pub fn shell(&self) -> SessionRpcShell<'a> {
3410        SessionRpcShell {
3411            session: self.session,
3412        }
3413    }
3414
3415    /// `session.skills.*` sub-namespace.
3416    pub fn skills(&self) -> SessionRpcSkills<'a> {
3417        SessionRpcSkills {
3418            session: self.session,
3419        }
3420    }
3421
3422    /// `session.tasks.*` sub-namespace.
3423    pub fn tasks(&self) -> SessionRpcTasks<'a> {
3424        SessionRpcTasks {
3425            session: self.session,
3426        }
3427    }
3428
3429    /// `session.telemetry.*` sub-namespace.
3430    pub fn telemetry(&self) -> SessionRpcTelemetry<'a> {
3431        SessionRpcTelemetry {
3432            session: self.session,
3433        }
3434    }
3435
3436    /// `session.tools.*` sub-namespace.
3437    pub fn tools(&self) -> SessionRpcTools<'a> {
3438        SessionRpcTools {
3439            session: self.session,
3440        }
3441    }
3442
3443    /// `session.ui.*` sub-namespace.
3444    pub fn ui(&self) -> SessionRpcUi<'a> {
3445        SessionRpcUi {
3446            session: self.session,
3447        }
3448    }
3449
3450    /// `session.usage.*` sub-namespace.
3451    pub fn usage(&self) -> SessionRpcUsage<'a> {
3452        SessionRpcUsage {
3453            session: self.session,
3454        }
3455    }
3456
3457    /// `session.visibility.*` sub-namespace.
3458    pub fn visibility(&self) -> SessionRpcVisibility<'a> {
3459        SessionRpcVisibility {
3460            session: self.session,
3461        }
3462    }
3463
3464    /// `session.workflow.*` sub-namespace.
3465    pub fn workflow(&self) -> SessionRpcWorkflow<'a> {
3466        SessionRpcWorkflow {
3467            session: self.session,
3468        }
3469    }
3470
3471    /// `session.workspaces.*` sub-namespace.
3472    pub fn workspaces(&self) -> SessionRpcWorkspaces<'a> {
3473        SessionRpcWorkspaces {
3474            session: self.session,
3475        }
3476    }
3477
3478    /// Suspends the session while preserving persisted state for later resume.
3479    ///
3480    /// Wire method: `session.suspend`.
3481    ///
3482    /// <div class="warning">
3483    ///
3484    /// **Experimental.** This API is part of an experimental wire-protocol surface
3485    /// and may change or be removed in future SDK or CLI releases. Pin both the
3486    /// SDK and CLI versions if your code depends on it.
3487    ///
3488    /// </div>
3489    pub async fn suspend(&self) -> Result<(), Error> {
3490        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3491        let _value = self
3492            .session
3493            .client()
3494            .call(rpc_methods::SESSION_SUSPEND, Some(wire_params))
3495            .await?;
3496        Ok(())
3497    }
3498
3499    /// Sends a user message to the session and returns its message ID.
3500    ///
3501    /// Wire method: `session.send`.
3502    ///
3503    /// # Parameters
3504    ///
3505    /// * `params` - Parameters for sending a user message to the session
3506    ///
3507    /// # Returns
3508    ///
3509    /// Result of sending a user message
3510    ///
3511    /// <div class="warning">
3512    ///
3513    /// **Experimental.** This API is part of an experimental wire-protocol surface
3514    /// and may change or be removed in future SDK or CLI releases. Pin both the
3515    /// SDK and CLI versions if your code depends on it.
3516    ///
3517    /// </div>
3518    pub async fn send(&self, params: SendRequest) -> Result<SendResult, Error> {
3519        let mut wire_params = serde_json::to_value(params)?;
3520        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3521        let _value = self
3522            .session
3523            .client()
3524            .call(rpc_methods::SESSION_SEND, Some(wire_params))
3525            .await?;
3526        Ok(serde_json::from_value(_value)?)
3527    }
3528
3529    /// 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.
3530    ///
3531    /// Wire method: `session.sendMessages`.
3532    ///
3533    /// # Parameters
3534    ///
3535    /// * `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.
3536    ///
3537    /// # Returns
3538    ///
3539    /// Result of sending zero or more user messages
3540    ///
3541    /// <div class="warning">
3542    ///
3543    /// **Experimental.** This API is part of an experimental wire-protocol surface
3544    /// and may change or be removed in future SDK or CLI releases. Pin both the
3545    /// SDK and CLI versions if your code depends on it.
3546    ///
3547    /// </div>
3548    pub async fn send_messages(
3549        &self,
3550        params: SendMessagesRequest,
3551    ) -> Result<SendMessagesResult, Error> {
3552        let mut wire_params = serde_json::to_value(params)?;
3553        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3554        let _value = self
3555            .session
3556            .client()
3557            .call(rpc_methods::SESSION_SENDMESSAGES, Some(wire_params))
3558            .await?;
3559        Ok(serde_json::from_value(_value)?)
3560    }
3561
3562    /// Queues or sends an internal system notification to the session according to its passive policy.
3563    ///
3564    /// Wire method: `session.sendSystemNotification`.
3565    ///
3566    /// # Parameters
3567    ///
3568    /// * `params` - Internal request for sending a system notification.
3569    ///
3570    /// <div class="warning">
3571    ///
3572    /// **Experimental.** This API is part of an experimental wire-protocol surface
3573    /// and may change or be removed in future SDK or CLI releases. Pin both the
3574    /// SDK and CLI versions if your code depends on it.
3575    ///
3576    /// </div>
3577    pub(crate) async fn send_system_notification(
3578        &self,
3579        params: SendSystemNotificationRequest,
3580    ) -> Result<(), Error> {
3581        let mut wire_params = serde_json::to_value(params)?;
3582        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3583        let _value = self
3584            .session
3585            .client()
3586            .call(
3587                rpc_methods::SESSION_SENDSYSTEMNOTIFICATION,
3588                Some(wire_params),
3589            )
3590            .await?;
3591        Ok(())
3592    }
3593
3594    /// Aborts the current agent turn.
3595    ///
3596    /// Wire method: `session.abort`.
3597    ///
3598    /// # Parameters
3599    ///
3600    /// * `params` - Parameters for aborting the current turn
3601    ///
3602    /// # Returns
3603    ///
3604    /// Result of aborting the current turn
3605    ///
3606    /// <div class="warning">
3607    ///
3608    /// **Experimental.** This API is part of an experimental wire-protocol surface
3609    /// and may change or be removed in future SDK or CLI releases. Pin both the
3610    /// SDK and CLI versions if your code depends on it.
3611    ///
3612    /// </div>
3613    pub async fn abort(&self, params: AbortRequest) -> Result<AbortResult, Error> {
3614        let mut wire_params = serde_json::to_value(params)?;
3615        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3616        let _value = self
3617            .session
3618            .client()
3619            .call(rpc_methods::SESSION_ABORT, Some(wire_params))
3620            .await?;
3621        Ok(serde_json::from_value(_value)?)
3622    }
3623
3624    /// 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.
3625    ///
3626    /// Wire method: `session.interruptMainTurn`.
3627    ///
3628    /// # Parameters
3629    ///
3630    /// * `params` - Parameters for interrupting the main agent turn.
3631    ///
3632    /// # Returns
3633    ///
3634    /// Result of interrupting the main agent turn.
3635    ///
3636    /// <div class="warning">
3637    ///
3638    /// **Experimental.** This API is part of an experimental wire-protocol surface
3639    /// and may change or be removed in future SDK or CLI releases. Pin both the
3640    /// SDK and CLI versions if your code depends on it.
3641    ///
3642    /// </div>
3643    pub async fn interrupt_main_turn(
3644        &self,
3645        params: InterruptMainTurnRequest,
3646    ) -> Result<InterruptMainTurnResult, Error> {
3647        let mut wire_params = serde_json::to_value(params)?;
3648        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3649        let _value = self
3650            .session
3651            .client()
3652            .call(rpc_methods::SESSION_INTERRUPTMAINTURN, Some(wire_params))
3653            .await?;
3654        Ok(serde_json::from_value(_value)?)
3655    }
3656
3657    /// Cancels every running background agent (task-registry subagents plus sidekick agents) without interrupting the main agent loop. Promoted attached shells are left running.
3658    ///
3659    /// Wire method: `session.cancelAllBackgroundAgents`.
3660    ///
3661    /// # Returns
3662    ///
3663    /// The number of running background agents (task-registry agents) that were cancelled.
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 cancel_all_background_agents(
3673        &self,
3674    ) -> Result<SessionCancelAllBackgroundAgentsResult, Error> {
3675        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3676        let _value = self
3677            .session
3678            .client()
3679            .call(
3680                rpc_methods::SESSION_CANCELALLBACKGROUNDAGENTS,
3681                Some(wire_params),
3682            )
3683            .await?;
3684        Ok(serde_json::from_value(_value)?)
3685    }
3686
3687    /// 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.
3688    ///
3689    /// Wire method: `session.shutdown`.
3690    ///
3691    /// # Parameters
3692    ///
3693    /// * `params` - Parameters for shutting down the session
3694    ///
3695    /// <div class="warning">
3696    ///
3697    /// **Experimental.** This API is part of an experimental wire-protocol surface
3698    /// and may change or be removed in future SDK or CLI releases. Pin both the
3699    /// SDK and CLI versions if your code depends on it.
3700    ///
3701    /// </div>
3702    pub async fn shutdown(&self, params: ShutdownRequest) -> Result<(), Error> {
3703        let mut wire_params = serde_json::to_value(params)?;
3704        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3705        let _value = self
3706            .session
3707            .client()
3708            .call(rpc_methods::SESSION_SHUTDOWN, Some(wire_params))
3709            .await?;
3710        Ok(())
3711    }
3712
3713    /// Emits a user-visible session log event.
3714    ///
3715    /// Wire method: `session.log`.
3716    ///
3717    /// # Parameters
3718    ///
3719    /// * `params` - Message text, optional severity level, persistence flag, optional follow-up URL, and optional tip.
3720    ///
3721    /// # Returns
3722    ///
3723    /// Identifier of the session event that was emitted for the log message.
3724    ///
3725    /// <div class="warning">
3726    ///
3727    /// **Experimental.** This API is part of an experimental wire-protocol surface
3728    /// and may change or be removed in future SDK or CLI releases. Pin both the
3729    /// SDK and CLI versions if your code depends on it.
3730    ///
3731    /// </div>
3732    pub async fn log(&self, params: LogRequest) -> Result<LogResult, Error> {
3733        let mut wire_params = serde_json::to_value(params)?;
3734        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3735        let _value = self
3736            .session
3737            .client()
3738            .call(rpc_methods::SESSION_LOG, Some(wire_params))
3739            .await?;
3740        Ok(serde_json::from_value(_value)?)
3741    }
3742}
3743
3744/// `session.agent.*` RPCs.
3745#[derive(Clone, Copy)]
3746pub struct SessionRpcAgent<'a> {
3747    pub(crate) session: &'a Session,
3748}
3749
3750impl<'a> SessionRpcAgent<'a> {
3751    /// Lists agents available to the session. Defaults to custom agents only; pass includeBuiltInAgents to include the effective built-in agents.
3752    ///
3753    /// Wire method: `session.agent.list`.
3754    ///
3755    /// # Returns
3756    ///
3757    /// Agents available to the session.
3758    ///
3759    /// <div class="warning">
3760    ///
3761    /// **Experimental.** This API is part of an experimental wire-protocol surface
3762    /// and may change or be removed in future SDK or CLI releases. Pin both the
3763    /// SDK and CLI versions if your code depends on it.
3764    ///
3765    /// </div>
3766    pub async fn list(&self) -> Result<AgentList, Error> {
3767        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3768        let _value = self
3769            .session
3770            .client()
3771            .call(rpc_methods::SESSION_AGENT_LIST, Some(wire_params))
3772            .await?;
3773        Ok(serde_json::from_value(_value)?)
3774    }
3775
3776    /// Lists agents available to the session. Defaults to custom agents only; pass includeBuiltInAgents to include the effective built-in agents.
3777    ///
3778    /// Wire method: `session.agent.list`.
3779    ///
3780    /// # Parameters
3781    ///
3782    /// * `params` - Controls whether built-in agents and authored prompt text are included.
3783    ///
3784    /// # Returns
3785    ///
3786    /// Agents available to the session.
3787    ///
3788    /// <div class="warning">
3789    ///
3790    /// **Experimental.** This API is part of an experimental wire-protocol surface
3791    /// and may change or be removed in future SDK or CLI releases. Pin both the
3792    /// SDK and CLI versions if your code depends on it.
3793    ///
3794    /// </div>
3795    pub async fn list_with_params(&self, params: AgentListRequest) -> Result<AgentList, Error> {
3796        let mut wire_params = serde_json::to_value(params)?;
3797        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3798        let _value = self
3799            .session
3800            .client()
3801            .call(rpc_methods::SESSION_AGENT_LIST, Some(wire_params))
3802            .await?;
3803        Ok(serde_json::from_value(_value)?)
3804    }
3805
3806    /// 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.
3807    ///
3808    /// Wire method: `session.agent.setPrompt`.
3809    ///
3810    /// # Parameters
3811    ///
3812    /// * `params` - An in-memory authored prompt override for an available agent.
3813    ///
3814    /// <div class="warning">
3815    ///
3816    /// **Experimental.** This API is part of an experimental wire-protocol surface
3817    /// and may change or be removed in future SDK or CLI releases. Pin both the
3818    /// SDK and CLI versions if your code depends on it.
3819    ///
3820    /// </div>
3821    pub async fn set_prompt(&self, params: AgentSetPromptRequest) -> Result<(), Error> {
3822        let mut wire_params = serde_json::to_value(params)?;
3823        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3824        let _value = self
3825            .session
3826            .client()
3827            .call(rpc_methods::SESSION_AGENT_SETPROMPT, Some(wire_params))
3828            .await?;
3829        Ok(())
3830    }
3831
3832    /// Gets the currently selected custom agent for the session.
3833    ///
3834    /// Wire method: `session.agent.getCurrent`.
3835    ///
3836    /// # Returns
3837    ///
3838    /// The currently selected custom agent, or null when using the default agent.
3839    ///
3840    /// <div class="warning">
3841    ///
3842    /// **Experimental.** This API is part of an experimental wire-protocol surface
3843    /// and may change or be removed in future SDK or CLI releases. Pin both the
3844    /// SDK and CLI versions if your code depends on it.
3845    ///
3846    /// </div>
3847    pub async fn get_current(&self) -> Result<AgentGetCurrentResult, Error> {
3848        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3849        let _value = self
3850            .session
3851            .client()
3852            .call(rpc_methods::SESSION_AGENT_GETCURRENT, Some(wire_params))
3853            .await?;
3854        Ok(serde_json::from_value(_value)?)
3855    }
3856
3857    /// Selects a custom agent for subsequent turns in the session.
3858    ///
3859    /// Wire method: `session.agent.select`.
3860    ///
3861    /// # Parameters
3862    ///
3863    /// * `params` - Name of the custom agent to select for subsequent turns.
3864    ///
3865    /// # Returns
3866    ///
3867    /// The newly selected custom agent.
3868    ///
3869    /// <div class="warning">
3870    ///
3871    /// **Experimental.** This API is part of an experimental wire-protocol surface
3872    /// and may change or be removed in future SDK or CLI releases. Pin both the
3873    /// SDK and CLI versions if your code depends on it.
3874    ///
3875    /// </div>
3876    pub async fn select(&self, params: AgentSelectRequest) -> Result<AgentSelectResult, Error> {
3877        let mut wire_params = serde_json::to_value(params)?;
3878        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3879        let _value = self
3880            .session
3881            .client()
3882            .call(rpc_methods::SESSION_AGENT_SELECT, Some(wire_params))
3883            .await?;
3884        Ok(serde_json::from_value(_value)?)
3885    }
3886
3887    /// Clears the selected custom agent and returns the session to the default agent.
3888    ///
3889    /// Wire method: `session.agent.deselect`.
3890    ///
3891    /// <div class="warning">
3892    ///
3893    /// **Experimental.** This API is part of an experimental wire-protocol surface
3894    /// and may change or be removed in future SDK or CLI releases. Pin both the
3895    /// SDK and CLI versions if your code depends on it.
3896    ///
3897    /// </div>
3898    pub async fn deselect(&self) -> Result<(), Error> {
3899        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3900        let _value = self
3901            .session
3902            .client()
3903            .call(rpc_methods::SESSION_AGENT_DESELECT, Some(wire_params))
3904            .await?;
3905        Ok(())
3906    }
3907
3908    /// Reloads custom agent definitions and returns the refreshed list.
3909    ///
3910    /// Wire method: `session.agent.reload`.
3911    ///
3912    /// # Returns
3913    ///
3914    /// Custom agents available to the session after reloading definitions from disk.
3915    ///
3916    /// <div class="warning">
3917    ///
3918    /// **Experimental.** This API is part of an experimental wire-protocol surface
3919    /// and may change or be removed in future SDK or CLI releases. Pin both the
3920    /// SDK and CLI versions if your code depends on it.
3921    ///
3922    /// </div>
3923    pub async fn reload(&self) -> Result<AgentReloadResult, Error> {
3924        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3925        let _value = self
3926            .session
3927            .client()
3928            .call(rpc_methods::SESSION_AGENT_RELOAD, Some(wire_params))
3929            .await?;
3930        Ok(serde_json::from_value(_value)?)
3931    }
3932}
3933
3934/// `session.autopilotObjective.*` RPCs.
3935#[derive(Clone, Copy)]
3936pub struct SessionRpcAutopilotObjective<'a> {
3937    pub(crate) session: &'a Session,
3938}
3939
3940impl<'a> SessionRpcAutopilotObjective<'a> {
3941    /// Reads the current canonical autopilot objective state for this session.
3942    ///
3943    /// Wire method: `session.autopilotObjective.getState`.
3944    ///
3945    /// # Returns
3946    ///
3947    /// Canonical runtime state for the session's current autopilot objective.
3948    ///
3949    /// <div class="warning">
3950    ///
3951    /// **Experimental.** This API is part of an experimental wire-protocol surface
3952    /// and may change or be removed in future SDK or CLI releases. Pin both the
3953    /// SDK and CLI versions if your code depends on it.
3954    ///
3955    /// </div>
3956    pub async fn get_state(&self) -> Result<AutopilotObjectiveGetStateResult, Error> {
3957        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3958        let _value = self
3959            .session
3960            .client()
3961            .call(
3962                rpc_methods::SESSION_AUTOPILOTOBJECTIVE_GETSTATE,
3963                Some(wire_params),
3964            )
3965            .await?;
3966        Ok(serde_json::from_value(_value)?)
3967    }
3968}
3969
3970/// `session.canvas.*` RPCs.
3971#[derive(Clone, Copy)]
3972pub struct SessionRpcCanvas<'a> {
3973    pub(crate) session: &'a Session,
3974}
3975
3976impl<'a> SessionRpcCanvas<'a> {
3977    /// `session.canvas.action.*` sub-namespace.
3978    pub fn action(&self) -> SessionRpcCanvasAction<'a> {
3979        SessionRpcCanvasAction {
3980            session: self.session,
3981        }
3982    }
3983
3984    /// `session.canvas.provider.*` sub-namespace.
3985    pub fn provider(&self) -> SessionRpcCanvasProvider<'a> {
3986        SessionRpcCanvasProvider {
3987            session: self.session,
3988        }
3989    }
3990
3991    /// Lists canvases declared for the session.
3992    ///
3993    /// Wire method: `session.canvas.list`.
3994    ///
3995    /// # Returns
3996    ///
3997    /// Declared canvases available in this session.
3998    ///
3999    /// <div class="warning">
4000    ///
4001    /// **Experimental.** This API is part of an experimental wire-protocol surface
4002    /// and may change or be removed in future SDK or CLI releases. Pin both the
4003    /// SDK and CLI versions if your code depends on it.
4004    ///
4005    /// </div>
4006    pub async fn list(&self) -> Result<CanvasList, Error> {
4007        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
4008        let _value = self
4009            .session
4010            .client()
4011            .call(rpc_methods::SESSION_CANVAS_LIST, Some(wire_params))
4012            .await?;
4013        Ok(serde_json::from_value(_value)?)
4014    }
4015
4016    /// Lists currently open canvas instances for the live session.
4017    ///
4018    /// Wire method: `session.canvas.listOpen`.
4019    ///
4020    /// # Returns
4021    ///
4022    /// Live open-canvas snapshot.
4023    ///
4024    /// <div class="warning">
4025    ///
4026    /// **Experimental.** This API is part of an experimental wire-protocol surface
4027    /// and may change or be removed in future SDK or CLI releases. Pin both the
4028    /// SDK and CLI versions if your code depends on it.
4029    ///
4030    /// </div>
4031    pub async fn list_open(&self) -> Result<CanvasListOpenResult, Error> {
4032        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
4033        let _value = self
4034            .session
4035            .client()
4036            .call(rpc_methods::SESSION_CANVAS_LISTOPEN, Some(wire_params))
4037            .await?;
4038        Ok(serde_json::from_value(_value)?)
4039    }
4040
4041    /// Opens or focuses a canvas instance.
4042    ///
4043    /// Wire method: `session.canvas.open`.
4044    ///
4045    /// # Parameters
4046    ///
4047    /// * `params` - Canvas open parameters.
4048    ///
4049    /// # Returns
4050    ///
4051    /// Open canvas instance snapshot.
4052    ///
4053    /// <div class="warning">
4054    ///
4055    /// **Experimental.** This API is part of an experimental wire-protocol surface
4056    /// and may change or be removed in future SDK or CLI releases. Pin both the
4057    /// SDK and CLI versions if your code depends on it.
4058    ///
4059    /// </div>
4060    pub async fn open(&self, params: CanvasOpenRequest) -> Result<OpenCanvasInstance, Error> {
4061        let mut wire_params = serde_json::to_value(params)?;
4062        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4063        let _value = self
4064            .session
4065            .client()
4066            .call(rpc_methods::SESSION_CANVAS_OPEN, Some(wire_params))
4067            .await?;
4068        Ok(serde_json::from_value(_value)?)
4069    }
4070
4071    /// Closes an open canvas instance.
4072    ///
4073    /// Wire method: `session.canvas.close`.
4074    ///
4075    /// # Parameters
4076    ///
4077    /// * `params` - Canvas close parameters.
4078    ///
4079    /// <div class="warning">
4080    ///
4081    /// **Experimental.** This API is part of an experimental wire-protocol surface
4082    /// and may change or be removed in future SDK or CLI releases. Pin both the
4083    /// SDK and CLI versions if your code depends on it.
4084    ///
4085    /// </div>
4086    pub async fn close(&self, params: CanvasCloseRequest) -> Result<(), Error> {
4087        let mut wire_params = serde_json::to_value(params)?;
4088        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4089        let _value = self
4090            .session
4091            .client()
4092            .call(rpc_methods::SESSION_CANVAS_CLOSE, Some(wire_params))
4093            .await?;
4094        Ok(())
4095    }
4096}
4097
4098/// `session.canvas.action.*` RPCs.
4099#[derive(Clone, Copy)]
4100pub struct SessionRpcCanvasAction<'a> {
4101    pub(crate) session: &'a Session,
4102}
4103
4104impl<'a> SessionRpcCanvasAction<'a> {
4105    /// Invokes an action on an open canvas instance.
4106    ///
4107    /// Wire method: `session.canvas.action.invoke`.
4108    ///
4109    /// # Parameters
4110    ///
4111    /// * `params` - Canvas action invocation parameters.
4112    ///
4113    /// # Returns
4114    ///
4115    /// Canvas action invocation result.
4116    ///
4117    /// <div class="warning">
4118    ///
4119    /// **Experimental.** This API is part of an experimental wire-protocol surface
4120    /// and may change or be removed in future SDK or CLI releases. Pin both the
4121    /// SDK and CLI versions if your code depends on it.
4122    ///
4123    /// </div>
4124    pub async fn invoke(
4125        &self,
4126        params: CanvasActionInvokeRequest,
4127    ) -> Result<CanvasActionInvokeResult, Error> {
4128        let mut wire_params = serde_json::to_value(params)?;
4129        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4130        let _value = self
4131            .session
4132            .client()
4133            .call(rpc_methods::SESSION_CANVAS_ACTION_INVOKE, Some(wire_params))
4134            .await?;
4135        Ok(serde_json::from_value(_value)?)
4136    }
4137}
4138
4139/// `session.canvas.provider.*` RPCs.
4140#[derive(Clone, Copy)]
4141pub struct SessionRpcCanvasProvider<'a> {
4142    pub(crate) session: &'a Session,
4143}
4144
4145impl<'a> SessionRpcCanvasProvider<'a> {
4146    /// Registers an internal canvas provider connection and its contributions.
4147    ///
4148    /// Wire method: `session.canvas.provider.register`.
4149    ///
4150    /// # Parameters
4151    ///
4152    /// * `params` - Internal canvas provider registration parameters.
4153    ///
4154    /// <div class="warning">
4155    ///
4156    /// **Experimental.** This API is part of an experimental wire-protocol surface
4157    /// and may change or be removed in future SDK or CLI releases. Pin both the
4158    /// SDK and CLI versions if your code depends on it.
4159    ///
4160    /// </div>
4161    pub(crate) async fn register(
4162        &self,
4163        params: CanvasProviderRegisterRequest,
4164    ) -> Result<(), Error> {
4165        let mut wire_params = serde_json::to_value(params)?;
4166        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4167        let _value = self
4168            .session
4169            .client()
4170            .call(
4171                rpc_methods::SESSION_CANVAS_PROVIDER_REGISTER,
4172                Some(wire_params),
4173            )
4174            .await?;
4175        Ok(())
4176    }
4177
4178    /// Unregisters an internal canvas provider connection.
4179    ///
4180    /// Wire method: `session.canvas.provider.unregister`.
4181    ///
4182    /// # Parameters
4183    ///
4184    /// * `params` - Internal canvas provider unregistration parameters.
4185    ///
4186    /// <div class="warning">
4187    ///
4188    /// **Experimental.** This API is part of an experimental wire-protocol surface
4189    /// and may change or be removed in future SDK or CLI releases. Pin both the
4190    /// SDK and CLI versions if your code depends on it.
4191    ///
4192    /// </div>
4193    pub(crate) async fn unregister(
4194        &self,
4195        params: CanvasProviderUnregisterRequest,
4196    ) -> Result<(), Error> {
4197        let mut wire_params = serde_json::to_value(params)?;
4198        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4199        let _value = self
4200            .session
4201            .client()
4202            .call(
4203                rpc_methods::SESSION_CANVAS_PROVIDER_UNREGISTER,
4204                Some(wire_params),
4205            )
4206            .await?;
4207        Ok(())
4208    }
4209}
4210
4211/// `session.commands.*` RPCs.
4212#[derive(Clone, Copy)]
4213pub struct SessionRpcCommands<'a> {
4214    pub(crate) session: &'a Session,
4215}
4216
4217impl<'a> SessionRpcCommands<'a> {
4218    /// Lists slash commands available in the session.
4219    ///
4220    /// Wire method: `session.commands.list`.
4221    ///
4222    /// # Returns
4223    ///
4224    /// Slash commands available in the session, after applying any include/exclude filters.
4225    ///
4226    /// <div class="warning">
4227    ///
4228    /// **Experimental.** This API is part of an experimental wire-protocol surface
4229    /// and may change or be removed in future SDK or CLI releases. Pin both the
4230    /// SDK and CLI versions if your code depends on it.
4231    ///
4232    /// </div>
4233    pub async fn list(&self) -> Result<CommandList, Error> {
4234        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
4235        let _value = self
4236            .session
4237            .client()
4238            .call(rpc_methods::SESSION_COMMANDS_LIST, Some(wire_params))
4239            .await?;
4240        Ok(serde_json::from_value(_value)?)
4241    }
4242
4243    /// Lists slash commands available in the session.
4244    ///
4245    /// Wire method: `session.commands.list`.
4246    ///
4247    /// # Parameters
4248    ///
4249    /// * `params` - Optional filters controlling which command sources to include in the listing.
4250    ///
4251    /// # Returns
4252    ///
4253    /// Slash commands available in the session, after applying any include/exclude filters.
4254    ///
4255    /// <div class="warning">
4256    ///
4257    /// **Experimental.** This API is part of an experimental wire-protocol surface
4258    /// and may change or be removed in future SDK or CLI releases. Pin both the
4259    /// SDK and CLI versions if your code depends on it.
4260    ///
4261    /// </div>
4262    pub async fn list_with_params(
4263        &self,
4264        params: CommandsListRequest,
4265    ) -> Result<CommandList, Error> {
4266        let mut wire_params = serde_json::to_value(params)?;
4267        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4268        let _value = self
4269            .session
4270            .client()
4271            .call(rpc_methods::SESSION_COMMANDS_LIST, Some(wire_params))
4272            .await?;
4273        Ok(serde_json::from_value(_value)?)
4274    }
4275
4276    /// Invokes a slash command in the session.
4277    ///
4278    /// Wire method: `session.commands.invoke`.
4279    ///
4280    /// # Parameters
4281    ///
4282    /// * `params` - Slash command name and optional raw input string to invoke.
4283    ///
4284    /// # Returns
4285    ///
4286    /// Result of invoking the slash command (text output, prompt to send to the agent, completion, or subcommand selection).
4287    ///
4288    /// <div class="warning">
4289    ///
4290    /// **Experimental.** This API is part of an experimental wire-protocol surface
4291    /// and may change or be removed in future SDK or CLI releases. Pin both the
4292    /// SDK and CLI versions if your code depends on it.
4293    ///
4294    /// </div>
4295    pub async fn invoke(
4296        &self,
4297        params: CommandsInvokeRequest,
4298    ) -> Result<SlashCommandInvocationResult, Error> {
4299        let mut wire_params = serde_json::to_value(params)?;
4300        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4301        let _value = self
4302            .session
4303            .client()
4304            .call(rpc_methods::SESSION_COMMANDS_INVOKE, Some(wire_params))
4305            .await?;
4306        Ok(serde_json::from_value(_value)?)
4307    }
4308
4309    /// Finalizes persistence associated with a client-applied slash-command effect.
4310    ///
4311    /// Wire method: `session.commands.finalizeInvocationEffect`.
4312    ///
4313    /// # Parameters
4314    ///
4315    /// * `params` - The pending slash-command invocation effect to finalize, plus whether the host applied or cancelled it.
4316    ///
4317    /// # Returns
4318    ///
4319    /// Whether finalizing the invocation effect succeeded, and the failure reason when it did not.
4320    ///
4321    /// <div class="warning">
4322    ///
4323    /// **Experimental.** This API is part of an experimental wire-protocol surface
4324    /// and may change or be removed in future SDK or CLI releases. Pin both the
4325    /// SDK and CLI versions if your code depends on it.
4326    ///
4327    /// </div>
4328    pub(crate) async fn finalize_invocation_effect(
4329        &self,
4330        params: CommandsFinalizeInvocationEffectRequest,
4331    ) -> Result<CommandsFinalizeInvocationEffectResult, Error> {
4332        let mut wire_params = serde_json::to_value(params)?;
4333        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4334        let _value = self
4335            .session
4336            .client()
4337            .call(
4338                rpc_methods::SESSION_COMMANDS_FINALIZEINVOCATIONEFFECT,
4339                Some(wire_params),
4340            )
4341            .await?;
4342        Ok(serde_json::from_value(_value)?)
4343    }
4344
4345    /// Reports completion of a pending client-handled slash command.
4346    ///
4347    /// Wire method: `session.commands.handlePendingCommand`.
4348    ///
4349    /// # Parameters
4350    ///
4351    /// * `params` - Pending command request ID and an optional error if the client handler failed.
4352    ///
4353    /// # Returns
4354    ///
4355    /// Indicates whether the pending client-handled command was completed successfully.
4356    ///
4357    /// <div class="warning">
4358    ///
4359    /// **Experimental.** This API is part of an experimental wire-protocol surface
4360    /// and may change or be removed in future SDK or CLI releases. Pin both the
4361    /// SDK and CLI versions if your code depends on it.
4362    ///
4363    /// </div>
4364    pub async fn handle_pending_command(
4365        &self,
4366        params: CommandsHandlePendingCommandRequest,
4367    ) -> Result<CommandsHandlePendingCommandResult, Error> {
4368        let mut wire_params = serde_json::to_value(params)?;
4369        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4370        let _value = self
4371            .session
4372            .client()
4373            .call(
4374                rpc_methods::SESSION_COMMANDS_HANDLEPENDINGCOMMAND,
4375                Some(wire_params),
4376            )
4377            .await?;
4378        Ok(serde_json::from_value(_value)?)
4379    }
4380
4381    /// Executes a slash command synchronously and returns any error.
4382    ///
4383    /// Wire method: `session.commands.execute`.
4384    ///
4385    /// # Parameters
4386    ///
4387    /// * `params` - Slash command name and argument string to execute synchronously.
4388    ///
4389    /// # Returns
4390    ///
4391    /// Error message produced while executing the command, if any.
4392    ///
4393    /// <div class="warning">
4394    ///
4395    /// **Experimental.** This API is part of an experimental wire-protocol surface
4396    /// and may change or be removed in future SDK or CLI releases. Pin both the
4397    /// SDK and CLI versions if your code depends on it.
4398    ///
4399    /// </div>
4400    pub async fn execute(
4401        &self,
4402        params: ExecuteCommandParams,
4403    ) -> Result<ExecuteCommandResult, Error> {
4404        let mut wire_params = serde_json::to_value(params)?;
4405        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4406        let _value = self
4407            .session
4408            .client()
4409            .call(rpc_methods::SESSION_COMMANDS_EXECUTE, Some(wire_params))
4410            .await?;
4411        Ok(serde_json::from_value(_value)?)
4412    }
4413
4414    /// Enqueues a slash command for FIFO processing on the local session.
4415    ///
4416    /// Wire method: `session.commands.enqueue`.
4417    ///
4418    /// # Parameters
4419    ///
4420    /// * `params` - Slash-prefixed command string to enqueue for FIFO processing.
4421    ///
4422    /// # Returns
4423    ///
4424    /// Indicates whether the command was accepted into the local execution queue.
4425    ///
4426    /// <div class="warning">
4427    ///
4428    /// **Experimental.** This API is part of an experimental wire-protocol surface
4429    /// and may change or be removed in future SDK or CLI releases. Pin both the
4430    /// SDK and CLI versions if your code depends on it.
4431    ///
4432    /// </div>
4433    pub async fn enqueue(
4434        &self,
4435        params: EnqueueCommandParams,
4436    ) -> Result<EnqueueCommandResult, Error> {
4437        let mut wire_params = serde_json::to_value(params)?;
4438        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4439        let _value = self
4440            .session
4441            .client()
4442            .call(rpc_methods::SESSION_COMMANDS_ENQUEUE, Some(wire_params))
4443            .await?;
4444        Ok(serde_json::from_value(_value)?)
4445    }
4446
4447    /// Reports whether the host actually executed a queued command and whether to continue processing.
4448    ///
4449    /// Wire method: `session.commands.respondToQueuedCommand`.
4450    ///
4451    /// # Parameters
4452    ///
4453    /// * `params` - Queued-command request ID and the result indicating whether the host executed it (and whether to stop processing further queued commands).
4454    ///
4455    /// # Returns
4456    ///
4457    /// Indicates whether the queued-command response was matched to a pending request.
4458    ///
4459    /// <div class="warning">
4460    ///
4461    /// **Experimental.** This API is part of an experimental wire-protocol surface
4462    /// and may change or be removed in future SDK or CLI releases. Pin both the
4463    /// SDK and CLI versions if your code depends on it.
4464    ///
4465    /// </div>
4466    pub async fn respond_to_queued_command(
4467        &self,
4468        params: CommandsRespondToQueuedCommandRequest,
4469    ) -> Result<CommandsRespondToQueuedCommandResult, Error> {
4470        let mut wire_params = serde_json::to_value(params)?;
4471        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4472        let _value = self
4473            .session
4474            .client()
4475            .call(
4476                rpc_methods::SESSION_COMMANDS_RESPONDTOQUEUEDCOMMAND,
4477                Some(wire_params),
4478            )
4479            .await?;
4480        Ok(serde_json::from_value(_value)?)
4481    }
4482}
4483
4484/// `session.completions.*` RPCs.
4485#[derive(Clone, Copy)]
4486pub struct SessionRpcCompletions<'a> {
4487    pub(crate) session: &'a Session,
4488}
4489
4490impl<'a> SessionRpcCompletions<'a> {
4491    /// 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).
4492    ///
4493    /// Wire method: `session.completions.getTriggerCharacters`.
4494    ///
4495    /// # Returns
4496    ///
4497    /// 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`).
4498    ///
4499    /// <div class="warning">
4500    ///
4501    /// **Experimental.** This API is part of an experimental wire-protocol surface
4502    /// and may change or be removed in future SDK or CLI releases. Pin both the
4503    /// SDK and CLI versions if your code depends on it.
4504    ///
4505    /// </div>
4506    pub async fn get_trigger_characters(
4507        &self,
4508    ) -> Result<CompletionsGetTriggerCharactersResult, Error> {
4509        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
4510        let _value = self
4511            .session
4512            .client()
4513            .call(
4514                rpc_methods::SESSION_COMPLETIONS_GETTRIGGERCHARACTERS,
4515                Some(wire_params),
4516            )
4517            .await?;
4518        Ok(serde_json::from_value(_value)?)
4519    }
4520
4521    /// 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.
4522    ///
4523    /// Wire method: `session.completions.request`.
4524    ///
4525    /// # Parameters
4526    ///
4527    /// * `params` - Request host-driven completions for the current composer input.
4528    ///
4529    /// # Returns
4530    ///
4531    /// Host-driven completion items for the current composer input. Empty when the host returns no items or does not support completions.
4532    ///
4533    /// <div class="warning">
4534    ///
4535    /// **Experimental.** This API is part of an experimental wire-protocol surface
4536    /// and may change or be removed in future SDK or CLI releases. Pin both the
4537    /// SDK and CLI versions if your code depends on it.
4538    ///
4539    /// </div>
4540    pub async fn request(
4541        &self,
4542        params: CompletionsRequestRequest,
4543    ) -> Result<CompletionsRequestResult, Error> {
4544        let mut wire_params = serde_json::to_value(params)?;
4545        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4546        let _value = self
4547            .session
4548            .client()
4549            .call(rpc_methods::SESSION_COMPLETIONS_REQUEST, Some(wire_params))
4550            .await?;
4551        Ok(serde_json::from_value(_value)?)
4552    }
4553}
4554
4555/// `session.connectors.*` RPCs.
4556#[derive(Clone, Copy)]
4557pub struct SessionRpcConnectors<'a> {
4558    pub(crate) session: &'a Session,
4559}
4560
4561impl<'a> SessionRpcConnectors<'a> {
4562    /// Returns feature availability and bounded polling limits for the EXPERIMENTAL session connector API. This method never performs a Connector service request.
4563    ///
4564    /// Wire method: `session.connectors.getCapabilities`.
4565    ///
4566    /// # Returns
4567    ///
4568    /// Feature detection and hard polling limits for the EXPERIMENTAL session connector API.
4569    ///
4570    /// <div class="warning">
4571    ///
4572    /// **Experimental.** This API is part of an experimental wire-protocol surface
4573    /// and may change or be removed in future SDK or CLI releases. Pin both the
4574    /// SDK and CLI versions if your code depends on it.
4575    ///
4576    /// </div>
4577    pub async fn get_capabilities(&self) -> Result<ConnectorCapabilities, Error> {
4578        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
4579        let _value = self
4580            .session
4581            .client()
4582            .call(
4583                rpc_methods::SESSION_CONNECTORS_GETCAPABILITIES,
4584                Some(wire_params),
4585            )
4586            .await?;
4587        Ok(serde_json::from_value(_value)?)
4588    }
4589
4590    /// Returns authoritative session Connector state from current availability, pinned account selection, cached catalog, and live MCP projection without performing a Connector service request.
4591    ///
4592    /// Wire method: `session.connectors.getStatus`.
4593    ///
4594    /// # Returns
4595    ///
4596    /// Authoritative session connector state. Account IDs are opaque routing identifiers and credentials are never included.
4597    ///
4598    /// <div class="warning">
4599    ///
4600    /// **Experimental.** This API is part of an experimental wire-protocol surface
4601    /// and may change or be removed in future SDK or CLI releases. Pin both the
4602    /// SDK and CLI versions if your code depends on it.
4603    ///
4604    /// </div>
4605    pub async fn get_status(&self) -> Result<ConnectorStatus, Error> {
4606        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
4607        let _value = self
4608            .session
4609            .client()
4610            .call(rpc_methods::SESSION_CONNECTORS_GETSTATUS, Some(wire_params))
4611            .await?;
4612        Ok(serde_json::from_value(_value)?)
4613    }
4614
4615    /// Returns the cached Connector catalog for the pinned opaque account selection, fetching it only when this session has no cached catalog.
4616    ///
4617    /// Wire method: `session.connectors.list`.
4618    ///
4619    /// # Parameters
4620    ///
4621    /// * `params` - Pins a Connector operation to one host-owned GitHub account through its opaque selection ID. Provider tokens are never accepted.
4622    ///
4623    /// # Returns
4624    ///
4625    /// Validated Connector catalog snapshot cached by the session.
4626    ///
4627    /// <div class="warning">
4628    ///
4629    /// **Experimental.** This API is part of an experimental wire-protocol surface
4630    /// and may change or be removed in future SDK or CLI releases. Pin both the
4631    /// SDK and CLI versions if your code depends on it.
4632    ///
4633    /// </div>
4634    pub async fn list(
4635        &self,
4636        params: ConnectorAccountRequest,
4637    ) -> Result<ConnectorCatalogResult, Error> {
4638        let mut wire_params = serde_json::to_value(params)?;
4639        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4640        let _value = self
4641            .session
4642            .client()
4643            .call(rpc_methods::SESSION_CONNECTORS_LIST, Some(wire_params))
4644            .await?;
4645        Ok(serde_json::from_value(_value)?)
4646    }
4647
4648    /// Refreshes and validates the Connector catalog for the pinned opaque account selection.
4649    ///
4650    /// Wire method: `session.connectors.refresh`.
4651    ///
4652    /// # Parameters
4653    ///
4654    /// * `params` - Pins a Connector operation to one host-owned GitHub account through its opaque selection ID. Provider tokens are never accepted.
4655    ///
4656    /// # Returns
4657    ///
4658    /// Validated Connector catalog snapshot cached by the session.
4659    ///
4660    /// <div class="warning">
4661    ///
4662    /// **Experimental.** This API is part of an experimental wire-protocol surface
4663    /// and may change or be removed in future SDK or CLI releases. Pin both the
4664    /// SDK and CLI versions if your code depends on it.
4665    ///
4666    /// </div>
4667    pub async fn refresh(
4668        &self,
4669        params: ConnectorAccountRequest,
4670    ) -> Result<ConnectorCatalogResult, Error> {
4671        let mut wire_params = serde_json::to_value(params)?;
4672        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4673        let _value = self
4674            .session
4675            .client()
4676            .call(rpc_methods::SESSION_CONNECTORS_REFRESH, Some(wire_params))
4677            .await?;
4678        Ok(serde_json::from_value(_value)?)
4679    }
4680
4681    /// Initiates an idempotent Connector connection request without opening a browser. Returns connected when the service is immediately authoritative, consent_required with a validated URL, or pending with an opaque continuation ID.
4682    ///
4683    /// Wire method: `session.connectors.connect`.
4684    ///
4685    /// # Parameters
4686    ///
4687    /// * `params` - Selects one Connector and the pinned host-owned account used for its service and MCP authorization.
4688    ///
4689    /// # Returns
4690    ///
4691    /// Typed result of initiating or continuing a Connector connection.
4692    ///
4693    /// <div class="warning">
4694    ///
4695    /// **Experimental.** This API is part of an experimental wire-protocol surface
4696    /// and may change or be removed in future SDK or CLI releases. Pin both the
4697    /// SDK and CLI versions if your code depends on it.
4698    ///
4699    /// </div>
4700    pub async fn connect(
4701        &self,
4702        params: ConnectorConnectRequest,
4703    ) -> Result<ConnectorConnectResult, Error> {
4704        let mut wire_params = serde_json::to_value(params)?;
4705        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4706        let _value = self
4707            .session
4708            .client()
4709            .call(rpc_methods::SESSION_CONNECTORS_CONNECT, Some(wire_params))
4710            .await?;
4711        Ok(serde_json::from_value(_value)?)
4712    }
4713
4714    /// Re-initiates an idempotent Connector connection request without browser or UI effects, with the same typed outcomes as connect.
4715    ///
4716    /// Wire method: `session.connectors.reconnect`.
4717    ///
4718    /// # Parameters
4719    ///
4720    /// * `params` - Selects one Connector and the pinned host-owned account used for its service and MCP authorization.
4721    ///
4722    /// # Returns
4723    ///
4724    /// Typed result of initiating or continuing a Connector connection.
4725    ///
4726    /// <div class="warning">
4727    ///
4728    /// **Experimental.** This API is part of an experimental wire-protocol surface
4729    /// and may change or be removed in future SDK or CLI releases. Pin both the
4730    /// SDK and CLI versions if your code depends on it.
4731    ///
4732    /// </div>
4733    pub async fn reconnect(
4734        &self,
4735        params: ConnectorConnectRequest,
4736    ) -> Result<ConnectorConnectResult, Error> {
4737        let mut wire_params = serde_json::to_value(params)?;
4738        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4739        let _value = self
4740            .session
4741            .client()
4742            .call(rpc_methods::SESSION_CONNECTORS_RECONNECT, Some(wire_params))
4743            .await?;
4744        Ok(serde_json::from_value(_value)?)
4745    }
4746
4747    /// Continues a pending Connector connection with caller-supplied attempt, interval, and deadline bounds. The runtime never opens the returned consent URL.
4748    ///
4749    /// Wire method: `session.connectors.continueConnection`.
4750    ///
4751    /// # Parameters
4752    ///
4753    /// * `params` - Explicitly bounded continuation of a pending Connector connection.
4754    ///
4755    /// # Returns
4756    ///
4757    /// Typed result of initiating or continuing a Connector connection.
4758    ///
4759    /// <div class="warning">
4760    ///
4761    /// **Experimental.** This API is part of an experimental wire-protocol surface
4762    /// and may change or be removed in future SDK or CLI releases. Pin both the
4763    /// SDK and CLI versions if your code depends on it.
4764    ///
4765    /// </div>
4766    pub async fn continue_connection(
4767        &self,
4768        params: ConnectorContinueRequest,
4769    ) -> Result<ConnectorConnectResult, Error> {
4770        let mut wire_params = serde_json::to_value(params)?;
4771        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4772        let _value = self
4773            .session
4774            .client()
4775            .call(
4776                rpc_methods::SESSION_CONNECTORS_CONTINUECONNECTION,
4777                Some(wire_params),
4778            )
4779            .await?;
4780        Ok(serde_json::from_value(_value)?)
4781    }
4782
4783    /// Disconnects one Connector for the pinned opaque account selection, refreshes the authoritative catalog, and removes its session-owned MCP projection.
4784    ///
4785    /// Wire method: `session.connectors.disconnect`.
4786    ///
4787    /// # Parameters
4788    ///
4789    /// * `params` - Selects one Connector and the pinned host-owned account used for its service and MCP authorization.
4790    ///
4791    /// # Returns
4792    ///
4793    /// Authoritative result after disconnect and MCP reconciliation.
4794    ///
4795    /// <div class="warning">
4796    ///
4797    /// **Experimental.** This API is part of an experimental wire-protocol surface
4798    /// and may change or be removed in future SDK or CLI releases. Pin both the
4799    /// SDK and CLI versions if your code depends on it.
4800    ///
4801    /// </div>
4802    pub async fn disconnect(
4803        &self,
4804        params: ConnectorConnectRequest,
4805    ) -> Result<ConnectorDisconnectResult, Error> {
4806        let mut wire_params = serde_json::to_value(params)?;
4807        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4808        let _value = self
4809            .session
4810            .client()
4811            .call(
4812                rpc_methods::SESSION_CONNECTORS_DISCONNECT,
4813                Some(wire_params),
4814            )
4815            .await?;
4816        Ok(serde_json::from_value(_value)?)
4817    }
4818
4819    /// Reconciles the authoritative cached or freshly requested Connector catalog into the session Connector MCP projection and returns live status.
4820    ///
4821    /// Wire method: `session.connectors.reconcile`.
4822    ///
4823    /// # Parameters
4824    ///
4825    /// * `params` - Requests authoritative Connector-to-MCP reconciliation for the pinned account.
4826    ///
4827    /// # Returns
4828    ///
4829    /// Authoritative session connector state. Account IDs are opaque routing identifiers and credentials are never included.
4830    ///
4831    /// <div class="warning">
4832    ///
4833    /// **Experimental.** This API is part of an experimental wire-protocol surface
4834    /// and may change or be removed in future SDK or CLI releases. Pin both the
4835    /// SDK and CLI versions if your code depends on it.
4836    ///
4837    /// </div>
4838    pub async fn reconcile(
4839        &self,
4840        params: ConnectorReconcileRequest,
4841    ) -> Result<ConnectorStatus, Error> {
4842        let mut wire_params = serde_json::to_value(params)?;
4843        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4844        let _value = self
4845            .session
4846            .client()
4847            .call(rpc_methods::SESSION_CONNECTORS_RECONCILE, Some(wire_params))
4848            .await?;
4849        Ok(serde_json::from_value(_value)?)
4850    }
4851
4852    /// Reconciles the authoritative Connector catalog into the session MCP projection during startup with a bounded deadline and fail-closed cleanup.
4853    ///
4854    /// Wire method: `session.connectors.reconcileForStartup`.
4855    ///
4856    /// # Parameters
4857    ///
4858    /// * `params` - Pins a Connector operation to one host-owned GitHub account through its opaque selection ID. Provider tokens are never accepted.
4859    ///
4860    /// # Returns
4861    ///
4862    /// Authoritative session connector state. Account IDs are opaque routing identifiers and credentials are never included.
4863    ///
4864    /// <div class="warning">
4865    ///
4866    /// **Experimental.** This API is part of an experimental wire-protocol surface
4867    /// and may change or be removed in future SDK or CLI releases. Pin both the
4868    /// SDK and CLI versions if your code depends on it.
4869    ///
4870    /// </div>
4871    pub(crate) async fn reconcile_for_startup(
4872        &self,
4873        params: ConnectorAccountRequest,
4874    ) -> Result<ConnectorStatus, Error> {
4875        let mut wire_params = serde_json::to_value(params)?;
4876        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4877        let _value = self
4878            .session
4879            .client()
4880            .call(
4881                rpc_methods::SESSION_CONNECTORS_RECONCILEFORSTARTUP,
4882                Some(wire_params),
4883            )
4884            .await?;
4885        Ok(serde_json::from_value(_value)?)
4886    }
4887
4888    /// Removes the runtime-owned Connector MCP projection without changing service-side connections.
4889    ///
4890    /// Wire method: `session.connectors.withdrawProjection`.
4891    ///
4892    /// # Returns
4893    ///
4894    /// Authoritative session connector state. Account IDs are opaque routing identifiers and credentials are never included.
4895    ///
4896    /// <div class="warning">
4897    ///
4898    /// **Experimental.** This API is part of an experimental wire-protocol surface
4899    /// and may change or be removed in future SDK or CLI releases. Pin both the
4900    /// SDK and CLI versions if your code depends on it.
4901    ///
4902    /// </div>
4903    pub(crate) async fn withdraw_projection(&self) -> Result<ConnectorStatus, Error> {
4904        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
4905        let _value = self
4906            .session
4907            .client()
4908            .call(
4909                rpc_methods::SESSION_CONNECTORS_WITHDRAWPROJECTION,
4910                Some(wire_params),
4911            )
4912            .await?;
4913        Ok(serde_json::from_value(_value)?)
4914    }
4915}
4916
4917/// `session.contentExclusion.*` RPCs.
4918#[derive(Clone, Copy)]
4919pub struct SessionRpcContentExclusion<'a> {
4920    pub(crate) session: &'a Session,
4921}
4922
4923impl<'a> SessionRpcContentExclusion<'a> {
4924    /// 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.
4925    ///
4926    /// Wire method: `session.contentExclusion.checkPaths`.
4927    ///
4928    /// # Parameters
4929    ///
4930    /// * `params` - Local file system absolute paths within the session working directory to check against its content-exclusion policy.
4931    ///
4932    /// # Returns
4933    ///
4934    /// Batch content-exclusion result. Callers must fail closed when policy evaluation is unavailable.
4935    ///
4936    /// <div class="warning">
4937    ///
4938    /// **Experimental.** This API is part of an experimental wire-protocol surface
4939    /// and may change or be removed in future SDK or CLI releases. Pin both the
4940    /// SDK and CLI versions if your code depends on it.
4941    ///
4942    /// </div>
4943    pub async fn check_paths(
4944        &self,
4945        params: ContentExclusionCheckPathsRequest,
4946    ) -> Result<ContentExclusionCheckPathsResult, Error> {
4947        let mut wire_params = serde_json::to_value(params)?;
4948        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4949        let _value = self
4950            .session
4951            .client()
4952            .call(
4953                rpc_methods::SESSION_CONTENTEXCLUSION_CHECKPATHS,
4954                Some(wire_params),
4955            )
4956            .await?;
4957        Ok(serde_json::from_value(_value)?)
4958    }
4959}
4960
4961/// `session.customizations.*` RPCs.
4962#[derive(Clone, Copy)]
4963pub struct SessionRpcCustomizations<'a> {
4964    pub(crate) session: &'a Session,
4965}
4966
4967impl<'a> SessionRpcCustomizations<'a> {
4968    /// Reloads all repository and user customizations for the active session: instructions, plugins and their MCP servers and hooks, custom agents, extensions, and skills. Returns diagnostics from the final skill reload.
4969    ///
4970    /// Wire method: `session.customizations.reload`.
4971    ///
4972    /// # Returns
4973    ///
4974    /// Diagnostics from reloading skill definitions, with warnings and errors as separate lists.
4975    ///
4976    /// <div class="warning">
4977    ///
4978    /// **Experimental.** This API is part of an experimental wire-protocol surface
4979    /// and may change or be removed in future SDK or CLI releases. Pin both the
4980    /// SDK and CLI versions if your code depends on it.
4981    ///
4982    /// </div>
4983    pub async fn reload(&self) -> Result<SkillsLoadDiagnostics, Error> {
4984        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
4985        let _value = self
4986            .session
4987            .client()
4988            .call(
4989                rpc_methods::SESSION_CUSTOMIZATIONS_RELOAD,
4990                Some(wire_params),
4991            )
4992            .await?;
4993        Ok(serde_json::from_value(_value)?)
4994    }
4995}
4996
4997/// `session.debug.*` RPCs.
4998#[derive(Clone, Copy)]
4999pub struct SessionRpcDebug<'a> {
5000    pub(crate) session: &'a Session,
5001}
5002
5003impl<'a> SessionRpcDebug<'a> {
5004    /// 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.
5005    ///
5006    /// Wire method: `session.debug.collectLogs`.
5007    ///
5008    /// # Parameters
5009    ///
5010    /// * `params` - Options for collecting a session debug bundle with configurable redaction.
5011    ///
5012    /// # Returns
5013    ///
5014    /// Result of collecting a session debug bundle.
5015    ///
5016    /// <div class="warning">
5017    ///
5018    /// **Experimental.** This API is part of an experimental wire-protocol surface
5019    /// and may change or be removed in future SDK or CLI releases. Pin both the
5020    /// SDK and CLI versions if your code depends on it.
5021    ///
5022    /// </div>
5023    pub async fn collect_logs(
5024        &self,
5025        params: DebugCollectLogsRequest,
5026    ) -> Result<DebugCollectLogsResult, Error> {
5027        let mut wire_params = serde_json::to_value(params)?;
5028        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5029        let _value = self
5030            .session
5031            .client()
5032            .call(rpc_methods::SESSION_DEBUG_COLLECTLOGS, Some(wire_params))
5033            .await?;
5034        Ok(serde_json::from_value(_value)?)
5035    }
5036}
5037
5038/// `session.diagnostics.*` RPCs.
5039#[derive(Clone, Copy)]
5040pub struct SessionRpcDiagnostics<'a> {
5041    pub(crate) session: &'a Session,
5042}
5043
5044impl<'a> SessionRpcDiagnostics<'a> {
5045    /// Patches configured session diagnostic sources without restarting their producers. Setting a source level to off clears its retained diagnostics and invalidates cursors selecting that source.
5046    ///
5047    /// Wire method: `session.diagnostics.configure`.
5048    ///
5049    /// # Parameters
5050    ///
5051    /// * `params` - Patch session diagnostic thresholds for explicitly supplied sources.
5052    ///
5053    /// # Returns
5054    ///
5055    /// Per-source session diagnostics configuration.
5056    ///
5057    /// <div class="warning">
5058    ///
5059    /// **Experimental.** This API is part of an experimental wire-protocol surface
5060    /// and may change or be removed in future SDK or CLI releases. Pin both the
5061    /// SDK and CLI versions if your code depends on it.
5062    ///
5063    /// </div>
5064    pub async fn configure(
5065        &self,
5066        params: DiagnosticsConfigureRequest,
5067    ) -> Result<DiagnosticsConfiguration, Error> {
5068        let mut wire_params = serde_json::to_value(params)?;
5069        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5070        let _value = self
5071            .session
5072            .client()
5073            .call(
5074                rpc_methods::SESSION_DIAGNOSTICS_CONFIGURE,
5075                Some(wire_params),
5076            )
5077            .await?;
5078        Ok(serde_json::from_value(_value)?)
5079    }
5080
5081    /// Reads a bounded batch of retained session diagnostics for the selected sources. Records are never consumed and each reader advances independently through its opaque cursor.
5082    ///
5083    /// Wire method: `session.diagnostics.read`.
5084    ///
5085    /// # Parameters
5086    ///
5087    /// * `params` - Cursor-based request for session diagnostics. The default limit is 100 (maximum 500); the default waitMs is zero (maximum 30000).
5088    ///
5089    /// # Returns
5090    ///
5091    /// One cursor-addressed page of retained session diagnostics.
5092    ///
5093    /// <div class="warning">
5094    ///
5095    /// **Experimental.** This API is part of an experimental wire-protocol surface
5096    /// and may change or be removed in future SDK or CLI releases. Pin both the
5097    /// SDK and CLI versions if your code depends on it.
5098    ///
5099    /// </div>
5100    pub async fn read(
5101        &self,
5102        params: DiagnosticsReadRequest,
5103    ) -> Result<DiagnosticsReadResult, Error> {
5104        let mut wire_params = serde_json::to_value(params)?;
5105        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5106        let _value = self
5107            .session
5108            .client()
5109            .call(rpc_methods::SESSION_DIAGNOSTICS_READ, Some(wire_params))
5110            .await?;
5111        Ok(serde_json::from_value(_value)?)
5112    }
5113}
5114
5115/// `session.eventLog.*` RPCs.
5116#[derive(Clone, Copy)]
5117pub struct SessionRpcEventLog<'a> {
5118    pub(crate) session: &'a Session,
5119}
5120
5121impl<'a> SessionRpcEventLog<'a> {
5122    /// Reads a batch of session events from a cursor, optionally waiting for new events. Supports tail-first reads via `direction: backward`.
5123    ///
5124    /// Wire method: `session.eventLog.read`.
5125    ///
5126    /// # Parameters
5127    ///
5128    /// * `params` - Cursor, batch size, and optional long-poll/filter parameters for reading session events.
5129    ///
5130    /// # Returns
5131    ///
5132    /// Batch of session events returned by a read, with cursor and continuation metadata.
5133    ///
5134    /// <div class="warning">
5135    ///
5136    /// **Experimental.** This API is part of an experimental wire-protocol surface
5137    /// and may change or be removed in future SDK or CLI releases. Pin both the
5138    /// SDK and CLI versions if your code depends on it.
5139    ///
5140    /// </div>
5141    pub async fn read(&self, params: EventLogReadRequest) -> Result<EventsReadResult, Error> {
5142        let mut wire_params = serde_json::to_value(params)?;
5143        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5144        let _value = self
5145            .session
5146            .client()
5147            .call(rpc_methods::SESSION_EVENTLOG_READ, Some(wire_params))
5148            .await?;
5149        Ok(serde_json::from_value(_value)?)
5150    }
5151
5152    /// Returns a snapshot of the current tail cursor without consuming events.
5153    ///
5154    /// Wire method: `session.eventLog.tail`.
5155    ///
5156    /// # Returns
5157    ///
5158    /// 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).
5159    ///
5160    /// <div class="warning">
5161    ///
5162    /// **Experimental.** This API is part of an experimental wire-protocol surface
5163    /// and may change or be removed in future SDK or CLI releases. Pin both the
5164    /// SDK and CLI versions if your code depends on it.
5165    ///
5166    /// </div>
5167    pub async fn tail(&self) -> Result<EventLogTailResult, Error> {
5168        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5169        let _value = self
5170            .session
5171            .client()
5172            .call(rpc_methods::SESSION_EVENTLOG_TAIL, Some(wire_params))
5173            .await?;
5174        Ok(serde_json::from_value(_value)?)
5175    }
5176
5177    /// Registers consumer interest in an event type for runtime gating purposes.
5178    ///
5179    /// Wire method: `session.eventLog.registerInterest`.
5180    ///
5181    /// # Parameters
5182    ///
5183    /// * `params` - Event type to register consumer interest for, used by runtime gating logic.
5184    ///
5185    /// # Returns
5186    ///
5187    /// Opaque handle representing an event-type interest registration.
5188    ///
5189    /// <div class="warning">
5190    ///
5191    /// **Experimental.** This API is part of an experimental wire-protocol surface
5192    /// and may change or be removed in future SDK or CLI releases. Pin both the
5193    /// SDK and CLI versions if your code depends on it.
5194    ///
5195    /// </div>
5196    pub async fn register_interest(
5197        &self,
5198        params: RegisterEventInterestParams,
5199    ) -> Result<RegisterEventInterestResult, Error> {
5200        let mut wire_params = serde_json::to_value(params)?;
5201        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5202        let _value = self
5203            .session
5204            .client()
5205            .call(
5206                rpc_methods::SESSION_EVENTLOG_REGISTERINTEREST,
5207                Some(wire_params),
5208            )
5209            .await?;
5210        Ok(serde_json::from_value(_value)?)
5211    }
5212
5213    /// Releases a consumer's previously-registered interest in an event type.
5214    ///
5215    /// Wire method: `session.eventLog.releaseInterest`.
5216    ///
5217    /// # Parameters
5218    ///
5219    /// * `params` - Opaque handle previously returned by `registerInterest` to release.
5220    ///
5221    /// # Returns
5222    ///
5223    /// Indicates whether the operation succeeded.
5224    ///
5225    /// <div class="warning">
5226    ///
5227    /// **Experimental.** This API is part of an experimental wire-protocol surface
5228    /// and may change or be removed in future SDK or CLI releases. Pin both the
5229    /// SDK and CLI versions if your code depends on it.
5230    ///
5231    /// </div>
5232    pub async fn release_interest(
5233        &self,
5234        params: ReleaseEventInterestParams,
5235    ) -> Result<EventLogReleaseInterestResult, Error> {
5236        let mut wire_params = serde_json::to_value(params)?;
5237        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5238        let _value = self
5239            .session
5240            .client()
5241            .call(
5242                rpc_methods::SESSION_EVENTLOG_RELEASEINTEREST,
5243                Some(wire_params),
5244            )
5245            .await?;
5246        Ok(serde_json::from_value(_value)?)
5247    }
5248}
5249
5250/// `session.extensions.*` RPCs.
5251#[derive(Clone, Copy)]
5252pub struct SessionRpcExtensions<'a> {
5253    pub(crate) session: &'a Session,
5254}
5255
5256impl<'a> SessionRpcExtensions<'a> {
5257    /// Lists extensions discovered for the session and their current status.
5258    ///
5259    /// Wire method: `session.extensions.list`.
5260    ///
5261    /// # Returns
5262    ///
5263    /// Extensions discovered for the session, with their current status.
5264    ///
5265    /// <div class="warning">
5266    ///
5267    /// **Experimental.** This API is part of an experimental wire-protocol surface
5268    /// and may change or be removed in future SDK or CLI releases. Pin both the
5269    /// SDK and CLI versions if your code depends on it.
5270    ///
5271    /// </div>
5272    pub async fn list(&self) -> Result<ExtensionList, Error> {
5273        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5274        let _value = self
5275            .session
5276            .client()
5277            .call(rpc_methods::SESSION_EXTENSIONS_LIST, Some(wire_params))
5278            .await?;
5279        Ok(serde_json::from_value(_value)?)
5280    }
5281
5282    /// Enables an extension for the session.
5283    ///
5284    /// Wire method: `session.extensions.enable`.
5285    ///
5286    /// # Parameters
5287    ///
5288    /// * `params` - Source-qualified extension identifier to enable for the session.
5289    ///
5290    /// <div class="warning">
5291    ///
5292    /// **Experimental.** This API is part of an experimental wire-protocol surface
5293    /// and may change or be removed in future SDK or CLI releases. Pin both the
5294    /// SDK and CLI versions if your code depends on it.
5295    ///
5296    /// </div>
5297    pub async fn enable(&self, params: ExtensionsEnableRequest) -> Result<(), Error> {
5298        let mut wire_params = serde_json::to_value(params)?;
5299        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5300        let _value = self
5301            .session
5302            .client()
5303            .call(rpc_methods::SESSION_EXTENSIONS_ENABLE, Some(wire_params))
5304            .await?;
5305        Ok(())
5306    }
5307
5308    /// Disables an extension for the session.
5309    ///
5310    /// Wire method: `session.extensions.disable`.
5311    ///
5312    /// # Parameters
5313    ///
5314    /// * `params` - Source-qualified extension identifier to disable for the session.
5315    ///
5316    /// <div class="warning">
5317    ///
5318    /// **Experimental.** This API is part of an experimental wire-protocol surface
5319    /// and may change or be removed in future SDK or CLI releases. Pin both the
5320    /// SDK and CLI versions if your code depends on it.
5321    ///
5322    /// </div>
5323    pub async fn disable(&self, params: ExtensionsDisableRequest) -> Result<(), Error> {
5324        let mut wire_params = serde_json::to_value(params)?;
5325        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5326        let _value = self
5327            .session
5328            .client()
5329            .call(rpc_methods::SESSION_EXTENSIONS_DISABLE, Some(wire_params))
5330            .await?;
5331        Ok(())
5332    }
5333
5334    /// Reloads extension definitions and processes for the session.
5335    ///
5336    /// Wire method: `session.extensions.reload`.
5337    ///
5338    /// <div class="warning">
5339    ///
5340    /// **Experimental.** This API is part of an experimental wire-protocol surface
5341    /// and may change or be removed in future SDK or CLI releases. Pin both the
5342    /// SDK and CLI versions if your code depends on it.
5343    ///
5344    /// </div>
5345    pub async fn reload(&self) -> Result<(), Error> {
5346        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5347        let _value = self
5348            .session
5349            .client()
5350            .call(rpc_methods::SESSION_EXTENSIONS_RELOAD, Some(wire_params))
5351            .await?;
5352        Ok(())
5353    }
5354
5355    /// 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.
5356    ///
5357    /// Wire method: `session.extensions.sendAttachmentsToMessage`.
5358    ///
5359    /// # Parameters
5360    ///
5361    /// * `params` - Parameters for session.extensions.sendAttachmentsToMessage.
5362    ///
5363    /// <div class="warning">
5364    ///
5365    /// **Experimental.** This API is part of an experimental wire-protocol surface
5366    /// and may change or be removed in future SDK or CLI releases. Pin both the
5367    /// SDK and CLI versions if your code depends on it.
5368    ///
5369    /// </div>
5370    pub async fn send_attachments_to_message(
5371        &self,
5372        params: SendAttachmentsToMessageParams,
5373    ) -> Result<(), Error> {
5374        let mut wire_params = serde_json::to_value(params)?;
5375        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5376        let _value = self
5377            .session
5378            .client()
5379            .call(
5380                rpc_methods::SESSION_EXTENSIONS_SENDATTACHMENTSTOMESSAGE,
5381                Some(wire_params),
5382            )
5383            .await?;
5384        Ok(())
5385    }
5386}
5387
5388/// `session.factory.*` RPCs.
5389#[derive(Clone, Copy)]
5390pub struct SessionRpcFactory<'a> {
5391    pub(crate) session: &'a Session,
5392}
5393
5394impl<'a> SessionRpcFactory<'a> {
5395    /// `session.factory.journal.*` sub-namespace.
5396    pub fn journal(&self) -> SessionRpcFactoryJournal<'a> {
5397        SessionRpcFactoryJournal {
5398            session: self.session,
5399        }
5400    }
5401
5402    /// Runs a registered factory by name at the top level.
5403    ///
5404    /// Wire method: `session.factory.run`.
5405    ///
5406    /// # Parameters
5407    ///
5408    /// * `params` - Parameters for invoking a registered factory.
5409    ///
5410    /// # Returns
5411    ///
5412    /// Complete current or terminal factory run envelope.
5413    ///
5414    /// <div class="warning">
5415    ///
5416    /// **Experimental.** This API is part of an experimental wire-protocol surface
5417    /// and may change or be removed in future SDK or CLI releases. Pin both the
5418    /// SDK and CLI versions if your code depends on it.
5419    ///
5420    /// </div>
5421    pub async fn run(&self, params: FactoryRunRequest) -> Result<FactoryRunResult, Error> {
5422        let mut wire_params = serde_json::to_value(params)?;
5423        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5424        let _value = self
5425            .session
5426            .client()
5427            .call(rpc_methods::SESSION_FACTORY_RUN, Some(wire_params))
5428            .await?;
5429        Ok(serde_json::from_value(_value)?)
5430    }
5431
5432    /// Resumes a factory run using its persisted name, arguments, journal, and accounting.
5433    ///
5434    /// Wire method: `session.factory.resume`.
5435    ///
5436    /// # Parameters
5437    ///
5438    /// * `params` - Parameters for resuming a factory run from its persisted identity.
5439    ///
5440    /// # Returns
5441    ///
5442    /// Resolved persisted factory identity and resumed run envelope.
5443    ///
5444    /// <div class="warning">
5445    ///
5446    /// **Experimental.** This API is part of an experimental wire-protocol surface
5447    /// and may change or be removed in future SDK or CLI releases. Pin both the
5448    /// SDK and CLI versions if your code depends on it.
5449    ///
5450    /// </div>
5451    pub async fn resume(&self, params: FactoryResumeRequest) -> Result<FactoryResumeResult, Error> {
5452        let mut wire_params = serde_json::to_value(params)?;
5453        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5454        let _value = self
5455            .session
5456            .client()
5457            .call(rpc_methods::SESSION_FACTORY_RESUME, Some(wire_params))
5458            .await?;
5459        Ok(serde_json::from_value(_value)?)
5460    }
5461
5462    /// Internal tool-originated factory invocation.
5463    ///
5464    /// Wire method: `session.factory.runFromTool`.
5465    ///
5466    /// # Parameters
5467    ///
5468    /// * `params` - Internal parameters for invoking a registered factory from a tool.
5469    ///
5470    /// # Returns
5471    ///
5472    /// Complete current or terminal factory run envelope.
5473    ///
5474    /// <div class="warning">
5475    ///
5476    /// **Experimental.** This API is part of an experimental wire-protocol surface
5477    /// and may change or be removed in future SDK or CLI releases. Pin both the
5478    /// SDK and CLI versions if your code depends on it.
5479    ///
5480    /// </div>
5481    pub(crate) async fn run_from_tool(
5482        &self,
5483        params: FactoryToolRunRequest,
5484    ) -> Result<FactoryRunResult, Error> {
5485        let mut wire_params = serde_json::to_value(params)?;
5486        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5487        let _value = self
5488            .session
5489            .client()
5490            .call(rpc_methods::SESSION_FACTORY_RUNFROMTOOL, Some(wire_params))
5491            .await?;
5492        Ok(serde_json::from_value(_value)?)
5493    }
5494
5495    /// Internal tool-originated factory resume.
5496    ///
5497    /// Wire method: `session.factory.resumeFromTool`.
5498    ///
5499    /// # Parameters
5500    ///
5501    /// * `params` - Internal parameters for resuming a factory run from a tool.
5502    ///
5503    /// # Returns
5504    ///
5505    /// Resolved persisted factory identity and resumed run envelope.
5506    ///
5507    /// <div class="warning">
5508    ///
5509    /// **Experimental.** This API is part of an experimental wire-protocol surface
5510    /// and may change or be removed in future SDK or CLI releases. Pin both the
5511    /// SDK and CLI versions if your code depends on it.
5512    ///
5513    /// </div>
5514    pub(crate) async fn resume_from_tool(
5515        &self,
5516        params: FactoryToolResumeRequest,
5517    ) -> Result<FactoryResumeResult, Error> {
5518        let mut wire_params = serde_json::to_value(params)?;
5519        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5520        let _value = self
5521            .session
5522            .client()
5523            .call(
5524                rpc_methods::SESSION_FACTORY_RESUMEFROMTOOL,
5525                Some(wire_params),
5526            )
5527            .await?;
5528        Ok(serde_json::from_value(_value)?)
5529    }
5530
5531    /// Gets the current or settled envelope for a factory run.
5532    ///
5533    /// Wire method: `session.factory.getRun`.
5534    ///
5535    /// # Parameters
5536    ///
5537    /// * `params` - Parameters for retrieving a factory run.
5538    ///
5539    /// # Returns
5540    ///
5541    /// Complete current or terminal factory run envelope.
5542    ///
5543    /// <div class="warning">
5544    ///
5545    /// **Experimental.** This API is part of an experimental wire-protocol surface
5546    /// and may change or be removed in future SDK or CLI releases. Pin both the
5547    /// SDK and CLI versions if your code depends on it.
5548    ///
5549    /// </div>
5550    pub async fn get_run(&self, params: FactoryGetRunRequest) -> Result<FactoryRunResult, Error> {
5551        let mut wire_params = serde_json::to_value(params)?;
5552        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5553        let _value = self
5554            .session
5555            .client()
5556            .call(rpc_methods::SESSION_FACTORY_GETRUN, Some(wire_params))
5557            .await?;
5558        Ok(serde_json::from_value(_value)?)
5559    }
5560
5561    /// Lists durable factory runs for this session in creation order.
5562    ///
5563    /// Wire method: `session.factory.listRuns`.
5564    ///
5565    /// # Parameters
5566    ///
5567    /// * `params` - Parameters for paging factory runs.
5568    ///
5569    /// # Returns
5570    ///
5571    /// A page of factory runs in durable creation order.
5572    ///
5573    /// <div class="warning">
5574    ///
5575    /// **Experimental.** This API is part of an experimental wire-protocol surface
5576    /// and may change or be removed in future SDK or CLI releases. Pin both the
5577    /// SDK and CLI versions if your code depends on it.
5578    ///
5579    /// </div>
5580    pub async fn list_runs(
5581        &self,
5582        params: FactoryListRunsRequest,
5583    ) -> Result<FactoryListRunsResult, Error> {
5584        let mut wire_params = serde_json::to_value(params)?;
5585        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5586        let _value = self
5587            .session
5588            .client()
5589            .call(rpc_methods::SESSION_FACTORY_LISTRUNS, Some(wire_params))
5590            .await?;
5591        Ok(serde_json::from_value(_value)?)
5592    }
5593
5594    /// Gets durable and live observability detail for one factory run.
5595    ///
5596    /// Wire method: `session.factory.getRunDetail`.
5597    ///
5598    /// # Parameters
5599    ///
5600    /// * `params` - Parameters for retrieving a factory run.
5601    ///
5602    /// # Returns
5603    ///
5604    /// Full factory run observability detail.
5605    ///
5606    /// <div class="warning">
5607    ///
5608    /// **Experimental.** This API is part of an experimental wire-protocol surface
5609    /// and may change or be removed in future SDK or CLI releases. Pin both the
5610    /// SDK and CLI versions if your code depends on it.
5611    ///
5612    /// </div>
5613    pub async fn get_run_detail(
5614        &self,
5615        params: FactoryGetRunRequest,
5616    ) -> Result<FactoryRunDetail, Error> {
5617        let mut wire_params = serde_json::to_value(params)?;
5618        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5619        let _value = self
5620            .session
5621            .client()
5622            .call(rpc_methods::SESSION_FACTORY_GETRUNDETAIL, Some(wire_params))
5623            .await?;
5624        Ok(serde_json::from_value(_value)?)
5625    }
5626
5627    /// Pages durable progress for one factory run.
5628    ///
5629    /// Wire method: `session.factory.getRunProgress`.
5630    ///
5631    /// # Parameters
5632    ///
5633    /// * `params` - Parameters for paging factory progress.
5634    ///
5635    /// # Returns
5636    ///
5637    /// A bidirectional page of factory progress.
5638    ///
5639    /// <div class="warning">
5640    ///
5641    /// **Experimental.** This API is part of an experimental wire-protocol surface
5642    /// and may change or be removed in future SDK or CLI releases. Pin both the
5643    /// SDK and CLI versions if your code depends on it.
5644    ///
5645    /// </div>
5646    pub async fn get_run_progress(
5647        &self,
5648        params: FactoryGetRunProgressRequest,
5649    ) -> Result<FactoryProgressPage, Error> {
5650        let mut wire_params = serde_json::to_value(params)?;
5651        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5652        let _value = self
5653            .session
5654            .client()
5655            .call(
5656                rpc_methods::SESSION_FACTORY_GETRUNPROGRESS,
5657                Some(wire_params),
5658            )
5659            .await?;
5660        Ok(serde_json::from_value(_value)?)
5661    }
5662
5663    /// Requests cancellation of a factory run and returns its run envelope.
5664    ///
5665    /// Wire method: `session.factory.cancel`.
5666    ///
5667    /// # Parameters
5668    ///
5669    /// * `params` - Parameters for cancelling a factory run.
5670    ///
5671    /// # Returns
5672    ///
5673    /// Complete current or terminal factory run envelope.
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 async fn cancel(&self, params: FactoryCancelRequest) -> Result<FactoryRunResult, Error> {
5683        let mut wire_params = serde_json::to_value(params)?;
5684        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5685        let _value = self
5686            .session
5687            .client()
5688            .call(rpc_methods::SESSION_FACTORY_CANCEL, Some(wire_params))
5689            .await?;
5690        Ok(serde_json::from_value(_value)?)
5691    }
5692
5693    /// Pauses a running factory and returns its settled run envelope.
5694    ///
5695    /// Wire method: `session.factory.pause`.
5696    ///
5697    /// # Parameters
5698    ///
5699    /// * `params` - Parameters for pausing a running factory.
5700    ///
5701    /// # Returns
5702    ///
5703    /// Complete current or terminal factory run envelope.
5704    ///
5705    /// <div class="warning">
5706    ///
5707    /// **Experimental.** This API is part of an experimental wire-protocol surface
5708    /// and may change or be removed in future SDK or CLI releases. Pin both the
5709    /// SDK and CLI versions if your code depends on it.
5710    ///
5711    /// </div>
5712    pub async fn pause(&self, params: FactoryPauseRequest) -> Result<FactoryRunResult, Error> {
5713        let mut wire_params = serde_json::to_value(params)?;
5714        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5715        let _value = self
5716            .session
5717            .client()
5718            .call(rpc_methods::SESSION_FACTORY_PAUSE, Some(wire_params))
5719            .await?;
5720        Ok(serde_json::from_value(_value)?)
5721    }
5722
5723    /// Atomically pauses an owned factory attempt at a durable checkpoint.
5724    ///
5725    /// Wire method: `session.factory.pauseAtCheckpoint`.
5726    ///
5727    /// # Parameters
5728    ///
5729    /// * `params` - Parameters for an owned durable pause checkpoint.
5730    ///
5731    /// <div class="warning">
5732    ///
5733    /// **Experimental.** This API is part of an experimental wire-protocol surface
5734    /// and may change or be removed in future SDK or CLI releases. Pin both the
5735    /// SDK and CLI versions if your code depends on it.
5736    ///
5737    /// </div>
5738    pub(crate) async fn pause_at_checkpoint(
5739        &self,
5740        params: FactoryPauseCheckpointRequest,
5741    ) -> Result<FactoryPauseCheckpointResult, Error> {
5742        let mut wire_params = serde_json::to_value(params)?;
5743        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5744        let _value = self
5745            .session
5746            .client()
5747            .call(
5748                rpc_methods::SESSION_FACTORY_PAUSEATCHECKPOINT,
5749                Some(wire_params),
5750            )
5751            .await?;
5752        Ok(serde_json::from_value(_value)?)
5753    }
5754
5755    /// Records a batch of ordered factory progress lines.
5756    ///
5757    /// Wire method: `session.factory.log`.
5758    ///
5759    /// # Parameters
5760    ///
5761    /// * `params` - Parameters for recording factory progress.
5762    ///
5763    /// # Returns
5764    ///
5765    /// Acknowledgement that a factory request was accepted.
5766    ///
5767    /// <div class="warning">
5768    ///
5769    /// **Experimental.** This API is part of an experimental wire-protocol surface
5770    /// and may change or be removed in future SDK or CLI releases. Pin both the
5771    /// SDK and CLI versions if your code depends on it.
5772    ///
5773    /// </div>
5774    pub async fn log(&self, params: FactoryLogRequest) -> Result<FactoryAckResult, Error> {
5775        let mut wire_params = serde_json::to_value(params)?;
5776        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5777        let _value = self
5778            .session
5779            .client()
5780            .call(rpc_methods::SESSION_FACTORY_LOG, Some(wire_params))
5781            .await?;
5782        Ok(serde_json::from_value(_value)?)
5783    }
5784
5785    /// Runs one factory-scoped subagent and returns its result.
5786    ///
5787    /// Wire method: `session.factory.agent`.
5788    ///
5789    /// # Parameters
5790    ///
5791    /// * `params` - Parameters for one factory-scoped subagent call.
5792    ///
5793    /// # Returns
5794    ///
5795    /// Result of one factory-scoped subagent call.
5796    ///
5797    /// <div class="warning">
5798    ///
5799    /// **Experimental.** This API is part of an experimental wire-protocol surface
5800    /// and may change or be removed in future SDK or CLI releases. Pin both the
5801    /// SDK and CLI versions if your code depends on it.
5802    ///
5803    /// </div>
5804    pub async fn agent(&self, params: FactoryAgentRequest) -> Result<FactoryAgentResult, Error> {
5805        let mut wire_params = serde_json::to_value(params)?;
5806        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5807        let _value = self
5808            .session
5809            .client()
5810            .call(rpc_methods::SESSION_FACTORY_AGENT, Some(wire_params))
5811            .await?;
5812        Ok(serde_json::from_value(_value)?)
5813    }
5814}
5815
5816/// `session.factory.journal.*` RPCs.
5817#[derive(Clone, Copy)]
5818pub struct SessionRpcFactoryJournal<'a> {
5819    pub(crate) session: &'a Session,
5820}
5821
5822impl<'a> SessionRpcFactoryJournal<'a> {
5823    /// Reads a memoized factory journal entry.
5824    ///
5825    /// Wire method: `session.factory.journal.get`.
5826    ///
5827    /// # Parameters
5828    ///
5829    /// * `params` - Parameters for reading a factory journal entry.
5830    ///
5831    /// # Returns
5832    ///
5833    /// Result of reading a factory journal entry.
5834    ///
5835    /// <div class="warning">
5836    ///
5837    /// **Experimental.** This API is part of an experimental wire-protocol surface
5838    /// and may change or be removed in future SDK or CLI releases. Pin both the
5839    /// SDK and CLI versions if your code depends on it.
5840    ///
5841    /// </div>
5842    pub async fn get(
5843        &self,
5844        params: FactoryJournalGetRequest,
5845    ) -> Result<FactoryJournalGetResult, Error> {
5846        let mut wire_params = serde_json::to_value(params)?;
5847        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5848        let _value = self
5849            .session
5850            .client()
5851            .call(rpc_methods::SESSION_FACTORY_JOURNAL_GET, Some(wire_params))
5852            .await?;
5853        Ok(serde_json::from_value(_value)?)
5854    }
5855
5856    /// Stores a memoized factory journal entry.
5857    ///
5858    /// Wire method: `session.factory.journal.put`.
5859    ///
5860    /// # Parameters
5861    ///
5862    /// * `params` - Parameters for storing a factory journal entry.
5863    ///
5864    /// # Returns
5865    ///
5866    /// Acknowledgement that a factory request was accepted.
5867    ///
5868    /// <div class="warning">
5869    ///
5870    /// **Experimental.** This API is part of an experimental wire-protocol surface
5871    /// and may change or be removed in future SDK or CLI releases. Pin both the
5872    /// SDK and CLI versions if your code depends on it.
5873    ///
5874    /// </div>
5875    pub async fn put(&self, params: FactoryJournalPutRequest) -> Result<FactoryAckResult, Error> {
5876        let mut wire_params = serde_json::to_value(params)?;
5877        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5878        let _value = self
5879            .session
5880            .client()
5881            .call(rpc_methods::SESSION_FACTORY_JOURNAL_PUT, Some(wire_params))
5882            .await?;
5883        Ok(serde_json::from_value(_value)?)
5884    }
5885}
5886
5887/// `session.fleet.*` RPCs.
5888#[derive(Clone, Copy)]
5889pub struct SessionRpcFleet<'a> {
5890    pub(crate) session: &'a Session,
5891}
5892
5893impl<'a> SessionRpcFleet<'a> {
5894    /// Starts fleet mode by submitting the fleet orchestration prompt to the session.
5895    ///
5896    /// Wire method: `session.fleet.start`.
5897    ///
5898    /// # Parameters
5899    ///
5900    /// * `params` - Parameters for starting fleet orchestration: an optional user prompt combined with the fleet instructions, plus the send options forwarded to the resulting turn.
5901    ///
5902    /// # Returns
5903    ///
5904    /// Indicates whether fleet mode was successfully activated.
5905    ///
5906    /// <div class="warning">
5907    ///
5908    /// **Experimental.** This API is part of an experimental wire-protocol surface
5909    /// and may change or be removed in future SDK or CLI releases. Pin both the
5910    /// SDK and CLI versions if your code depends on it.
5911    ///
5912    /// </div>
5913    pub async fn start(&self, params: FleetStartRequest) -> Result<FleetStartResult, Error> {
5914        let mut wire_params = serde_json::to_value(params)?;
5915        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5916        let _value = self
5917            .session
5918            .client()
5919            .call(rpc_methods::SESSION_FLEET_START, Some(wire_params))
5920            .await?;
5921        Ok(serde_json::from_value(_value)?)
5922    }
5923}
5924
5925/// `session.gitHubAuth.*` RPCs.
5926#[derive(Clone, Copy)]
5927pub struct SessionRpcGitHubAuth<'a> {
5928    pub(crate) session: &'a Session,
5929}
5930
5931impl<'a> SessionRpcGitHubAuth<'a> {
5932    /// Gets authentication status and account metadata for the session.
5933    ///
5934    /// Wire method: `session.gitHubAuth.getStatus`.
5935    ///
5936    /// # Returns
5937    ///
5938    /// Authentication status and account metadata for the session.
5939    ///
5940    /// <div class="warning">
5941    ///
5942    /// **Experimental.** This API is part of an experimental wire-protocol surface
5943    /// and may change or be removed in future SDK or CLI releases. Pin both the
5944    /// SDK and CLI versions if your code depends on it.
5945    ///
5946    /// </div>
5947    pub async fn get_status(&self) -> Result<SessionAuthStatus, Error> {
5948        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5949        let _value = self
5950            .session
5951            .client()
5952            .call(rpc_methods::SESSION_GITHUBAUTH_GETSTATUS, Some(wire_params))
5953            .await?;
5954        Ok(serde_json::from_value(_value)?)
5955    }
5956
5957    /// Updates the session's auth credentials used for outbound model and API requests.
5958    ///
5959    /// Wire method: `session.gitHubAuth.setCredentials`.
5960    ///
5961    /// # Parameters
5962    ///
5963    /// * `params` - New auth credentials to install on the session. Omit to leave credentials unchanged.
5964    ///
5965    /// # Returns
5966    ///
5967    /// Indicates whether the credential update succeeded.
5968    ///
5969    /// <div class="warning">
5970    ///
5971    /// **Experimental.** This API is part of an experimental wire-protocol surface
5972    /// and may change or be removed in future SDK or CLI releases. Pin both the
5973    /// SDK and CLI versions if your code depends on it.
5974    ///
5975    /// </div>
5976    pub async fn set_credentials(
5977        &self,
5978        params: SessionSetCredentialsParams,
5979    ) -> Result<SessionSetCredentialsResult, Error> {
5980        let mut wire_params = serde_json::to_value(params)?;
5981        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5982        let _value = self
5983            .session
5984            .client()
5985            .call(
5986                rpc_methods::SESSION_GITHUBAUTH_SETCREDENTIALS,
5987                Some(wire_params),
5988            )
5989            .await?;
5990        Ok(serde_json::from_value(_value)?)
5991    }
5992
5993    /// Gets the current authentication information for internal session hosts.
5994    ///
5995    /// Wire method: `session.gitHubAuth.getCurrentAuthInfo`.
5996    ///
5997    /// # Returns
5998    ///
5999    /// Current authentication information, or null when no authentication is active.
6000    ///
6001    /// <div class="warning">
6002    ///
6003    /// **Experimental.** This API is part of an experimental wire-protocol surface
6004    /// and may change or be removed in future SDK or CLI releases. Pin both the
6005    /// SDK and CLI versions if your code depends on it.
6006    ///
6007    /// </div>
6008    pub(crate) async fn get_current_auth_info(&self) -> Result<SessionAuthInfoResult, Error> {
6009        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6010        let _value = self
6011            .session
6012            .client()
6013            .call(
6014                rpc_methods::SESSION_GITHUBAUTH_GETCURRENTAUTHINFO,
6015                Some(wire_params),
6016            )
6017            .await?;
6018        Ok(serde_json::from_value(_value)?)
6019    }
6020
6021    /// Gets all authentication accounts available to the internal session host.
6022    ///
6023    /// Wire method: `session.gitHubAuth.getAllAuthAvailable`.
6024    ///
6025    /// # Returns
6026    ///
6027    /// Authentication accounts available to the internal session host.
6028    ///
6029    /// <div class="warning">
6030    ///
6031    /// **Experimental.** This API is part of an experimental wire-protocol surface
6032    /// and may change or be removed in future SDK or CLI releases. Pin both the
6033    /// SDK and CLI versions if your code depends on it.
6034    ///
6035    /// </div>
6036    pub(crate) async fn get_all_auth_available(
6037        &self,
6038    ) -> Result<SessionGitHubAuthGetAllAuthAvailableResult, Error> {
6039        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6040        let _value = self
6041            .session
6042            .client()
6043            .call(
6044                rpc_methods::SESSION_GITHUBAUTH_GETALLAUTHAVAILABLE,
6045                Some(wire_params),
6046            )
6047            .await?;
6048        Ok(serde_json::from_value(_value)?)
6049    }
6050
6051    /// Refreshes Copilot account metadata for the current authentication.
6052    ///
6053    /// Wire method: `session.gitHubAuth.refreshCopilotUser`.
6054    ///
6055    /// # Returns
6056    ///
6057    /// Current authentication information, or null when no authentication is active.
6058    ///
6059    /// <div class="warning">
6060    ///
6061    /// **Experimental.** This API is part of an experimental wire-protocol surface
6062    /// and may change or be removed in future SDK or CLI releases. Pin both the
6063    /// SDK and CLI versions if your code depends on it.
6064    ///
6065    /// </div>
6066    pub(crate) async fn refresh_copilot_user(&self) -> Result<SessionAuthInfoResult, Error> {
6067        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6068        let _value = self
6069            .session
6070            .client()
6071            .call(
6072                rpc_methods::SESSION_GITHUBAUTH_REFRESHCOPILOTUSER,
6073                Some(wire_params),
6074            )
6075            .await?;
6076        Ok(serde_json::from_value(_value)?)
6077    }
6078
6079    /// Logs in a GitHub user through the internal session host.
6080    ///
6081    /// Wire method: `session.gitHubAuth.login`.
6082    ///
6083    /// # Parameters
6084    ///
6085    /// * `params` - Internal GitHub login parameters.
6086    ///
6087    /// # Returns
6088    ///
6089    /// Authentication credentials accepted only at native protocol ingress. Runtime outputs use credential-free `AuthIdentity` metadata.
6090    ///
6091    /// <div class="warning">
6092    ///
6093    /// **Experimental.** This API is part of an experimental wire-protocol surface
6094    /// and may change or be removed in future SDK or CLI releases. Pin both the
6095    /// SDK and CLI versions if your code depends on it.
6096    ///
6097    /// </div>
6098    pub(crate) async fn login(&self, params: SessionAuthLoginRequest) -> Result<AuthInfo, Error> {
6099        let mut wire_params = serde_json::to_value(params)?;
6100        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6101        let _value = self
6102            .session
6103            .client()
6104            .call(rpc_methods::SESSION_GITHUBAUTH_LOGIN, Some(wire_params))
6105            .await?;
6106        Ok(serde_json::from_value(_value)?)
6107    }
6108
6109    /// Switches the session to another available authentication.
6110    ///
6111    /// Wire method: `session.gitHubAuth.switchToAuth`.
6112    ///
6113    /// # Parameters
6114    ///
6115    /// * `params` - Parameters for switching the session's active authentication.
6116    ///
6117    /// <div class="warning">
6118    ///
6119    /// **Experimental.** This API is part of an experimental wire-protocol surface
6120    /// and may change or be removed in future SDK or CLI releases. Pin both the
6121    /// SDK and CLI versions if your code depends on it.
6122    ///
6123    /// </div>
6124    pub(crate) async fn switch_to_auth(
6125        &self,
6126        params: SessionAuthSwitchRequest,
6127    ) -> Result<(), Error> {
6128        let mut wire_params = serde_json::to_value(params)?;
6129        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6130        let _value = self
6131            .session
6132            .client()
6133            .call(
6134                rpc_methods::SESSION_GITHUBAUTH_SWITCHTOAUTH,
6135                Some(wire_params),
6136            )
6137            .await?;
6138        Ok(())
6139    }
6140
6141    /// Logs out the session's current GitHub authentication.
6142    ///
6143    /// Wire method: `session.gitHubAuth.logout`.
6144    ///
6145    /// # Returns
6146    ///
6147    /// Whether the current authentication was logged out.
6148    ///
6149    /// <div class="warning">
6150    ///
6151    /// **Experimental.** This API is part of an experimental wire-protocol surface
6152    /// and may change or be removed in future SDK or CLI releases. Pin both the
6153    /// SDK and CLI versions if your code depends on it.
6154    ///
6155    /// </div>
6156    pub(crate) async fn logout(&self) -> Result<SessionGitHubAuthLogoutResult, Error> {
6157        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6158        let _value = self
6159            .session
6160            .client()
6161            .call(rpc_methods::SESSION_GITHUBAUTH_LOGOUT, Some(wire_params))
6162            .await?;
6163        Ok(serde_json::from_value(_value)?)
6164    }
6165
6166    /// Logs out a specific GitHub authentication.
6167    ///
6168    /// Wire method: `session.gitHubAuth.logoutUser`.
6169    ///
6170    /// # Parameters
6171    ///
6172    /// * `params` - Parameters identifying a GitHub authentication to log out.
6173    ///
6174    /// # Returns
6175    ///
6176    /// Whether the requested authentication was logged out.
6177    ///
6178    /// <div class="warning">
6179    ///
6180    /// **Experimental.** This API is part of an experimental wire-protocol surface
6181    /// and may change or be removed in future SDK or CLI releases. Pin both the
6182    /// SDK and CLI versions if your code depends on it.
6183    ///
6184    /// </div>
6185    pub(crate) async fn logout_user(
6186        &self,
6187        params: SessionAuthLogoutUserRequest,
6188    ) -> Result<SessionGitHubAuthLogoutUserResult, Error> {
6189        let mut wire_params = serde_json::to_value(params)?;
6190        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6191        let _value = self
6192            .session
6193            .client()
6194            .call(
6195                rpc_methods::SESSION_GITHUBAUTH_LOGOUTUSER,
6196                Some(wire_params),
6197            )
6198            .await?;
6199        Ok(serde_json::from_value(_value)?)
6200    }
6201
6202    /// Gets validation errors from the most recent authentication attempt.
6203    ///
6204    /// Wire method: `session.gitHubAuth.lastAuthErrors`.
6205    ///
6206    /// # Returns
6207    ///
6208    /// Validation errors from the most recent authentication attempt.
6209    ///
6210    /// <div class="warning">
6211    ///
6212    /// **Experimental.** This API is part of an experimental wire-protocol surface
6213    /// and may change or be removed in future SDK or CLI releases. Pin both the
6214    /// SDK and CLI versions if your code depends on it.
6215    ///
6216    /// </div>
6217    pub(crate) async fn last_auth_errors(&self) -> Result<AuthValidationErrors, Error> {
6218        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6219        let _value = self
6220            .session
6221            .client()
6222            .call(
6223                rpc_methods::SESSION_GITHUBAUTH_LASTAUTHERRORS,
6224                Some(wire_params),
6225            )
6226            .await?;
6227        Ok(serde_json::from_value(_value)?)
6228    }
6229}
6230
6231/// `session.history.*` RPCs.
6232#[derive(Clone, Copy)]
6233pub struct SessionRpcHistory<'a> {
6234    pub(crate) session: &'a Session,
6235}
6236
6237impl<'a> SessionRpcHistory<'a> {
6238    /// Compacts the session history to reduce context usage.
6239    ///
6240    /// Wire method: `session.history.compact`.
6241    ///
6242    /// # Returns
6243    ///
6244    /// Compaction outcome with the number of tokens and messages removed, summary text, and the resulting context window breakdown.
6245    ///
6246    /// <div class="warning">
6247    ///
6248    /// **Experimental.** This API is part of an experimental wire-protocol surface
6249    /// and may change or be removed in future SDK or CLI releases. Pin both the
6250    /// SDK and CLI versions if your code depends on it.
6251    ///
6252    /// </div>
6253    pub async fn compact(&self) -> Result<HistoryCompactResult, Error> {
6254        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6255        let _value = self
6256            .session
6257            .client()
6258            .call(rpc_methods::SESSION_HISTORY_COMPACT, Some(wire_params))
6259            .await?;
6260        Ok(serde_json::from_value(_value)?)
6261    }
6262
6263    /// Compacts the session history to reduce context usage.
6264    ///
6265    /// Wire method: `session.history.compact`.
6266    ///
6267    /// # Parameters
6268    ///
6269    /// * `params` - Optional compaction parameters.
6270    ///
6271    /// # Returns
6272    ///
6273    /// Compaction outcome with the number of tokens and messages removed, summary text, and the resulting context window breakdown.
6274    ///
6275    /// <div class="warning">
6276    ///
6277    /// **Experimental.** This API is part of an experimental wire-protocol surface
6278    /// and may change or be removed in future SDK or CLI releases. Pin both the
6279    /// SDK and CLI versions if your code depends on it.
6280    ///
6281    /// </div>
6282    pub async fn compact_with_params(
6283        &self,
6284        params: HistoryCompactRequest,
6285    ) -> Result<HistoryCompactResult, Error> {
6286        let mut wire_params = serde_json::to_value(params)?;
6287        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6288        let _value = self
6289            .session
6290            .client()
6291            .call(rpc_methods::SESSION_HISTORY_COMPACT, Some(wire_params))
6292            .await?;
6293        Ok(serde_json::from_value(_value)?)
6294    }
6295
6296    /// Truncates persisted session history to a specific event.
6297    ///
6298    /// Wire method: `session.history.truncate`.
6299    ///
6300    /// # Parameters
6301    ///
6302    /// * `params` - Identifier of the event to truncate to; this event and all later events are removed.
6303    ///
6304    /// # Returns
6305    ///
6306    /// Number of events that were removed by the truncation.
6307    ///
6308    /// <div class="warning">
6309    ///
6310    /// **Experimental.** This API is part of an experimental wire-protocol surface
6311    /// and may change or be removed in future SDK or CLI releases. Pin both the
6312    /// SDK and CLI versions if your code depends on it.
6313    ///
6314    /// </div>
6315    pub async fn truncate(
6316        &self,
6317        params: HistoryTruncateRequest,
6318    ) -> Result<HistoryTruncateResult, Error> {
6319        let mut wire_params = serde_json::to_value(params)?;
6320        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6321        let _value = self
6322            .session
6323            .client()
6324            .call(rpc_methods::SESSION_HISTORY_TRUNCATE, Some(wire_params))
6325            .await?;
6326        Ok(serde_json::from_value(_value)?)
6327    }
6328
6329    /// 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.
6330    ///
6331    /// Wire method: `session.history.listRewindPoints`.
6332    ///
6333    /// # Returns
6334    ///
6335    /// Rewind points and file-change-tracking availability for the session.
6336    ///
6337    /// <div class="warning">
6338    ///
6339    /// **Experimental.** This API is part of an experimental wire-protocol surface
6340    /// and may change or be removed in future SDK or CLI releases. Pin both the
6341    /// SDK and CLI versions if your code depends on it.
6342    ///
6343    /// </div>
6344    pub async fn list_rewind_points(&self) -> Result<HistoryListRewindPointsResult, Error> {
6345        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6346        let _value = self
6347            .session
6348            .client()
6349            .call(
6350                rpc_methods::SESSION_HISTORY_LISTREWINDPOINTS,
6351                Some(wire_params),
6352            )
6353            .await?;
6354        Ok(serde_json::from_value(_value)?)
6355    }
6356
6357    /// Previews the files that a conversation-and-files rewind would restore.
6358    ///
6359    /// Wire method: `session.history.previewRewind`.
6360    ///
6361    /// # Parameters
6362    ///
6363    /// * `params` - Event boundary to preview for conversation-and-files rewind.
6364    ///
6365    /// # Returns
6366    ///
6367    /// Files and aggregate changes for a prospective rewind.
6368    ///
6369    /// <div class="warning">
6370    ///
6371    /// **Experimental.** This API is part of an experimental wire-protocol surface
6372    /// and may change or be removed in future SDK or CLI releases. Pin both the
6373    /// SDK and CLI versions if your code depends on it.
6374    ///
6375    /// </div>
6376    pub async fn preview_rewind(
6377        &self,
6378        params: HistoryPreviewRewindRequest,
6379    ) -> Result<HistoryPreviewRewindResult, Error> {
6380        let mut wire_params = serde_json::to_value(params)?;
6381        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6382        let _value = self
6383            .session
6384            .client()
6385            .call(
6386                rpc_methods::SESSION_HISTORY_PREVIEWREWIND,
6387                Some(wire_params),
6388            )
6389            .await?;
6390        Ok(serde_json::from_value(_value)?)
6391    }
6392
6393    /// 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.
6394    ///
6395    /// Wire method: `session.history.rewind`.
6396    ///
6397    /// # Parameters
6398    ///
6399    /// * `params` - Boundary and mode for rewinding session history.
6400    ///
6401    /// # Returns
6402    ///
6403    /// Structured outcome of a rewind request.
6404    ///
6405    /// <div class="warning">
6406    ///
6407    /// **Experimental.** This API is part of an experimental wire-protocol surface
6408    /// and may change or be removed in future SDK or CLI releases. Pin both the
6409    /// SDK and CLI versions if your code depends on it.
6410    ///
6411    /// </div>
6412    pub async fn rewind(&self, params: HistoryRewindRequest) -> Result<HistoryRewindResult, Error> {
6413        let mut wire_params = serde_json::to_value(params)?;
6414        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6415        let _value = self
6416            .session
6417            .client()
6418            .call(rpc_methods::SESSION_HISTORY_REWIND, Some(wire_params))
6419            .await?;
6420        Ok(serde_json::from_value(_value)?)
6421    }
6422
6423    /// Cancels any in-progress background compaction on a local session.
6424    ///
6425    /// Wire method: `session.history.cancelBackgroundCompaction`.
6426    ///
6427    /// # Returns
6428    ///
6429    /// Indicates whether an in-progress background compaction was cancelled.
6430    ///
6431    /// <div class="warning">
6432    ///
6433    /// **Experimental.** This API is part of an experimental wire-protocol surface
6434    /// and may change or be removed in future SDK or CLI releases. Pin both the
6435    /// SDK and CLI versions if your code depends on it.
6436    ///
6437    /// </div>
6438    pub async fn cancel_background_compaction(
6439        &self,
6440    ) -> Result<HistoryCancelBackgroundCompactionResult, Error> {
6441        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6442        let _value = self
6443            .session
6444            .client()
6445            .call(
6446                rpc_methods::SESSION_HISTORY_CANCELBACKGROUNDCOMPACTION,
6447                Some(wire_params),
6448            )
6449            .await?;
6450        Ok(serde_json::from_value(_value)?)
6451    }
6452
6453    /// Aborts any in-progress manual compaction on a local session.
6454    ///
6455    /// Wire method: `session.history.abortManualCompaction`.
6456    ///
6457    /// # Returns
6458    ///
6459    /// Indicates whether an in-progress manual compaction was aborted.
6460    ///
6461    /// <div class="warning">
6462    ///
6463    /// **Experimental.** This API is part of an experimental wire-protocol surface
6464    /// and may change or be removed in future SDK or CLI releases. Pin both the
6465    /// SDK and CLI versions if your code depends on it.
6466    ///
6467    /// </div>
6468    pub async fn abort_manual_compaction(
6469        &self,
6470    ) -> Result<HistoryAbortManualCompactionResult, Error> {
6471        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6472        let _value = self
6473            .session
6474            .client()
6475            .call(
6476                rpc_methods::SESSION_HISTORY_ABORTMANUALCOMPACTION,
6477                Some(wire_params),
6478            )
6479            .await?;
6480        Ok(serde_json::from_value(_value)?)
6481    }
6482
6483    /// Produces a markdown summary of the session's conversation context for hand-off scenarios.
6484    ///
6485    /// Wire method: `session.history.summarizeForHandoff`.
6486    ///
6487    /// # Returns
6488    ///
6489    /// Markdown summary of the conversation context (empty when not available).
6490    ///
6491    /// <div class="warning">
6492    ///
6493    /// **Experimental.** This API is part of an experimental wire-protocol surface
6494    /// and may change or be removed in future SDK or CLI releases. Pin both the
6495    /// SDK and CLI versions if your code depends on it.
6496    ///
6497    /// </div>
6498    pub async fn summarize_for_handoff(&self) -> Result<HistorySummarizeForHandoffResult, Error> {
6499        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6500        let _value = self
6501            .session
6502            .client()
6503            .call(
6504                rpc_methods::SESSION_HISTORY_SUMMARIZEFORHANDOFF,
6505                Some(wire_params),
6506            )
6507            .await?;
6508        Ok(serde_json::from_value(_value)?)
6509    }
6510
6511    /// 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.
6512    ///
6513    /// Wire method: `session.history.clearContext`.
6514    ///
6515    /// # Parameters
6516    ///
6517    /// * `params` - Parameters for clearing the conversation and seeding the window that replaces it.
6518    ///
6519    /// # Returns
6520    ///
6521    /// What a successful clear removed. A clear that could not be applied rejects instead of reporting a count.
6522    ///
6523    /// <div class="warning">
6524    ///
6525    /// **Experimental.** This API is part of an experimental wire-protocol surface
6526    /// and may change or be removed in future SDK or CLI releases. Pin both the
6527    /// SDK and CLI versions if your code depends on it.
6528    ///
6529    /// </div>
6530    pub async fn clear_context(
6531        &self,
6532        params: HistoryClearContextRequest,
6533    ) -> Result<HistoryClearContextResult, Error> {
6534        let mut wire_params = serde_json::to_value(params)?;
6535        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6536        let _value = self
6537            .session
6538            .client()
6539            .call(rpc_methods::SESSION_HISTORY_CLEARCONTEXT, Some(wire_params))
6540            .await?;
6541        Ok(serde_json::from_value(_value)?)
6542    }
6543}
6544
6545/// `session.instructions.*` RPCs.
6546#[derive(Clone, Copy)]
6547pub struct SessionRpcInstructions<'a> {
6548    pub(crate) session: &'a Session,
6549}
6550
6551impl<'a> SessionRpcInstructions<'a> {
6552    /// Gets instruction sources loaded for the session.
6553    ///
6554    /// Wire method: `session.instructions.getSources`.
6555    ///
6556    /// # Returns
6557    ///
6558    /// Instruction sources loaded for the session, in merge order.
6559    ///
6560    /// <div class="warning">
6561    ///
6562    /// **Experimental.** This API is part of an experimental wire-protocol surface
6563    /// and may change or be removed in future SDK or CLI releases. Pin both the
6564    /// SDK and CLI versions if your code depends on it.
6565    ///
6566    /// </div>
6567    pub async fn get_sources(&self) -> Result<InstructionsGetSourcesResult, Error> {
6568        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6569        let _value = self
6570            .session
6571            .client()
6572            .call(
6573                rpc_methods::SESSION_INSTRUCTIONS_GETSOURCES,
6574                Some(wire_params),
6575            )
6576            .await?;
6577        Ok(serde_json::from_value(_value)?)
6578    }
6579
6580    /// Invalidates cached custom-instruction discovery so subsequent turns and source reads observe instruction files currently on disk.
6581    ///
6582    /// Wire method: `session.instructions.reload`.
6583    ///
6584    /// <div class="warning">
6585    ///
6586    /// **Experimental.** This API is part of an experimental wire-protocol surface
6587    /// and may change or be removed in future SDK or CLI releases. Pin both the
6588    /// SDK and CLI versions if your code depends on it.
6589    ///
6590    /// </div>
6591    pub async fn reload(&self) -> Result<(), Error> {
6592        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6593        let _value = self
6594            .session
6595            .client()
6596            .call(rpc_methods::SESSION_INSTRUCTIONS_RELOAD, Some(wire_params))
6597            .await?;
6598        Ok(())
6599    }
6600}
6601
6602/// `session.limitPrediction.*` RPCs.
6603#[derive(Clone, Copy)]
6604pub struct SessionRpcLimitPrediction<'a> {
6605    pub(crate) session: &'a Session,
6606}
6607
6608impl<'a> SessionRpcLimitPrediction<'a> {
6609    /// 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.
6610    ///
6611    /// Wire method: `session.limitPrediction.predict`.
6612    ///
6613    /// # Returns
6614    ///
6615    /// Prediction result. Available results include prediction details; unavailable results include an explicit reason.
6616    ///
6617    /// <div class="warning">
6618    ///
6619    /// **Experimental.** This API is part of an experimental wire-protocol surface
6620    /// and may change or be removed in future SDK or CLI releases. Pin both the
6621    /// SDK and CLI versions if your code depends on it.
6622    ///
6623    /// </div>
6624    pub async fn predict(&self) -> Result<SessionLimitPredictionResult, Error> {
6625        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6626        let _value = self
6627            .session
6628            .client()
6629            .call(
6630                rpc_methods::SESSION_LIMITPREDICTION_PREDICT,
6631                Some(wire_params),
6632            )
6633            .await?;
6634        Ok(serde_json::from_value(_value)?)
6635    }
6636
6637    /// 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.
6638    ///
6639    /// Wire method: `session.limitPrediction.predict`.
6640    ///
6641    /// # Parameters
6642    ///
6643    /// * `params` - Parameters for predicting an AI-credit session limit. Omitting `modelId` uses the session's currently selected model.
6644    ///
6645    /// # Returns
6646    ///
6647    /// Prediction result. Available results include prediction details; unavailable results include an explicit reason.
6648    ///
6649    /// <div class="warning">
6650    ///
6651    /// **Experimental.** This API is part of an experimental wire-protocol surface
6652    /// and may change or be removed in future SDK or CLI releases. Pin both the
6653    /// SDK and CLI versions if your code depends on it.
6654    ///
6655    /// </div>
6656    pub async fn predict_with_params(
6657        &self,
6658        params: SessionLimitPredictionRequest,
6659    ) -> Result<SessionLimitPredictionResult, Error> {
6660        let mut wire_params = serde_json::to_value(params)?;
6661        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6662        let _value = self
6663            .session
6664            .client()
6665            .call(
6666                rpc_methods::SESSION_LIMITPREDICTION_PREDICT,
6667                Some(wire_params),
6668            )
6669            .await?;
6670        Ok(serde_json::from_value(_value)?)
6671    }
6672}
6673
6674/// `session.lsp.*` RPCs.
6675#[derive(Clone, Copy)]
6676pub struct SessionRpcLsp<'a> {
6677    pub(crate) session: &'a Session,
6678}
6679
6680impl<'a> SessionRpcLsp<'a> {
6681    /// Loads the merged LSP configuration set for the session's working directory.
6682    ///
6683    /// Wire method: `session.lsp.initialize`.
6684    ///
6685    /// # Parameters
6686    ///
6687    /// * `params` - Parameters for (re)loading the merged LSP configuration set.
6688    ///
6689    /// <div class="warning">
6690    ///
6691    /// **Experimental.** This API is part of an experimental wire-protocol surface
6692    /// and may change or be removed in future SDK or CLI releases. Pin both the
6693    /// SDK and CLI versions if your code depends on it.
6694    ///
6695    /// </div>
6696    pub async fn initialize(&self, params: LspInitializeRequest) -> Result<(), Error> {
6697        let mut wire_params = serde_json::to_value(params)?;
6698        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6699        let _value = self
6700            .session
6701            .client()
6702            .call(rpc_methods::SESSION_LSP_INITIALIZE, Some(wire_params))
6703            .await?;
6704        Ok(())
6705    }
6706}
6707
6708/// `session.managedSettings.*` RPCs.
6709#[derive(Clone, Copy)]
6710pub struct SessionRpcManagedSettings<'a> {
6711    pub(crate) session: &'a Session,
6712}
6713
6714impl<'a> SessionRpcManagedSettings<'a> {
6715    /// 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.
6716    ///
6717    /// Wire method: `session.managedSettings.get`.
6718    ///
6719    /// # Returns
6720    ///
6721    /// 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.
6722    ///
6723    /// <div class="warning">
6724    ///
6725    /// **Experimental.** This API is part of an experimental wire-protocol surface
6726    /// and may change or be removed in future SDK or CLI releases. Pin both the
6727    /// SDK and CLI versions if your code depends on it.
6728    ///
6729    /// </div>
6730    pub async fn get(&self) -> Result<ManagedSettingsResolvedData, Error> {
6731        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6732        let _value = self
6733            .session
6734            .client()
6735            .call(rpc_methods::SESSION_MANAGEDSETTINGS_GET, Some(wire_params))
6736            .await?;
6737        Ok(serde_json::from_value(_value)?)
6738    }
6739}
6740
6741/// `session.mcp.*` RPCs.
6742#[derive(Clone, Copy)]
6743pub struct SessionRpcMcp<'a> {
6744    pub(crate) session: &'a Session,
6745}
6746
6747impl<'a> SessionRpcMcp<'a> {
6748    /// `session.mcp.apps.*` sub-namespace.
6749    pub fn apps(&self) -> SessionRpcMcpApps<'a> {
6750        SessionRpcMcpApps {
6751            session: self.session,
6752        }
6753    }
6754
6755    /// `session.mcp.headers.*` sub-namespace.
6756    pub fn headers(&self) -> SessionRpcMcpHeaders<'a> {
6757        SessionRpcMcpHeaders {
6758            session: self.session,
6759        }
6760    }
6761
6762    /// `session.mcp.oauth.*` sub-namespace.
6763    pub fn oauth(&self) -> SessionRpcMcpOauth<'a> {
6764        SessionRpcMcpOauth {
6765            session: self.session,
6766        }
6767    }
6768
6769    /// `session.mcp.resources.*` sub-namespace.
6770    pub fn resources(&self) -> SessionRpcMcpResources<'a> {
6771        SessionRpcMcpResources {
6772            session: self.session,
6773        }
6774    }
6775
6776    /// 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.
6777    ///
6778    /// Wire method: `session.mcp.list`.
6779    ///
6780    /// # Returns
6781    ///
6782    /// MCP servers configured for the session, with their connection status and host-level state.
6783    ///
6784    /// <div class="warning">
6785    ///
6786    /// **Experimental.** This API is part of an experimental wire-protocol surface
6787    /// and may change or be removed in future SDK or CLI releases. Pin both the
6788    /// SDK and CLI versions if your code depends on it.
6789    ///
6790    /// </div>
6791    pub async fn list(&self) -> Result<McpServerList, Error> {
6792        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6793        let _value = self
6794            .session
6795            .client()
6796            .call(rpc_methods::SESSION_MCP_LIST, Some(wire_params))
6797            .await?;
6798        Ok(serde_json::from_value(_value)?)
6799    }
6800
6801    /// 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.
6802    ///
6803    /// Wire method: `session.mcp.listTools`.
6804    ///
6805    /// # Parameters
6806    ///
6807    /// * `params` - Server name whose tool list should be returned.
6808    ///
6809    /// # Returns
6810    ///
6811    /// Tools exposed by the connected MCP server. Throws when the server is not connected.
6812    ///
6813    /// <div class="warning">
6814    ///
6815    /// **Experimental.** This API is part of an experimental wire-protocol surface
6816    /// and may change or be removed in future SDK or CLI releases. Pin both the
6817    /// SDK and CLI versions if your code depends on it.
6818    ///
6819    /// </div>
6820    pub async fn list_tools(
6821        &self,
6822        params: McpListToolsRequest,
6823    ) -> Result<McpListToolsResult, Error> {
6824        let mut wire_params = serde_json::to_value(params)?;
6825        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6826        let _value = self
6827            .session
6828            .client()
6829            .call(rpc_methods::SESSION_MCP_LISTTOOLS, Some(wire_params))
6830            .await?;
6831        Ok(serde_json::from_value(_value)?)
6832    }
6833
6834    /// Enables an MCP server for the session.
6835    ///
6836    /// Wire method: `session.mcp.enable`.
6837    ///
6838    /// # Parameters
6839    ///
6840    /// * `params` - Name of the MCP server to enable for the session.
6841    ///
6842    /// <div class="warning">
6843    ///
6844    /// **Experimental.** This API is part of an experimental wire-protocol surface
6845    /// and may change or be removed in future SDK or CLI releases. Pin both the
6846    /// SDK and CLI versions if your code depends on it.
6847    ///
6848    /// </div>
6849    pub async fn enable(&self, params: McpEnableRequest) -> Result<(), Error> {
6850        let mut wire_params = serde_json::to_value(params)?;
6851        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6852        let _value = self
6853            .session
6854            .client()
6855            .call(rpc_methods::SESSION_MCP_ENABLE, Some(wire_params))
6856            .await?;
6857        Ok(())
6858    }
6859
6860    /// Disables an MCP server for the session.
6861    ///
6862    /// Wire method: `session.mcp.disable`.
6863    ///
6864    /// # Parameters
6865    ///
6866    /// * `params` - Name of the MCP server to disable for the session.
6867    ///
6868    /// <div class="warning">
6869    ///
6870    /// **Experimental.** This API is part of an experimental wire-protocol surface
6871    /// and may change or be removed in future SDK or CLI releases. Pin both the
6872    /// SDK and CLI versions if your code depends on it.
6873    ///
6874    /// </div>
6875    pub async fn disable(&self, params: McpDisableRequest) -> Result<(), Error> {
6876        let mut wire_params = serde_json::to_value(params)?;
6877        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6878        let _value = self
6879            .session
6880            .client()
6881            .call(rpc_methods::SESSION_MCP_DISABLE, Some(wire_params))
6882            .await?;
6883        Ok(())
6884    }
6885
6886    /// Reloads MCP server connections for the session.
6887    ///
6888    /// Wire method: `session.mcp.reload`.
6889    ///
6890    /// <div class="warning">
6891    ///
6892    /// **Experimental.** This API is part of an experimental wire-protocol surface
6893    /// and may change or be removed in future SDK or CLI releases. Pin both the
6894    /// SDK and CLI versions if your code depends on it.
6895    ///
6896    /// </div>
6897    pub async fn reload(&self) -> Result<(), Error> {
6898        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6899        let _value = self
6900            .session
6901            .client()
6902            .call(rpc_methods::SESSION_MCP_RELOAD, Some(wire_params))
6903            .await?;
6904        Ok(())
6905    }
6906
6907    /// 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.
6908    ///
6909    /// Wire method: `session.mcp.moveLoadingToBackground`.
6910    ///
6911    /// # Returns
6912    ///
6913    /// Result of moving in-flight MCP loading to the background.
6914    ///
6915    /// <div class="warning">
6916    ///
6917    /// **Experimental.** This API is part of an experimental wire-protocol surface
6918    /// and may change or be removed in future SDK or CLI releases. Pin both the
6919    /// SDK and CLI versions if your code depends on it.
6920    ///
6921    /// </div>
6922    pub async fn move_loading_to_background(
6923        &self,
6924    ) -> Result<MoveMcpLoadingToBackgroundResult, Error> {
6925        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6926        let _value = self
6927            .session
6928            .client()
6929            .call(
6930                rpc_methods::SESSION_MCP_MOVELOADINGTOBACKGROUND,
6931                Some(wire_params),
6932            )
6933            .await?;
6934        Ok(serde_json::from_value(_value)?)
6935    }
6936
6937    /// Reloads MCP server connections for the session with an explicit host-provided configuration.
6938    ///
6939    /// Wire method: `session.mcp.reloadWithConfig`.
6940    ///
6941    /// # Parameters
6942    ///
6943    /// * `params` - Opaque MCP reload configuration.
6944    ///
6945    /// # Returns
6946    ///
6947    /// MCP server startup filtering result.
6948    ///
6949    /// <div class="warning">
6950    ///
6951    /// **Experimental.** This API is part of an experimental wire-protocol surface
6952    /// and may change or be removed in future SDK or CLI releases. Pin both the
6953    /// SDK and CLI versions if your code depends on it.
6954    ///
6955    /// </div>
6956    pub(crate) async fn reload_with_config(
6957        &self,
6958        params: McpReloadWithConfigRequest,
6959    ) -> Result<McpStartServersResult, Error> {
6960        let mut wire_params = serde_json::to_value(params)?;
6961        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6962        let _value = self
6963            .session
6964            .client()
6965            .call(rpc_methods::SESSION_MCP_RELOADWITHCONFIG, Some(wire_params))
6966            .await?;
6967        Ok(serde_json::from_value(_value)?)
6968    }
6969
6970    /// Runs an MCP sampling inference on behalf of an MCP server.
6971    ///
6972    /// Wire method: `session.mcp.executeSampling`.
6973    ///
6974    /// # Parameters
6975    ///
6976    /// * `params` - Identifiers and raw MCP CreateMessageRequest params used to run a sampling inference.
6977    ///
6978    /// # Returns
6979    ///
6980    /// Outcome of an MCP sampling execution: success result, failure error, or cancellation.
6981    ///
6982    /// <div class="warning">
6983    ///
6984    /// **Experimental.** This API is part of an experimental wire-protocol surface
6985    /// and may change or be removed in future SDK or CLI releases. Pin both the
6986    /// SDK and CLI versions if your code depends on it.
6987    ///
6988    /// </div>
6989    pub async fn execute_sampling(
6990        &self,
6991        params: McpExecuteSamplingParams,
6992    ) -> Result<McpSamplingExecutionResult, Error> {
6993        let mut wire_params = serde_json::to_value(params)?;
6994        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6995        let _value = self
6996            .session
6997            .client()
6998            .call(rpc_methods::SESSION_MCP_EXECUTESAMPLING, Some(wire_params))
6999            .await?;
7000        Ok(serde_json::from_value(_value)?)
7001    }
7002
7003    /// Cancels an in-flight MCP sampling execution by request ID.
7004    ///
7005    /// Wire method: `session.mcp.cancelSamplingExecution`.
7006    ///
7007    /// # Parameters
7008    ///
7009    /// * `params` - The requestId previously passed to executeSampling that should be cancelled.
7010    ///
7011    /// # Returns
7012    ///
7013    /// Indicates whether an in-flight sampling execution with the given requestId was found and cancelled.
7014    ///
7015    /// <div class="warning">
7016    ///
7017    /// **Experimental.** This API is part of an experimental wire-protocol surface
7018    /// and may change or be removed in future SDK or CLI releases. Pin both the
7019    /// SDK and CLI versions if your code depends on it.
7020    ///
7021    /// </div>
7022    pub async fn cancel_sampling_execution(
7023        &self,
7024        params: McpCancelSamplingExecutionParams,
7025    ) -> Result<McpCancelSamplingExecutionResult, Error> {
7026        let mut wire_params = serde_json::to_value(params)?;
7027        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7028        let _value = self
7029            .session
7030            .client()
7031            .call(
7032                rpc_methods::SESSION_MCP_CANCELSAMPLINGEXECUTION,
7033                Some(wire_params),
7034            )
7035            .await?;
7036        Ok(serde_json::from_value(_value)?)
7037    }
7038
7039    /// Sets how environment-variable values supplied to MCP servers are resolved (direct or indirect).
7040    ///
7041    /// Wire method: `session.mcp.setEnvValueMode`.
7042    ///
7043    /// # Parameters
7044    ///
7045    /// * `params` - Mode controlling how MCP server env values are resolved (`direct` or `indirect`).
7046    ///
7047    /// # Returns
7048    ///
7049    /// Env-value mode recorded on the session after the update.
7050    ///
7051    /// <div class="warning">
7052    ///
7053    /// **Experimental.** This API is part of an experimental wire-protocol surface
7054    /// and may change or be removed in future SDK or CLI releases. Pin both the
7055    /// SDK and CLI versions if your code depends on it.
7056    ///
7057    /// </div>
7058    pub async fn set_env_value_mode(
7059        &self,
7060        params: McpSetEnvValueModeParams,
7061    ) -> Result<McpSetEnvValueModeResult, Error> {
7062        let mut wire_params = serde_json::to_value(params)?;
7063        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7064        let _value = self
7065            .session
7066            .client()
7067            .call(rpc_methods::SESSION_MCP_SETENVVALUEMODE, Some(wire_params))
7068            .await?;
7069        Ok(serde_json::from_value(_value)?)
7070    }
7071
7072    /// Removes the auto-managed `github` MCP server when present.
7073    ///
7074    /// Wire method: `session.mcp.removeGitHub`.
7075    ///
7076    /// # Returns
7077    ///
7078    /// Indicates whether the auto-managed `github` MCP server was removed (false when nothing to remove).
7079    ///
7080    /// <div class="warning">
7081    ///
7082    /// **Experimental.** This API is part of an experimental wire-protocol surface
7083    /// and may change or be removed in future SDK or CLI releases. Pin both the
7084    /// SDK and CLI versions if your code depends on it.
7085    ///
7086    /// </div>
7087    pub async fn remove_git_hub(&self) -> Result<McpRemoveGitHubResult, Error> {
7088        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7089        let _value = self
7090            .session
7091            .client()
7092            .call(rpc_methods::SESSION_MCP_REMOVEGITHUB, Some(wire_params))
7093            .await?;
7094        Ok(serde_json::from_value(_value)?)
7095    }
7096
7097    /// Configures the built-in GitHub MCP server for the session's current auth context.
7098    ///
7099    /// Wire method: `session.mcp.configureGitHub`.
7100    ///
7101    /// # Parameters
7102    ///
7103    /// * `params` - Credential-free authentication identity used to configure GitHub MCP.
7104    ///
7105    /// # Returns
7106    ///
7107    /// Result of configuring GitHub MCP.
7108    ///
7109    /// <div class="warning">
7110    ///
7111    /// **Experimental.** This API is part of an experimental wire-protocol surface
7112    /// and may change or be removed in future SDK or CLI releases. Pin both the
7113    /// SDK and CLI versions if your code depends on it.
7114    ///
7115    /// </div>
7116    pub(crate) async fn configure_git_hub(
7117        &self,
7118        params: McpConfigureGitHubRequest,
7119    ) -> Result<McpConfigureGitHubResult, Error> {
7120        let mut wire_params = serde_json::to_value(params)?;
7121        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7122        let _value = self
7123            .session
7124            .client()
7125            .call(rpc_methods::SESSION_MCP_CONFIGUREGITHUB, Some(wire_params))
7126            .await?;
7127        Ok(serde_json::from_value(_value)?)
7128    }
7129
7130    /// 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.
7131    ///
7132    /// Wire method: `session.mcp.startServer`.
7133    ///
7134    /// # Parameters
7135    ///
7136    /// * `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.
7137    ///
7138    /// <div class="warning">
7139    ///
7140    /// **Experimental.** This API is part of an experimental wire-protocol surface
7141    /// and may change or be removed in future SDK or CLI releases. Pin both the
7142    /// SDK and CLI versions if your code depends on it.
7143    ///
7144    /// </div>
7145    pub async fn start_server(&self, params: McpStartServerRequest) -> Result<(), Error> {
7146        let mut wire_params = serde_json::to_value(params)?;
7147        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7148        let _value = self
7149            .session
7150            .client()
7151            .call(rpc_methods::SESSION_MCP_STARTSERVER, Some(wire_params))
7152            .await?;
7153        Ok(())
7154    }
7155
7156    /// 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.*`).
7157    ///
7158    /// Wire method: `session.mcp.restartServer`.
7159    ///
7160    /// # Parameters
7161    ///
7162    /// * `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.
7163    ///
7164    /// <div class="warning">
7165    ///
7166    /// **Experimental.** This API is part of an experimental wire-protocol surface
7167    /// and may change or be removed in future SDK or CLI releases. Pin both the
7168    /// SDK and CLI versions if your code depends on it.
7169    ///
7170    /// </div>
7171    pub async fn restart_server(&self, params: McpRestartServerRequest) -> Result<(), Error> {
7172        let mut wire_params = serde_json::to_value(params)?;
7173        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7174        let _value = self
7175            .session
7176            .client()
7177            .call(rpc_methods::SESSION_MCP_RESTARTSERVER, Some(wire_params))
7178            .await?;
7179        Ok(())
7180    }
7181
7182    /// Stops an individual MCP server on the session's host.
7183    ///
7184    /// Wire method: `session.mcp.stopServer`.
7185    ///
7186    /// # Parameters
7187    ///
7188    /// * `params` - Server name for an individual MCP server stop.
7189    ///
7190    /// <div class="warning">
7191    ///
7192    /// **Experimental.** This API is part of an experimental wire-protocol surface
7193    /// and may change or be removed in future SDK or CLI releases. Pin both the
7194    /// SDK and CLI versions if your code depends on it.
7195    ///
7196    /// </div>
7197    pub async fn stop_server(&self, params: McpStopServerRequest) -> Result<(), Error> {
7198        let mut wire_params = serde_json::to_value(params)?;
7199        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7200        let _value = self
7201            .session
7202            .client()
7203            .call(rpc_methods::SESSION_MCP_STOPSERVER, Some(wire_params))
7204            .await?;
7205        Ok(())
7206    }
7207
7208    /// 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.
7209    ///
7210    /// Wire method: `session.mcp.registerExternalClient`.
7211    ///
7212    /// # Parameters
7213    ///
7214    /// * `params` - Registration parameters for an external MCP client.
7215    ///
7216    /// <div class="warning">
7217    ///
7218    /// **Experimental.** This API is part of an experimental wire-protocol surface
7219    /// and may change or be removed in future SDK or CLI releases. Pin both the
7220    /// SDK and CLI versions if your code depends on it.
7221    ///
7222    /// </div>
7223    pub(crate) async fn register_external_client(
7224        &self,
7225        params: McpRegisterExternalClientRequest,
7226    ) -> Result<(), Error> {
7227        let mut wire_params = serde_json::to_value(params)?;
7228        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7229        let _value = self
7230            .session
7231            .client()
7232            .call(
7233                rpc_methods::SESSION_MCP_REGISTEREXTERNALCLIENT,
7234                Some(wire_params),
7235            )
7236            .await?;
7237        Ok(())
7238    }
7239
7240    /// 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.
7241    ///
7242    /// Wire method: `session.mcp.unregisterExternalClient`.
7243    ///
7244    /// # Parameters
7245    ///
7246    /// * `params` - Server name identifying the external client to remove.
7247    ///
7248    /// <div class="warning">
7249    ///
7250    /// **Experimental.** This API is part of an experimental wire-protocol surface
7251    /// and may change or be removed in future SDK or CLI releases. Pin both the
7252    /// SDK and CLI versions if your code depends on it.
7253    ///
7254    /// </div>
7255    pub(crate) async fn unregister_external_client(
7256        &self,
7257        params: McpUnregisterExternalClientRequest,
7258    ) -> Result<(), Error> {
7259        let mut wire_params = serde_json::to_value(params)?;
7260        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7261        let _value = self
7262            .session
7263            .client()
7264            .call(
7265                rpc_methods::SESSION_MCP_UNREGISTEREXTERNALCLIENT,
7266                Some(wire_params),
7267            )
7268            .await?;
7269        Ok(())
7270    }
7271
7272    /// Checks whether a named MCP server is currently running on the session's host.
7273    ///
7274    /// Wire method: `session.mcp.isServerRunning`.
7275    ///
7276    /// # Parameters
7277    ///
7278    /// * `params` - Server name to check running status for.
7279    ///
7280    /// # Returns
7281    ///
7282    /// Whether the named MCP server is running.
7283    ///
7284    /// <div class="warning">
7285    ///
7286    /// **Experimental.** This API is part of an experimental wire-protocol surface
7287    /// and may change or be removed in future SDK or CLI releases. Pin both the
7288    /// SDK and CLI versions if your code depends on it.
7289    ///
7290    /// </div>
7291    pub async fn is_server_running(
7292        &self,
7293        params: McpIsServerRunningRequest,
7294    ) -> Result<McpIsServerRunningResult, Error> {
7295        let mut wire_params = serde_json::to_value(params)?;
7296        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7297        let _value = self
7298            .session
7299            .client()
7300            .call(rpc_methods::SESSION_MCP_ISSERVERRUNNING, Some(wire_params))
7301            .await?;
7302        Ok(serde_json::from_value(_value)?)
7303    }
7304}
7305
7306/// `session.mcp.apps.*` RPCs.
7307#[derive(Clone, Copy)]
7308pub struct SessionRpcMcpApps<'a> {
7309    pub(crate) session: &'a Session,
7310}
7311
7312impl<'a> SessionRpcMcpApps<'a> {
7313    /// Fetch an MCP resource (typically a `ui://` MCP App bundle, per SEP-1865) from a connected server. Requires the `mcp-apps` session capability.
7314    ///
7315    /// Wire method: `session.mcp.apps.readResource`.
7316    ///
7317    /// # Parameters
7318    ///
7319    /// * `params` - MCP server and resource URI to fetch.
7320    ///
7321    /// # Returns
7322    ///
7323    /// Resource contents returned by the MCP server.
7324    ///
7325    /// <div class="warning">
7326    ///
7327    /// **Experimental.** This API is part of an experimental wire-protocol surface
7328    /// and may change or be removed in future SDK or CLI releases. Pin both the
7329    /// SDK and CLI versions if your code depends on it.
7330    ///
7331    /// </div>
7332    pub async fn read_resource(
7333        &self,
7334        params: McpAppsReadResourceRequest,
7335    ) -> Result<McpAppsReadResourceResult, Error> {
7336        let mut wire_params = serde_json::to_value(params)?;
7337        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7338        let _value = self
7339            .session
7340            .client()
7341            .call(
7342                rpc_methods::SESSION_MCP_APPS_READRESOURCE,
7343                Some(wire_params),
7344            )
7345            .await?;
7346        Ok(serde_json::from_value(_value)?)
7347    }
7348
7349    /// 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"`.
7350    ///
7351    /// Wire method: `session.mcp.apps.listTools`.
7352    ///
7353    /// # Parameters
7354    ///
7355    /// * `params` - MCP server to list app-callable tools for.
7356    ///
7357    /// # Returns
7358    ///
7359    /// App-callable tools from the named MCP server.
7360    ///
7361    /// <div class="warning">
7362    ///
7363    /// **Experimental.** This API is part of an experimental wire-protocol surface
7364    /// and may change or be removed in future SDK or CLI releases. Pin both the
7365    /// SDK and CLI versions if your code depends on it.
7366    ///
7367    /// </div>
7368    pub async fn list_tools(
7369        &self,
7370        params: McpAppsListToolsRequest,
7371    ) -> Result<McpAppsListToolsResult, Error> {
7372        let mut wire_params = serde_json::to_value(params)?;
7373        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7374        let _value = self
7375            .session
7376            .client()
7377            .call(rpc_methods::SESSION_MCP_APPS_LISTTOOLS, Some(wire_params))
7378            .await?;
7379        Ok(serde_json::from_value(_value)?)
7380    }
7381
7382    /// 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`.
7383    ///
7384    /// Wire method: `session.mcp.apps.callTool`.
7385    ///
7386    /// # Parameters
7387    ///
7388    /// * `params` - MCP server, tool name, and arguments to invoke from an MCP App view.
7389    ///
7390    /// # Returns
7391    ///
7392    /// Standard MCP CallToolResult
7393    ///
7394    /// <div class="warning">
7395    ///
7396    /// **Experimental.** This API is part of an experimental wire-protocol surface
7397    /// and may change or be removed in future SDK or CLI releases. Pin both the
7398    /// SDK and CLI versions if your code depends on it.
7399    ///
7400    /// </div>
7401    pub async fn call_tool(
7402        &self,
7403        params: McpAppsCallToolRequest,
7404    ) -> Result<SessionMcpAppsCallToolResult, Error> {
7405        let mut wire_params = serde_json::to_value(params)?;
7406        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7407        let _value = self
7408            .session
7409            .client()
7410            .call(rpc_methods::SESSION_MCP_APPS_CALLTOOL, Some(wire_params))
7411            .await?;
7412        Ok(serde_json::from_value(_value)?)
7413    }
7414
7415    /// 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.
7416    ///
7417    /// Wire method: `session.mcp.apps.setHostContext`.
7418    ///
7419    /// # Parameters
7420    ///
7421    /// * `params` - Host context to advertise to MCP App guests.
7422    ///
7423    /// <div class="warning">
7424    ///
7425    /// **Experimental.** This API is part of an experimental wire-protocol surface
7426    /// and may change or be removed in future SDK or CLI releases. Pin both the
7427    /// SDK and CLI versions if your code depends on it.
7428    ///
7429    /// </div>
7430    pub async fn set_host_context(
7431        &self,
7432        params: McpAppsSetHostContextRequest,
7433    ) -> Result<(), Error> {
7434        let mut wire_params = serde_json::to_value(params)?;
7435        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7436        let _value = self
7437            .session
7438            .client()
7439            .call(
7440                rpc_methods::SESSION_MCP_APPS_SETHOSTCONTEXT,
7441                Some(wire_params),
7442            )
7443            .await?;
7444        Ok(())
7445    }
7446
7447    /// Read the current host context advertised to MCP App guests.
7448    ///
7449    /// Wire method: `session.mcp.apps.getHostContext`.
7450    ///
7451    /// # Returns
7452    ///
7453    /// Current host context advertised to MCP App guests.
7454    ///
7455    /// <div class="warning">
7456    ///
7457    /// **Experimental.** This API is part of an experimental wire-protocol surface
7458    /// and may change or be removed in future SDK or CLI releases. Pin both the
7459    /// SDK and CLI versions if your code depends on it.
7460    ///
7461    /// </div>
7462    pub async fn get_host_context(&self) -> Result<McpAppsHostContext, Error> {
7463        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7464        let _value = self
7465            .session
7466            .client()
7467            .call(
7468                rpc_methods::SESSION_MCP_APPS_GETHOSTCONTEXT,
7469                Some(wire_params),
7470            )
7471            .await?;
7472        Ok(serde_json::from_value(_value)?)
7473    }
7474
7475    /// 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.
7476    ///
7477    /// Wire method: `session.mcp.apps.diagnose`.
7478    ///
7479    /// # Parameters
7480    ///
7481    /// * `params` - MCP server to diagnose MCP Apps wiring for.
7482    ///
7483    /// # Returns
7484    ///
7485    /// Diagnostic snapshot of MCP Apps wiring for the named server.
7486    ///
7487    /// <div class="warning">
7488    ///
7489    /// **Experimental.** This API is part of an experimental wire-protocol surface
7490    /// and may change or be removed in future SDK or CLI releases. Pin both the
7491    /// SDK and CLI versions if your code depends on it.
7492    ///
7493    /// </div>
7494    pub async fn diagnose(
7495        &self,
7496        params: McpAppsDiagnoseRequest,
7497    ) -> Result<McpAppsDiagnoseResult, Error> {
7498        let mut wire_params = serde_json::to_value(params)?;
7499        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7500        let _value = self
7501            .session
7502            .client()
7503            .call(rpc_methods::SESSION_MCP_APPS_DIAGNOSE, Some(wire_params))
7504            .await?;
7505        Ok(serde_json::from_value(_value)?)
7506    }
7507}
7508
7509/// `session.mcp.headers.*` RPCs.
7510#[derive(Clone, Copy)]
7511pub struct SessionRpcMcpHeaders<'a> {
7512    pub(crate) session: &'a Session,
7513}
7514
7515impl<'a> SessionRpcMcpHeaders<'a> {
7516    /// 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.
7517    ///
7518    /// Wire method: `session.mcp.headers.handlePendingHeadersRefreshRequest`.
7519    ///
7520    /// # Parameters
7521    ///
7522    /// * `params` - MCP headers refresh request id and the host response.
7523    ///
7524    /// # Returns
7525    ///
7526    /// Indicates whether the pending MCP headers refresh response was accepted.
7527    ///
7528    /// <div class="warning">
7529    ///
7530    /// **Experimental.** This API is part of an experimental wire-protocol surface
7531    /// and may change or be removed in future SDK or CLI releases. Pin both the
7532    /// SDK and CLI versions if your code depends on it.
7533    ///
7534    /// </div>
7535    pub async fn handle_pending_headers_refresh_request(
7536        &self,
7537        params: McpHeadersHandlePendingHeadersRefreshRequestRequest,
7538    ) -> Result<McpHeadersHandlePendingHeadersRefreshRequestResult, Error> {
7539        let mut wire_params = serde_json::to_value(params)?;
7540        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7541        let _value = self
7542            .session
7543            .client()
7544            .call(
7545                rpc_methods::SESSION_MCP_HEADERS_HANDLEPENDINGHEADERSREFRESHREQUEST,
7546                Some(wire_params),
7547            )
7548            .await?;
7549        Ok(serde_json::from_value(_value)?)
7550    }
7551}
7552
7553/// `session.mcp.oauth.*` RPCs.
7554#[derive(Clone, Copy)]
7555pub struct SessionRpcMcpOauth<'a> {
7556    pub(crate) session: &'a Session,
7557}
7558
7559impl<'a> SessionRpcMcpOauth<'a> {
7560    /// 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.
7561    ///
7562    /// Wire method: `session.mcp.oauth.handlePendingRequest`.
7563    ///
7564    /// # Parameters
7565    ///
7566    /// * `params` - Pending MCP OAuth request ID and host-provided token or cancellation response.
7567    ///
7568    /// # Returns
7569    ///
7570    /// Indicates whether the pending MCP OAuth response was accepted.
7571    ///
7572    /// <div class="warning">
7573    ///
7574    /// **Experimental.** This API is part of an experimental wire-protocol surface
7575    /// and may change or be removed in future SDK or CLI releases. Pin both the
7576    /// SDK and CLI versions if your code depends on it.
7577    ///
7578    /// </div>
7579    pub async fn handle_pending_request(
7580        &self,
7581        params: McpOauthHandlePendingRequest,
7582    ) -> Result<McpOauthHandlePendingResult, Error> {
7583        let mut wire_params = serde_json::to_value(params)?;
7584        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7585        let _value = self
7586            .session
7587            .client()
7588            .call(
7589                rpc_methods::SESSION_MCP_OAUTH_HANDLEPENDINGREQUEST,
7590                Some(wire_params),
7591            )
7592            .await?;
7593        Ok(serde_json::from_value(_value)?)
7594    }
7595
7596    /// Notifies the session that MCP OAuth authentication succeeded and updated credentials were persisted, so cached tool definitions can be refreshed.
7597    ///
7598    /// Wire method: `session.mcp.oauth.authenticationStateChanged`.
7599    ///
7600    /// # Parameters
7601    ///
7602    /// * `params` - Identifies the MCP server whose persisted OAuth credentials were updated.
7603    ///
7604    /// <div class="warning">
7605    ///
7606    /// **Experimental.** This API is part of an experimental wire-protocol surface
7607    /// and may change or be removed in future SDK or CLI releases. Pin both the
7608    /// SDK and CLI versions if your code depends on it.
7609    ///
7610    /// </div>
7611    pub async fn authentication_state_changed(
7612        &self,
7613        params: McpOauthAuthenticationStateChangedRequest,
7614    ) -> Result<(), Error> {
7615        let mut wire_params = serde_json::to_value(params)?;
7616        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7617        let _value = self
7618            .session
7619            .client()
7620            .call(
7621                rpc_methods::SESSION_MCP_OAUTH_AUTHENTICATIONSTATECHANGED,
7622                Some(wire_params),
7623            )
7624            .await?;
7625        Ok(())
7626    }
7627
7628    /// Starts OAuth authentication for a remote MCP server.
7629    ///
7630    /// Wire method: `session.mcp.oauth.login`.
7631    ///
7632    /// # Parameters
7633    ///
7634    /// * `params` - Remote MCP server name and optional overrides controlling reauthentication, OAuth client display name, callback success-page copy, and static OAuth client selection.
7635    ///
7636    /// # Returns
7637    ///
7638    /// OAuth authorization URL the caller should open, or empty when cached tokens already authenticated the server.
7639    ///
7640    /// <div class="warning">
7641    ///
7642    /// **Experimental.** This API is part of an experimental wire-protocol surface
7643    /// and may change or be removed in future SDK or CLI releases. Pin both the
7644    /// SDK and CLI versions if your code depends on it.
7645    ///
7646    /// </div>
7647    pub async fn login(&self, params: McpOauthLoginRequest) -> Result<McpOauthLoginResult, Error> {
7648        let mut wire_params = serde_json::to_value(params)?;
7649        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7650        let _value = self
7651            .session
7652            .client()
7653            .call(rpc_methods::SESSION_MCP_OAUTH_LOGIN, Some(wire_params))
7654            .await?;
7655        Ok(serde_json::from_value(_value)?)
7656    }
7657
7658    /// 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.
7659    ///
7660    /// Wire method: `session.mcp.oauth.probe`.
7661    ///
7662    /// # Parameters
7663    ///
7664    /// * `params` - Remote MCP server name for a passive OAuth status probe.
7665    ///
7666    /// # Returns
7667    ///
7668    /// 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.
7669    ///
7670    /// <div class="warning">
7671    ///
7672    /// **Experimental.** This API is part of an experimental wire-protocol surface
7673    /// and may change or be removed in future SDK or CLI releases. Pin both the
7674    /// SDK and CLI versions if your code depends on it.
7675    ///
7676    /// </div>
7677    pub async fn probe(&self, params: McpOauthProbeRequest) -> Result<McpOauthProbeResult, Error> {
7678        let mut wire_params = serde_json::to_value(params)?;
7679        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7680        let _value = self
7681            .session
7682            .client()
7683            .call(rpc_methods::SESSION_MCP_OAUTH_PROBE, Some(wire_params))
7684            .await?;
7685        Ok(serde_json::from_value(_value)?)
7686    }
7687
7688    /// Responds to a pending MCP OAuth authorization request by its request id.
7689    ///
7690    /// Wire method: `session.mcp.oauth.respond`.
7691    ///
7692    /// # Parameters
7693    ///
7694    /// * `params` - Pending MCP OAuth request id to respond to.
7695    ///
7696    /// # Returns
7697    ///
7698    /// Indicates whether the pending MCP OAuth response was accepted.
7699    ///
7700    /// <div class="warning">
7701    ///
7702    /// **Experimental.** This API is part of an experimental wire-protocol surface
7703    /// and may change or be removed in future SDK or CLI releases. Pin both the
7704    /// SDK and CLI versions if your code depends on it.
7705    ///
7706    /// </div>
7707    pub async fn respond(
7708        &self,
7709        params: McpOauthRespondRequest,
7710    ) -> Result<McpOauthRespondResult, Error> {
7711        let mut wire_params = serde_json::to_value(params)?;
7712        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7713        let _value = self
7714            .session
7715            .client()
7716            .call(rpc_methods::SESSION_MCP_OAUTH_RESPOND, Some(wire_params))
7717            .await?;
7718        Ok(serde_json::from_value(_value)?)
7719    }
7720}
7721
7722/// `session.mcp.resources.*` RPCs.
7723#[derive(Clone, Copy)]
7724pub struct SessionRpcMcpResources<'a> {
7725    pub(crate) session: &'a Session,
7726}
7727
7728impl<'a> SessionRpcMcpResources<'a> {
7729    /// Fetch an MCP resource from a connected server by URI (proxies MCP `resources/read`).
7730    ///
7731    /// Wire method: `session.mcp.resources.read`.
7732    ///
7733    /// # Parameters
7734    ///
7735    /// * `params` - MCP server and resource URI to fetch.
7736    ///
7737    /// # Returns
7738    ///
7739    /// Resource contents returned by the MCP server.
7740    ///
7741    /// <div class="warning">
7742    ///
7743    /// **Experimental.** This API is part of an experimental wire-protocol surface
7744    /// and may change or be removed in future SDK or CLI releases. Pin both the
7745    /// SDK and CLI versions if your code depends on it.
7746    ///
7747    /// </div>
7748    pub async fn read(
7749        &self,
7750        params: McpResourcesReadRequest,
7751    ) -> Result<McpResourcesReadResult, Error> {
7752        let mut wire_params = serde_json::to_value(params)?;
7753        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7754        let _value = self
7755            .session
7756            .client()
7757            .call(rpc_methods::SESSION_MCP_RESOURCES_READ, Some(wire_params))
7758            .await?;
7759        Ok(serde_json::from_value(_value)?)
7760    }
7761
7762    /// Enumerate one page of resources a connected MCP server exposes (proxies MCP `resources/list`). Pass `cursor` to continue from a prior result's `nextCursor`.
7763    ///
7764    /// Wire method: `session.mcp.resources.list`.
7765    ///
7766    /// # Parameters
7767    ///
7768    /// * `params` - MCP server whose resources to enumerate.
7769    ///
7770    /// # Returns
7771    ///
7772    /// One page of resources advertised by the named MCP server.
7773    ///
7774    /// <div class="warning">
7775    ///
7776    /// **Experimental.** This API is part of an experimental wire-protocol surface
7777    /// and may change or be removed in future SDK or CLI releases. Pin both the
7778    /// SDK and CLI versions if your code depends on it.
7779    ///
7780    /// </div>
7781    pub async fn list(
7782        &self,
7783        params: McpResourcesListRequest,
7784    ) -> Result<McpResourcesListResult, Error> {
7785        let mut wire_params = serde_json::to_value(params)?;
7786        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7787        let _value = self
7788            .session
7789            .client()
7790            .call(rpc_methods::SESSION_MCP_RESOURCES_LIST, Some(wire_params))
7791            .await?;
7792        Ok(serde_json::from_value(_value)?)
7793    }
7794
7795    /// 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`.
7796    ///
7797    /// Wire method: `session.mcp.resources.listTemplates`.
7798    ///
7799    /// # Parameters
7800    ///
7801    /// * `params` - MCP server whose resource templates to enumerate.
7802    ///
7803    /// # Returns
7804    ///
7805    /// One page of resource templates advertised by the named MCP server.
7806    ///
7807    /// <div class="warning">
7808    ///
7809    /// **Experimental.** This API is part of an experimental wire-protocol surface
7810    /// and may change or be removed in future SDK or CLI releases. Pin both the
7811    /// SDK and CLI versions if your code depends on it.
7812    ///
7813    /// </div>
7814    pub async fn list_templates(
7815        &self,
7816        params: McpResourcesListTemplatesRequest,
7817    ) -> Result<McpResourcesListTemplatesResult, Error> {
7818        let mut wire_params = serde_json::to_value(params)?;
7819        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7820        let _value = self
7821            .session
7822            .client()
7823            .call(
7824                rpc_methods::SESSION_MCP_RESOURCES_LISTTEMPLATES,
7825                Some(wire_params),
7826            )
7827            .await?;
7828        Ok(serde_json::from_value(_value)?)
7829    }
7830}
7831
7832/// `session.metadata.*` RPCs.
7833#[derive(Clone, Copy)]
7834pub struct SessionRpcMetadata<'a> {
7835    pub(crate) session: &'a Session,
7836}
7837
7838impl<'a> SessionRpcMetadata<'a> {
7839    /// Returns a snapshot of the session's identifying metadata, mode, agent, and remote info.
7840    ///
7841    /// Wire method: `session.metadata.snapshot`.
7842    ///
7843    /// # Returns
7844    ///
7845    /// Point-in-time snapshot of slow-changing session identifier and state fields
7846    ///
7847    /// <div class="warning">
7848    ///
7849    /// **Experimental.** This API is part of an experimental wire-protocol surface
7850    /// and may change or be removed in future SDK or CLI releases. Pin both the
7851    /// SDK and CLI versions if your code depends on it.
7852    ///
7853    /// </div>
7854    pub async fn snapshot(&self) -> Result<SessionMetadataSnapshot, Error> {
7855        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7856        let _value = self
7857            .session
7858            .client()
7859            .call(rpc_methods::SESSION_METADATA_SNAPSHOT, Some(wire_params))
7860            .await?;
7861        Ok(serde_json::from_value(_value)?)
7862    }
7863
7864    /// 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.
7865    ///
7866    /// Wire method: `session.metadata.getClientMetadata`.
7867    ///
7868    /// # Returns
7869    ///
7870    /// 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.
7871    ///
7872    /// <div class="warning">
7873    ///
7874    /// **Experimental.** This API is part of an experimental wire-protocol surface
7875    /// and may change or be removed in future SDK or CLI releases. Pin both the
7876    /// SDK and CLI versions if your code depends on it.
7877    ///
7878    /// </div>
7879    pub async fn get_client_metadata(&self) -> Result<ClientMetadata, Error> {
7880        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7881        let _value = self
7882            .session
7883            .client()
7884            .call(
7885                rpc_methods::SESSION_METADATA_GETCLIENTMETADATA,
7886                Some(wire_params),
7887            )
7888            .await?;
7889        Ok(serde_json::from_value(_value)?)
7890    }
7891
7892    /// Atomically patches the client-owned string metadata persisted with this local session and returns the committed bag.
7893    ///
7894    /// Wire method: `session.metadata.updateClientMetadata`.
7895    ///
7896    /// # Parameters
7897    ///
7898    /// * `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.
7899    ///
7900    /// # Returns
7901    ///
7902    /// 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.
7903    ///
7904    /// <div class="warning">
7905    ///
7906    /// **Experimental.** This API is part of an experimental wire-protocol surface
7907    /// and may change or be removed in future SDK or CLI releases. Pin both the
7908    /// SDK and CLI versions if your code depends on it.
7909    ///
7910    /// </div>
7911    pub async fn update_client_metadata(
7912        &self,
7913        params: MetadataUpdateClientMetadataRequest,
7914    ) -> Result<ClientMetadata, Error> {
7915        let mut wire_params = serde_json::to_value(params)?;
7916        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7917        let _value = self
7918            .session
7919            .client()
7920            .call(
7921                rpc_methods::SESSION_METADATA_UPDATECLIENTMETADATA,
7922                Some(wire_params),
7923            )
7924            .await?;
7925        Ok(serde_json::from_value(_value)?)
7926    }
7927
7928    /// Reports whether the local session is currently processing user/agent messages.
7929    ///
7930    /// Wire method: `session.metadata.isProcessing`.
7931    ///
7932    /// # Returns
7933    ///
7934    /// Indicates whether the local session is currently processing a turn or background continuation.
7935    ///
7936    /// <div class="warning">
7937    ///
7938    /// **Experimental.** This API is part of an experimental wire-protocol surface
7939    /// and may change or be removed in future SDK or CLI releases. Pin both the
7940    /// SDK and CLI versions if your code depends on it.
7941    ///
7942    /// </div>
7943    pub async fn is_processing(&self) -> Result<MetadataIsProcessingResult, Error> {
7944        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7945        let _value = self
7946            .session
7947            .client()
7948            .call(
7949                rpc_methods::SESSION_METADATA_ISPROCESSING,
7950                Some(wire_params),
7951            )
7952            .await?;
7953        Ok(serde_json::from_value(_value)?)
7954    }
7955
7956    /// Returns a snapshot of activity flags for the session.
7957    ///
7958    /// Wire method: `session.metadata.activity`.
7959    ///
7960    /// # Returns
7961    ///
7962    /// Current activity flags for the session.
7963    ///
7964    /// <div class="warning">
7965    ///
7966    /// **Experimental.** This API is part of an experimental wire-protocol surface
7967    /// and may change or be removed in future SDK or CLI releases. Pin both the
7968    /// SDK and CLI versions if your code depends on it.
7969    ///
7970    /// </div>
7971    pub async fn activity(&self) -> Result<SessionActivity, Error> {
7972        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7973        let _value = self
7974            .session
7975            .client()
7976            .call(rpc_methods::SESSION_METADATA_ACTIVITY, Some(wire_params))
7977            .await?;
7978        Ok(serde_json::from_value(_value)?)
7979    }
7980
7981    /// Returns the token breakdown for the session's current context window for a given model.
7982    ///
7983    /// Wire method: `session.metadata.contextInfo`.
7984    ///
7985    /// # Parameters
7986    ///
7987    /// * `params` - Model identifier and token limits used to compute the context-info breakdown.
7988    ///
7989    /// # Returns
7990    ///
7991    /// Token breakdown for the session's current context window, or null if uninitialized.
7992    ///
7993    /// <div class="warning">
7994    ///
7995    /// **Experimental.** This API is part of an experimental wire-protocol surface
7996    /// and may change or be removed in future SDK or CLI releases. Pin both the
7997    /// SDK and CLI versions if your code depends on it.
7998    ///
7999    /// </div>
8000    pub async fn context_info(
8001        &self,
8002        params: MetadataContextInfoRequest,
8003    ) -> Result<MetadataContextInfoResult, Error> {
8004        let mut wire_params = serde_json::to_value(params)?;
8005        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8006        let _value = self
8007            .session
8008            .client()
8009            .call(rpc_methods::SESSION_METADATA_CONTEXTINFO, Some(wire_params))
8010            .await?;
8011        Ok(serde_json::from_value(_value)?)
8012    }
8013
8014    /// 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.
8015    ///
8016    /// Wire method: `session.metadata.getContextAttribution`.
8017    ///
8018    /// # Returns
8019    ///
8020    /// Per-source attribution breakdown for the session's current context window, or null if uninitialized.
8021    ///
8022    /// <div class="warning">
8023    ///
8024    /// **Experimental.** This API is part of an experimental wire-protocol surface
8025    /// and may change or be removed in future SDK or CLI releases. Pin both the
8026    /// SDK and CLI versions if your code depends on it.
8027    ///
8028    /// </div>
8029    pub async fn get_context_attribution(&self) -> Result<MetadataContextAttributionResult, Error> {
8030        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8031        let _value = self
8032            .session
8033            .client()
8034            .call(
8035                rpc_methods::SESSION_METADATA_GETCONTEXTATTRIBUTION,
8036                Some(wire_params),
8037            )
8038            .await?;
8039        Ok(serde_json::from_value(_value)?)
8040    }
8041
8042    /// 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.
8043    ///
8044    /// Wire method: `session.metadata.getContextHeaviestMessages`.
8045    ///
8046    /// # Parameters
8047    ///
8048    /// * `params` - Parameters for the heaviest-messages query.
8049    ///
8050    /// # Returns
8051    ///
8052    /// The heaviest individual messages in the session's context window, most-expensive first.
8053    ///
8054    /// <div class="warning">
8055    ///
8056    /// **Experimental.** This API is part of an experimental wire-protocol surface
8057    /// and may change or be removed in future SDK or CLI releases. Pin both the
8058    /// SDK and CLI versions if your code depends on it.
8059    ///
8060    /// </div>
8061    pub async fn get_context_heaviest_messages(
8062        &self,
8063        params: MetadataContextHeaviestMessagesRequest,
8064    ) -> Result<MetadataContextHeaviestMessagesResult, Error> {
8065        let mut wire_params = serde_json::to_value(params)?;
8066        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8067        let _value = self
8068            .session
8069            .client()
8070            .call(
8071                rpc_methods::SESSION_METADATA_GETCONTEXTHEAVIESTMESSAGES,
8072                Some(wire_params),
8073            )
8074            .await?;
8075        Ok(serde_json::from_value(_value)?)
8076    }
8077
8078    /// 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.
8079    ///
8080    /// Wire method: `session.metadata.recordContextChange`.
8081    ///
8082    /// # Parameters
8083    ///
8084    /// * `params` - Updated working-directory/git context to record on the session.
8085    ///
8086    /// # Returns
8087    ///
8088    /// 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.
8089    ///
8090    /// <div class="warning">
8091    ///
8092    /// **Experimental.** This API is part of an experimental wire-protocol surface
8093    /// and may change or be removed in future SDK or CLI releases. Pin both the
8094    /// SDK and CLI versions if your code depends on it.
8095    ///
8096    /// </div>
8097    pub async fn record_context_change(
8098        &self,
8099        params: MetadataRecordContextChangeRequest,
8100    ) -> Result<MetadataRecordContextChangeResult, Error> {
8101        let mut wire_params = serde_json::to_value(params)?;
8102        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8103        let _value = self
8104            .session
8105            .client()
8106            .call(
8107                rpc_methods::SESSION_METADATA_RECORDCONTEXTCHANGE,
8108                Some(wire_params),
8109            )
8110            .await?;
8111        Ok(serde_json::from_value(_value)?)
8112    }
8113
8114    /// 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.
8115    ///
8116    /// Wire method: `session.metadata.setWorkingDirectory`.
8117    ///
8118    /// # Parameters
8119    ///
8120    /// * `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.
8121    ///
8122    /// # Returns
8123    ///
8124    /// 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.
8125    ///
8126    /// <div class="warning">
8127    ///
8128    /// **Experimental.** This API is part of an experimental wire-protocol surface
8129    /// and may change or be removed in future SDK or CLI releases. Pin both the
8130    /// SDK and CLI versions if your code depends on it.
8131    ///
8132    /// </div>
8133    pub async fn set_working_directory(
8134        &self,
8135        params: MetadataSetWorkingDirectoryRequest,
8136    ) -> Result<MetadataSetWorkingDirectoryResult, Error> {
8137        let mut wire_params = serde_json::to_value(params)?;
8138        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8139        let _value = self
8140            .session
8141            .client()
8142            .call(
8143                rpc_methods::SESSION_METADATA_SETWORKINGDIRECTORY,
8144                Some(wire_params),
8145            )
8146            .await?;
8147        Ok(serde_json::from_value(_value)?)
8148    }
8149
8150    /// Re-tokenizes the session's existing messages against a model and returns aggregate token totals.
8151    ///
8152    /// Wire method: `session.metadata.recomputeContextTokens`.
8153    ///
8154    /// # Parameters
8155    ///
8156    /// * `params` - Model identifier to use when re-tokenizing the session's existing messages.
8157    ///
8158    /// # Returns
8159    ///
8160    /// 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.
8161    ///
8162    /// <div class="warning">
8163    ///
8164    /// **Experimental.** This API is part of an experimental wire-protocol surface
8165    /// and may change or be removed in future SDK or CLI releases. Pin both the
8166    /// SDK and CLI versions if your code depends on it.
8167    ///
8168    /// </div>
8169    pub async fn recompute_context_tokens(
8170        &self,
8171        params: MetadataRecomputeContextTokensRequest,
8172    ) -> Result<MetadataRecomputeContextTokensResult, Error> {
8173        let mut wire_params = serde_json::to_value(params)?;
8174        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8175        let _value = self
8176            .session
8177            .client()
8178            .call(
8179                rpc_methods::SESSION_METADATA_RECOMPUTECONTEXTTOKENS,
8180                Some(wire_params),
8181            )
8182            .await?;
8183        Ok(serde_json::from_value(_value)?)
8184    }
8185}
8186
8187/// `session.mode.*` RPCs.
8188#[derive(Clone, Copy)]
8189pub struct SessionRpcMode<'a> {
8190    pub(crate) session: &'a Session,
8191}
8192
8193impl<'a> SessionRpcMode<'a> {
8194    /// Gets the current agent interaction mode.
8195    ///
8196    /// Wire method: `session.mode.get`.
8197    ///
8198    /// # Returns
8199    ///
8200    /// The session mode the agent is operating in
8201    ///
8202    /// <div class="warning">
8203    ///
8204    /// **Experimental.** This API is part of an experimental wire-protocol surface
8205    /// and may change or be removed in future SDK or CLI releases. Pin both the
8206    /// SDK and CLI versions if your code depends on it.
8207    ///
8208    /// </div>
8209    pub async fn get(&self) -> Result<SessionMode, Error> {
8210        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8211        let _value = self
8212            .session
8213            .client()
8214            .call(rpc_methods::SESSION_MODE_GET, Some(wire_params))
8215            .await?;
8216        Ok(serde_json::from_value(_value)?)
8217    }
8218
8219    /// Sets the current agent interaction mode.
8220    ///
8221    /// Wire method: `session.mode.set`.
8222    ///
8223    /// # Parameters
8224    ///
8225    /// * `params` - Agent interaction mode to apply to the session.
8226    ///
8227    /// # Returns
8228    ///
8229    /// Outcome of a session mode change, including any model switch it triggered and follow-up the host must perform.
8230    ///
8231    /// <div class="warning">
8232    ///
8233    /// **Experimental.** This API is part of an experimental wire-protocol surface
8234    /// and may change or be removed in future SDK or CLI releases. Pin both the
8235    /// SDK and CLI versions if your code depends on it.
8236    ///
8237    /// </div>
8238    pub async fn set(&self, params: ModeSetRequest) -> Result<ModeSetResult, Error> {
8239        let mut wire_params = serde_json::to_value(params)?;
8240        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8241        let _value = self
8242            .session
8243            .client()
8244            .call(rpc_methods::SESSION_MODE_SET, Some(wire_params))
8245            .await?;
8246        Ok(serde_json::from_value(_value)?)
8247    }
8248}
8249
8250/// `session.model.*` RPCs.
8251#[derive(Clone, Copy)]
8252pub struct SessionRpcModel<'a> {
8253    pub(crate) session: &'a Session,
8254}
8255
8256impl<'a> SessionRpcModel<'a> {
8257    /// Gets the session's authoritative model snapshot, including the committed Auto preference and any newer unclaimed Auto preference waiting for a future user turn.
8258    ///
8259    /// Wire method: `session.model.getCurrent`.
8260    ///
8261    /// # Returns
8262    ///
8263    /// 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.
8264    ///
8265    /// <div class="warning">
8266    ///
8267    /// **Experimental.** This API is part of an experimental wire-protocol surface
8268    /// and may change or be removed in future SDK or CLI releases. Pin both the
8269    /// SDK and CLI versions if your code depends on it.
8270    ///
8271    /// </div>
8272    pub async fn get_current(&self) -> Result<CurrentModel, Error> {
8273        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8274        let _value = self
8275            .session
8276            .client()
8277            .call(rpc_methods::SESSION_MODEL_GETCURRENT, Some(wire_params))
8278            .await?;
8279        Ok(serde_json::from_value(_value)?)
8280    }
8281
8282    /// Switches the session to a model and optional reasoning configuration.
8283    ///
8284    /// Wire method: `session.model.switchTo`.
8285    ///
8286    /// # Parameters
8287    ///
8288    /// * `params` - Target model identifier and optional reasoning effort, summary, capability overrides, and context tier.
8289    ///
8290    /// # Returns
8291    ///
8292    /// The model identifier active on the session after the switch.
8293    ///
8294    /// <div class="warning">
8295    ///
8296    /// **Experimental.** This API is part of an experimental wire-protocol surface
8297    /// and may change or be removed in future SDK or CLI releases. Pin both the
8298    /// SDK and CLI versions if your code depends on it.
8299    ///
8300    /// </div>
8301    pub async fn switch_to(
8302        &self,
8303        params: ModelSwitchToRequest,
8304    ) -> Result<ModelSwitchToResult, Error> {
8305        let mut wire_params = serde_json::to_value(params)?;
8306        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8307        let _value = self
8308            .session
8309            .client()
8310            .call(rpc_methods::SESSION_MODEL_SWITCHTO, Some(wire_params))
8311            .await?;
8312        Ok(serde_json::from_value(_value)?)
8313    }
8314
8315    /// 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`.
8316    ///
8317    /// Wire method: `session.model.switchAutoTier`.
8318    ///
8319    /// # Parameters
8320    ///
8321    /// * `params` - An Auto preference request for the session. This updates Auto configuration only; it does not change the selected model to `auto`.
8322    ///
8323    /// # Returns
8324    ///
8325    /// Immediate acknowledgement and Auto preference snapshot after a switch request. This result never implies that a pending preference committed.
8326    ///
8327    /// <div class="warning">
8328    ///
8329    /// **Experimental.** This API is part of an experimental wire-protocol surface
8330    /// and may change or be removed in future SDK or CLI releases. Pin both the
8331    /// SDK and CLI versions if your code depends on it.
8332    ///
8333    /// </div>
8334    pub async fn switch_auto_tier(
8335        &self,
8336        params: ModelSwitchAutoTierRequest,
8337    ) -> Result<ModelSwitchAutoTierResult, Error> {
8338        let mut wire_params = serde_json::to_value(params)?;
8339        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8340        let _value = self
8341            .session
8342            .client()
8343            .call(rpc_methods::SESSION_MODEL_SWITCHAUTOTIER, Some(wire_params))
8344            .await?;
8345        Ok(serde_json::from_value(_value)?)
8346    }
8347
8348    /// Resolves and applies organization-managed and repository model overlays.
8349    ///
8350    /// Wire method: `session.model.applyStartupOverlay`.
8351    ///
8352    /// # Parameters
8353    ///
8354    /// * `params` - Managed, repository, and CLI model overrides to overlay onto the session at startup.
8355    ///
8356    /// # Returns
8357    ///
8358    /// The model identifier active on the session after the switch.
8359    ///
8360    /// <div class="warning">
8361    ///
8362    /// **Experimental.** This API is part of an experimental wire-protocol surface
8363    /// and may change or be removed in future SDK or CLI releases. Pin both the
8364    /// SDK and CLI versions if your code depends on it.
8365    ///
8366    /// </div>
8367    pub(crate) async fn apply_startup_overlay(
8368        &self,
8369        params: ModelApplyStartupOverlayRequest,
8370    ) -> Result<ModelSwitchToResult, Error> {
8371        let mut wire_params = serde_json::to_value(params)?;
8372        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8373        let _value = self
8374            .session
8375            .client()
8376            .call(
8377                rpc_methods::SESSION_MODEL_APPLYSTARTUPOVERLAY,
8378                Some(wire_params),
8379            )
8380            .await?;
8381        Ok(serde_json::from_value(_value)?)
8382    }
8383
8384    /// Replaces or clears the host-supplied model allowlist for a running session.
8385    ///
8386    /// Wire method: `session.model.setAllowedModels`.
8387    ///
8388    /// # Parameters
8389    ///
8390    /// * `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.
8391    ///
8392    /// # Returns
8393    ///
8394    /// The applied host allowlist and effective session model policy after intersection.
8395    ///
8396    /// <div class="warning">
8397    ///
8398    /// **Experimental.** This API is part of an experimental wire-protocol surface
8399    /// and may change or be removed in future SDK or CLI releases. Pin both the
8400    /// SDK and CLI versions if your code depends on it.
8401    ///
8402    /// </div>
8403    pub async fn set_allowed_models(
8404        &self,
8405        params: ModelSetAllowedModelsRequest,
8406    ) -> Result<ModelSetAllowedModelsResult, Error> {
8407        let mut wire_params = serde_json::to_value(params)?;
8408        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8409        let _value = self
8410            .session
8411            .client()
8412            .call(
8413                rpc_methods::SESSION_MODEL_SETALLOWEDMODELS,
8414                Some(wire_params),
8415            )
8416            .await?;
8417        Ok(serde_json::from_value(_value)?)
8418    }
8419
8420    /// Updates the session's reasoning effort without changing the selected model.
8421    ///
8422    /// Wire method: `session.model.setReasoningEffort`.
8423    ///
8424    /// # Parameters
8425    ///
8426    /// * `params` - Reasoning effort level to apply to the currently selected model.
8427    ///
8428    /// # Returns
8429    ///
8430    /// 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.
8431    ///
8432    /// <div class="warning">
8433    ///
8434    /// **Experimental.** This API is part of an experimental wire-protocol surface
8435    /// and may change or be removed in future SDK or CLI releases. Pin both the
8436    /// SDK and CLI versions if your code depends on it.
8437    ///
8438    /// </div>
8439    pub async fn set_reasoning_effort(
8440        &self,
8441        params: ModelSetReasoningEffortRequest,
8442    ) -> Result<ModelSetReasoningEffortResult, Error> {
8443        let mut wire_params = serde_json::to_value(params)?;
8444        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8445        let _value = self
8446            .session
8447            .client()
8448            .call(
8449                rpc_methods::SESSION_MODEL_SETREASONINGEFFORT,
8450                Some(wire_params),
8451            )
8452            .await?;
8453        Ok(serde_json::from_value(_value)?)
8454    }
8455
8456    /// 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.
8457    ///
8458    /// Wire method: `session.model.list`.
8459    ///
8460    /// # Returns
8461    ///
8462    /// The list of models available to this session.
8463    ///
8464    /// <div class="warning">
8465    ///
8466    /// **Experimental.** This API is part of an experimental wire-protocol surface
8467    /// and may change or be removed in future SDK or CLI releases. Pin both the
8468    /// SDK and CLI versions if your code depends on it.
8469    ///
8470    /// </div>
8471    pub async fn list(&self) -> Result<SessionModelList, Error> {
8472        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8473        let _value = self
8474            .session
8475            .client()
8476            .call(rpc_methods::SESSION_MODEL_LIST, Some(wire_params))
8477            .await?;
8478        Ok(serde_json::from_value(_value)?)
8479    }
8480
8481    /// 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.
8482    ///
8483    /// Wire method: `session.model.list`.
8484    ///
8485    /// # Parameters
8486    ///
8487    /// * `params` - Optional listing options.
8488    ///
8489    /// # Returns
8490    ///
8491    /// The list of models available to this session.
8492    ///
8493    /// <div class="warning">
8494    ///
8495    /// **Experimental.** This API is part of an experimental wire-protocol surface
8496    /// and may change or be removed in future SDK or CLI releases. Pin both the
8497    /// SDK and CLI versions if your code depends on it.
8498    ///
8499    /// </div>
8500    pub async fn list_with_params(
8501        &self,
8502        params: ModelListRequest,
8503    ) -> Result<SessionModelList, Error> {
8504        let mut wire_params = serde_json::to_value(params)?;
8505        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8506        let _value = self
8507            .session
8508            .client()
8509            .call(rpc_methods::SESSION_MODEL_LIST, Some(wire_params))
8510            .await?;
8511        Ok(serde_json::from_value(_value)?)
8512    }
8513}
8514
8515/// `session.name.*` RPCs.
8516#[derive(Clone, Copy)]
8517pub struct SessionRpcName<'a> {
8518    pub(crate) session: &'a Session,
8519}
8520
8521impl<'a> SessionRpcName<'a> {
8522    /// Gets the session's friendly name.
8523    ///
8524    /// Wire method: `session.name.get`.
8525    ///
8526    /// # Returns
8527    ///
8528    /// The session's friendly name, or null when not yet set.
8529    ///
8530    /// <div class="warning">
8531    ///
8532    /// **Experimental.** This API is part of an experimental wire-protocol surface
8533    /// and may change or be removed in future SDK or CLI releases. Pin both the
8534    /// SDK and CLI versions if your code depends on it.
8535    ///
8536    /// </div>
8537    pub async fn get(&self) -> Result<NameGetResult, Error> {
8538        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8539        let _value = self
8540            .session
8541            .client()
8542            .call(rpc_methods::SESSION_NAME_GET, Some(wire_params))
8543            .await?;
8544        Ok(serde_json::from_value(_value)?)
8545    }
8546
8547    /// Sets the session's friendly name.
8548    ///
8549    /// Wire method: `session.name.set`.
8550    ///
8551    /// # Parameters
8552    ///
8553    /// * `params` - New friendly name to apply to the session.
8554    ///
8555    /// <div class="warning">
8556    ///
8557    /// **Experimental.** This API is part of an experimental wire-protocol surface
8558    /// and may change or be removed in future SDK or CLI releases. Pin both the
8559    /// SDK and CLI versions if your code depends on it.
8560    ///
8561    /// </div>
8562    pub async fn set(&self, params: NameSetRequest) -> Result<(), Error> {
8563        let mut wire_params = serde_json::to_value(params)?;
8564        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8565        let _value = self
8566            .session
8567            .client()
8568            .call(rpc_methods::SESSION_NAME_SET, Some(wire_params))
8569            .await?;
8570        Ok(())
8571    }
8572
8573    /// Persists an auto-generated session summary as the session's name when no user-set name exists.
8574    ///
8575    /// Wire method: `session.name.setAuto`.
8576    ///
8577    /// # Parameters
8578    ///
8579    /// * `params` - Auto-generated session summary to apply as the session's name when no user-set name exists.
8580    ///
8581    /// # Returns
8582    ///
8583    /// Indicates whether the auto-generated summary was applied as the session's name.
8584    ///
8585    /// <div class="warning">
8586    ///
8587    /// **Experimental.** This API is part of an experimental wire-protocol surface
8588    /// and may change or be removed in future SDK or CLI releases. Pin both the
8589    /// SDK and CLI versions if your code depends on it.
8590    ///
8591    /// </div>
8592    pub async fn set_auto(&self, params: NameSetAutoRequest) -> Result<NameSetAutoResult, Error> {
8593        let mut wire_params = serde_json::to_value(params)?;
8594        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8595        let _value = self
8596            .session
8597            .client()
8598            .call(rpc_methods::SESSION_NAME_SETAUTO, Some(wire_params))
8599            .await?;
8600        Ok(serde_json::from_value(_value)?)
8601    }
8602}
8603
8604/// `session.options.*` RPCs.
8605#[derive(Clone, Copy)]
8606pub struct SessionRpcOptions<'a> {
8607    pub(crate) session: &'a Session,
8608}
8609
8610impl<'a> SessionRpcOptions<'a> {
8611    /// Patches the genuinely-mutable subset of session options.
8612    ///
8613    /// Wire method: `session.options.update`.
8614    ///
8615    /// # Parameters
8616    ///
8617    /// * `params` - Patch of mutable session options to apply to the running session.
8618    ///
8619    /// # Returns
8620    ///
8621    /// Indicates whether the session options patch was applied successfully.
8622    ///
8623    /// <div class="warning">
8624    ///
8625    /// **Experimental.** This API is part of an experimental wire-protocol surface
8626    /// and may change or be removed in future SDK or CLI releases. Pin both the
8627    /// SDK and CLI versions if your code depends on it.
8628    ///
8629    /// </div>
8630    pub async fn update(
8631        &self,
8632        params: SessionUpdateOptionsParams,
8633    ) -> Result<SessionUpdateOptionsResult, Error> {
8634        let mut wire_params = serde_json::to_value(params)?;
8635        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8636        let _value = self
8637            .session
8638            .client()
8639            .call(rpc_methods::SESSION_OPTIONS_UPDATE, Some(wire_params))
8640            .await?;
8641        Ok(serde_json::from_value(_value)?)
8642    }
8643}
8644
8645/// `session.permissions.*` RPCs.
8646#[derive(Clone, Copy)]
8647pub struct SessionRpcPermissions<'a> {
8648    pub(crate) session: &'a Session,
8649}
8650
8651impl<'a> SessionRpcPermissions<'a> {
8652    /// `session.permissions.folderTrust.*` sub-namespace.
8653    pub fn folder_trust(&self) -> SessionRpcPermissionsFolderTrust<'a> {
8654        SessionRpcPermissionsFolderTrust {
8655            session: self.session,
8656        }
8657    }
8658
8659    /// `session.permissions.locations.*` sub-namespace.
8660    pub fn locations(&self) -> SessionRpcPermissionsLocations<'a> {
8661        SessionRpcPermissionsLocations {
8662            session: self.session,
8663        }
8664    }
8665
8666    /// `session.permissions.paths.*` sub-namespace.
8667    pub fn paths(&self) -> SessionRpcPermissionsPaths<'a> {
8668        SessionRpcPermissionsPaths {
8669            session: self.session,
8670        }
8671    }
8672
8673    /// `session.permissions.urls.*` sub-namespace.
8674    pub fn urls(&self) -> SessionRpcPermissionsUrls<'a> {
8675        SessionRpcPermissionsUrls {
8676            session: self.session,
8677        }
8678    }
8679
8680    /// Replaces selected permission policy fields (rules, paths, URLs, exclusions, allow-all flags) on the session.
8681    ///
8682    /// Wire method: `session.permissions.configure`.
8683    ///
8684    /// # Parameters
8685    ///
8686    /// * `params` - Patch of permission policy fields to apply (omit a field to leave it unchanged).
8687    ///
8688    /// # Returns
8689    ///
8690    /// Indicates whether the operation succeeded.
8691    ///
8692    /// <div class="warning">
8693    ///
8694    /// **Experimental.** This API is part of an experimental wire-protocol surface
8695    /// and may change or be removed in future SDK or CLI releases. Pin both the
8696    /// SDK and CLI versions if your code depends on it.
8697    ///
8698    /// </div>
8699    pub async fn configure(
8700        &self,
8701        params: PermissionsConfigureParams,
8702    ) -> Result<PermissionsConfigureResult, Error> {
8703        let mut wire_params = serde_json::to_value(params)?;
8704        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8705        let _value = self
8706            .session
8707            .client()
8708            .call(
8709                rpc_methods::SESSION_PERMISSIONS_CONFIGURE,
8710                Some(wire_params),
8711            )
8712            .await?;
8713        Ok(serde_json::from_value(_value)?)
8714    }
8715
8716    /// Provides a decision for a pending tool permission request.
8717    ///
8718    /// Wire method: `session.permissions.handlePendingPermissionRequest`.
8719    ///
8720    /// # Parameters
8721    ///
8722    /// * `params` - Pending permission request ID and the decision to apply (approve/reject and scope).
8723    ///
8724    /// # Returns
8725    ///
8726    /// Indicates whether the permission decision was applied; false when the request was already resolved.
8727    ///
8728    /// <div class="warning">
8729    ///
8730    /// **Experimental.** This API is part of an experimental wire-protocol surface
8731    /// and may change or be removed in future SDK or CLI releases. Pin both the
8732    /// SDK and CLI versions if your code depends on it.
8733    ///
8734    /// </div>
8735    pub async fn handle_pending_permission_request(
8736        &self,
8737        params: PermissionDecisionRequest,
8738    ) -> Result<PermissionRequestResult, Error> {
8739        let mut wire_params = serde_json::to_value(params)?;
8740        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8741        let _value = self
8742            .session
8743            .client()
8744            .call(
8745                rpc_methods::SESSION_PERMISSIONS_HANDLEPENDINGPERMISSIONREQUEST,
8746                Some(wire_params),
8747            )
8748            .await?;
8749        Ok(serde_json::from_value(_value)?)
8750    }
8751
8752    /// Reconstructs the set of pending tool permission requests from the session's event history.
8753    ///
8754    /// Wire method: `session.permissions.pendingRequests`.
8755    ///
8756    /// # Returns
8757    ///
8758    /// List of pending permission requests reconstructed from event history.
8759    ///
8760    /// <div class="warning">
8761    ///
8762    /// **Experimental.** This API is part of an experimental wire-protocol surface
8763    /// and may change or be removed in future SDK or CLI releases. Pin both the
8764    /// SDK and CLI versions if your code depends on it.
8765    ///
8766    /// </div>
8767    pub async fn pending_requests(&self) -> Result<PendingPermissionRequestList, Error> {
8768        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8769        let _value = self
8770            .session
8771            .client()
8772            .call(
8773                rpc_methods::SESSION_PERMISSIONS_PENDINGREQUESTS,
8774                Some(wire_params),
8775            )
8776            .await?;
8777        Ok(serde_json::from_value(_value)?)
8778    }
8779
8780    /// Enables or disables automatic approval of tool permission requests for the session.
8781    ///
8782    /// Wire method: `session.permissions.setApproveAll`.
8783    ///
8784    /// # Parameters
8785    ///
8786    /// * `params` - Allow-all toggle for tool permission requests, with an optional telemetry source.
8787    ///
8788    /// # Returns
8789    ///
8790    /// Indicates whether the operation succeeded.
8791    ///
8792    /// <div class="warning">
8793    ///
8794    /// **Experimental.** This API is part of an experimental wire-protocol surface
8795    /// and may change or be removed in future SDK or CLI releases. Pin both the
8796    /// SDK and CLI versions if your code depends on it.
8797    ///
8798    /// </div>
8799    pub async fn set_approve_all(
8800        &self,
8801        params: PermissionsSetApproveAllRequest,
8802    ) -> Result<PermissionsSetApproveAllResult, Error> {
8803        let mut wire_params = serde_json::to_value(params)?;
8804        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8805        let _value = self
8806            .session
8807            .client()
8808            .call(
8809                rpc_methods::SESSION_PERMISSIONS_SETAPPROVEALL,
8810                Some(wire_params),
8811            )
8812            .await?;
8813        Ok(serde_json::from_value(_value)?)
8814    }
8815
8816    /// 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.
8817    ///
8818    /// Wire method: `session.permissions.setMode`.
8819    ///
8820    /// # Parameters
8821    ///
8822    /// * `params` - Permission mode to apply for the session.
8823    ///
8824    /// # Returns
8825    ///
8826    /// Indicates whether the requested permission mode was applied and reports the authoritative post-mutation mode.
8827    ///
8828    /// <div class="warning">
8829    ///
8830    /// **Experimental.** This API is part of an experimental wire-protocol surface
8831    /// and may change or be removed in future SDK or CLI releases. Pin both the
8832    /// SDK and CLI versions if your code depends on it.
8833    ///
8834    /// </div>
8835    pub async fn set_mode(
8836        &self,
8837        params: PermissionsSetModeRequest,
8838    ) -> Result<PermissionsSetModeResult, Error> {
8839        let mut wire_params = serde_json::to_value(params)?;
8840        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8841        let _value = self
8842            .session
8843            .client()
8844            .call(rpc_methods::SESSION_PERMISSIONS_SETMODE, Some(wire_params))
8845            .await?;
8846        Ok(serde_json::from_value(_value)?)
8847    }
8848
8849    /// Returns the current permission mode for the session.
8850    ///
8851    /// Wire method: `session.permissions.getMode`.
8852    ///
8853    /// # Returns
8854    ///
8855    /// Current permission mode.
8856    ///
8857    /// <div class="warning">
8858    ///
8859    /// **Experimental.** This API is part of an experimental wire-protocol surface
8860    /// and may change or be removed in future SDK or CLI releases. Pin both the
8861    /// SDK and CLI versions if your code depends on it.
8862    ///
8863    /// </div>
8864    pub async fn get_mode(&self) -> Result<PermissionsGetModeResult, Error> {
8865        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8866        let _value = self
8867            .session
8868            .client()
8869            .call(rpc_methods::SESSION_PERMISSIONS_GETMODE, Some(wire_params))
8870            .await?;
8871        Ok(serde_json::from_value(_value)?)
8872    }
8873
8874    /// Adds or removes session-scoped or location-scoped permission rules.
8875    ///
8876    /// Wire method: `session.permissions.modifyRules`.
8877    ///
8878    /// # Parameters
8879    ///
8880    /// * `params` - Scope and add/remove instructions for modifying session- or location-scoped permission rules.
8881    ///
8882    /// # Returns
8883    ///
8884    /// Indicates whether the operation succeeded.
8885    ///
8886    /// <div class="warning">
8887    ///
8888    /// **Experimental.** This API is part of an experimental wire-protocol surface
8889    /// and may change or be removed in future SDK or CLI releases. Pin both the
8890    /// SDK and CLI versions if your code depends on it.
8891    ///
8892    /// </div>
8893    pub async fn modify_rules(
8894        &self,
8895        params: PermissionsModifyRulesParams,
8896    ) -> Result<PermissionsModifyRulesResult, Error> {
8897        let mut wire_params = serde_json::to_value(params)?;
8898        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8899        let _value = self
8900            .session
8901            .client()
8902            .call(
8903                rpc_methods::SESSION_PERMISSIONS_MODIFYRULES,
8904                Some(wire_params),
8905            )
8906            .await?;
8907        Ok(serde_json::from_value(_value)?)
8908    }
8909
8910    /// Sets whether the client wants permission prompts bridged into session events.
8911    ///
8912    /// Wire method: `session.permissions.setRequired`.
8913    ///
8914    /// # Parameters
8915    ///
8916    /// * `params` - Toggles whether permission prompts should be bridged into session events for this client.
8917    ///
8918    /// # Returns
8919    ///
8920    /// Indicates whether the operation succeeded.
8921    ///
8922    /// <div class="warning">
8923    ///
8924    /// **Experimental.** This API is part of an experimental wire-protocol surface
8925    /// and may change or be removed in future SDK or CLI releases. Pin both the
8926    /// SDK and CLI versions if your code depends on it.
8927    ///
8928    /// </div>
8929    pub async fn set_required(
8930        &self,
8931        params: PermissionsSetRequiredRequest,
8932    ) -> Result<PermissionsSetRequiredResult, Error> {
8933        let mut wire_params = serde_json::to_value(params)?;
8934        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8935        let _value = self
8936            .session
8937            .client()
8938            .call(
8939                rpc_methods::SESSION_PERMISSIONS_SETREQUIRED,
8940                Some(wire_params),
8941            )
8942            .await?;
8943        Ok(serde_json::from_value(_value)?)
8944    }
8945
8946    /// Clears session-scoped tool approvals and, for full resets, exact session-approved paths.
8947    ///
8948    /// Wire method: `session.permissions.resetSessionApprovals`.
8949    ///
8950    /// # Parameters
8951    ///
8952    /// * `params` - Clears session-scoped tool approvals and optionally clears location-scoped approvals and exact session-approved paths.
8953    ///
8954    /// # Returns
8955    ///
8956    /// Indicates whether the operation succeeded.
8957    ///
8958    /// <div class="warning">
8959    ///
8960    /// **Experimental.** This API is part of an experimental wire-protocol surface
8961    /// and may change or be removed in future SDK or CLI releases. Pin both the
8962    /// SDK and CLI versions if your code depends on it.
8963    ///
8964    /// </div>
8965    pub async fn reset_session_approvals(
8966        &self,
8967        params: PermissionsResetSessionApprovalsRequest,
8968    ) -> Result<PermissionsResetSessionApprovalsResult, Error> {
8969        let mut wire_params = serde_json::to_value(params)?;
8970        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8971        let _value = self
8972            .session
8973            .client()
8974            .call(
8975                rpc_methods::SESSION_PERMISSIONS_RESETSESSIONAPPROVALS,
8976                Some(wire_params),
8977            )
8978            .await?;
8979        Ok(serde_json::from_value(_value)?)
8980    }
8981
8982    /// Notifies the runtime that a permission prompt UI has been shown to the user.
8983    ///
8984    /// Wire method: `session.permissions.notifyPromptShown`.
8985    ///
8986    /// # Parameters
8987    ///
8988    /// * `params` - Notification payload describing the permission prompt that the client just rendered.
8989    ///
8990    /// # Returns
8991    ///
8992    /// Indicates whether the operation succeeded.
8993    ///
8994    /// <div class="warning">
8995    ///
8996    /// **Experimental.** This API is part of an experimental wire-protocol surface
8997    /// and may change or be removed in future SDK or CLI releases. Pin both the
8998    /// SDK and CLI versions if your code depends on it.
8999    ///
9000    /// </div>
9001    pub async fn notify_prompt_shown(
9002        &self,
9003        params: PermissionPromptShownNotification,
9004    ) -> Result<PermissionsNotifyPromptShownResult, Error> {
9005        let mut wire_params = serde_json::to_value(params)?;
9006        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9007        let _value = self
9008            .session
9009            .client()
9010            .call(
9011                rpc_methods::SESSION_PERMISSIONS_NOTIFYPROMPTSHOWN,
9012                Some(wire_params),
9013            )
9014            .await?;
9015        Ok(serde_json::from_value(_value)?)
9016    }
9017}
9018
9019/// `session.permissions.folderTrust.*` RPCs.
9020#[derive(Clone, Copy)]
9021pub struct SessionRpcPermissionsFolderTrust<'a> {
9022    pub(crate) session: &'a Session,
9023}
9024
9025impl<'a> SessionRpcPermissionsFolderTrust<'a> {
9026    /// Reports whether a folder is trusted according to the user's folder trust state.
9027    ///
9028    /// Wire method: `session.permissions.folderTrust.isTrusted`.
9029    ///
9030    /// # Parameters
9031    ///
9032    /// * `params` - Folder path to check for trust.
9033    ///
9034    /// # Returns
9035    ///
9036    /// Folder trust check result.
9037    ///
9038    /// <div class="warning">
9039    ///
9040    /// **Experimental.** This API is part of an experimental wire-protocol surface
9041    /// and may change or be removed in future SDK or CLI releases. Pin both the
9042    /// SDK and CLI versions if your code depends on it.
9043    ///
9044    /// </div>
9045    pub async fn is_trusted(
9046        &self,
9047        params: FolderTrustCheckParams,
9048    ) -> Result<FolderTrustCheckResult, Error> {
9049        let mut wire_params = serde_json::to_value(params)?;
9050        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9051        let _value = self
9052            .session
9053            .client()
9054            .call(
9055                rpc_methods::SESSION_PERMISSIONS_FOLDERTRUST_ISTRUSTED,
9056                Some(wire_params),
9057            )
9058            .await?;
9059        Ok(serde_json::from_value(_value)?)
9060    }
9061
9062    /// Adds a folder to the user's trusted folders list.
9063    ///
9064    /// Wire method: `session.permissions.folderTrust.addTrusted`.
9065    ///
9066    /// # Parameters
9067    ///
9068    /// * `params` - Folder path to add to trusted folders.
9069    ///
9070    /// # Returns
9071    ///
9072    /// Indicates whether the operation succeeded.
9073    ///
9074    /// <div class="warning">
9075    ///
9076    /// **Experimental.** This API is part of an experimental wire-protocol surface
9077    /// and may change or be removed in future SDK or CLI releases. Pin both the
9078    /// SDK and CLI versions if your code depends on it.
9079    ///
9080    /// </div>
9081    pub async fn add_trusted(
9082        &self,
9083        params: FolderTrustAddParams,
9084    ) -> Result<PermissionsFolderTrustAddTrustedResult, Error> {
9085        let mut wire_params = serde_json::to_value(params)?;
9086        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9087        let _value = self
9088            .session
9089            .client()
9090            .call(
9091                rpc_methods::SESSION_PERMISSIONS_FOLDERTRUST_ADDTRUSTED,
9092                Some(wire_params),
9093            )
9094            .await?;
9095        Ok(serde_json::from_value(_value)?)
9096    }
9097}
9098
9099/// `session.permissions.locations.*` RPCs.
9100#[derive(Clone, Copy)]
9101pub struct SessionRpcPermissionsLocations<'a> {
9102    pub(crate) session: &'a Session,
9103}
9104
9105impl<'a> SessionRpcPermissionsLocations<'a> {
9106    /// Resolves the permission location key and type for a working directory.
9107    ///
9108    /// Wire method: `session.permissions.locations.resolve`.
9109    ///
9110    /// # Parameters
9111    ///
9112    /// * `params` - Working directory to resolve into a location-permissions key.
9113    ///
9114    /// # Returns
9115    ///
9116    /// Resolved location-permissions key and type.
9117    ///
9118    /// <div class="warning">
9119    ///
9120    /// **Experimental.** This API is part of an experimental wire-protocol surface
9121    /// and may change or be removed in future SDK or CLI releases. Pin both the
9122    /// SDK and CLI versions if your code depends on it.
9123    ///
9124    /// </div>
9125    pub async fn resolve(
9126        &self,
9127        params: PermissionLocationResolveParams,
9128    ) -> Result<PermissionLocationResolveResult, Error> {
9129        let mut wire_params = serde_json::to_value(params)?;
9130        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9131        let _value = self
9132            .session
9133            .client()
9134            .call(
9135                rpc_methods::SESSION_PERMISSIONS_LOCATIONS_RESOLVE,
9136                Some(wire_params),
9137            )
9138            .await?;
9139        Ok(serde_json::from_value(_value)?)
9140    }
9141
9142    /// Applies persisted location-scoped tool approvals and allowed directories for a working directory to this session's permission service.
9143    ///
9144    /// Wire method: `session.permissions.locations.apply`.
9145    ///
9146    /// # Parameters
9147    ///
9148    /// * `params` - Working directory to load persisted location permissions for.
9149    ///
9150    /// # Returns
9151    ///
9152    /// Summary of persisted location permissions applied to the session.
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 apply(
9162        &self,
9163        params: PermissionLocationApplyParams,
9164    ) -> Result<PermissionLocationApplyResult, Error> {
9165        let mut wire_params = serde_json::to_value(params)?;
9166        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9167        let _value = self
9168            .session
9169            .client()
9170            .call(
9171                rpc_methods::SESSION_PERMISSIONS_LOCATIONS_APPLY,
9172                Some(wire_params),
9173            )
9174            .await?;
9175        Ok(serde_json::from_value(_value)?)
9176    }
9177
9178    /// Persists a tool approval for a permission location and applies its rules to this session's live permission service.
9179    ///
9180    /// Wire method: `session.permissions.locations.addToolApproval`.
9181    ///
9182    /// # Parameters
9183    ///
9184    /// * `params` - Location-scoped tool approval to persist.
9185    ///
9186    /// # Returns
9187    ///
9188    /// Indicates whether the operation succeeded.
9189    ///
9190    /// <div class="warning">
9191    ///
9192    /// **Experimental.** This API is part of an experimental wire-protocol surface
9193    /// and may change or be removed in future SDK or CLI releases. Pin both the
9194    /// SDK and CLI versions if your code depends on it.
9195    ///
9196    /// </div>
9197    pub async fn add_tool_approval(
9198        &self,
9199        params: PermissionLocationAddToolApprovalParams,
9200    ) -> Result<PermissionsLocationsAddToolApprovalResult, Error> {
9201        let mut wire_params = serde_json::to_value(params)?;
9202        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9203        let _value = self
9204            .session
9205            .client()
9206            .call(
9207                rpc_methods::SESSION_PERMISSIONS_LOCATIONS_ADDTOOLAPPROVAL,
9208                Some(wire_params),
9209            )
9210            .await?;
9211        Ok(serde_json::from_value(_value)?)
9212    }
9213}
9214
9215/// `session.permissions.paths.*` RPCs.
9216#[derive(Clone, Copy)]
9217pub struct SessionRpcPermissionsPaths<'a> {
9218    pub(crate) session: &'a Session,
9219}
9220
9221impl<'a> SessionRpcPermissionsPaths<'a> {
9222    /// Returns the session's recursive directory grants, exact session-approved paths, and primary working directory.
9223    ///
9224    /// Wire method: `session.permissions.paths.list`.
9225    ///
9226    /// # Returns
9227    ///
9228    /// Snapshot of the session's recursive directory grants, exact session-approved paths, and primary working directory.
9229    ///
9230    /// <div class="warning">
9231    ///
9232    /// **Experimental.** This API is part of an experimental wire-protocol surface
9233    /// and may change or be removed in future SDK or CLI releases. Pin both the
9234    /// SDK and CLI versions if your code depends on it.
9235    ///
9236    /// </div>
9237    pub async fn list(&self) -> Result<PermissionPathsList, Error> {
9238        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9239        let _value = self
9240            .session
9241            .client()
9242            .call(
9243                rpc_methods::SESSION_PERMISSIONS_PATHS_LIST,
9244                Some(wire_params),
9245            )
9246            .await?;
9247        Ok(serde_json::from_value(_value)?)
9248    }
9249
9250    /// Adds a directory to the session's allow-list and activates conventional skill and agent definitions under it.
9251    ///
9252    /// Wire method: `session.permissions.paths.add`.
9253    ///
9254    /// # Parameters
9255    ///
9256    /// * `params` - Directory path to add to the session's allowed directories.
9257    ///
9258    /// # Returns
9259    ///
9260    /// Indicates whether the operation succeeded.
9261    ///
9262    /// <div class="warning">
9263    ///
9264    /// **Experimental.** This API is part of an experimental wire-protocol surface
9265    /// and may change or be removed in future SDK or CLI releases. Pin both the
9266    /// SDK and CLI versions if your code depends on it.
9267    ///
9268    /// </div>
9269    pub async fn add(
9270        &self,
9271        params: PermissionPathsAddParams,
9272    ) -> Result<PermissionsPathsAddResult, Error> {
9273        let mut wire_params = serde_json::to_value(params)?;
9274        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9275        let _value = self
9276            .session
9277            .client()
9278            .call(
9279                rpc_methods::SESSION_PERMISSIONS_PATHS_ADD,
9280                Some(wire_params),
9281            )
9282            .await?;
9283        Ok(serde_json::from_value(_value)?)
9284    }
9285
9286    /// Updates the session's primary working directory used by the permission policy.
9287    ///
9288    /// Wire method: `session.permissions.paths.updatePrimary`.
9289    ///
9290    /// # Parameters
9291    ///
9292    /// * `params` - Directory path to set as the session's new primary working directory.
9293    ///
9294    /// # Returns
9295    ///
9296    /// Indicates whether the operation succeeded.
9297    ///
9298    /// <div class="warning">
9299    ///
9300    /// **Experimental.** This API is part of an experimental wire-protocol surface
9301    /// and may change or be removed in future SDK or CLI releases. Pin both the
9302    /// SDK and CLI versions if your code depends on it.
9303    ///
9304    /// </div>
9305    pub async fn update_primary(
9306        &self,
9307        params: PermissionPathsUpdatePrimaryParams,
9308    ) -> Result<PermissionsPathsUpdatePrimaryResult, Error> {
9309        let mut wire_params = serde_json::to_value(params)?;
9310        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9311        let _value = self
9312            .session
9313            .client()
9314            .call(
9315                rpc_methods::SESSION_PERMISSIONS_PATHS_UPDATEPRIMARY,
9316                Some(wire_params),
9317            )
9318            .await?;
9319        Ok(serde_json::from_value(_value)?)
9320    }
9321
9322    /// Reports whether a path falls within any of the session's allowed directories.
9323    ///
9324    /// Wire method: `session.permissions.paths.isPathWithinAllowedDirectories`.
9325    ///
9326    /// # Parameters
9327    ///
9328    /// * `params` - Path to evaluate against the session's allowed directories.
9329    ///
9330    /// # Returns
9331    ///
9332    /// Indicates whether the supplied path is within the session's allowed directories.
9333    ///
9334    /// <div class="warning">
9335    ///
9336    /// **Experimental.** This API is part of an experimental wire-protocol surface
9337    /// and may change or be removed in future SDK or CLI releases. Pin both the
9338    /// SDK and CLI versions if your code depends on it.
9339    ///
9340    /// </div>
9341    pub async fn is_path_within_allowed_directories(
9342        &self,
9343        params: PermissionPathsAllowedCheckParams,
9344    ) -> Result<PermissionPathsAllowedCheckResult, Error> {
9345        let mut wire_params = serde_json::to_value(params)?;
9346        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9347        let _value = self
9348            .session
9349            .client()
9350            .call(
9351                rpc_methods::SESSION_PERMISSIONS_PATHS_ISPATHWITHINALLOWEDDIRECTORIES,
9352                Some(wire_params),
9353            )
9354            .await?;
9355        Ok(serde_json::from_value(_value)?)
9356    }
9357
9358    /// Reports whether a path falls within the session's workspace (primary) directory.
9359    ///
9360    /// Wire method: `session.permissions.paths.isPathWithinWorkspace`.
9361    ///
9362    /// # Parameters
9363    ///
9364    /// * `params` - Path to evaluate against the session's workspace (primary) directory.
9365    ///
9366    /// # Returns
9367    ///
9368    /// Indicates whether the supplied path is within the session's workspace directory.
9369    ///
9370    /// <div class="warning">
9371    ///
9372    /// **Experimental.** This API is part of an experimental wire-protocol surface
9373    /// and may change or be removed in future SDK or CLI releases. Pin both the
9374    /// SDK and CLI versions if your code depends on it.
9375    ///
9376    /// </div>
9377    pub async fn is_path_within_workspace(
9378        &self,
9379        params: PermissionPathsWorkspaceCheckParams,
9380    ) -> Result<PermissionPathsWorkspaceCheckResult, Error> {
9381        let mut wire_params = serde_json::to_value(params)?;
9382        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9383        let _value = self
9384            .session
9385            .client()
9386            .call(
9387                rpc_methods::SESSION_PERMISSIONS_PATHS_ISPATHWITHINWORKSPACE,
9388                Some(wire_params),
9389            )
9390            .await?;
9391        Ok(serde_json::from_value(_value)?)
9392    }
9393}
9394
9395/// `session.permissions.urls.*` RPCs.
9396#[derive(Clone, Copy)]
9397pub struct SessionRpcPermissionsUrls<'a> {
9398    pub(crate) session: &'a Session,
9399}
9400
9401impl<'a> SessionRpcPermissionsUrls<'a> {
9402    /// Toggles the runtime's URL-permission policy between unrestricted and restricted modes.
9403    ///
9404    /// Wire method: `session.permissions.urls.setUnrestrictedMode`.
9405    ///
9406    /// # Parameters
9407    ///
9408    /// * `params` - Whether the URL-permission policy should run in unrestricted mode.
9409    ///
9410    /// # Returns
9411    ///
9412    /// Indicates whether the operation succeeded.
9413    ///
9414    /// <div class="warning">
9415    ///
9416    /// **Experimental.** This API is part of an experimental wire-protocol surface
9417    /// and may change or be removed in future SDK or CLI releases. Pin both the
9418    /// SDK and CLI versions if your code depends on it.
9419    ///
9420    /// </div>
9421    pub async fn set_unrestricted_mode(
9422        &self,
9423        params: PermissionUrlsSetUnrestrictedModeParams,
9424    ) -> Result<PermissionsUrlsSetUnrestrictedModeResult, Error> {
9425        let mut wire_params = serde_json::to_value(params)?;
9426        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9427        let _value = self
9428            .session
9429            .client()
9430            .call(
9431                rpc_methods::SESSION_PERMISSIONS_URLS_SETUNRESTRICTEDMODE,
9432                Some(wire_params),
9433            )
9434            .await?;
9435        Ok(serde_json::from_value(_value)?)
9436    }
9437}
9438
9439/// `session.plan.*` RPCs.
9440#[derive(Clone, Copy)]
9441pub struct SessionRpcPlan<'a> {
9442    pub(crate) session: &'a Session,
9443}
9444
9445impl<'a> SessionRpcPlan<'a> {
9446    /// Reads the session plan file from the workspace.
9447    ///
9448    /// Wire method: `session.plan.read`.
9449    ///
9450    /// # Returns
9451    ///
9452    /// Existence, contents, and resolved path of the session plan file.
9453    ///
9454    /// <div class="warning">
9455    ///
9456    /// **Experimental.** This API is part of an experimental wire-protocol surface
9457    /// and may change or be removed in future SDK or CLI releases. Pin both the
9458    /// SDK and CLI versions if your code depends on it.
9459    ///
9460    /// </div>
9461    pub async fn read(&self) -> Result<PlanReadResult, Error> {
9462        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9463        let _value = self
9464            .session
9465            .client()
9466            .call(rpc_methods::SESSION_PLAN_READ, Some(wire_params))
9467            .await?;
9468        Ok(serde_json::from_value(_value)?)
9469    }
9470
9471    /// Writes new content to the session plan file.
9472    ///
9473    /// Wire method: `session.plan.update`.
9474    ///
9475    /// # Parameters
9476    ///
9477    /// * `params` - Replacement contents to write to the session plan file.
9478    ///
9479    /// <div class="warning">
9480    ///
9481    /// **Experimental.** This API is part of an experimental wire-protocol surface
9482    /// and may change or be removed in future SDK or CLI releases. Pin both the
9483    /// SDK and CLI versions if your code depends on it.
9484    ///
9485    /// </div>
9486    pub async fn update(&self, params: PlanUpdateRequest) -> Result<(), Error> {
9487        let mut wire_params = serde_json::to_value(params)?;
9488        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9489        let _value = self
9490            .session
9491            .client()
9492            .call(rpc_methods::SESSION_PLAN_UPDATE, Some(wire_params))
9493            .await?;
9494        Ok(())
9495    }
9496
9497    /// Deletes the session plan file from the workspace.
9498    ///
9499    /// Wire method: `session.plan.delete`.
9500    ///
9501    /// <div class="warning">
9502    ///
9503    /// **Experimental.** This API is part of an experimental wire-protocol surface
9504    /// and may change or be removed in future SDK or CLI releases. Pin both the
9505    /// SDK and CLI versions if your code depends on it.
9506    ///
9507    /// </div>
9508    pub async fn delete(&self) -> Result<(), Error> {
9509        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9510        let _value = self
9511            .session
9512            .client()
9513            .call(rpc_methods::SESSION_PLAN_DELETE, Some(wire_params))
9514            .await?;
9515        Ok(())
9516    }
9517
9518    /// Reads todo rows from the session SQL database for plan rendering.
9519    ///
9520    /// Wire method: `session.plan.readSqlTodos`.
9521    ///
9522    /// # Returns
9523    ///
9524    /// Todo rows read from the session SQL database. Empty when no session database is available.
9525    ///
9526    /// <div class="warning">
9527    ///
9528    /// **Experimental.** This API is part of an experimental wire-protocol surface
9529    /// and may change or be removed in future SDK or CLI releases. Pin both the
9530    /// SDK and CLI versions if your code depends on it.
9531    ///
9532    /// </div>
9533    pub async fn read_sql_todos(&self) -> Result<PlanReadSqlTodosResult, Error> {
9534        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9535        let _value = self
9536            .session
9537            .client()
9538            .call(rpc_methods::SESSION_PLAN_READSQLTODOS, Some(wire_params))
9539            .await?;
9540        Ok(serde_json::from_value(_value)?)
9541    }
9542
9543    /// 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.
9544    ///
9545    /// Wire method: `session.plan.readSqlTodosWithDependencies`.
9546    ///
9547    /// # Returns
9548    ///
9549    /// Todo rows + dependency edges read from the session SQL database.
9550    ///
9551    /// <div class="warning">
9552    ///
9553    /// **Experimental.** This API is part of an experimental wire-protocol surface
9554    /// and may change or be removed in future SDK or CLI releases. Pin both the
9555    /// SDK and CLI versions if your code depends on it.
9556    ///
9557    /// </div>
9558    pub async fn read_sql_todos_with_dependencies(
9559        &self,
9560    ) -> Result<PlanReadSqlTodosWithDependenciesResult, Error> {
9561        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9562        let _value = self
9563            .session
9564            .client()
9565            .call(
9566                rpc_methods::SESSION_PLAN_READSQLTODOSWITHDEPENDENCIES,
9567                Some(wire_params),
9568            )
9569            .await?;
9570        Ok(serde_json::from_value(_value)?)
9571    }
9572}
9573
9574/// `session.plugins.*` RPCs.
9575#[derive(Clone, Copy)]
9576pub struct SessionRpcPlugins<'a> {
9577    pub(crate) session: &'a Session,
9578}
9579
9580impl<'a> SessionRpcPlugins<'a> {
9581    /// `session.plugins.marketplaces.*` sub-namespace.
9582    pub fn marketplaces(&self) -> SessionRpcPluginsMarketplaces<'a> {
9583        SessionRpcPluginsMarketplaces {
9584            session: self.session,
9585        }
9586    }
9587
9588    /// Lists globally installed, live, built-in, and enterprise-managed desired plugins using the live session's authoritative account, working directory, and retained managed policy.
9589    ///
9590    /// Wire method: `session.plugins.list`.
9591    ///
9592    /// # Returns
9593    ///
9594    /// Plugins installed for the session, with their enabled state and version metadata.
9595    ///
9596    /// <div class="warning">
9597    ///
9598    /// **Experimental.** This API is part of an experimental wire-protocol surface
9599    /// and may change or be removed in future SDK or CLI releases. Pin both the
9600    /// SDK and CLI versions if your code depends on it.
9601    ///
9602    /// </div>
9603    pub async fn list(&self) -> Result<PluginList, Error> {
9604        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9605        let _value = self
9606            .session
9607            .client()
9608            .call(rpc_methods::SESSION_PLUGINS_LIST, Some(wire_params))
9609            .await?;
9610        Ok(serde_json::from_value(_value)?)
9611    }
9612
9613    /// Installs a plugin using the live session's authoritative account, working directory, and retained managed policy.
9614    ///
9615    /// Wire method: `session.plugins.install`.
9616    ///
9617    /// # Parameters
9618    ///
9619    /// * `params` - Plugin source resolved relative to the session's authoritative working directory.
9620    ///
9621    /// # Returns
9622    ///
9623    /// Result of installing a plugin.
9624    ///
9625    /// <div class="warning">
9626    ///
9627    /// **Experimental.** This API is part of an experimental wire-protocol surface
9628    /// and may change or be removed in future SDK or CLI releases. Pin both the
9629    /// SDK and CLI versions if your code depends on it.
9630    ///
9631    /// </div>
9632    pub async fn install(
9633        &self,
9634        params: SessionPluginsInstallRequest,
9635    ) -> Result<PluginInstallResult, Error> {
9636        let mut wire_params = serde_json::to_value(params)?;
9637        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9638        let _value = self
9639            .session
9640            .client()
9641            .call(rpc_methods::SESSION_PLUGINS_INSTALL, Some(wire_params))
9642            .await?;
9643        Ok(serde_json::from_value(_value)?)
9644    }
9645
9646    /// Uninstalls a plugin when permitted by the live session's retained managed policy.
9647    ///
9648    /// Wire method: `session.plugins.uninstall`.
9649    ///
9650    /// # Parameters
9651    ///
9652    /// * `params` - Name (or spec) of the plugin to uninstall.
9653    ///
9654    /// <div class="warning">
9655    ///
9656    /// **Experimental.** This API is part of an experimental wire-protocol surface
9657    /// and may change or be removed in future SDK or CLI releases. Pin both the
9658    /// SDK and CLI versions if your code depends on it.
9659    ///
9660    /// </div>
9661    pub async fn uninstall(&self, params: PluginsUninstallRequest) -> Result<(), Error> {
9662        let mut wire_params = serde_json::to_value(params)?;
9663        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9664        let _value = self
9665            .session
9666            .client()
9667            .call(rpc_methods::SESSION_PLUGINS_UNINSTALL, Some(wire_params))
9668            .await?;
9669        Ok(())
9670    }
9671
9672    /// Updates an installed plugin using the live session's authoritative account, working directory, and retained managed policy.
9673    ///
9674    /// Wire method: `session.plugins.update`.
9675    ///
9676    /// # Parameters
9677    ///
9678    /// * `params` - Name (or spec) of the plugin to update.
9679    ///
9680    /// # Returns
9681    ///
9682    /// Result of updating a single plugin.
9683    ///
9684    /// <div class="warning">
9685    ///
9686    /// **Experimental.** This API is part of an experimental wire-protocol surface
9687    /// and may change or be removed in future SDK or CLI releases. Pin both the
9688    /// SDK and CLI versions if your code depends on it.
9689    ///
9690    /// </div>
9691    pub async fn update(&self, params: PluginsUpdateRequest) -> Result<PluginUpdateResult, Error> {
9692        let mut wire_params = serde_json::to_value(params)?;
9693        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9694        let _value = self
9695            .session
9696            .client()
9697            .call(rpc_methods::SESSION_PLUGINS_UPDATE, Some(wire_params))
9698            .await?;
9699        Ok(serde_json::from_value(_value)?)
9700    }
9701
9702    /// Enables installed plugins when permitted by the live session's retained managed policy.
9703    ///
9704    /// Wire method: `session.plugins.enable`.
9705    ///
9706    /// # Parameters
9707    ///
9708    /// * `params` - Plugin names (or specs) to enable in the session's authoritative working directory.
9709    ///
9710    /// <div class="warning">
9711    ///
9712    /// **Experimental.** This API is part of an experimental wire-protocol surface
9713    /// and may change or be removed in future SDK or CLI releases. Pin both the
9714    /// SDK and CLI versions if your code depends on it.
9715    ///
9716    /// </div>
9717    pub async fn enable(&self, params: SessionPluginsEnableRequest) -> Result<(), Error> {
9718        let mut wire_params = serde_json::to_value(params)?;
9719        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9720        let _value = self
9721            .session
9722            .client()
9723            .call(rpc_methods::SESSION_PLUGINS_ENABLE, Some(wire_params))
9724            .await?;
9725        Ok(())
9726    }
9727
9728    /// Disables installed plugins when permitted by the live session's retained managed policy.
9729    ///
9730    /// Wire method: `session.plugins.disable`.
9731    ///
9732    /// # Parameters
9733    ///
9734    /// * `params` - Plugin names (or specs) to disable in the session's authoritative working directory.
9735    ///
9736    /// <div class="warning">
9737    ///
9738    /// **Experimental.** This API is part of an experimental wire-protocol surface
9739    /// and may change or be removed in future SDK or CLI releases. Pin both the
9740    /// SDK and CLI versions if your code depends on it.
9741    ///
9742    /// </div>
9743    pub async fn disable(&self, params: SessionPluginsDisableRequest) -> Result<(), Error> {
9744        let mut wire_params = serde_json::to_value(params)?;
9745        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9746        let _value = self
9747            .session
9748            .client()
9749            .call(rpc_methods::SESSION_PLUGINS_DISABLE, Some(wire_params))
9750            .await?;
9751        Ok(())
9752    }
9753
9754    /// 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.
9755    ///
9756    /// Wire method: `session.plugins.reload`.
9757    ///
9758    /// <div class="warning">
9759    ///
9760    /// **Experimental.** This API is part of an experimental wire-protocol surface
9761    /// and may change or be removed in future SDK or CLI releases. Pin both the
9762    /// SDK and CLI versions if your code depends on it.
9763    ///
9764    /// </div>
9765    pub async fn reload(&self) -> Result<(), Error> {
9766        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9767        let _value = self
9768            .session
9769            .client()
9770            .call(rpc_methods::SESSION_PLUGINS_RELOAD, Some(wire_params))
9771            .await?;
9772        Ok(())
9773    }
9774
9775    /// 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.
9776    ///
9777    /// Wire method: `session.plugins.reload`.
9778    ///
9779    /// # Parameters
9780    ///
9781    /// * `params` - Optional flags controlling which side effects the reload performs.
9782    ///
9783    /// <div class="warning">
9784    ///
9785    /// **Experimental.** This API is part of an experimental wire-protocol surface
9786    /// and may change or be removed in future SDK or CLI releases. Pin both the
9787    /// SDK and CLI versions if your code depends on it.
9788    ///
9789    /// </div>
9790    pub async fn reload_with_params(&self, params: PluginsReloadRequest) -> Result<(), Error> {
9791        let mut wire_params = serde_json::to_value(params)?;
9792        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9793        let _value = self
9794            .session
9795            .client()
9796            .call(rpc_methods::SESSION_PLUGINS_RELOAD, Some(wire_params))
9797            .await?;
9798        Ok(())
9799    }
9800}
9801
9802/// `session.plugins.marketplaces.*` RPCs.
9803#[derive(Clone, Copy)]
9804pub struct SessionRpcPluginsMarketplaces<'a> {
9805    pub(crate) session: &'a Session,
9806}
9807
9808impl<'a> SessionRpcPluginsMarketplaces<'a> {
9809    /// Lists registered and enterprise-managed desired marketplaces using the live session's retained policy.
9810    ///
9811    /// Wire method: `session.plugins.marketplaces.list`.
9812    ///
9813    /// # Returns
9814    ///
9815    /// All registered marketplaces, including built-in defaults.
9816    ///
9817    /// <div class="warning">
9818    ///
9819    /// **Experimental.** This API is part of an experimental wire-protocol surface
9820    /// and may change or be removed in future SDK or CLI releases. Pin both the
9821    /// SDK and CLI versions if your code depends on it.
9822    ///
9823    /// </div>
9824    pub async fn list(&self) -> Result<MarketplaceListResult, Error> {
9825        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9826        let _value = self
9827            .session
9828            .client()
9829            .call(
9830                rpc_methods::SESSION_PLUGINS_MARKETPLACES_LIST,
9831                Some(wire_params),
9832            )
9833            .await?;
9834        Ok(serde_json::from_value(_value)?)
9835    }
9836
9837    /// Adds a marketplace when permitted by the live session's retained managed policy.
9838    ///
9839    /// Wire method: `session.plugins.marketplaces.add`.
9840    ///
9841    /// # Parameters
9842    ///
9843    /// * `params` - Marketplace source and optional working directory for relative-path resolution.
9844    ///
9845    /// # Returns
9846    ///
9847    /// Result of registering a new marketplace.
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 add(
9857        &self,
9858        params: PluginsMarketplacesAddRequest,
9859    ) -> Result<MarketplaceAddResult, Error> {
9860        let mut wire_params = serde_json::to_value(params)?;
9861        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9862        let _value = self
9863            .session
9864            .client()
9865            .call(
9866                rpc_methods::SESSION_PLUGINS_MARKETPLACES_ADD,
9867                Some(wire_params),
9868            )
9869            .await?;
9870        Ok(serde_json::from_value(_value)?)
9871    }
9872
9873    /// Removes a marketplace when permitted by the live session's retained managed policy.
9874    ///
9875    /// Wire method: `session.plugins.marketplaces.remove`.
9876    ///
9877    /// # Parameters
9878    ///
9879    /// * `params` - Name of the marketplace to remove and an optional force flag.
9880    ///
9881    /// # Returns
9882    ///
9883    /// Outcome of the remove attempt, including dependent-plugin info when applicable.
9884    ///
9885    /// <div class="warning">
9886    ///
9887    /// **Experimental.** This API is part of an experimental wire-protocol surface
9888    /// and may change or be removed in future SDK or CLI releases. Pin both the
9889    /// SDK and CLI versions if your code depends on it.
9890    ///
9891    /// </div>
9892    pub async fn remove(
9893        &self,
9894        params: PluginsMarketplacesRemoveRequest,
9895    ) -> Result<MarketplaceRemoveResult, Error> {
9896        let mut wire_params = serde_json::to_value(params)?;
9897        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9898        let _value = self
9899            .session
9900            .client()
9901            .call(
9902                rpc_methods::SESSION_PLUGINS_MARKETPLACES_REMOVE,
9903                Some(wire_params),
9904            )
9905            .await?;
9906        Ok(serde_json::from_value(_value)?)
9907    }
9908
9909    /// Browses a marketplace resolved through the live session's working directory and retained managed policy.
9910    ///
9911    /// Wire method: `session.plugins.marketplaces.browse`.
9912    ///
9913    /// # Parameters
9914    ///
9915    /// * `params` - Name of the marketplace whose plugin catalog to fetch.
9916    ///
9917    /// # Returns
9918    ///
9919    /// Plugins advertised by the marketplace.
9920    ///
9921    /// <div class="warning">
9922    ///
9923    /// **Experimental.** This API is part of an experimental wire-protocol surface
9924    /// and may change or be removed in future SDK or CLI releases. Pin both the
9925    /// SDK and CLI versions if your code depends on it.
9926    ///
9927    /// </div>
9928    pub async fn browse(
9929        &self,
9930        params: PluginsMarketplacesBrowseRequest,
9931    ) -> Result<MarketplaceBrowseResult, Error> {
9932        let mut wire_params = serde_json::to_value(params)?;
9933        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9934        let _value = self
9935            .session
9936            .client()
9937            .call(
9938                rpc_methods::SESSION_PLUGINS_MARKETPLACES_BROWSE,
9939                Some(wire_params),
9940            )
9941            .await?;
9942        Ok(serde_json::from_value(_value)?)
9943    }
9944
9945    /// Refreshes marketplaces resolved through the live session's working directory and retained managed policy.
9946    ///
9947    /// Wire method: `session.plugins.marketplaces.refresh`.
9948    ///
9949    /// # Returns
9950    ///
9951    /// Result of refreshing one or more marketplace catalogs.
9952    ///
9953    /// <div class="warning">
9954    ///
9955    /// **Experimental.** This API is part of an experimental wire-protocol surface
9956    /// and may change or be removed in future SDK or CLI releases. Pin both the
9957    /// SDK and CLI versions if your code depends on it.
9958    ///
9959    /// </div>
9960    pub async fn refresh(&self) -> Result<MarketplaceRefreshResult, Error> {
9961        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9962        let _value = self
9963            .session
9964            .client()
9965            .call(
9966                rpc_methods::SESSION_PLUGINS_MARKETPLACES_REFRESH,
9967                Some(wire_params),
9968            )
9969            .await?;
9970        Ok(serde_json::from_value(_value)?)
9971    }
9972
9973    /// Refreshes marketplaces resolved through the live session's working directory and retained managed policy.
9974    ///
9975    /// Wire method: `session.plugins.marketplaces.refresh`.
9976    ///
9977    /// # Parameters
9978    ///
9979    /// * `params` - Optional marketplace name; omit to refresh all.
9980    ///
9981    /// # Returns
9982    ///
9983    /// Result of refreshing one or more marketplace catalogs.
9984    ///
9985    /// <div class="warning">
9986    ///
9987    /// **Experimental.** This API is part of an experimental wire-protocol surface
9988    /// and may change or be removed in future SDK or CLI releases. Pin both the
9989    /// SDK and CLI versions if your code depends on it.
9990    ///
9991    /// </div>
9992    pub async fn refresh_with_params(
9993        &self,
9994        params: PluginsMarketplacesRefreshRequest,
9995    ) -> Result<MarketplaceRefreshResult, Error> {
9996        let mut wire_params = serde_json::to_value(params)?;
9997        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9998        let _value = self
9999            .session
10000            .client()
10001            .call(
10002                rpc_methods::SESSION_PLUGINS_MARKETPLACES_REFRESH,
10003                Some(wire_params),
10004            )
10005            .await?;
10006        Ok(serde_json::from_value(_value)?)
10007    }
10008}
10009
10010/// `session.provider.*` RPCs.
10011#[derive(Clone, Copy)]
10012pub struct SessionRpcProvider<'a> {
10013    pub(crate) session: &'a Session,
10014}
10015
10016impl<'a> SessionRpcProvider<'a> {
10017    /// 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.
10018    ///
10019    /// Wire method: `session.provider.getEndpoint`.
10020    ///
10021    /// # Returns
10022    ///
10023    /// A snapshot of the provider endpoint the session is currently configured to talk to.
10024    ///
10025    /// <div class="warning">
10026    ///
10027    /// **Experimental.** This API is part of an experimental wire-protocol surface
10028    /// and may change or be removed in future SDK or CLI releases. Pin both the
10029    /// SDK and CLI versions if your code depends on it.
10030    ///
10031    /// </div>
10032    pub async fn get_endpoint(&self) -> Result<ProviderEndpoint, Error> {
10033        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10034        let _value = self
10035            .session
10036            .client()
10037            .call(rpc_methods::SESSION_PROVIDER_GETENDPOINT, Some(wire_params))
10038            .await?;
10039        Ok(serde_json::from_value(_value)?)
10040    }
10041
10042    /// 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.
10043    ///
10044    /// Wire method: `session.provider.getEndpoint`.
10045    ///
10046    /// # Parameters
10047    ///
10048    /// * `params` - Optional model identifier to scope the endpoint snapshot to.
10049    ///
10050    /// # Returns
10051    ///
10052    /// A snapshot of the provider endpoint the session is currently configured to talk to.
10053    ///
10054    /// <div class="warning">
10055    ///
10056    /// **Experimental.** This API is part of an experimental wire-protocol surface
10057    /// and may change or be removed in future SDK or CLI releases. Pin both the
10058    /// SDK and CLI versions if your code depends on it.
10059    ///
10060    /// </div>
10061    pub async fn get_endpoint_with_params(
10062        &self,
10063        params: ProviderGetEndpointRequest,
10064    ) -> Result<ProviderEndpoint, Error> {
10065        let mut wire_params = serde_json::to_value(params)?;
10066        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10067        let _value = self
10068            .session
10069            .client()
10070            .call(rpc_methods::SESSION_PROVIDER_GETENDPOINT, Some(wire_params))
10071            .await?;
10072        Ok(serde_json::from_value(_value)?)
10073    }
10074
10075    /// 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.
10076    ///
10077    /// Wire method: `session.provider.add`.
10078    ///
10079    /// # Parameters
10080    ///
10081    /// * `params` - BYOK providers and/or models to add to the session's registry at runtime. Both fields are optional; provide providers, models, or both.
10082    ///
10083    /// # Returns
10084    ///
10085    /// The selectable model entries synthesized for the models added by this call.
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 async fn add(&self, params: ProviderAddRequest) -> Result<ProviderAddResult, Error> {
10095        let mut wire_params = serde_json::to_value(params)?;
10096        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10097        let _value = self
10098            .session
10099            .client()
10100            .call(rpc_methods::SESSION_PROVIDER_ADD, Some(wire_params))
10101            .await?;
10102        Ok(serde_json::from_value(_value)?)
10103    }
10104
10105    /// Atomically updates the session's BYOK provider and model registry by applying the supplied snapshot, replacing existing entries, updating models, or removing entries absent from the snapshot.
10106    ///
10107    /// Wire method: `session.provider.sync`.
10108    ///
10109    /// # Parameters
10110    ///
10111    /// * `params` - Authoritative BYOK provider and model registry snapshot to apply atomically to the session.
10112    ///
10113    /// # Returns
10114    ///
10115    /// The selectable model entries and selection ids synthesized for the synchronized BYOK models.
10116    ///
10117    /// <div class="warning">
10118    ///
10119    /// **Experimental.** This API is part of an experimental wire-protocol surface
10120    /// and may change or be removed in future SDK or CLI releases. Pin both the
10121    /// SDK and CLI versions if your code depends on it.
10122    ///
10123    /// </div>
10124    pub async fn sync(&self, params: ProviderSyncRequest) -> Result<ProviderSyncResult, Error> {
10125        let mut wire_params = serde_json::to_value(params)?;
10126        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10127        let _value = self
10128            .session
10129            .client()
10130            .call(rpc_methods::SESSION_PROVIDER_SYNC, Some(wire_params))
10131            .await?;
10132        Ok(serde_json::from_value(_value)?)
10133    }
10134}
10135
10136/// `session.queue.*` RPCs.
10137#[derive(Clone, Copy)]
10138pub struct SessionRpcQueue<'a> {
10139    pub(crate) session: &'a Session,
10140}
10141
10142impl<'a> SessionRpcQueue<'a> {
10143    /// Returns the local session's pending user-facing queued items and steering messages.
10144    ///
10145    /// Wire method: `session.queue.pendingItems`.
10146    ///
10147    /// # Returns
10148    ///
10149    /// Snapshot of the session's pending queued items and immediate-steering messages.
10150    ///
10151    /// <div class="warning">
10152    ///
10153    /// **Experimental.** This API is part of an experimental wire-protocol surface
10154    /// and may change or be removed in future SDK or CLI releases. Pin both the
10155    /// SDK and CLI versions if your code depends on it.
10156    ///
10157    /// </div>
10158    pub async fn pending_items(&self) -> Result<QueuePendingItemsResult, Error> {
10159        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10160        let _value = self
10161            .session
10162            .client()
10163            .call(rpc_methods::SESSION_QUEUE_PENDINGITEMS, Some(wire_params))
10164            .await?;
10165        Ok(serde_json::from_value(_value)?)
10166    }
10167
10168    /// Returns the internal native queue snapshot for in-process session orchestration.
10169    ///
10170    /// Wire method: `session.queue.snapshot`.
10171    ///
10172    /// # Returns
10173    ///
10174    /// Internal snapshot of native queue state for local session orchestration.
10175    ///
10176    /// <div class="warning">
10177    ///
10178    /// **Experimental.** This API is part of an experimental wire-protocol surface
10179    /// and may change or be removed in future SDK or CLI releases. Pin both the
10180    /// SDK and CLI versions if your code depends on it.
10181    ///
10182    /// </div>
10183    pub(crate) async fn snapshot(&self) -> Result<QueueSnapshotResult, Error> {
10184        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10185        let _value = self
10186            .session
10187            .client()
10188            .call(rpc_methods::SESSION_QUEUE_SNAPSHOT, Some(wire_params))
10189            .await?;
10190        Ok(serde_json::from_value(_value)?)
10191    }
10192
10193    /// Moves an addressable queued item to a public visible position.
10194    ///
10195    /// Wire method: `session.queue.moveItem`.
10196    ///
10197    /// # Parameters
10198    ///
10199    /// * `params` - Parameters for moving a queued item by stable id.
10200    ///
10201    /// # Returns
10202    ///
10203    /// Result of moving a queued item.
10204    ///
10205    /// <div class="warning">
10206    ///
10207    /// **Experimental.** This API is part of an experimental wire-protocol surface
10208    /// and may change or be removed in future SDK or CLI releases. Pin both the
10209    /// SDK and CLI versions if your code depends on it.
10210    ///
10211    /// </div>
10212    pub async fn move_item(
10213        &self,
10214        params: QueueMoveItemRequest,
10215    ) -> Result<QueueMoveItemResult, Error> {
10216        let mut wire_params = serde_json::to_value(params)?;
10217        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10218        let _value = self
10219            .session
10220            .client()
10221            .call(rpc_methods::SESSION_QUEUE_MOVEITEM, Some(wire_params))
10222            .await?;
10223        Ok(serde_json::from_value(_value)?)
10224    }
10225
10226    /// Inserts a new queued message at a public visible position.
10227    ///
10228    /// Wire method: `session.queue.insertAt`.
10229    ///
10230    /// # Parameters
10231    ///
10232    /// * `params` - Parameters for inserting a queued message at a public visible position.
10233    ///
10234    /// # Returns
10235    ///
10236    /// Result of inserting a queued message.
10237    ///
10238    /// <div class="warning">
10239    ///
10240    /// **Experimental.** This API is part of an experimental wire-protocol surface
10241    /// and may change or be removed in future SDK or CLI releases. Pin both the
10242    /// SDK and CLI versions if your code depends on it.
10243    ///
10244    /// </div>
10245    pub async fn insert_at(
10246        &self,
10247        params: QueueInsertAtRequest,
10248    ) -> Result<QueueInsertAtResult, Error> {
10249        let mut wire_params = serde_json::to_value(params)?;
10250        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10251        let _value = self
10252            .session
10253            .client()
10254            .call(rpc_methods::SESSION_QUEUE_INSERTAT, Some(wire_params))
10255            .await?;
10256        Ok(serde_json::from_value(_value)?)
10257    }
10258
10259    /// Removes an addressable queued item by its stable id.
10260    ///
10261    /// Wire method: `session.queue.removeAt`.
10262    ///
10263    /// # Parameters
10264    ///
10265    /// * `params` - Parameters for removing a queued item by stable id.
10266    ///
10267    /// # Returns
10268    ///
10269    /// Result of removing a queued item.
10270    ///
10271    /// <div class="warning">
10272    ///
10273    /// **Experimental.** This API is part of an experimental wire-protocol surface
10274    /// and may change or be removed in future SDK or CLI releases. Pin both the
10275    /// SDK and CLI versions if your code depends on it.
10276    ///
10277    /// </div>
10278    pub async fn remove_at(
10279        &self,
10280        params: QueueRemoveAtRequest,
10281    ) -> Result<QueueRemoveAtResult, Error> {
10282        let mut wire_params = serde_json::to_value(params)?;
10283        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10284        let _value = self
10285            .session
10286            .client()
10287            .call(rpc_methods::SESSION_QUEUE_REMOVEAT, Some(wire_params))
10288            .await?;
10289        Ok(serde_json::from_value(_value)?)
10290    }
10291
10292    /// Updates the text of an addressable single-message queue item.
10293    ///
10294    /// Wire method: `session.queue.updateText`.
10295    ///
10296    /// # Parameters
10297    ///
10298    /// * `params` - Parameters for editing a single queued message.
10299    ///
10300    /// # Returns
10301    ///
10302    /// Result of editing a queued message.
10303    ///
10304    /// <div class="warning">
10305    ///
10306    /// **Experimental.** This API is part of an experimental wire-protocol surface
10307    /// and may change or be removed in future SDK or CLI releases. Pin both the
10308    /// SDK and CLI versions if your code depends on it.
10309    ///
10310    /// </div>
10311    pub async fn update_text(
10312        &self,
10313        params: QueueUpdateTextRequest,
10314    ) -> Result<QueueUpdateTextResult, Error> {
10315        let mut wire_params = serde_json::to_value(params)?;
10316        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10317        let _value = self
10318            .session
10319            .client()
10320            .call(rpc_methods::SESSION_QUEUE_UPDATETEXT, Some(wire_params))
10321            .await?;
10322        Ok(serde_json::from_value(_value)?)
10323    }
10324
10325    /// Atomically withdraws an unchanged user message of a local session: from the queued or steering lane while unconsumed, or from the running turn it started while the model has not answered it and nothing the user sent after it is pending. Withdrawing from the running turn interrupts that turn and removes its events from history. A client retaining the original draft may restore it only when removed is true.
10326    ///
10327    /// Wire method: `session.queue.withdrawMessage`.
10328    ///
10329    /// # Parameters
10330    ///
10331    /// * `params` - Conditional withdrawal of a single user message, from its queue or from the running turn it started.
10332    ///
10333    /// # Returns
10334    ///
10335    /// Result of withdrawing a user message.
10336    ///
10337    /// <div class="warning">
10338    ///
10339    /// **Experimental.** This API is part of an experimental wire-protocol surface
10340    /// and may change or be removed in future SDK or CLI releases. Pin both the
10341    /// SDK and CLI versions if your code depends on it.
10342    ///
10343    /// </div>
10344    pub async fn withdraw_message(
10345        &self,
10346        params: QueueWithdrawMessageRequest,
10347    ) -> Result<QueueWithdrawMessageResult, Error> {
10348        let mut wire_params = serde_json::to_value(params)?;
10349        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10350        let _value = self
10351            .session
10352            .client()
10353            .call(
10354                rpc_methods::SESSION_QUEUE_WITHDRAWMESSAGE,
10355                Some(wire_params),
10356            )
10357            .await?;
10358        Ok(serde_json::from_value(_value)?)
10359    }
10360
10361    /// Atomically appends text and attachments to an unchanged, unconsumed local steering message. Returns updated=false if delivery or withdrawal already claimed the message.
10362    ///
10363    /// Wire method: `session.queue.appendSteering`.
10364    ///
10365    /// # Parameters
10366    ///
10367    /// * `params` - Append to one pending steering message without changing its identity or delivery position.
10368    ///
10369    /// # Returns
10370    ///
10371    /// Result of editing a queued message.
10372    ///
10373    /// <div class="warning">
10374    ///
10375    /// **Experimental.** This API is part of an experimental wire-protocol surface
10376    /// and may change or be removed in future SDK or CLI releases. Pin both the
10377    /// SDK and CLI versions if your code depends on it.
10378    ///
10379    /// </div>
10380    pub async fn append_steering(
10381        &self,
10382        params: QueueAppendSteeringRequest,
10383    ) -> Result<QueueUpdateTextResult, Error> {
10384        let mut wire_params = serde_json::to_value(params)?;
10385        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10386        let _value = self
10387            .session
10388            .client()
10389            .call(rpc_methods::SESSION_QUEUE_APPENDSTEERING, Some(wire_params))
10390            .await?;
10391        Ok(serde_json::from_value(_value)?)
10392    }
10393
10394    /// Duplicates an addressable queued item immediately after its source.
10395    ///
10396    /// Wire method: `session.queue.duplicateAt`.
10397    ///
10398    /// # Parameters
10399    ///
10400    /// * `params` - Parameters for duplicating a queued item.
10401    ///
10402    /// # Returns
10403    ///
10404    /// Result of duplicating a queued item.
10405    ///
10406    /// <div class="warning">
10407    ///
10408    /// **Experimental.** This API is part of an experimental wire-protocol surface
10409    /// and may change or be removed in future SDK or CLI releases. Pin both the
10410    /// SDK and CLI versions if your code depends on it.
10411    ///
10412    /// </div>
10413    pub async fn duplicate_at(
10414        &self,
10415        params: QueueDuplicateAtRequest,
10416    ) -> Result<QueueDuplicateAtResult, Error> {
10417        let mut wire_params = serde_json::to_value(params)?;
10418        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10419        let _value = self
10420            .session
10421            .client()
10422            .call(rpc_methods::SESSION_QUEUE_DUPLICATEAT, Some(wire_params))
10423            .await?;
10424        Ok(serde_json::from_value(_value)?)
10425    }
10426
10427    /// Acquires or releases the queued-lane drain pause.
10428    ///
10429    /// Wire method: `session.queue.setDrainPaused`.
10430    ///
10431    /// # Parameters
10432    ///
10433    /// * `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.
10434    ///
10435    /// <div class="warning">
10436    ///
10437    /// **Experimental.** This API is part of an experimental wire-protocol surface
10438    /// and may change or be removed in future SDK or CLI releases. Pin both the
10439    /// SDK and CLI versions if your code depends on it.
10440    ///
10441    /// </div>
10442    pub async fn set_drain_paused(&self, params: QueueSetDrainPausedRequest) -> Result<(), Error> {
10443        let mut wire_params = serde_json::to_value(params)?;
10444        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10445        let _value = self
10446            .session
10447            .client()
10448            .call(rpc_methods::SESSION_QUEUE_SETDRAINPAUSED, Some(wire_params))
10449            .await?;
10450        Ok(())
10451    }
10452
10453    /// Moves an addressable queued message into the live turn's steering lane.
10454    ///
10455    /// Wire method: `session.queue.sendNow`.
10456    ///
10457    /// # Parameters
10458    ///
10459    /// * `params` - Parameters for steering a queued message into a live turn.
10460    ///
10461    /// # Returns
10462    ///
10463    /// Result of trying to steer a queued message into a live turn.
10464    ///
10465    /// <div class="warning">
10466    ///
10467    /// **Experimental.** This API is part of an experimental wire-protocol surface
10468    /// and may change or be removed in future SDK or CLI releases. Pin both the
10469    /// SDK and CLI versions if your code depends on it.
10470    ///
10471    /// </div>
10472    pub async fn send_now(&self, params: QueueSendNowRequest) -> Result<QueueSendNowResult, Error> {
10473        let mut wire_params = serde_json::to_value(params)?;
10474        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10475        let _value = self
10476            .session
10477            .client()
10478            .call(rpc_methods::SESSION_QUEUE_SENDNOW, Some(wire_params))
10479            .await?;
10480        Ok(serde_json::from_value(_value)?)
10481    }
10482
10483    /// Reports whether the local session has native queued work pending.
10484    ///
10485    /// Wire method: `session.queue.hasPending`.
10486    ///
10487    /// # Returns
10488    ///
10489    /// Whether the native queue has pending work.
10490    ///
10491    /// <div class="warning">
10492    ///
10493    /// **Experimental.** This API is part of an experimental wire-protocol surface
10494    /// and may change or be removed in future SDK or CLI releases. Pin both the
10495    /// SDK and CLI versions if your code depends on it.
10496    ///
10497    /// </div>
10498    pub(crate) async fn has_pending(&self) -> Result<QueueHasPendingResult, Error> {
10499        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10500        let _value = self
10501            .session
10502            .client()
10503            .call(rpc_methods::SESSION_QUEUE_HASPENDING, Some(wire_params))
10504            .await?;
10505        Ok(serde_json::from_value(_value)?)
10506    }
10507
10508    /// Begins a native deferred-idle drain when background work has quiesced.
10509    ///
10510    /// Wire method: `session.queue.beginDeferredIdleDrain`.
10511    ///
10512    /// # Parameters
10513    ///
10514    /// * `params` - Inputs for starting a deferred-idle drain.
10515    ///
10516    /// # Returns
10517    ///
10518    /// Whether a deferred-idle drain should run.
10519    ///
10520    /// <div class="warning">
10521    ///
10522    /// **Experimental.** This API is part of an experimental wire-protocol surface
10523    /// and may change or be removed in future SDK or CLI releases. Pin both the
10524    /// SDK and CLI versions if your code depends on it.
10525    ///
10526    /// </div>
10527    pub(crate) async fn begin_deferred_idle_drain(
10528        &self,
10529        params: QueueBeginDeferredIdleDrainRequest,
10530    ) -> Result<QueueBeginDeferredIdleDrainResult, Error> {
10531        let mut wire_params = serde_json::to_value(params)?;
10532        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10533        let _value = self
10534            .session
10535            .client()
10536            .call(
10537                rpc_methods::SESSION_QUEUE_BEGINDEFERREDIDLEDRAIN,
10538                Some(wire_params),
10539            )
10540            .await?;
10541        Ok(serde_json::from_value(_value)?)
10542    }
10543
10544    /// Finishes a native deferred-idle drain and reports whether to drain queue work or emit idle.
10545    ///
10546    /// Wire method: `session.queue.finishDeferredIdleDrain`.
10547    ///
10548    /// # Parameters
10549    ///
10550    /// * `params` - Inputs for completing a deferred-idle drain.
10551    ///
10552    /// # Returns
10553    ///
10554    /// Action selected by the native deferred-idle drain.
10555    ///
10556    /// <div class="warning">
10557    ///
10558    /// **Experimental.** This API is part of an experimental wire-protocol surface
10559    /// and may change or be removed in future SDK or CLI releases. Pin both the
10560    /// SDK and CLI versions if your code depends on it.
10561    ///
10562    /// </div>
10563    pub(crate) async fn finish_deferred_idle_drain(
10564        &self,
10565        params: QueueFinishDeferredIdleDrainRequest,
10566    ) -> Result<QueueFinishDeferredIdleDrainResult, Error> {
10567        let mut wire_params = serde_json::to_value(params)?;
10568        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10569        let _value = self
10570            .session
10571            .client()
10572            .call(
10573                rpc_methods::SESSION_QUEUE_FINISHDEFERREDIDLEDRAIN,
10574                Some(wire_params),
10575            )
10576            .await?;
10577        Ok(serde_json::from_value(_value)?)
10578    }
10579
10580    /// Marks session.idle as deferred by native background work state.
10581    ///
10582    /// Wire method: `session.queue.deferSessionIdle`.
10583    ///
10584    /// # Parameters
10585    ///
10586    /// * `params` - Inputs for marking session.idle deferred in native state.
10587    ///
10588    /// <div class="warning">
10589    ///
10590    /// **Experimental.** This API is part of an experimental wire-protocol surface
10591    /// and may change or be removed in future SDK or CLI releases. Pin both the
10592    /// SDK and CLI versions if your code depends on it.
10593    ///
10594    /// </div>
10595    pub(crate) async fn defer_session_idle(
10596        &self,
10597        params: QueueDeferSessionIdleRequest,
10598    ) -> Result<(), 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(
10605                rpc_methods::SESSION_QUEUE_DEFERSESSIONIDLE,
10606                Some(wire_params),
10607            )
10608            .await?;
10609        Ok(())
10610    }
10611
10612    /// Removes the most recently queued user-facing item (LIFO).
10613    ///
10614    /// Wire method: `session.queue.removeMostRecent`.
10615    ///
10616    /// # Returns
10617    ///
10618    /// Indicates whether a user-facing pending item was removed.
10619    ///
10620    /// <div class="warning">
10621    ///
10622    /// **Experimental.** This API is part of an experimental wire-protocol surface
10623    /// and may change or be removed in future SDK or CLI releases. Pin both the
10624    /// SDK and CLI versions if your code depends on it.
10625    ///
10626    /// </div>
10627    pub async fn remove_most_recent(&self) -> Result<QueueRemoveMostRecentResult, Error> {
10628        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10629        let _value = self
10630            .session
10631            .client()
10632            .call(
10633                rpc_methods::SESSION_QUEUE_REMOVEMOSTRECENT,
10634                Some(wire_params),
10635            )
10636            .await?;
10637        Ok(serde_json::from_value(_value)?)
10638    }
10639
10640    /// Clears all pending queued items on the local session.
10641    ///
10642    /// Wire method: `session.queue.clear`.
10643    ///
10644    /// <div class="warning">
10645    ///
10646    /// **Experimental.** This API is part of an experimental wire-protocol surface
10647    /// and may change or be removed in future SDK or CLI releases. Pin both the
10648    /// SDK and CLI versions if your code depends on it.
10649    ///
10650    /// </div>
10651    pub async fn clear(&self) -> Result<(), Error> {
10652        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10653        let _value = self
10654            .session
10655            .client()
10656            .call(rpc_methods::SESSION_QUEUE_CLEAR, Some(wire_params))
10657            .await?;
10658        Ok(())
10659    }
10660
10661    /// Consumes queued native system notifications matching an internal filter.
10662    ///
10663    /// Wire method: `session.queue.consumeSystemNotifications`.
10664    ///
10665    /// # Parameters
10666    ///
10667    /// * `params` - Internal filter for consuming queued system notifications.
10668    ///
10669    /// # Returns
10670    ///
10671    /// Indicates whether a user-facing pending item was removed.
10672    ///
10673    /// <div class="warning">
10674    ///
10675    /// **Experimental.** This API is part of an experimental wire-protocol surface
10676    /// and may change or be removed in future SDK or CLI releases. Pin both the
10677    /// SDK and CLI versions if your code depends on it.
10678    ///
10679    /// </div>
10680    pub(crate) async fn consume_system_notifications(
10681        &self,
10682        params: QueueConsumeSystemNotificationsRequest,
10683    ) -> Result<QueueRemoveMostRecentResult, Error> {
10684        let mut wire_params = serde_json::to_value(params)?;
10685        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10686        let _value = self
10687            .session
10688            .client()
10689            .call(
10690                rpc_methods::SESSION_QUEUE_CONSUMESYSTEMNOTIFICATIONS,
10691                Some(wire_params),
10692            )
10693            .await?;
10694        Ok(serde_json::from_value(_value)?)
10695    }
10696
10697    /// Enqueues the internal resume-pending wake item when orphan handling needs a follow-up turn.
10698    ///
10699    /// Wire method: `session.queue.enqueueResumePending`.
10700    ///
10701    /// # Returns
10702    ///
10703    /// Result of enqueueing the resume-pending wake item.
10704    ///
10705    /// <div class="warning">
10706    ///
10707    /// **Experimental.** This API is part of an experimental wire-protocol surface
10708    /// and may change or be removed in future SDK or CLI releases. Pin both the
10709    /// SDK and CLI versions if your code depends on it.
10710    ///
10711    /// </div>
10712    pub(crate) async fn enqueue_resume_pending(
10713        &self,
10714    ) -> Result<QueueEnqueueResumePendingResult, Error> {
10715        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10716        let _value = self
10717            .session
10718            .client()
10719            .call(
10720                rpc_methods::SESSION_QUEUE_ENQUEUERESUMEPENDING,
10721                Some(wire_params),
10722            )
10723            .await?;
10724        Ok(serde_json::from_value(_value)?)
10725    }
10726
10727    /// Drains the native local-session work queue for in-process session orchestration.
10728    ///
10729    /// Wire method: `session.queue.process`.
10730    ///
10731    /// <div class="warning">
10732    ///
10733    /// **Experimental.** This API is part of an experimental wire-protocol surface
10734    /// and may change or be removed in future SDK or CLI releases. Pin both the
10735    /// SDK and CLI versions if your code depends on it.
10736    ///
10737    /// </div>
10738    pub(crate) async fn process(&self) -> Result<(), Error> {
10739        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10740        let _value = self
10741            .session
10742            .client()
10743            .call(rpc_methods::SESSION_QUEUE_PROCESS, Some(wire_params))
10744            .await?;
10745        Ok(())
10746    }
10747}
10748
10749/// `session.remote.*` RPCs.
10750#[derive(Clone, Copy)]
10751pub struct SessionRpcRemote<'a> {
10752    pub(crate) session: &'a Session,
10753}
10754
10755impl<'a> SessionRpcRemote<'a> {
10756    /// Enables remote session export or steering.
10757    ///
10758    /// Wire method: `session.remote.enable`.
10759    ///
10760    /// # Parameters
10761    ///
10762    /// * `params` - Optional remote session mode ("off", "export", or "on"); defaults to enabling both export and remote steering.
10763    ///
10764    /// # Returns
10765    ///
10766    /// GitHub URL for the session and a flag indicating whether remote steering is enabled.
10767    ///
10768    /// <div class="warning">
10769    ///
10770    /// **Experimental.** This API is part of an experimental wire-protocol surface
10771    /// and may change or be removed in future SDK or CLI releases. Pin both the
10772    /// SDK and CLI versions if your code depends on it.
10773    ///
10774    /// </div>
10775    pub async fn enable(&self, params: RemoteEnableRequest) -> Result<RemoteEnableResult, Error> {
10776        let mut wire_params = serde_json::to_value(params)?;
10777        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10778        let _value = self
10779            .session
10780            .client()
10781            .call(rpc_methods::SESSION_REMOTE_ENABLE, Some(wire_params))
10782            .await?;
10783        Ok(serde_json::from_value(_value)?)
10784    }
10785
10786    /// Disables remote session export and steering.
10787    ///
10788    /// Wire method: `session.remote.disable`.
10789    ///
10790    /// <div class="warning">
10791    ///
10792    /// **Experimental.** This API is part of an experimental wire-protocol surface
10793    /// and may change or be removed in future SDK or CLI releases. Pin both the
10794    /// SDK and CLI versions if your code depends on it.
10795    ///
10796    /// </div>
10797    pub async fn disable(&self) -> Result<(), Error> {
10798        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10799        let _value = self
10800            .session
10801            .client()
10802            .call(rpc_methods::SESSION_REMOTE_DISABLE, Some(wire_params))
10803            .await?;
10804        Ok(())
10805    }
10806
10807    /// Persists a remote-steerability change emitted by the host as a session event.
10808    ///
10809    /// Wire method: `session.remote.notifySteerableChanged`.
10810    ///
10811    /// # Parameters
10812    ///
10813    /// * `params` - New remote-steerability state to persist as a `session.remote_steerable_changed` event.
10814    ///
10815    /// # Returns
10816    ///
10817    /// 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.
10818    ///
10819    /// <div class="warning">
10820    ///
10821    /// **Experimental.** This API is part of an experimental wire-protocol surface
10822    /// and may change or be removed in future SDK or CLI releases. Pin both the
10823    /// SDK and CLI versions if your code depends on it.
10824    ///
10825    /// </div>
10826    pub async fn notify_steerable_changed(
10827        &self,
10828        params: RemoteNotifySteerableChangedRequest,
10829    ) -> Result<RemoteNotifySteerableChangedResult, Error> {
10830        let mut wire_params = serde_json::to_value(params)?;
10831        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10832        let _value = self
10833            .session
10834            .client()
10835            .call(
10836                rpc_methods::SESSION_REMOTE_NOTIFYSTEERABLECHANGED,
10837                Some(wire_params),
10838            )
10839            .await?;
10840        Ok(serde_json::from_value(_value)?)
10841    }
10842}
10843
10844/// `session.sandbox.*` RPCs.
10845#[derive(Clone, Copy)]
10846pub struct SessionRpcSandbox<'a> {
10847    pub(crate) session: &'a Session,
10848}
10849
10850impl<'a> SessionRpcSandbox<'a> {
10851    /// Returns whether managed policy requires sandbox enforcement and whether an enforcement failure has permanently blocked the session.
10852    ///
10853    /// Wire method: `session.sandbox.getEnforcementStatus`.
10854    ///
10855    /// # Returns
10856    ///
10857    /// Managed sandbox enforcement state for a session.
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_enforcement_status(&self) -> Result<SandboxEnforcementStatus, Error> {
10867        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10868        let _value = self
10869            .session
10870            .client()
10871            .call(
10872                rpc_methods::SESSION_SANDBOX_GETENFORCEMENTSTATUS,
10873                Some(wire_params),
10874            )
10875            .await?;
10876        Ok(serde_json::from_value(_value)?)
10877    }
10878
10879    /// 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.
10880    ///
10881    /// Wire method: `session.sandbox.disableForSession`.
10882    ///
10883    /// # Parameters
10884    ///
10885    /// * `params` - Request to disable sandboxing for the current session while resolving an active sandbox-bypass permission prompt.
10886    ///
10887    /// # Returns
10888    ///
10889    /// Result of attempting to disable sandboxing for the current session.
10890    ///
10891    /// <div class="warning">
10892    ///
10893    /// **Experimental.** This API is part of an experimental wire-protocol surface
10894    /// and may change or be removed in future SDK or CLI releases. Pin both the
10895    /// SDK and CLI versions if your code depends on it.
10896    ///
10897    /// </div>
10898    pub async fn disable_for_session(
10899        &self,
10900        params: SandboxDisableForSessionRequest,
10901    ) -> Result<SandboxDisableForSessionResult, Error> {
10902        let mut wire_params = serde_json::to_value(params)?;
10903        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10904        let _value = self
10905            .session
10906            .client()
10907            .call(
10908                rpc_methods::SESSION_SANDBOX_DISABLEFORSESSION,
10909                Some(wire_params),
10910            )
10911            .await?;
10912        Ok(serde_json::from_value(_value)?)
10913    }
10914}
10915
10916/// `session.schedule.*` RPCs.
10917#[derive(Clone, Copy)]
10918pub struct SessionRpcSchedule<'a> {
10919    pub(crate) session: &'a Session,
10920}
10921
10922impl<'a> SessionRpcSchedule<'a> {
10923    /// Lists the session's currently active scheduled prompts.
10924    ///
10925    /// Wire method: `session.schedule.list`.
10926    ///
10927    /// # Returns
10928    ///
10929    /// Snapshot of the currently active recurring prompts for this session.
10930    ///
10931    /// <div class="warning">
10932    ///
10933    /// **Experimental.** This API is part of an experimental wire-protocol surface
10934    /// and may change or be removed in future SDK or CLI releases. Pin both the
10935    /// SDK and CLI versions if your code depends on it.
10936    ///
10937    /// </div>
10938    pub async fn list(&self) -> Result<ScheduleList, Error> {
10939        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10940        let _value = self
10941            .session
10942            .client()
10943            .call(rpc_methods::SESSION_SCHEDULE_LIST, Some(wire_params))
10944            .await?;
10945        Ok(serde_json::from_value(_value)?)
10946    }
10947
10948    /// Hydrates the native schedule registry from persisted session events.
10949    ///
10950    /// Wire method: `session.schedule.hydrate`.
10951    ///
10952    /// <div class="warning">
10953    ///
10954    /// **Experimental.** This API is part of an experimental wire-protocol surface
10955    /// and may change or be removed in future SDK or CLI releases. Pin both the
10956    /// SDK and CLI versions if your code depends on it.
10957    ///
10958    /// </div>
10959    pub(crate) async fn hydrate(&self) -> Result<(), Error> {
10960        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10961        let _value = self
10962            .session
10963            .client()
10964            .call(rpc_methods::SESSION_SCHEDULE_HYDRATE, Some(wire_params))
10965            .await?;
10966        Ok(())
10967    }
10968
10969    /// Reports whether the session has an active self-paced scheduled prompt.
10970    ///
10971    /// Wire method: `session.schedule.hasSelfPaced`.
10972    ///
10973    /// # Returns
10974    ///
10975    /// Whether the session currently has an active self-paced schedule.
10976    ///
10977    /// <div class="warning">
10978    ///
10979    /// **Experimental.** This API is part of an experimental wire-protocol surface
10980    /// and may change or be removed in future SDK or CLI releases. Pin both the
10981    /// SDK and CLI versions if your code depends on it.
10982    ///
10983    /// </div>
10984    pub(crate) async fn has_self_paced(&self) -> Result<ScheduleHasSelfPacedResult, Error> {
10985        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10986        let _value = self
10987            .session
10988            .client()
10989            .call(
10990                rpc_methods::SESSION_SCHEDULE_HASSELFPACED,
10991                Some(wire_params),
10992            )
10993            .await?;
10994        Ok(serde_json::from_value(_value)?)
10995    }
10996
10997    /// Registers a relative-interval scheduled prompt.
10998    ///
10999    /// Wire method: `session.schedule.add`.
11000    ///
11001    /// # Parameters
11002    ///
11003    /// * `params` - Register a relative-interval scheduled prompt.
11004    ///
11005    /// # Returns
11006    ///
11007    /// Result of registering or re-arming a scheduled prompt.
11008    ///
11009    /// <div class="warning">
11010    ///
11011    /// **Experimental.** This API is part of an experimental wire-protocol surface
11012    /// and may change or be removed in future SDK or CLI releases. Pin both the
11013    /// SDK and CLI versions if your code depends on it.
11014    ///
11015    /// </div>
11016    pub(crate) async fn add(&self, params: ScheduleAddRequest) -> Result<ScheduleAddResult, Error> {
11017        let mut wire_params = serde_json::to_value(params)?;
11018        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11019        let _value = self
11020            .session
11021            .client()
11022            .call(rpc_methods::SESSION_SCHEDULE_ADD, Some(wire_params))
11023            .await?;
11024        Ok(serde_json::from_value(_value)?)
11025    }
11026
11027    /// Registers a recurring cron scheduled prompt.
11028    ///
11029    /// Wire method: `session.schedule.addCron`.
11030    ///
11031    /// # Parameters
11032    ///
11033    /// * `params` - Register a cron scheduled prompt.
11034    ///
11035    /// # Returns
11036    ///
11037    /// Result of registering or re-arming a scheduled prompt.
11038    ///
11039    /// <div class="warning">
11040    ///
11041    /// **Experimental.** This API is part of an experimental wire-protocol surface
11042    /// and may change or be removed in future SDK or CLI releases. Pin both the
11043    /// SDK and CLI versions if your code depends on it.
11044    ///
11045    /// </div>
11046    pub(crate) async fn add_cron(
11047        &self,
11048        params: ScheduleAddCronRequest,
11049    ) -> Result<ScheduleAddResult, Error> {
11050        let mut wire_params = serde_json::to_value(params)?;
11051        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11052        let _value = self
11053            .session
11054            .client()
11055            .call(rpc_methods::SESSION_SCHEDULE_ADDCRON, Some(wire_params))
11056            .await?;
11057        Ok(serde_json::from_value(_value)?)
11058    }
11059
11060    /// Registers an absolute-time scheduled prompt.
11061    ///
11062    /// Wire method: `session.schedule.addAt`.
11063    ///
11064    /// # Parameters
11065    ///
11066    /// * `params` - Register an absolute-time scheduled prompt.
11067    ///
11068    /// # Returns
11069    ///
11070    /// Result of registering or re-arming a scheduled prompt.
11071    ///
11072    /// <div class="warning">
11073    ///
11074    /// **Experimental.** This API is part of an experimental wire-protocol surface
11075    /// and may change or be removed in future SDK or CLI releases. Pin both the
11076    /// SDK and CLI versions if your code depends on it.
11077    ///
11078    /// </div>
11079    pub(crate) async fn add_at(
11080        &self,
11081        params: ScheduleAddAtRequest,
11082    ) -> Result<ScheduleAddResult, Error> {
11083        let mut wire_params = serde_json::to_value(params)?;
11084        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11085        let _value = self
11086            .session
11087            .client()
11088            .call(rpc_methods::SESSION_SCHEDULE_ADDAT, Some(wire_params))
11089            .await?;
11090        Ok(serde_json::from_value(_value)?)
11091    }
11092
11093    /// Registers a self-paced scheduled prompt.
11094    ///
11095    /// Wire method: `session.schedule.addSelfPaced`.
11096    ///
11097    /// # Parameters
11098    ///
11099    /// * `params` - Register a self-paced scheduled prompt.
11100    ///
11101    /// # Returns
11102    ///
11103    /// Result of registering or re-arming a scheduled prompt.
11104    ///
11105    /// <div class="warning">
11106    ///
11107    /// **Experimental.** This API is part of an experimental wire-protocol surface
11108    /// and may change or be removed in future SDK or CLI releases. Pin both the
11109    /// SDK and CLI versions if your code depends on it.
11110    ///
11111    /// </div>
11112    pub(crate) async fn add_self_paced(
11113        &self,
11114        params: ScheduleAddSelfPacedRequest,
11115    ) -> Result<ScheduleAddResult, Error> {
11116        let mut wire_params = serde_json::to_value(params)?;
11117        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11118        let _value = self
11119            .session
11120            .client()
11121            .call(
11122                rpc_methods::SESSION_SCHEDULE_ADDSELFPACED,
11123                Some(wire_params),
11124            )
11125            .await?;
11126        Ok(serde_json::from_value(_value)?)
11127    }
11128
11129    /// Re-arms an active self-paced scheduled prompt.
11130    ///
11131    /// Wire method: `session.schedule.rearmSelfPaced`.
11132    ///
11133    /// # Parameters
11134    ///
11135    /// * `params` - Re-arm a self-paced scheduled prompt.
11136    ///
11137    /// # Returns
11138    ///
11139    /// Result of registering or re-arming a scheduled prompt.
11140    ///
11141    /// <div class="warning">
11142    ///
11143    /// **Experimental.** This API is part of an experimental wire-protocol surface
11144    /// and may change or be removed in future SDK or CLI releases. Pin both the
11145    /// SDK and CLI versions if your code depends on it.
11146    ///
11147    /// </div>
11148    pub(crate) async fn rearm_self_paced(
11149        &self,
11150        params: ScheduleRearmSelfPacedRequest,
11151    ) -> Result<ScheduleAddResult, Error> {
11152        let mut wire_params = serde_json::to_value(params)?;
11153        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11154        let _value = self
11155            .session
11156            .client()
11157            .call(
11158                rpc_methods::SESSION_SCHEDULE_REARMSELFPACED,
11159                Some(wire_params),
11160            )
11161            .await?;
11162        Ok(serde_json::from_value(_value)?)
11163    }
11164
11165    /// Removes a scheduled prompt by id.
11166    ///
11167    /// Wire method: `session.schedule.stop`.
11168    ///
11169    /// # Parameters
11170    ///
11171    /// * `params` - Identifier of the scheduled prompt to remove.
11172    ///
11173    /// # Returns
11174    ///
11175    /// Remove a scheduled prompt by id. The result entry is omitted if the id was unknown.
11176    ///
11177    /// <div class="warning">
11178    ///
11179    /// **Experimental.** This API is part of an experimental wire-protocol surface
11180    /// and may change or be removed in future SDK or CLI releases. Pin both the
11181    /// SDK and CLI versions if your code depends on it.
11182    ///
11183    /// </div>
11184    pub async fn stop(&self, params: ScheduleStopRequest) -> Result<ScheduleStopResult, Error> {
11185        let mut wire_params = serde_json::to_value(params)?;
11186        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11187        let _value = self
11188            .session
11189            .client()
11190            .call(rpc_methods::SESSION_SCHEDULE_STOP, Some(wire_params))
11191            .await?;
11192        Ok(serde_json::from_value(_value)?)
11193    }
11194}
11195
11196/// `session.settings.*` RPCs.
11197#[derive(Clone, Copy)]
11198pub struct SessionRpcSettings<'a> {
11199    pub(crate) session: &'a Session,
11200}
11201
11202impl<'a> SessionRpcSettings<'a> {
11203    /// 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.
11204    ///
11205    /// Wire method: `session.settings.snapshot`.
11206    ///
11207    /// # Returns
11208    ///
11209    /// Redacted, serializable view of session runtime settings for SDK boundary consumers. Secrets and raw feature flags are intentionally excluded.
11210    ///
11211    /// <div class="warning">
11212    ///
11213    /// **Experimental.** This API is part of an experimental wire-protocol surface
11214    /// and may change or be removed in future SDK or CLI releases. Pin both the
11215    /// SDK and CLI versions if your code depends on it.
11216    ///
11217    /// </div>
11218    pub(crate) async fn snapshot(&self) -> Result<SessionSettingsSnapshot, Error> {
11219        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
11220        let _value = self
11221            .session
11222            .client()
11223            .call(rpc_methods::SESSION_SETTINGS_SNAPSHOT, Some(wire_params))
11224            .await?;
11225        Ok(serde_json::from_value(_value)?)
11226    }
11227
11228    /// 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.
11229    ///
11230    /// Wire method: `session.settings.evaluatePredicate`.
11231    ///
11232    /// # Parameters
11233    ///
11234    /// * `params` - Named Rust-owned settings predicate to evaluate for this session.
11235    ///
11236    /// # Returns
11237    ///
11238    /// Result of evaluating a Rust-owned settings predicate.
11239    ///
11240    /// <div class="warning">
11241    ///
11242    /// **Experimental.** This API is part of an experimental wire-protocol surface
11243    /// and may change or be removed in future SDK or CLI releases. Pin both the
11244    /// SDK and CLI versions if your code depends on it.
11245    ///
11246    /// </div>
11247    pub(crate) async fn evaluate_predicate(
11248        &self,
11249        params: SessionSettingsEvaluatePredicateRequest,
11250    ) -> Result<SessionSettingsEvaluatePredicateResult, Error> {
11251        let mut wire_params = serde_json::to_value(params)?;
11252        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11253        let _value = self
11254            .session
11255            .client()
11256            .call(
11257                rpc_methods::SESSION_SETTINGS_EVALUATEPREDICATE,
11258                Some(wire_params),
11259            )
11260            .await?;
11261        Ok(serde_json::from_value(_value)?)
11262    }
11263}
11264
11265/// `session.shell.*` RPCs.
11266#[derive(Clone, Copy)]
11267pub struct SessionRpcShell<'a> {
11268    pub(crate) session: &'a Session,
11269}
11270
11271impl<'a> SessionRpcShell<'a> {
11272    /// 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.
11273    ///
11274    /// Wire method: `session.shell.exec`.
11275    ///
11276    /// # Parameters
11277    ///
11278    /// * `params` - Shell command to run, with optional working directory and timeout in milliseconds.
11279    ///
11280    /// # Returns
11281    ///
11282    /// Identifier of the spawned process, used to correlate streamed output and exit notifications.
11283    ///
11284    /// <div class="warning">
11285    ///
11286    /// **Experimental.** This API is part of an experimental wire-protocol surface
11287    /// and may change or be removed in future SDK or CLI releases. Pin both the
11288    /// SDK and CLI versions if your code depends on it.
11289    ///
11290    /// </div>
11291    pub async fn exec(&self, params: ShellExecRequest) -> Result<ShellExecResult, Error> {
11292        let mut wire_params = serde_json::to_value(params)?;
11293        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11294        let _value = self
11295            .session
11296            .client()
11297            .call(rpc_methods::SESSION_SHELL_EXEC, Some(wire_params))
11298            .await?;
11299        Ok(serde_json::from_value(_value)?)
11300    }
11301
11302    /// 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.
11303    ///
11304    /// Wire method: `session.shell.kill`.
11305    ///
11306    /// # Parameters
11307    ///
11308    /// * `params` - Identifier of a process previously returned by "shell.exec" and the signal to send.
11309    ///
11310    /// # Returns
11311    ///
11312    /// Indicates whether the signal was delivered; false if the process was unknown or already exited.
11313    ///
11314    /// <div class="warning">
11315    ///
11316    /// **Experimental.** This API is part of an experimental wire-protocol surface
11317    /// and may change or be removed in future SDK or CLI releases. Pin both the
11318    /// SDK and CLI versions if your code depends on it.
11319    ///
11320    /// </div>
11321    pub async fn kill(&self, params: ShellKillRequest) -> Result<ShellKillResult, Error> {
11322        let mut wire_params = serde_json::to_value(params)?;
11323        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11324        let _value = self
11325            .session
11326            .client()
11327            .call(rpc_methods::SESSION_SHELL_KILL, Some(wire_params))
11328            .await?;
11329        Ok(serde_json::from_value(_value)?)
11330    }
11331
11332    /// Executes a user-requested shell command through the session runtime.
11333    ///
11334    /// Wire method: `session.shell.executeUserRequested`.
11335    ///
11336    /// # Parameters
11337    ///
11338    /// * `params` - User-requested shell command and cancellation handle.
11339    ///
11340    /// # Returns
11341    ///
11342    /// Result of a user-requested shell command.
11343    ///
11344    /// <div class="warning">
11345    ///
11346    /// **Experimental.** This API is part of an experimental wire-protocol surface
11347    /// and may change or be removed in future SDK or CLI releases. Pin both the
11348    /// SDK and CLI versions if your code depends on it.
11349    ///
11350    /// </div>
11351    pub async fn execute_user_requested(
11352        &self,
11353        params: ShellExecuteUserRequestedRequest,
11354    ) -> Result<UserRequestedShellCommandResult, Error> {
11355        let mut wire_params = serde_json::to_value(params)?;
11356        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11357        let _value = self
11358            .session
11359            .client()
11360            .call(
11361                rpc_methods::SESSION_SHELL_EXECUTEUSERREQUESTED,
11362                Some(wire_params),
11363            )
11364            .await?;
11365        Ok(serde_json::from_value(_value)?)
11366    }
11367
11368    /// Cancels a user-requested shell command by request ID.
11369    ///
11370    /// Wire method: `session.shell.cancelUserRequested`.
11371    ///
11372    /// # Parameters
11373    ///
11374    /// * `params` - User-requested shell execution cancellation handle.
11375    ///
11376    /// # Returns
11377    ///
11378    /// Cancellation result for a user-requested shell command.
11379    ///
11380    /// <div class="warning">
11381    ///
11382    /// **Experimental.** This API is part of an experimental wire-protocol surface
11383    /// and may change or be removed in future SDK or CLI releases. Pin both the
11384    /// SDK and CLI versions if your code depends on it.
11385    ///
11386    /// </div>
11387    pub async fn cancel_user_requested(
11388        &self,
11389        params: ShellCancelUserRequestedRequest,
11390    ) -> Result<CancelUserRequestedShellCommandResult, Error> {
11391        let mut wire_params = serde_json::to_value(params)?;
11392        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11393        let _value = self
11394            .session
11395            .client()
11396            .call(
11397                rpc_methods::SESSION_SHELL_CANCELUSERREQUESTED,
11398                Some(wire_params),
11399            )
11400            .await?;
11401        Ok(serde_json::from_value(_value)?)
11402    }
11403}
11404
11405/// `session.skills.*` RPCs.
11406#[derive(Clone, Copy)]
11407pub struct SessionRpcSkills<'a> {
11408    pub(crate) session: &'a Session,
11409}
11410
11411impl<'a> SessionRpcSkills<'a> {
11412    /// Lists skills available to the session.
11413    ///
11414    /// Wire method: `session.skills.list`.
11415    ///
11416    /// # Returns
11417    ///
11418    /// Skills available to the session, with their enabled state.
11419    ///
11420    /// <div class="warning">
11421    ///
11422    /// **Experimental.** This API is part of an experimental wire-protocol surface
11423    /// and may change or be removed in future SDK or CLI releases. Pin both the
11424    /// SDK and CLI versions if your code depends on it.
11425    ///
11426    /// </div>
11427    pub async fn list(&self) -> Result<SkillList, Error> {
11428        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
11429        let _value = self
11430            .session
11431            .client()
11432            .call(rpc_methods::SESSION_SKILLS_LIST, Some(wire_params))
11433            .await?;
11434        Ok(serde_json::from_value(_value)?)
11435    }
11436
11437    /// Returns the skills that have been invoked during this session.
11438    ///
11439    /// Wire method: `session.skills.getInvoked`.
11440    ///
11441    /// # Returns
11442    ///
11443    /// Skills invoked during this session, ordered by invocation time (most recent last).
11444    ///
11445    /// <div class="warning">
11446    ///
11447    /// **Experimental.** This API is part of an experimental wire-protocol surface
11448    /// and may change or be removed in future SDK or CLI releases. Pin both the
11449    /// SDK and CLI versions if your code depends on it.
11450    ///
11451    /// </div>
11452    pub async fn get_invoked(&self) -> Result<SkillsGetInvokedResult, Error> {
11453        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
11454        let _value = self
11455            .session
11456            .client()
11457            .call(rpc_methods::SESSION_SKILLS_GETINVOKED, Some(wire_params))
11458            .await?;
11459        Ok(serde_json::from_value(_value)?)
11460    }
11461
11462    /// Enables a skill for the session.
11463    ///
11464    /// Wire method: `session.skills.enable`.
11465    ///
11466    /// # Parameters
11467    ///
11468    /// * `params` - Name of the skill to enable for the session.
11469    ///
11470    /// <div class="warning">
11471    ///
11472    /// **Experimental.** This API is part of an experimental wire-protocol surface
11473    /// and may change or be removed in future SDK or CLI releases. Pin both the
11474    /// SDK and CLI versions if your code depends on it.
11475    ///
11476    /// </div>
11477    pub async fn enable(&self, params: SkillsEnableRequest) -> Result<(), Error> {
11478        let mut wire_params = serde_json::to_value(params)?;
11479        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11480        let _value = self
11481            .session
11482            .client()
11483            .call(rpc_methods::SESSION_SKILLS_ENABLE, Some(wire_params))
11484            .await?;
11485        Ok(())
11486    }
11487
11488    /// Disables a skill for the session.
11489    ///
11490    /// Wire method: `session.skills.disable`.
11491    ///
11492    /// # Parameters
11493    ///
11494    /// * `params` - Name of the skill to disable for the session.
11495    ///
11496    /// <div class="warning">
11497    ///
11498    /// **Experimental.** This API is part of an experimental wire-protocol surface
11499    /// and may change or be removed in future SDK or CLI releases. Pin both the
11500    /// SDK and CLI versions if your code depends on it.
11501    ///
11502    /// </div>
11503    pub async fn disable(&self, params: SkillsDisableRequest) -> Result<(), Error> {
11504        let mut wire_params = serde_json::to_value(params)?;
11505        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11506        let _value = self
11507            .session
11508            .client()
11509            .call(rpc_methods::SESSION_SKILLS_DISABLE, Some(wire_params))
11510            .await?;
11511        Ok(())
11512    }
11513
11514    /// Reloads skill definitions for the session.
11515    ///
11516    /// Wire method: `session.skills.reload`.
11517    ///
11518    /// # Returns
11519    ///
11520    /// Diagnostics from reloading skill definitions, with warnings and errors as separate lists.
11521    ///
11522    /// <div class="warning">
11523    ///
11524    /// **Experimental.** This API is part of an experimental wire-protocol surface
11525    /// and may change or be removed in future SDK or CLI releases. Pin both the
11526    /// SDK and CLI versions if your code depends on it.
11527    ///
11528    /// </div>
11529    pub async fn reload(&self) -> Result<SkillsLoadDiagnostics, Error> {
11530        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
11531        let _value = self
11532            .session
11533            .client()
11534            .call(rpc_methods::SESSION_SKILLS_RELOAD, Some(wire_params))
11535            .await?;
11536        Ok(serde_json::from_value(_value)?)
11537    }
11538
11539    /// Ensures the session's skill definitions have been loaded from disk.
11540    ///
11541    /// Wire method: `session.skills.ensureLoaded`.
11542    ///
11543    /// <div class="warning">
11544    ///
11545    /// **Experimental.** This API is part of an experimental wire-protocol surface
11546    /// and may change or be removed in future SDK or CLI releases. Pin both the
11547    /// SDK and CLI versions if your code depends on it.
11548    ///
11549    /// </div>
11550    pub async fn ensure_loaded(&self) -> Result<(), Error> {
11551        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
11552        let _value = self
11553            .session
11554            .client()
11555            .call(rpc_methods::SESSION_SKILLS_ENSURELOADED, Some(wire_params))
11556            .await?;
11557        Ok(())
11558    }
11559}
11560
11561/// `session.tasks.*` RPCs.
11562#[derive(Clone, Copy)]
11563pub struct SessionRpcTasks<'a> {
11564    pub(crate) session: &'a Session,
11565}
11566
11567impl<'a> SessionRpcTasks<'a> {
11568    /// Starts a background agent task in the session.
11569    ///
11570    /// Wire method: `session.tasks.startAgent`.
11571    ///
11572    /// # Parameters
11573    ///
11574    /// * `params` - Agent type, prompt, name, and optional description and model override for the new task.
11575    ///
11576    /// # Returns
11577    ///
11578    /// Identifier assigned to the newly started background agent task.
11579    ///
11580    /// <div class="warning">
11581    ///
11582    /// **Experimental.** This API is part of an experimental wire-protocol surface
11583    /// and may change or be removed in future SDK or CLI releases. Pin both the
11584    /// SDK and CLI versions if your code depends on it.
11585    ///
11586    /// </div>
11587    pub async fn start_agent(
11588        &self,
11589        params: TasksStartAgentRequest,
11590    ) -> Result<TasksStartAgentResult, Error> {
11591        let mut wire_params = serde_json::to_value(params)?;
11592        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11593        let _value = self
11594            .session
11595            .client()
11596            .call(rpc_methods::SESSION_TASKS_STARTAGENT, Some(wire_params))
11597            .await?;
11598        Ok(serde_json::from_value(_value)?)
11599    }
11600
11601    /// Lists background tasks tracked by the session.
11602    ///
11603    /// Wire method: `session.tasks.list`.
11604    ///
11605    /// # Returns
11606    ///
11607    /// Background tasks currently tracked by the session.
11608    ///
11609    /// <div class="warning">
11610    ///
11611    /// **Experimental.** This API is part of an experimental wire-protocol surface
11612    /// and may change or be removed in future SDK or CLI releases. Pin both the
11613    /// SDK and CLI versions if your code depends on it.
11614    ///
11615    /// </div>
11616    pub async fn list(&self) -> Result<TaskList, Error> {
11617        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
11618        let _value = self
11619            .session
11620            .client()
11621            .call(rpc_methods::SESSION_TASKS_LIST, Some(wire_params))
11622            .await?;
11623        Ok(serde_json::from_value(_value)?)
11624    }
11625
11626    /// Registers a client-owned task, or reclaims an orphaned task belonging to the same extension principal.
11627    ///
11628    /// Wire method: `session.tasks.register`.
11629    ///
11630    /// # Parameters
11631    ///
11632    /// * `params` - Registers or reclaims a client-owned task.
11633    ///
11634    /// # Returns
11635    ///
11636    /// Result of registering or reclaiming a client-owned task.
11637    ///
11638    /// <div class="warning">
11639    ///
11640    /// **Experimental.** This API is part of an experimental wire-protocol surface
11641    /// and may change or be removed in future SDK or CLI releases. Pin both the
11642    /// SDK and CLI versions if your code depends on it.
11643    ///
11644    /// </div>
11645    pub async fn register(
11646        &self,
11647        params: TasksRegisterRequest,
11648    ) -> Result<TasksRegisterResult, Error> {
11649        let mut wire_params = serde_json::to_value(params)?;
11650        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11651        let _value = self
11652            .session
11653            .client()
11654            .call(rpc_methods::SESSION_TASKS_REGISTER, Some(wire_params))
11655            .await?;
11656        Ok(serde_json::from_value(_value)?)
11657    }
11658
11659    /// Publishes generic progress or a terminal outcome for a client-owned task.
11660    ///
11661    /// Wire method: `session.tasks.update`.
11662    ///
11663    /// # Parameters
11664    ///
11665    /// * `params` - Updates a client-owned task.
11666    ///
11667    /// # Returns
11668    ///
11669    /// Result of publishing a client-owned task update.
11670    ///
11671    /// <div class="warning">
11672    ///
11673    /// **Experimental.** This API is part of an experimental wire-protocol surface
11674    /// and may change or be removed in future SDK or CLI releases. Pin both the
11675    /// SDK and CLI versions if your code depends on it.
11676    ///
11677    /// </div>
11678    pub async fn update(&self, params: TasksUpdateRequest) -> Result<TasksUpdateResult, Error> {
11679        let mut wire_params = serde_json::to_value(params)?;
11680        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11681        let _value = self
11682            .session
11683            .client()
11684            .call(rpc_methods::SESSION_TASKS_UPDATE, Some(wire_params))
11685            .await?;
11686        Ok(serde_json::from_value(_value)?)
11687    }
11688
11689    /// Refreshes metadata for any detached background shells the runtime knows about.
11690    ///
11691    /// Wire method: `session.tasks.refresh`.
11692    ///
11693    /// # Returns
11694    ///
11695    /// 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.
11696    ///
11697    /// <div class="warning">
11698    ///
11699    /// **Experimental.** This API is part of an experimental wire-protocol surface
11700    /// and may change or be removed in future SDK or CLI releases. Pin both the
11701    /// SDK and CLI versions if your code depends on it.
11702    ///
11703    /// </div>
11704    pub async fn refresh(&self) -> Result<TasksRefreshResult, Error> {
11705        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
11706        let _value = self
11707            .session
11708            .client()
11709            .call(rpc_methods::SESSION_TASKS_REFRESH, Some(wire_params))
11710            .await?;
11711        Ok(serde_json::from_value(_value)?)
11712    }
11713
11714    /// Waits for all in-flight background tasks and any follow-up turns to settle.
11715    ///
11716    /// Wire method: `session.tasks.waitForPending`.
11717    ///
11718    /// # Returns
11719    ///
11720    /// 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).
11721    ///
11722    /// <div class="warning">
11723    ///
11724    /// **Experimental.** This API is part of an experimental wire-protocol surface
11725    /// and may change or be removed in future SDK or CLI releases. Pin both the
11726    /// SDK and CLI versions if your code depends on it.
11727    ///
11728    /// </div>
11729    pub async fn wait_for_pending(&self) -> Result<TasksWaitForPendingResult, Error> {
11730        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
11731        let _value = self
11732            .session
11733            .client()
11734            .call(rpc_methods::SESSION_TASKS_WAITFORPENDING, Some(wire_params))
11735            .await?;
11736        Ok(serde_json::from_value(_value)?)
11737    }
11738
11739    /// Returns progress information for a background task by ID.
11740    ///
11741    /// Wire method: `session.tasks.getProgress`.
11742    ///
11743    /// # Parameters
11744    ///
11745    /// * `params` - Identifier of the background task to fetch progress for.
11746    ///
11747    /// # Returns
11748    ///
11749    /// Progress information for the task, or null when no task with that ID is tracked.
11750    ///
11751    /// <div class="warning">
11752    ///
11753    /// **Experimental.** This API is part of an experimental wire-protocol surface
11754    /// and may change or be removed in future SDK or CLI releases. Pin both the
11755    /// SDK and CLI versions if your code depends on it.
11756    ///
11757    /// </div>
11758    pub async fn get_progress(
11759        &self,
11760        params: TasksGetProgressRequest,
11761    ) -> Result<TasksGetProgressResult, Error> {
11762        let mut wire_params = serde_json::to_value(params)?;
11763        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11764        let _value = self
11765            .session
11766            .client()
11767            .call(rpc_methods::SESSION_TASKS_GETPROGRESS, Some(wire_params))
11768            .await?;
11769        Ok(serde_json::from_value(_value)?)
11770    }
11771
11772    /// Returns the first sync-waiting task that can currently be promoted to background mode.
11773    ///
11774    /// Wire method: `session.tasks.getCurrentPromotable`.
11775    ///
11776    /// # Returns
11777    ///
11778    /// The first sync-waiting task that can currently be promoted to background mode.
11779    ///
11780    /// <div class="warning">
11781    ///
11782    /// **Experimental.** This API is part of an experimental wire-protocol surface
11783    /// and may change or be removed in future SDK or CLI releases. Pin both the
11784    /// SDK and CLI versions if your code depends on it.
11785    ///
11786    /// </div>
11787    pub async fn get_current_promotable(&self) -> Result<TasksGetCurrentPromotableResult, Error> {
11788        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
11789        let _value = self
11790            .session
11791            .client()
11792            .call(
11793                rpc_methods::SESSION_TASKS_GETCURRENTPROMOTABLE,
11794                Some(wire_params),
11795            )
11796            .await?;
11797        Ok(serde_json::from_value(_value)?)
11798    }
11799
11800    /// Promotes an eligible synchronously-waited task so it continues running in the background.
11801    ///
11802    /// Wire method: `session.tasks.promoteToBackground`.
11803    ///
11804    /// # Parameters
11805    ///
11806    /// * `params` - Identifier of the task to promote to background mode.
11807    ///
11808    /// # Returns
11809    ///
11810    /// Indicates whether the task was successfully promoted to background mode.
11811    ///
11812    /// <div class="warning">
11813    ///
11814    /// **Experimental.** This API is part of an experimental wire-protocol surface
11815    /// and may change or be removed in future SDK or CLI releases. Pin both the
11816    /// SDK and CLI versions if your code depends on it.
11817    ///
11818    /// </div>
11819    pub async fn promote_to_background(
11820        &self,
11821        params: TasksPromoteToBackgroundRequest,
11822    ) -> Result<TasksPromoteToBackgroundResult, Error> {
11823        let mut wire_params = serde_json::to_value(params)?;
11824        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11825        let _value = self
11826            .session
11827            .client()
11828            .call(
11829                rpc_methods::SESSION_TASKS_PROMOTETOBACKGROUND,
11830                Some(wire_params),
11831            )
11832            .await?;
11833        Ok(serde_json::from_value(_value)?)
11834    }
11835
11836    /// Atomically promotes the first promotable sync-waiting task to background mode and returns it.
11837    ///
11838    /// Wire method: `session.tasks.promoteCurrentToBackground`.
11839    ///
11840    /// # Returns
11841    ///
11842    /// The promoted task as it now exists in background mode, omitted if no promotable task was waiting.
11843    ///
11844    /// <div class="warning">
11845    ///
11846    /// **Experimental.** This API is part of an experimental wire-protocol surface
11847    /// and may change or be removed in future SDK or CLI releases. Pin both the
11848    /// SDK and CLI versions if your code depends on it.
11849    ///
11850    /// </div>
11851    pub async fn promote_current_to_background(
11852        &self,
11853    ) -> Result<TasksPromoteCurrentToBackgroundResult, Error> {
11854        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
11855        let _value = self
11856            .session
11857            .client()
11858            .call(
11859                rpc_methods::SESSION_TASKS_PROMOTECURRENTTOBACKGROUND,
11860                Some(wire_params),
11861            )
11862            .await?;
11863        Ok(serde_json::from_value(_value)?)
11864    }
11865
11866    /// Cancels a background task.
11867    ///
11868    /// Wire method: `session.tasks.cancel`.
11869    ///
11870    /// # Parameters
11871    ///
11872    /// * `params` - Identifier of the background task to cancel.
11873    ///
11874    /// # Returns
11875    ///
11876    /// Indicates whether the background task was successfully cancelled.
11877    ///
11878    /// <div class="warning">
11879    ///
11880    /// **Experimental.** This API is part of an experimental wire-protocol surface
11881    /// and may change or be removed in future SDK or CLI releases. Pin both the
11882    /// SDK and CLI versions if your code depends on it.
11883    ///
11884    /// </div>
11885    pub async fn cancel(&self, params: TasksCancelRequest) -> Result<TasksCancelResult, Error> {
11886        let mut wire_params = serde_json::to_value(params)?;
11887        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11888        let _value = self
11889            .session
11890            .client()
11891            .call(rpc_methods::SESSION_TASKS_CANCEL, Some(wire_params))
11892            .await?;
11893        Ok(serde_json::from_value(_value)?)
11894    }
11895
11896    /// Removes a completed or cancelled background task from tracking.
11897    ///
11898    /// Wire method: `session.tasks.remove`.
11899    ///
11900    /// # Parameters
11901    ///
11902    /// * `params` - Identifier of the completed or cancelled task to remove from tracking.
11903    ///
11904    /// # Returns
11905    ///
11906    /// Indicates whether the task was removed. False when the task does not exist or is still running/idle.
11907    ///
11908    /// <div class="warning">
11909    ///
11910    /// **Experimental.** This API is part of an experimental wire-protocol surface
11911    /// and may change or be removed in future SDK or CLI releases. Pin both the
11912    /// SDK and CLI versions if your code depends on it.
11913    ///
11914    /// </div>
11915    pub async fn remove(&self, params: TasksRemoveRequest) -> Result<TasksRemoveResult, Error> {
11916        let mut wire_params = serde_json::to_value(params)?;
11917        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11918        let _value = self
11919            .session
11920            .client()
11921            .call(rpc_methods::SESSION_TASKS_REMOVE, Some(wire_params))
11922            .await?;
11923        Ok(serde_json::from_value(_value)?)
11924    }
11925
11926    /// Sends a message to a background agent task.
11927    ///
11928    /// Wire method: `session.tasks.sendMessage`.
11929    ///
11930    /// # Parameters
11931    ///
11932    /// * `params` - Identifier of the target agent task, message content, and optional sender agent ID.
11933    ///
11934    /// # Returns
11935    ///
11936    /// Indicates whether the message was delivered, with an error message when delivery failed.
11937    ///
11938    /// <div class="warning">
11939    ///
11940    /// **Experimental.** This API is part of an experimental wire-protocol surface
11941    /// and may change or be removed in future SDK or CLI releases. Pin both the
11942    /// SDK and CLI versions if your code depends on it.
11943    ///
11944    /// </div>
11945    pub async fn send_message(
11946        &self,
11947        params: TasksSendMessageRequest,
11948    ) -> Result<TasksSendMessageResult, Error> {
11949        let mut wire_params = serde_json::to_value(params)?;
11950        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11951        let _value = self
11952            .session
11953            .client()
11954            .call(rpc_methods::SESSION_TASKS_SENDMESSAGE, Some(wire_params))
11955            .await?;
11956        Ok(serde_json::from_value(_value)?)
11957    }
11958}
11959
11960/// `session.telemetry.*` RPCs.
11961#[derive(Clone, Copy)]
11962pub struct SessionRpcTelemetry<'a> {
11963    pub(crate) session: &'a Session,
11964}
11965
11966impl<'a> SessionRpcTelemetry<'a> {
11967    /// Gets the telemetry engagement ID currently associated with the session, when available.
11968    ///
11969    /// Wire method: `session.telemetry.getEngagementId`.
11970    ///
11971    /// # Returns
11972    ///
11973    /// Telemetry engagement ID for the session, when available.
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 get_engagement_id(&self) -> Result<SessionTelemetryEngagement, Error> {
11983        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
11984        let _value = self
11985            .session
11986            .client()
11987            .call(
11988                rpc_methods::SESSION_TELEMETRY_GETENGAGEMENTID,
11989                Some(wire_params),
11990            )
11991            .await?;
11992        Ok(serde_json::from_value(_value)?)
11993    }
11994
11995    /// Sets feature override key/value pairs to attach to subsequent telemetry events for the session.
11996    ///
11997    /// Wire method: `session.telemetry.setFeatureOverrides`.
11998    ///
11999    /// # Parameters
12000    ///
12001    /// * `params` - Feature override key/value pairs to attach to subsequent telemetry events from this session.
12002    ///
12003    /// <div class="warning">
12004    ///
12005    /// **Experimental.** This API is part of an experimental wire-protocol surface
12006    /// and may change or be removed in future SDK or CLI releases. Pin both the
12007    /// SDK and CLI versions if your code depends on it.
12008    ///
12009    /// </div>
12010    pub async fn set_feature_overrides(
12011        &self,
12012        params: TelemetrySetFeatureOverridesRequest,
12013    ) -> Result<(), Error> {
12014        let mut wire_params = serde_json::to_value(params)?;
12015        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
12016        let _value = self
12017            .session
12018            .client()
12019            .call(
12020                rpc_methods::SESSION_TELEMETRY_SETFEATUREOVERRIDES,
12021                Some(wire_params),
12022            )
12023            .await?;
12024        Ok(())
12025    }
12026}
12027
12028/// `session.tools.*` RPCs.
12029#[derive(Clone, Copy)]
12030pub struct SessionRpcTools<'a> {
12031    pub(crate) session: &'a Session,
12032}
12033
12034impl<'a> SessionRpcTools<'a> {
12035    /// Executes one tool from the session's currently offered tool set through the native invocation pipeline.
12036    ///
12037    /// Wire method: `session.tools.execute`.
12038    ///
12039    /// # Parameters
12040    ///
12041    /// * `params` - A tool name and arguments to execute through the session's native invocation pipeline.
12042    ///
12043    /// # Returns
12044    ///
12045    /// Canonical result returned by a session tool.
12046    ///
12047    /// <div class="warning">
12048    ///
12049    /// **Experimental.** This API is part of an experimental wire-protocol surface
12050    /// and may change or be removed in future SDK or CLI releases. Pin both the
12051    /// SDK and CLI versions if your code depends on it.
12052    ///
12053    /// </div>
12054    pub async fn execute(&self, params: ToolsExecuteRequest) -> Result<ToolResult, Error> {
12055        let mut wire_params = serde_json::to_value(params)?;
12056        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
12057        let _value = self
12058            .session
12059            .client()
12060            .call(rpc_methods::SESSION_TOOLS_EXECUTE, Some(wire_params))
12061            .await?;
12062        Ok(serde_json::from_value(_value)?)
12063    }
12064
12065    /// Returns the Rust-owned built-in tool descriptors used to construct the session's offered tool set.
12066    ///
12067    /// Wire method: `session.tools.getBuiltinDescriptors`.
12068    ///
12069    /// # Parameters
12070    ///
12071    /// * `params` - Options controlling how Rust-owned built-in tool descriptors are materialized.
12072    ///
12073    /// # Returns
12074    ///
12075    /// Rust-owned built-in tool descriptors for the session.
12076    ///
12077    /// <div class="warning">
12078    ///
12079    /// **Experimental.** This API is part of an experimental wire-protocol surface
12080    /// and may change or be removed in future SDK or CLI releases. Pin both the
12081    /// SDK and CLI versions if your code depends on it.
12082    ///
12083    /// </div>
12084    pub async fn get_builtin_descriptors(
12085        &self,
12086        params: ToolsGetBuiltinDescriptorsRequest,
12087    ) -> Result<ToolsGetBuiltinDescriptorsResult, Error> {
12088        let mut wire_params = serde_json::to_value(params)?;
12089        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
12090        let _value = self
12091            .session
12092            .client()
12093            .call(
12094                rpc_methods::SESSION_TOOLS_GETBUILTINDESCRIPTORS,
12095                Some(wire_params),
12096            )
12097            .await?;
12098        Ok(serde_json::from_value(_value)?)
12099    }
12100
12101    /// Projects a completed task_complete tool call into its label-safe session event payload.
12102    ///
12103    /// Wire method: `session.tools.taskCompleteEventData`.
12104    ///
12105    /// # Parameters
12106    ///
12107    /// * `params` - Task-completion tool arguments and final result used to build a label-safe session event payload.
12108    ///
12109    /// # Returns
12110    ///
12111    /// Task completion notification with summary from the agent
12112    ///
12113    /// <div class="warning">
12114    ///
12115    /// **Experimental.** This API is part of an experimental wire-protocol surface
12116    /// and may change or be removed in future SDK or CLI releases. Pin both the
12117    /// SDK and CLI versions if your code depends on it.
12118    ///
12119    /// </div>
12120    pub async fn task_complete_event_data(
12121        &self,
12122        params: ToolsTaskCompleteEventDataRequest,
12123    ) -> Result<TaskCompleteData, Error> {
12124        let mut wire_params = serde_json::to_value(params)?;
12125        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
12126        let _value = self
12127            .session
12128            .client()
12129            .call(
12130                rpc_methods::SESSION_TOOLS_TASKCOMPLETEEVENTDATA,
12131                Some(wire_params),
12132            )
12133            .await?;
12134        Ok(serde_json::from_value(_value)?)
12135    }
12136
12137    /// Provides the result for a pending external tool call.
12138    ///
12139    /// Wire method: `session.tools.handlePendingToolCall`.
12140    ///
12141    /// # Parameters
12142    ///
12143    /// * `params` - Pending external tool call request ID, with the tool result or an error describing why it failed.
12144    ///
12145    /// # Returns
12146    ///
12147    /// Indicates whether the external tool call result was handled successfully.
12148    ///
12149    /// <div class="warning">
12150    ///
12151    /// **Experimental.** This API is part of an experimental wire-protocol surface
12152    /// and may change or be removed in future SDK or CLI releases. Pin both the
12153    /// SDK and CLI versions if your code depends on it.
12154    ///
12155    /// </div>
12156    pub async fn handle_pending_tool_call(
12157        &self,
12158        params: HandlePendingToolCallRequest,
12159    ) -> Result<HandlePendingToolCallResult, Error> {
12160        let mut wire_params = serde_json::to_value(params)?;
12161        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
12162        let _value = self
12163            .session
12164            .client()
12165            .call(
12166                rpc_methods::SESSION_TOOLS_HANDLEPENDINGTOOLCALL,
12167                Some(wire_params),
12168            )
12169            .await?;
12170        Ok(serde_json::from_value(_value)?)
12171    }
12172
12173    /// Resolves, builds, and validates the runtime tool list for the session.
12174    ///
12175    /// Wire method: `session.tools.initializeAndValidate`.
12176    ///
12177    /// # Returns
12178    ///
12179    /// 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.
12180    ///
12181    /// <div class="warning">
12182    ///
12183    /// **Experimental.** This API is part of an experimental wire-protocol surface
12184    /// and may change or be removed in future SDK or CLI releases. Pin both the
12185    /// SDK and CLI versions if your code depends on it.
12186    ///
12187    /// </div>
12188    pub async fn initialize_and_validate(&self) -> Result<ToolsInitializeAndValidateResult, Error> {
12189        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
12190        let _value = self
12191            .session
12192            .client()
12193            .call(
12194                rpc_methods::SESSION_TOOLS_INITIALIZEANDVALIDATE,
12195                Some(wire_params),
12196            )
12197            .await?;
12198        Ok(serde_json::from_value(_value)?)
12199    }
12200
12201    /// Returns lightweight metadata for the session's currently initialized tools.
12202    ///
12203    /// Wire method: `session.tools.getCurrentMetadata`.
12204    ///
12205    /// # Returns
12206    ///
12207    /// Current lightweight tool metadata snapshot for the session.
12208    ///
12209    /// <div class="warning">
12210    ///
12211    /// **Experimental.** This API is part of an experimental wire-protocol surface
12212    /// and may change or be removed in future SDK or CLI releases. Pin both the
12213    /// SDK and CLI versions if your code depends on it.
12214    ///
12215    /// </div>
12216    pub async fn get_current_metadata(&self) -> Result<ToolsGetCurrentMetadataResult, Error> {
12217        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
12218        let _value = self
12219            .session
12220            .client()
12221            .call(
12222                rpc_methods::SESSION_TOOLS_GETCURRENTMETADATA,
12223                Some(wire_params),
12224            )
12225            .await?;
12226        Ok(serde_json::from_value(_value)?)
12227    }
12228
12229    /// 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.
12230    ///
12231    /// Wire method: `session.tools.set`.
12232    ///
12233    /// # Parameters
12234    ///
12235    /// * `params` - Complete externally implemented tool list for the calling connection. An empty list removes every tool previously supplied by that connection.
12236    ///
12237    /// # Returns
12238    ///
12239    /// Empty result after replacing the calling connection's externally implemented tools.
12240    ///
12241    /// <div class="warning">
12242    ///
12243    /// **Experimental.** This API is part of an experimental wire-protocol surface
12244    /// and may change or be removed in future SDK or CLI releases. Pin both the
12245    /// SDK and CLI versions if your code depends on it.
12246    ///
12247    /// </div>
12248    pub async fn set(&self, params: ToolsSetRequest) -> Result<ToolsSetResult, Error> {
12249        let mut wire_params = serde_json::to_value(params)?;
12250        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
12251        let _value = self
12252            .session
12253            .client()
12254            .call(rpc_methods::SESSION_TOOLS_SET, Some(wire_params))
12255            .await?;
12256        Ok(serde_json::from_value(_value)?)
12257    }
12258
12259    /// 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.
12260    ///
12261    /// Wire method: `session.tools.updateSubagentSettings`.
12262    ///
12263    /// # Parameters
12264    ///
12265    /// * `params` - Subagent settings to apply to the current session
12266    ///
12267    /// # Returns
12268    ///
12269    /// Empty result after applying subagent settings
12270    ///
12271    /// <div class="warning">
12272    ///
12273    /// **Experimental.** This API is part of an experimental wire-protocol surface
12274    /// and may change or be removed in future SDK or CLI releases. Pin both the
12275    /// SDK and CLI versions if your code depends on it.
12276    ///
12277    /// </div>
12278    pub async fn update_subagent_settings(
12279        &self,
12280        params: UpdateSubagentSettingsRequest,
12281    ) -> Result<ToolsUpdateSubagentSettingsResult, Error> {
12282        let mut wire_params = serde_json::to_value(params)?;
12283        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
12284        let _value = self
12285            .session
12286            .client()
12287            .call(
12288                rpc_methods::SESSION_TOOLS_UPDATESUBAGENTSETTINGS,
12289                Some(wire_params),
12290            )
12291            .await?;
12292        Ok(serde_json::from_value(_value)?)
12293    }
12294}
12295
12296/// `session.ui.*` RPCs.
12297#[derive(Clone, Copy)]
12298pub struct SessionRpcUi<'a> {
12299    pub(crate) session: &'a Session,
12300}
12301
12302impl<'a> SessionRpcUi<'a> {
12303    /// Runs a transient no-tools model query against the current conversation context.
12304    ///
12305    /// Wire method: `session.ui.ephemeralQuery`.
12306    ///
12307    /// # Parameters
12308    ///
12309    /// * `params` - Transient question to answer without adding it to conversation history.
12310    ///
12311    /// # Returns
12312    ///
12313    /// Completed transient query. Ordered chunks and the terminal outcome are also delivered through `ui.ephemeral_query` session events while it runs.
12314    ///
12315    /// <div class="warning">
12316    ///
12317    /// **Experimental.** This API is part of an experimental wire-protocol surface
12318    /// and may change or be removed in future SDK or CLI releases. Pin both the
12319    /// SDK and CLI versions if your code depends on it.
12320    ///
12321    /// </div>
12322    pub async fn ephemeral_query(
12323        &self,
12324        params: UIEphemeralQueryRequest,
12325    ) -> Result<UIEphemeralQueryResult, Error> {
12326        let mut wire_params = serde_json::to_value(params)?;
12327        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
12328        let _value = self
12329            .session
12330            .client()
12331            .call(rpc_methods::SESSION_UI_EPHEMERALQUERY, Some(wire_params))
12332            .await?;
12333        Ok(serde_json::from_value(_value)?)
12334    }
12335
12336    /// Requests structured input from a UI-capable client.
12337    ///
12338    /// Wire method: `session.ui.elicitation`.
12339    ///
12340    /// # Parameters
12341    ///
12342    /// * `params` - Prompt message and JSON schema describing the form fields to elicit from the user.
12343    ///
12344    /// # Returns
12345    ///
12346    /// The elicitation response (accept with form values, decline, or cancel)
12347    ///
12348    /// <div class="warning">
12349    ///
12350    /// **Experimental.** This API is part of an experimental wire-protocol surface
12351    /// and may change or be removed in future SDK or CLI releases. Pin both the
12352    /// SDK and CLI versions if your code depends on it.
12353    ///
12354    /// </div>
12355    pub async fn elicitation(
12356        &self,
12357        params: UIElicitationRequest,
12358    ) -> Result<UIElicitationResponse, Error> {
12359        let mut wire_params = serde_json::to_value(params)?;
12360        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
12361        let _value = self
12362            .session
12363            .client()
12364            .call(rpc_methods::SESSION_UI_ELICITATION, Some(wire_params))
12365            .await?;
12366        Ok(serde_json::from_value(_value)?)
12367    }
12368
12369    /// Provides the user response for a pending elicitation request.
12370    ///
12371    /// Wire method: `session.ui.handlePendingElicitation`.
12372    ///
12373    /// # Parameters
12374    ///
12375    /// * `params` - Pending elicitation request ID and the user's response (accept/decline/cancel + form values).
12376    ///
12377    /// # Returns
12378    ///
12379    /// Indicates whether the elicitation response was accepted; false if it was already resolved by another client.
12380    ///
12381    /// <div class="warning">
12382    ///
12383    /// **Experimental.** This API is part of an experimental wire-protocol surface
12384    /// and may change or be removed in future SDK or CLI releases. Pin both the
12385    /// SDK and CLI versions if your code depends on it.
12386    ///
12387    /// </div>
12388    pub async fn handle_pending_elicitation(
12389        &self,
12390        params: UIHandlePendingElicitationRequest,
12391    ) -> Result<UIElicitationResult, Error> {
12392        let mut wire_params = serde_json::to_value(params)?;
12393        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
12394        let _value = self
12395            .session
12396            .client()
12397            .call(
12398                rpc_methods::SESSION_UI_HANDLEPENDINGELICITATION,
12399                Some(wire_params),
12400            )
12401            .await?;
12402        Ok(serde_json::from_value(_value)?)
12403    }
12404
12405    /// Resolves a pending `user_input.requested` event with the user's response.
12406    ///
12407    /// Wire method: `session.ui.handlePendingUserInput`.
12408    ///
12409    /// # Parameters
12410    ///
12411    /// * `params` - Request ID of a pending `user_input.requested` event and the user's response.
12412    ///
12413    /// # Returns
12414    ///
12415    /// Indicates whether the pending UI request was resolved by this call.
12416    ///
12417    /// <div class="warning">
12418    ///
12419    /// **Experimental.** This API is part of an experimental wire-protocol surface
12420    /// and may change or be removed in future SDK or CLI releases. Pin both the
12421    /// SDK and CLI versions if your code depends on it.
12422    ///
12423    /// </div>
12424    pub async fn handle_pending_user_input(
12425        &self,
12426        params: UIHandlePendingUserInputRequest,
12427    ) -> Result<UIHandlePendingResult, Error> {
12428        let mut wire_params = serde_json::to_value(params)?;
12429        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
12430        let _value = self
12431            .session
12432            .client()
12433            .call(
12434                rpc_methods::SESSION_UI_HANDLEPENDINGUSERINPUT,
12435                Some(wire_params),
12436            )
12437            .await?;
12438        Ok(serde_json::from_value(_value)?)
12439    }
12440
12441    /// Resolves a pending `sampling.requested` event with a sampling result, or rejects it.
12442    ///
12443    /// Wire method: `session.ui.handlePendingSampling`.
12444    ///
12445    /// # Parameters
12446    ///
12447    /// * `params` - Request ID of a pending `sampling.requested` event and an optional sampling result payload (omit to reject).
12448    ///
12449    /// # Returns
12450    ///
12451    /// Indicates whether the pending UI request was resolved by this call.
12452    ///
12453    /// <div class="warning">
12454    ///
12455    /// **Experimental.** This API is part of an experimental wire-protocol surface
12456    /// and may change or be removed in future SDK or CLI releases. Pin both the
12457    /// SDK and CLI versions if your code depends on it.
12458    ///
12459    /// </div>
12460    pub async fn handle_pending_sampling(
12461        &self,
12462        params: UIHandlePendingSamplingRequest,
12463    ) -> Result<UIHandlePendingResult, Error> {
12464        let mut wire_params = serde_json::to_value(params)?;
12465        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
12466        let _value = self
12467            .session
12468            .client()
12469            .call(
12470                rpc_methods::SESSION_UI_HANDLEPENDINGSAMPLING,
12471                Some(wire_params),
12472            )
12473            .await?;
12474        Ok(serde_json::from_value(_value)?)
12475    }
12476
12477    /// Resolves a pending `auto_mode_switch.requested` event with the user's accept/decline decision.
12478    ///
12479    /// Wire method: `session.ui.handlePendingAutoModeSwitch`.
12480    ///
12481    /// # Parameters
12482    ///
12483    /// * `params` - Request ID of a pending `auto_mode_switch.requested` event and the user's response.
12484    ///
12485    /// # Returns
12486    ///
12487    /// Indicates whether the pending UI request was resolved by this call.
12488    ///
12489    /// <div class="warning">
12490    ///
12491    /// **Experimental.** This API is part of an experimental wire-protocol surface
12492    /// and may change or be removed in future SDK or CLI releases. Pin both the
12493    /// SDK and CLI versions if your code depends on it.
12494    ///
12495    /// </div>
12496    pub async fn handle_pending_auto_mode_switch(
12497        &self,
12498        params: UIHandlePendingAutoModeSwitchRequest,
12499    ) -> Result<UIHandlePendingResult, Error> {
12500        let mut wire_params = serde_json::to_value(params)?;
12501        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
12502        let _value = self
12503            .session
12504            .client()
12505            .call(
12506                rpc_methods::SESSION_UI_HANDLEPENDINGAUTOMODESWITCH,
12507                Some(wire_params),
12508            )
12509            .await?;
12510        Ok(serde_json::from_value(_value)?)
12511    }
12512
12513    /// Resolves a pending `session_limits_exhausted.requested` event with the user's selected limit action.
12514    ///
12515    /// Wire method: `session.ui.handlePendingSessionLimitsExhausted`.
12516    ///
12517    /// # Parameters
12518    ///
12519    /// * `params` - Request ID of a pending `session_limits_exhausted.requested` event and the user's selected limit action.
12520    ///
12521    /// # Returns
12522    ///
12523    /// Indicates whether the pending UI request was resolved by this call.
12524    ///
12525    /// <div class="warning">
12526    ///
12527    /// **Experimental.** This API is part of an experimental wire-protocol surface
12528    /// and may change or be removed in future SDK or CLI releases. Pin both the
12529    /// SDK and CLI versions if your code depends on it.
12530    ///
12531    /// </div>
12532    pub async fn handle_pending_session_limits_exhausted(
12533        &self,
12534        params: UIHandlePendingSessionLimitsExhaustedRequest,
12535    ) -> Result<UIHandlePendingResult, Error> {
12536        let mut wire_params = serde_json::to_value(params)?;
12537        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
12538        let _value = self
12539            .session
12540            .client()
12541            .call(
12542                rpc_methods::SESSION_UI_HANDLEPENDINGSESSIONLIMITSEXHAUSTED,
12543                Some(wire_params),
12544            )
12545            .await?;
12546        Ok(serde_json::from_value(_value)?)
12547    }
12548
12549    /// Resolves a pending `exit_plan_mode.requested` event with the user's response.
12550    ///
12551    /// Wire method: `session.ui.handlePendingExitPlanMode`.
12552    ///
12553    /// # Parameters
12554    ///
12555    /// * `params` - Request ID of a pending `exit_plan_mode.requested` event and the user's response.
12556    ///
12557    /// # Returns
12558    ///
12559    /// Indicates whether the pending UI request was resolved by this call.
12560    ///
12561    /// <div class="warning">
12562    ///
12563    /// **Experimental.** This API is part of an experimental wire-protocol surface
12564    /// and may change or be removed in future SDK or CLI releases. Pin both the
12565    /// SDK and CLI versions if your code depends on it.
12566    ///
12567    /// </div>
12568    pub async fn handle_pending_exit_plan_mode(
12569        &self,
12570        params: UIHandlePendingExitPlanModeRequest,
12571    ) -> Result<UIHandlePendingResult, Error> {
12572        let mut wire_params = serde_json::to_value(params)?;
12573        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
12574        let _value = self
12575            .session
12576            .client()
12577            .call(
12578                rpc_methods::SESSION_UI_HANDLEPENDINGEXITPLANMODE,
12579                Some(wire_params),
12580            )
12581            .await?;
12582        Ok(serde_json::from_value(_value)?)
12583    }
12584
12585    /// Registers an in-process handler for auto-mode-switch requests so the server bridge skips dispatch.
12586    ///
12587    /// Wire method: `session.ui.registerDirectAutoModeSwitchHandler`.
12588    ///
12589    /// # Returns
12590    ///
12591    /// 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).
12592    ///
12593    /// <div class="warning">
12594    ///
12595    /// **Experimental.** This API is part of an experimental wire-protocol surface
12596    /// and may change or be removed in future SDK or CLI releases. Pin both the
12597    /// SDK and CLI versions if your code depends on it.
12598    ///
12599    /// </div>
12600    pub async fn register_direct_auto_mode_switch_handler(
12601        &self,
12602    ) -> Result<UIRegisterDirectAutoModeSwitchHandlerResult, Error> {
12603        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
12604        let _value = self
12605            .session
12606            .client()
12607            .call(
12608                rpc_methods::SESSION_UI_REGISTERDIRECTAUTOMODESWITCHHANDLER,
12609                Some(wire_params),
12610            )
12611            .await?;
12612        Ok(serde_json::from_value(_value)?)
12613    }
12614
12615    /// Unregisters a previously-registered in-process auto-mode-switch handler by its opaque handle.
12616    ///
12617    /// Wire method: `session.ui.unregisterDirectAutoModeSwitchHandler`.
12618    ///
12619    /// # Parameters
12620    ///
12621    /// * `params` - Opaque handle previously returned by `registerDirectAutoModeSwitchHandler` to release.
12622    ///
12623    /// # Returns
12624    ///
12625    /// Indicates whether the handle was active and the registration count was decremented.
12626    ///
12627    /// <div class="warning">
12628    ///
12629    /// **Experimental.** This API is part of an experimental wire-protocol surface
12630    /// and may change or be removed in future SDK or CLI releases. Pin both the
12631    /// SDK and CLI versions if your code depends on it.
12632    ///
12633    /// </div>
12634    pub async fn unregister_direct_auto_mode_switch_handler(
12635        &self,
12636        params: UIUnregisterDirectAutoModeSwitchHandlerRequest,
12637    ) -> Result<UIUnregisterDirectAutoModeSwitchHandlerResult, Error> {
12638        let mut wire_params = serde_json::to_value(params)?;
12639        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
12640        let _value = self
12641            .session
12642            .client()
12643            .call(
12644                rpc_methods::SESSION_UI_UNREGISTERDIRECTAUTOMODESWITCHHANDLER,
12645                Some(wire_params),
12646            )
12647            .await?;
12648        Ok(serde_json::from_value(_value)?)
12649    }
12650}
12651
12652/// `session.usage.*` RPCs.
12653#[derive(Clone, Copy)]
12654pub struct SessionRpcUsage<'a> {
12655    pub(crate) session: &'a Session,
12656}
12657
12658impl<'a> SessionRpcUsage<'a> {
12659    /// Gets accumulated usage metrics for the session.
12660    ///
12661    /// Wire method: `session.usage.getMetrics`.
12662    ///
12663    /// # Returns
12664    ///
12665    /// Accumulated session usage metrics, including premium request cost, token counts, model breakdown, and code-change totals.
12666    ///
12667    /// <div class="warning">
12668    ///
12669    /// **Experimental.** This API is part of an experimental wire-protocol surface
12670    /// and may change or be removed in future SDK or CLI releases. Pin both the
12671    /// SDK and CLI versions if your code depends on it.
12672    ///
12673    /// </div>
12674    pub async fn get_metrics(&self) -> Result<UsageGetMetricsResult, Error> {
12675        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
12676        let _value = self
12677            .session
12678            .client()
12679            .call(rpc_methods::SESSION_USAGE_GETMETRICS, Some(wire_params))
12680            .await?;
12681        Ok(serde_json::from_value(_value)?)
12682    }
12683}
12684
12685/// `session.visibility.*` RPCs.
12686#[derive(Clone, Copy)]
12687pub struct SessionRpcVisibility<'a> {
12688    pub(crate) session: &'a Session,
12689}
12690
12691impl<'a> SessionRpcVisibility<'a> {
12692    /// 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").
12693    ///
12694    /// Wire method: `session.visibility.get`.
12695    ///
12696    /// # Returns
12697    ///
12698    /// Current sharing status and shareable GitHub URL for a session.
12699    ///
12700    /// <div class="warning">
12701    ///
12702    /// **Experimental.** This API is part of an experimental wire-protocol surface
12703    /// and may change or be removed in future SDK or CLI releases. Pin both the
12704    /// SDK and CLI versions if your code depends on it.
12705    ///
12706    /// </div>
12707    pub async fn get(&self) -> Result<VisibilityGetResult, Error> {
12708        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
12709        let _value = self
12710            .session
12711            .client()
12712            .call(rpc_methods::SESSION_VISIBILITY_GET, Some(wire_params))
12713            .await?;
12714        Ok(serde_json::from_value(_value)?)
12715    }
12716
12717    /// 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.
12718    ///
12719    /// Wire method: `session.visibility.set`.
12720    ///
12721    /// # Parameters
12722    ///
12723    /// * `params` - Desired sharing status for the session.
12724    ///
12725    /// # Returns
12726    ///
12727    /// Effective sharing status and shareable GitHub URL after updating session visibility.
12728    ///
12729    /// <div class="warning">
12730    ///
12731    /// **Experimental.** This API is part of an experimental wire-protocol surface
12732    /// and may change or be removed in future SDK or CLI releases. Pin both the
12733    /// SDK and CLI versions if your code depends on it.
12734    ///
12735    /// </div>
12736    pub async fn set(&self, params: VisibilitySetRequest) -> Result<VisibilitySetResult, Error> {
12737        let mut wire_params = serde_json::to_value(params)?;
12738        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
12739        let _value = self
12740            .session
12741            .client()
12742            .call(rpc_methods::SESSION_VISIBILITY_SET, Some(wire_params))
12743            .await?;
12744        Ok(serde_json::from_value(_value)?)
12745    }
12746}
12747
12748/// `session.workflow.*` RPCs.
12749#[derive(Clone, Copy)]
12750pub struct SessionRpcWorkflow<'a> {
12751    pub(crate) session: &'a Session,
12752}
12753
12754impl<'a> SessionRpcWorkflow<'a> {
12755    /// `session.workflow.journal.*` sub-namespace.
12756    pub fn journal(&self) -> SessionRpcWorkflowJournal<'a> {
12757        SessionRpcWorkflowJournal {
12758            session: self.session,
12759        }
12760    }
12761
12762    /// Runs a registered dynamic workflow by name at the top level.
12763    ///
12764    /// Wire method: `session.workflow.run`.
12765    ///
12766    /// # Parameters
12767    ///
12768    /// * `params` - Parameters for invoking a registered workflow.
12769    ///
12770    /// # Returns
12771    ///
12772    /// Complete current or terminal workflow run envelope.
12773    ///
12774    /// <div class="warning">
12775    ///
12776    /// **Experimental.** This API is part of an experimental wire-protocol surface
12777    /// and may change or be removed in future SDK or CLI releases. Pin both the
12778    /// SDK and CLI versions if your code depends on it.
12779    ///
12780    /// </div>
12781    pub async fn run(&self, params: WorkflowRunRequest) -> Result<WorkflowRunResult, Error> {
12782        let mut wire_params = serde_json::to_value(params)?;
12783        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
12784        let _value = self
12785            .session
12786            .client()
12787            .call(rpc_methods::SESSION_WORKFLOW_RUN, Some(wire_params))
12788            .await?;
12789        Ok(serde_json::from_value(_value)?)
12790    }
12791
12792    /// Resumes a dynamic workflow run using its persisted name, arguments, journal, and accounting.
12793    ///
12794    /// Wire method: `session.workflow.resume`.
12795    ///
12796    /// # Parameters
12797    ///
12798    /// * `params` - Parameters for resuming a workflow run from its persisted identity.
12799    ///
12800    /// # Returns
12801    ///
12802    /// Resolved persisted workflow identity and resumed run envelope.
12803    ///
12804    /// <div class="warning">
12805    ///
12806    /// **Experimental.** This API is part of an experimental wire-protocol surface
12807    /// and may change or be removed in future SDK or CLI releases. Pin both the
12808    /// SDK and CLI versions if your code depends on it.
12809    ///
12810    /// </div>
12811    pub async fn resume(
12812        &self,
12813        params: WorkflowResumeRequest,
12814    ) -> Result<WorkflowResumeResult, Error> {
12815        let mut wire_params = serde_json::to_value(params)?;
12816        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
12817        let _value = self
12818            .session
12819            .client()
12820            .call(rpc_methods::SESSION_WORKFLOW_RESUME, Some(wire_params))
12821            .await?;
12822        Ok(serde_json::from_value(_value)?)
12823    }
12824
12825    /// Internal tool-originated dynamic workflow invocation.
12826    ///
12827    /// Wire method: `session.workflow.runFromTool`.
12828    ///
12829    /// # Parameters
12830    ///
12831    /// * `params` - Internal parameters for invoking a registered workflow from a tool.
12832    ///
12833    /// # Returns
12834    ///
12835    /// Complete current or terminal workflow run envelope.
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(crate) async fn run_from_tool(
12845        &self,
12846        params: WorkflowToolRunRequest,
12847    ) -> Result<WorkflowRunResult, Error> {
12848        let mut wire_params = serde_json::to_value(params)?;
12849        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
12850        let _value = self
12851            .session
12852            .client()
12853            .call(rpc_methods::SESSION_WORKFLOW_RUNFROMTOOL, Some(wire_params))
12854            .await?;
12855        Ok(serde_json::from_value(_value)?)
12856    }
12857
12858    /// Internal tool-originated dynamic workflow resume.
12859    ///
12860    /// Wire method: `session.workflow.resumeFromTool`.
12861    ///
12862    /// # Parameters
12863    ///
12864    /// * `params` - Internal parameters for resuming a workflow run from a tool.
12865    ///
12866    /// # Returns
12867    ///
12868    /// Resolved persisted workflow identity and resumed run envelope.
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(crate) async fn resume_from_tool(
12878        &self,
12879        params: WorkflowToolResumeRequest,
12880    ) -> Result<WorkflowResumeResult, 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(
12887                rpc_methods::SESSION_WORKFLOW_RESUMEFROMTOOL,
12888                Some(wire_params),
12889            )
12890            .await?;
12891        Ok(serde_json::from_value(_value)?)
12892    }
12893
12894    /// Gets the current or settled envelope for a dynamic workflow run.
12895    ///
12896    /// Wire method: `session.workflow.getRun`.
12897    ///
12898    /// # Parameters
12899    ///
12900    /// * `params` - Parameters for retrieving a workflow run.
12901    ///
12902    /// # Returns
12903    ///
12904    /// Complete current or terminal workflow run envelope.
12905    ///
12906    /// <div class="warning">
12907    ///
12908    /// **Experimental.** This API is part of an experimental wire-protocol surface
12909    /// and may change or be removed in future SDK or CLI releases. Pin both the
12910    /// SDK and CLI versions if your code depends on it.
12911    ///
12912    /// </div>
12913    pub async fn get_run(&self, params: WorkflowGetRunRequest) -> Result<WorkflowRunResult, Error> {
12914        let mut wire_params = serde_json::to_value(params)?;
12915        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
12916        let _value = self
12917            .session
12918            .client()
12919            .call(rpc_methods::SESSION_WORKFLOW_GETRUN, Some(wire_params))
12920            .await?;
12921        Ok(serde_json::from_value(_value)?)
12922    }
12923
12924    /// Lists durable dynamic workflow runs for this session in creation order.
12925    ///
12926    /// Wire method: `session.workflow.listRuns`.
12927    ///
12928    /// # Parameters
12929    ///
12930    /// * `params` - Parameters for paging workflow runs.
12931    ///
12932    /// # Returns
12933    ///
12934    /// A page of workflow runs in durable creation order.
12935    ///
12936    /// <div class="warning">
12937    ///
12938    /// **Experimental.** This API is part of an experimental wire-protocol surface
12939    /// and may change or be removed in future SDK or CLI releases. Pin both the
12940    /// SDK and CLI versions if your code depends on it.
12941    ///
12942    /// </div>
12943    pub async fn list_runs(
12944        &self,
12945        params: WorkflowListRunsRequest,
12946    ) -> Result<WorkflowListRunsResult, Error> {
12947        let mut wire_params = serde_json::to_value(params)?;
12948        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
12949        let _value = self
12950            .session
12951            .client()
12952            .call(rpc_methods::SESSION_WORKFLOW_LISTRUNS, Some(wire_params))
12953            .await?;
12954        Ok(serde_json::from_value(_value)?)
12955    }
12956
12957    /// Gets durable and live observability detail for one dynamic workflow run.
12958    ///
12959    /// Wire method: `session.workflow.getRunDetail`.
12960    ///
12961    /// # Parameters
12962    ///
12963    /// * `params` - Parameters for retrieving a workflow run.
12964    ///
12965    /// # Returns
12966    ///
12967    /// Full workflow run observability detail.
12968    ///
12969    /// <div class="warning">
12970    ///
12971    /// **Experimental.** This API is part of an experimental wire-protocol surface
12972    /// and may change or be removed in future SDK or CLI releases. Pin both the
12973    /// SDK and CLI versions if your code depends on it.
12974    ///
12975    /// </div>
12976    pub async fn get_run_detail(
12977        &self,
12978        params: WorkflowGetRunRequest,
12979    ) -> Result<WorkflowRunDetail, Error> {
12980        let mut wire_params = serde_json::to_value(params)?;
12981        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
12982        let _value = self
12983            .session
12984            .client()
12985            .call(
12986                rpc_methods::SESSION_WORKFLOW_GETRUNDETAIL,
12987                Some(wire_params),
12988            )
12989            .await?;
12990        Ok(serde_json::from_value(_value)?)
12991    }
12992
12993    /// Pages durable progress for one dynamic workflow run.
12994    ///
12995    /// Wire method: `session.workflow.getRunProgress`.
12996    ///
12997    /// # Parameters
12998    ///
12999    /// * `params` - Parameters for paging workflow progress.
13000    ///
13001    /// # Returns
13002    ///
13003    /// A bidirectional page of workflow progress.
13004    ///
13005    /// <div class="warning">
13006    ///
13007    /// **Experimental.** This API is part of an experimental wire-protocol surface
13008    /// and may change or be removed in future SDK or CLI releases. Pin both the
13009    /// SDK and CLI versions if your code depends on it.
13010    ///
13011    /// </div>
13012    pub async fn get_run_progress(
13013        &self,
13014        params: WorkflowGetRunProgressRequest,
13015    ) -> Result<WorkflowProgressPage, Error> {
13016        let mut wire_params = serde_json::to_value(params)?;
13017        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
13018        let _value = self
13019            .session
13020            .client()
13021            .call(
13022                rpc_methods::SESSION_WORKFLOW_GETRUNPROGRESS,
13023                Some(wire_params),
13024            )
13025            .await?;
13026        Ok(serde_json::from_value(_value)?)
13027    }
13028
13029    /// Requests cancellation of a dynamic workflow run and returns its run envelope.
13030    ///
13031    /// Wire method: `session.workflow.cancel`.
13032    ///
13033    /// # Parameters
13034    ///
13035    /// * `params` - Parameters for cancelling a workflow run.
13036    ///
13037    /// # Returns
13038    ///
13039    /// Complete current or terminal workflow run envelope.
13040    ///
13041    /// <div class="warning">
13042    ///
13043    /// **Experimental.** This API is part of an experimental wire-protocol surface
13044    /// and may change or be removed in future SDK or CLI releases. Pin both the
13045    /// SDK and CLI versions if your code depends on it.
13046    ///
13047    /// </div>
13048    pub async fn cancel(&self, params: WorkflowCancelRequest) -> Result<WorkflowRunResult, Error> {
13049        let mut wire_params = serde_json::to_value(params)?;
13050        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
13051        let _value = self
13052            .session
13053            .client()
13054            .call(rpc_methods::SESSION_WORKFLOW_CANCEL, Some(wire_params))
13055            .await?;
13056        Ok(serde_json::from_value(_value)?)
13057    }
13058
13059    /// Pauses a running dynamic workflow and returns its settled run envelope.
13060    ///
13061    /// Wire method: `session.workflow.pause`.
13062    ///
13063    /// # Parameters
13064    ///
13065    /// * `params` - Parameters for pausing a running workflow.
13066    ///
13067    /// # Returns
13068    ///
13069    /// Complete current or terminal workflow run envelope.
13070    ///
13071    /// <div class="warning">
13072    ///
13073    /// **Experimental.** This API is part of an experimental wire-protocol surface
13074    /// and may change or be removed in future SDK or CLI releases. Pin both the
13075    /// SDK and CLI versions if your code depends on it.
13076    ///
13077    /// </div>
13078    pub async fn pause(&self, params: WorkflowPauseRequest) -> Result<WorkflowRunResult, Error> {
13079        let mut wire_params = serde_json::to_value(params)?;
13080        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
13081        let _value = self
13082            .session
13083            .client()
13084            .call(rpc_methods::SESSION_WORKFLOW_PAUSE, Some(wire_params))
13085            .await?;
13086        Ok(serde_json::from_value(_value)?)
13087    }
13088
13089    /// Atomically pauses an owned dynamic workflow attempt at a durable checkpoint.
13090    ///
13091    /// Wire method: `session.workflow.pauseAtCheckpoint`.
13092    ///
13093    /// # Parameters
13094    ///
13095    /// * `params` - Parameters for an owned durable pause checkpoint.
13096    ///
13097    /// <div class="warning">
13098    ///
13099    /// **Experimental.** This API is part of an experimental wire-protocol surface
13100    /// and may change or be removed in future SDK or CLI releases. Pin both the
13101    /// SDK and CLI versions if your code depends on it.
13102    ///
13103    /// </div>
13104    pub(crate) async fn pause_at_checkpoint(
13105        &self,
13106        params: WorkflowPauseCheckpointRequest,
13107    ) -> Result<WorkflowPauseCheckpointResult, Error> {
13108        let mut wire_params = serde_json::to_value(params)?;
13109        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
13110        let _value = self
13111            .session
13112            .client()
13113            .call(
13114                rpc_methods::SESSION_WORKFLOW_PAUSEATCHECKPOINT,
13115                Some(wire_params),
13116            )
13117            .await?;
13118        Ok(serde_json::from_value(_value)?)
13119    }
13120
13121    /// Records a batch of ordered dynamic workflow progress lines.
13122    ///
13123    /// Wire method: `session.workflow.log`.
13124    ///
13125    /// # Parameters
13126    ///
13127    /// * `params` - Parameters for recording workflow progress.
13128    ///
13129    /// # Returns
13130    ///
13131    /// Acknowledgement that a workflow request was accepted.
13132    ///
13133    /// <div class="warning">
13134    ///
13135    /// **Experimental.** This API is part of an experimental wire-protocol surface
13136    /// and may change or be removed in future SDK or CLI releases. Pin both the
13137    /// SDK and CLI versions if your code depends on it.
13138    ///
13139    /// </div>
13140    pub async fn log(&self, params: WorkflowLogRequest) -> Result<WorkflowAckResult, Error> {
13141        let mut wire_params = serde_json::to_value(params)?;
13142        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
13143        let _value = self
13144            .session
13145            .client()
13146            .call(rpc_methods::SESSION_WORKFLOW_LOG, Some(wire_params))
13147            .await?;
13148        Ok(serde_json::from_value(_value)?)
13149    }
13150
13151    /// Runs one dynamic-workflow-scoped subagent and returns its result.
13152    ///
13153    /// Wire method: `session.workflow.agent`.
13154    ///
13155    /// # Parameters
13156    ///
13157    /// * `params` - Parameters for one workflow-scoped subagent call.
13158    ///
13159    /// # Returns
13160    ///
13161    /// Result of one workflow-scoped subagent call.
13162    ///
13163    /// <div class="warning">
13164    ///
13165    /// **Experimental.** This API is part of an experimental wire-protocol surface
13166    /// and may change or be removed in future SDK or CLI releases. Pin both the
13167    /// SDK and CLI versions if your code depends on it.
13168    ///
13169    /// </div>
13170    pub async fn agent(&self, params: WorkflowAgentRequest) -> Result<WorkflowAgentResult, Error> {
13171        let mut wire_params = serde_json::to_value(params)?;
13172        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
13173        let _value = self
13174            .session
13175            .client()
13176            .call(rpc_methods::SESSION_WORKFLOW_AGENT, Some(wire_params))
13177            .await?;
13178        Ok(serde_json::from_value(_value)?)
13179    }
13180}
13181
13182/// `session.workflow.journal.*` RPCs.
13183#[derive(Clone, Copy)]
13184pub struct SessionRpcWorkflowJournal<'a> {
13185    pub(crate) session: &'a Session,
13186}
13187
13188impl<'a> SessionRpcWorkflowJournal<'a> {
13189    /// Reads a memoized dynamic workflow journal entry.
13190    ///
13191    /// Wire method: `session.workflow.journal.get`.
13192    ///
13193    /// # Parameters
13194    ///
13195    /// * `params` - Parameters for reading a workflow journal entry.
13196    ///
13197    /// # Returns
13198    ///
13199    /// Result of reading a workflow journal entry.
13200    ///
13201    /// <div class="warning">
13202    ///
13203    /// **Experimental.** This API is part of an experimental wire-protocol surface
13204    /// and may change or be removed in future SDK or CLI releases. Pin both the
13205    /// SDK and CLI versions if your code depends on it.
13206    ///
13207    /// </div>
13208    pub async fn get(
13209        &self,
13210        params: WorkflowJournalGetRequest,
13211    ) -> Result<WorkflowJournalGetResult, Error> {
13212        let mut wire_params = serde_json::to_value(params)?;
13213        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
13214        let _value = self
13215            .session
13216            .client()
13217            .call(rpc_methods::SESSION_WORKFLOW_JOURNAL_GET, Some(wire_params))
13218            .await?;
13219        Ok(serde_json::from_value(_value)?)
13220    }
13221
13222    /// Stores a memoized dynamic workflow journal entry.
13223    ///
13224    /// Wire method: `session.workflow.journal.put`.
13225    ///
13226    /// # Parameters
13227    ///
13228    /// * `params` - Parameters for storing a workflow journal entry.
13229    ///
13230    /// # Returns
13231    ///
13232    /// Acknowledgement that a workflow request was accepted.
13233    ///
13234    /// <div class="warning">
13235    ///
13236    /// **Experimental.** This API is part of an experimental wire-protocol surface
13237    /// and may change or be removed in future SDK or CLI releases. Pin both the
13238    /// SDK and CLI versions if your code depends on it.
13239    ///
13240    /// </div>
13241    pub async fn put(&self, params: WorkflowJournalPutRequest) -> Result<WorkflowAckResult, Error> {
13242        let mut wire_params = serde_json::to_value(params)?;
13243        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
13244        let _value = self
13245            .session
13246            .client()
13247            .call(rpc_methods::SESSION_WORKFLOW_JOURNAL_PUT, Some(wire_params))
13248            .await?;
13249        Ok(serde_json::from_value(_value)?)
13250    }
13251}
13252
13253/// `session.workspaces.*` RPCs.
13254#[derive(Clone, Copy)]
13255pub struct SessionRpcWorkspaces<'a> {
13256    pub(crate) session: &'a Session,
13257}
13258
13259impl<'a> SessionRpcWorkspaces<'a> {
13260    /// Gets current workspace metadata for the session.
13261    ///
13262    /// Wire method: `session.workspaces.getWorkspace`.
13263    ///
13264    /// # Returns
13265    ///
13266    /// Current workspace metadata for the session, including its absolute filesystem path when available.
13267    ///
13268    /// <div class="warning">
13269    ///
13270    /// **Experimental.** This API is part of an experimental wire-protocol surface
13271    /// and may change or be removed in future SDK or CLI releases. Pin both the
13272    /// SDK and CLI versions if your code depends on it.
13273    ///
13274    /// </div>
13275    pub async fn get_workspace(&self) -> Result<WorkspacesGetWorkspaceResult, Error> {
13276        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
13277        let _value = self
13278            .session
13279            .client()
13280            .call(
13281                rpc_methods::SESSION_WORKSPACES_GETWORKSPACE,
13282                Some(wire_params),
13283            )
13284            .await?;
13285        Ok(serde_json::from_value(_value)?)
13286    }
13287
13288    /// Updates workspace metadata for a local session and returns the refreshed workspace.
13289    ///
13290    /// Wire method: `session.workspaces.updateMetadata`.
13291    ///
13292    /// # Parameters
13293    ///
13294    /// * `params` - Workspace metadata fields to update.
13295    ///
13296    /// # Returns
13297    ///
13298    /// Current workspace metadata for the session, including its absolute filesystem path when available.
13299    ///
13300    /// <div class="warning">
13301    ///
13302    /// **Experimental.** This API is part of an experimental wire-protocol surface
13303    /// and may change or be removed in future SDK or CLI releases. Pin both the
13304    /// SDK and CLI versions if your code depends on it.
13305    ///
13306    /// </div>
13307    pub async fn update_metadata(
13308        &self,
13309        params: WorkspacesUpdateMetadataRequest,
13310    ) -> Result<WorkspacesGetWorkspaceResult, Error> {
13311        let mut wire_params = serde_json::to_value(params)?;
13312        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
13313        let _value = self
13314            .session
13315            .client()
13316            .call(
13317                rpc_methods::SESSION_WORKSPACES_UPDATEMETADATA,
13318                Some(wire_params),
13319            )
13320            .await?;
13321        Ok(serde_json::from_value(_value)?)
13322    }
13323
13324    /// Ensures a local session workspace exists and returns it.
13325    ///
13326    /// Wire method: `session.workspaces.ensure`.
13327    ///
13328    /// # Parameters
13329    ///
13330    /// * `params` - Optional session context used when creating a local workspace.
13331    ///
13332    /// # Returns
13333    ///
13334    /// Current workspace metadata for the session, including its absolute filesystem path when available.
13335    ///
13336    /// <div class="warning">
13337    ///
13338    /// **Experimental.** This API is part of an experimental wire-protocol surface
13339    /// and may change or be removed in future SDK or CLI releases. Pin both the
13340    /// SDK and CLI versions if your code depends on it.
13341    ///
13342    /// </div>
13343    pub async fn ensure(
13344        &self,
13345        params: WorkspacesEnsureRequest,
13346    ) -> Result<WorkspacesGetWorkspaceResult, Error> {
13347        let mut wire_params = serde_json::to_value(params)?;
13348        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
13349        let _value = self
13350            .session
13351            .client()
13352            .call(rpc_methods::SESSION_WORKSPACES_ENSURE, Some(wire_params))
13353            .await?;
13354        Ok(serde_json::from_value(_value)?)
13355    }
13356
13357    /// Lists files stored in the session workspace files directory.
13358    ///
13359    /// Wire method: `session.workspaces.listFiles`.
13360    ///
13361    /// # Returns
13362    ///
13363    /// Relative paths of files stored in the session workspace files directory.
13364    ///
13365    /// <div class="warning">
13366    ///
13367    /// **Experimental.** This API is part of an experimental wire-protocol surface
13368    /// and may change or be removed in future SDK or CLI releases. Pin both the
13369    /// SDK and CLI versions if your code depends on it.
13370    ///
13371    /// </div>
13372    pub async fn list_files(&self) -> Result<WorkspacesListFilesResult, Error> {
13373        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
13374        let _value = self
13375            .session
13376            .client()
13377            .call(rpc_methods::SESSION_WORKSPACES_LISTFILES, Some(wire_params))
13378            .await?;
13379        Ok(serde_json::from_value(_value)?)
13380    }
13381
13382    /// Reads a file from the session workspace files directory.
13383    ///
13384    /// Wire method: `session.workspaces.readFile`.
13385    ///
13386    /// # Parameters
13387    ///
13388    /// * `params` - Relative path of the workspace file to read.
13389    ///
13390    /// # Returns
13391    ///
13392    /// Contents of the requested workspace file as a UTF-8 string.
13393    ///
13394    /// <div class="warning">
13395    ///
13396    /// **Experimental.** This API is part of an experimental wire-protocol surface
13397    /// and may change or be removed in future SDK or CLI releases. Pin both the
13398    /// SDK and CLI versions if your code depends on it.
13399    ///
13400    /// </div>
13401    pub async fn read_file(
13402        &self,
13403        params: WorkspacesReadFileRequest,
13404    ) -> Result<WorkspacesReadFileResult, Error> {
13405        let mut wire_params = serde_json::to_value(params)?;
13406        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
13407        let _value = self
13408            .session
13409            .client()
13410            .call(rpc_methods::SESSION_WORKSPACES_READFILE, Some(wire_params))
13411            .await?;
13412        Ok(serde_json::from_value(_value)?)
13413    }
13414
13415    /// Creates or overwrites a file in the session workspace files directory.
13416    ///
13417    /// Wire method: `session.workspaces.createFile`.
13418    ///
13419    /// # Parameters
13420    ///
13421    /// * `params` - Relative path and UTF-8 content for the workspace file to create or overwrite.
13422    ///
13423    /// <div class="warning">
13424    ///
13425    /// **Experimental.** This API is part of an experimental wire-protocol surface
13426    /// and may change or be removed in future SDK or CLI releases. Pin both the
13427    /// SDK and CLI versions if your code depends on it.
13428    ///
13429    /// </div>
13430    pub async fn create_file(&self, params: WorkspacesCreateFileRequest) -> Result<(), Error> {
13431        let mut wire_params = serde_json::to_value(params)?;
13432        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
13433        let _value = self
13434            .session
13435            .client()
13436            .call(
13437                rpc_methods::SESSION_WORKSPACES_CREATEFILE,
13438                Some(wire_params),
13439            )
13440            .await?;
13441        Ok(())
13442    }
13443
13444    /// Returns metadata for a file or directory in the session workspace files directory.
13445    ///
13446    /// Wire method: `session.workspaces.statFile`.
13447    ///
13448    /// # Parameters
13449    ///
13450    /// * `params` - Relative path of the workspace file or directory to inspect.
13451    ///
13452    /// # Returns
13453    ///
13454    /// Filesystem metadata for a path in the session workspace files directory.
13455    ///
13456    /// <div class="warning">
13457    ///
13458    /// **Experimental.** This API is part of an experimental wire-protocol surface
13459    /// and may change or be removed in future SDK or CLI releases. Pin both the
13460    /// SDK and CLI versions if your code depends on it.
13461    ///
13462    /// </div>
13463    pub async fn stat_file(
13464        &self,
13465        params: WorkspacesStatFileRequest,
13466    ) -> Result<WorkspacesStatFileResult, Error> {
13467        let mut wire_params = serde_json::to_value(params)?;
13468        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
13469        let _value = self
13470            .session
13471            .client()
13472            .call(rpc_methods::SESSION_WORKSPACES_STATFILE, Some(wire_params))
13473            .await?;
13474        Ok(serde_json::from_value(_value)?)
13475    }
13476
13477    /// Creates a directory in the session workspace files directory.
13478    ///
13479    /// Wire method: `session.workspaces.createDirectory`.
13480    ///
13481    /// # Parameters
13482    ///
13483    /// * `params` - Directory to create within the session workspace files directory.
13484    ///
13485    /// <div class="warning">
13486    ///
13487    /// **Experimental.** This API is part of an experimental wire-protocol surface
13488    /// and may change or be removed in future SDK or CLI releases. Pin both the
13489    /// SDK and CLI versions if your code depends on it.
13490    ///
13491    /// </div>
13492    pub async fn create_directory(
13493        &self,
13494        params: WorkspacesCreateDirectoryRequest,
13495    ) -> Result<(), Error> {
13496        let mut wire_params = serde_json::to_value(params)?;
13497        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
13498        let _value = self
13499            .session
13500            .client()
13501            .call(
13502                rpc_methods::SESSION_WORKSPACES_CREATEDIRECTORY,
13503                Some(wire_params),
13504            )
13505            .await?;
13506        Ok(())
13507    }
13508
13509    /// Removes a file or directory from the session workspace files directory.
13510    ///
13511    /// Wire method: `session.workspaces.removePath`.
13512    ///
13513    /// # Parameters
13514    ///
13515    /// * `params` - File or directory to remove from the session workspace files directory.
13516    ///
13517    /// <div class="warning">
13518    ///
13519    /// **Experimental.** This API is part of an experimental wire-protocol surface
13520    /// and may change or be removed in future SDK or CLI releases. Pin both the
13521    /// SDK and CLI versions if your code depends on it.
13522    ///
13523    /// </div>
13524    pub async fn remove_path(&self, params: WorkspacesRemovePathRequest) -> Result<(), Error> {
13525        let mut wire_params = serde_json::to_value(params)?;
13526        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
13527        let _value = self
13528            .session
13529            .client()
13530            .call(
13531                rpc_methods::SESSION_WORKSPACES_REMOVEPATH,
13532                Some(wire_params),
13533            )
13534            .await?;
13535        Ok(())
13536    }
13537
13538    /// Renames a file or directory within the session workspace files directory.
13539    ///
13540    /// Wire method: `session.workspaces.renamePath`.
13541    ///
13542    /// # Parameters
13543    ///
13544    /// * `params` - Source and destination paths for a rename within the session workspace files directory.
13545    ///
13546    /// <div class="warning">
13547    ///
13548    /// **Experimental.** This API is part of an experimental wire-protocol surface
13549    /// and may change or be removed in future SDK or CLI releases. Pin both the
13550    /// SDK and CLI versions if your code depends on it.
13551    ///
13552    /// </div>
13553    pub async fn rename_path(&self, params: WorkspacesRenamePathRequest) -> Result<(), Error> {
13554        let mut wire_params = serde_json::to_value(params)?;
13555        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
13556        let _value = self
13557            .session
13558            .client()
13559            .call(
13560                rpc_methods::SESSION_WORKSPACES_RENAMEPATH,
13561                Some(wire_params),
13562            )
13563            .await?;
13564        Ok(())
13565    }
13566
13567    /// Lists workspace checkpoints in chronological order.
13568    ///
13569    /// Wire method: `session.workspaces.listCheckpoints`.
13570    ///
13571    /// # Returns
13572    ///
13573    /// Workspace checkpoints in chronological order; empty when the workspace is not enabled.
13574    ///
13575    /// <div class="warning">
13576    ///
13577    /// **Experimental.** This API is part of an experimental wire-protocol surface
13578    /// and may change or be removed in future SDK or CLI releases. Pin both the
13579    /// SDK and CLI versions if your code depends on it.
13580    ///
13581    /// </div>
13582    pub async fn list_checkpoints(&self) -> Result<WorkspacesListCheckpointsResult, Error> {
13583        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
13584        let _value = self
13585            .session
13586            .client()
13587            .call(
13588                rpc_methods::SESSION_WORKSPACES_LISTCHECKPOINTS,
13589                Some(wire_params),
13590            )
13591            .await?;
13592        Ok(serde_json::from_value(_value)?)
13593    }
13594
13595    /// Reads the content of a workspace checkpoint by number.
13596    ///
13597    /// Wire method: `session.workspaces.readCheckpoint`.
13598    ///
13599    /// # Parameters
13600    ///
13601    /// * `params` - Checkpoint number to read.
13602    ///
13603    /// # Returns
13604    ///
13605    /// Checkpoint content as a UTF-8 string, or null when the checkpoint or workspace is missing.
13606    ///
13607    /// <div class="warning">
13608    ///
13609    /// **Experimental.** This API is part of an experimental wire-protocol surface
13610    /// and may change or be removed in future SDK or CLI releases. Pin both the
13611    /// SDK and CLI versions if your code depends on it.
13612    ///
13613    /// </div>
13614    pub async fn read_checkpoint(
13615        &self,
13616        params: WorkspacesReadCheckpointRequest,
13617    ) -> Result<WorkspacesReadCheckpointResult, Error> {
13618        let mut wire_params = serde_json::to_value(params)?;
13619        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
13620        let _value = self
13621            .session
13622            .client()
13623            .call(
13624                rpc_methods::SESSION_WORKSPACES_READCHECKPOINT,
13625                Some(wire_params),
13626            )
13627            .await?;
13628        Ok(serde_json::from_value(_value)?)
13629    }
13630
13631    /// Adds a compaction summary checkpoint to the local session workspace.
13632    ///
13633    /// Wire method: `session.workspaces.addSummary`.
13634    ///
13635    /// # Parameters
13636    ///
13637    /// * `params` - Compaction summary checkpoint to persist.
13638    ///
13639    /// # Returns
13640    ///
13641    /// Persisted summary metadata and refreshed workspace metadata.
13642    ///
13643    /// <div class="warning">
13644    ///
13645    /// **Experimental.** This API is part of an experimental wire-protocol surface
13646    /// and may change or be removed in future SDK or CLI releases. Pin both the
13647    /// SDK and CLI versions if your code depends on it.
13648    ///
13649    /// </div>
13650    pub async fn add_summary(
13651        &self,
13652        params: WorkspacesAddSummaryRequest,
13653    ) -> Result<WorkspacesAddSummaryResult, Error> {
13654        let mut wire_params = serde_json::to_value(params)?;
13655        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
13656        let _value = self
13657            .session
13658            .client()
13659            .call(
13660                rpc_methods::SESSION_WORKSPACES_ADDSUMMARY,
13661                Some(wire_params),
13662            )
13663            .await?;
13664        Ok(serde_json::from_value(_value)?)
13665    }
13666
13667    /// Truncates local workspace compaction summaries after a rollback.
13668    ///
13669    /// Wire method: `session.workspaces.truncateSummaries`.
13670    ///
13671    /// # Parameters
13672    ///
13673    /// * `params` - Rollback point for local workspace summaries.
13674    ///
13675    /// # Returns
13676    ///
13677    /// Current workspace metadata for the session, including its absolute filesystem path when available.
13678    ///
13679    /// <div class="warning">
13680    ///
13681    /// **Experimental.** This API is part of an experimental wire-protocol surface
13682    /// and may change or be removed in future SDK or CLI releases. Pin both the
13683    /// SDK and CLI versions if your code depends on it.
13684    ///
13685    /// </div>
13686    pub async fn truncate_summaries(
13687        &self,
13688        params: WorkspacesTruncateSummariesRequest,
13689    ) -> Result<WorkspacesGetWorkspaceResult, Error> {
13690        let mut wire_params = serde_json::to_value(params)?;
13691        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
13692        let _value = self
13693            .session
13694            .client()
13695            .call(
13696                rpc_methods::SESSION_WORKSPACES_TRUNCATESUMMARIES,
13697                Some(wire_params),
13698            )
13699            .await?;
13700        Ok(serde_json::from_value(_value)?)
13701    }
13702
13703    /// Reads the autopilot objective state file from the local session workspace.
13704    ///
13705    /// Wire method: `session.workspaces.readAutopilotObjective`.
13706    ///
13707    /// # Returns
13708    ///
13709    /// Autopilot objective file content, or null when missing.
13710    ///
13711    /// <div class="warning">
13712    ///
13713    /// **Experimental.** This API is part of an experimental wire-protocol surface
13714    /// and may change or be removed in future SDK or CLI releases. Pin both the
13715    /// SDK and CLI versions if your code depends on it.
13716    ///
13717    /// </div>
13718    pub async fn read_autopilot_objective(
13719        &self,
13720    ) -> Result<WorkspacesReadAutopilotObjectiveResult, Error> {
13721        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
13722        let _value = self
13723            .session
13724            .client()
13725            .call(
13726                rpc_methods::SESSION_WORKSPACES_READAUTOPILOTOBJECTIVE,
13727                Some(wire_params),
13728            )
13729            .await?;
13730        Ok(serde_json::from_value(_value)?)
13731    }
13732
13733    /// Writes the autopilot objective state file in the local session workspace.
13734    ///
13735    /// Wire method: `session.workspaces.writeAutopilotObjective`.
13736    ///
13737    /// # Parameters
13738    ///
13739    /// * `params` - Autopilot objective file content to persist.
13740    ///
13741    /// # Returns
13742    ///
13743    /// Result of writing the autopilot objective file.
13744    ///
13745    /// <div class="warning">
13746    ///
13747    /// **Experimental.** This API is part of an experimental wire-protocol surface
13748    /// and may change or be removed in future SDK or CLI releases. Pin both the
13749    /// SDK and CLI versions if your code depends on it.
13750    ///
13751    /// </div>
13752    pub async fn write_autopilot_objective(
13753        &self,
13754        params: WorkspacesWriteAutopilotObjectiveRequest,
13755    ) -> Result<WorkspacesWriteAutopilotObjectiveResult, Error> {
13756        let mut wire_params = serde_json::to_value(params)?;
13757        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
13758        let _value = self
13759            .session
13760            .client()
13761            .call(
13762                rpc_methods::SESSION_WORKSPACES_WRITEAUTOPILOTOBJECTIVE,
13763                Some(wire_params),
13764            )
13765            .await?;
13766        Ok(serde_json::from_value(_value)?)
13767    }
13768
13769    /// Deletes the autopilot objective state file from the local session workspace.
13770    ///
13771    /// Wire method: `session.workspaces.deleteAutopilotObjective`.
13772    ///
13773    /// # Returns
13774    ///
13775    /// Result of deleting the autopilot objective file.
13776    ///
13777    /// <div class="warning">
13778    ///
13779    /// **Experimental.** This API is part of an experimental wire-protocol surface
13780    /// and may change or be removed in future SDK or CLI releases. Pin both the
13781    /// SDK and CLI versions if your code depends on it.
13782    ///
13783    /// </div>
13784    pub async fn delete_autopilot_objective(
13785        &self,
13786    ) -> Result<WorkspacesDeleteAutopilotObjectiveResult, Error> {
13787        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
13788        let _value = self
13789            .session
13790            .client()
13791            .call(
13792                rpc_methods::SESSION_WORKSPACES_DELETEAUTOPILOTOBJECTIVE,
13793                Some(wire_params),
13794            )
13795            .await?;
13796        Ok(serde_json::from_value(_value)?)
13797    }
13798
13799    /// Checks whether the local session workspace has an autopilot objective state file.
13800    ///
13801    /// Wire method: `session.workspaces.autopilotObjectiveExists`.
13802    ///
13803    /// # Returns
13804    ///
13805    /// Whether the autopilot objective file exists.
13806    ///
13807    /// <div class="warning">
13808    ///
13809    /// **Experimental.** This API is part of an experimental wire-protocol surface
13810    /// and may change or be removed in future SDK or CLI releases. Pin both the
13811    /// SDK and CLI versions if your code depends on it.
13812    ///
13813    /// </div>
13814    pub async fn autopilot_objective_exists(
13815        &self,
13816    ) -> Result<WorkspacesAutopilotObjectiveExistsResult, Error> {
13817        let wire_params = serde_json::json!({ "sessionId": self.session.id() });
13818        let _value = self
13819            .session
13820            .client()
13821            .call(
13822                rpc_methods::SESSION_WORKSPACES_AUTOPILOTOBJECTIVEEXISTS,
13823                Some(wire_params),
13824            )
13825            .await?;
13826        Ok(serde_json::from_value(_value)?)
13827    }
13828
13829    /// Saves pasted content as a UTF-8 file in the session workspace.
13830    ///
13831    /// Wire method: `session.workspaces.saveLargePaste`.
13832    ///
13833    /// # Parameters
13834    ///
13835    /// * `params` - Pasted content to save as a UTF-8 file in the session workspace.
13836    ///
13837    /// # Returns
13838    ///
13839    /// Descriptor for the saved paste file, or null when the workspace is unavailable.
13840    ///
13841    /// <div class="warning">
13842    ///
13843    /// **Experimental.** This API is part of an experimental wire-protocol surface
13844    /// and may change or be removed in future SDK or CLI releases. Pin both the
13845    /// SDK and CLI versions if your code depends on it.
13846    ///
13847    /// </div>
13848    pub async fn save_large_paste(
13849        &self,
13850        params: WorkspacesSaveLargePasteRequest,
13851    ) -> Result<WorkspacesSaveLargePasteResult, Error> {
13852        let mut wire_params = serde_json::to_value(params)?;
13853        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
13854        let _value = self
13855            .session
13856            .client()
13857            .call(
13858                rpc_methods::SESSION_WORKSPACES_SAVELARGEPASTE,
13859                Some(wire_params),
13860            )
13861            .await?;
13862        Ok(serde_json::from_value(_value)?)
13863    }
13864
13865    /// 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`.
13866    ///
13867    /// Wire method: `session.workspaces.diff`.
13868    ///
13869    /// # Parameters
13870    ///
13871    /// * `params` - Parameters for computing a workspace diff.
13872    ///
13873    /// # Returns
13874    ///
13875    /// Workspace diff result for the requested mode.
13876    ///
13877    /// <div class="warning">
13878    ///
13879    /// **Experimental.** This API is part of an experimental wire-protocol surface
13880    /// and may change or be removed in future SDK or CLI releases. Pin both the
13881    /// SDK and CLI versions if your code depends on it.
13882    ///
13883    /// </div>
13884    pub async fn diff(&self, params: WorkspacesDiffRequest) -> Result<WorkspaceDiffResult, Error> {
13885        let mut wire_params = serde_json::to_value(params)?;
13886        wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
13887        let _value = self
13888            .session
13889            .client()
13890            .call(rpc_methods::SESSION_WORKSPACES_DIFF, Some(wire_params))
13891            .await?;
13892        Ok(serde_json::from_value(_value)?)
13893    }
13894}