github_copilot_sdk/generated/rpc.rs
1//! Auto-generated typed JSON-RPC namespace — do not edit manually.
2//!
3//! Generated from `api.schema.json` by `scripts/codegen/rust.ts`. The
4//! [`ClientRpc`] and [`SessionRpc`] view structs let callers reach every
5//! protocol method through a typed namespace tree, so wire method names
6//! and request/response shapes live in exactly one place — this file.
7
8#![allow(missing_docs)]
9#![allow(clippy::too_many_arguments)]
10#![allow(deprecated)]
11#![allow(dead_code)]
12
13use super::api_types::{rpc_methods, *};
14use super::session_events::SessionMode;
15use crate::session::Session;
16use crate::{Client, Error};
17
18/// Typed view over the [`Client`]'s server-level RPC namespace.
19#[derive(Clone, Copy)]
20pub struct ClientRpc<'a> {
21 pub(crate) client: &'a Client,
22}
23
24impl<'a> ClientRpc<'a> {
25 /// `account.*` sub-namespace.
26 pub fn account(&self) -> ClientRpcAccount<'a> {
27 ClientRpcAccount {
28 client: self.client,
29 }
30 }
31
32 /// `agentRegistry.*` sub-namespace.
33 pub fn agent_registry(&self) -> ClientRpcAgentRegistry<'a> {
34 ClientRpcAgentRegistry {
35 client: self.client,
36 }
37 }
38
39 /// `agents.*` sub-namespace.
40 pub fn agents(&self) -> ClientRpcAgents<'a> {
41 ClientRpcAgents {
42 client: self.client,
43 }
44 }
45
46 /// `catalog.*` sub-namespace.
47 pub fn catalog(&self) -> ClientRpcCatalog<'a> {
48 ClientRpcCatalog {
49 client: self.client,
50 }
51 }
52
53 /// `commands.*` sub-namespace.
54 pub fn commands(&self) -> ClientRpcCommands<'a> {
55 ClientRpcCommands {
56 client: self.client,
57 }
58 }
59
60 /// `extensions.*` sub-namespace.
61 pub fn extensions(&self) -> ClientRpcExtensions<'a> {
62 ClientRpcExtensions {
63 client: self.client,
64 }
65 }
66
67 /// `instructions.*` sub-namespace.
68 pub fn instructions(&self) -> ClientRpcInstructions<'a> {
69 ClientRpcInstructions {
70 client: self.client,
71 }
72 }
73
74 /// `llmInference.*` sub-namespace.
75 pub fn llm_inference(&self) -> ClientRpcLlmInference<'a> {
76 ClientRpcLlmInference {
77 client: self.client,
78 }
79 }
80
81 /// `managedSettings.*` sub-namespace.
82 pub fn managed_settings(&self) -> ClientRpcManagedSettings<'a> {
83 ClientRpcManagedSettings {
84 client: self.client,
85 }
86 }
87
88 /// `mcp.*` sub-namespace.
89 pub fn mcp(&self) -> ClientRpcMcp<'a> {
90 ClientRpcMcp {
91 client: self.client,
92 }
93 }
94
95 /// `models.*` sub-namespace.
96 pub fn models(&self) -> ClientRpcModels<'a> {
97 ClientRpcModels {
98 client: self.client,
99 }
100 }
101
102 /// `plugins.*` sub-namespace.
103 pub fn plugins(&self) -> ClientRpcPlugins<'a> {
104 ClientRpcPlugins {
105 client: self.client,
106 }
107 }
108
109 /// `runtime.*` sub-namespace.
110 pub fn runtime(&self) -> ClientRpcRuntime<'a> {
111 ClientRpcRuntime {
112 client: self.client,
113 }
114 }
115
116 /// `secrets.*` sub-namespace.
117 pub fn secrets(&self) -> ClientRpcSecrets<'a> {
118 ClientRpcSecrets {
119 client: self.client,
120 }
121 }
122
123 /// `sessionFs.*` sub-namespace.
124 pub fn session_fs(&self) -> ClientRpcSessionFs<'a> {
125 ClientRpcSessionFs {
126 client: self.client,
127 }
128 }
129
130 /// `sessions.*` sub-namespace.
131 pub fn sessions(&self) -> ClientRpcSessions<'a> {
132 ClientRpcSessions {
133 client: self.client,
134 }
135 }
136
137 /// `skills.*` sub-namespace.
138 pub fn skills(&self) -> ClientRpcSkills<'a> {
139 ClientRpcSkills {
140 client: self.client,
141 }
142 }
143
144 /// `tools.*` sub-namespace.
145 pub fn tools(&self) -> ClientRpcTools<'a> {
146 ClientRpcTools {
147 client: self.client,
148 }
149 }
150
151 /// `user.*` sub-namespace.
152 pub fn user(&self) -> ClientRpcUser<'a> {
153 ClientRpcUser {
154 client: self.client,
155 }
156 }
157
158 /// Checks server responsiveness and returns protocol information.
159 ///
160 /// Wire method: `ping`.
161 ///
162 /// # Parameters
163 ///
164 /// * `params` - Optional message to echo back to the caller.
165 ///
166 /// # Returns
167 ///
168 /// Server liveness response, including the echoed message, current server timestamp, and protocol version.
169 ///
170 /// <div class="warning">
171 ///
172 /// **Experimental.** This API is part of an experimental wire-protocol surface
173 /// and may change or be removed in future SDK or CLI releases. Pin both the
174 /// SDK and CLI versions if your code depends on it.
175 ///
176 /// </div>
177 pub async fn ping(&self, params: PingRequest) -> Result<PingResult, Error> {
178 let wire_params = serde_json::to_value(params)?;
179 let _value = self
180 .client
181 .call(rpc_methods::PING, Some(wire_params))
182 .await?;
183 Ok(serde_json::from_value(_value)?)
184 }
185
186 /// 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.
187 ///
188 /// Wire method: `connect`.
189 ///
190 /// # Parameters
191 ///
192 /// * `params` - Connection-level opt-ins for the `server.connect` handshake. Transport authentication is consumed by the native protocol boundary before dispatch.
193 ///
194 /// # Returns
195 ///
196 /// Handshake result reporting the server's protocol version and package version on success.
197 ///
198 /// <div class="warning">
199 ///
200 /// **Experimental.** This API is part of an experimental wire-protocol surface
201 /// and may change or be removed in future SDK or CLI releases. Pin both the
202 /// SDK and CLI versions if your code depends on it.
203 ///
204 /// </div>
205 pub(crate) async fn connect(&self, params: ConnectRequest) -> Result<ConnectResult, Error> {
206 let wire_params = serde_json::to_value(params)?;
207 let _value = self
208 .client
209 .call(rpc_methods::CONNECT, Some(wire_params))
210 .await?;
211 Ok(serde_json::from_value(_value)?)
212 }
213
214 /// 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.
215 ///
216 /// Wire method: `registerExtensionLaunchProvider`.
217 ///
218 /// <div class="warning">
219 ///
220 /// **Experimental.** This API is part of an experimental wire-protocol surface
221 /// and may change or be removed in future SDK or CLI releases. Pin both the
222 /// SDK and CLI versions if your code depends on it.
223 ///
224 /// </div>
225 pub async fn register_extension_launch_provider(&self) -> Result<(), Error> {
226 let wire_params = serde_json::json!({});
227 let _value = self
228 .client
229 .call(
230 rpc_methods::REGISTEREXTENSIONLAUNCHPROVIDER,
231 Some(wire_params),
232 )
233 .await?;
234 Ok(())
235 }
236}
237
238/// `account.*` RPCs.
239#[derive(Clone, Copy)]
240pub struct ClientRpcAccount<'a> {
241 pub(crate) client: &'a Client,
242}
243
244impl<'a> ClientRpcAccount<'a> {
245 /// Gets Copilot quota usage for the current or opaquely selected authenticated user.
246 ///
247 /// Wire method: `account.getQuota`.
248 ///
249 /// # Returns
250 ///
251 /// Quota usage snapshots for the resolved user, keyed by quota type.
252 ///
253 /// <div class="warning">
254 ///
255 /// **Experimental.** This API is part of an experimental wire-protocol surface
256 /// and may change or be removed in future SDK or CLI releases. Pin both the
257 /// SDK and CLI versions if your code depends on it.
258 ///
259 /// </div>
260 pub async fn get_quota(&self) -> Result<AccountGetQuotaResult, Error> {
261 let wire_params = serde_json::json!({});
262 let _value = self
263 .client
264 .call(rpc_methods::ACCOUNT_GETQUOTA, Some(wire_params))
265 .await?;
266 Ok(serde_json::from_value(_value)?)
267 }
268
269 /// Gets Copilot quota usage for the current or opaquely selected authenticated user.
270 ///
271 /// Wire method: `account.getQuota`.
272 ///
273 /// # Parameters
274 ///
275 /// * `params` - Optional opaque account selection or compatibility GitHub token used to look up quota.
276 ///
277 /// # Returns
278 ///
279 /// Quota usage snapshots for the resolved user, keyed by quota type.
280 ///
281 /// <div class="warning">
282 ///
283 /// **Experimental.** This API is part of an experimental wire-protocol surface
284 /// and may change or be removed in future SDK or CLI releases. Pin both the
285 /// SDK and CLI versions if your code depends on it.
286 ///
287 /// </div>
288 pub async fn get_quota_with_params(
289 &self,
290 params: AccountGetQuotaRequest,
291 ) -> Result<AccountGetQuotaResult, Error> {
292 let wire_params = serde_json::to_value(params)?;
293 let _value = self
294 .client
295 .call(rpc_methods::ACCOUNT_GETQUOTA, Some(wire_params))
296 .await?;
297 Ok(serde_json::from_value(_value)?)
298 }
299
300 /// Gets the currently active authentication credentials from the global auth manager.
301 ///
302 /// Wire method: `account.getCurrentAuth`.
303 ///
304 /// # Returns
305 ///
306 /// Current authentication state
307 ///
308 /// <div class="warning">
309 ///
310 /// **Experimental.** This API is part of an experimental wire-protocol surface
311 /// and may change or be removed in future SDK or CLI releases. Pin both the
312 /// SDK and CLI versions if your code depends on it.
313 ///
314 /// </div>
315 pub async fn get_current_auth(&self) -> Result<AccountGetCurrentAuthResult, Error> {
316 let wire_params = serde_json::json!({});
317 let _value = self
318 .client
319 .call(rpc_methods::ACCOUNT_GETCURRENTAUTH, Some(wire_params))
320 .await?;
321 Ok(serde_json::from_value(_value)?)
322 }
323
324 /// Gets all authenticated users available for account switching.
325 ///
326 /// Wire method: `account.getAllUsers`.
327 ///
328 /// # Returns
329 ///
330 /// List of all authenticated users
331 ///
332 /// <div class="warning">
333 ///
334 /// **Experimental.** This API is part of an experimental wire-protocol surface
335 /// and may change or be removed in future SDK or CLI releases. Pin both the
336 /// SDK and CLI versions if your code depends on it.
337 ///
338 /// </div>
339 pub async fn get_all_users(&self) -> Result<AccountGetAllUsersResult, Error> {
340 let wire_params = serde_json::json!({});
341 let _value = self
342 .client
343 .call(rpc_methods::ACCOUNT_GETALLUSERS, Some(wire_params))
344 .await?;
345 Ok(serde_json::from_value(_value)?)
346 }
347
348 /// Validates and stores authentication credentials. When login is omitted, resolves the authenticated user from the token before persistence.
349 ///
350 /// Wire method: `account.login`.
351 ///
352 /// # Parameters
353 ///
354 /// * `params` - Credentials to validate and store. Omit login to resolve the authenticated user from the token.
355 ///
356 /// # Returns
357 ///
358 /// Result of a successful login; throws on failure
359 ///
360 /// <div class="warning">
361 ///
362 /// **Experimental.** This API is part of an experimental wire-protocol surface
363 /// and may change or be removed in future SDK or CLI releases. Pin both the
364 /// SDK and CLI versions if your code depends on it.
365 ///
366 /// </div>
367 pub async fn login(&self, params: AccountLoginRequest) -> Result<AccountLoginResult, Error> {
368 let wire_params = serde_json::to_value(params)?;
369 let _value = self
370 .client
371 .call(rpc_methods::ACCOUNT_LOGIN, Some(wire_params))
372 .await?;
373 Ok(serde_json::from_value(_value)?)
374 }
375
376 /// Removes user authentication from keychain and persisted state.
377 ///
378 /// Wire method: `account.logout`.
379 ///
380 /// # Parameters
381 ///
382 /// * `params` - User to log out
383 ///
384 /// # Returns
385 ///
386 /// Logout result indicating if more users remain
387 ///
388 /// <div class="warning">
389 ///
390 /// **Experimental.** This API is part of an experimental wire-protocol surface
391 /// and may change or be removed in future SDK or CLI releases. Pin both the
392 /// SDK and CLI versions if your code depends on it.
393 ///
394 /// </div>
395 pub async fn logout(&self, params: AccountLogoutRequest) -> Result<AccountLogoutResult, Error> {
396 let wire_params = serde_json::to_value(params)?;
397 let _value = self
398 .client
399 .call(rpc_methods::ACCOUNT_LOGOUT, Some(wire_params))
400 .await?;
401 Ok(serde_json::from_value(_value)?)
402 }
403}
404
405/// `agentRegistry.*` RPCs.
406#[derive(Clone, Copy)]
407pub struct ClientRpcAgentRegistry<'a> {
408 pub(crate) client: &'a Client,
409}
410
411impl<'a> ClientRpcAgentRegistry<'a> {
412 /// 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.
413 ///
414 /// Wire method: `agentRegistry.spawn`.
415 ///
416 /// # Parameters
417 ///
418 /// * `params` - Inputs to spawn a managed-server child via the controller's spawn delegate.
419 ///
420 /// # Returns
421 ///
422 /// Outcome of an agentRegistry.spawn call.
423 ///
424 /// <div class="warning">
425 ///
426 /// **Experimental.** This API is part of an experimental wire-protocol surface
427 /// and may change or be removed in future SDK or CLI releases. Pin both the
428 /// SDK and CLI versions if your code depends on it.
429 ///
430 /// </div>
431 pub async fn spawn(
432 &self,
433 params: AgentRegistrySpawnRequest,
434 ) -> Result<AgentRegistrySpawnResult, Error> {
435 let wire_params = serde_json::to_value(params)?;
436 let _value = self
437 .client
438 .call(rpc_methods::AGENTREGISTRY_SPAWN, Some(wire_params))
439 .await?;
440 Ok(serde_json::from_value(_value)?)
441 }
442}
443
444/// `agents.*` RPCs.
445#[derive(Clone, Copy)]
446pub struct ClientRpcAgents<'a> {
447 pub(crate) client: &'a Client,
448}
449
450impl<'a> ClientRpcAgents<'a> {
451 /// Discovers custom agents across user, project, plugin, and remote sources.
452 ///
453 /// Wire method: `agents.discover`.
454 ///
455 /// # Parameters
456 ///
457 /// * `params` - Optional project paths to include in agent discovery.
458 ///
459 /// # Returns
460 ///
461 /// Agents discovered across user, project, plugin, and remote sources.
462 ///
463 /// <div class="warning">
464 ///
465 /// **Experimental.** This API is part of an experimental wire-protocol surface
466 /// and may change or be removed in future SDK or CLI releases. Pin both the
467 /// SDK and CLI versions if your code depends on it.
468 ///
469 /// </div>
470 pub async fn discover(&self, params: AgentsDiscoverRequest) -> Result<ServerAgentList, Error> {
471 let wire_params = serde_json::to_value(params)?;
472 let _value = self
473 .client
474 .call(rpc_methods::AGENTS_DISCOVER, Some(wire_params))
475 .await?;
476 Ok(serde_json::from_value(_value)?)
477 }
478
479 /// 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.
480 ///
481 /// Wire method: `agents.getDiscoveryPaths`.
482 ///
483 /// # Parameters
484 ///
485 /// * `params` - Optional project paths to include when enumerating agent discovery directories.
486 ///
487 /// # Returns
488 ///
489 /// Canonical locations where custom agents can be created so the runtime will recognize them.
490 ///
491 /// <div class="warning">
492 ///
493 /// **Experimental.** This API is part of an experimental wire-protocol surface
494 /// and may change or be removed in future SDK or CLI releases. Pin both the
495 /// SDK and CLI versions if your code depends on it.
496 ///
497 /// </div>
498 pub async fn get_discovery_paths(
499 &self,
500 params: AgentsGetDiscoveryPathsRequest,
501 ) -> Result<AgentDiscoveryPathList, Error> {
502 let wire_params = serde_json::to_value(params)?;
503 let _value = self
504 .client
505 .call(rpc_methods::AGENTS_GETDISCOVERYPATHS, Some(wire_params))
506 .await?;
507 Ok(serde_json::from_value(_value)?)
508 }
509}
510
511/// `catalog.*` RPCs.
512#[derive(Clone, Copy)]
513pub struct ClientRpcCatalog<'a> {
514 pub(crate) client: &'a Client,
515}
516
517impl<'a> ClientRpcCatalog<'a> {
518 /// 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.
519 ///
520 /// Wire method: `catalog.search`.
521 ///
522 /// # Parameters
523 ///
524 /// * `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.
525 ///
526 /// # Returns
527 ///
528 /// Outcome of a catalog.search call: either bounded inert candidates, or one typed refusal. Never a partial success.
529 ///
530 /// <div class="warning">
531 ///
532 /// **Experimental.** This API is part of an experimental wire-protocol surface
533 /// and may change or be removed in future SDK or CLI releases. Pin both the
534 /// SDK and CLI versions if your code depends on it.
535 ///
536 /// </div>
537 pub async fn search(&self, params: CatalogSearchRequest) -> Result<CatalogSearchResult, Error> {
538 let wire_params = serde_json::to_value(params)?;
539 let _value = self
540 .client
541 .call(rpc_methods::CATALOG_SEARCH, Some(wire_params))
542 .await?;
543 Ok(serde_json::from_value(_value)?)
544 }
545}
546
547/// `commands.*` RPCs.
548#[derive(Clone, Copy)]
549pub struct ClientRpcCommands<'a> {
550 pub(crate) client: &'a Client,
551}
552
553impl<'a> ClientRpcCommands<'a> {
554 /// 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.
555 ///
556 /// Wire method: `commands.list`.
557 ///
558 /// # Returns
559 ///
560 /// Slash commands available in the session, after applying any include/exclude filters.
561 ///
562 /// <div class="warning">
563 ///
564 /// **Experimental.** This API is part of an experimental wire-protocol surface
565 /// and may change or be removed in future SDK or CLI releases. Pin both the
566 /// SDK and CLI versions if your code depends on it.
567 ///
568 /// </div>
569 pub async fn list(&self) -> Result<CommandList, Error> {
570 let wire_params = serde_json::json!({});
571 let _value = self
572 .client
573 .call(rpc_methods::COMMANDS_LIST, Some(wire_params))
574 .await?;
575 Ok(serde_json::from_value(_value)?)
576 }
577}
578
579/// `extensions.*` RPCs.
580#[derive(Clone, Copy)]
581pub struct ClientRpcExtensions<'a> {
582 pub(crate) client: &'a Client,
583}
584
585impl<'a> ClientRpcExtensions<'a> {
586 /// Discovers user and enabled installed-plugin extensions from persisted Copilot home state, including enablement preferences. Launch-scoped additional plugins are not included.
587 ///
588 /// Wire method: `extensions.discover`.
589 ///
590 /// # Returns
591 ///
592 /// Extensions discovered from persisted Copilot home state and their effective loading mode. Launch-scoped additional plugins are not included.
593 ///
594 /// <div class="warning">
595 ///
596 /// **Experimental.** This API is part of an experimental wire-protocol surface
597 /// and may change or be removed in future SDK or CLI releases. Pin both the
598 /// SDK and CLI versions if your code depends on it.
599 ///
600 /// </div>
601 pub async fn discover(&self) -> Result<DiscoveredExtensions, Error> {
602 let wire_params = serde_json::json!({});
603 let _value = self
604 .client
605 .call(rpc_methods::EXTENSIONS_DISCOVER, Some(wire_params))
606 .await?;
607 Ok(serde_json::from_value(_value)?)
608 }
609
610 /// Persistently enables extension IDs for future sessions. Active sessions are unchanged; use session.extensions.enable to update them.
611 ///
612 /// Wire method: `extensions.enable`.
613 ///
614 /// # Parameters
615 ///
616 /// * `params` - Source-qualified extension identifiers to persistently enable for future sessions.
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 pub async fn enable(&self, params: DiscoveredExtensionsEnableRequest) -> Result<(), Error> {
626 let wire_params = serde_json::to_value(params)?;
627 let _value = self
628 .client
629 .call(rpc_methods::EXTENSIONS_ENABLE, Some(wire_params))
630 .await?;
631 Ok(())
632 }
633
634 /// Persistently disables extension IDs for future sessions. Active sessions are unchanged; use session.extensions.disable to update them.
635 ///
636 /// Wire method: `extensions.disable`.
637 ///
638 /// # Parameters
639 ///
640 /// * `params` - Source-qualified extension identifiers to persistently disable for future sessions.
641 ///
642 /// <div class="warning">
643 ///
644 /// **Experimental.** This API is part of an experimental wire-protocol surface
645 /// and may change or be removed in future SDK or CLI releases. Pin both the
646 /// SDK and CLI versions if your code depends on it.
647 ///
648 /// </div>
649 pub async fn disable(&self, params: DiscoveredExtensionsDisableRequest) -> Result<(), Error> {
650 let wire_params = serde_json::to_value(params)?;
651 let _value = self
652 .client
653 .call(rpc_methods::EXTENSIONS_DISABLE, Some(wire_params))
654 .await?;
655 Ok(())
656 }
657}
658
659/// `instructions.*` RPCs.
660#[derive(Clone, Copy)]
661pub struct ClientRpcInstructions<'a> {
662 pub(crate) client: &'a Client,
663}
664
665impl<'a> ClientRpcInstructions<'a> {
666 /// Discovers instruction sources across user, repository, and plugin sources.
667 ///
668 /// Wire method: `instructions.discover`.
669 ///
670 /// # Parameters
671 ///
672 /// * `params` - Optional project paths to include in instruction discovery.
673 ///
674 /// # Returns
675 ///
676 /// Instruction sources discovered across user, repository, and plugin sources.
677 ///
678 /// <div class="warning">
679 ///
680 /// **Experimental.** This API is part of an experimental wire-protocol surface
681 /// and may change or be removed in future SDK or CLI releases. Pin both the
682 /// SDK and CLI versions if your code depends on it.
683 ///
684 /// </div>
685 pub async fn discover(
686 &self,
687 params: InstructionsDiscoverRequest,
688 ) -> Result<ServerInstructionSourceList, Error> {
689 let wire_params = serde_json::to_value(params)?;
690 let _value = self
691 .client
692 .call(rpc_methods::INSTRUCTIONS_DISCOVER, Some(wire_params))
693 .await?;
694 Ok(serde_json::from_value(_value)?)
695 }
696
697 /// 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.
698 ///
699 /// Wire method: `instructions.getDiscoveryPaths`.
700 ///
701 /// # Parameters
702 ///
703 /// * `params` - Optional project paths to include when enumerating instruction discovery targets.
704 ///
705 /// # Returns
706 ///
707 /// Canonical files and directories where custom instructions can be created so the runtime will recognize them.
708 ///
709 /// <div class="warning">
710 ///
711 /// **Experimental.** This API is part of an experimental wire-protocol surface
712 /// and may change or be removed in future SDK or CLI releases. Pin both the
713 /// SDK and CLI versions if your code depends on it.
714 ///
715 /// </div>
716 pub async fn get_discovery_paths(
717 &self,
718 params: InstructionsGetDiscoveryPathsRequest,
719 ) -> Result<InstructionDiscoveryPathList, Error> {
720 let wire_params = serde_json::to_value(params)?;
721 let _value = self
722 .client
723 .call(
724 rpc_methods::INSTRUCTIONS_GETDISCOVERYPATHS,
725 Some(wire_params),
726 )
727 .await?;
728 Ok(serde_json::from_value(_value)?)
729 }
730}
731
732/// `llmInference.*` RPCs.
733#[derive(Clone, Copy)]
734pub struct ClientRpcLlmInference<'a> {
735 pub(crate) client: &'a Client,
736}
737
738impl<'a> ClientRpcLlmInference<'a> {
739 /// Registers an SDK client as the LLM inference callback provider.
740 ///
741 /// Wire method: `llmInference.setProvider`.
742 ///
743 /// # Returns
744 ///
745 /// Indicates whether the calling client was registered as the LLM inference provider.
746 ///
747 /// <div class="warning">
748 ///
749 /// **Experimental.** This API is part of an experimental wire-protocol surface
750 /// and may change or be removed in future SDK or CLI releases. Pin both the
751 /// SDK and CLI versions if your code depends on it.
752 ///
753 /// </div>
754 pub async fn set_provider(&self) -> Result<LlmInferenceSetProviderResult, Error> {
755 let wire_params = serde_json::json!({});
756 let _value = self
757 .client
758 .call(rpc_methods::LLMINFERENCE_SETPROVIDER, Some(wire_params))
759 .await?;
760 Ok(serde_json::from_value(_value)?)
761 }
762
763 /// 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.
764 ///
765 /// Wire method: `llmInference.httpResponseStart`.
766 ///
767 /// # Parameters
768 ///
769 /// * `params` - Response head.
770 ///
771 /// # Returns
772 ///
773 /// Whether the start frame was accepted.
774 ///
775 /// <div class="warning">
776 ///
777 /// **Experimental.** This API is part of an experimental wire-protocol surface
778 /// and may change or be removed in future SDK or CLI releases. Pin both the
779 /// SDK and CLI versions if your code depends on it.
780 ///
781 /// </div>
782 pub async fn http_response_start(
783 &self,
784 params: LlmInferenceHttpResponseStartRequest,
785 ) -> Result<LlmInferenceHttpResponseStartResult, Error> {
786 let wire_params = serde_json::to_value(params)?;
787 let _value = self
788 .client
789 .call(
790 rpc_methods::LLMINFERENCE_HTTPRESPONSESTART,
791 Some(wire_params),
792 )
793 .await?;
794 Ok(serde_json::from_value(_value)?)
795 }
796
797 /// 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.
798 ///
799 /// Wire method: `llmInference.httpResponseChunk`.
800 ///
801 /// # Parameters
802 ///
803 /// * `params` - A response body chunk or terminal error.
804 ///
805 /// # Returns
806 ///
807 /// Whether the chunk was accepted.
808 ///
809 /// <div class="warning">
810 ///
811 /// **Experimental.** This API is part of an experimental wire-protocol surface
812 /// and may change or be removed in future SDK or CLI releases. Pin both the
813 /// SDK and CLI versions if your code depends on it.
814 ///
815 /// </div>
816 pub async fn http_response_chunk(
817 &self,
818 params: LlmInferenceHttpResponseChunkRequest,
819 ) -> Result<LlmInferenceHttpResponseChunkResult, Error> {
820 let wire_params = serde_json::to_value(params)?;
821 let _value = self
822 .client
823 .call(
824 rpc_methods::LLMINFERENCE_HTTPRESPONSECHUNK,
825 Some(wire_params),
826 )
827 .await?;
828 Ok(serde_json::from_value(_value)?)
829 }
830}
831
832/// `managedSettings.*` RPCs.
833#[derive(Clone, Copy)]
834pub struct ClientRpcManagedSettings<'a> {
835 pub(crate) client: &'a Client,
836}
837
838impl<'a> ClientRpcManagedSettings<'a> {
839 /// 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.
840 ///
841 /// Wire method: `managedSettings.read`.
842 ///
843 /// # Returns
844 ///
845 /// Validated device-managed settings discovered before a session exists.
846 ///
847 /// <div class="warning">
848 ///
849 /// **Experimental.** This API is part of an experimental wire-protocol surface
850 /// and may change or be removed in future SDK or CLI releases. Pin both the
851 /// SDK and CLI versions if your code depends on it.
852 ///
853 /// </div>
854 pub async fn read(&self) -> Result<ManagedSettingsReadResult, Error> {
855 let wire_params = serde_json::json!({});
856 let _value = self
857 .client
858 .call(rpc_methods::MANAGEDSETTINGS_READ, Some(wire_params))
859 .await?;
860 Ok(serde_json::from_value(_value)?)
861 }
862}
863
864/// `mcp.*` RPCs.
865#[derive(Clone, Copy)]
866pub struct ClientRpcMcp<'a> {
867 pub(crate) client: &'a Client,
868}
869
870impl<'a> ClientRpcMcp<'a> {
871 /// `mcp.config.*` sub-namespace.
872 pub fn config(&self) -> ClientRpcMcpConfig<'a> {
873 ClientRpcMcpConfig {
874 client: self.client,
875 }
876 }
877
878 /// Discovers MCP servers from user, workspace, plugin, and builtin sources.
879 ///
880 /// Wire method: `mcp.discover`.
881 ///
882 /// # Parameters
883 ///
884 /// * `params` - Optional working directory used as context for MCP server discovery.
885 ///
886 /// # Returns
887 ///
888 /// MCP servers discovered from user, workspace, plugin, and built-in sources.
889 ///
890 /// <div class="warning">
891 ///
892 /// **Experimental.** This API is part of an experimental wire-protocol surface
893 /// and may change or be removed in future SDK or CLI releases. Pin both the
894 /// SDK and CLI versions if your code depends on it.
895 ///
896 /// </div>
897 pub async fn discover(&self, params: McpDiscoverRequest) -> Result<McpDiscoverResult, Error> {
898 let wire_params = serde_json::to_value(params)?;
899 let _value = self
900 .client
901 .call(rpc_methods::MCP_DISCOVER, Some(wire_params))
902 .await?;
903 Ok(serde_json::from_value(_value)?)
904 }
905
906 /// 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.
907 ///
908 /// Wire method: `mcp.planInstall`.
909 ///
910 /// # Parameters
911 ///
912 /// * `params` - A side-effect-free request for an MCP install plan. Computing a plan never writes configuration, stores a secret, or reloads MCP servers.
913 ///
914 /// # Returns
915 ///
916 /// Outcome of an mcp.planInstall call: either a normalised plan, or one typed refusal. Nothing is written in either case.
917 ///
918 /// <div class="warning">
919 ///
920 /// **Experimental.** This API is part of an experimental wire-protocol surface
921 /// and may change or be removed in future SDK or CLI releases. Pin both the
922 /// SDK and CLI versions if your code depends on it.
923 ///
924 /// </div>
925 pub async fn plan_install(
926 &self,
927 params: McpPlanInstallRequest,
928 ) -> Result<McpPlanInstallResult, Error> {
929 let wire_params = serde_json::to_value(params)?;
930 let _value = self
931 .client
932 .call(rpc_methods::MCP_PLANINSTALL, Some(wire_params))
933 .await?;
934 Ok(serde_json::from_value(_value)?)
935 }
936}
937
938/// `mcp.config.*` RPCs.
939#[derive(Clone, Copy)]
940pub struct ClientRpcMcpConfig<'a> {
941 pub(crate) client: &'a Client,
942}
943
944impl<'a> ClientRpcMcpConfig<'a> {
945 /// Lists MCP servers from user configuration.
946 ///
947 /// Wire method: `mcp.config.list`.
948 ///
949 /// # Returns
950 ///
951 /// User-configured MCP servers, keyed by server name.
952 ///
953 /// <div class="warning">
954 ///
955 /// **Experimental.** This API is part of an experimental wire-protocol surface
956 /// and may change or be removed in future SDK or CLI releases. Pin both the
957 /// SDK and CLI versions if your code depends on it.
958 ///
959 /// </div>
960 pub async fn list(&self) -> Result<McpConfigList, Error> {
961 let wire_params = serde_json::json!({});
962 let _value = self
963 .client
964 .call(rpc_methods::MCP_CONFIG_LIST, Some(wire_params))
965 .await?;
966 Ok(serde_json::from_value(_value)?)
967 }
968
969 /// Adds an MCP server to user configuration.
970 ///
971 /// Wire method: `mcp.config.add`.
972 ///
973 /// # Parameters
974 ///
975 /// * `params` - MCP server name and configuration to add to user configuration.
976 ///
977 /// <div class="warning">
978 ///
979 /// **Experimental.** This API is part of an experimental wire-protocol surface
980 /// and may change or be removed in future SDK or CLI releases. Pin both the
981 /// SDK and CLI versions if your code depends on it.
982 ///
983 /// </div>
984 pub async fn add(&self, params: McpConfigAddRequest) -> Result<(), Error> {
985 let wire_params = serde_json::to_value(params)?;
986 let _value = self
987 .client
988 .call(rpc_methods::MCP_CONFIG_ADD, Some(wire_params))
989 .await?;
990 Ok(())
991 }
992
993 /// Updates an MCP server in user configuration.
994 ///
995 /// Wire method: `mcp.config.update`.
996 ///
997 /// # Parameters
998 ///
999 /// * `params` - MCP server name and replacement configuration to write to user configuration.
1000 ///
1001 /// <div class="warning">
1002 ///
1003 /// **Experimental.** This API is part of an experimental wire-protocol surface
1004 /// and may change or be removed in future SDK or CLI releases. Pin both the
1005 /// SDK and CLI versions if your code depends on it.
1006 ///
1007 /// </div>
1008 pub async fn update(&self, params: McpConfigUpdateRequest) -> Result<(), Error> {
1009 let wire_params = serde_json::to_value(params)?;
1010 let _value = self
1011 .client
1012 .call(rpc_methods::MCP_CONFIG_UPDATE, Some(wire_params))
1013 .await?;
1014 Ok(())
1015 }
1016
1017 /// Removes an MCP server from user configuration.
1018 ///
1019 /// Wire method: `mcp.config.remove`.
1020 ///
1021 /// # Parameters
1022 ///
1023 /// * `params` - MCP server name to remove from user configuration.
1024 ///
1025 /// <div class="warning">
1026 ///
1027 /// **Experimental.** This API is part of an experimental wire-protocol surface
1028 /// and may change or be removed in future SDK or CLI releases. Pin both the
1029 /// SDK and CLI versions if your code depends on it.
1030 ///
1031 /// </div>
1032 pub async fn remove(&self, params: McpConfigRemoveRequest) -> Result<(), Error> {
1033 let wire_params = serde_json::to_value(params)?;
1034 let _value = self
1035 .client
1036 .call(rpc_methods::MCP_CONFIG_REMOVE, Some(wire_params))
1037 .await?;
1038 Ok(())
1039 }
1040
1041 /// Enables MCP servers in user configuration for new sessions.
1042 ///
1043 /// Wire method: `mcp.config.enable`.
1044 ///
1045 /// # Parameters
1046 ///
1047 /// * `params` - MCP server names to enable for new sessions.
1048 ///
1049 /// <div class="warning">
1050 ///
1051 /// **Experimental.** This API is part of an experimental wire-protocol surface
1052 /// and may change or be removed in future SDK or CLI releases. Pin both the
1053 /// SDK and CLI versions if your code depends on it.
1054 ///
1055 /// </div>
1056 pub async fn enable(&self, params: McpConfigEnableRequest) -> Result<(), Error> {
1057 let wire_params = serde_json::to_value(params)?;
1058 let _value = self
1059 .client
1060 .call(rpc_methods::MCP_CONFIG_ENABLE, Some(wire_params))
1061 .await?;
1062 Ok(())
1063 }
1064
1065 /// Disables MCP servers in user configuration for new sessions.
1066 ///
1067 /// Wire method: `mcp.config.disable`.
1068 ///
1069 /// # Parameters
1070 ///
1071 /// * `params` - MCP server names to disable for new sessions.
1072 ///
1073 /// <div class="warning">
1074 ///
1075 /// **Experimental.** This API is part of an experimental wire-protocol surface
1076 /// and may change or be removed in future SDK or CLI releases. Pin both the
1077 /// SDK and CLI versions if your code depends on it.
1078 ///
1079 /// </div>
1080 pub async fn disable(&self, params: McpConfigDisableRequest) -> Result<(), Error> {
1081 let wire_params = serde_json::to_value(params)?;
1082 let _value = self
1083 .client
1084 .call(rpc_methods::MCP_CONFIG_DISABLE, Some(wire_params))
1085 .await?;
1086 Ok(())
1087 }
1088
1089 /// Drops this runtime process's in-memory MCP server-definition cache so the next MCP config read observes disk.
1090 ///
1091 /// Wire method: `mcp.config.reload`.
1092 ///
1093 /// <div class="warning">
1094 ///
1095 /// **Experimental.** This API is part of an experimental wire-protocol surface
1096 /// and may change or be removed in future SDK or CLI releases. Pin both the
1097 /// SDK and CLI versions if your code depends on it.
1098 ///
1099 /// </div>
1100 pub async fn reload(&self) -> Result<(), Error> {
1101 let wire_params = serde_json::json!({});
1102 let _value = self
1103 .client
1104 .call(rpc_methods::MCP_CONFIG_RELOAD, Some(wire_params))
1105 .await?;
1106 Ok(())
1107 }
1108}
1109
1110/// `models.*` RPCs.
1111#[derive(Clone, Copy)]
1112pub struct ClientRpcModels<'a> {
1113 pub(crate) client: &'a Client,
1114}
1115
1116impl<'a> ClientRpcModels<'a> {
1117 /// Lists Copilot models available to the authenticated user.
1118 ///
1119 /// Wire method: `models.list`.
1120 ///
1121 /// # Returns
1122 ///
1123 /// List of Copilot models available to the resolved user, including capabilities and billing metadata.
1124 ///
1125 /// <div class="warning">
1126 ///
1127 /// **Experimental.** This API is part of an experimental wire-protocol surface
1128 /// and may change or be removed in future SDK or CLI releases. Pin both the
1129 /// SDK and CLI versions if your code depends on it.
1130 ///
1131 /// </div>
1132 pub async fn list(&self) -> Result<ModelList, Error> {
1133 let wire_params = serde_json::json!({});
1134 let _value = self
1135 .client
1136 .call(rpc_methods::MODELS_LIST, Some(wire_params))
1137 .await?;
1138 Ok(serde_json::from_value(_value)?)
1139 }
1140
1141 /// Lists Copilot models available to the authenticated user.
1142 ///
1143 /// Wire method: `models.list`.
1144 ///
1145 /// # Parameters
1146 ///
1147 /// * `params` - Optional opaque account selection or compatibility GitHub token used to list models.
1148 ///
1149 /// # Returns
1150 ///
1151 /// List of Copilot models available to the resolved user, including capabilities and billing metadata.
1152 ///
1153 /// <div class="warning">
1154 ///
1155 /// **Experimental.** This API is part of an experimental wire-protocol surface
1156 /// and may change or be removed in future SDK or CLI releases. Pin both the
1157 /// SDK and CLI versions if your code depends on it.
1158 ///
1159 /// </div>
1160 pub async fn list_with_params(&self, params: ModelsListRequest) -> Result<ModelList, Error> {
1161 let wire_params = serde_json::to_value(params)?;
1162 let _value = self
1163 .client
1164 .call(rpc_methods::MODELS_LIST, Some(wire_params))
1165 .await?;
1166 Ok(serde_json::from_value(_value)?)
1167 }
1168
1169 /// Returns the running runtime's complete catalog of well-known built-in model IDs without authentication or network access.
1170 ///
1171 /// Wire method: `models.getBuiltInCatalog`.
1172 ///
1173 /// # Returns
1174 ///
1175 /// The running runtime's complete catalog of well-known built-in model IDs, including supported models and additional IDs with built-in metadata.
1176 ///
1177 /// <div class="warning">
1178 ///
1179 /// **Experimental.** This API is part of an experimental wire-protocol surface
1180 /// and may change or be removed in future SDK or CLI releases. Pin both the
1181 /// SDK and CLI versions if your code depends on it.
1182 ///
1183 /// </div>
1184 pub async fn get_built_in_catalog(&self) -> Result<BuiltInModelCatalog, Error> {
1185 let wire_params = serde_json::json!({});
1186 let _value = self
1187 .client
1188 .call(rpc_methods::MODELS_GETBUILTINCATALOG, Some(wire_params))
1189 .await?;
1190 Ok(serde_json::from_value(_value)?)
1191 }
1192}
1193
1194/// `plugins.*` RPCs.
1195#[derive(Clone, Copy)]
1196pub struct ClientRpcPlugins<'a> {
1197 pub(crate) client: &'a Client,
1198}
1199
1200impl<'a> ClientRpcPlugins<'a> {
1201 /// `plugins.builtin.*` sub-namespace.
1202 pub fn builtin(&self) -> ClientRpcPluginsBuiltin<'a> {
1203 ClientRpcPluginsBuiltin {
1204 client: self.client,
1205 }
1206 }
1207
1208 /// `plugins.marketplaces.*` sub-namespace.
1209 pub fn marketplaces(&self) -> ClientRpcPluginsMarketplaces<'a> {
1210 ClientRpcPluginsMarketplaces {
1211 client: self.client,
1212 }
1213 }
1214
1215 /// Lists plugins installed in user/global state.
1216 ///
1217 /// Wire method: `plugins.list`.
1218 ///
1219 /// # Returns
1220 ///
1221 /// Plugins installed in user/global state.
1222 ///
1223 /// <div class="warning">
1224 ///
1225 /// **Experimental.** This API is part of an experimental wire-protocol surface
1226 /// and may change or be removed in future SDK or CLI releases. Pin both the
1227 /// SDK and CLI versions if your code depends on it.
1228 ///
1229 /// </div>
1230 pub async fn list(&self) -> Result<PluginListResult, Error> {
1231 let wire_params = serde_json::json!({});
1232 let _value = self
1233 .client
1234 .call(rpc_methods::PLUGINS_LIST, Some(wire_params))
1235 .await?;
1236 Ok(serde_json::from_value(_value)?)
1237 }
1238
1239 /// Installs a plugin from a marketplace, GitHub repo, URL, or local path.
1240 ///
1241 /// Wire method: `plugins.install`.
1242 ///
1243 /// # Parameters
1244 ///
1245 /// * `params` - Plugin source and optional working directory for relative-path resolution.
1246 ///
1247 /// # Returns
1248 ///
1249 /// Result of installing a plugin.
1250 ///
1251 /// <div class="warning">
1252 ///
1253 /// **Experimental.** This API is part of an experimental wire-protocol surface
1254 /// and may change or be removed in future SDK or CLI releases. Pin both the
1255 /// SDK and CLI versions if your code depends on it.
1256 ///
1257 /// </div>
1258 pub async fn install(
1259 &self,
1260 params: PluginsInstallRequest,
1261 ) -> Result<PluginInstallResult, Error> {
1262 let wire_params = serde_json::to_value(params)?;
1263 let _value = self
1264 .client
1265 .call(rpc_methods::PLUGINS_INSTALL, Some(wire_params))
1266 .await?;
1267 Ok(serde_json::from_value(_value)?)
1268 }
1269
1270 /// Uninstalls an installed plugin.
1271 ///
1272 /// Wire method: `plugins.uninstall`.
1273 ///
1274 /// # Parameters
1275 ///
1276 /// * `params` - Name (or spec) of the plugin to uninstall.
1277 ///
1278 /// <div class="warning">
1279 ///
1280 /// **Experimental.** This API is part of an experimental wire-protocol surface
1281 /// and may change or be removed in future SDK or CLI releases. Pin both the
1282 /// SDK and CLI versions if your code depends on it.
1283 ///
1284 /// </div>
1285 pub async fn uninstall(&self, params: PluginsUninstallRequest) -> Result<(), Error> {
1286 let wire_params = serde_json::to_value(params)?;
1287 let _value = self
1288 .client
1289 .call(rpc_methods::PLUGINS_UNINSTALL, Some(wire_params))
1290 .await?;
1291 Ok(())
1292 }
1293
1294 /// Updates an installed plugin to its latest published version.
1295 ///
1296 /// Wire method: `plugins.update`.
1297 ///
1298 /// # Parameters
1299 ///
1300 /// * `params` - Name (or spec) of the plugin to update.
1301 ///
1302 /// # Returns
1303 ///
1304 /// Result of updating a single plugin.
1305 ///
1306 /// <div class="warning">
1307 ///
1308 /// **Experimental.** This API is part of an experimental wire-protocol surface
1309 /// and may change or be removed in future SDK or CLI releases. Pin both the
1310 /// SDK and CLI versions if your code depends on it.
1311 ///
1312 /// </div>
1313 pub async fn update(&self, params: PluginsUpdateRequest) -> Result<PluginUpdateResult, Error> {
1314 let wire_params = serde_json::to_value(params)?;
1315 let _value = self
1316 .client
1317 .call(rpc_methods::PLUGINS_UPDATE, Some(wire_params))
1318 .await?;
1319 Ok(serde_json::from_value(_value)?)
1320 }
1321
1322 /// Updates every installed plugin to its latest published version.
1323 ///
1324 /// Wire method: `plugins.updateAll`.
1325 ///
1326 /// # Returns
1327 ///
1328 /// Result of updating all installed plugins.
1329 ///
1330 /// <div class="warning">
1331 ///
1332 /// **Experimental.** This API is part of an experimental wire-protocol surface
1333 /// and may change or be removed in future SDK or CLI releases. Pin both the
1334 /// SDK and CLI versions if your code depends on it.
1335 ///
1336 /// </div>
1337 pub async fn update_all(&self) -> Result<PluginUpdateAllResult, Error> {
1338 let wire_params = serde_json::json!({});
1339 let _value = self
1340 .client
1341 .call(rpc_methods::PLUGINS_UPDATEALL, Some(wire_params))
1342 .await?;
1343 Ok(serde_json::from_value(_value)?)
1344 }
1345
1346 /// Enables installed plugins for new sessions.
1347 ///
1348 /// Wire method: `plugins.enable`.
1349 ///
1350 /// # Parameters
1351 ///
1352 /// * `params` - Plugin names (or specs) to enable.
1353 ///
1354 /// <div class="warning">
1355 ///
1356 /// **Experimental.** This API is part of an experimental wire-protocol surface
1357 /// and may change or be removed in future SDK or CLI releases. Pin both the
1358 /// SDK and CLI versions if your code depends on it.
1359 ///
1360 /// </div>
1361 pub async fn enable(&self, params: PluginsEnableRequest) -> Result<(), Error> {
1362 let wire_params = serde_json::to_value(params)?;
1363 let _value = self
1364 .client
1365 .call(rpc_methods::PLUGINS_ENABLE, Some(wire_params))
1366 .await?;
1367 Ok(())
1368 }
1369
1370 /// Disables installed plugins for new sessions.
1371 ///
1372 /// Wire method: `plugins.disable`.
1373 ///
1374 /// # Parameters
1375 ///
1376 /// * `params` - Plugin names (or specs) to disable.
1377 ///
1378 /// <div class="warning">
1379 ///
1380 /// **Experimental.** This API is part of an experimental wire-protocol surface
1381 /// and may change or be removed in future SDK or CLI releases. Pin both the
1382 /// SDK and CLI versions if your code depends on it.
1383 ///
1384 /// </div>
1385 pub async fn disable(&self, params: PluginsDisableRequest) -> Result<(), Error> {
1386 let wire_params = serde_json::to_value(params)?;
1387 let _value = self
1388 .client
1389 .call(rpc_methods::PLUGINS_DISABLE, Some(wire_params))
1390 .await?;
1391 Ok(())
1392 }
1393}
1394
1395/// `plugins.builtin.*` RPCs.
1396#[derive(Clone, Copy)]
1397pub struct ClientRpcPluginsBuiltin<'a> {
1398 pub(crate) client: &'a Client,
1399}
1400
1401impl<'a> ClientRpcPluginsBuiltin<'a> {
1402 /// Replaces this server's trusted built-in plugin directories while no sessions are active.
1403 ///
1404 /// Wire method: `plugins.builtin.set`.
1405 ///
1406 /// # Parameters
1407 ///
1408 /// * `params` - Trusted built-in plugin directories to use for this runtime process.
1409 ///
1410 /// <div class="warning">
1411 ///
1412 /// **Experimental.** This API is part of an experimental wire-protocol surface
1413 /// and may change or be removed in future SDK or CLI releases. Pin both the
1414 /// SDK and CLI versions if your code depends on it.
1415 ///
1416 /// </div>
1417 pub async fn set(&self, params: PluginsBuiltinSetRequest) -> Result<(), Error> {
1418 let wire_params = serde_json::to_value(params)?;
1419 let _value = self
1420 .client
1421 .call(rpc_methods::PLUGINS_BUILTIN_SET, Some(wire_params))
1422 .await?;
1423 Ok(())
1424 }
1425}
1426
1427/// `plugins.marketplaces.*` RPCs.
1428#[derive(Clone, Copy)]
1429pub struct ClientRpcPluginsMarketplaces<'a> {
1430 pub(crate) client: &'a Client,
1431}
1432
1433impl<'a> ClientRpcPluginsMarketplaces<'a> {
1434 /// Lists all registered marketplaces (defaults + user-added).
1435 ///
1436 /// Wire method: `plugins.marketplaces.list`.
1437 ///
1438 /// # Returns
1439 ///
1440 /// All registered marketplaces, including built-in defaults.
1441 ///
1442 /// <div class="warning">
1443 ///
1444 /// **Experimental.** This API is part of an experimental wire-protocol surface
1445 /// and may change or be removed in future SDK or CLI releases. Pin both the
1446 /// SDK and CLI versions if your code depends on it.
1447 ///
1448 /// </div>
1449 pub async fn list(&self) -> Result<MarketplaceListResult, Error> {
1450 let wire_params = serde_json::json!({});
1451 let _value = self
1452 .client
1453 .call(rpc_methods::PLUGINS_MARKETPLACES_LIST, Some(wire_params))
1454 .await?;
1455 Ok(serde_json::from_value(_value)?)
1456 }
1457
1458 /// Registers a new marketplace from a source (owner/repo, URL, or local path).
1459 ///
1460 /// Wire method: `plugins.marketplaces.add`.
1461 ///
1462 /// # Parameters
1463 ///
1464 /// * `params` - Marketplace source and optional working directory for relative-path resolution.
1465 ///
1466 /// # Returns
1467 ///
1468 /// Result of registering a new marketplace.
1469 ///
1470 /// <div class="warning">
1471 ///
1472 /// **Experimental.** This API is part of an experimental wire-protocol surface
1473 /// and may change or be removed in future SDK or CLI releases. Pin both the
1474 /// SDK and CLI versions if your code depends on it.
1475 ///
1476 /// </div>
1477 pub async fn add(
1478 &self,
1479 params: PluginsMarketplacesAddRequest,
1480 ) -> Result<MarketplaceAddResult, Error> {
1481 let wire_params = serde_json::to_value(params)?;
1482 let _value = self
1483 .client
1484 .call(rpc_methods::PLUGINS_MARKETPLACES_ADD, Some(wire_params))
1485 .await?;
1486 Ok(serde_json::from_value(_value)?)
1487 }
1488
1489 /// 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`.
1490 ///
1491 /// Wire method: `plugins.marketplaces.remove`.
1492 ///
1493 /// # Parameters
1494 ///
1495 /// * `params` - Name of the marketplace to remove and an optional force flag.
1496 ///
1497 /// # Returns
1498 ///
1499 /// Outcome of the remove attempt, including dependent-plugin info when applicable.
1500 ///
1501 /// <div class="warning">
1502 ///
1503 /// **Experimental.** This API is part of an experimental wire-protocol surface
1504 /// and may change or be removed in future SDK or CLI releases. Pin both the
1505 /// SDK and CLI versions if your code depends on it.
1506 ///
1507 /// </div>
1508 pub async fn remove(
1509 &self,
1510 params: PluginsMarketplacesRemoveRequest,
1511 ) -> Result<MarketplaceRemoveResult, Error> {
1512 let wire_params = serde_json::to_value(params)?;
1513 let _value = self
1514 .client
1515 .call(rpc_methods::PLUGINS_MARKETPLACES_REMOVE, Some(wire_params))
1516 .await?;
1517 Ok(serde_json::from_value(_value)?)
1518 }
1519
1520 /// Lists plugins advertised by a registered marketplace.
1521 ///
1522 /// Wire method: `plugins.marketplaces.browse`.
1523 ///
1524 /// # Parameters
1525 ///
1526 /// * `params` - Name of the marketplace whose plugin catalog to fetch.
1527 ///
1528 /// # Returns
1529 ///
1530 /// Plugins advertised by the marketplace.
1531 ///
1532 /// <div class="warning">
1533 ///
1534 /// **Experimental.** This API is part of an experimental wire-protocol surface
1535 /// and may change or be removed in future SDK or CLI releases. Pin both the
1536 /// SDK and CLI versions if your code depends on it.
1537 ///
1538 /// </div>
1539 pub async fn browse(
1540 &self,
1541 params: PluginsMarketplacesBrowseRequest,
1542 ) -> Result<MarketplaceBrowseResult, Error> {
1543 let wire_params = serde_json::to_value(params)?;
1544 let _value = self
1545 .client
1546 .call(rpc_methods::PLUGINS_MARKETPLACES_BROWSE, Some(wire_params))
1547 .await?;
1548 Ok(serde_json::from_value(_value)?)
1549 }
1550
1551 /// Re-fetches one or all registered marketplace catalogs.
1552 ///
1553 /// Wire method: `plugins.marketplaces.refresh`.
1554 ///
1555 /// # Returns
1556 ///
1557 /// Result of refreshing one or more marketplace catalogs.
1558 ///
1559 /// <div class="warning">
1560 ///
1561 /// **Experimental.** This API is part of an experimental wire-protocol surface
1562 /// and may change or be removed in future SDK or CLI releases. Pin both the
1563 /// SDK and CLI versions if your code depends on it.
1564 ///
1565 /// </div>
1566 pub async fn refresh(&self) -> Result<MarketplaceRefreshResult, Error> {
1567 let wire_params = serde_json::json!({});
1568 let _value = self
1569 .client
1570 .call(rpc_methods::PLUGINS_MARKETPLACES_REFRESH, Some(wire_params))
1571 .await?;
1572 Ok(serde_json::from_value(_value)?)
1573 }
1574
1575 /// Re-fetches one or all registered marketplace catalogs.
1576 ///
1577 /// Wire method: `plugins.marketplaces.refresh`.
1578 ///
1579 /// # Parameters
1580 ///
1581 /// * `params` - Optional marketplace name; omit to refresh all.
1582 ///
1583 /// # Returns
1584 ///
1585 /// Result of refreshing one or more marketplace catalogs.
1586 ///
1587 /// <div class="warning">
1588 ///
1589 /// **Experimental.** This API is part of an experimental wire-protocol surface
1590 /// and may change or be removed in future SDK or CLI releases. Pin both the
1591 /// SDK and CLI versions if your code depends on it.
1592 ///
1593 /// </div>
1594 pub async fn refresh_with_params(
1595 &self,
1596 params: PluginsMarketplacesRefreshRequest,
1597 ) -> Result<MarketplaceRefreshResult, Error> {
1598 let wire_params = serde_json::to_value(params)?;
1599 let _value = self
1600 .client
1601 .call(rpc_methods::PLUGINS_MARKETPLACES_REFRESH, Some(wire_params))
1602 .await?;
1603 Ok(serde_json::from_value(_value)?)
1604 }
1605}
1606
1607/// `runtime.*` RPCs.
1608#[derive(Clone, Copy)]
1609pub struct ClientRpcRuntime<'a> {
1610 pub(crate) client: &'a Client,
1611}
1612
1613impl<'a> ClientRpcRuntime<'a> {
1614 /// Gracefully shuts down an SDK-owned runtime. The response is sent only after cleanup completes; callers may then terminate the owned runtime process.
1615 ///
1616 /// Wire method: `runtime.shutdown`.
1617 ///
1618 /// <div class="warning">
1619 ///
1620 /// **Experimental.** This API is part of an experimental wire-protocol surface
1621 /// and may change or be removed in future SDK or CLI releases. Pin both the
1622 /// SDK and CLI versions if your code depends on it.
1623 ///
1624 /// </div>
1625 pub async fn shutdown(&self) -> Result<(), Error> {
1626 let wire_params = serde_json::json!({});
1627 let _value = self
1628 .client
1629 .call(rpc_methods::RUNTIME_SHUTDOWN, Some(wire_params))
1630 .await?;
1631 Ok(())
1632 }
1633}
1634
1635/// `secrets.*` RPCs.
1636#[derive(Clone, Copy)]
1637pub struct ClientRpcSecrets<'a> {
1638 pub(crate) client: &'a Client,
1639}
1640
1641impl<'a> ClientRpcSecrets<'a> {
1642 /// Registers secret values for redaction in session logs and exports. The SDK calls this to inject dynamically generated secret values (e.g., OIDC tokens).
1643 ///
1644 /// Wire method: `secrets.addFilterValues`.
1645 ///
1646 /// # Parameters
1647 ///
1648 /// * `params` - Secret values to add to the redaction filter.
1649 ///
1650 /// # Returns
1651 ///
1652 /// Confirmation that the secret values were registered.
1653 ///
1654 /// <div class="warning">
1655 ///
1656 /// **Experimental.** This API is part of an experimental wire-protocol surface
1657 /// and may change or be removed in future SDK or CLI releases. Pin both the
1658 /// SDK and CLI versions if your code depends on it.
1659 ///
1660 /// </div>
1661 pub async fn add_filter_values(
1662 &self,
1663 params: SecretsAddFilterValuesRequest,
1664 ) -> Result<SecretsAddFilterValuesResult, Error> {
1665 let wire_params = serde_json::to_value(params)?;
1666 let _value = self
1667 .client
1668 .call(rpc_methods::SECRETS_ADDFILTERVALUES, Some(wire_params))
1669 .await?;
1670 Ok(serde_json::from_value(_value)?)
1671 }
1672}
1673
1674/// `sessionFs.*` RPCs.
1675#[derive(Clone, Copy)]
1676pub struct ClientRpcSessionFs<'a> {
1677 pub(crate) client: &'a Client,
1678}
1679
1680impl<'a> ClientRpcSessionFs<'a> {
1681 /// Registers an SDK client as the session filesystem provider.
1682 ///
1683 /// Wire method: `sessionFs.setProvider`.
1684 ///
1685 /// # Parameters
1686 ///
1687 /// * `params` - Initial working directory, session-state path layout, and path conventions used to register the calling SDK client as the session filesystem provider.
1688 ///
1689 /// # Returns
1690 ///
1691 /// Indicates whether the calling client was registered as the session filesystem provider.
1692 ///
1693 /// <div class="warning">
1694 ///
1695 /// **Experimental.** This API is part of an experimental wire-protocol surface
1696 /// and may change or be removed in future SDK or CLI releases. Pin both the
1697 /// SDK and CLI versions if your code depends on it.
1698 ///
1699 /// </div>
1700 pub async fn set_provider(
1701 &self,
1702 params: SessionFsSetProviderRequest,
1703 ) -> Result<SessionFsSetProviderResult, Error> {
1704 let wire_params = serde_json::to_value(params)?;
1705 let _value = self
1706 .client
1707 .call(rpc_methods::SESSIONFS_SETPROVIDER, Some(wire_params))
1708 .await?;
1709 Ok(serde_json::from_value(_value)?)
1710 }
1711}
1712
1713/// `sessions.*` RPCs.
1714#[derive(Clone, Copy)]
1715pub struct ClientRpcSessions<'a> {
1716 pub(crate) client: &'a Client,
1717}
1718
1719impl<'a> ClientRpcSessions<'a> {
1720 /// Creates or resumes a local session and returns the opened session ID.
1721 ///
1722 /// Wire method: `sessions.open`.
1723 ///
1724 /// # Returns
1725 ///
1726 /// Result of opening a session.
1727 ///
1728 /// <div class="warning">
1729 ///
1730 /// **Experimental.** This API is part of an experimental wire-protocol surface
1731 /// and may change or be removed in future SDK or CLI releases. Pin both the
1732 /// SDK and CLI versions if your code depends on it.
1733 ///
1734 /// </div>
1735 pub async fn open(&self) -> Result<SessionOpenResult, Error> {
1736 let wire_params = serde_json::json!({});
1737 let _value = self
1738 .client
1739 .call(rpc_methods::SESSIONS_OPEN, Some(wire_params))
1740 .await?;
1741 Ok(serde_json::from_value(_value)?)
1742 }
1743
1744 /// Creates a new session by forking persisted history from an existing session.
1745 ///
1746 /// Wire method: `sessions.fork`.
1747 ///
1748 /// # Parameters
1749 ///
1750 /// * `params` - Source session identifier to fork from, optional event-ID boundary, and optional friendly name for the new session.
1751 ///
1752 /// # Returns
1753 ///
1754 /// Identifier and optional friendly name assigned to the newly forked session.
1755 ///
1756 /// <div class="warning">
1757 ///
1758 /// **Experimental.** This API is part of an experimental wire-protocol surface
1759 /// and may change or be removed in future SDK or CLI releases. Pin both the
1760 /// SDK and CLI versions if your code depends on it.
1761 ///
1762 /// </div>
1763 pub async fn fork(&self, params: SessionsForkRequest) -> Result<SessionsForkResult, Error> {
1764 let wire_params = serde_json::to_value(params)?;
1765 let _value = self
1766 .client
1767 .call(rpc_methods::SESSIONS_FORK, Some(wire_params))
1768 .await?;
1769 Ok(serde_json::from_value(_value)?)
1770 }
1771
1772 /// Connects to an existing remote session and exposes it as an SDK session.
1773 ///
1774 /// Wire method: `sessions.connect`.
1775 ///
1776 /// # Parameters
1777 ///
1778 /// * `params` - Remote session connection parameters.
1779 ///
1780 /// # Returns
1781 ///
1782 /// Remote session connection result.
1783 ///
1784 /// <div class="warning">
1785 ///
1786 /// **Experimental.** This API is part of an experimental wire-protocol surface
1787 /// and may change or be removed in future SDK or CLI releases. Pin both the
1788 /// SDK and CLI versions if your code depends on it.
1789 ///
1790 /// </div>
1791 pub async fn connect(
1792 &self,
1793 params: ConnectRemoteSessionParams,
1794 ) -> Result<RemoteSessionConnectionResult, Error> {
1795 let wire_params = serde_json::to_value(params)?;
1796 let _value = self
1797 .client
1798 .call(rpc_methods::SESSIONS_CONNECT, Some(wire_params))
1799 .await?;
1800 Ok(serde_json::from_value(_value)?)
1801 }
1802
1803 /// 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.).
1804 ///
1805 /// Wire method: `sessions.list`.
1806 ///
1807 /// # Returns
1808 ///
1809 /// Sessions matching the filter, ordered most-recently-modified first.
1810 ///
1811 /// <div class="warning">
1812 ///
1813 /// **Experimental.** This API is part of an experimental wire-protocol surface
1814 /// and may change or be removed in future SDK or CLI releases. Pin both the
1815 /// SDK and CLI versions if your code depends on it.
1816 ///
1817 /// </div>
1818 pub async fn list(&self) -> Result<SessionList, Error> {
1819 let wire_params = serde_json::json!({});
1820 let _value = self
1821 .client
1822 .call(rpc_methods::SESSIONS_LIST, Some(wire_params))
1823 .await?;
1824 Ok(serde_json::from_value(_value)?)
1825 }
1826
1827 /// 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.).
1828 ///
1829 /// Wire method: `sessions.list`.
1830 ///
1831 /// # Parameters
1832 ///
1833 /// * `params` - Optional source filter, metadata-load limit, and context filter applied to the returned sessions.
1834 ///
1835 /// # Returns
1836 ///
1837 /// Sessions matching the filter, ordered most-recently-modified first.
1838 ///
1839 /// <div class="warning">
1840 ///
1841 /// **Experimental.** This API is part of an experimental wire-protocol surface
1842 /// and may change or be removed in future SDK or CLI releases. Pin both the
1843 /// SDK and CLI versions if your code depends on it.
1844 ///
1845 /// </div>
1846 pub async fn list_with_params(
1847 &self,
1848 params: SessionsListRequest,
1849 ) -> Result<SessionList, Error> {
1850 let wire_params = serde_json::to_value(params)?;
1851 let _value = self
1852 .client
1853 .call(rpc_methods::SESSIONS_LIST, Some(wire_params))
1854 .await?;
1855 Ok(serde_json::from_value(_value)?)
1856 }
1857
1858 /// Reads lightweight persisted metadata for one local session without opening it.
1859 ///
1860 /// Wire method: `sessions.getMetadata`.
1861 ///
1862 /// # Parameters
1863 ///
1864 /// * `params` - Session ID whose persisted metadata should be read.
1865 ///
1866 /// # Returns
1867 ///
1868 /// Persisted local session metadata when the session exists.
1869 ///
1870 /// <div class="warning">
1871 ///
1872 /// **Experimental.** This API is part of an experimental wire-protocol surface
1873 /// and may change or be removed in future SDK or CLI releases. Pin both the
1874 /// SDK and CLI versions if your code depends on it.
1875 ///
1876 /// </div>
1877 pub(crate) async fn get_metadata(
1878 &self,
1879 params: SessionsGetMetadataRequest,
1880 ) -> Result<SessionsGetMetadataResult, Error> {
1881 let wire_params = serde_json::to_value(params)?;
1882 let _value = self
1883 .client
1884 .call(rpc_methods::SESSIONS_GETMETADATA, Some(wire_params))
1885 .await?;
1886 Ok(serde_json::from_value(_value)?)
1887 }
1888
1889 /// Lists recent local session IDs that contain user-visible history, omitting housekeeping-only sessions.
1890 ///
1891 /// Wire method: `sessions.listNonEmptySessionIds`.
1892 ///
1893 /// # Parameters
1894 ///
1895 /// * `params` - Limit for non-empty local session IDs.
1896 ///
1897 /// # Returns
1898 ///
1899 /// Recent local session IDs that contain user-visible history.
1900 ///
1901 /// <div class="warning">
1902 ///
1903 /// **Experimental.** This API is part of an experimental wire-protocol surface
1904 /// and may change or be removed in future SDK or CLI releases. Pin both the
1905 /// SDK and CLI versions if your code depends on it.
1906 ///
1907 /// </div>
1908 pub(crate) async fn list_non_empty_session_ids(
1909 &self,
1910 params: SessionsListNonEmptySessionIdsRequest,
1911 ) -> Result<SessionsListNonEmptySessionIdsResult, Error> {
1912 let wire_params = serde_json::to_value(params)?;
1913 let _value = self
1914 .client
1915 .call(
1916 rpc_methods::SESSIONS_LISTNONEMPTYSESSIONIDS,
1917 Some(wire_params),
1918 )
1919 .await?;
1920 Ok(serde_json::from_value(_value)?)
1921 }
1922
1923 /// Finds the local session bound to a GitHub task ID, if any.
1924 ///
1925 /// Wire method: `sessions.findByTaskId`.
1926 ///
1927 /// # Parameters
1928 ///
1929 /// * `params` - GitHub task ID to look up.
1930 ///
1931 /// # Returns
1932 ///
1933 /// ID of the local session bound to the given GitHub task, or omitted when none.
1934 ///
1935 /// <div class="warning">
1936 ///
1937 /// **Experimental.** This API is part of an experimental wire-protocol surface
1938 /// and may change or be removed in future SDK or CLI releases. Pin both the
1939 /// SDK and CLI versions if your code depends on it.
1940 ///
1941 /// </div>
1942 pub async fn find_by_task_id(
1943 &self,
1944 params: SessionsFindByTaskIDRequest,
1945 ) -> Result<SessionsFindByTaskIDResult, Error> {
1946 let wire_params = serde_json::to_value(params)?;
1947 let _value = self
1948 .client
1949 .call(rpc_methods::SESSIONS_FINDBYTASKID, Some(wire_params))
1950 .await?;
1951 Ok(serde_json::from_value(_value)?)
1952 }
1953
1954 /// Resolves a UUID prefix to a unique session ID, if exactly one session matches.
1955 ///
1956 /// Wire method: `sessions.findByPrefix`.
1957 ///
1958 /// # Parameters
1959 ///
1960 /// * `params` - UUID prefix to resolve to a unique session ID.
1961 ///
1962 /// # Returns
1963 ///
1964 /// Session ID matching the prefix, omitted when no unique match exists.
1965 ///
1966 /// <div class="warning">
1967 ///
1968 /// **Experimental.** This API is part of an experimental wire-protocol surface
1969 /// and may change or be removed in future SDK or CLI releases. Pin both the
1970 /// SDK and CLI versions if your code depends on it.
1971 ///
1972 /// </div>
1973 pub async fn find_by_prefix(
1974 &self,
1975 params: SessionsFindByPrefixRequest,
1976 ) -> Result<SessionsFindByPrefixResult, Error> {
1977 let wire_params = serde_json::to_value(params)?;
1978 let _value = self
1979 .client
1980 .call(rpc_methods::SESSIONS_FINDBYPREFIX, Some(wire_params))
1981 .await?;
1982 Ok(serde_json::from_value(_value)?)
1983 }
1984
1985 /// Returns the most-relevant prior session for a given working-directory context.
1986 ///
1987 /// Wire method: `sessions.getLastForContext`.
1988 ///
1989 /// # Parameters
1990 ///
1991 /// * `params` - Optional working-directory context used to score session relevance.
1992 ///
1993 /// # Returns
1994 ///
1995 /// Most-relevant session ID for the supplied context, or omitted when no sessions exist.
1996 ///
1997 /// <div class="warning">
1998 ///
1999 /// **Experimental.** This API is part of an experimental wire-protocol surface
2000 /// and may change or be removed in future SDK or CLI releases. Pin both the
2001 /// SDK and CLI versions if your code depends on it.
2002 ///
2003 /// </div>
2004 pub async fn get_last_for_context(
2005 &self,
2006 params: SessionsGetLastForContextRequest,
2007 ) -> Result<SessionsGetLastForContextResult, Error> {
2008 let wire_params = serde_json::to_value(params)?;
2009 let _value = self
2010 .client
2011 .call(rpc_methods::SESSIONS_GETLASTFORCONTEXT, Some(wire_params))
2012 .await?;
2013 Ok(serde_json::from_value(_value)?)
2014 }
2015
2016 /// 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.
2017 ///
2018 /// Wire method: `sessions.getEventFilePath`.
2019 ///
2020 /// # Parameters
2021 ///
2022 /// * `params` - Session ID whose event-log file path to compute.
2023 ///
2024 /// # Returns
2025 ///
2026 /// Absolute path to the session's events.jsonl file on disk.
2027 ///
2028 /// <div class="warning">
2029 ///
2030 /// **Experimental.** This API is part of an experimental wire-protocol surface
2031 /// and may change or be removed in future SDK or CLI releases. Pin both the
2032 /// SDK and CLI versions if your code depends on it.
2033 ///
2034 /// </div>
2035 pub(crate) async fn get_event_file_path(
2036 &self,
2037 params: SessionsGetEventFilePathRequest,
2038 ) -> Result<SessionsGetEventFilePathResult, Error> {
2039 let wire_params = serde_json::to_value(params)?;
2040 let _value = self
2041 .client
2042 .call(rpc_methods::SESSIONS_GETEVENTFILEPATH, Some(wire_params))
2043 .await?;
2044 Ok(serde_json::from_value(_value)?)
2045 }
2046
2047 /// Returns the on-disk byte size of each session's workspace directory.
2048 ///
2049 /// Wire method: `sessions.getSizes`.
2050 ///
2051 /// # Returns
2052 ///
2053 /// Map of sessionId -> on-disk size in bytes for each session's workspace directory.
2054 ///
2055 /// <div class="warning">
2056 ///
2057 /// **Experimental.** This API is part of an experimental wire-protocol surface
2058 /// and may change or be removed in future SDK or CLI releases. Pin both the
2059 /// SDK and CLI versions if your code depends on it.
2060 ///
2061 /// </div>
2062 pub async fn get_sizes(&self) -> Result<SessionSizes, Error> {
2063 let wire_params = serde_json::json!({});
2064 let _value = self
2065 .client
2066 .call(rpc_methods::SESSIONS_GETSIZES, Some(wire_params))
2067 .await?;
2068 Ok(serde_json::from_value(_value)?)
2069 }
2070
2071 /// Returns the subset of the supplied session IDs that are currently held by another running process.
2072 ///
2073 /// Wire method: `sessions.checkInUse`.
2074 ///
2075 /// # Parameters
2076 ///
2077 /// * `params` - Session IDs to test for live in-use locks.
2078 ///
2079 /// # Returns
2080 ///
2081 /// Session IDs from the input set that are currently in use by another process.
2082 ///
2083 /// <div class="warning">
2084 ///
2085 /// **Experimental.** This API is part of an experimental wire-protocol surface
2086 /// and may change or be removed in future SDK or CLI releases. Pin both the
2087 /// SDK and CLI versions if your code depends on it.
2088 ///
2089 /// </div>
2090 pub async fn check_in_use(
2091 &self,
2092 params: SessionsCheckInUseRequest,
2093 ) -> Result<SessionsCheckInUseResult, Error> {
2094 let wire_params = serde_json::to_value(params)?;
2095 let _value = self
2096 .client
2097 .call(rpc_methods::SESSIONS_CHECKINUSE, Some(wire_params))
2098 .await?;
2099 Ok(serde_json::from_value(_value)?)
2100 }
2101
2102 /// 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.
2103 ///
2104 /// Wire method: `sessions.getPersistedRemoteSteerable`.
2105 ///
2106 /// # Parameters
2107 ///
2108 /// * `params` - Session ID to look up the persisted remote-steerable flag for.
2109 ///
2110 /// # Returns
2111 ///
2112 /// The session's persisted remote-steerable flag, or omitted when no value has been persisted.
2113 ///
2114 /// <div class="warning">
2115 ///
2116 /// **Experimental.** This API is part of an experimental wire-protocol surface
2117 /// and may change or be removed in future SDK or CLI releases. Pin both the
2118 /// SDK and CLI versions if your code depends on it.
2119 ///
2120 /// </div>
2121 pub(crate) async fn get_persisted_remote_steerable(
2122 &self,
2123 params: SessionsGetPersistedRemoteSteerableRequest,
2124 ) -> Result<SessionsGetPersistedRemoteSteerableResult, Error> {
2125 let wire_params = serde_json::to_value(params)?;
2126 let _value = self
2127 .client
2128 .call(
2129 rpc_methods::SESSIONS_GETPERSISTEDREMOTESTEERABLE,
2130 Some(wire_params),
2131 )
2132 .await?;
2133 Ok(serde_json::from_value(_value)?)
2134 }
2135
2136 /// Closes a session: emits shutdown, flushes pending events, releases the in-use lock, and disposes the active session.
2137 ///
2138 /// Wire method: `sessions.close`.
2139 ///
2140 /// # Parameters
2141 ///
2142 /// * `params` - Session ID to close.
2143 ///
2144 /// # Returns
2145 ///
2146 /// 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.
2147 ///
2148 /// <div class="warning">
2149 ///
2150 /// **Experimental.** This API is part of an experimental wire-protocol surface
2151 /// and may change or be removed in future SDK or CLI releases. Pin both the
2152 /// SDK and CLI versions if your code depends on it.
2153 ///
2154 /// </div>
2155 pub async fn close(&self, params: SessionsCloseRequest) -> Result<SessionsCloseResult, Error> {
2156 let wire_params = serde_json::to_value(params)?;
2157 let _value = self
2158 .client
2159 .call(rpc_methods::SESSIONS_CLOSE, Some(wire_params))
2160 .await?;
2161 Ok(serde_json::from_value(_value)?)
2162 }
2163
2164 /// Closes, deactivates, and deletes a set of sessions, returning the bytes freed per session.
2165 ///
2166 /// Wire method: `sessions.bulkDelete`.
2167 ///
2168 /// # Parameters
2169 ///
2170 /// * `params` - Session IDs to close, deactivate, and delete from disk.
2171 ///
2172 /// # Returns
2173 ///
2174 /// Map of sessionId -> bytes freed by removing the session's workspace directory.
2175 ///
2176 /// <div class="warning">
2177 ///
2178 /// **Experimental.** This API is part of an experimental wire-protocol surface
2179 /// and may change or be removed in future SDK or CLI releases. Pin both the
2180 /// SDK and CLI versions if your code depends on it.
2181 ///
2182 /// </div>
2183 pub async fn bulk_delete(
2184 &self,
2185 params: SessionsBulkDeleteRequest,
2186 ) -> Result<SessionBulkDeleteResult, Error> {
2187 let wire_params = serde_json::to_value(params)?;
2188 let _value = self
2189 .client
2190 .call(rpc_methods::SESSIONS_BULKDELETE, Some(wire_params))
2191 .await?;
2192 Ok(serde_json::from_value(_value)?)
2193 }
2194
2195 /// Deletes one local session from disk after running the same lifecycle hooks as the session manager.
2196 ///
2197 /// Wire method: `sessions.delete`.
2198 ///
2199 /// # Parameters
2200 ///
2201 /// * `params` - Session ID to delete from disk.
2202 ///
2203 /// <div class="warning">
2204 ///
2205 /// **Experimental.** This API is part of an experimental wire-protocol surface
2206 /// and may change or be removed in future SDK or CLI releases. Pin both the
2207 /// SDK and CLI versions if your code depends on it.
2208 ///
2209 /// </div>
2210 pub(crate) async fn delete(&self, params: SessionsDeleteRequest) -> Result<(), Error> {
2211 let wire_params = serde_json::to_value(params)?;
2212 let _value = self
2213 .client
2214 .call(rpc_methods::SESSIONS_DELETE, Some(wire_params))
2215 .await?;
2216 Ok(())
2217 }
2218
2219 /// Deletes sessions older than the given threshold, with optional dry-run and exclusion list.
2220 ///
2221 /// Wire method: `sessions.pruneOld`.
2222 ///
2223 /// # Parameters
2224 ///
2225 /// * `params` - Age threshold and optional flags controlling which old sessions are pruned (or simulated when dryRun is true).
2226 ///
2227 /// # Returns
2228 ///
2229 /// Outcome of the prune operation: deleted IDs, dry-run candidates, skipped IDs, total bytes freed, and the dry-run flag.
2230 ///
2231 /// <div class="warning">
2232 ///
2233 /// **Experimental.** This API is part of an experimental wire-protocol surface
2234 /// and may change or be removed in future SDK or CLI releases. Pin both the
2235 /// SDK and CLI versions if your code depends on it.
2236 ///
2237 /// </div>
2238 pub async fn prune_old(
2239 &self,
2240 params: SessionsPruneOldRequest,
2241 ) -> Result<SessionPruneResult, Error> {
2242 let wire_params = serde_json::to_value(params)?;
2243 let _value = self
2244 .client
2245 .call(rpc_methods::SESSIONS_PRUNEOLD, Some(wire_params))
2246 .await?;
2247 Ok(serde_json::from_value(_value)?)
2248 }
2249
2250 /// Flushes a session's pending events to disk.
2251 ///
2252 /// Wire method: `sessions.save`.
2253 ///
2254 /// # Parameters
2255 ///
2256 /// * `params` - Session ID whose pending events should be flushed to disk.
2257 ///
2258 /// # Returns
2259 ///
2260 /// Flush a session's pending events to disk. No-op when no writer exists for the session (e.g., already closed).
2261 ///
2262 /// <div class="warning">
2263 ///
2264 /// **Experimental.** This API is part of an experimental wire-protocol surface
2265 /// and may change or be removed in future SDK or CLI releases. Pin both the
2266 /// SDK and CLI versions if your code depends on it.
2267 ///
2268 /// </div>
2269 pub async fn save(&self, params: SessionsSaveRequest) -> Result<SessionsSaveResult, Error> {
2270 let wire_params = serde_json::to_value(params)?;
2271 let _value = self
2272 .client
2273 .call(rpc_methods::SESSIONS_SAVE, Some(wire_params))
2274 .await?;
2275 Ok(serde_json::from_value(_value)?)
2276 }
2277
2278 /// Releases the in-use lock held by this process for a session.
2279 ///
2280 /// Wire method: `sessions.releaseLock`.
2281 ///
2282 /// # Parameters
2283 ///
2284 /// * `params` - Session ID whose in-use lock should be released.
2285 ///
2286 /// # Returns
2287 ///
2288 /// 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.
2289 ///
2290 /// <div class="warning">
2291 ///
2292 /// **Experimental.** This API is part of an experimental wire-protocol surface
2293 /// and may change or be removed in future SDK or CLI releases. Pin both the
2294 /// SDK and CLI versions if your code depends on it.
2295 ///
2296 /// </div>
2297 pub async fn release_lock(
2298 &self,
2299 params: SessionsReleaseLockRequest,
2300 ) -> Result<SessionsReleaseLockResult, Error> {
2301 let wire_params = serde_json::to_value(params)?;
2302 let _value = self
2303 .client
2304 .call(rpc_methods::SESSIONS_RELEASELOCK, Some(wire_params))
2305 .await?;
2306 Ok(serde_json::from_value(_value)?)
2307 }
2308
2309 /// Backfills missing summary and context fields on the supplied session metadata records.
2310 ///
2311 /// Wire method: `sessions.enrichMetadata`.
2312 ///
2313 /// # Parameters
2314 ///
2315 /// * `params` - Session metadata records to enrich with summary and context information.
2316 ///
2317 /// # Returns
2318 ///
2319 /// The enriched metadata records, with summary and context fields backfilled where available. Sessions confirmed empty and unnamed are omitted.
2320 ///
2321 /// <div class="warning">
2322 ///
2323 /// **Experimental.** This API is part of an experimental wire-protocol surface
2324 /// and may change or be removed in future SDK or CLI releases. Pin both the
2325 /// SDK and CLI versions if your code depends on it.
2326 ///
2327 /// </div>
2328 pub async fn enrich_metadata(
2329 &self,
2330 params: SessionsEnrichMetadataRequest,
2331 ) -> Result<SessionEnrichMetadataResult, Error> {
2332 let wire_params = serde_json::to_value(params)?;
2333 let _value = self
2334 .client
2335 .call(rpc_methods::SESSIONS_ENRICHMETADATA, Some(wire_params))
2336 .await?;
2337 Ok(serde_json::from_value(_value)?)
2338 }
2339
2340 /// Reloads user, plugin, and (optionally) repo hooks on the active session.
2341 ///
2342 /// Wire method: `sessions.reloadPluginHooks`.
2343 ///
2344 /// # Parameters
2345 ///
2346 /// * `params` - Active session ID and an optional flag for deferring repo-level hooks until folder trust.
2347 ///
2348 /// # Returns
2349 ///
2350 /// 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.
2351 ///
2352 /// <div class="warning">
2353 ///
2354 /// **Experimental.** This API is part of an experimental wire-protocol surface
2355 /// and may change or be removed in future SDK or CLI releases. Pin both the
2356 /// SDK and CLI versions if your code depends on it.
2357 ///
2358 /// </div>
2359 pub async fn reload_plugin_hooks(
2360 &self,
2361 params: SessionsReloadPluginHooksRequest,
2362 ) -> Result<SessionsReloadPluginHooksResult, Error> {
2363 let wire_params = serde_json::to_value(params)?;
2364 let _value = self
2365 .client
2366 .call(rpc_methods::SESSIONS_RELOADPLUGINHOOKS, Some(wire_params))
2367 .await?;
2368 Ok(serde_json::from_value(_value)?)
2369 }
2370
2371 /// Loads previously-deferred repo-level hooks on the active session, returning queued startup prompts.
2372 ///
2373 /// Wire method: `sessions.loadDeferredRepoHooks`.
2374 ///
2375 /// # Parameters
2376 ///
2377 /// * `params` - Active session ID whose deferred repo-level hooks should be loaded.
2378 ///
2379 /// # Returns
2380 ///
2381 /// Queued repo-level startup prompts and the total hook command count after loading.
2382 ///
2383 /// <div class="warning">
2384 ///
2385 /// **Experimental.** This API is part of an experimental wire-protocol surface
2386 /// and may change or be removed in future SDK or CLI releases. Pin both the
2387 /// SDK and CLI versions if your code depends on it.
2388 ///
2389 /// </div>
2390 pub async fn load_deferred_repo_hooks(
2391 &self,
2392 params: SessionsLoadDeferredRepoHooksRequest,
2393 ) -> Result<SessionLoadDeferredRepoHooksResult, Error> {
2394 let wire_params = serde_json::to_value(params)?;
2395 let _value = self
2396 .client
2397 .call(
2398 rpc_methods::SESSIONS_LOADDEFERREDREPOHOOKS,
2399 Some(wire_params),
2400 )
2401 .await?;
2402 Ok(serde_json::from_value(_value)?)
2403 }
2404
2405 /// Replaces the manager-wide additional plugins registered with the session manager.
2406 ///
2407 /// Wire method: `sessions.setAdditionalPlugins`.
2408 ///
2409 /// # Parameters
2410 ///
2411 /// * `params` - Manager-wide additional plugins to register; replaces any previously-configured set.
2412 ///
2413 /// # Returns
2414 ///
2415 /// 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.
2416 ///
2417 /// <div class="warning">
2418 ///
2419 /// **Experimental.** This API is part of an experimental wire-protocol surface
2420 /// and may change or be removed in future SDK or CLI releases. Pin both the
2421 /// SDK and CLI versions if your code depends on it.
2422 ///
2423 /// </div>
2424 pub async fn set_additional_plugins(
2425 &self,
2426 params: SessionsSetAdditionalPluginsRequest,
2427 ) -> Result<SessionsSetAdditionalPluginsResult, Error> {
2428 let wire_params = serde_json::to_value(params)?;
2429 let _value = self
2430 .client
2431 .call(
2432 rpc_methods::SESSIONS_SETADDITIONALPLUGINS,
2433 Some(wire_params),
2434 )
2435 .await?;
2436 Ok(serde_json::from_value(_value)?)
2437 }
2438
2439 /// 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.
2440 ///
2441 /// Wire method: `sessions.getBoardEntryCount`.
2442 ///
2443 /// # Parameters
2444 ///
2445 /// * `params` - Session ID whose board entry count should be returned.
2446 ///
2447 /// # Returns
2448 ///
2449 /// Dynamic-context board entry count, when available.
2450 ///
2451 /// <div class="warning">
2452 ///
2453 /// **Experimental.** This API is part of an experimental wire-protocol surface
2454 /// and may change or be removed in future SDK or CLI releases. Pin both the
2455 /// SDK and CLI versions if your code depends on it.
2456 ///
2457 /// </div>
2458 pub(crate) async fn get_board_entry_count(
2459 &self,
2460 params: SessionsGetBoardEntryCountRequest,
2461 ) -> Result<SessionsGetBoardEntryCountResult, Error> {
2462 let wire_params = serde_json::to_value(params)?;
2463 let _value = self
2464 .client
2465 .call(rpc_methods::SESSIONS_GETBOARDENTRYCOUNT, Some(wire_params))
2466 .await?;
2467 Ok(serde_json::from_value(_value)?)
2468 }
2469
2470 /// 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.
2471 ///
2472 /// Wire method: `sessions.startRemoteControl`.
2473 ///
2474 /// # Parameters
2475 ///
2476 /// * `params` - Parameters for attaching the remote-control singleton to a session.
2477 ///
2478 /// # Returns
2479 ///
2480 /// Wrapper for the singleton's current status.
2481 ///
2482 /// <div class="warning">
2483 ///
2484 /// **Experimental.** This API is part of an experimental wire-protocol surface
2485 /// and may change or be removed in future SDK or CLI releases. Pin both the
2486 /// SDK and CLI versions if your code depends on it.
2487 ///
2488 /// </div>
2489 pub async fn start_remote_control(
2490 &self,
2491 params: SessionsStartRemoteControlRequest,
2492 ) -> Result<RemoteControlStatusResult, Error> {
2493 let wire_params = serde_json::to_value(params)?;
2494 let _value = self
2495 .client
2496 .call(rpc_methods::SESSIONS_STARTREMOTECONTROL, Some(wire_params))
2497 .await?;
2498 Ok(serde_json::from_value(_value)?)
2499 }
2500
2501 /// 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.
2502 ///
2503 /// Wire method: `sessions.transferRemoteControl`.
2504 ///
2505 /// # Parameters
2506 ///
2507 /// * `params` - Parameters for atomically rebinding the remote-control singleton.
2508 ///
2509 /// # Returns
2510 ///
2511 /// Outcome of a transferRemoteControl call.
2512 ///
2513 /// <div class="warning">
2514 ///
2515 /// **Experimental.** This API is part of an experimental wire-protocol surface
2516 /// and may change or be removed in future SDK or CLI releases. Pin both the
2517 /// SDK and CLI versions if your code depends on it.
2518 ///
2519 /// </div>
2520 pub async fn transfer_remote_control(
2521 &self,
2522 params: SessionsTransferRemoteControlRequest,
2523 ) -> Result<RemoteControlTransferResult, Error> {
2524 let wire_params = serde_json::to_value(params)?;
2525 let _value = self
2526 .client
2527 .call(
2528 rpc_methods::SESSIONS_TRANSFERREMOTECONTROL,
2529 Some(wire_params),
2530 )
2531 .await?;
2532 Ok(serde_json::from_value(_value)?)
2533 }
2534
2535 /// 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.
2536 ///
2537 /// Wire method: `sessions.setRemoteControlSteering`.
2538 ///
2539 /// # Parameters
2540 ///
2541 /// * `params` - Patch for the singleton's steering state.
2542 ///
2543 /// # Returns
2544 ///
2545 /// Wrapper for the singleton's current status.
2546 ///
2547 /// <div class="warning">
2548 ///
2549 /// **Experimental.** This API is part of an experimental wire-protocol surface
2550 /// and may change or be removed in future SDK or CLI releases. Pin both the
2551 /// SDK and CLI versions if your code depends on it.
2552 ///
2553 /// </div>
2554 pub async fn set_remote_control_steering(
2555 &self,
2556 params: SessionsSetRemoteControlSteeringRequest,
2557 ) -> Result<RemoteControlStatusResult, Error> {
2558 let wire_params = serde_json::to_value(params)?;
2559 let _value = self
2560 .client
2561 .call(
2562 rpc_methods::SESSIONS_SETREMOTECONTROLSTEERING,
2563 Some(wire_params),
2564 )
2565 .await?;
2566 Ok(serde_json::from_value(_value)?)
2567 }
2568
2569 /// 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).
2570 ///
2571 /// Wire method: `sessions.stopRemoteControl`.
2572 ///
2573 /// # Returns
2574 ///
2575 /// Outcome of a stopRemoteControl call.
2576 ///
2577 /// <div class="warning">
2578 ///
2579 /// **Experimental.** This API is part of an experimental wire-protocol surface
2580 /// and may change or be removed in future SDK or CLI releases. Pin both the
2581 /// SDK and CLI versions if your code depends on it.
2582 ///
2583 /// </div>
2584 pub async fn stop_remote_control(&self) -> Result<RemoteControlStopResult, Error> {
2585 let wire_params = serde_json::json!({});
2586 let _value = self
2587 .client
2588 .call(rpc_methods::SESSIONS_STOPREMOTECONTROL, Some(wire_params))
2589 .await?;
2590 Ok(serde_json::from_value(_value)?)
2591 }
2592
2593 /// 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).
2594 ///
2595 /// Wire method: `sessions.stopRemoteControl`.
2596 ///
2597 /// # Parameters
2598 ///
2599 /// * `params` - Parameters for stopping the remote-control singleton.
2600 ///
2601 /// # Returns
2602 ///
2603 /// Outcome of a stopRemoteControl call.
2604 ///
2605 /// <div class="warning">
2606 ///
2607 /// **Experimental.** This API is part of an experimental wire-protocol surface
2608 /// and may change or be removed in future SDK or CLI releases. Pin both the
2609 /// SDK and CLI versions if your code depends on it.
2610 ///
2611 /// </div>
2612 pub async fn stop_remote_control_with_params(
2613 &self,
2614 params: SessionsStopRemoteControlRequest,
2615 ) -> Result<RemoteControlStopResult, Error> {
2616 let wire_params = serde_json::to_value(params)?;
2617 let _value = self
2618 .client
2619 .call(rpc_methods::SESSIONS_STOPREMOTECONTROL, Some(wire_params))
2620 .await?;
2621 Ok(serde_json::from_value(_value)?)
2622 }
2623
2624 /// Returns the current state of the remote-control singleton, including the attached session id and frontend URL when active.
2625 ///
2626 /// Wire method: `sessions.getRemoteControlStatus`.
2627 ///
2628 /// # Returns
2629 ///
2630 /// Wrapper for the singleton's current status.
2631 ///
2632 /// <div class="warning">
2633 ///
2634 /// **Experimental.** This API is part of an experimental wire-protocol surface
2635 /// and may change or be removed in future SDK or CLI releases. Pin both the
2636 /// SDK and CLI versions if your code depends on it.
2637 ///
2638 /// </div>
2639 pub async fn get_remote_control_status(&self) -> Result<RemoteControlStatusResult, Error> {
2640 let wire_params = serde_json::json!({});
2641 let _value = self
2642 .client
2643 .call(
2644 rpc_methods::SESSIONS_GETREMOTECONTROLSTATUS,
2645 Some(wire_params),
2646 )
2647 .await?;
2648 Ok(serde_json::from_value(_value)?)
2649 }
2650
2651 /// Registers extension-provided tools on the given session, gated by an optional `enabled` callback. Returns an opaque unsubscribe function the caller must invoke to deregister the tools when the extension is torn down. Marked internal because `loader`, `enabled`, and the returned `unsubscribe` are in-process handles that cannot cross the JSON-RPC boundary. Disappears once extension discovery / launch / tool registration are owned by the runtime: SDK consumers will pass pure config (search paths, disabled ids) via `SessionOptions` and the runtime will resolve, launch, register, and tear down extensions itself.
2652 ///
2653 /// Wire method: `sessions.registerExtensionToolsOnSession`.
2654 ///
2655 /// # Parameters
2656 ///
2657 /// * `params` - Params to attach an extension loader's tools to a session.
2658 ///
2659 /// # Returns
2660 ///
2661 /// Handle for releasing the extension tool registration.
2662 ///
2663 /// <div class="warning">
2664 ///
2665 /// **Experimental.** This API is part of an experimental wire-protocol surface
2666 /// and may change or be removed in future SDK or CLI releases. Pin both the
2667 /// SDK and CLI versions if your code depends on it.
2668 ///
2669 /// </div>
2670 pub(crate) async fn register_extension_tools_on_session(
2671 &self,
2672 params: RegisterExtensionToolsParams,
2673 ) -> Result<RegisterExtensionToolsResult, Error> {
2674 let wire_params = serde_json::to_value(params)?;
2675 let _value = self
2676 .client
2677 .call(
2678 rpc_methods::SESSIONS_REGISTEREXTENSIONTOOLSONSESSION,
2679 Some(wire_params),
2680 )
2681 .await?;
2682 Ok(serde_json::from_value(_value)?)
2683 }
2684
2685 /// Attaches (or detaches) an in-process ExtensionController delegate for the given session, used by shared-API surfaces that need to query or modify the session's extension state. Pass `controller: undefined` to detach. Marked internal because the controller is an in-process object that cannot cross the JSON-RPC boundary. Disappears alongside `registerExtensionToolsOnSession`: once the runtime owns extension management, the public surface exposes list/enable/disable/reload as dedicated RPCs served by the runtime.
2686 ///
2687 /// Wire method: `sessions.configureSessionExtensions`.
2688 ///
2689 /// # Parameters
2690 ///
2691 /// * `params` - Params to attach or detach an in-process ExtensionController delegate.
2692 ///
2693 /// <div class="warning">
2694 ///
2695 /// **Experimental.** This API is part of an experimental wire-protocol surface
2696 /// and may change or be removed in future SDK or CLI releases. Pin both the
2697 /// SDK and CLI versions if your code depends on it.
2698 ///
2699 /// </div>
2700 pub(crate) async fn configure_session_extensions(
2701 &self,
2702 params: ConfigureSessionExtensionsParams,
2703 ) -> Result<(), Error> {
2704 let wire_params = serde_json::to_value(params)?;
2705 let _value = self
2706 .client
2707 .call(
2708 rpc_methods::SESSIONS_CONFIGURESESSIONEXTENSIONS,
2709 Some(wire_params),
2710 )
2711 .await?;
2712 Ok(())
2713 }
2714}
2715
2716/// `skills.*` RPCs.
2717#[derive(Clone, Copy)]
2718pub struct ClientRpcSkills<'a> {
2719 pub(crate) client: &'a Client,
2720}
2721
2722impl<'a> ClientRpcSkills<'a> {
2723 /// `skills.config.*` sub-namespace.
2724 pub fn config(&self) -> ClientRpcSkillsConfig<'a> {
2725 ClientRpcSkillsConfig {
2726 client: self.client,
2727 }
2728 }
2729
2730 /// Discovers skills across global and project sources.
2731 ///
2732 /// Wire method: `skills.discover`.
2733 ///
2734 /// # Parameters
2735 ///
2736 /// * `params` - Optional project paths and additional skill directories to include in discovery.
2737 ///
2738 /// # Returns
2739 ///
2740 /// Skills discovered across global and project sources.
2741 ///
2742 /// <div class="warning">
2743 ///
2744 /// **Experimental.** This API is part of an experimental wire-protocol surface
2745 /// and may change or be removed in future SDK or CLI releases. Pin both the
2746 /// SDK and CLI versions if your code depends on it.
2747 ///
2748 /// </div>
2749 pub async fn discover(&self, params: SkillsDiscoverRequest) -> Result<ServerSkillList, Error> {
2750 let wire_params = serde_json::to_value(params)?;
2751 let _value = self
2752 .client
2753 .call(rpc_methods::SKILLS_DISCOVER, Some(wire_params))
2754 .await?;
2755 Ok(serde_json::from_value(_value)?)
2756 }
2757
2758 /// 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.
2759 ///
2760 /// Wire method: `skills.getDiscoveryPaths`.
2761 ///
2762 /// # Parameters
2763 ///
2764 /// * `params` - Optional project paths to enumerate.
2765 ///
2766 /// # Returns
2767 ///
2768 /// Canonical locations where skills can be created so the runtime will recognize them.
2769 ///
2770 /// <div class="warning">
2771 ///
2772 /// **Experimental.** This API is part of an experimental wire-protocol surface
2773 /// and may change or be removed in future SDK or CLI releases. Pin both the
2774 /// SDK and CLI versions if your code depends on it.
2775 ///
2776 /// </div>
2777 pub async fn get_discovery_paths(
2778 &self,
2779 params: SkillsGetDiscoveryPathsRequest,
2780 ) -> Result<SkillDiscoveryPathList, Error> {
2781 let wire_params = serde_json::to_value(params)?;
2782 let _value = self
2783 .client
2784 .call(rpc_methods::SKILLS_GETDISCOVERYPATHS, Some(wire_params))
2785 .await?;
2786 Ok(serde_json::from_value(_value)?)
2787 }
2788}
2789
2790/// `skills.config.*` RPCs.
2791#[derive(Clone, Copy)]
2792pub struct ClientRpcSkillsConfig<'a> {
2793 pub(crate) client: &'a Client,
2794}
2795
2796impl<'a> ClientRpcSkillsConfig<'a> {
2797 /// Replaces the global list of disabled skills.
2798 ///
2799 /// Wire method: `skills.config.setDisabledSkills`.
2800 ///
2801 /// # Parameters
2802 ///
2803 /// * `params` - Skill names to mark as disabled in global configuration, replacing any previous list.
2804 ///
2805 /// <div class="warning">
2806 ///
2807 /// **Experimental.** This API is part of an experimental wire-protocol surface
2808 /// and may change or be removed in future SDK or CLI releases. Pin both the
2809 /// SDK and CLI versions if your code depends on it.
2810 ///
2811 /// </div>
2812 pub async fn set_disabled_skills(
2813 &self,
2814 params: SkillsConfigSetDisabledSkillsRequest,
2815 ) -> Result<(), Error> {
2816 let wire_params = serde_json::to_value(params)?;
2817 let _value = self
2818 .client
2819 .call(
2820 rpc_methods::SKILLS_CONFIG_SETDISABLEDSKILLS,
2821 Some(wire_params),
2822 )
2823 .await?;
2824 Ok(())
2825 }
2826
2827 /// Atomically adds or removes one skill from the disabled list.
2828 ///
2829 /// Wire method: `skills.config.setSkillDisabled`.
2830 ///
2831 /// # Parameters
2832 ///
2833 /// * `params` - Adds or removes a single skill from the global disabled list, leaving every other entry untouched.
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 set_skill_disabled(
2843 &self,
2844 params: SkillsConfigSetSkillDisabledRequest,
2845 ) -> Result<(), Error> {
2846 let wire_params = serde_json::to_value(params)?;
2847 let _value = self
2848 .client
2849 .call(
2850 rpc_methods::SKILLS_CONFIG_SETSKILLDISABLED,
2851 Some(wire_params),
2852 )
2853 .await?;
2854 Ok(())
2855 }
2856}
2857
2858/// `tools.*` RPCs.
2859#[derive(Clone, Copy)]
2860pub struct ClientRpcTools<'a> {
2861 pub(crate) client: &'a Client,
2862}
2863
2864impl<'a> ClientRpcTools<'a> {
2865 /// Lists built-in tools available for a model.
2866 ///
2867 /// Wire method: `tools.list`.
2868 ///
2869 /// # Parameters
2870 ///
2871 /// * `params` - Optional model identifier whose tool overrides should be applied to the listing.
2872 ///
2873 /// # Returns
2874 ///
2875 /// Built-in tools available for the requested model, with their parameters and instructions.
2876 ///
2877 /// <div class="warning">
2878 ///
2879 /// **Experimental.** This API is part of an experimental wire-protocol surface
2880 /// and may change or be removed in future SDK or CLI releases. Pin both the
2881 /// SDK and CLI versions if your code depends on it.
2882 ///
2883 /// </div>
2884 pub async fn list(&self, params: ToolsListRequest) -> Result<ToolList, Error> {
2885 let wire_params = serde_json::to_value(params)?;
2886 let _value = self
2887 .client
2888 .call(rpc_methods::TOOLS_LIST, Some(wire_params))
2889 .await?;
2890 Ok(serde_json::from_value(_value)?)
2891 }
2892}
2893
2894/// `user.*` RPCs.
2895#[derive(Clone, Copy)]
2896pub struct ClientRpcUser<'a> {
2897 pub(crate) client: &'a Client,
2898}
2899
2900impl<'a> ClientRpcUser<'a> {
2901 /// `user.settings.*` sub-namespace.
2902 pub fn settings(&self) -> ClientRpcUserSettings<'a> {
2903 ClientRpcUserSettings {
2904 client: self.client,
2905 }
2906 }
2907}
2908
2909/// `user.settings.*` RPCs.
2910#[derive(Clone, Copy)]
2911pub struct ClientRpcUserSettings<'a> {
2912 pub(crate) client: &'a Client,
2913}
2914
2915impl<'a> ClientRpcUserSettings<'a> {
2916 /// Drops this runtime process's in-memory user settings cache so the next settings read observes disk.
2917 ///
2918 /// Wire method: `user.settings.reload`.
2919 ///
2920 /// <div class="warning">
2921 ///
2922 /// **Experimental.** This API is part of an experimental wire-protocol surface
2923 /// and may change or be removed in future SDK or CLI releases. Pin both the
2924 /// SDK and CLI versions if your code depends on it.
2925 ///
2926 /// </div>
2927 pub async fn reload(&self) -> Result<(), Error> {
2928 let wire_params = serde_json::json!({});
2929 let _value = self
2930 .client
2931 .call(rpc_methods::USER_SETTINGS_RELOAD, Some(wire_params))
2932 .await?;
2933 Ok(())
2934 }
2935
2936 /// 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.
2937 ///
2938 /// Wire method: `user.settings.get`.
2939 ///
2940 /// # Returns
2941 ///
2942 /// 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.
2943 ///
2944 /// <div class="warning">
2945 ///
2946 /// **Experimental.** This API is part of an experimental wire-protocol surface
2947 /// and may change or be removed in future SDK or CLI releases. Pin both the
2948 /// SDK and CLI versions if your code depends on it.
2949 ///
2950 /// </div>
2951 pub async fn get(&self) -> Result<UserSettingsGetResult, Error> {
2952 let wire_params = serde_json::json!({});
2953 let _value = self
2954 .client
2955 .call(rpc_methods::USER_SETTINGS_GET, Some(wire_params))
2956 .await?;
2957 Ok(serde_json::from_value(_value)?)
2958 }
2959
2960 /// 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.
2961 ///
2962 /// Wire method: `user.settings.set`.
2963 ///
2964 /// # Parameters
2965 ///
2966 /// * `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.
2967 ///
2968 /// # Returns
2969 ///
2970 /// Outcome of writing user settings.
2971 ///
2972 /// <div class="warning">
2973 ///
2974 /// **Experimental.** This API is part of an experimental wire-protocol surface
2975 /// and may change or be removed in future SDK or CLI releases. Pin both the
2976 /// SDK and CLI versions if your code depends on it.
2977 ///
2978 /// </div>
2979 pub async fn set(
2980 &self,
2981 params: UserSettingsSetRequest,
2982 ) -> Result<UserSettingsSetResult, Error> {
2983 let wire_params = serde_json::to_value(params)?;
2984 let _value = self
2985 .client
2986 .call(rpc_methods::USER_SETTINGS_SET, Some(wire_params))
2987 .await?;
2988 Ok(serde_json::from_value(_value)?)
2989 }
2990}
2991
2992/// Typed view over a [`Session`]'s RPC namespace.
2993#[derive(Clone, Copy)]
2994pub struct SessionRpc<'a> {
2995 pub(crate) session: &'a Session,
2996}
2997
2998impl<'a> SessionRpc<'a> {
2999 /// `session.agent.*` sub-namespace.
3000 pub fn agent(&self) -> SessionRpcAgent<'a> {
3001 SessionRpcAgent {
3002 session: self.session,
3003 }
3004 }
3005
3006 /// `session.canvas.*` sub-namespace.
3007 pub fn canvas(&self) -> SessionRpcCanvas<'a> {
3008 SessionRpcCanvas {
3009 session: self.session,
3010 }
3011 }
3012
3013 /// `session.commands.*` sub-namespace.
3014 pub fn commands(&self) -> SessionRpcCommands<'a> {
3015 SessionRpcCommands {
3016 session: self.session,
3017 }
3018 }
3019
3020 /// `session.completions.*` sub-namespace.
3021 pub fn completions(&self) -> SessionRpcCompletions<'a> {
3022 SessionRpcCompletions {
3023 session: self.session,
3024 }
3025 }
3026
3027 /// `session.contentExclusion.*` sub-namespace.
3028 pub fn content_exclusion(&self) -> SessionRpcContentExclusion<'a> {
3029 SessionRpcContentExclusion {
3030 session: self.session,
3031 }
3032 }
3033
3034 /// `session.debug.*` sub-namespace.
3035 pub fn debug(&self) -> SessionRpcDebug<'a> {
3036 SessionRpcDebug {
3037 session: self.session,
3038 }
3039 }
3040
3041 /// `session.eventLog.*` sub-namespace.
3042 pub fn event_log(&self) -> SessionRpcEventLog<'a> {
3043 SessionRpcEventLog {
3044 session: self.session,
3045 }
3046 }
3047
3048 /// `session.extensions.*` sub-namespace.
3049 pub fn extensions(&self) -> SessionRpcExtensions<'a> {
3050 SessionRpcExtensions {
3051 session: self.session,
3052 }
3053 }
3054
3055 /// `session.factory.*` sub-namespace.
3056 pub fn factory(&self) -> SessionRpcFactory<'a> {
3057 SessionRpcFactory {
3058 session: self.session,
3059 }
3060 }
3061
3062 /// `session.fleet.*` sub-namespace.
3063 pub fn fleet(&self) -> SessionRpcFleet<'a> {
3064 SessionRpcFleet {
3065 session: self.session,
3066 }
3067 }
3068
3069 /// `session.gitHubAuth.*` sub-namespace.
3070 pub fn git_hub_auth(&self) -> SessionRpcGitHubAuth<'a> {
3071 SessionRpcGitHubAuth {
3072 session: self.session,
3073 }
3074 }
3075
3076 /// `session.history.*` sub-namespace.
3077 pub fn history(&self) -> SessionRpcHistory<'a> {
3078 SessionRpcHistory {
3079 session: self.session,
3080 }
3081 }
3082
3083 /// `session.instructions.*` sub-namespace.
3084 pub fn instructions(&self) -> SessionRpcInstructions<'a> {
3085 SessionRpcInstructions {
3086 session: self.session,
3087 }
3088 }
3089
3090 /// `session.limitPrediction.*` sub-namespace.
3091 pub fn limit_prediction(&self) -> SessionRpcLimitPrediction<'a> {
3092 SessionRpcLimitPrediction {
3093 session: self.session,
3094 }
3095 }
3096
3097 /// `session.lsp.*` sub-namespace.
3098 pub fn lsp(&self) -> SessionRpcLsp<'a> {
3099 SessionRpcLsp {
3100 session: self.session,
3101 }
3102 }
3103
3104 /// `session.mcp.*` sub-namespace.
3105 pub fn mcp(&self) -> SessionRpcMcp<'a> {
3106 SessionRpcMcp {
3107 session: self.session,
3108 }
3109 }
3110
3111 /// `session.metadata.*` sub-namespace.
3112 pub fn metadata(&self) -> SessionRpcMetadata<'a> {
3113 SessionRpcMetadata {
3114 session: self.session,
3115 }
3116 }
3117
3118 /// `session.mode.*` sub-namespace.
3119 pub fn mode(&self) -> SessionRpcMode<'a> {
3120 SessionRpcMode {
3121 session: self.session,
3122 }
3123 }
3124
3125 /// `session.model.*` sub-namespace.
3126 pub fn model(&self) -> SessionRpcModel<'a> {
3127 SessionRpcModel {
3128 session: self.session,
3129 }
3130 }
3131
3132 /// `session.name.*` sub-namespace.
3133 pub fn name(&self) -> SessionRpcName<'a> {
3134 SessionRpcName {
3135 session: self.session,
3136 }
3137 }
3138
3139 /// `session.options.*` sub-namespace.
3140 pub fn options(&self) -> SessionRpcOptions<'a> {
3141 SessionRpcOptions {
3142 session: self.session,
3143 }
3144 }
3145
3146 /// `session.permissions.*` sub-namespace.
3147 pub fn permissions(&self) -> SessionRpcPermissions<'a> {
3148 SessionRpcPermissions {
3149 session: self.session,
3150 }
3151 }
3152
3153 /// `session.plan.*` sub-namespace.
3154 pub fn plan(&self) -> SessionRpcPlan<'a> {
3155 SessionRpcPlan {
3156 session: self.session,
3157 }
3158 }
3159
3160 /// `session.plugins.*` sub-namespace.
3161 pub fn plugins(&self) -> SessionRpcPlugins<'a> {
3162 SessionRpcPlugins {
3163 session: self.session,
3164 }
3165 }
3166
3167 /// `session.provider.*` sub-namespace.
3168 pub fn provider(&self) -> SessionRpcProvider<'a> {
3169 SessionRpcProvider {
3170 session: self.session,
3171 }
3172 }
3173
3174 /// `session.queue.*` sub-namespace.
3175 pub fn queue(&self) -> SessionRpcQueue<'a> {
3176 SessionRpcQueue {
3177 session: self.session,
3178 }
3179 }
3180
3181 /// `session.remote.*` sub-namespace.
3182 pub fn remote(&self) -> SessionRpcRemote<'a> {
3183 SessionRpcRemote {
3184 session: self.session,
3185 }
3186 }
3187
3188 /// `session.sandbox.*` sub-namespace.
3189 pub fn sandbox(&self) -> SessionRpcSandbox<'a> {
3190 SessionRpcSandbox {
3191 session: self.session,
3192 }
3193 }
3194
3195 /// `session.schedule.*` sub-namespace.
3196 pub fn schedule(&self) -> SessionRpcSchedule<'a> {
3197 SessionRpcSchedule {
3198 session: self.session,
3199 }
3200 }
3201
3202 /// `session.settings.*` sub-namespace.
3203 pub fn settings(&self) -> SessionRpcSettings<'a> {
3204 SessionRpcSettings {
3205 session: self.session,
3206 }
3207 }
3208
3209 /// `session.shell.*` sub-namespace.
3210 pub fn shell(&self) -> SessionRpcShell<'a> {
3211 SessionRpcShell {
3212 session: self.session,
3213 }
3214 }
3215
3216 /// `session.skills.*` sub-namespace.
3217 pub fn skills(&self) -> SessionRpcSkills<'a> {
3218 SessionRpcSkills {
3219 session: self.session,
3220 }
3221 }
3222
3223 /// `session.tasks.*` sub-namespace.
3224 pub fn tasks(&self) -> SessionRpcTasks<'a> {
3225 SessionRpcTasks {
3226 session: self.session,
3227 }
3228 }
3229
3230 /// `session.telemetry.*` sub-namespace.
3231 pub fn telemetry(&self) -> SessionRpcTelemetry<'a> {
3232 SessionRpcTelemetry {
3233 session: self.session,
3234 }
3235 }
3236
3237 /// `session.tools.*` sub-namespace.
3238 pub fn tools(&self) -> SessionRpcTools<'a> {
3239 SessionRpcTools {
3240 session: self.session,
3241 }
3242 }
3243
3244 /// `session.ui.*` sub-namespace.
3245 pub fn ui(&self) -> SessionRpcUi<'a> {
3246 SessionRpcUi {
3247 session: self.session,
3248 }
3249 }
3250
3251 /// `session.usage.*` sub-namespace.
3252 pub fn usage(&self) -> SessionRpcUsage<'a> {
3253 SessionRpcUsage {
3254 session: self.session,
3255 }
3256 }
3257
3258 /// `session.visibility.*` sub-namespace.
3259 pub fn visibility(&self) -> SessionRpcVisibility<'a> {
3260 SessionRpcVisibility {
3261 session: self.session,
3262 }
3263 }
3264
3265 /// `session.workspaces.*` sub-namespace.
3266 pub fn workspaces(&self) -> SessionRpcWorkspaces<'a> {
3267 SessionRpcWorkspaces {
3268 session: self.session,
3269 }
3270 }
3271
3272 /// Suspends the session while preserving persisted state for later resume.
3273 ///
3274 /// Wire method: `session.suspend`.
3275 ///
3276 /// <div class="warning">
3277 ///
3278 /// **Experimental.** This API is part of an experimental wire-protocol surface
3279 /// and may change or be removed in future SDK or CLI releases. Pin both the
3280 /// SDK and CLI versions if your code depends on it.
3281 ///
3282 /// </div>
3283 pub async fn suspend(&self) -> Result<(), Error> {
3284 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3285 let _value = self
3286 .session
3287 .client()
3288 .call(rpc_methods::SESSION_SUSPEND, Some(wire_params))
3289 .await?;
3290 Ok(())
3291 }
3292
3293 /// Sends a user message to the session and returns its message ID.
3294 ///
3295 /// Wire method: `session.send`.
3296 ///
3297 /// # Parameters
3298 ///
3299 /// * `params` - Parameters for sending a user message to the session
3300 ///
3301 /// # Returns
3302 ///
3303 /// Result of sending a user message
3304 ///
3305 /// <div class="warning">
3306 ///
3307 /// **Experimental.** This API is part of an experimental wire-protocol surface
3308 /// and may change or be removed in future SDK or CLI releases. Pin both the
3309 /// SDK and CLI versions if your code depends on it.
3310 ///
3311 /// </div>
3312 pub async fn send(&self, params: SendRequest) -> Result<SendResult, Error> {
3313 let mut wire_params = serde_json::to_value(params)?;
3314 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3315 let _value = self
3316 .session
3317 .client()
3318 .call(rpc_methods::SESSION_SEND, Some(wire_params))
3319 .await?;
3320 Ok(serde_json::from_value(_value)?)
3321 }
3322
3323 /// 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.
3324 ///
3325 /// Wire method: `session.sendMessages`.
3326 ///
3327 /// # Parameters
3328 ///
3329 /// * `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.
3330 ///
3331 /// # Returns
3332 ///
3333 /// Result of sending zero or more user messages
3334 ///
3335 /// <div class="warning">
3336 ///
3337 /// **Experimental.** This API is part of an experimental wire-protocol surface
3338 /// and may change or be removed in future SDK or CLI releases. Pin both the
3339 /// SDK and CLI versions if your code depends on it.
3340 ///
3341 /// </div>
3342 pub async fn send_messages(
3343 &self,
3344 params: SendMessagesRequest,
3345 ) -> Result<SendMessagesResult, Error> {
3346 let mut wire_params = serde_json::to_value(params)?;
3347 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3348 let _value = self
3349 .session
3350 .client()
3351 .call(rpc_methods::SESSION_SENDMESSAGES, Some(wire_params))
3352 .await?;
3353 Ok(serde_json::from_value(_value)?)
3354 }
3355
3356 /// Queues or sends an internal system notification to the session according to its passive policy.
3357 ///
3358 /// Wire method: `session.sendSystemNotification`.
3359 ///
3360 /// # Parameters
3361 ///
3362 /// * `params` - Internal request for sending a system notification.
3363 ///
3364 /// <div class="warning">
3365 ///
3366 /// **Experimental.** This API is part of an experimental wire-protocol surface
3367 /// and may change or be removed in future SDK or CLI releases. Pin both the
3368 /// SDK and CLI versions if your code depends on it.
3369 ///
3370 /// </div>
3371 pub(crate) async fn send_system_notification(
3372 &self,
3373 params: SendSystemNotificationRequest,
3374 ) -> Result<(), Error> {
3375 let mut wire_params = serde_json::to_value(params)?;
3376 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3377 let _value = self
3378 .session
3379 .client()
3380 .call(
3381 rpc_methods::SESSION_SENDSYSTEMNOTIFICATION,
3382 Some(wire_params),
3383 )
3384 .await?;
3385 Ok(())
3386 }
3387
3388 /// Aborts the current agent turn.
3389 ///
3390 /// Wire method: `session.abort`.
3391 ///
3392 /// # Parameters
3393 ///
3394 /// * `params` - Parameters for aborting the current turn
3395 ///
3396 /// # Returns
3397 ///
3398 /// Result of aborting the current turn
3399 ///
3400 /// <div class="warning">
3401 ///
3402 /// **Experimental.** This API is part of an experimental wire-protocol surface
3403 /// and may change or be removed in future SDK or CLI releases. Pin both the
3404 /// SDK and CLI versions if your code depends on it.
3405 ///
3406 /// </div>
3407 pub async fn abort(&self, params: AbortRequest) -> Result<AbortResult, Error> {
3408 let mut wire_params = serde_json::to_value(params)?;
3409 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3410 let _value = self
3411 .session
3412 .client()
3413 .call(rpc_methods::SESSION_ABORT, Some(wire_params))
3414 .await?;
3415 Ok(serde_json::from_value(_value)?)
3416 }
3417
3418 /// 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.
3419 ///
3420 /// Wire method: `session.interruptMainTurn`.
3421 ///
3422 /// # Parameters
3423 ///
3424 /// * `params` - Parameters for interrupting the main agent turn.
3425 ///
3426 /// # Returns
3427 ///
3428 /// Result of interrupting the main agent turn.
3429 ///
3430 /// <div class="warning">
3431 ///
3432 /// **Experimental.** This API is part of an experimental wire-protocol surface
3433 /// and may change or be removed in future SDK or CLI releases. Pin both the
3434 /// SDK and CLI versions if your code depends on it.
3435 ///
3436 /// </div>
3437 pub async fn interrupt_main_turn(
3438 &self,
3439 params: InterruptMainTurnRequest,
3440 ) -> Result<InterruptMainTurnResult, Error> {
3441 let mut wire_params = serde_json::to_value(params)?;
3442 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3443 let _value = self
3444 .session
3445 .client()
3446 .call(rpc_methods::SESSION_INTERRUPTMAINTURN, Some(wire_params))
3447 .await?;
3448 Ok(serde_json::from_value(_value)?)
3449 }
3450
3451 /// Cancels every running background agent (task-registry subagents plus sidekick agents) without interrupting the main agent loop. Promoted attached shells are left running.
3452 ///
3453 /// Wire method: `session.cancelAllBackgroundAgents`.
3454 ///
3455 /// # Returns
3456 ///
3457 /// The number of running background agents (task-registry agents) that were cancelled.
3458 ///
3459 /// <div class="warning">
3460 ///
3461 /// **Experimental.** This API is part of an experimental wire-protocol surface
3462 /// and may change or be removed in future SDK or CLI releases. Pin both the
3463 /// SDK and CLI versions if your code depends on it.
3464 ///
3465 /// </div>
3466 pub async fn cancel_all_background_agents(
3467 &self,
3468 ) -> Result<SessionCancelAllBackgroundAgentsResult, Error> {
3469 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3470 let _value = self
3471 .session
3472 .client()
3473 .call(
3474 rpc_methods::SESSION_CANCELALLBACKGROUNDAGENTS,
3475 Some(wire_params),
3476 )
3477 .await?;
3478 Ok(serde_json::from_value(_value)?)
3479 }
3480
3481 /// 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.
3482 ///
3483 /// Wire method: `session.shutdown`.
3484 ///
3485 /// # Parameters
3486 ///
3487 /// * `params` - Parameters for shutting down the session
3488 ///
3489 /// <div class="warning">
3490 ///
3491 /// **Experimental.** This API is part of an experimental wire-protocol surface
3492 /// and may change or be removed in future SDK or CLI releases. Pin both the
3493 /// SDK and CLI versions if your code depends on it.
3494 ///
3495 /// </div>
3496 pub async fn shutdown(&self, params: ShutdownRequest) -> Result<(), Error> {
3497 let mut wire_params = serde_json::to_value(params)?;
3498 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3499 let _value = self
3500 .session
3501 .client()
3502 .call(rpc_methods::SESSION_SHUTDOWN, Some(wire_params))
3503 .await?;
3504 Ok(())
3505 }
3506
3507 /// Emits a user-visible session log event.
3508 ///
3509 /// Wire method: `session.log`.
3510 ///
3511 /// # Parameters
3512 ///
3513 /// * `params` - Message text, optional severity level, persistence flag, optional follow-up URL, and optional tip.
3514 ///
3515 /// # Returns
3516 ///
3517 /// Identifier of the session event that was emitted for the log message.
3518 ///
3519 /// <div class="warning">
3520 ///
3521 /// **Experimental.** This API is part of an experimental wire-protocol surface
3522 /// and may change or be removed in future SDK or CLI releases. Pin both the
3523 /// SDK and CLI versions if your code depends on it.
3524 ///
3525 /// </div>
3526 pub async fn log(&self, params: LogRequest) -> Result<LogResult, Error> {
3527 let mut wire_params = serde_json::to_value(params)?;
3528 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3529 let _value = self
3530 .session
3531 .client()
3532 .call(rpc_methods::SESSION_LOG, Some(wire_params))
3533 .await?;
3534 Ok(serde_json::from_value(_value)?)
3535 }
3536}
3537
3538/// `session.agent.*` RPCs.
3539#[derive(Clone, Copy)]
3540pub struct SessionRpcAgent<'a> {
3541 pub(crate) session: &'a Session,
3542}
3543
3544impl<'a> SessionRpcAgent<'a> {
3545 /// Lists agents available to the session. Defaults to custom agents only; pass includeBuiltInAgents to include the effective built-in agents.
3546 ///
3547 /// Wire method: `session.agent.list`.
3548 ///
3549 /// # Returns
3550 ///
3551 /// Agents available to the session.
3552 ///
3553 /// <div class="warning">
3554 ///
3555 /// **Experimental.** This API is part of an experimental wire-protocol surface
3556 /// and may change or be removed in future SDK or CLI releases. Pin both the
3557 /// SDK and CLI versions if your code depends on it.
3558 ///
3559 /// </div>
3560 pub async fn list(&self) -> Result<AgentList, Error> {
3561 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3562 let _value = self
3563 .session
3564 .client()
3565 .call(rpc_methods::SESSION_AGENT_LIST, Some(wire_params))
3566 .await?;
3567 Ok(serde_json::from_value(_value)?)
3568 }
3569
3570 /// Lists agents available to the session. Defaults to custom agents only; pass includeBuiltInAgents to include the effective built-in agents.
3571 ///
3572 /// Wire method: `session.agent.list`.
3573 ///
3574 /// # Parameters
3575 ///
3576 /// * `params` - Controls whether built-in agents and authored prompt text are included.
3577 ///
3578 /// # Returns
3579 ///
3580 /// Agents available to the session.
3581 ///
3582 /// <div class="warning">
3583 ///
3584 /// **Experimental.** This API is part of an experimental wire-protocol surface
3585 /// and may change or be removed in future SDK or CLI releases. Pin both the
3586 /// SDK and CLI versions if your code depends on it.
3587 ///
3588 /// </div>
3589 pub async fn list_with_params(&self, params: AgentListRequest) -> Result<AgentList, Error> {
3590 let mut wire_params = serde_json::to_value(params)?;
3591 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3592 let _value = self
3593 .session
3594 .client()
3595 .call(rpc_methods::SESSION_AGENT_LIST, Some(wire_params))
3596 .await?;
3597 Ok(serde_json::from_value(_value)?)
3598 }
3599
3600 /// 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.
3601 ///
3602 /// Wire method: `session.agent.setPrompt`.
3603 ///
3604 /// # Parameters
3605 ///
3606 /// * `params` - An in-memory authored prompt override for an available agent.
3607 ///
3608 /// <div class="warning">
3609 ///
3610 /// **Experimental.** This API is part of an experimental wire-protocol surface
3611 /// and may change or be removed in future SDK or CLI releases. Pin both the
3612 /// SDK and CLI versions if your code depends on it.
3613 ///
3614 /// </div>
3615 pub async fn set_prompt(&self, params: AgentSetPromptRequest) -> Result<(), Error> {
3616 let mut wire_params = serde_json::to_value(params)?;
3617 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3618 let _value = self
3619 .session
3620 .client()
3621 .call(rpc_methods::SESSION_AGENT_SETPROMPT, Some(wire_params))
3622 .await?;
3623 Ok(())
3624 }
3625
3626 /// Gets the currently selected custom agent for the session.
3627 ///
3628 /// Wire method: `session.agent.getCurrent`.
3629 ///
3630 /// # Returns
3631 ///
3632 /// The currently selected custom agent, or null when using the default agent.
3633 ///
3634 /// <div class="warning">
3635 ///
3636 /// **Experimental.** This API is part of an experimental wire-protocol surface
3637 /// and may change or be removed in future SDK or CLI releases. Pin both the
3638 /// SDK and CLI versions if your code depends on it.
3639 ///
3640 /// </div>
3641 pub async fn get_current(&self) -> Result<AgentGetCurrentResult, Error> {
3642 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3643 let _value = self
3644 .session
3645 .client()
3646 .call(rpc_methods::SESSION_AGENT_GETCURRENT, Some(wire_params))
3647 .await?;
3648 Ok(serde_json::from_value(_value)?)
3649 }
3650
3651 /// Selects a custom agent for subsequent turns in the session.
3652 ///
3653 /// Wire method: `session.agent.select`.
3654 ///
3655 /// # Parameters
3656 ///
3657 /// * `params` - Name of the custom agent to select for subsequent turns.
3658 ///
3659 /// # Returns
3660 ///
3661 /// The newly selected custom agent.
3662 ///
3663 /// <div class="warning">
3664 ///
3665 /// **Experimental.** This API is part of an experimental wire-protocol surface
3666 /// and may change or be removed in future SDK or CLI releases. Pin both the
3667 /// SDK and CLI versions if your code depends on it.
3668 ///
3669 /// </div>
3670 pub async fn select(&self, params: AgentSelectRequest) -> Result<AgentSelectResult, Error> {
3671 let mut wire_params = serde_json::to_value(params)?;
3672 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3673 let _value = self
3674 .session
3675 .client()
3676 .call(rpc_methods::SESSION_AGENT_SELECT, Some(wire_params))
3677 .await?;
3678 Ok(serde_json::from_value(_value)?)
3679 }
3680
3681 /// Clears the selected custom agent and returns the session to the default agent.
3682 ///
3683 /// Wire method: `session.agent.deselect`.
3684 ///
3685 /// <div class="warning">
3686 ///
3687 /// **Experimental.** This API is part of an experimental wire-protocol surface
3688 /// and may change or be removed in future SDK or CLI releases. Pin both the
3689 /// SDK and CLI versions if your code depends on it.
3690 ///
3691 /// </div>
3692 pub async fn deselect(&self) -> Result<(), Error> {
3693 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3694 let _value = self
3695 .session
3696 .client()
3697 .call(rpc_methods::SESSION_AGENT_DESELECT, Some(wire_params))
3698 .await?;
3699 Ok(())
3700 }
3701
3702 /// Reloads custom agent definitions and returns the refreshed list.
3703 ///
3704 /// Wire method: `session.agent.reload`.
3705 ///
3706 /// # Returns
3707 ///
3708 /// Custom agents available to the session after reloading definitions from disk.
3709 ///
3710 /// <div class="warning">
3711 ///
3712 /// **Experimental.** This API is part of an experimental wire-protocol surface
3713 /// and may change or be removed in future SDK or CLI releases. Pin both the
3714 /// SDK and CLI versions if your code depends on it.
3715 ///
3716 /// </div>
3717 pub async fn reload(&self) -> Result<AgentReloadResult, Error> {
3718 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3719 let _value = self
3720 .session
3721 .client()
3722 .call(rpc_methods::SESSION_AGENT_RELOAD, Some(wire_params))
3723 .await?;
3724 Ok(serde_json::from_value(_value)?)
3725 }
3726}
3727
3728/// `session.canvas.*` RPCs.
3729#[derive(Clone, Copy)]
3730pub struct SessionRpcCanvas<'a> {
3731 pub(crate) session: &'a Session,
3732}
3733
3734impl<'a> SessionRpcCanvas<'a> {
3735 /// `session.canvas.action.*` sub-namespace.
3736 pub fn action(&self) -> SessionRpcCanvasAction<'a> {
3737 SessionRpcCanvasAction {
3738 session: self.session,
3739 }
3740 }
3741
3742 /// `session.canvas.provider.*` sub-namespace.
3743 pub fn provider(&self) -> SessionRpcCanvasProvider<'a> {
3744 SessionRpcCanvasProvider {
3745 session: self.session,
3746 }
3747 }
3748
3749 /// Lists canvases declared for the session.
3750 ///
3751 /// Wire method: `session.canvas.list`.
3752 ///
3753 /// # Returns
3754 ///
3755 /// Declared canvases available in this session.
3756 ///
3757 /// <div class="warning">
3758 ///
3759 /// **Experimental.** This API is part of an experimental wire-protocol surface
3760 /// and may change or be removed in future SDK or CLI releases. Pin both the
3761 /// SDK and CLI versions if your code depends on it.
3762 ///
3763 /// </div>
3764 pub async fn list(&self) -> Result<CanvasList, Error> {
3765 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3766 let _value = self
3767 .session
3768 .client()
3769 .call(rpc_methods::SESSION_CANVAS_LIST, Some(wire_params))
3770 .await?;
3771 Ok(serde_json::from_value(_value)?)
3772 }
3773
3774 /// Lists currently open canvas instances for the live session.
3775 ///
3776 /// Wire method: `session.canvas.listOpen`.
3777 ///
3778 /// # Returns
3779 ///
3780 /// Live open-canvas snapshot.
3781 ///
3782 /// <div class="warning">
3783 ///
3784 /// **Experimental.** This API is part of an experimental wire-protocol surface
3785 /// and may change or be removed in future SDK or CLI releases. Pin both the
3786 /// SDK and CLI versions if your code depends on it.
3787 ///
3788 /// </div>
3789 pub async fn list_open(&self) -> Result<CanvasListOpenResult, Error> {
3790 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3791 let _value = self
3792 .session
3793 .client()
3794 .call(rpc_methods::SESSION_CANVAS_LISTOPEN, Some(wire_params))
3795 .await?;
3796 Ok(serde_json::from_value(_value)?)
3797 }
3798
3799 /// Opens or focuses a canvas instance.
3800 ///
3801 /// Wire method: `session.canvas.open`.
3802 ///
3803 /// # Parameters
3804 ///
3805 /// * `params` - Canvas open parameters.
3806 ///
3807 /// # Returns
3808 ///
3809 /// Open canvas instance snapshot.
3810 ///
3811 /// <div class="warning">
3812 ///
3813 /// **Experimental.** This API is part of an experimental wire-protocol surface
3814 /// and may change or be removed in future SDK or CLI releases. Pin both the
3815 /// SDK and CLI versions if your code depends on it.
3816 ///
3817 /// </div>
3818 pub async fn open(&self, params: CanvasOpenRequest) -> Result<OpenCanvasInstance, Error> {
3819 let mut wire_params = serde_json::to_value(params)?;
3820 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3821 let _value = self
3822 .session
3823 .client()
3824 .call(rpc_methods::SESSION_CANVAS_OPEN, Some(wire_params))
3825 .await?;
3826 Ok(serde_json::from_value(_value)?)
3827 }
3828
3829 /// Closes an open canvas instance.
3830 ///
3831 /// Wire method: `session.canvas.close`.
3832 ///
3833 /// # Parameters
3834 ///
3835 /// * `params` - Canvas close parameters.
3836 ///
3837 /// <div class="warning">
3838 ///
3839 /// **Experimental.** This API is part of an experimental wire-protocol surface
3840 /// and may change or be removed in future SDK or CLI releases. Pin both the
3841 /// SDK and CLI versions if your code depends on it.
3842 ///
3843 /// </div>
3844 pub async fn close(&self, params: CanvasCloseRequest) -> Result<(), Error> {
3845 let mut wire_params = serde_json::to_value(params)?;
3846 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3847 let _value = self
3848 .session
3849 .client()
3850 .call(rpc_methods::SESSION_CANVAS_CLOSE, Some(wire_params))
3851 .await?;
3852 Ok(())
3853 }
3854}
3855
3856/// `session.canvas.action.*` RPCs.
3857#[derive(Clone, Copy)]
3858pub struct SessionRpcCanvasAction<'a> {
3859 pub(crate) session: &'a Session,
3860}
3861
3862impl<'a> SessionRpcCanvasAction<'a> {
3863 /// Invokes an action on an open canvas instance.
3864 ///
3865 /// Wire method: `session.canvas.action.invoke`.
3866 ///
3867 /// # Parameters
3868 ///
3869 /// * `params` - Canvas action invocation parameters.
3870 ///
3871 /// # Returns
3872 ///
3873 /// Canvas action invocation result.
3874 ///
3875 /// <div class="warning">
3876 ///
3877 /// **Experimental.** This API is part of an experimental wire-protocol surface
3878 /// and may change or be removed in future SDK or CLI releases. Pin both the
3879 /// SDK and CLI versions if your code depends on it.
3880 ///
3881 /// </div>
3882 pub async fn invoke(
3883 &self,
3884 params: CanvasActionInvokeRequest,
3885 ) -> Result<CanvasActionInvokeResult, Error> {
3886 let mut wire_params = serde_json::to_value(params)?;
3887 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3888 let _value = self
3889 .session
3890 .client()
3891 .call(rpc_methods::SESSION_CANVAS_ACTION_INVOKE, Some(wire_params))
3892 .await?;
3893 Ok(serde_json::from_value(_value)?)
3894 }
3895}
3896
3897/// `session.canvas.provider.*` RPCs.
3898#[derive(Clone, Copy)]
3899pub struct SessionRpcCanvasProvider<'a> {
3900 pub(crate) session: &'a Session,
3901}
3902
3903impl<'a> SessionRpcCanvasProvider<'a> {
3904 /// Registers an internal canvas provider connection and its contributions.
3905 ///
3906 /// Wire method: `session.canvas.provider.register`.
3907 ///
3908 /// # Parameters
3909 ///
3910 /// * `params` - Internal canvas provider registration parameters.
3911 ///
3912 /// <div class="warning">
3913 ///
3914 /// **Experimental.** This API is part of an experimental wire-protocol surface
3915 /// and may change or be removed in future SDK or CLI releases. Pin both the
3916 /// SDK and CLI versions if your code depends on it.
3917 ///
3918 /// </div>
3919 pub(crate) async fn register(
3920 &self,
3921 params: CanvasProviderRegisterRequest,
3922 ) -> Result<(), Error> {
3923 let mut wire_params = serde_json::to_value(params)?;
3924 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3925 let _value = self
3926 .session
3927 .client()
3928 .call(
3929 rpc_methods::SESSION_CANVAS_PROVIDER_REGISTER,
3930 Some(wire_params),
3931 )
3932 .await?;
3933 Ok(())
3934 }
3935
3936 /// Unregisters an internal canvas provider connection.
3937 ///
3938 /// Wire method: `session.canvas.provider.unregister`.
3939 ///
3940 /// # Parameters
3941 ///
3942 /// * `params` - Internal canvas provider unregistration parameters.
3943 ///
3944 /// <div class="warning">
3945 ///
3946 /// **Experimental.** This API is part of an experimental wire-protocol surface
3947 /// and may change or be removed in future SDK or CLI releases. Pin both the
3948 /// SDK and CLI versions if your code depends on it.
3949 ///
3950 /// </div>
3951 pub(crate) async fn unregister(
3952 &self,
3953 params: CanvasProviderUnregisterRequest,
3954 ) -> Result<(), Error> {
3955 let mut wire_params = serde_json::to_value(params)?;
3956 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3957 let _value = self
3958 .session
3959 .client()
3960 .call(
3961 rpc_methods::SESSION_CANVAS_PROVIDER_UNREGISTER,
3962 Some(wire_params),
3963 )
3964 .await?;
3965 Ok(())
3966 }
3967}
3968
3969/// `session.commands.*` RPCs.
3970#[derive(Clone, Copy)]
3971pub struct SessionRpcCommands<'a> {
3972 pub(crate) session: &'a Session,
3973}
3974
3975impl<'a> SessionRpcCommands<'a> {
3976 /// Lists slash commands available in the session.
3977 ///
3978 /// Wire method: `session.commands.list`.
3979 ///
3980 /// # Returns
3981 ///
3982 /// Slash commands available in the session, after applying any include/exclude filters.
3983 ///
3984 /// <div class="warning">
3985 ///
3986 /// **Experimental.** This API is part of an experimental wire-protocol surface
3987 /// and may change or be removed in future SDK or CLI releases. Pin both the
3988 /// SDK and CLI versions if your code depends on it.
3989 ///
3990 /// </div>
3991 pub async fn list(&self) -> Result<CommandList, Error> {
3992 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3993 let _value = self
3994 .session
3995 .client()
3996 .call(rpc_methods::SESSION_COMMANDS_LIST, Some(wire_params))
3997 .await?;
3998 Ok(serde_json::from_value(_value)?)
3999 }
4000
4001 /// Lists slash commands available in the session.
4002 ///
4003 /// Wire method: `session.commands.list`.
4004 ///
4005 /// # Parameters
4006 ///
4007 /// * `params` - Optional filters controlling which command sources to include in the listing.
4008 ///
4009 /// # Returns
4010 ///
4011 /// Slash commands available in the session, after applying any include/exclude filters.
4012 ///
4013 /// <div class="warning">
4014 ///
4015 /// **Experimental.** This API is part of an experimental wire-protocol surface
4016 /// and may change or be removed in future SDK or CLI releases. Pin both the
4017 /// SDK and CLI versions if your code depends on it.
4018 ///
4019 /// </div>
4020 pub async fn list_with_params(
4021 &self,
4022 params: CommandsListRequest,
4023 ) -> Result<CommandList, Error> {
4024 let mut wire_params = serde_json::to_value(params)?;
4025 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4026 let _value = self
4027 .session
4028 .client()
4029 .call(rpc_methods::SESSION_COMMANDS_LIST, Some(wire_params))
4030 .await?;
4031 Ok(serde_json::from_value(_value)?)
4032 }
4033
4034 /// Invokes a slash command in the session.
4035 ///
4036 /// Wire method: `session.commands.invoke`.
4037 ///
4038 /// # Parameters
4039 ///
4040 /// * `params` - Slash command name and optional raw input string to invoke.
4041 ///
4042 /// # Returns
4043 ///
4044 /// Result of invoking the slash command (text output, prompt to send to the agent, completion, or subcommand selection).
4045 ///
4046 /// <div class="warning">
4047 ///
4048 /// **Experimental.** This API is part of an experimental wire-protocol surface
4049 /// and may change or be removed in future SDK or CLI releases. Pin both the
4050 /// SDK and CLI versions if your code depends on it.
4051 ///
4052 /// </div>
4053 pub async fn invoke(
4054 &self,
4055 params: CommandsInvokeRequest,
4056 ) -> Result<SlashCommandInvocationResult, Error> {
4057 let mut wire_params = serde_json::to_value(params)?;
4058 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4059 let _value = self
4060 .session
4061 .client()
4062 .call(rpc_methods::SESSION_COMMANDS_INVOKE, Some(wire_params))
4063 .await?;
4064 Ok(serde_json::from_value(_value)?)
4065 }
4066
4067 /// Finalizes persistence associated with a client-applied slash-command effect.
4068 ///
4069 /// Wire method: `session.commands.finalizeInvocationEffect`.
4070 ///
4071 /// # Parameters
4072 ///
4073 /// * `params` - The pending slash-command invocation effect to finalize, plus whether the host applied or cancelled it.
4074 ///
4075 /// # Returns
4076 ///
4077 /// Whether finalizing the invocation effect succeeded, and the failure reason when it did not.
4078 ///
4079 /// <div class="warning">
4080 ///
4081 /// **Experimental.** This API is part of an experimental wire-protocol surface
4082 /// and may change or be removed in future SDK or CLI releases. Pin both the
4083 /// SDK and CLI versions if your code depends on it.
4084 ///
4085 /// </div>
4086 pub(crate) async fn finalize_invocation_effect(
4087 &self,
4088 params: CommandsFinalizeInvocationEffectRequest,
4089 ) -> Result<CommandsFinalizeInvocationEffectResult, Error> {
4090 let mut wire_params = serde_json::to_value(params)?;
4091 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4092 let _value = self
4093 .session
4094 .client()
4095 .call(
4096 rpc_methods::SESSION_COMMANDS_FINALIZEINVOCATIONEFFECT,
4097 Some(wire_params),
4098 )
4099 .await?;
4100 Ok(serde_json::from_value(_value)?)
4101 }
4102
4103 /// Reports completion of a pending client-handled slash command.
4104 ///
4105 /// Wire method: `session.commands.handlePendingCommand`.
4106 ///
4107 /// # Parameters
4108 ///
4109 /// * `params` - Pending command request ID and an optional error if the client handler failed.
4110 ///
4111 /// # Returns
4112 ///
4113 /// Indicates whether the pending client-handled command was completed successfully.
4114 ///
4115 /// <div class="warning">
4116 ///
4117 /// **Experimental.** This API is part of an experimental wire-protocol surface
4118 /// and may change or be removed in future SDK or CLI releases. Pin both the
4119 /// SDK and CLI versions if your code depends on it.
4120 ///
4121 /// </div>
4122 pub async fn handle_pending_command(
4123 &self,
4124 params: CommandsHandlePendingCommandRequest,
4125 ) -> Result<CommandsHandlePendingCommandResult, Error> {
4126 let mut wire_params = serde_json::to_value(params)?;
4127 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4128 let _value = self
4129 .session
4130 .client()
4131 .call(
4132 rpc_methods::SESSION_COMMANDS_HANDLEPENDINGCOMMAND,
4133 Some(wire_params),
4134 )
4135 .await?;
4136 Ok(serde_json::from_value(_value)?)
4137 }
4138
4139 /// Executes a slash command synchronously and returns any error.
4140 ///
4141 /// Wire method: `session.commands.execute`.
4142 ///
4143 /// # Parameters
4144 ///
4145 /// * `params` - Slash command name and argument string to execute synchronously.
4146 ///
4147 /// # Returns
4148 ///
4149 /// Error message produced while executing the command, if any.
4150 ///
4151 /// <div class="warning">
4152 ///
4153 /// **Experimental.** This API is part of an experimental wire-protocol surface
4154 /// and may change or be removed in future SDK or CLI releases. Pin both the
4155 /// SDK and CLI versions if your code depends on it.
4156 ///
4157 /// </div>
4158 pub async fn execute(
4159 &self,
4160 params: ExecuteCommandParams,
4161 ) -> Result<ExecuteCommandResult, Error> {
4162 let mut wire_params = serde_json::to_value(params)?;
4163 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4164 let _value = self
4165 .session
4166 .client()
4167 .call(rpc_methods::SESSION_COMMANDS_EXECUTE, Some(wire_params))
4168 .await?;
4169 Ok(serde_json::from_value(_value)?)
4170 }
4171
4172 /// Enqueues a slash command for FIFO processing on the local session.
4173 ///
4174 /// Wire method: `session.commands.enqueue`.
4175 ///
4176 /// # Parameters
4177 ///
4178 /// * `params` - Slash-prefixed command string to enqueue for FIFO processing.
4179 ///
4180 /// # Returns
4181 ///
4182 /// Indicates whether the command was accepted into the local execution queue.
4183 ///
4184 /// <div class="warning">
4185 ///
4186 /// **Experimental.** This API is part of an experimental wire-protocol surface
4187 /// and may change or be removed in future SDK or CLI releases. Pin both the
4188 /// SDK and CLI versions if your code depends on it.
4189 ///
4190 /// </div>
4191 pub async fn enqueue(
4192 &self,
4193 params: EnqueueCommandParams,
4194 ) -> Result<EnqueueCommandResult, Error> {
4195 let mut wire_params = serde_json::to_value(params)?;
4196 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4197 let _value = self
4198 .session
4199 .client()
4200 .call(rpc_methods::SESSION_COMMANDS_ENQUEUE, Some(wire_params))
4201 .await?;
4202 Ok(serde_json::from_value(_value)?)
4203 }
4204
4205 /// Reports whether the host actually executed a queued command and whether to continue processing.
4206 ///
4207 /// Wire method: `session.commands.respondToQueuedCommand`.
4208 ///
4209 /// # Parameters
4210 ///
4211 /// * `params` - Queued-command request ID and the result indicating whether the host executed it (and whether to stop processing further queued commands).
4212 ///
4213 /// # Returns
4214 ///
4215 /// Indicates whether the queued-command response was matched to a pending request.
4216 ///
4217 /// <div class="warning">
4218 ///
4219 /// **Experimental.** This API is part of an experimental wire-protocol surface
4220 /// and may change or be removed in future SDK or CLI releases. Pin both the
4221 /// SDK and CLI versions if your code depends on it.
4222 ///
4223 /// </div>
4224 pub async fn respond_to_queued_command(
4225 &self,
4226 params: CommandsRespondToQueuedCommandRequest,
4227 ) -> Result<CommandsRespondToQueuedCommandResult, Error> {
4228 let mut wire_params = serde_json::to_value(params)?;
4229 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4230 let _value = self
4231 .session
4232 .client()
4233 .call(
4234 rpc_methods::SESSION_COMMANDS_RESPONDTOQUEUEDCOMMAND,
4235 Some(wire_params),
4236 )
4237 .await?;
4238 Ok(serde_json::from_value(_value)?)
4239 }
4240}
4241
4242/// `session.completions.*` RPCs.
4243#[derive(Clone, Copy)]
4244pub struct SessionRpcCompletions<'a> {
4245 pub(crate) session: &'a Session,
4246}
4247
4248impl<'a> SessionRpcCompletions<'a> {
4249 /// 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).
4250 ///
4251 /// Wire method: `session.completions.getTriggerCharacters`.
4252 ///
4253 /// # Returns
4254 ///
4255 /// 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`).
4256 ///
4257 /// <div class="warning">
4258 ///
4259 /// **Experimental.** This API is part of an experimental wire-protocol surface
4260 /// and may change or be removed in future SDK or CLI releases. Pin both the
4261 /// SDK and CLI versions if your code depends on it.
4262 ///
4263 /// </div>
4264 pub async fn get_trigger_characters(
4265 &self,
4266 ) -> Result<CompletionsGetTriggerCharactersResult, Error> {
4267 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
4268 let _value = self
4269 .session
4270 .client()
4271 .call(
4272 rpc_methods::SESSION_COMPLETIONS_GETTRIGGERCHARACTERS,
4273 Some(wire_params),
4274 )
4275 .await?;
4276 Ok(serde_json::from_value(_value)?)
4277 }
4278
4279 /// 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.
4280 ///
4281 /// Wire method: `session.completions.request`.
4282 ///
4283 /// # Parameters
4284 ///
4285 /// * `params` - Request host-driven completions for the current composer input.
4286 ///
4287 /// # Returns
4288 ///
4289 /// Host-driven completion items for the current composer input. Empty when the host returns no items or does not support completions.
4290 ///
4291 /// <div class="warning">
4292 ///
4293 /// **Experimental.** This API is part of an experimental wire-protocol surface
4294 /// and may change or be removed in future SDK or CLI releases. Pin both the
4295 /// SDK and CLI versions if your code depends on it.
4296 ///
4297 /// </div>
4298 pub async fn request(
4299 &self,
4300 params: CompletionsRequestRequest,
4301 ) -> Result<CompletionsRequestResult, Error> {
4302 let mut wire_params = serde_json::to_value(params)?;
4303 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4304 let _value = self
4305 .session
4306 .client()
4307 .call(rpc_methods::SESSION_COMPLETIONS_REQUEST, Some(wire_params))
4308 .await?;
4309 Ok(serde_json::from_value(_value)?)
4310 }
4311}
4312
4313/// `session.contentExclusion.*` RPCs.
4314#[derive(Clone, Copy)]
4315pub struct SessionRpcContentExclusion<'a> {
4316 pub(crate) session: &'a Session,
4317}
4318
4319impl<'a> SessionRpcContentExclusion<'a> {
4320 /// 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.
4321 ///
4322 /// Wire method: `session.contentExclusion.checkPaths`.
4323 ///
4324 /// # Parameters
4325 ///
4326 /// * `params` - Local file system absolute paths within the session working directory to check against its content-exclusion policy.
4327 ///
4328 /// # Returns
4329 ///
4330 /// Batch content-exclusion result. Callers must fail closed when policy evaluation is unavailable.
4331 ///
4332 /// <div class="warning">
4333 ///
4334 /// **Experimental.** This API is part of an experimental wire-protocol surface
4335 /// and may change or be removed in future SDK or CLI releases. Pin both the
4336 /// SDK and CLI versions if your code depends on it.
4337 ///
4338 /// </div>
4339 pub async fn check_paths(
4340 &self,
4341 params: ContentExclusionCheckPathsRequest,
4342 ) -> Result<ContentExclusionCheckPathsResult, Error> {
4343 let mut wire_params = serde_json::to_value(params)?;
4344 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4345 let _value = self
4346 .session
4347 .client()
4348 .call(
4349 rpc_methods::SESSION_CONTENTEXCLUSION_CHECKPATHS,
4350 Some(wire_params),
4351 )
4352 .await?;
4353 Ok(serde_json::from_value(_value)?)
4354 }
4355}
4356
4357/// `session.debug.*` RPCs.
4358#[derive(Clone, Copy)]
4359pub struct SessionRpcDebug<'a> {
4360 pub(crate) session: &'a Session,
4361}
4362
4363impl<'a> SessionRpcDebug<'a> {
4364 /// Collects a redacted session debug log bundle into a local archive or staging directory. 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.
4365 ///
4366 /// Wire method: `session.debug.collectLogs`.
4367 ///
4368 /// # Parameters
4369 ///
4370 /// * `params` - Options for collecting a redacted session debug bundle.
4371 ///
4372 /// # Returns
4373 ///
4374 /// Result of collecting a redacted debug bundle.
4375 ///
4376 /// <div class="warning">
4377 ///
4378 /// **Experimental.** This API is part of an experimental wire-protocol surface
4379 /// and may change or be removed in future SDK or CLI releases. Pin both the
4380 /// SDK and CLI versions if your code depends on it.
4381 ///
4382 /// </div>
4383 pub async fn collect_logs(
4384 &self,
4385 params: DebugCollectLogsRequest,
4386 ) -> Result<DebugCollectLogsResult, Error> {
4387 let mut wire_params = serde_json::to_value(params)?;
4388 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4389 let _value = self
4390 .session
4391 .client()
4392 .call(rpc_methods::SESSION_DEBUG_COLLECTLOGS, Some(wire_params))
4393 .await?;
4394 Ok(serde_json::from_value(_value)?)
4395 }
4396}
4397
4398/// `session.eventLog.*` RPCs.
4399#[derive(Clone, Copy)]
4400pub struct SessionRpcEventLog<'a> {
4401 pub(crate) session: &'a Session,
4402}
4403
4404impl<'a> SessionRpcEventLog<'a> {
4405 /// Reads a batch of session events from a cursor, optionally waiting for new events. Supports tail-first reads via `direction: backward`.
4406 ///
4407 /// Wire method: `session.eventLog.read`.
4408 ///
4409 /// # Parameters
4410 ///
4411 /// * `params` - Cursor, batch size, and optional long-poll/filter parameters for reading session events.
4412 ///
4413 /// # Returns
4414 ///
4415 /// Batch of session events returned by a read, with cursor and continuation metadata.
4416 ///
4417 /// <div class="warning">
4418 ///
4419 /// **Experimental.** This API is part of an experimental wire-protocol surface
4420 /// and may change or be removed in future SDK or CLI releases. Pin both the
4421 /// SDK and CLI versions if your code depends on it.
4422 ///
4423 /// </div>
4424 pub async fn read(&self, params: EventLogReadRequest) -> Result<EventsReadResult, Error> {
4425 let mut wire_params = serde_json::to_value(params)?;
4426 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4427 let _value = self
4428 .session
4429 .client()
4430 .call(rpc_methods::SESSION_EVENTLOG_READ, Some(wire_params))
4431 .await?;
4432 Ok(serde_json::from_value(_value)?)
4433 }
4434
4435 /// Returns a snapshot of the current tail cursor without consuming events.
4436 ///
4437 /// Wire method: `session.eventLog.tail`.
4438 ///
4439 /// # Returns
4440 ///
4441 /// 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).
4442 ///
4443 /// <div class="warning">
4444 ///
4445 /// **Experimental.** This API is part of an experimental wire-protocol surface
4446 /// and may change or be removed in future SDK or CLI releases. Pin both the
4447 /// SDK and CLI versions if your code depends on it.
4448 ///
4449 /// </div>
4450 pub async fn tail(&self) -> Result<EventLogTailResult, Error> {
4451 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
4452 let _value = self
4453 .session
4454 .client()
4455 .call(rpc_methods::SESSION_EVENTLOG_TAIL, Some(wire_params))
4456 .await?;
4457 Ok(serde_json::from_value(_value)?)
4458 }
4459
4460 /// Registers consumer interest in an event type for runtime gating purposes.
4461 ///
4462 /// Wire method: `session.eventLog.registerInterest`.
4463 ///
4464 /// # Parameters
4465 ///
4466 /// * `params` - Event type to register consumer interest for, used by runtime gating logic.
4467 ///
4468 /// # Returns
4469 ///
4470 /// Opaque handle representing an event-type interest registration.
4471 ///
4472 /// <div class="warning">
4473 ///
4474 /// **Experimental.** This API is part of an experimental wire-protocol surface
4475 /// and may change or be removed in future SDK or CLI releases. Pin both the
4476 /// SDK and CLI versions if your code depends on it.
4477 ///
4478 /// </div>
4479 pub async fn register_interest(
4480 &self,
4481 params: RegisterEventInterestParams,
4482 ) -> Result<RegisterEventInterestResult, 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(
4489 rpc_methods::SESSION_EVENTLOG_REGISTERINTEREST,
4490 Some(wire_params),
4491 )
4492 .await?;
4493 Ok(serde_json::from_value(_value)?)
4494 }
4495
4496 /// Releases a consumer's previously-registered interest in an event type.
4497 ///
4498 /// Wire method: `session.eventLog.releaseInterest`.
4499 ///
4500 /// # Parameters
4501 ///
4502 /// * `params` - Opaque handle previously returned by `registerInterest` to release.
4503 ///
4504 /// # Returns
4505 ///
4506 /// Indicates whether the operation succeeded.
4507 ///
4508 /// <div class="warning">
4509 ///
4510 /// **Experimental.** This API is part of an experimental wire-protocol surface
4511 /// and may change or be removed in future SDK or CLI releases. Pin both the
4512 /// SDK and CLI versions if your code depends on it.
4513 ///
4514 /// </div>
4515 pub async fn release_interest(
4516 &self,
4517 params: ReleaseEventInterestParams,
4518 ) -> Result<EventLogReleaseInterestResult, Error> {
4519 let mut wire_params = serde_json::to_value(params)?;
4520 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4521 let _value = self
4522 .session
4523 .client()
4524 .call(
4525 rpc_methods::SESSION_EVENTLOG_RELEASEINTEREST,
4526 Some(wire_params),
4527 )
4528 .await?;
4529 Ok(serde_json::from_value(_value)?)
4530 }
4531}
4532
4533/// `session.extensions.*` RPCs.
4534#[derive(Clone, Copy)]
4535pub struct SessionRpcExtensions<'a> {
4536 pub(crate) session: &'a Session,
4537}
4538
4539impl<'a> SessionRpcExtensions<'a> {
4540 /// Lists extensions discovered for the session and their current status.
4541 ///
4542 /// Wire method: `session.extensions.list`.
4543 ///
4544 /// # Returns
4545 ///
4546 /// Extensions discovered for the session, with their current status.
4547 ///
4548 /// <div class="warning">
4549 ///
4550 /// **Experimental.** This API is part of an experimental wire-protocol surface
4551 /// and may change or be removed in future SDK or CLI releases. Pin both the
4552 /// SDK and CLI versions if your code depends on it.
4553 ///
4554 /// </div>
4555 pub async fn list(&self) -> Result<ExtensionList, Error> {
4556 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
4557 let _value = self
4558 .session
4559 .client()
4560 .call(rpc_methods::SESSION_EXTENSIONS_LIST, Some(wire_params))
4561 .await?;
4562 Ok(serde_json::from_value(_value)?)
4563 }
4564
4565 /// Enables an extension for the session.
4566 ///
4567 /// Wire method: `session.extensions.enable`.
4568 ///
4569 /// # Parameters
4570 ///
4571 /// * `params` - Source-qualified extension identifier to enable for the session.
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 enable(&self, params: ExtensionsEnableRequest) -> Result<(), 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(rpc_methods::SESSION_EXTENSIONS_ENABLE, Some(wire_params))
4587 .await?;
4588 Ok(())
4589 }
4590
4591 /// Disables an extension for the session.
4592 ///
4593 /// Wire method: `session.extensions.disable`.
4594 ///
4595 /// # Parameters
4596 ///
4597 /// * `params` - Source-qualified extension identifier to disable for the session.
4598 ///
4599 /// <div class="warning">
4600 ///
4601 /// **Experimental.** This API is part of an experimental wire-protocol surface
4602 /// and may change or be removed in future SDK or CLI releases. Pin both the
4603 /// SDK and CLI versions if your code depends on it.
4604 ///
4605 /// </div>
4606 pub async fn disable(&self, params: ExtensionsDisableRequest) -> Result<(), Error> {
4607 let mut wire_params = serde_json::to_value(params)?;
4608 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4609 let _value = self
4610 .session
4611 .client()
4612 .call(rpc_methods::SESSION_EXTENSIONS_DISABLE, Some(wire_params))
4613 .await?;
4614 Ok(())
4615 }
4616
4617 /// Reloads extension definitions and processes for the session.
4618 ///
4619 /// Wire method: `session.extensions.reload`.
4620 ///
4621 /// <div class="warning">
4622 ///
4623 /// **Experimental.** This API is part of an experimental wire-protocol surface
4624 /// and may change or be removed in future SDK or CLI releases. Pin both the
4625 /// SDK and CLI versions if your code depends on it.
4626 ///
4627 /// </div>
4628 pub async fn reload(&self) -> Result<(), Error> {
4629 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
4630 let _value = self
4631 .session
4632 .client()
4633 .call(rpc_methods::SESSION_EXTENSIONS_RELOAD, Some(wire_params))
4634 .await?;
4635 Ok(())
4636 }
4637
4638 /// 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.
4639 ///
4640 /// Wire method: `session.extensions.sendAttachmentsToMessage`.
4641 ///
4642 /// # Parameters
4643 ///
4644 /// * `params` - Parameters for session.extensions.sendAttachmentsToMessage.
4645 ///
4646 /// <div class="warning">
4647 ///
4648 /// **Experimental.** This API is part of an experimental wire-protocol surface
4649 /// and may change or be removed in future SDK or CLI releases. Pin both the
4650 /// SDK and CLI versions if your code depends on it.
4651 ///
4652 /// </div>
4653 pub async fn send_attachments_to_message(
4654 &self,
4655 params: SendAttachmentsToMessageParams,
4656 ) -> Result<(), Error> {
4657 let mut wire_params = serde_json::to_value(params)?;
4658 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4659 let _value = self
4660 .session
4661 .client()
4662 .call(
4663 rpc_methods::SESSION_EXTENSIONS_SENDATTACHMENTSTOMESSAGE,
4664 Some(wire_params),
4665 )
4666 .await?;
4667 Ok(())
4668 }
4669}
4670
4671/// `session.factory.*` RPCs.
4672#[derive(Clone, Copy)]
4673pub struct SessionRpcFactory<'a> {
4674 pub(crate) session: &'a Session,
4675}
4676
4677impl<'a> SessionRpcFactory<'a> {
4678 /// `session.factory.journal.*` sub-namespace.
4679 pub fn journal(&self) -> SessionRpcFactoryJournal<'a> {
4680 SessionRpcFactoryJournal {
4681 session: self.session,
4682 }
4683 }
4684
4685 /// Runs a registered factory by name at the top level.
4686 ///
4687 /// Wire method: `session.factory.run`.
4688 ///
4689 /// # Parameters
4690 ///
4691 /// * `params` - Parameters for invoking a registered factory.
4692 ///
4693 /// # Returns
4694 ///
4695 /// Complete current or terminal factory run envelope.
4696 ///
4697 /// <div class="warning">
4698 ///
4699 /// **Experimental.** This API is part of an experimental wire-protocol surface
4700 /// and may change or be removed in future SDK or CLI releases. Pin both the
4701 /// SDK and CLI versions if your code depends on it.
4702 ///
4703 /// </div>
4704 pub async fn run(&self, params: FactoryRunRequest) -> Result<FactoryRunResult, Error> {
4705 let mut wire_params = serde_json::to_value(params)?;
4706 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4707 let _value = self
4708 .session
4709 .client()
4710 .call(rpc_methods::SESSION_FACTORY_RUN, Some(wire_params))
4711 .await?;
4712 Ok(serde_json::from_value(_value)?)
4713 }
4714
4715 /// Resumes a factory run using its persisted name, arguments, journal, and accounting.
4716 ///
4717 /// Wire method: `session.factory.resume`.
4718 ///
4719 /// # Parameters
4720 ///
4721 /// * `params` - Parameters for resuming a factory run from its persisted identity.
4722 ///
4723 /// # Returns
4724 ///
4725 /// Resolved persisted factory identity and resumed run envelope.
4726 ///
4727 /// <div class="warning">
4728 ///
4729 /// **Experimental.** This API is part of an experimental wire-protocol surface
4730 /// and may change or be removed in future SDK or CLI releases. Pin both the
4731 /// SDK and CLI versions if your code depends on it.
4732 ///
4733 /// </div>
4734 pub async fn resume(&self, params: FactoryResumeRequest) -> Result<FactoryResumeResult, Error> {
4735 let mut wire_params = serde_json::to_value(params)?;
4736 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4737 let _value = self
4738 .session
4739 .client()
4740 .call(rpc_methods::SESSION_FACTORY_RESUME, Some(wire_params))
4741 .await?;
4742 Ok(serde_json::from_value(_value)?)
4743 }
4744
4745 /// Internal tool-originated factory invocation.
4746 ///
4747 /// Wire method: `session.factory.runFromTool`.
4748 ///
4749 /// # Parameters
4750 ///
4751 /// * `params` - Internal parameters for invoking a registered factory from a tool.
4752 ///
4753 /// # Returns
4754 ///
4755 /// Complete current or terminal factory run envelope.
4756 ///
4757 /// <div class="warning">
4758 ///
4759 /// **Experimental.** This API is part of an experimental wire-protocol surface
4760 /// and may change or be removed in future SDK or CLI releases. Pin both the
4761 /// SDK and CLI versions if your code depends on it.
4762 ///
4763 /// </div>
4764 pub(crate) async fn run_from_tool(
4765 &self,
4766 params: FactoryToolRunRequest,
4767 ) -> Result<FactoryRunResult, Error> {
4768 let mut wire_params = serde_json::to_value(params)?;
4769 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4770 let _value = self
4771 .session
4772 .client()
4773 .call(rpc_methods::SESSION_FACTORY_RUNFROMTOOL, Some(wire_params))
4774 .await?;
4775 Ok(serde_json::from_value(_value)?)
4776 }
4777
4778 /// Internal tool-originated factory resume.
4779 ///
4780 /// Wire method: `session.factory.resumeFromTool`.
4781 ///
4782 /// # Parameters
4783 ///
4784 /// * `params` - Internal parameters for resuming a factory run from a tool.
4785 ///
4786 /// # Returns
4787 ///
4788 /// Resolved persisted factory identity and resumed run envelope.
4789 ///
4790 /// <div class="warning">
4791 ///
4792 /// **Experimental.** This API is part of an experimental wire-protocol surface
4793 /// and may change or be removed in future SDK or CLI releases. Pin both the
4794 /// SDK and CLI versions if your code depends on it.
4795 ///
4796 /// </div>
4797 pub(crate) async fn resume_from_tool(
4798 &self,
4799 params: FactoryToolResumeRequest,
4800 ) -> Result<FactoryResumeResult, Error> {
4801 let mut wire_params = serde_json::to_value(params)?;
4802 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4803 let _value = self
4804 .session
4805 .client()
4806 .call(
4807 rpc_methods::SESSION_FACTORY_RESUMEFROMTOOL,
4808 Some(wire_params),
4809 )
4810 .await?;
4811 Ok(serde_json::from_value(_value)?)
4812 }
4813
4814 /// Gets the current or settled envelope for a factory run.
4815 ///
4816 /// Wire method: `session.factory.getRun`.
4817 ///
4818 /// # Parameters
4819 ///
4820 /// * `params` - Parameters for retrieving a factory run.
4821 ///
4822 /// # Returns
4823 ///
4824 /// Complete current or terminal factory run envelope.
4825 ///
4826 /// <div class="warning">
4827 ///
4828 /// **Experimental.** This API is part of an experimental wire-protocol surface
4829 /// and may change or be removed in future SDK or CLI releases. Pin both the
4830 /// SDK and CLI versions if your code depends on it.
4831 ///
4832 /// </div>
4833 pub async fn get_run(&self, params: FactoryGetRunRequest) -> Result<FactoryRunResult, Error> {
4834 let mut wire_params = serde_json::to_value(params)?;
4835 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4836 let _value = self
4837 .session
4838 .client()
4839 .call(rpc_methods::SESSION_FACTORY_GETRUN, Some(wire_params))
4840 .await?;
4841 Ok(serde_json::from_value(_value)?)
4842 }
4843
4844 /// Lists durable factory runs for this session in creation order.
4845 ///
4846 /// Wire method: `session.factory.listRuns`.
4847 ///
4848 /// # Parameters
4849 ///
4850 /// * `params` - Parameters for paging factory runs.
4851 ///
4852 /// # Returns
4853 ///
4854 /// A page of factory runs in durable creation order.
4855 ///
4856 /// <div class="warning">
4857 ///
4858 /// **Experimental.** This API is part of an experimental wire-protocol surface
4859 /// and may change or be removed in future SDK or CLI releases. Pin both the
4860 /// SDK and CLI versions if your code depends on it.
4861 ///
4862 /// </div>
4863 pub async fn list_runs(
4864 &self,
4865 params: FactoryListRunsRequest,
4866 ) -> Result<FactoryListRunsResult, Error> {
4867 let mut wire_params = serde_json::to_value(params)?;
4868 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4869 let _value = self
4870 .session
4871 .client()
4872 .call(rpc_methods::SESSION_FACTORY_LISTRUNS, Some(wire_params))
4873 .await?;
4874 Ok(serde_json::from_value(_value)?)
4875 }
4876
4877 /// Gets durable and live observability detail for one factory run.
4878 ///
4879 /// Wire method: `session.factory.getRunDetail`.
4880 ///
4881 /// # Parameters
4882 ///
4883 /// * `params` - Parameters for retrieving a factory run.
4884 ///
4885 /// # Returns
4886 ///
4887 /// Full factory run observability detail.
4888 ///
4889 /// <div class="warning">
4890 ///
4891 /// **Experimental.** This API is part of an experimental wire-protocol surface
4892 /// and may change or be removed in future SDK or CLI releases. Pin both the
4893 /// SDK and CLI versions if your code depends on it.
4894 ///
4895 /// </div>
4896 pub async fn get_run_detail(
4897 &self,
4898 params: FactoryGetRunRequest,
4899 ) -> Result<FactoryRunDetail, Error> {
4900 let mut wire_params = serde_json::to_value(params)?;
4901 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4902 let _value = self
4903 .session
4904 .client()
4905 .call(rpc_methods::SESSION_FACTORY_GETRUNDETAIL, Some(wire_params))
4906 .await?;
4907 Ok(serde_json::from_value(_value)?)
4908 }
4909
4910 /// Pages durable progress for one factory run.
4911 ///
4912 /// Wire method: `session.factory.getRunProgress`.
4913 ///
4914 /// # Parameters
4915 ///
4916 /// * `params` - Parameters for paging factory progress.
4917 ///
4918 /// # Returns
4919 ///
4920 /// A bidirectional page of factory progress.
4921 ///
4922 /// <div class="warning">
4923 ///
4924 /// **Experimental.** This API is part of an experimental wire-protocol surface
4925 /// and may change or be removed in future SDK or CLI releases. Pin both the
4926 /// SDK and CLI versions if your code depends on it.
4927 ///
4928 /// </div>
4929 pub async fn get_run_progress(
4930 &self,
4931 params: FactoryGetRunProgressRequest,
4932 ) -> Result<FactoryProgressPage, Error> {
4933 let mut wire_params = serde_json::to_value(params)?;
4934 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4935 let _value = self
4936 .session
4937 .client()
4938 .call(
4939 rpc_methods::SESSION_FACTORY_GETRUNPROGRESS,
4940 Some(wire_params),
4941 )
4942 .await?;
4943 Ok(serde_json::from_value(_value)?)
4944 }
4945
4946 /// Requests cancellation of a factory run and returns its run envelope.
4947 ///
4948 /// Wire method: `session.factory.cancel`.
4949 ///
4950 /// # Parameters
4951 ///
4952 /// * `params` - Parameters for cancelling a factory run.
4953 ///
4954 /// # Returns
4955 ///
4956 /// Complete current or terminal factory run envelope.
4957 ///
4958 /// <div class="warning">
4959 ///
4960 /// **Experimental.** This API is part of an experimental wire-protocol surface
4961 /// and may change or be removed in future SDK or CLI releases. Pin both the
4962 /// SDK and CLI versions if your code depends on it.
4963 ///
4964 /// </div>
4965 pub async fn cancel(&self, params: FactoryCancelRequest) -> Result<FactoryRunResult, Error> {
4966 let mut wire_params = serde_json::to_value(params)?;
4967 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4968 let _value = self
4969 .session
4970 .client()
4971 .call(rpc_methods::SESSION_FACTORY_CANCEL, Some(wire_params))
4972 .await?;
4973 Ok(serde_json::from_value(_value)?)
4974 }
4975
4976 /// Records a batch of ordered factory progress lines.
4977 ///
4978 /// Wire method: `session.factory.log`.
4979 ///
4980 /// # Parameters
4981 ///
4982 /// * `params` - Parameters for recording factory progress.
4983 ///
4984 /// # Returns
4985 ///
4986 /// Acknowledgement that a factory request was accepted.
4987 ///
4988 /// <div class="warning">
4989 ///
4990 /// **Experimental.** This API is part of an experimental wire-protocol surface
4991 /// and may change or be removed in future SDK or CLI releases. Pin both the
4992 /// SDK and CLI versions if your code depends on it.
4993 ///
4994 /// </div>
4995 pub async fn log(&self, params: FactoryLogRequest) -> Result<FactoryAckResult, Error> {
4996 let mut wire_params = serde_json::to_value(params)?;
4997 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4998 let _value = self
4999 .session
5000 .client()
5001 .call(rpc_methods::SESSION_FACTORY_LOG, Some(wire_params))
5002 .await?;
5003 Ok(serde_json::from_value(_value)?)
5004 }
5005
5006 /// Runs one factory-scoped subagent and returns its result.
5007 ///
5008 /// Wire method: `session.factory.agent`.
5009 ///
5010 /// # Parameters
5011 ///
5012 /// * `params` - Parameters for one factory-scoped subagent call.
5013 ///
5014 /// # Returns
5015 ///
5016 /// Result of one factory-scoped subagent call.
5017 ///
5018 /// <div class="warning">
5019 ///
5020 /// **Experimental.** This API is part of an experimental wire-protocol surface
5021 /// and may change or be removed in future SDK or CLI releases. Pin both the
5022 /// SDK and CLI versions if your code depends on it.
5023 ///
5024 /// </div>
5025 pub async fn agent(&self, params: FactoryAgentRequest) -> Result<FactoryAgentResult, Error> {
5026 let mut wire_params = serde_json::to_value(params)?;
5027 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5028 let _value = self
5029 .session
5030 .client()
5031 .call(rpc_methods::SESSION_FACTORY_AGENT, Some(wire_params))
5032 .await?;
5033 Ok(serde_json::from_value(_value)?)
5034 }
5035}
5036
5037/// `session.factory.journal.*` RPCs.
5038#[derive(Clone, Copy)]
5039pub struct SessionRpcFactoryJournal<'a> {
5040 pub(crate) session: &'a Session,
5041}
5042
5043impl<'a> SessionRpcFactoryJournal<'a> {
5044 /// Reads a memoized factory journal entry.
5045 ///
5046 /// Wire method: `session.factory.journal.get`.
5047 ///
5048 /// # Parameters
5049 ///
5050 /// * `params` - Parameters for reading a factory journal entry.
5051 ///
5052 /// # Returns
5053 ///
5054 /// Result of reading a factory journal entry.
5055 ///
5056 /// <div class="warning">
5057 ///
5058 /// **Experimental.** This API is part of an experimental wire-protocol surface
5059 /// and may change or be removed in future SDK or CLI releases. Pin both the
5060 /// SDK and CLI versions if your code depends on it.
5061 ///
5062 /// </div>
5063 pub async fn get(
5064 &self,
5065 params: FactoryJournalGetRequest,
5066 ) -> Result<FactoryJournalGetResult, Error> {
5067 let mut wire_params = serde_json::to_value(params)?;
5068 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5069 let _value = self
5070 .session
5071 .client()
5072 .call(rpc_methods::SESSION_FACTORY_JOURNAL_GET, Some(wire_params))
5073 .await?;
5074 Ok(serde_json::from_value(_value)?)
5075 }
5076
5077 /// Stores a memoized factory journal entry.
5078 ///
5079 /// Wire method: `session.factory.journal.put`.
5080 ///
5081 /// # Parameters
5082 ///
5083 /// * `params` - Parameters for storing a factory journal entry.
5084 ///
5085 /// # Returns
5086 ///
5087 /// Acknowledgement that a factory request was accepted.
5088 ///
5089 /// <div class="warning">
5090 ///
5091 /// **Experimental.** This API is part of an experimental wire-protocol surface
5092 /// and may change or be removed in future SDK or CLI releases. Pin both the
5093 /// SDK and CLI versions if your code depends on it.
5094 ///
5095 /// </div>
5096 pub async fn put(&self, params: FactoryJournalPutRequest) -> Result<FactoryAckResult, Error> {
5097 let mut wire_params = serde_json::to_value(params)?;
5098 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5099 let _value = self
5100 .session
5101 .client()
5102 .call(rpc_methods::SESSION_FACTORY_JOURNAL_PUT, Some(wire_params))
5103 .await?;
5104 Ok(serde_json::from_value(_value)?)
5105 }
5106}
5107
5108/// `session.fleet.*` RPCs.
5109#[derive(Clone, Copy)]
5110pub struct SessionRpcFleet<'a> {
5111 pub(crate) session: &'a Session,
5112}
5113
5114impl<'a> SessionRpcFleet<'a> {
5115 /// Starts fleet mode by submitting the fleet orchestration prompt to the session.
5116 ///
5117 /// Wire method: `session.fleet.start`.
5118 ///
5119 /// # Parameters
5120 ///
5121 /// * `params` - Optional user prompt to combine with the fleet orchestration instructions.
5122 ///
5123 /// # Returns
5124 ///
5125 /// Indicates whether fleet mode was successfully activated.
5126 ///
5127 /// <div class="warning">
5128 ///
5129 /// **Experimental.** This API is part of an experimental wire-protocol surface
5130 /// and may change or be removed in future SDK or CLI releases. Pin both the
5131 /// SDK and CLI versions if your code depends on it.
5132 ///
5133 /// </div>
5134 pub async fn start(&self, params: FleetStartRequest) -> Result<FleetStartResult, Error> {
5135 let mut wire_params = serde_json::to_value(params)?;
5136 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5137 let _value = self
5138 .session
5139 .client()
5140 .call(rpc_methods::SESSION_FLEET_START, Some(wire_params))
5141 .await?;
5142 Ok(serde_json::from_value(_value)?)
5143 }
5144}
5145
5146/// `session.gitHubAuth.*` RPCs.
5147#[derive(Clone, Copy)]
5148pub struct SessionRpcGitHubAuth<'a> {
5149 pub(crate) session: &'a Session,
5150}
5151
5152impl<'a> SessionRpcGitHubAuth<'a> {
5153 /// Gets authentication status and account metadata for the session.
5154 ///
5155 /// Wire method: `session.gitHubAuth.getStatus`.
5156 ///
5157 /// # Returns
5158 ///
5159 /// Authentication status and account metadata for the session.
5160 ///
5161 /// <div class="warning">
5162 ///
5163 /// **Experimental.** This API is part of an experimental wire-protocol surface
5164 /// and may change or be removed in future SDK or CLI releases. Pin both the
5165 /// SDK and CLI versions if your code depends on it.
5166 ///
5167 /// </div>
5168 pub async fn get_status(&self) -> Result<SessionAuthStatus, Error> {
5169 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5170 let _value = self
5171 .session
5172 .client()
5173 .call(rpc_methods::SESSION_GITHUBAUTH_GETSTATUS, Some(wire_params))
5174 .await?;
5175 Ok(serde_json::from_value(_value)?)
5176 }
5177
5178 /// Updates the session's auth credentials used for outbound model and API requests.
5179 ///
5180 /// Wire method: `session.gitHubAuth.setCredentials`.
5181 ///
5182 /// # Parameters
5183 ///
5184 /// * `params` - New auth credentials to install on the session. Omit to leave credentials unchanged.
5185 ///
5186 /// # Returns
5187 ///
5188 /// Indicates whether the credential update succeeded.
5189 ///
5190 /// <div class="warning">
5191 ///
5192 /// **Experimental.** This API is part of an experimental wire-protocol surface
5193 /// and may change or be removed in future SDK or CLI releases. Pin both the
5194 /// SDK and CLI versions if your code depends on it.
5195 ///
5196 /// </div>
5197 pub async fn set_credentials(
5198 &self,
5199 params: SessionSetCredentialsParams,
5200 ) -> Result<SessionSetCredentialsResult, Error> {
5201 let mut wire_params = serde_json::to_value(params)?;
5202 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5203 let _value = self
5204 .session
5205 .client()
5206 .call(
5207 rpc_methods::SESSION_GITHUBAUTH_SETCREDENTIALS,
5208 Some(wire_params),
5209 )
5210 .await?;
5211 Ok(serde_json::from_value(_value)?)
5212 }
5213
5214 /// Gets the current authentication information for internal session hosts.
5215 ///
5216 /// Wire method: `session.gitHubAuth.getCurrentAuthInfo`.
5217 ///
5218 /// # Returns
5219 ///
5220 /// Current authentication information, or null when no authentication is active.
5221 ///
5222 /// <div class="warning">
5223 ///
5224 /// **Experimental.** This API is part of an experimental wire-protocol surface
5225 /// and may change or be removed in future SDK or CLI releases. Pin both the
5226 /// SDK and CLI versions if your code depends on it.
5227 ///
5228 /// </div>
5229 pub(crate) async fn get_current_auth_info(&self) -> Result<SessionAuthInfoResult, Error> {
5230 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5231 let _value = self
5232 .session
5233 .client()
5234 .call(
5235 rpc_methods::SESSION_GITHUBAUTH_GETCURRENTAUTHINFO,
5236 Some(wire_params),
5237 )
5238 .await?;
5239 Ok(serde_json::from_value(_value)?)
5240 }
5241
5242 /// Gets all authentication accounts available to the internal session host.
5243 ///
5244 /// Wire method: `session.gitHubAuth.getAllAuthAvailable`.
5245 ///
5246 /// # Returns
5247 ///
5248 /// Authentication accounts available to the internal session host.
5249 ///
5250 /// <div class="warning">
5251 ///
5252 /// **Experimental.** This API is part of an experimental wire-protocol surface
5253 /// and may change or be removed in future SDK or CLI releases. Pin both the
5254 /// SDK and CLI versions if your code depends on it.
5255 ///
5256 /// </div>
5257 pub(crate) async fn get_all_auth_available(
5258 &self,
5259 ) -> Result<SessionGitHubAuthGetAllAuthAvailableResult, Error> {
5260 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5261 let _value = self
5262 .session
5263 .client()
5264 .call(
5265 rpc_methods::SESSION_GITHUBAUTH_GETALLAUTHAVAILABLE,
5266 Some(wire_params),
5267 )
5268 .await?;
5269 Ok(serde_json::from_value(_value)?)
5270 }
5271
5272 /// Refreshes Copilot account metadata for the current authentication.
5273 ///
5274 /// Wire method: `session.gitHubAuth.refreshCopilotUser`.
5275 ///
5276 /// # Returns
5277 ///
5278 /// Current authentication information, or null when no authentication is active.
5279 ///
5280 /// <div class="warning">
5281 ///
5282 /// **Experimental.** This API is part of an experimental wire-protocol surface
5283 /// and may change or be removed in future SDK or CLI releases. Pin both the
5284 /// SDK and CLI versions if your code depends on it.
5285 ///
5286 /// </div>
5287 pub(crate) async fn refresh_copilot_user(&self) -> Result<SessionAuthInfoResult, Error> {
5288 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5289 let _value = self
5290 .session
5291 .client()
5292 .call(
5293 rpc_methods::SESSION_GITHUBAUTH_REFRESHCOPILOTUSER,
5294 Some(wire_params),
5295 )
5296 .await?;
5297 Ok(serde_json::from_value(_value)?)
5298 }
5299
5300 /// Logs in a GitHub user through the internal session host.
5301 ///
5302 /// Wire method: `session.gitHubAuth.login`.
5303 ///
5304 /// # Parameters
5305 ///
5306 /// * `params` - Internal GitHub login parameters.
5307 ///
5308 /// # Returns
5309 ///
5310 /// Authentication credentials accepted only at native protocol ingress. Runtime outputs use credential-free `AuthIdentity` metadata.
5311 ///
5312 /// <div class="warning">
5313 ///
5314 /// **Experimental.** This API is part of an experimental wire-protocol surface
5315 /// and may change or be removed in future SDK or CLI releases. Pin both the
5316 /// SDK and CLI versions if your code depends on it.
5317 ///
5318 /// </div>
5319 pub(crate) async fn login(&self, params: SessionAuthLoginRequest) -> Result<AuthInfo, Error> {
5320 let mut wire_params = serde_json::to_value(params)?;
5321 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5322 let _value = self
5323 .session
5324 .client()
5325 .call(rpc_methods::SESSION_GITHUBAUTH_LOGIN, Some(wire_params))
5326 .await?;
5327 Ok(serde_json::from_value(_value)?)
5328 }
5329
5330 /// Switches the session to another available authentication.
5331 ///
5332 /// Wire method: `session.gitHubAuth.switchToAuth`.
5333 ///
5334 /// # Parameters
5335 ///
5336 /// * `params` - Parameters for switching the session's active authentication.
5337 ///
5338 /// <div class="warning">
5339 ///
5340 /// **Experimental.** This API is part of an experimental wire-protocol surface
5341 /// and may change or be removed in future SDK or CLI releases. Pin both the
5342 /// SDK and CLI versions if your code depends on it.
5343 ///
5344 /// </div>
5345 pub(crate) async fn switch_to_auth(
5346 &self,
5347 params: SessionAuthSwitchRequest,
5348 ) -> Result<(), Error> {
5349 let mut wire_params = serde_json::to_value(params)?;
5350 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5351 let _value = self
5352 .session
5353 .client()
5354 .call(
5355 rpc_methods::SESSION_GITHUBAUTH_SWITCHTOAUTH,
5356 Some(wire_params),
5357 )
5358 .await?;
5359 Ok(())
5360 }
5361
5362 /// Logs out the session's current GitHub authentication.
5363 ///
5364 /// Wire method: `session.gitHubAuth.logout`.
5365 ///
5366 /// # Returns
5367 ///
5368 /// Whether the current authentication was logged out.
5369 ///
5370 /// <div class="warning">
5371 ///
5372 /// **Experimental.** This API is part of an experimental wire-protocol surface
5373 /// and may change or be removed in future SDK or CLI releases. Pin both the
5374 /// SDK and CLI versions if your code depends on it.
5375 ///
5376 /// </div>
5377 pub(crate) async fn logout(&self) -> Result<SessionGitHubAuthLogoutResult, Error> {
5378 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5379 let _value = self
5380 .session
5381 .client()
5382 .call(rpc_methods::SESSION_GITHUBAUTH_LOGOUT, Some(wire_params))
5383 .await?;
5384 Ok(serde_json::from_value(_value)?)
5385 }
5386
5387 /// Logs out a specific GitHub authentication.
5388 ///
5389 /// Wire method: `session.gitHubAuth.logoutUser`.
5390 ///
5391 /// # Parameters
5392 ///
5393 /// * `params` - Parameters identifying a GitHub authentication to log out.
5394 ///
5395 /// # Returns
5396 ///
5397 /// Whether the requested authentication was logged out.
5398 ///
5399 /// <div class="warning">
5400 ///
5401 /// **Experimental.** This API is part of an experimental wire-protocol surface
5402 /// and may change or be removed in future SDK or CLI releases. Pin both the
5403 /// SDK and CLI versions if your code depends on it.
5404 ///
5405 /// </div>
5406 pub(crate) async fn logout_user(
5407 &self,
5408 params: SessionAuthLogoutUserRequest,
5409 ) -> Result<SessionGitHubAuthLogoutUserResult, Error> {
5410 let mut wire_params = serde_json::to_value(params)?;
5411 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5412 let _value = self
5413 .session
5414 .client()
5415 .call(
5416 rpc_methods::SESSION_GITHUBAUTH_LOGOUTUSER,
5417 Some(wire_params),
5418 )
5419 .await?;
5420 Ok(serde_json::from_value(_value)?)
5421 }
5422
5423 /// Gets validation errors from the most recent authentication attempt.
5424 ///
5425 /// Wire method: `session.gitHubAuth.lastAuthErrors`.
5426 ///
5427 /// # Returns
5428 ///
5429 /// Validation errors from the most recent authentication attempt.
5430 ///
5431 /// <div class="warning">
5432 ///
5433 /// **Experimental.** This API is part of an experimental wire-protocol surface
5434 /// and may change or be removed in future SDK or CLI releases. Pin both the
5435 /// SDK and CLI versions if your code depends on it.
5436 ///
5437 /// </div>
5438 pub(crate) async fn last_auth_errors(&self) -> Result<AuthValidationErrors, Error> {
5439 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5440 let _value = self
5441 .session
5442 .client()
5443 .call(
5444 rpc_methods::SESSION_GITHUBAUTH_LASTAUTHERRORS,
5445 Some(wire_params),
5446 )
5447 .await?;
5448 Ok(serde_json::from_value(_value)?)
5449 }
5450}
5451
5452/// `session.history.*` RPCs.
5453#[derive(Clone, Copy)]
5454pub struct SessionRpcHistory<'a> {
5455 pub(crate) session: &'a Session,
5456}
5457
5458impl<'a> SessionRpcHistory<'a> {
5459 /// Compacts the session history to reduce context usage.
5460 ///
5461 /// Wire method: `session.history.compact`.
5462 ///
5463 /// # Returns
5464 ///
5465 /// Compaction outcome with the number of tokens and messages removed, summary text, and the resulting context window breakdown.
5466 ///
5467 /// <div class="warning">
5468 ///
5469 /// **Experimental.** This API is part of an experimental wire-protocol surface
5470 /// and may change or be removed in future SDK or CLI releases. Pin both the
5471 /// SDK and CLI versions if your code depends on it.
5472 ///
5473 /// </div>
5474 pub async fn compact(&self) -> Result<HistoryCompactResult, Error> {
5475 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5476 let _value = self
5477 .session
5478 .client()
5479 .call(rpc_methods::SESSION_HISTORY_COMPACT, Some(wire_params))
5480 .await?;
5481 Ok(serde_json::from_value(_value)?)
5482 }
5483
5484 /// Compacts the session history to reduce context usage.
5485 ///
5486 /// Wire method: `session.history.compact`.
5487 ///
5488 /// # Parameters
5489 ///
5490 /// * `params` - Optional compaction parameters.
5491 ///
5492 /// # Returns
5493 ///
5494 /// Compaction outcome with the number of tokens and messages removed, summary text, and the resulting context window breakdown.
5495 ///
5496 /// <div class="warning">
5497 ///
5498 /// **Experimental.** This API is part of an experimental wire-protocol surface
5499 /// and may change or be removed in future SDK or CLI releases. Pin both the
5500 /// SDK and CLI versions if your code depends on it.
5501 ///
5502 /// </div>
5503 pub async fn compact_with_params(
5504 &self,
5505 params: HistoryCompactRequest,
5506 ) -> Result<HistoryCompactResult, Error> {
5507 let mut wire_params = serde_json::to_value(params)?;
5508 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5509 let _value = self
5510 .session
5511 .client()
5512 .call(rpc_methods::SESSION_HISTORY_COMPACT, Some(wire_params))
5513 .await?;
5514 Ok(serde_json::from_value(_value)?)
5515 }
5516
5517 /// Truncates persisted session history to a specific event.
5518 ///
5519 /// Wire method: `session.history.truncate`.
5520 ///
5521 /// # Parameters
5522 ///
5523 /// * `params` - Identifier of the event to truncate to; this event and all later events are removed.
5524 ///
5525 /// # Returns
5526 ///
5527 /// Number of events that were removed by the truncation.
5528 ///
5529 /// <div class="warning">
5530 ///
5531 /// **Experimental.** This API is part of an experimental wire-protocol surface
5532 /// and may change or be removed in future SDK or CLI releases. Pin both the
5533 /// SDK and CLI versions if your code depends on it.
5534 ///
5535 /// </div>
5536 pub async fn truncate(
5537 &self,
5538 params: HistoryTruncateRequest,
5539 ) -> Result<HistoryTruncateResult, Error> {
5540 let mut wire_params = serde_json::to_value(params)?;
5541 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5542 let _value = self
5543 .session
5544 .client()
5545 .call(rpc_methods::SESSION_HISTORY_TRUNCATE, Some(wire_params))
5546 .await?;
5547 Ok(serde_json::from_value(_value)?)
5548 }
5549
5550 /// 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.
5551 ///
5552 /// Wire method: `session.history.listRewindPoints`.
5553 ///
5554 /// # Returns
5555 ///
5556 /// Rewind points and file-change-tracking availability for the session.
5557 ///
5558 /// <div class="warning">
5559 ///
5560 /// **Experimental.** This API is part of an experimental wire-protocol surface
5561 /// and may change or be removed in future SDK or CLI releases. Pin both the
5562 /// SDK and CLI versions if your code depends on it.
5563 ///
5564 /// </div>
5565 pub async fn list_rewind_points(&self) -> Result<HistoryListRewindPointsResult, Error> {
5566 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5567 let _value = self
5568 .session
5569 .client()
5570 .call(
5571 rpc_methods::SESSION_HISTORY_LISTREWINDPOINTS,
5572 Some(wire_params),
5573 )
5574 .await?;
5575 Ok(serde_json::from_value(_value)?)
5576 }
5577
5578 /// Previews the files that a conversation-and-files rewind would restore.
5579 ///
5580 /// Wire method: `session.history.previewRewind`.
5581 ///
5582 /// # Parameters
5583 ///
5584 /// * `params` - Event boundary to preview for conversation-and-files rewind.
5585 ///
5586 /// # Returns
5587 ///
5588 /// Files and aggregate changes for a prospective rewind.
5589 ///
5590 /// <div class="warning">
5591 ///
5592 /// **Experimental.** This API is part of an experimental wire-protocol surface
5593 /// and may change or be removed in future SDK or CLI releases. Pin both the
5594 /// SDK and CLI versions if your code depends on it.
5595 ///
5596 /// </div>
5597 pub async fn preview_rewind(
5598 &self,
5599 params: HistoryPreviewRewindRequest,
5600 ) -> Result<HistoryPreviewRewindResult, Error> {
5601 let mut wire_params = serde_json::to_value(params)?;
5602 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5603 let _value = self
5604 .session
5605 .client()
5606 .call(
5607 rpc_methods::SESSION_HISTORY_PREVIEWREWIND,
5608 Some(wire_params),
5609 )
5610 .await?;
5611 Ok(serde_json::from_value(_value)?)
5612 }
5613
5614 /// 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.
5615 ///
5616 /// Wire method: `session.history.rewind`.
5617 ///
5618 /// # Parameters
5619 ///
5620 /// * `params` - Boundary and mode for rewinding session history.
5621 ///
5622 /// # Returns
5623 ///
5624 /// Structured outcome of a rewind request.
5625 ///
5626 /// <div class="warning">
5627 ///
5628 /// **Experimental.** This API is part of an experimental wire-protocol surface
5629 /// and may change or be removed in future SDK or CLI releases. Pin both the
5630 /// SDK and CLI versions if your code depends on it.
5631 ///
5632 /// </div>
5633 pub async fn rewind(&self, params: HistoryRewindRequest) -> Result<HistoryRewindResult, Error> {
5634 let mut wire_params = serde_json::to_value(params)?;
5635 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5636 let _value = self
5637 .session
5638 .client()
5639 .call(rpc_methods::SESSION_HISTORY_REWIND, Some(wire_params))
5640 .await?;
5641 Ok(serde_json::from_value(_value)?)
5642 }
5643
5644 /// Cancels any in-progress background compaction on a local session.
5645 ///
5646 /// Wire method: `session.history.cancelBackgroundCompaction`.
5647 ///
5648 /// # Returns
5649 ///
5650 /// Indicates whether an in-progress background compaction was cancelled.
5651 ///
5652 /// <div class="warning">
5653 ///
5654 /// **Experimental.** This API is part of an experimental wire-protocol surface
5655 /// and may change or be removed in future SDK or CLI releases. Pin both the
5656 /// SDK and CLI versions if your code depends on it.
5657 ///
5658 /// </div>
5659 pub async fn cancel_background_compaction(
5660 &self,
5661 ) -> Result<HistoryCancelBackgroundCompactionResult, Error> {
5662 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5663 let _value = self
5664 .session
5665 .client()
5666 .call(
5667 rpc_methods::SESSION_HISTORY_CANCELBACKGROUNDCOMPACTION,
5668 Some(wire_params),
5669 )
5670 .await?;
5671 Ok(serde_json::from_value(_value)?)
5672 }
5673
5674 /// Aborts any in-progress manual compaction on a local session.
5675 ///
5676 /// Wire method: `session.history.abortManualCompaction`.
5677 ///
5678 /// # Returns
5679 ///
5680 /// Indicates whether an in-progress manual compaction was aborted.
5681 ///
5682 /// <div class="warning">
5683 ///
5684 /// **Experimental.** This API is part of an experimental wire-protocol surface
5685 /// and may change or be removed in future SDK or CLI releases. Pin both the
5686 /// SDK and CLI versions if your code depends on it.
5687 ///
5688 /// </div>
5689 pub async fn abort_manual_compaction(
5690 &self,
5691 ) -> Result<HistoryAbortManualCompactionResult, Error> {
5692 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5693 let _value = self
5694 .session
5695 .client()
5696 .call(
5697 rpc_methods::SESSION_HISTORY_ABORTMANUALCOMPACTION,
5698 Some(wire_params),
5699 )
5700 .await?;
5701 Ok(serde_json::from_value(_value)?)
5702 }
5703
5704 /// Produces a markdown summary of the session's conversation context for hand-off scenarios.
5705 ///
5706 /// Wire method: `session.history.summarizeForHandoff`.
5707 ///
5708 /// # Returns
5709 ///
5710 /// Markdown summary of the conversation context (empty when not available).
5711 ///
5712 /// <div class="warning">
5713 ///
5714 /// **Experimental.** This API is part of an experimental wire-protocol surface
5715 /// and may change or be removed in future SDK or CLI releases. Pin both the
5716 /// SDK and CLI versions if your code depends on it.
5717 ///
5718 /// </div>
5719 pub async fn summarize_for_handoff(&self) -> Result<HistorySummarizeForHandoffResult, Error> {
5720 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5721 let _value = self
5722 .session
5723 .client()
5724 .call(
5725 rpc_methods::SESSION_HISTORY_SUMMARIZEFORHANDOFF,
5726 Some(wire_params),
5727 )
5728 .await?;
5729 Ok(serde_json::from_value(_value)?)
5730 }
5731
5732 /// 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.
5733 ///
5734 /// Wire method: `session.history.clearContext`.
5735 ///
5736 /// # Parameters
5737 ///
5738 /// * `params` - Parameters for clearing the conversation and seeding the window that replaces it.
5739 ///
5740 /// # Returns
5741 ///
5742 /// What a successful clear removed. A clear that could not be applied rejects instead of reporting a count.
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 async fn clear_context(
5752 &self,
5753 params: HistoryClearContextRequest,
5754 ) -> Result<HistoryClearContextResult, 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(rpc_methods::SESSION_HISTORY_CLEARCONTEXT, Some(wire_params))
5761 .await?;
5762 Ok(serde_json::from_value(_value)?)
5763 }
5764}
5765
5766/// `session.instructions.*` RPCs.
5767#[derive(Clone, Copy)]
5768pub struct SessionRpcInstructions<'a> {
5769 pub(crate) session: &'a Session,
5770}
5771
5772impl<'a> SessionRpcInstructions<'a> {
5773 /// Gets instruction sources loaded for the session.
5774 ///
5775 /// Wire method: `session.instructions.getSources`.
5776 ///
5777 /// # Returns
5778 ///
5779 /// Instruction sources loaded for the session, in merge order.
5780 ///
5781 /// <div class="warning">
5782 ///
5783 /// **Experimental.** This API is part of an experimental wire-protocol surface
5784 /// and may change or be removed in future SDK or CLI releases. Pin both the
5785 /// SDK and CLI versions if your code depends on it.
5786 ///
5787 /// </div>
5788 pub async fn get_sources(&self) -> Result<InstructionsGetSourcesResult, Error> {
5789 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5790 let _value = self
5791 .session
5792 .client()
5793 .call(
5794 rpc_methods::SESSION_INSTRUCTIONS_GETSOURCES,
5795 Some(wire_params),
5796 )
5797 .await?;
5798 Ok(serde_json::from_value(_value)?)
5799 }
5800}
5801
5802/// `session.limitPrediction.*` RPCs.
5803#[derive(Clone, Copy)]
5804pub struct SessionRpcLimitPrediction<'a> {
5805 pub(crate) session: &'a Session,
5806}
5807
5808impl<'a> SessionRpcLimitPrediction<'a> {
5809 /// 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.
5810 ///
5811 /// Wire method: `session.limitPrediction.predict`.
5812 ///
5813 /// # Returns
5814 ///
5815 /// Prediction result. Available results include prediction details; unavailable results include an explicit reason.
5816 ///
5817 /// <div class="warning">
5818 ///
5819 /// **Experimental.** This API is part of an experimental wire-protocol surface
5820 /// and may change or be removed in future SDK or CLI releases. Pin both the
5821 /// SDK and CLI versions if your code depends on it.
5822 ///
5823 /// </div>
5824 pub async fn predict(&self) -> Result<SessionLimitPredictionResult, Error> {
5825 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5826 let _value = self
5827 .session
5828 .client()
5829 .call(
5830 rpc_methods::SESSION_LIMITPREDICTION_PREDICT,
5831 Some(wire_params),
5832 )
5833 .await?;
5834 Ok(serde_json::from_value(_value)?)
5835 }
5836
5837 /// 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.
5838 ///
5839 /// Wire method: `session.limitPrediction.predict`.
5840 ///
5841 /// # Parameters
5842 ///
5843 /// * `params` - Parameters for predicting an AI-credit session limit. Omitting `modelId` uses the session's currently selected model.
5844 ///
5845 /// # Returns
5846 ///
5847 /// Prediction result. Available results include prediction details; unavailable results include an explicit reason.
5848 ///
5849 /// <div class="warning">
5850 ///
5851 /// **Experimental.** This API is part of an experimental wire-protocol surface
5852 /// and may change or be removed in future SDK or CLI releases. Pin both the
5853 /// SDK and CLI versions if your code depends on it.
5854 ///
5855 /// </div>
5856 pub async fn predict_with_params(
5857 &self,
5858 params: SessionLimitPredictionRequest,
5859 ) -> Result<SessionLimitPredictionResult, Error> {
5860 let mut wire_params = serde_json::to_value(params)?;
5861 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5862 let _value = self
5863 .session
5864 .client()
5865 .call(
5866 rpc_methods::SESSION_LIMITPREDICTION_PREDICT,
5867 Some(wire_params),
5868 )
5869 .await?;
5870 Ok(serde_json::from_value(_value)?)
5871 }
5872}
5873
5874/// `session.lsp.*` RPCs.
5875#[derive(Clone, Copy)]
5876pub struct SessionRpcLsp<'a> {
5877 pub(crate) session: &'a Session,
5878}
5879
5880impl<'a> SessionRpcLsp<'a> {
5881 /// Loads the merged LSP configuration set for the session's working directory.
5882 ///
5883 /// Wire method: `session.lsp.initialize`.
5884 ///
5885 /// # Parameters
5886 ///
5887 /// * `params` - Parameters for (re)loading the merged LSP configuration set.
5888 ///
5889 /// <div class="warning">
5890 ///
5891 /// **Experimental.** This API is part of an experimental wire-protocol surface
5892 /// and may change or be removed in future SDK or CLI releases. Pin both the
5893 /// SDK and CLI versions if your code depends on it.
5894 ///
5895 /// </div>
5896 pub async fn initialize(&self, params: LspInitializeRequest) -> Result<(), Error> {
5897 let mut wire_params = serde_json::to_value(params)?;
5898 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5899 let _value = self
5900 .session
5901 .client()
5902 .call(rpc_methods::SESSION_LSP_INITIALIZE, Some(wire_params))
5903 .await?;
5904 Ok(())
5905 }
5906}
5907
5908/// `session.mcp.*` RPCs.
5909#[derive(Clone, Copy)]
5910pub struct SessionRpcMcp<'a> {
5911 pub(crate) session: &'a Session,
5912}
5913
5914impl<'a> SessionRpcMcp<'a> {
5915 /// `session.mcp.apps.*` sub-namespace.
5916 pub fn apps(&self) -> SessionRpcMcpApps<'a> {
5917 SessionRpcMcpApps {
5918 session: self.session,
5919 }
5920 }
5921
5922 /// `session.mcp.headers.*` sub-namespace.
5923 pub fn headers(&self) -> SessionRpcMcpHeaders<'a> {
5924 SessionRpcMcpHeaders {
5925 session: self.session,
5926 }
5927 }
5928
5929 /// `session.mcp.oauth.*` sub-namespace.
5930 pub fn oauth(&self) -> SessionRpcMcpOauth<'a> {
5931 SessionRpcMcpOauth {
5932 session: self.session,
5933 }
5934 }
5935
5936 /// `session.mcp.resources.*` sub-namespace.
5937 pub fn resources(&self) -> SessionRpcMcpResources<'a> {
5938 SessionRpcMcpResources {
5939 session: self.session,
5940 }
5941 }
5942
5943 /// 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.
5944 ///
5945 /// Wire method: `session.mcp.list`.
5946 ///
5947 /// # Returns
5948 ///
5949 /// MCP servers configured for the session, with their connection status and host-level state.
5950 ///
5951 /// <div class="warning">
5952 ///
5953 /// **Experimental.** This API is part of an experimental wire-protocol surface
5954 /// and may change or be removed in future SDK or CLI releases. Pin both the
5955 /// SDK and CLI versions if your code depends on it.
5956 ///
5957 /// </div>
5958 pub async fn list(&self) -> Result<McpServerList, Error> {
5959 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5960 let _value = self
5961 .session
5962 .client()
5963 .call(rpc_methods::SESSION_MCP_LIST, Some(wire_params))
5964 .await?;
5965 Ok(serde_json::from_value(_value)?)
5966 }
5967
5968 /// 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.
5969 ///
5970 /// Wire method: `session.mcp.listTools`.
5971 ///
5972 /// # Parameters
5973 ///
5974 /// * `params` - Server name whose tool list should be returned.
5975 ///
5976 /// # Returns
5977 ///
5978 /// Tools exposed by the connected MCP server. Throws when the server is not connected.
5979 ///
5980 /// <div class="warning">
5981 ///
5982 /// **Experimental.** This API is part of an experimental wire-protocol surface
5983 /// and may change or be removed in future SDK or CLI releases. Pin both the
5984 /// SDK and CLI versions if your code depends on it.
5985 ///
5986 /// </div>
5987 pub async fn list_tools(
5988 &self,
5989 params: McpListToolsRequest,
5990 ) -> Result<McpListToolsResult, Error> {
5991 let mut wire_params = serde_json::to_value(params)?;
5992 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5993 let _value = self
5994 .session
5995 .client()
5996 .call(rpc_methods::SESSION_MCP_LISTTOOLS, Some(wire_params))
5997 .await?;
5998 Ok(serde_json::from_value(_value)?)
5999 }
6000
6001 /// Enables an MCP server for the session.
6002 ///
6003 /// Wire method: `session.mcp.enable`.
6004 ///
6005 /// # Parameters
6006 ///
6007 /// * `params` - Name of the MCP server to enable for the session.
6008 ///
6009 /// <div class="warning">
6010 ///
6011 /// **Experimental.** This API is part of an experimental wire-protocol surface
6012 /// and may change or be removed in future SDK or CLI releases. Pin both the
6013 /// SDK and CLI versions if your code depends on it.
6014 ///
6015 /// </div>
6016 pub async fn enable(&self, params: McpEnableRequest) -> Result<(), Error> {
6017 let mut wire_params = serde_json::to_value(params)?;
6018 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6019 let _value = self
6020 .session
6021 .client()
6022 .call(rpc_methods::SESSION_MCP_ENABLE, Some(wire_params))
6023 .await?;
6024 Ok(())
6025 }
6026
6027 /// Disables an MCP server for the session.
6028 ///
6029 /// Wire method: `session.mcp.disable`.
6030 ///
6031 /// # Parameters
6032 ///
6033 /// * `params` - Name of the MCP server to disable for the session.
6034 ///
6035 /// <div class="warning">
6036 ///
6037 /// **Experimental.** This API is part of an experimental wire-protocol surface
6038 /// and may change or be removed in future SDK or CLI releases. Pin both the
6039 /// SDK and CLI versions if your code depends on it.
6040 ///
6041 /// </div>
6042 pub async fn disable(&self, params: McpDisableRequest) -> Result<(), Error> {
6043 let mut wire_params = serde_json::to_value(params)?;
6044 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6045 let _value = self
6046 .session
6047 .client()
6048 .call(rpc_methods::SESSION_MCP_DISABLE, Some(wire_params))
6049 .await?;
6050 Ok(())
6051 }
6052
6053 /// Reloads MCP server connections for the session.
6054 ///
6055 /// Wire method: `session.mcp.reload`.
6056 ///
6057 /// <div class="warning">
6058 ///
6059 /// **Experimental.** This API is part of an experimental wire-protocol surface
6060 /// and may change or be removed in future SDK or CLI releases. Pin both the
6061 /// SDK and CLI versions if your code depends on it.
6062 ///
6063 /// </div>
6064 pub async fn reload(&self) -> Result<(), Error> {
6065 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6066 let _value = self
6067 .session
6068 .client()
6069 .call(rpc_methods::SESSION_MCP_RELOAD, Some(wire_params))
6070 .await?;
6071 Ok(())
6072 }
6073
6074 /// 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.
6075 ///
6076 /// Wire method: `session.mcp.moveLoadingToBackground`.
6077 ///
6078 /// # Returns
6079 ///
6080 /// Result of moving in-flight MCP loading to the background.
6081 ///
6082 /// <div class="warning">
6083 ///
6084 /// **Experimental.** This API is part of an experimental wire-protocol surface
6085 /// and may change or be removed in future SDK or CLI releases. Pin both the
6086 /// SDK and CLI versions if your code depends on it.
6087 ///
6088 /// </div>
6089 pub async fn move_loading_to_background(
6090 &self,
6091 ) -> Result<MoveMcpLoadingToBackgroundResult, Error> {
6092 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6093 let _value = self
6094 .session
6095 .client()
6096 .call(
6097 rpc_methods::SESSION_MCP_MOVELOADINGTOBACKGROUND,
6098 Some(wire_params),
6099 )
6100 .await?;
6101 Ok(serde_json::from_value(_value)?)
6102 }
6103
6104 /// Reloads MCP server connections for the session with an explicit host-provided configuration.
6105 ///
6106 /// Wire method: `session.mcp.reloadWithConfig`.
6107 ///
6108 /// # Parameters
6109 ///
6110 /// * `params` - Opaque MCP reload configuration.
6111 ///
6112 /// # Returns
6113 ///
6114 /// MCP server startup filtering result.
6115 ///
6116 /// <div class="warning">
6117 ///
6118 /// **Experimental.** This API is part of an experimental wire-protocol surface
6119 /// and may change or be removed in future SDK or CLI releases. Pin both the
6120 /// SDK and CLI versions if your code depends on it.
6121 ///
6122 /// </div>
6123 pub(crate) async fn reload_with_config(
6124 &self,
6125 params: McpReloadWithConfigRequest,
6126 ) -> Result<McpStartServersResult, Error> {
6127 let mut wire_params = serde_json::to_value(params)?;
6128 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6129 let _value = self
6130 .session
6131 .client()
6132 .call(rpc_methods::SESSION_MCP_RELOADWITHCONFIG, Some(wire_params))
6133 .await?;
6134 Ok(serde_json::from_value(_value)?)
6135 }
6136
6137 /// Runs an MCP sampling inference on behalf of an MCP server.
6138 ///
6139 /// Wire method: `session.mcp.executeSampling`.
6140 ///
6141 /// # Parameters
6142 ///
6143 /// * `params` - Identifiers and raw MCP CreateMessageRequest params used to run a sampling inference.
6144 ///
6145 /// # Returns
6146 ///
6147 /// Outcome of an MCP sampling execution: success result, failure error, or cancellation.
6148 ///
6149 /// <div class="warning">
6150 ///
6151 /// **Experimental.** This API is part of an experimental wire-protocol surface
6152 /// and may change or be removed in future SDK or CLI releases. Pin both the
6153 /// SDK and CLI versions if your code depends on it.
6154 ///
6155 /// </div>
6156 pub async fn execute_sampling(
6157 &self,
6158 params: McpExecuteSamplingParams,
6159 ) -> Result<McpSamplingExecutionResult, Error> {
6160 let mut wire_params = serde_json::to_value(params)?;
6161 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6162 let _value = self
6163 .session
6164 .client()
6165 .call(rpc_methods::SESSION_MCP_EXECUTESAMPLING, Some(wire_params))
6166 .await?;
6167 Ok(serde_json::from_value(_value)?)
6168 }
6169
6170 /// Cancels an in-flight MCP sampling execution by request ID.
6171 ///
6172 /// Wire method: `session.mcp.cancelSamplingExecution`.
6173 ///
6174 /// # Parameters
6175 ///
6176 /// * `params` - The requestId previously passed to executeSampling that should be cancelled.
6177 ///
6178 /// # Returns
6179 ///
6180 /// Indicates whether an in-flight sampling execution with the given requestId was found and cancelled.
6181 ///
6182 /// <div class="warning">
6183 ///
6184 /// **Experimental.** This API is part of an experimental wire-protocol surface
6185 /// and may change or be removed in future SDK or CLI releases. Pin both the
6186 /// SDK and CLI versions if your code depends on it.
6187 ///
6188 /// </div>
6189 pub async fn cancel_sampling_execution(
6190 &self,
6191 params: McpCancelSamplingExecutionParams,
6192 ) -> Result<McpCancelSamplingExecutionResult, Error> {
6193 let mut wire_params = serde_json::to_value(params)?;
6194 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6195 let _value = self
6196 .session
6197 .client()
6198 .call(
6199 rpc_methods::SESSION_MCP_CANCELSAMPLINGEXECUTION,
6200 Some(wire_params),
6201 )
6202 .await?;
6203 Ok(serde_json::from_value(_value)?)
6204 }
6205
6206 /// Sets how environment-variable values supplied to MCP servers are resolved (direct or indirect).
6207 ///
6208 /// Wire method: `session.mcp.setEnvValueMode`.
6209 ///
6210 /// # Parameters
6211 ///
6212 /// * `params` - Mode controlling how MCP server env values are resolved (`direct` or `indirect`).
6213 ///
6214 /// # Returns
6215 ///
6216 /// Env-value mode recorded on the session after the update.
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 set_env_value_mode(
6226 &self,
6227 params: McpSetEnvValueModeParams,
6228 ) -> Result<McpSetEnvValueModeResult, Error> {
6229 let mut wire_params = serde_json::to_value(params)?;
6230 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6231 let _value = self
6232 .session
6233 .client()
6234 .call(rpc_methods::SESSION_MCP_SETENVVALUEMODE, Some(wire_params))
6235 .await?;
6236 Ok(serde_json::from_value(_value)?)
6237 }
6238
6239 /// Removes the auto-managed `github` MCP server when present.
6240 ///
6241 /// Wire method: `session.mcp.removeGitHub`.
6242 ///
6243 /// # Returns
6244 ///
6245 /// Indicates whether the auto-managed `github` MCP server was removed (false when nothing to remove).
6246 ///
6247 /// <div class="warning">
6248 ///
6249 /// **Experimental.** This API is part of an experimental wire-protocol surface
6250 /// and may change or be removed in future SDK or CLI releases. Pin both the
6251 /// SDK and CLI versions if your code depends on it.
6252 ///
6253 /// </div>
6254 pub async fn remove_git_hub(&self) -> Result<McpRemoveGitHubResult, Error> {
6255 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6256 let _value = self
6257 .session
6258 .client()
6259 .call(rpc_methods::SESSION_MCP_REMOVEGITHUB, Some(wire_params))
6260 .await?;
6261 Ok(serde_json::from_value(_value)?)
6262 }
6263
6264 /// Configures the built-in GitHub MCP server for the session's current auth context.
6265 ///
6266 /// Wire method: `session.mcp.configureGitHub`.
6267 ///
6268 /// # Parameters
6269 ///
6270 /// * `params` - Credential-free authentication identity used to configure GitHub MCP.
6271 ///
6272 /// # Returns
6273 ///
6274 /// Result of configuring GitHub MCP.
6275 ///
6276 /// <div class="warning">
6277 ///
6278 /// **Experimental.** This API is part of an experimental wire-protocol surface
6279 /// and may change or be removed in future SDK or CLI releases. Pin both the
6280 /// SDK and CLI versions if your code depends on it.
6281 ///
6282 /// </div>
6283 pub(crate) async fn configure_git_hub(
6284 &self,
6285 params: McpConfigureGitHubRequest,
6286 ) -> Result<McpConfigureGitHubResult, Error> {
6287 let mut wire_params = serde_json::to_value(params)?;
6288 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6289 let _value = self
6290 .session
6291 .client()
6292 .call(rpc_methods::SESSION_MCP_CONFIGUREGITHUB, Some(wire_params))
6293 .await?;
6294 Ok(serde_json::from_value(_value)?)
6295 }
6296
6297 /// 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.
6298 ///
6299 /// Wire method: `session.mcp.startServer`.
6300 ///
6301 /// # Parameters
6302 ///
6303 /// * `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.
6304 ///
6305 /// <div class="warning">
6306 ///
6307 /// **Experimental.** This API is part of an experimental wire-protocol surface
6308 /// and may change or be removed in future SDK or CLI releases. Pin both the
6309 /// SDK and CLI versions if your code depends on it.
6310 ///
6311 /// </div>
6312 pub async fn start_server(&self, params: McpStartServerRequest) -> Result<(), Error> {
6313 let mut wire_params = serde_json::to_value(params)?;
6314 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6315 let _value = self
6316 .session
6317 .client()
6318 .call(rpc_methods::SESSION_MCP_STARTSERVER, Some(wire_params))
6319 .await?;
6320 Ok(())
6321 }
6322
6323 /// 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.*`).
6324 ///
6325 /// Wire method: `session.mcp.restartServer`.
6326 ///
6327 /// # Parameters
6328 ///
6329 /// * `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.
6330 ///
6331 /// <div class="warning">
6332 ///
6333 /// **Experimental.** This API is part of an experimental wire-protocol surface
6334 /// and may change or be removed in future SDK or CLI releases. Pin both the
6335 /// SDK and CLI versions if your code depends on it.
6336 ///
6337 /// </div>
6338 pub async fn restart_server(&self, params: McpRestartServerRequest) -> Result<(), Error> {
6339 let mut wire_params = serde_json::to_value(params)?;
6340 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6341 let _value = self
6342 .session
6343 .client()
6344 .call(rpc_methods::SESSION_MCP_RESTARTSERVER, Some(wire_params))
6345 .await?;
6346 Ok(())
6347 }
6348
6349 /// Stops an individual MCP server on the session's host.
6350 ///
6351 /// Wire method: `session.mcp.stopServer`.
6352 ///
6353 /// # Parameters
6354 ///
6355 /// * `params` - Server name for an individual MCP server stop.
6356 ///
6357 /// <div class="warning">
6358 ///
6359 /// **Experimental.** This API is part of an experimental wire-protocol surface
6360 /// and may change or be removed in future SDK or CLI releases. Pin both the
6361 /// SDK and CLI versions if your code depends on it.
6362 ///
6363 /// </div>
6364 pub async fn stop_server(&self, params: McpStopServerRequest) -> Result<(), Error> {
6365 let mut wire_params = serde_json::to_value(params)?;
6366 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6367 let _value = self
6368 .session
6369 .client()
6370 .call(rpc_methods::SESSION_MCP_STOPSERVER, Some(wire_params))
6371 .await?;
6372 Ok(())
6373 }
6374
6375 /// 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.
6376 ///
6377 /// Wire method: `session.mcp.registerExternalClient`.
6378 ///
6379 /// # Parameters
6380 ///
6381 /// * `params` - Registration parameters for an external MCP client.
6382 ///
6383 /// <div class="warning">
6384 ///
6385 /// **Experimental.** This API is part of an experimental wire-protocol surface
6386 /// and may change or be removed in future SDK or CLI releases. Pin both the
6387 /// SDK and CLI versions if your code depends on it.
6388 ///
6389 /// </div>
6390 pub(crate) async fn register_external_client(
6391 &self,
6392 params: McpRegisterExternalClientRequest,
6393 ) -> Result<(), Error> {
6394 let mut wire_params = serde_json::to_value(params)?;
6395 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6396 let _value = self
6397 .session
6398 .client()
6399 .call(
6400 rpc_methods::SESSION_MCP_REGISTEREXTERNALCLIENT,
6401 Some(wire_params),
6402 )
6403 .await?;
6404 Ok(())
6405 }
6406
6407 /// 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.
6408 ///
6409 /// Wire method: `session.mcp.unregisterExternalClient`.
6410 ///
6411 /// # Parameters
6412 ///
6413 /// * `params` - Server name identifying the external client to remove.
6414 ///
6415 /// <div class="warning">
6416 ///
6417 /// **Experimental.** This API is part of an experimental wire-protocol surface
6418 /// and may change or be removed in future SDK or CLI releases. Pin both the
6419 /// SDK and CLI versions if your code depends on it.
6420 ///
6421 /// </div>
6422 pub(crate) async fn unregister_external_client(
6423 &self,
6424 params: McpUnregisterExternalClientRequest,
6425 ) -> Result<(), Error> {
6426 let mut wire_params = serde_json::to_value(params)?;
6427 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6428 let _value = self
6429 .session
6430 .client()
6431 .call(
6432 rpc_methods::SESSION_MCP_UNREGISTEREXTERNALCLIENT,
6433 Some(wire_params),
6434 )
6435 .await?;
6436 Ok(())
6437 }
6438
6439 /// Checks whether a named MCP server is currently running on the session's host.
6440 ///
6441 /// Wire method: `session.mcp.isServerRunning`.
6442 ///
6443 /// # Parameters
6444 ///
6445 /// * `params` - Server name to check running status for.
6446 ///
6447 /// # Returns
6448 ///
6449 /// Whether the named MCP server is running.
6450 ///
6451 /// <div class="warning">
6452 ///
6453 /// **Experimental.** This API is part of an experimental wire-protocol surface
6454 /// and may change or be removed in future SDK or CLI releases. Pin both the
6455 /// SDK and CLI versions if your code depends on it.
6456 ///
6457 /// </div>
6458 pub async fn is_server_running(
6459 &self,
6460 params: McpIsServerRunningRequest,
6461 ) -> Result<McpIsServerRunningResult, Error> {
6462 let mut wire_params = serde_json::to_value(params)?;
6463 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6464 let _value = self
6465 .session
6466 .client()
6467 .call(rpc_methods::SESSION_MCP_ISSERVERRUNNING, Some(wire_params))
6468 .await?;
6469 Ok(serde_json::from_value(_value)?)
6470 }
6471}
6472
6473/// `session.mcp.apps.*` RPCs.
6474#[derive(Clone, Copy)]
6475pub struct SessionRpcMcpApps<'a> {
6476 pub(crate) session: &'a Session,
6477}
6478
6479impl<'a> SessionRpcMcpApps<'a> {
6480 /// Fetch an MCP resource (typically a `ui://` MCP App bundle, per SEP-1865) from a connected server. Requires the `mcp-apps` session capability.
6481 ///
6482 /// Wire method: `session.mcp.apps.readResource`.
6483 ///
6484 /// # Parameters
6485 ///
6486 /// * `params` - MCP server and resource URI to fetch.
6487 ///
6488 /// # Returns
6489 ///
6490 /// Resource contents returned by the MCP server.
6491 ///
6492 /// <div class="warning">
6493 ///
6494 /// **Experimental.** This API is part of an experimental wire-protocol surface
6495 /// and may change or be removed in future SDK or CLI releases. Pin both the
6496 /// SDK and CLI versions if your code depends on it.
6497 ///
6498 /// </div>
6499 pub async fn read_resource(
6500 &self,
6501 params: McpAppsReadResourceRequest,
6502 ) -> Result<McpAppsReadResourceResult, Error> {
6503 let mut wire_params = serde_json::to_value(params)?;
6504 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6505 let _value = self
6506 .session
6507 .client()
6508 .call(
6509 rpc_methods::SESSION_MCP_APPS_READRESOURCE,
6510 Some(wire_params),
6511 )
6512 .await?;
6513 Ok(serde_json::from_value(_value)?)
6514 }
6515
6516 /// 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"`.
6517 ///
6518 /// Wire method: `session.mcp.apps.listTools`.
6519 ///
6520 /// # Parameters
6521 ///
6522 /// * `params` - MCP server to list app-callable tools for.
6523 ///
6524 /// # Returns
6525 ///
6526 /// App-callable tools from the named MCP server.
6527 ///
6528 /// <div class="warning">
6529 ///
6530 /// **Experimental.** This API is part of an experimental wire-protocol surface
6531 /// and may change or be removed in future SDK or CLI releases. Pin both the
6532 /// SDK and CLI versions if your code depends on it.
6533 ///
6534 /// </div>
6535 pub async fn list_tools(
6536 &self,
6537 params: McpAppsListToolsRequest,
6538 ) -> Result<McpAppsListToolsResult, Error> {
6539 let mut wire_params = serde_json::to_value(params)?;
6540 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6541 let _value = self
6542 .session
6543 .client()
6544 .call(rpc_methods::SESSION_MCP_APPS_LISTTOOLS, Some(wire_params))
6545 .await?;
6546 Ok(serde_json::from_value(_value)?)
6547 }
6548
6549 /// 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`.
6550 ///
6551 /// Wire method: `session.mcp.apps.callTool`.
6552 ///
6553 /// # Parameters
6554 ///
6555 /// * `params` - MCP server, tool name, and arguments to invoke from an MCP App view.
6556 ///
6557 /// # Returns
6558 ///
6559 /// Standard MCP CallToolResult
6560 ///
6561 /// <div class="warning">
6562 ///
6563 /// **Experimental.** This API is part of an experimental wire-protocol surface
6564 /// and may change or be removed in future SDK or CLI releases. Pin both the
6565 /// SDK and CLI versions if your code depends on it.
6566 ///
6567 /// </div>
6568 pub async fn call_tool(
6569 &self,
6570 params: McpAppsCallToolRequest,
6571 ) -> Result<SessionMcpAppsCallToolResult, Error> {
6572 let mut wire_params = serde_json::to_value(params)?;
6573 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6574 let _value = self
6575 .session
6576 .client()
6577 .call(rpc_methods::SESSION_MCP_APPS_CALLTOOL, Some(wire_params))
6578 .await?;
6579 Ok(serde_json::from_value(_value)?)
6580 }
6581
6582 /// 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.
6583 ///
6584 /// Wire method: `session.mcp.apps.setHostContext`.
6585 ///
6586 /// # Parameters
6587 ///
6588 /// * `params` - Host context to advertise to MCP App guests.
6589 ///
6590 /// <div class="warning">
6591 ///
6592 /// **Experimental.** This API is part of an experimental wire-protocol surface
6593 /// and may change or be removed in future SDK or CLI releases. Pin both the
6594 /// SDK and CLI versions if your code depends on it.
6595 ///
6596 /// </div>
6597 pub async fn set_host_context(
6598 &self,
6599 params: McpAppsSetHostContextRequest,
6600 ) -> Result<(), Error> {
6601 let mut wire_params = serde_json::to_value(params)?;
6602 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6603 let _value = self
6604 .session
6605 .client()
6606 .call(
6607 rpc_methods::SESSION_MCP_APPS_SETHOSTCONTEXT,
6608 Some(wire_params),
6609 )
6610 .await?;
6611 Ok(())
6612 }
6613
6614 /// Read the current host context advertised to MCP App guests.
6615 ///
6616 /// Wire method: `session.mcp.apps.getHostContext`.
6617 ///
6618 /// # Returns
6619 ///
6620 /// Current host context advertised to MCP App guests.
6621 ///
6622 /// <div class="warning">
6623 ///
6624 /// **Experimental.** This API is part of an experimental wire-protocol surface
6625 /// and may change or be removed in future SDK or CLI releases. Pin both the
6626 /// SDK and CLI versions if your code depends on it.
6627 ///
6628 /// </div>
6629 pub async fn get_host_context(&self) -> Result<McpAppsHostContext, Error> {
6630 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6631 let _value = self
6632 .session
6633 .client()
6634 .call(
6635 rpc_methods::SESSION_MCP_APPS_GETHOSTCONTEXT,
6636 Some(wire_params),
6637 )
6638 .await?;
6639 Ok(serde_json::from_value(_value)?)
6640 }
6641
6642 /// 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.
6643 ///
6644 /// Wire method: `session.mcp.apps.diagnose`.
6645 ///
6646 /// # Parameters
6647 ///
6648 /// * `params` - MCP server to diagnose MCP Apps wiring for.
6649 ///
6650 /// # Returns
6651 ///
6652 /// Diagnostic snapshot of MCP Apps wiring for the named server.
6653 ///
6654 /// <div class="warning">
6655 ///
6656 /// **Experimental.** This API is part of an experimental wire-protocol surface
6657 /// and may change or be removed in future SDK or CLI releases. Pin both the
6658 /// SDK and CLI versions if your code depends on it.
6659 ///
6660 /// </div>
6661 pub async fn diagnose(
6662 &self,
6663 params: McpAppsDiagnoseRequest,
6664 ) -> Result<McpAppsDiagnoseResult, Error> {
6665 let mut wire_params = serde_json::to_value(params)?;
6666 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6667 let _value = self
6668 .session
6669 .client()
6670 .call(rpc_methods::SESSION_MCP_APPS_DIAGNOSE, Some(wire_params))
6671 .await?;
6672 Ok(serde_json::from_value(_value)?)
6673 }
6674}
6675
6676/// `session.mcp.headers.*` RPCs.
6677#[derive(Clone, Copy)]
6678pub struct SessionRpcMcpHeaders<'a> {
6679 pub(crate) session: &'a Session,
6680}
6681
6682impl<'a> SessionRpcMcpHeaders<'a> {
6683 /// 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.
6684 ///
6685 /// Wire method: `session.mcp.headers.handlePendingHeadersRefreshRequest`.
6686 ///
6687 /// # Parameters
6688 ///
6689 /// * `params` - MCP headers refresh request id and the host response.
6690 ///
6691 /// # Returns
6692 ///
6693 /// Indicates whether the pending MCP headers refresh response was accepted.
6694 ///
6695 /// <div class="warning">
6696 ///
6697 /// **Experimental.** This API is part of an experimental wire-protocol surface
6698 /// and may change or be removed in future SDK or CLI releases. Pin both the
6699 /// SDK and CLI versions if your code depends on it.
6700 ///
6701 /// </div>
6702 pub async fn handle_pending_headers_refresh_request(
6703 &self,
6704 params: McpHeadersHandlePendingHeadersRefreshRequestRequest,
6705 ) -> Result<McpHeadersHandlePendingHeadersRefreshRequestResult, Error> {
6706 let mut wire_params = serde_json::to_value(params)?;
6707 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6708 let _value = self
6709 .session
6710 .client()
6711 .call(
6712 rpc_methods::SESSION_MCP_HEADERS_HANDLEPENDINGHEADERSREFRESHREQUEST,
6713 Some(wire_params),
6714 )
6715 .await?;
6716 Ok(serde_json::from_value(_value)?)
6717 }
6718}
6719
6720/// `session.mcp.oauth.*` RPCs.
6721#[derive(Clone, Copy)]
6722pub struct SessionRpcMcpOauth<'a> {
6723 pub(crate) session: &'a Session,
6724}
6725
6726impl<'a> SessionRpcMcpOauth<'a> {
6727 /// 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.
6728 ///
6729 /// Wire method: `session.mcp.oauth.handlePendingRequest`.
6730 ///
6731 /// # Parameters
6732 ///
6733 /// * `params` - Pending MCP OAuth request ID and host-provided token or cancellation response.
6734 ///
6735 /// # Returns
6736 ///
6737 /// Indicates whether the pending MCP OAuth response was accepted.
6738 ///
6739 /// <div class="warning">
6740 ///
6741 /// **Experimental.** This API is part of an experimental wire-protocol surface
6742 /// and may change or be removed in future SDK or CLI releases. Pin both the
6743 /// SDK and CLI versions if your code depends on it.
6744 ///
6745 /// </div>
6746 pub async fn handle_pending_request(
6747 &self,
6748 params: McpOauthHandlePendingRequest,
6749 ) -> Result<McpOauthHandlePendingResult, Error> {
6750 let mut wire_params = serde_json::to_value(params)?;
6751 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6752 let _value = self
6753 .session
6754 .client()
6755 .call(
6756 rpc_methods::SESSION_MCP_OAUTH_HANDLEPENDINGREQUEST,
6757 Some(wire_params),
6758 )
6759 .await?;
6760 Ok(serde_json::from_value(_value)?)
6761 }
6762
6763 /// Notifies the session that MCP OAuth authentication succeeded and updated credentials were persisted, so cached tool definitions can be refreshed.
6764 ///
6765 /// Wire method: `session.mcp.oauth.authenticationStateChanged`.
6766 ///
6767 /// # Parameters
6768 ///
6769 /// * `params` - Identifies the MCP server whose persisted OAuth credentials were updated.
6770 ///
6771 /// <div class="warning">
6772 ///
6773 /// **Experimental.** This API is part of an experimental wire-protocol surface
6774 /// and may change or be removed in future SDK or CLI releases. Pin both the
6775 /// SDK and CLI versions if your code depends on it.
6776 ///
6777 /// </div>
6778 pub async fn authentication_state_changed(
6779 &self,
6780 params: McpOauthAuthenticationStateChangedRequest,
6781 ) -> Result<(), Error> {
6782 let mut wire_params = serde_json::to_value(params)?;
6783 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6784 let _value = self
6785 .session
6786 .client()
6787 .call(
6788 rpc_methods::SESSION_MCP_OAUTH_AUTHENTICATIONSTATECHANGED,
6789 Some(wire_params),
6790 )
6791 .await?;
6792 Ok(())
6793 }
6794
6795 /// Starts OAuth authentication for a remote MCP server.
6796 ///
6797 /// Wire method: `session.mcp.oauth.login`.
6798 ///
6799 /// # Parameters
6800 ///
6801 /// * `params` - Remote MCP server name and optional overrides controlling reauthentication, OAuth client display name, callback success-page copy, and static OAuth client selection.
6802 ///
6803 /// # Returns
6804 ///
6805 /// OAuth authorization URL the caller should open, or empty when cached tokens already authenticated the server.
6806 ///
6807 /// <div class="warning">
6808 ///
6809 /// **Experimental.** This API is part of an experimental wire-protocol surface
6810 /// and may change or be removed in future SDK or CLI releases. Pin both the
6811 /// SDK and CLI versions if your code depends on it.
6812 ///
6813 /// </div>
6814 pub async fn login(&self, params: McpOauthLoginRequest) -> Result<McpOauthLoginResult, Error> {
6815 let mut wire_params = serde_json::to_value(params)?;
6816 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6817 let _value = self
6818 .session
6819 .client()
6820 .call(rpc_methods::SESSION_MCP_OAUTH_LOGIN, Some(wire_params))
6821 .await?;
6822 Ok(serde_json::from_value(_value)?)
6823 }
6824
6825 /// 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.
6826 ///
6827 /// Wire method: `session.mcp.oauth.probe`.
6828 ///
6829 /// # Parameters
6830 ///
6831 /// * `params` - Remote MCP server name for a passive OAuth status probe.
6832 ///
6833 /// # Returns
6834 ///
6835 /// 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.
6836 ///
6837 /// <div class="warning">
6838 ///
6839 /// **Experimental.** This API is part of an experimental wire-protocol surface
6840 /// and may change or be removed in future SDK or CLI releases. Pin both the
6841 /// SDK and CLI versions if your code depends on it.
6842 ///
6843 /// </div>
6844 pub async fn probe(&self, params: McpOauthProbeRequest) -> Result<McpOauthProbeResult, Error> {
6845 let mut wire_params = serde_json::to_value(params)?;
6846 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6847 let _value = self
6848 .session
6849 .client()
6850 .call(rpc_methods::SESSION_MCP_OAUTH_PROBE, Some(wire_params))
6851 .await?;
6852 Ok(serde_json::from_value(_value)?)
6853 }
6854
6855 /// Responds to a pending MCP OAuth authorization request by its request id.
6856 ///
6857 /// Wire method: `session.mcp.oauth.respond`.
6858 ///
6859 /// # Parameters
6860 ///
6861 /// * `params` - Pending MCP OAuth request id to respond to.
6862 ///
6863 /// # Returns
6864 ///
6865 /// Indicates whether the pending MCP OAuth response was accepted.
6866 ///
6867 /// <div class="warning">
6868 ///
6869 /// **Experimental.** This API is part of an experimental wire-protocol surface
6870 /// and may change or be removed in future SDK or CLI releases. Pin both the
6871 /// SDK and CLI versions if your code depends on it.
6872 ///
6873 /// </div>
6874 pub async fn respond(
6875 &self,
6876 params: McpOauthRespondRequest,
6877 ) -> Result<McpOauthRespondResult, Error> {
6878 let mut wire_params = serde_json::to_value(params)?;
6879 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6880 let _value = self
6881 .session
6882 .client()
6883 .call(rpc_methods::SESSION_MCP_OAUTH_RESPOND, Some(wire_params))
6884 .await?;
6885 Ok(serde_json::from_value(_value)?)
6886 }
6887}
6888
6889/// `session.mcp.resources.*` RPCs.
6890#[derive(Clone, Copy)]
6891pub struct SessionRpcMcpResources<'a> {
6892 pub(crate) session: &'a Session,
6893}
6894
6895impl<'a> SessionRpcMcpResources<'a> {
6896 /// Fetch an MCP resource from a connected server by URI (proxies MCP `resources/read`).
6897 ///
6898 /// Wire method: `session.mcp.resources.read`.
6899 ///
6900 /// # Parameters
6901 ///
6902 /// * `params` - MCP server and resource URI to fetch.
6903 ///
6904 /// # Returns
6905 ///
6906 /// Resource contents returned by the MCP server.
6907 ///
6908 /// <div class="warning">
6909 ///
6910 /// **Experimental.** This API is part of an experimental wire-protocol surface
6911 /// and may change or be removed in future SDK or CLI releases. Pin both the
6912 /// SDK and CLI versions if your code depends on it.
6913 ///
6914 /// </div>
6915 pub async fn read(
6916 &self,
6917 params: McpResourcesReadRequest,
6918 ) -> Result<McpResourcesReadResult, Error> {
6919 let mut wire_params = serde_json::to_value(params)?;
6920 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6921 let _value = self
6922 .session
6923 .client()
6924 .call(rpc_methods::SESSION_MCP_RESOURCES_READ, Some(wire_params))
6925 .await?;
6926 Ok(serde_json::from_value(_value)?)
6927 }
6928
6929 /// Enumerate one page of resources a connected MCP server exposes (proxies MCP `resources/list`). Pass `cursor` to continue from a prior result's `nextCursor`.
6930 ///
6931 /// Wire method: `session.mcp.resources.list`.
6932 ///
6933 /// # Parameters
6934 ///
6935 /// * `params` - MCP server whose resources to enumerate.
6936 ///
6937 /// # Returns
6938 ///
6939 /// One page of resources advertised by the named MCP server.
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 list(
6949 &self,
6950 params: McpResourcesListRequest,
6951 ) -> Result<McpResourcesListResult, Error> {
6952 let mut wire_params = serde_json::to_value(params)?;
6953 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6954 let _value = self
6955 .session
6956 .client()
6957 .call(rpc_methods::SESSION_MCP_RESOURCES_LIST, Some(wire_params))
6958 .await?;
6959 Ok(serde_json::from_value(_value)?)
6960 }
6961
6962 /// 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`.
6963 ///
6964 /// Wire method: `session.mcp.resources.listTemplates`.
6965 ///
6966 /// # Parameters
6967 ///
6968 /// * `params` - MCP server whose resource templates to enumerate.
6969 ///
6970 /// # Returns
6971 ///
6972 /// One page of resource templates advertised by the named MCP server.
6973 ///
6974 /// <div class="warning">
6975 ///
6976 /// **Experimental.** This API is part of an experimental wire-protocol surface
6977 /// and may change or be removed in future SDK or CLI releases. Pin both the
6978 /// SDK and CLI versions if your code depends on it.
6979 ///
6980 /// </div>
6981 pub async fn list_templates(
6982 &self,
6983 params: McpResourcesListTemplatesRequest,
6984 ) -> Result<McpResourcesListTemplatesResult, Error> {
6985 let mut wire_params = serde_json::to_value(params)?;
6986 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6987 let _value = self
6988 .session
6989 .client()
6990 .call(
6991 rpc_methods::SESSION_MCP_RESOURCES_LISTTEMPLATES,
6992 Some(wire_params),
6993 )
6994 .await?;
6995 Ok(serde_json::from_value(_value)?)
6996 }
6997}
6998
6999/// `session.metadata.*` RPCs.
7000#[derive(Clone, Copy)]
7001pub struct SessionRpcMetadata<'a> {
7002 pub(crate) session: &'a Session,
7003}
7004
7005impl<'a> SessionRpcMetadata<'a> {
7006 /// Returns a snapshot of the session's identifying metadata, mode, agent, and remote info.
7007 ///
7008 /// Wire method: `session.metadata.snapshot`.
7009 ///
7010 /// # Returns
7011 ///
7012 /// Point-in-time snapshot of slow-changing session identifier and state fields
7013 ///
7014 /// <div class="warning">
7015 ///
7016 /// **Experimental.** This API is part of an experimental wire-protocol surface
7017 /// and may change or be removed in future SDK or CLI releases. Pin both the
7018 /// SDK and CLI versions if your code depends on it.
7019 ///
7020 /// </div>
7021 pub async fn snapshot(&self) -> Result<SessionMetadataSnapshot, Error> {
7022 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7023 let _value = self
7024 .session
7025 .client()
7026 .call(rpc_methods::SESSION_METADATA_SNAPSHOT, Some(wire_params))
7027 .await?;
7028 Ok(serde_json::from_value(_value)?)
7029 }
7030
7031 /// Reports whether the local session is currently processing user/agent messages.
7032 ///
7033 /// Wire method: `session.metadata.isProcessing`.
7034 ///
7035 /// # Returns
7036 ///
7037 /// Indicates whether the local session is currently processing a turn or background continuation.
7038 ///
7039 /// <div class="warning">
7040 ///
7041 /// **Experimental.** This API is part of an experimental wire-protocol surface
7042 /// and may change or be removed in future SDK or CLI releases. Pin both the
7043 /// SDK and CLI versions if your code depends on it.
7044 ///
7045 /// </div>
7046 pub async fn is_processing(&self) -> Result<MetadataIsProcessingResult, Error> {
7047 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7048 let _value = self
7049 .session
7050 .client()
7051 .call(
7052 rpc_methods::SESSION_METADATA_ISPROCESSING,
7053 Some(wire_params),
7054 )
7055 .await?;
7056 Ok(serde_json::from_value(_value)?)
7057 }
7058
7059 /// Returns a snapshot of activity flags for the session.
7060 ///
7061 /// Wire method: `session.metadata.activity`.
7062 ///
7063 /// # Returns
7064 ///
7065 /// Current activity flags for the session.
7066 ///
7067 /// <div class="warning">
7068 ///
7069 /// **Experimental.** This API is part of an experimental wire-protocol surface
7070 /// and may change or be removed in future SDK or CLI releases. Pin both the
7071 /// SDK and CLI versions if your code depends on it.
7072 ///
7073 /// </div>
7074 pub async fn activity(&self) -> Result<SessionActivity, Error> {
7075 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7076 let _value = self
7077 .session
7078 .client()
7079 .call(rpc_methods::SESSION_METADATA_ACTIVITY, Some(wire_params))
7080 .await?;
7081 Ok(serde_json::from_value(_value)?)
7082 }
7083
7084 /// Returns the token breakdown for the session's current context window for a given model.
7085 ///
7086 /// Wire method: `session.metadata.contextInfo`.
7087 ///
7088 /// # Parameters
7089 ///
7090 /// * `params` - Model identifier and token limits used to compute the context-info breakdown.
7091 ///
7092 /// # Returns
7093 ///
7094 /// Token breakdown for the session's current context window, or null if uninitialized.
7095 ///
7096 /// <div class="warning">
7097 ///
7098 /// **Experimental.** This API is part of an experimental wire-protocol surface
7099 /// and may change or be removed in future SDK or CLI releases. Pin both the
7100 /// SDK and CLI versions if your code depends on it.
7101 ///
7102 /// </div>
7103 pub async fn context_info(
7104 &self,
7105 params: MetadataContextInfoRequest,
7106 ) -> Result<MetadataContextInfoResult, Error> {
7107 let mut wire_params = serde_json::to_value(params)?;
7108 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7109 let _value = self
7110 .session
7111 .client()
7112 .call(rpc_methods::SESSION_METADATA_CONTEXTINFO, Some(wire_params))
7113 .await?;
7114 Ok(serde_json::from_value(_value)?)
7115 }
7116
7117 /// 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.
7118 ///
7119 /// Wire method: `session.metadata.getContextAttribution`.
7120 ///
7121 /// # Returns
7122 ///
7123 /// Per-source attribution breakdown for the session's current context window, or null if uninitialized.
7124 ///
7125 /// <div class="warning">
7126 ///
7127 /// **Experimental.** This API is part of an experimental wire-protocol surface
7128 /// and may change or be removed in future SDK or CLI releases. Pin both the
7129 /// SDK and CLI versions if your code depends on it.
7130 ///
7131 /// </div>
7132 pub async fn get_context_attribution(&self) -> Result<MetadataContextAttributionResult, Error> {
7133 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7134 let _value = self
7135 .session
7136 .client()
7137 .call(
7138 rpc_methods::SESSION_METADATA_GETCONTEXTATTRIBUTION,
7139 Some(wire_params),
7140 )
7141 .await?;
7142 Ok(serde_json::from_value(_value)?)
7143 }
7144
7145 /// 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.
7146 ///
7147 /// Wire method: `session.metadata.getContextHeaviestMessages`.
7148 ///
7149 /// # Parameters
7150 ///
7151 /// * `params` - Parameters for the heaviest-messages query.
7152 ///
7153 /// # Returns
7154 ///
7155 /// The heaviest individual messages in the session's context window, most-expensive first.
7156 ///
7157 /// <div class="warning">
7158 ///
7159 /// **Experimental.** This API is part of an experimental wire-protocol surface
7160 /// and may change or be removed in future SDK or CLI releases. Pin both the
7161 /// SDK and CLI versions if your code depends on it.
7162 ///
7163 /// </div>
7164 pub async fn get_context_heaviest_messages(
7165 &self,
7166 params: MetadataContextHeaviestMessagesRequest,
7167 ) -> Result<MetadataContextHeaviestMessagesResult, Error> {
7168 let mut wire_params = serde_json::to_value(params)?;
7169 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7170 let _value = self
7171 .session
7172 .client()
7173 .call(
7174 rpc_methods::SESSION_METADATA_GETCONTEXTHEAVIESTMESSAGES,
7175 Some(wire_params),
7176 )
7177 .await?;
7178 Ok(serde_json::from_value(_value)?)
7179 }
7180
7181 /// 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.
7182 ///
7183 /// Wire method: `session.metadata.recordContextChange`.
7184 ///
7185 /// # Parameters
7186 ///
7187 /// * `params` - Updated working-directory/git context to record on the session.
7188 ///
7189 /// # Returns
7190 ///
7191 /// 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.
7192 ///
7193 /// <div class="warning">
7194 ///
7195 /// **Experimental.** This API is part of an experimental wire-protocol surface
7196 /// and may change or be removed in future SDK or CLI releases. Pin both the
7197 /// SDK and CLI versions if your code depends on it.
7198 ///
7199 /// </div>
7200 pub async fn record_context_change(
7201 &self,
7202 params: MetadataRecordContextChangeRequest,
7203 ) -> Result<MetadataRecordContextChangeResult, Error> {
7204 let mut wire_params = serde_json::to_value(params)?;
7205 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7206 let _value = self
7207 .session
7208 .client()
7209 .call(
7210 rpc_methods::SESSION_METADATA_RECORDCONTEXTCHANGE,
7211 Some(wire_params),
7212 )
7213 .await?;
7214 Ok(serde_json::from_value(_value)?)
7215 }
7216
7217 /// 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.
7218 ///
7219 /// Wire method: `session.metadata.setWorkingDirectory`.
7220 ///
7221 /// # Parameters
7222 ///
7223 /// * `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.
7224 ///
7225 /// # Returns
7226 ///
7227 /// 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.
7228 ///
7229 /// <div class="warning">
7230 ///
7231 /// **Experimental.** This API is part of an experimental wire-protocol surface
7232 /// and may change or be removed in future SDK or CLI releases. Pin both the
7233 /// SDK and CLI versions if your code depends on it.
7234 ///
7235 /// </div>
7236 pub async fn set_working_directory(
7237 &self,
7238 params: MetadataSetWorkingDirectoryRequest,
7239 ) -> Result<MetadataSetWorkingDirectoryResult, Error> {
7240 let mut wire_params = serde_json::to_value(params)?;
7241 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7242 let _value = self
7243 .session
7244 .client()
7245 .call(
7246 rpc_methods::SESSION_METADATA_SETWORKINGDIRECTORY,
7247 Some(wire_params),
7248 )
7249 .await?;
7250 Ok(serde_json::from_value(_value)?)
7251 }
7252
7253 /// Re-tokenizes the session's existing messages against a model and returns aggregate token totals.
7254 ///
7255 /// Wire method: `session.metadata.recomputeContextTokens`.
7256 ///
7257 /// # Parameters
7258 ///
7259 /// * `params` - Model identifier to use when re-tokenizing the session's existing messages.
7260 ///
7261 /// # Returns
7262 ///
7263 /// 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.
7264 ///
7265 /// <div class="warning">
7266 ///
7267 /// **Experimental.** This API is part of an experimental wire-protocol surface
7268 /// and may change or be removed in future SDK or CLI releases. Pin both the
7269 /// SDK and CLI versions if your code depends on it.
7270 ///
7271 /// </div>
7272 pub async fn recompute_context_tokens(
7273 &self,
7274 params: MetadataRecomputeContextTokensRequest,
7275 ) -> Result<MetadataRecomputeContextTokensResult, Error> {
7276 let mut wire_params = serde_json::to_value(params)?;
7277 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7278 let _value = self
7279 .session
7280 .client()
7281 .call(
7282 rpc_methods::SESSION_METADATA_RECOMPUTECONTEXTTOKENS,
7283 Some(wire_params),
7284 )
7285 .await?;
7286 Ok(serde_json::from_value(_value)?)
7287 }
7288}
7289
7290/// `session.mode.*` RPCs.
7291#[derive(Clone, Copy)]
7292pub struct SessionRpcMode<'a> {
7293 pub(crate) session: &'a Session,
7294}
7295
7296impl<'a> SessionRpcMode<'a> {
7297 /// Gets the current agent interaction mode.
7298 ///
7299 /// Wire method: `session.mode.get`.
7300 ///
7301 /// # Returns
7302 ///
7303 /// The session mode the agent is operating in
7304 ///
7305 /// <div class="warning">
7306 ///
7307 /// **Experimental.** This API is part of an experimental wire-protocol surface
7308 /// and may change or be removed in future SDK or CLI releases. Pin both the
7309 /// SDK and CLI versions if your code depends on it.
7310 ///
7311 /// </div>
7312 pub async fn get(&self) -> Result<SessionMode, Error> {
7313 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7314 let _value = self
7315 .session
7316 .client()
7317 .call(rpc_methods::SESSION_MODE_GET, Some(wire_params))
7318 .await?;
7319 Ok(serde_json::from_value(_value)?)
7320 }
7321
7322 /// Sets the current agent interaction mode.
7323 ///
7324 /// Wire method: `session.mode.set`.
7325 ///
7326 /// # Parameters
7327 ///
7328 /// * `params` - Agent interaction mode to apply to the session.
7329 ///
7330 /// # Returns
7331 ///
7332 /// Outcome of a session mode change, including any model switch it triggered and follow-up the host must perform.
7333 ///
7334 /// <div class="warning">
7335 ///
7336 /// **Experimental.** This API is part of an experimental wire-protocol surface
7337 /// and may change or be removed in future SDK or CLI releases. Pin both the
7338 /// SDK and CLI versions if your code depends on it.
7339 ///
7340 /// </div>
7341 pub async fn set(&self, params: ModeSetRequest) -> Result<ModeSetResult, Error> {
7342 let mut wire_params = serde_json::to_value(params)?;
7343 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7344 let _value = self
7345 .session
7346 .client()
7347 .call(rpc_methods::SESSION_MODE_SET, Some(wire_params))
7348 .await?;
7349 Ok(serde_json::from_value(_value)?)
7350 }
7351}
7352
7353/// `session.model.*` RPCs.
7354#[derive(Clone, Copy)]
7355pub struct SessionRpcModel<'a> {
7356 pub(crate) session: &'a Session,
7357}
7358
7359impl<'a> SessionRpcModel<'a> {
7360 /// Gets the currently selected model for the session.
7361 ///
7362 /// Wire method: `session.model.getCurrent`.
7363 ///
7364 /// # Returns
7365 ///
7366 /// The currently selected model, reasoning effort, and context tier for the session. The context tier reflects `Session.getContextTier()`, restored from the session journal on resume.
7367 ///
7368 /// <div class="warning">
7369 ///
7370 /// **Experimental.** This API is part of an experimental wire-protocol surface
7371 /// and may change or be removed in future SDK or CLI releases. Pin both the
7372 /// SDK and CLI versions if your code depends on it.
7373 ///
7374 /// </div>
7375 pub async fn get_current(&self) -> Result<CurrentModel, Error> {
7376 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7377 let _value = self
7378 .session
7379 .client()
7380 .call(rpc_methods::SESSION_MODEL_GETCURRENT, Some(wire_params))
7381 .await?;
7382 Ok(serde_json::from_value(_value)?)
7383 }
7384
7385 /// Switches the session to a model and optional reasoning configuration.
7386 ///
7387 /// Wire method: `session.model.switchTo`.
7388 ///
7389 /// # Parameters
7390 ///
7391 /// * `params` - Target model identifier and optional reasoning effort, summary, capability overrides, and context tier.
7392 ///
7393 /// # Returns
7394 ///
7395 /// The model identifier active on the session after the switch.
7396 ///
7397 /// <div class="warning">
7398 ///
7399 /// **Experimental.** This API is part of an experimental wire-protocol surface
7400 /// and may change or be removed in future SDK or CLI releases. Pin both the
7401 /// SDK and CLI versions if your code depends on it.
7402 ///
7403 /// </div>
7404 pub async fn switch_to(
7405 &self,
7406 params: ModelSwitchToRequest,
7407 ) -> Result<ModelSwitchToResult, Error> {
7408 let mut wire_params = serde_json::to_value(params)?;
7409 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7410 let _value = self
7411 .session
7412 .client()
7413 .call(rpc_methods::SESSION_MODEL_SWITCHTO, Some(wire_params))
7414 .await?;
7415 Ok(serde_json::from_value(_value)?)
7416 }
7417
7418 /// Resolves and applies organization-managed and repository model overlays.
7419 ///
7420 /// Wire method: `session.model.applyStartupOverlay`.
7421 ///
7422 /// # Parameters
7423 ///
7424 /// * `params` - Managed, repository, and CLI model overrides to overlay onto the session at startup.
7425 ///
7426 /// # Returns
7427 ///
7428 /// The model identifier active on the session after the switch.
7429 ///
7430 /// <div class="warning">
7431 ///
7432 /// **Experimental.** This API is part of an experimental wire-protocol surface
7433 /// and may change or be removed in future SDK or CLI releases. Pin both the
7434 /// SDK and CLI versions if your code depends on it.
7435 ///
7436 /// </div>
7437 pub(crate) async fn apply_startup_overlay(
7438 &self,
7439 params: ModelApplyStartupOverlayRequest,
7440 ) -> Result<ModelSwitchToResult, Error> {
7441 let mut wire_params = serde_json::to_value(params)?;
7442 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7443 let _value = self
7444 .session
7445 .client()
7446 .call(
7447 rpc_methods::SESSION_MODEL_APPLYSTARTUPOVERLAY,
7448 Some(wire_params),
7449 )
7450 .await?;
7451 Ok(serde_json::from_value(_value)?)
7452 }
7453
7454 /// Updates the session's reasoning effort without changing the selected model.
7455 ///
7456 /// Wire method: `session.model.setReasoningEffort`.
7457 ///
7458 /// # Parameters
7459 ///
7460 /// * `params` - Reasoning effort level to apply to the currently selected model.
7461 ///
7462 /// # Returns
7463 ///
7464 /// 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.
7465 ///
7466 /// <div class="warning">
7467 ///
7468 /// **Experimental.** This API is part of an experimental wire-protocol surface
7469 /// and may change or be removed in future SDK or CLI releases. Pin both the
7470 /// SDK and CLI versions if your code depends on it.
7471 ///
7472 /// </div>
7473 pub async fn set_reasoning_effort(
7474 &self,
7475 params: ModelSetReasoningEffortRequest,
7476 ) -> Result<ModelSetReasoningEffortResult, Error> {
7477 let mut wire_params = serde_json::to_value(params)?;
7478 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7479 let _value = self
7480 .session
7481 .client()
7482 .call(
7483 rpc_methods::SESSION_MODEL_SETREASONINGEFFORT,
7484 Some(wire_params),
7485 )
7486 .await?;
7487 Ok(serde_json::from_value(_value)?)
7488 }
7489
7490 /// 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.
7491 ///
7492 /// Wire method: `session.model.list`.
7493 ///
7494 /// # Returns
7495 ///
7496 /// The list of models available to this session.
7497 ///
7498 /// <div class="warning">
7499 ///
7500 /// **Experimental.** This API is part of an experimental wire-protocol surface
7501 /// and may change or be removed in future SDK or CLI releases. Pin both the
7502 /// SDK and CLI versions if your code depends on it.
7503 ///
7504 /// </div>
7505 pub async fn list(&self) -> Result<SessionModelList, Error> {
7506 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7507 let _value = self
7508 .session
7509 .client()
7510 .call(rpc_methods::SESSION_MODEL_LIST, Some(wire_params))
7511 .await?;
7512 Ok(serde_json::from_value(_value)?)
7513 }
7514
7515 /// 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.
7516 ///
7517 /// Wire method: `session.model.list`.
7518 ///
7519 /// # Parameters
7520 ///
7521 /// * `params` - Optional listing options.
7522 ///
7523 /// # Returns
7524 ///
7525 /// The list of models available to this session.
7526 ///
7527 /// <div class="warning">
7528 ///
7529 /// **Experimental.** This API is part of an experimental wire-protocol surface
7530 /// and may change or be removed in future SDK or CLI releases. Pin both the
7531 /// SDK and CLI versions if your code depends on it.
7532 ///
7533 /// </div>
7534 pub async fn list_with_params(
7535 &self,
7536 params: ModelListRequest,
7537 ) -> Result<SessionModelList, Error> {
7538 let mut wire_params = serde_json::to_value(params)?;
7539 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7540 let _value = self
7541 .session
7542 .client()
7543 .call(rpc_methods::SESSION_MODEL_LIST, Some(wire_params))
7544 .await?;
7545 Ok(serde_json::from_value(_value)?)
7546 }
7547}
7548
7549/// `session.name.*` RPCs.
7550#[derive(Clone, Copy)]
7551pub struct SessionRpcName<'a> {
7552 pub(crate) session: &'a Session,
7553}
7554
7555impl<'a> SessionRpcName<'a> {
7556 /// Gets the session's friendly name.
7557 ///
7558 /// Wire method: `session.name.get`.
7559 ///
7560 /// # Returns
7561 ///
7562 /// The session's friendly name, or null when not yet set.
7563 ///
7564 /// <div class="warning">
7565 ///
7566 /// **Experimental.** This API is part of an experimental wire-protocol surface
7567 /// and may change or be removed in future SDK or CLI releases. Pin both the
7568 /// SDK and CLI versions if your code depends on it.
7569 ///
7570 /// </div>
7571 pub async fn get(&self) -> Result<NameGetResult, Error> {
7572 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7573 let _value = self
7574 .session
7575 .client()
7576 .call(rpc_methods::SESSION_NAME_GET, Some(wire_params))
7577 .await?;
7578 Ok(serde_json::from_value(_value)?)
7579 }
7580
7581 /// Sets the session's friendly name.
7582 ///
7583 /// Wire method: `session.name.set`.
7584 ///
7585 /// # Parameters
7586 ///
7587 /// * `params` - New friendly name to apply to the session.
7588 ///
7589 /// <div class="warning">
7590 ///
7591 /// **Experimental.** This API is part of an experimental wire-protocol surface
7592 /// and may change or be removed in future SDK or CLI releases. Pin both the
7593 /// SDK and CLI versions if your code depends on it.
7594 ///
7595 /// </div>
7596 pub async fn set(&self, params: NameSetRequest) -> Result<(), Error> {
7597 let mut wire_params = serde_json::to_value(params)?;
7598 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7599 let _value = self
7600 .session
7601 .client()
7602 .call(rpc_methods::SESSION_NAME_SET, Some(wire_params))
7603 .await?;
7604 Ok(())
7605 }
7606
7607 /// Persists an auto-generated session summary as the session's name when no user-set name exists.
7608 ///
7609 /// Wire method: `session.name.setAuto`.
7610 ///
7611 /// # Parameters
7612 ///
7613 /// * `params` - Auto-generated session summary to apply as the session's name when no user-set name exists.
7614 ///
7615 /// # Returns
7616 ///
7617 /// Indicates whether the auto-generated summary was applied as the session's name.
7618 ///
7619 /// <div class="warning">
7620 ///
7621 /// **Experimental.** This API is part of an experimental wire-protocol surface
7622 /// and may change or be removed in future SDK or CLI releases. Pin both the
7623 /// SDK and CLI versions if your code depends on it.
7624 ///
7625 /// </div>
7626 pub async fn set_auto(&self, params: NameSetAutoRequest) -> Result<NameSetAutoResult, Error> {
7627 let mut wire_params = serde_json::to_value(params)?;
7628 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7629 let _value = self
7630 .session
7631 .client()
7632 .call(rpc_methods::SESSION_NAME_SETAUTO, Some(wire_params))
7633 .await?;
7634 Ok(serde_json::from_value(_value)?)
7635 }
7636}
7637
7638/// `session.options.*` RPCs.
7639#[derive(Clone, Copy)]
7640pub struct SessionRpcOptions<'a> {
7641 pub(crate) session: &'a Session,
7642}
7643
7644impl<'a> SessionRpcOptions<'a> {
7645 /// Patches the genuinely-mutable subset of session options.
7646 ///
7647 /// Wire method: `session.options.update`.
7648 ///
7649 /// # Parameters
7650 ///
7651 /// * `params` - Patch of mutable session options to apply to the running session.
7652 ///
7653 /// # Returns
7654 ///
7655 /// Indicates whether the session options patch was applied successfully.
7656 ///
7657 /// <div class="warning">
7658 ///
7659 /// **Experimental.** This API is part of an experimental wire-protocol surface
7660 /// and may change or be removed in future SDK or CLI releases. Pin both the
7661 /// SDK and CLI versions if your code depends on it.
7662 ///
7663 /// </div>
7664 pub async fn update(
7665 &self,
7666 params: SessionUpdateOptionsParams,
7667 ) -> Result<SessionUpdateOptionsResult, Error> {
7668 let mut wire_params = serde_json::to_value(params)?;
7669 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7670 let _value = self
7671 .session
7672 .client()
7673 .call(rpc_methods::SESSION_OPTIONS_UPDATE, Some(wire_params))
7674 .await?;
7675 Ok(serde_json::from_value(_value)?)
7676 }
7677}
7678
7679/// `session.permissions.*` RPCs.
7680#[derive(Clone, Copy)]
7681pub struct SessionRpcPermissions<'a> {
7682 pub(crate) session: &'a Session,
7683}
7684
7685impl<'a> SessionRpcPermissions<'a> {
7686 /// `session.permissions.folderTrust.*` sub-namespace.
7687 pub fn folder_trust(&self) -> SessionRpcPermissionsFolderTrust<'a> {
7688 SessionRpcPermissionsFolderTrust {
7689 session: self.session,
7690 }
7691 }
7692
7693 /// `session.permissions.locations.*` sub-namespace.
7694 pub fn locations(&self) -> SessionRpcPermissionsLocations<'a> {
7695 SessionRpcPermissionsLocations {
7696 session: self.session,
7697 }
7698 }
7699
7700 /// `session.permissions.paths.*` sub-namespace.
7701 pub fn paths(&self) -> SessionRpcPermissionsPaths<'a> {
7702 SessionRpcPermissionsPaths {
7703 session: self.session,
7704 }
7705 }
7706
7707 /// `session.permissions.urls.*` sub-namespace.
7708 pub fn urls(&self) -> SessionRpcPermissionsUrls<'a> {
7709 SessionRpcPermissionsUrls {
7710 session: self.session,
7711 }
7712 }
7713
7714 /// Replaces selected permission policy fields (rules, paths, URLs, exclusions, allow-all flags) on the session.
7715 ///
7716 /// Wire method: `session.permissions.configure`.
7717 ///
7718 /// # Parameters
7719 ///
7720 /// * `params` - Patch of permission policy fields to apply (omit a field to leave it unchanged).
7721 ///
7722 /// # Returns
7723 ///
7724 /// Indicates whether the operation succeeded.
7725 ///
7726 /// <div class="warning">
7727 ///
7728 /// **Experimental.** This API is part of an experimental wire-protocol surface
7729 /// and may change or be removed in future SDK or CLI releases. Pin both the
7730 /// SDK and CLI versions if your code depends on it.
7731 ///
7732 /// </div>
7733 pub async fn configure(
7734 &self,
7735 params: PermissionsConfigureParams,
7736 ) -> Result<PermissionsConfigureResult, Error> {
7737 let mut wire_params = serde_json::to_value(params)?;
7738 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7739 let _value = self
7740 .session
7741 .client()
7742 .call(
7743 rpc_methods::SESSION_PERMISSIONS_CONFIGURE,
7744 Some(wire_params),
7745 )
7746 .await?;
7747 Ok(serde_json::from_value(_value)?)
7748 }
7749
7750 /// Provides a decision for a pending tool permission request.
7751 ///
7752 /// Wire method: `session.permissions.handlePendingPermissionRequest`.
7753 ///
7754 /// # Parameters
7755 ///
7756 /// * `params` - Pending permission request ID and the decision to apply (approve/reject and scope).
7757 ///
7758 /// # Returns
7759 ///
7760 /// Indicates whether the permission decision was applied; false when the request was already resolved.
7761 ///
7762 /// <div class="warning">
7763 ///
7764 /// **Experimental.** This API is part of an experimental wire-protocol surface
7765 /// and may change or be removed in future SDK or CLI releases. Pin both the
7766 /// SDK and CLI versions if your code depends on it.
7767 ///
7768 /// </div>
7769 pub async fn handle_pending_permission_request(
7770 &self,
7771 params: PermissionDecisionRequest,
7772 ) -> Result<PermissionRequestResult, Error> {
7773 let mut wire_params = serde_json::to_value(params)?;
7774 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7775 let _value = self
7776 .session
7777 .client()
7778 .call(
7779 rpc_methods::SESSION_PERMISSIONS_HANDLEPENDINGPERMISSIONREQUEST,
7780 Some(wire_params),
7781 )
7782 .await?;
7783 Ok(serde_json::from_value(_value)?)
7784 }
7785
7786 /// Reconstructs the set of pending tool permission requests from the session's event history.
7787 ///
7788 /// Wire method: `session.permissions.pendingRequests`.
7789 ///
7790 /// # Returns
7791 ///
7792 /// List of pending permission requests reconstructed from event history.
7793 ///
7794 /// <div class="warning">
7795 ///
7796 /// **Experimental.** This API is part of an experimental wire-protocol surface
7797 /// and may change or be removed in future SDK or CLI releases. Pin both the
7798 /// SDK and CLI versions if your code depends on it.
7799 ///
7800 /// </div>
7801 pub async fn pending_requests(&self) -> Result<PendingPermissionRequestList, Error> {
7802 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7803 let _value = self
7804 .session
7805 .client()
7806 .call(
7807 rpc_methods::SESSION_PERMISSIONS_PENDINGREQUESTS,
7808 Some(wire_params),
7809 )
7810 .await?;
7811 Ok(serde_json::from_value(_value)?)
7812 }
7813
7814 /// Enables or disables automatic approval of tool permission requests for the session.
7815 ///
7816 /// Wire method: `session.permissions.setApproveAll`.
7817 ///
7818 /// # Parameters
7819 ///
7820 /// * `params` - Allow-all toggle for tool permission requests, with an optional telemetry source.
7821 ///
7822 /// # Returns
7823 ///
7824 /// Indicates whether the operation succeeded.
7825 ///
7826 /// <div class="warning">
7827 ///
7828 /// **Experimental.** This API is part of an experimental wire-protocol surface
7829 /// and may change or be removed in future SDK or CLI releases. Pin both the
7830 /// SDK and CLI versions if your code depends on it.
7831 ///
7832 /// </div>
7833 pub async fn set_approve_all(
7834 &self,
7835 params: PermissionsSetApproveAllRequest,
7836 ) -> Result<PermissionsSetApproveAllResult, Error> {
7837 let mut wire_params = serde_json::to_value(params)?;
7838 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7839 let _value = self
7840 .session
7841 .client()
7842 .call(
7843 rpc_methods::SESSION_PERMISSIONS_SETAPPROVEALL,
7844 Some(wire_params),
7845 )
7846 .await?;
7847 Ok(serde_json::from_value(_value)?)
7848 }
7849
7850 /// 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.
7851 ///
7852 /// Wire method: `session.permissions.setMode`.
7853 ///
7854 /// # Parameters
7855 ///
7856 /// * `params` - Permission mode to apply for the session.
7857 ///
7858 /// # Returns
7859 ///
7860 /// Indicates whether the requested permission mode was applied and reports the authoritative post-mutation mode.
7861 ///
7862 /// <div class="warning">
7863 ///
7864 /// **Experimental.** This API is part of an experimental wire-protocol surface
7865 /// and may change or be removed in future SDK or CLI releases. Pin both the
7866 /// SDK and CLI versions if your code depends on it.
7867 ///
7868 /// </div>
7869 pub async fn set_mode(
7870 &self,
7871 params: PermissionsSetModeRequest,
7872 ) -> Result<PermissionsSetModeResult, Error> {
7873 let mut wire_params = serde_json::to_value(params)?;
7874 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7875 let _value = self
7876 .session
7877 .client()
7878 .call(rpc_methods::SESSION_PERMISSIONS_SETMODE, Some(wire_params))
7879 .await?;
7880 Ok(serde_json::from_value(_value)?)
7881 }
7882
7883 /// Returns the current permission mode for the session.
7884 ///
7885 /// Wire method: `session.permissions.getMode`.
7886 ///
7887 /// # Returns
7888 ///
7889 /// Current permission mode.
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 get_mode(&self) -> Result<PermissionsGetModeResult, Error> {
7899 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7900 let _value = self
7901 .session
7902 .client()
7903 .call(rpc_methods::SESSION_PERMISSIONS_GETMODE, Some(wire_params))
7904 .await?;
7905 Ok(serde_json::from_value(_value)?)
7906 }
7907
7908 /// Adds or removes session-scoped or location-scoped permission rules.
7909 ///
7910 /// Wire method: `session.permissions.modifyRules`.
7911 ///
7912 /// # Parameters
7913 ///
7914 /// * `params` - Scope and add/remove instructions for modifying session- or location-scoped permission rules.
7915 ///
7916 /// # Returns
7917 ///
7918 /// Indicates whether the operation succeeded.
7919 ///
7920 /// <div class="warning">
7921 ///
7922 /// **Experimental.** This API is part of an experimental wire-protocol surface
7923 /// and may change or be removed in future SDK or CLI releases. Pin both the
7924 /// SDK and CLI versions if your code depends on it.
7925 ///
7926 /// </div>
7927 pub async fn modify_rules(
7928 &self,
7929 params: PermissionsModifyRulesParams,
7930 ) -> Result<PermissionsModifyRulesResult, Error> {
7931 let mut wire_params = serde_json::to_value(params)?;
7932 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7933 let _value = self
7934 .session
7935 .client()
7936 .call(
7937 rpc_methods::SESSION_PERMISSIONS_MODIFYRULES,
7938 Some(wire_params),
7939 )
7940 .await?;
7941 Ok(serde_json::from_value(_value)?)
7942 }
7943
7944 /// Sets whether the client wants permission prompts bridged into session events.
7945 ///
7946 /// Wire method: `session.permissions.setRequired`.
7947 ///
7948 /// # Parameters
7949 ///
7950 /// * `params` - Toggles whether permission prompts should be bridged into session events for this client.
7951 ///
7952 /// # Returns
7953 ///
7954 /// Indicates whether the operation succeeded.
7955 ///
7956 /// <div class="warning">
7957 ///
7958 /// **Experimental.** This API is part of an experimental wire-protocol surface
7959 /// and may change or be removed in future SDK or CLI releases. Pin both the
7960 /// SDK and CLI versions if your code depends on it.
7961 ///
7962 /// </div>
7963 pub async fn set_required(
7964 &self,
7965 params: PermissionsSetRequiredRequest,
7966 ) -> Result<PermissionsSetRequiredResult, Error> {
7967 let mut wire_params = serde_json::to_value(params)?;
7968 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7969 let _value = self
7970 .session
7971 .client()
7972 .call(
7973 rpc_methods::SESSION_PERMISSIONS_SETREQUIRED,
7974 Some(wire_params),
7975 )
7976 .await?;
7977 Ok(serde_json::from_value(_value)?)
7978 }
7979
7980 /// Clears session-scoped tool permission approvals.
7981 ///
7982 /// Wire method: `session.permissions.resetSessionApprovals`.
7983 ///
7984 /// # Parameters
7985 ///
7986 /// * `params` - Clears session-scoped tool permission approvals, and optionally the location-scoped ones.
7987 ///
7988 /// # Returns
7989 ///
7990 /// Indicates whether the operation succeeded.
7991 ///
7992 /// <div class="warning">
7993 ///
7994 /// **Experimental.** This API is part of an experimental wire-protocol surface
7995 /// and may change or be removed in future SDK or CLI releases. Pin both the
7996 /// SDK and CLI versions if your code depends on it.
7997 ///
7998 /// </div>
7999 pub async fn reset_session_approvals(
8000 &self,
8001 params: PermissionsResetSessionApprovalsRequest,
8002 ) -> Result<PermissionsResetSessionApprovalsResult, Error> {
8003 let mut wire_params = serde_json::to_value(params)?;
8004 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8005 let _value = self
8006 .session
8007 .client()
8008 .call(
8009 rpc_methods::SESSION_PERMISSIONS_RESETSESSIONAPPROVALS,
8010 Some(wire_params),
8011 )
8012 .await?;
8013 Ok(serde_json::from_value(_value)?)
8014 }
8015
8016 /// Notifies the runtime that a permission prompt UI has been shown to the user.
8017 ///
8018 /// Wire method: `session.permissions.notifyPromptShown`.
8019 ///
8020 /// # Parameters
8021 ///
8022 /// * `params` - Notification payload describing the permission prompt that the client just rendered.
8023 ///
8024 /// # Returns
8025 ///
8026 /// Indicates whether the operation succeeded.
8027 ///
8028 /// <div class="warning">
8029 ///
8030 /// **Experimental.** This API is part of an experimental wire-protocol surface
8031 /// and may change or be removed in future SDK or CLI releases. Pin both the
8032 /// SDK and CLI versions if your code depends on it.
8033 ///
8034 /// </div>
8035 pub async fn notify_prompt_shown(
8036 &self,
8037 params: PermissionPromptShownNotification,
8038 ) -> Result<PermissionsNotifyPromptShownResult, Error> {
8039 let mut wire_params = serde_json::to_value(params)?;
8040 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8041 let _value = self
8042 .session
8043 .client()
8044 .call(
8045 rpc_methods::SESSION_PERMISSIONS_NOTIFYPROMPTSHOWN,
8046 Some(wire_params),
8047 )
8048 .await?;
8049 Ok(serde_json::from_value(_value)?)
8050 }
8051}
8052
8053/// `session.permissions.folderTrust.*` RPCs.
8054#[derive(Clone, Copy)]
8055pub struct SessionRpcPermissionsFolderTrust<'a> {
8056 pub(crate) session: &'a Session,
8057}
8058
8059impl<'a> SessionRpcPermissionsFolderTrust<'a> {
8060 /// Reports whether a folder is trusted according to the user's folder trust state.
8061 ///
8062 /// Wire method: `session.permissions.folderTrust.isTrusted`.
8063 ///
8064 /// # Parameters
8065 ///
8066 /// * `params` - Folder path to check for trust.
8067 ///
8068 /// # Returns
8069 ///
8070 /// Folder trust check result.
8071 ///
8072 /// <div class="warning">
8073 ///
8074 /// **Experimental.** This API is part of an experimental wire-protocol surface
8075 /// and may change or be removed in future SDK or CLI releases. Pin both the
8076 /// SDK and CLI versions if your code depends on it.
8077 ///
8078 /// </div>
8079 pub async fn is_trusted(
8080 &self,
8081 params: FolderTrustCheckParams,
8082 ) -> Result<FolderTrustCheckResult, Error> {
8083 let mut wire_params = serde_json::to_value(params)?;
8084 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8085 let _value = self
8086 .session
8087 .client()
8088 .call(
8089 rpc_methods::SESSION_PERMISSIONS_FOLDERTRUST_ISTRUSTED,
8090 Some(wire_params),
8091 )
8092 .await?;
8093 Ok(serde_json::from_value(_value)?)
8094 }
8095
8096 /// Adds a folder to the user's trusted folders list.
8097 ///
8098 /// Wire method: `session.permissions.folderTrust.addTrusted`.
8099 ///
8100 /// # Parameters
8101 ///
8102 /// * `params` - Folder path to add to trusted folders.
8103 ///
8104 /// # Returns
8105 ///
8106 /// Indicates whether the operation succeeded.
8107 ///
8108 /// <div class="warning">
8109 ///
8110 /// **Experimental.** This API is part of an experimental wire-protocol surface
8111 /// and may change or be removed in future SDK or CLI releases. Pin both the
8112 /// SDK and CLI versions if your code depends on it.
8113 ///
8114 /// </div>
8115 pub async fn add_trusted(
8116 &self,
8117 params: FolderTrustAddParams,
8118 ) -> Result<PermissionsFolderTrustAddTrustedResult, Error> {
8119 let mut wire_params = serde_json::to_value(params)?;
8120 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8121 let _value = self
8122 .session
8123 .client()
8124 .call(
8125 rpc_methods::SESSION_PERMISSIONS_FOLDERTRUST_ADDTRUSTED,
8126 Some(wire_params),
8127 )
8128 .await?;
8129 Ok(serde_json::from_value(_value)?)
8130 }
8131}
8132
8133/// `session.permissions.locations.*` RPCs.
8134#[derive(Clone, Copy)]
8135pub struct SessionRpcPermissionsLocations<'a> {
8136 pub(crate) session: &'a Session,
8137}
8138
8139impl<'a> SessionRpcPermissionsLocations<'a> {
8140 /// Resolves the permission location key and type for a working directory.
8141 ///
8142 /// Wire method: `session.permissions.locations.resolve`.
8143 ///
8144 /// # Parameters
8145 ///
8146 /// * `params` - Working directory to resolve into a location-permissions key.
8147 ///
8148 /// # Returns
8149 ///
8150 /// Resolved location-permissions key and type.
8151 ///
8152 /// <div class="warning">
8153 ///
8154 /// **Experimental.** This API is part of an experimental wire-protocol surface
8155 /// and may change or be removed in future SDK or CLI releases. Pin both the
8156 /// SDK and CLI versions if your code depends on it.
8157 ///
8158 /// </div>
8159 pub async fn resolve(
8160 &self,
8161 params: PermissionLocationResolveParams,
8162 ) -> Result<PermissionLocationResolveResult, Error> {
8163 let mut wire_params = serde_json::to_value(params)?;
8164 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8165 let _value = self
8166 .session
8167 .client()
8168 .call(
8169 rpc_methods::SESSION_PERMISSIONS_LOCATIONS_RESOLVE,
8170 Some(wire_params),
8171 )
8172 .await?;
8173 Ok(serde_json::from_value(_value)?)
8174 }
8175
8176 /// Applies persisted location-scoped tool approvals and allowed directories for a working directory to this session's permission service.
8177 ///
8178 /// Wire method: `session.permissions.locations.apply`.
8179 ///
8180 /// # Parameters
8181 ///
8182 /// * `params` - Working directory to load persisted location permissions for.
8183 ///
8184 /// # Returns
8185 ///
8186 /// Summary of persisted location permissions applied to the session.
8187 ///
8188 /// <div class="warning">
8189 ///
8190 /// **Experimental.** This API is part of an experimental wire-protocol surface
8191 /// and may change or be removed in future SDK or CLI releases. Pin both the
8192 /// SDK and CLI versions if your code depends on it.
8193 ///
8194 /// </div>
8195 pub async fn apply(
8196 &self,
8197 params: PermissionLocationApplyParams,
8198 ) -> Result<PermissionLocationApplyResult, Error> {
8199 let mut wire_params = serde_json::to_value(params)?;
8200 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8201 let _value = self
8202 .session
8203 .client()
8204 .call(
8205 rpc_methods::SESSION_PERMISSIONS_LOCATIONS_APPLY,
8206 Some(wire_params),
8207 )
8208 .await?;
8209 Ok(serde_json::from_value(_value)?)
8210 }
8211
8212 /// Persists a tool approval for a permission location and applies its rules to this session's live permission service.
8213 ///
8214 /// Wire method: `session.permissions.locations.addToolApproval`.
8215 ///
8216 /// # Parameters
8217 ///
8218 /// * `params` - Location-scoped tool approval to persist.
8219 ///
8220 /// # Returns
8221 ///
8222 /// Indicates whether the operation succeeded.
8223 ///
8224 /// <div class="warning">
8225 ///
8226 /// **Experimental.** This API is part of an experimental wire-protocol surface
8227 /// and may change or be removed in future SDK or CLI releases. Pin both the
8228 /// SDK and CLI versions if your code depends on it.
8229 ///
8230 /// </div>
8231 pub async fn add_tool_approval(
8232 &self,
8233 params: PermissionLocationAddToolApprovalParams,
8234 ) -> Result<PermissionsLocationsAddToolApprovalResult, Error> {
8235 let mut wire_params = serde_json::to_value(params)?;
8236 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8237 let _value = self
8238 .session
8239 .client()
8240 .call(
8241 rpc_methods::SESSION_PERMISSIONS_LOCATIONS_ADDTOOLAPPROVAL,
8242 Some(wire_params),
8243 )
8244 .await?;
8245 Ok(serde_json::from_value(_value)?)
8246 }
8247}
8248
8249/// `session.permissions.paths.*` RPCs.
8250#[derive(Clone, Copy)]
8251pub struct SessionRpcPermissionsPaths<'a> {
8252 pub(crate) session: &'a Session,
8253}
8254
8255impl<'a> SessionRpcPermissionsPaths<'a> {
8256 /// Returns the session's allowed directories and primary working directory.
8257 ///
8258 /// Wire method: `session.permissions.paths.list`.
8259 ///
8260 /// # Returns
8261 ///
8262 /// Snapshot of the session's allow-listed directories and primary working directory.
8263 ///
8264 /// <div class="warning">
8265 ///
8266 /// **Experimental.** This API is part of an experimental wire-protocol surface
8267 /// and may change or be removed in future SDK or CLI releases. Pin both the
8268 /// SDK and CLI versions if your code depends on it.
8269 ///
8270 /// </div>
8271 pub async fn list(&self) -> Result<PermissionPathsList, Error> {
8272 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8273 let _value = self
8274 .session
8275 .client()
8276 .call(
8277 rpc_methods::SESSION_PERMISSIONS_PATHS_LIST,
8278 Some(wire_params),
8279 )
8280 .await?;
8281 Ok(serde_json::from_value(_value)?)
8282 }
8283
8284 /// Adds a directory to the session's allow-list and activates conventional skill and agent definitions under it.
8285 ///
8286 /// Wire method: `session.permissions.paths.add`.
8287 ///
8288 /// # Parameters
8289 ///
8290 /// * `params` - Directory path to add to the session's allowed directories.
8291 ///
8292 /// # Returns
8293 ///
8294 /// Indicates whether the operation succeeded.
8295 ///
8296 /// <div class="warning">
8297 ///
8298 /// **Experimental.** This API is part of an experimental wire-protocol surface
8299 /// and may change or be removed in future SDK or CLI releases. Pin both the
8300 /// SDK and CLI versions if your code depends on it.
8301 ///
8302 /// </div>
8303 pub async fn add(
8304 &self,
8305 params: PermissionPathsAddParams,
8306 ) -> Result<PermissionsPathsAddResult, Error> {
8307 let mut wire_params = serde_json::to_value(params)?;
8308 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8309 let _value = self
8310 .session
8311 .client()
8312 .call(
8313 rpc_methods::SESSION_PERMISSIONS_PATHS_ADD,
8314 Some(wire_params),
8315 )
8316 .await?;
8317 Ok(serde_json::from_value(_value)?)
8318 }
8319
8320 /// Updates the session's primary working directory used by the permission policy.
8321 ///
8322 /// Wire method: `session.permissions.paths.updatePrimary`.
8323 ///
8324 /// # Parameters
8325 ///
8326 /// * `params` - Directory path to set as the session's new primary working directory.
8327 ///
8328 /// # Returns
8329 ///
8330 /// Indicates whether the operation succeeded.
8331 ///
8332 /// <div class="warning">
8333 ///
8334 /// **Experimental.** This API is part of an experimental wire-protocol surface
8335 /// and may change or be removed in future SDK or CLI releases. Pin both the
8336 /// SDK and CLI versions if your code depends on it.
8337 ///
8338 /// </div>
8339 pub async fn update_primary(
8340 &self,
8341 params: PermissionPathsUpdatePrimaryParams,
8342 ) -> Result<PermissionsPathsUpdatePrimaryResult, Error> {
8343 let mut wire_params = serde_json::to_value(params)?;
8344 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8345 let _value = self
8346 .session
8347 .client()
8348 .call(
8349 rpc_methods::SESSION_PERMISSIONS_PATHS_UPDATEPRIMARY,
8350 Some(wire_params),
8351 )
8352 .await?;
8353 Ok(serde_json::from_value(_value)?)
8354 }
8355
8356 /// Reports whether a path falls within any of the session's allowed directories.
8357 ///
8358 /// Wire method: `session.permissions.paths.isPathWithinAllowedDirectories`.
8359 ///
8360 /// # Parameters
8361 ///
8362 /// * `params` - Path to evaluate against the session's allowed directories.
8363 ///
8364 /// # Returns
8365 ///
8366 /// Indicates whether the supplied path is within the session's allowed directories.
8367 ///
8368 /// <div class="warning">
8369 ///
8370 /// **Experimental.** This API is part of an experimental wire-protocol surface
8371 /// and may change or be removed in future SDK or CLI releases. Pin both the
8372 /// SDK and CLI versions if your code depends on it.
8373 ///
8374 /// </div>
8375 pub async fn is_path_within_allowed_directories(
8376 &self,
8377 params: PermissionPathsAllowedCheckParams,
8378 ) -> Result<PermissionPathsAllowedCheckResult, Error> {
8379 let mut wire_params = serde_json::to_value(params)?;
8380 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8381 let _value = self
8382 .session
8383 .client()
8384 .call(
8385 rpc_methods::SESSION_PERMISSIONS_PATHS_ISPATHWITHINALLOWEDDIRECTORIES,
8386 Some(wire_params),
8387 )
8388 .await?;
8389 Ok(serde_json::from_value(_value)?)
8390 }
8391
8392 /// Reports whether a path falls within the session's workspace (primary) directory.
8393 ///
8394 /// Wire method: `session.permissions.paths.isPathWithinWorkspace`.
8395 ///
8396 /// # Parameters
8397 ///
8398 /// * `params` - Path to evaluate against the session's workspace (primary) directory.
8399 ///
8400 /// # Returns
8401 ///
8402 /// Indicates whether the supplied path is within the session's workspace directory.
8403 ///
8404 /// <div class="warning">
8405 ///
8406 /// **Experimental.** This API is part of an experimental wire-protocol surface
8407 /// and may change or be removed in future SDK or CLI releases. Pin both the
8408 /// SDK and CLI versions if your code depends on it.
8409 ///
8410 /// </div>
8411 pub async fn is_path_within_workspace(
8412 &self,
8413 params: PermissionPathsWorkspaceCheckParams,
8414 ) -> Result<PermissionPathsWorkspaceCheckResult, Error> {
8415 let mut wire_params = serde_json::to_value(params)?;
8416 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8417 let _value = self
8418 .session
8419 .client()
8420 .call(
8421 rpc_methods::SESSION_PERMISSIONS_PATHS_ISPATHWITHINWORKSPACE,
8422 Some(wire_params),
8423 )
8424 .await?;
8425 Ok(serde_json::from_value(_value)?)
8426 }
8427}
8428
8429/// `session.permissions.urls.*` RPCs.
8430#[derive(Clone, Copy)]
8431pub struct SessionRpcPermissionsUrls<'a> {
8432 pub(crate) session: &'a Session,
8433}
8434
8435impl<'a> SessionRpcPermissionsUrls<'a> {
8436 /// Toggles the runtime's URL-permission policy between unrestricted and restricted modes.
8437 ///
8438 /// Wire method: `session.permissions.urls.setUnrestrictedMode`.
8439 ///
8440 /// # Parameters
8441 ///
8442 /// * `params` - Whether the URL-permission policy should run in unrestricted mode.
8443 ///
8444 /// # Returns
8445 ///
8446 /// Indicates whether the operation succeeded.
8447 ///
8448 /// <div class="warning">
8449 ///
8450 /// **Experimental.** This API is part of an experimental wire-protocol surface
8451 /// and may change or be removed in future SDK or CLI releases. Pin both the
8452 /// SDK and CLI versions if your code depends on it.
8453 ///
8454 /// </div>
8455 pub async fn set_unrestricted_mode(
8456 &self,
8457 params: PermissionUrlsSetUnrestrictedModeParams,
8458 ) -> Result<PermissionsUrlsSetUnrestrictedModeResult, Error> {
8459 let mut wire_params = serde_json::to_value(params)?;
8460 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8461 let _value = self
8462 .session
8463 .client()
8464 .call(
8465 rpc_methods::SESSION_PERMISSIONS_URLS_SETUNRESTRICTEDMODE,
8466 Some(wire_params),
8467 )
8468 .await?;
8469 Ok(serde_json::from_value(_value)?)
8470 }
8471}
8472
8473/// `session.plan.*` RPCs.
8474#[derive(Clone, Copy)]
8475pub struct SessionRpcPlan<'a> {
8476 pub(crate) session: &'a Session,
8477}
8478
8479impl<'a> SessionRpcPlan<'a> {
8480 /// Reads the session plan file from the workspace.
8481 ///
8482 /// Wire method: `session.plan.read`.
8483 ///
8484 /// # Returns
8485 ///
8486 /// Existence, contents, and resolved path of the session plan file.
8487 ///
8488 /// <div class="warning">
8489 ///
8490 /// **Experimental.** This API is part of an experimental wire-protocol surface
8491 /// and may change or be removed in future SDK or CLI releases. Pin both the
8492 /// SDK and CLI versions if your code depends on it.
8493 ///
8494 /// </div>
8495 pub async fn read(&self) -> Result<PlanReadResult, Error> {
8496 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8497 let _value = self
8498 .session
8499 .client()
8500 .call(rpc_methods::SESSION_PLAN_READ, Some(wire_params))
8501 .await?;
8502 Ok(serde_json::from_value(_value)?)
8503 }
8504
8505 /// Writes new content to the session plan file.
8506 ///
8507 /// Wire method: `session.plan.update`.
8508 ///
8509 /// # Parameters
8510 ///
8511 /// * `params` - Replacement contents to write to the session plan file.
8512 ///
8513 /// <div class="warning">
8514 ///
8515 /// **Experimental.** This API is part of an experimental wire-protocol surface
8516 /// and may change or be removed in future SDK or CLI releases. Pin both the
8517 /// SDK and CLI versions if your code depends on it.
8518 ///
8519 /// </div>
8520 pub async fn update(&self, params: PlanUpdateRequest) -> Result<(), Error> {
8521 let mut wire_params = serde_json::to_value(params)?;
8522 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8523 let _value = self
8524 .session
8525 .client()
8526 .call(rpc_methods::SESSION_PLAN_UPDATE, Some(wire_params))
8527 .await?;
8528 Ok(())
8529 }
8530
8531 /// Deletes the session plan file from the workspace.
8532 ///
8533 /// Wire method: `session.plan.delete`.
8534 ///
8535 /// <div class="warning">
8536 ///
8537 /// **Experimental.** This API is part of an experimental wire-protocol surface
8538 /// and may change or be removed in future SDK or CLI releases. Pin both the
8539 /// SDK and CLI versions if your code depends on it.
8540 ///
8541 /// </div>
8542 pub async fn delete(&self) -> Result<(), Error> {
8543 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8544 let _value = self
8545 .session
8546 .client()
8547 .call(rpc_methods::SESSION_PLAN_DELETE, Some(wire_params))
8548 .await?;
8549 Ok(())
8550 }
8551
8552 /// Reads todo rows from the session SQL database for plan rendering.
8553 ///
8554 /// Wire method: `session.plan.readSqlTodos`.
8555 ///
8556 /// # Returns
8557 ///
8558 /// Todo rows read from the session SQL database. Empty when no session database is available.
8559 ///
8560 /// <div class="warning">
8561 ///
8562 /// **Experimental.** This API is part of an experimental wire-protocol surface
8563 /// and may change or be removed in future SDK or CLI releases. Pin both the
8564 /// SDK and CLI versions if your code depends on it.
8565 ///
8566 /// </div>
8567 pub async fn read_sql_todos(&self) -> Result<PlanReadSqlTodosResult, Error> {
8568 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8569 let _value = self
8570 .session
8571 .client()
8572 .call(rpc_methods::SESSION_PLAN_READSQLTODOS, Some(wire_params))
8573 .await?;
8574 Ok(serde_json::from_value(_value)?)
8575 }
8576
8577 /// 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.
8578 ///
8579 /// Wire method: `session.plan.readSqlTodosWithDependencies`.
8580 ///
8581 /// # Returns
8582 ///
8583 /// Todo rows + dependency edges read from the session SQL database.
8584 ///
8585 /// <div class="warning">
8586 ///
8587 /// **Experimental.** This API is part of an experimental wire-protocol surface
8588 /// and may change or be removed in future SDK or CLI releases. Pin both the
8589 /// SDK and CLI versions if your code depends on it.
8590 ///
8591 /// </div>
8592 pub async fn read_sql_todos_with_dependencies(
8593 &self,
8594 ) -> Result<PlanReadSqlTodosWithDependenciesResult, Error> {
8595 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8596 let _value = self
8597 .session
8598 .client()
8599 .call(
8600 rpc_methods::SESSION_PLAN_READSQLTODOSWITHDEPENDENCIES,
8601 Some(wire_params),
8602 )
8603 .await?;
8604 Ok(serde_json::from_value(_value)?)
8605 }
8606}
8607
8608/// `session.plugins.*` RPCs.
8609#[derive(Clone, Copy)]
8610pub struct SessionRpcPlugins<'a> {
8611 pub(crate) session: &'a Session,
8612}
8613
8614impl<'a> SessionRpcPlugins<'a> {
8615 /// Lists plugins installed for the session.
8616 ///
8617 /// Wire method: `session.plugins.list`.
8618 ///
8619 /// # Returns
8620 ///
8621 /// Plugins installed for the session, with their enabled state and version metadata.
8622 ///
8623 /// <div class="warning">
8624 ///
8625 /// **Experimental.** This API is part of an experimental wire-protocol surface
8626 /// and may change or be removed in future SDK or CLI releases. Pin both the
8627 /// SDK and CLI versions if your code depends on it.
8628 ///
8629 /// </div>
8630 pub async fn list(&self) -> Result<PluginList, Error> {
8631 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8632 let _value = self
8633 .session
8634 .client()
8635 .call(rpc_methods::SESSION_PLUGINS_LIST, Some(wire_params))
8636 .await?;
8637 Ok(serde_json::from_value(_value)?)
8638 }
8639
8640 /// 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.
8641 ///
8642 /// Wire method: `session.plugins.reload`.
8643 ///
8644 /// <div class="warning">
8645 ///
8646 /// **Experimental.** This API is part of an experimental wire-protocol surface
8647 /// and may change or be removed in future SDK or CLI releases. Pin both the
8648 /// SDK and CLI versions if your code depends on it.
8649 ///
8650 /// </div>
8651 pub async fn reload(&self) -> Result<(), Error> {
8652 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8653 let _value = self
8654 .session
8655 .client()
8656 .call(rpc_methods::SESSION_PLUGINS_RELOAD, Some(wire_params))
8657 .await?;
8658 Ok(())
8659 }
8660
8661 /// 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.
8662 ///
8663 /// Wire method: `session.plugins.reload`.
8664 ///
8665 /// # Parameters
8666 ///
8667 /// * `params` - Optional flags controlling which side effects the reload performs.
8668 ///
8669 /// <div class="warning">
8670 ///
8671 /// **Experimental.** This API is part of an experimental wire-protocol surface
8672 /// and may change or be removed in future SDK or CLI releases. Pin both the
8673 /// SDK and CLI versions if your code depends on it.
8674 ///
8675 /// </div>
8676 pub async fn reload_with_params(&self, params: PluginsReloadRequest) -> Result<(), Error> {
8677 let mut wire_params = serde_json::to_value(params)?;
8678 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8679 let _value = self
8680 .session
8681 .client()
8682 .call(rpc_methods::SESSION_PLUGINS_RELOAD, Some(wire_params))
8683 .await?;
8684 Ok(())
8685 }
8686}
8687
8688/// `session.provider.*` RPCs.
8689#[derive(Clone, Copy)]
8690pub struct SessionRpcProvider<'a> {
8691 pub(crate) session: &'a Session,
8692}
8693
8694impl<'a> SessionRpcProvider<'a> {
8695 /// 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.
8696 ///
8697 /// Wire method: `session.provider.getEndpoint`.
8698 ///
8699 /// # Returns
8700 ///
8701 /// A snapshot of the provider endpoint the session is currently configured to talk to.
8702 ///
8703 /// <div class="warning">
8704 ///
8705 /// **Experimental.** This API is part of an experimental wire-protocol surface
8706 /// and may change or be removed in future SDK or CLI releases. Pin both the
8707 /// SDK and CLI versions if your code depends on it.
8708 ///
8709 /// </div>
8710 pub async fn get_endpoint(&self) -> Result<ProviderEndpoint, Error> {
8711 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8712 let _value = self
8713 .session
8714 .client()
8715 .call(rpc_methods::SESSION_PROVIDER_GETENDPOINT, Some(wire_params))
8716 .await?;
8717 Ok(serde_json::from_value(_value)?)
8718 }
8719
8720 /// 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.
8721 ///
8722 /// Wire method: `session.provider.getEndpoint`.
8723 ///
8724 /// # Parameters
8725 ///
8726 /// * `params` - Optional model identifier to scope the endpoint snapshot to.
8727 ///
8728 /// # Returns
8729 ///
8730 /// A snapshot of the provider endpoint the session is currently configured to talk to.
8731 ///
8732 /// <div class="warning">
8733 ///
8734 /// **Experimental.** This API is part of an experimental wire-protocol surface
8735 /// and may change or be removed in future SDK or CLI releases. Pin both the
8736 /// SDK and CLI versions if your code depends on it.
8737 ///
8738 /// </div>
8739 pub async fn get_endpoint_with_params(
8740 &self,
8741 params: ProviderGetEndpointRequest,
8742 ) -> Result<ProviderEndpoint, Error> {
8743 let mut wire_params = serde_json::to_value(params)?;
8744 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8745 let _value = self
8746 .session
8747 .client()
8748 .call(rpc_methods::SESSION_PROVIDER_GETENDPOINT, Some(wire_params))
8749 .await?;
8750 Ok(serde_json::from_value(_value)?)
8751 }
8752
8753 /// 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.
8754 ///
8755 /// Wire method: `session.provider.add`.
8756 ///
8757 /// # Parameters
8758 ///
8759 /// * `params` - BYOK providers and/or models to add to the session's registry at runtime. Both fields are optional; provide providers, models, or both.
8760 ///
8761 /// # Returns
8762 ///
8763 /// The selectable model entries synthesized for the models added by this call.
8764 ///
8765 /// <div class="warning">
8766 ///
8767 /// **Experimental.** This API is part of an experimental wire-protocol surface
8768 /// and may change or be removed in future SDK or CLI releases. Pin both the
8769 /// SDK and CLI versions if your code depends on it.
8770 ///
8771 /// </div>
8772 pub async fn add(&self, params: ProviderAddRequest) -> Result<ProviderAddResult, 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(rpc_methods::SESSION_PROVIDER_ADD, Some(wire_params))
8779 .await?;
8780 Ok(serde_json::from_value(_value)?)
8781 }
8782}
8783
8784/// `session.queue.*` RPCs.
8785#[derive(Clone, Copy)]
8786pub struct SessionRpcQueue<'a> {
8787 pub(crate) session: &'a Session,
8788}
8789
8790impl<'a> SessionRpcQueue<'a> {
8791 /// Returns the local session's pending user-facing queued items and steering messages.
8792 ///
8793 /// Wire method: `session.queue.pendingItems`.
8794 ///
8795 /// # Returns
8796 ///
8797 /// Snapshot of the session's pending queued items and immediate-steering messages.
8798 ///
8799 /// <div class="warning">
8800 ///
8801 /// **Experimental.** This API is part of an experimental wire-protocol surface
8802 /// and may change or be removed in future SDK or CLI releases. Pin both the
8803 /// SDK and CLI versions if your code depends on it.
8804 ///
8805 /// </div>
8806 pub async fn pending_items(&self) -> Result<QueuePendingItemsResult, Error> {
8807 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8808 let _value = self
8809 .session
8810 .client()
8811 .call(rpc_methods::SESSION_QUEUE_PENDINGITEMS, Some(wire_params))
8812 .await?;
8813 Ok(serde_json::from_value(_value)?)
8814 }
8815
8816 /// Returns the internal native queue snapshot for in-process session orchestration.
8817 ///
8818 /// Wire method: `session.queue.snapshot`.
8819 ///
8820 /// # Returns
8821 ///
8822 /// Internal snapshot of native queue state for local session orchestration.
8823 ///
8824 /// <div class="warning">
8825 ///
8826 /// **Experimental.** This API is part of an experimental wire-protocol surface
8827 /// and may change or be removed in future SDK or CLI releases. Pin both the
8828 /// SDK and CLI versions if your code depends on it.
8829 ///
8830 /// </div>
8831 pub(crate) async fn snapshot(&self) -> Result<QueueSnapshotResult, Error> {
8832 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8833 let _value = self
8834 .session
8835 .client()
8836 .call(rpc_methods::SESSION_QUEUE_SNAPSHOT, Some(wire_params))
8837 .await?;
8838 Ok(serde_json::from_value(_value)?)
8839 }
8840
8841 /// Moves an addressable queued item to a public visible position.
8842 ///
8843 /// Wire method: `session.queue.moveItem`.
8844 ///
8845 /// # Parameters
8846 ///
8847 /// * `params` - Parameters for moving a queued item by stable id.
8848 ///
8849 /// # Returns
8850 ///
8851 /// Result of moving a queued item.
8852 ///
8853 /// <div class="warning">
8854 ///
8855 /// **Experimental.** This API is part of an experimental wire-protocol surface
8856 /// and may change or be removed in future SDK or CLI releases. Pin both the
8857 /// SDK and CLI versions if your code depends on it.
8858 ///
8859 /// </div>
8860 pub async fn move_item(
8861 &self,
8862 params: QueueMoveItemRequest,
8863 ) -> Result<QueueMoveItemResult, Error> {
8864 let mut wire_params = serde_json::to_value(params)?;
8865 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8866 let _value = self
8867 .session
8868 .client()
8869 .call(rpc_methods::SESSION_QUEUE_MOVEITEM, Some(wire_params))
8870 .await?;
8871 Ok(serde_json::from_value(_value)?)
8872 }
8873
8874 /// Inserts a new queued message at a public visible position.
8875 ///
8876 /// Wire method: `session.queue.insertAt`.
8877 ///
8878 /// # Parameters
8879 ///
8880 /// * `params` - Parameters for inserting a queued message at a public visible position.
8881 ///
8882 /// # Returns
8883 ///
8884 /// Result of inserting a queued message.
8885 ///
8886 /// <div class="warning">
8887 ///
8888 /// **Experimental.** This API is part of an experimental wire-protocol surface
8889 /// and may change or be removed in future SDK or CLI releases. Pin both the
8890 /// SDK and CLI versions if your code depends on it.
8891 ///
8892 /// </div>
8893 pub async fn insert_at(
8894 &self,
8895 params: QueueInsertAtRequest,
8896 ) -> Result<QueueInsertAtResult, Error> {
8897 let mut wire_params = serde_json::to_value(params)?;
8898 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8899 let _value = self
8900 .session
8901 .client()
8902 .call(rpc_methods::SESSION_QUEUE_INSERTAT, Some(wire_params))
8903 .await?;
8904 Ok(serde_json::from_value(_value)?)
8905 }
8906
8907 /// Removes an addressable queued item by its stable id.
8908 ///
8909 /// Wire method: `session.queue.removeAt`.
8910 ///
8911 /// # Parameters
8912 ///
8913 /// * `params` - Parameters for removing a queued item by stable id.
8914 ///
8915 /// # Returns
8916 ///
8917 /// Result of removing a queued item.
8918 ///
8919 /// <div class="warning">
8920 ///
8921 /// **Experimental.** This API is part of an experimental wire-protocol surface
8922 /// and may change or be removed in future SDK or CLI releases. Pin both the
8923 /// SDK and CLI versions if your code depends on it.
8924 ///
8925 /// </div>
8926 pub async fn remove_at(
8927 &self,
8928 params: QueueRemoveAtRequest,
8929 ) -> Result<QueueRemoveAtResult, Error> {
8930 let mut wire_params = serde_json::to_value(params)?;
8931 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8932 let _value = self
8933 .session
8934 .client()
8935 .call(rpc_methods::SESSION_QUEUE_REMOVEAT, Some(wire_params))
8936 .await?;
8937 Ok(serde_json::from_value(_value)?)
8938 }
8939
8940 /// Updates the text of an addressable single-message queue item.
8941 ///
8942 /// Wire method: `session.queue.updateText`.
8943 ///
8944 /// # Parameters
8945 ///
8946 /// * `params` - Parameters for editing a single queued message.
8947 ///
8948 /// # Returns
8949 ///
8950 /// Result of editing a queued message.
8951 ///
8952 /// <div class="warning">
8953 ///
8954 /// **Experimental.** This API is part of an experimental wire-protocol surface
8955 /// and may change or be removed in future SDK or CLI releases. Pin both the
8956 /// SDK and CLI versions if your code depends on it.
8957 ///
8958 /// </div>
8959 pub async fn update_text(
8960 &self,
8961 params: QueueUpdateTextRequest,
8962 ) -> Result<QueueUpdateTextResult, Error> {
8963 let mut wire_params = serde_json::to_value(params)?;
8964 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8965 let _value = self
8966 .session
8967 .client()
8968 .call(rpc_methods::SESSION_QUEUE_UPDATETEXT, Some(wire_params))
8969 .await?;
8970 Ok(serde_json::from_value(_value)?)
8971 }
8972
8973 /// Duplicates an addressable queued item immediately after its source.
8974 ///
8975 /// Wire method: `session.queue.duplicateAt`.
8976 ///
8977 /// # Parameters
8978 ///
8979 /// * `params` - Parameters for duplicating a queued item.
8980 ///
8981 /// # Returns
8982 ///
8983 /// Result of duplicating a queued item.
8984 ///
8985 /// <div class="warning">
8986 ///
8987 /// **Experimental.** This API is part of an experimental wire-protocol surface
8988 /// and may change or be removed in future SDK or CLI releases. Pin both the
8989 /// SDK and CLI versions if your code depends on it.
8990 ///
8991 /// </div>
8992 pub async fn duplicate_at(
8993 &self,
8994 params: QueueDuplicateAtRequest,
8995 ) -> Result<QueueDuplicateAtResult, Error> {
8996 let mut wire_params = serde_json::to_value(params)?;
8997 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8998 let _value = self
8999 .session
9000 .client()
9001 .call(rpc_methods::SESSION_QUEUE_DUPLICATEAT, Some(wire_params))
9002 .await?;
9003 Ok(serde_json::from_value(_value)?)
9004 }
9005
9006 /// Acquires or releases the queued-lane drain pause.
9007 ///
9008 /// Wire method: `session.queue.setDrainPaused`.
9009 ///
9010 /// # Parameters
9011 ///
9012 /// * `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.
9013 ///
9014 /// <div class="warning">
9015 ///
9016 /// **Experimental.** This API is part of an experimental wire-protocol surface
9017 /// and may change or be removed in future SDK or CLI releases. Pin both the
9018 /// SDK and CLI versions if your code depends on it.
9019 ///
9020 /// </div>
9021 pub async fn set_drain_paused(&self, params: QueueSetDrainPausedRequest) -> Result<(), Error> {
9022 let mut wire_params = serde_json::to_value(params)?;
9023 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9024 let _value = self
9025 .session
9026 .client()
9027 .call(rpc_methods::SESSION_QUEUE_SETDRAINPAUSED, Some(wire_params))
9028 .await?;
9029 Ok(())
9030 }
9031
9032 /// Moves an addressable queued message into the live turn's steering lane.
9033 ///
9034 /// Wire method: `session.queue.sendNow`.
9035 ///
9036 /// # Parameters
9037 ///
9038 /// * `params` - Parameters for steering a queued message into a live turn.
9039 ///
9040 /// # Returns
9041 ///
9042 /// Result of trying to steer a queued message into a live turn.
9043 ///
9044 /// <div class="warning">
9045 ///
9046 /// **Experimental.** This API is part of an experimental wire-protocol surface
9047 /// and may change or be removed in future SDK or CLI releases. Pin both the
9048 /// SDK and CLI versions if your code depends on it.
9049 ///
9050 /// </div>
9051 pub async fn send_now(&self, params: QueueSendNowRequest) -> Result<QueueSendNowResult, Error> {
9052 let mut wire_params = serde_json::to_value(params)?;
9053 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9054 let _value = self
9055 .session
9056 .client()
9057 .call(rpc_methods::SESSION_QUEUE_SENDNOW, Some(wire_params))
9058 .await?;
9059 Ok(serde_json::from_value(_value)?)
9060 }
9061
9062 /// Reports whether the local session has native queued work pending.
9063 ///
9064 /// Wire method: `session.queue.hasPending`.
9065 ///
9066 /// # Returns
9067 ///
9068 /// Whether the native queue has pending work.
9069 ///
9070 /// <div class="warning">
9071 ///
9072 /// **Experimental.** This API is part of an experimental wire-protocol surface
9073 /// and may change or be removed in future SDK or CLI releases. Pin both the
9074 /// SDK and CLI versions if your code depends on it.
9075 ///
9076 /// </div>
9077 pub(crate) async fn has_pending(&self) -> Result<QueueHasPendingResult, Error> {
9078 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9079 let _value = self
9080 .session
9081 .client()
9082 .call(rpc_methods::SESSION_QUEUE_HASPENDING, Some(wire_params))
9083 .await?;
9084 Ok(serde_json::from_value(_value)?)
9085 }
9086
9087 /// Begins a native deferred-idle drain when background work has quiesced.
9088 ///
9089 /// Wire method: `session.queue.beginDeferredIdleDrain`.
9090 ///
9091 /// # Parameters
9092 ///
9093 /// * `params` - Inputs for starting a deferred-idle drain.
9094 ///
9095 /// # Returns
9096 ///
9097 /// Whether a deferred-idle drain should run.
9098 ///
9099 /// <div class="warning">
9100 ///
9101 /// **Experimental.** This API is part of an experimental wire-protocol surface
9102 /// and may change or be removed in future SDK or CLI releases. Pin both the
9103 /// SDK and CLI versions if your code depends on it.
9104 ///
9105 /// </div>
9106 pub(crate) async fn begin_deferred_idle_drain(
9107 &self,
9108 params: QueueBeginDeferredIdleDrainRequest,
9109 ) -> Result<QueueBeginDeferredIdleDrainResult, Error> {
9110 let mut wire_params = serde_json::to_value(params)?;
9111 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9112 let _value = self
9113 .session
9114 .client()
9115 .call(
9116 rpc_methods::SESSION_QUEUE_BEGINDEFERREDIDLEDRAIN,
9117 Some(wire_params),
9118 )
9119 .await?;
9120 Ok(serde_json::from_value(_value)?)
9121 }
9122
9123 /// Finishes a native deferred-idle drain and reports whether to drain queue work or emit idle.
9124 ///
9125 /// Wire method: `session.queue.finishDeferredIdleDrain`.
9126 ///
9127 /// # Parameters
9128 ///
9129 /// * `params` - Inputs for completing a deferred-idle drain.
9130 ///
9131 /// # Returns
9132 ///
9133 /// Action selected by the native deferred-idle drain.
9134 ///
9135 /// <div class="warning">
9136 ///
9137 /// **Experimental.** This API is part of an experimental wire-protocol surface
9138 /// and may change or be removed in future SDK or CLI releases. Pin both the
9139 /// SDK and CLI versions if your code depends on it.
9140 ///
9141 /// </div>
9142 pub(crate) async fn finish_deferred_idle_drain(
9143 &self,
9144 params: QueueFinishDeferredIdleDrainRequest,
9145 ) -> Result<QueueFinishDeferredIdleDrainResult, Error> {
9146 let mut wire_params = serde_json::to_value(params)?;
9147 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9148 let _value = self
9149 .session
9150 .client()
9151 .call(
9152 rpc_methods::SESSION_QUEUE_FINISHDEFERREDIDLEDRAIN,
9153 Some(wire_params),
9154 )
9155 .await?;
9156 Ok(serde_json::from_value(_value)?)
9157 }
9158
9159 /// Marks session.idle as deferred by native background work state.
9160 ///
9161 /// Wire method: `session.queue.deferSessionIdle`.
9162 ///
9163 /// # Parameters
9164 ///
9165 /// * `params` - Inputs for marking session.idle deferred in native state.
9166 ///
9167 /// <div class="warning">
9168 ///
9169 /// **Experimental.** This API is part of an experimental wire-protocol surface
9170 /// and may change or be removed in future SDK or CLI releases. Pin both the
9171 /// SDK and CLI versions if your code depends on it.
9172 ///
9173 /// </div>
9174 pub(crate) async fn defer_session_idle(
9175 &self,
9176 params: QueueDeferSessionIdleRequest,
9177 ) -> Result<(), Error> {
9178 let mut wire_params = serde_json::to_value(params)?;
9179 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9180 let _value = self
9181 .session
9182 .client()
9183 .call(
9184 rpc_methods::SESSION_QUEUE_DEFERSESSIONIDLE,
9185 Some(wire_params),
9186 )
9187 .await?;
9188 Ok(())
9189 }
9190
9191 /// Removes the most recently queued user-facing item (LIFO).
9192 ///
9193 /// Wire method: `session.queue.removeMostRecent`.
9194 ///
9195 /// # Returns
9196 ///
9197 /// Indicates whether a user-facing pending item was removed.
9198 ///
9199 /// <div class="warning">
9200 ///
9201 /// **Experimental.** This API is part of an experimental wire-protocol surface
9202 /// and may change or be removed in future SDK or CLI releases. Pin both the
9203 /// SDK and CLI versions if your code depends on it.
9204 ///
9205 /// </div>
9206 pub async fn remove_most_recent(&self) -> Result<QueueRemoveMostRecentResult, Error> {
9207 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9208 let _value = self
9209 .session
9210 .client()
9211 .call(
9212 rpc_methods::SESSION_QUEUE_REMOVEMOSTRECENT,
9213 Some(wire_params),
9214 )
9215 .await?;
9216 Ok(serde_json::from_value(_value)?)
9217 }
9218
9219 /// Clears all pending queued items on the local session.
9220 ///
9221 /// Wire method: `session.queue.clear`.
9222 ///
9223 /// <div class="warning">
9224 ///
9225 /// **Experimental.** This API is part of an experimental wire-protocol surface
9226 /// and may change or be removed in future SDK or CLI releases. Pin both the
9227 /// SDK and CLI versions if your code depends on it.
9228 ///
9229 /// </div>
9230 pub async fn clear(&self) -> Result<(), Error> {
9231 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9232 let _value = self
9233 .session
9234 .client()
9235 .call(rpc_methods::SESSION_QUEUE_CLEAR, Some(wire_params))
9236 .await?;
9237 Ok(())
9238 }
9239
9240 /// Consumes queued native system notifications matching an internal filter.
9241 ///
9242 /// Wire method: `session.queue.consumeSystemNotifications`.
9243 ///
9244 /// # Parameters
9245 ///
9246 /// * `params` - Internal filter for consuming queued system notifications.
9247 ///
9248 /// # Returns
9249 ///
9250 /// Indicates whether a user-facing pending item was removed.
9251 ///
9252 /// <div class="warning">
9253 ///
9254 /// **Experimental.** This API is part of an experimental wire-protocol surface
9255 /// and may change or be removed in future SDK or CLI releases. Pin both the
9256 /// SDK and CLI versions if your code depends on it.
9257 ///
9258 /// </div>
9259 pub(crate) async fn consume_system_notifications(
9260 &self,
9261 params: QueueConsumeSystemNotificationsRequest,
9262 ) -> Result<QueueRemoveMostRecentResult, Error> {
9263 let mut wire_params = serde_json::to_value(params)?;
9264 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9265 let _value = self
9266 .session
9267 .client()
9268 .call(
9269 rpc_methods::SESSION_QUEUE_CONSUMESYSTEMNOTIFICATIONS,
9270 Some(wire_params),
9271 )
9272 .await?;
9273 Ok(serde_json::from_value(_value)?)
9274 }
9275
9276 /// Enqueues the internal resume-pending wake item when orphan handling needs a follow-up turn.
9277 ///
9278 /// Wire method: `session.queue.enqueueResumePending`.
9279 ///
9280 /// # Returns
9281 ///
9282 /// Result of enqueueing the resume-pending wake item.
9283 ///
9284 /// <div class="warning">
9285 ///
9286 /// **Experimental.** This API is part of an experimental wire-protocol surface
9287 /// and may change or be removed in future SDK or CLI releases. Pin both the
9288 /// SDK and CLI versions if your code depends on it.
9289 ///
9290 /// </div>
9291 pub(crate) async fn enqueue_resume_pending(
9292 &self,
9293 ) -> Result<QueueEnqueueResumePendingResult, Error> {
9294 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9295 let _value = self
9296 .session
9297 .client()
9298 .call(
9299 rpc_methods::SESSION_QUEUE_ENQUEUERESUMEPENDING,
9300 Some(wire_params),
9301 )
9302 .await?;
9303 Ok(serde_json::from_value(_value)?)
9304 }
9305
9306 /// Drains the native local-session work queue for in-process session orchestration.
9307 ///
9308 /// Wire method: `session.queue.process`.
9309 ///
9310 /// <div class="warning">
9311 ///
9312 /// **Experimental.** This API is part of an experimental wire-protocol surface
9313 /// and may change or be removed in future SDK or CLI releases. Pin both the
9314 /// SDK and CLI versions if your code depends on it.
9315 ///
9316 /// </div>
9317 pub(crate) async fn process(&self) -> Result<(), Error> {
9318 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9319 let _value = self
9320 .session
9321 .client()
9322 .call(rpc_methods::SESSION_QUEUE_PROCESS, Some(wire_params))
9323 .await?;
9324 Ok(())
9325 }
9326}
9327
9328/// `session.remote.*` RPCs.
9329#[derive(Clone, Copy)]
9330pub struct SessionRpcRemote<'a> {
9331 pub(crate) session: &'a Session,
9332}
9333
9334impl<'a> SessionRpcRemote<'a> {
9335 /// Enables remote session export or steering.
9336 ///
9337 /// Wire method: `session.remote.enable`.
9338 ///
9339 /// # Parameters
9340 ///
9341 /// * `params` - Optional remote session mode ("off", "export", or "on"); defaults to enabling both export and remote steering.
9342 ///
9343 /// # Returns
9344 ///
9345 /// GitHub URL for the session and a flag indicating whether remote steering is enabled.
9346 ///
9347 /// <div class="warning">
9348 ///
9349 /// **Experimental.** This API is part of an experimental wire-protocol surface
9350 /// and may change or be removed in future SDK or CLI releases. Pin both the
9351 /// SDK and CLI versions if your code depends on it.
9352 ///
9353 /// </div>
9354 pub async fn enable(&self, params: RemoteEnableRequest) -> Result<RemoteEnableResult, Error> {
9355 let mut wire_params = serde_json::to_value(params)?;
9356 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9357 let _value = self
9358 .session
9359 .client()
9360 .call(rpc_methods::SESSION_REMOTE_ENABLE, Some(wire_params))
9361 .await?;
9362 Ok(serde_json::from_value(_value)?)
9363 }
9364
9365 /// Disables remote session export and steering.
9366 ///
9367 /// Wire method: `session.remote.disable`.
9368 ///
9369 /// <div class="warning">
9370 ///
9371 /// **Experimental.** This API is part of an experimental wire-protocol surface
9372 /// and may change or be removed in future SDK or CLI releases. Pin both the
9373 /// SDK and CLI versions if your code depends on it.
9374 ///
9375 /// </div>
9376 pub async fn disable(&self) -> Result<(), Error> {
9377 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9378 let _value = self
9379 .session
9380 .client()
9381 .call(rpc_methods::SESSION_REMOTE_DISABLE, Some(wire_params))
9382 .await?;
9383 Ok(())
9384 }
9385
9386 /// Persists a remote-steerability change emitted by the host as a session event.
9387 ///
9388 /// Wire method: `session.remote.notifySteerableChanged`.
9389 ///
9390 /// # Parameters
9391 ///
9392 /// * `params` - New remote-steerability state to persist as a `session.remote_steerable_changed` event.
9393 ///
9394 /// # Returns
9395 ///
9396 /// 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.
9397 ///
9398 /// <div class="warning">
9399 ///
9400 /// **Experimental.** This API is part of an experimental wire-protocol surface
9401 /// and may change or be removed in future SDK or CLI releases. Pin both the
9402 /// SDK and CLI versions if your code depends on it.
9403 ///
9404 /// </div>
9405 pub async fn notify_steerable_changed(
9406 &self,
9407 params: RemoteNotifySteerableChangedRequest,
9408 ) -> Result<RemoteNotifySteerableChangedResult, Error> {
9409 let mut wire_params = serde_json::to_value(params)?;
9410 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9411 let _value = self
9412 .session
9413 .client()
9414 .call(
9415 rpc_methods::SESSION_REMOTE_NOTIFYSTEERABLECHANGED,
9416 Some(wire_params),
9417 )
9418 .await?;
9419 Ok(serde_json::from_value(_value)?)
9420 }
9421}
9422
9423/// `session.sandbox.*` RPCs.
9424#[derive(Clone, Copy)]
9425pub struct SessionRpcSandbox<'a> {
9426 pub(crate) session: &'a Session,
9427}
9428
9429impl<'a> SessionRpcSandbox<'a> {
9430 /// Returns whether managed policy requires sandbox enforcement and whether an enforcement failure has permanently blocked the session.
9431 ///
9432 /// Wire method: `session.sandbox.getEnforcementStatus`.
9433 ///
9434 /// # Returns
9435 ///
9436 /// Managed sandbox enforcement state for a session.
9437 ///
9438 /// <div class="warning">
9439 ///
9440 /// **Experimental.** This API is part of an experimental wire-protocol surface
9441 /// and may change or be removed in future SDK or CLI releases. Pin both the
9442 /// SDK and CLI versions if your code depends on it.
9443 ///
9444 /// </div>
9445 pub async fn get_enforcement_status(&self) -> Result<SandboxEnforcementStatus, Error> {
9446 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9447 let _value = self
9448 .session
9449 .client()
9450 .call(
9451 rpc_methods::SESSION_SANDBOX_GETENFORCEMENTSTATUS,
9452 Some(wire_params),
9453 )
9454 .await?;
9455 Ok(serde_json::from_value(_value)?)
9456 }
9457}
9458
9459/// `session.schedule.*` RPCs.
9460#[derive(Clone, Copy)]
9461pub struct SessionRpcSchedule<'a> {
9462 pub(crate) session: &'a Session,
9463}
9464
9465impl<'a> SessionRpcSchedule<'a> {
9466 /// Lists the session's currently active scheduled prompts.
9467 ///
9468 /// Wire method: `session.schedule.list`.
9469 ///
9470 /// # Returns
9471 ///
9472 /// Snapshot of the currently active recurring prompts for this session.
9473 ///
9474 /// <div class="warning">
9475 ///
9476 /// **Experimental.** This API is part of an experimental wire-protocol surface
9477 /// and may change or be removed in future SDK or CLI releases. Pin both the
9478 /// SDK and CLI versions if your code depends on it.
9479 ///
9480 /// </div>
9481 pub async fn list(&self) -> Result<ScheduleList, Error> {
9482 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9483 let _value = self
9484 .session
9485 .client()
9486 .call(rpc_methods::SESSION_SCHEDULE_LIST, Some(wire_params))
9487 .await?;
9488 Ok(serde_json::from_value(_value)?)
9489 }
9490
9491 /// Hydrates the native schedule registry from persisted session events.
9492 ///
9493 /// Wire method: `session.schedule.hydrate`.
9494 ///
9495 /// <div class="warning">
9496 ///
9497 /// **Experimental.** This API is part of an experimental wire-protocol surface
9498 /// and may change or be removed in future SDK or CLI releases. Pin both the
9499 /// SDK and CLI versions if your code depends on it.
9500 ///
9501 /// </div>
9502 pub(crate) async fn hydrate(&self) -> Result<(), Error> {
9503 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9504 let _value = self
9505 .session
9506 .client()
9507 .call(rpc_methods::SESSION_SCHEDULE_HYDRATE, Some(wire_params))
9508 .await?;
9509 Ok(())
9510 }
9511
9512 /// Reports whether the session has an active self-paced scheduled prompt.
9513 ///
9514 /// Wire method: `session.schedule.hasSelfPaced`.
9515 ///
9516 /// # Returns
9517 ///
9518 /// Whether the session currently has an active self-paced schedule.
9519 ///
9520 /// <div class="warning">
9521 ///
9522 /// **Experimental.** This API is part of an experimental wire-protocol surface
9523 /// and may change or be removed in future SDK or CLI releases. Pin both the
9524 /// SDK and CLI versions if your code depends on it.
9525 ///
9526 /// </div>
9527 pub(crate) async fn has_self_paced(&self) -> Result<ScheduleHasSelfPacedResult, Error> {
9528 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9529 let _value = self
9530 .session
9531 .client()
9532 .call(
9533 rpc_methods::SESSION_SCHEDULE_HASSELFPACED,
9534 Some(wire_params),
9535 )
9536 .await?;
9537 Ok(serde_json::from_value(_value)?)
9538 }
9539
9540 /// Registers a relative-interval scheduled prompt.
9541 ///
9542 /// Wire method: `session.schedule.add`.
9543 ///
9544 /// # Parameters
9545 ///
9546 /// * `params` - Register a relative-interval scheduled prompt.
9547 ///
9548 /// # Returns
9549 ///
9550 /// Result of registering or re-arming a scheduled prompt.
9551 ///
9552 /// <div class="warning">
9553 ///
9554 /// **Experimental.** This API is part of an experimental wire-protocol surface
9555 /// and may change or be removed in future SDK or CLI releases. Pin both the
9556 /// SDK and CLI versions if your code depends on it.
9557 ///
9558 /// </div>
9559 pub(crate) async fn add(&self, params: ScheduleAddRequest) -> Result<ScheduleAddResult, Error> {
9560 let mut wire_params = serde_json::to_value(params)?;
9561 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9562 let _value = self
9563 .session
9564 .client()
9565 .call(rpc_methods::SESSION_SCHEDULE_ADD, Some(wire_params))
9566 .await?;
9567 Ok(serde_json::from_value(_value)?)
9568 }
9569
9570 /// Registers a recurring cron scheduled prompt.
9571 ///
9572 /// Wire method: `session.schedule.addCron`.
9573 ///
9574 /// # Parameters
9575 ///
9576 /// * `params` - Register a cron scheduled prompt.
9577 ///
9578 /// # Returns
9579 ///
9580 /// Result of registering or re-arming a scheduled prompt.
9581 ///
9582 /// <div class="warning">
9583 ///
9584 /// **Experimental.** This API is part of an experimental wire-protocol surface
9585 /// and may change or be removed in future SDK or CLI releases. Pin both the
9586 /// SDK and CLI versions if your code depends on it.
9587 ///
9588 /// </div>
9589 pub(crate) async fn add_cron(
9590 &self,
9591 params: ScheduleAddCronRequest,
9592 ) -> Result<ScheduleAddResult, Error> {
9593 let mut wire_params = serde_json::to_value(params)?;
9594 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9595 let _value = self
9596 .session
9597 .client()
9598 .call(rpc_methods::SESSION_SCHEDULE_ADDCRON, Some(wire_params))
9599 .await?;
9600 Ok(serde_json::from_value(_value)?)
9601 }
9602
9603 /// Registers an absolute-time scheduled prompt.
9604 ///
9605 /// Wire method: `session.schedule.addAt`.
9606 ///
9607 /// # Parameters
9608 ///
9609 /// * `params` - Register an absolute-time scheduled prompt.
9610 ///
9611 /// # Returns
9612 ///
9613 /// Result of registering or re-arming a scheduled prompt.
9614 ///
9615 /// <div class="warning">
9616 ///
9617 /// **Experimental.** This API is part of an experimental wire-protocol surface
9618 /// and may change or be removed in future SDK or CLI releases. Pin both the
9619 /// SDK and CLI versions if your code depends on it.
9620 ///
9621 /// </div>
9622 pub(crate) async fn add_at(
9623 &self,
9624 params: ScheduleAddAtRequest,
9625 ) -> Result<ScheduleAddResult, Error> {
9626 let mut wire_params = serde_json::to_value(params)?;
9627 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9628 let _value = self
9629 .session
9630 .client()
9631 .call(rpc_methods::SESSION_SCHEDULE_ADDAT, Some(wire_params))
9632 .await?;
9633 Ok(serde_json::from_value(_value)?)
9634 }
9635
9636 /// Registers a self-paced scheduled prompt.
9637 ///
9638 /// Wire method: `session.schedule.addSelfPaced`.
9639 ///
9640 /// # Parameters
9641 ///
9642 /// * `params` - Register a self-paced scheduled prompt.
9643 ///
9644 /// # Returns
9645 ///
9646 /// Result of registering or re-arming a scheduled prompt.
9647 ///
9648 /// <div class="warning">
9649 ///
9650 /// **Experimental.** This API is part of an experimental wire-protocol surface
9651 /// and may change or be removed in future SDK or CLI releases. Pin both the
9652 /// SDK and CLI versions if your code depends on it.
9653 ///
9654 /// </div>
9655 pub(crate) async fn add_self_paced(
9656 &self,
9657 params: ScheduleAddSelfPacedRequest,
9658 ) -> Result<ScheduleAddResult, Error> {
9659 let mut wire_params = serde_json::to_value(params)?;
9660 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9661 let _value = self
9662 .session
9663 .client()
9664 .call(
9665 rpc_methods::SESSION_SCHEDULE_ADDSELFPACED,
9666 Some(wire_params),
9667 )
9668 .await?;
9669 Ok(serde_json::from_value(_value)?)
9670 }
9671
9672 /// Re-arms an active self-paced scheduled prompt.
9673 ///
9674 /// Wire method: `session.schedule.rearmSelfPaced`.
9675 ///
9676 /// # Parameters
9677 ///
9678 /// * `params` - Re-arm a self-paced scheduled prompt.
9679 ///
9680 /// # Returns
9681 ///
9682 /// Result of registering or re-arming a scheduled prompt.
9683 ///
9684 /// <div class="warning">
9685 ///
9686 /// **Experimental.** This API is part of an experimental wire-protocol surface
9687 /// and may change or be removed in future SDK or CLI releases. Pin both the
9688 /// SDK and CLI versions if your code depends on it.
9689 ///
9690 /// </div>
9691 pub(crate) async fn rearm_self_paced(
9692 &self,
9693 params: ScheduleRearmSelfPacedRequest,
9694 ) -> Result<ScheduleAddResult, Error> {
9695 let mut wire_params = serde_json::to_value(params)?;
9696 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9697 let _value = self
9698 .session
9699 .client()
9700 .call(
9701 rpc_methods::SESSION_SCHEDULE_REARMSELFPACED,
9702 Some(wire_params),
9703 )
9704 .await?;
9705 Ok(serde_json::from_value(_value)?)
9706 }
9707
9708 /// Removes a scheduled prompt by id.
9709 ///
9710 /// Wire method: `session.schedule.stop`.
9711 ///
9712 /// # Parameters
9713 ///
9714 /// * `params` - Identifier of the scheduled prompt to remove.
9715 ///
9716 /// # Returns
9717 ///
9718 /// Remove a scheduled prompt by id. The result entry is omitted if the id was unknown.
9719 ///
9720 /// <div class="warning">
9721 ///
9722 /// **Experimental.** This API is part of an experimental wire-protocol surface
9723 /// and may change or be removed in future SDK or CLI releases. Pin both the
9724 /// SDK and CLI versions if your code depends on it.
9725 ///
9726 /// </div>
9727 pub async fn stop(&self, params: ScheduleStopRequest) -> Result<ScheduleStopResult, Error> {
9728 let mut wire_params = serde_json::to_value(params)?;
9729 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9730 let _value = self
9731 .session
9732 .client()
9733 .call(rpc_methods::SESSION_SCHEDULE_STOP, Some(wire_params))
9734 .await?;
9735 Ok(serde_json::from_value(_value)?)
9736 }
9737}
9738
9739/// `session.settings.*` RPCs.
9740#[derive(Clone, Copy)]
9741pub struct SessionRpcSettings<'a> {
9742 pub(crate) session: &'a Session,
9743}
9744
9745impl<'a> SessionRpcSettings<'a> {
9746 /// 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.
9747 ///
9748 /// Wire method: `session.settings.snapshot`.
9749 ///
9750 /// # Returns
9751 ///
9752 /// Redacted, serializable view of session runtime settings for SDK boundary consumers. Secrets and raw feature flags are intentionally excluded.
9753 ///
9754 /// <div class="warning">
9755 ///
9756 /// **Experimental.** This API is part of an experimental wire-protocol surface
9757 /// and may change or be removed in future SDK or CLI releases. Pin both the
9758 /// SDK and CLI versions if your code depends on it.
9759 ///
9760 /// </div>
9761 pub(crate) async fn snapshot(&self) -> Result<SessionSettingsSnapshot, Error> {
9762 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9763 let _value = self
9764 .session
9765 .client()
9766 .call(rpc_methods::SESSION_SETTINGS_SNAPSHOT, Some(wire_params))
9767 .await?;
9768 Ok(serde_json::from_value(_value)?)
9769 }
9770
9771 /// 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.
9772 ///
9773 /// Wire method: `session.settings.evaluatePredicate`.
9774 ///
9775 /// # Parameters
9776 ///
9777 /// * `params` - Named Rust-owned settings predicate to evaluate for this session.
9778 ///
9779 /// # Returns
9780 ///
9781 /// Result of evaluating a Rust-owned settings predicate.
9782 ///
9783 /// <div class="warning">
9784 ///
9785 /// **Experimental.** This API is part of an experimental wire-protocol surface
9786 /// and may change or be removed in future SDK or CLI releases. Pin both the
9787 /// SDK and CLI versions if your code depends on it.
9788 ///
9789 /// </div>
9790 pub(crate) async fn evaluate_predicate(
9791 &self,
9792 params: SessionSettingsEvaluatePredicateRequest,
9793 ) -> Result<SessionSettingsEvaluatePredicateResult, Error> {
9794 let mut wire_params = serde_json::to_value(params)?;
9795 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9796 let _value = self
9797 .session
9798 .client()
9799 .call(
9800 rpc_methods::SESSION_SETTINGS_EVALUATEPREDICATE,
9801 Some(wire_params),
9802 )
9803 .await?;
9804 Ok(serde_json::from_value(_value)?)
9805 }
9806}
9807
9808/// `session.shell.*` RPCs.
9809#[derive(Clone, Copy)]
9810pub struct SessionRpcShell<'a> {
9811 pub(crate) session: &'a Session,
9812}
9813
9814impl<'a> SessionRpcShell<'a> {
9815 /// 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.
9816 ///
9817 /// Wire method: `session.shell.exec`.
9818 ///
9819 /// # Parameters
9820 ///
9821 /// * `params` - Shell command to run, with optional working directory and timeout in milliseconds.
9822 ///
9823 /// # Returns
9824 ///
9825 /// Identifier of the spawned process, used to correlate streamed output and exit notifications.
9826 ///
9827 /// <div class="warning">
9828 ///
9829 /// **Experimental.** This API is part of an experimental wire-protocol surface
9830 /// and may change or be removed in future SDK or CLI releases. Pin both the
9831 /// SDK and CLI versions if your code depends on it.
9832 ///
9833 /// </div>
9834 pub async fn exec(&self, params: ShellExecRequest) -> Result<ShellExecResult, Error> {
9835 let mut wire_params = serde_json::to_value(params)?;
9836 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9837 let _value = self
9838 .session
9839 .client()
9840 .call(rpc_methods::SESSION_SHELL_EXEC, Some(wire_params))
9841 .await?;
9842 Ok(serde_json::from_value(_value)?)
9843 }
9844
9845 /// 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.
9846 ///
9847 /// Wire method: `session.shell.kill`.
9848 ///
9849 /// # Parameters
9850 ///
9851 /// * `params` - Identifier of a process previously returned by "shell.exec" and the signal to send.
9852 ///
9853 /// # Returns
9854 ///
9855 /// Indicates whether the signal was delivered; false if the process was unknown or already exited.
9856 ///
9857 /// <div class="warning">
9858 ///
9859 /// **Experimental.** This API is part of an experimental wire-protocol surface
9860 /// and may change or be removed in future SDK or CLI releases. Pin both the
9861 /// SDK and CLI versions if your code depends on it.
9862 ///
9863 /// </div>
9864 pub async fn kill(&self, params: ShellKillRequest) -> Result<ShellKillResult, Error> {
9865 let mut wire_params = serde_json::to_value(params)?;
9866 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9867 let _value = self
9868 .session
9869 .client()
9870 .call(rpc_methods::SESSION_SHELL_KILL, Some(wire_params))
9871 .await?;
9872 Ok(serde_json::from_value(_value)?)
9873 }
9874
9875 /// Executes a user-requested shell command through the session runtime.
9876 ///
9877 /// Wire method: `session.shell.executeUserRequested`.
9878 ///
9879 /// # Parameters
9880 ///
9881 /// * `params` - User-requested shell command and cancellation handle.
9882 ///
9883 /// # Returns
9884 ///
9885 /// Result of a user-requested shell command.
9886 ///
9887 /// <div class="warning">
9888 ///
9889 /// **Experimental.** This API is part of an experimental wire-protocol surface
9890 /// and may change or be removed in future SDK or CLI releases. Pin both the
9891 /// SDK and CLI versions if your code depends on it.
9892 ///
9893 /// </div>
9894 pub async fn execute_user_requested(
9895 &self,
9896 params: ShellExecuteUserRequestedRequest,
9897 ) -> Result<UserRequestedShellCommandResult, Error> {
9898 let mut wire_params = serde_json::to_value(params)?;
9899 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9900 let _value = self
9901 .session
9902 .client()
9903 .call(
9904 rpc_methods::SESSION_SHELL_EXECUTEUSERREQUESTED,
9905 Some(wire_params),
9906 )
9907 .await?;
9908 Ok(serde_json::from_value(_value)?)
9909 }
9910
9911 /// Cancels a user-requested shell command by request ID.
9912 ///
9913 /// Wire method: `session.shell.cancelUserRequested`.
9914 ///
9915 /// # Parameters
9916 ///
9917 /// * `params` - User-requested shell execution cancellation handle.
9918 ///
9919 /// # Returns
9920 ///
9921 /// Cancellation result for a user-requested shell command.
9922 ///
9923 /// <div class="warning">
9924 ///
9925 /// **Experimental.** This API is part of an experimental wire-protocol surface
9926 /// and may change or be removed in future SDK or CLI releases. Pin both the
9927 /// SDK and CLI versions if your code depends on it.
9928 ///
9929 /// </div>
9930 pub async fn cancel_user_requested(
9931 &self,
9932 params: ShellCancelUserRequestedRequest,
9933 ) -> Result<CancelUserRequestedShellCommandResult, Error> {
9934 let mut wire_params = serde_json::to_value(params)?;
9935 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9936 let _value = self
9937 .session
9938 .client()
9939 .call(
9940 rpc_methods::SESSION_SHELL_CANCELUSERREQUESTED,
9941 Some(wire_params),
9942 )
9943 .await?;
9944 Ok(serde_json::from_value(_value)?)
9945 }
9946}
9947
9948/// `session.skills.*` RPCs.
9949#[derive(Clone, Copy)]
9950pub struct SessionRpcSkills<'a> {
9951 pub(crate) session: &'a Session,
9952}
9953
9954impl<'a> SessionRpcSkills<'a> {
9955 /// Lists skills available to the session.
9956 ///
9957 /// Wire method: `session.skills.list`.
9958 ///
9959 /// # Returns
9960 ///
9961 /// Skills available to the session, with their enabled state.
9962 ///
9963 /// <div class="warning">
9964 ///
9965 /// **Experimental.** This API is part of an experimental wire-protocol surface
9966 /// and may change or be removed in future SDK or CLI releases. Pin both the
9967 /// SDK and CLI versions if your code depends on it.
9968 ///
9969 /// </div>
9970 pub async fn list(&self) -> Result<SkillList, Error> {
9971 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9972 let _value = self
9973 .session
9974 .client()
9975 .call(rpc_methods::SESSION_SKILLS_LIST, Some(wire_params))
9976 .await?;
9977 Ok(serde_json::from_value(_value)?)
9978 }
9979
9980 /// Returns the skills that have been invoked during this session.
9981 ///
9982 /// Wire method: `session.skills.getInvoked`.
9983 ///
9984 /// # Returns
9985 ///
9986 /// Skills invoked during this session, ordered by invocation time (most recent last).
9987 ///
9988 /// <div class="warning">
9989 ///
9990 /// **Experimental.** This API is part of an experimental wire-protocol surface
9991 /// and may change or be removed in future SDK or CLI releases. Pin both the
9992 /// SDK and CLI versions if your code depends on it.
9993 ///
9994 /// </div>
9995 pub async fn get_invoked(&self) -> Result<SkillsGetInvokedResult, Error> {
9996 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9997 let _value = self
9998 .session
9999 .client()
10000 .call(rpc_methods::SESSION_SKILLS_GETINVOKED, Some(wire_params))
10001 .await?;
10002 Ok(serde_json::from_value(_value)?)
10003 }
10004
10005 /// Enables a skill for the session.
10006 ///
10007 /// Wire method: `session.skills.enable`.
10008 ///
10009 /// # Parameters
10010 ///
10011 /// * `params` - Name of the skill to enable for the session.
10012 ///
10013 /// <div class="warning">
10014 ///
10015 /// **Experimental.** This API is part of an experimental wire-protocol surface
10016 /// and may change or be removed in future SDK or CLI releases. Pin both the
10017 /// SDK and CLI versions if your code depends on it.
10018 ///
10019 /// </div>
10020 pub async fn enable(&self, params: SkillsEnableRequest) -> Result<(), Error> {
10021 let mut wire_params = serde_json::to_value(params)?;
10022 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10023 let _value = self
10024 .session
10025 .client()
10026 .call(rpc_methods::SESSION_SKILLS_ENABLE, Some(wire_params))
10027 .await?;
10028 Ok(())
10029 }
10030
10031 /// Disables a skill for the session.
10032 ///
10033 /// Wire method: `session.skills.disable`.
10034 ///
10035 /// # Parameters
10036 ///
10037 /// * `params` - Name of the skill to disable for the session.
10038 ///
10039 /// <div class="warning">
10040 ///
10041 /// **Experimental.** This API is part of an experimental wire-protocol surface
10042 /// and may change or be removed in future SDK or CLI releases. Pin both the
10043 /// SDK and CLI versions if your code depends on it.
10044 ///
10045 /// </div>
10046 pub async fn disable(&self, params: SkillsDisableRequest) -> Result<(), Error> {
10047 let mut wire_params = serde_json::to_value(params)?;
10048 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10049 let _value = self
10050 .session
10051 .client()
10052 .call(rpc_methods::SESSION_SKILLS_DISABLE, Some(wire_params))
10053 .await?;
10054 Ok(())
10055 }
10056
10057 /// Reloads skill definitions for the session.
10058 ///
10059 /// Wire method: `session.skills.reload`.
10060 ///
10061 /// # Returns
10062 ///
10063 /// Diagnostics from reloading skill definitions, with warnings and errors as separate lists.
10064 ///
10065 /// <div class="warning">
10066 ///
10067 /// **Experimental.** This API is part of an experimental wire-protocol surface
10068 /// and may change or be removed in future SDK or CLI releases. Pin both the
10069 /// SDK and CLI versions if your code depends on it.
10070 ///
10071 /// </div>
10072 pub async fn reload(&self) -> Result<SkillsLoadDiagnostics, Error> {
10073 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10074 let _value = self
10075 .session
10076 .client()
10077 .call(rpc_methods::SESSION_SKILLS_RELOAD, Some(wire_params))
10078 .await?;
10079 Ok(serde_json::from_value(_value)?)
10080 }
10081
10082 /// Ensures the session's skill definitions have been loaded from disk.
10083 ///
10084 /// Wire method: `session.skills.ensureLoaded`.
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 ensure_loaded(&self) -> Result<(), Error> {
10094 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10095 let _value = self
10096 .session
10097 .client()
10098 .call(rpc_methods::SESSION_SKILLS_ENSURELOADED, Some(wire_params))
10099 .await?;
10100 Ok(())
10101 }
10102}
10103
10104/// `session.tasks.*` RPCs.
10105#[derive(Clone, Copy)]
10106pub struct SessionRpcTasks<'a> {
10107 pub(crate) session: &'a Session,
10108}
10109
10110impl<'a> SessionRpcTasks<'a> {
10111 /// Starts a background agent task in the session.
10112 ///
10113 /// Wire method: `session.tasks.startAgent`.
10114 ///
10115 /// # Parameters
10116 ///
10117 /// * `params` - Agent type, prompt, name, and optional description and model override for the new task.
10118 ///
10119 /// # Returns
10120 ///
10121 /// Identifier assigned to the newly started background agent task.
10122 ///
10123 /// <div class="warning">
10124 ///
10125 /// **Experimental.** This API is part of an experimental wire-protocol surface
10126 /// and may change or be removed in future SDK or CLI releases. Pin both the
10127 /// SDK and CLI versions if your code depends on it.
10128 ///
10129 /// </div>
10130 pub async fn start_agent(
10131 &self,
10132 params: TasksStartAgentRequest,
10133 ) -> Result<TasksStartAgentResult, Error> {
10134 let mut wire_params = serde_json::to_value(params)?;
10135 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10136 let _value = self
10137 .session
10138 .client()
10139 .call(rpc_methods::SESSION_TASKS_STARTAGENT, Some(wire_params))
10140 .await?;
10141 Ok(serde_json::from_value(_value)?)
10142 }
10143
10144 /// Lists background tasks tracked by the session.
10145 ///
10146 /// Wire method: `session.tasks.list`.
10147 ///
10148 /// # Returns
10149 ///
10150 /// Background tasks currently tracked by the session.
10151 ///
10152 /// <div class="warning">
10153 ///
10154 /// **Experimental.** This API is part of an experimental wire-protocol surface
10155 /// and may change or be removed in future SDK or CLI releases. Pin both the
10156 /// SDK and CLI versions if your code depends on it.
10157 ///
10158 /// </div>
10159 pub async fn list(&self) -> Result<TaskList, Error> {
10160 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10161 let _value = self
10162 .session
10163 .client()
10164 .call(rpc_methods::SESSION_TASKS_LIST, Some(wire_params))
10165 .await?;
10166 Ok(serde_json::from_value(_value)?)
10167 }
10168
10169 /// Refreshes metadata for any detached background shells the runtime knows about.
10170 ///
10171 /// Wire method: `session.tasks.refresh`.
10172 ///
10173 /// # Returns
10174 ///
10175 /// 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.
10176 ///
10177 /// <div class="warning">
10178 ///
10179 /// **Experimental.** This API is part of an experimental wire-protocol surface
10180 /// and may change or be removed in future SDK or CLI releases. Pin both the
10181 /// SDK and CLI versions if your code depends on it.
10182 ///
10183 /// </div>
10184 pub async fn refresh(&self) -> Result<TasksRefreshResult, Error> {
10185 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10186 let _value = self
10187 .session
10188 .client()
10189 .call(rpc_methods::SESSION_TASKS_REFRESH, Some(wire_params))
10190 .await?;
10191 Ok(serde_json::from_value(_value)?)
10192 }
10193
10194 /// Waits for all in-flight background tasks and any follow-up turns to settle.
10195 ///
10196 /// Wire method: `session.tasks.waitForPending`.
10197 ///
10198 /// # Returns
10199 ///
10200 /// 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).
10201 ///
10202 /// <div class="warning">
10203 ///
10204 /// **Experimental.** This API is part of an experimental wire-protocol surface
10205 /// and may change or be removed in future SDK or CLI releases. Pin both the
10206 /// SDK and CLI versions if your code depends on it.
10207 ///
10208 /// </div>
10209 pub async fn wait_for_pending(&self) -> Result<TasksWaitForPendingResult, Error> {
10210 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10211 let _value = self
10212 .session
10213 .client()
10214 .call(rpc_methods::SESSION_TASKS_WAITFORPENDING, Some(wire_params))
10215 .await?;
10216 Ok(serde_json::from_value(_value)?)
10217 }
10218
10219 /// Returns progress information for a background task by ID.
10220 ///
10221 /// Wire method: `session.tasks.getProgress`.
10222 ///
10223 /// # Parameters
10224 ///
10225 /// * `params` - Identifier of the background task to fetch progress for.
10226 ///
10227 /// # Returns
10228 ///
10229 /// Progress information for the task, or null when no task with that ID is tracked.
10230 ///
10231 /// <div class="warning">
10232 ///
10233 /// **Experimental.** This API is part of an experimental wire-protocol surface
10234 /// and may change or be removed in future SDK or CLI releases. Pin both the
10235 /// SDK and CLI versions if your code depends on it.
10236 ///
10237 /// </div>
10238 pub async fn get_progress(
10239 &self,
10240 params: TasksGetProgressRequest,
10241 ) -> Result<TasksGetProgressResult, Error> {
10242 let mut wire_params = serde_json::to_value(params)?;
10243 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10244 let _value = self
10245 .session
10246 .client()
10247 .call(rpc_methods::SESSION_TASKS_GETPROGRESS, Some(wire_params))
10248 .await?;
10249 Ok(serde_json::from_value(_value)?)
10250 }
10251
10252 /// Returns the first sync-waiting task that can currently be promoted to background mode.
10253 ///
10254 /// Wire method: `session.tasks.getCurrentPromotable`.
10255 ///
10256 /// # Returns
10257 ///
10258 /// The first sync-waiting task that can currently be promoted to background mode.
10259 ///
10260 /// <div class="warning">
10261 ///
10262 /// **Experimental.** This API is part of an experimental wire-protocol surface
10263 /// and may change or be removed in future SDK or CLI releases. Pin both the
10264 /// SDK and CLI versions if your code depends on it.
10265 ///
10266 /// </div>
10267 pub async fn get_current_promotable(&self) -> Result<TasksGetCurrentPromotableResult, Error> {
10268 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10269 let _value = self
10270 .session
10271 .client()
10272 .call(
10273 rpc_methods::SESSION_TASKS_GETCURRENTPROMOTABLE,
10274 Some(wire_params),
10275 )
10276 .await?;
10277 Ok(serde_json::from_value(_value)?)
10278 }
10279
10280 /// Promotes an eligible synchronously-waited task so it continues running in the background.
10281 ///
10282 /// Wire method: `session.tasks.promoteToBackground`.
10283 ///
10284 /// # Parameters
10285 ///
10286 /// * `params` - Identifier of the task to promote to background mode.
10287 ///
10288 /// # Returns
10289 ///
10290 /// Indicates whether the task was successfully promoted to background mode.
10291 ///
10292 /// <div class="warning">
10293 ///
10294 /// **Experimental.** This API is part of an experimental wire-protocol surface
10295 /// and may change or be removed in future SDK or CLI releases. Pin both the
10296 /// SDK and CLI versions if your code depends on it.
10297 ///
10298 /// </div>
10299 pub async fn promote_to_background(
10300 &self,
10301 params: TasksPromoteToBackgroundRequest,
10302 ) -> Result<TasksPromoteToBackgroundResult, Error> {
10303 let mut wire_params = serde_json::to_value(params)?;
10304 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10305 let _value = self
10306 .session
10307 .client()
10308 .call(
10309 rpc_methods::SESSION_TASKS_PROMOTETOBACKGROUND,
10310 Some(wire_params),
10311 )
10312 .await?;
10313 Ok(serde_json::from_value(_value)?)
10314 }
10315
10316 /// Atomically promotes the first promotable sync-waiting task to background mode and returns it.
10317 ///
10318 /// Wire method: `session.tasks.promoteCurrentToBackground`.
10319 ///
10320 /// # Returns
10321 ///
10322 /// The promoted task as it now exists in background mode, omitted if no promotable task was waiting.
10323 ///
10324 /// <div class="warning">
10325 ///
10326 /// **Experimental.** This API is part of an experimental wire-protocol surface
10327 /// and may change or be removed in future SDK or CLI releases. Pin both the
10328 /// SDK and CLI versions if your code depends on it.
10329 ///
10330 /// </div>
10331 pub async fn promote_current_to_background(
10332 &self,
10333 ) -> Result<TasksPromoteCurrentToBackgroundResult, Error> {
10334 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10335 let _value = self
10336 .session
10337 .client()
10338 .call(
10339 rpc_methods::SESSION_TASKS_PROMOTECURRENTTOBACKGROUND,
10340 Some(wire_params),
10341 )
10342 .await?;
10343 Ok(serde_json::from_value(_value)?)
10344 }
10345
10346 /// Cancels a background task.
10347 ///
10348 /// Wire method: `session.tasks.cancel`.
10349 ///
10350 /// # Parameters
10351 ///
10352 /// * `params` - Identifier of the background task to cancel.
10353 ///
10354 /// # Returns
10355 ///
10356 /// Indicates whether the background task was successfully cancelled.
10357 ///
10358 /// <div class="warning">
10359 ///
10360 /// **Experimental.** This API is part of an experimental wire-protocol surface
10361 /// and may change or be removed in future SDK or CLI releases. Pin both the
10362 /// SDK and CLI versions if your code depends on it.
10363 ///
10364 /// </div>
10365 pub async fn cancel(&self, params: TasksCancelRequest) -> Result<TasksCancelResult, Error> {
10366 let mut wire_params = serde_json::to_value(params)?;
10367 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10368 let _value = self
10369 .session
10370 .client()
10371 .call(rpc_methods::SESSION_TASKS_CANCEL, Some(wire_params))
10372 .await?;
10373 Ok(serde_json::from_value(_value)?)
10374 }
10375
10376 /// Removes a completed or cancelled background task from tracking.
10377 ///
10378 /// Wire method: `session.tasks.remove`.
10379 ///
10380 /// # Parameters
10381 ///
10382 /// * `params` - Identifier of the completed or cancelled task to remove from tracking.
10383 ///
10384 /// # Returns
10385 ///
10386 /// Indicates whether the task was removed. False when the task does not exist or is still running/idle.
10387 ///
10388 /// <div class="warning">
10389 ///
10390 /// **Experimental.** This API is part of an experimental wire-protocol surface
10391 /// and may change or be removed in future SDK or CLI releases. Pin both the
10392 /// SDK and CLI versions if your code depends on it.
10393 ///
10394 /// </div>
10395 pub async fn remove(&self, params: TasksRemoveRequest) -> Result<TasksRemoveResult, Error> {
10396 let mut wire_params = serde_json::to_value(params)?;
10397 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10398 let _value = self
10399 .session
10400 .client()
10401 .call(rpc_methods::SESSION_TASKS_REMOVE, Some(wire_params))
10402 .await?;
10403 Ok(serde_json::from_value(_value)?)
10404 }
10405
10406 /// Sends a message to a background agent task.
10407 ///
10408 /// Wire method: `session.tasks.sendMessage`.
10409 ///
10410 /// # Parameters
10411 ///
10412 /// * `params` - Identifier of the target agent task, message content, and optional sender agent ID.
10413 ///
10414 /// # Returns
10415 ///
10416 /// Indicates whether the message was delivered, with an error message when delivery failed.
10417 ///
10418 /// <div class="warning">
10419 ///
10420 /// **Experimental.** This API is part of an experimental wire-protocol surface
10421 /// and may change or be removed in future SDK or CLI releases. Pin both the
10422 /// SDK and CLI versions if your code depends on it.
10423 ///
10424 /// </div>
10425 pub async fn send_message(
10426 &self,
10427 params: TasksSendMessageRequest,
10428 ) -> Result<TasksSendMessageResult, Error> {
10429 let mut wire_params = serde_json::to_value(params)?;
10430 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10431 let _value = self
10432 .session
10433 .client()
10434 .call(rpc_methods::SESSION_TASKS_SENDMESSAGE, Some(wire_params))
10435 .await?;
10436 Ok(serde_json::from_value(_value)?)
10437 }
10438}
10439
10440/// `session.telemetry.*` RPCs.
10441#[derive(Clone, Copy)]
10442pub struct SessionRpcTelemetry<'a> {
10443 pub(crate) session: &'a Session,
10444}
10445
10446impl<'a> SessionRpcTelemetry<'a> {
10447 /// Gets the telemetry engagement ID currently associated with the session, when available.
10448 ///
10449 /// Wire method: `session.telemetry.getEngagementId`.
10450 ///
10451 /// # Returns
10452 ///
10453 /// Telemetry engagement ID for the session, when available.
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 get_engagement_id(&self) -> Result<SessionTelemetryEngagement, Error> {
10463 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10464 let _value = self
10465 .session
10466 .client()
10467 .call(
10468 rpc_methods::SESSION_TELEMETRY_GETENGAGEMENTID,
10469 Some(wire_params),
10470 )
10471 .await?;
10472 Ok(serde_json::from_value(_value)?)
10473 }
10474
10475 /// Sets feature override key/value pairs to attach to subsequent telemetry events for the session.
10476 ///
10477 /// Wire method: `session.telemetry.setFeatureOverrides`.
10478 ///
10479 /// # Parameters
10480 ///
10481 /// * `params` - Feature override key/value pairs to attach to subsequent telemetry events from this session.
10482 ///
10483 /// <div class="warning">
10484 ///
10485 /// **Experimental.** This API is part of an experimental wire-protocol surface
10486 /// and may change or be removed in future SDK or CLI releases. Pin both the
10487 /// SDK and CLI versions if your code depends on it.
10488 ///
10489 /// </div>
10490 pub async fn set_feature_overrides(
10491 &self,
10492 params: TelemetrySetFeatureOverridesRequest,
10493 ) -> Result<(), Error> {
10494 let mut wire_params = serde_json::to_value(params)?;
10495 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10496 let _value = self
10497 .session
10498 .client()
10499 .call(
10500 rpc_methods::SESSION_TELEMETRY_SETFEATUREOVERRIDES,
10501 Some(wire_params),
10502 )
10503 .await?;
10504 Ok(())
10505 }
10506}
10507
10508/// `session.tools.*` RPCs.
10509#[derive(Clone, Copy)]
10510pub struct SessionRpcTools<'a> {
10511 pub(crate) session: &'a Session,
10512}
10513
10514impl<'a> SessionRpcTools<'a> {
10515 /// Executes one tool from the session's currently offered tool set through the native invocation pipeline.
10516 ///
10517 /// Wire method: `session.tools.execute`.
10518 ///
10519 /// # Parameters
10520 ///
10521 /// * `params` - A tool name and arguments to execute through the session's native invocation pipeline.
10522 ///
10523 /// # Returns
10524 ///
10525 /// Canonical result returned by a session tool.
10526 ///
10527 /// <div class="warning">
10528 ///
10529 /// **Experimental.** This API is part of an experimental wire-protocol surface
10530 /// and may change or be removed in future SDK or CLI releases. Pin both the
10531 /// SDK and CLI versions if your code depends on it.
10532 ///
10533 /// </div>
10534 pub async fn execute(&self, params: ToolsExecuteRequest) -> Result<ToolResult, Error> {
10535 let mut wire_params = serde_json::to_value(params)?;
10536 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10537 let _value = self
10538 .session
10539 .client()
10540 .call(rpc_methods::SESSION_TOOLS_EXECUTE, Some(wire_params))
10541 .await?;
10542 Ok(serde_json::from_value(_value)?)
10543 }
10544
10545 /// Returns the Rust-owned built-in tool descriptors used to construct the session's offered tool set.
10546 ///
10547 /// Wire method: `session.tools.getBuiltinDescriptors`.
10548 ///
10549 /// # Parameters
10550 ///
10551 /// * `params` - Options controlling how Rust-owned built-in tool descriptors are materialized.
10552 ///
10553 /// # Returns
10554 ///
10555 /// Rust-owned built-in tool descriptors for the session.
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 get_builtin_descriptors(
10565 &self,
10566 params: ToolsGetBuiltinDescriptorsRequest,
10567 ) -> Result<ToolsGetBuiltinDescriptorsResult, 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_TOOLS_GETBUILTINDESCRIPTORS,
10575 Some(wire_params),
10576 )
10577 .await?;
10578 Ok(serde_json::from_value(_value)?)
10579 }
10580
10581 /// Projects a completed task_complete tool call into its label-safe session event payload.
10582 ///
10583 /// Wire method: `session.tools.taskCompleteEventData`.
10584 ///
10585 /// # Parameters
10586 ///
10587 /// * `params` - Task-completion tool arguments and final result used to build a label-safe session event payload.
10588 ///
10589 /// # Returns
10590 ///
10591 /// Task completion notification with summary from the agent
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 task_complete_event_data(
10601 &self,
10602 params: ToolsTaskCompleteEventDataRequest,
10603 ) -> Result<TaskCompleteData, 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_TOOLS_TASKCOMPLETEEVENTDATA,
10611 Some(wire_params),
10612 )
10613 .await?;
10614 Ok(serde_json::from_value(_value)?)
10615 }
10616
10617 /// Provides the result for a pending external tool call.
10618 ///
10619 /// Wire method: `session.tools.handlePendingToolCall`.
10620 ///
10621 /// # Parameters
10622 ///
10623 /// * `params` - Pending external tool call request ID, with the tool result or an error describing why it failed.
10624 ///
10625 /// # Returns
10626 ///
10627 /// Indicates whether the external tool call result was handled successfully.
10628 ///
10629 /// <div class="warning">
10630 ///
10631 /// **Experimental.** This API is part of an experimental wire-protocol surface
10632 /// and may change or be removed in future SDK or CLI releases. Pin both the
10633 /// SDK and CLI versions if your code depends on it.
10634 ///
10635 /// </div>
10636 pub async fn handle_pending_tool_call(
10637 &self,
10638 params: HandlePendingToolCallRequest,
10639 ) -> Result<HandlePendingToolCallResult, Error> {
10640 let mut wire_params = serde_json::to_value(params)?;
10641 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10642 let _value = self
10643 .session
10644 .client()
10645 .call(
10646 rpc_methods::SESSION_TOOLS_HANDLEPENDINGTOOLCALL,
10647 Some(wire_params),
10648 )
10649 .await?;
10650 Ok(serde_json::from_value(_value)?)
10651 }
10652
10653 /// Resolves, builds, and validates the runtime tool list for the session.
10654 ///
10655 /// Wire method: `session.tools.initializeAndValidate`.
10656 ///
10657 /// # Returns
10658 ///
10659 /// 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.
10660 ///
10661 /// <div class="warning">
10662 ///
10663 /// **Experimental.** This API is part of an experimental wire-protocol surface
10664 /// and may change or be removed in future SDK or CLI releases. Pin both the
10665 /// SDK and CLI versions if your code depends on it.
10666 ///
10667 /// </div>
10668 pub async fn initialize_and_validate(&self) -> Result<ToolsInitializeAndValidateResult, Error> {
10669 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10670 let _value = self
10671 .session
10672 .client()
10673 .call(
10674 rpc_methods::SESSION_TOOLS_INITIALIZEANDVALIDATE,
10675 Some(wire_params),
10676 )
10677 .await?;
10678 Ok(serde_json::from_value(_value)?)
10679 }
10680
10681 /// Returns lightweight metadata for the session's currently initialized tools.
10682 ///
10683 /// Wire method: `session.tools.getCurrentMetadata`.
10684 ///
10685 /// # Returns
10686 ///
10687 /// Current lightweight tool metadata snapshot for the session.
10688 ///
10689 /// <div class="warning">
10690 ///
10691 /// **Experimental.** This API is part of an experimental wire-protocol surface
10692 /// and may change or be removed in future SDK or CLI releases. Pin both the
10693 /// SDK and CLI versions if your code depends on it.
10694 ///
10695 /// </div>
10696 pub async fn get_current_metadata(&self) -> Result<ToolsGetCurrentMetadataResult, Error> {
10697 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10698 let _value = self
10699 .session
10700 .client()
10701 .call(
10702 rpc_methods::SESSION_TOOLS_GETCURRENTMETADATA,
10703 Some(wire_params),
10704 )
10705 .await?;
10706 Ok(serde_json::from_value(_value)?)
10707 }
10708
10709 /// 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.
10710 ///
10711 /// Wire method: `session.tools.set`.
10712 ///
10713 /// # Parameters
10714 ///
10715 /// * `params` - Complete externally implemented tool list for the calling connection. An empty list removes every tool previously supplied by that connection.
10716 ///
10717 /// # Returns
10718 ///
10719 /// Empty result after replacing the calling connection's externally implemented tools.
10720 ///
10721 /// <div class="warning">
10722 ///
10723 /// **Experimental.** This API is part of an experimental wire-protocol surface
10724 /// and may change or be removed in future SDK or CLI releases. Pin both the
10725 /// SDK and CLI versions if your code depends on it.
10726 ///
10727 /// </div>
10728 pub async fn set(&self, params: ToolsSetRequest) -> Result<ToolsSetResult, Error> {
10729 let mut wire_params = serde_json::to_value(params)?;
10730 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10731 let _value = self
10732 .session
10733 .client()
10734 .call(rpc_methods::SESSION_TOOLS_SET, Some(wire_params))
10735 .await?;
10736 Ok(serde_json::from_value(_value)?)
10737 }
10738
10739 /// Updates the current session's live subagent settings after user settings change. The persisted user settings remain the source of truth for future sessions.
10740 ///
10741 /// Wire method: `session.tools.updateSubagentSettings`.
10742 ///
10743 /// # Parameters
10744 ///
10745 /// * `params` - Subagent settings to apply to the current session
10746 ///
10747 /// # Returns
10748 ///
10749 /// Empty result after applying subagent settings
10750 ///
10751 /// <div class="warning">
10752 ///
10753 /// **Experimental.** This API is part of an experimental wire-protocol surface
10754 /// and may change or be removed in future SDK or CLI releases. Pin both the
10755 /// SDK and CLI versions if your code depends on it.
10756 ///
10757 /// </div>
10758 pub async fn update_subagent_settings(
10759 &self,
10760 params: UpdateSubagentSettingsRequest,
10761 ) -> Result<ToolsUpdateSubagentSettingsResult, Error> {
10762 let mut wire_params = serde_json::to_value(params)?;
10763 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10764 let _value = self
10765 .session
10766 .client()
10767 .call(
10768 rpc_methods::SESSION_TOOLS_UPDATESUBAGENTSETTINGS,
10769 Some(wire_params),
10770 )
10771 .await?;
10772 Ok(serde_json::from_value(_value)?)
10773 }
10774}
10775
10776/// `session.ui.*` RPCs.
10777#[derive(Clone, Copy)]
10778pub struct SessionRpcUi<'a> {
10779 pub(crate) session: &'a Session,
10780}
10781
10782impl<'a> SessionRpcUi<'a> {
10783 /// Runs a transient no-tools model query against the current conversation context.
10784 ///
10785 /// Wire method: `session.ui.ephemeralQuery`.
10786 ///
10787 /// # Parameters
10788 ///
10789 /// * `params` - Transient question to answer without adding it to conversation history.
10790 ///
10791 /// # Returns
10792 ///
10793 /// Completed transient query. Ordered chunks and the terminal outcome are also delivered through `ui.ephemeral_query` session events while it runs.
10794 ///
10795 /// <div class="warning">
10796 ///
10797 /// **Experimental.** This API is part of an experimental wire-protocol surface
10798 /// and may change or be removed in future SDK or CLI releases. Pin both the
10799 /// SDK and CLI versions if your code depends on it.
10800 ///
10801 /// </div>
10802 pub async fn ephemeral_query(
10803 &self,
10804 params: UIEphemeralQueryRequest,
10805 ) -> Result<UIEphemeralQueryResult, Error> {
10806 let mut wire_params = serde_json::to_value(params)?;
10807 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10808 let _value = self
10809 .session
10810 .client()
10811 .call(rpc_methods::SESSION_UI_EPHEMERALQUERY, Some(wire_params))
10812 .await?;
10813 Ok(serde_json::from_value(_value)?)
10814 }
10815
10816 /// Requests structured input from a UI-capable client.
10817 ///
10818 /// Wire method: `session.ui.elicitation`.
10819 ///
10820 /// # Parameters
10821 ///
10822 /// * `params` - Prompt message and JSON schema describing the form fields to elicit from the user.
10823 ///
10824 /// # Returns
10825 ///
10826 /// The elicitation response (accept with form values, decline, or cancel)
10827 ///
10828 /// <div class="warning">
10829 ///
10830 /// **Experimental.** This API is part of an experimental wire-protocol surface
10831 /// and may change or be removed in future SDK or CLI releases. Pin both the
10832 /// SDK and CLI versions if your code depends on it.
10833 ///
10834 /// </div>
10835 pub async fn elicitation(
10836 &self,
10837 params: UIElicitationRequest,
10838 ) -> Result<UIElicitationResponse, Error> {
10839 let mut wire_params = serde_json::to_value(params)?;
10840 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10841 let _value = self
10842 .session
10843 .client()
10844 .call(rpc_methods::SESSION_UI_ELICITATION, Some(wire_params))
10845 .await?;
10846 Ok(serde_json::from_value(_value)?)
10847 }
10848
10849 /// Provides the user response for a pending elicitation request.
10850 ///
10851 /// Wire method: `session.ui.handlePendingElicitation`.
10852 ///
10853 /// # Parameters
10854 ///
10855 /// * `params` - Pending elicitation request ID and the user's response (accept/decline/cancel + form values).
10856 ///
10857 /// # Returns
10858 ///
10859 /// Indicates whether the elicitation response was accepted; false if it was already resolved by another client.
10860 ///
10861 /// <div class="warning">
10862 ///
10863 /// **Experimental.** This API is part of an experimental wire-protocol surface
10864 /// and may change or be removed in future SDK or CLI releases. Pin both the
10865 /// SDK and CLI versions if your code depends on it.
10866 ///
10867 /// </div>
10868 pub async fn handle_pending_elicitation(
10869 &self,
10870 params: UIHandlePendingElicitationRequest,
10871 ) -> Result<UIElicitationResult, Error> {
10872 let mut wire_params = serde_json::to_value(params)?;
10873 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10874 let _value = self
10875 .session
10876 .client()
10877 .call(
10878 rpc_methods::SESSION_UI_HANDLEPENDINGELICITATION,
10879 Some(wire_params),
10880 )
10881 .await?;
10882 Ok(serde_json::from_value(_value)?)
10883 }
10884
10885 /// Resolves a pending `user_input.requested` event with the user's response.
10886 ///
10887 /// Wire method: `session.ui.handlePendingUserInput`.
10888 ///
10889 /// # Parameters
10890 ///
10891 /// * `params` - Request ID of a pending `user_input.requested` event and the user's response.
10892 ///
10893 /// # Returns
10894 ///
10895 /// Indicates whether the pending UI request was resolved by this call.
10896 ///
10897 /// <div class="warning">
10898 ///
10899 /// **Experimental.** This API is part of an experimental wire-protocol surface
10900 /// and may change or be removed in future SDK or CLI releases. Pin both the
10901 /// SDK and CLI versions if your code depends on it.
10902 ///
10903 /// </div>
10904 pub async fn handle_pending_user_input(
10905 &self,
10906 params: UIHandlePendingUserInputRequest,
10907 ) -> Result<UIHandlePendingResult, Error> {
10908 let mut wire_params = serde_json::to_value(params)?;
10909 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10910 let _value = self
10911 .session
10912 .client()
10913 .call(
10914 rpc_methods::SESSION_UI_HANDLEPENDINGUSERINPUT,
10915 Some(wire_params),
10916 )
10917 .await?;
10918 Ok(serde_json::from_value(_value)?)
10919 }
10920
10921 /// Resolves a pending `sampling.requested` event with a sampling result, or rejects it.
10922 ///
10923 /// Wire method: `session.ui.handlePendingSampling`.
10924 ///
10925 /// # Parameters
10926 ///
10927 /// * `params` - Request ID of a pending `sampling.requested` event and an optional sampling result payload (omit to reject).
10928 ///
10929 /// # Returns
10930 ///
10931 /// Indicates whether the pending UI request was resolved by this call.
10932 ///
10933 /// <div class="warning">
10934 ///
10935 /// **Experimental.** This API is part of an experimental wire-protocol surface
10936 /// and may change or be removed in future SDK or CLI releases. Pin both the
10937 /// SDK and CLI versions if your code depends on it.
10938 ///
10939 /// </div>
10940 pub async fn handle_pending_sampling(
10941 &self,
10942 params: UIHandlePendingSamplingRequest,
10943 ) -> Result<UIHandlePendingResult, Error> {
10944 let mut wire_params = serde_json::to_value(params)?;
10945 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10946 let _value = self
10947 .session
10948 .client()
10949 .call(
10950 rpc_methods::SESSION_UI_HANDLEPENDINGSAMPLING,
10951 Some(wire_params),
10952 )
10953 .await?;
10954 Ok(serde_json::from_value(_value)?)
10955 }
10956
10957 /// Resolves a pending `auto_mode_switch.requested` event with the user's accept/decline decision.
10958 ///
10959 /// Wire method: `session.ui.handlePendingAutoModeSwitch`.
10960 ///
10961 /// # Parameters
10962 ///
10963 /// * `params` - Request ID of a pending `auto_mode_switch.requested` event and the user's response.
10964 ///
10965 /// # Returns
10966 ///
10967 /// Indicates whether the pending UI request was resolved by this call.
10968 ///
10969 /// <div class="warning">
10970 ///
10971 /// **Experimental.** This API is part of an experimental wire-protocol surface
10972 /// and may change or be removed in future SDK or CLI releases. Pin both the
10973 /// SDK and CLI versions if your code depends on it.
10974 ///
10975 /// </div>
10976 pub async fn handle_pending_auto_mode_switch(
10977 &self,
10978 params: UIHandlePendingAutoModeSwitchRequest,
10979 ) -> Result<UIHandlePendingResult, Error> {
10980 let mut wire_params = serde_json::to_value(params)?;
10981 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10982 let _value = self
10983 .session
10984 .client()
10985 .call(
10986 rpc_methods::SESSION_UI_HANDLEPENDINGAUTOMODESWITCH,
10987 Some(wire_params),
10988 )
10989 .await?;
10990 Ok(serde_json::from_value(_value)?)
10991 }
10992
10993 /// Resolves a pending `session_limits_exhausted.requested` event with the user's selected limit action.
10994 ///
10995 /// Wire method: `session.ui.handlePendingSessionLimitsExhausted`.
10996 ///
10997 /// # Parameters
10998 ///
10999 /// * `params` - Request ID of a pending `session_limits_exhausted.requested` event and the user's selected limit action.
11000 ///
11001 /// # Returns
11002 ///
11003 /// Indicates whether the pending UI request was resolved by this call.
11004 ///
11005 /// <div class="warning">
11006 ///
11007 /// **Experimental.** This API is part of an experimental wire-protocol surface
11008 /// and may change or be removed in future SDK or CLI releases. Pin both the
11009 /// SDK and CLI versions if your code depends on it.
11010 ///
11011 /// </div>
11012 pub async fn handle_pending_session_limits_exhausted(
11013 &self,
11014 params: UIHandlePendingSessionLimitsExhaustedRequest,
11015 ) -> Result<UIHandlePendingResult, Error> {
11016 let mut wire_params = serde_json::to_value(params)?;
11017 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11018 let _value = self
11019 .session
11020 .client()
11021 .call(
11022 rpc_methods::SESSION_UI_HANDLEPENDINGSESSIONLIMITSEXHAUSTED,
11023 Some(wire_params),
11024 )
11025 .await?;
11026 Ok(serde_json::from_value(_value)?)
11027 }
11028
11029 /// Resolves a pending `exit_plan_mode.requested` event with the user's response.
11030 ///
11031 /// Wire method: `session.ui.handlePendingExitPlanMode`.
11032 ///
11033 /// # Parameters
11034 ///
11035 /// * `params` - Request ID of a pending `exit_plan_mode.requested` event and the user's response.
11036 ///
11037 /// # Returns
11038 ///
11039 /// Indicates whether the pending UI request was resolved by this call.
11040 ///
11041 /// <div class="warning">
11042 ///
11043 /// **Experimental.** This API is part of an experimental wire-protocol surface
11044 /// and may change or be removed in future SDK or CLI releases. Pin both the
11045 /// SDK and CLI versions if your code depends on it.
11046 ///
11047 /// </div>
11048 pub async fn handle_pending_exit_plan_mode(
11049 &self,
11050 params: UIHandlePendingExitPlanModeRequest,
11051 ) -> Result<UIHandlePendingResult, Error> {
11052 let mut wire_params = serde_json::to_value(params)?;
11053 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11054 let _value = self
11055 .session
11056 .client()
11057 .call(
11058 rpc_methods::SESSION_UI_HANDLEPENDINGEXITPLANMODE,
11059 Some(wire_params),
11060 )
11061 .await?;
11062 Ok(serde_json::from_value(_value)?)
11063 }
11064
11065 /// Registers an in-process handler for auto-mode-switch requests so the server bridge skips dispatch.
11066 ///
11067 /// Wire method: `session.ui.registerDirectAutoModeSwitchHandler`.
11068 ///
11069 /// # Returns
11070 ///
11071 /// 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).
11072 ///
11073 /// <div class="warning">
11074 ///
11075 /// **Experimental.** This API is part of an experimental wire-protocol surface
11076 /// and may change or be removed in future SDK or CLI releases. Pin both the
11077 /// SDK and CLI versions if your code depends on it.
11078 ///
11079 /// </div>
11080 pub async fn register_direct_auto_mode_switch_handler(
11081 &self,
11082 ) -> Result<UIRegisterDirectAutoModeSwitchHandlerResult, Error> {
11083 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
11084 let _value = self
11085 .session
11086 .client()
11087 .call(
11088 rpc_methods::SESSION_UI_REGISTERDIRECTAUTOMODESWITCHHANDLER,
11089 Some(wire_params),
11090 )
11091 .await?;
11092 Ok(serde_json::from_value(_value)?)
11093 }
11094
11095 /// Unregisters a previously-registered in-process auto-mode-switch handler by its opaque handle.
11096 ///
11097 /// Wire method: `session.ui.unregisterDirectAutoModeSwitchHandler`.
11098 ///
11099 /// # Parameters
11100 ///
11101 /// * `params` - Opaque handle previously returned by `registerDirectAutoModeSwitchHandler` to release.
11102 ///
11103 /// # Returns
11104 ///
11105 /// Indicates whether the handle was active and the registration count was decremented.
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 unregister_direct_auto_mode_switch_handler(
11115 &self,
11116 params: UIUnregisterDirectAutoModeSwitchHandlerRequest,
11117 ) -> Result<UIUnregisterDirectAutoModeSwitchHandlerResult, Error> {
11118 let mut wire_params = serde_json::to_value(params)?;
11119 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11120 let _value = self
11121 .session
11122 .client()
11123 .call(
11124 rpc_methods::SESSION_UI_UNREGISTERDIRECTAUTOMODESWITCHHANDLER,
11125 Some(wire_params),
11126 )
11127 .await?;
11128 Ok(serde_json::from_value(_value)?)
11129 }
11130}
11131
11132/// `session.usage.*` RPCs.
11133#[derive(Clone, Copy)]
11134pub struct SessionRpcUsage<'a> {
11135 pub(crate) session: &'a Session,
11136}
11137
11138impl<'a> SessionRpcUsage<'a> {
11139 /// Gets accumulated usage metrics for the session.
11140 ///
11141 /// Wire method: `session.usage.getMetrics`.
11142 ///
11143 /// # Returns
11144 ///
11145 /// Accumulated session usage metrics, including premium request cost, token counts, model breakdown, and code-change totals.
11146 ///
11147 /// <div class="warning">
11148 ///
11149 /// **Experimental.** This API is part of an experimental wire-protocol surface
11150 /// and may change or be removed in future SDK or CLI releases. Pin both the
11151 /// SDK and CLI versions if your code depends on it.
11152 ///
11153 /// </div>
11154 pub async fn get_metrics(&self) -> Result<UsageGetMetricsResult, Error> {
11155 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
11156 let _value = self
11157 .session
11158 .client()
11159 .call(rpc_methods::SESSION_USAGE_GETMETRICS, Some(wire_params))
11160 .await?;
11161 Ok(serde_json::from_value(_value)?)
11162 }
11163}
11164
11165/// `session.visibility.*` RPCs.
11166#[derive(Clone, Copy)]
11167pub struct SessionRpcVisibility<'a> {
11168 pub(crate) session: &'a Session,
11169}
11170
11171impl<'a> SessionRpcVisibility<'a> {
11172 /// 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").
11173 ///
11174 /// Wire method: `session.visibility.get`.
11175 ///
11176 /// # Returns
11177 ///
11178 /// Current sharing status and shareable GitHub URL for a session.
11179 ///
11180 /// <div class="warning">
11181 ///
11182 /// **Experimental.** This API is part of an experimental wire-protocol surface
11183 /// and may change or be removed in future SDK or CLI releases. Pin both the
11184 /// SDK and CLI versions if your code depends on it.
11185 ///
11186 /// </div>
11187 pub async fn get(&self) -> Result<VisibilityGetResult, Error> {
11188 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
11189 let _value = self
11190 .session
11191 .client()
11192 .call(rpc_methods::SESSION_VISIBILITY_GET, Some(wire_params))
11193 .await?;
11194 Ok(serde_json::from_value(_value)?)
11195 }
11196
11197 /// 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.
11198 ///
11199 /// Wire method: `session.visibility.set`.
11200 ///
11201 /// # Parameters
11202 ///
11203 /// * `params` - Desired sharing status for the session.
11204 ///
11205 /// # Returns
11206 ///
11207 /// Effective sharing status and shareable GitHub URL after updating session visibility.
11208 ///
11209 /// <div class="warning">
11210 ///
11211 /// **Experimental.** This API is part of an experimental wire-protocol surface
11212 /// and may change or be removed in future SDK or CLI releases. Pin both the
11213 /// SDK and CLI versions if your code depends on it.
11214 ///
11215 /// </div>
11216 pub async fn set(&self, params: VisibilitySetRequest) -> Result<VisibilitySetResult, Error> {
11217 let mut wire_params = serde_json::to_value(params)?;
11218 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11219 let _value = self
11220 .session
11221 .client()
11222 .call(rpc_methods::SESSION_VISIBILITY_SET, Some(wire_params))
11223 .await?;
11224 Ok(serde_json::from_value(_value)?)
11225 }
11226}
11227
11228/// `session.workspaces.*` RPCs.
11229#[derive(Clone, Copy)]
11230pub struct SessionRpcWorkspaces<'a> {
11231 pub(crate) session: &'a Session,
11232}
11233
11234impl<'a> SessionRpcWorkspaces<'a> {
11235 /// Gets current workspace metadata for the session.
11236 ///
11237 /// Wire method: `session.workspaces.getWorkspace`.
11238 ///
11239 /// # Returns
11240 ///
11241 /// Current workspace metadata for the session, including its absolute filesystem path when available.
11242 ///
11243 /// <div class="warning">
11244 ///
11245 /// **Experimental.** This API is part of an experimental wire-protocol surface
11246 /// and may change or be removed in future SDK or CLI releases. Pin both the
11247 /// SDK and CLI versions if your code depends on it.
11248 ///
11249 /// </div>
11250 pub async fn get_workspace(&self) -> Result<WorkspacesGetWorkspaceResult, Error> {
11251 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
11252 let _value = self
11253 .session
11254 .client()
11255 .call(
11256 rpc_methods::SESSION_WORKSPACES_GETWORKSPACE,
11257 Some(wire_params),
11258 )
11259 .await?;
11260 Ok(serde_json::from_value(_value)?)
11261 }
11262
11263 /// Updates workspace metadata for a local session and returns the refreshed workspace.
11264 ///
11265 /// Wire method: `session.workspaces.updateMetadata`.
11266 ///
11267 /// # Parameters
11268 ///
11269 /// * `params` - Workspace metadata fields to update.
11270 ///
11271 /// # Returns
11272 ///
11273 /// Current workspace metadata for the session, including its absolute filesystem path when available.
11274 ///
11275 /// <div class="warning">
11276 ///
11277 /// **Experimental.** This API is part of an experimental wire-protocol surface
11278 /// and may change or be removed in future SDK or CLI releases. Pin both the
11279 /// SDK and CLI versions if your code depends on it.
11280 ///
11281 /// </div>
11282 pub async fn update_metadata(
11283 &self,
11284 params: WorkspacesUpdateMetadataRequest,
11285 ) -> Result<WorkspacesGetWorkspaceResult, Error> {
11286 let mut wire_params = serde_json::to_value(params)?;
11287 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11288 let _value = self
11289 .session
11290 .client()
11291 .call(
11292 rpc_methods::SESSION_WORKSPACES_UPDATEMETADATA,
11293 Some(wire_params),
11294 )
11295 .await?;
11296 Ok(serde_json::from_value(_value)?)
11297 }
11298
11299 /// Ensures a local session workspace exists and returns it.
11300 ///
11301 /// Wire method: `session.workspaces.ensure`.
11302 ///
11303 /// # Parameters
11304 ///
11305 /// * `params` - Optional session context used when creating a local workspace.
11306 ///
11307 /// # Returns
11308 ///
11309 /// Current workspace metadata for the session, including its absolute filesystem path when available.
11310 ///
11311 /// <div class="warning">
11312 ///
11313 /// **Experimental.** This API is part of an experimental wire-protocol surface
11314 /// and may change or be removed in future SDK or CLI releases. Pin both the
11315 /// SDK and CLI versions if your code depends on it.
11316 ///
11317 /// </div>
11318 pub async fn ensure(
11319 &self,
11320 params: WorkspacesEnsureRequest,
11321 ) -> Result<WorkspacesGetWorkspaceResult, Error> {
11322 let mut wire_params = serde_json::to_value(params)?;
11323 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11324 let _value = self
11325 .session
11326 .client()
11327 .call(rpc_methods::SESSION_WORKSPACES_ENSURE, Some(wire_params))
11328 .await?;
11329 Ok(serde_json::from_value(_value)?)
11330 }
11331
11332 /// Lists files stored in the session workspace files directory.
11333 ///
11334 /// Wire method: `session.workspaces.listFiles`.
11335 ///
11336 /// # Returns
11337 ///
11338 /// Relative paths of files stored in the session workspace files directory.
11339 ///
11340 /// <div class="warning">
11341 ///
11342 /// **Experimental.** This API is part of an experimental wire-protocol surface
11343 /// and may change or be removed in future SDK or CLI releases. Pin both the
11344 /// SDK and CLI versions if your code depends on it.
11345 ///
11346 /// </div>
11347 pub async fn list_files(&self) -> Result<WorkspacesListFilesResult, Error> {
11348 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
11349 let _value = self
11350 .session
11351 .client()
11352 .call(rpc_methods::SESSION_WORKSPACES_LISTFILES, Some(wire_params))
11353 .await?;
11354 Ok(serde_json::from_value(_value)?)
11355 }
11356
11357 /// Reads a file from the session workspace files directory.
11358 ///
11359 /// Wire method: `session.workspaces.readFile`.
11360 ///
11361 /// # Parameters
11362 ///
11363 /// * `params` - Relative path of the workspace file to read.
11364 ///
11365 /// # Returns
11366 ///
11367 /// Contents of the requested workspace file as a UTF-8 string.
11368 ///
11369 /// <div class="warning">
11370 ///
11371 /// **Experimental.** This API is part of an experimental wire-protocol surface
11372 /// and may change or be removed in future SDK or CLI releases. Pin both the
11373 /// SDK and CLI versions if your code depends on it.
11374 ///
11375 /// </div>
11376 pub async fn read_file(
11377 &self,
11378 params: WorkspacesReadFileRequest,
11379 ) -> Result<WorkspacesReadFileResult, Error> {
11380 let mut wire_params = serde_json::to_value(params)?;
11381 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11382 let _value = self
11383 .session
11384 .client()
11385 .call(rpc_methods::SESSION_WORKSPACES_READFILE, Some(wire_params))
11386 .await?;
11387 Ok(serde_json::from_value(_value)?)
11388 }
11389
11390 /// Creates or overwrites a file in the session workspace files directory.
11391 ///
11392 /// Wire method: `session.workspaces.createFile`.
11393 ///
11394 /// # Parameters
11395 ///
11396 /// * `params` - Relative path and UTF-8 content for the workspace file to create or overwrite.
11397 ///
11398 /// <div class="warning">
11399 ///
11400 /// **Experimental.** This API is part of an experimental wire-protocol surface
11401 /// and may change or be removed in future SDK or CLI releases. Pin both the
11402 /// SDK and CLI versions if your code depends on it.
11403 ///
11404 /// </div>
11405 pub async fn create_file(&self, params: WorkspacesCreateFileRequest) -> Result<(), Error> {
11406 let mut wire_params = serde_json::to_value(params)?;
11407 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11408 let _value = self
11409 .session
11410 .client()
11411 .call(
11412 rpc_methods::SESSION_WORKSPACES_CREATEFILE,
11413 Some(wire_params),
11414 )
11415 .await?;
11416 Ok(())
11417 }
11418
11419 /// Lists workspace checkpoints in chronological order.
11420 ///
11421 /// Wire method: `session.workspaces.listCheckpoints`.
11422 ///
11423 /// # Returns
11424 ///
11425 /// Workspace checkpoints in chronological order; empty when the workspace is not enabled.
11426 ///
11427 /// <div class="warning">
11428 ///
11429 /// **Experimental.** This API is part of an experimental wire-protocol surface
11430 /// and may change or be removed in future SDK or CLI releases. Pin both the
11431 /// SDK and CLI versions if your code depends on it.
11432 ///
11433 /// </div>
11434 pub async fn list_checkpoints(&self) -> Result<WorkspacesListCheckpointsResult, Error> {
11435 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
11436 let _value = self
11437 .session
11438 .client()
11439 .call(
11440 rpc_methods::SESSION_WORKSPACES_LISTCHECKPOINTS,
11441 Some(wire_params),
11442 )
11443 .await?;
11444 Ok(serde_json::from_value(_value)?)
11445 }
11446
11447 /// Reads the content of a workspace checkpoint by number.
11448 ///
11449 /// Wire method: `session.workspaces.readCheckpoint`.
11450 ///
11451 /// # Parameters
11452 ///
11453 /// * `params` - Checkpoint number to read.
11454 ///
11455 /// # Returns
11456 ///
11457 /// Checkpoint content as a UTF-8 string, or null when the checkpoint or workspace is missing.
11458 ///
11459 /// <div class="warning">
11460 ///
11461 /// **Experimental.** This API is part of an experimental wire-protocol surface
11462 /// and may change or be removed in future SDK or CLI releases. Pin both the
11463 /// SDK and CLI versions if your code depends on it.
11464 ///
11465 /// </div>
11466 pub async fn read_checkpoint(
11467 &self,
11468 params: WorkspacesReadCheckpointRequest,
11469 ) -> Result<WorkspacesReadCheckpointResult, Error> {
11470 let mut wire_params = serde_json::to_value(params)?;
11471 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11472 let _value = self
11473 .session
11474 .client()
11475 .call(
11476 rpc_methods::SESSION_WORKSPACES_READCHECKPOINT,
11477 Some(wire_params),
11478 )
11479 .await?;
11480 Ok(serde_json::from_value(_value)?)
11481 }
11482
11483 /// Adds a compaction summary checkpoint to the local session workspace.
11484 ///
11485 /// Wire method: `session.workspaces.addSummary`.
11486 ///
11487 /// # Parameters
11488 ///
11489 /// * `params` - Compaction summary checkpoint to persist.
11490 ///
11491 /// # Returns
11492 ///
11493 /// Persisted summary metadata and refreshed workspace metadata.
11494 ///
11495 /// <div class="warning">
11496 ///
11497 /// **Experimental.** This API is part of an experimental wire-protocol surface
11498 /// and may change or be removed in future SDK or CLI releases. Pin both the
11499 /// SDK and CLI versions if your code depends on it.
11500 ///
11501 /// </div>
11502 pub async fn add_summary(
11503 &self,
11504 params: WorkspacesAddSummaryRequest,
11505 ) -> Result<WorkspacesAddSummaryResult, Error> {
11506 let mut wire_params = serde_json::to_value(params)?;
11507 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11508 let _value = self
11509 .session
11510 .client()
11511 .call(
11512 rpc_methods::SESSION_WORKSPACES_ADDSUMMARY,
11513 Some(wire_params),
11514 )
11515 .await?;
11516 Ok(serde_json::from_value(_value)?)
11517 }
11518
11519 /// Truncates local workspace compaction summaries after a rollback.
11520 ///
11521 /// Wire method: `session.workspaces.truncateSummaries`.
11522 ///
11523 /// # Parameters
11524 ///
11525 /// * `params` - Rollback point for local workspace summaries.
11526 ///
11527 /// # Returns
11528 ///
11529 /// Current workspace metadata for the session, including its absolute filesystem path when available.
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 truncate_summaries(
11539 &self,
11540 params: WorkspacesTruncateSummariesRequest,
11541 ) -> Result<WorkspacesGetWorkspaceResult, Error> {
11542 let mut wire_params = serde_json::to_value(params)?;
11543 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11544 let _value = self
11545 .session
11546 .client()
11547 .call(
11548 rpc_methods::SESSION_WORKSPACES_TRUNCATESUMMARIES,
11549 Some(wire_params),
11550 )
11551 .await?;
11552 Ok(serde_json::from_value(_value)?)
11553 }
11554
11555 /// Reads the autopilot objective state file from the local session workspace.
11556 ///
11557 /// Wire method: `session.workspaces.readAutopilotObjective`.
11558 ///
11559 /// # Returns
11560 ///
11561 /// Autopilot objective file content, or null when missing.
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 read_autopilot_objective(
11571 &self,
11572 ) -> Result<WorkspacesReadAutopilotObjectiveResult, Error> {
11573 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
11574 let _value = self
11575 .session
11576 .client()
11577 .call(
11578 rpc_methods::SESSION_WORKSPACES_READAUTOPILOTOBJECTIVE,
11579 Some(wire_params),
11580 )
11581 .await?;
11582 Ok(serde_json::from_value(_value)?)
11583 }
11584
11585 /// Writes the autopilot objective state file in the local session workspace.
11586 ///
11587 /// Wire method: `session.workspaces.writeAutopilotObjective`.
11588 ///
11589 /// # Parameters
11590 ///
11591 /// * `params` - Autopilot objective file content to persist.
11592 ///
11593 /// # Returns
11594 ///
11595 /// Result of writing the autopilot objective file.
11596 ///
11597 /// <div class="warning">
11598 ///
11599 /// **Experimental.** This API is part of an experimental wire-protocol surface
11600 /// and may change or be removed in future SDK or CLI releases. Pin both the
11601 /// SDK and CLI versions if your code depends on it.
11602 ///
11603 /// </div>
11604 pub async fn write_autopilot_objective(
11605 &self,
11606 params: WorkspacesWriteAutopilotObjectiveRequest,
11607 ) -> Result<WorkspacesWriteAutopilotObjectiveResult, Error> {
11608 let mut wire_params = serde_json::to_value(params)?;
11609 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11610 let _value = self
11611 .session
11612 .client()
11613 .call(
11614 rpc_methods::SESSION_WORKSPACES_WRITEAUTOPILOTOBJECTIVE,
11615 Some(wire_params),
11616 )
11617 .await?;
11618 Ok(serde_json::from_value(_value)?)
11619 }
11620
11621 /// Deletes the autopilot objective state file from the local session workspace.
11622 ///
11623 /// Wire method: `session.workspaces.deleteAutopilotObjective`.
11624 ///
11625 /// # Returns
11626 ///
11627 /// Result of deleting the autopilot objective file.
11628 ///
11629 /// <div class="warning">
11630 ///
11631 /// **Experimental.** This API is part of an experimental wire-protocol surface
11632 /// and may change or be removed in future SDK or CLI releases. Pin both the
11633 /// SDK and CLI versions if your code depends on it.
11634 ///
11635 /// </div>
11636 pub async fn delete_autopilot_objective(
11637 &self,
11638 ) -> Result<WorkspacesDeleteAutopilotObjectiveResult, Error> {
11639 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
11640 let _value = self
11641 .session
11642 .client()
11643 .call(
11644 rpc_methods::SESSION_WORKSPACES_DELETEAUTOPILOTOBJECTIVE,
11645 Some(wire_params),
11646 )
11647 .await?;
11648 Ok(serde_json::from_value(_value)?)
11649 }
11650
11651 /// Checks whether the local session workspace has an autopilot objective state file.
11652 ///
11653 /// Wire method: `session.workspaces.autopilotObjectiveExists`.
11654 ///
11655 /// # Returns
11656 ///
11657 /// Whether the autopilot objective file exists.
11658 ///
11659 /// <div class="warning">
11660 ///
11661 /// **Experimental.** This API is part of an experimental wire-protocol surface
11662 /// and may change or be removed in future SDK or CLI releases. Pin both the
11663 /// SDK and CLI versions if your code depends on it.
11664 ///
11665 /// </div>
11666 pub async fn autopilot_objective_exists(
11667 &self,
11668 ) -> Result<WorkspacesAutopilotObjectiveExistsResult, Error> {
11669 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
11670 let _value = self
11671 .session
11672 .client()
11673 .call(
11674 rpc_methods::SESSION_WORKSPACES_AUTOPILOTOBJECTIVEEXISTS,
11675 Some(wire_params),
11676 )
11677 .await?;
11678 Ok(serde_json::from_value(_value)?)
11679 }
11680
11681 /// Saves pasted content as a UTF-8 file in the session workspace.
11682 ///
11683 /// Wire method: `session.workspaces.saveLargePaste`.
11684 ///
11685 /// # Parameters
11686 ///
11687 /// * `params` - Pasted content to save as a UTF-8 file in the session workspace.
11688 ///
11689 /// # Returns
11690 ///
11691 /// Descriptor for the saved paste file, or null when the workspace is unavailable.
11692 ///
11693 /// <div class="warning">
11694 ///
11695 /// **Experimental.** This API is part of an experimental wire-protocol surface
11696 /// and may change or be removed in future SDK or CLI releases. Pin both the
11697 /// SDK and CLI versions if your code depends on it.
11698 ///
11699 /// </div>
11700 pub async fn save_large_paste(
11701 &self,
11702 params: WorkspacesSaveLargePasteRequest,
11703 ) -> Result<WorkspacesSaveLargePasteResult, Error> {
11704 let mut wire_params = serde_json::to_value(params)?;
11705 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11706 let _value = self
11707 .session
11708 .client()
11709 .call(
11710 rpc_methods::SESSION_WORKSPACES_SAVELARGEPASTE,
11711 Some(wire_params),
11712 )
11713 .await?;
11714 Ok(serde_json::from_value(_value)?)
11715 }
11716
11717 /// 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`.
11718 ///
11719 /// Wire method: `session.workspaces.diff`.
11720 ///
11721 /// # Parameters
11722 ///
11723 /// * `params` - Parameters for computing a workspace diff.
11724 ///
11725 /// # Returns
11726 ///
11727 /// Workspace diff result for the requested mode.
11728 ///
11729 /// <div class="warning">
11730 ///
11731 /// **Experimental.** This API is part of an experimental wire-protocol surface
11732 /// and may change or be removed in future SDK or CLI releases. Pin both the
11733 /// SDK and CLI versions if your code depends on it.
11734 ///
11735 /// </div>
11736 pub async fn diff(&self, params: WorkspacesDiffRequest) -> Result<WorkspaceDiffResult, Error> {
11737 let mut wire_params = serde_json::to_value(params)?;
11738 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11739 let _value = self
11740 .session
11741 .client()
11742 .call(rpc_methods::SESSION_WORKSPACES_DIFF, Some(wire_params))
11743 .await?;
11744 Ok(serde_json::from_value(_value)?)
11745 }
11746}