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 /// `accounts.*` sub-namespace.
33 pub fn accounts(&self) -> ClientRpcAccounts<'a> {
34 ClientRpcAccounts {
35 client: self.client,
36 }
37 }
38
39 /// `agentRegistry.*` sub-namespace.
40 pub fn agent_registry(&self) -> ClientRpcAgentRegistry<'a> {
41 ClientRpcAgentRegistry {
42 client: self.client,
43 }
44 }
45
46 /// `agents.*` sub-namespace.
47 pub fn agents(&self) -> ClientRpcAgents<'a> {
48 ClientRpcAgents {
49 client: self.client,
50 }
51 }
52
53 /// `catalog.*` sub-namespace.
54 pub fn catalog(&self) -> ClientRpcCatalog<'a> {
55 ClientRpcCatalog {
56 client: self.client,
57 }
58 }
59
60 /// `commands.*` sub-namespace.
61 pub fn commands(&self) -> ClientRpcCommands<'a> {
62 ClientRpcCommands {
63 client: self.client,
64 }
65 }
66
67 /// `extensions.*` sub-namespace.
68 pub fn extensions(&self) -> ClientRpcExtensions<'a> {
69 ClientRpcExtensions {
70 client: self.client,
71 }
72 }
73
74 /// `hooks.*` sub-namespace.
75 pub fn hooks(&self) -> ClientRpcHooks<'a> {
76 ClientRpcHooks {
77 client: self.client,
78 }
79 }
80
81 /// `instructions.*` sub-namespace.
82 pub fn instructions(&self) -> ClientRpcInstructions<'a> {
83 ClientRpcInstructions {
84 client: self.client,
85 }
86 }
87
88 /// `llmInference.*` sub-namespace.
89 pub fn llm_inference(&self) -> ClientRpcLlmInference<'a> {
90 ClientRpcLlmInference {
91 client: self.client,
92 }
93 }
94
95 /// `managedSettings.*` sub-namespace.
96 pub fn managed_settings(&self) -> ClientRpcManagedSettings<'a> {
97 ClientRpcManagedSettings {
98 client: self.client,
99 }
100 }
101
102 /// `mcp.*` sub-namespace.
103 pub fn mcp(&self) -> ClientRpcMcp<'a> {
104 ClientRpcMcp {
105 client: self.client,
106 }
107 }
108
109 /// `models.*` sub-namespace.
110 pub fn models(&self) -> ClientRpcModels<'a> {
111 ClientRpcModels {
112 client: self.client,
113 }
114 }
115
116 /// `plugins.*` sub-namespace.
117 pub fn plugins(&self) -> ClientRpcPlugins<'a> {
118 ClientRpcPlugins {
119 client: self.client,
120 }
121 }
122
123 /// `runtime.*` sub-namespace.
124 pub fn runtime(&self) -> ClientRpcRuntime<'a> {
125 ClientRpcRuntime {
126 client: self.client,
127 }
128 }
129
130 /// `sandbox.*` sub-namespace.
131 pub fn sandbox(&self) -> ClientRpcSandbox<'a> {
132 ClientRpcSandbox {
133 client: self.client,
134 }
135 }
136
137 /// `secrets.*` sub-namespace.
138 pub fn secrets(&self) -> ClientRpcSecrets<'a> {
139 ClientRpcSecrets {
140 client: self.client,
141 }
142 }
143
144 /// `sessionFs.*` sub-namespace.
145 pub fn session_fs(&self) -> ClientRpcSessionFs<'a> {
146 ClientRpcSessionFs {
147 client: self.client,
148 }
149 }
150
151 /// `sessions.*` sub-namespace.
152 pub fn sessions(&self) -> ClientRpcSessions<'a> {
153 ClientRpcSessions {
154 client: self.client,
155 }
156 }
157
158 /// `skills.*` sub-namespace.
159 pub fn skills(&self) -> ClientRpcSkills<'a> {
160 ClientRpcSkills {
161 client: self.client,
162 }
163 }
164
165 /// `tools.*` sub-namespace.
166 pub fn tools(&self) -> ClientRpcTools<'a> {
167 ClientRpcTools {
168 client: self.client,
169 }
170 }
171
172 /// `user.*` sub-namespace.
173 pub fn user(&self) -> ClientRpcUser<'a> {
174 ClientRpcUser {
175 client: self.client,
176 }
177 }
178
179 /// Checks server responsiveness and returns protocol information.
180 ///
181 /// Wire method: `ping`.
182 ///
183 /// # Parameters
184 ///
185 /// * `params` - Optional message to echo back to the caller.
186 ///
187 /// # Returns
188 ///
189 /// Server liveness response, including the echoed message, current server timestamp, and protocol version.
190 ///
191 /// <div class="warning">
192 ///
193 /// **Experimental.** This API is part of an experimental wire-protocol surface
194 /// and may change or be removed in future SDK or CLI releases. Pin both the
195 /// SDK and CLI versions if your code depends on it.
196 ///
197 /// </div>
198 pub async fn ping(&self, params: PingRequest) -> Result<PingResult, Error> {
199 let wire_params = serde_json::to_value(params)?;
200 let _value = self
201 .client
202 .call(rpc_methods::PING, Some(wire_params))
203 .await?;
204 Ok(serde_json::from_value(_value)?)
205 }
206
207 /// 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.
208 ///
209 /// Wire method: `connect`.
210 ///
211 /// # Parameters
212 ///
213 /// * `params` - Connection-level opt-ins for the `server.connect` handshake. Transport authentication is consumed by the native protocol boundary before dispatch.
214 ///
215 /// # Returns
216 ///
217 /// Handshake result reporting the server's protocol version and package version on success.
218 ///
219 /// <div class="warning">
220 ///
221 /// **Experimental.** This API is part of an experimental wire-protocol surface
222 /// and may change or be removed in future SDK or CLI releases. Pin both the
223 /// SDK and CLI versions if your code depends on it.
224 ///
225 /// </div>
226 pub(crate) async fn connect(&self, params: ConnectRequest) -> Result<ConnectResult, Error> {
227 let wire_params = serde_json::to_value(params)?;
228 let _value = self
229 .client
230 .call(rpc_methods::CONNECT, Some(wire_params))
231 .await?;
232 Ok(serde_json::from_value(_value)?)
233 }
234
235 /// 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.
236 ///
237 /// Wire method: `registerExtensionLaunchProvider`.
238 ///
239 /// <div class="warning">
240 ///
241 /// **Experimental.** This API is part of an experimental wire-protocol surface
242 /// and may change or be removed in future SDK or CLI releases. Pin both the
243 /// SDK and CLI versions if your code depends on it.
244 ///
245 /// </div>
246 pub async fn register_extension_launch_provider(&self) -> Result<(), Error> {
247 let wire_params = serde_json::json!({});
248 let _value = self
249 .client
250 .call(
251 rpc_methods::REGISTEREXTENSIONLAUNCHPROVIDER,
252 Some(wire_params),
253 )
254 .await?;
255 Ok(())
256 }
257}
258
259/// `account.*` RPCs.
260#[derive(Clone, Copy)]
261pub struct ClientRpcAccount<'a> {
262 pub(crate) client: &'a Client,
263}
264
265impl<'a> ClientRpcAccount<'a> {
266 /// Gets Copilot quota usage for the current or opaquely selected authenticated user.
267 ///
268 /// Wire method: `account.getQuota`.
269 ///
270 /// # Returns
271 ///
272 /// Quota usage snapshots for the resolved user, keyed by quota type.
273 ///
274 /// <div class="warning">
275 ///
276 /// **Experimental.** This API is part of an experimental wire-protocol surface
277 /// and may change or be removed in future SDK or CLI releases. Pin both the
278 /// SDK and CLI versions if your code depends on it.
279 ///
280 /// </div>
281 pub async fn get_quota(&self) -> Result<AccountGetQuotaResult, Error> {
282 let wire_params = serde_json::json!({});
283 let _value = self
284 .client
285 .call(rpc_methods::ACCOUNT_GETQUOTA, Some(wire_params))
286 .await?;
287 Ok(serde_json::from_value(_value)?)
288 }
289
290 /// Gets Copilot quota usage for the current or opaquely selected authenticated user.
291 ///
292 /// Wire method: `account.getQuota`.
293 ///
294 /// # Parameters
295 ///
296 /// * `params` - Optional opaque account selection or compatibility GitHub token used to look up quota.
297 ///
298 /// # Returns
299 ///
300 /// Quota usage snapshots for the resolved user, keyed by quota type.
301 ///
302 /// <div class="warning">
303 ///
304 /// **Experimental.** This API is part of an experimental wire-protocol surface
305 /// and may change or be removed in future SDK or CLI releases. Pin both the
306 /// SDK and CLI versions if your code depends on it.
307 ///
308 /// </div>
309 pub async fn get_quota_with_params(
310 &self,
311 params: AccountGetQuotaRequest,
312 ) -> Result<AccountGetQuotaResult, Error> {
313 let wire_params = serde_json::to_value(params)?;
314 let _value = self
315 .client
316 .call(rpc_methods::ACCOUNT_GETQUOTA, Some(wire_params))
317 .await?;
318 Ok(serde_json::from_value(_value)?)
319 }
320
321 /// Gets the currently active authentication credentials from the global auth manager.
322 ///
323 /// Wire method: `account.getCurrentAuth`.
324 ///
325 /// # Returns
326 ///
327 /// Current authentication state
328 ///
329 /// <div class="warning">
330 ///
331 /// **Experimental.** This API is part of an experimental wire-protocol surface
332 /// and may change or be removed in future SDK or CLI releases. Pin both the
333 /// SDK and CLI versions if your code depends on it.
334 ///
335 /// </div>
336 pub async fn get_current_auth(&self) -> Result<AccountGetCurrentAuthResult, Error> {
337 let wire_params = serde_json::json!({});
338 let _value = self
339 .client
340 .call(rpc_methods::ACCOUNT_GETCURRENTAUTH, Some(wire_params))
341 .await?;
342 Ok(serde_json::from_value(_value)?)
343 }
344
345 /// Gets all authenticated users available for account switching.
346 ///
347 /// Wire method: `account.getAllUsers`.
348 ///
349 /// # Returns
350 ///
351 /// List of all authenticated users
352 ///
353 /// <div class="warning">
354 ///
355 /// **Experimental.** This API is part of an experimental wire-protocol surface
356 /// and may change or be removed in future SDK or CLI releases. Pin both the
357 /// SDK and CLI versions if your code depends on it.
358 ///
359 /// </div>
360 pub async fn get_all_users(&self) -> Result<AccountGetAllUsersResult, Error> {
361 let wire_params = serde_json::json!({});
362 let _value = self
363 .client
364 .call(rpc_methods::ACCOUNT_GETALLUSERS, Some(wire_params))
365 .await?;
366 Ok(serde_json::from_value(_value)?)
367 }
368
369 /// Validates and stores authentication credentials. When login is omitted, resolves the authenticated user from the token before persistence.
370 ///
371 /// Wire method: `account.login`.
372 ///
373 /// # Parameters
374 ///
375 /// * `params` - Credentials to validate and store. Omit login to resolve the authenticated user from the token.
376 ///
377 /// # Returns
378 ///
379 /// Result of a successful login; throws on failure
380 ///
381 /// <div class="warning">
382 ///
383 /// **Experimental.** This API is part of an experimental wire-protocol surface
384 /// and may change or be removed in future SDK or CLI releases. Pin both the
385 /// SDK and CLI versions if your code depends on it.
386 ///
387 /// </div>
388 pub async fn login(&self, params: AccountLoginRequest) -> Result<AccountLoginResult, Error> {
389 let wire_params = serde_json::to_value(params)?;
390 let _value = self
391 .client
392 .call(rpc_methods::ACCOUNT_LOGIN, Some(wire_params))
393 .await?;
394 Ok(serde_json::from_value(_value)?)
395 }
396
397 /// Removes user authentication from keychain and persisted state.
398 ///
399 /// Wire method: `account.logout`.
400 ///
401 /// # Parameters
402 ///
403 /// * `params` - User to log out
404 ///
405 /// # Returns
406 ///
407 /// Logout result indicating if more users remain
408 ///
409 /// <div class="warning">
410 ///
411 /// **Experimental.** This API is part of an experimental wire-protocol surface
412 /// and may change or be removed in future SDK or CLI releases. Pin both the
413 /// SDK and CLI versions if your code depends on it.
414 ///
415 /// </div>
416 pub async fn logout(&self, params: AccountLogoutRequest) -> Result<AccountLogoutResult, Error> {
417 let wire_params = serde_json::to_value(params)?;
418 let _value = self
419 .client
420 .call(rpc_methods::ACCOUNT_LOGOUT, Some(wire_params))
421 .await?;
422 Ok(serde_json::from_value(_value)?)
423 }
424}
425
426/// `accounts.*` RPCs.
427#[derive(Clone, Copy)]
428pub struct ClientRpcAccounts<'a> {
429 pub(crate) client: &'a Client,
430}
431
432impl<'a> ClientRpcAccounts<'a> {
433 /// Acquire a Microsoft Entra access token through the runtime's OneAuth broker. Account-scoped because it uses the same native broker as the account stack: a trusted host application mints a scoped Entra token for its own use, most notably to authenticate to a remote MCP server whose authorization server is Entra ID (in place of the generic browser-OAuth flow).
434 ///
435 /// Wire method: `accounts.acquireEntraToken`.
436 ///
437 /// # Parameters
438 ///
439 /// * `params` - OneAuth token request supplied by a trusted host application.
440 ///
441 /// # Returns
442 ///
443 /// Result of a OneAuth token acquisition.
444 ///
445 /// <div class="warning">
446 ///
447 /// **Experimental.** This API is part of an experimental wire-protocol surface
448 /// and may change or be removed in future SDK or CLI releases. Pin both the
449 /// SDK and CLI versions if your code depends on it.
450 ///
451 /// </div>
452 pub(crate) async fn acquire_entra_token(
453 &self,
454 params: EntraTokenAcquireRequest,
455 ) -> Result<EntraTokenAcquireResult, Error> {
456 let wire_params = serde_json::to_value(params)?;
457 let _value = self
458 .client
459 .call(rpc_methods::ACCOUNTS_ACQUIREENTRATOKEN, Some(wire_params))
460 .await?;
461 Ok(serde_json::from_value(_value)?)
462 }
463}
464
465/// `agentRegistry.*` RPCs.
466#[derive(Clone, Copy)]
467pub struct ClientRpcAgentRegistry<'a> {
468 pub(crate) client: &'a Client,
469}
470
471impl<'a> ClientRpcAgentRegistry<'a> {
472 /// 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.
473 ///
474 /// Wire method: `agentRegistry.spawn`.
475 ///
476 /// # Parameters
477 ///
478 /// * `params` - Inputs to spawn a managed-server child via the controller's spawn delegate.
479 ///
480 /// # Returns
481 ///
482 /// Outcome of an agentRegistry.spawn call.
483 ///
484 /// <div class="warning">
485 ///
486 /// **Experimental.** This API is part of an experimental wire-protocol surface
487 /// and may change or be removed in future SDK or CLI releases. Pin both the
488 /// SDK and CLI versions if your code depends on it.
489 ///
490 /// </div>
491 pub async fn spawn(
492 &self,
493 params: AgentRegistrySpawnRequest,
494 ) -> Result<AgentRegistrySpawnResult, Error> {
495 let wire_params = serde_json::to_value(params)?;
496 let _value = self
497 .client
498 .call(rpc_methods::AGENTREGISTRY_SPAWN, Some(wire_params))
499 .await?;
500 Ok(serde_json::from_value(_value)?)
501 }
502}
503
504/// `agents.*` RPCs.
505#[derive(Clone, Copy)]
506pub struct ClientRpcAgents<'a> {
507 pub(crate) client: &'a Client,
508}
509
510impl<'a> ClientRpcAgents<'a> {
511 /// Discovers custom agents across user, project, plugin, and remote sources.
512 ///
513 /// Wire method: `agents.discover`.
514 ///
515 /// # Parameters
516 ///
517 /// * `params` - Optional project paths to include in agent discovery.
518 ///
519 /// # Returns
520 ///
521 /// Agents discovered across user, project, plugin, and remote sources.
522 ///
523 /// <div class="warning">
524 ///
525 /// **Experimental.** This API is part of an experimental wire-protocol surface
526 /// and may change or be removed in future SDK or CLI releases. Pin both the
527 /// SDK and CLI versions if your code depends on it.
528 ///
529 /// </div>
530 pub async fn discover(&self, params: AgentsDiscoverRequest) -> Result<ServerAgentList, Error> {
531 let wire_params = serde_json::to_value(params)?;
532 let _value = self
533 .client
534 .call(rpc_methods::AGENTS_DISCOVER, Some(wire_params))
535 .await?;
536 Ok(serde_json::from_value(_value)?)
537 }
538
539 /// 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.
540 ///
541 /// Wire method: `agents.getDiscoveryPaths`.
542 ///
543 /// # Parameters
544 ///
545 /// * `params` - Optional project paths to include when enumerating agent discovery directories.
546 ///
547 /// # Returns
548 ///
549 /// Canonical locations where custom agents can be created so the runtime will recognize them.
550 ///
551 /// <div class="warning">
552 ///
553 /// **Experimental.** This API is part of an experimental wire-protocol surface
554 /// and may change or be removed in future SDK or CLI releases. Pin both the
555 /// SDK and CLI versions if your code depends on it.
556 ///
557 /// </div>
558 pub async fn get_discovery_paths(
559 &self,
560 params: AgentsGetDiscoveryPathsRequest,
561 ) -> Result<AgentDiscoveryPathList, Error> {
562 let wire_params = serde_json::to_value(params)?;
563 let _value = self
564 .client
565 .call(rpc_methods::AGENTS_GETDISCOVERYPATHS, Some(wire_params))
566 .await?;
567 Ok(serde_json::from_value(_value)?)
568 }
569}
570
571/// `catalog.*` RPCs.
572#[derive(Clone, Copy)]
573pub struct ClientRpcCatalog<'a> {
574 pub(crate) client: &'a Client,
575}
576
577impl<'a> ClientRpcCatalog<'a> {
578 /// 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.
579 ///
580 /// Wire method: `catalog.search`.
581 ///
582 /// # Parameters
583 ///
584 /// * `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.
585 ///
586 /// # Returns
587 ///
588 /// Outcome of a catalog.search call: either bounded inert candidates, or one typed refusal. Never a partial success.
589 ///
590 /// <div class="warning">
591 ///
592 /// **Experimental.** This API is part of an experimental wire-protocol surface
593 /// and may change or be removed in future SDK or CLI releases. Pin both the
594 /// SDK and CLI versions if your code depends on it.
595 ///
596 /// </div>
597 pub async fn search(&self, params: CatalogSearchRequest) -> Result<CatalogSearchResult, Error> {
598 let wire_params = serde_json::to_value(params)?;
599 let _value = self
600 .client
601 .call(rpc_methods::CATALOG_SEARCH, Some(wire_params))
602 .await?;
603 Ok(serde_json::from_value(_value)?)
604 }
605
606 /// 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.
607 ///
608 /// Wire method: `catalog.search`.
609 ///
610 /// # Parameters
611 ///
612 /// * `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.
613 ///
614 /// # Returns
615 ///
616 /// Outcome of a catalog.search call: either bounded inert candidates, or one typed refusal. Never a partial success.
617 ///
618 /// <div class="warning">
619 ///
620 /// **Experimental.** This API is part of an experimental wire-protocol surface
621 /// and may change or be removed in future SDK or CLI releases. Pin both the
622 /// SDK and CLI versions if your code depends on it.
623 ///
624 /// </div>
625 ///
626 /// Accepts [`CatalogSearchOptions`], including inputs added after [`CatalogSearchRequest`].
627 pub async fn search_with_options(
628 &self,
629 params: CatalogSearchOptions,
630 ) -> Result<CatalogSearchResult, Error> {
631 let wire_params = serde_json::to_value(params)?;
632 let _value = self
633 .client
634 .call(rpc_methods::CATALOG_SEARCH, Some(wire_params))
635 .await?;
636 Ok(serde_json::from_value(_value)?)
637 }
638
639 /// 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.
640 ///
641 /// Wire method: `catalog.select`.
642 ///
643 /// # Parameters
644 ///
645 /// * `params` - Terminates one retained catalog selection group through an opaque reference previously returned by the model-safe search projection.
646 ///
647 /// # Returns
648 ///
649 /// 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.
650 ///
651 /// <div class="warning">
652 ///
653 /// **Experimental.** This API is part of an experimental wire-protocol surface
654 /// and may change or be removed in future SDK or CLI releases. Pin both the
655 /// SDK and CLI versions if your code depends on it.
656 ///
657 /// </div>
658 pub async fn select(
659 &self,
660 params: CatalogSelectionRequest,
661 ) -> Result<CatalogSelectionResult, Error> {
662 let wire_params = serde_json::to_value(params)?;
663 let _value = self
664 .client
665 .call(rpc_methods::CATALOG_SELECT, Some(wire_params))
666 .await?;
667 Ok(serde_json::from_value(_value)?)
668 }
669}
670
671/// `commands.*` RPCs.
672#[derive(Clone, Copy)]
673pub struct ClientRpcCommands<'a> {
674 pub(crate) client: &'a Client,
675}
676
677impl<'a> ClientRpcCommands<'a> {
678 /// 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.
679 ///
680 /// Wire method: `commands.list`.
681 ///
682 /// # Returns
683 ///
684 /// Slash commands available in the session, after applying any include/exclude filters.
685 ///
686 /// <div class="warning">
687 ///
688 /// **Experimental.** This API is part of an experimental wire-protocol surface
689 /// and may change or be removed in future SDK or CLI releases. Pin both the
690 /// SDK and CLI versions if your code depends on it.
691 ///
692 /// </div>
693 pub async fn list(&self) -> Result<CommandList, Error> {
694 let wire_params = serde_json::json!({});
695 let _value = self
696 .client
697 .call(rpc_methods::COMMANDS_LIST, Some(wire_params))
698 .await?;
699 Ok(serde_json::from_value(_value)?)
700 }
701}
702
703/// `extensions.*` RPCs.
704#[derive(Clone, Copy)]
705pub struct ClientRpcExtensions<'a> {
706 pub(crate) client: &'a Client,
707}
708
709impl<'a> ClientRpcExtensions<'a> {
710 /// Discovers user and enabled installed-plugin extensions from persisted Copilot home state, including enablement preferences. Launch-scoped additional plugins are not included.
711 ///
712 /// Wire method: `extensions.discover`.
713 ///
714 /// # Returns
715 ///
716 /// Extensions discovered from persisted Copilot home state and their effective loading mode. Launch-scoped additional plugins are not included.
717 ///
718 /// <div class="warning">
719 ///
720 /// **Experimental.** This API is part of an experimental wire-protocol surface
721 /// and may change or be removed in future SDK or CLI releases. Pin both the
722 /// SDK and CLI versions if your code depends on it.
723 ///
724 /// </div>
725 pub async fn discover(&self) -> Result<DiscoveredExtensions, Error> {
726 let wire_params = serde_json::json!({});
727 let _value = self
728 .client
729 .call(rpc_methods::EXTENSIONS_DISCOVER, Some(wire_params))
730 .await?;
731 Ok(serde_json::from_value(_value)?)
732 }
733
734 /// Persistently enables extension IDs for future sessions. Active sessions are unchanged; use session.extensions.enable to update them.
735 ///
736 /// Wire method: `extensions.enable`.
737 ///
738 /// # Parameters
739 ///
740 /// * `params` - Source-qualified extension identifiers to persistently enable for future sessions.
741 ///
742 /// <div class="warning">
743 ///
744 /// **Experimental.** This API is part of an experimental wire-protocol surface
745 /// and may change or be removed in future SDK or CLI releases. Pin both the
746 /// SDK and CLI versions if your code depends on it.
747 ///
748 /// </div>
749 pub async fn enable(&self, params: DiscoveredExtensionsEnableRequest) -> Result<(), Error> {
750 let wire_params = serde_json::to_value(params)?;
751 let _value = self
752 .client
753 .call(rpc_methods::EXTENSIONS_ENABLE, Some(wire_params))
754 .await?;
755 Ok(())
756 }
757
758 /// Persistently disables extension IDs for future sessions. Active sessions are unchanged; use session.extensions.disable to update them.
759 ///
760 /// Wire method: `extensions.disable`.
761 ///
762 /// # Parameters
763 ///
764 /// * `params` - Source-qualified extension identifiers to persistently disable for future sessions.
765 ///
766 /// <div class="warning">
767 ///
768 /// **Experimental.** This API is part of an experimental wire-protocol surface
769 /// and may change or be removed in future SDK or CLI releases. Pin both the
770 /// SDK and CLI versions if your code depends on it.
771 ///
772 /// </div>
773 pub async fn disable(&self, params: DiscoveredExtensionsDisableRequest) -> Result<(), Error> {
774 let wire_params = serde_json::to_value(params)?;
775 let _value = self
776 .client
777 .call(rpc_methods::EXTENSIONS_DISABLE, Some(wire_params))
778 .await?;
779 Ok(())
780 }
781}
782
783/// `hooks.*` RPCs.
784#[derive(Clone, Copy)]
785pub struct ClientRpcHooks<'a> {
786 pub(crate) client: &'a Client,
787}
788
789impl<'a> ClientRpcHooks<'a> {
790 /// Discovers hook actions enabled under server-side discovery settings from user, repository, plugin, and managed-policy sources.
791 ///
792 /// Wire method: `hooks.discover`.
793 ///
794 /// # Parameters
795 ///
796 /// * `params` - Optional project paths and host-exclusion behavior for server-scoped hook discovery.
797 ///
798 /// # Returns
799 ///
800 /// 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.
801 ///
802 /// <div class="warning">
803 ///
804 /// **Experimental.** This API is part of an experimental wire-protocol surface
805 /// and may change or be removed in future SDK or CLI releases. Pin both the
806 /// SDK and CLI versions if your code depends on it.
807 ///
808 /// </div>
809 pub async fn discover(
810 &self,
811 params: HooksDiscoverRequest,
812 ) -> Result<HooksDiscoverResult, Error> {
813 let wire_params = serde_json::to_value(params)?;
814 let _value = self
815 .client
816 .call(rpc_methods::HOOKS_DISCOVER, Some(wire_params))
817 .await?;
818 Ok(serde_json::from_value(_value)?)
819 }
820}
821
822/// `instructions.*` RPCs.
823#[derive(Clone, Copy)]
824pub struct ClientRpcInstructions<'a> {
825 pub(crate) client: &'a Client,
826}
827
828impl<'a> ClientRpcInstructions<'a> {
829 /// Discovers instruction sources across user, repository, and plugin sources.
830 ///
831 /// Wire method: `instructions.discover`.
832 ///
833 /// # Parameters
834 ///
835 /// * `params` - Optional project paths to include in instruction discovery.
836 ///
837 /// # Returns
838 ///
839 /// Instruction sources discovered across user, repository, and plugin sources.
840 ///
841 /// <div class="warning">
842 ///
843 /// **Experimental.** This API is part of an experimental wire-protocol surface
844 /// and may change or be removed in future SDK or CLI releases. Pin both the
845 /// SDK and CLI versions if your code depends on it.
846 ///
847 /// </div>
848 pub async fn discover(
849 &self,
850 params: InstructionsDiscoverRequest,
851 ) -> Result<ServerInstructionSourceList, Error> {
852 let wire_params = serde_json::to_value(params)?;
853 let _value = self
854 .client
855 .call(rpc_methods::INSTRUCTIONS_DISCOVER, Some(wire_params))
856 .await?;
857 Ok(serde_json::from_value(_value)?)
858 }
859
860 /// 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.
861 ///
862 /// Wire method: `instructions.getDiscoveryPaths`.
863 ///
864 /// # Parameters
865 ///
866 /// * `params` - Optional project paths to include when enumerating instruction discovery targets.
867 ///
868 /// # Returns
869 ///
870 /// Canonical files and directories where custom instructions can be created so the runtime will recognize them.
871 ///
872 /// <div class="warning">
873 ///
874 /// **Experimental.** This API is part of an experimental wire-protocol surface
875 /// and may change or be removed in future SDK or CLI releases. Pin both the
876 /// SDK and CLI versions if your code depends on it.
877 ///
878 /// </div>
879 pub async fn get_discovery_paths(
880 &self,
881 params: InstructionsGetDiscoveryPathsRequest,
882 ) -> Result<InstructionDiscoveryPathList, Error> {
883 let wire_params = serde_json::to_value(params)?;
884 let _value = self
885 .client
886 .call(
887 rpc_methods::INSTRUCTIONS_GETDISCOVERYPATHS,
888 Some(wire_params),
889 )
890 .await?;
891 Ok(serde_json::from_value(_value)?)
892 }
893}
894
895/// `llmInference.*` RPCs.
896#[derive(Clone, Copy)]
897pub struct ClientRpcLlmInference<'a> {
898 pub(crate) client: &'a Client,
899}
900
901impl<'a> ClientRpcLlmInference<'a> {
902 /// Registers an SDK client as the LLM inference callback provider.
903 ///
904 /// Wire method: `llmInference.setProvider`.
905 ///
906 /// # Returns
907 ///
908 /// Indicates whether the calling client was registered as the LLM inference provider.
909 ///
910 /// <div class="warning">
911 ///
912 /// **Experimental.** This API is part of an experimental wire-protocol surface
913 /// and may change or be removed in future SDK or CLI releases. Pin both the
914 /// SDK and CLI versions if your code depends on it.
915 ///
916 /// </div>
917 pub async fn set_provider(&self) -> Result<LlmInferenceSetProviderResult, Error> {
918 let wire_params = serde_json::json!({});
919 let _value = self
920 .client
921 .call(rpc_methods::LLMINFERENCE_SETPROVIDER, Some(wire_params))
922 .await?;
923 Ok(serde_json::from_value(_value)?)
924 }
925
926 /// 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.
927 ///
928 /// Wire method: `llmInference.httpResponseStart`.
929 ///
930 /// # Parameters
931 ///
932 /// * `params` - Response head.
933 ///
934 /// # Returns
935 ///
936 /// Whether the start frame was accepted.
937 ///
938 /// <div class="warning">
939 ///
940 /// **Experimental.** This API is part of an experimental wire-protocol surface
941 /// and may change or be removed in future SDK or CLI releases. Pin both the
942 /// SDK and CLI versions if your code depends on it.
943 ///
944 /// </div>
945 pub async fn http_response_start(
946 &self,
947 params: LlmInferenceHttpResponseStartRequest,
948 ) -> Result<LlmInferenceHttpResponseStartResult, Error> {
949 let wire_params = serde_json::to_value(params)?;
950 let _value = self
951 .client
952 .call(
953 rpc_methods::LLMINFERENCE_HTTPRESPONSESTART,
954 Some(wire_params),
955 )
956 .await?;
957 Ok(serde_json::from_value(_value)?)
958 }
959
960 /// 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.
961 ///
962 /// Wire method: `llmInference.httpResponseChunk`.
963 ///
964 /// # Parameters
965 ///
966 /// * `params` - A response body chunk or terminal error.
967 ///
968 /// # Returns
969 ///
970 /// Whether the chunk was accepted.
971 ///
972 /// <div class="warning">
973 ///
974 /// **Experimental.** This API is part of an experimental wire-protocol surface
975 /// and may change or be removed in future SDK or CLI releases. Pin both the
976 /// SDK and CLI versions if your code depends on it.
977 ///
978 /// </div>
979 pub async fn http_response_chunk(
980 &self,
981 params: LlmInferenceHttpResponseChunkRequest,
982 ) -> Result<LlmInferenceHttpResponseChunkResult, Error> {
983 let wire_params = serde_json::to_value(params)?;
984 let _value = self
985 .client
986 .call(
987 rpc_methods::LLMINFERENCE_HTTPRESPONSECHUNK,
988 Some(wire_params),
989 )
990 .await?;
991 Ok(serde_json::from_value(_value)?)
992 }
993}
994
995/// `managedSettings.*` RPCs.
996#[derive(Clone, Copy)]
997pub struct ClientRpcManagedSettings<'a> {
998 pub(crate) client: &'a Client,
999}
1000
1001impl<'a> ClientRpcManagedSettings<'a> {
1002 /// 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.
1003 ///
1004 /// Wire method: `managedSettings.read`.
1005 ///
1006 /// # Returns
1007 ///
1008 /// Validated device-managed settings discovered before a session exists.
1009 ///
1010 /// <div class="warning">
1011 ///
1012 /// **Experimental.** This API is part of an experimental wire-protocol surface
1013 /// and may change or be removed in future SDK or CLI releases. Pin both the
1014 /// SDK and CLI versions if your code depends on it.
1015 ///
1016 /// </div>
1017 pub async fn read(&self) -> Result<ManagedSettingsReadResult, Error> {
1018 let wire_params = serde_json::json!({});
1019 let _value = self
1020 .client
1021 .call(rpc_methods::MANAGEDSETTINGS_READ, Some(wire_params))
1022 .await?;
1023 Ok(serde_json::from_value(_value)?)
1024 }
1025
1026 /// 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.
1027 ///
1028 /// Wire method: `managedSettings.clearCache`.
1029 ///
1030 /// <div class="warning">
1031 ///
1032 /// **Experimental.** This API is part of an experimental wire-protocol surface
1033 /// and may change or be removed in future SDK or CLI releases. Pin both the
1034 /// SDK and CLI versions if your code depends on it.
1035 ///
1036 /// </div>
1037 pub async fn clear_cache(&self) -> Result<(), Error> {
1038 let wire_params = serde_json::json!({});
1039 let _value = self
1040 .client
1041 .call(rpc_methods::MANAGEDSETTINGS_CLEARCACHE, Some(wire_params))
1042 .await?;
1043 Ok(())
1044 }
1045}
1046
1047/// `mcp.*` RPCs.
1048#[derive(Clone, Copy)]
1049pub struct ClientRpcMcp<'a> {
1050 pub(crate) client: &'a Client,
1051}
1052
1053impl<'a> ClientRpcMcp<'a> {
1054 /// `mcp.config.*` sub-namespace.
1055 pub fn config(&self) -> ClientRpcMcpConfig<'a> {
1056 ClientRpcMcpConfig {
1057 client: self.client,
1058 }
1059 }
1060
1061 /// `mcp.installations.*` sub-namespace.
1062 pub fn installations(&self) -> ClientRpcMcpInstallations<'a> {
1063 ClientRpcMcpInstallations {
1064 client: self.client,
1065 }
1066 }
1067
1068 /// Discovers MCP servers from user, workspace, plugin, and builtin sources.
1069 ///
1070 /// Wire method: `mcp.discover`.
1071 ///
1072 /// # Parameters
1073 ///
1074 /// * `params` - Optional working directory used as context for MCP server discovery.
1075 ///
1076 /// # Returns
1077 ///
1078 /// MCP servers discovered from user, workspace, plugin, and built-in sources.
1079 ///
1080 /// <div class="warning">
1081 ///
1082 /// **Experimental.** This API is part of an experimental wire-protocol surface
1083 /// and may change or be removed in future SDK or CLI releases. Pin both the
1084 /// SDK and CLI versions if your code depends on it.
1085 ///
1086 /// </div>
1087 pub async fn discover(&self, params: McpDiscoverRequest) -> Result<McpDiscoverResult, Error> {
1088 let wire_params = serde_json::to_value(params)?;
1089 let _value = self
1090 .client
1091 .call(rpc_methods::MCP_DISCOVER, Some(wire_params))
1092 .await?;
1093 Ok(serde_json::from_value(_value)?)
1094 }
1095
1096 /// 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.
1097 ///
1098 /// Wire method: `mcp.planInstall`.
1099 ///
1100 /// # Parameters
1101 ///
1102 /// * `params` - A side-effect-free request for an MCP install plan. Computing a plan never writes configuration, stores a secret, or reloads MCP servers.
1103 ///
1104 /// # Returns
1105 ///
1106 /// Outcome of an mcp.planInstall call: either a normalised plan, or one typed refusal. Nothing is written in either case.
1107 ///
1108 /// <div class="warning">
1109 ///
1110 /// **Experimental.** This API is part of an experimental wire-protocol surface
1111 /// and may change or be removed in future SDK or CLI releases. Pin both the
1112 /// SDK and CLI versions if your code depends on it.
1113 ///
1114 /// </div>
1115 pub async fn plan_install(
1116 &self,
1117 params: McpPlanInstallRequest,
1118 ) -> Result<McpPlanInstallResult, Error> {
1119 let wire_params = serde_json::to_value(params)?;
1120 let _value = self
1121 .client
1122 .call(rpc_methods::MCP_PLANINSTALL, Some(wire_params))
1123 .await?;
1124 Ok(serde_json::from_value(_value)?)
1125 }
1126
1127 /// 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.
1128 ///
1129 /// Wire method: `mcp.planInstall`.
1130 ///
1131 /// # Parameters
1132 ///
1133 /// * `params` - A side-effect-free request for an MCP install plan. Computing a plan never writes configuration, stores a secret, or reloads MCP servers.
1134 ///
1135 /// # Returns
1136 ///
1137 /// Outcome of an mcp.planInstall call: either a normalised plan, or one typed refusal. Nothing is written in either case.
1138 ///
1139 /// <div class="warning">
1140 ///
1141 /// **Experimental.** This API is part of an experimental wire-protocol surface
1142 /// and may change or be removed in future SDK or CLI releases. Pin both the
1143 /// SDK and CLI versions if your code depends on it.
1144 ///
1145 /// </div>
1146 ///
1147 /// Accepts [`McpPlanInstallOptions`], including inputs added after [`McpPlanInstallRequest`].
1148 pub async fn plan_install_with_options(
1149 &self,
1150 params: McpPlanInstallOptions,
1151 ) -> Result<McpPlanInstallResult, Error> {
1152 let wire_params = serde_json::to_value(params)?;
1153 let _value = self
1154 .client
1155 .call(rpc_methods::MCP_PLANINSTALL, Some(wire_params))
1156 .await?;
1157 Ok(serde_json::from_value(_value)?)
1158 }
1159
1160 /// Consumes a bound catalogue plan and retains one exact fully resolved personal remote MCP operation requiring no supplied values or configured secrets. Returns its runtime operation ID and original expiry before any confirmation, activation, writer initialisation or installation effect. Register the original connection, operation and selected-session binding before calling applyInstall. Missing lower owned admission is unavailable, never a raw-config fallback.
1161 ///
1162 /// Wire method: `mcp.prepareInstall`.
1163 ///
1164 /// # Parameters
1165 ///
1166 /// * `params` - Side-effect-free preparation of one original bound remote MCP choice.
1167 ///
1168 /// # Returns
1169 ///
1170 /// Management result with contract receipt, or a typed request/negotiation refusal.
1171 ///
1172 /// <div class="warning">
1173 ///
1174 /// **Experimental.** This API is part of an experimental wire-protocol surface
1175 /// and may change or be removed in future SDK or CLI releases. Pin both the
1176 /// SDK and CLI versions if your code depends on it.
1177 ///
1178 /// </div>
1179 pub async fn prepare_install(
1180 &self,
1181 params: McpPrepareInstallRequest,
1182 ) -> Result<McpInstallationManagementResult, Error> {
1183 let wire_params = serde_json::to_value(params)?;
1184 let _value = self
1185 .client
1186 .call(rpc_methods::MCP_PREPAREINSTALL, Some(wire_params))
1187 .await?;
1188 Ok(serde_json::from_value(_value)?)
1189 }
1190
1191 /// Consumes a retained prepared MCP operation once, revalidates its original authority, requests explicit human consent through installations.confirm on the original connection, then revalidates source and applies the sealed transaction. An uncertain result requires original-operation inspection or recovery, never replay.
1192 ///
1193 /// Wire method: `mcp.applyInstall`.
1194 ///
1195 /// # Parameters
1196 ///
1197 /// * `params` - Applies exactly one previously prepared operation on its original connection.
1198 ///
1199 /// # Returns
1200 ///
1201 /// An installation result together with the exact honoured contract, or a negotiation refusal.
1202 ///
1203 /// <div class="warning">
1204 ///
1205 /// **Experimental.** This API is part of an experimental wire-protocol surface
1206 /// and may change or be removed in future SDK or CLI releases. Pin both the
1207 /// SDK and CLI versions if your code depends on it.
1208 ///
1209 /// </div>
1210 pub async fn apply_install(
1211 &self,
1212 params: McpApplyInstallRequest,
1213 ) -> Result<McpInstallationResult, Error> {
1214 let wire_params = serde_json::to_value(params)?;
1215 let _value = self
1216 .client
1217 .call(rpc_methods::MCP_APPLYINSTALL, Some(wire_params))
1218 .await?;
1219 Ok(serde_json::from_value(_value)?)
1220 }
1221
1222 /// Prepares a read-only removal plan for an exact owned receipt under the selected existing session. Returns the original operation ID before confirmation; neither planning nor abandonment changes configuration or shared OAuth credentials.
1223 ///
1224 /// Wire method: `mcp.planUninstall`.
1225 ///
1226 /// # Parameters
1227 ///
1228 /// * `params` - Read-only preparation of one owned removal under fresh selected-session authority.
1229 ///
1230 /// # Returns
1231 ///
1232 /// Management result with contract receipt, or a typed request/negotiation refusal.
1233 ///
1234 /// <div class="warning">
1235 ///
1236 /// **Experimental.** This API is part of an experimental wire-protocol surface
1237 /// and may change or be removed in future SDK or CLI releases. Pin both the
1238 /// SDK and CLI versions if your code depends on it.
1239 ///
1240 /// </div>
1241 pub async fn plan_uninstall(
1242 &self,
1243 params: McpPlanUninstallRequest,
1244 ) -> Result<McpInstallationManagementResult, Error> {
1245 let wire_params = serde_json::to_value(params)?;
1246 let _value = self
1247 .client
1248 .call(rpc_methods::MCP_PLANUNINSTALL, Some(wire_params))
1249 .await?;
1250 Ok(serde_json::from_value(_value)?)
1251 }
1252
1253 /// Consumes the original owned-removal plan once and requests fresh exact human confirmation on its original connection. Drift is refused; unrelated manual configuration and shared OAuth credentials are preserved.
1254 ///
1255 /// Wire method: `mcp.applyUninstall`.
1256 ///
1257 /// # Parameters
1258 ///
1259 /// * `params` - One-use application of the exact retained removal plan.
1260 ///
1261 /// # Returns
1262 ///
1263 /// An installation result together with the exact honoured contract, or a negotiation refusal.
1264 ///
1265 /// <div class="warning">
1266 ///
1267 /// **Experimental.** This API is part of an experimental wire-protocol surface
1268 /// and may change or be removed in future SDK or CLI releases. Pin both the
1269 /// SDK and CLI versions if your code depends on it.
1270 ///
1271 /// </div>
1272 pub async fn apply_uninstall(
1273 &self,
1274 params: McpApplyUninstallRequest,
1275 ) -> Result<McpInstallationResult, Error> {
1276 let wire_params = serde_json::to_value(params)?;
1277 let _value = self
1278 .client
1279 .call(rpc_methods::MCP_APPLYUNINSTALL, Some(wire_params))
1280 .await?;
1281 Ok(serde_json::from_value(_value)?)
1282 }
1283}
1284
1285/// `mcp.config.*` RPCs.
1286#[derive(Clone, Copy)]
1287pub struct ClientRpcMcpConfig<'a> {
1288 pub(crate) client: &'a Client,
1289}
1290
1291impl<'a> ClientRpcMcpConfig<'a> {
1292 /// Lists MCP servers from user configuration.
1293 ///
1294 /// Wire method: `mcp.config.list`.
1295 ///
1296 /// # Returns
1297 ///
1298 /// User-configured MCP servers, keyed by server name.
1299 ///
1300 /// <div class="warning">
1301 ///
1302 /// **Experimental.** This API is part of an experimental wire-protocol surface
1303 /// and may change or be removed in future SDK or CLI releases. Pin both the
1304 /// SDK and CLI versions if your code depends on it.
1305 ///
1306 /// </div>
1307 pub async fn list(&self) -> Result<McpConfigList, Error> {
1308 let wire_params = serde_json::json!({});
1309 let _value = self
1310 .client
1311 .call(rpc_methods::MCP_CONFIG_LIST, Some(wire_params))
1312 .await?;
1313 Ok(serde_json::from_value(_value)?)
1314 }
1315
1316 /// Adds an MCP server to user configuration.
1317 ///
1318 /// Wire method: `mcp.config.add`.
1319 ///
1320 /// # Parameters
1321 ///
1322 /// * `params` - MCP server name and configuration to add to user configuration.
1323 ///
1324 /// <div class="warning">
1325 ///
1326 /// **Experimental.** This API is part of an experimental wire-protocol surface
1327 /// and may change or be removed in future SDK or CLI releases. Pin both the
1328 /// SDK and CLI versions if your code depends on it.
1329 ///
1330 /// </div>
1331 pub async fn add(&self, params: McpConfigAddRequest) -> Result<(), Error> {
1332 let wire_params = serde_json::to_value(params)?;
1333 let _value = self
1334 .client
1335 .call(rpc_methods::MCP_CONFIG_ADD, Some(wire_params))
1336 .await?;
1337 Ok(())
1338 }
1339
1340 /// Updates an MCP server in user configuration.
1341 ///
1342 /// Wire method: `mcp.config.update`.
1343 ///
1344 /// # Parameters
1345 ///
1346 /// * `params` - MCP server name and replacement configuration to write to user configuration.
1347 ///
1348 /// <div class="warning">
1349 ///
1350 /// **Experimental.** This API is part of an experimental wire-protocol surface
1351 /// and may change or be removed in future SDK or CLI releases. Pin both the
1352 /// SDK and CLI versions if your code depends on it.
1353 ///
1354 /// </div>
1355 pub async fn update(&self, params: McpConfigUpdateRequest) -> Result<(), Error> {
1356 let wire_params = serde_json::to_value(params)?;
1357 let _value = self
1358 .client
1359 .call(rpc_methods::MCP_CONFIG_UPDATE, Some(wire_params))
1360 .await?;
1361 Ok(())
1362 }
1363
1364 /// Removes an MCP server from user configuration.
1365 ///
1366 /// Wire method: `mcp.config.remove`.
1367 ///
1368 /// # Parameters
1369 ///
1370 /// * `params` - MCP server name to remove from user configuration.
1371 ///
1372 /// <div class="warning">
1373 ///
1374 /// **Experimental.** This API is part of an experimental wire-protocol surface
1375 /// and may change or be removed in future SDK or CLI releases. Pin both the
1376 /// SDK and CLI versions if your code depends on it.
1377 ///
1378 /// </div>
1379 pub async fn remove(&self, params: McpConfigRemoveRequest) -> Result<(), Error> {
1380 let wire_params = serde_json::to_value(params)?;
1381 let _value = self
1382 .client
1383 .call(rpc_methods::MCP_CONFIG_REMOVE, Some(wire_params))
1384 .await?;
1385 Ok(())
1386 }
1387
1388 /// Enables MCP servers in user configuration for new sessions.
1389 ///
1390 /// Wire method: `mcp.config.enable`.
1391 ///
1392 /// # Parameters
1393 ///
1394 /// * `params` - MCP server names to enable for new sessions.
1395 ///
1396 /// <div class="warning">
1397 ///
1398 /// **Experimental.** This API is part of an experimental wire-protocol surface
1399 /// and may change or be removed in future SDK or CLI releases. Pin both the
1400 /// SDK and CLI versions if your code depends on it.
1401 ///
1402 /// </div>
1403 pub async fn enable(&self, params: McpConfigEnableRequest) -> Result<(), Error> {
1404 let wire_params = serde_json::to_value(params)?;
1405 let _value = self
1406 .client
1407 .call(rpc_methods::MCP_CONFIG_ENABLE, Some(wire_params))
1408 .await?;
1409 Ok(())
1410 }
1411
1412 /// Disables MCP servers in user configuration for new sessions.
1413 ///
1414 /// Wire method: `mcp.config.disable`.
1415 ///
1416 /// # Parameters
1417 ///
1418 /// * `params` - MCP server names to disable for new sessions.
1419 ///
1420 /// <div class="warning">
1421 ///
1422 /// **Experimental.** This API is part of an experimental wire-protocol surface
1423 /// and may change or be removed in future SDK or CLI releases. Pin both the
1424 /// SDK and CLI versions if your code depends on it.
1425 ///
1426 /// </div>
1427 pub async fn disable(&self, params: McpConfigDisableRequest) -> Result<(), Error> {
1428 let wire_params = serde_json::to_value(params)?;
1429 let _value = self
1430 .client
1431 .call(rpc_methods::MCP_CONFIG_DISABLE, Some(wire_params))
1432 .await?;
1433 Ok(())
1434 }
1435
1436 /// Drops this runtime process's in-memory MCP server-definition cache so the next MCP config read observes disk.
1437 ///
1438 /// Wire method: `mcp.config.reload`.
1439 ///
1440 /// <div class="warning">
1441 ///
1442 /// **Experimental.** This API is part of an experimental wire-protocol surface
1443 /// and may change or be removed in future SDK or CLI releases. Pin both the
1444 /// SDK and CLI versions if your code depends on it.
1445 ///
1446 /// </div>
1447 pub async fn reload(&self) -> Result<(), Error> {
1448 let wire_params = serde_json::json!({});
1449 let _value = self
1450 .client
1451 .call(rpc_methods::MCP_CONFIG_RELOAD, Some(wire_params))
1452 .await?;
1453 Ok(())
1454 }
1455}
1456
1457/// `mcp.installations.*` RPCs.
1458#[derive(Clone, Copy)]
1459pub struct ClientRpcMcpInstallations<'a> {
1460 pub(crate) client: &'a Client,
1461}
1462
1463impl<'a> ClientRpcMcpInstallations<'a> {
1464 /// Reads receipt-owned MCP inventory for the selected account and host without activating servers or reconstructing missing ownership. Configuration ownership does not prove session-specific usability.
1465 ///
1466 /// Wire method: `mcp.installations.list`.
1467 ///
1468 /// # Parameters
1469 ///
1470 /// * `params` - New-work inventory or recovery request under an explicitly selected existing session.
1471 ///
1472 /// # Returns
1473 ///
1474 /// Management result with contract receipt, or a typed request/negotiation refusal.
1475 ///
1476 /// <div class="warning">
1477 ///
1478 /// **Experimental.** This API is part of an experimental wire-protocol surface
1479 /// and may change or be removed in future SDK or CLI releases. Pin both the
1480 /// SDK and CLI versions if your code depends on it.
1481 ///
1482 /// </div>
1483 pub async fn list(
1484 &self,
1485 params: McpInstallationsRequest,
1486 ) -> Result<McpInstallationManagementResult, Error> {
1487 let wire_params = serde_json::to_value(params)?;
1488 let _value = self
1489 .client
1490 .call(rpc_methods::MCP_INSTALLATIONS_LIST, Some(wire_params))
1491 .await?;
1492 Ok(serde_json::from_value(_value)?)
1493 }
1494
1495 /// Reconciles already-confirmed durable MCP transactions, then inspects owned inventory. Does not replay apply or reconstruct deleted ownership metadata; unresolved or unsafe evidence remains an explicit refusal.
1496 ///
1497 /// Wire method: `mcp.installations.recover`.
1498 ///
1499 /// # Parameters
1500 ///
1501 /// * `params` - New-work inventory or recovery request under an explicitly selected existing session.
1502 ///
1503 /// # Returns
1504 ///
1505 /// Management result with contract receipt, or a typed request/negotiation refusal.
1506 ///
1507 /// <div class="warning">
1508 ///
1509 /// **Experimental.** This API is part of an experimental wire-protocol surface
1510 /// and may change or be removed in future SDK or CLI releases. Pin both the
1511 /// SDK and CLI versions if your code depends on it.
1512 ///
1513 /// </div>
1514 pub async fn recover(
1515 &self,
1516 params: McpInstallationsRequest,
1517 ) -> Result<McpInstallationManagementResult, Error> {
1518 let wire_params = serde_json::to_value(params)?;
1519 let _value = self
1520 .client
1521 .call(rpc_methods::MCP_INSTALLATIONS_RECOVER, Some(wire_params))
1522 .await?;
1523 Ok(serde_json::from_value(_value)?)
1524 }
1525
1526 /// Inspects a known operation only on its original connection. Remains available after account or selected-session loss; does not acquire new authority or rebind an operation.
1527 ///
1528 /// Wire method: `mcp.installations.status`.
1529 ///
1530 /// # Parameters
1531 ///
1532 /// * `params` - Existing-operation control. A new session selector is deliberately not accepted.
1533 ///
1534 /// # Returns
1535 ///
1536 /// Management result with contract receipt, or a typed request/negotiation refusal.
1537 ///
1538 /// <div class="warning">
1539 ///
1540 /// **Experimental.** This API is part of an experimental wire-protocol surface
1541 /// and may change or be removed in future SDK or CLI releases. Pin both the
1542 /// SDK and CLI versions if your code depends on it.
1543 ///
1544 /// </div>
1545 pub async fn status(
1546 &self,
1547 params: McpInstallationOperationRequest,
1548 ) -> Result<McpInstallationManagementResult, Error> {
1549 let wire_params = serde_json::to_value(params)?;
1550 let _value = self
1551 .client
1552 .call(rpc_methods::MCP_INSTALLATIONS_STATUS, Some(wire_params))
1553 .await?;
1554 Ok(serde_json::from_value(_value)?)
1555 }
1556
1557 /// Requests cancellation of a known operation on its original connection, including before apply or confirmation. Already-started effects retain their transaction lease and report an honest terminal or recovery outcome.
1558 ///
1559 /// Wire method: `mcp.installations.cancel`.
1560 ///
1561 /// # Parameters
1562 ///
1563 /// * `params` - Existing-operation control. A new session selector is deliberately not accepted.
1564 ///
1565 /// # Returns
1566 ///
1567 /// Management result with contract receipt, or a typed request/negotiation refusal.
1568 ///
1569 /// <div class="warning">
1570 ///
1571 /// **Experimental.** This API is part of an experimental wire-protocol surface
1572 /// and may change or be removed in future SDK or CLI releases. Pin both the
1573 /// SDK and CLI versions if your code depends on it.
1574 ///
1575 /// </div>
1576 pub async fn cancel(
1577 &self,
1578 params: McpInstallationOperationRequest,
1579 ) -> Result<McpInstallationManagementResult, Error> {
1580 let wire_params = serde_json::to_value(params)?;
1581 let _value = self
1582 .client
1583 .call(rpc_methods::MCP_INSTALLATIONS_CANCEL, Some(wire_params))
1584 .await?;
1585 Ok(serde_json::from_value(_value)?)
1586 }
1587}
1588
1589/// `models.*` RPCs.
1590#[derive(Clone, Copy)]
1591pub struct ClientRpcModels<'a> {
1592 pub(crate) client: &'a Client,
1593}
1594
1595impl<'a> ClientRpcModels<'a> {
1596 /// Lists Copilot models available to the authenticated user.
1597 ///
1598 /// Wire method: `models.list`.
1599 ///
1600 /// # Returns
1601 ///
1602 /// List of Copilot models available to the resolved user, including capabilities and billing metadata.
1603 ///
1604 /// <div class="warning">
1605 ///
1606 /// **Experimental.** This API is part of an experimental wire-protocol surface
1607 /// and may change or be removed in future SDK or CLI releases. Pin both the
1608 /// SDK and CLI versions if your code depends on it.
1609 ///
1610 /// </div>
1611 pub async fn list(&self) -> Result<ModelList, Error> {
1612 let wire_params = serde_json::json!({});
1613 let _value = self
1614 .client
1615 .call(rpc_methods::MODELS_LIST, Some(wire_params))
1616 .await?;
1617 Ok(serde_json::from_value(_value)?)
1618 }
1619
1620 /// Lists Copilot models available to the authenticated user.
1621 ///
1622 /// Wire method: `models.list`.
1623 ///
1624 /// # Parameters
1625 ///
1626 /// * `params` - Optional opaque account selection or compatibility GitHub token used to list models.
1627 ///
1628 /// # Returns
1629 ///
1630 /// List of Copilot models available to the resolved user, including capabilities and billing metadata.
1631 ///
1632 /// <div class="warning">
1633 ///
1634 /// **Experimental.** This API is part of an experimental wire-protocol surface
1635 /// and may change or be removed in future SDK or CLI releases. Pin both the
1636 /// SDK and CLI versions if your code depends on it.
1637 ///
1638 /// </div>
1639 pub async fn list_with_params(&self, params: ModelsListRequest) -> Result<ModelList, Error> {
1640 let wire_params = serde_json::to_value(params)?;
1641 let _value = self
1642 .client
1643 .call(rpc_methods::MODELS_LIST, Some(wire_params))
1644 .await?;
1645 Ok(serde_json::from_value(_value)?)
1646 }
1647
1648 /// Returns the running runtime's complete catalog of well-known built-in model IDs without authentication or network access.
1649 ///
1650 /// Wire method: `models.getBuiltInCatalog`.
1651 ///
1652 /// # Returns
1653 ///
1654 /// The running runtime's complete catalog of well-known built-in model IDs, including supported models and additional IDs with built-in metadata.
1655 ///
1656 /// <div class="warning">
1657 ///
1658 /// **Experimental.** This API is part of an experimental wire-protocol surface
1659 /// and may change or be removed in future SDK or CLI releases. Pin both the
1660 /// SDK and CLI versions if your code depends on it.
1661 ///
1662 /// </div>
1663 pub async fn get_built_in_catalog(&self) -> Result<BuiltInModelCatalog, Error> {
1664 let wire_params = serde_json::json!({});
1665 let _value = self
1666 .client
1667 .call(rpc_methods::MODELS_GETBUILTINCATALOG, Some(wire_params))
1668 .await?;
1669 Ok(serde_json::from_value(_value)?)
1670 }
1671}
1672
1673/// `plugins.*` RPCs.
1674#[derive(Clone, Copy)]
1675pub struct ClientRpcPlugins<'a> {
1676 pub(crate) client: &'a Client,
1677}
1678
1679impl<'a> ClientRpcPlugins<'a> {
1680 /// `plugins.builtin.*` sub-namespace.
1681 pub fn builtin(&self) -> ClientRpcPluginsBuiltin<'a> {
1682 ClientRpcPluginsBuiltin {
1683 client: self.client,
1684 }
1685 }
1686
1687 /// `plugins.marketplaces.*` sub-namespace.
1688 pub fn marketplaces(&self) -> ClientRpcPluginsMarketplaces<'a> {
1689 ClientRpcPluginsMarketplaces {
1690 client: self.client,
1691 }
1692 }
1693
1694 /// Lists plugins installed in user/global state.
1695 ///
1696 /// Wire method: `plugins.list`.
1697 ///
1698 /// # Returns
1699 ///
1700 /// Plugins installed in user/global state.
1701 ///
1702 /// <div class="warning">
1703 ///
1704 /// **Experimental.** This API is part of an experimental wire-protocol surface
1705 /// and may change or be removed in future SDK or CLI releases. Pin both the
1706 /// SDK and CLI versions if your code depends on it.
1707 ///
1708 /// </div>
1709 pub async fn list(&self) -> Result<PluginListResult, Error> {
1710 let wire_params = serde_json::json!({});
1711 let _value = self
1712 .client
1713 .call(rpc_methods::PLUGINS_LIST, Some(wire_params))
1714 .await?;
1715 Ok(serde_json::from_value(_value)?)
1716 }
1717
1718 /// Installs a plugin from a marketplace, GitHub repo, URL, or local path.
1719 ///
1720 /// Wire method: `plugins.install`.
1721 ///
1722 /// # Parameters
1723 ///
1724 /// * `params` - Plugin source and optional working directory for relative-path resolution.
1725 ///
1726 /// # Returns
1727 ///
1728 /// Result of installing a plugin.
1729 ///
1730 /// <div class="warning">
1731 ///
1732 /// **Experimental.** This API is part of an experimental wire-protocol surface
1733 /// and may change or be removed in future SDK or CLI releases. Pin both the
1734 /// SDK and CLI versions if your code depends on it.
1735 ///
1736 /// </div>
1737 pub async fn install(
1738 &self,
1739 params: PluginsInstallRequest,
1740 ) -> Result<PluginInstallResult, Error> {
1741 let wire_params = serde_json::to_value(params)?;
1742 let _value = self
1743 .client
1744 .call(rpc_methods::PLUGINS_INSTALL, Some(wire_params))
1745 .await?;
1746 Ok(serde_json::from_value(_value)?)
1747 }
1748
1749 /// Uninstalls an installed plugin.
1750 ///
1751 /// Wire method: `plugins.uninstall`.
1752 ///
1753 /// # Parameters
1754 ///
1755 /// * `params` - Name (or spec) of the plugin to uninstall.
1756 ///
1757 /// <div class="warning">
1758 ///
1759 /// **Experimental.** This API is part of an experimental wire-protocol surface
1760 /// and may change or be removed in future SDK or CLI releases. Pin both the
1761 /// SDK and CLI versions if your code depends on it.
1762 ///
1763 /// </div>
1764 pub async fn uninstall(&self, params: PluginsUninstallRequest) -> Result<(), Error> {
1765 let wire_params = serde_json::to_value(params)?;
1766 let _value = self
1767 .client
1768 .call(rpc_methods::PLUGINS_UNINSTALL, Some(wire_params))
1769 .await?;
1770 Ok(())
1771 }
1772
1773 /// Updates an installed plugin to its latest published version.
1774 ///
1775 /// Wire method: `plugins.update`.
1776 ///
1777 /// # Parameters
1778 ///
1779 /// * `params` - Name (or spec) of the plugin to update.
1780 ///
1781 /// # Returns
1782 ///
1783 /// Result of updating a single plugin.
1784 ///
1785 /// <div class="warning">
1786 ///
1787 /// **Experimental.** This API is part of an experimental wire-protocol surface
1788 /// and may change or be removed in future SDK or CLI releases. Pin both the
1789 /// SDK and CLI versions if your code depends on it.
1790 ///
1791 /// </div>
1792 pub async fn update(&self, params: PluginsUpdateRequest) -> Result<PluginUpdateResult, Error> {
1793 let wire_params = serde_json::to_value(params)?;
1794 let _value = self
1795 .client
1796 .call(rpc_methods::PLUGINS_UPDATE, Some(wire_params))
1797 .await?;
1798 Ok(serde_json::from_value(_value)?)
1799 }
1800
1801 /// Updates every installed plugin to its latest published version.
1802 ///
1803 /// Wire method: `plugins.updateAll`.
1804 ///
1805 /// # Returns
1806 ///
1807 /// Result of updating all installed plugins.
1808 ///
1809 /// <div class="warning">
1810 ///
1811 /// **Experimental.** This API is part of an experimental wire-protocol surface
1812 /// and may change or be removed in future SDK or CLI releases. Pin both the
1813 /// SDK and CLI versions if your code depends on it.
1814 ///
1815 /// </div>
1816 pub async fn update_all(&self) -> Result<PluginUpdateAllResult, Error> {
1817 let wire_params = serde_json::json!({});
1818 let _value = self
1819 .client
1820 .call(rpc_methods::PLUGINS_UPDATEALL, Some(wire_params))
1821 .await?;
1822 Ok(serde_json::from_value(_value)?)
1823 }
1824
1825 /// Enables installed plugins for new sessions.
1826 ///
1827 /// Wire method: `plugins.enable`.
1828 ///
1829 /// # Parameters
1830 ///
1831 /// * `params` - Plugin names (or specs) to enable, plus the optional working directory the repository-controlled guard is evaluated against.
1832 ///
1833 /// <div class="warning">
1834 ///
1835 /// **Experimental.** This API is part of an experimental wire-protocol surface
1836 /// and may change or be removed in future SDK or CLI releases. Pin both the
1837 /// SDK and CLI versions if your code depends on it.
1838 ///
1839 /// </div>
1840 pub async fn enable(&self, params: PluginsEnableRequest) -> Result<(), Error> {
1841 let wire_params = serde_json::to_value(params)?;
1842 let _value = self
1843 .client
1844 .call(rpc_methods::PLUGINS_ENABLE, Some(wire_params))
1845 .await?;
1846 Ok(())
1847 }
1848
1849 /// Disables installed plugins for new sessions.
1850 ///
1851 /// Wire method: `plugins.disable`.
1852 ///
1853 /// # Parameters
1854 ///
1855 /// * `params` - Plugin names (or specs) to disable, plus the optional working directory the repository-controlled guard is evaluated against.
1856 ///
1857 /// <div class="warning">
1858 ///
1859 /// **Experimental.** This API is part of an experimental wire-protocol surface
1860 /// and may change or be removed in future SDK or CLI releases. Pin both the
1861 /// SDK and CLI versions if your code depends on it.
1862 ///
1863 /// </div>
1864 pub async fn disable(&self, params: PluginsDisableRequest) -> Result<(), Error> {
1865 let wire_params = serde_json::to_value(params)?;
1866 let _value = self
1867 .client
1868 .call(rpc_methods::PLUGINS_DISABLE, Some(wire_params))
1869 .await?;
1870 Ok(())
1871 }
1872}
1873
1874/// `plugins.builtin.*` RPCs.
1875#[derive(Clone, Copy)]
1876pub struct ClientRpcPluginsBuiltin<'a> {
1877 pub(crate) client: &'a Client,
1878}
1879
1880impl<'a> ClientRpcPluginsBuiltin<'a> {
1881 /// Replaces this server's trusted built-in plugin directories while no sessions are active.
1882 ///
1883 /// Wire method: `plugins.builtin.set`.
1884 ///
1885 /// # Parameters
1886 ///
1887 /// * `params` - Trusted built-in plugin directories to use for this runtime process.
1888 ///
1889 /// <div class="warning">
1890 ///
1891 /// **Experimental.** This API is part of an experimental wire-protocol surface
1892 /// and may change or be removed in future SDK or CLI releases. Pin both the
1893 /// SDK and CLI versions if your code depends on it.
1894 ///
1895 /// </div>
1896 pub async fn set(&self, params: PluginsBuiltinSetRequest) -> Result<(), Error> {
1897 let wire_params = serde_json::to_value(params)?;
1898 let _value = self
1899 .client
1900 .call(rpc_methods::PLUGINS_BUILTIN_SET, Some(wire_params))
1901 .await?;
1902 Ok(())
1903 }
1904}
1905
1906/// `plugins.marketplaces.*` RPCs.
1907#[derive(Clone, Copy)]
1908pub struct ClientRpcPluginsMarketplaces<'a> {
1909 pub(crate) client: &'a Client,
1910}
1911
1912impl<'a> ClientRpcPluginsMarketplaces<'a> {
1913 /// Lists all registered marketplaces (defaults + user-added).
1914 ///
1915 /// Wire method: `plugins.marketplaces.list`.
1916 ///
1917 /// # Returns
1918 ///
1919 /// All registered marketplaces, including built-in defaults.
1920 ///
1921 /// <div class="warning">
1922 ///
1923 /// **Experimental.** This API is part of an experimental wire-protocol surface
1924 /// and may change or be removed in future SDK or CLI releases. Pin both the
1925 /// SDK and CLI versions if your code depends on it.
1926 ///
1927 /// </div>
1928 pub async fn list(&self) -> Result<MarketplaceListResult, Error> {
1929 let wire_params = serde_json::json!({});
1930 let _value = self
1931 .client
1932 .call(rpc_methods::PLUGINS_MARKETPLACES_LIST, Some(wire_params))
1933 .await?;
1934 Ok(serde_json::from_value(_value)?)
1935 }
1936
1937 /// Registers a new marketplace from a source (owner/repo, URL, or local path).
1938 ///
1939 /// Wire method: `plugins.marketplaces.add`.
1940 ///
1941 /// # Parameters
1942 ///
1943 /// * `params` - Marketplace source and optional working directory for relative-path resolution.
1944 ///
1945 /// # Returns
1946 ///
1947 /// Result of registering a new marketplace.
1948 ///
1949 /// <div class="warning">
1950 ///
1951 /// **Experimental.** This API is part of an experimental wire-protocol surface
1952 /// and may change or be removed in future SDK or CLI releases. Pin both the
1953 /// SDK and CLI versions if your code depends on it.
1954 ///
1955 /// </div>
1956 pub async fn add(
1957 &self,
1958 params: PluginsMarketplacesAddRequest,
1959 ) -> Result<MarketplaceAddResult, Error> {
1960 let wire_params = serde_json::to_value(params)?;
1961 let _value = self
1962 .client
1963 .call(rpc_methods::PLUGINS_MARKETPLACES_ADD, Some(wire_params))
1964 .await?;
1965 Ok(serde_json::from_value(_value)?)
1966 }
1967
1968 /// 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`.
1969 ///
1970 /// Wire method: `plugins.marketplaces.remove`.
1971 ///
1972 /// # Parameters
1973 ///
1974 /// * `params` - Name of the marketplace to remove and an optional force flag.
1975 ///
1976 /// # Returns
1977 ///
1978 /// Outcome of the remove attempt, including dependent-plugin info when applicable.
1979 ///
1980 /// <div class="warning">
1981 ///
1982 /// **Experimental.** This API is part of an experimental wire-protocol surface
1983 /// and may change or be removed in future SDK or CLI releases. Pin both the
1984 /// SDK and CLI versions if your code depends on it.
1985 ///
1986 /// </div>
1987 pub async fn remove(
1988 &self,
1989 params: PluginsMarketplacesRemoveRequest,
1990 ) -> Result<MarketplaceRemoveResult, Error> {
1991 let wire_params = serde_json::to_value(params)?;
1992 let _value = self
1993 .client
1994 .call(rpc_methods::PLUGINS_MARKETPLACES_REMOVE, Some(wire_params))
1995 .await?;
1996 Ok(serde_json::from_value(_value)?)
1997 }
1998
1999 /// Lists plugins advertised by a registered marketplace.
2000 ///
2001 /// Wire method: `plugins.marketplaces.browse`.
2002 ///
2003 /// # Parameters
2004 ///
2005 /// * `params` - Name of the marketplace whose plugin catalog to fetch.
2006 ///
2007 /// # Returns
2008 ///
2009 /// Plugins advertised by the marketplace.
2010 ///
2011 /// <div class="warning">
2012 ///
2013 /// **Experimental.** This API is part of an experimental wire-protocol surface
2014 /// and may change or be removed in future SDK or CLI releases. Pin both the
2015 /// SDK and CLI versions if your code depends on it.
2016 ///
2017 /// </div>
2018 pub async fn browse(
2019 &self,
2020 params: PluginsMarketplacesBrowseRequest,
2021 ) -> Result<MarketplaceBrowseResult, Error> {
2022 let wire_params = serde_json::to_value(params)?;
2023 let _value = self
2024 .client
2025 .call(rpc_methods::PLUGINS_MARKETPLACES_BROWSE, Some(wire_params))
2026 .await?;
2027 Ok(serde_json::from_value(_value)?)
2028 }
2029
2030 /// Re-fetches one or all registered marketplace catalogs.
2031 ///
2032 /// Wire method: `plugins.marketplaces.refresh`.
2033 ///
2034 /// # Returns
2035 ///
2036 /// Result of refreshing one or more marketplace catalogs.
2037 ///
2038 /// <div class="warning">
2039 ///
2040 /// **Experimental.** This API is part of an experimental wire-protocol surface
2041 /// and may change or be removed in future SDK or CLI releases. Pin both the
2042 /// SDK and CLI versions if your code depends on it.
2043 ///
2044 /// </div>
2045 pub async fn refresh(&self) -> Result<MarketplaceRefreshResult, Error> {
2046 let wire_params = serde_json::json!({});
2047 let _value = self
2048 .client
2049 .call(rpc_methods::PLUGINS_MARKETPLACES_REFRESH, Some(wire_params))
2050 .await?;
2051 Ok(serde_json::from_value(_value)?)
2052 }
2053
2054 /// Re-fetches one or all registered marketplace catalogs.
2055 ///
2056 /// Wire method: `plugins.marketplaces.refresh`.
2057 ///
2058 /// # Parameters
2059 ///
2060 /// * `params` - Optional marketplace name; omit to refresh all.
2061 ///
2062 /// # Returns
2063 ///
2064 /// Result of refreshing one or more marketplace catalogs.
2065 ///
2066 /// <div class="warning">
2067 ///
2068 /// **Experimental.** This API is part of an experimental wire-protocol surface
2069 /// and may change or be removed in future SDK or CLI releases. Pin both the
2070 /// SDK and CLI versions if your code depends on it.
2071 ///
2072 /// </div>
2073 pub async fn refresh_with_params(
2074 &self,
2075 params: PluginsMarketplacesRefreshRequest,
2076 ) -> Result<MarketplaceRefreshResult, Error> {
2077 let wire_params = serde_json::to_value(params)?;
2078 let _value = self
2079 .client
2080 .call(rpc_methods::PLUGINS_MARKETPLACES_REFRESH, Some(wire_params))
2081 .await?;
2082 Ok(serde_json::from_value(_value)?)
2083 }
2084}
2085
2086/// `runtime.*` RPCs.
2087#[derive(Clone, Copy)]
2088pub struct ClientRpcRuntime<'a> {
2089 pub(crate) client: &'a Client,
2090}
2091
2092impl<'a> ClientRpcRuntime<'a> {
2093 /// Gracefully shuts down an SDK-owned runtime. The response is sent only after cleanup completes; callers may then terminate the owned runtime process.
2094 ///
2095 /// Wire method: `runtime.shutdown`.
2096 ///
2097 /// <div class="warning">
2098 ///
2099 /// **Experimental.** This API is part of an experimental wire-protocol surface
2100 /// and may change or be removed in future SDK or CLI releases. Pin both the
2101 /// SDK and CLI versions if your code depends on it.
2102 ///
2103 /// </div>
2104 pub async fn shutdown(&self) -> Result<(), Error> {
2105 let wire_params = serde_json::json!({});
2106 let _value = self
2107 .client
2108 .call(rpc_methods::RUNTIME_SHUTDOWN, Some(wire_params))
2109 .await?;
2110 Ok(())
2111 }
2112}
2113
2114/// `sandbox.*` RPCs.
2115#[derive(Clone, Copy)]
2116pub struct ClientRpcSandbox<'a> {
2117 pub(crate) client: &'a Client,
2118}
2119
2120impl<'a> ClientRpcSandbox<'a> {
2121 /// Reports whether the host running this runtime can run the command sandbox, without starting a session or spawning a sandboxed command.
2122 ///
2123 /// Wire method: `sandbox.getHostSupport`.
2124 ///
2125 /// # Returns
2126 ///
2127 /// 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.
2128 ///
2129 /// <div class="warning">
2130 ///
2131 /// **Experimental.** This API is part of an experimental wire-protocol surface
2132 /// and may change or be removed in future SDK or CLI releases. Pin both the
2133 /// SDK and CLI versions if your code depends on it.
2134 ///
2135 /// </div>
2136 pub async fn get_host_support(&self) -> Result<SandboxHostSupport, Error> {
2137 let wire_params = serde_json::json!({});
2138 let _value = self
2139 .client
2140 .call(rpc_methods::SANDBOX_GETHOSTSUPPORT, Some(wire_params))
2141 .await?;
2142 Ok(serde_json::from_value(_value)?)
2143 }
2144}
2145
2146/// `secrets.*` RPCs.
2147#[derive(Clone, Copy)]
2148pub struct ClientRpcSecrets<'a> {
2149 pub(crate) client: &'a Client,
2150}
2151
2152impl<'a> ClientRpcSecrets<'a> {
2153 /// Registers secret values for redaction in session logs and exports. The SDK calls this to inject dynamically generated secret values (e.g., OIDC tokens).
2154 ///
2155 /// Wire method: `secrets.addFilterValues`.
2156 ///
2157 /// # Parameters
2158 ///
2159 /// * `params` - Secret values to add to the redaction filter.
2160 ///
2161 /// # Returns
2162 ///
2163 /// Confirmation that the secret values were registered.
2164 ///
2165 /// <div class="warning">
2166 ///
2167 /// **Experimental.** This API is part of an experimental wire-protocol surface
2168 /// and may change or be removed in future SDK or CLI releases. Pin both the
2169 /// SDK and CLI versions if your code depends on it.
2170 ///
2171 /// </div>
2172 pub async fn add_filter_values(
2173 &self,
2174 params: SecretsAddFilterValuesRequest,
2175 ) -> Result<SecretsAddFilterValuesResult, Error> {
2176 let wire_params = serde_json::to_value(params)?;
2177 let _value = self
2178 .client
2179 .call(rpc_methods::SECRETS_ADDFILTERVALUES, Some(wire_params))
2180 .await?;
2181 Ok(serde_json::from_value(_value)?)
2182 }
2183}
2184
2185/// `sessionFs.*` RPCs.
2186#[derive(Clone, Copy)]
2187pub struct ClientRpcSessionFs<'a> {
2188 pub(crate) client: &'a Client,
2189}
2190
2191impl<'a> ClientRpcSessionFs<'a> {
2192 /// Registers an SDK client as the session filesystem provider.
2193 ///
2194 /// Wire method: `sessionFs.setProvider`.
2195 ///
2196 /// # Parameters
2197 ///
2198 /// * `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.
2199 ///
2200 /// # Returns
2201 ///
2202 /// Indicates whether the calling client was registered as the session filesystem provider.
2203 ///
2204 /// <div class="warning">
2205 ///
2206 /// **Experimental.** This API is part of an experimental wire-protocol surface
2207 /// and may change or be removed in future SDK or CLI releases. Pin both the
2208 /// SDK and CLI versions if your code depends on it.
2209 ///
2210 /// </div>
2211 pub async fn set_provider(
2212 &self,
2213 params: SessionFsSetProviderRequest,
2214 ) -> Result<SessionFsSetProviderResult, Error> {
2215 let wire_params = serde_json::to_value(params)?;
2216 let _value = self
2217 .client
2218 .call(rpc_methods::SESSIONFS_SETPROVIDER, Some(wire_params))
2219 .await?;
2220 Ok(serde_json::from_value(_value)?)
2221 }
2222}
2223
2224/// `sessions.*` RPCs.
2225#[derive(Clone, Copy)]
2226pub struct ClientRpcSessions<'a> {
2227 pub(crate) client: &'a Client,
2228}
2229
2230impl<'a> ClientRpcSessions<'a> {
2231 /// Creates or resumes a local session and returns the opened session ID.
2232 ///
2233 /// Wire method: `sessions.open`.
2234 ///
2235 /// # Returns
2236 ///
2237 /// Result of opening a session.
2238 ///
2239 /// <div class="warning">
2240 ///
2241 /// **Experimental.** This API is part of an experimental wire-protocol surface
2242 /// and may change or be removed in future SDK or CLI releases. Pin both the
2243 /// SDK and CLI versions if your code depends on it.
2244 ///
2245 /// </div>
2246 pub async fn open(&self) -> Result<SessionOpenResult, Error> {
2247 let wire_params = serde_json::json!({});
2248 let _value = self
2249 .client
2250 .call(rpc_methods::SESSIONS_OPEN, Some(wire_params))
2251 .await?;
2252 Ok(serde_json::from_value(_value)?)
2253 }
2254
2255 /// Creates a new session by forking persisted history from an existing session.
2256 ///
2257 /// Wire method: `sessions.fork`.
2258 ///
2259 /// # Parameters
2260 ///
2261 /// * `params` - Source session identifier to fork from, optional event-ID boundary, and optional friendly name for the new session.
2262 ///
2263 /// # Returns
2264 ///
2265 /// Identifier and optional friendly name assigned to the newly forked session.
2266 ///
2267 /// <div class="warning">
2268 ///
2269 /// **Experimental.** This API is part of an experimental wire-protocol surface
2270 /// and may change or be removed in future SDK or CLI releases. Pin both the
2271 /// SDK and CLI versions if your code depends on it.
2272 ///
2273 /// </div>
2274 pub async fn fork(&self, params: SessionsForkRequest) -> Result<SessionsForkResult, Error> {
2275 let wire_params = serde_json::to_value(params)?;
2276 let _value = self
2277 .client
2278 .call(rpc_methods::SESSIONS_FORK, Some(wire_params))
2279 .await?;
2280 Ok(serde_json::from_value(_value)?)
2281 }
2282
2283 /// Connects to an existing remote session and exposes it as an SDK session.
2284 ///
2285 /// Wire method: `sessions.connect`.
2286 ///
2287 /// # Parameters
2288 ///
2289 /// * `params` - Remote session connection parameters.
2290 ///
2291 /// # Returns
2292 ///
2293 /// Remote session connection result.
2294 ///
2295 /// <div class="warning">
2296 ///
2297 /// **Experimental.** This API is part of an experimental wire-protocol surface
2298 /// and may change or be removed in future SDK or CLI releases. Pin both the
2299 /// SDK and CLI versions if your code depends on it.
2300 ///
2301 /// </div>
2302 pub async fn connect(
2303 &self,
2304 params: ConnectRemoteSessionParams,
2305 ) -> Result<RemoteSessionConnectionResult, Error> {
2306 let wire_params = serde_json::to_value(params)?;
2307 let _value = self
2308 .client
2309 .call(rpc_methods::SESSIONS_CONNECT, Some(wire_params))
2310 .await?;
2311 Ok(serde_json::from_value(_value)?)
2312 }
2313
2314 /// 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.).
2315 ///
2316 /// Wire method: `sessions.list`.
2317 ///
2318 /// # Returns
2319 ///
2320 /// Sessions matching the filter, ordered most-recently-modified first.
2321 ///
2322 /// <div class="warning">
2323 ///
2324 /// **Experimental.** This API is part of an experimental wire-protocol surface
2325 /// and may change or be removed in future SDK or CLI releases. Pin both the
2326 /// SDK and CLI versions if your code depends on it.
2327 ///
2328 /// </div>
2329 pub async fn list(&self) -> Result<SessionList, Error> {
2330 let wire_params = serde_json::json!({});
2331 let _value = self
2332 .client
2333 .call(rpc_methods::SESSIONS_LIST, Some(wire_params))
2334 .await?;
2335 Ok(serde_json::from_value(_value)?)
2336 }
2337
2338 /// 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.).
2339 ///
2340 /// Wire method: `sessions.list`.
2341 ///
2342 /// # Parameters
2343 ///
2344 /// * `params` - Optional source filter, metadata-load limit, and context filter applied to the returned sessions.
2345 ///
2346 /// # Returns
2347 ///
2348 /// Sessions matching the filter, ordered most-recently-modified first.
2349 ///
2350 /// <div class="warning">
2351 ///
2352 /// **Experimental.** This API is part of an experimental wire-protocol surface
2353 /// and may change or be removed in future SDK or CLI releases. Pin both the
2354 /// SDK and CLI versions if your code depends on it.
2355 ///
2356 /// </div>
2357 pub async fn list_with_params(
2358 &self,
2359 params: SessionsListRequest,
2360 ) -> Result<SessionList, Error> {
2361 let wire_params = serde_json::to_value(params)?;
2362 let _value = self
2363 .client
2364 .call(rpc_methods::SESSIONS_LIST, Some(wire_params))
2365 .await?;
2366 Ok(serde_json::from_value(_value)?)
2367 }
2368
2369 /// Reads lightweight persisted metadata for one local session without opening it.
2370 ///
2371 /// Wire method: `sessions.getMetadata`.
2372 ///
2373 /// # Parameters
2374 ///
2375 /// * `params` - Session ID whose persisted metadata should be read.
2376 ///
2377 /// # Returns
2378 ///
2379 /// Persisted local session metadata when the session exists.
2380 ///
2381 /// <div class="warning">
2382 ///
2383 /// **Experimental.** This API is part of an experimental wire-protocol surface
2384 /// and may change or be removed in future SDK or CLI releases. Pin both the
2385 /// SDK and CLI versions if your code depends on it.
2386 ///
2387 /// </div>
2388 pub(crate) async fn get_metadata(
2389 &self,
2390 params: SessionsGetMetadataRequest,
2391 ) -> Result<SessionsGetMetadataResult, Error> {
2392 let wire_params = serde_json::to_value(params)?;
2393 let _value = self
2394 .client
2395 .call(rpc_methods::SESSIONS_GETMETADATA, Some(wire_params))
2396 .await?;
2397 Ok(serde_json::from_value(_value)?)
2398 }
2399
2400 /// 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.
2401 ///
2402 /// Wire method: `sessions.getClientMetadata`.
2403 ///
2404 /// # Parameters
2405 ///
2406 /// * `params` - Bounded batch request for client-owned metadata from persisted local sessions.
2407 ///
2408 /// # Returns
2409 ///
2410 /// Ordered client metadata outcomes for the requested local sessions.
2411 ///
2412 /// <div class="warning">
2413 ///
2414 /// **Experimental.** This API is part of an experimental wire-protocol surface
2415 /// and may change or be removed in future SDK or CLI releases. Pin both the
2416 /// SDK and CLI versions if your code depends on it.
2417 ///
2418 /// </div>
2419 pub async fn get_client_metadata(
2420 &self,
2421 params: SessionsGetClientMetadataRequest,
2422 ) -> Result<SessionsGetClientMetadataResult, Error> {
2423 let wire_params = serde_json::to_value(params)?;
2424 let _value = self
2425 .client
2426 .call(rpc_methods::SESSIONS_GETCLIENTMETADATA, Some(wire_params))
2427 .await?;
2428 Ok(serde_json::from_value(_value)?)
2429 }
2430
2431 /// 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.
2432 ///
2433 /// Wire method: `sessions.readPersistedEvents`.
2434 ///
2435 /// # Parameters
2436 ///
2437 /// * `params` - Pagination options for reading an inactive or active local session's persisted event journal.
2438 ///
2439 /// # Returns
2440 ///
2441 /// Batch of session events returned by a read, with cursor and continuation metadata.
2442 ///
2443 /// <div class="warning">
2444 ///
2445 /// **Experimental.** This API is part of an experimental wire-protocol surface
2446 /// and may change or be removed in future SDK or CLI releases. Pin both the
2447 /// SDK and CLI versions if your code depends on it.
2448 ///
2449 /// </div>
2450 pub async fn read_persisted_events(
2451 &self,
2452 params: SessionsReadPersistedEventsRequest,
2453 ) -> Result<EventsReadResult, Error> {
2454 let wire_params = serde_json::to_value(params)?;
2455 let _value = self
2456 .client
2457 .call(rpc_methods::SESSIONS_READPERSISTEDEVENTS, Some(wire_params))
2458 .await?;
2459 Ok(serde_json::from_value(_value)?)
2460 }
2461
2462 /// Lists recent local session IDs that contain user-visible history, omitting housekeeping-only sessions.
2463 ///
2464 /// Wire method: `sessions.listNonEmptySessionIds`.
2465 ///
2466 /// # Parameters
2467 ///
2468 /// * `params` - Limit for non-empty local session IDs.
2469 ///
2470 /// # Returns
2471 ///
2472 /// Recent local session IDs that contain user-visible history.
2473 ///
2474 /// <div class="warning">
2475 ///
2476 /// **Experimental.** This API is part of an experimental wire-protocol surface
2477 /// and may change or be removed in future SDK or CLI releases. Pin both the
2478 /// SDK and CLI versions if your code depends on it.
2479 ///
2480 /// </div>
2481 pub(crate) async fn list_non_empty_session_ids(
2482 &self,
2483 params: SessionsListNonEmptySessionIdsRequest,
2484 ) -> Result<SessionsListNonEmptySessionIdsResult, Error> {
2485 let wire_params = serde_json::to_value(params)?;
2486 let _value = self
2487 .client
2488 .call(
2489 rpc_methods::SESSIONS_LISTNONEMPTYSESSIONIDS,
2490 Some(wire_params),
2491 )
2492 .await?;
2493 Ok(serde_json::from_value(_value)?)
2494 }
2495
2496 /// Finds the local session bound to a GitHub task ID, if any.
2497 ///
2498 /// Wire method: `sessions.findByTaskId`.
2499 ///
2500 /// # Parameters
2501 ///
2502 /// * `params` - GitHub task ID to look up.
2503 ///
2504 /// # Returns
2505 ///
2506 /// ID of the local session bound to the given GitHub task, or omitted when none.
2507 ///
2508 /// <div class="warning">
2509 ///
2510 /// **Experimental.** This API is part of an experimental wire-protocol surface
2511 /// and may change or be removed in future SDK or CLI releases. Pin both the
2512 /// SDK and CLI versions if your code depends on it.
2513 ///
2514 /// </div>
2515 pub async fn find_by_task_id(
2516 &self,
2517 params: SessionsFindByTaskIDRequest,
2518 ) -> Result<SessionsFindByTaskIDResult, Error> {
2519 let wire_params = serde_json::to_value(params)?;
2520 let _value = self
2521 .client
2522 .call(rpc_methods::SESSIONS_FINDBYTASKID, Some(wire_params))
2523 .await?;
2524 Ok(serde_json::from_value(_value)?)
2525 }
2526
2527 /// Resolves a UUID prefix to a unique session ID, if exactly one session matches.
2528 ///
2529 /// Wire method: `sessions.findByPrefix`.
2530 ///
2531 /// # Parameters
2532 ///
2533 /// * `params` - UUID prefix to resolve to a unique session ID.
2534 ///
2535 /// # Returns
2536 ///
2537 /// Session ID matching the prefix, omitted when no unique match exists.
2538 ///
2539 /// <div class="warning">
2540 ///
2541 /// **Experimental.** This API is part of an experimental wire-protocol surface
2542 /// and may change or be removed in future SDK or CLI releases. Pin both the
2543 /// SDK and CLI versions if your code depends on it.
2544 ///
2545 /// </div>
2546 pub async fn find_by_prefix(
2547 &self,
2548 params: SessionsFindByPrefixRequest,
2549 ) -> Result<SessionsFindByPrefixResult, Error> {
2550 let wire_params = serde_json::to_value(params)?;
2551 let _value = self
2552 .client
2553 .call(rpc_methods::SESSIONS_FINDBYPREFIX, Some(wire_params))
2554 .await?;
2555 Ok(serde_json::from_value(_value)?)
2556 }
2557
2558 /// Returns the most-relevant prior session for a given working-directory context.
2559 ///
2560 /// Wire method: `sessions.getLastForContext`.
2561 ///
2562 /// # Parameters
2563 ///
2564 /// * `params` - Optional working-directory context used to score session relevance.
2565 ///
2566 /// # Returns
2567 ///
2568 /// Most-relevant session ID for the supplied context, or omitted when no sessions exist.
2569 ///
2570 /// <div class="warning">
2571 ///
2572 /// **Experimental.** This API is part of an experimental wire-protocol surface
2573 /// and may change or be removed in future SDK or CLI releases. Pin both the
2574 /// SDK and CLI versions if your code depends on it.
2575 ///
2576 /// </div>
2577 pub async fn get_last_for_context(
2578 &self,
2579 params: SessionsGetLastForContextRequest,
2580 ) -> Result<SessionsGetLastForContextResult, Error> {
2581 let wire_params = serde_json::to_value(params)?;
2582 let _value = self
2583 .client
2584 .call(rpc_methods::SESSIONS_GETLASTFORCONTEXT, Some(wire_params))
2585 .await?;
2586 Ok(serde_json::from_value(_value)?)
2587 }
2588
2589 /// 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.
2590 ///
2591 /// Wire method: `sessions.getEventFilePath`.
2592 ///
2593 /// # Parameters
2594 ///
2595 /// * `params` - Session ID whose event-log file path to compute.
2596 ///
2597 /// # Returns
2598 ///
2599 /// Absolute path to the session's events.jsonl file on disk.
2600 ///
2601 /// <div class="warning">
2602 ///
2603 /// **Experimental.** This API is part of an experimental wire-protocol surface
2604 /// and may change or be removed in future SDK or CLI releases. Pin both the
2605 /// SDK and CLI versions if your code depends on it.
2606 ///
2607 /// </div>
2608 pub(crate) async fn get_event_file_path(
2609 &self,
2610 params: SessionsGetEventFilePathRequest,
2611 ) -> Result<SessionsGetEventFilePathResult, Error> {
2612 let wire_params = serde_json::to_value(params)?;
2613 let _value = self
2614 .client
2615 .call(rpc_methods::SESSIONS_GETEVENTFILEPATH, Some(wire_params))
2616 .await?;
2617 Ok(serde_json::from_value(_value)?)
2618 }
2619
2620 /// Returns the on-disk byte size of each session's workspace directory.
2621 ///
2622 /// Wire method: `sessions.getSizes`.
2623 ///
2624 /// # Returns
2625 ///
2626 /// Map of sessionId -> on-disk size in bytes for each session's workspace directory.
2627 ///
2628 /// <div class="warning">
2629 ///
2630 /// **Experimental.** This API is part of an experimental wire-protocol surface
2631 /// and may change or be removed in future SDK or CLI releases. Pin both the
2632 /// SDK and CLI versions if your code depends on it.
2633 ///
2634 /// </div>
2635 pub async fn get_sizes(&self) -> Result<SessionSizes, Error> {
2636 let wire_params = serde_json::json!({});
2637 let _value = self
2638 .client
2639 .call(rpc_methods::SESSIONS_GETSIZES, Some(wire_params))
2640 .await?;
2641 Ok(serde_json::from_value(_value)?)
2642 }
2643
2644 /// Returns the subset of the supplied session IDs that are currently held by another running process.
2645 ///
2646 /// Wire method: `sessions.checkInUse`.
2647 ///
2648 /// # Parameters
2649 ///
2650 /// * `params` - Session IDs to test for live in-use locks.
2651 ///
2652 /// # Returns
2653 ///
2654 /// Session IDs from the input set that are currently in use by another process.
2655 ///
2656 /// <div class="warning">
2657 ///
2658 /// **Experimental.** This API is part of an experimental wire-protocol surface
2659 /// and may change or be removed in future SDK or CLI releases. Pin both the
2660 /// SDK and CLI versions if your code depends on it.
2661 ///
2662 /// </div>
2663 pub async fn check_in_use(
2664 &self,
2665 params: SessionsCheckInUseRequest,
2666 ) -> Result<SessionsCheckInUseResult, Error> {
2667 let wire_params = serde_json::to_value(params)?;
2668 let _value = self
2669 .client
2670 .call(rpc_methods::SESSIONS_CHECKINUSE, Some(wire_params))
2671 .await?;
2672 Ok(serde_json::from_value(_value)?)
2673 }
2674
2675 /// 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.
2676 ///
2677 /// Wire method: `sessions.getPersistedRemoteSteerable`.
2678 ///
2679 /// # Parameters
2680 ///
2681 /// * `params` - Session ID to look up the persisted remote-steerable flag for.
2682 ///
2683 /// # Returns
2684 ///
2685 /// The session's persisted remote-steerable flag, or omitted when no value has been persisted.
2686 ///
2687 /// <div class="warning">
2688 ///
2689 /// **Experimental.** This API is part of an experimental wire-protocol surface
2690 /// and may change or be removed in future SDK or CLI releases. Pin both the
2691 /// SDK and CLI versions if your code depends on it.
2692 ///
2693 /// </div>
2694 pub(crate) async fn get_persisted_remote_steerable(
2695 &self,
2696 params: SessionsGetPersistedRemoteSteerableRequest,
2697 ) -> Result<SessionsGetPersistedRemoteSteerableResult, Error> {
2698 let wire_params = serde_json::to_value(params)?;
2699 let _value = self
2700 .client
2701 .call(
2702 rpc_methods::SESSIONS_GETPERSISTEDREMOTESTEERABLE,
2703 Some(wire_params),
2704 )
2705 .await?;
2706 Ok(serde_json::from_value(_value)?)
2707 }
2708
2709 /// Closes a session: emits shutdown, flushes pending events, releases the in-use lock, and disposes the active session.
2710 ///
2711 /// Wire method: `sessions.close`.
2712 ///
2713 /// # Parameters
2714 ///
2715 /// * `params` - Session ID to close.
2716 ///
2717 /// # Returns
2718 ///
2719 /// 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.
2720 ///
2721 /// <div class="warning">
2722 ///
2723 /// **Experimental.** This API is part of an experimental wire-protocol surface
2724 /// and may change or be removed in future SDK or CLI releases. Pin both the
2725 /// SDK and CLI versions if your code depends on it.
2726 ///
2727 /// </div>
2728 pub async fn close(&self, params: SessionsCloseRequest) -> Result<SessionsCloseResult, Error> {
2729 let wire_params = serde_json::to_value(params)?;
2730 let _value = self
2731 .client
2732 .call(rpc_methods::SESSIONS_CLOSE, Some(wire_params))
2733 .await?;
2734 Ok(serde_json::from_value(_value)?)
2735 }
2736
2737 /// Closes, deactivates, and deletes a set of sessions, returning the bytes freed per session.
2738 ///
2739 /// Wire method: `sessions.bulkDelete`.
2740 ///
2741 /// # Parameters
2742 ///
2743 /// * `params` - Session IDs to close, deactivate, and delete from disk.
2744 ///
2745 /// # Returns
2746 ///
2747 /// Map of sessionId -> bytes freed by removing the session's workspace directory.
2748 ///
2749 /// <div class="warning">
2750 ///
2751 /// **Experimental.** This API is part of an experimental wire-protocol surface
2752 /// and may change or be removed in future SDK or CLI releases. Pin both the
2753 /// SDK and CLI versions if your code depends on it.
2754 ///
2755 /// </div>
2756 pub async fn bulk_delete(
2757 &self,
2758 params: SessionsBulkDeleteRequest,
2759 ) -> Result<SessionBulkDeleteResult, Error> {
2760 let wire_params = serde_json::to_value(params)?;
2761 let _value = self
2762 .client
2763 .call(rpc_methods::SESSIONS_BULKDELETE, Some(wire_params))
2764 .await?;
2765 Ok(serde_json::from_value(_value)?)
2766 }
2767
2768 /// Deletes one local session from disk after running the same lifecycle hooks as the session manager.
2769 ///
2770 /// Wire method: `sessions.delete`.
2771 ///
2772 /// # Parameters
2773 ///
2774 /// * `params` - Session ID to delete from disk.
2775 ///
2776 /// <div class="warning">
2777 ///
2778 /// **Experimental.** This API is part of an experimental wire-protocol surface
2779 /// and may change or be removed in future SDK or CLI releases. Pin both the
2780 /// SDK and CLI versions if your code depends on it.
2781 ///
2782 /// </div>
2783 pub(crate) async fn delete(&self, params: SessionsDeleteRequest) -> Result<(), Error> {
2784 let wire_params = serde_json::to_value(params)?;
2785 let _value = self
2786 .client
2787 .call(rpc_methods::SESSIONS_DELETE, Some(wire_params))
2788 .await?;
2789 Ok(())
2790 }
2791
2792 /// Deletes sessions older than the given threshold, with optional dry-run and exclusion list.
2793 ///
2794 /// Wire method: `sessions.pruneOld`.
2795 ///
2796 /// # Parameters
2797 ///
2798 /// * `params` - Age threshold and optional flags controlling which old sessions are pruned (or simulated when dryRun is true).
2799 ///
2800 /// # Returns
2801 ///
2802 /// Outcome of the prune operation: deleted IDs, dry-run candidates, skipped IDs, total bytes freed, and the dry-run flag.
2803 ///
2804 /// <div class="warning">
2805 ///
2806 /// **Experimental.** This API is part of an experimental wire-protocol surface
2807 /// and may change or be removed in future SDK or CLI releases. Pin both the
2808 /// SDK and CLI versions if your code depends on it.
2809 ///
2810 /// </div>
2811 pub async fn prune_old(
2812 &self,
2813 params: SessionsPruneOldRequest,
2814 ) -> Result<SessionPruneResult, Error> {
2815 let wire_params = serde_json::to_value(params)?;
2816 let _value = self
2817 .client
2818 .call(rpc_methods::SESSIONS_PRUNEOLD, Some(wire_params))
2819 .await?;
2820 Ok(serde_json::from_value(_value)?)
2821 }
2822
2823 /// Flushes a session's pending events to disk.
2824 ///
2825 /// Wire method: `sessions.save`.
2826 ///
2827 /// # Parameters
2828 ///
2829 /// * `params` - Session ID whose pending events should be flushed to disk.
2830 ///
2831 /// # Returns
2832 ///
2833 /// Flush a session's pending events to disk. No-op when no writer exists for the session (e.g., already closed).
2834 ///
2835 /// <div class="warning">
2836 ///
2837 /// **Experimental.** This API is part of an experimental wire-protocol surface
2838 /// and may change or be removed in future SDK or CLI releases. Pin both the
2839 /// SDK and CLI versions if your code depends on it.
2840 ///
2841 /// </div>
2842 pub async fn save(&self, params: SessionsSaveRequest) -> Result<SessionsSaveResult, Error> {
2843 let wire_params = serde_json::to_value(params)?;
2844 let _value = self
2845 .client
2846 .call(rpc_methods::SESSIONS_SAVE, Some(wire_params))
2847 .await?;
2848 Ok(serde_json::from_value(_value)?)
2849 }
2850
2851 /// Releases the in-use lock held by this process for a session.
2852 ///
2853 /// Wire method: `sessions.releaseLock`.
2854 ///
2855 /// # Parameters
2856 ///
2857 /// * `params` - Session ID whose in-use lock should be released.
2858 ///
2859 /// # Returns
2860 ///
2861 /// 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.
2862 ///
2863 /// <div class="warning">
2864 ///
2865 /// **Experimental.** This API is part of an experimental wire-protocol surface
2866 /// and may change or be removed in future SDK or CLI releases. Pin both the
2867 /// SDK and CLI versions if your code depends on it.
2868 ///
2869 /// </div>
2870 pub async fn release_lock(
2871 &self,
2872 params: SessionsReleaseLockRequest,
2873 ) -> Result<SessionsReleaseLockResult, Error> {
2874 let wire_params = serde_json::to_value(params)?;
2875 let _value = self
2876 .client
2877 .call(rpc_methods::SESSIONS_RELEASELOCK, Some(wire_params))
2878 .await?;
2879 Ok(serde_json::from_value(_value)?)
2880 }
2881
2882 /// Backfills missing summary and context fields on the supplied session metadata records.
2883 ///
2884 /// Wire method: `sessions.enrichMetadata`.
2885 ///
2886 /// # Parameters
2887 ///
2888 /// * `params` - Session metadata records to enrich with summary and context information.
2889 ///
2890 /// # Returns
2891 ///
2892 /// The enriched metadata records, with summary and context fields backfilled where available. Sessions confirmed empty and unnamed are omitted.
2893 ///
2894 /// <div class="warning">
2895 ///
2896 /// **Experimental.** This API is part of an experimental wire-protocol surface
2897 /// and may change or be removed in future SDK or CLI releases. Pin both the
2898 /// SDK and CLI versions if your code depends on it.
2899 ///
2900 /// </div>
2901 pub async fn enrich_metadata(
2902 &self,
2903 params: SessionsEnrichMetadataRequest,
2904 ) -> Result<SessionEnrichMetadataResult, Error> {
2905 let wire_params = serde_json::to_value(params)?;
2906 let _value = self
2907 .client
2908 .call(rpc_methods::SESSIONS_ENRICHMETADATA, Some(wire_params))
2909 .await?;
2910 Ok(serde_json::from_value(_value)?)
2911 }
2912
2913 /// Reloads user, plugin, and (optionally) repo hooks on the active session.
2914 ///
2915 /// Wire method: `sessions.reloadPluginHooks`.
2916 ///
2917 /// # Parameters
2918 ///
2919 /// * `params` - Active session ID and an optional flag for deferring repo-level hooks until folder trust.
2920 ///
2921 /// # Returns
2922 ///
2923 /// 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.
2924 ///
2925 /// <div class="warning">
2926 ///
2927 /// **Experimental.** This API is part of an experimental wire-protocol surface
2928 /// and may change or be removed in future SDK or CLI releases. Pin both the
2929 /// SDK and CLI versions if your code depends on it.
2930 ///
2931 /// </div>
2932 pub async fn reload_plugin_hooks(
2933 &self,
2934 params: SessionsReloadPluginHooksRequest,
2935 ) -> Result<SessionsReloadPluginHooksResult, Error> {
2936 let wire_params = serde_json::to_value(params)?;
2937 let _value = self
2938 .client
2939 .call(rpc_methods::SESSIONS_RELOADPLUGINHOOKS, Some(wire_params))
2940 .await?;
2941 Ok(serde_json::from_value(_value)?)
2942 }
2943
2944 /// Loads previously-deferred repo-level hooks on the active session, returning queued startup prompts.
2945 ///
2946 /// Wire method: `sessions.loadDeferredRepoHooks`.
2947 ///
2948 /// # Parameters
2949 ///
2950 /// * `params` - Active session ID whose deferred repo-level hooks should be loaded.
2951 ///
2952 /// # Returns
2953 ///
2954 /// Queued repo-level startup prompts and the total hook command count after loading.
2955 ///
2956 /// <div class="warning">
2957 ///
2958 /// **Experimental.** This API is part of an experimental wire-protocol surface
2959 /// and may change or be removed in future SDK or CLI releases. Pin both the
2960 /// SDK and CLI versions if your code depends on it.
2961 ///
2962 /// </div>
2963 pub async fn load_deferred_repo_hooks(
2964 &self,
2965 params: SessionsLoadDeferredRepoHooksRequest,
2966 ) -> Result<SessionLoadDeferredRepoHooksResult, Error> {
2967 let wire_params = serde_json::to_value(params)?;
2968 let _value = self
2969 .client
2970 .call(
2971 rpc_methods::SESSIONS_LOADDEFERREDREPOHOOKS,
2972 Some(wire_params),
2973 )
2974 .await?;
2975 Ok(serde_json::from_value(_value)?)
2976 }
2977
2978 /// Replaces the manager-wide additional plugins registered with the session manager.
2979 ///
2980 /// Wire method: `sessions.setAdditionalPlugins`.
2981 ///
2982 /// # Parameters
2983 ///
2984 /// * `params` - Manager-wide additional plugins to register; replaces any previously-configured set.
2985 ///
2986 /// # Returns
2987 ///
2988 /// 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.
2989 ///
2990 /// <div class="warning">
2991 ///
2992 /// **Experimental.** This API is part of an experimental wire-protocol surface
2993 /// and may change or be removed in future SDK or CLI releases. Pin both the
2994 /// SDK and CLI versions if your code depends on it.
2995 ///
2996 /// </div>
2997 pub async fn set_additional_plugins(
2998 &self,
2999 params: SessionsSetAdditionalPluginsRequest,
3000 ) -> Result<SessionsSetAdditionalPluginsResult, Error> {
3001 let wire_params = serde_json::to_value(params)?;
3002 let _value = self
3003 .client
3004 .call(
3005 rpc_methods::SESSIONS_SETADDITIONALPLUGINS,
3006 Some(wire_params),
3007 )
3008 .await?;
3009 Ok(serde_json::from_value(_value)?)
3010 }
3011
3012 /// 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.
3013 ///
3014 /// Wire method: `sessions.getBoardEntryCount`.
3015 ///
3016 /// # Parameters
3017 ///
3018 /// * `params` - Session ID whose board entry count should be returned.
3019 ///
3020 /// # Returns
3021 ///
3022 /// Dynamic-context board entry count, when available.
3023 ///
3024 /// <div class="warning">
3025 ///
3026 /// **Experimental.** This API is part of an experimental wire-protocol surface
3027 /// and may change or be removed in future SDK or CLI releases. Pin both the
3028 /// SDK and CLI versions if your code depends on it.
3029 ///
3030 /// </div>
3031 pub(crate) async fn get_board_entry_count(
3032 &self,
3033 params: SessionsGetBoardEntryCountRequest,
3034 ) -> Result<SessionsGetBoardEntryCountResult, Error> {
3035 let wire_params = serde_json::to_value(params)?;
3036 let _value = self
3037 .client
3038 .call(rpc_methods::SESSIONS_GETBOARDENTRYCOUNT, Some(wire_params))
3039 .await?;
3040 Ok(serde_json::from_value(_value)?)
3041 }
3042
3043 /// 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.
3044 ///
3045 /// Wire method: `sessions.startRemoteControl`.
3046 ///
3047 /// # Parameters
3048 ///
3049 /// * `params` - Parameters for attaching the remote-control singleton to a session.
3050 ///
3051 /// # Returns
3052 ///
3053 /// Wrapper for the singleton's current status.
3054 ///
3055 /// <div class="warning">
3056 ///
3057 /// **Experimental.** This API is part of an experimental wire-protocol surface
3058 /// and may change or be removed in future SDK or CLI releases. Pin both the
3059 /// SDK and CLI versions if your code depends on it.
3060 ///
3061 /// </div>
3062 pub async fn start_remote_control(
3063 &self,
3064 params: SessionsStartRemoteControlRequest,
3065 ) -> Result<RemoteControlStatusResult, Error> {
3066 let wire_params = serde_json::to_value(params)?;
3067 let _value = self
3068 .client
3069 .call(rpc_methods::SESSIONS_STARTREMOTECONTROL, Some(wire_params))
3070 .await?;
3071 Ok(serde_json::from_value(_value)?)
3072 }
3073
3074 /// 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.
3075 ///
3076 /// Wire method: `sessions.transferRemoteControl`.
3077 ///
3078 /// # Parameters
3079 ///
3080 /// * `params` - Parameters for atomically rebinding the remote-control singleton.
3081 ///
3082 /// # Returns
3083 ///
3084 /// Outcome of a transferRemoteControl call.
3085 ///
3086 /// <div class="warning">
3087 ///
3088 /// **Experimental.** This API is part of an experimental wire-protocol surface
3089 /// and may change or be removed in future SDK or CLI releases. Pin both the
3090 /// SDK and CLI versions if your code depends on it.
3091 ///
3092 /// </div>
3093 pub async fn transfer_remote_control(
3094 &self,
3095 params: SessionsTransferRemoteControlRequest,
3096 ) -> Result<RemoteControlTransferResult, Error> {
3097 let wire_params = serde_json::to_value(params)?;
3098 let _value = self
3099 .client
3100 .call(
3101 rpc_methods::SESSIONS_TRANSFERREMOTECONTROL,
3102 Some(wire_params),
3103 )
3104 .await?;
3105 Ok(serde_json::from_value(_value)?)
3106 }
3107
3108 /// 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.
3109 ///
3110 /// Wire method: `sessions.setRemoteControlSteering`.
3111 ///
3112 /// # Parameters
3113 ///
3114 /// * `params` - Patch for the singleton's steering state.
3115 ///
3116 /// # Returns
3117 ///
3118 /// Wrapper for the singleton's current status.
3119 ///
3120 /// <div class="warning">
3121 ///
3122 /// **Experimental.** This API is part of an experimental wire-protocol surface
3123 /// and may change or be removed in future SDK or CLI releases. Pin both the
3124 /// SDK and CLI versions if your code depends on it.
3125 ///
3126 /// </div>
3127 pub async fn set_remote_control_steering(
3128 &self,
3129 params: SessionsSetRemoteControlSteeringRequest,
3130 ) -> Result<RemoteControlStatusResult, Error> {
3131 let wire_params = serde_json::to_value(params)?;
3132 let _value = self
3133 .client
3134 .call(
3135 rpc_methods::SESSIONS_SETREMOTECONTROLSTEERING,
3136 Some(wire_params),
3137 )
3138 .await?;
3139 Ok(serde_json::from_value(_value)?)
3140 }
3141
3142 /// 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).
3143 ///
3144 /// Wire method: `sessions.stopRemoteControl`.
3145 ///
3146 /// # Returns
3147 ///
3148 /// Outcome of a stopRemoteControl call.
3149 ///
3150 /// <div class="warning">
3151 ///
3152 /// **Experimental.** This API is part of an experimental wire-protocol surface
3153 /// and may change or be removed in future SDK or CLI releases. Pin both the
3154 /// SDK and CLI versions if your code depends on it.
3155 ///
3156 /// </div>
3157 pub async fn stop_remote_control(&self) -> Result<RemoteControlStopResult, Error> {
3158 let wire_params = serde_json::json!({});
3159 let _value = self
3160 .client
3161 .call(rpc_methods::SESSIONS_STOPREMOTECONTROL, Some(wire_params))
3162 .await?;
3163 Ok(serde_json::from_value(_value)?)
3164 }
3165
3166 /// 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).
3167 ///
3168 /// Wire method: `sessions.stopRemoteControl`.
3169 ///
3170 /// # Parameters
3171 ///
3172 /// * `params` - Parameters for stopping the remote-control singleton.
3173 ///
3174 /// # Returns
3175 ///
3176 /// Outcome of a stopRemoteControl call.
3177 ///
3178 /// <div class="warning">
3179 ///
3180 /// **Experimental.** This API is part of an experimental wire-protocol surface
3181 /// and may change or be removed in future SDK or CLI releases. Pin both the
3182 /// SDK and CLI versions if your code depends on it.
3183 ///
3184 /// </div>
3185 pub async fn stop_remote_control_with_params(
3186 &self,
3187 params: SessionsStopRemoteControlRequest,
3188 ) -> Result<RemoteControlStopResult, Error> {
3189 let wire_params = serde_json::to_value(params)?;
3190 let _value = self
3191 .client
3192 .call(rpc_methods::SESSIONS_STOPREMOTECONTROL, Some(wire_params))
3193 .await?;
3194 Ok(serde_json::from_value(_value)?)
3195 }
3196
3197 /// Returns the current state of the remote-control singleton, including the attached session id and frontend URL when active.
3198 ///
3199 /// Wire method: `sessions.getRemoteControlStatus`.
3200 ///
3201 /// # Returns
3202 ///
3203 /// Wrapper for the singleton's current status.
3204 ///
3205 /// <div class="warning">
3206 ///
3207 /// **Experimental.** This API is part of an experimental wire-protocol surface
3208 /// and may change or be removed in future SDK or CLI releases. Pin both the
3209 /// SDK and CLI versions if your code depends on it.
3210 ///
3211 /// </div>
3212 pub async fn get_remote_control_status(&self) -> Result<RemoteControlStatusResult, Error> {
3213 let wire_params = serde_json::json!({});
3214 let _value = self
3215 .client
3216 .call(
3217 rpc_methods::SESSIONS_GETREMOTECONTROLSTATUS,
3218 Some(wire_params),
3219 )
3220 .await?;
3221 Ok(serde_json::from_value(_value)?)
3222 }
3223
3224 /// 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.
3225 ///
3226 /// Wire method: `sessions.configureSessionExtensions`.
3227 ///
3228 /// # Parameters
3229 ///
3230 /// * `params` - Params to attach or detach an in-process ExtensionController delegate.
3231 ///
3232 /// <div class="warning">
3233 ///
3234 /// **Experimental.** This API is part of an experimental wire-protocol surface
3235 /// and may change or be removed in future SDK or CLI releases. Pin both the
3236 /// SDK and CLI versions if your code depends on it.
3237 ///
3238 /// </div>
3239 pub(crate) async fn configure_session_extensions(
3240 &self,
3241 params: ConfigureSessionExtensionsParams,
3242 ) -> Result<(), Error> {
3243 let wire_params = serde_json::to_value(params)?;
3244 let _value = self
3245 .client
3246 .call(
3247 rpc_methods::SESSIONS_CONFIGURESESSIONEXTENSIONS,
3248 Some(wire_params),
3249 )
3250 .await?;
3251 Ok(())
3252 }
3253}
3254
3255/// `skills.*` RPCs.
3256#[derive(Clone, Copy)]
3257pub struct ClientRpcSkills<'a> {
3258 pub(crate) client: &'a Client,
3259}
3260
3261impl<'a> ClientRpcSkills<'a> {
3262 /// `skills.config.*` sub-namespace.
3263 pub fn config(&self) -> ClientRpcSkillsConfig<'a> {
3264 ClientRpcSkillsConfig {
3265 client: self.client,
3266 }
3267 }
3268
3269 /// `skills.installations.*` sub-namespace.
3270 pub fn installations(&self) -> ClientRpcSkillsInstallations<'a> {
3271 ClientRpcSkillsInstallations {
3272 client: self.client,
3273 }
3274 }
3275
3276 /// Plans installation of a verified Agent Finder Skill candidate without writing files. The returned review is safe to present to a user and installing always leaves the Skill disabled until separately enabled.
3277 ///
3278 /// Wire method: `skills.planInstall`.
3279 ///
3280 /// # Parameters
3281 ///
3282 /// * `params` - Side-effect-free planning of one verified Agent Finder Skill candidate.
3283 ///
3284 /// # Returns
3285 ///
3286 /// Skill installation management result with the honoured contract, or a typed refusal.
3287 ///
3288 /// <div class="warning">
3289 ///
3290 /// **Experimental.** This API is part of an experimental wire-protocol surface
3291 /// and may change or be removed in future SDK or CLI releases. Pin both the
3292 /// SDK and CLI versions if your code depends on it.
3293 ///
3294 /// </div>
3295 pub async fn plan_install(
3296 &self,
3297 params: SkillPlanInstallRequest,
3298 ) -> Result<SkillInstallationManagementResult, Error> {
3299 let wire_params = serde_json::to_value(params)?;
3300 let _value = self
3301 .client
3302 .call(rpc_methods::SKILLS_PLANINSTALL, Some(wire_params))
3303 .await?;
3304 Ok(serde_json::from_value(_value)?)
3305 }
3306
3307 /// Consumes one verified Skill installation plan, requests explicit human consent through installations.confirm on the original connection, then revalidates and installs the Skill disabled.
3308 ///
3309 /// Wire method: `skills.applyInstall`.
3310 ///
3311 /// # Parameters
3312 ///
3313 /// * `params` - Applies exactly one retained verified Skill installation plan.
3314 ///
3315 /// # Returns
3316 ///
3317 /// Skill installation result with the honoured contract, or a typed request/negotiation refusal.
3318 ///
3319 /// <div class="warning">
3320 ///
3321 /// **Experimental.** This API is part of an experimental wire-protocol surface
3322 /// and may change or be removed in future SDK or CLI releases. Pin both the
3323 /// SDK and CLI versions if your code depends on it.
3324 ///
3325 /// </div>
3326 pub async fn apply_install(
3327 &self,
3328 params: SkillApplyInstallRequest,
3329 ) -> Result<SkillInstallationResult, Error> {
3330 let wire_params = serde_json::to_value(params)?;
3331 let _value = self
3332 .client
3333 .call(rpc_methods::SKILLS_APPLYINSTALL, Some(wire_params))
3334 .await?;
3335 Ok(serde_json::from_value(_value)?)
3336 }
3337
3338 /// Prepares a read-only removal plan for an owned verified Agent Finder Skill installation. Uninstall planning is never gated by the Skill-install feature flag.
3339 ///
3340 /// Wire method: `skills.planUninstall`.
3341 ///
3342 /// # Parameters
3343 ///
3344 /// * `params` - Read-only preparation of one owned Skill removal under fresh selected-session authority.
3345 ///
3346 /// # Returns
3347 ///
3348 /// Skill installation management result with the honoured contract, or a typed refusal.
3349 ///
3350 /// <div class="warning">
3351 ///
3352 /// **Experimental.** This API is part of an experimental wire-protocol surface
3353 /// and may change or be removed in future SDK or CLI releases. Pin both the
3354 /// SDK and CLI versions if your code depends on it.
3355 ///
3356 /// </div>
3357 pub async fn plan_uninstall(
3358 &self,
3359 params: SkillPlanUninstallRequest,
3360 ) -> Result<SkillInstallationManagementResult, Error> {
3361 let wire_params = serde_json::to_value(params)?;
3362 let _value = self
3363 .client
3364 .call(rpc_methods::SKILLS_PLANUNINSTALL, Some(wire_params))
3365 .await?;
3366 Ok(serde_json::from_value(_value)?)
3367 }
3368
3369 /// Consumes an owned Skill removal plan, requests explicit human consent through installations.confirm, refuses drift, and removes the exact owned files through quarantine.
3370 ///
3371 /// Wire method: `skills.applyUninstall`.
3372 ///
3373 /// # Parameters
3374 ///
3375 /// * `params` - One-use application of the exact retained Skill removal plan.
3376 ///
3377 /// # Returns
3378 ///
3379 /// Skill installation result with the honoured contract, or a typed request/negotiation refusal.
3380 ///
3381 /// <div class="warning">
3382 ///
3383 /// **Experimental.** This API is part of an experimental wire-protocol surface
3384 /// and may change or be removed in future SDK or CLI releases. Pin both the
3385 /// SDK and CLI versions if your code depends on it.
3386 ///
3387 /// </div>
3388 pub async fn apply_uninstall(
3389 &self,
3390 params: SkillApplyUninstallRequest,
3391 ) -> Result<SkillInstallationResult, Error> {
3392 let wire_params = serde_json::to_value(params)?;
3393 let _value = self
3394 .client
3395 .call(rpc_methods::SKILLS_APPLYUNINSTALL, Some(wire_params))
3396 .await?;
3397 Ok(serde_json::from_value(_value)?)
3398 }
3399
3400 /// Discovers skills across global and project sources.
3401 ///
3402 /// Wire method: `skills.discover`.
3403 ///
3404 /// # Parameters
3405 ///
3406 /// * `params` - Optional project paths and additional skill directories to include in discovery.
3407 ///
3408 /// # Returns
3409 ///
3410 /// Skills discovered across global and project sources.
3411 ///
3412 /// <div class="warning">
3413 ///
3414 /// **Experimental.** This API is part of an experimental wire-protocol surface
3415 /// and may change or be removed in future SDK or CLI releases. Pin both the
3416 /// SDK and CLI versions if your code depends on it.
3417 ///
3418 /// </div>
3419 pub async fn discover(&self, params: SkillsDiscoverRequest) -> Result<ServerSkillList, Error> {
3420 let wire_params = serde_json::to_value(params)?;
3421 let _value = self
3422 .client
3423 .call(rpc_methods::SKILLS_DISCOVER, Some(wire_params))
3424 .await?;
3425 Ok(serde_json::from_value(_value)?)
3426 }
3427
3428 /// 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.
3429 ///
3430 /// Wire method: `skills.getDiscoveryPaths`.
3431 ///
3432 /// # Parameters
3433 ///
3434 /// * `params` - Optional project paths to enumerate.
3435 ///
3436 /// # Returns
3437 ///
3438 /// Canonical locations where skills can be created so the runtime will recognize them.
3439 ///
3440 /// <div class="warning">
3441 ///
3442 /// **Experimental.** This API is part of an experimental wire-protocol surface
3443 /// and may change or be removed in future SDK or CLI releases. Pin both the
3444 /// SDK and CLI versions if your code depends on it.
3445 ///
3446 /// </div>
3447 pub async fn get_discovery_paths(
3448 &self,
3449 params: SkillsGetDiscoveryPathsRequest,
3450 ) -> Result<SkillDiscoveryPathList, Error> {
3451 let wire_params = serde_json::to_value(params)?;
3452 let _value = self
3453 .client
3454 .call(rpc_methods::SKILLS_GETDISCOVERYPATHS, Some(wire_params))
3455 .await?;
3456 Ok(serde_json::from_value(_value)?)
3457 }
3458}
3459
3460/// `skills.config.*` RPCs.
3461#[derive(Clone, Copy)]
3462pub struct ClientRpcSkillsConfig<'a> {
3463 pub(crate) client: &'a Client,
3464}
3465
3466impl<'a> ClientRpcSkillsConfig<'a> {
3467 /// Replaces the global list of disabled skills.
3468 ///
3469 /// Wire method: `skills.config.setDisabledSkills`.
3470 ///
3471 /// # Parameters
3472 ///
3473 /// * `params` - Skill names to mark as disabled in global configuration, replacing any previous list.
3474 ///
3475 /// <div class="warning">
3476 ///
3477 /// **Experimental.** This API is part of an experimental wire-protocol surface
3478 /// and may change or be removed in future SDK or CLI releases. Pin both the
3479 /// SDK and CLI versions if your code depends on it.
3480 ///
3481 /// </div>
3482 pub async fn set_disabled_skills(
3483 &self,
3484 params: SkillsConfigSetDisabledSkillsRequest,
3485 ) -> Result<(), Error> {
3486 let wire_params = serde_json::to_value(params)?;
3487 let _value = self
3488 .client
3489 .call(
3490 rpc_methods::SKILLS_CONFIG_SETDISABLEDSKILLS,
3491 Some(wire_params),
3492 )
3493 .await?;
3494 Ok(())
3495 }
3496
3497 /// Atomically adds or removes one skill from the disabled list.
3498 ///
3499 /// Wire method: `skills.config.setSkillDisabled`.
3500 ///
3501 /// # Parameters
3502 ///
3503 /// * `params` - Adds or removes a single skill from the global disabled list, leaving every other entry untouched.
3504 ///
3505 /// <div class="warning">
3506 ///
3507 /// **Experimental.** This API is part of an experimental wire-protocol surface
3508 /// and may change or be removed in future SDK or CLI releases. Pin both the
3509 /// SDK and CLI versions if your code depends on it.
3510 ///
3511 /// </div>
3512 pub async fn set_skill_disabled(
3513 &self,
3514 params: SkillsConfigSetSkillDisabledRequest,
3515 ) -> Result<(), Error> {
3516 let wire_params = serde_json::to_value(params)?;
3517 let _value = self
3518 .client
3519 .call(
3520 rpc_methods::SKILLS_CONFIG_SETSKILLDISABLED,
3521 Some(wire_params),
3522 )
3523 .await?;
3524 Ok(())
3525 }
3526}
3527
3528/// `skills.installations.*` RPCs.
3529#[derive(Clone, Copy)]
3530pub struct ClientRpcSkillsInstallations<'a> {
3531 pub(crate) client: &'a Client,
3532}
3533
3534impl<'a> ClientRpcSkillsInstallations<'a> {
3535 /// Lists owned verified Agent Finder Skill installations for the selected existing session. Listing is never gated by the Skill-install feature flag.
3536 ///
3537 /// Wire method: `skills.installations.list`.
3538 ///
3539 /// # Parameters
3540 ///
3541 /// * `params` - Inventory request under an explicitly selected existing session.
3542 ///
3543 /// # Returns
3544 ///
3545 /// Skill installation management result with the honoured contract, or a typed refusal.
3546 ///
3547 /// <div class="warning">
3548 ///
3549 /// **Experimental.** This API is part of an experimental wire-protocol surface
3550 /// and may change or be removed in future SDK or CLI releases. Pin both the
3551 /// SDK and CLI versions if your code depends on it.
3552 ///
3553 /// </div>
3554 pub async fn list(
3555 &self,
3556 params: SkillInstallationsRequest,
3557 ) -> Result<SkillInstallationManagementResult, Error> {
3558 let wire_params = serde_json::to_value(params)?;
3559 let _value = self
3560 .client
3561 .call(rpc_methods::SKILLS_INSTALLATIONS_LIST, Some(wire_params))
3562 .await?;
3563 Ok(serde_json::from_value(_value)?)
3564 }
3565
3566 /// Reconciles interrupted owned Skill installation work for the selected existing session, then inspects owned inventory. Recovery is never gated by the Skill-install feature flag.
3567 ///
3568 /// Wire method: `skills.installations.recover`.
3569 ///
3570 /// # Parameters
3571 ///
3572 /// * `params` - Inventory request under an explicitly selected existing session.
3573 ///
3574 /// # Returns
3575 ///
3576 /// Skill installation management result with the honoured contract, or a typed refusal.
3577 ///
3578 /// <div class="warning">
3579 ///
3580 /// **Experimental.** This API is part of an experimental wire-protocol surface
3581 /// and may change or be removed in future SDK or CLI releases. Pin both the
3582 /// SDK and CLI versions if your code depends on it.
3583 ///
3584 /// </div>
3585 pub async fn recover(
3586 &self,
3587 params: SkillInstallationsRequest,
3588 ) -> Result<SkillInstallationManagementResult, Error> {
3589 let wire_params = serde_json::to_value(params)?;
3590 let _value = self
3591 .client
3592 .call(rpc_methods::SKILLS_INSTALLATIONS_RECOVER, Some(wire_params))
3593 .await?;
3594 Ok(serde_json::from_value(_value)?)
3595 }
3596
3597 /// Inspects a known Skill installation operation on its original runtime connection. Status is never gated by the Skill-install feature flag.
3598 ///
3599 /// Wire method: `skills.installations.status`.
3600 ///
3601 /// # Parameters
3602 ///
3603 /// * `params` - Existing-operation control. A new session selector is deliberately not accepted.
3604 ///
3605 /// # Returns
3606 ///
3607 /// Skill installation management result with the honoured contract, or a typed refusal.
3608 ///
3609 /// <div class="warning">
3610 ///
3611 /// **Experimental.** This API is part of an experimental wire-protocol surface
3612 /// and may change or be removed in future SDK or CLI releases. Pin both the
3613 /// SDK and CLI versions if your code depends on it.
3614 ///
3615 /// </div>
3616 pub async fn status(
3617 &self,
3618 params: SkillInstallationOperationRequest,
3619 ) -> Result<SkillInstallationManagementResult, Error> {
3620 let wire_params = serde_json::to_value(params)?;
3621 let _value = self
3622 .client
3623 .call(rpc_methods::SKILLS_INSTALLATIONS_STATUS, Some(wire_params))
3624 .await?;
3625 Ok(serde_json::from_value(_value)?)
3626 }
3627
3628 /// Requests cancellation of a known Skill installation operation before commit. Already-started durable work requires recovery instead of silent replay.
3629 ///
3630 /// Wire method: `skills.installations.cancel`.
3631 ///
3632 /// # Parameters
3633 ///
3634 /// * `params` - Existing-operation control. A new session selector is deliberately not accepted.
3635 ///
3636 /// # Returns
3637 ///
3638 /// Skill installation management result with the honoured contract, or a typed refusal.
3639 ///
3640 /// <div class="warning">
3641 ///
3642 /// **Experimental.** This API is part of an experimental wire-protocol surface
3643 /// and may change or be removed in future SDK or CLI releases. Pin both the
3644 /// SDK and CLI versions if your code depends on it.
3645 ///
3646 /// </div>
3647 pub async fn cancel(
3648 &self,
3649 params: SkillInstallationOperationRequest,
3650 ) -> Result<SkillInstallationManagementResult, Error> {
3651 let wire_params = serde_json::to_value(params)?;
3652 let _value = self
3653 .client
3654 .call(rpc_methods::SKILLS_INSTALLATIONS_CANCEL, Some(wire_params))
3655 .await?;
3656 Ok(serde_json::from_value(_value)?)
3657 }
3658
3659 /// Atomically persists enablement for one owned Agent Finder Skill and reconciles the selected bound session. Enablement is installation-scoped by receipt identity and is never gated by the Skill-install feature flag.
3660 ///
3661 /// Wire method: `skills.installations.setEnabled`.
3662 ///
3663 /// # Parameters
3664 ///
3665 /// * `params` - Persisted enablement update for one owned Skill installation.
3666 ///
3667 /// # Returns
3668 ///
3669 /// Skill installation management result with the honoured contract, or a typed refusal.
3670 ///
3671 /// <div class="warning">
3672 ///
3673 /// **Experimental.** This API is part of an experimental wire-protocol surface
3674 /// and may change or be removed in future SDK or CLI releases. Pin both the
3675 /// SDK and CLI versions if your code depends on it.
3676 ///
3677 /// </div>
3678 pub async fn set_enabled(
3679 &self,
3680 params: SkillSetEnabledRequest,
3681 ) -> Result<SkillInstallationManagementResult, Error> {
3682 let wire_params = serde_json::to_value(params)?;
3683 let _value = self
3684 .client
3685 .call(
3686 rpc_methods::SKILLS_INSTALLATIONS_SETENABLED,
3687 Some(wire_params),
3688 )
3689 .await?;
3690 Ok(serde_json::from_value(_value)?)
3691 }
3692}
3693
3694/// `tools.*` RPCs.
3695#[derive(Clone, Copy)]
3696pub struct ClientRpcTools<'a> {
3697 pub(crate) client: &'a Client,
3698}
3699
3700impl<'a> ClientRpcTools<'a> {
3701 /// Lists built-in tools available for a model.
3702 ///
3703 /// Wire method: `tools.list`.
3704 ///
3705 /// # Parameters
3706 ///
3707 /// * `params` - Optional model identifier whose tool overrides should be applied to the listing.
3708 ///
3709 /// # Returns
3710 ///
3711 /// Built-in tools available for the requested model, with their parameters and instructions.
3712 ///
3713 /// <div class="warning">
3714 ///
3715 /// **Experimental.** This API is part of an experimental wire-protocol surface
3716 /// and may change or be removed in future SDK or CLI releases. Pin both the
3717 /// SDK and CLI versions if your code depends on it.
3718 ///
3719 /// </div>
3720 pub async fn list(&self, params: ToolsListRequest) -> Result<ToolList, Error> {
3721 let wire_params = serde_json::to_value(params)?;
3722 let _value = self
3723 .client
3724 .call(rpc_methods::TOOLS_LIST, Some(wire_params))
3725 .await?;
3726 Ok(serde_json::from_value(_value)?)
3727 }
3728}
3729
3730/// `user.*` RPCs.
3731#[derive(Clone, Copy)]
3732pub struct ClientRpcUser<'a> {
3733 pub(crate) client: &'a Client,
3734}
3735
3736impl<'a> ClientRpcUser<'a> {
3737 /// `user.settings.*` sub-namespace.
3738 pub fn settings(&self) -> ClientRpcUserSettings<'a> {
3739 ClientRpcUserSettings {
3740 client: self.client,
3741 }
3742 }
3743}
3744
3745/// `user.settings.*` RPCs.
3746#[derive(Clone, Copy)]
3747pub struct ClientRpcUserSettings<'a> {
3748 pub(crate) client: &'a Client,
3749}
3750
3751impl<'a> ClientRpcUserSettings<'a> {
3752 /// Drops this runtime process's in-memory user settings cache so the next settings read observes disk.
3753 ///
3754 /// Wire method: `user.settings.reload`.
3755 ///
3756 /// <div class="warning">
3757 ///
3758 /// **Experimental.** This API is part of an experimental wire-protocol surface
3759 /// and may change or be removed in future SDK or CLI releases. Pin both the
3760 /// SDK and CLI versions if your code depends on it.
3761 ///
3762 /// </div>
3763 pub async fn reload(&self) -> Result<(), Error> {
3764 let wire_params = serde_json::json!({});
3765 let _value = self
3766 .client
3767 .call(rpc_methods::USER_SETTINGS_RELOAD, Some(wire_params))
3768 .await?;
3769 Ok(())
3770 }
3771
3772 /// 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.
3773 ///
3774 /// Wire method: `user.settings.get`.
3775 ///
3776 /// # Returns
3777 ///
3778 /// 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.
3779 ///
3780 /// <div class="warning">
3781 ///
3782 /// **Experimental.** This API is part of an experimental wire-protocol surface
3783 /// and may change or be removed in future SDK or CLI releases. Pin both the
3784 /// SDK and CLI versions if your code depends on it.
3785 ///
3786 /// </div>
3787 pub async fn get(&self) -> Result<UserSettingsGetResult, Error> {
3788 let wire_params = serde_json::json!({});
3789 let _value = self
3790 .client
3791 .call(rpc_methods::USER_SETTINGS_GET, Some(wire_params))
3792 .await?;
3793 Ok(serde_json::from_value(_value)?)
3794 }
3795
3796 /// 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.
3797 ///
3798 /// Wire method: `user.settings.set`.
3799 ///
3800 /// # Parameters
3801 ///
3802 /// * `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.
3803 ///
3804 /// # Returns
3805 ///
3806 /// Outcome of writing user settings.
3807 ///
3808 /// <div class="warning">
3809 ///
3810 /// **Experimental.** This API is part of an experimental wire-protocol surface
3811 /// and may change or be removed in future SDK or CLI releases. Pin both the
3812 /// SDK and CLI versions if your code depends on it.
3813 ///
3814 /// </div>
3815 pub async fn set(
3816 &self,
3817 params: UserSettingsSetRequest,
3818 ) -> Result<UserSettingsSetResult, Error> {
3819 let wire_params = serde_json::to_value(params)?;
3820 let _value = self
3821 .client
3822 .call(rpc_methods::USER_SETTINGS_SET, Some(wire_params))
3823 .await?;
3824 Ok(serde_json::from_value(_value)?)
3825 }
3826}
3827
3828/// Typed view over a [`Session`]'s RPC namespace.
3829#[derive(Clone, Copy)]
3830pub struct SessionRpc<'a> {
3831 pub(crate) session: &'a Session,
3832}
3833
3834impl<'a> SessionRpc<'a> {
3835 /// `session.accounts.*` sub-namespace.
3836 pub fn accounts(&self) -> SessionRpcAccounts<'a> {
3837 SessionRpcAccounts {
3838 session: self.session,
3839 }
3840 }
3841
3842 /// `session.agent.*` sub-namespace.
3843 pub fn agent(&self) -> SessionRpcAgent<'a> {
3844 SessionRpcAgent {
3845 session: self.session,
3846 }
3847 }
3848
3849 /// `session.autopilotObjective.*` sub-namespace.
3850 pub fn autopilot_objective(&self) -> SessionRpcAutopilotObjective<'a> {
3851 SessionRpcAutopilotObjective {
3852 session: self.session,
3853 }
3854 }
3855
3856 /// `session.canvas.*` sub-namespace.
3857 pub fn canvas(&self) -> SessionRpcCanvas<'a> {
3858 SessionRpcCanvas {
3859 session: self.session,
3860 }
3861 }
3862
3863 /// `session.commands.*` sub-namespace.
3864 pub fn commands(&self) -> SessionRpcCommands<'a> {
3865 SessionRpcCommands {
3866 session: self.session,
3867 }
3868 }
3869
3870 /// `session.completions.*` sub-namespace.
3871 pub fn completions(&self) -> SessionRpcCompletions<'a> {
3872 SessionRpcCompletions {
3873 session: self.session,
3874 }
3875 }
3876
3877 /// `session.connectors.*` sub-namespace.
3878 pub fn connectors(&self) -> SessionRpcConnectors<'a> {
3879 SessionRpcConnectors {
3880 session: self.session,
3881 }
3882 }
3883
3884 /// `session.contentExclusion.*` sub-namespace.
3885 pub fn content_exclusion(&self) -> SessionRpcContentExclusion<'a> {
3886 SessionRpcContentExclusion {
3887 session: self.session,
3888 }
3889 }
3890
3891 /// `session.customizations.*` sub-namespace.
3892 pub fn customizations(&self) -> SessionRpcCustomizations<'a> {
3893 SessionRpcCustomizations {
3894 session: self.session,
3895 }
3896 }
3897
3898 /// `session.debug.*` sub-namespace.
3899 pub fn debug(&self) -> SessionRpcDebug<'a> {
3900 SessionRpcDebug {
3901 session: self.session,
3902 }
3903 }
3904
3905 /// `session.diagnostics.*` sub-namespace.
3906 pub fn diagnostics(&self) -> SessionRpcDiagnostics<'a> {
3907 SessionRpcDiagnostics {
3908 session: self.session,
3909 }
3910 }
3911
3912 /// `session.eventLog.*` sub-namespace.
3913 pub fn event_log(&self) -> SessionRpcEventLog<'a> {
3914 SessionRpcEventLog {
3915 session: self.session,
3916 }
3917 }
3918
3919 /// `session.extensions.*` sub-namespace.
3920 pub fn extensions(&self) -> SessionRpcExtensions<'a> {
3921 SessionRpcExtensions {
3922 session: self.session,
3923 }
3924 }
3925
3926 /// `session.fleet.*` sub-namespace.
3927 pub fn fleet(&self) -> SessionRpcFleet<'a> {
3928 SessionRpcFleet {
3929 session: self.session,
3930 }
3931 }
3932
3933 /// `session.gitHubAuth.*` sub-namespace.
3934 pub fn git_hub_auth(&self) -> SessionRpcGitHubAuth<'a> {
3935 SessionRpcGitHubAuth {
3936 session: self.session,
3937 }
3938 }
3939
3940 /// `session.history.*` sub-namespace.
3941 pub fn history(&self) -> SessionRpcHistory<'a> {
3942 SessionRpcHistory {
3943 session: self.session,
3944 }
3945 }
3946
3947 /// `session.instructions.*` sub-namespace.
3948 pub fn instructions(&self) -> SessionRpcInstructions<'a> {
3949 SessionRpcInstructions {
3950 session: self.session,
3951 }
3952 }
3953
3954 /// `session.limitPrediction.*` sub-namespace.
3955 pub fn limit_prediction(&self) -> SessionRpcLimitPrediction<'a> {
3956 SessionRpcLimitPrediction {
3957 session: self.session,
3958 }
3959 }
3960
3961 /// `session.lsp.*` sub-namespace.
3962 pub fn lsp(&self) -> SessionRpcLsp<'a> {
3963 SessionRpcLsp {
3964 session: self.session,
3965 }
3966 }
3967
3968 /// `session.managedSettings.*` sub-namespace.
3969 pub fn managed_settings(&self) -> SessionRpcManagedSettings<'a> {
3970 SessionRpcManagedSettings {
3971 session: self.session,
3972 }
3973 }
3974
3975 /// `session.mcp.*` sub-namespace.
3976 pub fn mcp(&self) -> SessionRpcMcp<'a> {
3977 SessionRpcMcp {
3978 session: self.session,
3979 }
3980 }
3981
3982 /// `session.metadata.*` sub-namespace.
3983 pub fn metadata(&self) -> SessionRpcMetadata<'a> {
3984 SessionRpcMetadata {
3985 session: self.session,
3986 }
3987 }
3988
3989 /// `session.mode.*` sub-namespace.
3990 pub fn mode(&self) -> SessionRpcMode<'a> {
3991 SessionRpcMode {
3992 session: self.session,
3993 }
3994 }
3995
3996 /// `session.model.*` sub-namespace.
3997 pub fn model(&self) -> SessionRpcModel<'a> {
3998 SessionRpcModel {
3999 session: self.session,
4000 }
4001 }
4002
4003 /// `session.name.*` sub-namespace.
4004 pub fn name(&self) -> SessionRpcName<'a> {
4005 SessionRpcName {
4006 session: self.session,
4007 }
4008 }
4009
4010 /// `session.options.*` sub-namespace.
4011 pub fn options(&self) -> SessionRpcOptions<'a> {
4012 SessionRpcOptions {
4013 session: self.session,
4014 }
4015 }
4016
4017 /// `session.permissions.*` sub-namespace.
4018 pub fn permissions(&self) -> SessionRpcPermissions<'a> {
4019 SessionRpcPermissions {
4020 session: self.session,
4021 }
4022 }
4023
4024 /// `session.plan.*` sub-namespace.
4025 pub fn plan(&self) -> SessionRpcPlan<'a> {
4026 SessionRpcPlan {
4027 session: self.session,
4028 }
4029 }
4030
4031 /// `session.plugins.*` sub-namespace.
4032 pub fn plugins(&self) -> SessionRpcPlugins<'a> {
4033 SessionRpcPlugins {
4034 session: self.session,
4035 }
4036 }
4037
4038 /// `session.provider.*` sub-namespace.
4039 pub fn provider(&self) -> SessionRpcProvider<'a> {
4040 SessionRpcProvider {
4041 session: self.session,
4042 }
4043 }
4044
4045 /// `session.queue.*` sub-namespace.
4046 pub fn queue(&self) -> SessionRpcQueue<'a> {
4047 SessionRpcQueue {
4048 session: self.session,
4049 }
4050 }
4051
4052 /// `session.remote.*` sub-namespace.
4053 pub fn remote(&self) -> SessionRpcRemote<'a> {
4054 SessionRpcRemote {
4055 session: self.session,
4056 }
4057 }
4058
4059 /// `session.sandbox.*` sub-namespace.
4060 pub fn sandbox(&self) -> SessionRpcSandbox<'a> {
4061 SessionRpcSandbox {
4062 session: self.session,
4063 }
4064 }
4065
4066 /// `session.schedule.*` sub-namespace.
4067 pub fn schedule(&self) -> SessionRpcSchedule<'a> {
4068 SessionRpcSchedule {
4069 session: self.session,
4070 }
4071 }
4072
4073 /// `session.settings.*` sub-namespace.
4074 pub fn settings(&self) -> SessionRpcSettings<'a> {
4075 SessionRpcSettings {
4076 session: self.session,
4077 }
4078 }
4079
4080 /// `session.shell.*` sub-namespace.
4081 pub fn shell(&self) -> SessionRpcShell<'a> {
4082 SessionRpcShell {
4083 session: self.session,
4084 }
4085 }
4086
4087 /// `session.skills.*` sub-namespace.
4088 pub fn skills(&self) -> SessionRpcSkills<'a> {
4089 SessionRpcSkills {
4090 session: self.session,
4091 }
4092 }
4093
4094 /// `session.tasks.*` sub-namespace.
4095 pub fn tasks(&self) -> SessionRpcTasks<'a> {
4096 SessionRpcTasks {
4097 session: self.session,
4098 }
4099 }
4100
4101 /// `session.telemetry.*` sub-namespace.
4102 pub fn telemetry(&self) -> SessionRpcTelemetry<'a> {
4103 SessionRpcTelemetry {
4104 session: self.session,
4105 }
4106 }
4107
4108 /// `session.tools.*` sub-namespace.
4109 pub fn tools(&self) -> SessionRpcTools<'a> {
4110 SessionRpcTools {
4111 session: self.session,
4112 }
4113 }
4114
4115 /// `session.ui.*` sub-namespace.
4116 pub fn ui(&self) -> SessionRpcUi<'a> {
4117 SessionRpcUi {
4118 session: self.session,
4119 }
4120 }
4121
4122 /// `session.usage.*` sub-namespace.
4123 pub fn usage(&self) -> SessionRpcUsage<'a> {
4124 SessionRpcUsage {
4125 session: self.session,
4126 }
4127 }
4128
4129 /// `session.visibility.*` sub-namespace.
4130 pub fn visibility(&self) -> SessionRpcVisibility<'a> {
4131 SessionRpcVisibility {
4132 session: self.session,
4133 }
4134 }
4135
4136 /// `session.workflow.*` sub-namespace.
4137 pub fn workflow(&self) -> SessionRpcWorkflow<'a> {
4138 SessionRpcWorkflow {
4139 session: self.session,
4140 }
4141 }
4142
4143 /// `session.workspaces.*` sub-namespace.
4144 pub fn workspaces(&self) -> SessionRpcWorkspaces<'a> {
4145 SessionRpcWorkspaces {
4146 session: self.session,
4147 }
4148 }
4149
4150 /// Suspends the session while preserving persisted state for later resume.
4151 ///
4152 /// Wire method: `session.suspend`.
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 async fn suspend(&self) -> Result<(), Error> {
4162 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
4163 let _value = self
4164 .session
4165 .client()
4166 .call(rpc_methods::SESSION_SUSPEND, Some(wire_params))
4167 .await?;
4168 Ok(())
4169 }
4170
4171 /// Sends a user message to the session and returns its message ID.
4172 ///
4173 /// Wire method: `session.send`.
4174 ///
4175 /// # Parameters
4176 ///
4177 /// * `params` - Parameters for sending a user message to the session
4178 ///
4179 /// # Returns
4180 ///
4181 /// Result of sending a user message
4182 ///
4183 /// <div class="warning">
4184 ///
4185 /// **Experimental.** This API is part of an experimental wire-protocol surface
4186 /// and may change or be removed in future SDK or CLI releases. Pin both the
4187 /// SDK and CLI versions if your code depends on it.
4188 ///
4189 /// </div>
4190 pub async fn send(&self, params: SendRequest) -> Result<SendResult, Error> {
4191 let mut wire_params = serde_json::to_value(params)?;
4192 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4193 let _value = self
4194 .session
4195 .client()
4196 .call(rpc_methods::SESSION_SEND, Some(wire_params))
4197 .await?;
4198 Ok(serde_json::from_value(_value)?)
4199 }
4200
4201 /// 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.
4202 ///
4203 /// Wire method: `session.sendMessages`.
4204 ///
4205 /// # Parameters
4206 ///
4207 /// * `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.
4208 ///
4209 /// # Returns
4210 ///
4211 /// Result of sending zero or more user messages
4212 ///
4213 /// <div class="warning">
4214 ///
4215 /// **Experimental.** This API is part of an experimental wire-protocol surface
4216 /// and may change or be removed in future SDK or CLI releases. Pin both the
4217 /// SDK and CLI versions if your code depends on it.
4218 ///
4219 /// </div>
4220 pub async fn send_messages(
4221 &self,
4222 params: SendMessagesRequest,
4223 ) -> Result<SendMessagesResult, Error> {
4224 let mut wire_params = serde_json::to_value(params)?;
4225 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4226 let _value = self
4227 .session
4228 .client()
4229 .call(rpc_methods::SESSION_SENDMESSAGES, Some(wire_params))
4230 .await?;
4231 Ok(serde_json::from_value(_value)?)
4232 }
4233
4234 /// Queues or sends an internal system notification to the session according to its passive policy.
4235 ///
4236 /// Wire method: `session.sendSystemNotification`.
4237 ///
4238 /// # Parameters
4239 ///
4240 /// * `params` - Internal request for sending a system notification.
4241 ///
4242 /// <div class="warning">
4243 ///
4244 /// **Experimental.** This API is part of an experimental wire-protocol surface
4245 /// and may change or be removed in future SDK or CLI releases. Pin both the
4246 /// SDK and CLI versions if your code depends on it.
4247 ///
4248 /// </div>
4249 pub(crate) async fn send_system_notification(
4250 &self,
4251 params: SendSystemNotificationRequest,
4252 ) -> Result<(), Error> {
4253 let mut wire_params = serde_json::to_value(params)?;
4254 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4255 let _value = self
4256 .session
4257 .client()
4258 .call(
4259 rpc_methods::SESSION_SENDSYSTEMNOTIFICATION,
4260 Some(wire_params),
4261 )
4262 .await?;
4263 Ok(())
4264 }
4265
4266 /// Aborts the current agent turn.
4267 ///
4268 /// Wire method: `session.abort`.
4269 ///
4270 /// # Parameters
4271 ///
4272 /// * `params` - Parameters for aborting the current turn
4273 ///
4274 /// # Returns
4275 ///
4276 /// Result of aborting the current turn
4277 ///
4278 /// <div class="warning">
4279 ///
4280 /// **Experimental.** This API is part of an experimental wire-protocol surface
4281 /// and may change or be removed in future SDK or CLI releases. Pin both the
4282 /// SDK and CLI versions if your code depends on it.
4283 ///
4284 /// </div>
4285 pub async fn abort(&self, params: AbortRequest) -> Result<AbortResult, Error> {
4286 let mut wire_params = serde_json::to_value(params)?;
4287 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4288 let _value = self
4289 .session
4290 .client()
4291 .call(rpc_methods::SESSION_ABORT, Some(wire_params))
4292 .await?;
4293 Ok(serde_json::from_value(_value)?)
4294 }
4295
4296 /// 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.
4297 ///
4298 /// Wire method: `session.interruptMainTurn`.
4299 ///
4300 /// # Parameters
4301 ///
4302 /// * `params` - Parameters for interrupting the main agent turn.
4303 ///
4304 /// # Returns
4305 ///
4306 /// Result of interrupting the main agent turn.
4307 ///
4308 /// <div class="warning">
4309 ///
4310 /// **Experimental.** This API is part of an experimental wire-protocol surface
4311 /// and may change or be removed in future SDK or CLI releases. Pin both the
4312 /// SDK and CLI versions if your code depends on it.
4313 ///
4314 /// </div>
4315 pub async fn interrupt_main_turn(
4316 &self,
4317 params: InterruptMainTurnRequest,
4318 ) -> Result<InterruptMainTurnResult, Error> {
4319 let mut wire_params = serde_json::to_value(params)?;
4320 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4321 let _value = self
4322 .session
4323 .client()
4324 .call(rpc_methods::SESSION_INTERRUPTMAINTURN, Some(wire_params))
4325 .await?;
4326 Ok(serde_json::from_value(_value)?)
4327 }
4328
4329 /// Cancels every running background agent (task-registry subagents plus sidekick agents) without interrupting the main agent loop. Promoted attached shells are left running.
4330 ///
4331 /// Wire method: `session.cancelAllBackgroundAgents`.
4332 ///
4333 /// # Returns
4334 ///
4335 /// The number of running background agents (task-registry agents) that were cancelled.
4336 ///
4337 /// <div class="warning">
4338 ///
4339 /// **Experimental.** This API is part of an experimental wire-protocol surface
4340 /// and may change or be removed in future SDK or CLI releases. Pin both the
4341 /// SDK and CLI versions if your code depends on it.
4342 ///
4343 /// </div>
4344 pub async fn cancel_all_background_agents(
4345 &self,
4346 ) -> Result<SessionCancelAllBackgroundAgentsResult, Error> {
4347 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
4348 let _value = self
4349 .session
4350 .client()
4351 .call(
4352 rpc_methods::SESSION_CANCELALLBACKGROUNDAGENTS,
4353 Some(wire_params),
4354 )
4355 .await?;
4356 Ok(serde_json::from_value(_value)?)
4357 }
4358
4359 /// 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.
4360 ///
4361 /// Wire method: `session.shutdown`.
4362 ///
4363 /// # Parameters
4364 ///
4365 /// * `params` - Parameters for shutting down the session
4366 ///
4367 /// <div class="warning">
4368 ///
4369 /// **Experimental.** This API is part of an experimental wire-protocol surface
4370 /// and may change or be removed in future SDK or CLI releases. Pin both the
4371 /// SDK and CLI versions if your code depends on it.
4372 ///
4373 /// </div>
4374 pub async fn shutdown(&self, params: ShutdownRequest) -> Result<(), Error> {
4375 let mut wire_params = serde_json::to_value(params)?;
4376 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4377 let _value = self
4378 .session
4379 .client()
4380 .call(rpc_methods::SESSION_SHUTDOWN, Some(wire_params))
4381 .await?;
4382 Ok(())
4383 }
4384
4385 /// Emits a user-visible session log event.
4386 ///
4387 /// Wire method: `session.log`.
4388 ///
4389 /// # Parameters
4390 ///
4391 /// * `params` - Message text, optional severity level, persistence flag, optional follow-up URL, and optional tip.
4392 ///
4393 /// # Returns
4394 ///
4395 /// Identifier of the session event that was emitted for the log message.
4396 ///
4397 /// <div class="warning">
4398 ///
4399 /// **Experimental.** This API is part of an experimental wire-protocol surface
4400 /// and may change or be removed in future SDK or CLI releases. Pin both the
4401 /// SDK and CLI versions if your code depends on it.
4402 ///
4403 /// </div>
4404 pub async fn log(&self, params: LogRequest) -> Result<LogResult, Error> {
4405 let mut wire_params = serde_json::to_value(params)?;
4406 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4407 let _value = self
4408 .session
4409 .client()
4410 .call(rpc_methods::SESSION_LOG, Some(wire_params))
4411 .await?;
4412 Ok(serde_json::from_value(_value)?)
4413 }
4414}
4415
4416/// `session.accounts.*` RPCs.
4417#[derive(Clone, Copy)]
4418pub struct SessionRpcAccounts<'a> {
4419 pub(crate) session: &'a Session,
4420}
4421
4422impl<'a> SessionRpcAccounts<'a> {
4423 /// `session.accounts.login.*` sub-namespace.
4424 pub fn login(&self) -> SessionRpcAccountsLogin<'a> {
4425 SessionRpcAccountsLogin {
4426 session: self.session,
4427 }
4428 }
4429
4430 /// Enumerate a typed accounts collection: the signed-in accounts, or the providers offered for interactive login.
4431 ///
4432 /// Wire method: `session.accounts.enumerate`.
4433 ///
4434 /// # Parameters
4435 ///
4436 /// * `params` - Enumerate request carrying the typed collection query.
4437 ///
4438 /// # Returns
4439 ///
4440 /// The enumerated collection, keyed by the same selector as the query.
4441 ///
4442 /// <div class="warning">
4443 ///
4444 /// **Experimental.** This API is part of an experimental wire-protocol surface
4445 /// and may change or be removed in future SDK or CLI releases. Pin both the
4446 /// SDK and CLI versions if your code depends on it.
4447 ///
4448 /// </div>
4449 pub async fn enumerate(
4450 &self,
4451 params: AccountsEnumerateRequest,
4452 ) -> Result<AuthEnumerateValue, Error> {
4453 let mut wire_params = serde_json::to_value(params)?;
4454 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4455 let _value = self
4456 .session
4457 .client()
4458 .call(rpc_methods::SESSION_ACCOUNTS_ENUMERATE, Some(wire_params))
4459 .await?;
4460 Ok(serde_json::from_value(_value)?)
4461 }
4462
4463 /// Read one typed accounts datum: the active account, a neutral status summary, or the last authentication errors.
4464 ///
4465 /// Wire method: `session.accounts.get`.
4466 ///
4467 /// # Parameters
4468 ///
4469 /// * `params` - Read request carrying the typed datum query.
4470 ///
4471 /// # Returns
4472 ///
4473 /// The read result, keyed by the same selector as the query.
4474 ///
4475 /// <div class="warning">
4476 ///
4477 /// **Experimental.** This API is part of an experimental wire-protocol surface
4478 /// and may change or be removed in future SDK or CLI releases. Pin both the
4479 /// SDK and CLI versions if your code depends on it.
4480 ///
4481 /// </div>
4482 pub async fn get(&self, params: AccountsGetRequest) -> Result<AuthReadValue, Error> {
4483 let mut wire_params = serde_json::to_value(params)?;
4484 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4485 let _value = self
4486 .session
4487 .client()
4488 .call(rpc_methods::SESSION_ACCOUNTS_GET, Some(wire_params))
4489 .await?;
4490 Ok(serde_json::from_value(_value)?)
4491 }
4492
4493 /// Apply one non-interactive accounts mutation: switch the active account, log an account out, or set credentials from a token.
4494 ///
4495 /// Wire method: `session.accounts.set`.
4496 ///
4497 /// # Parameters
4498 ///
4499 /// * `params` - Mutation request carrying the typed write command.
4500 ///
4501 /// # Returns
4502 ///
4503 /// Result of a non-interactive accounts mutation.
4504 ///
4505 /// <div class="warning">
4506 ///
4507 /// **Experimental.** This API is part of an experimental wire-protocol surface
4508 /// and may change or be removed in future SDK or CLI releases. Pin both the
4509 /// SDK and CLI versions if your code depends on it.
4510 ///
4511 /// </div>
4512 pub async fn set(&self, params: AccountsSetRequest) -> Result<AuthWriteResult, Error> {
4513 let mut wire_params = serde_json::to_value(params)?;
4514 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4515 let _value = self
4516 .session
4517 .client()
4518 .call(rpc_methods::SESSION_ACCOUNTS_SET, Some(wire_params))
4519 .await?;
4520 Ok(serde_json::from_value(_value)?)
4521 }
4522}
4523
4524/// `session.accounts.login.*` RPCs.
4525#[derive(Clone, Copy)]
4526pub struct SessionRpcAccountsLogin<'a> {
4527 pub(crate) session: &'a Session,
4528}
4529
4530impl<'a> SessionRpcAccountsLogin<'a> {
4531 /// Begin an interactive login flow for a provider kind (dispatch is kind-only) and return its opaque flow id and first step.
4532 ///
4533 /// Wire method: `session.accounts.login.begin`.
4534 ///
4535 /// # Parameters
4536 ///
4537 /// * `params` - Begin an interactive login flow for a provider kind. Dispatch is kind-only.
4538 ///
4539 /// # Returns
4540 ///
4541 /// A started login flow: its opaque id and first step.
4542 ///
4543 /// <div class="warning">
4544 ///
4545 /// **Experimental.** This API is part of an experimental wire-protocol surface
4546 /// and may change or be removed in future SDK or CLI releases. Pin both the
4547 /// SDK and CLI versions if your code depends on it.
4548 ///
4549 /// </div>
4550 pub async fn begin(&self, params: AuthLoginBeginRequest) -> Result<AuthLoginBegun, Error> {
4551 let mut wire_params = serde_json::to_value(params)?;
4552 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4553 let _value = self
4554 .session
4555 .client()
4556 .call(rpc_methods::SESSION_ACCOUNTS_LOGIN_BEGIN, Some(wire_params))
4557 .await?;
4558 Ok(serde_json::from_value(_value)?)
4559 }
4560
4561 /// Advance an in-flight login flow, optionally fulfilling an input-required step, and return the next step.
4562 ///
4563 /// Wire method: `session.accounts.login.advance`.
4564 ///
4565 /// # Parameters
4566 ///
4567 /// * `params` - Advance an in-flight login flow, optionally fulfilling an input-required step.
4568 ///
4569 /// # Returns
4570 ///
4571 /// One step in an interactive login flow. The consumer acts on the step and calls advance to proceed. Browser-open is encoded as two distinct steps by design: `open-url` is CONSUMER-driven (the provider surfaces the authorize URL and the consumer opens it — github.com/GHEC web), while `needs-interaction` is PROVIDER-driven (the provider opens the browser or broker UI itself and does not surface a URL — Entra).
4572 ///
4573 /// <div class="warning">
4574 ///
4575 /// **Experimental.** This API is part of an experimental wire-protocol surface
4576 /// and may change or be removed in future SDK or CLI releases. Pin both the
4577 /// SDK and CLI versions if your code depends on it.
4578 ///
4579 /// </div>
4580 pub async fn advance(&self, params: AuthLoginAdvanceRequest) -> Result<AuthLoginStep, Error> {
4581 let mut wire_params = serde_json::to_value(params)?;
4582 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4583 let _value = self
4584 .session
4585 .client()
4586 .call(
4587 rpc_methods::SESSION_ACCOUNTS_LOGIN_ADVANCE,
4588 Some(wire_params),
4589 )
4590 .await?;
4591 Ok(serde_json::from_value(_value)?)
4592 }
4593
4594 /// Cancel an in-flight login flow and release its resources.
4595 ///
4596 /// Wire method: `session.accounts.login.cancel`.
4597 ///
4598 /// # Parameters
4599 ///
4600 /// * `params` - Cancel an in-flight login flow.
4601 ///
4602 /// <div class="warning">
4603 ///
4604 /// **Experimental.** This API is part of an experimental wire-protocol surface
4605 /// and may change or be removed in future SDK or CLI releases. Pin both the
4606 /// SDK and CLI versions if your code depends on it.
4607 ///
4608 /// </div>
4609 pub async fn cancel(&self, params: AuthLoginCancelRequest) -> Result<(), Error> {
4610 let mut wire_params = serde_json::to_value(params)?;
4611 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4612 let _value = self
4613 .session
4614 .client()
4615 .call(
4616 rpc_methods::SESSION_ACCOUNTS_LOGIN_CANCEL,
4617 Some(wire_params),
4618 )
4619 .await?;
4620 Ok(())
4621 }
4622}
4623
4624/// `session.agent.*` RPCs.
4625#[derive(Clone, Copy)]
4626pub struct SessionRpcAgent<'a> {
4627 pub(crate) session: &'a Session,
4628}
4629
4630impl<'a> SessionRpcAgent<'a> {
4631 /// Lists agents available to the session. Defaults to custom agents only; pass includeBuiltInAgents to include the effective built-in agents.
4632 ///
4633 /// Wire method: `session.agent.list`.
4634 ///
4635 /// # Returns
4636 ///
4637 /// Agents available to the session.
4638 ///
4639 /// <div class="warning">
4640 ///
4641 /// **Experimental.** This API is part of an experimental wire-protocol surface
4642 /// and may change or be removed in future SDK or CLI releases. Pin both the
4643 /// SDK and CLI versions if your code depends on it.
4644 ///
4645 /// </div>
4646 pub async fn list(&self) -> Result<AgentList, Error> {
4647 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
4648 let _value = self
4649 .session
4650 .client()
4651 .call(rpc_methods::SESSION_AGENT_LIST, Some(wire_params))
4652 .await?;
4653 Ok(serde_json::from_value(_value)?)
4654 }
4655
4656 /// Lists agents available to the session. Defaults to custom agents only; pass includeBuiltInAgents to include the effective built-in agents.
4657 ///
4658 /// Wire method: `session.agent.list`.
4659 ///
4660 /// # Parameters
4661 ///
4662 /// * `params` - Controls whether built-in agents and authored prompt text are included.
4663 ///
4664 /// # Returns
4665 ///
4666 /// Agents available to the session.
4667 ///
4668 /// <div class="warning">
4669 ///
4670 /// **Experimental.** This API is part of an experimental wire-protocol surface
4671 /// and may change or be removed in future SDK or CLI releases. Pin both the
4672 /// SDK and CLI versions if your code depends on it.
4673 ///
4674 /// </div>
4675 pub async fn list_with_params(&self, params: AgentListRequest) -> Result<AgentList, Error> {
4676 let mut wire_params = serde_json::to_value(params)?;
4677 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4678 let _value = self
4679 .session
4680 .client()
4681 .call(rpc_methods::SESSION_AGENT_LIST, Some(wire_params))
4682 .await?;
4683 Ok(serde_json::from_value(_value)?)
4684 }
4685
4686 /// 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.
4687 ///
4688 /// Wire method: `session.agent.setPrompt`.
4689 ///
4690 /// # Parameters
4691 ///
4692 /// * `params` - An in-memory authored prompt override for an available agent.
4693 ///
4694 /// <div class="warning">
4695 ///
4696 /// **Experimental.** This API is part of an experimental wire-protocol surface
4697 /// and may change or be removed in future SDK or CLI releases. Pin both the
4698 /// SDK and CLI versions if your code depends on it.
4699 ///
4700 /// </div>
4701 pub async fn set_prompt(&self, params: AgentSetPromptRequest) -> Result<(), Error> {
4702 let mut wire_params = serde_json::to_value(params)?;
4703 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4704 let _value = self
4705 .session
4706 .client()
4707 .call(rpc_methods::SESSION_AGENT_SETPROMPT, Some(wire_params))
4708 .await?;
4709 Ok(())
4710 }
4711
4712 /// Gets the currently selected custom agent for the session.
4713 ///
4714 /// Wire method: `session.agent.getCurrent`.
4715 ///
4716 /// # Returns
4717 ///
4718 /// The currently selected custom agent, or null when using the default agent.
4719 ///
4720 /// <div class="warning">
4721 ///
4722 /// **Experimental.** This API is part of an experimental wire-protocol surface
4723 /// and may change or be removed in future SDK or CLI releases. Pin both the
4724 /// SDK and CLI versions if your code depends on it.
4725 ///
4726 /// </div>
4727 pub async fn get_current(&self) -> Result<AgentGetCurrentResult, Error> {
4728 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
4729 let _value = self
4730 .session
4731 .client()
4732 .call(rpc_methods::SESSION_AGENT_GETCURRENT, Some(wire_params))
4733 .await?;
4734 Ok(serde_json::from_value(_value)?)
4735 }
4736
4737 /// Selects a custom agent for subsequent turns in the session.
4738 ///
4739 /// Wire method: `session.agent.select`.
4740 ///
4741 /// # Parameters
4742 ///
4743 /// * `params` - Name of the custom agent to select for subsequent turns.
4744 ///
4745 /// # Returns
4746 ///
4747 /// The newly selected custom agent.
4748 ///
4749 /// <div class="warning">
4750 ///
4751 /// **Experimental.** This API is part of an experimental wire-protocol surface
4752 /// and may change or be removed in future SDK or CLI releases. Pin both the
4753 /// SDK and CLI versions if your code depends on it.
4754 ///
4755 /// </div>
4756 pub async fn select(&self, params: AgentSelectRequest) -> Result<AgentSelectResult, Error> {
4757 let mut wire_params = serde_json::to_value(params)?;
4758 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4759 let _value = self
4760 .session
4761 .client()
4762 .call(rpc_methods::SESSION_AGENT_SELECT, Some(wire_params))
4763 .await?;
4764 Ok(serde_json::from_value(_value)?)
4765 }
4766
4767 /// Clears the selected custom agent and returns the session to the default agent.
4768 ///
4769 /// Wire method: `session.agent.deselect`.
4770 ///
4771 /// <div class="warning">
4772 ///
4773 /// **Experimental.** This API is part of an experimental wire-protocol surface
4774 /// and may change or be removed in future SDK or CLI releases. Pin both the
4775 /// SDK and CLI versions if your code depends on it.
4776 ///
4777 /// </div>
4778 pub async fn deselect(&self) -> Result<(), Error> {
4779 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
4780 let _value = self
4781 .session
4782 .client()
4783 .call(rpc_methods::SESSION_AGENT_DESELECT, Some(wire_params))
4784 .await?;
4785 Ok(())
4786 }
4787
4788 /// Reloads custom agent definitions and returns the refreshed list.
4789 ///
4790 /// Wire method: `session.agent.reload`.
4791 ///
4792 /// # Returns
4793 ///
4794 /// Custom agents available to the session after reloading definitions from disk.
4795 ///
4796 /// <div class="warning">
4797 ///
4798 /// **Experimental.** This API is part of an experimental wire-protocol surface
4799 /// and may change or be removed in future SDK or CLI releases. Pin both the
4800 /// SDK and CLI versions if your code depends on it.
4801 ///
4802 /// </div>
4803 pub async fn reload(&self) -> Result<AgentReloadResult, Error> {
4804 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
4805 let _value = self
4806 .session
4807 .client()
4808 .call(rpc_methods::SESSION_AGENT_RELOAD, Some(wire_params))
4809 .await?;
4810 Ok(serde_json::from_value(_value)?)
4811 }
4812}
4813
4814/// `session.autopilotObjective.*` RPCs.
4815#[derive(Clone, Copy)]
4816pub struct SessionRpcAutopilotObjective<'a> {
4817 pub(crate) session: &'a Session,
4818}
4819
4820impl<'a> SessionRpcAutopilotObjective<'a> {
4821 /// Reads the current canonical autopilot objective state for this session.
4822 ///
4823 /// Wire method: `session.autopilotObjective.getState`.
4824 ///
4825 /// # Returns
4826 ///
4827 /// Canonical runtime state for the session's current autopilot objective.
4828 ///
4829 /// <div class="warning">
4830 ///
4831 /// **Experimental.** This API is part of an experimental wire-protocol surface
4832 /// and may change or be removed in future SDK or CLI releases. Pin both the
4833 /// SDK and CLI versions if your code depends on it.
4834 ///
4835 /// </div>
4836 pub async fn get_state(&self) -> Result<AutopilotObjectiveGetStateResult, Error> {
4837 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
4838 let _value = self
4839 .session
4840 .client()
4841 .call(
4842 rpc_methods::SESSION_AUTOPILOTOBJECTIVE_GETSTATE,
4843 Some(wire_params),
4844 )
4845 .await?;
4846 Ok(serde_json::from_value(_value)?)
4847 }
4848}
4849
4850/// `session.canvas.*` RPCs.
4851#[derive(Clone, Copy)]
4852pub struct SessionRpcCanvas<'a> {
4853 pub(crate) session: &'a Session,
4854}
4855
4856impl<'a> SessionRpcCanvas<'a> {
4857 /// `session.canvas.action.*` sub-namespace.
4858 pub fn action(&self) -> SessionRpcCanvasAction<'a> {
4859 SessionRpcCanvasAction {
4860 session: self.session,
4861 }
4862 }
4863
4864 /// `session.canvas.provider.*` sub-namespace.
4865 pub fn provider(&self) -> SessionRpcCanvasProvider<'a> {
4866 SessionRpcCanvasProvider {
4867 session: self.session,
4868 }
4869 }
4870
4871 /// Lists canvases declared for the session.
4872 ///
4873 /// Wire method: `session.canvas.list`.
4874 ///
4875 /// # Returns
4876 ///
4877 /// Declared canvases available in this session.
4878 ///
4879 /// <div class="warning">
4880 ///
4881 /// **Experimental.** This API is part of an experimental wire-protocol surface
4882 /// and may change or be removed in future SDK or CLI releases. Pin both the
4883 /// SDK and CLI versions if your code depends on it.
4884 ///
4885 /// </div>
4886 pub async fn list(&self) -> Result<CanvasList, Error> {
4887 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
4888 let _value = self
4889 .session
4890 .client()
4891 .call(rpc_methods::SESSION_CANVAS_LIST, Some(wire_params))
4892 .await?;
4893 Ok(serde_json::from_value(_value)?)
4894 }
4895
4896 /// Lists currently open canvas instances for the live session.
4897 ///
4898 /// Wire method: `session.canvas.listOpen`.
4899 ///
4900 /// # Returns
4901 ///
4902 /// Live open-canvas snapshot.
4903 ///
4904 /// <div class="warning">
4905 ///
4906 /// **Experimental.** This API is part of an experimental wire-protocol surface
4907 /// and may change or be removed in future SDK or CLI releases. Pin both the
4908 /// SDK and CLI versions if your code depends on it.
4909 ///
4910 /// </div>
4911 pub async fn list_open(&self) -> Result<CanvasListOpenResult, Error> {
4912 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
4913 let _value = self
4914 .session
4915 .client()
4916 .call(rpc_methods::SESSION_CANVAS_LISTOPEN, Some(wire_params))
4917 .await?;
4918 Ok(serde_json::from_value(_value)?)
4919 }
4920
4921 /// Opens or focuses a canvas instance.
4922 ///
4923 /// Wire method: `session.canvas.open`.
4924 ///
4925 /// # Parameters
4926 ///
4927 /// * `params` - Canvas open parameters.
4928 ///
4929 /// # Returns
4930 ///
4931 /// Open canvas instance snapshot.
4932 ///
4933 /// <div class="warning">
4934 ///
4935 /// **Experimental.** This API is part of an experimental wire-protocol surface
4936 /// and may change or be removed in future SDK or CLI releases. Pin both the
4937 /// SDK and CLI versions if your code depends on it.
4938 ///
4939 /// </div>
4940 pub async fn open(&self, params: CanvasOpenRequest) -> Result<OpenCanvasInstance, Error> {
4941 let mut wire_params = serde_json::to_value(params)?;
4942 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4943 let _value = self
4944 .session
4945 .client()
4946 .call(rpc_methods::SESSION_CANVAS_OPEN, Some(wire_params))
4947 .await?;
4948 Ok(serde_json::from_value(_value)?)
4949 }
4950
4951 /// Closes an open canvas instance.
4952 ///
4953 /// Wire method: `session.canvas.close`.
4954 ///
4955 /// # Parameters
4956 ///
4957 /// * `params` - Canvas close parameters.
4958 ///
4959 /// <div class="warning">
4960 ///
4961 /// **Experimental.** This API is part of an experimental wire-protocol surface
4962 /// and may change or be removed in future SDK or CLI releases. Pin both the
4963 /// SDK and CLI versions if your code depends on it.
4964 ///
4965 /// </div>
4966 pub async fn close(&self, params: CanvasCloseRequest) -> Result<(), Error> {
4967 let mut wire_params = serde_json::to_value(params)?;
4968 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4969 let _value = self
4970 .session
4971 .client()
4972 .call(rpc_methods::SESSION_CANVAS_CLOSE, Some(wire_params))
4973 .await?;
4974 Ok(())
4975 }
4976}
4977
4978/// `session.canvas.action.*` RPCs.
4979#[derive(Clone, Copy)]
4980pub struct SessionRpcCanvasAction<'a> {
4981 pub(crate) session: &'a Session,
4982}
4983
4984impl<'a> SessionRpcCanvasAction<'a> {
4985 /// Invokes an action on an open canvas instance.
4986 ///
4987 /// Wire method: `session.canvas.action.invoke`.
4988 ///
4989 /// # Parameters
4990 ///
4991 /// * `params` - Canvas action invocation parameters.
4992 ///
4993 /// # Returns
4994 ///
4995 /// Canvas action invocation result.
4996 ///
4997 /// <div class="warning">
4998 ///
4999 /// **Experimental.** This API is part of an experimental wire-protocol surface
5000 /// and may change or be removed in future SDK or CLI releases. Pin both the
5001 /// SDK and CLI versions if your code depends on it.
5002 ///
5003 /// </div>
5004 pub async fn invoke(
5005 &self,
5006 params: CanvasActionInvokeRequest,
5007 ) -> Result<CanvasActionInvokeResult, Error> {
5008 let mut wire_params = serde_json::to_value(params)?;
5009 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5010 let _value = self
5011 .session
5012 .client()
5013 .call(rpc_methods::SESSION_CANVAS_ACTION_INVOKE, Some(wire_params))
5014 .await?;
5015 Ok(serde_json::from_value(_value)?)
5016 }
5017}
5018
5019/// `session.canvas.provider.*` RPCs.
5020#[derive(Clone, Copy)]
5021pub struct SessionRpcCanvasProvider<'a> {
5022 pub(crate) session: &'a Session,
5023}
5024
5025impl<'a> SessionRpcCanvasProvider<'a> {
5026 /// Registers an internal canvas provider connection and its contributions.
5027 ///
5028 /// Wire method: `session.canvas.provider.register`.
5029 ///
5030 /// # Parameters
5031 ///
5032 /// * `params` - Internal canvas provider registration parameters.
5033 ///
5034 /// <div class="warning">
5035 ///
5036 /// **Experimental.** This API is part of an experimental wire-protocol surface
5037 /// and may change or be removed in future SDK or CLI releases. Pin both the
5038 /// SDK and CLI versions if your code depends on it.
5039 ///
5040 /// </div>
5041 pub(crate) async fn register(
5042 &self,
5043 params: CanvasProviderRegisterRequest,
5044 ) -> Result<(), Error> {
5045 let mut wire_params = serde_json::to_value(params)?;
5046 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5047 let _value = self
5048 .session
5049 .client()
5050 .call(
5051 rpc_methods::SESSION_CANVAS_PROVIDER_REGISTER,
5052 Some(wire_params),
5053 )
5054 .await?;
5055 Ok(())
5056 }
5057
5058 /// Unregisters an internal canvas provider connection.
5059 ///
5060 /// Wire method: `session.canvas.provider.unregister`.
5061 ///
5062 /// # Parameters
5063 ///
5064 /// * `params` - Internal canvas provider unregistration parameters.
5065 ///
5066 /// <div class="warning">
5067 ///
5068 /// **Experimental.** This API is part of an experimental wire-protocol surface
5069 /// and may change or be removed in future SDK or CLI releases. Pin both the
5070 /// SDK and CLI versions if your code depends on it.
5071 ///
5072 /// </div>
5073 pub(crate) async fn unregister(
5074 &self,
5075 params: CanvasProviderUnregisterRequest,
5076 ) -> Result<(), Error> {
5077 let mut wire_params = serde_json::to_value(params)?;
5078 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5079 let _value = self
5080 .session
5081 .client()
5082 .call(
5083 rpc_methods::SESSION_CANVAS_PROVIDER_UNREGISTER,
5084 Some(wire_params),
5085 )
5086 .await?;
5087 Ok(())
5088 }
5089}
5090
5091/// `session.commands.*` RPCs.
5092#[derive(Clone, Copy)]
5093pub struct SessionRpcCommands<'a> {
5094 pub(crate) session: &'a Session,
5095}
5096
5097impl<'a> SessionRpcCommands<'a> {
5098 /// Lists slash commands available in the session.
5099 ///
5100 /// Wire method: `session.commands.list`.
5101 ///
5102 /// # Returns
5103 ///
5104 /// Slash commands available in the session, after applying any include/exclude filters.
5105 ///
5106 /// <div class="warning">
5107 ///
5108 /// **Experimental.** This API is part of an experimental wire-protocol surface
5109 /// and may change or be removed in future SDK or CLI releases. Pin both the
5110 /// SDK and CLI versions if your code depends on it.
5111 ///
5112 /// </div>
5113 pub async fn list(&self) -> Result<CommandList, Error> {
5114 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5115 let _value = self
5116 .session
5117 .client()
5118 .call(rpc_methods::SESSION_COMMANDS_LIST, Some(wire_params))
5119 .await?;
5120 Ok(serde_json::from_value(_value)?)
5121 }
5122
5123 /// Lists slash commands available in the session.
5124 ///
5125 /// Wire method: `session.commands.list`.
5126 ///
5127 /// # Parameters
5128 ///
5129 /// * `params` - Optional filters controlling which command sources to include in the listing.
5130 ///
5131 /// # Returns
5132 ///
5133 /// Slash commands available in the session, after applying any include/exclude filters.
5134 ///
5135 /// <div class="warning">
5136 ///
5137 /// **Experimental.** This API is part of an experimental wire-protocol surface
5138 /// and may change or be removed in future SDK or CLI releases. Pin both the
5139 /// SDK and CLI versions if your code depends on it.
5140 ///
5141 /// </div>
5142 pub async fn list_with_params(
5143 &self,
5144 params: CommandsListRequest,
5145 ) -> Result<CommandList, Error> {
5146 let mut wire_params = serde_json::to_value(params)?;
5147 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5148 let _value = self
5149 .session
5150 .client()
5151 .call(rpc_methods::SESSION_COMMANDS_LIST, Some(wire_params))
5152 .await?;
5153 Ok(serde_json::from_value(_value)?)
5154 }
5155
5156 /// Invokes a slash command in the session.
5157 ///
5158 /// Wire method: `session.commands.invoke`.
5159 ///
5160 /// # Parameters
5161 ///
5162 /// * `params` - Slash command name and optional raw input string to invoke.
5163 ///
5164 /// # Returns
5165 ///
5166 /// Result of invoking the slash command (text output, prompt to send to the agent, completion, or subcommand selection).
5167 ///
5168 /// <div class="warning">
5169 ///
5170 /// **Experimental.** This API is part of an experimental wire-protocol surface
5171 /// and may change or be removed in future SDK or CLI releases. Pin both the
5172 /// SDK and CLI versions if your code depends on it.
5173 ///
5174 /// </div>
5175 pub async fn invoke(
5176 &self,
5177 params: CommandsInvokeRequest,
5178 ) -> Result<SlashCommandInvocationResult, Error> {
5179 let mut wire_params = serde_json::to_value(params)?;
5180 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5181 let _value = self
5182 .session
5183 .client()
5184 .call(rpc_methods::SESSION_COMMANDS_INVOKE, Some(wire_params))
5185 .await?;
5186 Ok(serde_json::from_value(_value)?)
5187 }
5188
5189 /// Finalizes persistence associated with a client-applied slash-command effect.
5190 ///
5191 /// Wire method: `session.commands.finalizeInvocationEffect`.
5192 ///
5193 /// # Parameters
5194 ///
5195 /// * `params` - The pending slash-command invocation effect to finalize, plus whether the host applied or cancelled it.
5196 ///
5197 /// # Returns
5198 ///
5199 /// Whether finalizing the invocation effect succeeded, and the failure reason when it did not.
5200 ///
5201 /// <div class="warning">
5202 ///
5203 /// **Experimental.** This API is part of an experimental wire-protocol surface
5204 /// and may change or be removed in future SDK or CLI releases. Pin both the
5205 /// SDK and CLI versions if your code depends on it.
5206 ///
5207 /// </div>
5208 pub(crate) async fn finalize_invocation_effect(
5209 &self,
5210 params: CommandsFinalizeInvocationEffectRequest,
5211 ) -> Result<CommandsFinalizeInvocationEffectResult, Error> {
5212 let mut wire_params = serde_json::to_value(params)?;
5213 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5214 let _value = self
5215 .session
5216 .client()
5217 .call(
5218 rpc_methods::SESSION_COMMANDS_FINALIZEINVOCATIONEFFECT,
5219 Some(wire_params),
5220 )
5221 .await?;
5222 Ok(serde_json::from_value(_value)?)
5223 }
5224
5225 /// Reports completion of a pending client-handled slash command.
5226 ///
5227 /// Wire method: `session.commands.handlePendingCommand`.
5228 ///
5229 /// # Parameters
5230 ///
5231 /// * `params` - Pending command request ID and an optional error if the client handler failed.
5232 ///
5233 /// # Returns
5234 ///
5235 /// Indicates whether the pending client-handled command was completed successfully.
5236 ///
5237 /// <div class="warning">
5238 ///
5239 /// **Experimental.** This API is part of an experimental wire-protocol surface
5240 /// and may change or be removed in future SDK or CLI releases. Pin both the
5241 /// SDK and CLI versions if your code depends on it.
5242 ///
5243 /// </div>
5244 pub async fn handle_pending_command(
5245 &self,
5246 params: CommandsHandlePendingCommandRequest,
5247 ) -> Result<CommandsHandlePendingCommandResult, Error> {
5248 let mut wire_params = serde_json::to_value(params)?;
5249 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5250 let _value = self
5251 .session
5252 .client()
5253 .call(
5254 rpc_methods::SESSION_COMMANDS_HANDLEPENDINGCOMMAND,
5255 Some(wire_params),
5256 )
5257 .await?;
5258 Ok(serde_json::from_value(_value)?)
5259 }
5260
5261 /// Executes a slash command synchronously and returns any error.
5262 ///
5263 /// Wire method: `session.commands.execute`.
5264 ///
5265 /// # Parameters
5266 ///
5267 /// * `params` - Slash command name and argument string to execute synchronously.
5268 ///
5269 /// # Returns
5270 ///
5271 /// Error message produced while executing the command, if any.
5272 ///
5273 /// <div class="warning">
5274 ///
5275 /// **Experimental.** This API is part of an experimental wire-protocol surface
5276 /// and may change or be removed in future SDK or CLI releases. Pin both the
5277 /// SDK and CLI versions if your code depends on it.
5278 ///
5279 /// </div>
5280 pub async fn execute(
5281 &self,
5282 params: ExecuteCommandParams,
5283 ) -> Result<ExecuteCommandResult, Error> {
5284 let mut wire_params = serde_json::to_value(params)?;
5285 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5286 let _value = self
5287 .session
5288 .client()
5289 .call(rpc_methods::SESSION_COMMANDS_EXECUTE, Some(wire_params))
5290 .await?;
5291 Ok(serde_json::from_value(_value)?)
5292 }
5293
5294 /// Enqueues a slash command for FIFO processing on the local session.
5295 ///
5296 /// Wire method: `session.commands.enqueue`.
5297 ///
5298 /// # Parameters
5299 ///
5300 /// * `params` - Slash-prefixed command string to enqueue for FIFO processing.
5301 ///
5302 /// # Returns
5303 ///
5304 /// Indicates whether the command was accepted into the local execution queue.
5305 ///
5306 /// <div class="warning">
5307 ///
5308 /// **Experimental.** This API is part of an experimental wire-protocol surface
5309 /// and may change or be removed in future SDK or CLI releases. Pin both the
5310 /// SDK and CLI versions if your code depends on it.
5311 ///
5312 /// </div>
5313 pub async fn enqueue(
5314 &self,
5315 params: EnqueueCommandParams,
5316 ) -> Result<EnqueueCommandResult, Error> {
5317 let mut wire_params = serde_json::to_value(params)?;
5318 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5319 let _value = self
5320 .session
5321 .client()
5322 .call(rpc_methods::SESSION_COMMANDS_ENQUEUE, Some(wire_params))
5323 .await?;
5324 Ok(serde_json::from_value(_value)?)
5325 }
5326
5327 /// Reports whether the host actually executed a queued command and whether to continue processing.
5328 ///
5329 /// Wire method: `session.commands.respondToQueuedCommand`.
5330 ///
5331 /// # Parameters
5332 ///
5333 /// * `params` - Queued-command request ID and the result indicating whether the host executed it (and whether to stop processing further queued commands).
5334 ///
5335 /// # Returns
5336 ///
5337 /// Indicates whether the queued-command response was matched to a pending request.
5338 ///
5339 /// <div class="warning">
5340 ///
5341 /// **Experimental.** This API is part of an experimental wire-protocol surface
5342 /// and may change or be removed in future SDK or CLI releases. Pin both the
5343 /// SDK and CLI versions if your code depends on it.
5344 ///
5345 /// </div>
5346 pub async fn respond_to_queued_command(
5347 &self,
5348 params: CommandsRespondToQueuedCommandRequest,
5349 ) -> Result<CommandsRespondToQueuedCommandResult, Error> {
5350 let mut wire_params = serde_json::to_value(params)?;
5351 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5352 let _value = self
5353 .session
5354 .client()
5355 .call(
5356 rpc_methods::SESSION_COMMANDS_RESPONDTOQUEUEDCOMMAND,
5357 Some(wire_params),
5358 )
5359 .await?;
5360 Ok(serde_json::from_value(_value)?)
5361 }
5362}
5363
5364/// `session.completions.*` RPCs.
5365#[derive(Clone, Copy)]
5366pub struct SessionRpcCompletions<'a> {
5367 pub(crate) session: &'a Session,
5368}
5369
5370impl<'a> SessionRpcCompletions<'a> {
5371 /// 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).
5372 ///
5373 /// Wire method: `session.completions.getTriggerCharacters`.
5374 ///
5375 /// # Returns
5376 ///
5377 /// 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`).
5378 ///
5379 /// <div class="warning">
5380 ///
5381 /// **Experimental.** This API is part of an experimental wire-protocol surface
5382 /// and may change or be removed in future SDK or CLI releases. Pin both the
5383 /// SDK and CLI versions if your code depends on it.
5384 ///
5385 /// </div>
5386 pub async fn get_trigger_characters(
5387 &self,
5388 ) -> Result<CompletionsGetTriggerCharactersResult, Error> {
5389 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5390 let _value = self
5391 .session
5392 .client()
5393 .call(
5394 rpc_methods::SESSION_COMPLETIONS_GETTRIGGERCHARACTERS,
5395 Some(wire_params),
5396 )
5397 .await?;
5398 Ok(serde_json::from_value(_value)?)
5399 }
5400
5401 /// 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.
5402 ///
5403 /// Wire method: `session.completions.request`.
5404 ///
5405 /// # Parameters
5406 ///
5407 /// * `params` - Request host-driven completions for the current composer input.
5408 ///
5409 /// # Returns
5410 ///
5411 /// Host-driven completion items for the current composer input. Empty when the host returns no items or does not support completions.
5412 ///
5413 /// <div class="warning">
5414 ///
5415 /// **Experimental.** This API is part of an experimental wire-protocol surface
5416 /// and may change or be removed in future SDK or CLI releases. Pin both the
5417 /// SDK and CLI versions if your code depends on it.
5418 ///
5419 /// </div>
5420 pub async fn request(
5421 &self,
5422 params: CompletionsRequestRequest,
5423 ) -> Result<CompletionsRequestResult, Error> {
5424 let mut wire_params = serde_json::to_value(params)?;
5425 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5426 let _value = self
5427 .session
5428 .client()
5429 .call(rpc_methods::SESSION_COMPLETIONS_REQUEST, Some(wire_params))
5430 .await?;
5431 Ok(serde_json::from_value(_value)?)
5432 }
5433}
5434
5435/// `session.connectors.*` RPCs.
5436#[derive(Clone, Copy)]
5437pub struct SessionRpcConnectors<'a> {
5438 pub(crate) session: &'a Session,
5439}
5440
5441impl<'a> SessionRpcConnectors<'a> {
5442 /// Returns feature availability and bounded polling limits for the EXPERIMENTAL session connector API. This method never performs a Connector service request.
5443 ///
5444 /// Wire method: `session.connectors.getCapabilities`.
5445 ///
5446 /// # Returns
5447 ///
5448 /// Feature detection and hard polling limits for the EXPERIMENTAL session connector API.
5449 ///
5450 /// <div class="warning">
5451 ///
5452 /// **Experimental.** This API is part of an experimental wire-protocol surface
5453 /// and may change or be removed in future SDK or CLI releases. Pin both the
5454 /// SDK and CLI versions if your code depends on it.
5455 ///
5456 /// </div>
5457 pub async fn get_capabilities(&self) -> Result<ConnectorCapabilities, Error> {
5458 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5459 let _value = self
5460 .session
5461 .client()
5462 .call(
5463 rpc_methods::SESSION_CONNECTORS_GETCAPABILITIES,
5464 Some(wire_params),
5465 )
5466 .await?;
5467 Ok(serde_json::from_value(_value)?)
5468 }
5469
5470 /// Returns authoritative session Connector state from current availability, pinned account selection, cached catalog, and live MCP projection without performing a Connector service request.
5471 ///
5472 /// Wire method: `session.connectors.getStatus`.
5473 ///
5474 /// # Returns
5475 ///
5476 /// Authoritative session connector state. Account IDs are opaque routing identifiers and credentials are never included.
5477 ///
5478 /// <div class="warning">
5479 ///
5480 /// **Experimental.** This API is part of an experimental wire-protocol surface
5481 /// and may change or be removed in future SDK or CLI releases. Pin both the
5482 /// SDK and CLI versions if your code depends on it.
5483 ///
5484 /// </div>
5485 pub async fn get_status(&self) -> Result<ConnectorStatus, Error> {
5486 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5487 let _value = self
5488 .session
5489 .client()
5490 .call(rpc_methods::SESSION_CONNECTORS_GETSTATUS, Some(wire_params))
5491 .await?;
5492 Ok(serde_json::from_value(_value)?)
5493 }
5494
5495 /// Returns the cached Connector catalog for the pinned opaque account selection, fetching it only when this session has no cached catalog.
5496 ///
5497 /// Wire method: `session.connectors.list`.
5498 ///
5499 /// # Parameters
5500 ///
5501 /// * `params` - Pins a Connector operation to one host-owned GitHub account through its opaque selection ID. Provider tokens are never accepted.
5502 ///
5503 /// # Returns
5504 ///
5505 /// Validated Connector catalog snapshot cached by the session.
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 async fn list(
5515 &self,
5516 params: ConnectorAccountRequest,
5517 ) -> Result<ConnectorCatalogResult, 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(rpc_methods::SESSION_CONNECTORS_LIST, Some(wire_params))
5524 .await?;
5525 Ok(serde_json::from_value(_value)?)
5526 }
5527
5528 /// Refreshes and validates the Connector catalog for the pinned opaque account selection.
5529 ///
5530 /// Wire method: `session.connectors.refresh`.
5531 ///
5532 /// # Parameters
5533 ///
5534 /// * `params` - Pins a Connector operation to one host-owned GitHub account through its opaque selection ID. Provider tokens are never accepted.
5535 ///
5536 /// # Returns
5537 ///
5538 /// Validated Connector catalog snapshot cached by the session.
5539 ///
5540 /// <div class="warning">
5541 ///
5542 /// **Experimental.** This API is part of an experimental wire-protocol surface
5543 /// and may change or be removed in future SDK or CLI releases. Pin both the
5544 /// SDK and CLI versions if your code depends on it.
5545 ///
5546 /// </div>
5547 pub async fn refresh(
5548 &self,
5549 params: ConnectorAccountRequest,
5550 ) -> Result<ConnectorCatalogResult, 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_CONNECTORS_REFRESH, Some(wire_params))
5557 .await?;
5558 Ok(serde_json::from_value(_value)?)
5559 }
5560
5561 /// 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.
5562 ///
5563 /// Wire method: `session.connectors.connect`.
5564 ///
5565 /// # Parameters
5566 ///
5567 /// * `params` - Selects one Connector and the pinned host-owned account used for its service and MCP authorization.
5568 ///
5569 /// # Returns
5570 ///
5571 /// Typed result of initiating or continuing a Connector connection.
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 connect(
5581 &self,
5582 params: ConnectorConnectRequest,
5583 ) -> Result<ConnectorConnectResult, 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_CONNECTORS_CONNECT, Some(wire_params))
5590 .await?;
5591 Ok(serde_json::from_value(_value)?)
5592 }
5593
5594 /// Re-initiates an idempotent Connector connection request without browser or UI effects, with the same typed outcomes as connect.
5595 ///
5596 /// Wire method: `session.connectors.reconnect`.
5597 ///
5598 /// # Parameters
5599 ///
5600 /// * `params` - Selects one Connector and the pinned host-owned account used for its service and MCP authorization.
5601 ///
5602 /// # Returns
5603 ///
5604 /// Typed result of initiating or continuing a Connector connection.
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 reconnect(
5614 &self,
5615 params: ConnectorConnectRequest,
5616 ) -> Result<ConnectorConnectResult, 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_CONNECTORS_RECONNECT, Some(wire_params))
5623 .await?;
5624 Ok(serde_json::from_value(_value)?)
5625 }
5626
5627 /// Continues a pending Connector connection with caller-supplied attempt, interval, and deadline bounds. The runtime never opens the returned consent URL.
5628 ///
5629 /// Wire method: `session.connectors.continueConnection`.
5630 ///
5631 /// # Parameters
5632 ///
5633 /// * `params` - Explicitly bounded continuation of a pending Connector connection.
5634 ///
5635 /// # Returns
5636 ///
5637 /// Typed result of initiating or continuing a Connector connection.
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 continue_connection(
5647 &self,
5648 params: ConnectorContinueRequest,
5649 ) -> Result<ConnectorConnectResult, 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_CONNECTORS_CONTINUECONNECTION,
5657 Some(wire_params),
5658 )
5659 .await?;
5660 Ok(serde_json::from_value(_value)?)
5661 }
5662
5663 /// Disconnects one Connector for the pinned opaque account selection, refreshes the authoritative catalog, and removes its session-owned MCP projection.
5664 ///
5665 /// Wire method: `session.connectors.disconnect`.
5666 ///
5667 /// # Parameters
5668 ///
5669 /// * `params` - Selects one Connector and the pinned host-owned account used for its service and MCP authorization.
5670 ///
5671 /// # Returns
5672 ///
5673 /// Authoritative result after disconnect and MCP reconciliation.
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 disconnect(
5683 &self,
5684 params: ConnectorConnectRequest,
5685 ) -> Result<ConnectorDisconnectResult, Error> {
5686 let mut wire_params = serde_json::to_value(params)?;
5687 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5688 let _value = self
5689 .session
5690 .client()
5691 .call(
5692 rpc_methods::SESSION_CONNECTORS_DISCONNECT,
5693 Some(wire_params),
5694 )
5695 .await?;
5696 Ok(serde_json::from_value(_value)?)
5697 }
5698
5699 /// Reconciles the authoritative cached or freshly requested Connector catalog into the session Connector MCP projection and returns live status.
5700 ///
5701 /// Wire method: `session.connectors.reconcile`.
5702 ///
5703 /// # Parameters
5704 ///
5705 /// * `params` - Requests authoritative Connector-to-MCP reconciliation for the pinned account.
5706 ///
5707 /// # Returns
5708 ///
5709 /// Authoritative session connector state. Account IDs are opaque routing identifiers and credentials are never included.
5710 ///
5711 /// <div class="warning">
5712 ///
5713 /// **Experimental.** This API is part of an experimental wire-protocol surface
5714 /// and may change or be removed in future SDK or CLI releases. Pin both the
5715 /// SDK and CLI versions if your code depends on it.
5716 ///
5717 /// </div>
5718 pub async fn reconcile(
5719 &self,
5720 params: ConnectorReconcileRequest,
5721 ) -> Result<ConnectorStatus, Error> {
5722 let mut wire_params = serde_json::to_value(params)?;
5723 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5724 let _value = self
5725 .session
5726 .client()
5727 .call(rpc_methods::SESSION_CONNECTORS_RECONCILE, Some(wire_params))
5728 .await?;
5729 Ok(serde_json::from_value(_value)?)
5730 }
5731
5732 /// Reconciles the authoritative Connector catalog into the session MCP projection during startup with a bounded deadline and fail-closed cleanup.
5733 ///
5734 /// Wire method: `session.connectors.reconcileForStartup`.
5735 ///
5736 /// # Parameters
5737 ///
5738 /// * `params` - Pins a Connector operation to one host-owned GitHub account through its opaque selection ID. Provider tokens are never accepted.
5739 ///
5740 /// # Returns
5741 ///
5742 /// Authoritative session connector state. Account IDs are opaque routing identifiers and credentials are never included.
5743 ///
5744 /// <div class="warning">
5745 ///
5746 /// **Experimental.** This API is part of an experimental wire-protocol surface
5747 /// and may change or be removed in future SDK or CLI releases. Pin both the
5748 /// SDK and CLI versions if your code depends on it.
5749 ///
5750 /// </div>
5751 pub(crate) async fn reconcile_for_startup(
5752 &self,
5753 params: ConnectorAccountRequest,
5754 ) -> Result<ConnectorStatus, Error> {
5755 let mut wire_params = serde_json::to_value(params)?;
5756 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5757 let _value = self
5758 .session
5759 .client()
5760 .call(
5761 rpc_methods::SESSION_CONNECTORS_RECONCILEFORSTARTUP,
5762 Some(wire_params),
5763 )
5764 .await?;
5765 Ok(serde_json::from_value(_value)?)
5766 }
5767
5768 /// Removes the runtime-owned Connector MCP projection without changing service-side connections.
5769 ///
5770 /// Wire method: `session.connectors.withdrawProjection`.
5771 ///
5772 /// # Returns
5773 ///
5774 /// Authoritative session connector state. Account IDs are opaque routing identifiers and credentials are never included.
5775 ///
5776 /// <div class="warning">
5777 ///
5778 /// **Experimental.** This API is part of an experimental wire-protocol surface
5779 /// and may change or be removed in future SDK or CLI releases. Pin both the
5780 /// SDK and CLI versions if your code depends on it.
5781 ///
5782 /// </div>
5783 pub(crate) async fn withdraw_projection(&self) -> Result<ConnectorStatus, Error> {
5784 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5785 let _value = self
5786 .session
5787 .client()
5788 .call(
5789 rpc_methods::SESSION_CONNECTORS_WITHDRAWPROJECTION,
5790 Some(wire_params),
5791 )
5792 .await?;
5793 Ok(serde_json::from_value(_value)?)
5794 }
5795}
5796
5797/// `session.contentExclusion.*` RPCs.
5798#[derive(Clone, Copy)]
5799pub struct SessionRpcContentExclusion<'a> {
5800 pub(crate) session: &'a Session,
5801}
5802
5803impl<'a> SessionRpcContentExclusion<'a> {
5804 /// 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.
5805 ///
5806 /// Wire method: `session.contentExclusion.checkPaths`.
5807 ///
5808 /// # Parameters
5809 ///
5810 /// * `params` - Local file system absolute paths within the session working directory to check against its content-exclusion policy.
5811 ///
5812 /// # Returns
5813 ///
5814 /// Batch content-exclusion result. Callers must fail closed when policy evaluation is unavailable.
5815 ///
5816 /// <div class="warning">
5817 ///
5818 /// **Experimental.** This API is part of an experimental wire-protocol surface
5819 /// and may change or be removed in future SDK or CLI releases. Pin both the
5820 /// SDK and CLI versions if your code depends on it.
5821 ///
5822 /// </div>
5823 pub async fn check_paths(
5824 &self,
5825 params: ContentExclusionCheckPathsRequest,
5826 ) -> Result<ContentExclusionCheckPathsResult, Error> {
5827 let mut wire_params = serde_json::to_value(params)?;
5828 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5829 let _value = self
5830 .session
5831 .client()
5832 .call(
5833 rpc_methods::SESSION_CONTENTEXCLUSION_CHECKPATHS,
5834 Some(wire_params),
5835 )
5836 .await?;
5837 Ok(serde_json::from_value(_value)?)
5838 }
5839}
5840
5841/// `session.customizations.*` RPCs.
5842#[derive(Clone, Copy)]
5843pub struct SessionRpcCustomizations<'a> {
5844 pub(crate) session: &'a Session,
5845}
5846
5847impl<'a> SessionRpcCustomizations<'a> {
5848 /// 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.
5849 ///
5850 /// Wire method: `session.customizations.reload`.
5851 ///
5852 /// # Returns
5853 ///
5854 /// Diagnostics from reloading skill definitions, with warnings and errors as separate lists.
5855 ///
5856 /// <div class="warning">
5857 ///
5858 /// **Experimental.** This API is part of an experimental wire-protocol surface
5859 /// and may change or be removed in future SDK or CLI releases. Pin both the
5860 /// SDK and CLI versions if your code depends on it.
5861 ///
5862 /// </div>
5863 pub async fn reload(&self) -> Result<SkillsLoadDiagnostics, Error> {
5864 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5865 let _value = self
5866 .session
5867 .client()
5868 .call(
5869 rpc_methods::SESSION_CUSTOMIZATIONS_RELOAD,
5870 Some(wire_params),
5871 )
5872 .await?;
5873 Ok(serde_json::from_value(_value)?)
5874 }
5875}
5876
5877/// `session.debug.*` RPCs.
5878#[derive(Clone, Copy)]
5879pub struct SessionRpcDebug<'a> {
5880 pub(crate) session: &'a Session,
5881}
5882
5883impl<'a> SessionRpcDebug<'a> {
5884 /// 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.
5885 ///
5886 /// Wire method: `session.debug.collectLogs`.
5887 ///
5888 /// # Parameters
5889 ///
5890 /// * `params` - Options for collecting a session debug bundle with configurable redaction.
5891 ///
5892 /// # Returns
5893 ///
5894 /// Result of collecting a session debug bundle.
5895 ///
5896 /// <div class="warning">
5897 ///
5898 /// **Experimental.** This API is part of an experimental wire-protocol surface
5899 /// and may change or be removed in future SDK or CLI releases. Pin both the
5900 /// SDK and CLI versions if your code depends on it.
5901 ///
5902 /// </div>
5903 pub async fn collect_logs(
5904 &self,
5905 params: DebugCollectLogsRequest,
5906 ) -> Result<DebugCollectLogsResult, Error> {
5907 let mut wire_params = serde_json::to_value(params)?;
5908 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5909 let _value = self
5910 .session
5911 .client()
5912 .call(rpc_methods::SESSION_DEBUG_COLLECTLOGS, Some(wire_params))
5913 .await?;
5914 Ok(serde_json::from_value(_value)?)
5915 }
5916}
5917
5918/// `session.diagnostics.*` RPCs.
5919#[derive(Clone, Copy)]
5920pub struct SessionRpcDiagnostics<'a> {
5921 pub(crate) session: &'a Session,
5922}
5923
5924impl<'a> SessionRpcDiagnostics<'a> {
5925 /// 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.
5926 ///
5927 /// Wire method: `session.diagnostics.configure`.
5928 ///
5929 /// # Parameters
5930 ///
5931 /// * `params` - Patch session diagnostic thresholds for explicitly supplied sources.
5932 ///
5933 /// # Returns
5934 ///
5935 /// Per-source session diagnostics configuration.
5936 ///
5937 /// <div class="warning">
5938 ///
5939 /// **Experimental.** This API is part of an experimental wire-protocol surface
5940 /// and may change or be removed in future SDK or CLI releases. Pin both the
5941 /// SDK and CLI versions if your code depends on it.
5942 ///
5943 /// </div>
5944 pub async fn configure(
5945 &self,
5946 params: DiagnosticsConfigureRequest,
5947 ) -> Result<DiagnosticsConfiguration, Error> {
5948 let mut wire_params = serde_json::to_value(params)?;
5949 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5950 let _value = self
5951 .session
5952 .client()
5953 .call(
5954 rpc_methods::SESSION_DIAGNOSTICS_CONFIGURE,
5955 Some(wire_params),
5956 )
5957 .await?;
5958 Ok(serde_json::from_value(_value)?)
5959 }
5960
5961 /// 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.
5962 ///
5963 /// Wire method: `session.diagnostics.read`.
5964 ///
5965 /// # Parameters
5966 ///
5967 /// * `params` - Cursor-based request for session diagnostics. The default limit is 100 (maximum 500); the default waitMs is zero (maximum 30000).
5968 ///
5969 /// # Returns
5970 ///
5971 /// One cursor-addressed page of retained session diagnostics.
5972 ///
5973 /// <div class="warning">
5974 ///
5975 /// **Experimental.** This API is part of an experimental wire-protocol surface
5976 /// and may change or be removed in future SDK or CLI releases. Pin both the
5977 /// SDK and CLI versions if your code depends on it.
5978 ///
5979 /// </div>
5980 pub async fn read(
5981 &self,
5982 params: DiagnosticsReadRequest,
5983 ) -> Result<DiagnosticsReadResult, Error> {
5984 let mut wire_params = serde_json::to_value(params)?;
5985 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5986 let _value = self
5987 .session
5988 .client()
5989 .call(rpc_methods::SESSION_DIAGNOSTICS_READ, Some(wire_params))
5990 .await?;
5991 Ok(serde_json::from_value(_value)?)
5992 }
5993}
5994
5995/// `session.eventLog.*` RPCs.
5996#[derive(Clone, Copy)]
5997pub struct SessionRpcEventLog<'a> {
5998 pub(crate) session: &'a Session,
5999}
6000
6001impl<'a> SessionRpcEventLog<'a> {
6002 /// Reads a batch of session events from a cursor, optionally waiting for new events. Supports tail-first reads via `direction: backward`.
6003 ///
6004 /// Wire method: `session.eventLog.read`.
6005 ///
6006 /// # Parameters
6007 ///
6008 /// * `params` - Cursor, batch size, and optional long-poll/filter parameters for reading session events.
6009 ///
6010 /// # Returns
6011 ///
6012 /// Batch of session events returned by a read, with cursor and continuation metadata.
6013 ///
6014 /// <div class="warning">
6015 ///
6016 /// **Experimental.** This API is part of an experimental wire-protocol surface
6017 /// and may change or be removed in future SDK or CLI releases. Pin both the
6018 /// SDK and CLI versions if your code depends on it.
6019 ///
6020 /// </div>
6021 pub async fn read(&self, params: EventLogReadRequest) -> Result<EventsReadResult, Error> {
6022 let mut wire_params = serde_json::to_value(params)?;
6023 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6024 let _value = self
6025 .session
6026 .client()
6027 .call(rpc_methods::SESSION_EVENTLOG_READ, Some(wire_params))
6028 .await?;
6029 Ok(serde_json::from_value(_value)?)
6030 }
6031
6032 /// Returns a snapshot of the current tail cursor without consuming events.
6033 ///
6034 /// Wire method: `session.eventLog.tail`.
6035 ///
6036 /// # Returns
6037 ///
6038 /// 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).
6039 ///
6040 /// <div class="warning">
6041 ///
6042 /// **Experimental.** This API is part of an experimental wire-protocol surface
6043 /// and may change or be removed in future SDK or CLI releases. Pin both the
6044 /// SDK and CLI versions if your code depends on it.
6045 ///
6046 /// </div>
6047 pub async fn tail(&self) -> Result<EventLogTailResult, Error> {
6048 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6049 let _value = self
6050 .session
6051 .client()
6052 .call(rpc_methods::SESSION_EVENTLOG_TAIL, Some(wire_params))
6053 .await?;
6054 Ok(serde_json::from_value(_value)?)
6055 }
6056
6057 /// Registers consumer interest in an event type for runtime gating purposes.
6058 ///
6059 /// Wire method: `session.eventLog.registerInterest`.
6060 ///
6061 /// # Parameters
6062 ///
6063 /// * `params` - Event type to register consumer interest for, used by runtime gating logic.
6064 ///
6065 /// # Returns
6066 ///
6067 /// Opaque handle representing an event-type interest registration.
6068 ///
6069 /// <div class="warning">
6070 ///
6071 /// **Experimental.** This API is part of an experimental wire-protocol surface
6072 /// and may change or be removed in future SDK or CLI releases. Pin both the
6073 /// SDK and CLI versions if your code depends on it.
6074 ///
6075 /// </div>
6076 pub async fn register_interest(
6077 &self,
6078 params: RegisterEventInterestParams,
6079 ) -> Result<RegisterEventInterestResult, Error> {
6080 let mut wire_params = serde_json::to_value(params)?;
6081 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6082 let _value = self
6083 .session
6084 .client()
6085 .call(
6086 rpc_methods::SESSION_EVENTLOG_REGISTERINTEREST,
6087 Some(wire_params),
6088 )
6089 .await?;
6090 Ok(serde_json::from_value(_value)?)
6091 }
6092
6093 /// Releases a consumer's previously-registered interest in an event type.
6094 ///
6095 /// Wire method: `session.eventLog.releaseInterest`.
6096 ///
6097 /// # Parameters
6098 ///
6099 /// * `params` - Opaque handle previously returned by `registerInterest` to release.
6100 ///
6101 /// # Returns
6102 ///
6103 /// Indicates whether the operation succeeded.
6104 ///
6105 /// <div class="warning">
6106 ///
6107 /// **Experimental.** This API is part of an experimental wire-protocol surface
6108 /// and may change or be removed in future SDK or CLI releases. Pin both the
6109 /// SDK and CLI versions if your code depends on it.
6110 ///
6111 /// </div>
6112 pub async fn release_interest(
6113 &self,
6114 params: ReleaseEventInterestParams,
6115 ) -> Result<EventLogReleaseInterestResult, Error> {
6116 let mut wire_params = serde_json::to_value(params)?;
6117 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6118 let _value = self
6119 .session
6120 .client()
6121 .call(
6122 rpc_methods::SESSION_EVENTLOG_RELEASEINTEREST,
6123 Some(wire_params),
6124 )
6125 .await?;
6126 Ok(serde_json::from_value(_value)?)
6127 }
6128}
6129
6130/// `session.extensions.*` RPCs.
6131#[derive(Clone, Copy)]
6132pub struct SessionRpcExtensions<'a> {
6133 pub(crate) session: &'a Session,
6134}
6135
6136impl<'a> SessionRpcExtensions<'a> {
6137 /// Lists extensions discovered for the session and their current status.
6138 ///
6139 /// Wire method: `session.extensions.list`.
6140 ///
6141 /// # Returns
6142 ///
6143 /// Extensions discovered for the session, with their current status.
6144 ///
6145 /// <div class="warning">
6146 ///
6147 /// **Experimental.** This API is part of an experimental wire-protocol surface
6148 /// and may change or be removed in future SDK or CLI releases. Pin both the
6149 /// SDK and CLI versions if your code depends on it.
6150 ///
6151 /// </div>
6152 pub async fn list(&self) -> Result<ExtensionList, Error> {
6153 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6154 let _value = self
6155 .session
6156 .client()
6157 .call(rpc_methods::SESSION_EXTENSIONS_LIST, Some(wire_params))
6158 .await?;
6159 Ok(serde_json::from_value(_value)?)
6160 }
6161
6162 /// Enables an extension for the session.
6163 ///
6164 /// Wire method: `session.extensions.enable`.
6165 ///
6166 /// # Parameters
6167 ///
6168 /// * `params` - Source-qualified extension identifier to enable for the session.
6169 ///
6170 /// <div class="warning">
6171 ///
6172 /// **Experimental.** This API is part of an experimental wire-protocol surface
6173 /// and may change or be removed in future SDK or CLI releases. Pin both the
6174 /// SDK and CLI versions if your code depends on it.
6175 ///
6176 /// </div>
6177 pub async fn enable(&self, params: ExtensionsEnableRequest) -> Result<(), Error> {
6178 let mut wire_params = serde_json::to_value(params)?;
6179 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6180 let _value = self
6181 .session
6182 .client()
6183 .call(rpc_methods::SESSION_EXTENSIONS_ENABLE, Some(wire_params))
6184 .await?;
6185 Ok(())
6186 }
6187
6188 /// Disables an extension for the session.
6189 ///
6190 /// Wire method: `session.extensions.disable`.
6191 ///
6192 /// # Parameters
6193 ///
6194 /// * `params` - Source-qualified extension identifier to disable for the session.
6195 ///
6196 /// <div class="warning">
6197 ///
6198 /// **Experimental.** This API is part of an experimental wire-protocol surface
6199 /// and may change or be removed in future SDK or CLI releases. Pin both the
6200 /// SDK and CLI versions if your code depends on it.
6201 ///
6202 /// </div>
6203 pub async fn disable(&self, params: ExtensionsDisableRequest) -> Result<(), Error> {
6204 let mut wire_params = serde_json::to_value(params)?;
6205 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6206 let _value = self
6207 .session
6208 .client()
6209 .call(rpc_methods::SESSION_EXTENSIONS_DISABLE, Some(wire_params))
6210 .await?;
6211 Ok(())
6212 }
6213
6214 /// Reloads extension definitions and processes for the session.
6215 ///
6216 /// Wire method: `session.extensions.reload`.
6217 ///
6218 /// <div class="warning">
6219 ///
6220 /// **Experimental.** This API is part of an experimental wire-protocol surface
6221 /// and may change or be removed in future SDK or CLI releases. Pin both the
6222 /// SDK and CLI versions if your code depends on it.
6223 ///
6224 /// </div>
6225 pub async fn reload(&self) -> Result<(), Error> {
6226 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6227 let _value = self
6228 .session
6229 .client()
6230 .call(rpc_methods::SESSION_EXTENSIONS_RELOAD, Some(wire_params))
6231 .await?;
6232 Ok(())
6233 }
6234
6235 /// 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.
6236 ///
6237 /// Wire method: `session.extensions.sendAttachmentsToMessage`.
6238 ///
6239 /// # Parameters
6240 ///
6241 /// * `params` - Parameters for session.extensions.sendAttachmentsToMessage.
6242 ///
6243 /// <div class="warning">
6244 ///
6245 /// **Experimental.** This API is part of an experimental wire-protocol surface
6246 /// and may change or be removed in future SDK or CLI releases. Pin both the
6247 /// SDK and CLI versions if your code depends on it.
6248 ///
6249 /// </div>
6250 pub async fn send_attachments_to_message(
6251 &self,
6252 params: SendAttachmentsToMessageParams,
6253 ) -> Result<(), Error> {
6254 let mut wire_params = serde_json::to_value(params)?;
6255 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6256 let _value = self
6257 .session
6258 .client()
6259 .call(
6260 rpc_methods::SESSION_EXTENSIONS_SENDATTACHMENTSTOMESSAGE,
6261 Some(wire_params),
6262 )
6263 .await?;
6264 Ok(())
6265 }
6266}
6267
6268/// `session.fleet.*` RPCs.
6269#[derive(Clone, Copy)]
6270pub struct SessionRpcFleet<'a> {
6271 pub(crate) session: &'a Session,
6272}
6273
6274impl<'a> SessionRpcFleet<'a> {
6275 /// Starts fleet mode by submitting the fleet orchestration prompt to the session.
6276 ///
6277 /// Wire method: `session.fleet.start`.
6278 ///
6279 /// # Parameters
6280 ///
6281 /// * `params` - Parameters for starting fleet orchestration: an optional user prompt combined with the fleet instructions, plus the send options forwarded to the resulting turn.
6282 ///
6283 /// # Returns
6284 ///
6285 /// Indicates whether fleet mode was successfully activated.
6286 ///
6287 /// <div class="warning">
6288 ///
6289 /// **Experimental.** This API is part of an experimental wire-protocol surface
6290 /// and may change or be removed in future SDK or CLI releases. Pin both the
6291 /// SDK and CLI versions if your code depends on it.
6292 ///
6293 /// </div>
6294 pub async fn start(&self, params: FleetStartRequest) -> Result<FleetStartResult, Error> {
6295 let mut wire_params = serde_json::to_value(params)?;
6296 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6297 let _value = self
6298 .session
6299 .client()
6300 .call(rpc_methods::SESSION_FLEET_START, Some(wire_params))
6301 .await?;
6302 Ok(serde_json::from_value(_value)?)
6303 }
6304}
6305
6306/// `session.gitHubAuth.*` RPCs.
6307#[derive(Clone, Copy)]
6308pub struct SessionRpcGitHubAuth<'a> {
6309 pub(crate) session: &'a Session,
6310}
6311
6312impl<'a> SessionRpcGitHubAuth<'a> {
6313 /// Gets authentication status and account metadata for the session.
6314 ///
6315 /// Wire method: `session.gitHubAuth.getStatus`.
6316 ///
6317 /// # Returns
6318 ///
6319 /// Authentication status and account metadata for the session.
6320 ///
6321 /// <div class="warning">
6322 ///
6323 /// **Experimental.** This API is part of an experimental wire-protocol surface
6324 /// and may change or be removed in future SDK or CLI releases. Pin both the
6325 /// SDK and CLI versions if your code depends on it.
6326 ///
6327 /// </div>
6328 pub async fn get_status(&self) -> Result<SessionAuthStatus, Error> {
6329 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6330 let _value = self
6331 .session
6332 .client()
6333 .call(rpc_methods::SESSION_GITHUBAUTH_GETSTATUS, Some(wire_params))
6334 .await?;
6335 Ok(serde_json::from_value(_value)?)
6336 }
6337
6338 /// Updates the session's auth credentials used for outbound model and API requests.
6339 ///
6340 /// Wire method: `session.gitHubAuth.setCredentials`.
6341 ///
6342 /// # Parameters
6343 ///
6344 /// * `params` - New auth credentials to install on the session. Omit to leave credentials unchanged.
6345 ///
6346 /// # Returns
6347 ///
6348 /// Indicates whether the credential update succeeded.
6349 ///
6350 /// <div class="warning">
6351 ///
6352 /// **Experimental.** This API is part of an experimental wire-protocol surface
6353 /// and may change or be removed in future SDK or CLI releases. Pin both the
6354 /// SDK and CLI versions if your code depends on it.
6355 ///
6356 /// </div>
6357 pub async fn set_credentials(
6358 &self,
6359 params: SessionSetCredentialsParams,
6360 ) -> Result<SessionSetCredentialsResult, Error> {
6361 let mut wire_params = serde_json::to_value(params)?;
6362 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6363 let _value = self
6364 .session
6365 .client()
6366 .call(
6367 rpc_methods::SESSION_GITHUBAUTH_SETCREDENTIALS,
6368 Some(wire_params),
6369 )
6370 .await?;
6371 Ok(serde_json::from_value(_value)?)
6372 }
6373
6374 /// Gets the current authentication information for internal session hosts.
6375 ///
6376 /// Wire method: `session.gitHubAuth.getCurrentAuthInfo`.
6377 ///
6378 /// # Returns
6379 ///
6380 /// Current authentication information, or null when no authentication is active.
6381 ///
6382 /// <div class="warning">
6383 ///
6384 /// **Experimental.** This API is part of an experimental wire-protocol surface
6385 /// and may change or be removed in future SDK or CLI releases. Pin both the
6386 /// SDK and CLI versions if your code depends on it.
6387 ///
6388 /// </div>
6389 pub(crate) async fn get_current_auth_info(&self) -> Result<SessionAuthInfoResult, Error> {
6390 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6391 let _value = self
6392 .session
6393 .client()
6394 .call(
6395 rpc_methods::SESSION_GITHUBAUTH_GETCURRENTAUTHINFO,
6396 Some(wire_params),
6397 )
6398 .await?;
6399 Ok(serde_json::from_value(_value)?)
6400 }
6401
6402 /// Gets all authentication accounts available to the internal session host.
6403 ///
6404 /// Wire method: `session.gitHubAuth.getAllAuthAvailable`.
6405 ///
6406 /// # Returns
6407 ///
6408 /// Authentication accounts available to the internal session host.
6409 ///
6410 /// <div class="warning">
6411 ///
6412 /// **Experimental.** This API is part of an experimental wire-protocol surface
6413 /// and may change or be removed in future SDK or CLI releases. Pin both the
6414 /// SDK and CLI versions if your code depends on it.
6415 ///
6416 /// </div>
6417 pub(crate) async fn get_all_auth_available(
6418 &self,
6419 ) -> Result<SessionGitHubAuthGetAllAuthAvailableResult, Error> {
6420 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6421 let _value = self
6422 .session
6423 .client()
6424 .call(
6425 rpc_methods::SESSION_GITHUBAUTH_GETALLAUTHAVAILABLE,
6426 Some(wire_params),
6427 )
6428 .await?;
6429 Ok(serde_json::from_value(_value)?)
6430 }
6431
6432 /// Refreshes Copilot account metadata for the current authentication.
6433 ///
6434 /// Wire method: `session.gitHubAuth.refreshCopilotUser`.
6435 ///
6436 /// # Returns
6437 ///
6438 /// Current authentication information, or null when no authentication is active.
6439 ///
6440 /// <div class="warning">
6441 ///
6442 /// **Experimental.** This API is part of an experimental wire-protocol surface
6443 /// and may change or be removed in future SDK or CLI releases. Pin both the
6444 /// SDK and CLI versions if your code depends on it.
6445 ///
6446 /// </div>
6447 pub(crate) async fn refresh_copilot_user(&self) -> Result<SessionAuthInfoResult, Error> {
6448 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6449 let _value = self
6450 .session
6451 .client()
6452 .call(
6453 rpc_methods::SESSION_GITHUBAUTH_REFRESHCOPILOTUSER,
6454 Some(wire_params),
6455 )
6456 .await?;
6457 Ok(serde_json::from_value(_value)?)
6458 }
6459
6460 /// Logs in a GitHub user through the internal session host.
6461 ///
6462 /// Wire method: `session.gitHubAuth.login`.
6463 ///
6464 /// # Parameters
6465 ///
6466 /// * `params` - Internal GitHub login parameters.
6467 ///
6468 /// # Returns
6469 ///
6470 /// Authentication credentials accepted only at native protocol ingress. Runtime outputs use credential-free `AuthIdentity` metadata.
6471 ///
6472 /// <div class="warning">
6473 ///
6474 /// **Experimental.** This API is part of an experimental wire-protocol surface
6475 /// and may change or be removed in future SDK or CLI releases. Pin both the
6476 /// SDK and CLI versions if your code depends on it.
6477 ///
6478 /// </div>
6479 pub(crate) async fn login(&self, params: SessionAuthLoginRequest) -> Result<AuthInfo, Error> {
6480 let mut wire_params = serde_json::to_value(params)?;
6481 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6482 let _value = self
6483 .session
6484 .client()
6485 .call(rpc_methods::SESSION_GITHUBAUTH_LOGIN, Some(wire_params))
6486 .await?;
6487 Ok(serde_json::from_value(_value)?)
6488 }
6489
6490 /// Switches the session to another available authentication.
6491 ///
6492 /// Wire method: `session.gitHubAuth.switchToAuth`.
6493 ///
6494 /// # Parameters
6495 ///
6496 /// * `params` - Parameters for switching the session's active authentication.
6497 ///
6498 /// <div class="warning">
6499 ///
6500 /// **Experimental.** This API is part of an experimental wire-protocol surface
6501 /// and may change or be removed in future SDK or CLI releases. Pin both the
6502 /// SDK and CLI versions if your code depends on it.
6503 ///
6504 /// </div>
6505 pub(crate) async fn switch_to_auth(
6506 &self,
6507 params: SessionAuthSwitchRequest,
6508 ) -> Result<(), Error> {
6509 let mut wire_params = serde_json::to_value(params)?;
6510 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6511 let _value = self
6512 .session
6513 .client()
6514 .call(
6515 rpc_methods::SESSION_GITHUBAUTH_SWITCHTOAUTH,
6516 Some(wire_params),
6517 )
6518 .await?;
6519 Ok(())
6520 }
6521
6522 /// Logs out the session's current GitHub authentication.
6523 ///
6524 /// Wire method: `session.gitHubAuth.logout`.
6525 ///
6526 /// # Returns
6527 ///
6528 /// Whether the current authentication was logged out.
6529 ///
6530 /// <div class="warning">
6531 ///
6532 /// **Experimental.** This API is part of an experimental wire-protocol surface
6533 /// and may change or be removed in future SDK or CLI releases. Pin both the
6534 /// SDK and CLI versions if your code depends on it.
6535 ///
6536 /// </div>
6537 pub(crate) async fn logout(&self) -> Result<SessionGitHubAuthLogoutResult, Error> {
6538 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6539 let _value = self
6540 .session
6541 .client()
6542 .call(rpc_methods::SESSION_GITHUBAUTH_LOGOUT, Some(wire_params))
6543 .await?;
6544 Ok(serde_json::from_value(_value)?)
6545 }
6546
6547 /// Logs out a specific GitHub authentication.
6548 ///
6549 /// Wire method: `session.gitHubAuth.logoutUser`.
6550 ///
6551 /// # Parameters
6552 ///
6553 /// * `params` - Parameters identifying a GitHub authentication to log out.
6554 ///
6555 /// # Returns
6556 ///
6557 /// Whether the requested authentication was logged out.
6558 ///
6559 /// <div class="warning">
6560 ///
6561 /// **Experimental.** This API is part of an experimental wire-protocol surface
6562 /// and may change or be removed in future SDK or CLI releases. Pin both the
6563 /// SDK and CLI versions if your code depends on it.
6564 ///
6565 /// </div>
6566 pub(crate) async fn logout_user(
6567 &self,
6568 params: SessionAuthLogoutUserRequest,
6569 ) -> Result<SessionGitHubAuthLogoutUserResult, Error> {
6570 let mut wire_params = serde_json::to_value(params)?;
6571 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6572 let _value = self
6573 .session
6574 .client()
6575 .call(
6576 rpc_methods::SESSION_GITHUBAUTH_LOGOUTUSER,
6577 Some(wire_params),
6578 )
6579 .await?;
6580 Ok(serde_json::from_value(_value)?)
6581 }
6582
6583 /// Gets validation errors from the most recent authentication attempt.
6584 ///
6585 /// Wire method: `session.gitHubAuth.lastAuthErrors`.
6586 ///
6587 /// # Returns
6588 ///
6589 /// Validation errors from the most recent authentication attempt.
6590 ///
6591 /// <div class="warning">
6592 ///
6593 /// **Experimental.** This API is part of an experimental wire-protocol surface
6594 /// and may change or be removed in future SDK or CLI releases. Pin both the
6595 /// SDK and CLI versions if your code depends on it.
6596 ///
6597 /// </div>
6598 pub(crate) async fn last_auth_errors(&self) -> Result<AuthValidationErrors, Error> {
6599 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6600 let _value = self
6601 .session
6602 .client()
6603 .call(
6604 rpc_methods::SESSION_GITHUBAUTH_LASTAUTHERRORS,
6605 Some(wire_params),
6606 )
6607 .await?;
6608 Ok(serde_json::from_value(_value)?)
6609 }
6610}
6611
6612/// `session.history.*` RPCs.
6613#[derive(Clone, Copy)]
6614pub struct SessionRpcHistory<'a> {
6615 pub(crate) session: &'a Session,
6616}
6617
6618impl<'a> SessionRpcHistory<'a> {
6619 /// Compacts the session history to reduce context usage.
6620 ///
6621 /// Wire method: `session.history.compact`.
6622 ///
6623 /// # Returns
6624 ///
6625 /// Compaction outcome with the number of tokens and messages removed, summary text, and the resulting context window breakdown.
6626 ///
6627 /// <div class="warning">
6628 ///
6629 /// **Experimental.** This API is part of an experimental wire-protocol surface
6630 /// and may change or be removed in future SDK or CLI releases. Pin both the
6631 /// SDK and CLI versions if your code depends on it.
6632 ///
6633 /// </div>
6634 pub async fn compact(&self) -> Result<HistoryCompactResult, Error> {
6635 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6636 let _value = self
6637 .session
6638 .client()
6639 .call(rpc_methods::SESSION_HISTORY_COMPACT, Some(wire_params))
6640 .await?;
6641 Ok(serde_json::from_value(_value)?)
6642 }
6643
6644 /// Compacts the session history to reduce context usage.
6645 ///
6646 /// Wire method: `session.history.compact`.
6647 ///
6648 /// # Parameters
6649 ///
6650 /// * `params` - Optional compaction parameters.
6651 ///
6652 /// # Returns
6653 ///
6654 /// Compaction outcome with the number of tokens and messages removed, summary text, and the resulting context window breakdown.
6655 ///
6656 /// <div class="warning">
6657 ///
6658 /// **Experimental.** This API is part of an experimental wire-protocol surface
6659 /// and may change or be removed in future SDK or CLI releases. Pin both the
6660 /// SDK and CLI versions if your code depends on it.
6661 ///
6662 /// </div>
6663 pub async fn compact_with_params(
6664 &self,
6665 params: HistoryCompactRequest,
6666 ) -> Result<HistoryCompactResult, Error> {
6667 let mut wire_params = serde_json::to_value(params)?;
6668 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6669 let _value = self
6670 .session
6671 .client()
6672 .call(rpc_methods::SESSION_HISTORY_COMPACT, Some(wire_params))
6673 .await?;
6674 Ok(serde_json::from_value(_value)?)
6675 }
6676
6677 /// Truncates persisted session history to a specific event.
6678 ///
6679 /// Wire method: `session.history.truncate`.
6680 ///
6681 /// # Parameters
6682 ///
6683 /// * `params` - Identifier of the event to truncate to; this event and all later events are removed.
6684 ///
6685 /// # Returns
6686 ///
6687 /// Number of events that were removed by the truncation.
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 truncate(
6697 &self,
6698 params: HistoryTruncateRequest,
6699 ) -> Result<HistoryTruncateResult, Error> {
6700 let mut wire_params = serde_json::to_value(params)?;
6701 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6702 let _value = self
6703 .session
6704 .client()
6705 .call(rpc_methods::SESSION_HISTORY_TRUNCATE, Some(wire_params))
6706 .await?;
6707 Ok(serde_json::from_value(_value)?)
6708 }
6709
6710 /// 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.
6711 ///
6712 /// Wire method: `session.history.listRewindPoints`.
6713 ///
6714 /// # Returns
6715 ///
6716 /// Rewind points and file-change-tracking availability for the session.
6717 ///
6718 /// <div class="warning">
6719 ///
6720 /// **Experimental.** This API is part of an experimental wire-protocol surface
6721 /// and may change or be removed in future SDK or CLI releases. Pin both the
6722 /// SDK and CLI versions if your code depends on it.
6723 ///
6724 /// </div>
6725 pub async fn list_rewind_points(&self) -> Result<HistoryListRewindPointsResult, Error> {
6726 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6727 let _value = self
6728 .session
6729 .client()
6730 .call(
6731 rpc_methods::SESSION_HISTORY_LISTREWINDPOINTS,
6732 Some(wire_params),
6733 )
6734 .await?;
6735 Ok(serde_json::from_value(_value)?)
6736 }
6737
6738 /// Previews the files that a conversation-and-files rewind would restore.
6739 ///
6740 /// Wire method: `session.history.previewRewind`.
6741 ///
6742 /// # Parameters
6743 ///
6744 /// * `params` - Event boundary to preview for conversation-and-files rewind.
6745 ///
6746 /// # Returns
6747 ///
6748 /// Files and aggregate changes for a prospective rewind.
6749 ///
6750 /// <div class="warning">
6751 ///
6752 /// **Experimental.** This API is part of an experimental wire-protocol surface
6753 /// and may change or be removed in future SDK or CLI releases. Pin both the
6754 /// SDK and CLI versions if your code depends on it.
6755 ///
6756 /// </div>
6757 pub async fn preview_rewind(
6758 &self,
6759 params: HistoryPreviewRewindRequest,
6760 ) -> Result<HistoryPreviewRewindResult, Error> {
6761 let mut wire_params = serde_json::to_value(params)?;
6762 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6763 let _value = self
6764 .session
6765 .client()
6766 .call(
6767 rpc_methods::SESSION_HISTORY_PREVIEWREWIND,
6768 Some(wire_params),
6769 )
6770 .await?;
6771 Ok(serde_json::from_value(_value)?)
6772 }
6773
6774 /// 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.
6775 ///
6776 /// Wire method: `session.history.rewind`.
6777 ///
6778 /// # Parameters
6779 ///
6780 /// * `params` - Boundary and mode for rewinding session history.
6781 ///
6782 /// # Returns
6783 ///
6784 /// Structured outcome of a rewind request.
6785 ///
6786 /// <div class="warning">
6787 ///
6788 /// **Experimental.** This API is part of an experimental wire-protocol surface
6789 /// and may change or be removed in future SDK or CLI releases. Pin both the
6790 /// SDK and CLI versions if your code depends on it.
6791 ///
6792 /// </div>
6793 pub async fn rewind(&self, params: HistoryRewindRequest) -> Result<HistoryRewindResult, Error> {
6794 let mut wire_params = serde_json::to_value(params)?;
6795 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6796 let _value = self
6797 .session
6798 .client()
6799 .call(rpc_methods::SESSION_HISTORY_REWIND, Some(wire_params))
6800 .await?;
6801 Ok(serde_json::from_value(_value)?)
6802 }
6803
6804 /// Cancels any in-progress background compaction on a local session.
6805 ///
6806 /// Wire method: `session.history.cancelBackgroundCompaction`.
6807 ///
6808 /// # Returns
6809 ///
6810 /// Indicates whether an in-progress background compaction was cancelled.
6811 ///
6812 /// <div class="warning">
6813 ///
6814 /// **Experimental.** This API is part of an experimental wire-protocol surface
6815 /// and may change or be removed in future SDK or CLI releases. Pin both the
6816 /// SDK and CLI versions if your code depends on it.
6817 ///
6818 /// </div>
6819 pub async fn cancel_background_compaction(
6820 &self,
6821 ) -> Result<HistoryCancelBackgroundCompactionResult, Error> {
6822 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6823 let _value = self
6824 .session
6825 .client()
6826 .call(
6827 rpc_methods::SESSION_HISTORY_CANCELBACKGROUNDCOMPACTION,
6828 Some(wire_params),
6829 )
6830 .await?;
6831 Ok(serde_json::from_value(_value)?)
6832 }
6833
6834 /// Aborts any in-progress manual compaction on a local session.
6835 ///
6836 /// Wire method: `session.history.abortManualCompaction`.
6837 ///
6838 /// # Returns
6839 ///
6840 /// Indicates whether an in-progress manual compaction was aborted.
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 abort_manual_compaction(
6850 &self,
6851 ) -> Result<HistoryAbortManualCompactionResult, Error> {
6852 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6853 let _value = self
6854 .session
6855 .client()
6856 .call(
6857 rpc_methods::SESSION_HISTORY_ABORTMANUALCOMPACTION,
6858 Some(wire_params),
6859 )
6860 .await?;
6861 Ok(serde_json::from_value(_value)?)
6862 }
6863
6864 /// Produces a markdown summary of the session's conversation context for hand-off scenarios.
6865 ///
6866 /// Wire method: `session.history.summarizeForHandoff`.
6867 ///
6868 /// # Returns
6869 ///
6870 /// Markdown summary of the conversation context (empty when not available).
6871 ///
6872 /// <div class="warning">
6873 ///
6874 /// **Experimental.** This API is part of an experimental wire-protocol surface
6875 /// and may change or be removed in future SDK or CLI releases. Pin both the
6876 /// SDK and CLI versions if your code depends on it.
6877 ///
6878 /// </div>
6879 pub async fn summarize_for_handoff(&self) -> Result<HistorySummarizeForHandoffResult, Error> {
6880 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6881 let _value = self
6882 .session
6883 .client()
6884 .call(
6885 rpc_methods::SESSION_HISTORY_SUMMARIZEFORHANDOFF,
6886 Some(wire_params),
6887 )
6888 .await?;
6889 Ok(serde_json::from_value(_value)?)
6890 }
6891
6892 /// 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.
6893 ///
6894 /// Wire method: `session.history.clearContext`.
6895 ///
6896 /// # Parameters
6897 ///
6898 /// * `params` - Parameters for clearing the conversation and seeding the window that replaces it.
6899 ///
6900 /// # Returns
6901 ///
6902 /// What a successful clear removed. A clear that could not be applied rejects instead of reporting a count.
6903 ///
6904 /// <div class="warning">
6905 ///
6906 /// **Experimental.** This API is part of an experimental wire-protocol surface
6907 /// and may change or be removed in future SDK or CLI releases. Pin both the
6908 /// SDK and CLI versions if your code depends on it.
6909 ///
6910 /// </div>
6911 pub async fn clear_context(
6912 &self,
6913 params: HistoryClearContextRequest,
6914 ) -> Result<HistoryClearContextResult, Error> {
6915 let mut wire_params = serde_json::to_value(params)?;
6916 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6917 let _value = self
6918 .session
6919 .client()
6920 .call(rpc_methods::SESSION_HISTORY_CLEARCONTEXT, Some(wire_params))
6921 .await?;
6922 Ok(serde_json::from_value(_value)?)
6923 }
6924}
6925
6926/// `session.instructions.*` RPCs.
6927#[derive(Clone, Copy)]
6928pub struct SessionRpcInstructions<'a> {
6929 pub(crate) session: &'a Session,
6930}
6931
6932impl<'a> SessionRpcInstructions<'a> {
6933 /// Gets instruction sources loaded for the session.
6934 ///
6935 /// Wire method: `session.instructions.getSources`.
6936 ///
6937 /// # Returns
6938 ///
6939 /// Instruction sources loaded for the session, in merge order.
6940 ///
6941 /// <div class="warning">
6942 ///
6943 /// **Experimental.** This API is part of an experimental wire-protocol surface
6944 /// and may change or be removed in future SDK or CLI releases. Pin both the
6945 /// SDK and CLI versions if your code depends on it.
6946 ///
6947 /// </div>
6948 pub async fn get_sources(&self) -> Result<InstructionsGetSourcesResult, Error> {
6949 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6950 let _value = self
6951 .session
6952 .client()
6953 .call(
6954 rpc_methods::SESSION_INSTRUCTIONS_GETSOURCES,
6955 Some(wire_params),
6956 )
6957 .await?;
6958 Ok(serde_json::from_value(_value)?)
6959 }
6960
6961 /// Invalidates cached custom-instruction discovery so subsequent turns and source reads observe instruction files currently on disk.
6962 ///
6963 /// Wire method: `session.instructions.reload`.
6964 ///
6965 /// <div class="warning">
6966 ///
6967 /// **Experimental.** This API is part of an experimental wire-protocol surface
6968 /// and may change or be removed in future SDK or CLI releases. Pin both the
6969 /// SDK and CLI versions if your code depends on it.
6970 ///
6971 /// </div>
6972 pub async fn reload(&self) -> Result<(), Error> {
6973 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6974 let _value = self
6975 .session
6976 .client()
6977 .call(rpc_methods::SESSION_INSTRUCTIONS_RELOAD, Some(wire_params))
6978 .await?;
6979 Ok(())
6980 }
6981}
6982
6983/// `session.limitPrediction.*` RPCs.
6984#[derive(Clone, Copy)]
6985pub struct SessionRpcLimitPrediction<'a> {
6986 pub(crate) session: &'a Session,
6987}
6988
6989impl<'a> SessionRpcLimitPrediction<'a> {
6990 /// 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.
6991 ///
6992 /// Wire method: `session.limitPrediction.predict`.
6993 ///
6994 /// # Returns
6995 ///
6996 /// Prediction result. Available results include prediction details; unavailable results include an explicit reason.
6997 ///
6998 /// <div class="warning">
6999 ///
7000 /// **Experimental.** This API is part of an experimental wire-protocol surface
7001 /// and may change or be removed in future SDK or CLI releases. Pin both the
7002 /// SDK and CLI versions if your code depends on it.
7003 ///
7004 /// </div>
7005 pub async fn predict(&self) -> Result<SessionLimitPredictionResult, Error> {
7006 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7007 let _value = self
7008 .session
7009 .client()
7010 .call(
7011 rpc_methods::SESSION_LIMITPREDICTION_PREDICT,
7012 Some(wire_params),
7013 )
7014 .await?;
7015 Ok(serde_json::from_value(_value)?)
7016 }
7017
7018 /// 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.
7019 ///
7020 /// Wire method: `session.limitPrediction.predict`.
7021 ///
7022 /// # Parameters
7023 ///
7024 /// * `params` - Parameters for predicting an AI-credit session limit. Omitting `modelId` uses the session's currently selected model.
7025 ///
7026 /// # Returns
7027 ///
7028 /// Prediction result. Available results include prediction details; unavailable results include an explicit reason.
7029 ///
7030 /// <div class="warning">
7031 ///
7032 /// **Experimental.** This API is part of an experimental wire-protocol surface
7033 /// and may change or be removed in future SDK or CLI releases. Pin both the
7034 /// SDK and CLI versions if your code depends on it.
7035 ///
7036 /// </div>
7037 pub async fn predict_with_params(
7038 &self,
7039 params: SessionLimitPredictionRequest,
7040 ) -> Result<SessionLimitPredictionResult, Error> {
7041 let mut wire_params = serde_json::to_value(params)?;
7042 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7043 let _value = self
7044 .session
7045 .client()
7046 .call(
7047 rpc_methods::SESSION_LIMITPREDICTION_PREDICT,
7048 Some(wire_params),
7049 )
7050 .await?;
7051 Ok(serde_json::from_value(_value)?)
7052 }
7053}
7054
7055/// `session.lsp.*` RPCs.
7056#[derive(Clone, Copy)]
7057pub struct SessionRpcLsp<'a> {
7058 pub(crate) session: &'a Session,
7059}
7060
7061impl<'a> SessionRpcLsp<'a> {
7062 /// Loads the merged LSP configuration set for the session's working directory.
7063 ///
7064 /// Wire method: `session.lsp.initialize`.
7065 ///
7066 /// # Parameters
7067 ///
7068 /// * `params` - Parameters for (re)loading the merged LSP configuration set.
7069 ///
7070 /// <div class="warning">
7071 ///
7072 /// **Experimental.** This API is part of an experimental wire-protocol surface
7073 /// and may change or be removed in future SDK or CLI releases. Pin both the
7074 /// SDK and CLI versions if your code depends on it.
7075 ///
7076 /// </div>
7077 pub async fn initialize(&self, params: LspInitializeRequest) -> Result<(), Error> {
7078 let mut wire_params = serde_json::to_value(params)?;
7079 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7080 let _value = self
7081 .session
7082 .client()
7083 .call(rpc_methods::SESSION_LSP_INITIALIZE, Some(wire_params))
7084 .await?;
7085 Ok(())
7086 }
7087}
7088
7089/// `session.managedSettings.*` RPCs.
7090#[derive(Clone, Copy)]
7091pub struct SessionRpcManagedSettings<'a> {
7092 pub(crate) session: &'a Session,
7093}
7094
7095impl<'a> SessionRpcManagedSettings<'a> {
7096 /// 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.
7097 ///
7098 /// Wire method: `session.managedSettings.get`.
7099 ///
7100 /// # Returns
7101 ///
7102 /// 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.
7103 ///
7104 /// <div class="warning">
7105 ///
7106 /// **Experimental.** This API is part of an experimental wire-protocol surface
7107 /// and may change or be removed in future SDK or CLI releases. Pin both the
7108 /// SDK and CLI versions if your code depends on it.
7109 ///
7110 /// </div>
7111 pub async fn get(&self) -> Result<ManagedSettingsResolvedData, Error> {
7112 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7113 let _value = self
7114 .session
7115 .client()
7116 .call(rpc_methods::SESSION_MANAGEDSETTINGS_GET, Some(wire_params))
7117 .await?;
7118 Ok(serde_json::from_value(_value)?)
7119 }
7120}
7121
7122/// `session.mcp.*` RPCs.
7123#[derive(Clone, Copy)]
7124pub struct SessionRpcMcp<'a> {
7125 pub(crate) session: &'a Session,
7126}
7127
7128impl<'a> SessionRpcMcp<'a> {
7129 /// `session.mcp.apps.*` sub-namespace.
7130 pub fn apps(&self) -> SessionRpcMcpApps<'a> {
7131 SessionRpcMcpApps {
7132 session: self.session,
7133 }
7134 }
7135
7136 /// `session.mcp.headers.*` sub-namespace.
7137 pub fn headers(&self) -> SessionRpcMcpHeaders<'a> {
7138 SessionRpcMcpHeaders {
7139 session: self.session,
7140 }
7141 }
7142
7143 /// `session.mcp.oauth.*` sub-namespace.
7144 pub fn oauth(&self) -> SessionRpcMcpOauth<'a> {
7145 SessionRpcMcpOauth {
7146 session: self.session,
7147 }
7148 }
7149
7150 /// `session.mcp.resources.*` sub-namespace.
7151 pub fn resources(&self) -> SessionRpcMcpResources<'a> {
7152 SessionRpcMcpResources {
7153 session: self.session,
7154 }
7155 }
7156
7157 /// 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.
7158 ///
7159 /// Wire method: `session.mcp.list`.
7160 ///
7161 /// # Returns
7162 ///
7163 /// MCP servers configured for the session, with their connection status and host-level state.
7164 ///
7165 /// <div class="warning">
7166 ///
7167 /// **Experimental.** This API is part of an experimental wire-protocol surface
7168 /// and may change or be removed in future SDK or CLI releases. Pin both the
7169 /// SDK and CLI versions if your code depends on it.
7170 ///
7171 /// </div>
7172 pub async fn list(&self) -> Result<McpServerList, Error> {
7173 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7174 let _value = self
7175 .session
7176 .client()
7177 .call(rpc_methods::SESSION_MCP_LIST, Some(wire_params))
7178 .await?;
7179 Ok(serde_json::from_value(_value)?)
7180 }
7181
7182 /// 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.
7183 ///
7184 /// Wire method: `session.mcp.listTools`.
7185 ///
7186 /// # Parameters
7187 ///
7188 /// * `params` - Server name whose tool list should be returned.
7189 ///
7190 /// # Returns
7191 ///
7192 /// Tools exposed by the connected MCP server. Throws when the server is not connected.
7193 ///
7194 /// <div class="warning">
7195 ///
7196 /// **Experimental.** This API is part of an experimental wire-protocol surface
7197 /// and may change or be removed in future SDK or CLI releases. Pin both the
7198 /// SDK and CLI versions if your code depends on it.
7199 ///
7200 /// </div>
7201 pub async fn list_tools(
7202 &self,
7203 params: McpListToolsRequest,
7204 ) -> Result<McpListToolsResult, Error> {
7205 let mut wire_params = serde_json::to_value(params)?;
7206 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7207 let _value = self
7208 .session
7209 .client()
7210 .call(rpc_methods::SESSION_MCP_LISTTOOLS, Some(wire_params))
7211 .await?;
7212 Ok(serde_json::from_value(_value)?)
7213 }
7214
7215 /// Enables an MCP server for the session.
7216 ///
7217 /// Wire method: `session.mcp.enable`.
7218 ///
7219 /// # Parameters
7220 ///
7221 /// * `params` - Name of the MCP server to enable for the session.
7222 ///
7223 /// <div class="warning">
7224 ///
7225 /// **Experimental.** This API is part of an experimental wire-protocol surface
7226 /// and may change or be removed in future SDK or CLI releases. Pin both the
7227 /// SDK and CLI versions if your code depends on it.
7228 ///
7229 /// </div>
7230 pub async fn enable(&self, params: McpEnableRequest) -> Result<(), Error> {
7231 let mut wire_params = serde_json::to_value(params)?;
7232 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7233 let _value = self
7234 .session
7235 .client()
7236 .call(rpc_methods::SESSION_MCP_ENABLE, Some(wire_params))
7237 .await?;
7238 Ok(())
7239 }
7240
7241 /// Enables an MCP server for the session.
7242 ///
7243 /// Wire method: `session.mcp.enable`.
7244 ///
7245 /// # Parameters
7246 ///
7247 /// * `params` - Name of the MCP server to enable for the session.
7248 ///
7249 /// <div class="warning">
7250 ///
7251 /// **Experimental.** This API is part of an experimental wire-protocol surface
7252 /// and may change or be removed in future SDK or CLI releases. Pin both the
7253 /// SDK and CLI versions if your code depends on it.
7254 ///
7255 /// </div>
7256 ///
7257 /// Accepts [`McpEnableOptions`], including inputs added after [`McpEnableRequest`].
7258 pub async fn enable_with_options(&self, params: McpEnableOptions) -> 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(rpc_methods::SESSION_MCP_ENABLE, Some(wire_params))
7265 .await?;
7266 Ok(())
7267 }
7268
7269 /// Disables an MCP server for the session.
7270 ///
7271 /// Wire method: `session.mcp.disable`.
7272 ///
7273 /// # Parameters
7274 ///
7275 /// * `params` - Name of the MCP server to disable for the session.
7276 ///
7277 /// <div class="warning">
7278 ///
7279 /// **Experimental.** This API is part of an experimental wire-protocol surface
7280 /// and may change or be removed in future SDK or CLI releases. Pin both the
7281 /// SDK and CLI versions if your code depends on it.
7282 ///
7283 /// </div>
7284 pub async fn disable(&self, params: McpDisableRequest) -> Result<(), Error> {
7285 let mut wire_params = serde_json::to_value(params)?;
7286 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7287 let _value = self
7288 .session
7289 .client()
7290 .call(rpc_methods::SESSION_MCP_DISABLE, Some(wire_params))
7291 .await?;
7292 Ok(())
7293 }
7294
7295 /// Disables an MCP server for the session.
7296 ///
7297 /// Wire method: `session.mcp.disable`.
7298 ///
7299 /// # Parameters
7300 ///
7301 /// * `params` - Name of the MCP server to disable for the session.
7302 ///
7303 /// <div class="warning">
7304 ///
7305 /// **Experimental.** This API is part of an experimental wire-protocol surface
7306 /// and may change or be removed in future SDK or CLI releases. Pin both the
7307 /// SDK and CLI versions if your code depends on it.
7308 ///
7309 /// </div>
7310 ///
7311 /// Accepts [`McpDisableOptions`], including inputs added after [`McpDisableRequest`].
7312 pub async fn disable_with_options(&self, params: McpDisableOptions) -> Result<(), Error> {
7313 let mut wire_params = serde_json::to_value(params)?;
7314 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7315 let _value = self
7316 .session
7317 .client()
7318 .call(rpc_methods::SESSION_MCP_DISABLE, Some(wire_params))
7319 .await?;
7320 Ok(())
7321 }
7322
7323 /// Reloads MCP server connections for the session.
7324 ///
7325 /// Wire method: `session.mcp.reload`.
7326 ///
7327 /// <div class="warning">
7328 ///
7329 /// **Experimental.** This API is part of an experimental wire-protocol surface
7330 /// and may change or be removed in future SDK or CLI releases. Pin both the
7331 /// SDK and CLI versions if your code depends on it.
7332 ///
7333 /// </div>
7334 pub async fn reload(&self) -> Result<(), Error> {
7335 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7336 let _value = self
7337 .session
7338 .client()
7339 .call(rpc_methods::SESSION_MCP_RELOAD, Some(wire_params))
7340 .await?;
7341 Ok(())
7342 }
7343
7344 /// 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.
7345 ///
7346 /// Wire method: `session.mcp.moveLoadingToBackground`.
7347 ///
7348 /// # Returns
7349 ///
7350 /// Result of moving in-flight MCP loading to the background.
7351 ///
7352 /// <div class="warning">
7353 ///
7354 /// **Experimental.** This API is part of an experimental wire-protocol surface
7355 /// and may change or be removed in future SDK or CLI releases. Pin both the
7356 /// SDK and CLI versions if your code depends on it.
7357 ///
7358 /// </div>
7359 pub async fn move_loading_to_background(
7360 &self,
7361 ) -> Result<MoveMcpLoadingToBackgroundResult, Error> {
7362 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7363 let _value = self
7364 .session
7365 .client()
7366 .call(
7367 rpc_methods::SESSION_MCP_MOVELOADINGTOBACKGROUND,
7368 Some(wire_params),
7369 )
7370 .await?;
7371 Ok(serde_json::from_value(_value)?)
7372 }
7373
7374 /// Reloads MCP server connections for the session with an explicit host-provided configuration.
7375 ///
7376 /// Wire method: `session.mcp.reloadWithConfig`.
7377 ///
7378 /// # Parameters
7379 ///
7380 /// * `params` - Opaque MCP reload configuration.
7381 ///
7382 /// # Returns
7383 ///
7384 /// MCP server startup filtering result.
7385 ///
7386 /// <div class="warning">
7387 ///
7388 /// **Experimental.** This API is part of an experimental wire-protocol surface
7389 /// and may change or be removed in future SDK or CLI releases. Pin both the
7390 /// SDK and CLI versions if your code depends on it.
7391 ///
7392 /// </div>
7393 pub(crate) async fn reload_with_config(
7394 &self,
7395 params: McpReloadWithConfigRequest,
7396 ) -> Result<McpStartServersResult, Error> {
7397 let mut wire_params = serde_json::to_value(params)?;
7398 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7399 let _value = self
7400 .session
7401 .client()
7402 .call(rpc_methods::SESSION_MCP_RELOADWITHCONFIG, Some(wire_params))
7403 .await?;
7404 Ok(serde_json::from_value(_value)?)
7405 }
7406
7407 /// Runs an MCP sampling inference on behalf of an MCP server.
7408 ///
7409 /// Wire method: `session.mcp.executeSampling`.
7410 ///
7411 /// # Parameters
7412 ///
7413 /// * `params` - Identifiers and raw MCP CreateMessageRequest params used to run a sampling inference.
7414 ///
7415 /// # Returns
7416 ///
7417 /// Outcome of an MCP sampling execution: success result, failure error, or cancellation.
7418 ///
7419 /// <div class="warning">
7420 ///
7421 /// **Experimental.** This API is part of an experimental wire-protocol surface
7422 /// and may change or be removed in future SDK or CLI releases. Pin both the
7423 /// SDK and CLI versions if your code depends on it.
7424 ///
7425 /// </div>
7426 pub async fn execute_sampling(
7427 &self,
7428 params: McpExecuteSamplingParams,
7429 ) -> Result<McpSamplingExecutionResult, Error> {
7430 let mut wire_params = serde_json::to_value(params)?;
7431 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7432 let _value = self
7433 .session
7434 .client()
7435 .call(rpc_methods::SESSION_MCP_EXECUTESAMPLING, Some(wire_params))
7436 .await?;
7437 Ok(serde_json::from_value(_value)?)
7438 }
7439
7440 /// Cancels an in-flight MCP sampling execution by request ID.
7441 ///
7442 /// Wire method: `session.mcp.cancelSamplingExecution`.
7443 ///
7444 /// # Parameters
7445 ///
7446 /// * `params` - The requestId previously passed to executeSampling that should be cancelled.
7447 ///
7448 /// # Returns
7449 ///
7450 /// Indicates whether an in-flight sampling execution with the given requestId was found and cancelled.
7451 ///
7452 /// <div class="warning">
7453 ///
7454 /// **Experimental.** This API is part of an experimental wire-protocol surface
7455 /// and may change or be removed in future SDK or CLI releases. Pin both the
7456 /// SDK and CLI versions if your code depends on it.
7457 ///
7458 /// </div>
7459 pub async fn cancel_sampling_execution(
7460 &self,
7461 params: McpCancelSamplingExecutionParams,
7462 ) -> Result<McpCancelSamplingExecutionResult, Error> {
7463 let mut wire_params = serde_json::to_value(params)?;
7464 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7465 let _value = self
7466 .session
7467 .client()
7468 .call(
7469 rpc_methods::SESSION_MCP_CANCELSAMPLINGEXECUTION,
7470 Some(wire_params),
7471 )
7472 .await?;
7473 Ok(serde_json::from_value(_value)?)
7474 }
7475
7476 /// Sets how environment-variable values supplied to MCP servers are resolved (direct or indirect).
7477 ///
7478 /// Wire method: `session.mcp.setEnvValueMode`.
7479 ///
7480 /// # Parameters
7481 ///
7482 /// * `params` - Mode controlling how MCP server env values are resolved (`direct` or `indirect`).
7483 ///
7484 /// # Returns
7485 ///
7486 /// Env-value mode recorded on the session after the update.
7487 ///
7488 /// <div class="warning">
7489 ///
7490 /// **Experimental.** This API is part of an experimental wire-protocol surface
7491 /// and may change or be removed in future SDK or CLI releases. Pin both the
7492 /// SDK and CLI versions if your code depends on it.
7493 ///
7494 /// </div>
7495 pub async fn set_env_value_mode(
7496 &self,
7497 params: McpSetEnvValueModeParams,
7498 ) -> Result<McpSetEnvValueModeResult, Error> {
7499 let mut wire_params = serde_json::to_value(params)?;
7500 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7501 let _value = self
7502 .session
7503 .client()
7504 .call(rpc_methods::SESSION_MCP_SETENVVALUEMODE, Some(wire_params))
7505 .await?;
7506 Ok(serde_json::from_value(_value)?)
7507 }
7508
7509 /// Removes the auto-managed `github` MCP server when present.
7510 ///
7511 /// Wire method: `session.mcp.removeGitHub`.
7512 ///
7513 /// # Returns
7514 ///
7515 /// Indicates whether the auto-managed `github` MCP server was removed (false when nothing to remove).
7516 ///
7517 /// <div class="warning">
7518 ///
7519 /// **Experimental.** This API is part of an experimental wire-protocol surface
7520 /// and may change or be removed in future SDK or CLI releases. Pin both the
7521 /// SDK and CLI versions if your code depends on it.
7522 ///
7523 /// </div>
7524 pub async fn remove_git_hub(&self) -> Result<McpRemoveGitHubResult, Error> {
7525 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7526 let _value = self
7527 .session
7528 .client()
7529 .call(rpc_methods::SESSION_MCP_REMOVEGITHUB, Some(wire_params))
7530 .await?;
7531 Ok(serde_json::from_value(_value)?)
7532 }
7533
7534 /// Configures the built-in GitHub MCP server for the session's current auth context.
7535 ///
7536 /// Wire method: `session.mcp.configureGitHub`.
7537 ///
7538 /// # Parameters
7539 ///
7540 /// * `params` - Credential-free authentication identity used to configure GitHub MCP.
7541 ///
7542 /// # Returns
7543 ///
7544 /// Result of configuring GitHub MCP.
7545 ///
7546 /// <div class="warning">
7547 ///
7548 /// **Experimental.** This API is part of an experimental wire-protocol surface
7549 /// and may change or be removed in future SDK or CLI releases. Pin both the
7550 /// SDK and CLI versions if your code depends on it.
7551 ///
7552 /// </div>
7553 pub(crate) async fn configure_git_hub(
7554 &self,
7555 params: McpConfigureGitHubRequest,
7556 ) -> Result<McpConfigureGitHubResult, Error> {
7557 let mut wire_params = serde_json::to_value(params)?;
7558 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7559 let _value = self
7560 .session
7561 .client()
7562 .call(rpc_methods::SESSION_MCP_CONFIGUREGITHUB, Some(wire_params))
7563 .await?;
7564 Ok(serde_json::from_value(_value)?)
7565 }
7566
7567 /// 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.
7568 ///
7569 /// Wire method: `session.mcp.startServer`.
7570 ///
7571 /// # Parameters
7572 ///
7573 /// * `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.
7574 ///
7575 /// <div class="warning">
7576 ///
7577 /// **Experimental.** This API is part of an experimental wire-protocol surface
7578 /// and may change or be removed in future SDK or CLI releases. Pin both the
7579 /// SDK and CLI versions if your code depends on it.
7580 ///
7581 /// </div>
7582 pub async fn start_server(&self, params: McpStartServerRequest) -> Result<(), 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(rpc_methods::SESSION_MCP_STARTSERVER, Some(wire_params))
7589 .await?;
7590 Ok(())
7591 }
7592
7593 /// 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.
7594 ///
7595 /// Wire method: `session.mcp.startServer`.
7596 ///
7597 /// # Parameters
7598 ///
7599 /// * `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.
7600 ///
7601 /// <div class="warning">
7602 ///
7603 /// **Experimental.** This API is part of an experimental wire-protocol surface
7604 /// and may change or be removed in future SDK or CLI releases. Pin both the
7605 /// SDK and CLI versions if your code depends on it.
7606 ///
7607 /// </div>
7608 ///
7609 /// Accepts [`McpStartServerOptions`], including inputs added after [`McpStartServerRequest`].
7610 pub async fn start_server_with_options(
7611 &self,
7612 params: McpStartServerOptions,
7613 ) -> Result<(), Error> {
7614 let mut wire_params = serde_json::to_value(params)?;
7615 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7616 let _value = self
7617 .session
7618 .client()
7619 .call(rpc_methods::SESSION_MCP_STARTSERVER, Some(wire_params))
7620 .await?;
7621 Ok(())
7622 }
7623
7624 /// 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.*`).
7625 ///
7626 /// Wire method: `session.mcp.restartServer`.
7627 ///
7628 /// # Parameters
7629 ///
7630 /// * `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.
7631 ///
7632 /// <div class="warning">
7633 ///
7634 /// **Experimental.** This API is part of an experimental wire-protocol surface
7635 /// and may change or be removed in future SDK or CLI releases. Pin both the
7636 /// SDK and CLI versions if your code depends on it.
7637 ///
7638 /// </div>
7639 pub async fn restart_server(&self, params: McpRestartServerRequest) -> Result<(), Error> {
7640 let mut wire_params = serde_json::to_value(params)?;
7641 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7642 let _value = self
7643 .session
7644 .client()
7645 .call(rpc_methods::SESSION_MCP_RESTARTSERVER, Some(wire_params))
7646 .await?;
7647 Ok(())
7648 }
7649
7650 /// 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.*`).
7651 ///
7652 /// Wire method: `session.mcp.restartServer`.
7653 ///
7654 /// # Parameters
7655 ///
7656 /// * `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.
7657 ///
7658 /// <div class="warning">
7659 ///
7660 /// **Experimental.** This API is part of an experimental wire-protocol surface
7661 /// and may change or be removed in future SDK or CLI releases. Pin both the
7662 /// SDK and CLI versions if your code depends on it.
7663 ///
7664 /// </div>
7665 ///
7666 /// Accepts [`McpRestartServerOptions`], including inputs added after [`McpRestartServerRequest`].
7667 pub async fn restart_server_with_options(
7668 &self,
7669 params: McpRestartServerOptions,
7670 ) -> Result<(), Error> {
7671 let mut wire_params = serde_json::to_value(params)?;
7672 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7673 let _value = self
7674 .session
7675 .client()
7676 .call(rpc_methods::SESSION_MCP_RESTARTSERVER, Some(wire_params))
7677 .await?;
7678 Ok(())
7679 }
7680
7681 /// Stops an individual MCP server on the session's host.
7682 ///
7683 /// Wire method: `session.mcp.stopServer`.
7684 ///
7685 /// # Parameters
7686 ///
7687 /// * `params` - Server name for an individual MCP server stop.
7688 ///
7689 /// <div class="warning">
7690 ///
7691 /// **Experimental.** This API is part of an experimental wire-protocol surface
7692 /// and may change or be removed in future SDK or CLI releases. Pin both the
7693 /// SDK and CLI versions if your code depends on it.
7694 ///
7695 /// </div>
7696 pub async fn stop_server(&self, params: McpStopServerRequest) -> Result<(), Error> {
7697 let mut wire_params = serde_json::to_value(params)?;
7698 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7699 let _value = self
7700 .session
7701 .client()
7702 .call(rpc_methods::SESSION_MCP_STOPSERVER, Some(wire_params))
7703 .await?;
7704 Ok(())
7705 }
7706
7707 /// Stops an individual MCP server on the session's host.
7708 ///
7709 /// Wire method: `session.mcp.stopServer`.
7710 ///
7711 /// # Parameters
7712 ///
7713 /// * `params` - Server name for an individual MCP server stop.
7714 ///
7715 /// <div class="warning">
7716 ///
7717 /// **Experimental.** This API is part of an experimental wire-protocol surface
7718 /// and may change or be removed in future SDK or CLI releases. Pin both the
7719 /// SDK and CLI versions if your code depends on it.
7720 ///
7721 /// </div>
7722 ///
7723 /// Accepts [`McpStopServerOptions`], including inputs added after [`McpStopServerRequest`].
7724 pub async fn stop_server_with_options(
7725 &self,
7726 params: McpStopServerOptions,
7727 ) -> Result<(), Error> {
7728 let mut wire_params = serde_json::to_value(params)?;
7729 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7730 let _value = self
7731 .session
7732 .client()
7733 .call(rpc_methods::SESSION_MCP_STOPSERVER, Some(wire_params))
7734 .await?;
7735 Ok(())
7736 }
7737
7738 /// 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.
7739 ///
7740 /// Wire method: `session.mcp.registerExternalClient`.
7741 ///
7742 /// # Parameters
7743 ///
7744 /// * `params` - Registration parameters for an external MCP client.
7745 ///
7746 /// <div class="warning">
7747 ///
7748 /// **Experimental.** This API is part of an experimental wire-protocol surface
7749 /// and may change or be removed in future SDK or CLI releases. Pin both the
7750 /// SDK and CLI versions if your code depends on it.
7751 ///
7752 /// </div>
7753 pub(crate) async fn register_external_client(
7754 &self,
7755 params: McpRegisterExternalClientRequest,
7756 ) -> Result<(), Error> {
7757 let mut wire_params = serde_json::to_value(params)?;
7758 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7759 let _value = self
7760 .session
7761 .client()
7762 .call(
7763 rpc_methods::SESSION_MCP_REGISTEREXTERNALCLIENT,
7764 Some(wire_params),
7765 )
7766 .await?;
7767 Ok(())
7768 }
7769
7770 /// 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.
7771 ///
7772 /// Wire method: `session.mcp.unregisterExternalClient`.
7773 ///
7774 /// # Parameters
7775 ///
7776 /// * `params` - Server name identifying the external client to remove.
7777 ///
7778 /// <div class="warning">
7779 ///
7780 /// **Experimental.** This API is part of an experimental wire-protocol surface
7781 /// and may change or be removed in future SDK or CLI releases. Pin both the
7782 /// SDK and CLI versions if your code depends on it.
7783 ///
7784 /// </div>
7785 pub(crate) async fn unregister_external_client(
7786 &self,
7787 params: McpUnregisterExternalClientRequest,
7788 ) -> Result<(), Error> {
7789 let mut wire_params = serde_json::to_value(params)?;
7790 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7791 let _value = self
7792 .session
7793 .client()
7794 .call(
7795 rpc_methods::SESSION_MCP_UNREGISTEREXTERNALCLIENT,
7796 Some(wire_params),
7797 )
7798 .await?;
7799 Ok(())
7800 }
7801
7802 /// Checks whether a named MCP server is currently running on the session's host.
7803 ///
7804 /// Wire method: `session.mcp.isServerRunning`.
7805 ///
7806 /// # Parameters
7807 ///
7808 /// * `params` - Server name to check running status for.
7809 ///
7810 /// # Returns
7811 ///
7812 /// Whether the named MCP server is running.
7813 ///
7814 /// <div class="warning">
7815 ///
7816 /// **Experimental.** This API is part of an experimental wire-protocol surface
7817 /// and may change or be removed in future SDK or CLI releases. Pin both the
7818 /// SDK and CLI versions if your code depends on it.
7819 ///
7820 /// </div>
7821 pub async fn is_server_running(
7822 &self,
7823 params: McpIsServerRunningRequest,
7824 ) -> Result<McpIsServerRunningResult, Error> {
7825 let mut wire_params = serde_json::to_value(params)?;
7826 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7827 let _value = self
7828 .session
7829 .client()
7830 .call(rpc_methods::SESSION_MCP_ISSERVERRUNNING, Some(wire_params))
7831 .await?;
7832 Ok(serde_json::from_value(_value)?)
7833 }
7834}
7835
7836/// `session.mcp.apps.*` RPCs.
7837#[derive(Clone, Copy)]
7838pub struct SessionRpcMcpApps<'a> {
7839 pub(crate) session: &'a Session,
7840}
7841
7842impl<'a> SessionRpcMcpApps<'a> {
7843 /// Fetch an MCP resource (typically a `ui://` MCP App bundle, per SEP-1865) from a connected server. Requires the `mcp-apps` session capability.
7844 ///
7845 /// Wire method: `session.mcp.apps.readResource`.
7846 ///
7847 /// # Parameters
7848 ///
7849 /// * `params` - MCP server and resource URI to fetch.
7850 ///
7851 /// # Returns
7852 ///
7853 /// Resource contents returned by the MCP server.
7854 ///
7855 /// <div class="warning">
7856 ///
7857 /// **Experimental.** This API is part of an experimental wire-protocol surface
7858 /// and may change or be removed in future SDK or CLI releases. Pin both the
7859 /// SDK and CLI versions if your code depends on it.
7860 ///
7861 /// </div>
7862 pub async fn read_resource(
7863 &self,
7864 params: McpAppsReadResourceRequest,
7865 ) -> Result<McpAppsReadResourceResult, Error> {
7866 let mut wire_params = serde_json::to_value(params)?;
7867 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7868 let _value = self
7869 .session
7870 .client()
7871 .call(
7872 rpc_methods::SESSION_MCP_APPS_READRESOURCE,
7873 Some(wire_params),
7874 )
7875 .await?;
7876 Ok(serde_json::from_value(_value)?)
7877 }
7878
7879 /// 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"`.
7880 ///
7881 /// Wire method: `session.mcp.apps.listTools`.
7882 ///
7883 /// # Parameters
7884 ///
7885 /// * `params` - MCP server to list app-callable tools for.
7886 ///
7887 /// # Returns
7888 ///
7889 /// App-callable tools from the named MCP server.
7890 ///
7891 /// <div class="warning">
7892 ///
7893 /// **Experimental.** This API is part of an experimental wire-protocol surface
7894 /// and may change or be removed in future SDK or CLI releases. Pin both the
7895 /// SDK and CLI versions if your code depends on it.
7896 ///
7897 /// </div>
7898 pub async fn list_tools(
7899 &self,
7900 params: McpAppsListToolsRequest,
7901 ) -> Result<McpAppsListToolsResult, Error> {
7902 let mut wire_params = serde_json::to_value(params)?;
7903 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7904 let _value = self
7905 .session
7906 .client()
7907 .call(rpc_methods::SESSION_MCP_APPS_LISTTOOLS, Some(wire_params))
7908 .await?;
7909 Ok(serde_json::from_value(_value)?)
7910 }
7911
7912 /// 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`.
7913 ///
7914 /// Wire method: `session.mcp.apps.callTool`.
7915 ///
7916 /// # Parameters
7917 ///
7918 /// * `params` - MCP server, tool name, and arguments to invoke from an MCP App view.
7919 ///
7920 /// # Returns
7921 ///
7922 /// Standard MCP CallToolResult
7923 ///
7924 /// <div class="warning">
7925 ///
7926 /// **Experimental.** This API is part of an experimental wire-protocol surface
7927 /// and may change or be removed in future SDK or CLI releases. Pin both the
7928 /// SDK and CLI versions if your code depends on it.
7929 ///
7930 /// </div>
7931 pub async fn call_tool(
7932 &self,
7933 params: McpAppsCallToolRequest,
7934 ) -> Result<SessionMcpAppsCallToolResult, Error> {
7935 let mut wire_params = serde_json::to_value(params)?;
7936 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7937 let _value = self
7938 .session
7939 .client()
7940 .call(rpc_methods::SESSION_MCP_APPS_CALLTOOL, Some(wire_params))
7941 .await?;
7942 Ok(serde_json::from_value(_value)?)
7943 }
7944
7945 /// 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.
7946 ///
7947 /// Wire method: `session.mcp.apps.setHostContext`.
7948 ///
7949 /// # Parameters
7950 ///
7951 /// * `params` - Host context to advertise to MCP App guests.
7952 ///
7953 /// <div class="warning">
7954 ///
7955 /// **Experimental.** This API is part of an experimental wire-protocol surface
7956 /// and may change or be removed in future SDK or CLI releases. Pin both the
7957 /// SDK and CLI versions if your code depends on it.
7958 ///
7959 /// </div>
7960 pub async fn set_host_context(
7961 &self,
7962 params: McpAppsSetHostContextRequest,
7963 ) -> Result<(), Error> {
7964 let mut wire_params = serde_json::to_value(params)?;
7965 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7966 let _value = self
7967 .session
7968 .client()
7969 .call(
7970 rpc_methods::SESSION_MCP_APPS_SETHOSTCONTEXT,
7971 Some(wire_params),
7972 )
7973 .await?;
7974 Ok(())
7975 }
7976
7977 /// Read the current host context advertised to MCP App guests.
7978 ///
7979 /// Wire method: `session.mcp.apps.getHostContext`.
7980 ///
7981 /// # Returns
7982 ///
7983 /// Current host context advertised to MCP App guests.
7984 ///
7985 /// <div class="warning">
7986 ///
7987 /// **Experimental.** This API is part of an experimental wire-protocol surface
7988 /// and may change or be removed in future SDK or CLI releases. Pin both the
7989 /// SDK and CLI versions if your code depends on it.
7990 ///
7991 /// </div>
7992 pub async fn get_host_context(&self) -> Result<McpAppsHostContext, Error> {
7993 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7994 let _value = self
7995 .session
7996 .client()
7997 .call(
7998 rpc_methods::SESSION_MCP_APPS_GETHOSTCONTEXT,
7999 Some(wire_params),
8000 )
8001 .await?;
8002 Ok(serde_json::from_value(_value)?)
8003 }
8004
8005 /// 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.
8006 ///
8007 /// Wire method: `session.mcp.apps.diagnose`.
8008 ///
8009 /// # Parameters
8010 ///
8011 /// * `params` - MCP server to diagnose MCP Apps wiring for.
8012 ///
8013 /// # Returns
8014 ///
8015 /// Diagnostic snapshot of MCP Apps wiring for the named server.
8016 ///
8017 /// <div class="warning">
8018 ///
8019 /// **Experimental.** This API is part of an experimental wire-protocol surface
8020 /// and may change or be removed in future SDK or CLI releases. Pin both the
8021 /// SDK and CLI versions if your code depends on it.
8022 ///
8023 /// </div>
8024 pub async fn diagnose(
8025 &self,
8026 params: McpAppsDiagnoseRequest,
8027 ) -> Result<McpAppsDiagnoseResult, Error> {
8028 let mut wire_params = serde_json::to_value(params)?;
8029 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8030 let _value = self
8031 .session
8032 .client()
8033 .call(rpc_methods::SESSION_MCP_APPS_DIAGNOSE, Some(wire_params))
8034 .await?;
8035 Ok(serde_json::from_value(_value)?)
8036 }
8037}
8038
8039/// `session.mcp.headers.*` RPCs.
8040#[derive(Clone, Copy)]
8041pub struct SessionRpcMcpHeaders<'a> {
8042 pub(crate) session: &'a Session,
8043}
8044
8045impl<'a> SessionRpcMcpHeaders<'a> {
8046 /// 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.
8047 ///
8048 /// Wire method: `session.mcp.headers.handlePendingHeadersRefreshRequest`.
8049 ///
8050 /// # Parameters
8051 ///
8052 /// * `params` - MCP headers refresh request id and the host response.
8053 ///
8054 /// # Returns
8055 ///
8056 /// Indicates whether the pending MCP headers refresh response was accepted.
8057 ///
8058 /// <div class="warning">
8059 ///
8060 /// **Experimental.** This API is part of an experimental wire-protocol surface
8061 /// and may change or be removed in future SDK or CLI releases. Pin both the
8062 /// SDK and CLI versions if your code depends on it.
8063 ///
8064 /// </div>
8065 pub async fn handle_pending_headers_refresh_request(
8066 &self,
8067 params: McpHeadersHandlePendingHeadersRefreshRequestRequest,
8068 ) -> Result<McpHeadersHandlePendingHeadersRefreshRequestResult, Error> {
8069 let mut wire_params = serde_json::to_value(params)?;
8070 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8071 let _value = self
8072 .session
8073 .client()
8074 .call(
8075 rpc_methods::SESSION_MCP_HEADERS_HANDLEPENDINGHEADERSREFRESHREQUEST,
8076 Some(wire_params),
8077 )
8078 .await?;
8079 Ok(serde_json::from_value(_value)?)
8080 }
8081}
8082
8083/// `session.mcp.oauth.*` RPCs.
8084#[derive(Clone, Copy)]
8085pub struct SessionRpcMcpOauth<'a> {
8086 pub(crate) session: &'a Session,
8087}
8088
8089impl<'a> SessionRpcMcpOauth<'a> {
8090 /// 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.
8091 ///
8092 /// Wire method: `session.mcp.oauth.handlePendingRequest`.
8093 ///
8094 /// # Parameters
8095 ///
8096 /// * `params` - Pending MCP OAuth request ID and host-provided token or cancellation response.
8097 ///
8098 /// # Returns
8099 ///
8100 /// Indicates whether the pending MCP OAuth response was accepted.
8101 ///
8102 /// <div class="warning">
8103 ///
8104 /// **Experimental.** This API is part of an experimental wire-protocol surface
8105 /// and may change or be removed in future SDK or CLI releases. Pin both the
8106 /// SDK and CLI versions if your code depends on it.
8107 ///
8108 /// </div>
8109 pub async fn handle_pending_request(
8110 &self,
8111 params: McpOauthHandlePendingRequest,
8112 ) -> Result<McpOauthHandlePendingResult, Error> {
8113 let mut wire_params = serde_json::to_value(params)?;
8114 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8115 let _value = self
8116 .session
8117 .client()
8118 .call(
8119 rpc_methods::SESSION_MCP_OAUTH_HANDLEPENDINGREQUEST,
8120 Some(wire_params),
8121 )
8122 .await?;
8123 Ok(serde_json::from_value(_value)?)
8124 }
8125
8126 /// Notifies the session that MCP OAuth authentication succeeded and updated credentials were persisted, so cached tool definitions can be refreshed.
8127 ///
8128 /// Wire method: `session.mcp.oauth.authenticationStateChanged`.
8129 ///
8130 /// # Parameters
8131 ///
8132 /// * `params` - Identifies the MCP server whose persisted OAuth credentials were updated.
8133 ///
8134 /// <div class="warning">
8135 ///
8136 /// **Experimental.** This API is part of an experimental wire-protocol surface
8137 /// and may change or be removed in future SDK or CLI releases. Pin both the
8138 /// SDK and CLI versions if your code depends on it.
8139 ///
8140 /// </div>
8141 pub async fn authentication_state_changed(
8142 &self,
8143 params: McpOauthAuthenticationStateChangedRequest,
8144 ) -> Result<(), Error> {
8145 let mut wire_params = serde_json::to_value(params)?;
8146 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8147 let _value = self
8148 .session
8149 .client()
8150 .call(
8151 rpc_methods::SESSION_MCP_OAUTH_AUTHENTICATIONSTATECHANGED,
8152 Some(wire_params),
8153 )
8154 .await?;
8155 Ok(())
8156 }
8157
8158 /// Prepares an inert, expiring owned OAuth login bound to the original session requester and exact installation. Does not activate, connect, read credentials or open a browser.
8159 ///
8160 /// Wire method: `session.mcp.oauth.prepareLogin`.
8161 ///
8162 /// # Parameters
8163 ///
8164 /// * `params` - Effect-free preparation bound to the existing local session, requester and installation, with frozen options.
8165 ///
8166 /// # Returns
8167 ///
8168 /// An inert runtime-issued login handle. Preparation alone performs no activation or OAuth work.
8169 ///
8170 /// <div class="warning">
8171 ///
8172 /// **Experimental.** This API is part of an experimental wire-protocol surface
8173 /// and may change or be removed in future SDK or CLI releases. Pin both the
8174 /// SDK and CLI versions if your code depends on it.
8175 ///
8176 /// </div>
8177 pub async fn prepare_login(
8178 &self,
8179 params: SessionMcpOauthPrepareLoginParams,
8180 ) -> Result<McpOauthPrepareLoginResult, Error> {
8181 let mut wire_params = serde_json::to_value(params)?;
8182 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8183 let _value = self
8184 .session
8185 .client()
8186 .call(
8187 rpc_methods::SESSION_MCP_OAUTH_PREPARELOGIN,
8188 Some(wire_params),
8189 )
8190 .await?;
8191 Ok(serde_json::from_value(_value)?)
8192 }
8193
8194 /// Starts OAuth authentication for a remote MCP server. Owned servers require the original one-use prepareLogin handle and exact installation ID; manual servers retain the existing direct login behaviour.
8195 ///
8196 /// Wire method: `session.mcp.oauth.login`.
8197 ///
8198 /// # Parameters
8199 ///
8200 /// * `params` - Remote MCP server name and optional overrides controlling reauthentication, OAuth client display name, callback success-page copy, and static OAuth client selection.
8201 ///
8202 /// # Returns
8203 ///
8204 /// OAuth authorization URL the caller should open, or empty when cached tokens already authenticated the server.
8205 ///
8206 /// <div class="warning">
8207 ///
8208 /// **Experimental.** This API is part of an experimental wire-protocol surface
8209 /// and may change or be removed in future SDK or CLI releases. Pin both the
8210 /// SDK and CLI versions if your code depends on it.
8211 ///
8212 /// </div>
8213 pub async fn login(&self, params: McpOauthLoginRequest) -> Result<McpOauthLoginResult, Error> {
8214 let mut wire_params = serde_json::to_value(params)?;
8215 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8216 let _value = self
8217 .session
8218 .client()
8219 .call(rpc_methods::SESSION_MCP_OAUTH_LOGIN, Some(wire_params))
8220 .await?;
8221 Ok(serde_json::from_value(_value)?)
8222 }
8223
8224 /// Starts OAuth authentication for a remote MCP server. Owned servers require the original one-use prepareLogin handle and exact installation ID; manual servers retain the existing direct login behaviour.
8225 ///
8226 /// Wire method: `session.mcp.oauth.login`.
8227 ///
8228 /// # Parameters
8229 ///
8230 /// * `params` - Remote MCP server name and optional overrides controlling reauthentication, OAuth client display name, callback success-page copy, and static OAuth client selection.
8231 ///
8232 /// # Returns
8233 ///
8234 /// OAuth authorization URL the caller should open, or empty when cached tokens already authenticated the server.
8235 ///
8236 /// <div class="warning">
8237 ///
8238 /// **Experimental.** This API is part of an experimental wire-protocol surface
8239 /// and may change or be removed in future SDK or CLI releases. Pin both the
8240 /// SDK and CLI versions if your code depends on it.
8241 ///
8242 /// </div>
8243 ///
8244 /// Accepts [`McpOauthLoginOptions`], including inputs added after [`McpOauthLoginRequest`].
8245 pub async fn login_with_options(
8246 &self,
8247 params: McpOauthLoginOptions,
8248 ) -> Result<McpOauthLoginResult, Error> {
8249 let mut wire_params = serde_json::to_value(params)?;
8250 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8251 let _value = self
8252 .session
8253 .client()
8254 .call(rpc_methods::SESSION_MCP_OAUTH_LOGIN, Some(wire_params))
8255 .await?;
8256 Ok(serde_json::from_value(_value)?)
8257 }
8258
8259 /// 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.
8260 ///
8261 /// Wire method: `session.mcp.oauth.probe`.
8262 ///
8263 /// # Parameters
8264 ///
8265 /// * `params` - Remote MCP server name for a passive OAuth status probe.
8266 ///
8267 /// # Returns
8268 ///
8269 /// 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.
8270 ///
8271 /// <div class="warning">
8272 ///
8273 /// **Experimental.** This API is part of an experimental wire-protocol surface
8274 /// and may change or be removed in future SDK or CLI releases. Pin both the
8275 /// SDK and CLI versions if your code depends on it.
8276 ///
8277 /// </div>
8278 pub async fn probe(&self, params: McpOauthProbeRequest) -> Result<McpOauthProbeResult, Error> {
8279 let mut wire_params = serde_json::to_value(params)?;
8280 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8281 let _value = self
8282 .session
8283 .client()
8284 .call(rpc_methods::SESSION_MCP_OAUTH_PROBE, Some(wire_params))
8285 .await?;
8286 Ok(serde_json::from_value(_value)?)
8287 }
8288
8289 /// 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.
8290 ///
8291 /// Wire method: `session.mcp.oauth.probe`.
8292 ///
8293 /// # Parameters
8294 ///
8295 /// * `params` - Remote MCP server name for a passive OAuth status probe.
8296 ///
8297 /// # Returns
8298 ///
8299 /// 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.
8300 ///
8301 /// <div class="warning">
8302 ///
8303 /// **Experimental.** This API is part of an experimental wire-protocol surface
8304 /// and may change or be removed in future SDK or CLI releases. Pin both the
8305 /// SDK and CLI versions if your code depends on it.
8306 ///
8307 /// </div>
8308 ///
8309 /// Accepts [`McpOauthProbeOptions`], including inputs added after [`McpOauthProbeRequest`].
8310 pub async fn probe_with_options(
8311 &self,
8312 params: McpOauthProbeOptions,
8313 ) -> Result<McpOauthProbeResult, Error> {
8314 let mut wire_params = serde_json::to_value(params)?;
8315 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8316 let _value = self
8317 .session
8318 .client()
8319 .call(rpc_methods::SESSION_MCP_OAUTH_PROBE, Some(wire_params))
8320 .await?;
8321 Ok(serde_json::from_value(_value)?)
8322 }
8323
8324 /// Cancels the exact owned OAuth login issued to this original session requester, without clearing shared credentials.
8325 ///
8326 /// Wire method: `session.mcp.oauth.cancelLogin`.
8327 ///
8328 /// # Parameters
8329 ///
8330 /// * `params` - Targets only the original prepared/applying owned login on this exact session requester.
8331 ///
8332 /// # Returns
8333 ///
8334 /// Honest terminal cancellation result; persistence or recovery failures remain RPC errors.
8335 ///
8336 /// <div class="warning">
8337 ///
8338 /// **Experimental.** This API is part of an experimental wire-protocol surface
8339 /// and may change or be removed in future SDK or CLI releases. Pin both the
8340 /// SDK and CLI versions if your code depends on it.
8341 ///
8342 /// </div>
8343 pub async fn cancel_login(
8344 &self,
8345 params: SessionMcpOauthCancelLoginParams,
8346 ) -> Result<McpOauthCancelLoginResult, Error> {
8347 let mut wire_params = serde_json::to_value(params)?;
8348 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8349 let _value = self
8350 .session
8351 .client()
8352 .call(
8353 rpc_methods::SESSION_MCP_OAUTH_CANCELLOGIN,
8354 Some(wire_params),
8355 )
8356 .await?;
8357 Ok(serde_json::from_value(_value)?)
8358 }
8359
8360 /// Responds to a pending MCP OAuth authorization request by its request id.
8361 ///
8362 /// Wire method: `session.mcp.oauth.respond`.
8363 ///
8364 /// # Parameters
8365 ///
8366 /// * `params` - Pending MCP OAuth request id to respond to.
8367 ///
8368 /// # Returns
8369 ///
8370 /// Indicates whether the pending MCP OAuth response was accepted.
8371 ///
8372 /// <div class="warning">
8373 ///
8374 /// **Experimental.** This API is part of an experimental wire-protocol surface
8375 /// and may change or be removed in future SDK or CLI releases. Pin both the
8376 /// SDK and CLI versions if your code depends on it.
8377 ///
8378 /// </div>
8379 pub async fn respond(
8380 &self,
8381 params: McpOauthRespondRequest,
8382 ) -> Result<McpOauthRespondResult, Error> {
8383 let mut wire_params = serde_json::to_value(params)?;
8384 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8385 let _value = self
8386 .session
8387 .client()
8388 .call(rpc_methods::SESSION_MCP_OAUTH_RESPOND, Some(wire_params))
8389 .await?;
8390 Ok(serde_json::from_value(_value)?)
8391 }
8392}
8393
8394/// `session.mcp.resources.*` RPCs.
8395#[derive(Clone, Copy)]
8396pub struct SessionRpcMcpResources<'a> {
8397 pub(crate) session: &'a Session,
8398}
8399
8400impl<'a> SessionRpcMcpResources<'a> {
8401 /// Fetch an MCP resource from a connected server by URI (proxies MCP `resources/read`).
8402 ///
8403 /// Wire method: `session.mcp.resources.read`.
8404 ///
8405 /// # Parameters
8406 ///
8407 /// * `params` - MCP server and resource URI to fetch.
8408 ///
8409 /// # Returns
8410 ///
8411 /// Resource contents returned by the MCP server.
8412 ///
8413 /// <div class="warning">
8414 ///
8415 /// **Experimental.** This API is part of an experimental wire-protocol surface
8416 /// and may change or be removed in future SDK or CLI releases. Pin both the
8417 /// SDK and CLI versions if your code depends on it.
8418 ///
8419 /// </div>
8420 pub async fn read(
8421 &self,
8422 params: McpResourcesReadRequest,
8423 ) -> Result<McpResourcesReadResult, Error> {
8424 let mut wire_params = serde_json::to_value(params)?;
8425 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8426 let _value = self
8427 .session
8428 .client()
8429 .call(rpc_methods::SESSION_MCP_RESOURCES_READ, Some(wire_params))
8430 .await?;
8431 Ok(serde_json::from_value(_value)?)
8432 }
8433
8434 /// Enumerate one page of resources a connected MCP server exposes (proxies MCP `resources/list`). Pass `cursor` to continue from a prior result's `nextCursor`.
8435 ///
8436 /// Wire method: `session.mcp.resources.list`.
8437 ///
8438 /// # Parameters
8439 ///
8440 /// * `params` - MCP server whose resources to enumerate.
8441 ///
8442 /// # Returns
8443 ///
8444 /// One page of resources advertised by the named MCP server.
8445 ///
8446 /// <div class="warning">
8447 ///
8448 /// **Experimental.** This API is part of an experimental wire-protocol surface
8449 /// and may change or be removed in future SDK or CLI releases. Pin both the
8450 /// SDK and CLI versions if your code depends on it.
8451 ///
8452 /// </div>
8453 pub async fn list(
8454 &self,
8455 params: McpResourcesListRequest,
8456 ) -> Result<McpResourcesListResult, Error> {
8457 let mut wire_params = serde_json::to_value(params)?;
8458 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8459 let _value = self
8460 .session
8461 .client()
8462 .call(rpc_methods::SESSION_MCP_RESOURCES_LIST, Some(wire_params))
8463 .await?;
8464 Ok(serde_json::from_value(_value)?)
8465 }
8466
8467 /// 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`.
8468 ///
8469 /// Wire method: `session.mcp.resources.listTemplates`.
8470 ///
8471 /// # Parameters
8472 ///
8473 /// * `params` - MCP server whose resource templates to enumerate.
8474 ///
8475 /// # Returns
8476 ///
8477 /// One page of resource templates advertised by the named MCP server.
8478 ///
8479 /// <div class="warning">
8480 ///
8481 /// **Experimental.** This API is part of an experimental wire-protocol surface
8482 /// and may change or be removed in future SDK or CLI releases. Pin both the
8483 /// SDK and CLI versions if your code depends on it.
8484 ///
8485 /// </div>
8486 pub async fn list_templates(
8487 &self,
8488 params: McpResourcesListTemplatesRequest,
8489 ) -> Result<McpResourcesListTemplatesResult, Error> {
8490 let mut wire_params = serde_json::to_value(params)?;
8491 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8492 let _value = self
8493 .session
8494 .client()
8495 .call(
8496 rpc_methods::SESSION_MCP_RESOURCES_LISTTEMPLATES,
8497 Some(wire_params),
8498 )
8499 .await?;
8500 Ok(serde_json::from_value(_value)?)
8501 }
8502}
8503
8504/// `session.metadata.*` RPCs.
8505#[derive(Clone, Copy)]
8506pub struct SessionRpcMetadata<'a> {
8507 pub(crate) session: &'a Session,
8508}
8509
8510impl<'a> SessionRpcMetadata<'a> {
8511 /// Returns a snapshot of the session's identifying metadata, mode, agent, and remote info.
8512 ///
8513 /// Wire method: `session.metadata.snapshot`.
8514 ///
8515 /// # Returns
8516 ///
8517 /// Point-in-time snapshot of slow-changing session identifier and state fields
8518 ///
8519 /// <div class="warning">
8520 ///
8521 /// **Experimental.** This API is part of an experimental wire-protocol surface
8522 /// and may change or be removed in future SDK or CLI releases. Pin both the
8523 /// SDK and CLI versions if your code depends on it.
8524 ///
8525 /// </div>
8526 pub async fn snapshot(&self) -> Result<SessionMetadataSnapshot, Error> {
8527 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8528 let _value = self
8529 .session
8530 .client()
8531 .call(rpc_methods::SESSION_METADATA_SNAPSHOT, Some(wire_params))
8532 .await?;
8533 Ok(serde_json::from_value(_value)?)
8534 }
8535
8536 /// 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.
8537 ///
8538 /// Wire method: `session.metadata.getClientMetadata`.
8539 ///
8540 /// # Returns
8541 ///
8542 /// 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.
8543 ///
8544 /// <div class="warning">
8545 ///
8546 /// **Experimental.** This API is part of an experimental wire-protocol surface
8547 /// and may change or be removed in future SDK or CLI releases. Pin both the
8548 /// SDK and CLI versions if your code depends on it.
8549 ///
8550 /// </div>
8551 pub async fn get_client_metadata(&self) -> Result<ClientMetadata, Error> {
8552 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8553 let _value = self
8554 .session
8555 .client()
8556 .call(
8557 rpc_methods::SESSION_METADATA_GETCLIENTMETADATA,
8558 Some(wire_params),
8559 )
8560 .await?;
8561 Ok(serde_json::from_value(_value)?)
8562 }
8563
8564 /// Atomically patches the client-owned string metadata persisted with this local session and returns the committed bag.
8565 ///
8566 /// Wire method: `session.metadata.updateClientMetadata`.
8567 ///
8568 /// # Parameters
8569 ///
8570 /// * `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.
8571 ///
8572 /// # Returns
8573 ///
8574 /// 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.
8575 ///
8576 /// <div class="warning">
8577 ///
8578 /// **Experimental.** This API is part of an experimental wire-protocol surface
8579 /// and may change or be removed in future SDK or CLI releases. Pin both the
8580 /// SDK and CLI versions if your code depends on it.
8581 ///
8582 /// </div>
8583 pub async fn update_client_metadata(
8584 &self,
8585 params: MetadataUpdateClientMetadataRequest,
8586 ) -> Result<ClientMetadata, Error> {
8587 let mut wire_params = serde_json::to_value(params)?;
8588 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8589 let _value = self
8590 .session
8591 .client()
8592 .call(
8593 rpc_methods::SESSION_METADATA_UPDATECLIENTMETADATA,
8594 Some(wire_params),
8595 )
8596 .await?;
8597 Ok(serde_json::from_value(_value)?)
8598 }
8599
8600 /// Reports whether the local session is currently processing user/agent messages.
8601 ///
8602 /// Wire method: `session.metadata.isProcessing`.
8603 ///
8604 /// # Returns
8605 ///
8606 /// Indicates whether the local session is currently processing a turn or background continuation.
8607 ///
8608 /// <div class="warning">
8609 ///
8610 /// **Experimental.** This API is part of an experimental wire-protocol surface
8611 /// and may change or be removed in future SDK or CLI releases. Pin both the
8612 /// SDK and CLI versions if your code depends on it.
8613 ///
8614 /// </div>
8615 pub async fn is_processing(&self) -> Result<MetadataIsProcessingResult, Error> {
8616 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8617 let _value = self
8618 .session
8619 .client()
8620 .call(
8621 rpc_methods::SESSION_METADATA_ISPROCESSING,
8622 Some(wire_params),
8623 )
8624 .await?;
8625 Ok(serde_json::from_value(_value)?)
8626 }
8627
8628 /// Returns a snapshot of activity flags for the session.
8629 ///
8630 /// Wire method: `session.metadata.activity`.
8631 ///
8632 /// # Returns
8633 ///
8634 /// Current activity flags for the session.
8635 ///
8636 /// <div class="warning">
8637 ///
8638 /// **Experimental.** This API is part of an experimental wire-protocol surface
8639 /// and may change or be removed in future SDK or CLI releases. Pin both the
8640 /// SDK and CLI versions if your code depends on it.
8641 ///
8642 /// </div>
8643 pub async fn activity(&self) -> Result<SessionActivity, Error> {
8644 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8645 let _value = self
8646 .session
8647 .client()
8648 .call(rpc_methods::SESSION_METADATA_ACTIVITY, Some(wire_params))
8649 .await?;
8650 Ok(serde_json::from_value(_value)?)
8651 }
8652
8653 /// Returns the token breakdown for the session's current context window for a given model.
8654 ///
8655 /// Wire method: `session.metadata.contextInfo`.
8656 ///
8657 /// # Parameters
8658 ///
8659 /// * `params` - Model identifier and token limits used to compute the context-info breakdown.
8660 ///
8661 /// # Returns
8662 ///
8663 /// Token breakdown for the session's current context window, or null if uninitialized.
8664 ///
8665 /// <div class="warning">
8666 ///
8667 /// **Experimental.** This API is part of an experimental wire-protocol surface
8668 /// and may change or be removed in future SDK or CLI releases. Pin both the
8669 /// SDK and CLI versions if your code depends on it.
8670 ///
8671 /// </div>
8672 pub async fn context_info(
8673 &self,
8674 params: MetadataContextInfoRequest,
8675 ) -> Result<MetadataContextInfoResult, Error> {
8676 let mut wire_params = serde_json::to_value(params)?;
8677 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8678 let _value = self
8679 .session
8680 .client()
8681 .call(rpc_methods::SESSION_METADATA_CONTEXTINFO, Some(wire_params))
8682 .await?;
8683 Ok(serde_json::from_value(_value)?)
8684 }
8685
8686 /// 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.
8687 ///
8688 /// Wire method: `session.metadata.getContextAttribution`.
8689 ///
8690 /// # Returns
8691 ///
8692 /// Per-source attribution breakdown for the session's current context window, or null if uninitialized.
8693 ///
8694 /// <div class="warning">
8695 ///
8696 /// **Experimental.** This API is part of an experimental wire-protocol surface
8697 /// and may change or be removed in future SDK or CLI releases. Pin both the
8698 /// SDK and CLI versions if your code depends on it.
8699 ///
8700 /// </div>
8701 pub async fn get_context_attribution(&self) -> Result<MetadataContextAttributionResult, Error> {
8702 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8703 let _value = self
8704 .session
8705 .client()
8706 .call(
8707 rpc_methods::SESSION_METADATA_GETCONTEXTATTRIBUTION,
8708 Some(wire_params),
8709 )
8710 .await?;
8711 Ok(serde_json::from_value(_value)?)
8712 }
8713
8714 /// 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.
8715 ///
8716 /// Wire method: `session.metadata.getContextHeaviestMessages`.
8717 ///
8718 /// # Parameters
8719 ///
8720 /// * `params` - Parameters for the heaviest-messages query.
8721 ///
8722 /// # Returns
8723 ///
8724 /// The heaviest individual messages in the session's context window, most-expensive first.
8725 ///
8726 /// <div class="warning">
8727 ///
8728 /// **Experimental.** This API is part of an experimental wire-protocol surface
8729 /// and may change or be removed in future SDK or CLI releases. Pin both the
8730 /// SDK and CLI versions if your code depends on it.
8731 ///
8732 /// </div>
8733 pub async fn get_context_heaviest_messages(
8734 &self,
8735 params: MetadataContextHeaviestMessagesRequest,
8736 ) -> Result<MetadataContextHeaviestMessagesResult, Error> {
8737 let mut wire_params = serde_json::to_value(params)?;
8738 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8739 let _value = self
8740 .session
8741 .client()
8742 .call(
8743 rpc_methods::SESSION_METADATA_GETCONTEXTHEAVIESTMESSAGES,
8744 Some(wire_params),
8745 )
8746 .await?;
8747 Ok(serde_json::from_value(_value)?)
8748 }
8749
8750 /// 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.
8751 ///
8752 /// Wire method: `session.metadata.recordContextChange`.
8753 ///
8754 /// # Parameters
8755 ///
8756 /// * `params` - Updated working-directory/git context to record on the session.
8757 ///
8758 /// # Returns
8759 ///
8760 /// 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.
8761 ///
8762 /// <div class="warning">
8763 ///
8764 /// **Experimental.** This API is part of an experimental wire-protocol surface
8765 /// and may change or be removed in future SDK or CLI releases. Pin both the
8766 /// SDK and CLI versions if your code depends on it.
8767 ///
8768 /// </div>
8769 pub async fn record_context_change(
8770 &self,
8771 params: MetadataRecordContextChangeRequest,
8772 ) -> Result<MetadataRecordContextChangeResult, Error> {
8773 let mut wire_params = serde_json::to_value(params)?;
8774 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8775 let _value = self
8776 .session
8777 .client()
8778 .call(
8779 rpc_methods::SESSION_METADATA_RECORDCONTEXTCHANGE,
8780 Some(wire_params),
8781 )
8782 .await?;
8783 Ok(serde_json::from_value(_value)?)
8784 }
8785
8786 /// 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.
8787 ///
8788 /// Wire method: `session.metadata.setWorkingDirectory`.
8789 ///
8790 /// # Parameters
8791 ///
8792 /// * `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.
8793 ///
8794 /// # Returns
8795 ///
8796 /// 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.
8797 ///
8798 /// <div class="warning">
8799 ///
8800 /// **Experimental.** This API is part of an experimental wire-protocol surface
8801 /// and may change or be removed in future SDK or CLI releases. Pin both the
8802 /// SDK and CLI versions if your code depends on it.
8803 ///
8804 /// </div>
8805 pub async fn set_working_directory(
8806 &self,
8807 params: MetadataSetWorkingDirectoryRequest,
8808 ) -> Result<MetadataSetWorkingDirectoryResult, Error> {
8809 let mut wire_params = serde_json::to_value(params)?;
8810 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8811 let _value = self
8812 .session
8813 .client()
8814 .call(
8815 rpc_methods::SESSION_METADATA_SETWORKINGDIRECTORY,
8816 Some(wire_params),
8817 )
8818 .await?;
8819 Ok(serde_json::from_value(_value)?)
8820 }
8821
8822 /// Re-tokenizes the session's existing messages against a model and returns aggregate token totals.
8823 ///
8824 /// Wire method: `session.metadata.recomputeContextTokens`.
8825 ///
8826 /// # Parameters
8827 ///
8828 /// * `params` - Model identifier to use when re-tokenizing the session's existing messages.
8829 ///
8830 /// # Returns
8831 ///
8832 /// 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.
8833 ///
8834 /// <div class="warning">
8835 ///
8836 /// **Experimental.** This API is part of an experimental wire-protocol surface
8837 /// and may change or be removed in future SDK or CLI releases. Pin both the
8838 /// SDK and CLI versions if your code depends on it.
8839 ///
8840 /// </div>
8841 pub async fn recompute_context_tokens(
8842 &self,
8843 params: MetadataRecomputeContextTokensRequest,
8844 ) -> Result<MetadataRecomputeContextTokensResult, Error> {
8845 let mut wire_params = serde_json::to_value(params)?;
8846 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8847 let _value = self
8848 .session
8849 .client()
8850 .call(
8851 rpc_methods::SESSION_METADATA_RECOMPUTECONTEXTTOKENS,
8852 Some(wire_params),
8853 )
8854 .await?;
8855 Ok(serde_json::from_value(_value)?)
8856 }
8857}
8858
8859/// `session.mode.*` RPCs.
8860#[derive(Clone, Copy)]
8861pub struct SessionRpcMode<'a> {
8862 pub(crate) session: &'a Session,
8863}
8864
8865impl<'a> SessionRpcMode<'a> {
8866 /// Gets the current agent interaction mode.
8867 ///
8868 /// Wire method: `session.mode.get`.
8869 ///
8870 /// # Returns
8871 ///
8872 /// The session mode the agent is operating in
8873 ///
8874 /// <div class="warning">
8875 ///
8876 /// **Experimental.** This API is part of an experimental wire-protocol surface
8877 /// and may change or be removed in future SDK or CLI releases. Pin both the
8878 /// SDK and CLI versions if your code depends on it.
8879 ///
8880 /// </div>
8881 pub async fn get(&self) -> Result<SessionMode, Error> {
8882 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8883 let _value = self
8884 .session
8885 .client()
8886 .call(rpc_methods::SESSION_MODE_GET, Some(wire_params))
8887 .await?;
8888 Ok(serde_json::from_value(_value)?)
8889 }
8890
8891 /// Sets the current agent interaction mode.
8892 ///
8893 /// Wire method: `session.mode.set`.
8894 ///
8895 /// # Parameters
8896 ///
8897 /// * `params` - Agent interaction mode to apply to the session.
8898 ///
8899 /// # Returns
8900 ///
8901 /// Outcome of a session mode change, including any model switch it triggered and follow-up the host must perform.
8902 ///
8903 /// <div class="warning">
8904 ///
8905 /// **Experimental.** This API is part of an experimental wire-protocol surface
8906 /// and may change or be removed in future SDK or CLI releases. Pin both the
8907 /// SDK and CLI versions if your code depends on it.
8908 ///
8909 /// </div>
8910 pub async fn set(&self, params: ModeSetRequest) -> Result<ModeSetResult, Error> {
8911 let mut wire_params = serde_json::to_value(params)?;
8912 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8913 let _value = self
8914 .session
8915 .client()
8916 .call(rpc_methods::SESSION_MODE_SET, Some(wire_params))
8917 .await?;
8918 Ok(serde_json::from_value(_value)?)
8919 }
8920}
8921
8922/// `session.model.*` RPCs.
8923#[derive(Clone, Copy)]
8924pub struct SessionRpcModel<'a> {
8925 pub(crate) session: &'a Session,
8926}
8927
8928impl<'a> SessionRpcModel<'a> {
8929 /// Gets the session's authoritative model snapshot, including the committed Auto preference and any newer unclaimed Auto preference waiting for a future user turn.
8930 ///
8931 /// Wire method: `session.model.getCurrent`.
8932 ///
8933 /// # Returns
8934 ///
8935 /// 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.
8936 ///
8937 /// <div class="warning">
8938 ///
8939 /// **Experimental.** This API is part of an experimental wire-protocol surface
8940 /// and may change or be removed in future SDK or CLI releases. Pin both the
8941 /// SDK and CLI versions if your code depends on it.
8942 ///
8943 /// </div>
8944 pub async fn get_current(&self) -> Result<CurrentModel, Error> {
8945 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8946 let _value = self
8947 .session
8948 .client()
8949 .call(rpc_methods::SESSION_MODEL_GETCURRENT, Some(wire_params))
8950 .await?;
8951 Ok(serde_json::from_value(_value)?)
8952 }
8953
8954 /// Switches the session to a model and optional reasoning configuration.
8955 ///
8956 /// Wire method: `session.model.switchTo`.
8957 ///
8958 /// # Parameters
8959 ///
8960 /// * `params` - Target model identifier and optional reasoning effort, summary, capability overrides, and context tier.
8961 ///
8962 /// # Returns
8963 ///
8964 /// The model identifier active on the session after the switch.
8965 ///
8966 /// <div class="warning">
8967 ///
8968 /// **Experimental.** This API is part of an experimental wire-protocol surface
8969 /// and may change or be removed in future SDK or CLI releases. Pin both the
8970 /// SDK and CLI versions if your code depends on it.
8971 ///
8972 /// </div>
8973 pub async fn switch_to(
8974 &self,
8975 params: ModelSwitchToRequest,
8976 ) -> Result<ModelSwitchToResult, Error> {
8977 let mut wire_params = serde_json::to_value(params)?;
8978 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8979 let _value = self
8980 .session
8981 .client()
8982 .call(rpc_methods::SESSION_MODEL_SWITCHTO, Some(wire_params))
8983 .await?;
8984 Ok(serde_json::from_value(_value)?)
8985 }
8986
8987 /// 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`.
8988 ///
8989 /// Wire method: `session.model.switchAutoTier`.
8990 ///
8991 /// # Parameters
8992 ///
8993 /// * `params` - An Auto preference request for the session. This updates Auto configuration only; it does not change the selected model to `auto`.
8994 ///
8995 /// # Returns
8996 ///
8997 /// Immediate acknowledgement and Auto preference snapshot after a switch request. This result never implies that a pending preference committed.
8998 ///
8999 /// <div class="warning">
9000 ///
9001 /// **Experimental.** This API is part of an experimental wire-protocol surface
9002 /// and may change or be removed in future SDK or CLI releases. Pin both the
9003 /// SDK and CLI versions if your code depends on it.
9004 ///
9005 /// </div>
9006 pub async fn switch_auto_tier(
9007 &self,
9008 params: ModelSwitchAutoTierRequest,
9009 ) -> Result<ModelSwitchAutoTierResult, Error> {
9010 let mut wire_params = serde_json::to_value(params)?;
9011 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9012 let _value = self
9013 .session
9014 .client()
9015 .call(rpc_methods::SESSION_MODEL_SWITCHAUTOTIER, Some(wire_params))
9016 .await?;
9017 Ok(serde_json::from_value(_value)?)
9018 }
9019
9020 /// Resolves and applies organization-managed and repository model overlays.
9021 ///
9022 /// Wire method: `session.model.applyStartupOverlay`.
9023 ///
9024 /// # Parameters
9025 ///
9026 /// * `params` - Managed, repository, and CLI model overrides to overlay onto the session at startup.
9027 ///
9028 /// # Returns
9029 ///
9030 /// The model identifier active on the session after the switch.
9031 ///
9032 /// <div class="warning">
9033 ///
9034 /// **Experimental.** This API is part of an experimental wire-protocol surface
9035 /// and may change or be removed in future SDK or CLI releases. Pin both the
9036 /// SDK and CLI versions if your code depends on it.
9037 ///
9038 /// </div>
9039 pub(crate) async fn apply_startup_overlay(
9040 &self,
9041 params: ModelApplyStartupOverlayRequest,
9042 ) -> Result<ModelSwitchToResult, Error> {
9043 let mut wire_params = serde_json::to_value(params)?;
9044 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9045 let _value = self
9046 .session
9047 .client()
9048 .call(
9049 rpc_methods::SESSION_MODEL_APPLYSTARTUPOVERLAY,
9050 Some(wire_params),
9051 )
9052 .await?;
9053 Ok(serde_json::from_value(_value)?)
9054 }
9055
9056 /// Replaces or clears the host-supplied model allowlist for a running session.
9057 ///
9058 /// Wire method: `session.model.setAllowedModels`.
9059 ///
9060 /// # Parameters
9061 ///
9062 /// * `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.
9063 ///
9064 /// # Returns
9065 ///
9066 /// The applied host allowlist and effective session model policy after intersection.
9067 ///
9068 /// <div class="warning">
9069 ///
9070 /// **Experimental.** This API is part of an experimental wire-protocol surface
9071 /// and may change or be removed in future SDK or CLI releases. Pin both the
9072 /// SDK and CLI versions if your code depends on it.
9073 ///
9074 /// </div>
9075 pub async fn set_allowed_models(
9076 &self,
9077 params: ModelSetAllowedModelsRequest,
9078 ) -> Result<ModelSetAllowedModelsResult, Error> {
9079 let mut wire_params = serde_json::to_value(params)?;
9080 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9081 let _value = self
9082 .session
9083 .client()
9084 .call(
9085 rpc_methods::SESSION_MODEL_SETALLOWEDMODELS,
9086 Some(wire_params),
9087 )
9088 .await?;
9089 Ok(serde_json::from_value(_value)?)
9090 }
9091
9092 /// Updates the session's reasoning effort without changing the selected model.
9093 ///
9094 /// Wire method: `session.model.setReasoningEffort`.
9095 ///
9096 /// # Parameters
9097 ///
9098 /// * `params` - Reasoning effort level to apply to the currently selected model.
9099 ///
9100 /// # Returns
9101 ///
9102 /// 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.
9103 ///
9104 /// <div class="warning">
9105 ///
9106 /// **Experimental.** This API is part of an experimental wire-protocol surface
9107 /// and may change or be removed in future SDK or CLI releases. Pin both the
9108 /// SDK and CLI versions if your code depends on it.
9109 ///
9110 /// </div>
9111 pub async fn set_reasoning_effort(
9112 &self,
9113 params: ModelSetReasoningEffortRequest,
9114 ) -> Result<ModelSetReasoningEffortResult, Error> {
9115 let mut wire_params = serde_json::to_value(params)?;
9116 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9117 let _value = self
9118 .session
9119 .client()
9120 .call(
9121 rpc_methods::SESSION_MODEL_SETREASONINGEFFORT,
9122 Some(wire_params),
9123 )
9124 .await?;
9125 Ok(serde_json::from_value(_value)?)
9126 }
9127
9128 /// 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.
9129 ///
9130 /// Wire method: `session.model.list`.
9131 ///
9132 /// # Returns
9133 ///
9134 /// The list of models available to this session.
9135 ///
9136 /// <div class="warning">
9137 ///
9138 /// **Experimental.** This API is part of an experimental wire-protocol surface
9139 /// and may change or be removed in future SDK or CLI releases. Pin both the
9140 /// SDK and CLI versions if your code depends on it.
9141 ///
9142 /// </div>
9143 pub async fn list(&self) -> Result<SessionModelList, Error> {
9144 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9145 let _value = self
9146 .session
9147 .client()
9148 .call(rpc_methods::SESSION_MODEL_LIST, Some(wire_params))
9149 .await?;
9150 Ok(serde_json::from_value(_value)?)
9151 }
9152
9153 /// 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.
9154 ///
9155 /// Wire method: `session.model.list`.
9156 ///
9157 /// # Parameters
9158 ///
9159 /// * `params` - Optional listing options.
9160 ///
9161 /// # Returns
9162 ///
9163 /// The list of models available to this session.
9164 ///
9165 /// <div class="warning">
9166 ///
9167 /// **Experimental.** This API is part of an experimental wire-protocol surface
9168 /// and may change or be removed in future SDK or CLI releases. Pin both the
9169 /// SDK and CLI versions if your code depends on it.
9170 ///
9171 /// </div>
9172 pub async fn list_with_params(
9173 &self,
9174 params: ModelListRequest,
9175 ) -> Result<SessionModelList, Error> {
9176 let mut wire_params = serde_json::to_value(params)?;
9177 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9178 let _value = self
9179 .session
9180 .client()
9181 .call(rpc_methods::SESSION_MODEL_LIST, Some(wire_params))
9182 .await?;
9183 Ok(serde_json::from_value(_value)?)
9184 }
9185}
9186
9187/// `session.name.*` RPCs.
9188#[derive(Clone, Copy)]
9189pub struct SessionRpcName<'a> {
9190 pub(crate) session: &'a Session,
9191}
9192
9193impl<'a> SessionRpcName<'a> {
9194 /// Gets the session's friendly name.
9195 ///
9196 /// Wire method: `session.name.get`.
9197 ///
9198 /// # Returns
9199 ///
9200 /// The session's friendly name, or null when not yet set.
9201 ///
9202 /// <div class="warning">
9203 ///
9204 /// **Experimental.** This API is part of an experimental wire-protocol surface
9205 /// and may change or be removed in future SDK or CLI releases. Pin both the
9206 /// SDK and CLI versions if your code depends on it.
9207 ///
9208 /// </div>
9209 pub async fn get(&self) -> Result<NameGetResult, Error> {
9210 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9211 let _value = self
9212 .session
9213 .client()
9214 .call(rpc_methods::SESSION_NAME_GET, Some(wire_params))
9215 .await?;
9216 Ok(serde_json::from_value(_value)?)
9217 }
9218
9219 /// Sets the session's friendly name.
9220 ///
9221 /// Wire method: `session.name.set`.
9222 ///
9223 /// # Parameters
9224 ///
9225 /// * `params` - New friendly name to apply to the session.
9226 ///
9227 /// <div class="warning">
9228 ///
9229 /// **Experimental.** This API is part of an experimental wire-protocol surface
9230 /// and may change or be removed in future SDK or CLI releases. Pin both the
9231 /// SDK and CLI versions if your code depends on it.
9232 ///
9233 /// </div>
9234 pub async fn set(&self, params: NameSetRequest) -> Result<(), Error> {
9235 let mut wire_params = serde_json::to_value(params)?;
9236 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9237 let _value = self
9238 .session
9239 .client()
9240 .call(rpc_methods::SESSION_NAME_SET, Some(wire_params))
9241 .await?;
9242 Ok(())
9243 }
9244
9245 /// Persists an auto-generated session summary as the session's name when no user-set name exists.
9246 ///
9247 /// Wire method: `session.name.setAuto`.
9248 ///
9249 /// # Parameters
9250 ///
9251 /// * `params` - Auto-generated session summary to apply as the session's name when no user-set name exists.
9252 ///
9253 /// # Returns
9254 ///
9255 /// Indicates whether the auto-generated summary was applied as the session's name.
9256 ///
9257 /// <div class="warning">
9258 ///
9259 /// **Experimental.** This API is part of an experimental wire-protocol surface
9260 /// and may change or be removed in future SDK or CLI releases. Pin both the
9261 /// SDK and CLI versions if your code depends on it.
9262 ///
9263 /// </div>
9264 pub async fn set_auto(&self, params: NameSetAutoRequest) -> Result<NameSetAutoResult, Error> {
9265 let mut wire_params = serde_json::to_value(params)?;
9266 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9267 let _value = self
9268 .session
9269 .client()
9270 .call(rpc_methods::SESSION_NAME_SETAUTO, Some(wire_params))
9271 .await?;
9272 Ok(serde_json::from_value(_value)?)
9273 }
9274}
9275
9276/// `session.options.*` RPCs.
9277#[derive(Clone, Copy)]
9278pub struct SessionRpcOptions<'a> {
9279 pub(crate) session: &'a Session,
9280}
9281
9282impl<'a> SessionRpcOptions<'a> {
9283 /// Patches the genuinely-mutable subset of session options.
9284 ///
9285 /// Wire method: `session.options.update`.
9286 ///
9287 /// # Parameters
9288 ///
9289 /// * `params` - Patch of mutable session options to apply to the running session.
9290 ///
9291 /// # Returns
9292 ///
9293 /// Indicates whether the session options patch was applied successfully.
9294 ///
9295 /// <div class="warning">
9296 ///
9297 /// **Experimental.** This API is part of an experimental wire-protocol surface
9298 /// and may change or be removed in future SDK or CLI releases. Pin both the
9299 /// SDK and CLI versions if your code depends on it.
9300 ///
9301 /// </div>
9302 pub async fn update(
9303 &self,
9304 params: SessionUpdateOptionsParams,
9305 ) -> Result<SessionUpdateOptionsResult, Error> {
9306 let mut wire_params = serde_json::to_value(params)?;
9307 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9308 let _value = self
9309 .session
9310 .client()
9311 .call(rpc_methods::SESSION_OPTIONS_UPDATE, Some(wire_params))
9312 .await?;
9313 Ok(serde_json::from_value(_value)?)
9314 }
9315}
9316
9317/// `session.permissions.*` RPCs.
9318#[derive(Clone, Copy)]
9319pub struct SessionRpcPermissions<'a> {
9320 pub(crate) session: &'a Session,
9321}
9322
9323impl<'a> SessionRpcPermissions<'a> {
9324 /// `session.permissions.folderTrust.*` sub-namespace.
9325 pub fn folder_trust(&self) -> SessionRpcPermissionsFolderTrust<'a> {
9326 SessionRpcPermissionsFolderTrust {
9327 session: self.session,
9328 }
9329 }
9330
9331 /// `session.permissions.locations.*` sub-namespace.
9332 pub fn locations(&self) -> SessionRpcPermissionsLocations<'a> {
9333 SessionRpcPermissionsLocations {
9334 session: self.session,
9335 }
9336 }
9337
9338 /// `session.permissions.paths.*` sub-namespace.
9339 pub fn paths(&self) -> SessionRpcPermissionsPaths<'a> {
9340 SessionRpcPermissionsPaths {
9341 session: self.session,
9342 }
9343 }
9344
9345 /// `session.permissions.urls.*` sub-namespace.
9346 pub fn urls(&self) -> SessionRpcPermissionsUrls<'a> {
9347 SessionRpcPermissionsUrls {
9348 session: self.session,
9349 }
9350 }
9351
9352 /// Replaces selected permission policy fields (rules, paths, URLs, exclusions, allow-all flags) on the session.
9353 ///
9354 /// Wire method: `session.permissions.configure`.
9355 ///
9356 /// # Parameters
9357 ///
9358 /// * `params` - Patch of permission policy fields to apply (omit a field to leave it unchanged).
9359 ///
9360 /// # Returns
9361 ///
9362 /// Indicates whether the operation succeeded.
9363 ///
9364 /// <div class="warning">
9365 ///
9366 /// **Experimental.** This API is part of an experimental wire-protocol surface
9367 /// and may change or be removed in future SDK or CLI releases. Pin both the
9368 /// SDK and CLI versions if your code depends on it.
9369 ///
9370 /// </div>
9371 pub async fn configure(
9372 &self,
9373 params: PermissionsConfigureParams,
9374 ) -> Result<PermissionsConfigureResult, Error> {
9375 let mut wire_params = serde_json::to_value(params)?;
9376 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9377 let _value = self
9378 .session
9379 .client()
9380 .call(
9381 rpc_methods::SESSION_PERMISSIONS_CONFIGURE,
9382 Some(wire_params),
9383 )
9384 .await?;
9385 Ok(serde_json::from_value(_value)?)
9386 }
9387
9388 /// Provides a decision for a pending tool permission request.
9389 ///
9390 /// Wire method: `session.permissions.handlePendingPermissionRequest`.
9391 ///
9392 /// # Parameters
9393 ///
9394 /// * `params` - Pending permission request ID and the decision to apply (approve/reject and scope).
9395 ///
9396 /// # Returns
9397 ///
9398 /// Indicates whether the permission decision was applied; false when the request was already resolved.
9399 ///
9400 /// <div class="warning">
9401 ///
9402 /// **Experimental.** This API is part of an experimental wire-protocol surface
9403 /// and may change or be removed in future SDK or CLI releases. Pin both the
9404 /// SDK and CLI versions if your code depends on it.
9405 ///
9406 /// </div>
9407 pub async fn handle_pending_permission_request(
9408 &self,
9409 params: PermissionDecisionRequest,
9410 ) -> Result<PermissionRequestResult, Error> {
9411 let mut wire_params = serde_json::to_value(params)?;
9412 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9413 let _value = self
9414 .session
9415 .client()
9416 .call(
9417 rpc_methods::SESSION_PERMISSIONS_HANDLEPENDINGPERMISSIONREQUEST,
9418 Some(wire_params),
9419 )
9420 .await?;
9421 Ok(serde_json::from_value(_value)?)
9422 }
9423
9424 /// Reconstructs the set of pending tool permission requests from the session's event history.
9425 ///
9426 /// Wire method: `session.permissions.pendingRequests`.
9427 ///
9428 /// # Returns
9429 ///
9430 /// List of pending permission requests reconstructed from event history.
9431 ///
9432 /// <div class="warning">
9433 ///
9434 /// **Experimental.** This API is part of an experimental wire-protocol surface
9435 /// and may change or be removed in future SDK or CLI releases. Pin both the
9436 /// SDK and CLI versions if your code depends on it.
9437 ///
9438 /// </div>
9439 pub async fn pending_requests(&self) -> Result<PendingPermissionRequestList, Error> {
9440 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9441 let _value = self
9442 .session
9443 .client()
9444 .call(
9445 rpc_methods::SESSION_PERMISSIONS_PENDINGREQUESTS,
9446 Some(wire_params),
9447 )
9448 .await?;
9449 Ok(serde_json::from_value(_value)?)
9450 }
9451
9452 /// Enables or disables automatic approval of tool permission requests for the session.
9453 ///
9454 /// Wire method: `session.permissions.setApproveAll`.
9455 ///
9456 /// # Parameters
9457 ///
9458 /// * `params` - Allow-all toggle for tool permission requests, with an optional telemetry source.
9459 ///
9460 /// # Returns
9461 ///
9462 /// Indicates whether the operation succeeded.
9463 ///
9464 /// <div class="warning">
9465 ///
9466 /// **Experimental.** This API is part of an experimental wire-protocol surface
9467 /// and may change or be removed in future SDK or CLI releases. Pin both the
9468 /// SDK and CLI versions if your code depends on it.
9469 ///
9470 /// </div>
9471 pub async fn set_approve_all(
9472 &self,
9473 params: PermissionsSetApproveAllRequest,
9474 ) -> Result<PermissionsSetApproveAllResult, Error> {
9475 let mut wire_params = serde_json::to_value(params)?;
9476 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9477 let _value = self
9478 .session
9479 .client()
9480 .call(
9481 rpc_methods::SESSION_PERMISSIONS_SETAPPROVEALL,
9482 Some(wire_params),
9483 )
9484 .await?;
9485 Ok(serde_json::from_value(_value)?)
9486 }
9487
9488 /// 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.
9489 ///
9490 /// Wire method: `session.permissions.setMode`.
9491 ///
9492 /// # Parameters
9493 ///
9494 /// * `params` - Permission mode to apply for the session.
9495 ///
9496 /// # Returns
9497 ///
9498 /// Indicates whether the requested permission mode was applied and reports the authoritative post-mutation mode.
9499 ///
9500 /// <div class="warning">
9501 ///
9502 /// **Experimental.** This API is part of an experimental wire-protocol surface
9503 /// and may change or be removed in future SDK or CLI releases. Pin both the
9504 /// SDK and CLI versions if your code depends on it.
9505 ///
9506 /// </div>
9507 pub async fn set_mode(
9508 &self,
9509 params: PermissionsSetModeRequest,
9510 ) -> Result<PermissionsSetModeResult, Error> {
9511 let mut wire_params = serde_json::to_value(params)?;
9512 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9513 let _value = self
9514 .session
9515 .client()
9516 .call(rpc_methods::SESSION_PERMISSIONS_SETMODE, Some(wire_params))
9517 .await?;
9518 Ok(serde_json::from_value(_value)?)
9519 }
9520
9521 /// Returns the current permission mode for the session.
9522 ///
9523 /// Wire method: `session.permissions.getMode`.
9524 ///
9525 /// # Returns
9526 ///
9527 /// Current permission mode.
9528 ///
9529 /// <div class="warning">
9530 ///
9531 /// **Experimental.** This API is part of an experimental wire-protocol surface
9532 /// and may change or be removed in future SDK or CLI releases. Pin both the
9533 /// SDK and CLI versions if your code depends on it.
9534 ///
9535 /// </div>
9536 pub async fn get_mode(&self) -> Result<PermissionsGetModeResult, Error> {
9537 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9538 let _value = self
9539 .session
9540 .client()
9541 .call(rpc_methods::SESSION_PERMISSIONS_GETMODE, Some(wire_params))
9542 .await?;
9543 Ok(serde_json::from_value(_value)?)
9544 }
9545
9546 /// Adds or removes session-scoped or location-scoped permission rules.
9547 ///
9548 /// Wire method: `session.permissions.modifyRules`.
9549 ///
9550 /// # Parameters
9551 ///
9552 /// * `params` - Scope and add/remove instructions for modifying session- or location-scoped permission rules.
9553 ///
9554 /// # Returns
9555 ///
9556 /// Indicates whether the operation succeeded.
9557 ///
9558 /// <div class="warning">
9559 ///
9560 /// **Experimental.** This API is part of an experimental wire-protocol surface
9561 /// and may change or be removed in future SDK or CLI releases. Pin both the
9562 /// SDK and CLI versions if your code depends on it.
9563 ///
9564 /// </div>
9565 pub async fn modify_rules(
9566 &self,
9567 params: PermissionsModifyRulesParams,
9568 ) -> Result<PermissionsModifyRulesResult, Error> {
9569 let mut wire_params = serde_json::to_value(params)?;
9570 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9571 let _value = self
9572 .session
9573 .client()
9574 .call(
9575 rpc_methods::SESSION_PERMISSIONS_MODIFYRULES,
9576 Some(wire_params),
9577 )
9578 .await?;
9579 Ok(serde_json::from_value(_value)?)
9580 }
9581
9582 /// Sets whether the client wants permission prompts bridged into session events.
9583 ///
9584 /// Wire method: `session.permissions.setRequired`.
9585 ///
9586 /// # Parameters
9587 ///
9588 /// * `params` - Toggles whether permission prompts should be bridged into session events for this client.
9589 ///
9590 /// # Returns
9591 ///
9592 /// Indicates whether the operation succeeded.
9593 ///
9594 /// <div class="warning">
9595 ///
9596 /// **Experimental.** This API is part of an experimental wire-protocol surface
9597 /// and may change or be removed in future SDK or CLI releases. Pin both the
9598 /// SDK and CLI versions if your code depends on it.
9599 ///
9600 /// </div>
9601 pub async fn set_required(
9602 &self,
9603 params: PermissionsSetRequiredRequest,
9604 ) -> Result<PermissionsSetRequiredResult, Error> {
9605 let mut wire_params = serde_json::to_value(params)?;
9606 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9607 let _value = self
9608 .session
9609 .client()
9610 .call(
9611 rpc_methods::SESSION_PERMISSIONS_SETREQUIRED,
9612 Some(wire_params),
9613 )
9614 .await?;
9615 Ok(serde_json::from_value(_value)?)
9616 }
9617
9618 /// Clears session-scoped tool approvals and, for full resets, exact session-approved paths.
9619 ///
9620 /// Wire method: `session.permissions.resetSessionApprovals`.
9621 ///
9622 /// # Parameters
9623 ///
9624 /// * `params` - Clears session-scoped tool approvals and optionally clears location-scoped approvals and exact session-approved paths.
9625 ///
9626 /// # Returns
9627 ///
9628 /// Indicates whether the operation succeeded.
9629 ///
9630 /// <div class="warning">
9631 ///
9632 /// **Experimental.** This API is part of an experimental wire-protocol surface
9633 /// and may change or be removed in future SDK or CLI releases. Pin both the
9634 /// SDK and CLI versions if your code depends on it.
9635 ///
9636 /// </div>
9637 pub async fn reset_session_approvals(
9638 &self,
9639 params: PermissionsResetSessionApprovalsRequest,
9640 ) -> Result<PermissionsResetSessionApprovalsResult, Error> {
9641 let mut wire_params = serde_json::to_value(params)?;
9642 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9643 let _value = self
9644 .session
9645 .client()
9646 .call(
9647 rpc_methods::SESSION_PERMISSIONS_RESETSESSIONAPPROVALS,
9648 Some(wire_params),
9649 )
9650 .await?;
9651 Ok(serde_json::from_value(_value)?)
9652 }
9653
9654 /// Notifies the runtime that a permission prompt UI has been shown to the user.
9655 ///
9656 /// Wire method: `session.permissions.notifyPromptShown`.
9657 ///
9658 /// # Parameters
9659 ///
9660 /// * `params` - Notification payload describing the permission prompt that the client just rendered.
9661 ///
9662 /// # Returns
9663 ///
9664 /// Indicates whether the operation succeeded.
9665 ///
9666 /// <div class="warning">
9667 ///
9668 /// **Experimental.** This API is part of an experimental wire-protocol surface
9669 /// and may change or be removed in future SDK or CLI releases. Pin both the
9670 /// SDK and CLI versions if your code depends on it.
9671 ///
9672 /// </div>
9673 pub async fn notify_prompt_shown(
9674 &self,
9675 params: PermissionPromptShownNotification,
9676 ) -> Result<PermissionsNotifyPromptShownResult, Error> {
9677 let mut wire_params = serde_json::to_value(params)?;
9678 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9679 let _value = self
9680 .session
9681 .client()
9682 .call(
9683 rpc_methods::SESSION_PERMISSIONS_NOTIFYPROMPTSHOWN,
9684 Some(wire_params),
9685 )
9686 .await?;
9687 Ok(serde_json::from_value(_value)?)
9688 }
9689}
9690
9691/// `session.permissions.folderTrust.*` RPCs.
9692#[derive(Clone, Copy)]
9693pub struct SessionRpcPermissionsFolderTrust<'a> {
9694 pub(crate) session: &'a Session,
9695}
9696
9697impl<'a> SessionRpcPermissionsFolderTrust<'a> {
9698 /// Reports whether a folder is trusted according to the user's folder trust state.
9699 ///
9700 /// Wire method: `session.permissions.folderTrust.isTrusted`.
9701 ///
9702 /// # Parameters
9703 ///
9704 /// * `params` - Folder path to check for trust.
9705 ///
9706 /// # Returns
9707 ///
9708 /// Folder trust check result.
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 is_trusted(
9718 &self,
9719 params: FolderTrustCheckParams,
9720 ) -> Result<FolderTrustCheckResult, Error> {
9721 let mut wire_params = serde_json::to_value(params)?;
9722 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9723 let _value = self
9724 .session
9725 .client()
9726 .call(
9727 rpc_methods::SESSION_PERMISSIONS_FOLDERTRUST_ISTRUSTED,
9728 Some(wire_params),
9729 )
9730 .await?;
9731 Ok(serde_json::from_value(_value)?)
9732 }
9733
9734 /// Adds a folder to the user's trusted folders list.
9735 ///
9736 /// Wire method: `session.permissions.folderTrust.addTrusted`.
9737 ///
9738 /// # Parameters
9739 ///
9740 /// * `params` - Folder path to add to trusted folders.
9741 ///
9742 /// # Returns
9743 ///
9744 /// Indicates whether the operation succeeded.
9745 ///
9746 /// <div class="warning">
9747 ///
9748 /// **Experimental.** This API is part of an experimental wire-protocol surface
9749 /// and may change or be removed in future SDK or CLI releases. Pin both the
9750 /// SDK and CLI versions if your code depends on it.
9751 ///
9752 /// </div>
9753 pub async fn add_trusted(
9754 &self,
9755 params: FolderTrustAddParams,
9756 ) -> Result<PermissionsFolderTrustAddTrustedResult, Error> {
9757 let mut wire_params = serde_json::to_value(params)?;
9758 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9759 let _value = self
9760 .session
9761 .client()
9762 .call(
9763 rpc_methods::SESSION_PERMISSIONS_FOLDERTRUST_ADDTRUSTED,
9764 Some(wire_params),
9765 )
9766 .await?;
9767 Ok(serde_json::from_value(_value)?)
9768 }
9769}
9770
9771/// `session.permissions.locations.*` RPCs.
9772#[derive(Clone, Copy)]
9773pub struct SessionRpcPermissionsLocations<'a> {
9774 pub(crate) session: &'a Session,
9775}
9776
9777impl<'a> SessionRpcPermissionsLocations<'a> {
9778 /// Resolves the permission location key and type for a working directory.
9779 ///
9780 /// Wire method: `session.permissions.locations.resolve`.
9781 ///
9782 /// # Parameters
9783 ///
9784 /// * `params` - Working directory to resolve into a location-permissions key.
9785 ///
9786 /// # Returns
9787 ///
9788 /// Resolved location-permissions key and type.
9789 ///
9790 /// <div class="warning">
9791 ///
9792 /// **Experimental.** This API is part of an experimental wire-protocol surface
9793 /// and may change or be removed in future SDK or CLI releases. Pin both the
9794 /// SDK and CLI versions if your code depends on it.
9795 ///
9796 /// </div>
9797 pub async fn resolve(
9798 &self,
9799 params: PermissionLocationResolveParams,
9800 ) -> Result<PermissionLocationResolveResult, Error> {
9801 let mut wire_params = serde_json::to_value(params)?;
9802 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9803 let _value = self
9804 .session
9805 .client()
9806 .call(
9807 rpc_methods::SESSION_PERMISSIONS_LOCATIONS_RESOLVE,
9808 Some(wire_params),
9809 )
9810 .await?;
9811 Ok(serde_json::from_value(_value)?)
9812 }
9813
9814 /// Applies persisted location-scoped tool approvals and allowed directories for a working directory to this session's permission service.
9815 ///
9816 /// Wire method: `session.permissions.locations.apply`.
9817 ///
9818 /// # Parameters
9819 ///
9820 /// * `params` - Working directory to load persisted location permissions for.
9821 ///
9822 /// # Returns
9823 ///
9824 /// Summary of persisted location permissions applied to the session.
9825 ///
9826 /// <div class="warning">
9827 ///
9828 /// **Experimental.** This API is part of an experimental wire-protocol surface
9829 /// and may change or be removed in future SDK or CLI releases. Pin both the
9830 /// SDK and CLI versions if your code depends on it.
9831 ///
9832 /// </div>
9833 pub async fn apply(
9834 &self,
9835 params: PermissionLocationApplyParams,
9836 ) -> Result<PermissionLocationApplyResult, Error> {
9837 let mut wire_params = serde_json::to_value(params)?;
9838 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9839 let _value = self
9840 .session
9841 .client()
9842 .call(
9843 rpc_methods::SESSION_PERMISSIONS_LOCATIONS_APPLY,
9844 Some(wire_params),
9845 )
9846 .await?;
9847 Ok(serde_json::from_value(_value)?)
9848 }
9849
9850 /// Persists a tool approval for a permission location and applies its rules to this session's live permission service.
9851 ///
9852 /// Wire method: `session.permissions.locations.addToolApproval`.
9853 ///
9854 /// # Parameters
9855 ///
9856 /// * `params` - Location-scoped tool approval to persist.
9857 ///
9858 /// # Returns
9859 ///
9860 /// Indicates whether the operation succeeded.
9861 ///
9862 /// <div class="warning">
9863 ///
9864 /// **Experimental.** This API is part of an experimental wire-protocol surface
9865 /// and may change or be removed in future SDK or CLI releases. Pin both the
9866 /// SDK and CLI versions if your code depends on it.
9867 ///
9868 /// </div>
9869 pub async fn add_tool_approval(
9870 &self,
9871 params: PermissionLocationAddToolApprovalParams,
9872 ) -> Result<PermissionsLocationsAddToolApprovalResult, Error> {
9873 let mut wire_params = serde_json::to_value(params)?;
9874 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9875 let _value = self
9876 .session
9877 .client()
9878 .call(
9879 rpc_methods::SESSION_PERMISSIONS_LOCATIONS_ADDTOOLAPPROVAL,
9880 Some(wire_params),
9881 )
9882 .await?;
9883 Ok(serde_json::from_value(_value)?)
9884 }
9885}
9886
9887/// `session.permissions.paths.*` RPCs.
9888#[derive(Clone, Copy)]
9889pub struct SessionRpcPermissionsPaths<'a> {
9890 pub(crate) session: &'a Session,
9891}
9892
9893impl<'a> SessionRpcPermissionsPaths<'a> {
9894 /// Returns the session's recursive directory grants, exact session-approved paths, and primary working directory.
9895 ///
9896 /// Wire method: `session.permissions.paths.list`.
9897 ///
9898 /// # Returns
9899 ///
9900 /// Snapshot of the session's recursive directory grants, exact session-approved paths, and primary working directory.
9901 ///
9902 /// <div class="warning">
9903 ///
9904 /// **Experimental.** This API is part of an experimental wire-protocol surface
9905 /// and may change or be removed in future SDK or CLI releases. Pin both the
9906 /// SDK and CLI versions if your code depends on it.
9907 ///
9908 /// </div>
9909 pub async fn list(&self) -> Result<PermissionPathsList, Error> {
9910 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9911 let _value = self
9912 .session
9913 .client()
9914 .call(
9915 rpc_methods::SESSION_PERMISSIONS_PATHS_LIST,
9916 Some(wire_params),
9917 )
9918 .await?;
9919 Ok(serde_json::from_value(_value)?)
9920 }
9921
9922 /// Adds a directory to the session's allow-list and activates conventional skill and agent definitions under it.
9923 ///
9924 /// Wire method: `session.permissions.paths.add`.
9925 ///
9926 /// # Parameters
9927 ///
9928 /// * `params` - Directory path to add to the session's allowed directories.
9929 ///
9930 /// # Returns
9931 ///
9932 /// Indicates whether the operation succeeded.
9933 ///
9934 /// <div class="warning">
9935 ///
9936 /// **Experimental.** This API is part of an experimental wire-protocol surface
9937 /// and may change or be removed in future SDK or CLI releases. Pin both the
9938 /// SDK and CLI versions if your code depends on it.
9939 ///
9940 /// </div>
9941 pub async fn add(
9942 &self,
9943 params: PermissionPathsAddParams,
9944 ) -> Result<PermissionsPathsAddResult, Error> {
9945 let mut wire_params = serde_json::to_value(params)?;
9946 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9947 let _value = self
9948 .session
9949 .client()
9950 .call(
9951 rpc_methods::SESSION_PERMISSIONS_PATHS_ADD,
9952 Some(wire_params),
9953 )
9954 .await?;
9955 Ok(serde_json::from_value(_value)?)
9956 }
9957
9958 /// Updates the session's primary working directory used by the permission policy.
9959 ///
9960 /// Wire method: `session.permissions.paths.updatePrimary`.
9961 ///
9962 /// # Parameters
9963 ///
9964 /// * `params` - Directory path to set as the session's new primary working directory.
9965 ///
9966 /// # Returns
9967 ///
9968 /// Indicates whether the operation succeeded.
9969 ///
9970 /// <div class="warning">
9971 ///
9972 /// **Experimental.** This API is part of an experimental wire-protocol surface
9973 /// and may change or be removed in future SDK or CLI releases. Pin both the
9974 /// SDK and CLI versions if your code depends on it.
9975 ///
9976 /// </div>
9977 pub async fn update_primary(
9978 &self,
9979 params: PermissionPathsUpdatePrimaryParams,
9980 ) -> Result<PermissionsPathsUpdatePrimaryResult, Error> {
9981 let mut wire_params = serde_json::to_value(params)?;
9982 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9983 let _value = self
9984 .session
9985 .client()
9986 .call(
9987 rpc_methods::SESSION_PERMISSIONS_PATHS_UPDATEPRIMARY,
9988 Some(wire_params),
9989 )
9990 .await?;
9991 Ok(serde_json::from_value(_value)?)
9992 }
9993
9994 /// Reports whether a path falls within any of the session's allowed directories.
9995 ///
9996 /// Wire method: `session.permissions.paths.isPathWithinAllowedDirectories`.
9997 ///
9998 /// # Parameters
9999 ///
10000 /// * `params` - Path to evaluate against the session's allowed directories.
10001 ///
10002 /// # Returns
10003 ///
10004 /// Indicates whether the supplied path is within the session's allowed directories.
10005 ///
10006 /// <div class="warning">
10007 ///
10008 /// **Experimental.** This API is part of an experimental wire-protocol surface
10009 /// and may change or be removed in future SDK or CLI releases. Pin both the
10010 /// SDK and CLI versions if your code depends on it.
10011 ///
10012 /// </div>
10013 pub async fn is_path_within_allowed_directories(
10014 &self,
10015 params: PermissionPathsAllowedCheckParams,
10016 ) -> Result<PermissionPathsAllowedCheckResult, Error> {
10017 let mut wire_params = serde_json::to_value(params)?;
10018 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10019 let _value = self
10020 .session
10021 .client()
10022 .call(
10023 rpc_methods::SESSION_PERMISSIONS_PATHS_ISPATHWITHINALLOWEDDIRECTORIES,
10024 Some(wire_params),
10025 )
10026 .await?;
10027 Ok(serde_json::from_value(_value)?)
10028 }
10029
10030 /// Reports whether a path falls within the session's workspace (primary) directory.
10031 ///
10032 /// Wire method: `session.permissions.paths.isPathWithinWorkspace`.
10033 ///
10034 /// # Parameters
10035 ///
10036 /// * `params` - Path to evaluate against the session's workspace (primary) directory.
10037 ///
10038 /// # Returns
10039 ///
10040 /// Indicates whether the supplied path is within the session's workspace directory.
10041 ///
10042 /// <div class="warning">
10043 ///
10044 /// **Experimental.** This API is part of an experimental wire-protocol surface
10045 /// and may change or be removed in future SDK or CLI releases. Pin both the
10046 /// SDK and CLI versions if your code depends on it.
10047 ///
10048 /// </div>
10049 pub async fn is_path_within_workspace(
10050 &self,
10051 params: PermissionPathsWorkspaceCheckParams,
10052 ) -> Result<PermissionPathsWorkspaceCheckResult, Error> {
10053 let mut wire_params = serde_json::to_value(params)?;
10054 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10055 let _value = self
10056 .session
10057 .client()
10058 .call(
10059 rpc_methods::SESSION_PERMISSIONS_PATHS_ISPATHWITHINWORKSPACE,
10060 Some(wire_params),
10061 )
10062 .await?;
10063 Ok(serde_json::from_value(_value)?)
10064 }
10065}
10066
10067/// `session.permissions.urls.*` RPCs.
10068#[derive(Clone, Copy)]
10069pub struct SessionRpcPermissionsUrls<'a> {
10070 pub(crate) session: &'a Session,
10071}
10072
10073impl<'a> SessionRpcPermissionsUrls<'a> {
10074 /// Toggles the runtime's URL-permission policy between unrestricted and restricted modes.
10075 ///
10076 /// Wire method: `session.permissions.urls.setUnrestrictedMode`.
10077 ///
10078 /// # Parameters
10079 ///
10080 /// * `params` - Whether the URL-permission policy should run in unrestricted mode.
10081 ///
10082 /// # Returns
10083 ///
10084 /// Indicates whether the operation succeeded.
10085 ///
10086 /// <div class="warning">
10087 ///
10088 /// **Experimental.** This API is part of an experimental wire-protocol surface
10089 /// and may change or be removed in future SDK or CLI releases. Pin both the
10090 /// SDK and CLI versions if your code depends on it.
10091 ///
10092 /// </div>
10093 pub async fn set_unrestricted_mode(
10094 &self,
10095 params: PermissionUrlsSetUnrestrictedModeParams,
10096 ) -> Result<PermissionsUrlsSetUnrestrictedModeResult, Error> {
10097 let mut wire_params = serde_json::to_value(params)?;
10098 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10099 let _value = self
10100 .session
10101 .client()
10102 .call(
10103 rpc_methods::SESSION_PERMISSIONS_URLS_SETUNRESTRICTEDMODE,
10104 Some(wire_params),
10105 )
10106 .await?;
10107 Ok(serde_json::from_value(_value)?)
10108 }
10109}
10110
10111/// `session.plan.*` RPCs.
10112#[derive(Clone, Copy)]
10113pub struct SessionRpcPlan<'a> {
10114 pub(crate) session: &'a Session,
10115}
10116
10117impl<'a> SessionRpcPlan<'a> {
10118 /// Reads the session plan file from the workspace.
10119 ///
10120 /// Wire method: `session.plan.read`.
10121 ///
10122 /// # Returns
10123 ///
10124 /// Existence, contents, and resolved path of the session plan file.
10125 ///
10126 /// <div class="warning">
10127 ///
10128 /// **Experimental.** This API is part of an experimental wire-protocol surface
10129 /// and may change or be removed in future SDK or CLI releases. Pin both the
10130 /// SDK and CLI versions if your code depends on it.
10131 ///
10132 /// </div>
10133 pub async fn read(&self) -> Result<PlanReadResult, Error> {
10134 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10135 let _value = self
10136 .session
10137 .client()
10138 .call(rpc_methods::SESSION_PLAN_READ, Some(wire_params))
10139 .await?;
10140 Ok(serde_json::from_value(_value)?)
10141 }
10142
10143 /// Writes new content to the session plan file.
10144 ///
10145 /// Wire method: `session.plan.update`.
10146 ///
10147 /// # Parameters
10148 ///
10149 /// * `params` - Replacement contents to write to the session plan file.
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 update(&self, params: PlanUpdateRequest) -> Result<(), Error> {
10159 let mut wire_params = serde_json::to_value(params)?;
10160 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10161 let _value = self
10162 .session
10163 .client()
10164 .call(rpc_methods::SESSION_PLAN_UPDATE, Some(wire_params))
10165 .await?;
10166 Ok(())
10167 }
10168
10169 /// Deletes the session plan file from the workspace.
10170 ///
10171 /// Wire method: `session.plan.delete`.
10172 ///
10173 /// <div class="warning">
10174 ///
10175 /// **Experimental.** This API is part of an experimental wire-protocol surface
10176 /// and may change or be removed in future SDK or CLI releases. Pin both the
10177 /// SDK and CLI versions if your code depends on it.
10178 ///
10179 /// </div>
10180 pub async fn delete(&self) -> Result<(), Error> {
10181 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10182 let _value = self
10183 .session
10184 .client()
10185 .call(rpc_methods::SESSION_PLAN_DELETE, Some(wire_params))
10186 .await?;
10187 Ok(())
10188 }
10189
10190 /// Reads todo rows from the session SQL database for plan rendering.
10191 ///
10192 /// Wire method: `session.plan.readSqlTodos`.
10193 ///
10194 /// # Returns
10195 ///
10196 /// Todo rows read from the session SQL database. Empty when no session database is available.
10197 ///
10198 /// <div class="warning">
10199 ///
10200 /// **Experimental.** This API is part of an experimental wire-protocol surface
10201 /// and may change or be removed in future SDK or CLI releases. Pin both the
10202 /// SDK and CLI versions if your code depends on it.
10203 ///
10204 /// </div>
10205 pub async fn read_sql_todos(&self) -> Result<PlanReadSqlTodosResult, Error> {
10206 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10207 let _value = self
10208 .session
10209 .client()
10210 .call(rpc_methods::SESSION_PLAN_READSQLTODOS, Some(wire_params))
10211 .await?;
10212 Ok(serde_json::from_value(_value)?)
10213 }
10214
10215 /// 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.
10216 ///
10217 /// Wire method: `session.plan.readSqlTodosWithDependencies`.
10218 ///
10219 /// # Returns
10220 ///
10221 /// Todo rows + dependency edges read from the session SQL database.
10222 ///
10223 /// <div class="warning">
10224 ///
10225 /// **Experimental.** This API is part of an experimental wire-protocol surface
10226 /// and may change or be removed in future SDK or CLI releases. Pin both the
10227 /// SDK and CLI versions if your code depends on it.
10228 ///
10229 /// </div>
10230 pub async fn read_sql_todos_with_dependencies(
10231 &self,
10232 ) -> Result<PlanReadSqlTodosWithDependenciesResult, Error> {
10233 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10234 let _value = self
10235 .session
10236 .client()
10237 .call(
10238 rpc_methods::SESSION_PLAN_READSQLTODOSWITHDEPENDENCIES,
10239 Some(wire_params),
10240 )
10241 .await?;
10242 Ok(serde_json::from_value(_value)?)
10243 }
10244}
10245
10246/// `session.plugins.*` RPCs.
10247#[derive(Clone, Copy)]
10248pub struct SessionRpcPlugins<'a> {
10249 pub(crate) session: &'a Session,
10250}
10251
10252impl<'a> SessionRpcPlugins<'a> {
10253 /// `session.plugins.marketplaces.*` sub-namespace.
10254 pub fn marketplaces(&self) -> SessionRpcPluginsMarketplaces<'a> {
10255 SessionRpcPluginsMarketplaces {
10256 session: self.session,
10257 }
10258 }
10259
10260 /// Lists globally installed, live, built-in, and enterprise-managed desired plugins using the live session's authoritative account, working directory, and retained managed policy.
10261 ///
10262 /// Wire method: `session.plugins.list`.
10263 ///
10264 /// # Returns
10265 ///
10266 /// Plugins installed for the session, with their enabled state and version metadata.
10267 ///
10268 /// <div class="warning">
10269 ///
10270 /// **Experimental.** This API is part of an experimental wire-protocol surface
10271 /// and may change or be removed in future SDK or CLI releases. Pin both the
10272 /// SDK and CLI versions if your code depends on it.
10273 ///
10274 /// </div>
10275 pub async fn list(&self) -> Result<PluginList, Error> {
10276 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10277 let _value = self
10278 .session
10279 .client()
10280 .call(rpc_methods::SESSION_PLUGINS_LIST, Some(wire_params))
10281 .await?;
10282 Ok(serde_json::from_value(_value)?)
10283 }
10284
10285 /// Installs a plugin using the live session's authoritative account, working directory, and retained managed policy.
10286 ///
10287 /// Wire method: `session.plugins.install`.
10288 ///
10289 /// # Parameters
10290 ///
10291 /// * `params` - Plugin source resolved relative to the session's authoritative working directory.
10292 ///
10293 /// # Returns
10294 ///
10295 /// Result of installing a plugin.
10296 ///
10297 /// <div class="warning">
10298 ///
10299 /// **Experimental.** This API is part of an experimental wire-protocol surface
10300 /// and may change or be removed in future SDK or CLI releases. Pin both the
10301 /// SDK and CLI versions if your code depends on it.
10302 ///
10303 /// </div>
10304 pub async fn install(
10305 &self,
10306 params: SessionPluginsInstallRequest,
10307 ) -> Result<PluginInstallResult, Error> {
10308 let mut wire_params = serde_json::to_value(params)?;
10309 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10310 let _value = self
10311 .session
10312 .client()
10313 .call(rpc_methods::SESSION_PLUGINS_INSTALL, Some(wire_params))
10314 .await?;
10315 Ok(serde_json::from_value(_value)?)
10316 }
10317
10318 /// Uninstalls a plugin when permitted by the live session's retained managed policy.
10319 ///
10320 /// Wire method: `session.plugins.uninstall`.
10321 ///
10322 /// # Parameters
10323 ///
10324 /// * `params` - Name (or spec) of the plugin to uninstall.
10325 ///
10326 /// <div class="warning">
10327 ///
10328 /// **Experimental.** This API is part of an experimental wire-protocol surface
10329 /// and may change or be removed in future SDK or CLI releases. Pin both the
10330 /// SDK and CLI versions if your code depends on it.
10331 ///
10332 /// </div>
10333 pub async fn uninstall(&self, params: PluginsUninstallRequest) -> Result<(), Error> {
10334 let mut wire_params = serde_json::to_value(params)?;
10335 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10336 let _value = self
10337 .session
10338 .client()
10339 .call(rpc_methods::SESSION_PLUGINS_UNINSTALL, Some(wire_params))
10340 .await?;
10341 Ok(())
10342 }
10343
10344 /// Updates an installed plugin using the live session's authoritative account, working directory, and retained managed policy.
10345 ///
10346 /// Wire method: `session.plugins.update`.
10347 ///
10348 /// # Parameters
10349 ///
10350 /// * `params` - Name (or spec) of the plugin to update.
10351 ///
10352 /// # Returns
10353 ///
10354 /// Result of updating a single plugin.
10355 ///
10356 /// <div class="warning">
10357 ///
10358 /// **Experimental.** This API is part of an experimental wire-protocol surface
10359 /// and may change or be removed in future SDK or CLI releases. Pin both the
10360 /// SDK and CLI versions if your code depends on it.
10361 ///
10362 /// </div>
10363 pub async fn update(&self, params: PluginsUpdateRequest) -> Result<PluginUpdateResult, Error> {
10364 let mut wire_params = serde_json::to_value(params)?;
10365 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10366 let _value = self
10367 .session
10368 .client()
10369 .call(rpc_methods::SESSION_PLUGINS_UPDATE, Some(wire_params))
10370 .await?;
10371 Ok(serde_json::from_value(_value)?)
10372 }
10373
10374 /// Enables installed plugins when permitted by the live session's retained managed policy.
10375 ///
10376 /// Wire method: `session.plugins.enable`.
10377 ///
10378 /// # Parameters
10379 ///
10380 /// * `params` - Plugin names (or specs) to enable in the session's authoritative working directory.
10381 ///
10382 /// <div class="warning">
10383 ///
10384 /// **Experimental.** This API is part of an experimental wire-protocol surface
10385 /// and may change or be removed in future SDK or CLI releases. Pin both the
10386 /// SDK and CLI versions if your code depends on it.
10387 ///
10388 /// </div>
10389 pub async fn enable(&self, params: SessionPluginsEnableRequest) -> Result<(), Error> {
10390 let mut wire_params = serde_json::to_value(params)?;
10391 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10392 let _value = self
10393 .session
10394 .client()
10395 .call(rpc_methods::SESSION_PLUGINS_ENABLE, Some(wire_params))
10396 .await?;
10397 Ok(())
10398 }
10399
10400 /// Disables installed plugins when permitted by the live session's retained managed policy.
10401 ///
10402 /// Wire method: `session.plugins.disable`.
10403 ///
10404 /// # Parameters
10405 ///
10406 /// * `params` - Plugin names (or specs) to disable in the session's authoritative working directory.
10407 ///
10408 /// <div class="warning">
10409 ///
10410 /// **Experimental.** This API is part of an experimental wire-protocol surface
10411 /// and may change or be removed in future SDK or CLI releases. Pin both the
10412 /// SDK and CLI versions if your code depends on it.
10413 ///
10414 /// </div>
10415 pub async fn disable(&self, params: SessionPluginsDisableRequest) -> Result<(), Error> {
10416 let mut wire_params = serde_json::to_value(params)?;
10417 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10418 let _value = self
10419 .session
10420 .client()
10421 .call(rpc_methods::SESSION_PLUGINS_DISABLE, Some(wire_params))
10422 .await?;
10423 Ok(())
10424 }
10425
10426 /// 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.
10427 ///
10428 /// Wire method: `session.plugins.reload`.
10429 ///
10430 /// <div class="warning">
10431 ///
10432 /// **Experimental.** This API is part of an experimental wire-protocol surface
10433 /// and may change or be removed in future SDK or CLI releases. Pin both the
10434 /// SDK and CLI versions if your code depends on it.
10435 ///
10436 /// </div>
10437 pub async fn reload(&self) -> Result<(), Error> {
10438 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10439 let _value = self
10440 .session
10441 .client()
10442 .call(rpc_methods::SESSION_PLUGINS_RELOAD, Some(wire_params))
10443 .await?;
10444 Ok(())
10445 }
10446
10447 /// 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.
10448 ///
10449 /// Wire method: `session.plugins.reload`.
10450 ///
10451 /// # Parameters
10452 ///
10453 /// * `params` - Optional flags controlling which side effects the reload performs.
10454 ///
10455 /// <div class="warning">
10456 ///
10457 /// **Experimental.** This API is part of an experimental wire-protocol surface
10458 /// and may change or be removed in future SDK or CLI releases. Pin both the
10459 /// SDK and CLI versions if your code depends on it.
10460 ///
10461 /// </div>
10462 pub async fn reload_with_params(&self, params: PluginsReloadRequest) -> Result<(), Error> {
10463 let mut wire_params = serde_json::to_value(params)?;
10464 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10465 let _value = self
10466 .session
10467 .client()
10468 .call(rpc_methods::SESSION_PLUGINS_RELOAD, Some(wire_params))
10469 .await?;
10470 Ok(())
10471 }
10472}
10473
10474/// `session.plugins.marketplaces.*` RPCs.
10475#[derive(Clone, Copy)]
10476pub struct SessionRpcPluginsMarketplaces<'a> {
10477 pub(crate) session: &'a Session,
10478}
10479
10480impl<'a> SessionRpcPluginsMarketplaces<'a> {
10481 /// Lists registered and enterprise-managed desired marketplaces using the live session's retained policy.
10482 ///
10483 /// Wire method: `session.plugins.marketplaces.list`.
10484 ///
10485 /// # Returns
10486 ///
10487 /// All registered marketplaces, including built-in defaults.
10488 ///
10489 /// <div class="warning">
10490 ///
10491 /// **Experimental.** This API is part of an experimental wire-protocol surface
10492 /// and may change or be removed in future SDK or CLI releases. Pin both the
10493 /// SDK and CLI versions if your code depends on it.
10494 ///
10495 /// </div>
10496 pub async fn list(&self) -> Result<MarketplaceListResult, Error> {
10497 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10498 let _value = self
10499 .session
10500 .client()
10501 .call(
10502 rpc_methods::SESSION_PLUGINS_MARKETPLACES_LIST,
10503 Some(wire_params),
10504 )
10505 .await?;
10506 Ok(serde_json::from_value(_value)?)
10507 }
10508
10509 /// Adds a marketplace when permitted by the live session's retained managed policy.
10510 ///
10511 /// Wire method: `session.plugins.marketplaces.add`.
10512 ///
10513 /// # Parameters
10514 ///
10515 /// * `params` - Marketplace source and optional working directory for relative-path resolution.
10516 ///
10517 /// # Returns
10518 ///
10519 /// Result of registering a new marketplace.
10520 ///
10521 /// <div class="warning">
10522 ///
10523 /// **Experimental.** This API is part of an experimental wire-protocol surface
10524 /// and may change or be removed in future SDK or CLI releases. Pin both the
10525 /// SDK and CLI versions if your code depends on it.
10526 ///
10527 /// </div>
10528 pub async fn add(
10529 &self,
10530 params: PluginsMarketplacesAddRequest,
10531 ) -> Result<MarketplaceAddResult, Error> {
10532 let mut wire_params = serde_json::to_value(params)?;
10533 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10534 let _value = self
10535 .session
10536 .client()
10537 .call(
10538 rpc_methods::SESSION_PLUGINS_MARKETPLACES_ADD,
10539 Some(wire_params),
10540 )
10541 .await?;
10542 Ok(serde_json::from_value(_value)?)
10543 }
10544
10545 /// Removes a marketplace when permitted by the live session's retained managed policy.
10546 ///
10547 /// Wire method: `session.plugins.marketplaces.remove`.
10548 ///
10549 /// # Parameters
10550 ///
10551 /// * `params` - Name of the marketplace to remove and an optional force flag.
10552 ///
10553 /// # Returns
10554 ///
10555 /// Outcome of the remove attempt, including dependent-plugin info when applicable.
10556 ///
10557 /// <div class="warning">
10558 ///
10559 /// **Experimental.** This API is part of an experimental wire-protocol surface
10560 /// and may change or be removed in future SDK or CLI releases. Pin both the
10561 /// SDK and CLI versions if your code depends on it.
10562 ///
10563 /// </div>
10564 pub async fn remove(
10565 &self,
10566 params: PluginsMarketplacesRemoveRequest,
10567 ) -> Result<MarketplaceRemoveResult, Error> {
10568 let mut wire_params = serde_json::to_value(params)?;
10569 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10570 let _value = self
10571 .session
10572 .client()
10573 .call(
10574 rpc_methods::SESSION_PLUGINS_MARKETPLACES_REMOVE,
10575 Some(wire_params),
10576 )
10577 .await?;
10578 Ok(serde_json::from_value(_value)?)
10579 }
10580
10581 /// Browses a marketplace resolved through the live session's working directory and retained managed policy.
10582 ///
10583 /// Wire method: `session.plugins.marketplaces.browse`.
10584 ///
10585 /// # Parameters
10586 ///
10587 /// * `params` - Name of the marketplace whose plugin catalog to fetch.
10588 ///
10589 /// # Returns
10590 ///
10591 /// Plugins advertised by the marketplace.
10592 ///
10593 /// <div class="warning">
10594 ///
10595 /// **Experimental.** This API is part of an experimental wire-protocol surface
10596 /// and may change or be removed in future SDK or CLI releases. Pin both the
10597 /// SDK and CLI versions if your code depends on it.
10598 ///
10599 /// </div>
10600 pub async fn browse(
10601 &self,
10602 params: PluginsMarketplacesBrowseRequest,
10603 ) -> Result<MarketplaceBrowseResult, Error> {
10604 let mut wire_params = serde_json::to_value(params)?;
10605 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10606 let _value = self
10607 .session
10608 .client()
10609 .call(
10610 rpc_methods::SESSION_PLUGINS_MARKETPLACES_BROWSE,
10611 Some(wire_params),
10612 )
10613 .await?;
10614 Ok(serde_json::from_value(_value)?)
10615 }
10616
10617 /// Refreshes marketplaces resolved through the live session's working directory and retained managed policy.
10618 ///
10619 /// Wire method: `session.plugins.marketplaces.refresh`.
10620 ///
10621 /// # Returns
10622 ///
10623 /// Result of refreshing one or more marketplace catalogs.
10624 ///
10625 /// <div class="warning">
10626 ///
10627 /// **Experimental.** This API is part of an experimental wire-protocol surface
10628 /// and may change or be removed in future SDK or CLI releases. Pin both the
10629 /// SDK and CLI versions if your code depends on it.
10630 ///
10631 /// </div>
10632 pub async fn refresh(&self) -> Result<MarketplaceRefreshResult, Error> {
10633 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10634 let _value = self
10635 .session
10636 .client()
10637 .call(
10638 rpc_methods::SESSION_PLUGINS_MARKETPLACES_REFRESH,
10639 Some(wire_params),
10640 )
10641 .await?;
10642 Ok(serde_json::from_value(_value)?)
10643 }
10644
10645 /// Refreshes marketplaces resolved through the live session's working directory and retained managed policy.
10646 ///
10647 /// Wire method: `session.plugins.marketplaces.refresh`.
10648 ///
10649 /// # Parameters
10650 ///
10651 /// * `params` - Optional marketplace name; omit to refresh all.
10652 ///
10653 /// # Returns
10654 ///
10655 /// Result of refreshing one or more marketplace catalogs.
10656 ///
10657 /// <div class="warning">
10658 ///
10659 /// **Experimental.** This API is part of an experimental wire-protocol surface
10660 /// and may change or be removed in future SDK or CLI releases. Pin both the
10661 /// SDK and CLI versions if your code depends on it.
10662 ///
10663 /// </div>
10664 pub async fn refresh_with_params(
10665 &self,
10666 params: PluginsMarketplacesRefreshRequest,
10667 ) -> Result<MarketplaceRefreshResult, Error> {
10668 let mut wire_params = serde_json::to_value(params)?;
10669 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10670 let _value = self
10671 .session
10672 .client()
10673 .call(
10674 rpc_methods::SESSION_PLUGINS_MARKETPLACES_REFRESH,
10675 Some(wire_params),
10676 )
10677 .await?;
10678 Ok(serde_json::from_value(_value)?)
10679 }
10680}
10681
10682/// `session.provider.*` RPCs.
10683#[derive(Clone, Copy)]
10684pub struct SessionRpcProvider<'a> {
10685 pub(crate) session: &'a Session,
10686}
10687
10688impl<'a> SessionRpcProvider<'a> {
10689 /// 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.
10690 ///
10691 /// Wire method: `session.provider.getEndpoint`.
10692 ///
10693 /// # Returns
10694 ///
10695 /// A snapshot of the provider endpoint the session is currently configured to talk to.
10696 ///
10697 /// <div class="warning">
10698 ///
10699 /// **Experimental.** This API is part of an experimental wire-protocol surface
10700 /// and may change or be removed in future SDK or CLI releases. Pin both the
10701 /// SDK and CLI versions if your code depends on it.
10702 ///
10703 /// </div>
10704 pub async fn get_endpoint(&self) -> Result<ProviderEndpoint, Error> {
10705 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10706 let _value = self
10707 .session
10708 .client()
10709 .call(rpc_methods::SESSION_PROVIDER_GETENDPOINT, Some(wire_params))
10710 .await?;
10711 Ok(serde_json::from_value(_value)?)
10712 }
10713
10714 /// 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.
10715 ///
10716 /// Wire method: `session.provider.getEndpoint`.
10717 ///
10718 /// # Parameters
10719 ///
10720 /// * `params` - Optional model identifier to scope the endpoint snapshot to.
10721 ///
10722 /// # Returns
10723 ///
10724 /// A snapshot of the provider endpoint the session is currently configured to talk to.
10725 ///
10726 /// <div class="warning">
10727 ///
10728 /// **Experimental.** This API is part of an experimental wire-protocol surface
10729 /// and may change or be removed in future SDK or CLI releases. Pin both the
10730 /// SDK and CLI versions if your code depends on it.
10731 ///
10732 /// </div>
10733 pub async fn get_endpoint_with_params(
10734 &self,
10735 params: ProviderGetEndpointRequest,
10736 ) -> Result<ProviderEndpoint, Error> {
10737 let mut wire_params = serde_json::to_value(params)?;
10738 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10739 let _value = self
10740 .session
10741 .client()
10742 .call(rpc_methods::SESSION_PROVIDER_GETENDPOINT, Some(wire_params))
10743 .await?;
10744 Ok(serde_json::from_value(_value)?)
10745 }
10746
10747 /// 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.
10748 ///
10749 /// Wire method: `session.provider.add`.
10750 ///
10751 /// # Parameters
10752 ///
10753 /// * `params` - BYOK providers and/or models to add to the session's registry at runtime. Both fields are optional; provide providers, models, or both.
10754 ///
10755 /// # Returns
10756 ///
10757 /// The selectable model entries synthesized for the models added by this call.
10758 ///
10759 /// <div class="warning">
10760 ///
10761 /// **Experimental.** This API is part of an experimental wire-protocol surface
10762 /// and may change or be removed in future SDK or CLI releases. Pin both the
10763 /// SDK and CLI versions if your code depends on it.
10764 ///
10765 /// </div>
10766 pub async fn add(&self, params: ProviderAddRequest) -> Result<ProviderAddResult, Error> {
10767 let mut wire_params = serde_json::to_value(params)?;
10768 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10769 let _value = self
10770 .session
10771 .client()
10772 .call(rpc_methods::SESSION_PROVIDER_ADD, Some(wire_params))
10773 .await?;
10774 Ok(serde_json::from_value(_value)?)
10775 }
10776
10777 /// 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.
10778 ///
10779 /// Wire method: `session.provider.sync`.
10780 ///
10781 /// # Parameters
10782 ///
10783 /// * `params` - Authoritative BYOK provider and model registry snapshot to apply atomically to the session.
10784 ///
10785 /// # Returns
10786 ///
10787 /// The selectable model entries and selection ids synthesized for the synchronized BYOK models.
10788 ///
10789 /// <div class="warning">
10790 ///
10791 /// **Experimental.** This API is part of an experimental wire-protocol surface
10792 /// and may change or be removed in future SDK or CLI releases. Pin both the
10793 /// SDK and CLI versions if your code depends on it.
10794 ///
10795 /// </div>
10796 pub async fn sync(&self, params: ProviderSyncRequest) -> Result<ProviderSyncResult, Error> {
10797 let mut wire_params = serde_json::to_value(params)?;
10798 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10799 let _value = self
10800 .session
10801 .client()
10802 .call(rpc_methods::SESSION_PROVIDER_SYNC, Some(wire_params))
10803 .await?;
10804 Ok(serde_json::from_value(_value)?)
10805 }
10806}
10807
10808/// `session.queue.*` RPCs.
10809#[derive(Clone, Copy)]
10810pub struct SessionRpcQueue<'a> {
10811 pub(crate) session: &'a Session,
10812}
10813
10814impl<'a> SessionRpcQueue<'a> {
10815 /// Returns the local session's pending user-facing queued items and steering messages.
10816 ///
10817 /// Wire method: `session.queue.pendingItems`.
10818 ///
10819 /// # Returns
10820 ///
10821 /// Snapshot of the session's pending queued items and immediate-steering messages.
10822 ///
10823 /// <div class="warning">
10824 ///
10825 /// **Experimental.** This API is part of an experimental wire-protocol surface
10826 /// and may change or be removed in future SDK or CLI releases. Pin both the
10827 /// SDK and CLI versions if your code depends on it.
10828 ///
10829 /// </div>
10830 pub async fn pending_items(&self) -> Result<QueuePendingItemsResult, Error> {
10831 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10832 let _value = self
10833 .session
10834 .client()
10835 .call(rpc_methods::SESSION_QUEUE_PENDINGITEMS, Some(wire_params))
10836 .await?;
10837 Ok(serde_json::from_value(_value)?)
10838 }
10839
10840 /// Returns the internal native queue snapshot for in-process session orchestration.
10841 ///
10842 /// Wire method: `session.queue.snapshot`.
10843 ///
10844 /// # Returns
10845 ///
10846 /// Internal snapshot of native queue state for local session orchestration.
10847 ///
10848 /// <div class="warning">
10849 ///
10850 /// **Experimental.** This API is part of an experimental wire-protocol surface
10851 /// and may change or be removed in future SDK or CLI releases. Pin both the
10852 /// SDK and CLI versions if your code depends on it.
10853 ///
10854 /// </div>
10855 pub(crate) async fn snapshot(&self) -> Result<QueueSnapshotResult, Error> {
10856 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10857 let _value = self
10858 .session
10859 .client()
10860 .call(rpc_methods::SESSION_QUEUE_SNAPSHOT, Some(wire_params))
10861 .await?;
10862 Ok(serde_json::from_value(_value)?)
10863 }
10864
10865 /// Moves an addressable queued item to a public visible position.
10866 ///
10867 /// Wire method: `session.queue.moveItem`.
10868 ///
10869 /// # Parameters
10870 ///
10871 /// * `params` - Parameters for moving a queued item by stable id.
10872 ///
10873 /// # Returns
10874 ///
10875 /// Result of moving a queued item.
10876 ///
10877 /// <div class="warning">
10878 ///
10879 /// **Experimental.** This API is part of an experimental wire-protocol surface
10880 /// and may change or be removed in future SDK or CLI releases. Pin both the
10881 /// SDK and CLI versions if your code depends on it.
10882 ///
10883 /// </div>
10884 pub async fn move_item(
10885 &self,
10886 params: QueueMoveItemRequest,
10887 ) -> Result<QueueMoveItemResult, Error> {
10888 let mut wire_params = serde_json::to_value(params)?;
10889 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10890 let _value = self
10891 .session
10892 .client()
10893 .call(rpc_methods::SESSION_QUEUE_MOVEITEM, Some(wire_params))
10894 .await?;
10895 Ok(serde_json::from_value(_value)?)
10896 }
10897
10898 /// Inserts a new queued message at a public visible position.
10899 ///
10900 /// Wire method: `session.queue.insertAt`.
10901 ///
10902 /// # Parameters
10903 ///
10904 /// * `params` - Parameters for inserting a queued message at a public visible position.
10905 ///
10906 /// # Returns
10907 ///
10908 /// Result of inserting a queued message.
10909 ///
10910 /// <div class="warning">
10911 ///
10912 /// **Experimental.** This API is part of an experimental wire-protocol surface
10913 /// and may change or be removed in future SDK or CLI releases. Pin both the
10914 /// SDK and CLI versions if your code depends on it.
10915 ///
10916 /// </div>
10917 pub async fn insert_at(
10918 &self,
10919 params: QueueInsertAtRequest,
10920 ) -> Result<QueueInsertAtResult, Error> {
10921 let mut wire_params = serde_json::to_value(params)?;
10922 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10923 let _value = self
10924 .session
10925 .client()
10926 .call(rpc_methods::SESSION_QUEUE_INSERTAT, Some(wire_params))
10927 .await?;
10928 Ok(serde_json::from_value(_value)?)
10929 }
10930
10931 /// Removes an addressable queued item by its stable id.
10932 ///
10933 /// Wire method: `session.queue.removeAt`.
10934 ///
10935 /// # Parameters
10936 ///
10937 /// * `params` - Parameters for removing a queued item by stable id.
10938 ///
10939 /// # Returns
10940 ///
10941 /// Result of removing a queued item.
10942 ///
10943 /// <div class="warning">
10944 ///
10945 /// **Experimental.** This API is part of an experimental wire-protocol surface
10946 /// and may change or be removed in future SDK or CLI releases. Pin both the
10947 /// SDK and CLI versions if your code depends on it.
10948 ///
10949 /// </div>
10950 pub async fn remove_at(
10951 &self,
10952 params: QueueRemoveAtRequest,
10953 ) -> Result<QueueRemoveAtResult, Error> {
10954 let mut wire_params = serde_json::to_value(params)?;
10955 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10956 let _value = self
10957 .session
10958 .client()
10959 .call(rpc_methods::SESSION_QUEUE_REMOVEAT, Some(wire_params))
10960 .await?;
10961 Ok(serde_json::from_value(_value)?)
10962 }
10963
10964 /// Updates the text of an addressable single-message queue item.
10965 ///
10966 /// Wire method: `session.queue.updateText`.
10967 ///
10968 /// # Parameters
10969 ///
10970 /// * `params` - Parameters for editing a single queued message.
10971 ///
10972 /// # Returns
10973 ///
10974 /// Result of editing a queued message.
10975 ///
10976 /// <div class="warning">
10977 ///
10978 /// **Experimental.** This API is part of an experimental wire-protocol surface
10979 /// and may change or be removed in future SDK or CLI releases. Pin both the
10980 /// SDK and CLI versions if your code depends on it.
10981 ///
10982 /// </div>
10983 pub async fn update_text(
10984 &self,
10985 params: QueueUpdateTextRequest,
10986 ) -> Result<QueueUpdateTextResult, Error> {
10987 let mut wire_params = serde_json::to_value(params)?;
10988 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10989 let _value = self
10990 .session
10991 .client()
10992 .call(rpc_methods::SESSION_QUEUE_UPDATETEXT, Some(wire_params))
10993 .await?;
10994 Ok(serde_json::from_value(_value)?)
10995 }
10996
10997 /// 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.
10998 ///
10999 /// Wire method: `session.queue.withdrawMessage`.
11000 ///
11001 /// # Parameters
11002 ///
11003 /// * `params` - Conditional withdrawal of a single user message, from its queue or from the running turn it started.
11004 ///
11005 /// # Returns
11006 ///
11007 /// Result of withdrawing a user message.
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 async fn withdraw_message(
11017 &self,
11018 params: QueueWithdrawMessageRequest,
11019 ) -> Result<QueueWithdrawMessageResult, Error> {
11020 let mut wire_params = serde_json::to_value(params)?;
11021 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11022 let _value = self
11023 .session
11024 .client()
11025 .call(
11026 rpc_methods::SESSION_QUEUE_WITHDRAWMESSAGE,
11027 Some(wire_params),
11028 )
11029 .await?;
11030 Ok(serde_json::from_value(_value)?)
11031 }
11032
11033 /// Atomically appends text and attachments to an unchanged, unconsumed local steering message. Returns updated=false if delivery or withdrawal already claimed the message.
11034 ///
11035 /// Wire method: `session.queue.appendSteering`.
11036 ///
11037 /// # Parameters
11038 ///
11039 /// * `params` - Append to one pending steering message without changing its identity or delivery position.
11040 ///
11041 /// # Returns
11042 ///
11043 /// Result of editing a queued message.
11044 ///
11045 /// <div class="warning">
11046 ///
11047 /// **Experimental.** This API is part of an experimental wire-protocol surface
11048 /// and may change or be removed in future SDK or CLI releases. Pin both the
11049 /// SDK and CLI versions if your code depends on it.
11050 ///
11051 /// </div>
11052 pub async fn append_steering(
11053 &self,
11054 params: QueueAppendSteeringRequest,
11055 ) -> Result<QueueUpdateTextResult, Error> {
11056 let mut wire_params = serde_json::to_value(params)?;
11057 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11058 let _value = self
11059 .session
11060 .client()
11061 .call(rpc_methods::SESSION_QUEUE_APPENDSTEERING, Some(wire_params))
11062 .await?;
11063 Ok(serde_json::from_value(_value)?)
11064 }
11065
11066 /// Duplicates an addressable queued item immediately after its source.
11067 ///
11068 /// Wire method: `session.queue.duplicateAt`.
11069 ///
11070 /// # Parameters
11071 ///
11072 /// * `params` - Parameters for duplicating a queued item.
11073 ///
11074 /// # Returns
11075 ///
11076 /// Result of duplicating a queued item.
11077 ///
11078 /// <div class="warning">
11079 ///
11080 /// **Experimental.** This API is part of an experimental wire-protocol surface
11081 /// and may change or be removed in future SDK or CLI releases. Pin both the
11082 /// SDK and CLI versions if your code depends on it.
11083 ///
11084 /// </div>
11085 pub async fn duplicate_at(
11086 &self,
11087 params: QueueDuplicateAtRequest,
11088 ) -> Result<QueueDuplicateAtResult, Error> {
11089 let mut wire_params = serde_json::to_value(params)?;
11090 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11091 let _value = self
11092 .session
11093 .client()
11094 .call(rpc_methods::SESSION_QUEUE_DUPLICATEAT, Some(wire_params))
11095 .await?;
11096 Ok(serde_json::from_value(_value)?)
11097 }
11098
11099 /// Acquires or releases the queued-lane drain pause.
11100 ///
11101 /// Wire method: `session.queue.setDrainPaused`.
11102 ///
11103 /// # Parameters
11104 ///
11105 /// * `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.
11106 ///
11107 /// <div class="warning">
11108 ///
11109 /// **Experimental.** This API is part of an experimental wire-protocol surface
11110 /// and may change or be removed in future SDK or CLI releases. Pin both the
11111 /// SDK and CLI versions if your code depends on it.
11112 ///
11113 /// </div>
11114 pub async fn set_drain_paused(&self, params: QueueSetDrainPausedRequest) -> Result<(), Error> {
11115 let mut wire_params = serde_json::to_value(params)?;
11116 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11117 let _value = self
11118 .session
11119 .client()
11120 .call(rpc_methods::SESSION_QUEUE_SETDRAINPAUSED, Some(wire_params))
11121 .await?;
11122 Ok(())
11123 }
11124
11125 /// Moves an addressable queued message into the live turn's steering lane.
11126 ///
11127 /// Wire method: `session.queue.sendNow`.
11128 ///
11129 /// # Parameters
11130 ///
11131 /// * `params` - Parameters for steering a queued message into a live turn.
11132 ///
11133 /// # Returns
11134 ///
11135 /// Result of trying to steer a queued message into a live turn.
11136 ///
11137 /// <div class="warning">
11138 ///
11139 /// **Experimental.** This API is part of an experimental wire-protocol surface
11140 /// and may change or be removed in future SDK or CLI releases. Pin both the
11141 /// SDK and CLI versions if your code depends on it.
11142 ///
11143 /// </div>
11144 pub async fn send_now(&self, params: QueueSendNowRequest) -> Result<QueueSendNowResult, Error> {
11145 let mut wire_params = serde_json::to_value(params)?;
11146 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11147 let _value = self
11148 .session
11149 .client()
11150 .call(rpc_methods::SESSION_QUEUE_SENDNOW, Some(wire_params))
11151 .await?;
11152 Ok(serde_json::from_value(_value)?)
11153 }
11154
11155 /// Reports whether the local session has native queued work pending.
11156 ///
11157 /// Wire method: `session.queue.hasPending`.
11158 ///
11159 /// # Returns
11160 ///
11161 /// Whether the native queue has pending work.
11162 ///
11163 /// <div class="warning">
11164 ///
11165 /// **Experimental.** This API is part of an experimental wire-protocol surface
11166 /// and may change or be removed in future SDK or CLI releases. Pin both the
11167 /// SDK and CLI versions if your code depends on it.
11168 ///
11169 /// </div>
11170 pub(crate) async fn has_pending(&self) -> Result<QueueHasPendingResult, Error> {
11171 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
11172 let _value = self
11173 .session
11174 .client()
11175 .call(rpc_methods::SESSION_QUEUE_HASPENDING, Some(wire_params))
11176 .await?;
11177 Ok(serde_json::from_value(_value)?)
11178 }
11179
11180 /// Begins a native deferred-idle drain when background work has quiesced.
11181 ///
11182 /// Wire method: `session.queue.beginDeferredIdleDrain`.
11183 ///
11184 /// # Parameters
11185 ///
11186 /// * `params` - Inputs for starting a deferred-idle drain.
11187 ///
11188 /// # Returns
11189 ///
11190 /// Whether a deferred-idle drain should run.
11191 ///
11192 /// <div class="warning">
11193 ///
11194 /// **Experimental.** This API is part of an experimental wire-protocol surface
11195 /// and may change or be removed in future SDK or CLI releases. Pin both the
11196 /// SDK and CLI versions if your code depends on it.
11197 ///
11198 /// </div>
11199 pub(crate) async fn begin_deferred_idle_drain(
11200 &self,
11201 params: QueueBeginDeferredIdleDrainRequest,
11202 ) -> Result<QueueBeginDeferredIdleDrainResult, Error> {
11203 let mut wire_params = serde_json::to_value(params)?;
11204 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11205 let _value = self
11206 .session
11207 .client()
11208 .call(
11209 rpc_methods::SESSION_QUEUE_BEGINDEFERREDIDLEDRAIN,
11210 Some(wire_params),
11211 )
11212 .await?;
11213 Ok(serde_json::from_value(_value)?)
11214 }
11215
11216 /// Finishes a native deferred-idle drain and reports whether to drain queue work or emit idle.
11217 ///
11218 /// Wire method: `session.queue.finishDeferredIdleDrain`.
11219 ///
11220 /// # Parameters
11221 ///
11222 /// * `params` - Inputs for completing a deferred-idle drain.
11223 ///
11224 /// # Returns
11225 ///
11226 /// Action selected by the native deferred-idle drain.
11227 ///
11228 /// <div class="warning">
11229 ///
11230 /// **Experimental.** This API is part of an experimental wire-protocol surface
11231 /// and may change or be removed in future SDK or CLI releases. Pin both the
11232 /// SDK and CLI versions if your code depends on it.
11233 ///
11234 /// </div>
11235 pub(crate) async fn finish_deferred_idle_drain(
11236 &self,
11237 params: QueueFinishDeferredIdleDrainRequest,
11238 ) -> Result<QueueFinishDeferredIdleDrainResult, Error> {
11239 let mut wire_params = serde_json::to_value(params)?;
11240 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11241 let _value = self
11242 .session
11243 .client()
11244 .call(
11245 rpc_methods::SESSION_QUEUE_FINISHDEFERREDIDLEDRAIN,
11246 Some(wire_params),
11247 )
11248 .await?;
11249 Ok(serde_json::from_value(_value)?)
11250 }
11251
11252 /// Marks session.idle as deferred by native background work state.
11253 ///
11254 /// Wire method: `session.queue.deferSessionIdle`.
11255 ///
11256 /// # Parameters
11257 ///
11258 /// * `params` - Inputs for marking session.idle deferred in native state.
11259 ///
11260 /// <div class="warning">
11261 ///
11262 /// **Experimental.** This API is part of an experimental wire-protocol surface
11263 /// and may change or be removed in future SDK or CLI releases. Pin both the
11264 /// SDK and CLI versions if your code depends on it.
11265 ///
11266 /// </div>
11267 pub(crate) async fn defer_session_idle(
11268 &self,
11269 params: QueueDeferSessionIdleRequest,
11270 ) -> Result<(), Error> {
11271 let mut wire_params = serde_json::to_value(params)?;
11272 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11273 let _value = self
11274 .session
11275 .client()
11276 .call(
11277 rpc_methods::SESSION_QUEUE_DEFERSESSIONIDLE,
11278 Some(wire_params),
11279 )
11280 .await?;
11281 Ok(())
11282 }
11283
11284 /// Removes the most recently queued user-facing item (LIFO).
11285 ///
11286 /// Wire method: `session.queue.removeMostRecent`.
11287 ///
11288 /// # Returns
11289 ///
11290 /// Indicates whether a user-facing pending item was removed.
11291 ///
11292 /// <div class="warning">
11293 ///
11294 /// **Experimental.** This API is part of an experimental wire-protocol surface
11295 /// and may change or be removed in future SDK or CLI releases. Pin both the
11296 /// SDK and CLI versions if your code depends on it.
11297 ///
11298 /// </div>
11299 pub async fn remove_most_recent(&self) -> Result<QueueRemoveMostRecentResult, Error> {
11300 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
11301 let _value = self
11302 .session
11303 .client()
11304 .call(
11305 rpc_methods::SESSION_QUEUE_REMOVEMOSTRECENT,
11306 Some(wire_params),
11307 )
11308 .await?;
11309 Ok(serde_json::from_value(_value)?)
11310 }
11311
11312 /// Clears all pending queued items on the local session.
11313 ///
11314 /// Wire method: `session.queue.clear`.
11315 ///
11316 /// <div class="warning">
11317 ///
11318 /// **Experimental.** This API is part of an experimental wire-protocol surface
11319 /// and may change or be removed in future SDK or CLI releases. Pin both the
11320 /// SDK and CLI versions if your code depends on it.
11321 ///
11322 /// </div>
11323 pub async fn clear(&self) -> Result<(), Error> {
11324 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
11325 let _value = self
11326 .session
11327 .client()
11328 .call(rpc_methods::SESSION_QUEUE_CLEAR, Some(wire_params))
11329 .await?;
11330 Ok(())
11331 }
11332
11333 /// Consumes queued native system notifications matching an internal filter.
11334 ///
11335 /// Wire method: `session.queue.consumeSystemNotifications`.
11336 ///
11337 /// # Parameters
11338 ///
11339 /// * `params` - Internal filter for consuming queued system notifications.
11340 ///
11341 /// # Returns
11342 ///
11343 /// Indicates whether a user-facing pending item was removed.
11344 ///
11345 /// <div class="warning">
11346 ///
11347 /// **Experimental.** This API is part of an experimental wire-protocol surface
11348 /// and may change or be removed in future SDK or CLI releases. Pin both the
11349 /// SDK and CLI versions if your code depends on it.
11350 ///
11351 /// </div>
11352 pub(crate) async fn consume_system_notifications(
11353 &self,
11354 params: QueueConsumeSystemNotificationsRequest,
11355 ) -> Result<QueueRemoveMostRecentResult, Error> {
11356 let mut wire_params = serde_json::to_value(params)?;
11357 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11358 let _value = self
11359 .session
11360 .client()
11361 .call(
11362 rpc_methods::SESSION_QUEUE_CONSUMESYSTEMNOTIFICATIONS,
11363 Some(wire_params),
11364 )
11365 .await?;
11366 Ok(serde_json::from_value(_value)?)
11367 }
11368
11369 /// Enqueues the internal resume-pending wake item when orphan handling needs a follow-up turn.
11370 ///
11371 /// Wire method: `session.queue.enqueueResumePending`.
11372 ///
11373 /// # Returns
11374 ///
11375 /// Result of enqueueing the resume-pending wake item.
11376 ///
11377 /// <div class="warning">
11378 ///
11379 /// **Experimental.** This API is part of an experimental wire-protocol surface
11380 /// and may change or be removed in future SDK or CLI releases. Pin both the
11381 /// SDK and CLI versions if your code depends on it.
11382 ///
11383 /// </div>
11384 pub(crate) async fn enqueue_resume_pending(
11385 &self,
11386 ) -> Result<QueueEnqueueResumePendingResult, Error> {
11387 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
11388 let _value = self
11389 .session
11390 .client()
11391 .call(
11392 rpc_methods::SESSION_QUEUE_ENQUEUERESUMEPENDING,
11393 Some(wire_params),
11394 )
11395 .await?;
11396 Ok(serde_json::from_value(_value)?)
11397 }
11398
11399 /// Drains the native local-session work queue for in-process session orchestration.
11400 ///
11401 /// Wire method: `session.queue.process`.
11402 ///
11403 /// <div class="warning">
11404 ///
11405 /// **Experimental.** This API is part of an experimental wire-protocol surface
11406 /// and may change or be removed in future SDK or CLI releases. Pin both the
11407 /// SDK and CLI versions if your code depends on it.
11408 ///
11409 /// </div>
11410 pub(crate) async fn process(&self) -> Result<(), Error> {
11411 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
11412 let _value = self
11413 .session
11414 .client()
11415 .call(rpc_methods::SESSION_QUEUE_PROCESS, Some(wire_params))
11416 .await?;
11417 Ok(())
11418 }
11419}
11420
11421/// `session.remote.*` RPCs.
11422#[derive(Clone, Copy)]
11423pub struct SessionRpcRemote<'a> {
11424 pub(crate) session: &'a Session,
11425}
11426
11427impl<'a> SessionRpcRemote<'a> {
11428 /// Enables remote session export or steering.
11429 ///
11430 /// Wire method: `session.remote.enable`.
11431 ///
11432 /// # Parameters
11433 ///
11434 /// * `params` - Optional remote session mode ("off", "export", or "on"); defaults to enabling both export and remote steering.
11435 ///
11436 /// # Returns
11437 ///
11438 /// GitHub URL for the session and a flag indicating whether remote steering is enabled.
11439 ///
11440 /// <div class="warning">
11441 ///
11442 /// **Experimental.** This API is part of an experimental wire-protocol surface
11443 /// and may change or be removed in future SDK or CLI releases. Pin both the
11444 /// SDK and CLI versions if your code depends on it.
11445 ///
11446 /// </div>
11447 pub async fn enable(&self, params: RemoteEnableRequest) -> Result<RemoteEnableResult, Error> {
11448 let mut wire_params = serde_json::to_value(params)?;
11449 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11450 let _value = self
11451 .session
11452 .client()
11453 .call(rpc_methods::SESSION_REMOTE_ENABLE, Some(wire_params))
11454 .await?;
11455 Ok(serde_json::from_value(_value)?)
11456 }
11457
11458 /// Disables remote session export and steering.
11459 ///
11460 /// Wire method: `session.remote.disable`.
11461 ///
11462 /// <div class="warning">
11463 ///
11464 /// **Experimental.** This API is part of an experimental wire-protocol surface
11465 /// and may change or be removed in future SDK or CLI releases. Pin both the
11466 /// SDK and CLI versions if your code depends on it.
11467 ///
11468 /// </div>
11469 pub async fn disable(&self) -> Result<(), Error> {
11470 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
11471 let _value = self
11472 .session
11473 .client()
11474 .call(rpc_methods::SESSION_REMOTE_DISABLE, Some(wire_params))
11475 .await?;
11476 Ok(())
11477 }
11478
11479 /// Persists a remote-steerability change emitted by the host as a session event.
11480 ///
11481 /// Wire method: `session.remote.notifySteerableChanged`.
11482 ///
11483 /// # Parameters
11484 ///
11485 /// * `params` - New remote-steerability state to persist as a `session.remote_steerable_changed` event.
11486 ///
11487 /// # Returns
11488 ///
11489 /// 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.
11490 ///
11491 /// <div class="warning">
11492 ///
11493 /// **Experimental.** This API is part of an experimental wire-protocol surface
11494 /// and may change or be removed in future SDK or CLI releases. Pin both the
11495 /// SDK and CLI versions if your code depends on it.
11496 ///
11497 /// </div>
11498 pub async fn notify_steerable_changed(
11499 &self,
11500 params: RemoteNotifySteerableChangedRequest,
11501 ) -> Result<RemoteNotifySteerableChangedResult, Error> {
11502 let mut wire_params = serde_json::to_value(params)?;
11503 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11504 let _value = self
11505 .session
11506 .client()
11507 .call(
11508 rpc_methods::SESSION_REMOTE_NOTIFYSTEERABLECHANGED,
11509 Some(wire_params),
11510 )
11511 .await?;
11512 Ok(serde_json::from_value(_value)?)
11513 }
11514}
11515
11516/// `session.sandbox.*` RPCs.
11517#[derive(Clone, Copy)]
11518pub struct SessionRpcSandbox<'a> {
11519 pub(crate) session: &'a Session,
11520}
11521
11522impl<'a> SessionRpcSandbox<'a> {
11523 /// Returns whether managed policy requires sandbox enforcement and whether an enforcement failure has permanently blocked the session.
11524 ///
11525 /// Wire method: `session.sandbox.getEnforcementStatus`.
11526 ///
11527 /// # Returns
11528 ///
11529 /// Managed sandbox enforcement state for a session.
11530 ///
11531 /// <div class="warning">
11532 ///
11533 /// **Experimental.** This API is part of an experimental wire-protocol surface
11534 /// and may change or be removed in future SDK or CLI releases. Pin both the
11535 /// SDK and CLI versions if your code depends on it.
11536 ///
11537 /// </div>
11538 pub async fn get_enforcement_status(&self) -> Result<SandboxEnforcementStatus, Error> {
11539 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
11540 let _value = self
11541 .session
11542 .client()
11543 .call(
11544 rpc_methods::SESSION_SANDBOX_GETENFORCEMENTSTATUS,
11545 Some(wire_params),
11546 )
11547 .await?;
11548 Ok(serde_json::from_value(_value)?)
11549 }
11550
11551 /// 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.
11552 ///
11553 /// Wire method: `session.sandbox.disableForSession`.
11554 ///
11555 /// # Parameters
11556 ///
11557 /// * `params` - Request to disable sandboxing for the current session while resolving an active sandbox-bypass permission prompt.
11558 ///
11559 /// # Returns
11560 ///
11561 /// Result of attempting to disable sandboxing for the current session.
11562 ///
11563 /// <div class="warning">
11564 ///
11565 /// **Experimental.** This API is part of an experimental wire-protocol surface
11566 /// and may change or be removed in future SDK or CLI releases. Pin both the
11567 /// SDK and CLI versions if your code depends on it.
11568 ///
11569 /// </div>
11570 pub async fn disable_for_session(
11571 &self,
11572 params: SandboxDisableForSessionRequest,
11573 ) -> Result<SandboxDisableForSessionResult, Error> {
11574 let mut wire_params = serde_json::to_value(params)?;
11575 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11576 let _value = self
11577 .session
11578 .client()
11579 .call(
11580 rpc_methods::SESSION_SANDBOX_DISABLEFORSESSION,
11581 Some(wire_params),
11582 )
11583 .await?;
11584 Ok(serde_json::from_value(_value)?)
11585 }
11586}
11587
11588/// `session.schedule.*` RPCs.
11589#[derive(Clone, Copy)]
11590pub struct SessionRpcSchedule<'a> {
11591 pub(crate) session: &'a Session,
11592}
11593
11594impl<'a> SessionRpcSchedule<'a> {
11595 /// Lists the session's currently active scheduled prompts.
11596 ///
11597 /// Wire method: `session.schedule.list`.
11598 ///
11599 /// # Returns
11600 ///
11601 /// Snapshot of the currently active recurring prompts for this session.
11602 ///
11603 /// <div class="warning">
11604 ///
11605 /// **Experimental.** This API is part of an experimental wire-protocol surface
11606 /// and may change or be removed in future SDK or CLI releases. Pin both the
11607 /// SDK and CLI versions if your code depends on it.
11608 ///
11609 /// </div>
11610 pub async fn list(&self) -> Result<ScheduleList, Error> {
11611 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
11612 let _value = self
11613 .session
11614 .client()
11615 .call(rpc_methods::SESSION_SCHEDULE_LIST, Some(wire_params))
11616 .await?;
11617 Ok(serde_json::from_value(_value)?)
11618 }
11619
11620 /// Hydrates the native schedule registry from persisted session events.
11621 ///
11622 /// Wire method: `session.schedule.hydrate`.
11623 ///
11624 /// <div class="warning">
11625 ///
11626 /// **Experimental.** This API is part of an experimental wire-protocol surface
11627 /// and may change or be removed in future SDK or CLI releases. Pin both the
11628 /// SDK and CLI versions if your code depends on it.
11629 ///
11630 /// </div>
11631 pub(crate) async fn hydrate(&self) -> Result<(), Error> {
11632 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
11633 let _value = self
11634 .session
11635 .client()
11636 .call(rpc_methods::SESSION_SCHEDULE_HYDRATE, Some(wire_params))
11637 .await?;
11638 Ok(())
11639 }
11640
11641 /// Reports whether the session has an active self-paced scheduled prompt.
11642 ///
11643 /// Wire method: `session.schedule.hasSelfPaced`.
11644 ///
11645 /// # Returns
11646 ///
11647 /// Whether the session currently has an active self-paced schedule.
11648 ///
11649 /// <div class="warning">
11650 ///
11651 /// **Experimental.** This API is part of an experimental wire-protocol surface
11652 /// and may change or be removed in future SDK or CLI releases. Pin both the
11653 /// SDK and CLI versions if your code depends on it.
11654 ///
11655 /// </div>
11656 pub(crate) async fn has_self_paced(&self) -> Result<ScheduleHasSelfPacedResult, Error> {
11657 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
11658 let _value = self
11659 .session
11660 .client()
11661 .call(
11662 rpc_methods::SESSION_SCHEDULE_HASSELFPACED,
11663 Some(wire_params),
11664 )
11665 .await?;
11666 Ok(serde_json::from_value(_value)?)
11667 }
11668
11669 /// Registers a relative-interval scheduled prompt.
11670 ///
11671 /// Wire method: `session.schedule.add`.
11672 ///
11673 /// # Parameters
11674 ///
11675 /// * `params` - Register a relative-interval scheduled prompt.
11676 ///
11677 /// # Returns
11678 ///
11679 /// Result of registering or re-arming a scheduled prompt.
11680 ///
11681 /// <div class="warning">
11682 ///
11683 /// **Experimental.** This API is part of an experimental wire-protocol surface
11684 /// and may change or be removed in future SDK or CLI releases. Pin both the
11685 /// SDK and CLI versions if your code depends on it.
11686 ///
11687 /// </div>
11688 pub(crate) async fn add(&self, params: ScheduleAddRequest) -> Result<ScheduleAddResult, Error> {
11689 let mut wire_params = serde_json::to_value(params)?;
11690 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11691 let _value = self
11692 .session
11693 .client()
11694 .call(rpc_methods::SESSION_SCHEDULE_ADD, Some(wire_params))
11695 .await?;
11696 Ok(serde_json::from_value(_value)?)
11697 }
11698
11699 /// Registers a recurring cron scheduled prompt.
11700 ///
11701 /// Wire method: `session.schedule.addCron`.
11702 ///
11703 /// # Parameters
11704 ///
11705 /// * `params` - Register a cron scheduled prompt.
11706 ///
11707 /// # Returns
11708 ///
11709 /// Result of registering or re-arming a scheduled prompt.
11710 ///
11711 /// <div class="warning">
11712 ///
11713 /// **Experimental.** This API is part of an experimental wire-protocol surface
11714 /// and may change or be removed in future SDK or CLI releases. Pin both the
11715 /// SDK and CLI versions if your code depends on it.
11716 ///
11717 /// </div>
11718 pub(crate) async fn add_cron(
11719 &self,
11720 params: ScheduleAddCronRequest,
11721 ) -> Result<ScheduleAddResult, Error> {
11722 let mut wire_params = serde_json::to_value(params)?;
11723 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11724 let _value = self
11725 .session
11726 .client()
11727 .call(rpc_methods::SESSION_SCHEDULE_ADDCRON, Some(wire_params))
11728 .await?;
11729 Ok(serde_json::from_value(_value)?)
11730 }
11731
11732 /// Registers an absolute-time scheduled prompt.
11733 ///
11734 /// Wire method: `session.schedule.addAt`.
11735 ///
11736 /// # Parameters
11737 ///
11738 /// * `params` - Register an absolute-time scheduled prompt.
11739 ///
11740 /// # Returns
11741 ///
11742 /// Result of registering or re-arming a scheduled prompt.
11743 ///
11744 /// <div class="warning">
11745 ///
11746 /// **Experimental.** This API is part of an experimental wire-protocol surface
11747 /// and may change or be removed in future SDK or CLI releases. Pin both the
11748 /// SDK and CLI versions if your code depends on it.
11749 ///
11750 /// </div>
11751 pub(crate) async fn add_at(
11752 &self,
11753 params: ScheduleAddAtRequest,
11754 ) -> Result<ScheduleAddResult, Error> {
11755 let mut wire_params = serde_json::to_value(params)?;
11756 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11757 let _value = self
11758 .session
11759 .client()
11760 .call(rpc_methods::SESSION_SCHEDULE_ADDAT, Some(wire_params))
11761 .await?;
11762 Ok(serde_json::from_value(_value)?)
11763 }
11764
11765 /// Registers a self-paced scheduled prompt.
11766 ///
11767 /// Wire method: `session.schedule.addSelfPaced`.
11768 ///
11769 /// # Parameters
11770 ///
11771 /// * `params` - Register a self-paced scheduled prompt.
11772 ///
11773 /// # Returns
11774 ///
11775 /// Result of registering or re-arming a scheduled prompt.
11776 ///
11777 /// <div class="warning">
11778 ///
11779 /// **Experimental.** This API is part of an experimental wire-protocol surface
11780 /// and may change or be removed in future SDK or CLI releases. Pin both the
11781 /// SDK and CLI versions if your code depends on it.
11782 ///
11783 /// </div>
11784 pub(crate) async fn add_self_paced(
11785 &self,
11786 params: ScheduleAddSelfPacedRequest,
11787 ) -> Result<ScheduleAddResult, Error> {
11788 let mut wire_params = serde_json::to_value(params)?;
11789 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11790 let _value = self
11791 .session
11792 .client()
11793 .call(
11794 rpc_methods::SESSION_SCHEDULE_ADDSELFPACED,
11795 Some(wire_params),
11796 )
11797 .await?;
11798 Ok(serde_json::from_value(_value)?)
11799 }
11800
11801 /// Re-arms an active self-paced scheduled prompt.
11802 ///
11803 /// Wire method: `session.schedule.rearmSelfPaced`.
11804 ///
11805 /// # Parameters
11806 ///
11807 /// * `params` - Re-arm a self-paced scheduled prompt.
11808 ///
11809 /// # Returns
11810 ///
11811 /// Result of registering or re-arming a scheduled prompt.
11812 ///
11813 /// <div class="warning">
11814 ///
11815 /// **Experimental.** This API is part of an experimental wire-protocol surface
11816 /// and may change or be removed in future SDK or CLI releases. Pin both the
11817 /// SDK and CLI versions if your code depends on it.
11818 ///
11819 /// </div>
11820 pub(crate) async fn rearm_self_paced(
11821 &self,
11822 params: ScheduleRearmSelfPacedRequest,
11823 ) -> Result<ScheduleAddResult, Error> {
11824 let mut wire_params = serde_json::to_value(params)?;
11825 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11826 let _value = self
11827 .session
11828 .client()
11829 .call(
11830 rpc_methods::SESSION_SCHEDULE_REARMSELFPACED,
11831 Some(wire_params),
11832 )
11833 .await?;
11834 Ok(serde_json::from_value(_value)?)
11835 }
11836
11837 /// Removes a scheduled prompt by id.
11838 ///
11839 /// Wire method: `session.schedule.stop`.
11840 ///
11841 /// # Parameters
11842 ///
11843 /// * `params` - Identifier of the scheduled prompt to remove.
11844 ///
11845 /// # Returns
11846 ///
11847 /// Remove a scheduled prompt by id. The result entry is omitted if the id was unknown.
11848 ///
11849 /// <div class="warning">
11850 ///
11851 /// **Experimental.** This API is part of an experimental wire-protocol surface
11852 /// and may change or be removed in future SDK or CLI releases. Pin both the
11853 /// SDK and CLI versions if your code depends on it.
11854 ///
11855 /// </div>
11856 pub async fn stop(&self, params: ScheduleStopRequest) -> Result<ScheduleStopResult, Error> {
11857 let mut wire_params = serde_json::to_value(params)?;
11858 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11859 let _value = self
11860 .session
11861 .client()
11862 .call(rpc_methods::SESSION_SCHEDULE_STOP, Some(wire_params))
11863 .await?;
11864 Ok(serde_json::from_value(_value)?)
11865 }
11866}
11867
11868/// `session.settings.*` RPCs.
11869#[derive(Clone, Copy)]
11870pub struct SessionRpcSettings<'a> {
11871 pub(crate) session: &'a Session,
11872}
11873
11874impl<'a> SessionRpcSettings<'a> {
11875 /// 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.
11876 ///
11877 /// Wire method: `session.settings.snapshot`.
11878 ///
11879 /// # Returns
11880 ///
11881 /// Redacted, serializable view of session runtime settings for SDK boundary consumers. Secrets and raw feature flags are intentionally excluded.
11882 ///
11883 /// <div class="warning">
11884 ///
11885 /// **Experimental.** This API is part of an experimental wire-protocol surface
11886 /// and may change or be removed in future SDK or CLI releases. Pin both the
11887 /// SDK and CLI versions if your code depends on it.
11888 ///
11889 /// </div>
11890 pub(crate) async fn snapshot(&self) -> Result<SessionSettingsSnapshot, Error> {
11891 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
11892 let _value = self
11893 .session
11894 .client()
11895 .call(rpc_methods::SESSION_SETTINGS_SNAPSHOT, Some(wire_params))
11896 .await?;
11897 Ok(serde_json::from_value(_value)?)
11898 }
11899
11900 /// 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.
11901 ///
11902 /// Wire method: `session.settings.evaluatePredicate`.
11903 ///
11904 /// # Parameters
11905 ///
11906 /// * `params` - Named Rust-owned settings predicate to evaluate for this session.
11907 ///
11908 /// # Returns
11909 ///
11910 /// Result of evaluating a Rust-owned settings predicate.
11911 ///
11912 /// <div class="warning">
11913 ///
11914 /// **Experimental.** This API is part of an experimental wire-protocol surface
11915 /// and may change or be removed in future SDK or CLI releases. Pin both the
11916 /// SDK and CLI versions if your code depends on it.
11917 ///
11918 /// </div>
11919 pub(crate) async fn evaluate_predicate(
11920 &self,
11921 params: SessionSettingsEvaluatePredicateRequest,
11922 ) -> Result<SessionSettingsEvaluatePredicateResult, Error> {
11923 let mut wire_params = serde_json::to_value(params)?;
11924 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11925 let _value = self
11926 .session
11927 .client()
11928 .call(
11929 rpc_methods::SESSION_SETTINGS_EVALUATEPREDICATE,
11930 Some(wire_params),
11931 )
11932 .await?;
11933 Ok(serde_json::from_value(_value)?)
11934 }
11935}
11936
11937/// `session.shell.*` RPCs.
11938#[derive(Clone, Copy)]
11939pub struct SessionRpcShell<'a> {
11940 pub(crate) session: &'a Session,
11941}
11942
11943impl<'a> SessionRpcShell<'a> {
11944 /// 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.
11945 ///
11946 /// Wire method: `session.shell.exec`.
11947 ///
11948 /// # Parameters
11949 ///
11950 /// * `params` - Shell command to run, with optional working directory and timeout in milliseconds.
11951 ///
11952 /// # Returns
11953 ///
11954 /// Identifier of the spawned process, used to correlate streamed output and exit notifications.
11955 ///
11956 /// <div class="warning">
11957 ///
11958 /// **Experimental.** This API is part of an experimental wire-protocol surface
11959 /// and may change or be removed in future SDK or CLI releases. Pin both the
11960 /// SDK and CLI versions if your code depends on it.
11961 ///
11962 /// </div>
11963 pub async fn exec(&self, params: ShellExecRequest) -> Result<ShellExecResult, Error> {
11964 let mut wire_params = serde_json::to_value(params)?;
11965 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11966 let _value = self
11967 .session
11968 .client()
11969 .call(rpc_methods::SESSION_SHELL_EXEC, Some(wire_params))
11970 .await?;
11971 Ok(serde_json::from_value(_value)?)
11972 }
11973
11974 /// 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.
11975 ///
11976 /// Wire method: `session.shell.kill`.
11977 ///
11978 /// # Parameters
11979 ///
11980 /// * `params` - Identifier of a process previously returned by "shell.exec" and the signal to send.
11981 ///
11982 /// # Returns
11983 ///
11984 /// Indicates whether the signal was delivered; false if the process was unknown or already exited.
11985 ///
11986 /// <div class="warning">
11987 ///
11988 /// **Experimental.** This API is part of an experimental wire-protocol surface
11989 /// and may change or be removed in future SDK or CLI releases. Pin both the
11990 /// SDK and CLI versions if your code depends on it.
11991 ///
11992 /// </div>
11993 pub async fn kill(&self, params: ShellKillRequest) -> Result<ShellKillResult, Error> {
11994 let mut wire_params = serde_json::to_value(params)?;
11995 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11996 let _value = self
11997 .session
11998 .client()
11999 .call(rpc_methods::SESSION_SHELL_KILL, Some(wire_params))
12000 .await?;
12001 Ok(serde_json::from_value(_value)?)
12002 }
12003
12004 /// Executes a user-requested shell command through the session runtime.
12005 ///
12006 /// Wire method: `session.shell.executeUserRequested`.
12007 ///
12008 /// # Parameters
12009 ///
12010 /// * `params` - User-requested shell command and cancellation handle.
12011 ///
12012 /// # Returns
12013 ///
12014 /// Result of a user-requested shell command.
12015 ///
12016 /// <div class="warning">
12017 ///
12018 /// **Experimental.** This API is part of an experimental wire-protocol surface
12019 /// and may change or be removed in future SDK or CLI releases. Pin both the
12020 /// SDK and CLI versions if your code depends on it.
12021 ///
12022 /// </div>
12023 pub async fn execute_user_requested(
12024 &self,
12025 params: ShellExecuteUserRequestedRequest,
12026 ) -> Result<UserRequestedShellCommandResult, Error> {
12027 let mut wire_params = serde_json::to_value(params)?;
12028 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
12029 let _value = self
12030 .session
12031 .client()
12032 .call(
12033 rpc_methods::SESSION_SHELL_EXECUTEUSERREQUESTED,
12034 Some(wire_params),
12035 )
12036 .await?;
12037 Ok(serde_json::from_value(_value)?)
12038 }
12039
12040 /// Cancels a user-requested shell command by request ID.
12041 ///
12042 /// Wire method: `session.shell.cancelUserRequested`.
12043 ///
12044 /// # Parameters
12045 ///
12046 /// * `params` - User-requested shell execution cancellation handle.
12047 ///
12048 /// # Returns
12049 ///
12050 /// Cancellation result for a user-requested shell command.
12051 ///
12052 /// <div class="warning">
12053 ///
12054 /// **Experimental.** This API is part of an experimental wire-protocol surface
12055 /// and may change or be removed in future SDK or CLI releases. Pin both the
12056 /// SDK and CLI versions if your code depends on it.
12057 ///
12058 /// </div>
12059 pub async fn cancel_user_requested(
12060 &self,
12061 params: ShellCancelUserRequestedRequest,
12062 ) -> Result<CancelUserRequestedShellCommandResult, Error> {
12063 let mut wire_params = serde_json::to_value(params)?;
12064 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
12065 let _value = self
12066 .session
12067 .client()
12068 .call(
12069 rpc_methods::SESSION_SHELL_CANCELUSERREQUESTED,
12070 Some(wire_params),
12071 )
12072 .await?;
12073 Ok(serde_json::from_value(_value)?)
12074 }
12075}
12076
12077/// `session.skills.*` RPCs.
12078#[derive(Clone, Copy)]
12079pub struct SessionRpcSkills<'a> {
12080 pub(crate) session: &'a Session,
12081}
12082
12083impl<'a> SessionRpcSkills<'a> {
12084 /// Lists skills available to the session.
12085 ///
12086 /// Wire method: `session.skills.list`.
12087 ///
12088 /// # Returns
12089 ///
12090 /// Skills available to the session, with their enabled state.
12091 ///
12092 /// <div class="warning">
12093 ///
12094 /// **Experimental.** This API is part of an experimental wire-protocol surface
12095 /// and may change or be removed in future SDK or CLI releases. Pin both the
12096 /// SDK and CLI versions if your code depends on it.
12097 ///
12098 /// </div>
12099 pub async fn list(&self) -> Result<SkillList, Error> {
12100 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
12101 let _value = self
12102 .session
12103 .client()
12104 .call(rpc_methods::SESSION_SKILLS_LIST, Some(wire_params))
12105 .await?;
12106 Ok(serde_json::from_value(_value)?)
12107 }
12108
12109 /// Returns the skills that have been invoked during this session.
12110 ///
12111 /// Wire method: `session.skills.getInvoked`.
12112 ///
12113 /// # Returns
12114 ///
12115 /// Skills invoked during this session, ordered by invocation time (most recent last).
12116 ///
12117 /// <div class="warning">
12118 ///
12119 /// **Experimental.** This API is part of an experimental wire-protocol surface
12120 /// and may change or be removed in future SDK or CLI releases. Pin both the
12121 /// SDK and CLI versions if your code depends on it.
12122 ///
12123 /// </div>
12124 pub async fn get_invoked(&self) -> Result<SkillsGetInvokedResult, Error> {
12125 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
12126 let _value = self
12127 .session
12128 .client()
12129 .call(rpc_methods::SESSION_SKILLS_GETINVOKED, Some(wire_params))
12130 .await?;
12131 Ok(serde_json::from_value(_value)?)
12132 }
12133
12134 /// Enables a skill for the session.
12135 ///
12136 /// Wire method: `session.skills.enable`.
12137 ///
12138 /// # Parameters
12139 ///
12140 /// * `params` - Name of the skill to enable for the session.
12141 ///
12142 /// <div class="warning">
12143 ///
12144 /// **Experimental.** This API is part of an experimental wire-protocol surface
12145 /// and may change or be removed in future SDK or CLI releases. Pin both the
12146 /// SDK and CLI versions if your code depends on it.
12147 ///
12148 /// </div>
12149 pub async fn enable(&self, params: SkillsEnableRequest) -> Result<(), Error> {
12150 let mut wire_params = serde_json::to_value(params)?;
12151 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
12152 let _value = self
12153 .session
12154 .client()
12155 .call(rpc_methods::SESSION_SKILLS_ENABLE, Some(wire_params))
12156 .await?;
12157 Ok(())
12158 }
12159
12160 /// Disables a skill for the session.
12161 ///
12162 /// Wire method: `session.skills.disable`.
12163 ///
12164 /// # Parameters
12165 ///
12166 /// * `params` - Name of the skill to disable for the session.
12167 ///
12168 /// <div class="warning">
12169 ///
12170 /// **Experimental.** This API is part of an experimental wire-protocol surface
12171 /// and may change or be removed in future SDK or CLI releases. Pin both the
12172 /// SDK and CLI versions if your code depends on it.
12173 ///
12174 /// </div>
12175 pub async fn disable(&self, params: SkillsDisableRequest) -> Result<(), Error> {
12176 let mut wire_params = serde_json::to_value(params)?;
12177 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
12178 let _value = self
12179 .session
12180 .client()
12181 .call(rpc_methods::SESSION_SKILLS_DISABLE, Some(wire_params))
12182 .await?;
12183 Ok(())
12184 }
12185
12186 /// Reloads skill definitions for the session.
12187 ///
12188 /// Wire method: `session.skills.reload`.
12189 ///
12190 /// # Returns
12191 ///
12192 /// Diagnostics from reloading skill definitions, with warnings and errors as separate lists.
12193 ///
12194 /// <div class="warning">
12195 ///
12196 /// **Experimental.** This API is part of an experimental wire-protocol surface
12197 /// and may change or be removed in future SDK or CLI releases. Pin both the
12198 /// SDK and CLI versions if your code depends on it.
12199 ///
12200 /// </div>
12201 pub async fn reload(&self) -> Result<SkillsLoadDiagnostics, Error> {
12202 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
12203 let _value = self
12204 .session
12205 .client()
12206 .call(rpc_methods::SESSION_SKILLS_RELOAD, Some(wire_params))
12207 .await?;
12208 Ok(serde_json::from_value(_value)?)
12209 }
12210
12211 /// Ensures the session's skill definitions have been loaded from disk.
12212 ///
12213 /// Wire method: `session.skills.ensureLoaded`.
12214 ///
12215 /// <div class="warning">
12216 ///
12217 /// **Experimental.** This API is part of an experimental wire-protocol surface
12218 /// and may change or be removed in future SDK or CLI releases. Pin both the
12219 /// SDK and CLI versions if your code depends on it.
12220 ///
12221 /// </div>
12222 pub async fn ensure_loaded(&self) -> Result<(), Error> {
12223 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
12224 let _value = self
12225 .session
12226 .client()
12227 .call(rpc_methods::SESSION_SKILLS_ENSURELOADED, Some(wire_params))
12228 .await?;
12229 Ok(())
12230 }
12231}
12232
12233/// `session.tasks.*` RPCs.
12234#[derive(Clone, Copy)]
12235pub struct SessionRpcTasks<'a> {
12236 pub(crate) session: &'a Session,
12237}
12238
12239impl<'a> SessionRpcTasks<'a> {
12240 /// Starts a background agent task in the session.
12241 ///
12242 /// Wire method: `session.tasks.startAgent`.
12243 ///
12244 /// # Parameters
12245 ///
12246 /// * `params` - Agent type, prompt, name, and optional description and model override for the new task.
12247 ///
12248 /// # Returns
12249 ///
12250 /// Identifier assigned to the newly started background agent task.
12251 ///
12252 /// <div class="warning">
12253 ///
12254 /// **Experimental.** This API is part of an experimental wire-protocol surface
12255 /// and may change or be removed in future SDK or CLI releases. Pin both the
12256 /// SDK and CLI versions if your code depends on it.
12257 ///
12258 /// </div>
12259 pub async fn start_agent(
12260 &self,
12261 params: TasksStartAgentRequest,
12262 ) -> Result<TasksStartAgentResult, Error> {
12263 let mut wire_params = serde_json::to_value(params)?;
12264 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
12265 let _value = self
12266 .session
12267 .client()
12268 .call(rpc_methods::SESSION_TASKS_STARTAGENT, Some(wire_params))
12269 .await?;
12270 Ok(serde_json::from_value(_value)?)
12271 }
12272
12273 /// Lists background tasks tracked by the session.
12274 ///
12275 /// Wire method: `session.tasks.list`.
12276 ///
12277 /// # Returns
12278 ///
12279 /// Background tasks currently tracked by the session.
12280 ///
12281 /// <div class="warning">
12282 ///
12283 /// **Experimental.** This API is part of an experimental wire-protocol surface
12284 /// and may change or be removed in future SDK or CLI releases. Pin both the
12285 /// SDK and CLI versions if your code depends on it.
12286 ///
12287 /// </div>
12288 pub async fn list(&self) -> Result<TaskList, Error> {
12289 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
12290 let _value = self
12291 .session
12292 .client()
12293 .call(rpc_methods::SESSION_TASKS_LIST, Some(wire_params))
12294 .await?;
12295 Ok(serde_json::from_value(_value)?)
12296 }
12297
12298 /// Registers a client-owned task, or reclaims an orphaned task belonging to the same extension principal.
12299 ///
12300 /// Wire method: `session.tasks.register`.
12301 ///
12302 /// # Parameters
12303 ///
12304 /// * `params` - Registers or reclaims a client-owned task.
12305 ///
12306 /// # Returns
12307 ///
12308 /// Result of registering or reclaiming a client-owned task.
12309 ///
12310 /// <div class="warning">
12311 ///
12312 /// **Experimental.** This API is part of an experimental wire-protocol surface
12313 /// and may change or be removed in future SDK or CLI releases. Pin both the
12314 /// SDK and CLI versions if your code depends on it.
12315 ///
12316 /// </div>
12317 pub async fn register(
12318 &self,
12319 params: TasksRegisterRequest,
12320 ) -> Result<TasksRegisterResult, Error> {
12321 let mut wire_params = serde_json::to_value(params)?;
12322 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
12323 let _value = self
12324 .session
12325 .client()
12326 .call(rpc_methods::SESSION_TASKS_REGISTER, Some(wire_params))
12327 .await?;
12328 Ok(serde_json::from_value(_value)?)
12329 }
12330
12331 /// Publishes generic progress or a terminal outcome for a client-owned task.
12332 ///
12333 /// Wire method: `session.tasks.update`.
12334 ///
12335 /// # Parameters
12336 ///
12337 /// * `params` - Updates a client-owned task.
12338 ///
12339 /// # Returns
12340 ///
12341 /// Result of publishing a client-owned task update.
12342 ///
12343 /// <div class="warning">
12344 ///
12345 /// **Experimental.** This API is part of an experimental wire-protocol surface
12346 /// and may change or be removed in future SDK or CLI releases. Pin both the
12347 /// SDK and CLI versions if your code depends on it.
12348 ///
12349 /// </div>
12350 pub async fn update(&self, params: TasksUpdateRequest) -> Result<TasksUpdateResult, Error> {
12351 let mut wire_params = serde_json::to_value(params)?;
12352 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
12353 let _value = self
12354 .session
12355 .client()
12356 .call(rpc_methods::SESSION_TASKS_UPDATE, Some(wire_params))
12357 .await?;
12358 Ok(serde_json::from_value(_value)?)
12359 }
12360
12361 /// Refreshes metadata for any detached background shells the runtime knows about.
12362 ///
12363 /// Wire method: `session.tasks.refresh`.
12364 ///
12365 /// # Returns
12366 ///
12367 /// 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.
12368 ///
12369 /// <div class="warning">
12370 ///
12371 /// **Experimental.** This API is part of an experimental wire-protocol surface
12372 /// and may change or be removed in future SDK or CLI releases. Pin both the
12373 /// SDK and CLI versions if your code depends on it.
12374 ///
12375 /// </div>
12376 pub async fn refresh(&self) -> Result<TasksRefreshResult, Error> {
12377 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
12378 let _value = self
12379 .session
12380 .client()
12381 .call(rpc_methods::SESSION_TASKS_REFRESH, Some(wire_params))
12382 .await?;
12383 Ok(serde_json::from_value(_value)?)
12384 }
12385
12386 /// Waits for all in-flight background tasks and any follow-up turns to settle.
12387 ///
12388 /// Wire method: `session.tasks.waitForPending`.
12389 ///
12390 /// # Returns
12391 ///
12392 /// 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).
12393 ///
12394 /// <div class="warning">
12395 ///
12396 /// **Experimental.** This API is part of an experimental wire-protocol surface
12397 /// and may change or be removed in future SDK or CLI releases. Pin both the
12398 /// SDK and CLI versions if your code depends on it.
12399 ///
12400 /// </div>
12401 pub async fn wait_for_pending(&self) -> Result<TasksWaitForPendingResult, Error> {
12402 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
12403 let _value = self
12404 .session
12405 .client()
12406 .call(rpc_methods::SESSION_TASKS_WAITFORPENDING, Some(wire_params))
12407 .await?;
12408 Ok(serde_json::from_value(_value)?)
12409 }
12410
12411 /// Returns progress information for a background task by ID.
12412 ///
12413 /// Wire method: `session.tasks.getProgress`.
12414 ///
12415 /// # Parameters
12416 ///
12417 /// * `params` - Identifier of the background task to fetch progress for.
12418 ///
12419 /// # Returns
12420 ///
12421 /// Progress information for the task, or null when no task with that ID is tracked.
12422 ///
12423 /// <div class="warning">
12424 ///
12425 /// **Experimental.** This API is part of an experimental wire-protocol surface
12426 /// and may change or be removed in future SDK or CLI releases. Pin both the
12427 /// SDK and CLI versions if your code depends on it.
12428 ///
12429 /// </div>
12430 pub async fn get_progress(
12431 &self,
12432 params: TasksGetProgressRequest,
12433 ) -> Result<TasksGetProgressResult, Error> {
12434 let mut wire_params = serde_json::to_value(params)?;
12435 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
12436 let _value = self
12437 .session
12438 .client()
12439 .call(rpc_methods::SESSION_TASKS_GETPROGRESS, Some(wire_params))
12440 .await?;
12441 Ok(serde_json::from_value(_value)?)
12442 }
12443
12444 /// Returns the first sync-waiting task that can currently be promoted to background mode.
12445 ///
12446 /// Wire method: `session.tasks.getCurrentPromotable`.
12447 ///
12448 /// # Returns
12449 ///
12450 /// The first sync-waiting task that can currently be promoted to background mode.
12451 ///
12452 /// <div class="warning">
12453 ///
12454 /// **Experimental.** This API is part of an experimental wire-protocol surface
12455 /// and may change or be removed in future SDK or CLI releases. Pin both the
12456 /// SDK and CLI versions if your code depends on it.
12457 ///
12458 /// </div>
12459 pub async fn get_current_promotable(&self) -> Result<TasksGetCurrentPromotableResult, Error> {
12460 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
12461 let _value = self
12462 .session
12463 .client()
12464 .call(
12465 rpc_methods::SESSION_TASKS_GETCURRENTPROMOTABLE,
12466 Some(wire_params),
12467 )
12468 .await?;
12469 Ok(serde_json::from_value(_value)?)
12470 }
12471
12472 /// Promotes an eligible synchronously-waited task so it continues running in the background.
12473 ///
12474 /// Wire method: `session.tasks.promoteToBackground`.
12475 ///
12476 /// # Parameters
12477 ///
12478 /// * `params` - Identifier of the task to promote to background mode.
12479 ///
12480 /// # Returns
12481 ///
12482 /// Indicates whether the task was successfully promoted to background mode.
12483 ///
12484 /// <div class="warning">
12485 ///
12486 /// **Experimental.** This API is part of an experimental wire-protocol surface
12487 /// and may change or be removed in future SDK or CLI releases. Pin both the
12488 /// SDK and CLI versions if your code depends on it.
12489 ///
12490 /// </div>
12491 pub async fn promote_to_background(
12492 &self,
12493 params: TasksPromoteToBackgroundRequest,
12494 ) -> Result<TasksPromoteToBackgroundResult, Error> {
12495 let mut wire_params = serde_json::to_value(params)?;
12496 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
12497 let _value = self
12498 .session
12499 .client()
12500 .call(
12501 rpc_methods::SESSION_TASKS_PROMOTETOBACKGROUND,
12502 Some(wire_params),
12503 )
12504 .await?;
12505 Ok(serde_json::from_value(_value)?)
12506 }
12507
12508 /// Atomically promotes the first promotable sync-waiting task to background mode and returns it.
12509 ///
12510 /// Wire method: `session.tasks.promoteCurrentToBackground`.
12511 ///
12512 /// # Returns
12513 ///
12514 /// The promoted task as it now exists in background mode, omitted if no promotable task was waiting.
12515 ///
12516 /// <div class="warning">
12517 ///
12518 /// **Experimental.** This API is part of an experimental wire-protocol surface
12519 /// and may change or be removed in future SDK or CLI releases. Pin both the
12520 /// SDK and CLI versions if your code depends on it.
12521 ///
12522 /// </div>
12523 pub async fn promote_current_to_background(
12524 &self,
12525 ) -> Result<TasksPromoteCurrentToBackgroundResult, Error> {
12526 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
12527 let _value = self
12528 .session
12529 .client()
12530 .call(
12531 rpc_methods::SESSION_TASKS_PROMOTECURRENTTOBACKGROUND,
12532 Some(wire_params),
12533 )
12534 .await?;
12535 Ok(serde_json::from_value(_value)?)
12536 }
12537
12538 /// Cancels a background task.
12539 ///
12540 /// Wire method: `session.tasks.cancel`.
12541 ///
12542 /// # Parameters
12543 ///
12544 /// * `params` - Identifier of the background task to cancel.
12545 ///
12546 /// # Returns
12547 ///
12548 /// Indicates whether the background task was successfully cancelled.
12549 ///
12550 /// <div class="warning">
12551 ///
12552 /// **Experimental.** This API is part of an experimental wire-protocol surface
12553 /// and may change or be removed in future SDK or CLI releases. Pin both the
12554 /// SDK and CLI versions if your code depends on it.
12555 ///
12556 /// </div>
12557 pub async fn cancel(&self, params: TasksCancelRequest) -> Result<TasksCancelResult, Error> {
12558 let mut wire_params = serde_json::to_value(params)?;
12559 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
12560 let _value = self
12561 .session
12562 .client()
12563 .call(rpc_methods::SESSION_TASKS_CANCEL, Some(wire_params))
12564 .await?;
12565 Ok(serde_json::from_value(_value)?)
12566 }
12567
12568 /// Removes a completed or cancelled background task from tracking.
12569 ///
12570 /// Wire method: `session.tasks.remove`.
12571 ///
12572 /// # Parameters
12573 ///
12574 /// * `params` - Identifier of the completed or cancelled task to remove from tracking.
12575 ///
12576 /// # Returns
12577 ///
12578 /// Indicates whether the task was removed. False when the task does not exist or is still running/idle.
12579 ///
12580 /// <div class="warning">
12581 ///
12582 /// **Experimental.** This API is part of an experimental wire-protocol surface
12583 /// and may change or be removed in future SDK or CLI releases. Pin both the
12584 /// SDK and CLI versions if your code depends on it.
12585 ///
12586 /// </div>
12587 pub async fn remove(&self, params: TasksRemoveRequest) -> Result<TasksRemoveResult, Error> {
12588 let mut wire_params = serde_json::to_value(params)?;
12589 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
12590 let _value = self
12591 .session
12592 .client()
12593 .call(rpc_methods::SESSION_TASKS_REMOVE, Some(wire_params))
12594 .await?;
12595 Ok(serde_json::from_value(_value)?)
12596 }
12597
12598 /// Sends a message to a background agent task.
12599 ///
12600 /// Wire method: `session.tasks.sendMessage`.
12601 ///
12602 /// # Parameters
12603 ///
12604 /// * `params` - Identifier of the target agent task, message content, and optional sender agent ID.
12605 ///
12606 /// # Returns
12607 ///
12608 /// Indicates whether the message was delivered, with an error message when delivery failed.
12609 ///
12610 /// <div class="warning">
12611 ///
12612 /// **Experimental.** This API is part of an experimental wire-protocol surface
12613 /// and may change or be removed in future SDK or CLI releases. Pin both the
12614 /// SDK and CLI versions if your code depends on it.
12615 ///
12616 /// </div>
12617 pub async fn send_message(
12618 &self,
12619 params: TasksSendMessageRequest,
12620 ) -> Result<TasksSendMessageResult, Error> {
12621 let mut wire_params = serde_json::to_value(params)?;
12622 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
12623 let _value = self
12624 .session
12625 .client()
12626 .call(rpc_methods::SESSION_TASKS_SENDMESSAGE, Some(wire_params))
12627 .await?;
12628 Ok(serde_json::from_value(_value)?)
12629 }
12630}
12631
12632/// `session.telemetry.*` RPCs.
12633#[derive(Clone, Copy)]
12634pub struct SessionRpcTelemetry<'a> {
12635 pub(crate) session: &'a Session,
12636}
12637
12638impl<'a> SessionRpcTelemetry<'a> {
12639 /// Gets the telemetry engagement ID currently associated with the session, when available.
12640 ///
12641 /// Wire method: `session.telemetry.getEngagementId`.
12642 ///
12643 /// # Returns
12644 ///
12645 /// Telemetry engagement ID for the session, when available.
12646 ///
12647 /// <div class="warning">
12648 ///
12649 /// **Experimental.** This API is part of an experimental wire-protocol surface
12650 /// and may change or be removed in future SDK or CLI releases. Pin both the
12651 /// SDK and CLI versions if your code depends on it.
12652 ///
12653 /// </div>
12654 pub async fn get_engagement_id(&self) -> Result<SessionTelemetryEngagement, Error> {
12655 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
12656 let _value = self
12657 .session
12658 .client()
12659 .call(
12660 rpc_methods::SESSION_TELEMETRY_GETENGAGEMENTID,
12661 Some(wire_params),
12662 )
12663 .await?;
12664 Ok(serde_json::from_value(_value)?)
12665 }
12666
12667 /// Sets feature override key/value pairs to attach to subsequent telemetry events for the session.
12668 ///
12669 /// Wire method: `session.telemetry.setFeatureOverrides`.
12670 ///
12671 /// # Parameters
12672 ///
12673 /// * `params` - Feature override key/value pairs to attach to subsequent telemetry events from this session.
12674 ///
12675 /// <div class="warning">
12676 ///
12677 /// **Experimental.** This API is part of an experimental wire-protocol surface
12678 /// and may change or be removed in future SDK or CLI releases. Pin both the
12679 /// SDK and CLI versions if your code depends on it.
12680 ///
12681 /// </div>
12682 pub async fn set_feature_overrides(
12683 &self,
12684 params: TelemetrySetFeatureOverridesRequest,
12685 ) -> Result<(), Error> {
12686 let mut wire_params = serde_json::to_value(params)?;
12687 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
12688 let _value = self
12689 .session
12690 .client()
12691 .call(
12692 rpc_methods::SESSION_TELEMETRY_SETFEATUREOVERRIDES,
12693 Some(wire_params),
12694 )
12695 .await?;
12696 Ok(())
12697 }
12698}
12699
12700/// `session.tools.*` RPCs.
12701#[derive(Clone, Copy)]
12702pub struct SessionRpcTools<'a> {
12703 pub(crate) session: &'a Session,
12704}
12705
12706impl<'a> SessionRpcTools<'a> {
12707 /// Executes one tool from the session's currently offered tool set through the native invocation pipeline.
12708 ///
12709 /// Wire method: `session.tools.execute`.
12710 ///
12711 /// # Parameters
12712 ///
12713 /// * `params` - A tool name and arguments to execute through the session's native invocation pipeline.
12714 ///
12715 /// # Returns
12716 ///
12717 /// Canonical result returned by a session tool.
12718 ///
12719 /// <div class="warning">
12720 ///
12721 /// **Experimental.** This API is part of an experimental wire-protocol surface
12722 /// and may change or be removed in future SDK or CLI releases. Pin both the
12723 /// SDK and CLI versions if your code depends on it.
12724 ///
12725 /// </div>
12726 pub async fn execute(&self, params: ToolsExecuteRequest) -> Result<ToolResult, Error> {
12727 let mut wire_params = serde_json::to_value(params)?;
12728 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
12729 let _value = self
12730 .session
12731 .client()
12732 .call(rpc_methods::SESSION_TOOLS_EXECUTE, Some(wire_params))
12733 .await?;
12734 Ok(serde_json::from_value(_value)?)
12735 }
12736
12737 /// Returns the Rust-owned built-in tool descriptors used to construct the session's offered tool set.
12738 ///
12739 /// Wire method: `session.tools.getBuiltinDescriptors`.
12740 ///
12741 /// # Parameters
12742 ///
12743 /// * `params` - Options controlling how Rust-owned built-in tool descriptors are materialized.
12744 ///
12745 /// # Returns
12746 ///
12747 /// Rust-owned built-in tool descriptors for the session.
12748 ///
12749 /// <div class="warning">
12750 ///
12751 /// **Experimental.** This API is part of an experimental wire-protocol surface
12752 /// and may change or be removed in future SDK or CLI releases. Pin both the
12753 /// SDK and CLI versions if your code depends on it.
12754 ///
12755 /// </div>
12756 pub async fn get_builtin_descriptors(
12757 &self,
12758 params: ToolsGetBuiltinDescriptorsRequest,
12759 ) -> Result<ToolsGetBuiltinDescriptorsResult, Error> {
12760 let mut wire_params = serde_json::to_value(params)?;
12761 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
12762 let _value = self
12763 .session
12764 .client()
12765 .call(
12766 rpc_methods::SESSION_TOOLS_GETBUILTINDESCRIPTORS,
12767 Some(wire_params),
12768 )
12769 .await?;
12770 Ok(serde_json::from_value(_value)?)
12771 }
12772
12773 /// Projects a completed task_complete tool call into its label-safe session event payload.
12774 ///
12775 /// Wire method: `session.tools.taskCompleteEventData`.
12776 ///
12777 /// # Parameters
12778 ///
12779 /// * `params` - Task-completion tool arguments and final result used to build a label-safe session event payload.
12780 ///
12781 /// # Returns
12782 ///
12783 /// Task completion notification with summary from the agent
12784 ///
12785 /// <div class="warning">
12786 ///
12787 /// **Experimental.** This API is part of an experimental wire-protocol surface
12788 /// and may change or be removed in future SDK or CLI releases. Pin both the
12789 /// SDK and CLI versions if your code depends on it.
12790 ///
12791 /// </div>
12792 pub async fn task_complete_event_data(
12793 &self,
12794 params: ToolsTaskCompleteEventDataRequest,
12795 ) -> Result<TaskCompleteData, Error> {
12796 let mut wire_params = serde_json::to_value(params)?;
12797 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
12798 let _value = self
12799 .session
12800 .client()
12801 .call(
12802 rpc_methods::SESSION_TOOLS_TASKCOMPLETEEVENTDATA,
12803 Some(wire_params),
12804 )
12805 .await?;
12806 Ok(serde_json::from_value(_value)?)
12807 }
12808
12809 /// Provides the result for a pending external tool call.
12810 ///
12811 /// Wire method: `session.tools.handlePendingToolCall`.
12812 ///
12813 /// # Parameters
12814 ///
12815 /// * `params` - Pending external tool call request ID, with the tool result or an error describing why it failed.
12816 ///
12817 /// # Returns
12818 ///
12819 /// Indicates whether the external tool call result was handled successfully.
12820 ///
12821 /// <div class="warning">
12822 ///
12823 /// **Experimental.** This API is part of an experimental wire-protocol surface
12824 /// and may change or be removed in future SDK or CLI releases. Pin both the
12825 /// SDK and CLI versions if your code depends on it.
12826 ///
12827 /// </div>
12828 pub async fn handle_pending_tool_call(
12829 &self,
12830 params: HandlePendingToolCallRequest,
12831 ) -> Result<HandlePendingToolCallResult, Error> {
12832 let mut wire_params = serde_json::to_value(params)?;
12833 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
12834 let _value = self
12835 .session
12836 .client()
12837 .call(
12838 rpc_methods::SESSION_TOOLS_HANDLEPENDINGTOOLCALL,
12839 Some(wire_params),
12840 )
12841 .await?;
12842 Ok(serde_json::from_value(_value)?)
12843 }
12844
12845 /// Resolves, builds, and validates the runtime tool list for the session.
12846 ///
12847 /// Wire method: `session.tools.initializeAndValidate`.
12848 ///
12849 /// # Returns
12850 ///
12851 /// 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.
12852 ///
12853 /// <div class="warning">
12854 ///
12855 /// **Experimental.** This API is part of an experimental wire-protocol surface
12856 /// and may change or be removed in future SDK or CLI releases. Pin both the
12857 /// SDK and CLI versions if your code depends on it.
12858 ///
12859 /// </div>
12860 pub async fn initialize_and_validate(&self) -> Result<ToolsInitializeAndValidateResult, Error> {
12861 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
12862 let _value = self
12863 .session
12864 .client()
12865 .call(
12866 rpc_methods::SESSION_TOOLS_INITIALIZEANDVALIDATE,
12867 Some(wire_params),
12868 )
12869 .await?;
12870 Ok(serde_json::from_value(_value)?)
12871 }
12872
12873 /// Returns lightweight metadata for the session's currently initialized tools.
12874 ///
12875 /// Wire method: `session.tools.getCurrentMetadata`.
12876 ///
12877 /// # Returns
12878 ///
12879 /// Current lightweight tool metadata snapshot for the session.
12880 ///
12881 /// <div class="warning">
12882 ///
12883 /// **Experimental.** This API is part of an experimental wire-protocol surface
12884 /// and may change or be removed in future SDK or CLI releases. Pin both the
12885 /// SDK and CLI versions if your code depends on it.
12886 ///
12887 /// </div>
12888 pub async fn get_current_metadata(&self) -> Result<ToolsGetCurrentMetadataResult, Error> {
12889 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
12890 let _value = self
12891 .session
12892 .client()
12893 .call(
12894 rpc_methods::SESSION_TOOLS_GETCURRENTMETADATA,
12895 Some(wire_params),
12896 )
12897 .await?;
12898 Ok(serde_json::from_value(_value)?)
12899 }
12900
12901 /// 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.
12902 ///
12903 /// Wire method: `session.tools.set`.
12904 ///
12905 /// # Parameters
12906 ///
12907 /// * `params` - Complete externally implemented tool list for the calling connection. An empty list removes every tool previously supplied by that connection.
12908 ///
12909 /// # Returns
12910 ///
12911 /// Empty result after replacing the calling connection's externally implemented tools.
12912 ///
12913 /// <div class="warning">
12914 ///
12915 /// **Experimental.** This API is part of an experimental wire-protocol surface
12916 /// and may change or be removed in future SDK or CLI releases. Pin both the
12917 /// SDK and CLI versions if your code depends on it.
12918 ///
12919 /// </div>
12920 pub async fn set(&self, params: ToolsSetRequest) -> Result<ToolsSetResult, Error> {
12921 let mut wire_params = serde_json::to_value(params)?;
12922 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
12923 let _value = self
12924 .session
12925 .client()
12926 .call(rpc_methods::SESSION_TOOLS_SET, Some(wire_params))
12927 .await?;
12928 Ok(serde_json::from_value(_value)?)
12929 }
12930
12931 /// 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.
12932 ///
12933 /// Wire method: `session.tools.updateSubagentSettings`.
12934 ///
12935 /// # Parameters
12936 ///
12937 /// * `params` - Subagent settings to apply to the current session
12938 ///
12939 /// # Returns
12940 ///
12941 /// Empty result after applying subagent settings
12942 ///
12943 /// <div class="warning">
12944 ///
12945 /// **Experimental.** This API is part of an experimental wire-protocol surface
12946 /// and may change or be removed in future SDK or CLI releases. Pin both the
12947 /// SDK and CLI versions if your code depends on it.
12948 ///
12949 /// </div>
12950 pub async fn update_subagent_settings(
12951 &self,
12952 params: UpdateSubagentSettingsRequest,
12953 ) -> Result<ToolsUpdateSubagentSettingsResult, Error> {
12954 let mut wire_params = serde_json::to_value(params)?;
12955 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
12956 let _value = self
12957 .session
12958 .client()
12959 .call(
12960 rpc_methods::SESSION_TOOLS_UPDATESUBAGENTSETTINGS,
12961 Some(wire_params),
12962 )
12963 .await?;
12964 Ok(serde_json::from_value(_value)?)
12965 }
12966}
12967
12968/// `session.ui.*` RPCs.
12969#[derive(Clone, Copy)]
12970pub struct SessionRpcUi<'a> {
12971 pub(crate) session: &'a Session,
12972}
12973
12974impl<'a> SessionRpcUi<'a> {
12975 /// Runs a transient no-tools model query against the current conversation context.
12976 ///
12977 /// Wire method: `session.ui.ephemeralQuery`.
12978 ///
12979 /// # Parameters
12980 ///
12981 /// * `params` - Transient question to answer without adding it to conversation history.
12982 ///
12983 /// # Returns
12984 ///
12985 /// Completed transient query. Ordered chunks and the terminal outcome are also delivered through `ui.ephemeral_query` session events while it runs.
12986 ///
12987 /// <div class="warning">
12988 ///
12989 /// **Experimental.** This API is part of an experimental wire-protocol surface
12990 /// and may change or be removed in future SDK or CLI releases. Pin both the
12991 /// SDK and CLI versions if your code depends on it.
12992 ///
12993 /// </div>
12994 pub async fn ephemeral_query(
12995 &self,
12996 params: UIEphemeralQueryRequest,
12997 ) -> Result<UIEphemeralQueryResult, Error> {
12998 let mut wire_params = serde_json::to_value(params)?;
12999 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
13000 let _value = self
13001 .session
13002 .client()
13003 .call(rpc_methods::SESSION_UI_EPHEMERALQUERY, Some(wire_params))
13004 .await?;
13005 Ok(serde_json::from_value(_value)?)
13006 }
13007
13008 /// Requests structured input from a UI-capable client.
13009 ///
13010 /// Wire method: `session.ui.elicitation`.
13011 ///
13012 /// # Parameters
13013 ///
13014 /// * `params` - Prompt message and JSON schema describing the form fields to elicit from the user.
13015 ///
13016 /// # Returns
13017 ///
13018 /// The elicitation response (accept with form values, decline, or cancel)
13019 ///
13020 /// <div class="warning">
13021 ///
13022 /// **Experimental.** This API is part of an experimental wire-protocol surface
13023 /// and may change or be removed in future SDK or CLI releases. Pin both the
13024 /// SDK and CLI versions if your code depends on it.
13025 ///
13026 /// </div>
13027 pub async fn elicitation(
13028 &self,
13029 params: UIElicitationRequest,
13030 ) -> Result<UIElicitationResponse, Error> {
13031 let mut wire_params = serde_json::to_value(params)?;
13032 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
13033 let _value = self
13034 .session
13035 .client()
13036 .call(rpc_methods::SESSION_UI_ELICITATION, Some(wire_params))
13037 .await?;
13038 Ok(serde_json::from_value(_value)?)
13039 }
13040
13041 /// Provides the user response for a pending elicitation request.
13042 ///
13043 /// Wire method: `session.ui.handlePendingElicitation`.
13044 ///
13045 /// # Parameters
13046 ///
13047 /// * `params` - Pending elicitation request ID and the user's response (accept/decline/cancel + form values).
13048 ///
13049 /// # Returns
13050 ///
13051 /// Indicates whether the elicitation response was accepted; false if it was already resolved by another client.
13052 ///
13053 /// <div class="warning">
13054 ///
13055 /// **Experimental.** This API is part of an experimental wire-protocol surface
13056 /// and may change or be removed in future SDK or CLI releases. Pin both the
13057 /// SDK and CLI versions if your code depends on it.
13058 ///
13059 /// </div>
13060 pub async fn handle_pending_elicitation(
13061 &self,
13062 params: UIHandlePendingElicitationRequest,
13063 ) -> Result<UIElicitationResult, Error> {
13064 let mut wire_params = serde_json::to_value(params)?;
13065 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
13066 let _value = self
13067 .session
13068 .client()
13069 .call(
13070 rpc_methods::SESSION_UI_HANDLEPENDINGELICITATION,
13071 Some(wire_params),
13072 )
13073 .await?;
13074 Ok(serde_json::from_value(_value)?)
13075 }
13076
13077 /// Resolves a pending `user_input.requested` event with the user's response.
13078 ///
13079 /// Wire method: `session.ui.handlePendingUserInput`.
13080 ///
13081 /// # Parameters
13082 ///
13083 /// * `params` - Request ID of a pending `user_input.requested` event and the user's response.
13084 ///
13085 /// # Returns
13086 ///
13087 /// Indicates whether the pending UI request was resolved by this call.
13088 ///
13089 /// <div class="warning">
13090 ///
13091 /// **Experimental.** This API is part of an experimental wire-protocol surface
13092 /// and may change or be removed in future SDK or CLI releases. Pin both the
13093 /// SDK and CLI versions if your code depends on it.
13094 ///
13095 /// </div>
13096 pub async fn handle_pending_user_input(
13097 &self,
13098 params: UIHandlePendingUserInputRequest,
13099 ) -> Result<UIHandlePendingResult, Error> {
13100 let mut wire_params = serde_json::to_value(params)?;
13101 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
13102 let _value = self
13103 .session
13104 .client()
13105 .call(
13106 rpc_methods::SESSION_UI_HANDLEPENDINGUSERINPUT,
13107 Some(wire_params),
13108 )
13109 .await?;
13110 Ok(serde_json::from_value(_value)?)
13111 }
13112
13113 /// Resolves a pending `sampling.requested` event with a sampling result, or rejects it.
13114 ///
13115 /// Wire method: `session.ui.handlePendingSampling`.
13116 ///
13117 /// # Parameters
13118 ///
13119 /// * `params` - Request ID of a pending `sampling.requested` event and an optional sampling result payload (omit to reject).
13120 ///
13121 /// # Returns
13122 ///
13123 /// Indicates whether the pending UI request was resolved by this call.
13124 ///
13125 /// <div class="warning">
13126 ///
13127 /// **Experimental.** This API is part of an experimental wire-protocol surface
13128 /// and may change or be removed in future SDK or CLI releases. Pin both the
13129 /// SDK and CLI versions if your code depends on it.
13130 ///
13131 /// </div>
13132 pub async fn handle_pending_sampling(
13133 &self,
13134 params: UIHandlePendingSamplingRequest,
13135 ) -> Result<UIHandlePendingResult, Error> {
13136 let mut wire_params = serde_json::to_value(params)?;
13137 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
13138 let _value = self
13139 .session
13140 .client()
13141 .call(
13142 rpc_methods::SESSION_UI_HANDLEPENDINGSAMPLING,
13143 Some(wire_params),
13144 )
13145 .await?;
13146 Ok(serde_json::from_value(_value)?)
13147 }
13148
13149 /// Resolves a pending `auto_mode_switch.requested` event with the user's accept/decline decision.
13150 ///
13151 /// Wire method: `session.ui.handlePendingAutoModeSwitch`.
13152 ///
13153 /// # Parameters
13154 ///
13155 /// * `params` - Request ID of a pending `auto_mode_switch.requested` event and the user's response.
13156 ///
13157 /// # Returns
13158 ///
13159 /// Indicates whether the pending UI request was resolved by this call.
13160 ///
13161 /// <div class="warning">
13162 ///
13163 /// **Experimental.** This API is part of an experimental wire-protocol surface
13164 /// and may change or be removed in future SDK or CLI releases. Pin both the
13165 /// SDK and CLI versions if your code depends on it.
13166 ///
13167 /// </div>
13168 pub async fn handle_pending_auto_mode_switch(
13169 &self,
13170 params: UIHandlePendingAutoModeSwitchRequest,
13171 ) -> Result<UIHandlePendingResult, Error> {
13172 let mut wire_params = serde_json::to_value(params)?;
13173 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
13174 let _value = self
13175 .session
13176 .client()
13177 .call(
13178 rpc_methods::SESSION_UI_HANDLEPENDINGAUTOMODESWITCH,
13179 Some(wire_params),
13180 )
13181 .await?;
13182 Ok(serde_json::from_value(_value)?)
13183 }
13184
13185 /// Resolves a pending `session_limits_exhausted.requested` event with the user's selected limit action.
13186 ///
13187 /// Wire method: `session.ui.handlePendingSessionLimitsExhausted`.
13188 ///
13189 /// # Parameters
13190 ///
13191 /// * `params` - Request ID of a pending `session_limits_exhausted.requested` event and the user's selected limit action.
13192 ///
13193 /// # Returns
13194 ///
13195 /// Indicates whether the pending UI request was resolved by this call.
13196 ///
13197 /// <div class="warning">
13198 ///
13199 /// **Experimental.** This API is part of an experimental wire-protocol surface
13200 /// and may change or be removed in future SDK or CLI releases. Pin both the
13201 /// SDK and CLI versions if your code depends on it.
13202 ///
13203 /// </div>
13204 pub async fn handle_pending_session_limits_exhausted(
13205 &self,
13206 params: UIHandlePendingSessionLimitsExhaustedRequest,
13207 ) -> Result<UIHandlePendingResult, Error> {
13208 let mut wire_params = serde_json::to_value(params)?;
13209 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
13210 let _value = self
13211 .session
13212 .client()
13213 .call(
13214 rpc_methods::SESSION_UI_HANDLEPENDINGSESSIONLIMITSEXHAUSTED,
13215 Some(wire_params),
13216 )
13217 .await?;
13218 Ok(serde_json::from_value(_value)?)
13219 }
13220
13221 /// Resolves a pending `exit_plan_mode.requested` event with the user's response.
13222 ///
13223 /// Wire method: `session.ui.handlePendingExitPlanMode`.
13224 ///
13225 /// # Parameters
13226 ///
13227 /// * `params` - Request ID of a pending `exit_plan_mode.requested` event and the user's response.
13228 ///
13229 /// # Returns
13230 ///
13231 /// Indicates whether the pending UI request was resolved by this call.
13232 ///
13233 /// <div class="warning">
13234 ///
13235 /// **Experimental.** This API is part of an experimental wire-protocol surface
13236 /// and may change or be removed in future SDK or CLI releases. Pin both the
13237 /// SDK and CLI versions if your code depends on it.
13238 ///
13239 /// </div>
13240 pub async fn handle_pending_exit_plan_mode(
13241 &self,
13242 params: UIHandlePendingExitPlanModeRequest,
13243 ) -> Result<UIHandlePendingResult, Error> {
13244 let mut wire_params = serde_json::to_value(params)?;
13245 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
13246 let _value = self
13247 .session
13248 .client()
13249 .call(
13250 rpc_methods::SESSION_UI_HANDLEPENDINGEXITPLANMODE,
13251 Some(wire_params),
13252 )
13253 .await?;
13254 Ok(serde_json::from_value(_value)?)
13255 }
13256
13257 /// Registers an in-process handler for auto-mode-switch requests so the server bridge skips dispatch.
13258 ///
13259 /// Wire method: `session.ui.registerDirectAutoModeSwitchHandler`.
13260 ///
13261 /// # Returns
13262 ///
13263 /// 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).
13264 ///
13265 /// <div class="warning">
13266 ///
13267 /// **Experimental.** This API is part of an experimental wire-protocol surface
13268 /// and may change or be removed in future SDK or CLI releases. Pin both the
13269 /// SDK and CLI versions if your code depends on it.
13270 ///
13271 /// </div>
13272 pub async fn register_direct_auto_mode_switch_handler(
13273 &self,
13274 ) -> Result<UIRegisterDirectAutoModeSwitchHandlerResult, Error> {
13275 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
13276 let _value = self
13277 .session
13278 .client()
13279 .call(
13280 rpc_methods::SESSION_UI_REGISTERDIRECTAUTOMODESWITCHHANDLER,
13281 Some(wire_params),
13282 )
13283 .await?;
13284 Ok(serde_json::from_value(_value)?)
13285 }
13286
13287 /// Unregisters a previously-registered in-process auto-mode-switch handler by its opaque handle.
13288 ///
13289 /// Wire method: `session.ui.unregisterDirectAutoModeSwitchHandler`.
13290 ///
13291 /// # Parameters
13292 ///
13293 /// * `params` - Opaque handle previously returned by `registerDirectAutoModeSwitchHandler` to release.
13294 ///
13295 /// # Returns
13296 ///
13297 /// Indicates whether the handle was active and the registration count was decremented.
13298 ///
13299 /// <div class="warning">
13300 ///
13301 /// **Experimental.** This API is part of an experimental wire-protocol surface
13302 /// and may change or be removed in future SDK or CLI releases. Pin both the
13303 /// SDK and CLI versions if your code depends on it.
13304 ///
13305 /// </div>
13306 pub async fn unregister_direct_auto_mode_switch_handler(
13307 &self,
13308 params: UIUnregisterDirectAutoModeSwitchHandlerRequest,
13309 ) -> Result<UIUnregisterDirectAutoModeSwitchHandlerResult, Error> {
13310 let mut wire_params = serde_json::to_value(params)?;
13311 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
13312 let _value = self
13313 .session
13314 .client()
13315 .call(
13316 rpc_methods::SESSION_UI_UNREGISTERDIRECTAUTOMODESWITCHHANDLER,
13317 Some(wire_params),
13318 )
13319 .await?;
13320 Ok(serde_json::from_value(_value)?)
13321 }
13322}
13323
13324/// `session.usage.*` RPCs.
13325#[derive(Clone, Copy)]
13326pub struct SessionRpcUsage<'a> {
13327 pub(crate) session: &'a Session,
13328}
13329
13330impl<'a> SessionRpcUsage<'a> {
13331 /// Gets accumulated usage metrics for the session.
13332 ///
13333 /// Wire method: `session.usage.getMetrics`.
13334 ///
13335 /// # Returns
13336 ///
13337 /// Accumulated session usage metrics, including premium request cost, token counts, model breakdown, and code-change totals.
13338 ///
13339 /// <div class="warning">
13340 ///
13341 /// **Experimental.** This API is part of an experimental wire-protocol surface
13342 /// and may change or be removed in future SDK or CLI releases. Pin both the
13343 /// SDK and CLI versions if your code depends on it.
13344 ///
13345 /// </div>
13346 pub async fn get_metrics(&self) -> Result<UsageGetMetricsResult, Error> {
13347 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
13348 let _value = self
13349 .session
13350 .client()
13351 .call(rpc_methods::SESSION_USAGE_GETMETRICS, Some(wire_params))
13352 .await?;
13353 Ok(serde_json::from_value(_value)?)
13354 }
13355}
13356
13357/// `session.visibility.*` RPCs.
13358#[derive(Clone, Copy)]
13359pub struct SessionRpcVisibility<'a> {
13360 pub(crate) session: &'a Session,
13361}
13362
13363impl<'a> SessionRpcVisibility<'a> {
13364 /// 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").
13365 ///
13366 /// Wire method: `session.visibility.get`.
13367 ///
13368 /// # Returns
13369 ///
13370 /// Current sharing status and shareable GitHub URL for a session.
13371 ///
13372 /// <div class="warning">
13373 ///
13374 /// **Experimental.** This API is part of an experimental wire-protocol surface
13375 /// and may change or be removed in future SDK or CLI releases. Pin both the
13376 /// SDK and CLI versions if your code depends on it.
13377 ///
13378 /// </div>
13379 pub async fn get(&self) -> Result<VisibilityGetResult, Error> {
13380 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
13381 let _value = self
13382 .session
13383 .client()
13384 .call(rpc_methods::SESSION_VISIBILITY_GET, Some(wire_params))
13385 .await?;
13386 Ok(serde_json::from_value(_value)?)
13387 }
13388
13389 /// 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.
13390 ///
13391 /// Wire method: `session.visibility.set`.
13392 ///
13393 /// # Parameters
13394 ///
13395 /// * `params` - Desired sharing status for the session.
13396 ///
13397 /// # Returns
13398 ///
13399 /// Effective sharing status and shareable GitHub URL after updating session visibility.
13400 ///
13401 /// <div class="warning">
13402 ///
13403 /// **Experimental.** This API is part of an experimental wire-protocol surface
13404 /// and may change or be removed in future SDK or CLI releases. Pin both the
13405 /// SDK and CLI versions if your code depends on it.
13406 ///
13407 /// </div>
13408 pub async fn set(&self, params: VisibilitySetRequest) -> Result<VisibilitySetResult, Error> {
13409 let mut wire_params = serde_json::to_value(params)?;
13410 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
13411 let _value = self
13412 .session
13413 .client()
13414 .call(rpc_methods::SESSION_VISIBILITY_SET, Some(wire_params))
13415 .await?;
13416 Ok(serde_json::from_value(_value)?)
13417 }
13418}
13419
13420/// `session.workflow.*` RPCs.
13421#[derive(Clone, Copy)]
13422pub struct SessionRpcWorkflow<'a> {
13423 pub(crate) session: &'a Session,
13424}
13425
13426impl<'a> SessionRpcWorkflow<'a> {
13427 /// `session.workflow.journal.*` sub-namespace.
13428 pub fn journal(&self) -> SessionRpcWorkflowJournal<'a> {
13429 SessionRpcWorkflowJournal {
13430 session: self.session,
13431 }
13432 }
13433
13434 /// Runs a registered dynamic workflow by name at the top level.
13435 ///
13436 /// Wire method: `session.workflow.run`.
13437 ///
13438 /// # Parameters
13439 ///
13440 /// * `params` - Parameters for invoking a registered workflow.
13441 ///
13442 /// # Returns
13443 ///
13444 /// Complete current or terminal workflow run envelope.
13445 ///
13446 /// <div class="warning">
13447 ///
13448 /// **Experimental.** This API is part of an experimental wire-protocol surface
13449 /// and may change or be removed in future SDK or CLI releases. Pin both the
13450 /// SDK and CLI versions if your code depends on it.
13451 ///
13452 /// </div>
13453 pub async fn run(&self, params: WorkflowRunRequest) -> Result<WorkflowRunResult, Error> {
13454 let mut wire_params = serde_json::to_value(params)?;
13455 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
13456 let _value = self
13457 .session
13458 .client()
13459 .call(rpc_methods::SESSION_WORKFLOW_RUN, Some(wire_params))
13460 .await?;
13461 Ok(serde_json::from_value(_value)?)
13462 }
13463
13464 /// Resumes a dynamic workflow run using its persisted name, arguments, journal, and accounting.
13465 ///
13466 /// Wire method: `session.workflow.resume`.
13467 ///
13468 /// # Parameters
13469 ///
13470 /// * `params` - Parameters for resuming a workflow run from its persisted identity.
13471 ///
13472 /// # Returns
13473 ///
13474 /// Resolved persisted workflow identity and resumed run envelope.
13475 ///
13476 /// <div class="warning">
13477 ///
13478 /// **Experimental.** This API is part of an experimental wire-protocol surface
13479 /// and may change or be removed in future SDK or CLI releases. Pin both the
13480 /// SDK and CLI versions if your code depends on it.
13481 ///
13482 /// </div>
13483 pub async fn resume(
13484 &self,
13485 params: WorkflowResumeRequest,
13486 ) -> Result<WorkflowResumeResult, Error> {
13487 let mut wire_params = serde_json::to_value(params)?;
13488 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
13489 let _value = self
13490 .session
13491 .client()
13492 .call(rpc_methods::SESSION_WORKFLOW_RESUME, Some(wire_params))
13493 .await?;
13494 Ok(serde_json::from_value(_value)?)
13495 }
13496
13497 /// Internal tool-originated dynamic workflow invocation.
13498 ///
13499 /// Wire method: `session.workflow.runFromTool`.
13500 ///
13501 /// # Parameters
13502 ///
13503 /// * `params` - Internal parameters for invoking a registered workflow from a tool.
13504 ///
13505 /// # Returns
13506 ///
13507 /// Complete current or terminal workflow run envelope.
13508 ///
13509 /// <div class="warning">
13510 ///
13511 /// **Experimental.** This API is part of an experimental wire-protocol surface
13512 /// and may change or be removed in future SDK or CLI releases. Pin both the
13513 /// SDK and CLI versions if your code depends on it.
13514 ///
13515 /// </div>
13516 pub(crate) async fn run_from_tool(
13517 &self,
13518 params: WorkflowToolRunRequest,
13519 ) -> Result<WorkflowRunResult, Error> {
13520 let mut wire_params = serde_json::to_value(params)?;
13521 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
13522 let _value = self
13523 .session
13524 .client()
13525 .call(rpc_methods::SESSION_WORKFLOW_RUNFROMTOOL, Some(wire_params))
13526 .await?;
13527 Ok(serde_json::from_value(_value)?)
13528 }
13529
13530 /// Internal tool-originated dynamic workflow resume.
13531 ///
13532 /// Wire method: `session.workflow.resumeFromTool`.
13533 ///
13534 /// # Parameters
13535 ///
13536 /// * `params` - Internal parameters for resuming a workflow run from a tool.
13537 ///
13538 /// # Returns
13539 ///
13540 /// Resolved persisted workflow identity and resumed run envelope.
13541 ///
13542 /// <div class="warning">
13543 ///
13544 /// **Experimental.** This API is part of an experimental wire-protocol surface
13545 /// and may change or be removed in future SDK or CLI releases. Pin both the
13546 /// SDK and CLI versions if your code depends on it.
13547 ///
13548 /// </div>
13549 pub(crate) async fn resume_from_tool(
13550 &self,
13551 params: WorkflowToolResumeRequest,
13552 ) -> Result<WorkflowResumeResult, Error> {
13553 let mut wire_params = serde_json::to_value(params)?;
13554 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
13555 let _value = self
13556 .session
13557 .client()
13558 .call(
13559 rpc_methods::SESSION_WORKFLOW_RESUMEFROMTOOL,
13560 Some(wire_params),
13561 )
13562 .await?;
13563 Ok(serde_json::from_value(_value)?)
13564 }
13565
13566 /// Gets the current or settled envelope for a dynamic workflow run.
13567 ///
13568 /// Wire method: `session.workflow.getRun`.
13569 ///
13570 /// # Parameters
13571 ///
13572 /// * `params` - Parameters for retrieving a workflow run.
13573 ///
13574 /// # Returns
13575 ///
13576 /// Complete current or terminal workflow run envelope.
13577 ///
13578 /// <div class="warning">
13579 ///
13580 /// **Experimental.** This API is part of an experimental wire-protocol surface
13581 /// and may change or be removed in future SDK or CLI releases. Pin both the
13582 /// SDK and CLI versions if your code depends on it.
13583 ///
13584 /// </div>
13585 pub async fn get_run(&self, params: WorkflowGetRunRequest) -> Result<WorkflowRunResult, Error> {
13586 let mut wire_params = serde_json::to_value(params)?;
13587 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
13588 let _value = self
13589 .session
13590 .client()
13591 .call(rpc_methods::SESSION_WORKFLOW_GETRUN, Some(wire_params))
13592 .await?;
13593 Ok(serde_json::from_value(_value)?)
13594 }
13595
13596 /// Lists durable dynamic workflow runs for this session in creation order.
13597 ///
13598 /// Wire method: `session.workflow.listRuns`.
13599 ///
13600 /// # Parameters
13601 ///
13602 /// * `params` - Parameters for paging workflow runs.
13603 ///
13604 /// # Returns
13605 ///
13606 /// A page of workflow runs in durable creation order.
13607 ///
13608 /// <div class="warning">
13609 ///
13610 /// **Experimental.** This API is part of an experimental wire-protocol surface
13611 /// and may change or be removed in future SDK or CLI releases. Pin both the
13612 /// SDK and CLI versions if your code depends on it.
13613 ///
13614 /// </div>
13615 pub async fn list_runs(
13616 &self,
13617 params: WorkflowListRunsRequest,
13618 ) -> Result<WorkflowListRunsResult, Error> {
13619 let mut wire_params = serde_json::to_value(params)?;
13620 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
13621 let _value = self
13622 .session
13623 .client()
13624 .call(rpc_methods::SESSION_WORKFLOW_LISTRUNS, Some(wire_params))
13625 .await?;
13626 Ok(serde_json::from_value(_value)?)
13627 }
13628
13629 /// Gets durable and live observability detail for one dynamic workflow run.
13630 ///
13631 /// Wire method: `session.workflow.getRunDetail`.
13632 ///
13633 /// # Parameters
13634 ///
13635 /// * `params` - Parameters for retrieving a workflow run.
13636 ///
13637 /// # Returns
13638 ///
13639 /// Full workflow run observability detail.
13640 ///
13641 /// <div class="warning">
13642 ///
13643 /// **Experimental.** This API is part of an experimental wire-protocol surface
13644 /// and may change or be removed in future SDK or CLI releases. Pin both the
13645 /// SDK and CLI versions if your code depends on it.
13646 ///
13647 /// </div>
13648 pub async fn get_run_detail(
13649 &self,
13650 params: WorkflowGetRunRequest,
13651 ) -> Result<WorkflowRunDetail, Error> {
13652 let mut wire_params = serde_json::to_value(params)?;
13653 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
13654 let _value = self
13655 .session
13656 .client()
13657 .call(
13658 rpc_methods::SESSION_WORKFLOW_GETRUNDETAIL,
13659 Some(wire_params),
13660 )
13661 .await?;
13662 Ok(serde_json::from_value(_value)?)
13663 }
13664
13665 /// Pages durable progress for one dynamic workflow run.
13666 ///
13667 /// Wire method: `session.workflow.getRunProgress`.
13668 ///
13669 /// # Parameters
13670 ///
13671 /// * `params` - Parameters for paging workflow progress.
13672 ///
13673 /// # Returns
13674 ///
13675 /// A bidirectional page of workflow progress.
13676 ///
13677 /// <div class="warning">
13678 ///
13679 /// **Experimental.** This API is part of an experimental wire-protocol surface
13680 /// and may change or be removed in future SDK or CLI releases. Pin both the
13681 /// SDK and CLI versions if your code depends on it.
13682 ///
13683 /// </div>
13684 pub async fn get_run_progress(
13685 &self,
13686 params: WorkflowGetRunProgressRequest,
13687 ) -> Result<WorkflowProgressPage, Error> {
13688 let mut wire_params = serde_json::to_value(params)?;
13689 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
13690 let _value = self
13691 .session
13692 .client()
13693 .call(
13694 rpc_methods::SESSION_WORKFLOW_GETRUNPROGRESS,
13695 Some(wire_params),
13696 )
13697 .await?;
13698 Ok(serde_json::from_value(_value)?)
13699 }
13700
13701 /// Requests cancellation of a dynamic workflow run and returns its run envelope.
13702 ///
13703 /// Wire method: `session.workflow.cancel`.
13704 ///
13705 /// # Parameters
13706 ///
13707 /// * `params` - Parameters for cancelling a workflow run.
13708 ///
13709 /// # Returns
13710 ///
13711 /// Complete current or terminal workflow run envelope.
13712 ///
13713 /// <div class="warning">
13714 ///
13715 /// **Experimental.** This API is part of an experimental wire-protocol surface
13716 /// and may change or be removed in future SDK or CLI releases. Pin both the
13717 /// SDK and CLI versions if your code depends on it.
13718 ///
13719 /// </div>
13720 pub async fn cancel(&self, params: WorkflowCancelRequest) -> Result<WorkflowRunResult, Error> {
13721 let mut wire_params = serde_json::to_value(params)?;
13722 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
13723 let _value = self
13724 .session
13725 .client()
13726 .call(rpc_methods::SESSION_WORKFLOW_CANCEL, Some(wire_params))
13727 .await?;
13728 Ok(serde_json::from_value(_value)?)
13729 }
13730
13731 /// Pauses a running dynamic workflow and returns its settled run envelope.
13732 ///
13733 /// Wire method: `session.workflow.pause`.
13734 ///
13735 /// # Parameters
13736 ///
13737 /// * `params` - Parameters for pausing a running workflow.
13738 ///
13739 /// # Returns
13740 ///
13741 /// Complete current or terminal workflow run envelope.
13742 ///
13743 /// <div class="warning">
13744 ///
13745 /// **Experimental.** This API is part of an experimental wire-protocol surface
13746 /// and may change or be removed in future SDK or CLI releases. Pin both the
13747 /// SDK and CLI versions if your code depends on it.
13748 ///
13749 /// </div>
13750 pub async fn pause(&self, params: WorkflowPauseRequest) -> Result<WorkflowRunResult, Error> {
13751 let mut wire_params = serde_json::to_value(params)?;
13752 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
13753 let _value = self
13754 .session
13755 .client()
13756 .call(rpc_methods::SESSION_WORKFLOW_PAUSE, Some(wire_params))
13757 .await?;
13758 Ok(serde_json::from_value(_value)?)
13759 }
13760
13761 /// Atomically pauses an owned dynamic workflow attempt at a durable checkpoint.
13762 ///
13763 /// Wire method: `session.workflow.pauseAtCheckpoint`.
13764 ///
13765 /// # Parameters
13766 ///
13767 /// * `params` - Parameters for an owned durable pause checkpoint.
13768 ///
13769 /// <div class="warning">
13770 ///
13771 /// **Experimental.** This API is part of an experimental wire-protocol surface
13772 /// and may change or be removed in future SDK or CLI releases. Pin both the
13773 /// SDK and CLI versions if your code depends on it.
13774 ///
13775 /// </div>
13776 pub(crate) async fn pause_at_checkpoint(
13777 &self,
13778 params: WorkflowPauseCheckpointRequest,
13779 ) -> Result<WorkflowPauseCheckpointResult, Error> {
13780 let mut wire_params = serde_json::to_value(params)?;
13781 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
13782 let _value = self
13783 .session
13784 .client()
13785 .call(
13786 rpc_methods::SESSION_WORKFLOW_PAUSEATCHECKPOINT,
13787 Some(wire_params),
13788 )
13789 .await?;
13790 Ok(serde_json::from_value(_value)?)
13791 }
13792
13793 /// Records a batch of ordered dynamic workflow progress lines.
13794 ///
13795 /// Wire method: `session.workflow.log`.
13796 ///
13797 /// # Parameters
13798 ///
13799 /// * `params` - Parameters for recording workflow progress.
13800 ///
13801 /// # Returns
13802 ///
13803 /// Acknowledgement that a workflow request was accepted.
13804 ///
13805 /// <div class="warning">
13806 ///
13807 /// **Experimental.** This API is part of an experimental wire-protocol surface
13808 /// and may change or be removed in future SDK or CLI releases. Pin both the
13809 /// SDK and CLI versions if your code depends on it.
13810 ///
13811 /// </div>
13812 pub async fn log(&self, params: WorkflowLogRequest) -> Result<WorkflowAckResult, Error> {
13813 let mut wire_params = serde_json::to_value(params)?;
13814 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
13815 let _value = self
13816 .session
13817 .client()
13818 .call(rpc_methods::SESSION_WORKFLOW_LOG, Some(wire_params))
13819 .await?;
13820 Ok(serde_json::from_value(_value)?)
13821 }
13822
13823 /// Runs one dynamic-workflow-scoped subagent and returns its result.
13824 ///
13825 /// Wire method: `session.workflow.agent`.
13826 ///
13827 /// # Parameters
13828 ///
13829 /// * `params` - Parameters for one workflow-scoped subagent call.
13830 ///
13831 /// # Returns
13832 ///
13833 /// Result of one workflow-scoped subagent call.
13834 ///
13835 /// <div class="warning">
13836 ///
13837 /// **Experimental.** This API is part of an experimental wire-protocol surface
13838 /// and may change or be removed in future SDK or CLI releases. Pin both the
13839 /// SDK and CLI versions if your code depends on it.
13840 ///
13841 /// </div>
13842 pub async fn agent(&self, params: WorkflowAgentRequest) -> Result<WorkflowAgentResult, Error> {
13843 let mut wire_params = serde_json::to_value(params)?;
13844 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
13845 let _value = self
13846 .session
13847 .client()
13848 .call(rpc_methods::SESSION_WORKFLOW_AGENT, Some(wire_params))
13849 .await?;
13850 Ok(serde_json::from_value(_value)?)
13851 }
13852}
13853
13854/// `session.workflow.journal.*` RPCs.
13855#[derive(Clone, Copy)]
13856pub struct SessionRpcWorkflowJournal<'a> {
13857 pub(crate) session: &'a Session,
13858}
13859
13860impl<'a> SessionRpcWorkflowJournal<'a> {
13861 /// Reads a memoized dynamic workflow journal entry.
13862 ///
13863 /// Wire method: `session.workflow.journal.get`.
13864 ///
13865 /// # Parameters
13866 ///
13867 /// * `params` - Parameters for reading a workflow journal entry.
13868 ///
13869 /// # Returns
13870 ///
13871 /// Result of reading a workflow journal entry.
13872 ///
13873 /// <div class="warning">
13874 ///
13875 /// **Experimental.** This API is part of an experimental wire-protocol surface
13876 /// and may change or be removed in future SDK or CLI releases. Pin both the
13877 /// SDK and CLI versions if your code depends on it.
13878 ///
13879 /// </div>
13880 pub async fn get(
13881 &self,
13882 params: WorkflowJournalGetRequest,
13883 ) -> Result<WorkflowJournalGetResult, Error> {
13884 let mut wire_params = serde_json::to_value(params)?;
13885 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
13886 let _value = self
13887 .session
13888 .client()
13889 .call(rpc_methods::SESSION_WORKFLOW_JOURNAL_GET, Some(wire_params))
13890 .await?;
13891 Ok(serde_json::from_value(_value)?)
13892 }
13893
13894 /// Stores a memoized dynamic workflow journal entry.
13895 ///
13896 /// Wire method: `session.workflow.journal.put`.
13897 ///
13898 /// # Parameters
13899 ///
13900 /// * `params` - Parameters for storing a workflow journal entry.
13901 ///
13902 /// # Returns
13903 ///
13904 /// Acknowledgement that a workflow request was accepted.
13905 ///
13906 /// <div class="warning">
13907 ///
13908 /// **Experimental.** This API is part of an experimental wire-protocol surface
13909 /// and may change or be removed in future SDK or CLI releases. Pin both the
13910 /// SDK and CLI versions if your code depends on it.
13911 ///
13912 /// </div>
13913 pub async fn put(&self, params: WorkflowJournalPutRequest) -> Result<WorkflowAckResult, Error> {
13914 let mut wire_params = serde_json::to_value(params)?;
13915 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
13916 let _value = self
13917 .session
13918 .client()
13919 .call(rpc_methods::SESSION_WORKFLOW_JOURNAL_PUT, Some(wire_params))
13920 .await?;
13921 Ok(serde_json::from_value(_value)?)
13922 }
13923}
13924
13925/// `session.workspaces.*` RPCs.
13926#[derive(Clone, Copy)]
13927pub struct SessionRpcWorkspaces<'a> {
13928 pub(crate) session: &'a Session,
13929}
13930
13931impl<'a> SessionRpcWorkspaces<'a> {
13932 /// Gets current workspace metadata for the session.
13933 ///
13934 /// Wire method: `session.workspaces.getWorkspace`.
13935 ///
13936 /// # Returns
13937 ///
13938 /// Current workspace metadata for the session, including its absolute filesystem path when available.
13939 ///
13940 /// <div class="warning">
13941 ///
13942 /// **Experimental.** This API is part of an experimental wire-protocol surface
13943 /// and may change or be removed in future SDK or CLI releases. Pin both the
13944 /// SDK and CLI versions if your code depends on it.
13945 ///
13946 /// </div>
13947 pub async fn get_workspace(&self) -> Result<WorkspacesGetWorkspaceResult, Error> {
13948 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
13949 let _value = self
13950 .session
13951 .client()
13952 .call(
13953 rpc_methods::SESSION_WORKSPACES_GETWORKSPACE,
13954 Some(wire_params),
13955 )
13956 .await?;
13957 Ok(serde_json::from_value(_value)?)
13958 }
13959
13960 /// Updates workspace metadata for a local session and returns the refreshed workspace.
13961 ///
13962 /// Wire method: `session.workspaces.updateMetadata`.
13963 ///
13964 /// # Parameters
13965 ///
13966 /// * `params` - Workspace metadata fields to update.
13967 ///
13968 /// # Returns
13969 ///
13970 /// Current workspace metadata for the session, including its absolute filesystem path when available.
13971 ///
13972 /// <div class="warning">
13973 ///
13974 /// **Experimental.** This API is part of an experimental wire-protocol surface
13975 /// and may change or be removed in future SDK or CLI releases. Pin both the
13976 /// SDK and CLI versions if your code depends on it.
13977 ///
13978 /// </div>
13979 pub async fn update_metadata(
13980 &self,
13981 params: WorkspacesUpdateMetadataRequest,
13982 ) -> Result<WorkspacesGetWorkspaceResult, Error> {
13983 let mut wire_params = serde_json::to_value(params)?;
13984 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
13985 let _value = self
13986 .session
13987 .client()
13988 .call(
13989 rpc_methods::SESSION_WORKSPACES_UPDATEMETADATA,
13990 Some(wire_params),
13991 )
13992 .await?;
13993 Ok(serde_json::from_value(_value)?)
13994 }
13995
13996 /// Ensures a local session workspace exists and returns it.
13997 ///
13998 /// Wire method: `session.workspaces.ensure`.
13999 ///
14000 /// # Parameters
14001 ///
14002 /// * `params` - Optional session context used when creating a local workspace.
14003 ///
14004 /// # Returns
14005 ///
14006 /// Current workspace metadata for the session, including its absolute filesystem path when available.
14007 ///
14008 /// <div class="warning">
14009 ///
14010 /// **Experimental.** This API is part of an experimental wire-protocol surface
14011 /// and may change or be removed in future SDK or CLI releases. Pin both the
14012 /// SDK and CLI versions if your code depends on it.
14013 ///
14014 /// </div>
14015 pub async fn ensure(
14016 &self,
14017 params: WorkspacesEnsureRequest,
14018 ) -> Result<WorkspacesGetWorkspaceResult, Error> {
14019 let mut wire_params = serde_json::to_value(params)?;
14020 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
14021 let _value = self
14022 .session
14023 .client()
14024 .call(rpc_methods::SESSION_WORKSPACES_ENSURE, Some(wire_params))
14025 .await?;
14026 Ok(serde_json::from_value(_value)?)
14027 }
14028
14029 /// Lists files stored in the session workspace files directory.
14030 ///
14031 /// Wire method: `session.workspaces.listFiles`.
14032 ///
14033 /// # Returns
14034 ///
14035 /// Relative paths of files stored in the session workspace files directory.
14036 ///
14037 /// <div class="warning">
14038 ///
14039 /// **Experimental.** This API is part of an experimental wire-protocol surface
14040 /// and may change or be removed in future SDK or CLI releases. Pin both the
14041 /// SDK and CLI versions if your code depends on it.
14042 ///
14043 /// </div>
14044 pub async fn list_files(&self) -> Result<WorkspacesListFilesResult, Error> {
14045 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
14046 let _value = self
14047 .session
14048 .client()
14049 .call(rpc_methods::SESSION_WORKSPACES_LISTFILES, Some(wire_params))
14050 .await?;
14051 Ok(serde_json::from_value(_value)?)
14052 }
14053
14054 /// Reads a file from the session workspace files directory.
14055 ///
14056 /// Wire method: `session.workspaces.readFile`.
14057 ///
14058 /// # Parameters
14059 ///
14060 /// * `params` - Relative path of the workspace file to read.
14061 ///
14062 /// # Returns
14063 ///
14064 /// Contents of the requested workspace file as a UTF-8 string.
14065 ///
14066 /// <div class="warning">
14067 ///
14068 /// **Experimental.** This API is part of an experimental wire-protocol surface
14069 /// and may change or be removed in future SDK or CLI releases. Pin both the
14070 /// SDK and CLI versions if your code depends on it.
14071 ///
14072 /// </div>
14073 pub async fn read_file(
14074 &self,
14075 params: WorkspacesReadFileRequest,
14076 ) -> Result<WorkspacesReadFileResult, Error> {
14077 let mut wire_params = serde_json::to_value(params)?;
14078 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
14079 let _value = self
14080 .session
14081 .client()
14082 .call(rpc_methods::SESSION_WORKSPACES_READFILE, Some(wire_params))
14083 .await?;
14084 Ok(serde_json::from_value(_value)?)
14085 }
14086
14087 /// Creates or overwrites a file in the session workspace files directory.
14088 ///
14089 /// Wire method: `session.workspaces.createFile`.
14090 ///
14091 /// # Parameters
14092 ///
14093 /// * `params` - Relative path and UTF-8 content for the workspace file to create or overwrite.
14094 ///
14095 /// <div class="warning">
14096 ///
14097 /// **Experimental.** This API is part of an experimental wire-protocol surface
14098 /// and may change or be removed in future SDK or CLI releases. Pin both the
14099 /// SDK and CLI versions if your code depends on it.
14100 ///
14101 /// </div>
14102 pub async fn create_file(&self, params: WorkspacesCreateFileRequest) -> Result<(), Error> {
14103 let mut wire_params = serde_json::to_value(params)?;
14104 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
14105 let _value = self
14106 .session
14107 .client()
14108 .call(
14109 rpc_methods::SESSION_WORKSPACES_CREATEFILE,
14110 Some(wire_params),
14111 )
14112 .await?;
14113 Ok(())
14114 }
14115
14116 /// Returns metadata for a file or directory in the session workspace files directory.
14117 ///
14118 /// Wire method: `session.workspaces.statFile`.
14119 ///
14120 /// # Parameters
14121 ///
14122 /// * `params` - Relative path of the workspace file or directory to inspect.
14123 ///
14124 /// # Returns
14125 ///
14126 /// Filesystem metadata for a path in the session workspace files directory.
14127 ///
14128 /// <div class="warning">
14129 ///
14130 /// **Experimental.** This API is part of an experimental wire-protocol surface
14131 /// and may change or be removed in future SDK or CLI releases. Pin both the
14132 /// SDK and CLI versions if your code depends on it.
14133 ///
14134 /// </div>
14135 pub async fn stat_file(
14136 &self,
14137 params: WorkspacesStatFileRequest,
14138 ) -> Result<WorkspacesStatFileResult, Error> {
14139 let mut wire_params = serde_json::to_value(params)?;
14140 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
14141 let _value = self
14142 .session
14143 .client()
14144 .call(rpc_methods::SESSION_WORKSPACES_STATFILE, Some(wire_params))
14145 .await?;
14146 Ok(serde_json::from_value(_value)?)
14147 }
14148
14149 /// Creates a directory in the session workspace files directory.
14150 ///
14151 /// Wire method: `session.workspaces.createDirectory`.
14152 ///
14153 /// # Parameters
14154 ///
14155 /// * `params` - Directory to create within the session workspace files directory.
14156 ///
14157 /// <div class="warning">
14158 ///
14159 /// **Experimental.** This API is part of an experimental wire-protocol surface
14160 /// and may change or be removed in future SDK or CLI releases. Pin both the
14161 /// SDK and CLI versions if your code depends on it.
14162 ///
14163 /// </div>
14164 pub async fn create_directory(
14165 &self,
14166 params: WorkspacesCreateDirectoryRequest,
14167 ) -> Result<(), Error> {
14168 let mut wire_params = serde_json::to_value(params)?;
14169 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
14170 let _value = self
14171 .session
14172 .client()
14173 .call(
14174 rpc_methods::SESSION_WORKSPACES_CREATEDIRECTORY,
14175 Some(wire_params),
14176 )
14177 .await?;
14178 Ok(())
14179 }
14180
14181 /// Removes a file or directory from the session workspace files directory.
14182 ///
14183 /// Wire method: `session.workspaces.removePath`.
14184 ///
14185 /// # Parameters
14186 ///
14187 /// * `params` - File or directory to remove from the session workspace files directory.
14188 ///
14189 /// <div class="warning">
14190 ///
14191 /// **Experimental.** This API is part of an experimental wire-protocol surface
14192 /// and may change or be removed in future SDK or CLI releases. Pin both the
14193 /// SDK and CLI versions if your code depends on it.
14194 ///
14195 /// </div>
14196 pub async fn remove_path(&self, params: WorkspacesRemovePathRequest) -> Result<(), Error> {
14197 let mut wire_params = serde_json::to_value(params)?;
14198 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
14199 let _value = self
14200 .session
14201 .client()
14202 .call(
14203 rpc_methods::SESSION_WORKSPACES_REMOVEPATH,
14204 Some(wire_params),
14205 )
14206 .await?;
14207 Ok(())
14208 }
14209
14210 /// Renames a file or directory within the session workspace files directory.
14211 ///
14212 /// Wire method: `session.workspaces.renamePath`.
14213 ///
14214 /// # Parameters
14215 ///
14216 /// * `params` - Source and destination paths for a rename within the session workspace files directory.
14217 ///
14218 /// <div class="warning">
14219 ///
14220 /// **Experimental.** This API is part of an experimental wire-protocol surface
14221 /// and may change or be removed in future SDK or CLI releases. Pin both the
14222 /// SDK and CLI versions if your code depends on it.
14223 ///
14224 /// </div>
14225 pub async fn rename_path(&self, params: WorkspacesRenamePathRequest) -> Result<(), Error> {
14226 let mut wire_params = serde_json::to_value(params)?;
14227 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
14228 let _value = self
14229 .session
14230 .client()
14231 .call(
14232 rpc_methods::SESSION_WORKSPACES_RENAMEPATH,
14233 Some(wire_params),
14234 )
14235 .await?;
14236 Ok(())
14237 }
14238
14239 /// Lists workspace checkpoints in chronological order.
14240 ///
14241 /// Wire method: `session.workspaces.listCheckpoints`.
14242 ///
14243 /// # Returns
14244 ///
14245 /// Workspace checkpoints in chronological order; empty when the workspace is not enabled.
14246 ///
14247 /// <div class="warning">
14248 ///
14249 /// **Experimental.** This API is part of an experimental wire-protocol surface
14250 /// and may change or be removed in future SDK or CLI releases. Pin both the
14251 /// SDK and CLI versions if your code depends on it.
14252 ///
14253 /// </div>
14254 pub async fn list_checkpoints(&self) -> Result<WorkspacesListCheckpointsResult, Error> {
14255 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
14256 let _value = self
14257 .session
14258 .client()
14259 .call(
14260 rpc_methods::SESSION_WORKSPACES_LISTCHECKPOINTS,
14261 Some(wire_params),
14262 )
14263 .await?;
14264 Ok(serde_json::from_value(_value)?)
14265 }
14266
14267 /// Reads the content of a workspace checkpoint by number.
14268 ///
14269 /// Wire method: `session.workspaces.readCheckpoint`.
14270 ///
14271 /// # Parameters
14272 ///
14273 /// * `params` - Checkpoint number to read.
14274 ///
14275 /// # Returns
14276 ///
14277 /// Checkpoint content as a UTF-8 string, or null when the checkpoint or workspace is missing.
14278 ///
14279 /// <div class="warning">
14280 ///
14281 /// **Experimental.** This API is part of an experimental wire-protocol surface
14282 /// and may change or be removed in future SDK or CLI releases. Pin both the
14283 /// SDK and CLI versions if your code depends on it.
14284 ///
14285 /// </div>
14286 pub async fn read_checkpoint(
14287 &self,
14288 params: WorkspacesReadCheckpointRequest,
14289 ) -> Result<WorkspacesReadCheckpointResult, Error> {
14290 let mut wire_params = serde_json::to_value(params)?;
14291 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
14292 let _value = self
14293 .session
14294 .client()
14295 .call(
14296 rpc_methods::SESSION_WORKSPACES_READCHECKPOINT,
14297 Some(wire_params),
14298 )
14299 .await?;
14300 Ok(serde_json::from_value(_value)?)
14301 }
14302
14303 /// Adds a compaction summary checkpoint to the local session workspace.
14304 ///
14305 /// Wire method: `session.workspaces.addSummary`.
14306 ///
14307 /// # Parameters
14308 ///
14309 /// * `params` - Compaction summary checkpoint to persist.
14310 ///
14311 /// # Returns
14312 ///
14313 /// Persisted summary metadata and refreshed workspace metadata.
14314 ///
14315 /// <div class="warning">
14316 ///
14317 /// **Experimental.** This API is part of an experimental wire-protocol surface
14318 /// and may change or be removed in future SDK or CLI releases. Pin both the
14319 /// SDK and CLI versions if your code depends on it.
14320 ///
14321 /// </div>
14322 pub async fn add_summary(
14323 &self,
14324 params: WorkspacesAddSummaryRequest,
14325 ) -> Result<WorkspacesAddSummaryResult, Error> {
14326 let mut wire_params = serde_json::to_value(params)?;
14327 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
14328 let _value = self
14329 .session
14330 .client()
14331 .call(
14332 rpc_methods::SESSION_WORKSPACES_ADDSUMMARY,
14333 Some(wire_params),
14334 )
14335 .await?;
14336 Ok(serde_json::from_value(_value)?)
14337 }
14338
14339 /// Truncates local workspace compaction summaries after a rollback.
14340 ///
14341 /// Wire method: `session.workspaces.truncateSummaries`.
14342 ///
14343 /// # Parameters
14344 ///
14345 /// * `params` - Rollback point for local workspace summaries.
14346 ///
14347 /// # Returns
14348 ///
14349 /// Current workspace metadata for the session, including its absolute filesystem path when available.
14350 ///
14351 /// <div class="warning">
14352 ///
14353 /// **Experimental.** This API is part of an experimental wire-protocol surface
14354 /// and may change or be removed in future SDK or CLI releases. Pin both the
14355 /// SDK and CLI versions if your code depends on it.
14356 ///
14357 /// </div>
14358 pub async fn truncate_summaries(
14359 &self,
14360 params: WorkspacesTruncateSummariesRequest,
14361 ) -> Result<WorkspacesGetWorkspaceResult, Error> {
14362 let mut wire_params = serde_json::to_value(params)?;
14363 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
14364 let _value = self
14365 .session
14366 .client()
14367 .call(
14368 rpc_methods::SESSION_WORKSPACES_TRUNCATESUMMARIES,
14369 Some(wire_params),
14370 )
14371 .await?;
14372 Ok(serde_json::from_value(_value)?)
14373 }
14374
14375 /// Reads the autopilot objective state file from the local session workspace.
14376 ///
14377 /// Wire method: `session.workspaces.readAutopilotObjective`.
14378 ///
14379 /// # Returns
14380 ///
14381 /// Autopilot objective file content, or null when missing.
14382 ///
14383 /// <div class="warning">
14384 ///
14385 /// **Experimental.** This API is part of an experimental wire-protocol surface
14386 /// and may change or be removed in future SDK or CLI releases. Pin both the
14387 /// SDK and CLI versions if your code depends on it.
14388 ///
14389 /// </div>
14390 pub async fn read_autopilot_objective(
14391 &self,
14392 ) -> Result<WorkspacesReadAutopilotObjectiveResult, Error> {
14393 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
14394 let _value = self
14395 .session
14396 .client()
14397 .call(
14398 rpc_methods::SESSION_WORKSPACES_READAUTOPILOTOBJECTIVE,
14399 Some(wire_params),
14400 )
14401 .await?;
14402 Ok(serde_json::from_value(_value)?)
14403 }
14404
14405 /// Writes the autopilot objective state file in the local session workspace.
14406 ///
14407 /// Wire method: `session.workspaces.writeAutopilotObjective`.
14408 ///
14409 /// # Parameters
14410 ///
14411 /// * `params` - Autopilot objective file content to persist.
14412 ///
14413 /// # Returns
14414 ///
14415 /// Result of writing the autopilot objective file.
14416 ///
14417 /// <div class="warning">
14418 ///
14419 /// **Experimental.** This API is part of an experimental wire-protocol surface
14420 /// and may change or be removed in future SDK or CLI releases. Pin both the
14421 /// SDK and CLI versions if your code depends on it.
14422 ///
14423 /// </div>
14424 pub async fn write_autopilot_objective(
14425 &self,
14426 params: WorkspacesWriteAutopilotObjectiveRequest,
14427 ) -> Result<WorkspacesWriteAutopilotObjectiveResult, Error> {
14428 let mut wire_params = serde_json::to_value(params)?;
14429 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
14430 let _value = self
14431 .session
14432 .client()
14433 .call(
14434 rpc_methods::SESSION_WORKSPACES_WRITEAUTOPILOTOBJECTIVE,
14435 Some(wire_params),
14436 )
14437 .await?;
14438 Ok(serde_json::from_value(_value)?)
14439 }
14440
14441 /// Deletes the autopilot objective state file from the local session workspace.
14442 ///
14443 /// Wire method: `session.workspaces.deleteAutopilotObjective`.
14444 ///
14445 /// # Returns
14446 ///
14447 /// Result of deleting the autopilot objective file.
14448 ///
14449 /// <div class="warning">
14450 ///
14451 /// **Experimental.** This API is part of an experimental wire-protocol surface
14452 /// and may change or be removed in future SDK or CLI releases. Pin both the
14453 /// SDK and CLI versions if your code depends on it.
14454 ///
14455 /// </div>
14456 pub async fn delete_autopilot_objective(
14457 &self,
14458 ) -> Result<WorkspacesDeleteAutopilotObjectiveResult, Error> {
14459 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
14460 let _value = self
14461 .session
14462 .client()
14463 .call(
14464 rpc_methods::SESSION_WORKSPACES_DELETEAUTOPILOTOBJECTIVE,
14465 Some(wire_params),
14466 )
14467 .await?;
14468 Ok(serde_json::from_value(_value)?)
14469 }
14470
14471 /// Checks whether the local session workspace has an autopilot objective state file.
14472 ///
14473 /// Wire method: `session.workspaces.autopilotObjectiveExists`.
14474 ///
14475 /// # Returns
14476 ///
14477 /// Whether the autopilot objective file exists.
14478 ///
14479 /// <div class="warning">
14480 ///
14481 /// **Experimental.** This API is part of an experimental wire-protocol surface
14482 /// and may change or be removed in future SDK or CLI releases. Pin both the
14483 /// SDK and CLI versions if your code depends on it.
14484 ///
14485 /// </div>
14486 pub async fn autopilot_objective_exists(
14487 &self,
14488 ) -> Result<WorkspacesAutopilotObjectiveExistsResult, Error> {
14489 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
14490 let _value = self
14491 .session
14492 .client()
14493 .call(
14494 rpc_methods::SESSION_WORKSPACES_AUTOPILOTOBJECTIVEEXISTS,
14495 Some(wire_params),
14496 )
14497 .await?;
14498 Ok(serde_json::from_value(_value)?)
14499 }
14500
14501 /// Saves pasted content as a UTF-8 file in the session workspace.
14502 ///
14503 /// Wire method: `session.workspaces.saveLargePaste`.
14504 ///
14505 /// # Parameters
14506 ///
14507 /// * `params` - Pasted content to save as a UTF-8 file in the session workspace.
14508 ///
14509 /// # Returns
14510 ///
14511 /// Descriptor for the saved paste file, or null when the workspace is unavailable.
14512 ///
14513 /// <div class="warning">
14514 ///
14515 /// **Experimental.** This API is part of an experimental wire-protocol surface
14516 /// and may change or be removed in future SDK or CLI releases. Pin both the
14517 /// SDK and CLI versions if your code depends on it.
14518 ///
14519 /// </div>
14520 pub async fn save_large_paste(
14521 &self,
14522 params: WorkspacesSaveLargePasteRequest,
14523 ) -> Result<WorkspacesSaveLargePasteResult, Error> {
14524 let mut wire_params = serde_json::to_value(params)?;
14525 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
14526 let _value = self
14527 .session
14528 .client()
14529 .call(
14530 rpc_methods::SESSION_WORKSPACES_SAVELARGEPASTE,
14531 Some(wire_params),
14532 )
14533 .await?;
14534 Ok(serde_json::from_value(_value)?)
14535 }
14536
14537 /// 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`.
14538 ///
14539 /// Wire method: `session.workspaces.diff`.
14540 ///
14541 /// # Parameters
14542 ///
14543 /// * `params` - Parameters for computing a workspace diff.
14544 ///
14545 /// # Returns
14546 ///
14547 /// Workspace diff result for the requested mode.
14548 ///
14549 /// <div class="warning">
14550 ///
14551 /// **Experimental.** This API is part of an experimental wire-protocol surface
14552 /// and may change or be removed in future SDK or CLI releases. Pin both the
14553 /// SDK and CLI versions if your code depends on it.
14554 ///
14555 /// </div>
14556 pub async fn diff(&self, params: WorkspacesDiffRequest) -> Result<WorkspaceDiffResult, Error> {
14557 let mut wire_params = serde_json::to_value(params)?;
14558 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
14559 let _value = self
14560 .session
14561 .client()
14562 .call(rpc_methods::SESSION_WORKSPACES_DIFF, Some(wire_params))
14563 .await?;
14564 Ok(serde_json::from_value(_value)?)
14565 }
14566}