github_copilot_sdk/generated/rpc.rs
1//! Auto-generated typed JSON-RPC namespace — do not edit manually.
2//!
3//! Generated from `api.schema.json` by `scripts/codegen/rust.ts`. The
4//! [`ClientRpc`] and [`SessionRpc`] view structs let callers reach every
5//! protocol method through a typed namespace tree, so wire method names
6//! and request/response shapes live in exactly one place — this file.
7
8#![allow(missing_docs)]
9#![allow(clippy::too_many_arguments)]
10#![allow(deprecated)]
11#![allow(dead_code)]
12
13use super::api_types::{rpc_methods, *};
14use super::session_events::SessionMode;
15use crate::session::Session;
16use crate::{Client, Error};
17
18/// Typed view over the [`Client`]'s server-level RPC namespace.
19#[derive(Clone, Copy)]
20pub struct ClientRpc<'a> {
21 pub(crate) client: &'a Client,
22}
23
24impl<'a> ClientRpc<'a> {
25 /// `account.*` sub-namespace.
26 pub fn account(&self) -> ClientRpcAccount<'a> {
27 ClientRpcAccount {
28 client: self.client,
29 }
30 }
31
32 /// `agentRegistry.*` sub-namespace.
33 pub fn agent_registry(&self) -> ClientRpcAgentRegistry<'a> {
34 ClientRpcAgentRegistry {
35 client: self.client,
36 }
37 }
38
39 /// `agents.*` sub-namespace.
40 pub fn agents(&self) -> ClientRpcAgents<'a> {
41 ClientRpcAgents {
42 client: self.client,
43 }
44 }
45
46 /// `catalog.*` sub-namespace.
47 pub fn catalog(&self) -> ClientRpcCatalog<'a> {
48 ClientRpcCatalog {
49 client: self.client,
50 }
51 }
52
53 /// `commands.*` sub-namespace.
54 pub fn commands(&self) -> ClientRpcCommands<'a> {
55 ClientRpcCommands {
56 client: self.client,
57 }
58 }
59
60 /// `extensions.*` sub-namespace.
61 pub fn extensions(&self) -> ClientRpcExtensions<'a> {
62 ClientRpcExtensions {
63 client: self.client,
64 }
65 }
66
67 /// `hooks.*` sub-namespace.
68 pub fn hooks(&self) -> ClientRpcHooks<'a> {
69 ClientRpcHooks {
70 client: self.client,
71 }
72 }
73
74 /// `instructions.*` sub-namespace.
75 pub fn instructions(&self) -> ClientRpcInstructions<'a> {
76 ClientRpcInstructions {
77 client: self.client,
78 }
79 }
80
81 /// `llmInference.*` sub-namespace.
82 pub fn llm_inference(&self) -> ClientRpcLlmInference<'a> {
83 ClientRpcLlmInference {
84 client: self.client,
85 }
86 }
87
88 /// `managedSettings.*` sub-namespace.
89 pub fn managed_settings(&self) -> ClientRpcManagedSettings<'a> {
90 ClientRpcManagedSettings {
91 client: self.client,
92 }
93 }
94
95 /// `mcp.*` sub-namespace.
96 pub fn mcp(&self) -> ClientRpcMcp<'a> {
97 ClientRpcMcp {
98 client: self.client,
99 }
100 }
101
102 /// `models.*` sub-namespace.
103 pub fn models(&self) -> ClientRpcModels<'a> {
104 ClientRpcModels {
105 client: self.client,
106 }
107 }
108
109 /// `plugins.*` sub-namespace.
110 pub fn plugins(&self) -> ClientRpcPlugins<'a> {
111 ClientRpcPlugins {
112 client: self.client,
113 }
114 }
115
116 /// `runtime.*` sub-namespace.
117 pub fn runtime(&self) -> ClientRpcRuntime<'a> {
118 ClientRpcRuntime {
119 client: self.client,
120 }
121 }
122
123 /// `secrets.*` sub-namespace.
124 pub fn secrets(&self) -> ClientRpcSecrets<'a> {
125 ClientRpcSecrets {
126 client: self.client,
127 }
128 }
129
130 /// `sessionFs.*` sub-namespace.
131 pub fn session_fs(&self) -> ClientRpcSessionFs<'a> {
132 ClientRpcSessionFs {
133 client: self.client,
134 }
135 }
136
137 /// `sessions.*` sub-namespace.
138 pub fn sessions(&self) -> ClientRpcSessions<'a> {
139 ClientRpcSessions {
140 client: self.client,
141 }
142 }
143
144 /// `skills.*` sub-namespace.
145 pub fn skills(&self) -> ClientRpcSkills<'a> {
146 ClientRpcSkills {
147 client: self.client,
148 }
149 }
150
151 /// `tools.*` sub-namespace.
152 pub fn tools(&self) -> ClientRpcTools<'a> {
153 ClientRpcTools {
154 client: self.client,
155 }
156 }
157
158 /// `user.*` sub-namespace.
159 pub fn user(&self) -> ClientRpcUser<'a> {
160 ClientRpcUser {
161 client: self.client,
162 }
163 }
164
165 /// Checks server responsiveness and returns protocol information.
166 ///
167 /// Wire method: `ping`.
168 ///
169 /// # Parameters
170 ///
171 /// * `params` - Optional message to echo back to the caller.
172 ///
173 /// # Returns
174 ///
175 /// Server liveness response, including the echoed message, current server timestamp, and protocol version.
176 ///
177 /// <div class="warning">
178 ///
179 /// **Experimental.** This API is part of an experimental wire-protocol surface
180 /// and may change or be removed in future SDK or CLI releases. Pin both the
181 /// SDK and CLI versions if your code depends on it.
182 ///
183 /// </div>
184 pub async fn ping(&self, params: PingRequest) -> Result<PingResult, Error> {
185 let wire_params = serde_json::to_value(params)?;
186 let _value = self
187 .client
188 .call(rpc_methods::PING, Some(wire_params))
189 .await?;
190 Ok(serde_json::from_value(_value)?)
191 }
192
193 /// Performs the SDK server connection handshake and validates the optional connection token. Marked internal because this is JSON-RPC transport plumbing invoked automatically by an SDK client's own `connect()` wrapper, not a user-facing method. Stays internal as long as the SDK client owns the handshake; would only become public if the SDK ever exposed the raw schema surface to consumers without a connection wrapper.
194 ///
195 /// Wire method: `connect`.
196 ///
197 /// # Parameters
198 ///
199 /// * `params` - Connection-level opt-ins for the `server.connect` handshake. Transport authentication is consumed by the native protocol boundary before dispatch.
200 ///
201 /// # Returns
202 ///
203 /// Handshake result reporting the server's protocol version and package version on success.
204 ///
205 /// <div class="warning">
206 ///
207 /// **Experimental.** This API is part of an experimental wire-protocol surface
208 /// and may change or be removed in future SDK or CLI releases. Pin both the
209 /// SDK and CLI versions if your code depends on it.
210 ///
211 /// </div>
212 pub(crate) async fn connect(&self, params: ConnectRequest) -> Result<ConnectResult, Error> {
213 let wire_params = serde_json::to_value(params)?;
214 let _value = self
215 .client
216 .call(rpc_methods::CONNECT, Some(wire_params))
217 .await?;
218 Ok(serde_json::from_value(_value)?)
219 }
220
221 /// Registers the calling SDK client as the per-entrypoint extension launch provider. Call before creating any sessions. When omitted, the runtime uses its built-in extension launcher.
222 ///
223 /// Wire method: `registerExtensionLaunchProvider`.
224 ///
225 /// <div class="warning">
226 ///
227 /// **Experimental.** This API is part of an experimental wire-protocol surface
228 /// and may change or be removed in future SDK or CLI releases. Pin both the
229 /// SDK and CLI versions if your code depends on it.
230 ///
231 /// </div>
232 pub async fn register_extension_launch_provider(&self) -> Result<(), Error> {
233 let wire_params = serde_json::json!({});
234 let _value = self
235 .client
236 .call(
237 rpc_methods::REGISTEREXTENSIONLAUNCHPROVIDER,
238 Some(wire_params),
239 )
240 .await?;
241 Ok(())
242 }
243}
244
245/// `account.*` RPCs.
246#[derive(Clone, Copy)]
247pub struct ClientRpcAccount<'a> {
248 pub(crate) client: &'a Client,
249}
250
251impl<'a> ClientRpcAccount<'a> {
252 /// Gets Copilot quota usage for the current or opaquely selected authenticated user.
253 ///
254 /// Wire method: `account.getQuota`.
255 ///
256 /// # Returns
257 ///
258 /// Quota usage snapshots for the resolved user, keyed by quota type.
259 ///
260 /// <div class="warning">
261 ///
262 /// **Experimental.** This API is part of an experimental wire-protocol surface
263 /// and may change or be removed in future SDK or CLI releases. Pin both the
264 /// SDK and CLI versions if your code depends on it.
265 ///
266 /// </div>
267 pub async fn get_quota(&self) -> Result<AccountGetQuotaResult, Error> {
268 let wire_params = serde_json::json!({});
269 let _value = self
270 .client
271 .call(rpc_methods::ACCOUNT_GETQUOTA, Some(wire_params))
272 .await?;
273 Ok(serde_json::from_value(_value)?)
274 }
275
276 /// Gets Copilot quota usage for the current or opaquely selected authenticated user.
277 ///
278 /// Wire method: `account.getQuota`.
279 ///
280 /// # Parameters
281 ///
282 /// * `params` - Optional opaque account selection or compatibility GitHub token used to look up quota.
283 ///
284 /// # Returns
285 ///
286 /// Quota usage snapshots for the resolved user, keyed by quota type.
287 ///
288 /// <div class="warning">
289 ///
290 /// **Experimental.** This API is part of an experimental wire-protocol surface
291 /// and may change or be removed in future SDK or CLI releases. Pin both the
292 /// SDK and CLI versions if your code depends on it.
293 ///
294 /// </div>
295 pub async fn get_quota_with_params(
296 &self,
297 params: AccountGetQuotaRequest,
298 ) -> Result<AccountGetQuotaResult, Error> {
299 let wire_params = serde_json::to_value(params)?;
300 let _value = self
301 .client
302 .call(rpc_methods::ACCOUNT_GETQUOTA, Some(wire_params))
303 .await?;
304 Ok(serde_json::from_value(_value)?)
305 }
306
307 /// Gets the currently active authentication credentials from the global auth manager.
308 ///
309 /// Wire method: `account.getCurrentAuth`.
310 ///
311 /// # Returns
312 ///
313 /// Current authentication state
314 ///
315 /// <div class="warning">
316 ///
317 /// **Experimental.** This API is part of an experimental wire-protocol surface
318 /// and may change or be removed in future SDK or CLI releases. Pin both the
319 /// SDK and CLI versions if your code depends on it.
320 ///
321 /// </div>
322 pub async fn get_current_auth(&self) -> Result<AccountGetCurrentAuthResult, Error> {
323 let wire_params = serde_json::json!({});
324 let _value = self
325 .client
326 .call(rpc_methods::ACCOUNT_GETCURRENTAUTH, Some(wire_params))
327 .await?;
328 Ok(serde_json::from_value(_value)?)
329 }
330
331 /// Gets all authenticated users available for account switching.
332 ///
333 /// Wire method: `account.getAllUsers`.
334 ///
335 /// # Returns
336 ///
337 /// List of all authenticated users
338 ///
339 /// <div class="warning">
340 ///
341 /// **Experimental.** This API is part of an experimental wire-protocol surface
342 /// and may change or be removed in future SDK or CLI releases. Pin both the
343 /// SDK and CLI versions if your code depends on it.
344 ///
345 /// </div>
346 pub async fn get_all_users(&self) -> Result<AccountGetAllUsersResult, Error> {
347 let wire_params = serde_json::json!({});
348 let _value = self
349 .client
350 .call(rpc_methods::ACCOUNT_GETALLUSERS, Some(wire_params))
351 .await?;
352 Ok(serde_json::from_value(_value)?)
353 }
354
355 /// Validates and stores authentication credentials. When login is omitted, resolves the authenticated user from the token before persistence.
356 ///
357 /// Wire method: `account.login`.
358 ///
359 /// # Parameters
360 ///
361 /// * `params` - Credentials to validate and store. Omit login to resolve the authenticated user from the token.
362 ///
363 /// # Returns
364 ///
365 /// Result of a successful login; throws on failure
366 ///
367 /// <div class="warning">
368 ///
369 /// **Experimental.** This API is part of an experimental wire-protocol surface
370 /// and may change or be removed in future SDK or CLI releases. Pin both the
371 /// SDK and CLI versions if your code depends on it.
372 ///
373 /// </div>
374 pub async fn login(&self, params: AccountLoginRequest) -> Result<AccountLoginResult, Error> {
375 let wire_params = serde_json::to_value(params)?;
376 let _value = self
377 .client
378 .call(rpc_methods::ACCOUNT_LOGIN, Some(wire_params))
379 .await?;
380 Ok(serde_json::from_value(_value)?)
381 }
382
383 /// Removes user authentication from keychain and persisted state.
384 ///
385 /// Wire method: `account.logout`.
386 ///
387 /// # Parameters
388 ///
389 /// * `params` - User to log out
390 ///
391 /// # Returns
392 ///
393 /// Logout result indicating if more users remain
394 ///
395 /// <div class="warning">
396 ///
397 /// **Experimental.** This API is part of an experimental wire-protocol surface
398 /// and may change or be removed in future SDK or CLI releases. Pin both the
399 /// SDK and CLI versions if your code depends on it.
400 ///
401 /// </div>
402 pub async fn logout(&self, params: AccountLogoutRequest) -> Result<AccountLogoutResult, Error> {
403 let wire_params = serde_json::to_value(params)?;
404 let _value = self
405 .client
406 .call(rpc_methods::ACCOUNT_LOGOUT, Some(wire_params))
407 .await?;
408 Ok(serde_json::from_value(_value)?)
409 }
410}
411
412/// `agentRegistry.*` RPCs.
413#[derive(Clone, Copy)]
414pub struct ClientRpcAgentRegistry<'a> {
415 pub(crate) client: &'a Client,
416}
417
418impl<'a> ClientRpcAgentRegistry<'a> {
419 /// Spawns a managed-server child with the supplied configuration and returns a discriminated-union result. The caller (typically the CLI controller) is responsible for attaching to the spawned child and sending any follow-up prompt. When the controller-local spawn gate is closed the server returns JSON-RPC MethodNotFound.
420 ///
421 /// Wire method: `agentRegistry.spawn`.
422 ///
423 /// # Parameters
424 ///
425 /// * `params` - Inputs to spawn a managed-server child via the controller's spawn delegate.
426 ///
427 /// # Returns
428 ///
429 /// Outcome of an agentRegistry.spawn call.
430 ///
431 /// <div class="warning">
432 ///
433 /// **Experimental.** This API is part of an experimental wire-protocol surface
434 /// and may change or be removed in future SDK or CLI releases. Pin both the
435 /// SDK and CLI versions if your code depends on it.
436 ///
437 /// </div>
438 pub async fn spawn(
439 &self,
440 params: AgentRegistrySpawnRequest,
441 ) -> Result<AgentRegistrySpawnResult, Error> {
442 let wire_params = serde_json::to_value(params)?;
443 let _value = self
444 .client
445 .call(rpc_methods::AGENTREGISTRY_SPAWN, Some(wire_params))
446 .await?;
447 Ok(serde_json::from_value(_value)?)
448 }
449}
450
451/// `agents.*` RPCs.
452#[derive(Clone, Copy)]
453pub struct ClientRpcAgents<'a> {
454 pub(crate) client: &'a Client,
455}
456
457impl<'a> ClientRpcAgents<'a> {
458 /// Discovers custom agents across user, project, plugin, and remote sources.
459 ///
460 /// Wire method: `agents.discover`.
461 ///
462 /// # Parameters
463 ///
464 /// * `params` - Optional project paths to include in agent discovery.
465 ///
466 /// # Returns
467 ///
468 /// Agents discovered across user, project, plugin, and remote sources.
469 ///
470 /// <div class="warning">
471 ///
472 /// **Experimental.** This API is part of an experimental wire-protocol surface
473 /// and may change or be removed in future SDK or CLI releases. Pin both the
474 /// SDK and CLI versions if your code depends on it.
475 ///
476 /// </div>
477 pub async fn discover(&self, params: AgentsDiscoverRequest) -> Result<ServerAgentList, Error> {
478 let wire_params = serde_json::to_value(params)?;
479 let _value = self
480 .client
481 .call(rpc_methods::AGENTS_DISCOVER, Some(wire_params))
482 .await?;
483 Ok(serde_json::from_value(_value)?)
484 }
485
486 /// Returns the canonical directories where a client may create custom agents that the runtime will recognize, including ones that do not exist yet. Project directories become active once created.
487 ///
488 /// Wire method: `agents.getDiscoveryPaths`.
489 ///
490 /// # Parameters
491 ///
492 /// * `params` - Optional project paths to include when enumerating agent discovery directories.
493 ///
494 /// # Returns
495 ///
496 /// Canonical locations where custom agents can be created so the runtime will recognize them.
497 ///
498 /// <div class="warning">
499 ///
500 /// **Experimental.** This API is part of an experimental wire-protocol surface
501 /// and may change or be removed in future SDK or CLI releases. Pin both the
502 /// SDK and CLI versions if your code depends on it.
503 ///
504 /// </div>
505 pub async fn get_discovery_paths(
506 &self,
507 params: AgentsGetDiscoveryPathsRequest,
508 ) -> Result<AgentDiscoveryPathList, Error> {
509 let wire_params = serde_json::to_value(params)?;
510 let _value = self
511 .client
512 .call(rpc_methods::AGENTS_GETDISCOVERYPATHS, Some(wire_params))
513 .await?;
514 Ok(serde_json::from_value(_value)?)
515 }
516}
517
518/// `catalog.*` RPCs.
519#[derive(Clone, Copy)]
520pub struct ClientRpcCatalog<'a> {
521 pub(crate) client: &'a Client,
522}
523
524impl<'a> ClientRpcCatalog<'a> {
525 /// Requests a bounded catalog search. This host-implemented server method is available through SDK/TUI hosts; standalone and C-ABI runtimes whose host does not implement server-method dispatch return JSON-RPC MethodNotFound. A runtime with search available returns inert candidate summaries, each with an opaque single-use handle scoped to this runtime instance; a runtime without it returns the typed search-unavailable result. Public authorities may be searched anonymously, while an authority that requires credentials yields the typed authentication-required result. All returned text, URLs, and package metadata are untrusted external data and can never trigger instructions, tools, or installation. Read-only: nothing is installed, configured, or persisted.
526 ///
527 /// Wire method: `catalog.search`.
528 ///
529 /// # Parameters
530 ///
531 /// * `params` - A bounded catalog search. Both the query length and the result count are capped by the schema so a caller cannot request an unbounded scan.
532 ///
533 /// # Returns
534 ///
535 /// Outcome of a catalog.search call: either bounded inert candidates, or one typed refusal. Never a partial success.
536 ///
537 /// <div class="warning">
538 ///
539 /// **Experimental.** This API is part of an experimental wire-protocol surface
540 /// and may change or be removed in future SDK or CLI releases. Pin both the
541 /// SDK and CLI versions if your code depends on it.
542 ///
543 /// </div>
544 pub async fn search(&self, params: CatalogSearchRequest) -> Result<CatalogSearchResult, Error> {
545 let wire_params = serde_json::to_value(params)?;
546 let _value = self
547 .client
548 .call(rpc_methods::CATALOG_SEARCH, Some(wire_params))
549 .await?;
550 Ok(serde_json::from_value(_value)?)
551 }
552}
553
554/// `commands.*` RPCs.
555#[derive(Clone, Copy)]
556pub struct ClientRpcCommands<'a> {
557 pub(crate) client: &'a Client,
558}
559
560impl<'a> ClientRpcCommands<'a> {
561 /// 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.
562 ///
563 /// Wire method: `commands.list`.
564 ///
565 /// # Returns
566 ///
567 /// Slash commands available in the session, after applying any include/exclude filters.
568 ///
569 /// <div class="warning">
570 ///
571 /// **Experimental.** This API is part of an experimental wire-protocol surface
572 /// and may change or be removed in future SDK or CLI releases. Pin both the
573 /// SDK and CLI versions if your code depends on it.
574 ///
575 /// </div>
576 pub async fn list(&self) -> Result<CommandList, Error> {
577 let wire_params = serde_json::json!({});
578 let _value = self
579 .client
580 .call(rpc_methods::COMMANDS_LIST, Some(wire_params))
581 .await?;
582 Ok(serde_json::from_value(_value)?)
583 }
584}
585
586/// `extensions.*` RPCs.
587#[derive(Clone, Copy)]
588pub struct ClientRpcExtensions<'a> {
589 pub(crate) client: &'a Client,
590}
591
592impl<'a> ClientRpcExtensions<'a> {
593 /// Discovers user and enabled installed-plugin extensions from persisted Copilot home state, including enablement preferences. Launch-scoped additional plugins are not included.
594 ///
595 /// Wire method: `extensions.discover`.
596 ///
597 /// # Returns
598 ///
599 /// Extensions discovered from persisted Copilot home state and their effective loading mode. Launch-scoped additional plugins are not included.
600 ///
601 /// <div class="warning">
602 ///
603 /// **Experimental.** This API is part of an experimental wire-protocol surface
604 /// and may change or be removed in future SDK or CLI releases. Pin both the
605 /// SDK and CLI versions if your code depends on it.
606 ///
607 /// </div>
608 pub async fn discover(&self) -> Result<DiscoveredExtensions, Error> {
609 let wire_params = serde_json::json!({});
610 let _value = self
611 .client
612 .call(rpc_methods::EXTENSIONS_DISCOVER, Some(wire_params))
613 .await?;
614 Ok(serde_json::from_value(_value)?)
615 }
616
617 /// Persistently enables extension IDs for future sessions. Active sessions are unchanged; use session.extensions.enable to update them.
618 ///
619 /// Wire method: `extensions.enable`.
620 ///
621 /// # Parameters
622 ///
623 /// * `params` - Source-qualified extension identifiers to persistently enable for future sessions.
624 ///
625 /// <div class="warning">
626 ///
627 /// **Experimental.** This API is part of an experimental wire-protocol surface
628 /// and may change or be removed in future SDK or CLI releases. Pin both the
629 /// SDK and CLI versions if your code depends on it.
630 ///
631 /// </div>
632 pub async fn enable(&self, params: DiscoveredExtensionsEnableRequest) -> Result<(), Error> {
633 let wire_params = serde_json::to_value(params)?;
634 let _value = self
635 .client
636 .call(rpc_methods::EXTENSIONS_ENABLE, Some(wire_params))
637 .await?;
638 Ok(())
639 }
640
641 /// Persistently disables extension IDs for future sessions. Active sessions are unchanged; use session.extensions.disable to update them.
642 ///
643 /// Wire method: `extensions.disable`.
644 ///
645 /// # Parameters
646 ///
647 /// * `params` - Source-qualified extension identifiers to persistently disable for future sessions.
648 ///
649 /// <div class="warning">
650 ///
651 /// **Experimental.** This API is part of an experimental wire-protocol surface
652 /// and may change or be removed in future SDK or CLI releases. Pin both the
653 /// SDK and CLI versions if your code depends on it.
654 ///
655 /// </div>
656 pub async fn disable(&self, params: DiscoveredExtensionsDisableRequest) -> Result<(), Error> {
657 let wire_params = serde_json::to_value(params)?;
658 let _value = self
659 .client
660 .call(rpc_methods::EXTENSIONS_DISABLE, Some(wire_params))
661 .await?;
662 Ok(())
663 }
664}
665
666/// `hooks.*` RPCs.
667#[derive(Clone, Copy)]
668pub struct ClientRpcHooks<'a> {
669 pub(crate) client: &'a Client,
670}
671
672impl<'a> ClientRpcHooks<'a> {
673 /// Discovers hook actions enabled under server-side discovery settings from user, repository, plugin, and managed-policy sources.
674 ///
675 /// Wire method: `hooks.discover`.
676 ///
677 /// # Parameters
678 ///
679 /// * `params` - Optional project paths and host-exclusion behavior for server-scoped hook discovery.
680 ///
681 /// # Returns
682 ///
683 /// Server-discovered hook actions and partial-load diagnostics from user, repository, plugin, and managed-policy sources. Concrete sessions may include additional session-specific hook sources.
684 ///
685 /// <div class="warning">
686 ///
687 /// **Experimental.** This API is part of an experimental wire-protocol surface
688 /// and may change or be removed in future SDK or CLI releases. Pin both the
689 /// SDK and CLI versions if your code depends on it.
690 ///
691 /// </div>
692 pub async fn discover(
693 &self,
694 params: HooksDiscoverRequest,
695 ) -> Result<HooksDiscoverResult, Error> {
696 let wire_params = serde_json::to_value(params)?;
697 let _value = self
698 .client
699 .call(rpc_methods::HOOKS_DISCOVER, Some(wire_params))
700 .await?;
701 Ok(serde_json::from_value(_value)?)
702 }
703}
704
705/// `instructions.*` RPCs.
706#[derive(Clone, Copy)]
707pub struct ClientRpcInstructions<'a> {
708 pub(crate) client: &'a Client,
709}
710
711impl<'a> ClientRpcInstructions<'a> {
712 /// Discovers instruction sources across user, repository, and plugin sources.
713 ///
714 /// Wire method: `instructions.discover`.
715 ///
716 /// # Parameters
717 ///
718 /// * `params` - Optional project paths to include in instruction discovery.
719 ///
720 /// # Returns
721 ///
722 /// Instruction sources discovered across user, repository, and plugin sources.
723 ///
724 /// <div class="warning">
725 ///
726 /// **Experimental.** This API is part of an experimental wire-protocol surface
727 /// and may change or be removed in future SDK or CLI releases. Pin both the
728 /// SDK and CLI versions if your code depends on it.
729 ///
730 /// </div>
731 pub async fn discover(
732 &self,
733 params: InstructionsDiscoverRequest,
734 ) -> Result<ServerInstructionSourceList, Error> {
735 let wire_params = serde_json::to_value(params)?;
736 let _value = self
737 .client
738 .call(rpc_methods::INSTRUCTIONS_DISCOVER, Some(wire_params))
739 .await?;
740 Ok(serde_json::from_value(_value)?)
741 }
742
743 /// 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.
744 ///
745 /// Wire method: `instructions.getDiscoveryPaths`.
746 ///
747 /// # Parameters
748 ///
749 /// * `params` - Optional project paths to include when enumerating instruction discovery targets.
750 ///
751 /// # Returns
752 ///
753 /// Canonical files and directories where custom instructions can be created so the runtime will recognize them.
754 ///
755 /// <div class="warning">
756 ///
757 /// **Experimental.** This API is part of an experimental wire-protocol surface
758 /// and may change or be removed in future SDK or CLI releases. Pin both the
759 /// SDK and CLI versions if your code depends on it.
760 ///
761 /// </div>
762 pub async fn get_discovery_paths(
763 &self,
764 params: InstructionsGetDiscoveryPathsRequest,
765 ) -> Result<InstructionDiscoveryPathList, Error> {
766 let wire_params = serde_json::to_value(params)?;
767 let _value = self
768 .client
769 .call(
770 rpc_methods::INSTRUCTIONS_GETDISCOVERYPATHS,
771 Some(wire_params),
772 )
773 .await?;
774 Ok(serde_json::from_value(_value)?)
775 }
776}
777
778/// `llmInference.*` RPCs.
779#[derive(Clone, Copy)]
780pub struct ClientRpcLlmInference<'a> {
781 pub(crate) client: &'a Client,
782}
783
784impl<'a> ClientRpcLlmInference<'a> {
785 /// Registers an SDK client as the LLM inference callback provider.
786 ///
787 /// Wire method: `llmInference.setProvider`.
788 ///
789 /// # Returns
790 ///
791 /// Indicates whether the calling client was registered as the LLM inference provider.
792 ///
793 /// <div class="warning">
794 ///
795 /// **Experimental.** This API is part of an experimental wire-protocol surface
796 /// and may change or be removed in future SDK or CLI releases. Pin both the
797 /// SDK and CLI versions if your code depends on it.
798 ///
799 /// </div>
800 pub async fn set_provider(&self) -> Result<LlmInferenceSetProviderResult, Error> {
801 let wire_params = serde_json::json!({});
802 let _value = self
803 .client
804 .call(rpc_methods::LLMINFERENCE_SETPROVIDER, Some(wire_params))
805 .await?;
806 Ok(serde_json::from_value(_value)?)
807 }
808
809 /// 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.
810 ///
811 /// Wire method: `llmInference.httpResponseStart`.
812 ///
813 /// # Parameters
814 ///
815 /// * `params` - Response head.
816 ///
817 /// # Returns
818 ///
819 /// Whether the start frame was accepted.
820 ///
821 /// <div class="warning">
822 ///
823 /// **Experimental.** This API is part of an experimental wire-protocol surface
824 /// and may change or be removed in future SDK or CLI releases. Pin both the
825 /// SDK and CLI versions if your code depends on it.
826 ///
827 /// </div>
828 pub async fn http_response_start(
829 &self,
830 params: LlmInferenceHttpResponseStartRequest,
831 ) -> Result<LlmInferenceHttpResponseStartResult, Error> {
832 let wire_params = serde_json::to_value(params)?;
833 let _value = self
834 .client
835 .call(
836 rpc_methods::LLMINFERENCE_HTTPRESPONSESTART,
837 Some(wire_params),
838 )
839 .await?;
840 Ok(serde_json::from_value(_value)?)
841 }
842
843 /// 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.
844 ///
845 /// Wire method: `llmInference.httpResponseChunk`.
846 ///
847 /// # Parameters
848 ///
849 /// * `params` - A response body chunk or terminal error.
850 ///
851 /// # Returns
852 ///
853 /// Whether the chunk was accepted.
854 ///
855 /// <div class="warning">
856 ///
857 /// **Experimental.** This API is part of an experimental wire-protocol surface
858 /// and may change or be removed in future SDK or CLI releases. Pin both the
859 /// SDK and CLI versions if your code depends on it.
860 ///
861 /// </div>
862 pub async fn http_response_chunk(
863 &self,
864 params: LlmInferenceHttpResponseChunkRequest,
865 ) -> Result<LlmInferenceHttpResponseChunkResult, Error> {
866 let wire_params = serde_json::to_value(params)?;
867 let _value = self
868 .client
869 .call(
870 rpc_methods::LLMINFERENCE_HTTPRESPONSECHUNK,
871 Some(wire_params),
872 )
873 .await?;
874 Ok(serde_json::from_value(_value)?)
875 }
876}
877
878/// `managedSettings.*` RPCs.
879#[derive(Clone, Copy)]
880pub struct ClientRpcManagedSettings<'a> {
881 pub(crate) client: &'a Client,
882}
883
884impl<'a> ClientRpcManagedSettings<'a> {
885 /// 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.
886 ///
887 /// Wire method: `managedSettings.read`.
888 ///
889 /// # Returns
890 ///
891 /// Validated device-managed settings discovered before a session exists.
892 ///
893 /// <div class="warning">
894 ///
895 /// **Experimental.** This API is part of an experimental wire-protocol surface
896 /// and may change or be removed in future SDK or CLI releases. Pin both the
897 /// SDK and CLI versions if your code depends on it.
898 ///
899 /// </div>
900 pub async fn read(&self) -> Result<ManagedSettingsReadResult, Error> {
901 let wire_params = serde_json::json!({});
902 let _value = self
903 .client
904 .call(rpc_methods::MANAGEDSETTINGS_READ, Some(wire_params))
905 .await?;
906 Ok(serde_json::from_value(_value)?)
907 }
908
909 /// Force-refreshes enterprise managed settings for every account: wipes the persistent server-policy cache (the whole `<cacheHome>/managed-settings` directory) and drops this runtime process's in-memory retained server policy. It does not itself fetch policy — the effect is that the next time a session resolves managed settings for an account, that resolution re-fetches the account's org policy from the network instead of serving a cached response. Note that `managedSettings.read` returns only device/MDM settings and never triggers the account server-policy fetch, so a host implementing "sync account policy" should start a fresh session resolution rather than treat a subsequent `managedSettings.read` as the refreshed org policy. Mirrors the invalidation a sign-out performs, broadened from the one signing-out account to all of them; device/MDM layers describe the machine, not the account, and are left untouched. Rejects if the on-disk cache cannot be removed.
910 ///
911 /// Wire method: `managedSettings.clearCache`.
912 ///
913 /// <div class="warning">
914 ///
915 /// **Experimental.** This API is part of an experimental wire-protocol surface
916 /// and may change or be removed in future SDK or CLI releases. Pin both the
917 /// SDK and CLI versions if your code depends on it.
918 ///
919 /// </div>
920 pub async fn clear_cache(&self) -> Result<(), Error> {
921 let wire_params = serde_json::json!({});
922 let _value = self
923 .client
924 .call(rpc_methods::MANAGEDSETTINGS_CLEARCACHE, Some(wire_params))
925 .await?;
926 Ok(())
927 }
928}
929
930/// `mcp.*` RPCs.
931#[derive(Clone, Copy)]
932pub struct ClientRpcMcp<'a> {
933 pub(crate) client: &'a Client,
934}
935
936impl<'a> ClientRpcMcp<'a> {
937 /// `mcp.config.*` sub-namespace.
938 pub fn config(&self) -> ClientRpcMcpConfig<'a> {
939 ClientRpcMcpConfig {
940 client: self.client,
941 }
942 }
943
944 /// Discovers MCP servers from user, workspace, plugin, and builtin sources.
945 ///
946 /// Wire method: `mcp.discover`.
947 ///
948 /// # Parameters
949 ///
950 /// * `params` - Optional working directory used as context for MCP server discovery.
951 ///
952 /// # Returns
953 ///
954 /// MCP servers discovered from user, workspace, plugin, and built-in sources.
955 ///
956 /// <div class="warning">
957 ///
958 /// **Experimental.** This API is part of an experimental wire-protocol surface
959 /// and may change or be removed in future SDK or CLI releases. Pin both the
960 /// SDK and CLI versions if your code depends on it.
961 ///
962 /// </div>
963 pub async fn discover(&self, params: McpDiscoverRequest) -> Result<McpDiscoverResult, Error> {
964 let wire_params = serde_json::to_value(params)?;
965 let _value = self
966 .client
967 .call(rpc_methods::MCP_DISCOVER, Some(wire_params))
968 .await?;
969 Ok(serde_json::from_value(_value)?)
970 }
971
972 /// 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.
973 ///
974 /// Wire method: `mcp.planInstall`.
975 ///
976 /// # Parameters
977 ///
978 /// * `params` - A side-effect-free request for an MCP install plan. Computing a plan never writes configuration, stores a secret, or reloads MCP servers.
979 ///
980 /// # Returns
981 ///
982 /// Outcome of an mcp.planInstall call: either a normalised plan, or one typed refusal. Nothing is written in either case.
983 ///
984 /// <div class="warning">
985 ///
986 /// **Experimental.** This API is part of an experimental wire-protocol surface
987 /// and may change or be removed in future SDK or CLI releases. Pin both the
988 /// SDK and CLI versions if your code depends on it.
989 ///
990 /// </div>
991 pub async fn plan_install(
992 &self,
993 params: McpPlanInstallRequest,
994 ) -> Result<McpPlanInstallResult, Error> {
995 let wire_params = serde_json::to_value(params)?;
996 let _value = self
997 .client
998 .call(rpc_methods::MCP_PLANINSTALL, Some(wire_params))
999 .await?;
1000 Ok(serde_json::from_value(_value)?)
1001 }
1002}
1003
1004/// `mcp.config.*` RPCs.
1005#[derive(Clone, Copy)]
1006pub struct ClientRpcMcpConfig<'a> {
1007 pub(crate) client: &'a Client,
1008}
1009
1010impl<'a> ClientRpcMcpConfig<'a> {
1011 /// Lists MCP servers from user configuration.
1012 ///
1013 /// Wire method: `mcp.config.list`.
1014 ///
1015 /// # Returns
1016 ///
1017 /// User-configured MCP servers, keyed by server name.
1018 ///
1019 /// <div class="warning">
1020 ///
1021 /// **Experimental.** This API is part of an experimental wire-protocol surface
1022 /// and may change or be removed in future SDK or CLI releases. Pin both the
1023 /// SDK and CLI versions if your code depends on it.
1024 ///
1025 /// </div>
1026 pub async fn list(&self) -> Result<McpConfigList, Error> {
1027 let wire_params = serde_json::json!({});
1028 let _value = self
1029 .client
1030 .call(rpc_methods::MCP_CONFIG_LIST, Some(wire_params))
1031 .await?;
1032 Ok(serde_json::from_value(_value)?)
1033 }
1034
1035 /// Adds an MCP server to user configuration.
1036 ///
1037 /// Wire method: `mcp.config.add`.
1038 ///
1039 /// # Parameters
1040 ///
1041 /// * `params` - MCP server name and configuration to add to user configuration.
1042 ///
1043 /// <div class="warning">
1044 ///
1045 /// **Experimental.** This API is part of an experimental wire-protocol surface
1046 /// and may change or be removed in future SDK or CLI releases. Pin both the
1047 /// SDK and CLI versions if your code depends on it.
1048 ///
1049 /// </div>
1050 pub async fn add(&self, params: McpConfigAddRequest) -> Result<(), Error> {
1051 let wire_params = serde_json::to_value(params)?;
1052 let _value = self
1053 .client
1054 .call(rpc_methods::MCP_CONFIG_ADD, Some(wire_params))
1055 .await?;
1056 Ok(())
1057 }
1058
1059 /// Updates an MCP server in user configuration.
1060 ///
1061 /// Wire method: `mcp.config.update`.
1062 ///
1063 /// # Parameters
1064 ///
1065 /// * `params` - MCP server name and replacement configuration to write to user configuration.
1066 ///
1067 /// <div class="warning">
1068 ///
1069 /// **Experimental.** This API is part of an experimental wire-protocol surface
1070 /// and may change or be removed in future SDK or CLI releases. Pin both the
1071 /// SDK and CLI versions if your code depends on it.
1072 ///
1073 /// </div>
1074 pub async fn update(&self, params: McpConfigUpdateRequest) -> Result<(), Error> {
1075 let wire_params = serde_json::to_value(params)?;
1076 let _value = self
1077 .client
1078 .call(rpc_methods::MCP_CONFIG_UPDATE, Some(wire_params))
1079 .await?;
1080 Ok(())
1081 }
1082
1083 /// Removes an MCP server from user configuration.
1084 ///
1085 /// Wire method: `mcp.config.remove`.
1086 ///
1087 /// # Parameters
1088 ///
1089 /// * `params` - MCP server name to remove from user configuration.
1090 ///
1091 /// <div class="warning">
1092 ///
1093 /// **Experimental.** This API is part of an experimental wire-protocol surface
1094 /// and may change or be removed in future SDK or CLI releases. Pin both the
1095 /// SDK and CLI versions if your code depends on it.
1096 ///
1097 /// </div>
1098 pub async fn remove(&self, params: McpConfigRemoveRequest) -> Result<(), Error> {
1099 let wire_params = serde_json::to_value(params)?;
1100 let _value = self
1101 .client
1102 .call(rpc_methods::MCP_CONFIG_REMOVE, Some(wire_params))
1103 .await?;
1104 Ok(())
1105 }
1106
1107 /// Enables MCP servers in user configuration for new sessions.
1108 ///
1109 /// Wire method: `mcp.config.enable`.
1110 ///
1111 /// # Parameters
1112 ///
1113 /// * `params` - MCP server names to enable for new sessions.
1114 ///
1115 /// <div class="warning">
1116 ///
1117 /// **Experimental.** This API is part of an experimental wire-protocol surface
1118 /// and may change or be removed in future SDK or CLI releases. Pin both the
1119 /// SDK and CLI versions if your code depends on it.
1120 ///
1121 /// </div>
1122 pub async fn enable(&self, params: McpConfigEnableRequest) -> Result<(), Error> {
1123 let wire_params = serde_json::to_value(params)?;
1124 let _value = self
1125 .client
1126 .call(rpc_methods::MCP_CONFIG_ENABLE, Some(wire_params))
1127 .await?;
1128 Ok(())
1129 }
1130
1131 /// Disables MCP servers in user configuration for new sessions.
1132 ///
1133 /// Wire method: `mcp.config.disable`.
1134 ///
1135 /// # Parameters
1136 ///
1137 /// * `params` - MCP server names to disable for new sessions.
1138 ///
1139 /// <div class="warning">
1140 ///
1141 /// **Experimental.** This API is part of an experimental wire-protocol surface
1142 /// and may change or be removed in future SDK or CLI releases. Pin both the
1143 /// SDK and CLI versions if your code depends on it.
1144 ///
1145 /// </div>
1146 pub async fn disable(&self, params: McpConfigDisableRequest) -> Result<(), Error> {
1147 let wire_params = serde_json::to_value(params)?;
1148 let _value = self
1149 .client
1150 .call(rpc_methods::MCP_CONFIG_DISABLE, Some(wire_params))
1151 .await?;
1152 Ok(())
1153 }
1154
1155 /// Drops this runtime process's in-memory MCP server-definition cache so the next MCP config read observes disk.
1156 ///
1157 /// Wire method: `mcp.config.reload`.
1158 ///
1159 /// <div class="warning">
1160 ///
1161 /// **Experimental.** This API is part of an experimental wire-protocol surface
1162 /// and may change or be removed in future SDK or CLI releases. Pin both the
1163 /// SDK and CLI versions if your code depends on it.
1164 ///
1165 /// </div>
1166 pub async fn reload(&self) -> Result<(), Error> {
1167 let wire_params = serde_json::json!({});
1168 let _value = self
1169 .client
1170 .call(rpc_methods::MCP_CONFIG_RELOAD, Some(wire_params))
1171 .await?;
1172 Ok(())
1173 }
1174}
1175
1176/// `models.*` RPCs.
1177#[derive(Clone, Copy)]
1178pub struct ClientRpcModels<'a> {
1179 pub(crate) client: &'a Client,
1180}
1181
1182impl<'a> ClientRpcModels<'a> {
1183 /// Lists Copilot models available to the authenticated user.
1184 ///
1185 /// Wire method: `models.list`.
1186 ///
1187 /// # Returns
1188 ///
1189 /// List of Copilot models available to the resolved user, including capabilities and billing metadata.
1190 ///
1191 /// <div class="warning">
1192 ///
1193 /// **Experimental.** This API is part of an experimental wire-protocol surface
1194 /// and may change or be removed in future SDK or CLI releases. Pin both the
1195 /// SDK and CLI versions if your code depends on it.
1196 ///
1197 /// </div>
1198 pub async fn list(&self) -> Result<ModelList, Error> {
1199 let wire_params = serde_json::json!({});
1200 let _value = self
1201 .client
1202 .call(rpc_methods::MODELS_LIST, Some(wire_params))
1203 .await?;
1204 Ok(serde_json::from_value(_value)?)
1205 }
1206
1207 /// Lists Copilot models available to the authenticated user.
1208 ///
1209 /// Wire method: `models.list`.
1210 ///
1211 /// # Parameters
1212 ///
1213 /// * `params` - Optional opaque account selection or compatibility GitHub token used to list models.
1214 ///
1215 /// # Returns
1216 ///
1217 /// List of Copilot models available to the resolved user, including capabilities and billing metadata.
1218 ///
1219 /// <div class="warning">
1220 ///
1221 /// **Experimental.** This API is part of an experimental wire-protocol surface
1222 /// and may change or be removed in future SDK or CLI releases. Pin both the
1223 /// SDK and CLI versions if your code depends on it.
1224 ///
1225 /// </div>
1226 pub async fn list_with_params(&self, params: ModelsListRequest) -> Result<ModelList, Error> {
1227 let wire_params = serde_json::to_value(params)?;
1228 let _value = self
1229 .client
1230 .call(rpc_methods::MODELS_LIST, Some(wire_params))
1231 .await?;
1232 Ok(serde_json::from_value(_value)?)
1233 }
1234
1235 /// Returns the running runtime's complete catalog of well-known built-in model IDs without authentication or network access.
1236 ///
1237 /// Wire method: `models.getBuiltInCatalog`.
1238 ///
1239 /// # Returns
1240 ///
1241 /// The running runtime's complete catalog of well-known built-in model IDs, including supported models and additional IDs with built-in metadata.
1242 ///
1243 /// <div class="warning">
1244 ///
1245 /// **Experimental.** This API is part of an experimental wire-protocol surface
1246 /// and may change or be removed in future SDK or CLI releases. Pin both the
1247 /// SDK and CLI versions if your code depends on it.
1248 ///
1249 /// </div>
1250 pub async fn get_built_in_catalog(&self) -> Result<BuiltInModelCatalog, Error> {
1251 let wire_params = serde_json::json!({});
1252 let _value = self
1253 .client
1254 .call(rpc_methods::MODELS_GETBUILTINCATALOG, Some(wire_params))
1255 .await?;
1256 Ok(serde_json::from_value(_value)?)
1257 }
1258}
1259
1260/// `plugins.*` RPCs.
1261#[derive(Clone, Copy)]
1262pub struct ClientRpcPlugins<'a> {
1263 pub(crate) client: &'a Client,
1264}
1265
1266impl<'a> ClientRpcPlugins<'a> {
1267 /// `plugins.builtin.*` sub-namespace.
1268 pub fn builtin(&self) -> ClientRpcPluginsBuiltin<'a> {
1269 ClientRpcPluginsBuiltin {
1270 client: self.client,
1271 }
1272 }
1273
1274 /// `plugins.marketplaces.*` sub-namespace.
1275 pub fn marketplaces(&self) -> ClientRpcPluginsMarketplaces<'a> {
1276 ClientRpcPluginsMarketplaces {
1277 client: self.client,
1278 }
1279 }
1280
1281 /// Lists plugins installed in user/global state.
1282 ///
1283 /// Wire method: `plugins.list`.
1284 ///
1285 /// # Returns
1286 ///
1287 /// Plugins installed in user/global state.
1288 ///
1289 /// <div class="warning">
1290 ///
1291 /// **Experimental.** This API is part of an experimental wire-protocol surface
1292 /// and may change or be removed in future SDK or CLI releases. Pin both the
1293 /// SDK and CLI versions if your code depends on it.
1294 ///
1295 /// </div>
1296 pub async fn list(&self) -> Result<PluginListResult, Error> {
1297 let wire_params = serde_json::json!({});
1298 let _value = self
1299 .client
1300 .call(rpc_methods::PLUGINS_LIST, Some(wire_params))
1301 .await?;
1302 Ok(serde_json::from_value(_value)?)
1303 }
1304
1305 /// Installs a plugin from a marketplace, GitHub repo, URL, or local path.
1306 ///
1307 /// Wire method: `plugins.install`.
1308 ///
1309 /// # Parameters
1310 ///
1311 /// * `params` - Plugin source and optional working directory for relative-path resolution.
1312 ///
1313 /// # Returns
1314 ///
1315 /// Result of installing a plugin.
1316 ///
1317 /// <div class="warning">
1318 ///
1319 /// **Experimental.** This API is part of an experimental wire-protocol surface
1320 /// and may change or be removed in future SDK or CLI releases. Pin both the
1321 /// SDK and CLI versions if your code depends on it.
1322 ///
1323 /// </div>
1324 pub async fn install(
1325 &self,
1326 params: PluginsInstallRequest,
1327 ) -> Result<PluginInstallResult, Error> {
1328 let wire_params = serde_json::to_value(params)?;
1329 let _value = self
1330 .client
1331 .call(rpc_methods::PLUGINS_INSTALL, Some(wire_params))
1332 .await?;
1333 Ok(serde_json::from_value(_value)?)
1334 }
1335
1336 /// Uninstalls an installed plugin.
1337 ///
1338 /// Wire method: `plugins.uninstall`.
1339 ///
1340 /// # Parameters
1341 ///
1342 /// * `params` - Name (or spec) of the plugin to uninstall.
1343 ///
1344 /// <div class="warning">
1345 ///
1346 /// **Experimental.** This API is part of an experimental wire-protocol surface
1347 /// and may change or be removed in future SDK or CLI releases. Pin both the
1348 /// SDK and CLI versions if your code depends on it.
1349 ///
1350 /// </div>
1351 pub async fn uninstall(&self, params: PluginsUninstallRequest) -> Result<(), Error> {
1352 let wire_params = serde_json::to_value(params)?;
1353 let _value = self
1354 .client
1355 .call(rpc_methods::PLUGINS_UNINSTALL, Some(wire_params))
1356 .await?;
1357 Ok(())
1358 }
1359
1360 /// Updates an installed plugin to its latest published version.
1361 ///
1362 /// Wire method: `plugins.update`.
1363 ///
1364 /// # Parameters
1365 ///
1366 /// * `params` - Name (or spec) of the plugin to update.
1367 ///
1368 /// # Returns
1369 ///
1370 /// Result of updating a single plugin.
1371 ///
1372 /// <div class="warning">
1373 ///
1374 /// **Experimental.** This API is part of an experimental wire-protocol surface
1375 /// and may change or be removed in future SDK or CLI releases. Pin both the
1376 /// SDK and CLI versions if your code depends on it.
1377 ///
1378 /// </div>
1379 pub async fn update(&self, params: PluginsUpdateRequest) -> Result<PluginUpdateResult, Error> {
1380 let wire_params = serde_json::to_value(params)?;
1381 let _value = self
1382 .client
1383 .call(rpc_methods::PLUGINS_UPDATE, Some(wire_params))
1384 .await?;
1385 Ok(serde_json::from_value(_value)?)
1386 }
1387
1388 /// Updates every installed plugin to its latest published version.
1389 ///
1390 /// Wire method: `plugins.updateAll`.
1391 ///
1392 /// # Returns
1393 ///
1394 /// Result of updating all installed plugins.
1395 ///
1396 /// <div class="warning">
1397 ///
1398 /// **Experimental.** This API is part of an experimental wire-protocol surface
1399 /// and may change or be removed in future SDK or CLI releases. Pin both the
1400 /// SDK and CLI versions if your code depends on it.
1401 ///
1402 /// </div>
1403 pub async fn update_all(&self) -> Result<PluginUpdateAllResult, Error> {
1404 let wire_params = serde_json::json!({});
1405 let _value = self
1406 .client
1407 .call(rpc_methods::PLUGINS_UPDATEALL, Some(wire_params))
1408 .await?;
1409 Ok(serde_json::from_value(_value)?)
1410 }
1411
1412 /// Enables installed plugins for new sessions.
1413 ///
1414 /// Wire method: `plugins.enable`.
1415 ///
1416 /// # Parameters
1417 ///
1418 /// * `params` - Plugin names (or specs) to enable, plus the optional working directory the repository-controlled guard is evaluated against.
1419 ///
1420 /// <div class="warning">
1421 ///
1422 /// **Experimental.** This API is part of an experimental wire-protocol surface
1423 /// and may change or be removed in future SDK or CLI releases. Pin both the
1424 /// SDK and CLI versions if your code depends on it.
1425 ///
1426 /// </div>
1427 pub async fn enable(&self, params: PluginsEnableRequest) -> Result<(), Error> {
1428 let wire_params = serde_json::to_value(params)?;
1429 let _value = self
1430 .client
1431 .call(rpc_methods::PLUGINS_ENABLE, Some(wire_params))
1432 .await?;
1433 Ok(())
1434 }
1435
1436 /// Disables installed plugins for new sessions.
1437 ///
1438 /// Wire method: `plugins.disable`.
1439 ///
1440 /// # Parameters
1441 ///
1442 /// * `params` - Plugin names (or specs) to disable, plus the optional working directory the repository-controlled guard is evaluated against.
1443 ///
1444 /// <div class="warning">
1445 ///
1446 /// **Experimental.** This API is part of an experimental wire-protocol surface
1447 /// and may change or be removed in future SDK or CLI releases. Pin both the
1448 /// SDK and CLI versions if your code depends on it.
1449 ///
1450 /// </div>
1451 pub async fn disable(&self, params: PluginsDisableRequest) -> Result<(), Error> {
1452 let wire_params = serde_json::to_value(params)?;
1453 let _value = self
1454 .client
1455 .call(rpc_methods::PLUGINS_DISABLE, Some(wire_params))
1456 .await?;
1457 Ok(())
1458 }
1459}
1460
1461/// `plugins.builtin.*` RPCs.
1462#[derive(Clone, Copy)]
1463pub struct ClientRpcPluginsBuiltin<'a> {
1464 pub(crate) client: &'a Client,
1465}
1466
1467impl<'a> ClientRpcPluginsBuiltin<'a> {
1468 /// Replaces this server's trusted built-in plugin directories while no sessions are active.
1469 ///
1470 /// Wire method: `plugins.builtin.set`.
1471 ///
1472 /// # Parameters
1473 ///
1474 /// * `params` - Trusted built-in plugin directories to use for this runtime process.
1475 ///
1476 /// <div class="warning">
1477 ///
1478 /// **Experimental.** This API is part of an experimental wire-protocol surface
1479 /// and may change or be removed in future SDK or CLI releases. Pin both the
1480 /// SDK and CLI versions if your code depends on it.
1481 ///
1482 /// </div>
1483 pub async fn set(&self, params: PluginsBuiltinSetRequest) -> Result<(), Error> {
1484 let wire_params = serde_json::to_value(params)?;
1485 let _value = self
1486 .client
1487 .call(rpc_methods::PLUGINS_BUILTIN_SET, Some(wire_params))
1488 .await?;
1489 Ok(())
1490 }
1491}
1492
1493/// `plugins.marketplaces.*` RPCs.
1494#[derive(Clone, Copy)]
1495pub struct ClientRpcPluginsMarketplaces<'a> {
1496 pub(crate) client: &'a Client,
1497}
1498
1499impl<'a> ClientRpcPluginsMarketplaces<'a> {
1500 /// Lists all registered marketplaces (defaults + user-added).
1501 ///
1502 /// Wire method: `plugins.marketplaces.list`.
1503 ///
1504 /// # Returns
1505 ///
1506 /// All registered marketplaces, including built-in defaults.
1507 ///
1508 /// <div class="warning">
1509 ///
1510 /// **Experimental.** This API is part of an experimental wire-protocol surface
1511 /// and may change or be removed in future SDK or CLI releases. Pin both the
1512 /// SDK and CLI versions if your code depends on it.
1513 ///
1514 /// </div>
1515 pub async fn list(&self) -> Result<MarketplaceListResult, Error> {
1516 let wire_params = serde_json::json!({});
1517 let _value = self
1518 .client
1519 .call(rpc_methods::PLUGINS_MARKETPLACES_LIST, Some(wire_params))
1520 .await?;
1521 Ok(serde_json::from_value(_value)?)
1522 }
1523
1524 /// Registers a new marketplace from a source (owner/repo, URL, or local path).
1525 ///
1526 /// Wire method: `plugins.marketplaces.add`.
1527 ///
1528 /// # Parameters
1529 ///
1530 /// * `params` - Marketplace source and optional working directory for relative-path resolution.
1531 ///
1532 /// # Returns
1533 ///
1534 /// Result of registering a new marketplace.
1535 ///
1536 /// <div class="warning">
1537 ///
1538 /// **Experimental.** This API is part of an experimental wire-protocol surface
1539 /// and may change or be removed in future SDK or CLI releases. Pin both the
1540 /// SDK and CLI versions if your code depends on it.
1541 ///
1542 /// </div>
1543 pub async fn add(
1544 &self,
1545 params: PluginsMarketplacesAddRequest,
1546 ) -> Result<MarketplaceAddResult, Error> {
1547 let wire_params = serde_json::to_value(params)?;
1548 let _value = self
1549 .client
1550 .call(rpc_methods::PLUGINS_MARKETPLACES_ADD, Some(wire_params))
1551 .await?;
1552 Ok(serde_json::from_value(_value)?)
1553 }
1554
1555 /// 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`.
1556 ///
1557 /// Wire method: `plugins.marketplaces.remove`.
1558 ///
1559 /// # Parameters
1560 ///
1561 /// * `params` - Name of the marketplace to remove and an optional force flag.
1562 ///
1563 /// # Returns
1564 ///
1565 /// Outcome of the remove attempt, including dependent-plugin info when applicable.
1566 ///
1567 /// <div class="warning">
1568 ///
1569 /// **Experimental.** This API is part of an experimental wire-protocol surface
1570 /// and may change or be removed in future SDK or CLI releases. Pin both the
1571 /// SDK and CLI versions if your code depends on it.
1572 ///
1573 /// </div>
1574 pub async fn remove(
1575 &self,
1576 params: PluginsMarketplacesRemoveRequest,
1577 ) -> Result<MarketplaceRemoveResult, Error> {
1578 let wire_params = serde_json::to_value(params)?;
1579 let _value = self
1580 .client
1581 .call(rpc_methods::PLUGINS_MARKETPLACES_REMOVE, Some(wire_params))
1582 .await?;
1583 Ok(serde_json::from_value(_value)?)
1584 }
1585
1586 /// Lists plugins advertised by a registered marketplace.
1587 ///
1588 /// Wire method: `plugins.marketplaces.browse`.
1589 ///
1590 /// # Parameters
1591 ///
1592 /// * `params` - Name of the marketplace whose plugin catalog to fetch.
1593 ///
1594 /// # Returns
1595 ///
1596 /// Plugins advertised by the marketplace.
1597 ///
1598 /// <div class="warning">
1599 ///
1600 /// **Experimental.** This API is part of an experimental wire-protocol surface
1601 /// and may change or be removed in future SDK or CLI releases. Pin both the
1602 /// SDK and CLI versions if your code depends on it.
1603 ///
1604 /// </div>
1605 pub async fn browse(
1606 &self,
1607 params: PluginsMarketplacesBrowseRequest,
1608 ) -> Result<MarketplaceBrowseResult, Error> {
1609 let wire_params = serde_json::to_value(params)?;
1610 let _value = self
1611 .client
1612 .call(rpc_methods::PLUGINS_MARKETPLACES_BROWSE, Some(wire_params))
1613 .await?;
1614 Ok(serde_json::from_value(_value)?)
1615 }
1616
1617 /// Re-fetches one or all registered marketplace catalogs.
1618 ///
1619 /// Wire method: `plugins.marketplaces.refresh`.
1620 ///
1621 /// # Returns
1622 ///
1623 /// Result of refreshing one or more marketplace catalogs.
1624 ///
1625 /// <div class="warning">
1626 ///
1627 /// **Experimental.** This API is part of an experimental wire-protocol surface
1628 /// and may change or be removed in future SDK or CLI releases. Pin both the
1629 /// SDK and CLI versions if your code depends on it.
1630 ///
1631 /// </div>
1632 pub async fn refresh(&self) -> Result<MarketplaceRefreshResult, Error> {
1633 let wire_params = serde_json::json!({});
1634 let _value = self
1635 .client
1636 .call(rpc_methods::PLUGINS_MARKETPLACES_REFRESH, Some(wire_params))
1637 .await?;
1638 Ok(serde_json::from_value(_value)?)
1639 }
1640
1641 /// Re-fetches one or all registered marketplace catalogs.
1642 ///
1643 /// Wire method: `plugins.marketplaces.refresh`.
1644 ///
1645 /// # Parameters
1646 ///
1647 /// * `params` - Optional marketplace name; omit to refresh all.
1648 ///
1649 /// # Returns
1650 ///
1651 /// Result of refreshing one or more marketplace catalogs.
1652 ///
1653 /// <div class="warning">
1654 ///
1655 /// **Experimental.** This API is part of an experimental wire-protocol surface
1656 /// and may change or be removed in future SDK or CLI releases. Pin both the
1657 /// SDK and CLI versions if your code depends on it.
1658 ///
1659 /// </div>
1660 pub async fn refresh_with_params(
1661 &self,
1662 params: PluginsMarketplacesRefreshRequest,
1663 ) -> Result<MarketplaceRefreshResult, Error> {
1664 let wire_params = serde_json::to_value(params)?;
1665 let _value = self
1666 .client
1667 .call(rpc_methods::PLUGINS_MARKETPLACES_REFRESH, Some(wire_params))
1668 .await?;
1669 Ok(serde_json::from_value(_value)?)
1670 }
1671}
1672
1673/// `runtime.*` RPCs.
1674#[derive(Clone, Copy)]
1675pub struct ClientRpcRuntime<'a> {
1676 pub(crate) client: &'a Client,
1677}
1678
1679impl<'a> ClientRpcRuntime<'a> {
1680 /// Gracefully shuts down an SDK-owned runtime. The response is sent only after cleanup completes; callers may then terminate the owned runtime process.
1681 ///
1682 /// Wire method: `runtime.shutdown`.
1683 ///
1684 /// <div class="warning">
1685 ///
1686 /// **Experimental.** This API is part of an experimental wire-protocol surface
1687 /// and may change or be removed in future SDK or CLI releases. Pin both the
1688 /// SDK and CLI versions if your code depends on it.
1689 ///
1690 /// </div>
1691 pub async fn shutdown(&self) -> Result<(), Error> {
1692 let wire_params = serde_json::json!({});
1693 let _value = self
1694 .client
1695 .call(rpc_methods::RUNTIME_SHUTDOWN, Some(wire_params))
1696 .await?;
1697 Ok(())
1698 }
1699}
1700
1701/// `secrets.*` RPCs.
1702#[derive(Clone, Copy)]
1703pub struct ClientRpcSecrets<'a> {
1704 pub(crate) client: &'a Client,
1705}
1706
1707impl<'a> ClientRpcSecrets<'a> {
1708 /// Registers secret values for redaction in session logs and exports. The SDK calls this to inject dynamically generated secret values (e.g., OIDC tokens).
1709 ///
1710 /// Wire method: `secrets.addFilterValues`.
1711 ///
1712 /// # Parameters
1713 ///
1714 /// * `params` - Secret values to add to the redaction filter.
1715 ///
1716 /// # Returns
1717 ///
1718 /// Confirmation that the secret values were registered.
1719 ///
1720 /// <div class="warning">
1721 ///
1722 /// **Experimental.** This API is part of an experimental wire-protocol surface
1723 /// and may change or be removed in future SDK or CLI releases. Pin both the
1724 /// SDK and CLI versions if your code depends on it.
1725 ///
1726 /// </div>
1727 pub async fn add_filter_values(
1728 &self,
1729 params: SecretsAddFilterValuesRequest,
1730 ) -> Result<SecretsAddFilterValuesResult, Error> {
1731 let wire_params = serde_json::to_value(params)?;
1732 let _value = self
1733 .client
1734 .call(rpc_methods::SECRETS_ADDFILTERVALUES, Some(wire_params))
1735 .await?;
1736 Ok(serde_json::from_value(_value)?)
1737 }
1738}
1739
1740/// `sessionFs.*` RPCs.
1741#[derive(Clone, Copy)]
1742pub struct ClientRpcSessionFs<'a> {
1743 pub(crate) client: &'a Client,
1744}
1745
1746impl<'a> ClientRpcSessionFs<'a> {
1747 /// Registers an SDK client as the session filesystem provider.
1748 ///
1749 /// Wire method: `sessionFs.setProvider`.
1750 ///
1751 /// # Parameters
1752 ///
1753 /// * `params` - Initial working directory, session-state path layout, and path conventions used to register the calling SDK client as the session filesystem provider.
1754 ///
1755 /// # Returns
1756 ///
1757 /// Indicates whether the calling client was registered as the session filesystem provider.
1758 ///
1759 /// <div class="warning">
1760 ///
1761 /// **Experimental.** This API is part of an experimental wire-protocol surface
1762 /// and may change or be removed in future SDK or CLI releases. Pin both the
1763 /// SDK and CLI versions if your code depends on it.
1764 ///
1765 /// </div>
1766 pub async fn set_provider(
1767 &self,
1768 params: SessionFsSetProviderRequest,
1769 ) -> Result<SessionFsSetProviderResult, Error> {
1770 let wire_params = serde_json::to_value(params)?;
1771 let _value = self
1772 .client
1773 .call(rpc_methods::SESSIONFS_SETPROVIDER, Some(wire_params))
1774 .await?;
1775 Ok(serde_json::from_value(_value)?)
1776 }
1777}
1778
1779/// `sessions.*` RPCs.
1780#[derive(Clone, Copy)]
1781pub struct ClientRpcSessions<'a> {
1782 pub(crate) client: &'a Client,
1783}
1784
1785impl<'a> ClientRpcSessions<'a> {
1786 /// Creates or resumes a local session and returns the opened session ID.
1787 ///
1788 /// Wire method: `sessions.open`.
1789 ///
1790 /// # Returns
1791 ///
1792 /// Result of opening a session.
1793 ///
1794 /// <div class="warning">
1795 ///
1796 /// **Experimental.** This API is part of an experimental wire-protocol surface
1797 /// and may change or be removed in future SDK or CLI releases. Pin both the
1798 /// SDK and CLI versions if your code depends on it.
1799 ///
1800 /// </div>
1801 pub async fn open(&self) -> Result<SessionOpenResult, Error> {
1802 let wire_params = serde_json::json!({});
1803 let _value = self
1804 .client
1805 .call(rpc_methods::SESSIONS_OPEN, Some(wire_params))
1806 .await?;
1807 Ok(serde_json::from_value(_value)?)
1808 }
1809
1810 /// Creates a new session by forking persisted history from an existing session.
1811 ///
1812 /// Wire method: `sessions.fork`.
1813 ///
1814 /// # Parameters
1815 ///
1816 /// * `params` - Source session identifier to fork from, optional event-ID boundary, and optional friendly name for the new session.
1817 ///
1818 /// # Returns
1819 ///
1820 /// Identifier and optional friendly name assigned to the newly forked session.
1821 ///
1822 /// <div class="warning">
1823 ///
1824 /// **Experimental.** This API is part of an experimental wire-protocol surface
1825 /// and may change or be removed in future SDK or CLI releases. Pin both the
1826 /// SDK and CLI versions if your code depends on it.
1827 ///
1828 /// </div>
1829 pub async fn fork(&self, params: SessionsForkRequest) -> Result<SessionsForkResult, Error> {
1830 let wire_params = serde_json::to_value(params)?;
1831 let _value = self
1832 .client
1833 .call(rpc_methods::SESSIONS_FORK, Some(wire_params))
1834 .await?;
1835 Ok(serde_json::from_value(_value)?)
1836 }
1837
1838 /// Connects to an existing remote session and exposes it as an SDK session.
1839 ///
1840 /// Wire method: `sessions.connect`.
1841 ///
1842 /// # Parameters
1843 ///
1844 /// * `params` - Remote session connection parameters.
1845 ///
1846 /// # Returns
1847 ///
1848 /// Remote session connection result.
1849 ///
1850 /// <div class="warning">
1851 ///
1852 /// **Experimental.** This API is part of an experimental wire-protocol surface
1853 /// and may change or be removed in future SDK or CLI releases. Pin both the
1854 /// SDK and CLI versions if your code depends on it.
1855 ///
1856 /// </div>
1857 pub async fn connect(
1858 &self,
1859 params: ConnectRemoteSessionParams,
1860 ) -> Result<RemoteSessionConnectionResult, Error> {
1861 let wire_params = serde_json::to_value(params)?;
1862 let _value = self
1863 .client
1864 .call(rpc_methods::SESSIONS_CONNECT, Some(wire_params))
1865 .await?;
1866 Ok(serde_json::from_value(_value)?)
1867 }
1868
1869 /// 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.).
1870 ///
1871 /// Wire method: `sessions.list`.
1872 ///
1873 /// # Returns
1874 ///
1875 /// Sessions matching the filter, ordered most-recently-modified first.
1876 ///
1877 /// <div class="warning">
1878 ///
1879 /// **Experimental.** This API is part of an experimental wire-protocol surface
1880 /// and may change or be removed in future SDK or CLI releases. Pin both the
1881 /// SDK and CLI versions if your code depends on it.
1882 ///
1883 /// </div>
1884 pub async fn list(&self) -> Result<SessionList, Error> {
1885 let wire_params = serde_json::json!({});
1886 let _value = self
1887 .client
1888 .call(rpc_methods::SESSIONS_LIST, Some(wire_params))
1889 .await?;
1890 Ok(serde_json::from_value(_value)?)
1891 }
1892
1893 /// 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.).
1894 ///
1895 /// Wire method: `sessions.list`.
1896 ///
1897 /// # Parameters
1898 ///
1899 /// * `params` - Optional source filter, metadata-load limit, and context filter applied to the returned sessions.
1900 ///
1901 /// # Returns
1902 ///
1903 /// Sessions matching the filter, ordered most-recently-modified first.
1904 ///
1905 /// <div class="warning">
1906 ///
1907 /// **Experimental.** This API is part of an experimental wire-protocol surface
1908 /// and may change or be removed in future SDK or CLI releases. Pin both the
1909 /// SDK and CLI versions if your code depends on it.
1910 ///
1911 /// </div>
1912 pub async fn list_with_params(
1913 &self,
1914 params: SessionsListRequest,
1915 ) -> Result<SessionList, Error> {
1916 let wire_params = serde_json::to_value(params)?;
1917 let _value = self
1918 .client
1919 .call(rpc_methods::SESSIONS_LIST, Some(wire_params))
1920 .await?;
1921 Ok(serde_json::from_value(_value)?)
1922 }
1923
1924 /// Reads lightweight persisted metadata for one local session without opening it.
1925 ///
1926 /// Wire method: `sessions.getMetadata`.
1927 ///
1928 /// # Parameters
1929 ///
1930 /// * `params` - Session ID whose persisted metadata should be read.
1931 ///
1932 /// # Returns
1933 ///
1934 /// Persisted local session metadata when the session exists.
1935 ///
1936 /// <div class="warning">
1937 ///
1938 /// **Experimental.** This API is part of an experimental wire-protocol surface
1939 /// and may change or be removed in future SDK or CLI releases. Pin both the
1940 /// SDK and CLI versions if your code depends on it.
1941 ///
1942 /// </div>
1943 pub(crate) async fn get_metadata(
1944 &self,
1945 params: SessionsGetMetadataRequest,
1946 ) -> Result<SessionsGetMetadataResult, Error> {
1947 let wire_params = serde_json::to_value(params)?;
1948 let _value = self
1949 .client
1950 .call(rpc_methods::SESSIONS_GETMETADATA, Some(wire_params))
1951 .await?;
1952 Ok(serde_json::from_value(_value)?)
1953 }
1954
1955 /// Reads client-owned metadata for multiple persisted local sessions without opening them. Results preserve request order and report missing, corrupt, unsupported, or temporarily unavailable sessions independently.
1956 ///
1957 /// Wire method: `sessions.getClientMetadata`.
1958 ///
1959 /// # Parameters
1960 ///
1961 /// * `params` - Bounded batch request for client-owned metadata from persisted local sessions.
1962 ///
1963 /// # Returns
1964 ///
1965 /// Ordered client metadata outcomes for the requested local sessions.
1966 ///
1967 /// <div class="warning">
1968 ///
1969 /// **Experimental.** This API is part of an experimental wire-protocol surface
1970 /// and may change or be removed in future SDK or CLI releases. Pin both the
1971 /// SDK and CLI versions if your code depends on it.
1972 ///
1973 /// </div>
1974 pub async fn get_client_metadata(
1975 &self,
1976 params: SessionsGetClientMetadataRequest,
1977 ) -> Result<SessionsGetClientMetadataResult, Error> {
1978 let wire_params = serde_json::to_value(params)?;
1979 let _value = self
1980 .client
1981 .call(rpc_methods::SESSIONS_GETCLIENTMETADATA, Some(wire_params))
1982 .await?;
1983 Ok(serde_json::from_value(_value)?)
1984 }
1985
1986 /// Reads a page of durable events directly from a local session's persisted journal without creating, resuming, or activating the session. The first read pins the currently opened journal generation and its byte-length boundary; opaque cursor continuations remain on that generation across runtime-owned compaction, truncation, and rewrite operations, which replace the live path atomically, and events appended after the boundary are excluded. For cold hydration, await the first successful page before activation and establish lossless live-event buffering before resume; merge subsequent live events by ID, preserving persisted order and letting live payloads win. Continuations are process-local, single-use capabilities bound to the originating session and storage context and must be paged sequentially; concurrent or repeated use of the same cursor expires that duplicate read rather than reading the generation twice. A complete snapshot has cursorStatus 'ok' and hasMore false. Snapshots expire after five idle minutes, with at most eight retained per process and idle-only eviction under pressure; completion and cancelled-worker exit release their handles. No transcript copy is created, but retained handles may keep replaced files' disk blocks alive until release. Pages have a soft 1 MiB serialized event-array budget including resolved binary assets; one oversized event is returned alone to guarantee progress. Working memory also includes a record/lookahead and asset resolution; resolving the first binary reference may scan the full pinned generation to build a bounded offset index. If the snapshot expires, is evicted, is cancelled before a continuation is established, or becomes unreadable after an observable unsupported in-place shortening, the continuation returns cursorStatus 'expired' with an empty terminal page and never falls back to a different generation. A missing or initially unreadable journal is an RPC error. Persisted history excludes ephemeral events and may omit payloads that are reconstructed only for an active session; use the active session event stream for post-resume live events.
1987 ///
1988 /// Wire method: `sessions.readPersistedEvents`.
1989 ///
1990 /// # Parameters
1991 ///
1992 /// * `params` - Pagination options for reading an inactive or active local session's persisted event journal.
1993 ///
1994 /// # Returns
1995 ///
1996 /// Batch of session events returned by a read, with cursor and continuation metadata.
1997 ///
1998 /// <div class="warning">
1999 ///
2000 /// **Experimental.** This API is part of an experimental wire-protocol surface
2001 /// and may change or be removed in future SDK or CLI releases. Pin both the
2002 /// SDK and CLI versions if your code depends on it.
2003 ///
2004 /// </div>
2005 pub async fn read_persisted_events(
2006 &self,
2007 params: SessionsReadPersistedEventsRequest,
2008 ) -> Result<EventsReadResult, Error> {
2009 let wire_params = serde_json::to_value(params)?;
2010 let _value = self
2011 .client
2012 .call(rpc_methods::SESSIONS_READPERSISTEDEVENTS, Some(wire_params))
2013 .await?;
2014 Ok(serde_json::from_value(_value)?)
2015 }
2016
2017 /// Lists recent local session IDs that contain user-visible history, omitting housekeeping-only sessions.
2018 ///
2019 /// Wire method: `sessions.listNonEmptySessionIds`.
2020 ///
2021 /// # Parameters
2022 ///
2023 /// * `params` - Limit for non-empty local session IDs.
2024 ///
2025 /// # Returns
2026 ///
2027 /// Recent local session IDs that contain user-visible history.
2028 ///
2029 /// <div class="warning">
2030 ///
2031 /// **Experimental.** This API is part of an experimental wire-protocol surface
2032 /// and may change or be removed in future SDK or CLI releases. Pin both the
2033 /// SDK and CLI versions if your code depends on it.
2034 ///
2035 /// </div>
2036 pub(crate) async fn list_non_empty_session_ids(
2037 &self,
2038 params: SessionsListNonEmptySessionIdsRequest,
2039 ) -> Result<SessionsListNonEmptySessionIdsResult, Error> {
2040 let wire_params = serde_json::to_value(params)?;
2041 let _value = self
2042 .client
2043 .call(
2044 rpc_methods::SESSIONS_LISTNONEMPTYSESSIONIDS,
2045 Some(wire_params),
2046 )
2047 .await?;
2048 Ok(serde_json::from_value(_value)?)
2049 }
2050
2051 /// Finds the local session bound to a GitHub task ID, if any.
2052 ///
2053 /// Wire method: `sessions.findByTaskId`.
2054 ///
2055 /// # Parameters
2056 ///
2057 /// * `params` - GitHub task ID to look up.
2058 ///
2059 /// # Returns
2060 ///
2061 /// ID of the local session bound to the given GitHub task, or omitted when none.
2062 ///
2063 /// <div class="warning">
2064 ///
2065 /// **Experimental.** This API is part of an experimental wire-protocol surface
2066 /// and may change or be removed in future SDK or CLI releases. Pin both the
2067 /// SDK and CLI versions if your code depends on it.
2068 ///
2069 /// </div>
2070 pub async fn find_by_task_id(
2071 &self,
2072 params: SessionsFindByTaskIDRequest,
2073 ) -> Result<SessionsFindByTaskIDResult, Error> {
2074 let wire_params = serde_json::to_value(params)?;
2075 let _value = self
2076 .client
2077 .call(rpc_methods::SESSIONS_FINDBYTASKID, Some(wire_params))
2078 .await?;
2079 Ok(serde_json::from_value(_value)?)
2080 }
2081
2082 /// Resolves a UUID prefix to a unique session ID, if exactly one session matches.
2083 ///
2084 /// Wire method: `sessions.findByPrefix`.
2085 ///
2086 /// # Parameters
2087 ///
2088 /// * `params` - UUID prefix to resolve to a unique session ID.
2089 ///
2090 /// # Returns
2091 ///
2092 /// Session ID matching the prefix, omitted when no unique match exists.
2093 ///
2094 /// <div class="warning">
2095 ///
2096 /// **Experimental.** This API is part of an experimental wire-protocol surface
2097 /// and may change or be removed in future SDK or CLI releases. Pin both the
2098 /// SDK and CLI versions if your code depends on it.
2099 ///
2100 /// </div>
2101 pub async fn find_by_prefix(
2102 &self,
2103 params: SessionsFindByPrefixRequest,
2104 ) -> Result<SessionsFindByPrefixResult, Error> {
2105 let wire_params = serde_json::to_value(params)?;
2106 let _value = self
2107 .client
2108 .call(rpc_methods::SESSIONS_FINDBYPREFIX, Some(wire_params))
2109 .await?;
2110 Ok(serde_json::from_value(_value)?)
2111 }
2112
2113 /// Returns the most-relevant prior session for a given working-directory context.
2114 ///
2115 /// Wire method: `sessions.getLastForContext`.
2116 ///
2117 /// # Parameters
2118 ///
2119 /// * `params` - Optional working-directory context used to score session relevance.
2120 ///
2121 /// # Returns
2122 ///
2123 /// Most-relevant session ID for the supplied context, or omitted when no sessions exist.
2124 ///
2125 /// <div class="warning">
2126 ///
2127 /// **Experimental.** This API is part of an experimental wire-protocol surface
2128 /// and may change or be removed in future SDK or CLI releases. Pin both the
2129 /// SDK and CLI versions if your code depends on it.
2130 ///
2131 /// </div>
2132 pub async fn get_last_for_context(
2133 &self,
2134 params: SessionsGetLastForContextRequest,
2135 ) -> Result<SessionsGetLastForContextResult, Error> {
2136 let wire_params = serde_json::to_value(params)?;
2137 let _value = self
2138 .client
2139 .call(rpc_methods::SESSIONS_GETLASTFORCONTEXT, Some(wire_params))
2140 .await?;
2141 Ok(serde_json::from_value(_value)?)
2142 }
2143
2144 /// 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.
2145 ///
2146 /// Wire method: `sessions.getEventFilePath`.
2147 ///
2148 /// # Parameters
2149 ///
2150 /// * `params` - Session ID whose event-log file path to compute.
2151 ///
2152 /// # Returns
2153 ///
2154 /// Absolute path to the session's events.jsonl file on disk.
2155 ///
2156 /// <div class="warning">
2157 ///
2158 /// **Experimental.** This API is part of an experimental wire-protocol surface
2159 /// and may change or be removed in future SDK or CLI releases. Pin both the
2160 /// SDK and CLI versions if your code depends on it.
2161 ///
2162 /// </div>
2163 pub(crate) async fn get_event_file_path(
2164 &self,
2165 params: SessionsGetEventFilePathRequest,
2166 ) -> Result<SessionsGetEventFilePathResult, Error> {
2167 let wire_params = serde_json::to_value(params)?;
2168 let _value = self
2169 .client
2170 .call(rpc_methods::SESSIONS_GETEVENTFILEPATH, Some(wire_params))
2171 .await?;
2172 Ok(serde_json::from_value(_value)?)
2173 }
2174
2175 /// Returns the on-disk byte size of each session's workspace directory.
2176 ///
2177 /// Wire method: `sessions.getSizes`.
2178 ///
2179 /// # Returns
2180 ///
2181 /// Map of sessionId -> on-disk size in bytes for each session's workspace directory.
2182 ///
2183 /// <div class="warning">
2184 ///
2185 /// **Experimental.** This API is part of an experimental wire-protocol surface
2186 /// and may change or be removed in future SDK or CLI releases. Pin both the
2187 /// SDK and CLI versions if your code depends on it.
2188 ///
2189 /// </div>
2190 pub async fn get_sizes(&self) -> Result<SessionSizes, Error> {
2191 let wire_params = serde_json::json!({});
2192 let _value = self
2193 .client
2194 .call(rpc_methods::SESSIONS_GETSIZES, Some(wire_params))
2195 .await?;
2196 Ok(serde_json::from_value(_value)?)
2197 }
2198
2199 /// Returns the subset of the supplied session IDs that are currently held by another running process.
2200 ///
2201 /// Wire method: `sessions.checkInUse`.
2202 ///
2203 /// # Parameters
2204 ///
2205 /// * `params` - Session IDs to test for live in-use locks.
2206 ///
2207 /// # Returns
2208 ///
2209 /// Session IDs from the input set that are currently in use by another process.
2210 ///
2211 /// <div class="warning">
2212 ///
2213 /// **Experimental.** This API is part of an experimental wire-protocol surface
2214 /// and may change or be removed in future SDK or CLI releases. Pin both the
2215 /// SDK and CLI versions if your code depends on it.
2216 ///
2217 /// </div>
2218 pub async fn check_in_use(
2219 &self,
2220 params: SessionsCheckInUseRequest,
2221 ) -> Result<SessionsCheckInUseResult, Error> {
2222 let wire_params = serde_json::to_value(params)?;
2223 let _value = self
2224 .client
2225 .call(rpc_methods::SESSIONS_CHECKINUSE, Some(wire_params))
2226 .await?;
2227 Ok(serde_json::from_value(_value)?)
2228 }
2229
2230 /// 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.
2231 ///
2232 /// Wire method: `sessions.getPersistedRemoteSteerable`.
2233 ///
2234 /// # Parameters
2235 ///
2236 /// * `params` - Session ID to look up the persisted remote-steerable flag for.
2237 ///
2238 /// # Returns
2239 ///
2240 /// The session's persisted remote-steerable flag, or omitted when no value has been persisted.
2241 ///
2242 /// <div class="warning">
2243 ///
2244 /// **Experimental.** This API is part of an experimental wire-protocol surface
2245 /// and may change or be removed in future SDK or CLI releases. Pin both the
2246 /// SDK and CLI versions if your code depends on it.
2247 ///
2248 /// </div>
2249 pub(crate) async fn get_persisted_remote_steerable(
2250 &self,
2251 params: SessionsGetPersistedRemoteSteerableRequest,
2252 ) -> Result<SessionsGetPersistedRemoteSteerableResult, Error> {
2253 let wire_params = serde_json::to_value(params)?;
2254 let _value = self
2255 .client
2256 .call(
2257 rpc_methods::SESSIONS_GETPERSISTEDREMOTESTEERABLE,
2258 Some(wire_params),
2259 )
2260 .await?;
2261 Ok(serde_json::from_value(_value)?)
2262 }
2263
2264 /// Closes a session: emits shutdown, flushes pending events, releases the in-use lock, and disposes the active session.
2265 ///
2266 /// Wire method: `sessions.close`.
2267 ///
2268 /// # Parameters
2269 ///
2270 /// * `params` - Session ID to close.
2271 ///
2272 /// # Returns
2273 ///
2274 /// 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.
2275 ///
2276 /// <div class="warning">
2277 ///
2278 /// **Experimental.** This API is part of an experimental wire-protocol surface
2279 /// and may change or be removed in future SDK or CLI releases. Pin both the
2280 /// SDK and CLI versions if your code depends on it.
2281 ///
2282 /// </div>
2283 pub async fn close(&self, params: SessionsCloseRequest) -> Result<SessionsCloseResult, Error> {
2284 let wire_params = serde_json::to_value(params)?;
2285 let _value = self
2286 .client
2287 .call(rpc_methods::SESSIONS_CLOSE, Some(wire_params))
2288 .await?;
2289 Ok(serde_json::from_value(_value)?)
2290 }
2291
2292 /// Closes, deactivates, and deletes a set of sessions, returning the bytes freed per session.
2293 ///
2294 /// Wire method: `sessions.bulkDelete`.
2295 ///
2296 /// # Parameters
2297 ///
2298 /// * `params` - Session IDs to close, deactivate, and delete from disk.
2299 ///
2300 /// # Returns
2301 ///
2302 /// Map of sessionId -> bytes freed by removing the session's workspace directory.
2303 ///
2304 /// <div class="warning">
2305 ///
2306 /// **Experimental.** This API is part of an experimental wire-protocol surface
2307 /// and may change or be removed in future SDK or CLI releases. Pin both the
2308 /// SDK and CLI versions if your code depends on it.
2309 ///
2310 /// </div>
2311 pub async fn bulk_delete(
2312 &self,
2313 params: SessionsBulkDeleteRequest,
2314 ) -> Result<SessionBulkDeleteResult, Error> {
2315 let wire_params = serde_json::to_value(params)?;
2316 let _value = self
2317 .client
2318 .call(rpc_methods::SESSIONS_BULKDELETE, Some(wire_params))
2319 .await?;
2320 Ok(serde_json::from_value(_value)?)
2321 }
2322
2323 /// Deletes one local session from disk after running the same lifecycle hooks as the session manager.
2324 ///
2325 /// Wire method: `sessions.delete`.
2326 ///
2327 /// # Parameters
2328 ///
2329 /// * `params` - Session ID to delete from disk.
2330 ///
2331 /// <div class="warning">
2332 ///
2333 /// **Experimental.** This API is part of an experimental wire-protocol surface
2334 /// and may change or be removed in future SDK or CLI releases. Pin both the
2335 /// SDK and CLI versions if your code depends on it.
2336 ///
2337 /// </div>
2338 pub(crate) async fn delete(&self, params: SessionsDeleteRequest) -> Result<(), Error> {
2339 let wire_params = serde_json::to_value(params)?;
2340 let _value = self
2341 .client
2342 .call(rpc_methods::SESSIONS_DELETE, Some(wire_params))
2343 .await?;
2344 Ok(())
2345 }
2346
2347 /// Deletes sessions older than the given threshold, with optional dry-run and exclusion list.
2348 ///
2349 /// Wire method: `sessions.pruneOld`.
2350 ///
2351 /// # Parameters
2352 ///
2353 /// * `params` - Age threshold and optional flags controlling which old sessions are pruned (or simulated when dryRun is true).
2354 ///
2355 /// # Returns
2356 ///
2357 /// Outcome of the prune operation: deleted IDs, dry-run candidates, skipped IDs, total bytes freed, and the dry-run flag.
2358 ///
2359 /// <div class="warning">
2360 ///
2361 /// **Experimental.** This API is part of an experimental wire-protocol surface
2362 /// and may change or be removed in future SDK or CLI releases. Pin both the
2363 /// SDK and CLI versions if your code depends on it.
2364 ///
2365 /// </div>
2366 pub async fn prune_old(
2367 &self,
2368 params: SessionsPruneOldRequest,
2369 ) -> Result<SessionPruneResult, Error> {
2370 let wire_params = serde_json::to_value(params)?;
2371 let _value = self
2372 .client
2373 .call(rpc_methods::SESSIONS_PRUNEOLD, Some(wire_params))
2374 .await?;
2375 Ok(serde_json::from_value(_value)?)
2376 }
2377
2378 /// Flushes a session's pending events to disk.
2379 ///
2380 /// Wire method: `sessions.save`.
2381 ///
2382 /// # Parameters
2383 ///
2384 /// * `params` - Session ID whose pending events should be flushed to disk.
2385 ///
2386 /// # Returns
2387 ///
2388 /// Flush a session's pending events to disk. No-op when no writer exists for the session (e.g., already closed).
2389 ///
2390 /// <div class="warning">
2391 ///
2392 /// **Experimental.** This API is part of an experimental wire-protocol surface
2393 /// and may change or be removed in future SDK or CLI releases. Pin both the
2394 /// SDK and CLI versions if your code depends on it.
2395 ///
2396 /// </div>
2397 pub async fn save(&self, params: SessionsSaveRequest) -> Result<SessionsSaveResult, Error> {
2398 let wire_params = serde_json::to_value(params)?;
2399 let _value = self
2400 .client
2401 .call(rpc_methods::SESSIONS_SAVE, Some(wire_params))
2402 .await?;
2403 Ok(serde_json::from_value(_value)?)
2404 }
2405
2406 /// Releases the in-use lock held by this process for a session.
2407 ///
2408 /// Wire method: `sessions.releaseLock`.
2409 ///
2410 /// # Parameters
2411 ///
2412 /// * `params` - Session ID whose in-use lock should be released.
2413 ///
2414 /// # Returns
2415 ///
2416 /// 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.
2417 ///
2418 /// <div class="warning">
2419 ///
2420 /// **Experimental.** This API is part of an experimental wire-protocol surface
2421 /// and may change or be removed in future SDK or CLI releases. Pin both the
2422 /// SDK and CLI versions if your code depends on it.
2423 ///
2424 /// </div>
2425 pub async fn release_lock(
2426 &self,
2427 params: SessionsReleaseLockRequest,
2428 ) -> Result<SessionsReleaseLockResult, Error> {
2429 let wire_params = serde_json::to_value(params)?;
2430 let _value = self
2431 .client
2432 .call(rpc_methods::SESSIONS_RELEASELOCK, Some(wire_params))
2433 .await?;
2434 Ok(serde_json::from_value(_value)?)
2435 }
2436
2437 /// Backfills missing summary and context fields on the supplied session metadata records.
2438 ///
2439 /// Wire method: `sessions.enrichMetadata`.
2440 ///
2441 /// # Parameters
2442 ///
2443 /// * `params` - Session metadata records to enrich with summary and context information.
2444 ///
2445 /// # Returns
2446 ///
2447 /// The enriched metadata records, with summary and context fields backfilled where available. Sessions confirmed empty and unnamed are omitted.
2448 ///
2449 /// <div class="warning">
2450 ///
2451 /// **Experimental.** This API is part of an experimental wire-protocol surface
2452 /// and may change or be removed in future SDK or CLI releases. Pin both the
2453 /// SDK and CLI versions if your code depends on it.
2454 ///
2455 /// </div>
2456 pub async fn enrich_metadata(
2457 &self,
2458 params: SessionsEnrichMetadataRequest,
2459 ) -> Result<SessionEnrichMetadataResult, Error> {
2460 let wire_params = serde_json::to_value(params)?;
2461 let _value = self
2462 .client
2463 .call(rpc_methods::SESSIONS_ENRICHMETADATA, Some(wire_params))
2464 .await?;
2465 Ok(serde_json::from_value(_value)?)
2466 }
2467
2468 /// Reloads user, plugin, and (optionally) repo hooks on the active session.
2469 ///
2470 /// Wire method: `sessions.reloadPluginHooks`.
2471 ///
2472 /// # Parameters
2473 ///
2474 /// * `params` - Active session ID and an optional flag for deferring repo-level hooks until folder trust.
2475 ///
2476 /// # Returns
2477 ///
2478 /// 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.
2479 ///
2480 /// <div class="warning">
2481 ///
2482 /// **Experimental.** This API is part of an experimental wire-protocol surface
2483 /// and may change or be removed in future SDK or CLI releases. Pin both the
2484 /// SDK and CLI versions if your code depends on it.
2485 ///
2486 /// </div>
2487 pub async fn reload_plugin_hooks(
2488 &self,
2489 params: SessionsReloadPluginHooksRequest,
2490 ) -> Result<SessionsReloadPluginHooksResult, Error> {
2491 let wire_params = serde_json::to_value(params)?;
2492 let _value = self
2493 .client
2494 .call(rpc_methods::SESSIONS_RELOADPLUGINHOOKS, Some(wire_params))
2495 .await?;
2496 Ok(serde_json::from_value(_value)?)
2497 }
2498
2499 /// Loads previously-deferred repo-level hooks on the active session, returning queued startup prompts.
2500 ///
2501 /// Wire method: `sessions.loadDeferredRepoHooks`.
2502 ///
2503 /// # Parameters
2504 ///
2505 /// * `params` - Active session ID whose deferred repo-level hooks should be loaded.
2506 ///
2507 /// # Returns
2508 ///
2509 /// Queued repo-level startup prompts and the total hook command count after loading.
2510 ///
2511 /// <div class="warning">
2512 ///
2513 /// **Experimental.** This API is part of an experimental wire-protocol surface
2514 /// and may change or be removed in future SDK or CLI releases. Pin both the
2515 /// SDK and CLI versions if your code depends on it.
2516 ///
2517 /// </div>
2518 pub async fn load_deferred_repo_hooks(
2519 &self,
2520 params: SessionsLoadDeferredRepoHooksRequest,
2521 ) -> Result<SessionLoadDeferredRepoHooksResult, Error> {
2522 let wire_params = serde_json::to_value(params)?;
2523 let _value = self
2524 .client
2525 .call(
2526 rpc_methods::SESSIONS_LOADDEFERREDREPOHOOKS,
2527 Some(wire_params),
2528 )
2529 .await?;
2530 Ok(serde_json::from_value(_value)?)
2531 }
2532
2533 /// Replaces the manager-wide additional plugins registered with the session manager.
2534 ///
2535 /// Wire method: `sessions.setAdditionalPlugins`.
2536 ///
2537 /// # Parameters
2538 ///
2539 /// * `params` - Manager-wide additional plugins to register; replaces any previously-configured set.
2540 ///
2541 /// # Returns
2542 ///
2543 /// 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.
2544 ///
2545 /// <div class="warning">
2546 ///
2547 /// **Experimental.** This API is part of an experimental wire-protocol surface
2548 /// and may change or be removed in future SDK or CLI releases. Pin both the
2549 /// SDK and CLI versions if your code depends on it.
2550 ///
2551 /// </div>
2552 pub async fn set_additional_plugins(
2553 &self,
2554 params: SessionsSetAdditionalPluginsRequest,
2555 ) -> Result<SessionsSetAdditionalPluginsResult, Error> {
2556 let wire_params = serde_json::to_value(params)?;
2557 let _value = self
2558 .client
2559 .call(
2560 rpc_methods::SESSIONS_SETADDITIONALPLUGINS,
2561 Some(wire_params),
2562 )
2563 .await?;
2564 Ok(serde_json::from_value(_value)?)
2565 }
2566
2567 /// 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.
2568 ///
2569 /// Wire method: `sessions.getBoardEntryCount`.
2570 ///
2571 /// # Parameters
2572 ///
2573 /// * `params` - Session ID whose board entry count should be returned.
2574 ///
2575 /// # Returns
2576 ///
2577 /// Dynamic-context board entry count, when available.
2578 ///
2579 /// <div class="warning">
2580 ///
2581 /// **Experimental.** This API is part of an experimental wire-protocol surface
2582 /// and may change or be removed in future SDK or CLI releases. Pin both the
2583 /// SDK and CLI versions if your code depends on it.
2584 ///
2585 /// </div>
2586 pub(crate) async fn get_board_entry_count(
2587 &self,
2588 params: SessionsGetBoardEntryCountRequest,
2589 ) -> Result<SessionsGetBoardEntryCountResult, Error> {
2590 let wire_params = serde_json::to_value(params)?;
2591 let _value = self
2592 .client
2593 .call(rpc_methods::SESSIONS_GETBOARDENTRYCOUNT, Some(wire_params))
2594 .await?;
2595 Ok(serde_json::from_value(_value)?)
2596 }
2597
2598 /// 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.
2599 ///
2600 /// Wire method: `sessions.startRemoteControl`.
2601 ///
2602 /// # Parameters
2603 ///
2604 /// * `params` - Parameters for attaching the remote-control singleton to a session.
2605 ///
2606 /// # Returns
2607 ///
2608 /// Wrapper for the singleton's current status.
2609 ///
2610 /// <div class="warning">
2611 ///
2612 /// **Experimental.** This API is part of an experimental wire-protocol surface
2613 /// and may change or be removed in future SDK or CLI releases. Pin both the
2614 /// SDK and CLI versions if your code depends on it.
2615 ///
2616 /// </div>
2617 pub async fn start_remote_control(
2618 &self,
2619 params: SessionsStartRemoteControlRequest,
2620 ) -> Result<RemoteControlStatusResult, Error> {
2621 let wire_params = serde_json::to_value(params)?;
2622 let _value = self
2623 .client
2624 .call(rpc_methods::SESSIONS_STARTREMOTECONTROL, Some(wire_params))
2625 .await?;
2626 Ok(serde_json::from_value(_value)?)
2627 }
2628
2629 /// 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.
2630 ///
2631 /// Wire method: `sessions.transferRemoteControl`.
2632 ///
2633 /// # Parameters
2634 ///
2635 /// * `params` - Parameters for atomically rebinding the remote-control singleton.
2636 ///
2637 /// # Returns
2638 ///
2639 /// Outcome of a transferRemoteControl call.
2640 ///
2641 /// <div class="warning">
2642 ///
2643 /// **Experimental.** This API is part of an experimental wire-protocol surface
2644 /// and may change or be removed in future SDK or CLI releases. Pin both the
2645 /// SDK and CLI versions if your code depends on it.
2646 ///
2647 /// </div>
2648 pub async fn transfer_remote_control(
2649 &self,
2650 params: SessionsTransferRemoteControlRequest,
2651 ) -> Result<RemoteControlTransferResult, Error> {
2652 let wire_params = serde_json::to_value(params)?;
2653 let _value = self
2654 .client
2655 .call(
2656 rpc_methods::SESSIONS_TRANSFERREMOTECONTROL,
2657 Some(wire_params),
2658 )
2659 .await?;
2660 Ok(serde_json::from_value(_value)?)
2661 }
2662
2663 /// 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.
2664 ///
2665 /// Wire method: `sessions.setRemoteControlSteering`.
2666 ///
2667 /// # Parameters
2668 ///
2669 /// * `params` - Patch for the singleton's steering state.
2670 ///
2671 /// # Returns
2672 ///
2673 /// Wrapper for the singleton's current status.
2674 ///
2675 /// <div class="warning">
2676 ///
2677 /// **Experimental.** This API is part of an experimental wire-protocol surface
2678 /// and may change or be removed in future SDK or CLI releases. Pin both the
2679 /// SDK and CLI versions if your code depends on it.
2680 ///
2681 /// </div>
2682 pub async fn set_remote_control_steering(
2683 &self,
2684 params: SessionsSetRemoteControlSteeringRequest,
2685 ) -> Result<RemoteControlStatusResult, Error> {
2686 let wire_params = serde_json::to_value(params)?;
2687 let _value = self
2688 .client
2689 .call(
2690 rpc_methods::SESSIONS_SETREMOTECONTROLSTEERING,
2691 Some(wire_params),
2692 )
2693 .await?;
2694 Ok(serde_json::from_value(_value)?)
2695 }
2696
2697 /// 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).
2698 ///
2699 /// Wire method: `sessions.stopRemoteControl`.
2700 ///
2701 /// # Returns
2702 ///
2703 /// Outcome of a stopRemoteControl call.
2704 ///
2705 /// <div class="warning">
2706 ///
2707 /// **Experimental.** This API is part of an experimental wire-protocol surface
2708 /// and may change or be removed in future SDK or CLI releases. Pin both the
2709 /// SDK and CLI versions if your code depends on it.
2710 ///
2711 /// </div>
2712 pub async fn stop_remote_control(&self) -> Result<RemoteControlStopResult, Error> {
2713 let wire_params = serde_json::json!({});
2714 let _value = self
2715 .client
2716 .call(rpc_methods::SESSIONS_STOPREMOTECONTROL, Some(wire_params))
2717 .await?;
2718 Ok(serde_json::from_value(_value)?)
2719 }
2720
2721 /// 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).
2722 ///
2723 /// Wire method: `sessions.stopRemoteControl`.
2724 ///
2725 /// # Parameters
2726 ///
2727 /// * `params` - Parameters for stopping the remote-control singleton.
2728 ///
2729 /// # Returns
2730 ///
2731 /// Outcome of a stopRemoteControl call.
2732 ///
2733 /// <div class="warning">
2734 ///
2735 /// **Experimental.** This API is part of an experimental wire-protocol surface
2736 /// and may change or be removed in future SDK or CLI releases. Pin both the
2737 /// SDK and CLI versions if your code depends on it.
2738 ///
2739 /// </div>
2740 pub async fn stop_remote_control_with_params(
2741 &self,
2742 params: SessionsStopRemoteControlRequest,
2743 ) -> Result<RemoteControlStopResult, Error> {
2744 let wire_params = serde_json::to_value(params)?;
2745 let _value = self
2746 .client
2747 .call(rpc_methods::SESSIONS_STOPREMOTECONTROL, Some(wire_params))
2748 .await?;
2749 Ok(serde_json::from_value(_value)?)
2750 }
2751
2752 /// Returns the current state of the remote-control singleton, including the attached session id and frontend URL when active.
2753 ///
2754 /// Wire method: `sessions.getRemoteControlStatus`.
2755 ///
2756 /// # Returns
2757 ///
2758 /// Wrapper for the singleton's current status.
2759 ///
2760 /// <div class="warning">
2761 ///
2762 /// **Experimental.** This API is part of an experimental wire-protocol surface
2763 /// and may change or be removed in future SDK or CLI releases. Pin both the
2764 /// SDK and CLI versions if your code depends on it.
2765 ///
2766 /// </div>
2767 pub async fn get_remote_control_status(&self) -> Result<RemoteControlStatusResult, Error> {
2768 let wire_params = serde_json::json!({});
2769 let _value = self
2770 .client
2771 .call(
2772 rpc_methods::SESSIONS_GETREMOTECONTROLSTATUS,
2773 Some(wire_params),
2774 )
2775 .await?;
2776 Ok(serde_json::from_value(_value)?)
2777 }
2778
2779 /// Attaches (or detaches) an in-process ExtensionController delegate for the given session in a local host adapter. Pass `controller: undefined` to detach. Internal because the controller cannot cross the JSON-RPC boundary; the runtime manages its own session extension service.
2780 ///
2781 /// Wire method: `sessions.configureSessionExtensions`.
2782 ///
2783 /// # Parameters
2784 ///
2785 /// * `params` - Params to attach or detach an in-process ExtensionController delegate.
2786 ///
2787 /// <div class="warning">
2788 ///
2789 /// **Experimental.** This API is part of an experimental wire-protocol surface
2790 /// and may change or be removed in future SDK or CLI releases. Pin both the
2791 /// SDK and CLI versions if your code depends on it.
2792 ///
2793 /// </div>
2794 pub(crate) async fn configure_session_extensions(
2795 &self,
2796 params: ConfigureSessionExtensionsParams,
2797 ) -> Result<(), Error> {
2798 let wire_params = serde_json::to_value(params)?;
2799 let _value = self
2800 .client
2801 .call(
2802 rpc_methods::SESSIONS_CONFIGURESESSIONEXTENSIONS,
2803 Some(wire_params),
2804 )
2805 .await?;
2806 Ok(())
2807 }
2808}
2809
2810/// `skills.*` RPCs.
2811#[derive(Clone, Copy)]
2812pub struct ClientRpcSkills<'a> {
2813 pub(crate) client: &'a Client,
2814}
2815
2816impl<'a> ClientRpcSkills<'a> {
2817 /// `skills.config.*` sub-namespace.
2818 pub fn config(&self) -> ClientRpcSkillsConfig<'a> {
2819 ClientRpcSkillsConfig {
2820 client: self.client,
2821 }
2822 }
2823
2824 /// Discovers skills across global and project sources.
2825 ///
2826 /// Wire method: `skills.discover`.
2827 ///
2828 /// # Parameters
2829 ///
2830 /// * `params` - Optional project paths and additional skill directories to include in discovery.
2831 ///
2832 /// # Returns
2833 ///
2834 /// Skills discovered across global and project sources.
2835 ///
2836 /// <div class="warning">
2837 ///
2838 /// **Experimental.** This API is part of an experimental wire-protocol surface
2839 /// and may change or be removed in future SDK or CLI releases. Pin both the
2840 /// SDK and CLI versions if your code depends on it.
2841 ///
2842 /// </div>
2843 pub async fn discover(&self, params: SkillsDiscoverRequest) -> Result<ServerSkillList, Error> {
2844 let wire_params = serde_json::to_value(params)?;
2845 let _value = self
2846 .client
2847 .call(rpc_methods::SKILLS_DISCOVER, Some(wire_params))
2848 .await?;
2849 Ok(serde_json::from_value(_value)?)
2850 }
2851
2852 /// 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.
2853 ///
2854 /// Wire method: `skills.getDiscoveryPaths`.
2855 ///
2856 /// # Parameters
2857 ///
2858 /// * `params` - Optional project paths to enumerate.
2859 ///
2860 /// # Returns
2861 ///
2862 /// Canonical locations where skills can be created so the runtime will recognize them.
2863 ///
2864 /// <div class="warning">
2865 ///
2866 /// **Experimental.** This API is part of an experimental wire-protocol surface
2867 /// and may change or be removed in future SDK or CLI releases. Pin both the
2868 /// SDK and CLI versions if your code depends on it.
2869 ///
2870 /// </div>
2871 pub async fn get_discovery_paths(
2872 &self,
2873 params: SkillsGetDiscoveryPathsRequest,
2874 ) -> Result<SkillDiscoveryPathList, Error> {
2875 let wire_params = serde_json::to_value(params)?;
2876 let _value = self
2877 .client
2878 .call(rpc_methods::SKILLS_GETDISCOVERYPATHS, Some(wire_params))
2879 .await?;
2880 Ok(serde_json::from_value(_value)?)
2881 }
2882}
2883
2884/// `skills.config.*` RPCs.
2885#[derive(Clone, Copy)]
2886pub struct ClientRpcSkillsConfig<'a> {
2887 pub(crate) client: &'a Client,
2888}
2889
2890impl<'a> ClientRpcSkillsConfig<'a> {
2891 /// Replaces the global list of disabled skills.
2892 ///
2893 /// Wire method: `skills.config.setDisabledSkills`.
2894 ///
2895 /// # Parameters
2896 ///
2897 /// * `params` - Skill names to mark as disabled in global configuration, replacing any previous list.
2898 ///
2899 /// <div class="warning">
2900 ///
2901 /// **Experimental.** This API is part of an experimental wire-protocol surface
2902 /// and may change or be removed in future SDK or CLI releases. Pin both the
2903 /// SDK and CLI versions if your code depends on it.
2904 ///
2905 /// </div>
2906 pub async fn set_disabled_skills(
2907 &self,
2908 params: SkillsConfigSetDisabledSkillsRequest,
2909 ) -> Result<(), Error> {
2910 let wire_params = serde_json::to_value(params)?;
2911 let _value = self
2912 .client
2913 .call(
2914 rpc_methods::SKILLS_CONFIG_SETDISABLEDSKILLS,
2915 Some(wire_params),
2916 )
2917 .await?;
2918 Ok(())
2919 }
2920
2921 /// Atomically adds or removes one skill from the disabled list.
2922 ///
2923 /// Wire method: `skills.config.setSkillDisabled`.
2924 ///
2925 /// # Parameters
2926 ///
2927 /// * `params` - Adds or removes a single skill from the global disabled list, leaving every other entry untouched.
2928 ///
2929 /// <div class="warning">
2930 ///
2931 /// **Experimental.** This API is part of an experimental wire-protocol surface
2932 /// and may change or be removed in future SDK or CLI releases. Pin both the
2933 /// SDK and CLI versions if your code depends on it.
2934 ///
2935 /// </div>
2936 pub async fn set_skill_disabled(
2937 &self,
2938 params: SkillsConfigSetSkillDisabledRequest,
2939 ) -> Result<(), Error> {
2940 let wire_params = serde_json::to_value(params)?;
2941 let _value = self
2942 .client
2943 .call(
2944 rpc_methods::SKILLS_CONFIG_SETSKILLDISABLED,
2945 Some(wire_params),
2946 )
2947 .await?;
2948 Ok(())
2949 }
2950}
2951
2952/// `tools.*` RPCs.
2953#[derive(Clone, Copy)]
2954pub struct ClientRpcTools<'a> {
2955 pub(crate) client: &'a Client,
2956}
2957
2958impl<'a> ClientRpcTools<'a> {
2959 /// Lists built-in tools available for a model.
2960 ///
2961 /// Wire method: `tools.list`.
2962 ///
2963 /// # Parameters
2964 ///
2965 /// * `params` - Optional model identifier whose tool overrides should be applied to the listing.
2966 ///
2967 /// # Returns
2968 ///
2969 /// Built-in tools available for the requested model, with their parameters and instructions.
2970 ///
2971 /// <div class="warning">
2972 ///
2973 /// **Experimental.** This API is part of an experimental wire-protocol surface
2974 /// and may change or be removed in future SDK or CLI releases. Pin both the
2975 /// SDK and CLI versions if your code depends on it.
2976 ///
2977 /// </div>
2978 pub async fn list(&self, params: ToolsListRequest) -> Result<ToolList, Error> {
2979 let wire_params = serde_json::to_value(params)?;
2980 let _value = self
2981 .client
2982 .call(rpc_methods::TOOLS_LIST, Some(wire_params))
2983 .await?;
2984 Ok(serde_json::from_value(_value)?)
2985 }
2986}
2987
2988/// `user.*` RPCs.
2989#[derive(Clone, Copy)]
2990pub struct ClientRpcUser<'a> {
2991 pub(crate) client: &'a Client,
2992}
2993
2994impl<'a> ClientRpcUser<'a> {
2995 /// `user.settings.*` sub-namespace.
2996 pub fn settings(&self) -> ClientRpcUserSettings<'a> {
2997 ClientRpcUserSettings {
2998 client: self.client,
2999 }
3000 }
3001}
3002
3003/// `user.settings.*` RPCs.
3004#[derive(Clone, Copy)]
3005pub struct ClientRpcUserSettings<'a> {
3006 pub(crate) client: &'a Client,
3007}
3008
3009impl<'a> ClientRpcUserSettings<'a> {
3010 /// Drops this runtime process's in-memory user settings cache so the next settings read observes disk.
3011 ///
3012 /// Wire method: `user.settings.reload`.
3013 ///
3014 /// <div class="warning">
3015 ///
3016 /// **Experimental.** This API is part of an experimental wire-protocol surface
3017 /// and may change or be removed in future SDK or CLI releases. Pin both the
3018 /// SDK and CLI versions if your code depends on it.
3019 ///
3020 /// </div>
3021 pub async fn reload(&self) -> Result<(), Error> {
3022 let wire_params = serde_json::json!({});
3023 let _value = self
3024 .client
3025 .call(rpc_methods::USER_SETTINGS_RELOAD, Some(wire_params))
3026 .await?;
3027 Ok(())
3028 }
3029
3030 /// 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.
3031 ///
3032 /// Wire method: `user.settings.get`.
3033 ///
3034 /// # Returns
3035 ///
3036 /// 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.
3037 ///
3038 /// <div class="warning">
3039 ///
3040 /// **Experimental.** This API is part of an experimental wire-protocol surface
3041 /// and may change or be removed in future SDK or CLI releases. Pin both the
3042 /// SDK and CLI versions if your code depends on it.
3043 ///
3044 /// </div>
3045 pub async fn get(&self) -> Result<UserSettingsGetResult, Error> {
3046 let wire_params = serde_json::json!({});
3047 let _value = self
3048 .client
3049 .call(rpc_methods::USER_SETTINGS_GET, Some(wire_params))
3050 .await?;
3051 Ok(serde_json::from_value(_value)?)
3052 }
3053
3054 /// 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.
3055 ///
3056 /// Wire method: `user.settings.set`.
3057 ///
3058 /// # Parameters
3059 ///
3060 /// * `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.
3061 ///
3062 /// # Returns
3063 ///
3064 /// Outcome of writing user settings.
3065 ///
3066 /// <div class="warning">
3067 ///
3068 /// **Experimental.** This API is part of an experimental wire-protocol surface
3069 /// and may change or be removed in future SDK or CLI releases. Pin both the
3070 /// SDK and CLI versions if your code depends on it.
3071 ///
3072 /// </div>
3073 pub async fn set(
3074 &self,
3075 params: UserSettingsSetRequest,
3076 ) -> Result<UserSettingsSetResult, Error> {
3077 let wire_params = serde_json::to_value(params)?;
3078 let _value = self
3079 .client
3080 .call(rpc_methods::USER_SETTINGS_SET, Some(wire_params))
3081 .await?;
3082 Ok(serde_json::from_value(_value)?)
3083 }
3084}
3085
3086/// Typed view over a [`Session`]'s RPC namespace.
3087#[derive(Clone, Copy)]
3088pub struct SessionRpc<'a> {
3089 pub(crate) session: &'a Session,
3090}
3091
3092impl<'a> SessionRpc<'a> {
3093 /// `session.agent.*` sub-namespace.
3094 pub fn agent(&self) -> SessionRpcAgent<'a> {
3095 SessionRpcAgent {
3096 session: self.session,
3097 }
3098 }
3099
3100 /// `session.autopilotObjective.*` sub-namespace.
3101 pub fn autopilot_objective(&self) -> SessionRpcAutopilotObjective<'a> {
3102 SessionRpcAutopilotObjective {
3103 session: self.session,
3104 }
3105 }
3106
3107 /// `session.canvas.*` sub-namespace.
3108 pub fn canvas(&self) -> SessionRpcCanvas<'a> {
3109 SessionRpcCanvas {
3110 session: self.session,
3111 }
3112 }
3113
3114 /// `session.commands.*` sub-namespace.
3115 pub fn commands(&self) -> SessionRpcCommands<'a> {
3116 SessionRpcCommands {
3117 session: self.session,
3118 }
3119 }
3120
3121 /// `session.completions.*` sub-namespace.
3122 pub fn completions(&self) -> SessionRpcCompletions<'a> {
3123 SessionRpcCompletions {
3124 session: self.session,
3125 }
3126 }
3127
3128 /// `session.contentExclusion.*` sub-namespace.
3129 pub fn content_exclusion(&self) -> SessionRpcContentExclusion<'a> {
3130 SessionRpcContentExclusion {
3131 session: self.session,
3132 }
3133 }
3134
3135 /// `session.debug.*` sub-namespace.
3136 pub fn debug(&self) -> SessionRpcDebug<'a> {
3137 SessionRpcDebug {
3138 session: self.session,
3139 }
3140 }
3141
3142 /// `session.eventLog.*` sub-namespace.
3143 pub fn event_log(&self) -> SessionRpcEventLog<'a> {
3144 SessionRpcEventLog {
3145 session: self.session,
3146 }
3147 }
3148
3149 /// `session.extensions.*` sub-namespace.
3150 pub fn extensions(&self) -> SessionRpcExtensions<'a> {
3151 SessionRpcExtensions {
3152 session: self.session,
3153 }
3154 }
3155
3156 /// `session.factory.*` sub-namespace.
3157 pub fn factory(&self) -> SessionRpcFactory<'a> {
3158 SessionRpcFactory {
3159 session: self.session,
3160 }
3161 }
3162
3163 /// `session.fleet.*` sub-namespace.
3164 pub fn fleet(&self) -> SessionRpcFleet<'a> {
3165 SessionRpcFleet {
3166 session: self.session,
3167 }
3168 }
3169
3170 /// `session.gitHubAuth.*` sub-namespace.
3171 pub fn git_hub_auth(&self) -> SessionRpcGitHubAuth<'a> {
3172 SessionRpcGitHubAuth {
3173 session: self.session,
3174 }
3175 }
3176
3177 /// `session.history.*` sub-namespace.
3178 pub fn history(&self) -> SessionRpcHistory<'a> {
3179 SessionRpcHistory {
3180 session: self.session,
3181 }
3182 }
3183
3184 /// `session.instructions.*` sub-namespace.
3185 pub fn instructions(&self) -> SessionRpcInstructions<'a> {
3186 SessionRpcInstructions {
3187 session: self.session,
3188 }
3189 }
3190
3191 /// `session.limitPrediction.*` sub-namespace.
3192 pub fn limit_prediction(&self) -> SessionRpcLimitPrediction<'a> {
3193 SessionRpcLimitPrediction {
3194 session: self.session,
3195 }
3196 }
3197
3198 /// `session.lsp.*` sub-namespace.
3199 pub fn lsp(&self) -> SessionRpcLsp<'a> {
3200 SessionRpcLsp {
3201 session: self.session,
3202 }
3203 }
3204
3205 /// `session.mcp.*` sub-namespace.
3206 pub fn mcp(&self) -> SessionRpcMcp<'a> {
3207 SessionRpcMcp {
3208 session: self.session,
3209 }
3210 }
3211
3212 /// `session.metadata.*` sub-namespace.
3213 pub fn metadata(&self) -> SessionRpcMetadata<'a> {
3214 SessionRpcMetadata {
3215 session: self.session,
3216 }
3217 }
3218
3219 /// `session.mode.*` sub-namespace.
3220 pub fn mode(&self) -> SessionRpcMode<'a> {
3221 SessionRpcMode {
3222 session: self.session,
3223 }
3224 }
3225
3226 /// `session.model.*` sub-namespace.
3227 pub fn model(&self) -> SessionRpcModel<'a> {
3228 SessionRpcModel {
3229 session: self.session,
3230 }
3231 }
3232
3233 /// `session.name.*` sub-namespace.
3234 pub fn name(&self) -> SessionRpcName<'a> {
3235 SessionRpcName {
3236 session: self.session,
3237 }
3238 }
3239
3240 /// `session.options.*` sub-namespace.
3241 pub fn options(&self) -> SessionRpcOptions<'a> {
3242 SessionRpcOptions {
3243 session: self.session,
3244 }
3245 }
3246
3247 /// `session.permissions.*` sub-namespace.
3248 pub fn permissions(&self) -> SessionRpcPermissions<'a> {
3249 SessionRpcPermissions {
3250 session: self.session,
3251 }
3252 }
3253
3254 /// `session.plan.*` sub-namespace.
3255 pub fn plan(&self) -> SessionRpcPlan<'a> {
3256 SessionRpcPlan {
3257 session: self.session,
3258 }
3259 }
3260
3261 /// `session.plugins.*` sub-namespace.
3262 pub fn plugins(&self) -> SessionRpcPlugins<'a> {
3263 SessionRpcPlugins {
3264 session: self.session,
3265 }
3266 }
3267
3268 /// `session.provider.*` sub-namespace.
3269 pub fn provider(&self) -> SessionRpcProvider<'a> {
3270 SessionRpcProvider {
3271 session: self.session,
3272 }
3273 }
3274
3275 /// `session.queue.*` sub-namespace.
3276 pub fn queue(&self) -> SessionRpcQueue<'a> {
3277 SessionRpcQueue {
3278 session: self.session,
3279 }
3280 }
3281
3282 /// `session.remote.*` sub-namespace.
3283 pub fn remote(&self) -> SessionRpcRemote<'a> {
3284 SessionRpcRemote {
3285 session: self.session,
3286 }
3287 }
3288
3289 /// `session.sandbox.*` sub-namespace.
3290 pub fn sandbox(&self) -> SessionRpcSandbox<'a> {
3291 SessionRpcSandbox {
3292 session: self.session,
3293 }
3294 }
3295
3296 /// `session.schedule.*` sub-namespace.
3297 pub fn schedule(&self) -> SessionRpcSchedule<'a> {
3298 SessionRpcSchedule {
3299 session: self.session,
3300 }
3301 }
3302
3303 /// `session.settings.*` sub-namespace.
3304 pub fn settings(&self) -> SessionRpcSettings<'a> {
3305 SessionRpcSettings {
3306 session: self.session,
3307 }
3308 }
3309
3310 /// `session.shell.*` sub-namespace.
3311 pub fn shell(&self) -> SessionRpcShell<'a> {
3312 SessionRpcShell {
3313 session: self.session,
3314 }
3315 }
3316
3317 /// `session.skills.*` sub-namespace.
3318 pub fn skills(&self) -> SessionRpcSkills<'a> {
3319 SessionRpcSkills {
3320 session: self.session,
3321 }
3322 }
3323
3324 /// `session.tasks.*` sub-namespace.
3325 pub fn tasks(&self) -> SessionRpcTasks<'a> {
3326 SessionRpcTasks {
3327 session: self.session,
3328 }
3329 }
3330
3331 /// `session.telemetry.*` sub-namespace.
3332 pub fn telemetry(&self) -> SessionRpcTelemetry<'a> {
3333 SessionRpcTelemetry {
3334 session: self.session,
3335 }
3336 }
3337
3338 /// `session.tools.*` sub-namespace.
3339 pub fn tools(&self) -> SessionRpcTools<'a> {
3340 SessionRpcTools {
3341 session: self.session,
3342 }
3343 }
3344
3345 /// `session.ui.*` sub-namespace.
3346 pub fn ui(&self) -> SessionRpcUi<'a> {
3347 SessionRpcUi {
3348 session: self.session,
3349 }
3350 }
3351
3352 /// `session.usage.*` sub-namespace.
3353 pub fn usage(&self) -> SessionRpcUsage<'a> {
3354 SessionRpcUsage {
3355 session: self.session,
3356 }
3357 }
3358
3359 /// `session.visibility.*` sub-namespace.
3360 pub fn visibility(&self) -> SessionRpcVisibility<'a> {
3361 SessionRpcVisibility {
3362 session: self.session,
3363 }
3364 }
3365
3366 /// `session.workspaces.*` sub-namespace.
3367 pub fn workspaces(&self) -> SessionRpcWorkspaces<'a> {
3368 SessionRpcWorkspaces {
3369 session: self.session,
3370 }
3371 }
3372
3373 /// Suspends the session while preserving persisted state for later resume.
3374 ///
3375 /// Wire method: `session.suspend`.
3376 ///
3377 /// <div class="warning">
3378 ///
3379 /// **Experimental.** This API is part of an experimental wire-protocol surface
3380 /// and may change or be removed in future SDK or CLI releases. Pin both the
3381 /// SDK and CLI versions if your code depends on it.
3382 ///
3383 /// </div>
3384 pub async fn suspend(&self) -> Result<(), Error> {
3385 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3386 let _value = self
3387 .session
3388 .client()
3389 .call(rpc_methods::SESSION_SUSPEND, Some(wire_params))
3390 .await?;
3391 Ok(())
3392 }
3393
3394 /// Sends a user message to the session and returns its message ID.
3395 ///
3396 /// Wire method: `session.send`.
3397 ///
3398 /// # Parameters
3399 ///
3400 /// * `params` - Parameters for sending a user message to the session
3401 ///
3402 /// # Returns
3403 ///
3404 /// Result of sending a user message
3405 ///
3406 /// <div class="warning">
3407 ///
3408 /// **Experimental.** This API is part of an experimental wire-protocol surface
3409 /// and may change or be removed in future SDK or CLI releases. Pin both the
3410 /// SDK and CLI versions if your code depends on it.
3411 ///
3412 /// </div>
3413 pub async fn send(&self, params: SendRequest) -> Result<SendResult, Error> {
3414 let mut wire_params = serde_json::to_value(params)?;
3415 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3416 let _value = self
3417 .session
3418 .client()
3419 .call(rpc_methods::SESSION_SEND, Some(wire_params))
3420 .await?;
3421 Ok(serde_json::from_value(_value)?)
3422 }
3423
3424 /// 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.
3425 ///
3426 /// Wire method: `session.sendMessages`.
3427 ///
3428 /// # Parameters
3429 ///
3430 /// * `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.
3431 ///
3432 /// # Returns
3433 ///
3434 /// Result of sending zero or more user messages
3435 ///
3436 /// <div class="warning">
3437 ///
3438 /// **Experimental.** This API is part of an experimental wire-protocol surface
3439 /// and may change or be removed in future SDK or CLI releases. Pin both the
3440 /// SDK and CLI versions if your code depends on it.
3441 ///
3442 /// </div>
3443 pub async fn send_messages(
3444 &self,
3445 params: SendMessagesRequest,
3446 ) -> Result<SendMessagesResult, Error> {
3447 let mut wire_params = serde_json::to_value(params)?;
3448 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3449 let _value = self
3450 .session
3451 .client()
3452 .call(rpc_methods::SESSION_SENDMESSAGES, Some(wire_params))
3453 .await?;
3454 Ok(serde_json::from_value(_value)?)
3455 }
3456
3457 /// Queues or sends an internal system notification to the session according to its passive policy.
3458 ///
3459 /// Wire method: `session.sendSystemNotification`.
3460 ///
3461 /// # Parameters
3462 ///
3463 /// * `params` - Internal request for sending a system notification.
3464 ///
3465 /// <div class="warning">
3466 ///
3467 /// **Experimental.** This API is part of an experimental wire-protocol surface
3468 /// and may change or be removed in future SDK or CLI releases. Pin both the
3469 /// SDK and CLI versions if your code depends on it.
3470 ///
3471 /// </div>
3472 pub(crate) async fn send_system_notification(
3473 &self,
3474 params: SendSystemNotificationRequest,
3475 ) -> Result<(), Error> {
3476 let mut wire_params = serde_json::to_value(params)?;
3477 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3478 let _value = self
3479 .session
3480 .client()
3481 .call(
3482 rpc_methods::SESSION_SENDSYSTEMNOTIFICATION,
3483 Some(wire_params),
3484 )
3485 .await?;
3486 Ok(())
3487 }
3488
3489 /// Aborts the current agent turn.
3490 ///
3491 /// Wire method: `session.abort`.
3492 ///
3493 /// # Parameters
3494 ///
3495 /// * `params` - Parameters for aborting the current turn
3496 ///
3497 /// # Returns
3498 ///
3499 /// Result of aborting the current turn
3500 ///
3501 /// <div class="warning">
3502 ///
3503 /// **Experimental.** This API is part of an experimental wire-protocol surface
3504 /// and may change or be removed in future SDK or CLI releases. Pin both the
3505 /// SDK and CLI versions if your code depends on it.
3506 ///
3507 /// </div>
3508 pub async fn abort(&self, params: AbortRequest) -> Result<AbortResult, Error> {
3509 let mut wire_params = serde_json::to_value(params)?;
3510 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3511 let _value = self
3512 .session
3513 .client()
3514 .call(rpc_methods::SESSION_ABORT, Some(wire_params))
3515 .await?;
3516 Ok(serde_json::from_value(_value)?)
3517 }
3518
3519 /// 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.
3520 ///
3521 /// Wire method: `session.interruptMainTurn`.
3522 ///
3523 /// # Parameters
3524 ///
3525 /// * `params` - Parameters for interrupting the main agent turn.
3526 ///
3527 /// # Returns
3528 ///
3529 /// Result of interrupting the main agent turn.
3530 ///
3531 /// <div class="warning">
3532 ///
3533 /// **Experimental.** This API is part of an experimental wire-protocol surface
3534 /// and may change or be removed in future SDK or CLI releases. Pin both the
3535 /// SDK and CLI versions if your code depends on it.
3536 ///
3537 /// </div>
3538 pub async fn interrupt_main_turn(
3539 &self,
3540 params: InterruptMainTurnRequest,
3541 ) -> Result<InterruptMainTurnResult, Error> {
3542 let mut wire_params = serde_json::to_value(params)?;
3543 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3544 let _value = self
3545 .session
3546 .client()
3547 .call(rpc_methods::SESSION_INTERRUPTMAINTURN, Some(wire_params))
3548 .await?;
3549 Ok(serde_json::from_value(_value)?)
3550 }
3551
3552 /// Cancels every running background agent (task-registry subagents plus sidekick agents) without interrupting the main agent loop. Promoted attached shells are left running.
3553 ///
3554 /// Wire method: `session.cancelAllBackgroundAgents`.
3555 ///
3556 /// # Returns
3557 ///
3558 /// The number of running background agents (task-registry agents) that were cancelled.
3559 ///
3560 /// <div class="warning">
3561 ///
3562 /// **Experimental.** This API is part of an experimental wire-protocol surface
3563 /// and may change or be removed in future SDK or CLI releases. Pin both the
3564 /// SDK and CLI versions if your code depends on it.
3565 ///
3566 /// </div>
3567 pub async fn cancel_all_background_agents(
3568 &self,
3569 ) -> Result<SessionCancelAllBackgroundAgentsResult, Error> {
3570 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3571 let _value = self
3572 .session
3573 .client()
3574 .call(
3575 rpc_methods::SESSION_CANCELALLBACKGROUNDAGENTS,
3576 Some(wire_params),
3577 )
3578 .await?;
3579 Ok(serde_json::from_value(_value)?)
3580 }
3581
3582 /// 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.
3583 ///
3584 /// Wire method: `session.shutdown`.
3585 ///
3586 /// # Parameters
3587 ///
3588 /// * `params` - Parameters for shutting down the session
3589 ///
3590 /// <div class="warning">
3591 ///
3592 /// **Experimental.** This API is part of an experimental wire-protocol surface
3593 /// and may change or be removed in future SDK or CLI releases. Pin both the
3594 /// SDK and CLI versions if your code depends on it.
3595 ///
3596 /// </div>
3597 pub async fn shutdown(&self, params: ShutdownRequest) -> Result<(), Error> {
3598 let mut wire_params = serde_json::to_value(params)?;
3599 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3600 let _value = self
3601 .session
3602 .client()
3603 .call(rpc_methods::SESSION_SHUTDOWN, Some(wire_params))
3604 .await?;
3605 Ok(())
3606 }
3607
3608 /// Emits a user-visible session log event.
3609 ///
3610 /// Wire method: `session.log`.
3611 ///
3612 /// # Parameters
3613 ///
3614 /// * `params` - Message text, optional severity level, persistence flag, optional follow-up URL, and optional tip.
3615 ///
3616 /// # Returns
3617 ///
3618 /// Identifier of the session event that was emitted for the log message.
3619 ///
3620 /// <div class="warning">
3621 ///
3622 /// **Experimental.** This API is part of an experimental wire-protocol surface
3623 /// and may change or be removed in future SDK or CLI releases. Pin both the
3624 /// SDK and CLI versions if your code depends on it.
3625 ///
3626 /// </div>
3627 pub async fn log(&self, params: LogRequest) -> Result<LogResult, Error> {
3628 let mut wire_params = serde_json::to_value(params)?;
3629 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3630 let _value = self
3631 .session
3632 .client()
3633 .call(rpc_methods::SESSION_LOG, Some(wire_params))
3634 .await?;
3635 Ok(serde_json::from_value(_value)?)
3636 }
3637}
3638
3639/// `session.agent.*` RPCs.
3640#[derive(Clone, Copy)]
3641pub struct SessionRpcAgent<'a> {
3642 pub(crate) session: &'a Session,
3643}
3644
3645impl<'a> SessionRpcAgent<'a> {
3646 /// Lists agents available to the session. Defaults to custom agents only; pass includeBuiltInAgents to include the effective built-in agents.
3647 ///
3648 /// Wire method: `session.agent.list`.
3649 ///
3650 /// # Returns
3651 ///
3652 /// Agents available to the session.
3653 ///
3654 /// <div class="warning">
3655 ///
3656 /// **Experimental.** This API is part of an experimental wire-protocol surface
3657 /// and may change or be removed in future SDK or CLI releases. Pin both the
3658 /// SDK and CLI versions if your code depends on it.
3659 ///
3660 /// </div>
3661 pub async fn list(&self) -> Result<AgentList, Error> {
3662 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3663 let _value = self
3664 .session
3665 .client()
3666 .call(rpc_methods::SESSION_AGENT_LIST, Some(wire_params))
3667 .await?;
3668 Ok(serde_json::from_value(_value)?)
3669 }
3670
3671 /// Lists agents available to the session. Defaults to custom agents only; pass includeBuiltInAgents to include the effective built-in agents.
3672 ///
3673 /// Wire method: `session.agent.list`.
3674 ///
3675 /// # Parameters
3676 ///
3677 /// * `params` - Controls whether built-in agents and authored prompt text are included.
3678 ///
3679 /// # Returns
3680 ///
3681 /// Agents available to the session.
3682 ///
3683 /// <div class="warning">
3684 ///
3685 /// **Experimental.** This API is part of an experimental wire-protocol surface
3686 /// and may change or be removed in future SDK or CLI releases. Pin both the
3687 /// SDK and CLI versions if your code depends on it.
3688 ///
3689 /// </div>
3690 pub async fn list_with_params(&self, params: AgentListRequest) -> Result<AgentList, Error> {
3691 let mut wire_params = serde_json::to_value(params)?;
3692 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3693 let _value = self
3694 .session
3695 .client()
3696 .call(rpc_methods::SESSION_AGENT_LIST, Some(wire_params))
3697 .await?;
3698 Ok(serde_json::from_value(_value)?)
3699 }
3700
3701 /// 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.
3702 ///
3703 /// Wire method: `session.agent.setPrompt`.
3704 ///
3705 /// # Parameters
3706 ///
3707 /// * `params` - An in-memory authored prompt override for an available agent.
3708 ///
3709 /// <div class="warning">
3710 ///
3711 /// **Experimental.** This API is part of an experimental wire-protocol surface
3712 /// and may change or be removed in future SDK or CLI releases. Pin both the
3713 /// SDK and CLI versions if your code depends on it.
3714 ///
3715 /// </div>
3716 pub async fn set_prompt(&self, params: AgentSetPromptRequest) -> Result<(), Error> {
3717 let mut wire_params = serde_json::to_value(params)?;
3718 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3719 let _value = self
3720 .session
3721 .client()
3722 .call(rpc_methods::SESSION_AGENT_SETPROMPT, Some(wire_params))
3723 .await?;
3724 Ok(())
3725 }
3726
3727 /// Gets the currently selected custom agent for the session.
3728 ///
3729 /// Wire method: `session.agent.getCurrent`.
3730 ///
3731 /// # Returns
3732 ///
3733 /// The currently selected custom agent, or null when using the default agent.
3734 ///
3735 /// <div class="warning">
3736 ///
3737 /// **Experimental.** This API is part of an experimental wire-protocol surface
3738 /// and may change or be removed in future SDK or CLI releases. Pin both the
3739 /// SDK and CLI versions if your code depends on it.
3740 ///
3741 /// </div>
3742 pub async fn get_current(&self) -> Result<AgentGetCurrentResult, Error> {
3743 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3744 let _value = self
3745 .session
3746 .client()
3747 .call(rpc_methods::SESSION_AGENT_GETCURRENT, Some(wire_params))
3748 .await?;
3749 Ok(serde_json::from_value(_value)?)
3750 }
3751
3752 /// Selects a custom agent for subsequent turns in the session.
3753 ///
3754 /// Wire method: `session.agent.select`.
3755 ///
3756 /// # Parameters
3757 ///
3758 /// * `params` - Name of the custom agent to select for subsequent turns.
3759 ///
3760 /// # Returns
3761 ///
3762 /// The newly selected custom agent.
3763 ///
3764 /// <div class="warning">
3765 ///
3766 /// **Experimental.** This API is part of an experimental wire-protocol surface
3767 /// and may change or be removed in future SDK or CLI releases. Pin both the
3768 /// SDK and CLI versions if your code depends on it.
3769 ///
3770 /// </div>
3771 pub async fn select(&self, params: AgentSelectRequest) -> Result<AgentSelectResult, Error> {
3772 let mut wire_params = serde_json::to_value(params)?;
3773 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3774 let _value = self
3775 .session
3776 .client()
3777 .call(rpc_methods::SESSION_AGENT_SELECT, Some(wire_params))
3778 .await?;
3779 Ok(serde_json::from_value(_value)?)
3780 }
3781
3782 /// Clears the selected custom agent and returns the session to the default agent.
3783 ///
3784 /// Wire method: `session.agent.deselect`.
3785 ///
3786 /// <div class="warning">
3787 ///
3788 /// **Experimental.** This API is part of an experimental wire-protocol surface
3789 /// and may change or be removed in future SDK or CLI releases. Pin both the
3790 /// SDK and CLI versions if your code depends on it.
3791 ///
3792 /// </div>
3793 pub async fn deselect(&self) -> Result<(), Error> {
3794 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3795 let _value = self
3796 .session
3797 .client()
3798 .call(rpc_methods::SESSION_AGENT_DESELECT, Some(wire_params))
3799 .await?;
3800 Ok(())
3801 }
3802
3803 /// Reloads custom agent definitions and returns the refreshed list.
3804 ///
3805 /// Wire method: `session.agent.reload`.
3806 ///
3807 /// # Returns
3808 ///
3809 /// Custom agents available to the session after reloading definitions from disk.
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 reload(&self) -> Result<AgentReloadResult, Error> {
3819 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3820 let _value = self
3821 .session
3822 .client()
3823 .call(rpc_methods::SESSION_AGENT_RELOAD, Some(wire_params))
3824 .await?;
3825 Ok(serde_json::from_value(_value)?)
3826 }
3827}
3828
3829/// `session.autopilotObjective.*` RPCs.
3830#[derive(Clone, Copy)]
3831pub struct SessionRpcAutopilotObjective<'a> {
3832 pub(crate) session: &'a Session,
3833}
3834
3835impl<'a> SessionRpcAutopilotObjective<'a> {
3836 /// Reads the current canonical autopilot objective state for this session.
3837 ///
3838 /// Wire method: `session.autopilotObjective.getState`.
3839 ///
3840 /// # Returns
3841 ///
3842 /// Canonical runtime state for the session's current autopilot objective.
3843 ///
3844 /// <div class="warning">
3845 ///
3846 /// **Experimental.** This API is part of an experimental wire-protocol surface
3847 /// and may change or be removed in future SDK or CLI releases. Pin both the
3848 /// SDK and CLI versions if your code depends on it.
3849 ///
3850 /// </div>
3851 pub async fn get_state(&self) -> Result<AutopilotObjectiveGetStateResult, Error> {
3852 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3853 let _value = self
3854 .session
3855 .client()
3856 .call(
3857 rpc_methods::SESSION_AUTOPILOTOBJECTIVE_GETSTATE,
3858 Some(wire_params),
3859 )
3860 .await?;
3861 Ok(serde_json::from_value(_value)?)
3862 }
3863}
3864
3865/// `session.canvas.*` RPCs.
3866#[derive(Clone, Copy)]
3867pub struct SessionRpcCanvas<'a> {
3868 pub(crate) session: &'a Session,
3869}
3870
3871impl<'a> SessionRpcCanvas<'a> {
3872 /// `session.canvas.action.*` sub-namespace.
3873 pub fn action(&self) -> SessionRpcCanvasAction<'a> {
3874 SessionRpcCanvasAction {
3875 session: self.session,
3876 }
3877 }
3878
3879 /// `session.canvas.provider.*` sub-namespace.
3880 pub fn provider(&self) -> SessionRpcCanvasProvider<'a> {
3881 SessionRpcCanvasProvider {
3882 session: self.session,
3883 }
3884 }
3885
3886 /// Lists canvases declared for the session.
3887 ///
3888 /// Wire method: `session.canvas.list`.
3889 ///
3890 /// # Returns
3891 ///
3892 /// Declared canvases available in this session.
3893 ///
3894 /// <div class="warning">
3895 ///
3896 /// **Experimental.** This API is part of an experimental wire-protocol surface
3897 /// and may change or be removed in future SDK or CLI releases. Pin both the
3898 /// SDK and CLI versions if your code depends on it.
3899 ///
3900 /// </div>
3901 pub async fn list(&self) -> Result<CanvasList, Error> {
3902 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3903 let _value = self
3904 .session
3905 .client()
3906 .call(rpc_methods::SESSION_CANVAS_LIST, Some(wire_params))
3907 .await?;
3908 Ok(serde_json::from_value(_value)?)
3909 }
3910
3911 /// Lists currently open canvas instances for the live session.
3912 ///
3913 /// Wire method: `session.canvas.listOpen`.
3914 ///
3915 /// # Returns
3916 ///
3917 /// Live open-canvas snapshot.
3918 ///
3919 /// <div class="warning">
3920 ///
3921 /// **Experimental.** This API is part of an experimental wire-protocol surface
3922 /// and may change or be removed in future SDK or CLI releases. Pin both the
3923 /// SDK and CLI versions if your code depends on it.
3924 ///
3925 /// </div>
3926 pub async fn list_open(&self) -> Result<CanvasListOpenResult, Error> {
3927 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3928 let _value = self
3929 .session
3930 .client()
3931 .call(rpc_methods::SESSION_CANVAS_LISTOPEN, Some(wire_params))
3932 .await?;
3933 Ok(serde_json::from_value(_value)?)
3934 }
3935
3936 /// Opens or focuses a canvas instance.
3937 ///
3938 /// Wire method: `session.canvas.open`.
3939 ///
3940 /// # Parameters
3941 ///
3942 /// * `params` - Canvas open parameters.
3943 ///
3944 /// # Returns
3945 ///
3946 /// Open canvas instance snapshot.
3947 ///
3948 /// <div class="warning">
3949 ///
3950 /// **Experimental.** This API is part of an experimental wire-protocol surface
3951 /// and may change or be removed in future SDK or CLI releases. Pin both the
3952 /// SDK and CLI versions if your code depends on it.
3953 ///
3954 /// </div>
3955 pub async fn open(&self, params: CanvasOpenRequest) -> Result<OpenCanvasInstance, Error> {
3956 let mut wire_params = serde_json::to_value(params)?;
3957 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3958 let _value = self
3959 .session
3960 .client()
3961 .call(rpc_methods::SESSION_CANVAS_OPEN, Some(wire_params))
3962 .await?;
3963 Ok(serde_json::from_value(_value)?)
3964 }
3965
3966 /// Closes an open canvas instance.
3967 ///
3968 /// Wire method: `session.canvas.close`.
3969 ///
3970 /// # Parameters
3971 ///
3972 /// * `params` - Canvas close parameters.
3973 ///
3974 /// <div class="warning">
3975 ///
3976 /// **Experimental.** This API is part of an experimental wire-protocol surface
3977 /// and may change or be removed in future SDK or CLI releases. Pin both the
3978 /// SDK and CLI versions if your code depends on it.
3979 ///
3980 /// </div>
3981 pub async fn close(&self, params: CanvasCloseRequest) -> Result<(), Error> {
3982 let mut wire_params = serde_json::to_value(params)?;
3983 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3984 let _value = self
3985 .session
3986 .client()
3987 .call(rpc_methods::SESSION_CANVAS_CLOSE, Some(wire_params))
3988 .await?;
3989 Ok(())
3990 }
3991}
3992
3993/// `session.canvas.action.*` RPCs.
3994#[derive(Clone, Copy)]
3995pub struct SessionRpcCanvasAction<'a> {
3996 pub(crate) session: &'a Session,
3997}
3998
3999impl<'a> SessionRpcCanvasAction<'a> {
4000 /// Invokes an action on an open canvas instance.
4001 ///
4002 /// Wire method: `session.canvas.action.invoke`.
4003 ///
4004 /// # Parameters
4005 ///
4006 /// * `params` - Canvas action invocation parameters.
4007 ///
4008 /// # Returns
4009 ///
4010 /// Canvas action invocation result.
4011 ///
4012 /// <div class="warning">
4013 ///
4014 /// **Experimental.** This API is part of an experimental wire-protocol surface
4015 /// and may change or be removed in future SDK or CLI releases. Pin both the
4016 /// SDK and CLI versions if your code depends on it.
4017 ///
4018 /// </div>
4019 pub async fn invoke(
4020 &self,
4021 params: CanvasActionInvokeRequest,
4022 ) -> Result<CanvasActionInvokeResult, Error> {
4023 let mut wire_params = serde_json::to_value(params)?;
4024 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4025 let _value = self
4026 .session
4027 .client()
4028 .call(rpc_methods::SESSION_CANVAS_ACTION_INVOKE, Some(wire_params))
4029 .await?;
4030 Ok(serde_json::from_value(_value)?)
4031 }
4032}
4033
4034/// `session.canvas.provider.*` RPCs.
4035#[derive(Clone, Copy)]
4036pub struct SessionRpcCanvasProvider<'a> {
4037 pub(crate) session: &'a Session,
4038}
4039
4040impl<'a> SessionRpcCanvasProvider<'a> {
4041 /// Registers an internal canvas provider connection and its contributions.
4042 ///
4043 /// Wire method: `session.canvas.provider.register`.
4044 ///
4045 /// # Parameters
4046 ///
4047 /// * `params` - Internal canvas provider registration parameters.
4048 ///
4049 /// <div class="warning">
4050 ///
4051 /// **Experimental.** This API is part of an experimental wire-protocol surface
4052 /// and may change or be removed in future SDK or CLI releases. Pin both the
4053 /// SDK and CLI versions if your code depends on it.
4054 ///
4055 /// </div>
4056 pub(crate) async fn register(
4057 &self,
4058 params: CanvasProviderRegisterRequest,
4059 ) -> Result<(), Error> {
4060 let mut wire_params = serde_json::to_value(params)?;
4061 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4062 let _value = self
4063 .session
4064 .client()
4065 .call(
4066 rpc_methods::SESSION_CANVAS_PROVIDER_REGISTER,
4067 Some(wire_params),
4068 )
4069 .await?;
4070 Ok(())
4071 }
4072
4073 /// Unregisters an internal canvas provider connection.
4074 ///
4075 /// Wire method: `session.canvas.provider.unregister`.
4076 ///
4077 /// # Parameters
4078 ///
4079 /// * `params` - Internal canvas provider unregistration parameters.
4080 ///
4081 /// <div class="warning">
4082 ///
4083 /// **Experimental.** This API is part of an experimental wire-protocol surface
4084 /// and may change or be removed in future SDK or CLI releases. Pin both the
4085 /// SDK and CLI versions if your code depends on it.
4086 ///
4087 /// </div>
4088 pub(crate) async fn unregister(
4089 &self,
4090 params: CanvasProviderUnregisterRequest,
4091 ) -> Result<(), Error> {
4092 let mut wire_params = serde_json::to_value(params)?;
4093 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4094 let _value = self
4095 .session
4096 .client()
4097 .call(
4098 rpc_methods::SESSION_CANVAS_PROVIDER_UNREGISTER,
4099 Some(wire_params),
4100 )
4101 .await?;
4102 Ok(())
4103 }
4104}
4105
4106/// `session.commands.*` RPCs.
4107#[derive(Clone, Copy)]
4108pub struct SessionRpcCommands<'a> {
4109 pub(crate) session: &'a Session,
4110}
4111
4112impl<'a> SessionRpcCommands<'a> {
4113 /// Lists slash commands available in the session.
4114 ///
4115 /// Wire method: `session.commands.list`.
4116 ///
4117 /// # Returns
4118 ///
4119 /// Slash commands available in the session, after applying any include/exclude filters.
4120 ///
4121 /// <div class="warning">
4122 ///
4123 /// **Experimental.** This API is part of an experimental wire-protocol surface
4124 /// and may change or be removed in future SDK or CLI releases. Pin both the
4125 /// SDK and CLI versions if your code depends on it.
4126 ///
4127 /// </div>
4128 pub async fn list(&self) -> Result<CommandList, Error> {
4129 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
4130 let _value = self
4131 .session
4132 .client()
4133 .call(rpc_methods::SESSION_COMMANDS_LIST, Some(wire_params))
4134 .await?;
4135 Ok(serde_json::from_value(_value)?)
4136 }
4137
4138 /// Lists slash commands available in the session.
4139 ///
4140 /// Wire method: `session.commands.list`.
4141 ///
4142 /// # Parameters
4143 ///
4144 /// * `params` - Optional filters controlling which command sources to include in the listing.
4145 ///
4146 /// # Returns
4147 ///
4148 /// Slash commands available in the session, after applying any include/exclude filters.
4149 ///
4150 /// <div class="warning">
4151 ///
4152 /// **Experimental.** This API is part of an experimental wire-protocol surface
4153 /// and may change or be removed in future SDK or CLI releases. Pin both the
4154 /// SDK and CLI versions if your code depends on it.
4155 ///
4156 /// </div>
4157 pub async fn list_with_params(
4158 &self,
4159 params: CommandsListRequest,
4160 ) -> Result<CommandList, Error> {
4161 let mut wire_params = serde_json::to_value(params)?;
4162 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4163 let _value = self
4164 .session
4165 .client()
4166 .call(rpc_methods::SESSION_COMMANDS_LIST, Some(wire_params))
4167 .await?;
4168 Ok(serde_json::from_value(_value)?)
4169 }
4170
4171 /// Invokes a slash command in the session.
4172 ///
4173 /// Wire method: `session.commands.invoke`.
4174 ///
4175 /// # Parameters
4176 ///
4177 /// * `params` - Slash command name and optional raw input string to invoke.
4178 ///
4179 /// # Returns
4180 ///
4181 /// Result of invoking the slash command (text output, prompt to send to the agent, completion, or subcommand selection).
4182 ///
4183 /// <div class="warning">
4184 ///
4185 /// **Experimental.** This API is part of an experimental wire-protocol surface
4186 /// and may change or be removed in future SDK or CLI releases. Pin both the
4187 /// SDK and CLI versions if your code depends on it.
4188 ///
4189 /// </div>
4190 pub async fn invoke(
4191 &self,
4192 params: CommandsInvokeRequest,
4193 ) -> Result<SlashCommandInvocationResult, Error> {
4194 let mut wire_params = serde_json::to_value(params)?;
4195 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4196 let _value = self
4197 .session
4198 .client()
4199 .call(rpc_methods::SESSION_COMMANDS_INVOKE, Some(wire_params))
4200 .await?;
4201 Ok(serde_json::from_value(_value)?)
4202 }
4203
4204 /// Finalizes persistence associated with a client-applied slash-command effect.
4205 ///
4206 /// Wire method: `session.commands.finalizeInvocationEffect`.
4207 ///
4208 /// # Parameters
4209 ///
4210 /// * `params` - The pending slash-command invocation effect to finalize, plus whether the host applied or cancelled it.
4211 ///
4212 /// # Returns
4213 ///
4214 /// Whether finalizing the invocation effect succeeded, and the failure reason when it did not.
4215 ///
4216 /// <div class="warning">
4217 ///
4218 /// **Experimental.** This API is part of an experimental wire-protocol surface
4219 /// and may change or be removed in future SDK or CLI releases. Pin both the
4220 /// SDK and CLI versions if your code depends on it.
4221 ///
4222 /// </div>
4223 pub(crate) async fn finalize_invocation_effect(
4224 &self,
4225 params: CommandsFinalizeInvocationEffectRequest,
4226 ) -> Result<CommandsFinalizeInvocationEffectResult, Error> {
4227 let mut wire_params = serde_json::to_value(params)?;
4228 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4229 let _value = self
4230 .session
4231 .client()
4232 .call(
4233 rpc_methods::SESSION_COMMANDS_FINALIZEINVOCATIONEFFECT,
4234 Some(wire_params),
4235 )
4236 .await?;
4237 Ok(serde_json::from_value(_value)?)
4238 }
4239
4240 /// Reports completion of a pending client-handled slash command.
4241 ///
4242 /// Wire method: `session.commands.handlePendingCommand`.
4243 ///
4244 /// # Parameters
4245 ///
4246 /// * `params` - Pending command request ID and an optional error if the client handler failed.
4247 ///
4248 /// # Returns
4249 ///
4250 /// Indicates whether the pending client-handled command was completed successfully.
4251 ///
4252 /// <div class="warning">
4253 ///
4254 /// **Experimental.** This API is part of an experimental wire-protocol surface
4255 /// and may change or be removed in future SDK or CLI releases. Pin both the
4256 /// SDK and CLI versions if your code depends on it.
4257 ///
4258 /// </div>
4259 pub async fn handle_pending_command(
4260 &self,
4261 params: CommandsHandlePendingCommandRequest,
4262 ) -> Result<CommandsHandlePendingCommandResult, Error> {
4263 let mut wire_params = serde_json::to_value(params)?;
4264 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4265 let _value = self
4266 .session
4267 .client()
4268 .call(
4269 rpc_methods::SESSION_COMMANDS_HANDLEPENDINGCOMMAND,
4270 Some(wire_params),
4271 )
4272 .await?;
4273 Ok(serde_json::from_value(_value)?)
4274 }
4275
4276 /// Executes a slash command synchronously and returns any error.
4277 ///
4278 /// Wire method: `session.commands.execute`.
4279 ///
4280 /// # Parameters
4281 ///
4282 /// * `params` - Slash command name and argument string to execute synchronously.
4283 ///
4284 /// # Returns
4285 ///
4286 /// Error message produced while executing the command, if any.
4287 ///
4288 /// <div class="warning">
4289 ///
4290 /// **Experimental.** This API is part of an experimental wire-protocol surface
4291 /// and may change or be removed in future SDK or CLI releases. Pin both the
4292 /// SDK and CLI versions if your code depends on it.
4293 ///
4294 /// </div>
4295 pub async fn execute(
4296 &self,
4297 params: ExecuteCommandParams,
4298 ) -> Result<ExecuteCommandResult, Error> {
4299 let mut wire_params = serde_json::to_value(params)?;
4300 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4301 let _value = self
4302 .session
4303 .client()
4304 .call(rpc_methods::SESSION_COMMANDS_EXECUTE, Some(wire_params))
4305 .await?;
4306 Ok(serde_json::from_value(_value)?)
4307 }
4308
4309 /// Enqueues a slash command for FIFO processing on the local session.
4310 ///
4311 /// Wire method: `session.commands.enqueue`.
4312 ///
4313 /// # Parameters
4314 ///
4315 /// * `params` - Slash-prefixed command string to enqueue for FIFO processing.
4316 ///
4317 /// # Returns
4318 ///
4319 /// Indicates whether the command was accepted into the local execution queue.
4320 ///
4321 /// <div class="warning">
4322 ///
4323 /// **Experimental.** This API is part of an experimental wire-protocol surface
4324 /// and may change or be removed in future SDK or CLI releases. Pin both the
4325 /// SDK and CLI versions if your code depends on it.
4326 ///
4327 /// </div>
4328 pub async fn enqueue(
4329 &self,
4330 params: EnqueueCommandParams,
4331 ) -> Result<EnqueueCommandResult, Error> {
4332 let mut wire_params = serde_json::to_value(params)?;
4333 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4334 let _value = self
4335 .session
4336 .client()
4337 .call(rpc_methods::SESSION_COMMANDS_ENQUEUE, Some(wire_params))
4338 .await?;
4339 Ok(serde_json::from_value(_value)?)
4340 }
4341
4342 /// Reports whether the host actually executed a queued command and whether to continue processing.
4343 ///
4344 /// Wire method: `session.commands.respondToQueuedCommand`.
4345 ///
4346 /// # Parameters
4347 ///
4348 /// * `params` - Queued-command request ID and the result indicating whether the host executed it (and whether to stop processing further queued commands).
4349 ///
4350 /// # Returns
4351 ///
4352 /// Indicates whether the queued-command response was matched to a pending request.
4353 ///
4354 /// <div class="warning">
4355 ///
4356 /// **Experimental.** This API is part of an experimental wire-protocol surface
4357 /// and may change or be removed in future SDK or CLI releases. Pin both the
4358 /// SDK and CLI versions if your code depends on it.
4359 ///
4360 /// </div>
4361 pub async fn respond_to_queued_command(
4362 &self,
4363 params: CommandsRespondToQueuedCommandRequest,
4364 ) -> Result<CommandsRespondToQueuedCommandResult, Error> {
4365 let mut wire_params = serde_json::to_value(params)?;
4366 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4367 let _value = self
4368 .session
4369 .client()
4370 .call(
4371 rpc_methods::SESSION_COMMANDS_RESPONDTOQUEUEDCOMMAND,
4372 Some(wire_params),
4373 )
4374 .await?;
4375 Ok(serde_json::from_value(_value)?)
4376 }
4377}
4378
4379/// `session.completions.*` RPCs.
4380#[derive(Clone, Copy)]
4381pub struct SessionRpcCompletions<'a> {
4382 pub(crate) session: &'a Session,
4383}
4384
4385impl<'a> SessionRpcCompletions<'a> {
4386 /// 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).
4387 ///
4388 /// Wire method: `session.completions.getTriggerCharacters`.
4389 ///
4390 /// # Returns
4391 ///
4392 /// 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`).
4393 ///
4394 /// <div class="warning">
4395 ///
4396 /// **Experimental.** This API is part of an experimental wire-protocol surface
4397 /// and may change or be removed in future SDK or CLI releases. Pin both the
4398 /// SDK and CLI versions if your code depends on it.
4399 ///
4400 /// </div>
4401 pub async fn get_trigger_characters(
4402 &self,
4403 ) -> Result<CompletionsGetTriggerCharactersResult, Error> {
4404 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
4405 let _value = self
4406 .session
4407 .client()
4408 .call(
4409 rpc_methods::SESSION_COMPLETIONS_GETTRIGGERCHARACTERS,
4410 Some(wire_params),
4411 )
4412 .await?;
4413 Ok(serde_json::from_value(_value)?)
4414 }
4415
4416 /// 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.
4417 ///
4418 /// Wire method: `session.completions.request`.
4419 ///
4420 /// # Parameters
4421 ///
4422 /// * `params` - Request host-driven completions for the current composer input.
4423 ///
4424 /// # Returns
4425 ///
4426 /// Host-driven completion items for the current composer input. Empty when the host returns no items or does not support completions.
4427 ///
4428 /// <div class="warning">
4429 ///
4430 /// **Experimental.** This API is part of an experimental wire-protocol surface
4431 /// and may change or be removed in future SDK or CLI releases. Pin both the
4432 /// SDK and CLI versions if your code depends on it.
4433 ///
4434 /// </div>
4435 pub async fn request(
4436 &self,
4437 params: CompletionsRequestRequest,
4438 ) -> Result<CompletionsRequestResult, Error> {
4439 let mut wire_params = serde_json::to_value(params)?;
4440 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4441 let _value = self
4442 .session
4443 .client()
4444 .call(rpc_methods::SESSION_COMPLETIONS_REQUEST, Some(wire_params))
4445 .await?;
4446 Ok(serde_json::from_value(_value)?)
4447 }
4448}
4449
4450/// `session.contentExclusion.*` RPCs.
4451#[derive(Clone, Copy)]
4452pub struct SessionRpcContentExclusion<'a> {
4453 pub(crate) session: &'a Session,
4454}
4455
4456impl<'a> SessionRpcContentExclusion<'a> {
4457 /// 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.
4458 ///
4459 /// Wire method: `session.contentExclusion.checkPaths`.
4460 ///
4461 /// # Parameters
4462 ///
4463 /// * `params` - Local file system absolute paths within the session working directory to check against its content-exclusion policy.
4464 ///
4465 /// # Returns
4466 ///
4467 /// Batch content-exclusion result. Callers must fail closed when policy evaluation is unavailable.
4468 ///
4469 /// <div class="warning">
4470 ///
4471 /// **Experimental.** This API is part of an experimental wire-protocol surface
4472 /// and may change or be removed in future SDK or CLI releases. Pin both the
4473 /// SDK and CLI versions if your code depends on it.
4474 ///
4475 /// </div>
4476 pub async fn check_paths(
4477 &self,
4478 params: ContentExclusionCheckPathsRequest,
4479 ) -> Result<ContentExclusionCheckPathsResult, Error> {
4480 let mut wire_params = serde_json::to_value(params)?;
4481 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4482 let _value = self
4483 .session
4484 .client()
4485 .call(
4486 rpc_methods::SESSION_CONTENTEXCLUSION_CHECKPATHS,
4487 Some(wire_params),
4488 )
4489 .await?;
4490 Ok(serde_json::from_value(_value)?)
4491 }
4492}
4493
4494/// `session.debug.*` RPCs.
4495#[derive(Clone, Copy)]
4496pub struct SessionRpcDebug<'a> {
4497 pub(crate) session: &'a Session,
4498}
4499
4500impl<'a> SessionRpcDebug<'a> {
4501 /// Collects a session debug log bundle into a local archive or staging directory. Logs are redacted by default; redaction can be configured per caller-provided diagnostic entry. The runtime includes session-owned logs by default and accepts caller-provided diagnostic entries so host applications can add their own files without changing this API shape.
4502 ///
4503 /// Wire method: `session.debug.collectLogs`.
4504 ///
4505 /// # Parameters
4506 ///
4507 /// * `params` - Options for collecting a session debug bundle with configurable redaction.
4508 ///
4509 /// # Returns
4510 ///
4511 /// Result of collecting a session debug bundle.
4512 ///
4513 /// <div class="warning">
4514 ///
4515 /// **Experimental.** This API is part of an experimental wire-protocol surface
4516 /// and may change or be removed in future SDK or CLI releases. Pin both the
4517 /// SDK and CLI versions if your code depends on it.
4518 ///
4519 /// </div>
4520 pub async fn collect_logs(
4521 &self,
4522 params: DebugCollectLogsRequest,
4523 ) -> Result<DebugCollectLogsResult, Error> {
4524 let mut wire_params = serde_json::to_value(params)?;
4525 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4526 let _value = self
4527 .session
4528 .client()
4529 .call(rpc_methods::SESSION_DEBUG_COLLECTLOGS, Some(wire_params))
4530 .await?;
4531 Ok(serde_json::from_value(_value)?)
4532 }
4533}
4534
4535/// `session.eventLog.*` RPCs.
4536#[derive(Clone, Copy)]
4537pub struct SessionRpcEventLog<'a> {
4538 pub(crate) session: &'a Session,
4539}
4540
4541impl<'a> SessionRpcEventLog<'a> {
4542 /// Reads a batch of session events from a cursor, optionally waiting for new events. Supports tail-first reads via `direction: backward`.
4543 ///
4544 /// Wire method: `session.eventLog.read`.
4545 ///
4546 /// # Parameters
4547 ///
4548 /// * `params` - Cursor, batch size, and optional long-poll/filter parameters for reading session events.
4549 ///
4550 /// # Returns
4551 ///
4552 /// Batch of session events returned by a read, with cursor and continuation metadata.
4553 ///
4554 /// <div class="warning">
4555 ///
4556 /// **Experimental.** This API is part of an experimental wire-protocol surface
4557 /// and may change or be removed in future SDK or CLI releases. Pin both the
4558 /// SDK and CLI versions if your code depends on it.
4559 ///
4560 /// </div>
4561 pub async fn read(&self, params: EventLogReadRequest) -> Result<EventsReadResult, Error> {
4562 let mut wire_params = serde_json::to_value(params)?;
4563 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4564 let _value = self
4565 .session
4566 .client()
4567 .call(rpc_methods::SESSION_EVENTLOG_READ, Some(wire_params))
4568 .await?;
4569 Ok(serde_json::from_value(_value)?)
4570 }
4571
4572 /// Returns a snapshot of the current tail cursor without consuming events.
4573 ///
4574 /// Wire method: `session.eventLog.tail`.
4575 ///
4576 /// # Returns
4577 ///
4578 /// 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).
4579 ///
4580 /// <div class="warning">
4581 ///
4582 /// **Experimental.** This API is part of an experimental wire-protocol surface
4583 /// and may change or be removed in future SDK or CLI releases. Pin both the
4584 /// SDK and CLI versions if your code depends on it.
4585 ///
4586 /// </div>
4587 pub async fn tail(&self) -> Result<EventLogTailResult, Error> {
4588 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
4589 let _value = self
4590 .session
4591 .client()
4592 .call(rpc_methods::SESSION_EVENTLOG_TAIL, Some(wire_params))
4593 .await?;
4594 Ok(serde_json::from_value(_value)?)
4595 }
4596
4597 /// Registers consumer interest in an event type for runtime gating purposes.
4598 ///
4599 /// Wire method: `session.eventLog.registerInterest`.
4600 ///
4601 /// # Parameters
4602 ///
4603 /// * `params` - Event type to register consumer interest for, used by runtime gating logic.
4604 ///
4605 /// # Returns
4606 ///
4607 /// Opaque handle representing an event-type interest registration.
4608 ///
4609 /// <div class="warning">
4610 ///
4611 /// **Experimental.** This API is part of an experimental wire-protocol surface
4612 /// and may change or be removed in future SDK or CLI releases. Pin both the
4613 /// SDK and CLI versions if your code depends on it.
4614 ///
4615 /// </div>
4616 pub async fn register_interest(
4617 &self,
4618 params: RegisterEventInterestParams,
4619 ) -> Result<RegisterEventInterestResult, Error> {
4620 let mut wire_params = serde_json::to_value(params)?;
4621 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4622 let _value = self
4623 .session
4624 .client()
4625 .call(
4626 rpc_methods::SESSION_EVENTLOG_REGISTERINTEREST,
4627 Some(wire_params),
4628 )
4629 .await?;
4630 Ok(serde_json::from_value(_value)?)
4631 }
4632
4633 /// Releases a consumer's previously-registered interest in an event type.
4634 ///
4635 /// Wire method: `session.eventLog.releaseInterest`.
4636 ///
4637 /// # Parameters
4638 ///
4639 /// * `params` - Opaque handle previously returned by `registerInterest` to release.
4640 ///
4641 /// # Returns
4642 ///
4643 /// Indicates whether the operation succeeded.
4644 ///
4645 /// <div class="warning">
4646 ///
4647 /// **Experimental.** This API is part of an experimental wire-protocol surface
4648 /// and may change or be removed in future SDK or CLI releases. Pin both the
4649 /// SDK and CLI versions if your code depends on it.
4650 ///
4651 /// </div>
4652 pub async fn release_interest(
4653 &self,
4654 params: ReleaseEventInterestParams,
4655 ) -> Result<EventLogReleaseInterestResult, Error> {
4656 let mut wire_params = serde_json::to_value(params)?;
4657 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4658 let _value = self
4659 .session
4660 .client()
4661 .call(
4662 rpc_methods::SESSION_EVENTLOG_RELEASEINTEREST,
4663 Some(wire_params),
4664 )
4665 .await?;
4666 Ok(serde_json::from_value(_value)?)
4667 }
4668}
4669
4670/// `session.extensions.*` RPCs.
4671#[derive(Clone, Copy)]
4672pub struct SessionRpcExtensions<'a> {
4673 pub(crate) session: &'a Session,
4674}
4675
4676impl<'a> SessionRpcExtensions<'a> {
4677 /// Lists extensions discovered for the session and their current status.
4678 ///
4679 /// Wire method: `session.extensions.list`.
4680 ///
4681 /// # Returns
4682 ///
4683 /// Extensions discovered for the session, with their current status.
4684 ///
4685 /// <div class="warning">
4686 ///
4687 /// **Experimental.** This API is part of an experimental wire-protocol surface
4688 /// and may change or be removed in future SDK or CLI releases. Pin both the
4689 /// SDK and CLI versions if your code depends on it.
4690 ///
4691 /// </div>
4692 pub async fn list(&self) -> Result<ExtensionList, Error> {
4693 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
4694 let _value = self
4695 .session
4696 .client()
4697 .call(rpc_methods::SESSION_EXTENSIONS_LIST, Some(wire_params))
4698 .await?;
4699 Ok(serde_json::from_value(_value)?)
4700 }
4701
4702 /// Enables an extension for the session.
4703 ///
4704 /// Wire method: `session.extensions.enable`.
4705 ///
4706 /// # Parameters
4707 ///
4708 /// * `params` - Source-qualified extension identifier to enable for the session.
4709 ///
4710 /// <div class="warning">
4711 ///
4712 /// **Experimental.** This API is part of an experimental wire-protocol surface
4713 /// and may change or be removed in future SDK or CLI releases. Pin both the
4714 /// SDK and CLI versions if your code depends on it.
4715 ///
4716 /// </div>
4717 pub async fn enable(&self, params: ExtensionsEnableRequest) -> Result<(), Error> {
4718 let mut wire_params = serde_json::to_value(params)?;
4719 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4720 let _value = self
4721 .session
4722 .client()
4723 .call(rpc_methods::SESSION_EXTENSIONS_ENABLE, Some(wire_params))
4724 .await?;
4725 Ok(())
4726 }
4727
4728 /// Disables an extension for the session.
4729 ///
4730 /// Wire method: `session.extensions.disable`.
4731 ///
4732 /// # Parameters
4733 ///
4734 /// * `params` - Source-qualified extension identifier to disable for the session.
4735 ///
4736 /// <div class="warning">
4737 ///
4738 /// **Experimental.** This API is part of an experimental wire-protocol surface
4739 /// and may change or be removed in future SDK or CLI releases. Pin both the
4740 /// SDK and CLI versions if your code depends on it.
4741 ///
4742 /// </div>
4743 pub async fn disable(&self, params: ExtensionsDisableRequest) -> Result<(), Error> {
4744 let mut wire_params = serde_json::to_value(params)?;
4745 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4746 let _value = self
4747 .session
4748 .client()
4749 .call(rpc_methods::SESSION_EXTENSIONS_DISABLE, Some(wire_params))
4750 .await?;
4751 Ok(())
4752 }
4753
4754 /// Reloads extension definitions and processes for the session.
4755 ///
4756 /// Wire method: `session.extensions.reload`.
4757 ///
4758 /// <div class="warning">
4759 ///
4760 /// **Experimental.** This API is part of an experimental wire-protocol surface
4761 /// and may change or be removed in future SDK or CLI releases. Pin both the
4762 /// SDK and CLI versions if your code depends on it.
4763 ///
4764 /// </div>
4765 pub async fn reload(&self) -> Result<(), Error> {
4766 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
4767 let _value = self
4768 .session
4769 .client()
4770 .call(rpc_methods::SESSION_EXTENSIONS_RELOAD, Some(wire_params))
4771 .await?;
4772 Ok(())
4773 }
4774
4775 /// 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.
4776 ///
4777 /// Wire method: `session.extensions.sendAttachmentsToMessage`.
4778 ///
4779 /// # Parameters
4780 ///
4781 /// * `params` - Parameters for session.extensions.sendAttachmentsToMessage.
4782 ///
4783 /// <div class="warning">
4784 ///
4785 /// **Experimental.** This API is part of an experimental wire-protocol surface
4786 /// and may change or be removed in future SDK or CLI releases. Pin both the
4787 /// SDK and CLI versions if your code depends on it.
4788 ///
4789 /// </div>
4790 pub async fn send_attachments_to_message(
4791 &self,
4792 params: SendAttachmentsToMessageParams,
4793 ) -> Result<(), Error> {
4794 let mut wire_params = serde_json::to_value(params)?;
4795 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4796 let _value = self
4797 .session
4798 .client()
4799 .call(
4800 rpc_methods::SESSION_EXTENSIONS_SENDATTACHMENTSTOMESSAGE,
4801 Some(wire_params),
4802 )
4803 .await?;
4804 Ok(())
4805 }
4806}
4807
4808/// `session.factory.*` RPCs.
4809#[derive(Clone, Copy)]
4810pub struct SessionRpcFactory<'a> {
4811 pub(crate) session: &'a Session,
4812}
4813
4814impl<'a> SessionRpcFactory<'a> {
4815 /// `session.factory.journal.*` sub-namespace.
4816 pub fn journal(&self) -> SessionRpcFactoryJournal<'a> {
4817 SessionRpcFactoryJournal {
4818 session: self.session,
4819 }
4820 }
4821
4822 /// Runs a registered factory by name at the top level.
4823 ///
4824 /// Wire method: `session.factory.run`.
4825 ///
4826 /// # Parameters
4827 ///
4828 /// * `params` - Parameters for invoking a registered factory.
4829 ///
4830 /// # Returns
4831 ///
4832 /// Complete current or terminal factory run envelope.
4833 ///
4834 /// <div class="warning">
4835 ///
4836 /// **Experimental.** This API is part of an experimental wire-protocol surface
4837 /// and may change or be removed in future SDK or CLI releases. Pin both the
4838 /// SDK and CLI versions if your code depends on it.
4839 ///
4840 /// </div>
4841 pub async fn run(&self, params: FactoryRunRequest) -> Result<FactoryRunResult, Error> {
4842 let mut wire_params = serde_json::to_value(params)?;
4843 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4844 let _value = self
4845 .session
4846 .client()
4847 .call(rpc_methods::SESSION_FACTORY_RUN, Some(wire_params))
4848 .await?;
4849 Ok(serde_json::from_value(_value)?)
4850 }
4851
4852 /// Resumes a factory run using its persisted name, arguments, journal, and accounting.
4853 ///
4854 /// Wire method: `session.factory.resume`.
4855 ///
4856 /// # Parameters
4857 ///
4858 /// * `params` - Parameters for resuming a factory run from its persisted identity.
4859 ///
4860 /// # Returns
4861 ///
4862 /// Resolved persisted factory identity and resumed run envelope.
4863 ///
4864 /// <div class="warning">
4865 ///
4866 /// **Experimental.** This API is part of an experimental wire-protocol surface
4867 /// and may change or be removed in future SDK or CLI releases. Pin both the
4868 /// SDK and CLI versions if your code depends on it.
4869 ///
4870 /// </div>
4871 pub async fn resume(&self, params: FactoryResumeRequest) -> Result<FactoryResumeResult, Error> {
4872 let mut wire_params = serde_json::to_value(params)?;
4873 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4874 let _value = self
4875 .session
4876 .client()
4877 .call(rpc_methods::SESSION_FACTORY_RESUME, Some(wire_params))
4878 .await?;
4879 Ok(serde_json::from_value(_value)?)
4880 }
4881
4882 /// Internal tool-originated factory invocation.
4883 ///
4884 /// Wire method: `session.factory.runFromTool`.
4885 ///
4886 /// # Parameters
4887 ///
4888 /// * `params` - Internal parameters for invoking a registered factory from a tool.
4889 ///
4890 /// # Returns
4891 ///
4892 /// Complete current or terminal factory run envelope.
4893 ///
4894 /// <div class="warning">
4895 ///
4896 /// **Experimental.** This API is part of an experimental wire-protocol surface
4897 /// and may change or be removed in future SDK or CLI releases. Pin both the
4898 /// SDK and CLI versions if your code depends on it.
4899 ///
4900 /// </div>
4901 pub(crate) async fn run_from_tool(
4902 &self,
4903 params: FactoryToolRunRequest,
4904 ) -> Result<FactoryRunResult, Error> {
4905 let mut wire_params = serde_json::to_value(params)?;
4906 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4907 let _value = self
4908 .session
4909 .client()
4910 .call(rpc_methods::SESSION_FACTORY_RUNFROMTOOL, Some(wire_params))
4911 .await?;
4912 Ok(serde_json::from_value(_value)?)
4913 }
4914
4915 /// Internal tool-originated factory resume.
4916 ///
4917 /// Wire method: `session.factory.resumeFromTool`.
4918 ///
4919 /// # Parameters
4920 ///
4921 /// * `params` - Internal parameters for resuming a factory run from a tool.
4922 ///
4923 /// # Returns
4924 ///
4925 /// Resolved persisted factory identity and resumed run envelope.
4926 ///
4927 /// <div class="warning">
4928 ///
4929 /// **Experimental.** This API is part of an experimental wire-protocol surface
4930 /// and may change or be removed in future SDK or CLI releases. Pin both the
4931 /// SDK and CLI versions if your code depends on it.
4932 ///
4933 /// </div>
4934 pub(crate) async fn resume_from_tool(
4935 &self,
4936 params: FactoryToolResumeRequest,
4937 ) -> Result<FactoryResumeResult, Error> {
4938 let mut wire_params = serde_json::to_value(params)?;
4939 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4940 let _value = self
4941 .session
4942 .client()
4943 .call(
4944 rpc_methods::SESSION_FACTORY_RESUMEFROMTOOL,
4945 Some(wire_params),
4946 )
4947 .await?;
4948 Ok(serde_json::from_value(_value)?)
4949 }
4950
4951 /// Gets the current or settled envelope for a factory run.
4952 ///
4953 /// Wire method: `session.factory.getRun`.
4954 ///
4955 /// # Parameters
4956 ///
4957 /// * `params` - Parameters for retrieving a factory run.
4958 ///
4959 /// # Returns
4960 ///
4961 /// Complete current or terminal factory run envelope.
4962 ///
4963 /// <div class="warning">
4964 ///
4965 /// **Experimental.** This API is part of an experimental wire-protocol surface
4966 /// and may change or be removed in future SDK or CLI releases. Pin both the
4967 /// SDK and CLI versions if your code depends on it.
4968 ///
4969 /// </div>
4970 pub async fn get_run(&self, params: FactoryGetRunRequest) -> Result<FactoryRunResult, Error> {
4971 let mut wire_params = serde_json::to_value(params)?;
4972 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4973 let _value = self
4974 .session
4975 .client()
4976 .call(rpc_methods::SESSION_FACTORY_GETRUN, Some(wire_params))
4977 .await?;
4978 Ok(serde_json::from_value(_value)?)
4979 }
4980
4981 /// Lists durable factory runs for this session in creation order.
4982 ///
4983 /// Wire method: `session.factory.listRuns`.
4984 ///
4985 /// # Parameters
4986 ///
4987 /// * `params` - Parameters for paging factory runs.
4988 ///
4989 /// # Returns
4990 ///
4991 /// A page of factory runs in durable creation order.
4992 ///
4993 /// <div class="warning">
4994 ///
4995 /// **Experimental.** This API is part of an experimental wire-protocol surface
4996 /// and may change or be removed in future SDK or CLI releases. Pin both the
4997 /// SDK and CLI versions if your code depends on it.
4998 ///
4999 /// </div>
5000 pub async fn list_runs(
5001 &self,
5002 params: FactoryListRunsRequest,
5003 ) -> Result<FactoryListRunsResult, Error> {
5004 let mut wire_params = serde_json::to_value(params)?;
5005 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5006 let _value = self
5007 .session
5008 .client()
5009 .call(rpc_methods::SESSION_FACTORY_LISTRUNS, Some(wire_params))
5010 .await?;
5011 Ok(serde_json::from_value(_value)?)
5012 }
5013
5014 /// Gets durable and live observability detail for one factory run.
5015 ///
5016 /// Wire method: `session.factory.getRunDetail`.
5017 ///
5018 /// # Parameters
5019 ///
5020 /// * `params` - Parameters for retrieving a factory run.
5021 ///
5022 /// # Returns
5023 ///
5024 /// Full factory run observability detail.
5025 ///
5026 /// <div class="warning">
5027 ///
5028 /// **Experimental.** This API is part of an experimental wire-protocol surface
5029 /// and may change or be removed in future SDK or CLI releases. Pin both the
5030 /// SDK and CLI versions if your code depends on it.
5031 ///
5032 /// </div>
5033 pub async fn get_run_detail(
5034 &self,
5035 params: FactoryGetRunRequest,
5036 ) -> Result<FactoryRunDetail, Error> {
5037 let mut wire_params = serde_json::to_value(params)?;
5038 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5039 let _value = self
5040 .session
5041 .client()
5042 .call(rpc_methods::SESSION_FACTORY_GETRUNDETAIL, Some(wire_params))
5043 .await?;
5044 Ok(serde_json::from_value(_value)?)
5045 }
5046
5047 /// Pages durable progress for one factory run.
5048 ///
5049 /// Wire method: `session.factory.getRunProgress`.
5050 ///
5051 /// # Parameters
5052 ///
5053 /// * `params` - Parameters for paging factory progress.
5054 ///
5055 /// # Returns
5056 ///
5057 /// A bidirectional page of factory progress.
5058 ///
5059 /// <div class="warning">
5060 ///
5061 /// **Experimental.** This API is part of an experimental wire-protocol surface
5062 /// and may change or be removed in future SDK or CLI releases. Pin both the
5063 /// SDK and CLI versions if your code depends on it.
5064 ///
5065 /// </div>
5066 pub async fn get_run_progress(
5067 &self,
5068 params: FactoryGetRunProgressRequest,
5069 ) -> Result<FactoryProgressPage, Error> {
5070 let mut wire_params = serde_json::to_value(params)?;
5071 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5072 let _value = self
5073 .session
5074 .client()
5075 .call(
5076 rpc_methods::SESSION_FACTORY_GETRUNPROGRESS,
5077 Some(wire_params),
5078 )
5079 .await?;
5080 Ok(serde_json::from_value(_value)?)
5081 }
5082
5083 /// Requests cancellation of a factory run and returns its run envelope.
5084 ///
5085 /// Wire method: `session.factory.cancel`.
5086 ///
5087 /// # Parameters
5088 ///
5089 /// * `params` - Parameters for cancelling a factory run.
5090 ///
5091 /// # Returns
5092 ///
5093 /// Complete current or terminal factory run envelope.
5094 ///
5095 /// <div class="warning">
5096 ///
5097 /// **Experimental.** This API is part of an experimental wire-protocol surface
5098 /// and may change or be removed in future SDK or CLI releases. Pin both the
5099 /// SDK and CLI versions if your code depends on it.
5100 ///
5101 /// </div>
5102 pub async fn cancel(&self, params: FactoryCancelRequest) -> Result<FactoryRunResult, Error> {
5103 let mut wire_params = serde_json::to_value(params)?;
5104 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5105 let _value = self
5106 .session
5107 .client()
5108 .call(rpc_methods::SESSION_FACTORY_CANCEL, Some(wire_params))
5109 .await?;
5110 Ok(serde_json::from_value(_value)?)
5111 }
5112
5113 /// Pauses a running factory and returns its settled run envelope.
5114 ///
5115 /// Wire method: `session.factory.pause`.
5116 ///
5117 /// # Parameters
5118 ///
5119 /// * `params` - Parameters for pausing a running factory.
5120 ///
5121 /// # Returns
5122 ///
5123 /// Complete current or terminal factory run envelope.
5124 ///
5125 /// <div class="warning">
5126 ///
5127 /// **Experimental.** This API is part of an experimental wire-protocol surface
5128 /// and may change or be removed in future SDK or CLI releases. Pin both the
5129 /// SDK and CLI versions if your code depends on it.
5130 ///
5131 /// </div>
5132 pub async fn pause(&self, params: FactoryPauseRequest) -> Result<FactoryRunResult, Error> {
5133 let mut wire_params = serde_json::to_value(params)?;
5134 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5135 let _value = self
5136 .session
5137 .client()
5138 .call(rpc_methods::SESSION_FACTORY_PAUSE, Some(wire_params))
5139 .await?;
5140 Ok(serde_json::from_value(_value)?)
5141 }
5142
5143 /// Atomically pauses an owned factory attempt at a durable checkpoint.
5144 ///
5145 /// Wire method: `session.factory.pauseAtCheckpoint`.
5146 ///
5147 /// # Parameters
5148 ///
5149 /// * `params` - Parameters for an owned durable pause checkpoint.
5150 ///
5151 /// <div class="warning">
5152 ///
5153 /// **Experimental.** This API is part of an experimental wire-protocol surface
5154 /// and may change or be removed in future SDK or CLI releases. Pin both the
5155 /// SDK and CLI versions if your code depends on it.
5156 ///
5157 /// </div>
5158 pub(crate) async fn pause_at_checkpoint(
5159 &self,
5160 params: FactoryPauseCheckpointRequest,
5161 ) -> Result<FactoryPauseCheckpointResult, Error> {
5162 let mut wire_params = serde_json::to_value(params)?;
5163 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5164 let _value = self
5165 .session
5166 .client()
5167 .call(
5168 rpc_methods::SESSION_FACTORY_PAUSEATCHECKPOINT,
5169 Some(wire_params),
5170 )
5171 .await?;
5172 Ok(serde_json::from_value(_value)?)
5173 }
5174
5175 /// Records a batch of ordered factory progress lines.
5176 ///
5177 /// Wire method: `session.factory.log`.
5178 ///
5179 /// # Parameters
5180 ///
5181 /// * `params` - Parameters for recording factory progress.
5182 ///
5183 /// # Returns
5184 ///
5185 /// Acknowledgement that a factory request was accepted.
5186 ///
5187 /// <div class="warning">
5188 ///
5189 /// **Experimental.** This API is part of an experimental wire-protocol surface
5190 /// and may change or be removed in future SDK or CLI releases. Pin both the
5191 /// SDK and CLI versions if your code depends on it.
5192 ///
5193 /// </div>
5194 pub async fn log(&self, params: FactoryLogRequest) -> Result<FactoryAckResult, Error> {
5195 let mut wire_params = serde_json::to_value(params)?;
5196 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5197 let _value = self
5198 .session
5199 .client()
5200 .call(rpc_methods::SESSION_FACTORY_LOG, Some(wire_params))
5201 .await?;
5202 Ok(serde_json::from_value(_value)?)
5203 }
5204
5205 /// Runs one factory-scoped subagent and returns its result.
5206 ///
5207 /// Wire method: `session.factory.agent`.
5208 ///
5209 /// # Parameters
5210 ///
5211 /// * `params` - Parameters for one factory-scoped subagent call.
5212 ///
5213 /// # Returns
5214 ///
5215 /// Result of one factory-scoped subagent call.
5216 ///
5217 /// <div class="warning">
5218 ///
5219 /// **Experimental.** This API is part of an experimental wire-protocol surface
5220 /// and may change or be removed in future SDK or CLI releases. Pin both the
5221 /// SDK and CLI versions if your code depends on it.
5222 ///
5223 /// </div>
5224 pub async fn agent(&self, params: FactoryAgentRequest) -> Result<FactoryAgentResult, Error> {
5225 let mut wire_params = serde_json::to_value(params)?;
5226 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5227 let _value = self
5228 .session
5229 .client()
5230 .call(rpc_methods::SESSION_FACTORY_AGENT, Some(wire_params))
5231 .await?;
5232 Ok(serde_json::from_value(_value)?)
5233 }
5234}
5235
5236/// `session.factory.journal.*` RPCs.
5237#[derive(Clone, Copy)]
5238pub struct SessionRpcFactoryJournal<'a> {
5239 pub(crate) session: &'a Session,
5240}
5241
5242impl<'a> SessionRpcFactoryJournal<'a> {
5243 /// Reads a memoized factory journal entry.
5244 ///
5245 /// Wire method: `session.factory.journal.get`.
5246 ///
5247 /// # Parameters
5248 ///
5249 /// * `params` - Parameters for reading a factory journal entry.
5250 ///
5251 /// # Returns
5252 ///
5253 /// Result of reading a factory journal entry.
5254 ///
5255 /// <div class="warning">
5256 ///
5257 /// **Experimental.** This API is part of an experimental wire-protocol surface
5258 /// and may change or be removed in future SDK or CLI releases. Pin both the
5259 /// SDK and CLI versions if your code depends on it.
5260 ///
5261 /// </div>
5262 pub async fn get(
5263 &self,
5264 params: FactoryJournalGetRequest,
5265 ) -> Result<FactoryJournalGetResult, Error> {
5266 let mut wire_params = serde_json::to_value(params)?;
5267 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5268 let _value = self
5269 .session
5270 .client()
5271 .call(rpc_methods::SESSION_FACTORY_JOURNAL_GET, Some(wire_params))
5272 .await?;
5273 Ok(serde_json::from_value(_value)?)
5274 }
5275
5276 /// Stores a memoized factory journal entry.
5277 ///
5278 /// Wire method: `session.factory.journal.put`.
5279 ///
5280 /// # Parameters
5281 ///
5282 /// * `params` - Parameters for storing a factory journal entry.
5283 ///
5284 /// # Returns
5285 ///
5286 /// Acknowledgement that a factory request was accepted.
5287 ///
5288 /// <div class="warning">
5289 ///
5290 /// **Experimental.** This API is part of an experimental wire-protocol surface
5291 /// and may change or be removed in future SDK or CLI releases. Pin both the
5292 /// SDK and CLI versions if your code depends on it.
5293 ///
5294 /// </div>
5295 pub async fn put(&self, params: FactoryJournalPutRequest) -> Result<FactoryAckResult, Error> {
5296 let mut wire_params = serde_json::to_value(params)?;
5297 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5298 let _value = self
5299 .session
5300 .client()
5301 .call(rpc_methods::SESSION_FACTORY_JOURNAL_PUT, Some(wire_params))
5302 .await?;
5303 Ok(serde_json::from_value(_value)?)
5304 }
5305}
5306
5307/// `session.fleet.*` RPCs.
5308#[derive(Clone, Copy)]
5309pub struct SessionRpcFleet<'a> {
5310 pub(crate) session: &'a Session,
5311}
5312
5313impl<'a> SessionRpcFleet<'a> {
5314 /// Starts fleet mode by submitting the fleet orchestration prompt to the session.
5315 ///
5316 /// Wire method: `session.fleet.start`.
5317 ///
5318 /// # Parameters
5319 ///
5320 /// * `params` - Parameters for starting fleet orchestration: an optional user prompt combined with the fleet instructions, plus the send options forwarded to the resulting turn.
5321 ///
5322 /// # Returns
5323 ///
5324 /// Indicates whether fleet mode was successfully activated.
5325 ///
5326 /// <div class="warning">
5327 ///
5328 /// **Experimental.** This API is part of an experimental wire-protocol surface
5329 /// and may change or be removed in future SDK or CLI releases. Pin both the
5330 /// SDK and CLI versions if your code depends on it.
5331 ///
5332 /// </div>
5333 pub async fn start(&self, params: FleetStartRequest) -> Result<FleetStartResult, Error> {
5334 let mut wire_params = serde_json::to_value(params)?;
5335 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5336 let _value = self
5337 .session
5338 .client()
5339 .call(rpc_methods::SESSION_FLEET_START, Some(wire_params))
5340 .await?;
5341 Ok(serde_json::from_value(_value)?)
5342 }
5343}
5344
5345/// `session.gitHubAuth.*` RPCs.
5346#[derive(Clone, Copy)]
5347pub struct SessionRpcGitHubAuth<'a> {
5348 pub(crate) session: &'a Session,
5349}
5350
5351impl<'a> SessionRpcGitHubAuth<'a> {
5352 /// Gets authentication status and account metadata for the session.
5353 ///
5354 /// Wire method: `session.gitHubAuth.getStatus`.
5355 ///
5356 /// # Returns
5357 ///
5358 /// Authentication status and account metadata for the session.
5359 ///
5360 /// <div class="warning">
5361 ///
5362 /// **Experimental.** This API is part of an experimental wire-protocol surface
5363 /// and may change or be removed in future SDK or CLI releases. Pin both the
5364 /// SDK and CLI versions if your code depends on it.
5365 ///
5366 /// </div>
5367 pub async fn get_status(&self) -> Result<SessionAuthStatus, Error> {
5368 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5369 let _value = self
5370 .session
5371 .client()
5372 .call(rpc_methods::SESSION_GITHUBAUTH_GETSTATUS, Some(wire_params))
5373 .await?;
5374 Ok(serde_json::from_value(_value)?)
5375 }
5376
5377 /// Updates the session's auth credentials used for outbound model and API requests.
5378 ///
5379 /// Wire method: `session.gitHubAuth.setCredentials`.
5380 ///
5381 /// # Parameters
5382 ///
5383 /// * `params` - New auth credentials to install on the session. Omit to leave credentials unchanged.
5384 ///
5385 /// # Returns
5386 ///
5387 /// Indicates whether the credential update succeeded.
5388 ///
5389 /// <div class="warning">
5390 ///
5391 /// **Experimental.** This API is part of an experimental wire-protocol surface
5392 /// and may change or be removed in future SDK or CLI releases. Pin both the
5393 /// SDK and CLI versions if your code depends on it.
5394 ///
5395 /// </div>
5396 pub async fn set_credentials(
5397 &self,
5398 params: SessionSetCredentialsParams,
5399 ) -> Result<SessionSetCredentialsResult, Error> {
5400 let mut wire_params = serde_json::to_value(params)?;
5401 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5402 let _value = self
5403 .session
5404 .client()
5405 .call(
5406 rpc_methods::SESSION_GITHUBAUTH_SETCREDENTIALS,
5407 Some(wire_params),
5408 )
5409 .await?;
5410 Ok(serde_json::from_value(_value)?)
5411 }
5412
5413 /// Gets the current authentication information for internal session hosts.
5414 ///
5415 /// Wire method: `session.gitHubAuth.getCurrentAuthInfo`.
5416 ///
5417 /// # Returns
5418 ///
5419 /// Current authentication information, or null when no authentication is active.
5420 ///
5421 /// <div class="warning">
5422 ///
5423 /// **Experimental.** This API is part of an experimental wire-protocol surface
5424 /// and may change or be removed in future SDK or CLI releases. Pin both the
5425 /// SDK and CLI versions if your code depends on it.
5426 ///
5427 /// </div>
5428 pub(crate) async fn get_current_auth_info(&self) -> Result<SessionAuthInfoResult, Error> {
5429 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5430 let _value = self
5431 .session
5432 .client()
5433 .call(
5434 rpc_methods::SESSION_GITHUBAUTH_GETCURRENTAUTHINFO,
5435 Some(wire_params),
5436 )
5437 .await?;
5438 Ok(serde_json::from_value(_value)?)
5439 }
5440
5441 /// Gets all authentication accounts available to the internal session host.
5442 ///
5443 /// Wire method: `session.gitHubAuth.getAllAuthAvailable`.
5444 ///
5445 /// # Returns
5446 ///
5447 /// Authentication accounts available to the internal session host.
5448 ///
5449 /// <div class="warning">
5450 ///
5451 /// **Experimental.** This API is part of an experimental wire-protocol surface
5452 /// and may change or be removed in future SDK or CLI releases. Pin both the
5453 /// SDK and CLI versions if your code depends on it.
5454 ///
5455 /// </div>
5456 pub(crate) async fn get_all_auth_available(
5457 &self,
5458 ) -> Result<SessionGitHubAuthGetAllAuthAvailableResult, Error> {
5459 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5460 let _value = self
5461 .session
5462 .client()
5463 .call(
5464 rpc_methods::SESSION_GITHUBAUTH_GETALLAUTHAVAILABLE,
5465 Some(wire_params),
5466 )
5467 .await?;
5468 Ok(serde_json::from_value(_value)?)
5469 }
5470
5471 /// Refreshes Copilot account metadata for the current authentication.
5472 ///
5473 /// Wire method: `session.gitHubAuth.refreshCopilotUser`.
5474 ///
5475 /// # Returns
5476 ///
5477 /// Current authentication information, or null when no authentication is active.
5478 ///
5479 /// <div class="warning">
5480 ///
5481 /// **Experimental.** This API is part of an experimental wire-protocol surface
5482 /// and may change or be removed in future SDK or CLI releases. Pin both the
5483 /// SDK and CLI versions if your code depends on it.
5484 ///
5485 /// </div>
5486 pub(crate) async fn refresh_copilot_user(&self) -> Result<SessionAuthInfoResult, Error> {
5487 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5488 let _value = self
5489 .session
5490 .client()
5491 .call(
5492 rpc_methods::SESSION_GITHUBAUTH_REFRESHCOPILOTUSER,
5493 Some(wire_params),
5494 )
5495 .await?;
5496 Ok(serde_json::from_value(_value)?)
5497 }
5498
5499 /// Logs in a GitHub user through the internal session host.
5500 ///
5501 /// Wire method: `session.gitHubAuth.login`.
5502 ///
5503 /// # Parameters
5504 ///
5505 /// * `params` - Internal GitHub login parameters.
5506 ///
5507 /// # Returns
5508 ///
5509 /// Authentication credentials accepted only at native protocol ingress. Runtime outputs use credential-free `AuthIdentity` metadata.
5510 ///
5511 /// <div class="warning">
5512 ///
5513 /// **Experimental.** This API is part of an experimental wire-protocol surface
5514 /// and may change or be removed in future SDK or CLI releases. Pin both the
5515 /// SDK and CLI versions if your code depends on it.
5516 ///
5517 /// </div>
5518 pub(crate) async fn login(&self, params: SessionAuthLoginRequest) -> Result<AuthInfo, Error> {
5519 let mut wire_params = serde_json::to_value(params)?;
5520 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5521 let _value = self
5522 .session
5523 .client()
5524 .call(rpc_methods::SESSION_GITHUBAUTH_LOGIN, Some(wire_params))
5525 .await?;
5526 Ok(serde_json::from_value(_value)?)
5527 }
5528
5529 /// Switches the session to another available authentication.
5530 ///
5531 /// Wire method: `session.gitHubAuth.switchToAuth`.
5532 ///
5533 /// # Parameters
5534 ///
5535 /// * `params` - Parameters for switching the session's active authentication.
5536 ///
5537 /// <div class="warning">
5538 ///
5539 /// **Experimental.** This API is part of an experimental wire-protocol surface
5540 /// and may change or be removed in future SDK or CLI releases. Pin both the
5541 /// SDK and CLI versions if your code depends on it.
5542 ///
5543 /// </div>
5544 pub(crate) async fn switch_to_auth(
5545 &self,
5546 params: SessionAuthSwitchRequest,
5547 ) -> Result<(), Error> {
5548 let mut wire_params = serde_json::to_value(params)?;
5549 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5550 let _value = self
5551 .session
5552 .client()
5553 .call(
5554 rpc_methods::SESSION_GITHUBAUTH_SWITCHTOAUTH,
5555 Some(wire_params),
5556 )
5557 .await?;
5558 Ok(())
5559 }
5560
5561 /// Logs out the session's current GitHub authentication.
5562 ///
5563 /// Wire method: `session.gitHubAuth.logout`.
5564 ///
5565 /// # Returns
5566 ///
5567 /// Whether the current authentication was logged out.
5568 ///
5569 /// <div class="warning">
5570 ///
5571 /// **Experimental.** This API is part of an experimental wire-protocol surface
5572 /// and may change or be removed in future SDK or CLI releases. Pin both the
5573 /// SDK and CLI versions if your code depends on it.
5574 ///
5575 /// </div>
5576 pub(crate) async fn logout(&self) -> Result<SessionGitHubAuthLogoutResult, Error> {
5577 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5578 let _value = self
5579 .session
5580 .client()
5581 .call(rpc_methods::SESSION_GITHUBAUTH_LOGOUT, Some(wire_params))
5582 .await?;
5583 Ok(serde_json::from_value(_value)?)
5584 }
5585
5586 /// Logs out a specific GitHub authentication.
5587 ///
5588 /// Wire method: `session.gitHubAuth.logoutUser`.
5589 ///
5590 /// # Parameters
5591 ///
5592 /// * `params` - Parameters identifying a GitHub authentication to log out.
5593 ///
5594 /// # Returns
5595 ///
5596 /// Whether the requested authentication was logged out.
5597 ///
5598 /// <div class="warning">
5599 ///
5600 /// **Experimental.** This API is part of an experimental wire-protocol surface
5601 /// and may change or be removed in future SDK or CLI releases. Pin both the
5602 /// SDK and CLI versions if your code depends on it.
5603 ///
5604 /// </div>
5605 pub(crate) async fn logout_user(
5606 &self,
5607 params: SessionAuthLogoutUserRequest,
5608 ) -> Result<SessionGitHubAuthLogoutUserResult, Error> {
5609 let mut wire_params = serde_json::to_value(params)?;
5610 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5611 let _value = self
5612 .session
5613 .client()
5614 .call(
5615 rpc_methods::SESSION_GITHUBAUTH_LOGOUTUSER,
5616 Some(wire_params),
5617 )
5618 .await?;
5619 Ok(serde_json::from_value(_value)?)
5620 }
5621
5622 /// Gets validation errors from the most recent authentication attempt.
5623 ///
5624 /// Wire method: `session.gitHubAuth.lastAuthErrors`.
5625 ///
5626 /// # Returns
5627 ///
5628 /// Validation errors from the most recent authentication attempt.
5629 ///
5630 /// <div class="warning">
5631 ///
5632 /// **Experimental.** This API is part of an experimental wire-protocol surface
5633 /// and may change or be removed in future SDK or CLI releases. Pin both the
5634 /// SDK and CLI versions if your code depends on it.
5635 ///
5636 /// </div>
5637 pub(crate) async fn last_auth_errors(&self) -> Result<AuthValidationErrors, Error> {
5638 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5639 let _value = self
5640 .session
5641 .client()
5642 .call(
5643 rpc_methods::SESSION_GITHUBAUTH_LASTAUTHERRORS,
5644 Some(wire_params),
5645 )
5646 .await?;
5647 Ok(serde_json::from_value(_value)?)
5648 }
5649}
5650
5651/// `session.history.*` RPCs.
5652#[derive(Clone, Copy)]
5653pub struct SessionRpcHistory<'a> {
5654 pub(crate) session: &'a Session,
5655}
5656
5657impl<'a> SessionRpcHistory<'a> {
5658 /// Compacts the session history to reduce context usage.
5659 ///
5660 /// Wire method: `session.history.compact`.
5661 ///
5662 /// # Returns
5663 ///
5664 /// Compaction outcome with the number of tokens and messages removed, summary text, and the resulting context window breakdown.
5665 ///
5666 /// <div class="warning">
5667 ///
5668 /// **Experimental.** This API is part of an experimental wire-protocol surface
5669 /// and may change or be removed in future SDK or CLI releases. Pin both the
5670 /// SDK and CLI versions if your code depends on it.
5671 ///
5672 /// </div>
5673 pub async fn compact(&self) -> Result<HistoryCompactResult, Error> {
5674 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5675 let _value = self
5676 .session
5677 .client()
5678 .call(rpc_methods::SESSION_HISTORY_COMPACT, Some(wire_params))
5679 .await?;
5680 Ok(serde_json::from_value(_value)?)
5681 }
5682
5683 /// Compacts the session history to reduce context usage.
5684 ///
5685 /// Wire method: `session.history.compact`.
5686 ///
5687 /// # Parameters
5688 ///
5689 /// * `params` - Optional compaction parameters.
5690 ///
5691 /// # Returns
5692 ///
5693 /// Compaction outcome with the number of tokens and messages removed, summary text, and the resulting context window breakdown.
5694 ///
5695 /// <div class="warning">
5696 ///
5697 /// **Experimental.** This API is part of an experimental wire-protocol surface
5698 /// and may change or be removed in future SDK or CLI releases. Pin both the
5699 /// SDK and CLI versions if your code depends on it.
5700 ///
5701 /// </div>
5702 pub async fn compact_with_params(
5703 &self,
5704 params: HistoryCompactRequest,
5705 ) -> Result<HistoryCompactResult, Error> {
5706 let mut wire_params = serde_json::to_value(params)?;
5707 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5708 let _value = self
5709 .session
5710 .client()
5711 .call(rpc_methods::SESSION_HISTORY_COMPACT, Some(wire_params))
5712 .await?;
5713 Ok(serde_json::from_value(_value)?)
5714 }
5715
5716 /// Truncates persisted session history to a specific event.
5717 ///
5718 /// Wire method: `session.history.truncate`.
5719 ///
5720 /// # Parameters
5721 ///
5722 /// * `params` - Identifier of the event to truncate to; this event and all later events are removed.
5723 ///
5724 /// # Returns
5725 ///
5726 /// Number of events that were removed by the truncation.
5727 ///
5728 /// <div class="warning">
5729 ///
5730 /// **Experimental.** This API is part of an experimental wire-protocol surface
5731 /// and may change or be removed in future SDK or CLI releases. Pin both the
5732 /// SDK and CLI versions if your code depends on it.
5733 ///
5734 /// </div>
5735 pub async fn truncate(
5736 &self,
5737 params: HistoryTruncateRequest,
5738 ) -> Result<HistoryTruncateResult, Error> {
5739 let mut wire_params = serde_json::to_value(params)?;
5740 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5741 let _value = self
5742 .session
5743 .client()
5744 .call(rpc_methods::SESSION_HISTORY_TRUNCATE, Some(wire_params))
5745 .await?;
5746 Ok(serde_json::from_value(_value)?)
5747 }
5748
5749 /// 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.
5750 ///
5751 /// Wire method: `session.history.listRewindPoints`.
5752 ///
5753 /// # Returns
5754 ///
5755 /// Rewind points and file-change-tracking availability for the session.
5756 ///
5757 /// <div class="warning">
5758 ///
5759 /// **Experimental.** This API is part of an experimental wire-protocol surface
5760 /// and may change or be removed in future SDK or CLI releases. Pin both the
5761 /// SDK and CLI versions if your code depends on it.
5762 ///
5763 /// </div>
5764 pub async fn list_rewind_points(&self) -> Result<HistoryListRewindPointsResult, Error> {
5765 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5766 let _value = self
5767 .session
5768 .client()
5769 .call(
5770 rpc_methods::SESSION_HISTORY_LISTREWINDPOINTS,
5771 Some(wire_params),
5772 )
5773 .await?;
5774 Ok(serde_json::from_value(_value)?)
5775 }
5776
5777 /// Previews the files that a conversation-and-files rewind would restore.
5778 ///
5779 /// Wire method: `session.history.previewRewind`.
5780 ///
5781 /// # Parameters
5782 ///
5783 /// * `params` - Event boundary to preview for conversation-and-files rewind.
5784 ///
5785 /// # Returns
5786 ///
5787 /// Files and aggregate changes for a prospective rewind.
5788 ///
5789 /// <div class="warning">
5790 ///
5791 /// **Experimental.** This API is part of an experimental wire-protocol surface
5792 /// and may change or be removed in future SDK or CLI releases. Pin both the
5793 /// SDK and CLI versions if your code depends on it.
5794 ///
5795 /// </div>
5796 pub async fn preview_rewind(
5797 &self,
5798 params: HistoryPreviewRewindRequest,
5799 ) -> Result<HistoryPreviewRewindResult, Error> {
5800 let mut wire_params = serde_json::to_value(params)?;
5801 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5802 let _value = self
5803 .session
5804 .client()
5805 .call(
5806 rpc_methods::SESSION_HISTORY_PREVIEWREWIND,
5807 Some(wire_params),
5808 )
5809 .await?;
5810 Ok(serde_json::from_value(_value)?)
5811 }
5812
5813 /// 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.
5814 ///
5815 /// Wire method: `session.history.rewind`.
5816 ///
5817 /// # Parameters
5818 ///
5819 /// * `params` - Boundary and mode for rewinding session history.
5820 ///
5821 /// # Returns
5822 ///
5823 /// Structured outcome of a rewind request.
5824 ///
5825 /// <div class="warning">
5826 ///
5827 /// **Experimental.** This API is part of an experimental wire-protocol surface
5828 /// and may change or be removed in future SDK or CLI releases. Pin both the
5829 /// SDK and CLI versions if your code depends on it.
5830 ///
5831 /// </div>
5832 pub async fn rewind(&self, params: HistoryRewindRequest) -> Result<HistoryRewindResult, Error> {
5833 let mut wire_params = serde_json::to_value(params)?;
5834 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5835 let _value = self
5836 .session
5837 .client()
5838 .call(rpc_methods::SESSION_HISTORY_REWIND, Some(wire_params))
5839 .await?;
5840 Ok(serde_json::from_value(_value)?)
5841 }
5842
5843 /// Cancels any in-progress background compaction on a local session.
5844 ///
5845 /// Wire method: `session.history.cancelBackgroundCompaction`.
5846 ///
5847 /// # Returns
5848 ///
5849 /// Indicates whether an in-progress background compaction was cancelled.
5850 ///
5851 /// <div class="warning">
5852 ///
5853 /// **Experimental.** This API is part of an experimental wire-protocol surface
5854 /// and may change or be removed in future SDK or CLI releases. Pin both the
5855 /// SDK and CLI versions if your code depends on it.
5856 ///
5857 /// </div>
5858 pub async fn cancel_background_compaction(
5859 &self,
5860 ) -> Result<HistoryCancelBackgroundCompactionResult, Error> {
5861 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5862 let _value = self
5863 .session
5864 .client()
5865 .call(
5866 rpc_methods::SESSION_HISTORY_CANCELBACKGROUNDCOMPACTION,
5867 Some(wire_params),
5868 )
5869 .await?;
5870 Ok(serde_json::from_value(_value)?)
5871 }
5872
5873 /// Aborts any in-progress manual compaction on a local session.
5874 ///
5875 /// Wire method: `session.history.abortManualCompaction`.
5876 ///
5877 /// # Returns
5878 ///
5879 /// Indicates whether an in-progress manual compaction was aborted.
5880 ///
5881 /// <div class="warning">
5882 ///
5883 /// **Experimental.** This API is part of an experimental wire-protocol surface
5884 /// and may change or be removed in future SDK or CLI releases. Pin both the
5885 /// SDK and CLI versions if your code depends on it.
5886 ///
5887 /// </div>
5888 pub async fn abort_manual_compaction(
5889 &self,
5890 ) -> Result<HistoryAbortManualCompactionResult, Error> {
5891 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5892 let _value = self
5893 .session
5894 .client()
5895 .call(
5896 rpc_methods::SESSION_HISTORY_ABORTMANUALCOMPACTION,
5897 Some(wire_params),
5898 )
5899 .await?;
5900 Ok(serde_json::from_value(_value)?)
5901 }
5902
5903 /// Produces a markdown summary of the session's conversation context for hand-off scenarios.
5904 ///
5905 /// Wire method: `session.history.summarizeForHandoff`.
5906 ///
5907 /// # Returns
5908 ///
5909 /// Markdown summary of the conversation context (empty when not available).
5910 ///
5911 /// <div class="warning">
5912 ///
5913 /// **Experimental.** This API is part of an experimental wire-protocol surface
5914 /// and may change or be removed in future SDK or CLI releases. Pin both the
5915 /// SDK and CLI versions if your code depends on it.
5916 ///
5917 /// </div>
5918 pub async fn summarize_for_handoff(&self) -> Result<HistorySummarizeForHandoffResult, Error> {
5919 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5920 let _value = self
5921 .session
5922 .client()
5923 .call(
5924 rpc_methods::SESSION_HISTORY_SUMMARIZEFORHANDOFF,
5925 Some(wire_params),
5926 )
5927 .await?;
5928 Ok(serde_json::from_value(_value)?)
5929 }
5930
5931 /// 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.
5932 ///
5933 /// Wire method: `session.history.clearContext`.
5934 ///
5935 /// # Parameters
5936 ///
5937 /// * `params` - Parameters for clearing the conversation and seeding the window that replaces it.
5938 ///
5939 /// # Returns
5940 ///
5941 /// What a successful clear removed. A clear that could not be applied rejects instead of reporting a count.
5942 ///
5943 /// <div class="warning">
5944 ///
5945 /// **Experimental.** This API is part of an experimental wire-protocol surface
5946 /// and may change or be removed in future SDK or CLI releases. Pin both the
5947 /// SDK and CLI versions if your code depends on it.
5948 ///
5949 /// </div>
5950 pub async fn clear_context(
5951 &self,
5952 params: HistoryClearContextRequest,
5953 ) -> Result<HistoryClearContextResult, Error> {
5954 let mut wire_params = serde_json::to_value(params)?;
5955 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5956 let _value = self
5957 .session
5958 .client()
5959 .call(rpc_methods::SESSION_HISTORY_CLEARCONTEXT, Some(wire_params))
5960 .await?;
5961 Ok(serde_json::from_value(_value)?)
5962 }
5963}
5964
5965/// `session.instructions.*` RPCs.
5966#[derive(Clone, Copy)]
5967pub struct SessionRpcInstructions<'a> {
5968 pub(crate) session: &'a Session,
5969}
5970
5971impl<'a> SessionRpcInstructions<'a> {
5972 /// Gets instruction sources loaded for the session.
5973 ///
5974 /// Wire method: `session.instructions.getSources`.
5975 ///
5976 /// # Returns
5977 ///
5978 /// Instruction sources loaded for the session, in merge order.
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 get_sources(&self) -> Result<InstructionsGetSourcesResult, Error> {
5988 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5989 let _value = self
5990 .session
5991 .client()
5992 .call(
5993 rpc_methods::SESSION_INSTRUCTIONS_GETSOURCES,
5994 Some(wire_params),
5995 )
5996 .await?;
5997 Ok(serde_json::from_value(_value)?)
5998 }
5999}
6000
6001/// `session.limitPrediction.*` RPCs.
6002#[derive(Clone, Copy)]
6003pub struct SessionRpcLimitPrediction<'a> {
6004 pub(crate) session: &'a Session,
6005}
6006
6007impl<'a> SessionRpcLimitPrediction<'a> {
6008 /// 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.
6009 ///
6010 /// Wire method: `session.limitPrediction.predict`.
6011 ///
6012 /// # Returns
6013 ///
6014 /// Prediction result. Available results include prediction details; unavailable results include an explicit reason.
6015 ///
6016 /// <div class="warning">
6017 ///
6018 /// **Experimental.** This API is part of an experimental wire-protocol surface
6019 /// and may change or be removed in future SDK or CLI releases. Pin both the
6020 /// SDK and CLI versions if your code depends on it.
6021 ///
6022 /// </div>
6023 pub async fn predict(&self) -> Result<SessionLimitPredictionResult, Error> {
6024 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6025 let _value = self
6026 .session
6027 .client()
6028 .call(
6029 rpc_methods::SESSION_LIMITPREDICTION_PREDICT,
6030 Some(wire_params),
6031 )
6032 .await?;
6033 Ok(serde_json::from_value(_value)?)
6034 }
6035
6036 /// 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.
6037 ///
6038 /// Wire method: `session.limitPrediction.predict`.
6039 ///
6040 /// # Parameters
6041 ///
6042 /// * `params` - Parameters for predicting an AI-credit session limit. Omitting `modelId` uses the session's currently selected model.
6043 ///
6044 /// # Returns
6045 ///
6046 /// Prediction result. Available results include prediction details; unavailable results include an explicit reason.
6047 ///
6048 /// <div class="warning">
6049 ///
6050 /// **Experimental.** This API is part of an experimental wire-protocol surface
6051 /// and may change or be removed in future SDK or CLI releases. Pin both the
6052 /// SDK and CLI versions if your code depends on it.
6053 ///
6054 /// </div>
6055 pub async fn predict_with_params(
6056 &self,
6057 params: SessionLimitPredictionRequest,
6058 ) -> Result<SessionLimitPredictionResult, Error> {
6059 let mut wire_params = serde_json::to_value(params)?;
6060 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6061 let _value = self
6062 .session
6063 .client()
6064 .call(
6065 rpc_methods::SESSION_LIMITPREDICTION_PREDICT,
6066 Some(wire_params),
6067 )
6068 .await?;
6069 Ok(serde_json::from_value(_value)?)
6070 }
6071}
6072
6073/// `session.lsp.*` RPCs.
6074#[derive(Clone, Copy)]
6075pub struct SessionRpcLsp<'a> {
6076 pub(crate) session: &'a Session,
6077}
6078
6079impl<'a> SessionRpcLsp<'a> {
6080 /// Loads the merged LSP configuration set for the session's working directory.
6081 ///
6082 /// Wire method: `session.lsp.initialize`.
6083 ///
6084 /// # Parameters
6085 ///
6086 /// * `params` - Parameters for (re)loading the merged LSP configuration set.
6087 ///
6088 /// <div class="warning">
6089 ///
6090 /// **Experimental.** This API is part of an experimental wire-protocol surface
6091 /// and may change or be removed in future SDK or CLI releases. Pin both the
6092 /// SDK and CLI versions if your code depends on it.
6093 ///
6094 /// </div>
6095 pub async fn initialize(&self, params: LspInitializeRequest) -> Result<(), Error> {
6096 let mut wire_params = serde_json::to_value(params)?;
6097 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6098 let _value = self
6099 .session
6100 .client()
6101 .call(rpc_methods::SESSION_LSP_INITIALIZE, Some(wire_params))
6102 .await?;
6103 Ok(())
6104 }
6105}
6106
6107/// `session.mcp.*` RPCs.
6108#[derive(Clone, Copy)]
6109pub struct SessionRpcMcp<'a> {
6110 pub(crate) session: &'a Session,
6111}
6112
6113impl<'a> SessionRpcMcp<'a> {
6114 /// `session.mcp.apps.*` sub-namespace.
6115 pub fn apps(&self) -> SessionRpcMcpApps<'a> {
6116 SessionRpcMcpApps {
6117 session: self.session,
6118 }
6119 }
6120
6121 /// `session.mcp.headers.*` sub-namespace.
6122 pub fn headers(&self) -> SessionRpcMcpHeaders<'a> {
6123 SessionRpcMcpHeaders {
6124 session: self.session,
6125 }
6126 }
6127
6128 /// `session.mcp.oauth.*` sub-namespace.
6129 pub fn oauth(&self) -> SessionRpcMcpOauth<'a> {
6130 SessionRpcMcpOauth {
6131 session: self.session,
6132 }
6133 }
6134
6135 /// `session.mcp.resources.*` sub-namespace.
6136 pub fn resources(&self) -> SessionRpcMcpResources<'a> {
6137 SessionRpcMcpResources {
6138 session: self.session,
6139 }
6140 }
6141
6142 /// 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.
6143 ///
6144 /// Wire method: `session.mcp.list`.
6145 ///
6146 /// # Returns
6147 ///
6148 /// MCP servers configured for the session, with their connection status and host-level state.
6149 ///
6150 /// <div class="warning">
6151 ///
6152 /// **Experimental.** This API is part of an experimental wire-protocol surface
6153 /// and may change or be removed in future SDK or CLI releases. Pin both the
6154 /// SDK and CLI versions if your code depends on it.
6155 ///
6156 /// </div>
6157 pub async fn list(&self) -> Result<McpServerList, Error> {
6158 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6159 let _value = self
6160 .session
6161 .client()
6162 .call(rpc_methods::SESSION_MCP_LIST, Some(wire_params))
6163 .await?;
6164 Ok(serde_json::from_value(_value)?)
6165 }
6166
6167 /// 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.
6168 ///
6169 /// Wire method: `session.mcp.listTools`.
6170 ///
6171 /// # Parameters
6172 ///
6173 /// * `params` - Server name whose tool list should be returned.
6174 ///
6175 /// # Returns
6176 ///
6177 /// Tools exposed by the connected MCP server. Throws when the server is not connected.
6178 ///
6179 /// <div class="warning">
6180 ///
6181 /// **Experimental.** This API is part of an experimental wire-protocol surface
6182 /// and may change or be removed in future SDK or CLI releases. Pin both the
6183 /// SDK and CLI versions if your code depends on it.
6184 ///
6185 /// </div>
6186 pub async fn list_tools(
6187 &self,
6188 params: McpListToolsRequest,
6189 ) -> Result<McpListToolsResult, Error> {
6190 let mut wire_params = serde_json::to_value(params)?;
6191 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6192 let _value = self
6193 .session
6194 .client()
6195 .call(rpc_methods::SESSION_MCP_LISTTOOLS, Some(wire_params))
6196 .await?;
6197 Ok(serde_json::from_value(_value)?)
6198 }
6199
6200 /// Enables an MCP server for the session.
6201 ///
6202 /// Wire method: `session.mcp.enable`.
6203 ///
6204 /// # Parameters
6205 ///
6206 /// * `params` - Name of the MCP server to enable for the session.
6207 ///
6208 /// <div class="warning">
6209 ///
6210 /// **Experimental.** This API is part of an experimental wire-protocol surface
6211 /// and may change or be removed in future SDK or CLI releases. Pin both the
6212 /// SDK and CLI versions if your code depends on it.
6213 ///
6214 /// </div>
6215 pub async fn enable(&self, params: McpEnableRequest) -> Result<(), Error> {
6216 let mut wire_params = serde_json::to_value(params)?;
6217 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6218 let _value = self
6219 .session
6220 .client()
6221 .call(rpc_methods::SESSION_MCP_ENABLE, Some(wire_params))
6222 .await?;
6223 Ok(())
6224 }
6225
6226 /// Disables an MCP server for the session.
6227 ///
6228 /// Wire method: `session.mcp.disable`.
6229 ///
6230 /// # Parameters
6231 ///
6232 /// * `params` - Name of the MCP server to disable for the session.
6233 ///
6234 /// <div class="warning">
6235 ///
6236 /// **Experimental.** This API is part of an experimental wire-protocol surface
6237 /// and may change or be removed in future SDK or CLI releases. Pin both the
6238 /// SDK and CLI versions if your code depends on it.
6239 ///
6240 /// </div>
6241 pub async fn disable(&self, params: McpDisableRequest) -> Result<(), Error> {
6242 let mut wire_params = serde_json::to_value(params)?;
6243 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6244 let _value = self
6245 .session
6246 .client()
6247 .call(rpc_methods::SESSION_MCP_DISABLE, Some(wire_params))
6248 .await?;
6249 Ok(())
6250 }
6251
6252 /// Reloads MCP server connections for the session.
6253 ///
6254 /// Wire method: `session.mcp.reload`.
6255 ///
6256 /// <div class="warning">
6257 ///
6258 /// **Experimental.** This API is part of an experimental wire-protocol surface
6259 /// and may change or be removed in future SDK or CLI releases. Pin both the
6260 /// SDK and CLI versions if your code depends on it.
6261 ///
6262 /// </div>
6263 pub async fn reload(&self) -> Result<(), Error> {
6264 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6265 let _value = self
6266 .session
6267 .client()
6268 .call(rpc_methods::SESSION_MCP_RELOAD, Some(wire_params))
6269 .await?;
6270 Ok(())
6271 }
6272
6273 /// 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.
6274 ///
6275 /// Wire method: `session.mcp.moveLoadingToBackground`.
6276 ///
6277 /// # Returns
6278 ///
6279 /// Result of moving in-flight MCP loading to the background.
6280 ///
6281 /// <div class="warning">
6282 ///
6283 /// **Experimental.** This API is part of an experimental wire-protocol surface
6284 /// and may change or be removed in future SDK or CLI releases. Pin both the
6285 /// SDK and CLI versions if your code depends on it.
6286 ///
6287 /// </div>
6288 pub async fn move_loading_to_background(
6289 &self,
6290 ) -> Result<MoveMcpLoadingToBackgroundResult, Error> {
6291 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6292 let _value = self
6293 .session
6294 .client()
6295 .call(
6296 rpc_methods::SESSION_MCP_MOVELOADINGTOBACKGROUND,
6297 Some(wire_params),
6298 )
6299 .await?;
6300 Ok(serde_json::from_value(_value)?)
6301 }
6302
6303 /// Reloads MCP server connections for the session with an explicit host-provided configuration.
6304 ///
6305 /// Wire method: `session.mcp.reloadWithConfig`.
6306 ///
6307 /// # Parameters
6308 ///
6309 /// * `params` - Opaque MCP reload configuration.
6310 ///
6311 /// # Returns
6312 ///
6313 /// MCP server startup filtering result.
6314 ///
6315 /// <div class="warning">
6316 ///
6317 /// **Experimental.** This API is part of an experimental wire-protocol surface
6318 /// and may change or be removed in future SDK or CLI releases. Pin both the
6319 /// SDK and CLI versions if your code depends on it.
6320 ///
6321 /// </div>
6322 pub(crate) async fn reload_with_config(
6323 &self,
6324 params: McpReloadWithConfigRequest,
6325 ) -> Result<McpStartServersResult, Error> {
6326 let mut wire_params = serde_json::to_value(params)?;
6327 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6328 let _value = self
6329 .session
6330 .client()
6331 .call(rpc_methods::SESSION_MCP_RELOADWITHCONFIG, Some(wire_params))
6332 .await?;
6333 Ok(serde_json::from_value(_value)?)
6334 }
6335
6336 /// Runs an MCP sampling inference on behalf of an MCP server.
6337 ///
6338 /// Wire method: `session.mcp.executeSampling`.
6339 ///
6340 /// # Parameters
6341 ///
6342 /// * `params` - Identifiers and raw MCP CreateMessageRequest params used to run a sampling inference.
6343 ///
6344 /// # Returns
6345 ///
6346 /// Outcome of an MCP sampling execution: success result, failure error, or cancellation.
6347 ///
6348 /// <div class="warning">
6349 ///
6350 /// **Experimental.** This API is part of an experimental wire-protocol surface
6351 /// and may change or be removed in future SDK or CLI releases. Pin both the
6352 /// SDK and CLI versions if your code depends on it.
6353 ///
6354 /// </div>
6355 pub async fn execute_sampling(
6356 &self,
6357 params: McpExecuteSamplingParams,
6358 ) -> Result<McpSamplingExecutionResult, Error> {
6359 let mut wire_params = serde_json::to_value(params)?;
6360 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6361 let _value = self
6362 .session
6363 .client()
6364 .call(rpc_methods::SESSION_MCP_EXECUTESAMPLING, Some(wire_params))
6365 .await?;
6366 Ok(serde_json::from_value(_value)?)
6367 }
6368
6369 /// Cancels an in-flight MCP sampling execution by request ID.
6370 ///
6371 /// Wire method: `session.mcp.cancelSamplingExecution`.
6372 ///
6373 /// # Parameters
6374 ///
6375 /// * `params` - The requestId previously passed to executeSampling that should be cancelled.
6376 ///
6377 /// # Returns
6378 ///
6379 /// Indicates whether an in-flight sampling execution with the given requestId was found and cancelled.
6380 ///
6381 /// <div class="warning">
6382 ///
6383 /// **Experimental.** This API is part of an experimental wire-protocol surface
6384 /// and may change or be removed in future SDK or CLI releases. Pin both the
6385 /// SDK and CLI versions if your code depends on it.
6386 ///
6387 /// </div>
6388 pub async fn cancel_sampling_execution(
6389 &self,
6390 params: McpCancelSamplingExecutionParams,
6391 ) -> Result<McpCancelSamplingExecutionResult, Error> {
6392 let mut wire_params = serde_json::to_value(params)?;
6393 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6394 let _value = self
6395 .session
6396 .client()
6397 .call(
6398 rpc_methods::SESSION_MCP_CANCELSAMPLINGEXECUTION,
6399 Some(wire_params),
6400 )
6401 .await?;
6402 Ok(serde_json::from_value(_value)?)
6403 }
6404
6405 /// Sets how environment-variable values supplied to MCP servers are resolved (direct or indirect).
6406 ///
6407 /// Wire method: `session.mcp.setEnvValueMode`.
6408 ///
6409 /// # Parameters
6410 ///
6411 /// * `params` - Mode controlling how MCP server env values are resolved (`direct` or `indirect`).
6412 ///
6413 /// # Returns
6414 ///
6415 /// Env-value mode recorded on the session after the update.
6416 ///
6417 /// <div class="warning">
6418 ///
6419 /// **Experimental.** This API is part of an experimental wire-protocol surface
6420 /// and may change or be removed in future SDK or CLI releases. Pin both the
6421 /// SDK and CLI versions if your code depends on it.
6422 ///
6423 /// </div>
6424 pub async fn set_env_value_mode(
6425 &self,
6426 params: McpSetEnvValueModeParams,
6427 ) -> Result<McpSetEnvValueModeResult, Error> {
6428 let mut wire_params = serde_json::to_value(params)?;
6429 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6430 let _value = self
6431 .session
6432 .client()
6433 .call(rpc_methods::SESSION_MCP_SETENVVALUEMODE, Some(wire_params))
6434 .await?;
6435 Ok(serde_json::from_value(_value)?)
6436 }
6437
6438 /// Removes the auto-managed `github` MCP server when present.
6439 ///
6440 /// Wire method: `session.mcp.removeGitHub`.
6441 ///
6442 /// # Returns
6443 ///
6444 /// Indicates whether the auto-managed `github` MCP server was removed (false when nothing to remove).
6445 ///
6446 /// <div class="warning">
6447 ///
6448 /// **Experimental.** This API is part of an experimental wire-protocol surface
6449 /// and may change or be removed in future SDK or CLI releases. Pin both the
6450 /// SDK and CLI versions if your code depends on it.
6451 ///
6452 /// </div>
6453 pub async fn remove_git_hub(&self) -> Result<McpRemoveGitHubResult, Error> {
6454 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6455 let _value = self
6456 .session
6457 .client()
6458 .call(rpc_methods::SESSION_MCP_REMOVEGITHUB, Some(wire_params))
6459 .await?;
6460 Ok(serde_json::from_value(_value)?)
6461 }
6462
6463 /// Configures the built-in GitHub MCP server for the session's current auth context.
6464 ///
6465 /// Wire method: `session.mcp.configureGitHub`.
6466 ///
6467 /// # Parameters
6468 ///
6469 /// * `params` - Credential-free authentication identity used to configure GitHub MCP.
6470 ///
6471 /// # Returns
6472 ///
6473 /// Result of configuring GitHub MCP.
6474 ///
6475 /// <div class="warning">
6476 ///
6477 /// **Experimental.** This API is part of an experimental wire-protocol surface
6478 /// and may change or be removed in future SDK or CLI releases. Pin both the
6479 /// SDK and CLI versions if your code depends on it.
6480 ///
6481 /// </div>
6482 pub(crate) async fn configure_git_hub(
6483 &self,
6484 params: McpConfigureGitHubRequest,
6485 ) -> Result<McpConfigureGitHubResult, Error> {
6486 let mut wire_params = serde_json::to_value(params)?;
6487 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6488 let _value = self
6489 .session
6490 .client()
6491 .call(rpc_methods::SESSION_MCP_CONFIGUREGITHUB, Some(wire_params))
6492 .await?;
6493 Ok(serde_json::from_value(_value)?)
6494 }
6495
6496 /// 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.
6497 ///
6498 /// Wire method: `session.mcp.startServer`.
6499 ///
6500 /// # Parameters
6501 ///
6502 /// * `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.
6503 ///
6504 /// <div class="warning">
6505 ///
6506 /// **Experimental.** This API is part of an experimental wire-protocol surface
6507 /// and may change or be removed in future SDK or CLI releases. Pin both the
6508 /// SDK and CLI versions if your code depends on it.
6509 ///
6510 /// </div>
6511 pub async fn start_server(&self, params: McpStartServerRequest) -> Result<(), Error> {
6512 let mut wire_params = serde_json::to_value(params)?;
6513 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6514 let _value = self
6515 .session
6516 .client()
6517 .call(rpc_methods::SESSION_MCP_STARTSERVER, Some(wire_params))
6518 .await?;
6519 Ok(())
6520 }
6521
6522 /// 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.*`).
6523 ///
6524 /// Wire method: `session.mcp.restartServer`.
6525 ///
6526 /// # Parameters
6527 ///
6528 /// * `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.
6529 ///
6530 /// <div class="warning">
6531 ///
6532 /// **Experimental.** This API is part of an experimental wire-protocol surface
6533 /// and may change or be removed in future SDK or CLI releases. Pin both the
6534 /// SDK and CLI versions if your code depends on it.
6535 ///
6536 /// </div>
6537 pub async fn restart_server(&self, params: McpRestartServerRequest) -> Result<(), Error> {
6538 let mut wire_params = serde_json::to_value(params)?;
6539 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6540 let _value = self
6541 .session
6542 .client()
6543 .call(rpc_methods::SESSION_MCP_RESTARTSERVER, Some(wire_params))
6544 .await?;
6545 Ok(())
6546 }
6547
6548 /// Stops an individual MCP server on the session's host.
6549 ///
6550 /// Wire method: `session.mcp.stopServer`.
6551 ///
6552 /// # Parameters
6553 ///
6554 /// * `params` - Server name for an individual MCP server stop.
6555 ///
6556 /// <div class="warning">
6557 ///
6558 /// **Experimental.** This API is part of an experimental wire-protocol surface
6559 /// and may change or be removed in future SDK or CLI releases. Pin both the
6560 /// SDK and CLI versions if your code depends on it.
6561 ///
6562 /// </div>
6563 pub async fn stop_server(&self, params: McpStopServerRequest) -> Result<(), Error> {
6564 let mut wire_params = serde_json::to_value(params)?;
6565 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6566 let _value = self
6567 .session
6568 .client()
6569 .call(rpc_methods::SESSION_MCP_STOPSERVER, Some(wire_params))
6570 .await?;
6571 Ok(())
6572 }
6573
6574 /// 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.
6575 ///
6576 /// Wire method: `session.mcp.registerExternalClient`.
6577 ///
6578 /// # Parameters
6579 ///
6580 /// * `params` - Registration parameters for an external MCP client.
6581 ///
6582 /// <div class="warning">
6583 ///
6584 /// **Experimental.** This API is part of an experimental wire-protocol surface
6585 /// and may change or be removed in future SDK or CLI releases. Pin both the
6586 /// SDK and CLI versions if your code depends on it.
6587 ///
6588 /// </div>
6589 pub(crate) async fn register_external_client(
6590 &self,
6591 params: McpRegisterExternalClientRequest,
6592 ) -> Result<(), Error> {
6593 let mut wire_params = serde_json::to_value(params)?;
6594 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6595 let _value = self
6596 .session
6597 .client()
6598 .call(
6599 rpc_methods::SESSION_MCP_REGISTEREXTERNALCLIENT,
6600 Some(wire_params),
6601 )
6602 .await?;
6603 Ok(())
6604 }
6605
6606 /// 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.
6607 ///
6608 /// Wire method: `session.mcp.unregisterExternalClient`.
6609 ///
6610 /// # Parameters
6611 ///
6612 /// * `params` - Server name identifying the external client to remove.
6613 ///
6614 /// <div class="warning">
6615 ///
6616 /// **Experimental.** This API is part of an experimental wire-protocol surface
6617 /// and may change or be removed in future SDK or CLI releases. Pin both the
6618 /// SDK and CLI versions if your code depends on it.
6619 ///
6620 /// </div>
6621 pub(crate) async fn unregister_external_client(
6622 &self,
6623 params: McpUnregisterExternalClientRequest,
6624 ) -> Result<(), Error> {
6625 let mut wire_params = serde_json::to_value(params)?;
6626 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6627 let _value = self
6628 .session
6629 .client()
6630 .call(
6631 rpc_methods::SESSION_MCP_UNREGISTEREXTERNALCLIENT,
6632 Some(wire_params),
6633 )
6634 .await?;
6635 Ok(())
6636 }
6637
6638 /// Checks whether a named MCP server is currently running on the session's host.
6639 ///
6640 /// Wire method: `session.mcp.isServerRunning`.
6641 ///
6642 /// # Parameters
6643 ///
6644 /// * `params` - Server name to check running status for.
6645 ///
6646 /// # Returns
6647 ///
6648 /// Whether the named MCP server is running.
6649 ///
6650 /// <div class="warning">
6651 ///
6652 /// **Experimental.** This API is part of an experimental wire-protocol surface
6653 /// and may change or be removed in future SDK or CLI releases. Pin both the
6654 /// SDK and CLI versions if your code depends on it.
6655 ///
6656 /// </div>
6657 pub async fn is_server_running(
6658 &self,
6659 params: McpIsServerRunningRequest,
6660 ) -> Result<McpIsServerRunningResult, Error> {
6661 let mut wire_params = serde_json::to_value(params)?;
6662 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6663 let _value = self
6664 .session
6665 .client()
6666 .call(rpc_methods::SESSION_MCP_ISSERVERRUNNING, Some(wire_params))
6667 .await?;
6668 Ok(serde_json::from_value(_value)?)
6669 }
6670}
6671
6672/// `session.mcp.apps.*` RPCs.
6673#[derive(Clone, Copy)]
6674pub struct SessionRpcMcpApps<'a> {
6675 pub(crate) session: &'a Session,
6676}
6677
6678impl<'a> SessionRpcMcpApps<'a> {
6679 /// Fetch an MCP resource (typically a `ui://` MCP App bundle, per SEP-1865) from a connected server. Requires the `mcp-apps` session capability.
6680 ///
6681 /// Wire method: `session.mcp.apps.readResource`.
6682 ///
6683 /// # Parameters
6684 ///
6685 /// * `params` - MCP server and resource URI to fetch.
6686 ///
6687 /// # Returns
6688 ///
6689 /// Resource contents returned by the MCP server.
6690 ///
6691 /// <div class="warning">
6692 ///
6693 /// **Experimental.** This API is part of an experimental wire-protocol surface
6694 /// and may change or be removed in future SDK or CLI releases. Pin both the
6695 /// SDK and CLI versions if your code depends on it.
6696 ///
6697 /// </div>
6698 pub async fn read_resource(
6699 &self,
6700 params: McpAppsReadResourceRequest,
6701 ) -> Result<McpAppsReadResourceResult, Error> {
6702 let mut wire_params = serde_json::to_value(params)?;
6703 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6704 let _value = self
6705 .session
6706 .client()
6707 .call(
6708 rpc_methods::SESSION_MCP_APPS_READRESOURCE,
6709 Some(wire_params),
6710 )
6711 .await?;
6712 Ok(serde_json::from_value(_value)?)
6713 }
6714
6715 /// 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"`.
6716 ///
6717 /// Wire method: `session.mcp.apps.listTools`.
6718 ///
6719 /// # Parameters
6720 ///
6721 /// * `params` - MCP server to list app-callable tools for.
6722 ///
6723 /// # Returns
6724 ///
6725 /// App-callable tools from the named MCP server.
6726 ///
6727 /// <div class="warning">
6728 ///
6729 /// **Experimental.** This API is part of an experimental wire-protocol surface
6730 /// and may change or be removed in future SDK or CLI releases. Pin both the
6731 /// SDK and CLI versions if your code depends on it.
6732 ///
6733 /// </div>
6734 pub async fn list_tools(
6735 &self,
6736 params: McpAppsListToolsRequest,
6737 ) -> Result<McpAppsListToolsResult, Error> {
6738 let mut wire_params = serde_json::to_value(params)?;
6739 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6740 let _value = self
6741 .session
6742 .client()
6743 .call(rpc_methods::SESSION_MCP_APPS_LISTTOOLS, Some(wire_params))
6744 .await?;
6745 Ok(serde_json::from_value(_value)?)
6746 }
6747
6748 /// 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`.
6749 ///
6750 /// Wire method: `session.mcp.apps.callTool`.
6751 ///
6752 /// # Parameters
6753 ///
6754 /// * `params` - MCP server, tool name, and arguments to invoke from an MCP App view.
6755 ///
6756 /// # Returns
6757 ///
6758 /// Standard MCP CallToolResult
6759 ///
6760 /// <div class="warning">
6761 ///
6762 /// **Experimental.** This API is part of an experimental wire-protocol surface
6763 /// and may change or be removed in future SDK or CLI releases. Pin both the
6764 /// SDK and CLI versions if your code depends on it.
6765 ///
6766 /// </div>
6767 pub async fn call_tool(
6768 &self,
6769 params: McpAppsCallToolRequest,
6770 ) -> Result<SessionMcpAppsCallToolResult, Error> {
6771 let mut wire_params = serde_json::to_value(params)?;
6772 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6773 let _value = self
6774 .session
6775 .client()
6776 .call(rpc_methods::SESSION_MCP_APPS_CALLTOOL, Some(wire_params))
6777 .await?;
6778 Ok(serde_json::from_value(_value)?)
6779 }
6780
6781 /// 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.
6782 ///
6783 /// Wire method: `session.mcp.apps.setHostContext`.
6784 ///
6785 /// # Parameters
6786 ///
6787 /// * `params` - Host context to advertise to MCP App guests.
6788 ///
6789 /// <div class="warning">
6790 ///
6791 /// **Experimental.** This API is part of an experimental wire-protocol surface
6792 /// and may change or be removed in future SDK or CLI releases. Pin both the
6793 /// SDK and CLI versions if your code depends on it.
6794 ///
6795 /// </div>
6796 pub async fn set_host_context(
6797 &self,
6798 params: McpAppsSetHostContextRequest,
6799 ) -> Result<(), Error> {
6800 let mut wire_params = serde_json::to_value(params)?;
6801 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6802 let _value = self
6803 .session
6804 .client()
6805 .call(
6806 rpc_methods::SESSION_MCP_APPS_SETHOSTCONTEXT,
6807 Some(wire_params),
6808 )
6809 .await?;
6810 Ok(())
6811 }
6812
6813 /// Read the current host context advertised to MCP App guests.
6814 ///
6815 /// Wire method: `session.mcp.apps.getHostContext`.
6816 ///
6817 /// # Returns
6818 ///
6819 /// Current host context advertised to MCP App guests.
6820 ///
6821 /// <div class="warning">
6822 ///
6823 /// **Experimental.** This API is part of an experimental wire-protocol surface
6824 /// and may change or be removed in future SDK or CLI releases. Pin both the
6825 /// SDK and CLI versions if your code depends on it.
6826 ///
6827 /// </div>
6828 pub async fn get_host_context(&self) -> Result<McpAppsHostContext, Error> {
6829 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6830 let _value = self
6831 .session
6832 .client()
6833 .call(
6834 rpc_methods::SESSION_MCP_APPS_GETHOSTCONTEXT,
6835 Some(wire_params),
6836 )
6837 .await?;
6838 Ok(serde_json::from_value(_value)?)
6839 }
6840
6841 /// 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.
6842 ///
6843 /// Wire method: `session.mcp.apps.diagnose`.
6844 ///
6845 /// # Parameters
6846 ///
6847 /// * `params` - MCP server to diagnose MCP Apps wiring for.
6848 ///
6849 /// # Returns
6850 ///
6851 /// Diagnostic snapshot of MCP Apps wiring for the named server.
6852 ///
6853 /// <div class="warning">
6854 ///
6855 /// **Experimental.** This API is part of an experimental wire-protocol surface
6856 /// and may change or be removed in future SDK or CLI releases. Pin both the
6857 /// SDK and CLI versions if your code depends on it.
6858 ///
6859 /// </div>
6860 pub async fn diagnose(
6861 &self,
6862 params: McpAppsDiagnoseRequest,
6863 ) -> Result<McpAppsDiagnoseResult, Error> {
6864 let mut wire_params = serde_json::to_value(params)?;
6865 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6866 let _value = self
6867 .session
6868 .client()
6869 .call(rpc_methods::SESSION_MCP_APPS_DIAGNOSE, Some(wire_params))
6870 .await?;
6871 Ok(serde_json::from_value(_value)?)
6872 }
6873}
6874
6875/// `session.mcp.headers.*` RPCs.
6876#[derive(Clone, Copy)]
6877pub struct SessionRpcMcpHeaders<'a> {
6878 pub(crate) session: &'a Session,
6879}
6880
6881impl<'a> SessionRpcMcpHeaders<'a> {
6882 /// 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.
6883 ///
6884 /// Wire method: `session.mcp.headers.handlePendingHeadersRefreshRequest`.
6885 ///
6886 /// # Parameters
6887 ///
6888 /// * `params` - MCP headers refresh request id and the host response.
6889 ///
6890 /// # Returns
6891 ///
6892 /// Indicates whether the pending MCP headers refresh response was accepted.
6893 ///
6894 /// <div class="warning">
6895 ///
6896 /// **Experimental.** This API is part of an experimental wire-protocol surface
6897 /// and may change or be removed in future SDK or CLI releases. Pin both the
6898 /// SDK and CLI versions if your code depends on it.
6899 ///
6900 /// </div>
6901 pub async fn handle_pending_headers_refresh_request(
6902 &self,
6903 params: McpHeadersHandlePendingHeadersRefreshRequestRequest,
6904 ) -> Result<McpHeadersHandlePendingHeadersRefreshRequestResult, Error> {
6905 let mut wire_params = serde_json::to_value(params)?;
6906 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6907 let _value = self
6908 .session
6909 .client()
6910 .call(
6911 rpc_methods::SESSION_MCP_HEADERS_HANDLEPENDINGHEADERSREFRESHREQUEST,
6912 Some(wire_params),
6913 )
6914 .await?;
6915 Ok(serde_json::from_value(_value)?)
6916 }
6917}
6918
6919/// `session.mcp.oauth.*` RPCs.
6920#[derive(Clone, Copy)]
6921pub struct SessionRpcMcpOauth<'a> {
6922 pub(crate) session: &'a Session,
6923}
6924
6925impl<'a> SessionRpcMcpOauth<'a> {
6926 /// 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.
6927 ///
6928 /// Wire method: `session.mcp.oauth.handlePendingRequest`.
6929 ///
6930 /// # Parameters
6931 ///
6932 /// * `params` - Pending MCP OAuth request ID and host-provided token or cancellation response.
6933 ///
6934 /// # Returns
6935 ///
6936 /// Indicates whether the pending MCP OAuth response was accepted.
6937 ///
6938 /// <div class="warning">
6939 ///
6940 /// **Experimental.** This API is part of an experimental wire-protocol surface
6941 /// and may change or be removed in future SDK or CLI releases. Pin both the
6942 /// SDK and CLI versions if your code depends on it.
6943 ///
6944 /// </div>
6945 pub async fn handle_pending_request(
6946 &self,
6947 params: McpOauthHandlePendingRequest,
6948 ) -> Result<McpOauthHandlePendingResult, Error> {
6949 let mut wire_params = serde_json::to_value(params)?;
6950 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6951 let _value = self
6952 .session
6953 .client()
6954 .call(
6955 rpc_methods::SESSION_MCP_OAUTH_HANDLEPENDINGREQUEST,
6956 Some(wire_params),
6957 )
6958 .await?;
6959 Ok(serde_json::from_value(_value)?)
6960 }
6961
6962 /// Notifies the session that MCP OAuth authentication succeeded and updated credentials were persisted, so cached tool definitions can be refreshed.
6963 ///
6964 /// Wire method: `session.mcp.oauth.authenticationStateChanged`.
6965 ///
6966 /// # Parameters
6967 ///
6968 /// * `params` - Identifies the MCP server whose persisted OAuth credentials were updated.
6969 ///
6970 /// <div class="warning">
6971 ///
6972 /// **Experimental.** This API is part of an experimental wire-protocol surface
6973 /// and may change or be removed in future SDK or CLI releases. Pin both the
6974 /// SDK and CLI versions if your code depends on it.
6975 ///
6976 /// </div>
6977 pub async fn authentication_state_changed(
6978 &self,
6979 params: McpOauthAuthenticationStateChangedRequest,
6980 ) -> Result<(), Error> {
6981 let mut wire_params = serde_json::to_value(params)?;
6982 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6983 let _value = self
6984 .session
6985 .client()
6986 .call(
6987 rpc_methods::SESSION_MCP_OAUTH_AUTHENTICATIONSTATECHANGED,
6988 Some(wire_params),
6989 )
6990 .await?;
6991 Ok(())
6992 }
6993
6994 /// Starts OAuth authentication for a remote MCP server.
6995 ///
6996 /// Wire method: `session.mcp.oauth.login`.
6997 ///
6998 /// # Parameters
6999 ///
7000 /// * `params` - Remote MCP server name and optional overrides controlling reauthentication, OAuth client display name, callback success-page copy, and static OAuth client selection.
7001 ///
7002 /// # Returns
7003 ///
7004 /// OAuth authorization URL the caller should open, or empty when cached tokens already authenticated the server.
7005 ///
7006 /// <div class="warning">
7007 ///
7008 /// **Experimental.** This API is part of an experimental wire-protocol surface
7009 /// and may change or be removed in future SDK or CLI releases. Pin both the
7010 /// SDK and CLI versions if your code depends on it.
7011 ///
7012 /// </div>
7013 pub async fn login(&self, params: McpOauthLoginRequest) -> Result<McpOauthLoginResult, Error> {
7014 let mut wire_params = serde_json::to_value(params)?;
7015 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7016 let _value = self
7017 .session
7018 .client()
7019 .call(rpc_methods::SESSION_MCP_OAUTH_LOGIN, Some(wire_params))
7020 .await?;
7021 Ok(serde_json::from_value(_value)?)
7022 }
7023
7024 /// 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.
7025 ///
7026 /// Wire method: `session.mcp.oauth.probe`.
7027 ///
7028 /// # Parameters
7029 ///
7030 /// * `params` - Remote MCP server name for a passive OAuth status probe.
7031 ///
7032 /// # Returns
7033 ///
7034 /// 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.
7035 ///
7036 /// <div class="warning">
7037 ///
7038 /// **Experimental.** This API is part of an experimental wire-protocol surface
7039 /// and may change or be removed in future SDK or CLI releases. Pin both the
7040 /// SDK and CLI versions if your code depends on it.
7041 ///
7042 /// </div>
7043 pub async fn probe(&self, params: McpOauthProbeRequest) -> Result<McpOauthProbeResult, Error> {
7044 let mut wire_params = serde_json::to_value(params)?;
7045 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7046 let _value = self
7047 .session
7048 .client()
7049 .call(rpc_methods::SESSION_MCP_OAUTH_PROBE, Some(wire_params))
7050 .await?;
7051 Ok(serde_json::from_value(_value)?)
7052 }
7053
7054 /// Responds to a pending MCP OAuth authorization request by its request id.
7055 ///
7056 /// Wire method: `session.mcp.oauth.respond`.
7057 ///
7058 /// # Parameters
7059 ///
7060 /// * `params` - Pending MCP OAuth request id to respond to.
7061 ///
7062 /// # Returns
7063 ///
7064 /// Indicates whether the pending MCP OAuth response was accepted.
7065 ///
7066 /// <div class="warning">
7067 ///
7068 /// **Experimental.** This API is part of an experimental wire-protocol surface
7069 /// and may change or be removed in future SDK or CLI releases. Pin both the
7070 /// SDK and CLI versions if your code depends on it.
7071 ///
7072 /// </div>
7073 pub async fn respond(
7074 &self,
7075 params: McpOauthRespondRequest,
7076 ) -> Result<McpOauthRespondResult, Error> {
7077 let mut wire_params = serde_json::to_value(params)?;
7078 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7079 let _value = self
7080 .session
7081 .client()
7082 .call(rpc_methods::SESSION_MCP_OAUTH_RESPOND, Some(wire_params))
7083 .await?;
7084 Ok(serde_json::from_value(_value)?)
7085 }
7086}
7087
7088/// `session.mcp.resources.*` RPCs.
7089#[derive(Clone, Copy)]
7090pub struct SessionRpcMcpResources<'a> {
7091 pub(crate) session: &'a Session,
7092}
7093
7094impl<'a> SessionRpcMcpResources<'a> {
7095 /// Fetch an MCP resource from a connected server by URI (proxies MCP `resources/read`).
7096 ///
7097 /// Wire method: `session.mcp.resources.read`.
7098 ///
7099 /// # Parameters
7100 ///
7101 /// * `params` - MCP server and resource URI to fetch.
7102 ///
7103 /// # Returns
7104 ///
7105 /// Resource contents returned by the MCP server.
7106 ///
7107 /// <div class="warning">
7108 ///
7109 /// **Experimental.** This API is part of an experimental wire-protocol surface
7110 /// and may change or be removed in future SDK or CLI releases. Pin both the
7111 /// SDK and CLI versions if your code depends on it.
7112 ///
7113 /// </div>
7114 pub async fn read(
7115 &self,
7116 params: McpResourcesReadRequest,
7117 ) -> Result<McpResourcesReadResult, Error> {
7118 let mut wire_params = serde_json::to_value(params)?;
7119 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7120 let _value = self
7121 .session
7122 .client()
7123 .call(rpc_methods::SESSION_MCP_RESOURCES_READ, Some(wire_params))
7124 .await?;
7125 Ok(serde_json::from_value(_value)?)
7126 }
7127
7128 /// Enumerate one page of resources a connected MCP server exposes (proxies MCP `resources/list`). Pass `cursor` to continue from a prior result's `nextCursor`.
7129 ///
7130 /// Wire method: `session.mcp.resources.list`.
7131 ///
7132 /// # Parameters
7133 ///
7134 /// * `params` - MCP server whose resources to enumerate.
7135 ///
7136 /// # Returns
7137 ///
7138 /// One page of resources advertised by the named MCP server.
7139 ///
7140 /// <div class="warning">
7141 ///
7142 /// **Experimental.** This API is part of an experimental wire-protocol surface
7143 /// and may change or be removed in future SDK or CLI releases. Pin both the
7144 /// SDK and CLI versions if your code depends on it.
7145 ///
7146 /// </div>
7147 pub async fn list(
7148 &self,
7149 params: McpResourcesListRequest,
7150 ) -> Result<McpResourcesListResult, Error> {
7151 let mut wire_params = serde_json::to_value(params)?;
7152 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7153 let _value = self
7154 .session
7155 .client()
7156 .call(rpc_methods::SESSION_MCP_RESOURCES_LIST, Some(wire_params))
7157 .await?;
7158 Ok(serde_json::from_value(_value)?)
7159 }
7160
7161 /// 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`.
7162 ///
7163 /// Wire method: `session.mcp.resources.listTemplates`.
7164 ///
7165 /// # Parameters
7166 ///
7167 /// * `params` - MCP server whose resource templates to enumerate.
7168 ///
7169 /// # Returns
7170 ///
7171 /// One page of resource templates advertised by the named MCP server.
7172 ///
7173 /// <div class="warning">
7174 ///
7175 /// **Experimental.** This API is part of an experimental wire-protocol surface
7176 /// and may change or be removed in future SDK or CLI releases. Pin both the
7177 /// SDK and CLI versions if your code depends on it.
7178 ///
7179 /// </div>
7180 pub async fn list_templates(
7181 &self,
7182 params: McpResourcesListTemplatesRequest,
7183 ) -> Result<McpResourcesListTemplatesResult, Error> {
7184 let mut wire_params = serde_json::to_value(params)?;
7185 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7186 let _value = self
7187 .session
7188 .client()
7189 .call(
7190 rpc_methods::SESSION_MCP_RESOURCES_LISTTEMPLATES,
7191 Some(wire_params),
7192 )
7193 .await?;
7194 Ok(serde_json::from_value(_value)?)
7195 }
7196}
7197
7198/// `session.metadata.*` RPCs.
7199#[derive(Clone, Copy)]
7200pub struct SessionRpcMetadata<'a> {
7201 pub(crate) session: &'a Session,
7202}
7203
7204impl<'a> SessionRpcMetadata<'a> {
7205 /// Returns a snapshot of the session's identifying metadata, mode, agent, and remote info.
7206 ///
7207 /// Wire method: `session.metadata.snapshot`.
7208 ///
7209 /// # Returns
7210 ///
7211 /// Point-in-time snapshot of slow-changing session identifier and state fields
7212 ///
7213 /// <div class="warning">
7214 ///
7215 /// **Experimental.** This API is part of an experimental wire-protocol surface
7216 /// and may change or be removed in future SDK or CLI releases. Pin both the
7217 /// SDK and CLI versions if your code depends on it.
7218 ///
7219 /// </div>
7220 pub async fn snapshot(&self) -> Result<SessionMetadataSnapshot, Error> {
7221 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7222 let _value = self
7223 .session
7224 .client()
7225 .call(rpc_methods::SESSION_METADATA_SNAPSHOT, Some(wire_params))
7226 .await?;
7227 Ok(serde_json::from_value(_value)?)
7228 }
7229
7230 /// Returns the client-owned string metadata persisted with this local session. The metadata is not included in model context, events, telemetry, snapshots, or remote exports.
7231 ///
7232 /// Wire method: `session.metadata.getClientMetadata`.
7233 ///
7234 /// # Returns
7235 ///
7236 /// Client-owned, case-sensitive string metadata persisted with a local session. Clients should namespace keys by owner. Keys must be non-empty and at most 256 UTF-8 bytes; keys under `copilot/` and `github/` are reserved. Values may contain at most 16 KiB of UTF-8 data. A bag may contain at most 128 entries and its serialized sidecar may contain at most 64 KiB. The runtime stores but never interprets these values.
7237 ///
7238 /// <div class="warning">
7239 ///
7240 /// **Experimental.** This API is part of an experimental wire-protocol surface
7241 /// and may change or be removed in future SDK or CLI releases. Pin both the
7242 /// SDK and CLI versions if your code depends on it.
7243 ///
7244 /// </div>
7245 pub async fn get_client_metadata(&self) -> Result<ClientMetadata, Error> {
7246 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7247 let _value = self
7248 .session
7249 .client()
7250 .call(
7251 rpc_methods::SESSION_METADATA_GETCLIENTMETADATA,
7252 Some(wire_params),
7253 )
7254 .await?;
7255 Ok(serde_json::from_value(_value)?)
7256 }
7257
7258 /// Atomically patches the client-owned string metadata persisted with this local session and returns the committed bag.
7259 ///
7260 /// Wire method: `session.metadata.updateClientMetadata`.
7261 ///
7262 /// # Parameters
7263 ///
7264 /// * `params` - Atomic patch for client-owned session metadata. Operations apply in clear, remove, then set order. The resulting bag must satisfy the ClientMetadata entry and serialized-size limits. Local storage coordinates concurrent runtime processes; custom SessionFs providers must serialize writers that access the same session from multiple processes.
7265 ///
7266 /// # Returns
7267 ///
7268 /// Client-owned, case-sensitive string metadata persisted with a local session. Clients should namespace keys by owner. Keys must be non-empty and at most 256 UTF-8 bytes; keys under `copilot/` and `github/` are reserved. Values may contain at most 16 KiB of UTF-8 data. A bag may contain at most 128 entries and its serialized sidecar may contain at most 64 KiB. The runtime stores but never interprets these values.
7269 ///
7270 /// <div class="warning">
7271 ///
7272 /// **Experimental.** This API is part of an experimental wire-protocol surface
7273 /// and may change or be removed in future SDK or CLI releases. Pin both the
7274 /// SDK and CLI versions if your code depends on it.
7275 ///
7276 /// </div>
7277 pub async fn update_client_metadata(
7278 &self,
7279 params: MetadataUpdateClientMetadataRequest,
7280 ) -> Result<ClientMetadata, Error> {
7281 let mut wire_params = serde_json::to_value(params)?;
7282 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7283 let _value = self
7284 .session
7285 .client()
7286 .call(
7287 rpc_methods::SESSION_METADATA_UPDATECLIENTMETADATA,
7288 Some(wire_params),
7289 )
7290 .await?;
7291 Ok(serde_json::from_value(_value)?)
7292 }
7293
7294 /// Reports whether the local session is currently processing user/agent messages.
7295 ///
7296 /// Wire method: `session.metadata.isProcessing`.
7297 ///
7298 /// # Returns
7299 ///
7300 /// Indicates whether the local session is currently processing a turn or background continuation.
7301 ///
7302 /// <div class="warning">
7303 ///
7304 /// **Experimental.** This API is part of an experimental wire-protocol surface
7305 /// and may change or be removed in future SDK or CLI releases. Pin both the
7306 /// SDK and CLI versions if your code depends on it.
7307 ///
7308 /// </div>
7309 pub async fn is_processing(&self) -> Result<MetadataIsProcessingResult, Error> {
7310 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7311 let _value = self
7312 .session
7313 .client()
7314 .call(
7315 rpc_methods::SESSION_METADATA_ISPROCESSING,
7316 Some(wire_params),
7317 )
7318 .await?;
7319 Ok(serde_json::from_value(_value)?)
7320 }
7321
7322 /// Returns a snapshot of activity flags for the session.
7323 ///
7324 /// Wire method: `session.metadata.activity`.
7325 ///
7326 /// # Returns
7327 ///
7328 /// Current activity flags for the session.
7329 ///
7330 /// <div class="warning">
7331 ///
7332 /// **Experimental.** This API is part of an experimental wire-protocol surface
7333 /// and may change or be removed in future SDK or CLI releases. Pin both the
7334 /// SDK and CLI versions if your code depends on it.
7335 ///
7336 /// </div>
7337 pub async fn activity(&self) -> Result<SessionActivity, Error> {
7338 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7339 let _value = self
7340 .session
7341 .client()
7342 .call(rpc_methods::SESSION_METADATA_ACTIVITY, Some(wire_params))
7343 .await?;
7344 Ok(serde_json::from_value(_value)?)
7345 }
7346
7347 /// Returns the token breakdown for the session's current context window for a given model.
7348 ///
7349 /// Wire method: `session.metadata.contextInfo`.
7350 ///
7351 /// # Parameters
7352 ///
7353 /// * `params` - Model identifier and token limits used to compute the context-info breakdown.
7354 ///
7355 /// # Returns
7356 ///
7357 /// Token breakdown for the session's current context window, or null if uninitialized.
7358 ///
7359 /// <div class="warning">
7360 ///
7361 /// **Experimental.** This API is part of an experimental wire-protocol surface
7362 /// and may change or be removed in future SDK or CLI releases. Pin both the
7363 /// SDK and CLI versions if your code depends on it.
7364 ///
7365 /// </div>
7366 pub async fn context_info(
7367 &self,
7368 params: MetadataContextInfoRequest,
7369 ) -> Result<MetadataContextInfoResult, Error> {
7370 let mut wire_params = serde_json::to_value(params)?;
7371 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7372 let _value = self
7373 .session
7374 .client()
7375 .call(rpc_methods::SESSION_METADATA_CONTEXTINFO, Some(wire_params))
7376 .await?;
7377 Ok(serde_json::from_value(_value)?)
7378 }
7379
7380 /// 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.
7381 ///
7382 /// Wire method: `session.metadata.getContextAttribution`.
7383 ///
7384 /// # Returns
7385 ///
7386 /// Per-source attribution breakdown for the session's current context window, or null if uninitialized.
7387 ///
7388 /// <div class="warning">
7389 ///
7390 /// **Experimental.** This API is part of an experimental wire-protocol surface
7391 /// and may change or be removed in future SDK or CLI releases. Pin both the
7392 /// SDK and CLI versions if your code depends on it.
7393 ///
7394 /// </div>
7395 pub async fn get_context_attribution(&self) -> Result<MetadataContextAttributionResult, Error> {
7396 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7397 let _value = self
7398 .session
7399 .client()
7400 .call(
7401 rpc_methods::SESSION_METADATA_GETCONTEXTATTRIBUTION,
7402 Some(wire_params),
7403 )
7404 .await?;
7405 Ok(serde_json::from_value(_value)?)
7406 }
7407
7408 /// 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.
7409 ///
7410 /// Wire method: `session.metadata.getContextHeaviestMessages`.
7411 ///
7412 /// # Parameters
7413 ///
7414 /// * `params` - Parameters for the heaviest-messages query.
7415 ///
7416 /// # Returns
7417 ///
7418 /// The heaviest individual messages in the session's context window, most-expensive first.
7419 ///
7420 /// <div class="warning">
7421 ///
7422 /// **Experimental.** This API is part of an experimental wire-protocol surface
7423 /// and may change or be removed in future SDK or CLI releases. Pin both the
7424 /// SDK and CLI versions if your code depends on it.
7425 ///
7426 /// </div>
7427 pub async fn get_context_heaviest_messages(
7428 &self,
7429 params: MetadataContextHeaviestMessagesRequest,
7430 ) -> Result<MetadataContextHeaviestMessagesResult, Error> {
7431 let mut wire_params = serde_json::to_value(params)?;
7432 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7433 let _value = self
7434 .session
7435 .client()
7436 .call(
7437 rpc_methods::SESSION_METADATA_GETCONTEXTHEAVIESTMESSAGES,
7438 Some(wire_params),
7439 )
7440 .await?;
7441 Ok(serde_json::from_value(_value)?)
7442 }
7443
7444 /// 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.
7445 ///
7446 /// Wire method: `session.metadata.recordContextChange`.
7447 ///
7448 /// # Parameters
7449 ///
7450 /// * `params` - Updated working-directory/git context to record on the session.
7451 ///
7452 /// # Returns
7453 ///
7454 /// 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.
7455 ///
7456 /// <div class="warning">
7457 ///
7458 /// **Experimental.** This API is part of an experimental wire-protocol surface
7459 /// and may change or be removed in future SDK or CLI releases. Pin both the
7460 /// SDK and CLI versions if your code depends on it.
7461 ///
7462 /// </div>
7463 pub async fn record_context_change(
7464 &self,
7465 params: MetadataRecordContextChangeRequest,
7466 ) -> Result<MetadataRecordContextChangeResult, Error> {
7467 let mut wire_params = serde_json::to_value(params)?;
7468 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7469 let _value = self
7470 .session
7471 .client()
7472 .call(
7473 rpc_methods::SESSION_METADATA_RECORDCONTEXTCHANGE,
7474 Some(wire_params),
7475 )
7476 .await?;
7477 Ok(serde_json::from_value(_value)?)
7478 }
7479
7480 /// 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.
7481 ///
7482 /// Wire method: `session.metadata.setWorkingDirectory`.
7483 ///
7484 /// # Parameters
7485 ///
7486 /// * `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.
7487 ///
7488 /// # Returns
7489 ///
7490 /// 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.
7491 ///
7492 /// <div class="warning">
7493 ///
7494 /// **Experimental.** This API is part of an experimental wire-protocol surface
7495 /// and may change or be removed in future SDK or CLI releases. Pin both the
7496 /// SDK and CLI versions if your code depends on it.
7497 ///
7498 /// </div>
7499 pub async fn set_working_directory(
7500 &self,
7501 params: MetadataSetWorkingDirectoryRequest,
7502 ) -> Result<MetadataSetWorkingDirectoryResult, Error> {
7503 let mut wire_params = serde_json::to_value(params)?;
7504 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7505 let _value = self
7506 .session
7507 .client()
7508 .call(
7509 rpc_methods::SESSION_METADATA_SETWORKINGDIRECTORY,
7510 Some(wire_params),
7511 )
7512 .await?;
7513 Ok(serde_json::from_value(_value)?)
7514 }
7515
7516 /// Re-tokenizes the session's existing messages against a model and returns aggregate token totals.
7517 ///
7518 /// Wire method: `session.metadata.recomputeContextTokens`.
7519 ///
7520 /// # Parameters
7521 ///
7522 /// * `params` - Model identifier to use when re-tokenizing the session's existing messages.
7523 ///
7524 /// # Returns
7525 ///
7526 /// 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.
7527 ///
7528 /// <div class="warning">
7529 ///
7530 /// **Experimental.** This API is part of an experimental wire-protocol surface
7531 /// and may change or be removed in future SDK or CLI releases. Pin both the
7532 /// SDK and CLI versions if your code depends on it.
7533 ///
7534 /// </div>
7535 pub async fn recompute_context_tokens(
7536 &self,
7537 params: MetadataRecomputeContextTokensRequest,
7538 ) -> Result<MetadataRecomputeContextTokensResult, Error> {
7539 let mut wire_params = serde_json::to_value(params)?;
7540 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7541 let _value = self
7542 .session
7543 .client()
7544 .call(
7545 rpc_methods::SESSION_METADATA_RECOMPUTECONTEXTTOKENS,
7546 Some(wire_params),
7547 )
7548 .await?;
7549 Ok(serde_json::from_value(_value)?)
7550 }
7551}
7552
7553/// `session.mode.*` RPCs.
7554#[derive(Clone, Copy)]
7555pub struct SessionRpcMode<'a> {
7556 pub(crate) session: &'a Session,
7557}
7558
7559impl<'a> SessionRpcMode<'a> {
7560 /// Gets the current agent interaction mode.
7561 ///
7562 /// Wire method: `session.mode.get`.
7563 ///
7564 /// # Returns
7565 ///
7566 /// The session mode the agent is operating in
7567 ///
7568 /// <div class="warning">
7569 ///
7570 /// **Experimental.** This API is part of an experimental wire-protocol surface
7571 /// and may change or be removed in future SDK or CLI releases. Pin both the
7572 /// SDK and CLI versions if your code depends on it.
7573 ///
7574 /// </div>
7575 pub async fn get(&self) -> Result<SessionMode, Error> {
7576 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7577 let _value = self
7578 .session
7579 .client()
7580 .call(rpc_methods::SESSION_MODE_GET, Some(wire_params))
7581 .await?;
7582 Ok(serde_json::from_value(_value)?)
7583 }
7584
7585 /// Sets the current agent interaction mode.
7586 ///
7587 /// Wire method: `session.mode.set`.
7588 ///
7589 /// # Parameters
7590 ///
7591 /// * `params` - Agent interaction mode to apply to the session.
7592 ///
7593 /// # Returns
7594 ///
7595 /// Outcome of a session mode change, including any model switch it triggered and follow-up the host must perform.
7596 ///
7597 /// <div class="warning">
7598 ///
7599 /// **Experimental.** This API is part of an experimental wire-protocol surface
7600 /// and may change or be removed in future SDK or CLI releases. Pin both the
7601 /// SDK and CLI versions if your code depends on it.
7602 ///
7603 /// </div>
7604 pub async fn set(&self, params: ModeSetRequest) -> Result<ModeSetResult, Error> {
7605 let mut wire_params = serde_json::to_value(params)?;
7606 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7607 let _value = self
7608 .session
7609 .client()
7610 .call(rpc_methods::SESSION_MODE_SET, Some(wire_params))
7611 .await?;
7612 Ok(serde_json::from_value(_value)?)
7613 }
7614}
7615
7616/// `session.model.*` RPCs.
7617#[derive(Clone, Copy)]
7618pub struct SessionRpcModel<'a> {
7619 pub(crate) session: &'a Session,
7620}
7621
7622impl<'a> SessionRpcModel<'a> {
7623 /// Gets the session's authoritative model snapshot, including the committed Auto preference and any newer unclaimed Auto preference waiting for a future user turn.
7624 ///
7625 /// Wire method: `session.model.getCurrent`.
7626 ///
7627 /// # Returns
7628 ///
7629 /// The session's authoritative model snapshot. Auto preference fields are configuration for the virtual `auto` model and do not change the selected model identifier. The context tier reflects `Session.getContextTier()`, restored from the session journal on resume.
7630 ///
7631 /// <div class="warning">
7632 ///
7633 /// **Experimental.** This API is part of an experimental wire-protocol surface
7634 /// and may change or be removed in future SDK or CLI releases. Pin both the
7635 /// SDK and CLI versions if your code depends on it.
7636 ///
7637 /// </div>
7638 pub async fn get_current(&self) -> Result<CurrentModel, Error> {
7639 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7640 let _value = self
7641 .session
7642 .client()
7643 .call(rpc_methods::SESSION_MODEL_GETCURRENT, Some(wire_params))
7644 .await?;
7645 Ok(serde_json::from_value(_value)?)
7646 }
7647
7648 /// Switches the session to a model and optional reasoning configuration.
7649 ///
7650 /// Wire method: `session.model.switchTo`.
7651 ///
7652 /// # Parameters
7653 ///
7654 /// * `params` - Target model identifier and optional reasoning effort, summary, capability overrides, and context tier.
7655 ///
7656 /// # Returns
7657 ///
7658 /// The model identifier active on the session after the switch.
7659 ///
7660 /// <div class="warning">
7661 ///
7662 /// **Experimental.** This API is part of an experimental wire-protocol surface
7663 /// and may change or be removed in future SDK or CLI releases. Pin both the
7664 /// SDK and CLI versions if your code depends on it.
7665 ///
7666 /// </div>
7667 pub async fn switch_to(
7668 &self,
7669 params: ModelSwitchToRequest,
7670 ) -> Result<ModelSwitchToResult, Error> {
7671 let mut wire_params = serde_json::to_value(params)?;
7672 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7673 let _value = self
7674 .session
7675 .client()
7676 .call(rpc_methods::SESSION_MODEL_SWITCHTO, Some(wire_params))
7677 .await?;
7678 Ok(serde_json::from_value(_value)?)
7679 }
7680
7681 /// Requests an Auto preference change without changing the session's selected model. The latest unclaimed request wins; the runtime commits it only after a later prompt using the `auto` model mints a usable model and token pair. A `pending` response confirms that the request was accepted, not that it committed. Observe eventual success through `session.model_change`, failure through the ephemeral `session.auto_tier_switch_failed` event, or current unclaimed state through `session.model.getCurrent`.
7682 ///
7683 /// Wire method: `session.model.switchAutoTier`.
7684 ///
7685 /// # Parameters
7686 ///
7687 /// * `params` - An Auto preference request for the session. This updates Auto configuration only; it does not change the selected model to `auto`.
7688 ///
7689 /// # Returns
7690 ///
7691 /// Immediate acknowledgement and Auto preference snapshot after a switch request. This result never implies that a pending preference committed.
7692 ///
7693 /// <div class="warning">
7694 ///
7695 /// **Experimental.** This API is part of an experimental wire-protocol surface
7696 /// and may change or be removed in future SDK or CLI releases. Pin both the
7697 /// SDK and CLI versions if your code depends on it.
7698 ///
7699 /// </div>
7700 pub async fn switch_auto_tier(
7701 &self,
7702 params: ModelSwitchAutoTierRequest,
7703 ) -> Result<ModelSwitchAutoTierResult, Error> {
7704 let mut wire_params = serde_json::to_value(params)?;
7705 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7706 let _value = self
7707 .session
7708 .client()
7709 .call(rpc_methods::SESSION_MODEL_SWITCHAUTOTIER, Some(wire_params))
7710 .await?;
7711 Ok(serde_json::from_value(_value)?)
7712 }
7713
7714 /// Resolves and applies organization-managed and repository model overlays.
7715 ///
7716 /// Wire method: `session.model.applyStartupOverlay`.
7717 ///
7718 /// # Parameters
7719 ///
7720 /// * `params` - Managed, repository, and CLI model overrides to overlay onto the session at startup.
7721 ///
7722 /// # Returns
7723 ///
7724 /// The model identifier active on the session after the switch.
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(crate) async fn apply_startup_overlay(
7734 &self,
7735 params: ModelApplyStartupOverlayRequest,
7736 ) -> Result<ModelSwitchToResult, 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_MODEL_APPLYSTARTUPOVERLAY,
7744 Some(wire_params),
7745 )
7746 .await?;
7747 Ok(serde_json::from_value(_value)?)
7748 }
7749
7750 /// Replaces or clears the host-supplied model allowlist for a running session.
7751 ///
7752 /// Wire method: `session.model.setAllowedModels`.
7753 ///
7754 /// # Parameters
7755 ///
7756 /// * `params` - Host-supplied exact model selection IDs to allow for this running session. CAPI IDs are intersected with repository `.github/allowed_models.txt` policy; provider-qualified IDs remain exempt from repository-only policy but are restricted by this host list. Omit or pass null to clear the host restriction; an explicit empty or disjoint list is rejected. Validation and pre-selection fallback failures preserve the previous restriction. Failures after a fallback selection commits retain the new restriction and selected model; callers should inspect current session state after such an error.
7757 ///
7758 /// # Returns
7759 ///
7760 /// The applied host allowlist and effective session model policy after intersection.
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 set_allowed_models(
7770 &self,
7771 params: ModelSetAllowedModelsRequest,
7772 ) -> Result<ModelSetAllowedModelsResult, 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_MODEL_SETALLOWEDMODELS,
7780 Some(wire_params),
7781 )
7782 .await?;
7783 Ok(serde_json::from_value(_value)?)
7784 }
7785
7786 /// Updates the session's reasoning effort without changing the selected model.
7787 ///
7788 /// Wire method: `session.model.setReasoningEffort`.
7789 ///
7790 /// # Parameters
7791 ///
7792 /// * `params` - Reasoning effort level to apply to the currently selected model.
7793 ///
7794 /// # Returns
7795 ///
7796 /// 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.
7797 ///
7798 /// <div class="warning">
7799 ///
7800 /// **Experimental.** This API is part of an experimental wire-protocol surface
7801 /// and may change or be removed in future SDK or CLI releases. Pin both the
7802 /// SDK and CLI versions if your code depends on it.
7803 ///
7804 /// </div>
7805 pub async fn set_reasoning_effort(
7806 &self,
7807 params: ModelSetReasoningEffortRequest,
7808 ) -> Result<ModelSetReasoningEffortResult, Error> {
7809 let mut wire_params = serde_json::to_value(params)?;
7810 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7811 let _value = self
7812 .session
7813 .client()
7814 .call(
7815 rpc_methods::SESSION_MODEL_SETREASONINGEFFORT,
7816 Some(wire_params),
7817 )
7818 .await?;
7819 Ok(serde_json::from_value(_value)?)
7820 }
7821
7822 /// 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.
7823 ///
7824 /// Wire method: `session.model.list`.
7825 ///
7826 /// # Returns
7827 ///
7828 /// The list of models available to this session.
7829 ///
7830 /// <div class="warning">
7831 ///
7832 /// **Experimental.** This API is part of an experimental wire-protocol surface
7833 /// and may change or be removed in future SDK or CLI releases. Pin both the
7834 /// SDK and CLI versions if your code depends on it.
7835 ///
7836 /// </div>
7837 pub async fn list(&self) -> Result<SessionModelList, Error> {
7838 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7839 let _value = self
7840 .session
7841 .client()
7842 .call(rpc_methods::SESSION_MODEL_LIST, Some(wire_params))
7843 .await?;
7844 Ok(serde_json::from_value(_value)?)
7845 }
7846
7847 /// 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.
7848 ///
7849 /// Wire method: `session.model.list`.
7850 ///
7851 /// # Parameters
7852 ///
7853 /// * `params` - Optional listing options.
7854 ///
7855 /// # Returns
7856 ///
7857 /// The list of models available to this session.
7858 ///
7859 /// <div class="warning">
7860 ///
7861 /// **Experimental.** This API is part of an experimental wire-protocol surface
7862 /// and may change or be removed in future SDK or CLI releases. Pin both the
7863 /// SDK and CLI versions if your code depends on it.
7864 ///
7865 /// </div>
7866 pub async fn list_with_params(
7867 &self,
7868 params: ModelListRequest,
7869 ) -> Result<SessionModelList, Error> {
7870 let mut wire_params = serde_json::to_value(params)?;
7871 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7872 let _value = self
7873 .session
7874 .client()
7875 .call(rpc_methods::SESSION_MODEL_LIST, Some(wire_params))
7876 .await?;
7877 Ok(serde_json::from_value(_value)?)
7878 }
7879}
7880
7881/// `session.name.*` RPCs.
7882#[derive(Clone, Copy)]
7883pub struct SessionRpcName<'a> {
7884 pub(crate) session: &'a Session,
7885}
7886
7887impl<'a> SessionRpcName<'a> {
7888 /// Gets the session's friendly name.
7889 ///
7890 /// Wire method: `session.name.get`.
7891 ///
7892 /// # Returns
7893 ///
7894 /// The session's friendly name, or null when not yet set.
7895 ///
7896 /// <div class="warning">
7897 ///
7898 /// **Experimental.** This API is part of an experimental wire-protocol surface
7899 /// and may change or be removed in future SDK or CLI releases. Pin both the
7900 /// SDK and CLI versions if your code depends on it.
7901 ///
7902 /// </div>
7903 pub async fn get(&self) -> Result<NameGetResult, Error> {
7904 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7905 let _value = self
7906 .session
7907 .client()
7908 .call(rpc_methods::SESSION_NAME_GET, Some(wire_params))
7909 .await?;
7910 Ok(serde_json::from_value(_value)?)
7911 }
7912
7913 /// Sets the session's friendly name.
7914 ///
7915 /// Wire method: `session.name.set`.
7916 ///
7917 /// # Parameters
7918 ///
7919 /// * `params` - New friendly name to apply to the session.
7920 ///
7921 /// <div class="warning">
7922 ///
7923 /// **Experimental.** This API is part of an experimental wire-protocol surface
7924 /// and may change or be removed in future SDK or CLI releases. Pin both the
7925 /// SDK and CLI versions if your code depends on it.
7926 ///
7927 /// </div>
7928 pub async fn set(&self, params: NameSetRequest) -> Result<(), Error> {
7929 let mut wire_params = serde_json::to_value(params)?;
7930 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7931 let _value = self
7932 .session
7933 .client()
7934 .call(rpc_methods::SESSION_NAME_SET, Some(wire_params))
7935 .await?;
7936 Ok(())
7937 }
7938
7939 /// Persists an auto-generated session summary as the session's name when no user-set name exists.
7940 ///
7941 /// Wire method: `session.name.setAuto`.
7942 ///
7943 /// # Parameters
7944 ///
7945 /// * `params` - Auto-generated session summary to apply as the session's name when no user-set name exists.
7946 ///
7947 /// # Returns
7948 ///
7949 /// Indicates whether the auto-generated summary was applied as the session's name.
7950 ///
7951 /// <div class="warning">
7952 ///
7953 /// **Experimental.** This API is part of an experimental wire-protocol surface
7954 /// and may change or be removed in future SDK or CLI releases. Pin both the
7955 /// SDK and CLI versions if your code depends on it.
7956 ///
7957 /// </div>
7958 pub async fn set_auto(&self, params: NameSetAutoRequest) -> Result<NameSetAutoResult, Error> {
7959 let mut wire_params = serde_json::to_value(params)?;
7960 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7961 let _value = self
7962 .session
7963 .client()
7964 .call(rpc_methods::SESSION_NAME_SETAUTO, Some(wire_params))
7965 .await?;
7966 Ok(serde_json::from_value(_value)?)
7967 }
7968}
7969
7970/// `session.options.*` RPCs.
7971#[derive(Clone, Copy)]
7972pub struct SessionRpcOptions<'a> {
7973 pub(crate) session: &'a Session,
7974}
7975
7976impl<'a> SessionRpcOptions<'a> {
7977 /// Patches the genuinely-mutable subset of session options.
7978 ///
7979 /// Wire method: `session.options.update`.
7980 ///
7981 /// # Parameters
7982 ///
7983 /// * `params` - Patch of mutable session options to apply to the running session.
7984 ///
7985 /// # Returns
7986 ///
7987 /// Indicates whether the session options patch was applied successfully.
7988 ///
7989 /// <div class="warning">
7990 ///
7991 /// **Experimental.** This API is part of an experimental wire-protocol surface
7992 /// and may change or be removed in future SDK or CLI releases. Pin both the
7993 /// SDK and CLI versions if your code depends on it.
7994 ///
7995 /// </div>
7996 pub async fn update(
7997 &self,
7998 params: SessionUpdateOptionsParams,
7999 ) -> Result<SessionUpdateOptionsResult, Error> {
8000 let mut wire_params = serde_json::to_value(params)?;
8001 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8002 let _value = self
8003 .session
8004 .client()
8005 .call(rpc_methods::SESSION_OPTIONS_UPDATE, Some(wire_params))
8006 .await?;
8007 Ok(serde_json::from_value(_value)?)
8008 }
8009}
8010
8011/// `session.permissions.*` RPCs.
8012#[derive(Clone, Copy)]
8013pub struct SessionRpcPermissions<'a> {
8014 pub(crate) session: &'a Session,
8015}
8016
8017impl<'a> SessionRpcPermissions<'a> {
8018 /// `session.permissions.folderTrust.*` sub-namespace.
8019 pub fn folder_trust(&self) -> SessionRpcPermissionsFolderTrust<'a> {
8020 SessionRpcPermissionsFolderTrust {
8021 session: self.session,
8022 }
8023 }
8024
8025 /// `session.permissions.locations.*` sub-namespace.
8026 pub fn locations(&self) -> SessionRpcPermissionsLocations<'a> {
8027 SessionRpcPermissionsLocations {
8028 session: self.session,
8029 }
8030 }
8031
8032 /// `session.permissions.paths.*` sub-namespace.
8033 pub fn paths(&self) -> SessionRpcPermissionsPaths<'a> {
8034 SessionRpcPermissionsPaths {
8035 session: self.session,
8036 }
8037 }
8038
8039 /// `session.permissions.urls.*` sub-namespace.
8040 pub fn urls(&self) -> SessionRpcPermissionsUrls<'a> {
8041 SessionRpcPermissionsUrls {
8042 session: self.session,
8043 }
8044 }
8045
8046 /// Replaces selected permission policy fields (rules, paths, URLs, exclusions, allow-all flags) on the session.
8047 ///
8048 /// Wire method: `session.permissions.configure`.
8049 ///
8050 /// # Parameters
8051 ///
8052 /// * `params` - Patch of permission policy fields to apply (omit a field to leave it unchanged).
8053 ///
8054 /// # Returns
8055 ///
8056 /// Indicates whether the operation succeeded.
8057 ///
8058 /// <div class="warning">
8059 ///
8060 /// **Experimental.** This API is part of an experimental wire-protocol surface
8061 /// and may change or be removed in future SDK or CLI releases. Pin both the
8062 /// SDK and CLI versions if your code depends on it.
8063 ///
8064 /// </div>
8065 pub async fn configure(
8066 &self,
8067 params: PermissionsConfigureParams,
8068 ) -> Result<PermissionsConfigureResult, Error> {
8069 let mut wire_params = serde_json::to_value(params)?;
8070 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8071 let _value = self
8072 .session
8073 .client()
8074 .call(
8075 rpc_methods::SESSION_PERMISSIONS_CONFIGURE,
8076 Some(wire_params),
8077 )
8078 .await?;
8079 Ok(serde_json::from_value(_value)?)
8080 }
8081
8082 /// Provides a decision for a pending tool permission request.
8083 ///
8084 /// Wire method: `session.permissions.handlePendingPermissionRequest`.
8085 ///
8086 /// # Parameters
8087 ///
8088 /// * `params` - Pending permission request ID and the decision to apply (approve/reject and scope).
8089 ///
8090 /// # Returns
8091 ///
8092 /// Indicates whether the permission decision was applied; false when the request was already resolved.
8093 ///
8094 /// <div class="warning">
8095 ///
8096 /// **Experimental.** This API is part of an experimental wire-protocol surface
8097 /// and may change or be removed in future SDK or CLI releases. Pin both the
8098 /// SDK and CLI versions if your code depends on it.
8099 ///
8100 /// </div>
8101 pub async fn handle_pending_permission_request(
8102 &self,
8103 params: PermissionDecisionRequest,
8104 ) -> Result<PermissionRequestResult, Error> {
8105 let mut wire_params = serde_json::to_value(params)?;
8106 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8107 let _value = self
8108 .session
8109 .client()
8110 .call(
8111 rpc_methods::SESSION_PERMISSIONS_HANDLEPENDINGPERMISSIONREQUEST,
8112 Some(wire_params),
8113 )
8114 .await?;
8115 Ok(serde_json::from_value(_value)?)
8116 }
8117
8118 /// Reconstructs the set of pending tool permission requests from the session's event history.
8119 ///
8120 /// Wire method: `session.permissions.pendingRequests`.
8121 ///
8122 /// # Returns
8123 ///
8124 /// List of pending permission requests reconstructed from event history.
8125 ///
8126 /// <div class="warning">
8127 ///
8128 /// **Experimental.** This API is part of an experimental wire-protocol surface
8129 /// and may change or be removed in future SDK or CLI releases. Pin both the
8130 /// SDK and CLI versions if your code depends on it.
8131 ///
8132 /// </div>
8133 pub async fn pending_requests(&self) -> Result<PendingPermissionRequestList, Error> {
8134 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8135 let _value = self
8136 .session
8137 .client()
8138 .call(
8139 rpc_methods::SESSION_PERMISSIONS_PENDINGREQUESTS,
8140 Some(wire_params),
8141 )
8142 .await?;
8143 Ok(serde_json::from_value(_value)?)
8144 }
8145
8146 /// Enables or disables automatic approval of tool permission requests for the session.
8147 ///
8148 /// Wire method: `session.permissions.setApproveAll`.
8149 ///
8150 /// # Parameters
8151 ///
8152 /// * `params` - Allow-all toggle for tool permission requests, with an optional telemetry source.
8153 ///
8154 /// # Returns
8155 ///
8156 /// Indicates whether the operation succeeded.
8157 ///
8158 /// <div class="warning">
8159 ///
8160 /// **Experimental.** This API is part of an experimental wire-protocol surface
8161 /// and may change or be removed in future SDK or CLI releases. Pin both the
8162 /// SDK and CLI versions if your code depends on it.
8163 ///
8164 /// </div>
8165 pub async fn set_approve_all(
8166 &self,
8167 params: PermissionsSetApproveAllRequest,
8168 ) -> Result<PermissionsSetApproveAllResult, Error> {
8169 let mut wire_params = serde_json::to_value(params)?;
8170 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8171 let _value = self
8172 .session
8173 .client()
8174 .call(
8175 rpc_methods::SESSION_PERMISSIONS_SETAPPROVEALL,
8176 Some(wire_params),
8177 )
8178 .await?;
8179 Ok(serde_json::from_value(_value)?)
8180 }
8181
8182 /// 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.
8183 ///
8184 /// Wire method: `session.permissions.setMode`.
8185 ///
8186 /// # Parameters
8187 ///
8188 /// * `params` - Permission mode to apply for the session.
8189 ///
8190 /// # Returns
8191 ///
8192 /// Indicates whether the requested permission mode was applied and reports the authoritative post-mutation mode.
8193 ///
8194 /// <div class="warning">
8195 ///
8196 /// **Experimental.** This API is part of an experimental wire-protocol surface
8197 /// and may change or be removed in future SDK or CLI releases. Pin both the
8198 /// SDK and CLI versions if your code depends on it.
8199 ///
8200 /// </div>
8201 pub async fn set_mode(
8202 &self,
8203 params: PermissionsSetModeRequest,
8204 ) -> Result<PermissionsSetModeResult, Error> {
8205 let mut wire_params = serde_json::to_value(params)?;
8206 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8207 let _value = self
8208 .session
8209 .client()
8210 .call(rpc_methods::SESSION_PERMISSIONS_SETMODE, Some(wire_params))
8211 .await?;
8212 Ok(serde_json::from_value(_value)?)
8213 }
8214
8215 /// Returns the current permission mode for the session.
8216 ///
8217 /// Wire method: `session.permissions.getMode`.
8218 ///
8219 /// # Returns
8220 ///
8221 /// Current permission mode.
8222 ///
8223 /// <div class="warning">
8224 ///
8225 /// **Experimental.** This API is part of an experimental wire-protocol surface
8226 /// and may change or be removed in future SDK or CLI releases. Pin both the
8227 /// SDK and CLI versions if your code depends on it.
8228 ///
8229 /// </div>
8230 pub async fn get_mode(&self) -> Result<PermissionsGetModeResult, Error> {
8231 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8232 let _value = self
8233 .session
8234 .client()
8235 .call(rpc_methods::SESSION_PERMISSIONS_GETMODE, Some(wire_params))
8236 .await?;
8237 Ok(serde_json::from_value(_value)?)
8238 }
8239
8240 /// Adds or removes session-scoped or location-scoped permission rules.
8241 ///
8242 /// Wire method: `session.permissions.modifyRules`.
8243 ///
8244 /// # Parameters
8245 ///
8246 /// * `params` - Scope and add/remove instructions for modifying session- or location-scoped permission rules.
8247 ///
8248 /// # Returns
8249 ///
8250 /// Indicates whether the operation succeeded.
8251 ///
8252 /// <div class="warning">
8253 ///
8254 /// **Experimental.** This API is part of an experimental wire-protocol surface
8255 /// and may change or be removed in future SDK or CLI releases. Pin both the
8256 /// SDK and CLI versions if your code depends on it.
8257 ///
8258 /// </div>
8259 pub async fn modify_rules(
8260 &self,
8261 params: PermissionsModifyRulesParams,
8262 ) -> Result<PermissionsModifyRulesResult, Error> {
8263 let mut wire_params = serde_json::to_value(params)?;
8264 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8265 let _value = self
8266 .session
8267 .client()
8268 .call(
8269 rpc_methods::SESSION_PERMISSIONS_MODIFYRULES,
8270 Some(wire_params),
8271 )
8272 .await?;
8273 Ok(serde_json::from_value(_value)?)
8274 }
8275
8276 /// Sets whether the client wants permission prompts bridged into session events.
8277 ///
8278 /// Wire method: `session.permissions.setRequired`.
8279 ///
8280 /// # Parameters
8281 ///
8282 /// * `params` - Toggles whether permission prompts should be bridged into session events for this client.
8283 ///
8284 /// # Returns
8285 ///
8286 /// Indicates whether the operation succeeded.
8287 ///
8288 /// <div class="warning">
8289 ///
8290 /// **Experimental.** This API is part of an experimental wire-protocol surface
8291 /// and may change or be removed in future SDK or CLI releases. Pin both the
8292 /// SDK and CLI versions if your code depends on it.
8293 ///
8294 /// </div>
8295 pub async fn set_required(
8296 &self,
8297 params: PermissionsSetRequiredRequest,
8298 ) -> Result<PermissionsSetRequiredResult, Error> {
8299 let mut wire_params = serde_json::to_value(params)?;
8300 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8301 let _value = self
8302 .session
8303 .client()
8304 .call(
8305 rpc_methods::SESSION_PERMISSIONS_SETREQUIRED,
8306 Some(wire_params),
8307 )
8308 .await?;
8309 Ok(serde_json::from_value(_value)?)
8310 }
8311
8312 /// Clears session-scoped tool permission approvals.
8313 ///
8314 /// Wire method: `session.permissions.resetSessionApprovals`.
8315 ///
8316 /// # Parameters
8317 ///
8318 /// * `params` - Clears session-scoped tool permission approvals, and optionally the location-scoped ones.
8319 ///
8320 /// # Returns
8321 ///
8322 /// Indicates whether the operation succeeded.
8323 ///
8324 /// <div class="warning">
8325 ///
8326 /// **Experimental.** This API is part of an experimental wire-protocol surface
8327 /// and may change or be removed in future SDK or CLI releases. Pin both the
8328 /// SDK and CLI versions if your code depends on it.
8329 ///
8330 /// </div>
8331 pub async fn reset_session_approvals(
8332 &self,
8333 params: PermissionsResetSessionApprovalsRequest,
8334 ) -> Result<PermissionsResetSessionApprovalsResult, Error> {
8335 let mut wire_params = serde_json::to_value(params)?;
8336 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8337 let _value = self
8338 .session
8339 .client()
8340 .call(
8341 rpc_methods::SESSION_PERMISSIONS_RESETSESSIONAPPROVALS,
8342 Some(wire_params),
8343 )
8344 .await?;
8345 Ok(serde_json::from_value(_value)?)
8346 }
8347
8348 /// Notifies the runtime that a permission prompt UI has been shown to the user.
8349 ///
8350 /// Wire method: `session.permissions.notifyPromptShown`.
8351 ///
8352 /// # Parameters
8353 ///
8354 /// * `params` - Notification payload describing the permission prompt that the client just rendered.
8355 ///
8356 /// # Returns
8357 ///
8358 /// Indicates whether the operation succeeded.
8359 ///
8360 /// <div class="warning">
8361 ///
8362 /// **Experimental.** This API is part of an experimental wire-protocol surface
8363 /// and may change or be removed in future SDK or CLI releases. Pin both the
8364 /// SDK and CLI versions if your code depends on it.
8365 ///
8366 /// </div>
8367 pub async fn notify_prompt_shown(
8368 &self,
8369 params: PermissionPromptShownNotification,
8370 ) -> Result<PermissionsNotifyPromptShownResult, Error> {
8371 let mut wire_params = serde_json::to_value(params)?;
8372 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8373 let _value = self
8374 .session
8375 .client()
8376 .call(
8377 rpc_methods::SESSION_PERMISSIONS_NOTIFYPROMPTSHOWN,
8378 Some(wire_params),
8379 )
8380 .await?;
8381 Ok(serde_json::from_value(_value)?)
8382 }
8383}
8384
8385/// `session.permissions.folderTrust.*` RPCs.
8386#[derive(Clone, Copy)]
8387pub struct SessionRpcPermissionsFolderTrust<'a> {
8388 pub(crate) session: &'a Session,
8389}
8390
8391impl<'a> SessionRpcPermissionsFolderTrust<'a> {
8392 /// Reports whether a folder is trusted according to the user's folder trust state.
8393 ///
8394 /// Wire method: `session.permissions.folderTrust.isTrusted`.
8395 ///
8396 /// # Parameters
8397 ///
8398 /// * `params` - Folder path to check for trust.
8399 ///
8400 /// # Returns
8401 ///
8402 /// Folder trust check result.
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_trusted(
8412 &self,
8413 params: FolderTrustCheckParams,
8414 ) -> Result<FolderTrustCheckResult, 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_FOLDERTRUST_ISTRUSTED,
8422 Some(wire_params),
8423 )
8424 .await?;
8425 Ok(serde_json::from_value(_value)?)
8426 }
8427
8428 /// Adds a folder to the user's trusted folders list.
8429 ///
8430 /// Wire method: `session.permissions.folderTrust.addTrusted`.
8431 ///
8432 /// # Parameters
8433 ///
8434 /// * `params` - Folder path to add to trusted folders.
8435 ///
8436 /// # Returns
8437 ///
8438 /// Indicates whether the operation succeeded.
8439 ///
8440 /// <div class="warning">
8441 ///
8442 /// **Experimental.** This API is part of an experimental wire-protocol surface
8443 /// and may change or be removed in future SDK or CLI releases. Pin both the
8444 /// SDK and CLI versions if your code depends on it.
8445 ///
8446 /// </div>
8447 pub async fn add_trusted(
8448 &self,
8449 params: FolderTrustAddParams,
8450 ) -> Result<PermissionsFolderTrustAddTrustedResult, Error> {
8451 let mut wire_params = serde_json::to_value(params)?;
8452 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8453 let _value = self
8454 .session
8455 .client()
8456 .call(
8457 rpc_methods::SESSION_PERMISSIONS_FOLDERTRUST_ADDTRUSTED,
8458 Some(wire_params),
8459 )
8460 .await?;
8461 Ok(serde_json::from_value(_value)?)
8462 }
8463}
8464
8465/// `session.permissions.locations.*` RPCs.
8466#[derive(Clone, Copy)]
8467pub struct SessionRpcPermissionsLocations<'a> {
8468 pub(crate) session: &'a Session,
8469}
8470
8471impl<'a> SessionRpcPermissionsLocations<'a> {
8472 /// Resolves the permission location key and type for a working directory.
8473 ///
8474 /// Wire method: `session.permissions.locations.resolve`.
8475 ///
8476 /// # Parameters
8477 ///
8478 /// * `params` - Working directory to resolve into a location-permissions key.
8479 ///
8480 /// # Returns
8481 ///
8482 /// Resolved location-permissions key and type.
8483 ///
8484 /// <div class="warning">
8485 ///
8486 /// **Experimental.** This API is part of an experimental wire-protocol surface
8487 /// and may change or be removed in future SDK or CLI releases. Pin both the
8488 /// SDK and CLI versions if your code depends on it.
8489 ///
8490 /// </div>
8491 pub async fn resolve(
8492 &self,
8493 params: PermissionLocationResolveParams,
8494 ) -> Result<PermissionLocationResolveResult, Error> {
8495 let mut wire_params = serde_json::to_value(params)?;
8496 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8497 let _value = self
8498 .session
8499 .client()
8500 .call(
8501 rpc_methods::SESSION_PERMISSIONS_LOCATIONS_RESOLVE,
8502 Some(wire_params),
8503 )
8504 .await?;
8505 Ok(serde_json::from_value(_value)?)
8506 }
8507
8508 /// Applies persisted location-scoped tool approvals and allowed directories for a working directory to this session's permission service.
8509 ///
8510 /// Wire method: `session.permissions.locations.apply`.
8511 ///
8512 /// # Parameters
8513 ///
8514 /// * `params` - Working directory to load persisted location permissions for.
8515 ///
8516 /// # Returns
8517 ///
8518 /// Summary of persisted location permissions applied to the session.
8519 ///
8520 /// <div class="warning">
8521 ///
8522 /// **Experimental.** This API is part of an experimental wire-protocol surface
8523 /// and may change or be removed in future SDK or CLI releases. Pin both the
8524 /// SDK and CLI versions if your code depends on it.
8525 ///
8526 /// </div>
8527 pub async fn apply(
8528 &self,
8529 params: PermissionLocationApplyParams,
8530 ) -> Result<PermissionLocationApplyResult, Error> {
8531 let mut wire_params = serde_json::to_value(params)?;
8532 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8533 let _value = self
8534 .session
8535 .client()
8536 .call(
8537 rpc_methods::SESSION_PERMISSIONS_LOCATIONS_APPLY,
8538 Some(wire_params),
8539 )
8540 .await?;
8541 Ok(serde_json::from_value(_value)?)
8542 }
8543
8544 /// Persists a tool approval for a permission location and applies its rules to this session's live permission service.
8545 ///
8546 /// Wire method: `session.permissions.locations.addToolApproval`.
8547 ///
8548 /// # Parameters
8549 ///
8550 /// * `params` - Location-scoped tool approval to persist.
8551 ///
8552 /// # Returns
8553 ///
8554 /// Indicates whether the operation succeeded.
8555 ///
8556 /// <div class="warning">
8557 ///
8558 /// **Experimental.** This API is part of an experimental wire-protocol surface
8559 /// and may change or be removed in future SDK or CLI releases. Pin both the
8560 /// SDK and CLI versions if your code depends on it.
8561 ///
8562 /// </div>
8563 pub async fn add_tool_approval(
8564 &self,
8565 params: PermissionLocationAddToolApprovalParams,
8566 ) -> Result<PermissionsLocationsAddToolApprovalResult, Error> {
8567 let mut wire_params = serde_json::to_value(params)?;
8568 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8569 let _value = self
8570 .session
8571 .client()
8572 .call(
8573 rpc_methods::SESSION_PERMISSIONS_LOCATIONS_ADDTOOLAPPROVAL,
8574 Some(wire_params),
8575 )
8576 .await?;
8577 Ok(serde_json::from_value(_value)?)
8578 }
8579}
8580
8581/// `session.permissions.paths.*` RPCs.
8582#[derive(Clone, Copy)]
8583pub struct SessionRpcPermissionsPaths<'a> {
8584 pub(crate) session: &'a Session,
8585}
8586
8587impl<'a> SessionRpcPermissionsPaths<'a> {
8588 /// Returns the session's allowed directories and primary working directory.
8589 ///
8590 /// Wire method: `session.permissions.paths.list`.
8591 ///
8592 /// # Returns
8593 ///
8594 /// Snapshot of the session's allow-listed directories and primary working directory.
8595 ///
8596 /// <div class="warning">
8597 ///
8598 /// **Experimental.** This API is part of an experimental wire-protocol surface
8599 /// and may change or be removed in future SDK or CLI releases. Pin both the
8600 /// SDK and CLI versions if your code depends on it.
8601 ///
8602 /// </div>
8603 pub async fn list(&self) -> Result<PermissionPathsList, Error> {
8604 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8605 let _value = self
8606 .session
8607 .client()
8608 .call(
8609 rpc_methods::SESSION_PERMISSIONS_PATHS_LIST,
8610 Some(wire_params),
8611 )
8612 .await?;
8613 Ok(serde_json::from_value(_value)?)
8614 }
8615
8616 /// Adds a directory to the session's allow-list and activates conventional skill and agent definitions under it.
8617 ///
8618 /// Wire method: `session.permissions.paths.add`.
8619 ///
8620 /// # Parameters
8621 ///
8622 /// * `params` - Directory path to add to the session's allowed directories.
8623 ///
8624 /// # Returns
8625 ///
8626 /// Indicates whether the operation succeeded.
8627 ///
8628 /// <div class="warning">
8629 ///
8630 /// **Experimental.** This API is part of an experimental wire-protocol surface
8631 /// and may change or be removed in future SDK or CLI releases. Pin both the
8632 /// SDK and CLI versions if your code depends on it.
8633 ///
8634 /// </div>
8635 pub async fn add(
8636 &self,
8637 params: PermissionPathsAddParams,
8638 ) -> Result<PermissionsPathsAddResult, Error> {
8639 let mut wire_params = serde_json::to_value(params)?;
8640 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8641 let _value = self
8642 .session
8643 .client()
8644 .call(
8645 rpc_methods::SESSION_PERMISSIONS_PATHS_ADD,
8646 Some(wire_params),
8647 )
8648 .await?;
8649 Ok(serde_json::from_value(_value)?)
8650 }
8651
8652 /// Updates the session's primary working directory used by the permission policy.
8653 ///
8654 /// Wire method: `session.permissions.paths.updatePrimary`.
8655 ///
8656 /// # Parameters
8657 ///
8658 /// * `params` - Directory path to set as the session's new primary working directory.
8659 ///
8660 /// # Returns
8661 ///
8662 /// Indicates whether the operation succeeded.
8663 ///
8664 /// <div class="warning">
8665 ///
8666 /// **Experimental.** This API is part of an experimental wire-protocol surface
8667 /// and may change or be removed in future SDK or CLI releases. Pin both the
8668 /// SDK and CLI versions if your code depends on it.
8669 ///
8670 /// </div>
8671 pub async fn update_primary(
8672 &self,
8673 params: PermissionPathsUpdatePrimaryParams,
8674 ) -> Result<PermissionsPathsUpdatePrimaryResult, Error> {
8675 let mut wire_params = serde_json::to_value(params)?;
8676 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8677 let _value = self
8678 .session
8679 .client()
8680 .call(
8681 rpc_methods::SESSION_PERMISSIONS_PATHS_UPDATEPRIMARY,
8682 Some(wire_params),
8683 )
8684 .await?;
8685 Ok(serde_json::from_value(_value)?)
8686 }
8687
8688 /// Reports whether a path falls within any of the session's allowed directories.
8689 ///
8690 /// Wire method: `session.permissions.paths.isPathWithinAllowedDirectories`.
8691 ///
8692 /// # Parameters
8693 ///
8694 /// * `params` - Path to evaluate against the session's allowed directories.
8695 ///
8696 /// # Returns
8697 ///
8698 /// Indicates whether the supplied path is within the session's allowed directories.
8699 ///
8700 /// <div class="warning">
8701 ///
8702 /// **Experimental.** This API is part of an experimental wire-protocol surface
8703 /// and may change or be removed in future SDK or CLI releases. Pin both the
8704 /// SDK and CLI versions if your code depends on it.
8705 ///
8706 /// </div>
8707 pub async fn is_path_within_allowed_directories(
8708 &self,
8709 params: PermissionPathsAllowedCheckParams,
8710 ) -> Result<PermissionPathsAllowedCheckResult, Error> {
8711 let mut wire_params = serde_json::to_value(params)?;
8712 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8713 let _value = self
8714 .session
8715 .client()
8716 .call(
8717 rpc_methods::SESSION_PERMISSIONS_PATHS_ISPATHWITHINALLOWEDDIRECTORIES,
8718 Some(wire_params),
8719 )
8720 .await?;
8721 Ok(serde_json::from_value(_value)?)
8722 }
8723
8724 /// Reports whether a path falls within the session's workspace (primary) directory.
8725 ///
8726 /// Wire method: `session.permissions.paths.isPathWithinWorkspace`.
8727 ///
8728 /// # Parameters
8729 ///
8730 /// * `params` - Path to evaluate against the session's workspace (primary) directory.
8731 ///
8732 /// # Returns
8733 ///
8734 /// Indicates whether the supplied path is within the session's workspace directory.
8735 ///
8736 /// <div class="warning">
8737 ///
8738 /// **Experimental.** This API is part of an experimental wire-protocol surface
8739 /// and may change or be removed in future SDK or CLI releases. Pin both the
8740 /// SDK and CLI versions if your code depends on it.
8741 ///
8742 /// </div>
8743 pub async fn is_path_within_workspace(
8744 &self,
8745 params: PermissionPathsWorkspaceCheckParams,
8746 ) -> Result<PermissionPathsWorkspaceCheckResult, Error> {
8747 let mut wire_params = serde_json::to_value(params)?;
8748 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8749 let _value = self
8750 .session
8751 .client()
8752 .call(
8753 rpc_methods::SESSION_PERMISSIONS_PATHS_ISPATHWITHINWORKSPACE,
8754 Some(wire_params),
8755 )
8756 .await?;
8757 Ok(serde_json::from_value(_value)?)
8758 }
8759}
8760
8761/// `session.permissions.urls.*` RPCs.
8762#[derive(Clone, Copy)]
8763pub struct SessionRpcPermissionsUrls<'a> {
8764 pub(crate) session: &'a Session,
8765}
8766
8767impl<'a> SessionRpcPermissionsUrls<'a> {
8768 /// Toggles the runtime's URL-permission policy between unrestricted and restricted modes.
8769 ///
8770 /// Wire method: `session.permissions.urls.setUnrestrictedMode`.
8771 ///
8772 /// # Parameters
8773 ///
8774 /// * `params` - Whether the URL-permission policy should run in unrestricted mode.
8775 ///
8776 /// # Returns
8777 ///
8778 /// Indicates whether the operation succeeded.
8779 ///
8780 /// <div class="warning">
8781 ///
8782 /// **Experimental.** This API is part of an experimental wire-protocol surface
8783 /// and may change or be removed in future SDK or CLI releases. Pin both the
8784 /// SDK and CLI versions if your code depends on it.
8785 ///
8786 /// </div>
8787 pub async fn set_unrestricted_mode(
8788 &self,
8789 params: PermissionUrlsSetUnrestrictedModeParams,
8790 ) -> Result<PermissionsUrlsSetUnrestrictedModeResult, Error> {
8791 let mut wire_params = serde_json::to_value(params)?;
8792 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8793 let _value = self
8794 .session
8795 .client()
8796 .call(
8797 rpc_methods::SESSION_PERMISSIONS_URLS_SETUNRESTRICTEDMODE,
8798 Some(wire_params),
8799 )
8800 .await?;
8801 Ok(serde_json::from_value(_value)?)
8802 }
8803}
8804
8805/// `session.plan.*` RPCs.
8806#[derive(Clone, Copy)]
8807pub struct SessionRpcPlan<'a> {
8808 pub(crate) session: &'a Session,
8809}
8810
8811impl<'a> SessionRpcPlan<'a> {
8812 /// Reads the session plan file from the workspace.
8813 ///
8814 /// Wire method: `session.plan.read`.
8815 ///
8816 /// # Returns
8817 ///
8818 /// Existence, contents, and resolved path of the session plan file.
8819 ///
8820 /// <div class="warning">
8821 ///
8822 /// **Experimental.** This API is part of an experimental wire-protocol surface
8823 /// and may change or be removed in future SDK or CLI releases. Pin both the
8824 /// SDK and CLI versions if your code depends on it.
8825 ///
8826 /// </div>
8827 pub async fn read(&self) -> Result<PlanReadResult, Error> {
8828 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8829 let _value = self
8830 .session
8831 .client()
8832 .call(rpc_methods::SESSION_PLAN_READ, Some(wire_params))
8833 .await?;
8834 Ok(serde_json::from_value(_value)?)
8835 }
8836
8837 /// Writes new content to the session plan file.
8838 ///
8839 /// Wire method: `session.plan.update`.
8840 ///
8841 /// # Parameters
8842 ///
8843 /// * `params` - Replacement contents to write to the session plan file.
8844 ///
8845 /// <div class="warning">
8846 ///
8847 /// **Experimental.** This API is part of an experimental wire-protocol surface
8848 /// and may change or be removed in future SDK or CLI releases. Pin both the
8849 /// SDK and CLI versions if your code depends on it.
8850 ///
8851 /// </div>
8852 pub async fn update(&self, params: PlanUpdateRequest) -> Result<(), Error> {
8853 let mut wire_params = serde_json::to_value(params)?;
8854 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8855 let _value = self
8856 .session
8857 .client()
8858 .call(rpc_methods::SESSION_PLAN_UPDATE, Some(wire_params))
8859 .await?;
8860 Ok(())
8861 }
8862
8863 /// Deletes the session plan file from the workspace.
8864 ///
8865 /// Wire method: `session.plan.delete`.
8866 ///
8867 /// <div class="warning">
8868 ///
8869 /// **Experimental.** This API is part of an experimental wire-protocol surface
8870 /// and may change or be removed in future SDK or CLI releases. Pin both the
8871 /// SDK and CLI versions if your code depends on it.
8872 ///
8873 /// </div>
8874 pub async fn delete(&self) -> Result<(), Error> {
8875 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8876 let _value = self
8877 .session
8878 .client()
8879 .call(rpc_methods::SESSION_PLAN_DELETE, Some(wire_params))
8880 .await?;
8881 Ok(())
8882 }
8883
8884 /// Reads todo rows from the session SQL database for plan rendering.
8885 ///
8886 /// Wire method: `session.plan.readSqlTodos`.
8887 ///
8888 /// # Returns
8889 ///
8890 /// Todo rows read from the session SQL database. Empty when no session database is available.
8891 ///
8892 /// <div class="warning">
8893 ///
8894 /// **Experimental.** This API is part of an experimental wire-protocol surface
8895 /// and may change or be removed in future SDK or CLI releases. Pin both the
8896 /// SDK and CLI versions if your code depends on it.
8897 ///
8898 /// </div>
8899 pub async fn read_sql_todos(&self) -> Result<PlanReadSqlTodosResult, Error> {
8900 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8901 let _value = self
8902 .session
8903 .client()
8904 .call(rpc_methods::SESSION_PLAN_READSQLTODOS, Some(wire_params))
8905 .await?;
8906 Ok(serde_json::from_value(_value)?)
8907 }
8908
8909 /// 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.
8910 ///
8911 /// Wire method: `session.plan.readSqlTodosWithDependencies`.
8912 ///
8913 /// # Returns
8914 ///
8915 /// Todo rows + dependency edges read from the session SQL database.
8916 ///
8917 /// <div class="warning">
8918 ///
8919 /// **Experimental.** This API is part of an experimental wire-protocol surface
8920 /// and may change or be removed in future SDK or CLI releases. Pin both the
8921 /// SDK and CLI versions if your code depends on it.
8922 ///
8923 /// </div>
8924 pub async fn read_sql_todos_with_dependencies(
8925 &self,
8926 ) -> Result<PlanReadSqlTodosWithDependenciesResult, Error> {
8927 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8928 let _value = self
8929 .session
8930 .client()
8931 .call(
8932 rpc_methods::SESSION_PLAN_READSQLTODOSWITHDEPENDENCIES,
8933 Some(wire_params),
8934 )
8935 .await?;
8936 Ok(serde_json::from_value(_value)?)
8937 }
8938}
8939
8940/// `session.plugins.*` RPCs.
8941#[derive(Clone, Copy)]
8942pub struct SessionRpcPlugins<'a> {
8943 pub(crate) session: &'a Session,
8944}
8945
8946impl<'a> SessionRpcPlugins<'a> {
8947 /// Lists plugins installed for the session.
8948 ///
8949 /// Wire method: `session.plugins.list`.
8950 ///
8951 /// # Returns
8952 ///
8953 /// Plugins installed for the session, with their enabled state and version metadata.
8954 ///
8955 /// <div class="warning">
8956 ///
8957 /// **Experimental.** This API is part of an experimental wire-protocol surface
8958 /// and may change or be removed in future SDK or CLI releases. Pin both the
8959 /// SDK and CLI versions if your code depends on it.
8960 ///
8961 /// </div>
8962 pub async fn list(&self) -> Result<PluginList, Error> {
8963 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8964 let _value = self
8965 .session
8966 .client()
8967 .call(rpc_methods::SESSION_PLUGINS_LIST, Some(wire_params))
8968 .await?;
8969 Ok(serde_json::from_value(_value)?)
8970 }
8971
8972 /// 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.
8973 ///
8974 /// Wire method: `session.plugins.reload`.
8975 ///
8976 /// <div class="warning">
8977 ///
8978 /// **Experimental.** This API is part of an experimental wire-protocol surface
8979 /// and may change or be removed in future SDK or CLI releases. Pin both the
8980 /// SDK and CLI versions if your code depends on it.
8981 ///
8982 /// </div>
8983 pub async fn reload(&self) -> Result<(), Error> {
8984 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8985 let _value = self
8986 .session
8987 .client()
8988 .call(rpc_methods::SESSION_PLUGINS_RELOAD, Some(wire_params))
8989 .await?;
8990 Ok(())
8991 }
8992
8993 /// 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.
8994 ///
8995 /// Wire method: `session.plugins.reload`.
8996 ///
8997 /// # Parameters
8998 ///
8999 /// * `params` - Optional flags controlling which side effects the reload performs.
9000 ///
9001 /// <div class="warning">
9002 ///
9003 /// **Experimental.** This API is part of an experimental wire-protocol surface
9004 /// and may change or be removed in future SDK or CLI releases. Pin both the
9005 /// SDK and CLI versions if your code depends on it.
9006 ///
9007 /// </div>
9008 pub async fn reload_with_params(&self, params: PluginsReloadRequest) -> Result<(), Error> {
9009 let mut wire_params = serde_json::to_value(params)?;
9010 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9011 let _value = self
9012 .session
9013 .client()
9014 .call(rpc_methods::SESSION_PLUGINS_RELOAD, Some(wire_params))
9015 .await?;
9016 Ok(())
9017 }
9018}
9019
9020/// `session.provider.*` RPCs.
9021#[derive(Clone, Copy)]
9022pub struct SessionRpcProvider<'a> {
9023 pub(crate) session: &'a Session,
9024}
9025
9026impl<'a> SessionRpcProvider<'a> {
9027 /// 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.
9028 ///
9029 /// Wire method: `session.provider.getEndpoint`.
9030 ///
9031 /// # Returns
9032 ///
9033 /// A snapshot of the provider endpoint the session is currently configured to talk to.
9034 ///
9035 /// <div class="warning">
9036 ///
9037 /// **Experimental.** This API is part of an experimental wire-protocol surface
9038 /// and may change or be removed in future SDK or CLI releases. Pin both the
9039 /// SDK and CLI versions if your code depends on it.
9040 ///
9041 /// </div>
9042 pub async fn get_endpoint(&self) -> Result<ProviderEndpoint, Error> {
9043 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9044 let _value = self
9045 .session
9046 .client()
9047 .call(rpc_methods::SESSION_PROVIDER_GETENDPOINT, Some(wire_params))
9048 .await?;
9049 Ok(serde_json::from_value(_value)?)
9050 }
9051
9052 /// 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.
9053 ///
9054 /// Wire method: `session.provider.getEndpoint`.
9055 ///
9056 /// # Parameters
9057 ///
9058 /// * `params` - Optional model identifier to scope the endpoint snapshot to.
9059 ///
9060 /// # Returns
9061 ///
9062 /// A snapshot of the provider endpoint the session is currently configured to talk to.
9063 ///
9064 /// <div class="warning">
9065 ///
9066 /// **Experimental.** This API is part of an experimental wire-protocol surface
9067 /// and may change or be removed in future SDK or CLI releases. Pin both the
9068 /// SDK and CLI versions if your code depends on it.
9069 ///
9070 /// </div>
9071 pub async fn get_endpoint_with_params(
9072 &self,
9073 params: ProviderGetEndpointRequest,
9074 ) -> Result<ProviderEndpoint, Error> {
9075 let mut wire_params = serde_json::to_value(params)?;
9076 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9077 let _value = self
9078 .session
9079 .client()
9080 .call(rpc_methods::SESSION_PROVIDER_GETENDPOINT, Some(wire_params))
9081 .await?;
9082 Ok(serde_json::from_value(_value)?)
9083 }
9084
9085 /// 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.
9086 ///
9087 /// Wire method: `session.provider.add`.
9088 ///
9089 /// # Parameters
9090 ///
9091 /// * `params` - BYOK providers and/or models to add to the session's registry at runtime. Both fields are optional; provide providers, models, or both.
9092 ///
9093 /// # Returns
9094 ///
9095 /// The selectable model entries synthesized for the models added by this call.
9096 ///
9097 /// <div class="warning">
9098 ///
9099 /// **Experimental.** This API is part of an experimental wire-protocol surface
9100 /// and may change or be removed in future SDK or CLI releases. Pin both the
9101 /// SDK and CLI versions if your code depends on it.
9102 ///
9103 /// </div>
9104 pub async fn add(&self, params: ProviderAddRequest) -> Result<ProviderAddResult, Error> {
9105 let mut wire_params = serde_json::to_value(params)?;
9106 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9107 let _value = self
9108 .session
9109 .client()
9110 .call(rpc_methods::SESSION_PROVIDER_ADD, Some(wire_params))
9111 .await?;
9112 Ok(serde_json::from_value(_value)?)
9113 }
9114}
9115
9116/// `session.queue.*` RPCs.
9117#[derive(Clone, Copy)]
9118pub struct SessionRpcQueue<'a> {
9119 pub(crate) session: &'a Session,
9120}
9121
9122impl<'a> SessionRpcQueue<'a> {
9123 /// Returns the local session's pending user-facing queued items and steering messages.
9124 ///
9125 /// Wire method: `session.queue.pendingItems`.
9126 ///
9127 /// # Returns
9128 ///
9129 /// Snapshot of the session's pending queued items and immediate-steering messages.
9130 ///
9131 /// <div class="warning">
9132 ///
9133 /// **Experimental.** This API is part of an experimental wire-protocol surface
9134 /// and may change or be removed in future SDK or CLI releases. Pin both the
9135 /// SDK and CLI versions if your code depends on it.
9136 ///
9137 /// </div>
9138 pub async fn pending_items(&self) -> Result<QueuePendingItemsResult, Error> {
9139 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9140 let _value = self
9141 .session
9142 .client()
9143 .call(rpc_methods::SESSION_QUEUE_PENDINGITEMS, Some(wire_params))
9144 .await?;
9145 Ok(serde_json::from_value(_value)?)
9146 }
9147
9148 /// Returns the internal native queue snapshot for in-process session orchestration.
9149 ///
9150 /// Wire method: `session.queue.snapshot`.
9151 ///
9152 /// # Returns
9153 ///
9154 /// Internal snapshot of native queue state for local session orchestration.
9155 ///
9156 /// <div class="warning">
9157 ///
9158 /// **Experimental.** This API is part of an experimental wire-protocol surface
9159 /// and may change or be removed in future SDK or CLI releases. Pin both the
9160 /// SDK and CLI versions if your code depends on it.
9161 ///
9162 /// </div>
9163 pub(crate) async fn snapshot(&self) -> Result<QueueSnapshotResult, Error> {
9164 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9165 let _value = self
9166 .session
9167 .client()
9168 .call(rpc_methods::SESSION_QUEUE_SNAPSHOT, Some(wire_params))
9169 .await?;
9170 Ok(serde_json::from_value(_value)?)
9171 }
9172
9173 /// Moves an addressable queued item to a public visible position.
9174 ///
9175 /// Wire method: `session.queue.moveItem`.
9176 ///
9177 /// # Parameters
9178 ///
9179 /// * `params` - Parameters for moving a queued item by stable id.
9180 ///
9181 /// # Returns
9182 ///
9183 /// Result of moving a queued item.
9184 ///
9185 /// <div class="warning">
9186 ///
9187 /// **Experimental.** This API is part of an experimental wire-protocol surface
9188 /// and may change or be removed in future SDK or CLI releases. Pin both the
9189 /// SDK and CLI versions if your code depends on it.
9190 ///
9191 /// </div>
9192 pub async fn move_item(
9193 &self,
9194 params: QueueMoveItemRequest,
9195 ) -> Result<QueueMoveItemResult, Error> {
9196 let mut wire_params = serde_json::to_value(params)?;
9197 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9198 let _value = self
9199 .session
9200 .client()
9201 .call(rpc_methods::SESSION_QUEUE_MOVEITEM, Some(wire_params))
9202 .await?;
9203 Ok(serde_json::from_value(_value)?)
9204 }
9205
9206 /// Inserts a new queued message at a public visible position.
9207 ///
9208 /// Wire method: `session.queue.insertAt`.
9209 ///
9210 /// # Parameters
9211 ///
9212 /// * `params` - Parameters for inserting a queued message at a public visible position.
9213 ///
9214 /// # Returns
9215 ///
9216 /// Result of inserting a queued message.
9217 ///
9218 /// <div class="warning">
9219 ///
9220 /// **Experimental.** This API is part of an experimental wire-protocol surface
9221 /// and may change or be removed in future SDK or CLI releases. Pin both the
9222 /// SDK and CLI versions if your code depends on it.
9223 ///
9224 /// </div>
9225 pub async fn insert_at(
9226 &self,
9227 params: QueueInsertAtRequest,
9228 ) -> Result<QueueInsertAtResult, Error> {
9229 let mut wire_params = serde_json::to_value(params)?;
9230 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9231 let _value = self
9232 .session
9233 .client()
9234 .call(rpc_methods::SESSION_QUEUE_INSERTAT, Some(wire_params))
9235 .await?;
9236 Ok(serde_json::from_value(_value)?)
9237 }
9238
9239 /// Removes an addressable queued item by its stable id.
9240 ///
9241 /// Wire method: `session.queue.removeAt`.
9242 ///
9243 /// # Parameters
9244 ///
9245 /// * `params` - Parameters for removing a queued item by stable id.
9246 ///
9247 /// # Returns
9248 ///
9249 /// Result of removing a queued item.
9250 ///
9251 /// <div class="warning">
9252 ///
9253 /// **Experimental.** This API is part of an experimental wire-protocol surface
9254 /// and may change or be removed in future SDK or CLI releases. Pin both the
9255 /// SDK and CLI versions if your code depends on it.
9256 ///
9257 /// </div>
9258 pub async fn remove_at(
9259 &self,
9260 params: QueueRemoveAtRequest,
9261 ) -> Result<QueueRemoveAtResult, Error> {
9262 let mut wire_params = serde_json::to_value(params)?;
9263 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9264 let _value = self
9265 .session
9266 .client()
9267 .call(rpc_methods::SESSION_QUEUE_REMOVEAT, Some(wire_params))
9268 .await?;
9269 Ok(serde_json::from_value(_value)?)
9270 }
9271
9272 /// Updates the text of an addressable single-message queue item.
9273 ///
9274 /// Wire method: `session.queue.updateText`.
9275 ///
9276 /// # Parameters
9277 ///
9278 /// * `params` - Parameters for editing a single queued message.
9279 ///
9280 /// # Returns
9281 ///
9282 /// Result of editing a queued message.
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 async fn update_text(
9292 &self,
9293 params: QueueUpdateTextRequest,
9294 ) -> Result<QueueUpdateTextResult, Error> {
9295 let mut wire_params = serde_json::to_value(params)?;
9296 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9297 let _value = self
9298 .session
9299 .client()
9300 .call(rpc_methods::SESSION_QUEUE_UPDATETEXT, Some(wire_params))
9301 .await?;
9302 Ok(serde_json::from_value(_value)?)
9303 }
9304
9305 /// Duplicates an addressable queued item immediately after its source.
9306 ///
9307 /// Wire method: `session.queue.duplicateAt`.
9308 ///
9309 /// # Parameters
9310 ///
9311 /// * `params` - Parameters for duplicating a queued item.
9312 ///
9313 /// # Returns
9314 ///
9315 /// Result of duplicating a queued item.
9316 ///
9317 /// <div class="warning">
9318 ///
9319 /// **Experimental.** This API is part of an experimental wire-protocol surface
9320 /// and may change or be removed in future SDK or CLI releases. Pin both the
9321 /// SDK and CLI versions if your code depends on it.
9322 ///
9323 /// </div>
9324 pub async fn duplicate_at(
9325 &self,
9326 params: QueueDuplicateAtRequest,
9327 ) -> Result<QueueDuplicateAtResult, Error> {
9328 let mut wire_params = serde_json::to_value(params)?;
9329 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9330 let _value = self
9331 .session
9332 .client()
9333 .call(rpc_methods::SESSION_QUEUE_DUPLICATEAT, Some(wire_params))
9334 .await?;
9335 Ok(serde_json::from_value(_value)?)
9336 }
9337
9338 /// Acquires or releases the queued-lane drain pause.
9339 ///
9340 /// Wire method: `session.queue.setDrainPaused`.
9341 ///
9342 /// # Parameters
9343 ///
9344 /// * `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.
9345 ///
9346 /// <div class="warning">
9347 ///
9348 /// **Experimental.** This API is part of an experimental wire-protocol surface
9349 /// and may change or be removed in future SDK or CLI releases. Pin both the
9350 /// SDK and CLI versions if your code depends on it.
9351 ///
9352 /// </div>
9353 pub async fn set_drain_paused(&self, params: QueueSetDrainPausedRequest) -> Result<(), Error> {
9354 let mut wire_params = serde_json::to_value(params)?;
9355 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9356 let _value = self
9357 .session
9358 .client()
9359 .call(rpc_methods::SESSION_QUEUE_SETDRAINPAUSED, Some(wire_params))
9360 .await?;
9361 Ok(())
9362 }
9363
9364 /// Moves an addressable queued message into the live turn's steering lane.
9365 ///
9366 /// Wire method: `session.queue.sendNow`.
9367 ///
9368 /// # Parameters
9369 ///
9370 /// * `params` - Parameters for steering a queued message into a live turn.
9371 ///
9372 /// # Returns
9373 ///
9374 /// Result of trying to steer a queued message into a live turn.
9375 ///
9376 /// <div class="warning">
9377 ///
9378 /// **Experimental.** This API is part of an experimental wire-protocol surface
9379 /// and may change or be removed in future SDK or CLI releases. Pin both the
9380 /// SDK and CLI versions if your code depends on it.
9381 ///
9382 /// </div>
9383 pub async fn send_now(&self, params: QueueSendNowRequest) -> Result<QueueSendNowResult, Error> {
9384 let mut wire_params = serde_json::to_value(params)?;
9385 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9386 let _value = self
9387 .session
9388 .client()
9389 .call(rpc_methods::SESSION_QUEUE_SENDNOW, Some(wire_params))
9390 .await?;
9391 Ok(serde_json::from_value(_value)?)
9392 }
9393
9394 /// Reports whether the local session has native queued work pending.
9395 ///
9396 /// Wire method: `session.queue.hasPending`.
9397 ///
9398 /// # Returns
9399 ///
9400 /// Whether the native queue has pending work.
9401 ///
9402 /// <div class="warning">
9403 ///
9404 /// **Experimental.** This API is part of an experimental wire-protocol surface
9405 /// and may change or be removed in future SDK or CLI releases. Pin both the
9406 /// SDK and CLI versions if your code depends on it.
9407 ///
9408 /// </div>
9409 pub(crate) async fn has_pending(&self) -> Result<QueueHasPendingResult, Error> {
9410 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9411 let _value = self
9412 .session
9413 .client()
9414 .call(rpc_methods::SESSION_QUEUE_HASPENDING, Some(wire_params))
9415 .await?;
9416 Ok(serde_json::from_value(_value)?)
9417 }
9418
9419 /// Begins a native deferred-idle drain when background work has quiesced.
9420 ///
9421 /// Wire method: `session.queue.beginDeferredIdleDrain`.
9422 ///
9423 /// # Parameters
9424 ///
9425 /// * `params` - Inputs for starting a deferred-idle drain.
9426 ///
9427 /// # Returns
9428 ///
9429 /// Whether a deferred-idle drain should run.
9430 ///
9431 /// <div class="warning">
9432 ///
9433 /// **Experimental.** This API is part of an experimental wire-protocol surface
9434 /// and may change or be removed in future SDK or CLI releases. Pin both the
9435 /// SDK and CLI versions if your code depends on it.
9436 ///
9437 /// </div>
9438 pub(crate) async fn begin_deferred_idle_drain(
9439 &self,
9440 params: QueueBeginDeferredIdleDrainRequest,
9441 ) -> Result<QueueBeginDeferredIdleDrainResult, Error> {
9442 let mut wire_params = serde_json::to_value(params)?;
9443 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9444 let _value = self
9445 .session
9446 .client()
9447 .call(
9448 rpc_methods::SESSION_QUEUE_BEGINDEFERREDIDLEDRAIN,
9449 Some(wire_params),
9450 )
9451 .await?;
9452 Ok(serde_json::from_value(_value)?)
9453 }
9454
9455 /// Finishes a native deferred-idle drain and reports whether to drain queue work or emit idle.
9456 ///
9457 /// Wire method: `session.queue.finishDeferredIdleDrain`.
9458 ///
9459 /// # Parameters
9460 ///
9461 /// * `params` - Inputs for completing a deferred-idle drain.
9462 ///
9463 /// # Returns
9464 ///
9465 /// Action selected by the native deferred-idle drain.
9466 ///
9467 /// <div class="warning">
9468 ///
9469 /// **Experimental.** This API is part of an experimental wire-protocol surface
9470 /// and may change or be removed in future SDK or CLI releases. Pin both the
9471 /// SDK and CLI versions if your code depends on it.
9472 ///
9473 /// </div>
9474 pub(crate) async fn finish_deferred_idle_drain(
9475 &self,
9476 params: QueueFinishDeferredIdleDrainRequest,
9477 ) -> Result<QueueFinishDeferredIdleDrainResult, Error> {
9478 let mut wire_params = serde_json::to_value(params)?;
9479 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9480 let _value = self
9481 .session
9482 .client()
9483 .call(
9484 rpc_methods::SESSION_QUEUE_FINISHDEFERREDIDLEDRAIN,
9485 Some(wire_params),
9486 )
9487 .await?;
9488 Ok(serde_json::from_value(_value)?)
9489 }
9490
9491 /// Marks session.idle as deferred by native background work state.
9492 ///
9493 /// Wire method: `session.queue.deferSessionIdle`.
9494 ///
9495 /// # Parameters
9496 ///
9497 /// * `params` - Inputs for marking session.idle deferred in native state.
9498 ///
9499 /// <div class="warning">
9500 ///
9501 /// **Experimental.** This API is part of an experimental wire-protocol surface
9502 /// and may change or be removed in future SDK or CLI releases. Pin both the
9503 /// SDK and CLI versions if your code depends on it.
9504 ///
9505 /// </div>
9506 pub(crate) async fn defer_session_idle(
9507 &self,
9508 params: QueueDeferSessionIdleRequest,
9509 ) -> Result<(), Error> {
9510 let mut wire_params = serde_json::to_value(params)?;
9511 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9512 let _value = self
9513 .session
9514 .client()
9515 .call(
9516 rpc_methods::SESSION_QUEUE_DEFERSESSIONIDLE,
9517 Some(wire_params),
9518 )
9519 .await?;
9520 Ok(())
9521 }
9522
9523 /// Removes the most recently queued user-facing item (LIFO).
9524 ///
9525 /// Wire method: `session.queue.removeMostRecent`.
9526 ///
9527 /// # Returns
9528 ///
9529 /// Indicates whether a user-facing pending item was removed.
9530 ///
9531 /// <div class="warning">
9532 ///
9533 /// **Experimental.** This API is part of an experimental wire-protocol surface
9534 /// and may change or be removed in future SDK or CLI releases. Pin both the
9535 /// SDK and CLI versions if your code depends on it.
9536 ///
9537 /// </div>
9538 pub async fn remove_most_recent(&self) -> Result<QueueRemoveMostRecentResult, Error> {
9539 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9540 let _value = self
9541 .session
9542 .client()
9543 .call(
9544 rpc_methods::SESSION_QUEUE_REMOVEMOSTRECENT,
9545 Some(wire_params),
9546 )
9547 .await?;
9548 Ok(serde_json::from_value(_value)?)
9549 }
9550
9551 /// Clears all pending queued items on the local session.
9552 ///
9553 /// Wire method: `session.queue.clear`.
9554 ///
9555 /// <div class="warning">
9556 ///
9557 /// **Experimental.** This API is part of an experimental wire-protocol surface
9558 /// and may change or be removed in future SDK or CLI releases. Pin both the
9559 /// SDK and CLI versions if your code depends on it.
9560 ///
9561 /// </div>
9562 pub async fn clear(&self) -> Result<(), Error> {
9563 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9564 let _value = self
9565 .session
9566 .client()
9567 .call(rpc_methods::SESSION_QUEUE_CLEAR, Some(wire_params))
9568 .await?;
9569 Ok(())
9570 }
9571
9572 /// Consumes queued native system notifications matching an internal filter.
9573 ///
9574 /// Wire method: `session.queue.consumeSystemNotifications`.
9575 ///
9576 /// # Parameters
9577 ///
9578 /// * `params` - Internal filter for consuming queued system notifications.
9579 ///
9580 /// # Returns
9581 ///
9582 /// Indicates whether a user-facing pending item was removed.
9583 ///
9584 /// <div class="warning">
9585 ///
9586 /// **Experimental.** This API is part of an experimental wire-protocol surface
9587 /// and may change or be removed in future SDK or CLI releases. Pin both the
9588 /// SDK and CLI versions if your code depends on it.
9589 ///
9590 /// </div>
9591 pub(crate) async fn consume_system_notifications(
9592 &self,
9593 params: QueueConsumeSystemNotificationsRequest,
9594 ) -> Result<QueueRemoveMostRecentResult, Error> {
9595 let mut wire_params = serde_json::to_value(params)?;
9596 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9597 let _value = self
9598 .session
9599 .client()
9600 .call(
9601 rpc_methods::SESSION_QUEUE_CONSUMESYSTEMNOTIFICATIONS,
9602 Some(wire_params),
9603 )
9604 .await?;
9605 Ok(serde_json::from_value(_value)?)
9606 }
9607
9608 /// Enqueues the internal resume-pending wake item when orphan handling needs a follow-up turn.
9609 ///
9610 /// Wire method: `session.queue.enqueueResumePending`.
9611 ///
9612 /// # Returns
9613 ///
9614 /// Result of enqueueing the resume-pending wake item.
9615 ///
9616 /// <div class="warning">
9617 ///
9618 /// **Experimental.** This API is part of an experimental wire-protocol surface
9619 /// and may change or be removed in future SDK or CLI releases. Pin both the
9620 /// SDK and CLI versions if your code depends on it.
9621 ///
9622 /// </div>
9623 pub(crate) async fn enqueue_resume_pending(
9624 &self,
9625 ) -> Result<QueueEnqueueResumePendingResult, Error> {
9626 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9627 let _value = self
9628 .session
9629 .client()
9630 .call(
9631 rpc_methods::SESSION_QUEUE_ENQUEUERESUMEPENDING,
9632 Some(wire_params),
9633 )
9634 .await?;
9635 Ok(serde_json::from_value(_value)?)
9636 }
9637
9638 /// Drains the native local-session work queue for in-process session orchestration.
9639 ///
9640 /// Wire method: `session.queue.process`.
9641 ///
9642 /// <div class="warning">
9643 ///
9644 /// **Experimental.** This API is part of an experimental wire-protocol surface
9645 /// and may change or be removed in future SDK or CLI releases. Pin both the
9646 /// SDK and CLI versions if your code depends on it.
9647 ///
9648 /// </div>
9649 pub(crate) async fn process(&self) -> Result<(), Error> {
9650 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9651 let _value = self
9652 .session
9653 .client()
9654 .call(rpc_methods::SESSION_QUEUE_PROCESS, Some(wire_params))
9655 .await?;
9656 Ok(())
9657 }
9658}
9659
9660/// `session.remote.*` RPCs.
9661#[derive(Clone, Copy)]
9662pub struct SessionRpcRemote<'a> {
9663 pub(crate) session: &'a Session,
9664}
9665
9666impl<'a> SessionRpcRemote<'a> {
9667 /// Enables remote session export or steering.
9668 ///
9669 /// Wire method: `session.remote.enable`.
9670 ///
9671 /// # Parameters
9672 ///
9673 /// * `params` - Optional remote session mode ("off", "export", or "on"); defaults to enabling both export and remote steering.
9674 ///
9675 /// # Returns
9676 ///
9677 /// GitHub URL for the session and a flag indicating whether remote steering is enabled.
9678 ///
9679 /// <div class="warning">
9680 ///
9681 /// **Experimental.** This API is part of an experimental wire-protocol surface
9682 /// and may change or be removed in future SDK or CLI releases. Pin both the
9683 /// SDK and CLI versions if your code depends on it.
9684 ///
9685 /// </div>
9686 pub async fn enable(&self, params: RemoteEnableRequest) -> Result<RemoteEnableResult, Error> {
9687 let mut wire_params = serde_json::to_value(params)?;
9688 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9689 let _value = self
9690 .session
9691 .client()
9692 .call(rpc_methods::SESSION_REMOTE_ENABLE, Some(wire_params))
9693 .await?;
9694 Ok(serde_json::from_value(_value)?)
9695 }
9696
9697 /// Disables remote session export and steering.
9698 ///
9699 /// Wire method: `session.remote.disable`.
9700 ///
9701 /// <div class="warning">
9702 ///
9703 /// **Experimental.** This API is part of an experimental wire-protocol surface
9704 /// and may change or be removed in future SDK or CLI releases. Pin both the
9705 /// SDK and CLI versions if your code depends on it.
9706 ///
9707 /// </div>
9708 pub async fn disable(&self) -> Result<(), Error> {
9709 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9710 let _value = self
9711 .session
9712 .client()
9713 .call(rpc_methods::SESSION_REMOTE_DISABLE, Some(wire_params))
9714 .await?;
9715 Ok(())
9716 }
9717
9718 /// Persists a remote-steerability change emitted by the host as a session event.
9719 ///
9720 /// Wire method: `session.remote.notifySteerableChanged`.
9721 ///
9722 /// # Parameters
9723 ///
9724 /// * `params` - New remote-steerability state to persist as a `session.remote_steerable_changed` event.
9725 ///
9726 /// # Returns
9727 ///
9728 /// 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.
9729 ///
9730 /// <div class="warning">
9731 ///
9732 /// **Experimental.** This API is part of an experimental wire-protocol surface
9733 /// and may change or be removed in future SDK or CLI releases. Pin both the
9734 /// SDK and CLI versions if your code depends on it.
9735 ///
9736 /// </div>
9737 pub async fn notify_steerable_changed(
9738 &self,
9739 params: RemoteNotifySteerableChangedRequest,
9740 ) -> Result<RemoteNotifySteerableChangedResult, Error> {
9741 let mut wire_params = serde_json::to_value(params)?;
9742 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9743 let _value = self
9744 .session
9745 .client()
9746 .call(
9747 rpc_methods::SESSION_REMOTE_NOTIFYSTEERABLECHANGED,
9748 Some(wire_params),
9749 )
9750 .await?;
9751 Ok(serde_json::from_value(_value)?)
9752 }
9753}
9754
9755/// `session.sandbox.*` RPCs.
9756#[derive(Clone, Copy)]
9757pub struct SessionRpcSandbox<'a> {
9758 pub(crate) session: &'a Session,
9759}
9760
9761impl<'a> SessionRpcSandbox<'a> {
9762 /// Returns whether managed policy requires sandbox enforcement and whether an enforcement failure has permanently blocked the session.
9763 ///
9764 /// Wire method: `session.sandbox.getEnforcementStatus`.
9765 ///
9766 /// # Returns
9767 ///
9768 /// Managed sandbox enforcement state for a session.
9769 ///
9770 /// <div class="warning">
9771 ///
9772 /// **Experimental.** This API is part of an experimental wire-protocol surface
9773 /// and may change or be removed in future SDK or CLI releases. Pin both the
9774 /// SDK and CLI versions if your code depends on it.
9775 ///
9776 /// </div>
9777 pub async fn get_enforcement_status(&self) -> Result<SandboxEnforcementStatus, Error> {
9778 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9779 let _value = self
9780 .session
9781 .client()
9782 .call(
9783 rpc_methods::SESSION_SANDBOX_GETENFORCEMENTSTATUS,
9784 Some(wire_params),
9785 )
9786 .await?;
9787 Ok(serde_json::from_value(_value)?)
9788 }
9789
9790 /// Disables sandboxing for the remainder of the current session and approves the referenced pending sandbox-bypass permission request. The request is rejected unless the exact request is still pending and the effective sandbox policy permits bypass.
9791 ///
9792 /// Wire method: `session.sandbox.disableForSession`.
9793 ///
9794 /// # Parameters
9795 ///
9796 /// * `params` - Request to disable sandboxing for the current session while resolving an active sandbox-bypass permission prompt.
9797 ///
9798 /// # Returns
9799 ///
9800 /// Result of attempting to disable sandboxing for the current session.
9801 ///
9802 /// <div class="warning">
9803 ///
9804 /// **Experimental.** This API is part of an experimental wire-protocol surface
9805 /// and may change or be removed in future SDK or CLI releases. Pin both the
9806 /// SDK and CLI versions if your code depends on it.
9807 ///
9808 /// </div>
9809 pub async fn disable_for_session(
9810 &self,
9811 params: SandboxDisableForSessionRequest,
9812 ) -> Result<SandboxDisableForSessionResult, Error> {
9813 let mut wire_params = serde_json::to_value(params)?;
9814 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9815 let _value = self
9816 .session
9817 .client()
9818 .call(
9819 rpc_methods::SESSION_SANDBOX_DISABLEFORSESSION,
9820 Some(wire_params),
9821 )
9822 .await?;
9823 Ok(serde_json::from_value(_value)?)
9824 }
9825}
9826
9827/// `session.schedule.*` RPCs.
9828#[derive(Clone, Copy)]
9829pub struct SessionRpcSchedule<'a> {
9830 pub(crate) session: &'a Session,
9831}
9832
9833impl<'a> SessionRpcSchedule<'a> {
9834 /// Lists the session's currently active scheduled prompts.
9835 ///
9836 /// Wire method: `session.schedule.list`.
9837 ///
9838 /// # Returns
9839 ///
9840 /// Snapshot of the currently active recurring prompts for this session.
9841 ///
9842 /// <div class="warning">
9843 ///
9844 /// **Experimental.** This API is part of an experimental wire-protocol surface
9845 /// and may change or be removed in future SDK or CLI releases. Pin both the
9846 /// SDK and CLI versions if your code depends on it.
9847 ///
9848 /// </div>
9849 pub async fn list(&self) -> Result<ScheduleList, Error> {
9850 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9851 let _value = self
9852 .session
9853 .client()
9854 .call(rpc_methods::SESSION_SCHEDULE_LIST, Some(wire_params))
9855 .await?;
9856 Ok(serde_json::from_value(_value)?)
9857 }
9858
9859 /// Hydrates the native schedule registry from persisted session events.
9860 ///
9861 /// Wire method: `session.schedule.hydrate`.
9862 ///
9863 /// <div class="warning">
9864 ///
9865 /// **Experimental.** This API is part of an experimental wire-protocol surface
9866 /// and may change or be removed in future SDK or CLI releases. Pin both the
9867 /// SDK and CLI versions if your code depends on it.
9868 ///
9869 /// </div>
9870 pub(crate) async fn hydrate(&self) -> Result<(), Error> {
9871 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9872 let _value = self
9873 .session
9874 .client()
9875 .call(rpc_methods::SESSION_SCHEDULE_HYDRATE, Some(wire_params))
9876 .await?;
9877 Ok(())
9878 }
9879
9880 /// Reports whether the session has an active self-paced scheduled prompt.
9881 ///
9882 /// Wire method: `session.schedule.hasSelfPaced`.
9883 ///
9884 /// # Returns
9885 ///
9886 /// Whether the session currently has an active self-paced schedule.
9887 ///
9888 /// <div class="warning">
9889 ///
9890 /// **Experimental.** This API is part of an experimental wire-protocol surface
9891 /// and may change or be removed in future SDK or CLI releases. Pin both the
9892 /// SDK and CLI versions if your code depends on it.
9893 ///
9894 /// </div>
9895 pub(crate) async fn has_self_paced(&self) -> Result<ScheduleHasSelfPacedResult, Error> {
9896 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9897 let _value = self
9898 .session
9899 .client()
9900 .call(
9901 rpc_methods::SESSION_SCHEDULE_HASSELFPACED,
9902 Some(wire_params),
9903 )
9904 .await?;
9905 Ok(serde_json::from_value(_value)?)
9906 }
9907
9908 /// Registers a relative-interval scheduled prompt.
9909 ///
9910 /// Wire method: `session.schedule.add`.
9911 ///
9912 /// # Parameters
9913 ///
9914 /// * `params` - Register a relative-interval scheduled prompt.
9915 ///
9916 /// # Returns
9917 ///
9918 /// Result of registering or re-arming a scheduled prompt.
9919 ///
9920 /// <div class="warning">
9921 ///
9922 /// **Experimental.** This API is part of an experimental wire-protocol surface
9923 /// and may change or be removed in future SDK or CLI releases. Pin both the
9924 /// SDK and CLI versions if your code depends on it.
9925 ///
9926 /// </div>
9927 pub(crate) async fn add(&self, params: ScheduleAddRequest) -> Result<ScheduleAddResult, Error> {
9928 let mut wire_params = serde_json::to_value(params)?;
9929 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9930 let _value = self
9931 .session
9932 .client()
9933 .call(rpc_methods::SESSION_SCHEDULE_ADD, Some(wire_params))
9934 .await?;
9935 Ok(serde_json::from_value(_value)?)
9936 }
9937
9938 /// Registers a recurring cron scheduled prompt.
9939 ///
9940 /// Wire method: `session.schedule.addCron`.
9941 ///
9942 /// # Parameters
9943 ///
9944 /// * `params` - Register a cron scheduled prompt.
9945 ///
9946 /// # Returns
9947 ///
9948 /// Result of registering or re-arming a scheduled prompt.
9949 ///
9950 /// <div class="warning">
9951 ///
9952 /// **Experimental.** This API is part of an experimental wire-protocol surface
9953 /// and may change or be removed in future SDK or CLI releases. Pin both the
9954 /// SDK and CLI versions if your code depends on it.
9955 ///
9956 /// </div>
9957 pub(crate) async fn add_cron(
9958 &self,
9959 params: ScheduleAddCronRequest,
9960 ) -> Result<ScheduleAddResult, Error> {
9961 let mut wire_params = serde_json::to_value(params)?;
9962 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9963 let _value = self
9964 .session
9965 .client()
9966 .call(rpc_methods::SESSION_SCHEDULE_ADDCRON, Some(wire_params))
9967 .await?;
9968 Ok(serde_json::from_value(_value)?)
9969 }
9970
9971 /// Registers an absolute-time scheduled prompt.
9972 ///
9973 /// Wire method: `session.schedule.addAt`.
9974 ///
9975 /// # Parameters
9976 ///
9977 /// * `params` - Register an absolute-time scheduled prompt.
9978 ///
9979 /// # Returns
9980 ///
9981 /// Result of registering or re-arming a scheduled prompt.
9982 ///
9983 /// <div class="warning">
9984 ///
9985 /// **Experimental.** This API is part of an experimental wire-protocol surface
9986 /// and may change or be removed in future SDK or CLI releases. Pin both the
9987 /// SDK and CLI versions if your code depends on it.
9988 ///
9989 /// </div>
9990 pub(crate) async fn add_at(
9991 &self,
9992 params: ScheduleAddAtRequest,
9993 ) -> Result<ScheduleAddResult, Error> {
9994 let mut wire_params = serde_json::to_value(params)?;
9995 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9996 let _value = self
9997 .session
9998 .client()
9999 .call(rpc_methods::SESSION_SCHEDULE_ADDAT, Some(wire_params))
10000 .await?;
10001 Ok(serde_json::from_value(_value)?)
10002 }
10003
10004 /// Registers a self-paced scheduled prompt.
10005 ///
10006 /// Wire method: `session.schedule.addSelfPaced`.
10007 ///
10008 /// # Parameters
10009 ///
10010 /// * `params` - Register a self-paced scheduled prompt.
10011 ///
10012 /// # Returns
10013 ///
10014 /// Result of registering or re-arming a scheduled prompt.
10015 ///
10016 /// <div class="warning">
10017 ///
10018 /// **Experimental.** This API is part of an experimental wire-protocol surface
10019 /// and may change or be removed in future SDK or CLI releases. Pin both the
10020 /// SDK and CLI versions if your code depends on it.
10021 ///
10022 /// </div>
10023 pub(crate) async fn add_self_paced(
10024 &self,
10025 params: ScheduleAddSelfPacedRequest,
10026 ) -> Result<ScheduleAddResult, Error> {
10027 let mut wire_params = serde_json::to_value(params)?;
10028 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10029 let _value = self
10030 .session
10031 .client()
10032 .call(
10033 rpc_methods::SESSION_SCHEDULE_ADDSELFPACED,
10034 Some(wire_params),
10035 )
10036 .await?;
10037 Ok(serde_json::from_value(_value)?)
10038 }
10039
10040 /// Re-arms an active self-paced scheduled prompt.
10041 ///
10042 /// Wire method: `session.schedule.rearmSelfPaced`.
10043 ///
10044 /// # Parameters
10045 ///
10046 /// * `params` - Re-arm a self-paced scheduled prompt.
10047 ///
10048 /// # Returns
10049 ///
10050 /// Result of registering or re-arming a scheduled prompt.
10051 ///
10052 /// <div class="warning">
10053 ///
10054 /// **Experimental.** This API is part of an experimental wire-protocol surface
10055 /// and may change or be removed in future SDK or CLI releases. Pin both the
10056 /// SDK and CLI versions if your code depends on it.
10057 ///
10058 /// </div>
10059 pub(crate) async fn rearm_self_paced(
10060 &self,
10061 params: ScheduleRearmSelfPacedRequest,
10062 ) -> Result<ScheduleAddResult, Error> {
10063 let mut wire_params = serde_json::to_value(params)?;
10064 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10065 let _value = self
10066 .session
10067 .client()
10068 .call(
10069 rpc_methods::SESSION_SCHEDULE_REARMSELFPACED,
10070 Some(wire_params),
10071 )
10072 .await?;
10073 Ok(serde_json::from_value(_value)?)
10074 }
10075
10076 /// Removes a scheduled prompt by id.
10077 ///
10078 /// Wire method: `session.schedule.stop`.
10079 ///
10080 /// # Parameters
10081 ///
10082 /// * `params` - Identifier of the scheduled prompt to remove.
10083 ///
10084 /// # Returns
10085 ///
10086 /// Remove a scheduled prompt by id. The result entry is omitted if the id was unknown.
10087 ///
10088 /// <div class="warning">
10089 ///
10090 /// **Experimental.** This API is part of an experimental wire-protocol surface
10091 /// and may change or be removed in future SDK or CLI releases. Pin both the
10092 /// SDK and CLI versions if your code depends on it.
10093 ///
10094 /// </div>
10095 pub async fn stop(&self, params: ScheduleStopRequest) -> Result<ScheduleStopResult, Error> {
10096 let mut wire_params = serde_json::to_value(params)?;
10097 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10098 let _value = self
10099 .session
10100 .client()
10101 .call(rpc_methods::SESSION_SCHEDULE_STOP, Some(wire_params))
10102 .await?;
10103 Ok(serde_json::from_value(_value)?)
10104 }
10105}
10106
10107/// `session.settings.*` RPCs.
10108#[derive(Clone, Copy)]
10109pub struct SessionRpcSettings<'a> {
10110 pub(crate) session: &'a Session,
10111}
10112
10113impl<'a> SessionRpcSettings<'a> {
10114 /// 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.
10115 ///
10116 /// Wire method: `session.settings.snapshot`.
10117 ///
10118 /// # Returns
10119 ///
10120 /// Redacted, serializable view of session runtime settings for SDK boundary consumers. Secrets and raw feature flags are intentionally excluded.
10121 ///
10122 /// <div class="warning">
10123 ///
10124 /// **Experimental.** This API is part of an experimental wire-protocol surface
10125 /// and may change or be removed in future SDK or CLI releases. Pin both the
10126 /// SDK and CLI versions if your code depends on it.
10127 ///
10128 /// </div>
10129 pub(crate) async fn snapshot(&self) -> Result<SessionSettingsSnapshot, Error> {
10130 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10131 let _value = self
10132 .session
10133 .client()
10134 .call(rpc_methods::SESSION_SETTINGS_SNAPSHOT, Some(wire_params))
10135 .await?;
10136 Ok(serde_json::from_value(_value)?)
10137 }
10138
10139 /// 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.
10140 ///
10141 /// Wire method: `session.settings.evaluatePredicate`.
10142 ///
10143 /// # Parameters
10144 ///
10145 /// * `params` - Named Rust-owned settings predicate to evaluate for this session.
10146 ///
10147 /// # Returns
10148 ///
10149 /// Result of evaluating a Rust-owned settings predicate.
10150 ///
10151 /// <div class="warning">
10152 ///
10153 /// **Experimental.** This API is part of an experimental wire-protocol surface
10154 /// and may change or be removed in future SDK or CLI releases. Pin both the
10155 /// SDK and CLI versions if your code depends on it.
10156 ///
10157 /// </div>
10158 pub(crate) async fn evaluate_predicate(
10159 &self,
10160 params: SessionSettingsEvaluatePredicateRequest,
10161 ) -> Result<SessionSettingsEvaluatePredicateResult, Error> {
10162 let mut wire_params = serde_json::to_value(params)?;
10163 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10164 let _value = self
10165 .session
10166 .client()
10167 .call(
10168 rpc_methods::SESSION_SETTINGS_EVALUATEPREDICATE,
10169 Some(wire_params),
10170 )
10171 .await?;
10172 Ok(serde_json::from_value(_value)?)
10173 }
10174}
10175
10176/// `session.shell.*` RPCs.
10177#[derive(Clone, Copy)]
10178pub struct SessionRpcShell<'a> {
10179 pub(crate) session: &'a Session,
10180}
10181
10182impl<'a> SessionRpcShell<'a> {
10183 /// 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.
10184 ///
10185 /// Wire method: `session.shell.exec`.
10186 ///
10187 /// # Parameters
10188 ///
10189 /// * `params` - Shell command to run, with optional working directory and timeout in milliseconds.
10190 ///
10191 /// # Returns
10192 ///
10193 /// Identifier of the spawned process, used to correlate streamed output and exit notifications.
10194 ///
10195 /// <div class="warning">
10196 ///
10197 /// **Experimental.** This API is part of an experimental wire-protocol surface
10198 /// and may change or be removed in future SDK or CLI releases. Pin both the
10199 /// SDK and CLI versions if your code depends on it.
10200 ///
10201 /// </div>
10202 pub async fn exec(&self, params: ShellExecRequest) -> Result<ShellExecResult, Error> {
10203 let mut wire_params = serde_json::to_value(params)?;
10204 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10205 let _value = self
10206 .session
10207 .client()
10208 .call(rpc_methods::SESSION_SHELL_EXEC, Some(wire_params))
10209 .await?;
10210 Ok(serde_json::from_value(_value)?)
10211 }
10212
10213 /// 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.
10214 ///
10215 /// Wire method: `session.shell.kill`.
10216 ///
10217 /// # Parameters
10218 ///
10219 /// * `params` - Identifier of a process previously returned by "shell.exec" and the signal to send.
10220 ///
10221 /// # Returns
10222 ///
10223 /// Indicates whether the signal was delivered; false if the process was unknown or already exited.
10224 ///
10225 /// <div class="warning">
10226 ///
10227 /// **Experimental.** This API is part of an experimental wire-protocol surface
10228 /// and may change or be removed in future SDK or CLI releases. Pin both the
10229 /// SDK and CLI versions if your code depends on it.
10230 ///
10231 /// </div>
10232 pub async fn kill(&self, params: ShellKillRequest) -> Result<ShellKillResult, Error> {
10233 let mut wire_params = serde_json::to_value(params)?;
10234 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10235 let _value = self
10236 .session
10237 .client()
10238 .call(rpc_methods::SESSION_SHELL_KILL, Some(wire_params))
10239 .await?;
10240 Ok(serde_json::from_value(_value)?)
10241 }
10242
10243 /// Executes a user-requested shell command through the session runtime.
10244 ///
10245 /// Wire method: `session.shell.executeUserRequested`.
10246 ///
10247 /// # Parameters
10248 ///
10249 /// * `params` - User-requested shell command and cancellation handle.
10250 ///
10251 /// # Returns
10252 ///
10253 /// Result of a user-requested shell command.
10254 ///
10255 /// <div class="warning">
10256 ///
10257 /// **Experimental.** This API is part of an experimental wire-protocol surface
10258 /// and may change or be removed in future SDK or CLI releases. Pin both the
10259 /// SDK and CLI versions if your code depends on it.
10260 ///
10261 /// </div>
10262 pub async fn execute_user_requested(
10263 &self,
10264 params: ShellExecuteUserRequestedRequest,
10265 ) -> Result<UserRequestedShellCommandResult, Error> {
10266 let mut wire_params = serde_json::to_value(params)?;
10267 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10268 let _value = self
10269 .session
10270 .client()
10271 .call(
10272 rpc_methods::SESSION_SHELL_EXECUTEUSERREQUESTED,
10273 Some(wire_params),
10274 )
10275 .await?;
10276 Ok(serde_json::from_value(_value)?)
10277 }
10278
10279 /// Cancels a user-requested shell command by request ID.
10280 ///
10281 /// Wire method: `session.shell.cancelUserRequested`.
10282 ///
10283 /// # Parameters
10284 ///
10285 /// * `params` - User-requested shell execution cancellation handle.
10286 ///
10287 /// # Returns
10288 ///
10289 /// Cancellation result for a user-requested shell command.
10290 ///
10291 /// <div class="warning">
10292 ///
10293 /// **Experimental.** This API is part of an experimental wire-protocol surface
10294 /// and may change or be removed in future SDK or CLI releases. Pin both the
10295 /// SDK and CLI versions if your code depends on it.
10296 ///
10297 /// </div>
10298 pub async fn cancel_user_requested(
10299 &self,
10300 params: ShellCancelUserRequestedRequest,
10301 ) -> Result<CancelUserRequestedShellCommandResult, Error> {
10302 let mut wire_params = serde_json::to_value(params)?;
10303 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10304 let _value = self
10305 .session
10306 .client()
10307 .call(
10308 rpc_methods::SESSION_SHELL_CANCELUSERREQUESTED,
10309 Some(wire_params),
10310 )
10311 .await?;
10312 Ok(serde_json::from_value(_value)?)
10313 }
10314}
10315
10316/// `session.skills.*` RPCs.
10317#[derive(Clone, Copy)]
10318pub struct SessionRpcSkills<'a> {
10319 pub(crate) session: &'a Session,
10320}
10321
10322impl<'a> SessionRpcSkills<'a> {
10323 /// Lists skills available to the session.
10324 ///
10325 /// Wire method: `session.skills.list`.
10326 ///
10327 /// # Returns
10328 ///
10329 /// Skills available to the session, with their enabled state.
10330 ///
10331 /// <div class="warning">
10332 ///
10333 /// **Experimental.** This API is part of an experimental wire-protocol surface
10334 /// and may change or be removed in future SDK or CLI releases. Pin both the
10335 /// SDK and CLI versions if your code depends on it.
10336 ///
10337 /// </div>
10338 pub async fn list(&self) -> Result<SkillList, Error> {
10339 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10340 let _value = self
10341 .session
10342 .client()
10343 .call(rpc_methods::SESSION_SKILLS_LIST, Some(wire_params))
10344 .await?;
10345 Ok(serde_json::from_value(_value)?)
10346 }
10347
10348 /// Returns the skills that have been invoked during this session.
10349 ///
10350 /// Wire method: `session.skills.getInvoked`.
10351 ///
10352 /// # Returns
10353 ///
10354 /// Skills invoked during this session, ordered by invocation time (most recent last).
10355 ///
10356 /// <div class="warning">
10357 ///
10358 /// **Experimental.** This API is part of an experimental wire-protocol surface
10359 /// and may change or be removed in future SDK or CLI releases. Pin both the
10360 /// SDK and CLI versions if your code depends on it.
10361 ///
10362 /// </div>
10363 pub async fn get_invoked(&self) -> Result<SkillsGetInvokedResult, Error> {
10364 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10365 let _value = self
10366 .session
10367 .client()
10368 .call(rpc_methods::SESSION_SKILLS_GETINVOKED, Some(wire_params))
10369 .await?;
10370 Ok(serde_json::from_value(_value)?)
10371 }
10372
10373 /// Enables a skill for the session.
10374 ///
10375 /// Wire method: `session.skills.enable`.
10376 ///
10377 /// # Parameters
10378 ///
10379 /// * `params` - Name of the skill to enable for the session.
10380 ///
10381 /// <div class="warning">
10382 ///
10383 /// **Experimental.** This API is part of an experimental wire-protocol surface
10384 /// and may change or be removed in future SDK or CLI releases. Pin both the
10385 /// SDK and CLI versions if your code depends on it.
10386 ///
10387 /// </div>
10388 pub async fn enable(&self, params: SkillsEnableRequest) -> Result<(), Error> {
10389 let mut wire_params = serde_json::to_value(params)?;
10390 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10391 let _value = self
10392 .session
10393 .client()
10394 .call(rpc_methods::SESSION_SKILLS_ENABLE, Some(wire_params))
10395 .await?;
10396 Ok(())
10397 }
10398
10399 /// Disables a skill for the session.
10400 ///
10401 /// Wire method: `session.skills.disable`.
10402 ///
10403 /// # Parameters
10404 ///
10405 /// * `params` - Name of the skill to disable for the session.
10406 ///
10407 /// <div class="warning">
10408 ///
10409 /// **Experimental.** This API is part of an experimental wire-protocol surface
10410 /// and may change or be removed in future SDK or CLI releases. Pin both the
10411 /// SDK and CLI versions if your code depends on it.
10412 ///
10413 /// </div>
10414 pub async fn disable(&self, params: SkillsDisableRequest) -> Result<(), Error> {
10415 let mut wire_params = serde_json::to_value(params)?;
10416 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10417 let _value = self
10418 .session
10419 .client()
10420 .call(rpc_methods::SESSION_SKILLS_DISABLE, Some(wire_params))
10421 .await?;
10422 Ok(())
10423 }
10424
10425 /// Reloads skill definitions for the session.
10426 ///
10427 /// Wire method: `session.skills.reload`.
10428 ///
10429 /// # Returns
10430 ///
10431 /// Diagnostics from reloading skill definitions, with warnings and errors as separate lists.
10432 ///
10433 /// <div class="warning">
10434 ///
10435 /// **Experimental.** This API is part of an experimental wire-protocol surface
10436 /// and may change or be removed in future SDK or CLI releases. Pin both the
10437 /// SDK and CLI versions if your code depends on it.
10438 ///
10439 /// </div>
10440 pub async fn reload(&self) -> Result<SkillsLoadDiagnostics, Error> {
10441 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10442 let _value = self
10443 .session
10444 .client()
10445 .call(rpc_methods::SESSION_SKILLS_RELOAD, Some(wire_params))
10446 .await?;
10447 Ok(serde_json::from_value(_value)?)
10448 }
10449
10450 /// Ensures the session's skill definitions have been loaded from disk.
10451 ///
10452 /// Wire method: `session.skills.ensureLoaded`.
10453 ///
10454 /// <div class="warning">
10455 ///
10456 /// **Experimental.** This API is part of an experimental wire-protocol surface
10457 /// and may change or be removed in future SDK or CLI releases. Pin both the
10458 /// SDK and CLI versions if your code depends on it.
10459 ///
10460 /// </div>
10461 pub async fn ensure_loaded(&self) -> Result<(), Error> {
10462 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10463 let _value = self
10464 .session
10465 .client()
10466 .call(rpc_methods::SESSION_SKILLS_ENSURELOADED, Some(wire_params))
10467 .await?;
10468 Ok(())
10469 }
10470}
10471
10472/// `session.tasks.*` RPCs.
10473#[derive(Clone, Copy)]
10474pub struct SessionRpcTasks<'a> {
10475 pub(crate) session: &'a Session,
10476}
10477
10478impl<'a> SessionRpcTasks<'a> {
10479 /// Starts a background agent task in the session.
10480 ///
10481 /// Wire method: `session.tasks.startAgent`.
10482 ///
10483 /// # Parameters
10484 ///
10485 /// * `params` - Agent type, prompt, name, and optional description and model override for the new task.
10486 ///
10487 /// # Returns
10488 ///
10489 /// Identifier assigned to the newly started background agent task.
10490 ///
10491 /// <div class="warning">
10492 ///
10493 /// **Experimental.** This API is part of an experimental wire-protocol surface
10494 /// and may change or be removed in future SDK or CLI releases. Pin both the
10495 /// SDK and CLI versions if your code depends on it.
10496 ///
10497 /// </div>
10498 pub async fn start_agent(
10499 &self,
10500 params: TasksStartAgentRequest,
10501 ) -> Result<TasksStartAgentResult, Error> {
10502 let mut wire_params = serde_json::to_value(params)?;
10503 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10504 let _value = self
10505 .session
10506 .client()
10507 .call(rpc_methods::SESSION_TASKS_STARTAGENT, Some(wire_params))
10508 .await?;
10509 Ok(serde_json::from_value(_value)?)
10510 }
10511
10512 /// Lists background tasks tracked by the session.
10513 ///
10514 /// Wire method: `session.tasks.list`.
10515 ///
10516 /// # Returns
10517 ///
10518 /// Background tasks currently tracked by the session.
10519 ///
10520 /// <div class="warning">
10521 ///
10522 /// **Experimental.** This API is part of an experimental wire-protocol surface
10523 /// and may change or be removed in future SDK or CLI releases. Pin both the
10524 /// SDK and CLI versions if your code depends on it.
10525 ///
10526 /// </div>
10527 pub async fn list(&self) -> Result<TaskList, Error> {
10528 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10529 let _value = self
10530 .session
10531 .client()
10532 .call(rpc_methods::SESSION_TASKS_LIST, Some(wire_params))
10533 .await?;
10534 Ok(serde_json::from_value(_value)?)
10535 }
10536
10537 /// Registers a client-owned task, or reclaims an orphaned task belonging to the same extension principal.
10538 ///
10539 /// Wire method: `session.tasks.register`.
10540 ///
10541 /// # Parameters
10542 ///
10543 /// * `params` - Registers or reclaims a client-owned task.
10544 ///
10545 /// # Returns
10546 ///
10547 /// Result of registering or reclaiming a client-owned task.
10548 ///
10549 /// <div class="warning">
10550 ///
10551 /// **Experimental.** This API is part of an experimental wire-protocol surface
10552 /// and may change or be removed in future SDK or CLI releases. Pin both the
10553 /// SDK and CLI versions if your code depends on it.
10554 ///
10555 /// </div>
10556 pub async fn register(
10557 &self,
10558 params: TasksRegisterRequest,
10559 ) -> Result<TasksRegisterResult, Error> {
10560 let mut wire_params = serde_json::to_value(params)?;
10561 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10562 let _value = self
10563 .session
10564 .client()
10565 .call(rpc_methods::SESSION_TASKS_REGISTER, Some(wire_params))
10566 .await?;
10567 Ok(serde_json::from_value(_value)?)
10568 }
10569
10570 /// Publishes generic progress or a terminal outcome for a client-owned task.
10571 ///
10572 /// Wire method: `session.tasks.update`.
10573 ///
10574 /// # Parameters
10575 ///
10576 /// * `params` - Updates a client-owned task.
10577 ///
10578 /// # Returns
10579 ///
10580 /// Result of publishing a client-owned task update.
10581 ///
10582 /// <div class="warning">
10583 ///
10584 /// **Experimental.** This API is part of an experimental wire-protocol surface
10585 /// and may change or be removed in future SDK or CLI releases. Pin both the
10586 /// SDK and CLI versions if your code depends on it.
10587 ///
10588 /// </div>
10589 pub async fn update(&self, params: TasksUpdateRequest) -> Result<TasksUpdateResult, Error> {
10590 let mut wire_params = serde_json::to_value(params)?;
10591 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10592 let _value = self
10593 .session
10594 .client()
10595 .call(rpc_methods::SESSION_TASKS_UPDATE, Some(wire_params))
10596 .await?;
10597 Ok(serde_json::from_value(_value)?)
10598 }
10599
10600 /// Refreshes metadata for any detached background shells the runtime knows about.
10601 ///
10602 /// Wire method: `session.tasks.refresh`.
10603 ///
10604 /// # Returns
10605 ///
10606 /// 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.
10607 ///
10608 /// <div class="warning">
10609 ///
10610 /// **Experimental.** This API is part of an experimental wire-protocol surface
10611 /// and may change or be removed in future SDK or CLI releases. Pin both the
10612 /// SDK and CLI versions if your code depends on it.
10613 ///
10614 /// </div>
10615 pub async fn refresh(&self) -> Result<TasksRefreshResult, Error> {
10616 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10617 let _value = self
10618 .session
10619 .client()
10620 .call(rpc_methods::SESSION_TASKS_REFRESH, Some(wire_params))
10621 .await?;
10622 Ok(serde_json::from_value(_value)?)
10623 }
10624
10625 /// Waits for all in-flight background tasks and any follow-up turns to settle.
10626 ///
10627 /// Wire method: `session.tasks.waitForPending`.
10628 ///
10629 /// # Returns
10630 ///
10631 /// 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).
10632 ///
10633 /// <div class="warning">
10634 ///
10635 /// **Experimental.** This API is part of an experimental wire-protocol surface
10636 /// and may change or be removed in future SDK or CLI releases. Pin both the
10637 /// SDK and CLI versions if your code depends on it.
10638 ///
10639 /// </div>
10640 pub async fn wait_for_pending(&self) -> Result<TasksWaitForPendingResult, Error> {
10641 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10642 let _value = self
10643 .session
10644 .client()
10645 .call(rpc_methods::SESSION_TASKS_WAITFORPENDING, Some(wire_params))
10646 .await?;
10647 Ok(serde_json::from_value(_value)?)
10648 }
10649
10650 /// Returns progress information for a background task by ID.
10651 ///
10652 /// Wire method: `session.tasks.getProgress`.
10653 ///
10654 /// # Parameters
10655 ///
10656 /// * `params` - Identifier of the background task to fetch progress for.
10657 ///
10658 /// # Returns
10659 ///
10660 /// Progress information for the task, or null when no task with that ID is tracked.
10661 ///
10662 /// <div class="warning">
10663 ///
10664 /// **Experimental.** This API is part of an experimental wire-protocol surface
10665 /// and may change or be removed in future SDK or CLI releases. Pin both the
10666 /// SDK and CLI versions if your code depends on it.
10667 ///
10668 /// </div>
10669 pub async fn get_progress(
10670 &self,
10671 params: TasksGetProgressRequest,
10672 ) -> Result<TasksGetProgressResult, Error> {
10673 let mut wire_params = serde_json::to_value(params)?;
10674 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10675 let _value = self
10676 .session
10677 .client()
10678 .call(rpc_methods::SESSION_TASKS_GETPROGRESS, Some(wire_params))
10679 .await?;
10680 Ok(serde_json::from_value(_value)?)
10681 }
10682
10683 /// Returns the first sync-waiting task that can currently be promoted to background mode.
10684 ///
10685 /// Wire method: `session.tasks.getCurrentPromotable`.
10686 ///
10687 /// # Returns
10688 ///
10689 /// The first sync-waiting task that can currently be promoted to background mode.
10690 ///
10691 /// <div class="warning">
10692 ///
10693 /// **Experimental.** This API is part of an experimental wire-protocol surface
10694 /// and may change or be removed in future SDK or CLI releases. Pin both the
10695 /// SDK and CLI versions if your code depends on it.
10696 ///
10697 /// </div>
10698 pub async fn get_current_promotable(&self) -> Result<TasksGetCurrentPromotableResult, Error> {
10699 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10700 let _value = self
10701 .session
10702 .client()
10703 .call(
10704 rpc_methods::SESSION_TASKS_GETCURRENTPROMOTABLE,
10705 Some(wire_params),
10706 )
10707 .await?;
10708 Ok(serde_json::from_value(_value)?)
10709 }
10710
10711 /// Promotes an eligible synchronously-waited task so it continues running in the background.
10712 ///
10713 /// Wire method: `session.tasks.promoteToBackground`.
10714 ///
10715 /// # Parameters
10716 ///
10717 /// * `params` - Identifier of the task to promote to background mode.
10718 ///
10719 /// # Returns
10720 ///
10721 /// Indicates whether the task was successfully promoted to background mode.
10722 ///
10723 /// <div class="warning">
10724 ///
10725 /// **Experimental.** This API is part of an experimental wire-protocol surface
10726 /// and may change or be removed in future SDK or CLI releases. Pin both the
10727 /// SDK and CLI versions if your code depends on it.
10728 ///
10729 /// </div>
10730 pub async fn promote_to_background(
10731 &self,
10732 params: TasksPromoteToBackgroundRequest,
10733 ) -> Result<TasksPromoteToBackgroundResult, Error> {
10734 let mut wire_params = serde_json::to_value(params)?;
10735 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10736 let _value = self
10737 .session
10738 .client()
10739 .call(
10740 rpc_methods::SESSION_TASKS_PROMOTETOBACKGROUND,
10741 Some(wire_params),
10742 )
10743 .await?;
10744 Ok(serde_json::from_value(_value)?)
10745 }
10746
10747 /// Atomically promotes the first promotable sync-waiting task to background mode and returns it.
10748 ///
10749 /// Wire method: `session.tasks.promoteCurrentToBackground`.
10750 ///
10751 /// # Returns
10752 ///
10753 /// The promoted task as it now exists in background mode, omitted if no promotable task was waiting.
10754 ///
10755 /// <div class="warning">
10756 ///
10757 /// **Experimental.** This API is part of an experimental wire-protocol surface
10758 /// and may change or be removed in future SDK or CLI releases. Pin both the
10759 /// SDK and CLI versions if your code depends on it.
10760 ///
10761 /// </div>
10762 pub async fn promote_current_to_background(
10763 &self,
10764 ) -> Result<TasksPromoteCurrentToBackgroundResult, Error> {
10765 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10766 let _value = self
10767 .session
10768 .client()
10769 .call(
10770 rpc_methods::SESSION_TASKS_PROMOTECURRENTTOBACKGROUND,
10771 Some(wire_params),
10772 )
10773 .await?;
10774 Ok(serde_json::from_value(_value)?)
10775 }
10776
10777 /// Cancels a background task.
10778 ///
10779 /// Wire method: `session.tasks.cancel`.
10780 ///
10781 /// # Parameters
10782 ///
10783 /// * `params` - Identifier of the background task to cancel.
10784 ///
10785 /// # Returns
10786 ///
10787 /// Indicates whether the background task was successfully cancelled.
10788 ///
10789 /// <div class="warning">
10790 ///
10791 /// **Experimental.** This API is part of an experimental wire-protocol surface
10792 /// and may change or be removed in future SDK or CLI releases. Pin both the
10793 /// SDK and CLI versions if your code depends on it.
10794 ///
10795 /// </div>
10796 pub async fn cancel(&self, params: TasksCancelRequest) -> Result<TasksCancelResult, Error> {
10797 let mut wire_params = serde_json::to_value(params)?;
10798 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10799 let _value = self
10800 .session
10801 .client()
10802 .call(rpc_methods::SESSION_TASKS_CANCEL, Some(wire_params))
10803 .await?;
10804 Ok(serde_json::from_value(_value)?)
10805 }
10806
10807 /// Removes a completed or cancelled background task from tracking.
10808 ///
10809 /// Wire method: `session.tasks.remove`.
10810 ///
10811 /// # Parameters
10812 ///
10813 /// * `params` - Identifier of the completed or cancelled task to remove from tracking.
10814 ///
10815 /// # Returns
10816 ///
10817 /// Indicates whether the task was removed. False when the task does not exist or is still running/idle.
10818 ///
10819 /// <div class="warning">
10820 ///
10821 /// **Experimental.** This API is part of an experimental wire-protocol surface
10822 /// and may change or be removed in future SDK or CLI releases. Pin both the
10823 /// SDK and CLI versions if your code depends on it.
10824 ///
10825 /// </div>
10826 pub async fn remove(&self, params: TasksRemoveRequest) -> Result<TasksRemoveResult, Error> {
10827 let mut wire_params = serde_json::to_value(params)?;
10828 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10829 let _value = self
10830 .session
10831 .client()
10832 .call(rpc_methods::SESSION_TASKS_REMOVE, Some(wire_params))
10833 .await?;
10834 Ok(serde_json::from_value(_value)?)
10835 }
10836
10837 /// Sends a message to a background agent task.
10838 ///
10839 /// Wire method: `session.tasks.sendMessage`.
10840 ///
10841 /// # Parameters
10842 ///
10843 /// * `params` - Identifier of the target agent task, message content, and optional sender agent ID.
10844 ///
10845 /// # Returns
10846 ///
10847 /// Indicates whether the message was delivered, with an error message when delivery failed.
10848 ///
10849 /// <div class="warning">
10850 ///
10851 /// **Experimental.** This API is part of an experimental wire-protocol surface
10852 /// and may change or be removed in future SDK or CLI releases. Pin both the
10853 /// SDK and CLI versions if your code depends on it.
10854 ///
10855 /// </div>
10856 pub async fn send_message(
10857 &self,
10858 params: TasksSendMessageRequest,
10859 ) -> Result<TasksSendMessageResult, Error> {
10860 let mut wire_params = serde_json::to_value(params)?;
10861 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10862 let _value = self
10863 .session
10864 .client()
10865 .call(rpc_methods::SESSION_TASKS_SENDMESSAGE, Some(wire_params))
10866 .await?;
10867 Ok(serde_json::from_value(_value)?)
10868 }
10869}
10870
10871/// `session.telemetry.*` RPCs.
10872#[derive(Clone, Copy)]
10873pub struct SessionRpcTelemetry<'a> {
10874 pub(crate) session: &'a Session,
10875}
10876
10877impl<'a> SessionRpcTelemetry<'a> {
10878 /// Gets the telemetry engagement ID currently associated with the session, when available.
10879 ///
10880 /// Wire method: `session.telemetry.getEngagementId`.
10881 ///
10882 /// # Returns
10883 ///
10884 /// Telemetry engagement ID for the session, when available.
10885 ///
10886 /// <div class="warning">
10887 ///
10888 /// **Experimental.** This API is part of an experimental wire-protocol surface
10889 /// and may change or be removed in future SDK or CLI releases. Pin both the
10890 /// SDK and CLI versions if your code depends on it.
10891 ///
10892 /// </div>
10893 pub async fn get_engagement_id(&self) -> Result<SessionTelemetryEngagement, Error> {
10894 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10895 let _value = self
10896 .session
10897 .client()
10898 .call(
10899 rpc_methods::SESSION_TELEMETRY_GETENGAGEMENTID,
10900 Some(wire_params),
10901 )
10902 .await?;
10903 Ok(serde_json::from_value(_value)?)
10904 }
10905
10906 /// Sets feature override key/value pairs to attach to subsequent telemetry events for the session.
10907 ///
10908 /// Wire method: `session.telemetry.setFeatureOverrides`.
10909 ///
10910 /// # Parameters
10911 ///
10912 /// * `params` - Feature override key/value pairs to attach to subsequent telemetry events from this session.
10913 ///
10914 /// <div class="warning">
10915 ///
10916 /// **Experimental.** This API is part of an experimental wire-protocol surface
10917 /// and may change or be removed in future SDK or CLI releases. Pin both the
10918 /// SDK and CLI versions if your code depends on it.
10919 ///
10920 /// </div>
10921 pub async fn set_feature_overrides(
10922 &self,
10923 params: TelemetrySetFeatureOverridesRequest,
10924 ) -> Result<(), Error> {
10925 let mut wire_params = serde_json::to_value(params)?;
10926 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10927 let _value = self
10928 .session
10929 .client()
10930 .call(
10931 rpc_methods::SESSION_TELEMETRY_SETFEATUREOVERRIDES,
10932 Some(wire_params),
10933 )
10934 .await?;
10935 Ok(())
10936 }
10937}
10938
10939/// `session.tools.*` RPCs.
10940#[derive(Clone, Copy)]
10941pub struct SessionRpcTools<'a> {
10942 pub(crate) session: &'a Session,
10943}
10944
10945impl<'a> SessionRpcTools<'a> {
10946 /// Executes one tool from the session's currently offered tool set through the native invocation pipeline.
10947 ///
10948 /// Wire method: `session.tools.execute`.
10949 ///
10950 /// # Parameters
10951 ///
10952 /// * `params` - A tool name and arguments to execute through the session's native invocation pipeline.
10953 ///
10954 /// # Returns
10955 ///
10956 /// Canonical result returned by a session tool.
10957 ///
10958 /// <div class="warning">
10959 ///
10960 /// **Experimental.** This API is part of an experimental wire-protocol surface
10961 /// and may change or be removed in future SDK or CLI releases. Pin both the
10962 /// SDK and CLI versions if your code depends on it.
10963 ///
10964 /// </div>
10965 pub async fn execute(&self, params: ToolsExecuteRequest) -> Result<ToolResult, Error> {
10966 let mut wire_params = serde_json::to_value(params)?;
10967 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10968 let _value = self
10969 .session
10970 .client()
10971 .call(rpc_methods::SESSION_TOOLS_EXECUTE, Some(wire_params))
10972 .await?;
10973 Ok(serde_json::from_value(_value)?)
10974 }
10975
10976 /// Returns the Rust-owned built-in tool descriptors used to construct the session's offered tool set.
10977 ///
10978 /// Wire method: `session.tools.getBuiltinDescriptors`.
10979 ///
10980 /// # Parameters
10981 ///
10982 /// * `params` - Options controlling how Rust-owned built-in tool descriptors are materialized.
10983 ///
10984 /// # Returns
10985 ///
10986 /// Rust-owned built-in tool descriptors for the session.
10987 ///
10988 /// <div class="warning">
10989 ///
10990 /// **Experimental.** This API is part of an experimental wire-protocol surface
10991 /// and may change or be removed in future SDK or CLI releases. Pin both the
10992 /// SDK and CLI versions if your code depends on it.
10993 ///
10994 /// </div>
10995 pub async fn get_builtin_descriptors(
10996 &self,
10997 params: ToolsGetBuiltinDescriptorsRequest,
10998 ) -> Result<ToolsGetBuiltinDescriptorsResult, Error> {
10999 let mut wire_params = serde_json::to_value(params)?;
11000 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11001 let _value = self
11002 .session
11003 .client()
11004 .call(
11005 rpc_methods::SESSION_TOOLS_GETBUILTINDESCRIPTORS,
11006 Some(wire_params),
11007 )
11008 .await?;
11009 Ok(serde_json::from_value(_value)?)
11010 }
11011
11012 /// Projects a completed task_complete tool call into its label-safe session event payload.
11013 ///
11014 /// Wire method: `session.tools.taskCompleteEventData`.
11015 ///
11016 /// # Parameters
11017 ///
11018 /// * `params` - Task-completion tool arguments and final result used to build a label-safe session event payload.
11019 ///
11020 /// # Returns
11021 ///
11022 /// Task completion notification with summary from the agent
11023 ///
11024 /// <div class="warning">
11025 ///
11026 /// **Experimental.** This API is part of an experimental wire-protocol surface
11027 /// and may change or be removed in future SDK or CLI releases. Pin both the
11028 /// SDK and CLI versions if your code depends on it.
11029 ///
11030 /// </div>
11031 pub async fn task_complete_event_data(
11032 &self,
11033 params: ToolsTaskCompleteEventDataRequest,
11034 ) -> Result<TaskCompleteData, Error> {
11035 let mut wire_params = serde_json::to_value(params)?;
11036 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11037 let _value = self
11038 .session
11039 .client()
11040 .call(
11041 rpc_methods::SESSION_TOOLS_TASKCOMPLETEEVENTDATA,
11042 Some(wire_params),
11043 )
11044 .await?;
11045 Ok(serde_json::from_value(_value)?)
11046 }
11047
11048 /// Provides the result for a pending external tool call.
11049 ///
11050 /// Wire method: `session.tools.handlePendingToolCall`.
11051 ///
11052 /// # Parameters
11053 ///
11054 /// * `params` - Pending external tool call request ID, with the tool result or an error describing why it failed.
11055 ///
11056 /// # Returns
11057 ///
11058 /// Indicates whether the external tool call result was handled successfully.
11059 ///
11060 /// <div class="warning">
11061 ///
11062 /// **Experimental.** This API is part of an experimental wire-protocol surface
11063 /// and may change or be removed in future SDK or CLI releases. Pin both the
11064 /// SDK and CLI versions if your code depends on it.
11065 ///
11066 /// </div>
11067 pub async fn handle_pending_tool_call(
11068 &self,
11069 params: HandlePendingToolCallRequest,
11070 ) -> Result<HandlePendingToolCallResult, Error> {
11071 let mut wire_params = serde_json::to_value(params)?;
11072 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11073 let _value = self
11074 .session
11075 .client()
11076 .call(
11077 rpc_methods::SESSION_TOOLS_HANDLEPENDINGTOOLCALL,
11078 Some(wire_params),
11079 )
11080 .await?;
11081 Ok(serde_json::from_value(_value)?)
11082 }
11083
11084 /// Resolves, builds, and validates the runtime tool list for the session.
11085 ///
11086 /// Wire method: `session.tools.initializeAndValidate`.
11087 ///
11088 /// # Returns
11089 ///
11090 /// 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.
11091 ///
11092 /// <div class="warning">
11093 ///
11094 /// **Experimental.** This API is part of an experimental wire-protocol surface
11095 /// and may change or be removed in future SDK or CLI releases. Pin both the
11096 /// SDK and CLI versions if your code depends on it.
11097 ///
11098 /// </div>
11099 pub async fn initialize_and_validate(&self) -> Result<ToolsInitializeAndValidateResult, Error> {
11100 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
11101 let _value = self
11102 .session
11103 .client()
11104 .call(
11105 rpc_methods::SESSION_TOOLS_INITIALIZEANDVALIDATE,
11106 Some(wire_params),
11107 )
11108 .await?;
11109 Ok(serde_json::from_value(_value)?)
11110 }
11111
11112 /// Returns lightweight metadata for the session's currently initialized tools.
11113 ///
11114 /// Wire method: `session.tools.getCurrentMetadata`.
11115 ///
11116 /// # Returns
11117 ///
11118 /// Current lightweight tool metadata snapshot for the session.
11119 ///
11120 /// <div class="warning">
11121 ///
11122 /// **Experimental.** This API is part of an experimental wire-protocol surface
11123 /// and may change or be removed in future SDK or CLI releases. Pin both the
11124 /// SDK and CLI versions if your code depends on it.
11125 ///
11126 /// </div>
11127 pub async fn get_current_metadata(&self) -> Result<ToolsGetCurrentMetadataResult, Error> {
11128 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
11129 let _value = self
11130 .session
11131 .client()
11132 .call(
11133 rpc_methods::SESSION_TOOLS_GETCURRENTMETADATA,
11134 Some(wire_params),
11135 )
11136 .await?;
11137 Ok(serde_json::from_value(_value)?)
11138 }
11139
11140 /// 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.
11141 ///
11142 /// Wire method: `session.tools.set`.
11143 ///
11144 /// # Parameters
11145 ///
11146 /// * `params` - Complete externally implemented tool list for the calling connection. An empty list removes every tool previously supplied by that connection.
11147 ///
11148 /// # Returns
11149 ///
11150 /// Empty result after replacing the calling connection's externally implemented tools.
11151 ///
11152 /// <div class="warning">
11153 ///
11154 /// **Experimental.** This API is part of an experimental wire-protocol surface
11155 /// and may change or be removed in future SDK or CLI releases. Pin both the
11156 /// SDK and CLI versions if your code depends on it.
11157 ///
11158 /// </div>
11159 pub async fn set(&self, params: ToolsSetRequest) -> Result<ToolsSetResult, Error> {
11160 let mut wire_params = serde_json::to_value(params)?;
11161 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11162 let _value = self
11163 .session
11164 .client()
11165 .call(rpc_methods::SESSION_TOOLS_SET, Some(wire_params))
11166 .await?;
11167 Ok(serde_json::from_value(_value)?)
11168 }
11169
11170 /// Sets the current session's live subagent settings override, which takes precedence over persisted user settings until cleared. Persisted user settings remain the source of truth for future sessions.
11171 ///
11172 /// Wire method: `session.tools.updateSubagentSettings`.
11173 ///
11174 /// # Parameters
11175 ///
11176 /// * `params` - Subagent settings to apply to the current session
11177 ///
11178 /// # Returns
11179 ///
11180 /// Empty result after applying subagent settings
11181 ///
11182 /// <div class="warning">
11183 ///
11184 /// **Experimental.** This API is part of an experimental wire-protocol surface
11185 /// and may change or be removed in future SDK or CLI releases. Pin both the
11186 /// SDK and CLI versions if your code depends on it.
11187 ///
11188 /// </div>
11189 pub async fn update_subagent_settings(
11190 &self,
11191 params: UpdateSubagentSettingsRequest,
11192 ) -> Result<ToolsUpdateSubagentSettingsResult, Error> {
11193 let mut wire_params = serde_json::to_value(params)?;
11194 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11195 let _value = self
11196 .session
11197 .client()
11198 .call(
11199 rpc_methods::SESSION_TOOLS_UPDATESUBAGENTSETTINGS,
11200 Some(wire_params),
11201 )
11202 .await?;
11203 Ok(serde_json::from_value(_value)?)
11204 }
11205}
11206
11207/// `session.ui.*` RPCs.
11208#[derive(Clone, Copy)]
11209pub struct SessionRpcUi<'a> {
11210 pub(crate) session: &'a Session,
11211}
11212
11213impl<'a> SessionRpcUi<'a> {
11214 /// Runs a transient no-tools model query against the current conversation context.
11215 ///
11216 /// Wire method: `session.ui.ephemeralQuery`.
11217 ///
11218 /// # Parameters
11219 ///
11220 /// * `params` - Transient question to answer without adding it to conversation history.
11221 ///
11222 /// # Returns
11223 ///
11224 /// Completed transient query. Ordered chunks and the terminal outcome are also delivered through `ui.ephemeral_query` session events while it runs.
11225 ///
11226 /// <div class="warning">
11227 ///
11228 /// **Experimental.** This API is part of an experimental wire-protocol surface
11229 /// and may change or be removed in future SDK or CLI releases. Pin both the
11230 /// SDK and CLI versions if your code depends on it.
11231 ///
11232 /// </div>
11233 pub async fn ephemeral_query(
11234 &self,
11235 params: UIEphemeralQueryRequest,
11236 ) -> Result<UIEphemeralQueryResult, Error> {
11237 let mut wire_params = serde_json::to_value(params)?;
11238 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11239 let _value = self
11240 .session
11241 .client()
11242 .call(rpc_methods::SESSION_UI_EPHEMERALQUERY, Some(wire_params))
11243 .await?;
11244 Ok(serde_json::from_value(_value)?)
11245 }
11246
11247 /// Requests structured input from a UI-capable client.
11248 ///
11249 /// Wire method: `session.ui.elicitation`.
11250 ///
11251 /// # Parameters
11252 ///
11253 /// * `params` - Prompt message and JSON schema describing the form fields to elicit from the user.
11254 ///
11255 /// # Returns
11256 ///
11257 /// The elicitation response (accept with form values, decline, or cancel)
11258 ///
11259 /// <div class="warning">
11260 ///
11261 /// **Experimental.** This API is part of an experimental wire-protocol surface
11262 /// and may change or be removed in future SDK or CLI releases. Pin both the
11263 /// SDK and CLI versions if your code depends on it.
11264 ///
11265 /// </div>
11266 pub async fn elicitation(
11267 &self,
11268 params: UIElicitationRequest,
11269 ) -> Result<UIElicitationResponse, Error> {
11270 let mut wire_params = serde_json::to_value(params)?;
11271 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11272 let _value = self
11273 .session
11274 .client()
11275 .call(rpc_methods::SESSION_UI_ELICITATION, Some(wire_params))
11276 .await?;
11277 Ok(serde_json::from_value(_value)?)
11278 }
11279
11280 /// Provides the user response for a pending elicitation request.
11281 ///
11282 /// Wire method: `session.ui.handlePendingElicitation`.
11283 ///
11284 /// # Parameters
11285 ///
11286 /// * `params` - Pending elicitation request ID and the user's response (accept/decline/cancel + form values).
11287 ///
11288 /// # Returns
11289 ///
11290 /// Indicates whether the elicitation response was accepted; false if it was already resolved by another client.
11291 ///
11292 /// <div class="warning">
11293 ///
11294 /// **Experimental.** This API is part of an experimental wire-protocol surface
11295 /// and may change or be removed in future SDK or CLI releases. Pin both the
11296 /// SDK and CLI versions if your code depends on it.
11297 ///
11298 /// </div>
11299 pub async fn handle_pending_elicitation(
11300 &self,
11301 params: UIHandlePendingElicitationRequest,
11302 ) -> Result<UIElicitationResult, Error> {
11303 let mut wire_params = serde_json::to_value(params)?;
11304 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11305 let _value = self
11306 .session
11307 .client()
11308 .call(
11309 rpc_methods::SESSION_UI_HANDLEPENDINGELICITATION,
11310 Some(wire_params),
11311 )
11312 .await?;
11313 Ok(serde_json::from_value(_value)?)
11314 }
11315
11316 /// Resolves a pending `user_input.requested` event with the user's response.
11317 ///
11318 /// Wire method: `session.ui.handlePendingUserInput`.
11319 ///
11320 /// # Parameters
11321 ///
11322 /// * `params` - Request ID of a pending `user_input.requested` event and the user's response.
11323 ///
11324 /// # Returns
11325 ///
11326 /// Indicates whether the pending UI request was resolved by this call.
11327 ///
11328 /// <div class="warning">
11329 ///
11330 /// **Experimental.** This API is part of an experimental wire-protocol surface
11331 /// and may change or be removed in future SDK or CLI releases. Pin both the
11332 /// SDK and CLI versions if your code depends on it.
11333 ///
11334 /// </div>
11335 pub async fn handle_pending_user_input(
11336 &self,
11337 params: UIHandlePendingUserInputRequest,
11338 ) -> Result<UIHandlePendingResult, Error> {
11339 let mut wire_params = serde_json::to_value(params)?;
11340 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11341 let _value = self
11342 .session
11343 .client()
11344 .call(
11345 rpc_methods::SESSION_UI_HANDLEPENDINGUSERINPUT,
11346 Some(wire_params),
11347 )
11348 .await?;
11349 Ok(serde_json::from_value(_value)?)
11350 }
11351
11352 /// Resolves a pending `sampling.requested` event with a sampling result, or rejects it.
11353 ///
11354 /// Wire method: `session.ui.handlePendingSampling`.
11355 ///
11356 /// # Parameters
11357 ///
11358 /// * `params` - Request ID of a pending `sampling.requested` event and an optional sampling result payload (omit to reject).
11359 ///
11360 /// # Returns
11361 ///
11362 /// Indicates whether the pending UI request was resolved by this call.
11363 ///
11364 /// <div class="warning">
11365 ///
11366 /// **Experimental.** This API is part of an experimental wire-protocol surface
11367 /// and may change or be removed in future SDK or CLI releases. Pin both the
11368 /// SDK and CLI versions if your code depends on it.
11369 ///
11370 /// </div>
11371 pub async fn handle_pending_sampling(
11372 &self,
11373 params: UIHandlePendingSamplingRequest,
11374 ) -> Result<UIHandlePendingResult, Error> {
11375 let mut wire_params = serde_json::to_value(params)?;
11376 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11377 let _value = self
11378 .session
11379 .client()
11380 .call(
11381 rpc_methods::SESSION_UI_HANDLEPENDINGSAMPLING,
11382 Some(wire_params),
11383 )
11384 .await?;
11385 Ok(serde_json::from_value(_value)?)
11386 }
11387
11388 /// Resolves a pending `auto_mode_switch.requested` event with the user's accept/decline decision.
11389 ///
11390 /// Wire method: `session.ui.handlePendingAutoModeSwitch`.
11391 ///
11392 /// # Parameters
11393 ///
11394 /// * `params` - Request ID of a pending `auto_mode_switch.requested` event and the user's response.
11395 ///
11396 /// # Returns
11397 ///
11398 /// Indicates whether the pending UI request was resolved by this call.
11399 ///
11400 /// <div class="warning">
11401 ///
11402 /// **Experimental.** This API is part of an experimental wire-protocol surface
11403 /// and may change or be removed in future SDK or CLI releases. Pin both the
11404 /// SDK and CLI versions if your code depends on it.
11405 ///
11406 /// </div>
11407 pub async fn handle_pending_auto_mode_switch(
11408 &self,
11409 params: UIHandlePendingAutoModeSwitchRequest,
11410 ) -> Result<UIHandlePendingResult, Error> {
11411 let mut wire_params = serde_json::to_value(params)?;
11412 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11413 let _value = self
11414 .session
11415 .client()
11416 .call(
11417 rpc_methods::SESSION_UI_HANDLEPENDINGAUTOMODESWITCH,
11418 Some(wire_params),
11419 )
11420 .await?;
11421 Ok(serde_json::from_value(_value)?)
11422 }
11423
11424 /// Resolves a pending `session_limits_exhausted.requested` event with the user's selected limit action.
11425 ///
11426 /// Wire method: `session.ui.handlePendingSessionLimitsExhausted`.
11427 ///
11428 /// # Parameters
11429 ///
11430 /// * `params` - Request ID of a pending `session_limits_exhausted.requested` event and the user's selected limit action.
11431 ///
11432 /// # Returns
11433 ///
11434 /// Indicates whether the pending UI request was resolved by this call.
11435 ///
11436 /// <div class="warning">
11437 ///
11438 /// **Experimental.** This API is part of an experimental wire-protocol surface
11439 /// and may change or be removed in future SDK or CLI releases. Pin both the
11440 /// SDK and CLI versions if your code depends on it.
11441 ///
11442 /// </div>
11443 pub async fn handle_pending_session_limits_exhausted(
11444 &self,
11445 params: UIHandlePendingSessionLimitsExhaustedRequest,
11446 ) -> Result<UIHandlePendingResult, Error> {
11447 let mut wire_params = serde_json::to_value(params)?;
11448 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11449 let _value = self
11450 .session
11451 .client()
11452 .call(
11453 rpc_methods::SESSION_UI_HANDLEPENDINGSESSIONLIMITSEXHAUSTED,
11454 Some(wire_params),
11455 )
11456 .await?;
11457 Ok(serde_json::from_value(_value)?)
11458 }
11459
11460 /// Resolves a pending `exit_plan_mode.requested` event with the user's response.
11461 ///
11462 /// Wire method: `session.ui.handlePendingExitPlanMode`.
11463 ///
11464 /// # Parameters
11465 ///
11466 /// * `params` - Request ID of a pending `exit_plan_mode.requested` event and the user's response.
11467 ///
11468 /// # Returns
11469 ///
11470 /// Indicates whether the pending UI request was resolved by this call.
11471 ///
11472 /// <div class="warning">
11473 ///
11474 /// **Experimental.** This API is part of an experimental wire-protocol surface
11475 /// and may change or be removed in future SDK or CLI releases. Pin both the
11476 /// SDK and CLI versions if your code depends on it.
11477 ///
11478 /// </div>
11479 pub async fn handle_pending_exit_plan_mode(
11480 &self,
11481 params: UIHandlePendingExitPlanModeRequest,
11482 ) -> Result<UIHandlePendingResult, Error> {
11483 let mut wire_params = serde_json::to_value(params)?;
11484 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11485 let _value = self
11486 .session
11487 .client()
11488 .call(
11489 rpc_methods::SESSION_UI_HANDLEPENDINGEXITPLANMODE,
11490 Some(wire_params),
11491 )
11492 .await?;
11493 Ok(serde_json::from_value(_value)?)
11494 }
11495
11496 /// Registers an in-process handler for auto-mode-switch requests so the server bridge skips dispatch.
11497 ///
11498 /// Wire method: `session.ui.registerDirectAutoModeSwitchHandler`.
11499 ///
11500 /// # Returns
11501 ///
11502 /// 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).
11503 ///
11504 /// <div class="warning">
11505 ///
11506 /// **Experimental.** This API is part of an experimental wire-protocol surface
11507 /// and may change or be removed in future SDK or CLI releases. Pin both the
11508 /// SDK and CLI versions if your code depends on it.
11509 ///
11510 /// </div>
11511 pub async fn register_direct_auto_mode_switch_handler(
11512 &self,
11513 ) -> Result<UIRegisterDirectAutoModeSwitchHandlerResult, Error> {
11514 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
11515 let _value = self
11516 .session
11517 .client()
11518 .call(
11519 rpc_methods::SESSION_UI_REGISTERDIRECTAUTOMODESWITCHHANDLER,
11520 Some(wire_params),
11521 )
11522 .await?;
11523 Ok(serde_json::from_value(_value)?)
11524 }
11525
11526 /// Unregisters a previously-registered in-process auto-mode-switch handler by its opaque handle.
11527 ///
11528 /// Wire method: `session.ui.unregisterDirectAutoModeSwitchHandler`.
11529 ///
11530 /// # Parameters
11531 ///
11532 /// * `params` - Opaque handle previously returned by `registerDirectAutoModeSwitchHandler` to release.
11533 ///
11534 /// # Returns
11535 ///
11536 /// Indicates whether the handle was active and the registration count was decremented.
11537 ///
11538 /// <div class="warning">
11539 ///
11540 /// **Experimental.** This API is part of an experimental wire-protocol surface
11541 /// and may change or be removed in future SDK or CLI releases. Pin both the
11542 /// SDK and CLI versions if your code depends on it.
11543 ///
11544 /// </div>
11545 pub async fn unregister_direct_auto_mode_switch_handler(
11546 &self,
11547 params: UIUnregisterDirectAutoModeSwitchHandlerRequest,
11548 ) -> Result<UIUnregisterDirectAutoModeSwitchHandlerResult, Error> {
11549 let mut wire_params = serde_json::to_value(params)?;
11550 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11551 let _value = self
11552 .session
11553 .client()
11554 .call(
11555 rpc_methods::SESSION_UI_UNREGISTERDIRECTAUTOMODESWITCHHANDLER,
11556 Some(wire_params),
11557 )
11558 .await?;
11559 Ok(serde_json::from_value(_value)?)
11560 }
11561}
11562
11563/// `session.usage.*` RPCs.
11564#[derive(Clone, Copy)]
11565pub struct SessionRpcUsage<'a> {
11566 pub(crate) session: &'a Session,
11567}
11568
11569impl<'a> SessionRpcUsage<'a> {
11570 /// Gets accumulated usage metrics for the session.
11571 ///
11572 /// Wire method: `session.usage.getMetrics`.
11573 ///
11574 /// # Returns
11575 ///
11576 /// Accumulated session usage metrics, including premium request cost, token counts, model breakdown, and code-change totals.
11577 ///
11578 /// <div class="warning">
11579 ///
11580 /// **Experimental.** This API is part of an experimental wire-protocol surface
11581 /// and may change or be removed in future SDK or CLI releases. Pin both the
11582 /// SDK and CLI versions if your code depends on it.
11583 ///
11584 /// </div>
11585 pub async fn get_metrics(&self) -> Result<UsageGetMetricsResult, Error> {
11586 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
11587 let _value = self
11588 .session
11589 .client()
11590 .call(rpc_methods::SESSION_USAGE_GETMETRICS, Some(wire_params))
11591 .await?;
11592 Ok(serde_json::from_value(_value)?)
11593 }
11594}
11595
11596/// `session.visibility.*` RPCs.
11597#[derive(Clone, Copy)]
11598pub struct SessionRpcVisibility<'a> {
11599 pub(crate) session: &'a Session,
11600}
11601
11602impl<'a> SessionRpcVisibility<'a> {
11603 /// 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").
11604 ///
11605 /// Wire method: `session.visibility.get`.
11606 ///
11607 /// # Returns
11608 ///
11609 /// Current sharing status and shareable GitHub URL for a session.
11610 ///
11611 /// <div class="warning">
11612 ///
11613 /// **Experimental.** This API is part of an experimental wire-protocol surface
11614 /// and may change or be removed in future SDK or CLI releases. Pin both the
11615 /// SDK and CLI versions if your code depends on it.
11616 ///
11617 /// </div>
11618 pub async fn get(&self) -> Result<VisibilityGetResult, Error> {
11619 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
11620 let _value = self
11621 .session
11622 .client()
11623 .call(rpc_methods::SESSION_VISIBILITY_GET, Some(wire_params))
11624 .await?;
11625 Ok(serde_json::from_value(_value)?)
11626 }
11627
11628 /// 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.
11629 ///
11630 /// Wire method: `session.visibility.set`.
11631 ///
11632 /// # Parameters
11633 ///
11634 /// * `params` - Desired sharing status for the session.
11635 ///
11636 /// # Returns
11637 ///
11638 /// Effective sharing status and shareable GitHub URL after updating session visibility.
11639 ///
11640 /// <div class="warning">
11641 ///
11642 /// **Experimental.** This API is part of an experimental wire-protocol surface
11643 /// and may change or be removed in future SDK or CLI releases. Pin both the
11644 /// SDK and CLI versions if your code depends on it.
11645 ///
11646 /// </div>
11647 pub async fn set(&self, params: VisibilitySetRequest) -> Result<VisibilitySetResult, Error> {
11648 let mut wire_params = serde_json::to_value(params)?;
11649 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11650 let _value = self
11651 .session
11652 .client()
11653 .call(rpc_methods::SESSION_VISIBILITY_SET, Some(wire_params))
11654 .await?;
11655 Ok(serde_json::from_value(_value)?)
11656 }
11657}
11658
11659/// `session.workspaces.*` RPCs.
11660#[derive(Clone, Copy)]
11661pub struct SessionRpcWorkspaces<'a> {
11662 pub(crate) session: &'a Session,
11663}
11664
11665impl<'a> SessionRpcWorkspaces<'a> {
11666 /// Gets current workspace metadata for the session.
11667 ///
11668 /// Wire method: `session.workspaces.getWorkspace`.
11669 ///
11670 /// # Returns
11671 ///
11672 /// Current workspace metadata for the session, including its absolute filesystem path when available.
11673 ///
11674 /// <div class="warning">
11675 ///
11676 /// **Experimental.** This API is part of an experimental wire-protocol surface
11677 /// and may change or be removed in future SDK or CLI releases. Pin both the
11678 /// SDK and CLI versions if your code depends on it.
11679 ///
11680 /// </div>
11681 pub async fn get_workspace(&self) -> Result<WorkspacesGetWorkspaceResult, Error> {
11682 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
11683 let _value = self
11684 .session
11685 .client()
11686 .call(
11687 rpc_methods::SESSION_WORKSPACES_GETWORKSPACE,
11688 Some(wire_params),
11689 )
11690 .await?;
11691 Ok(serde_json::from_value(_value)?)
11692 }
11693
11694 /// Updates workspace metadata for a local session and returns the refreshed workspace.
11695 ///
11696 /// Wire method: `session.workspaces.updateMetadata`.
11697 ///
11698 /// # Parameters
11699 ///
11700 /// * `params` - Workspace metadata fields to update.
11701 ///
11702 /// # Returns
11703 ///
11704 /// Current workspace metadata for the session, including its absolute filesystem path when available.
11705 ///
11706 /// <div class="warning">
11707 ///
11708 /// **Experimental.** This API is part of an experimental wire-protocol surface
11709 /// and may change or be removed in future SDK or CLI releases. Pin both the
11710 /// SDK and CLI versions if your code depends on it.
11711 ///
11712 /// </div>
11713 pub async fn update_metadata(
11714 &self,
11715 params: WorkspacesUpdateMetadataRequest,
11716 ) -> Result<WorkspacesGetWorkspaceResult, Error> {
11717 let mut wire_params = serde_json::to_value(params)?;
11718 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11719 let _value = self
11720 .session
11721 .client()
11722 .call(
11723 rpc_methods::SESSION_WORKSPACES_UPDATEMETADATA,
11724 Some(wire_params),
11725 )
11726 .await?;
11727 Ok(serde_json::from_value(_value)?)
11728 }
11729
11730 /// Ensures a local session workspace exists and returns it.
11731 ///
11732 /// Wire method: `session.workspaces.ensure`.
11733 ///
11734 /// # Parameters
11735 ///
11736 /// * `params` - Optional session context used when creating a local workspace.
11737 ///
11738 /// # Returns
11739 ///
11740 /// Current workspace metadata for the session, including its absolute filesystem path when available.
11741 ///
11742 /// <div class="warning">
11743 ///
11744 /// **Experimental.** This API is part of an experimental wire-protocol surface
11745 /// and may change or be removed in future SDK or CLI releases. Pin both the
11746 /// SDK and CLI versions if your code depends on it.
11747 ///
11748 /// </div>
11749 pub async fn ensure(
11750 &self,
11751 params: WorkspacesEnsureRequest,
11752 ) -> Result<WorkspacesGetWorkspaceResult, Error> {
11753 let mut wire_params = serde_json::to_value(params)?;
11754 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11755 let _value = self
11756 .session
11757 .client()
11758 .call(rpc_methods::SESSION_WORKSPACES_ENSURE, Some(wire_params))
11759 .await?;
11760 Ok(serde_json::from_value(_value)?)
11761 }
11762
11763 /// Lists files stored in the session workspace files directory.
11764 ///
11765 /// Wire method: `session.workspaces.listFiles`.
11766 ///
11767 /// # Returns
11768 ///
11769 /// Relative paths of files stored in the session workspace files directory.
11770 ///
11771 /// <div class="warning">
11772 ///
11773 /// **Experimental.** This API is part of an experimental wire-protocol surface
11774 /// and may change or be removed in future SDK or CLI releases. Pin both the
11775 /// SDK and CLI versions if your code depends on it.
11776 ///
11777 /// </div>
11778 pub async fn list_files(&self) -> Result<WorkspacesListFilesResult, Error> {
11779 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
11780 let _value = self
11781 .session
11782 .client()
11783 .call(rpc_methods::SESSION_WORKSPACES_LISTFILES, Some(wire_params))
11784 .await?;
11785 Ok(serde_json::from_value(_value)?)
11786 }
11787
11788 /// Reads a file from the session workspace files directory.
11789 ///
11790 /// Wire method: `session.workspaces.readFile`.
11791 ///
11792 /// # Parameters
11793 ///
11794 /// * `params` - Relative path of the workspace file to read.
11795 ///
11796 /// # Returns
11797 ///
11798 /// Contents of the requested workspace file as a UTF-8 string.
11799 ///
11800 /// <div class="warning">
11801 ///
11802 /// **Experimental.** This API is part of an experimental wire-protocol surface
11803 /// and may change or be removed in future SDK or CLI releases. Pin both the
11804 /// SDK and CLI versions if your code depends on it.
11805 ///
11806 /// </div>
11807 pub async fn read_file(
11808 &self,
11809 params: WorkspacesReadFileRequest,
11810 ) -> Result<WorkspacesReadFileResult, Error> {
11811 let mut wire_params = serde_json::to_value(params)?;
11812 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11813 let _value = self
11814 .session
11815 .client()
11816 .call(rpc_methods::SESSION_WORKSPACES_READFILE, Some(wire_params))
11817 .await?;
11818 Ok(serde_json::from_value(_value)?)
11819 }
11820
11821 /// Creates or overwrites a file in the session workspace files directory.
11822 ///
11823 /// Wire method: `session.workspaces.createFile`.
11824 ///
11825 /// # Parameters
11826 ///
11827 /// * `params` - Relative path and UTF-8 content for the workspace file to create or overwrite.
11828 ///
11829 /// <div class="warning">
11830 ///
11831 /// **Experimental.** This API is part of an experimental wire-protocol surface
11832 /// and may change or be removed in future SDK or CLI releases. Pin both the
11833 /// SDK and CLI versions if your code depends on it.
11834 ///
11835 /// </div>
11836 pub async fn create_file(&self, params: WorkspacesCreateFileRequest) -> Result<(), Error> {
11837 let mut wire_params = serde_json::to_value(params)?;
11838 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11839 let _value = self
11840 .session
11841 .client()
11842 .call(
11843 rpc_methods::SESSION_WORKSPACES_CREATEFILE,
11844 Some(wire_params),
11845 )
11846 .await?;
11847 Ok(())
11848 }
11849
11850 /// Returns metadata for a file or directory in the session workspace files directory.
11851 ///
11852 /// Wire method: `session.workspaces.statFile`.
11853 ///
11854 /// # Parameters
11855 ///
11856 /// * `params` - Relative path of the workspace file or directory to inspect.
11857 ///
11858 /// # Returns
11859 ///
11860 /// Filesystem metadata for a path in the session workspace files directory.
11861 ///
11862 /// <div class="warning">
11863 ///
11864 /// **Experimental.** This API is part of an experimental wire-protocol surface
11865 /// and may change or be removed in future SDK or CLI releases. Pin both the
11866 /// SDK and CLI versions if your code depends on it.
11867 ///
11868 /// </div>
11869 pub async fn stat_file(
11870 &self,
11871 params: WorkspacesStatFileRequest,
11872 ) -> Result<WorkspacesStatFileResult, Error> {
11873 let mut wire_params = serde_json::to_value(params)?;
11874 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11875 let _value = self
11876 .session
11877 .client()
11878 .call(rpc_methods::SESSION_WORKSPACES_STATFILE, Some(wire_params))
11879 .await?;
11880 Ok(serde_json::from_value(_value)?)
11881 }
11882
11883 /// Creates a directory in the session workspace files directory.
11884 ///
11885 /// Wire method: `session.workspaces.createDirectory`.
11886 ///
11887 /// # Parameters
11888 ///
11889 /// * `params` - Directory to create within the session workspace files directory.
11890 ///
11891 /// <div class="warning">
11892 ///
11893 /// **Experimental.** This API is part of an experimental wire-protocol surface
11894 /// and may change or be removed in future SDK or CLI releases. Pin both the
11895 /// SDK and CLI versions if your code depends on it.
11896 ///
11897 /// </div>
11898 pub async fn create_directory(
11899 &self,
11900 params: WorkspacesCreateDirectoryRequest,
11901 ) -> Result<(), Error> {
11902 let mut wire_params = serde_json::to_value(params)?;
11903 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11904 let _value = self
11905 .session
11906 .client()
11907 .call(
11908 rpc_methods::SESSION_WORKSPACES_CREATEDIRECTORY,
11909 Some(wire_params),
11910 )
11911 .await?;
11912 Ok(())
11913 }
11914
11915 /// Removes a file or directory from the session workspace files directory.
11916 ///
11917 /// Wire method: `session.workspaces.removePath`.
11918 ///
11919 /// # Parameters
11920 ///
11921 /// * `params` - File or directory to remove from the session workspace files directory.
11922 ///
11923 /// <div class="warning">
11924 ///
11925 /// **Experimental.** This API is part of an experimental wire-protocol surface
11926 /// and may change or be removed in future SDK or CLI releases. Pin both the
11927 /// SDK and CLI versions if your code depends on it.
11928 ///
11929 /// </div>
11930 pub async fn remove_path(&self, params: WorkspacesRemovePathRequest) -> Result<(), Error> {
11931 let mut wire_params = serde_json::to_value(params)?;
11932 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11933 let _value = self
11934 .session
11935 .client()
11936 .call(
11937 rpc_methods::SESSION_WORKSPACES_REMOVEPATH,
11938 Some(wire_params),
11939 )
11940 .await?;
11941 Ok(())
11942 }
11943
11944 /// Renames a file or directory within the session workspace files directory.
11945 ///
11946 /// Wire method: `session.workspaces.renamePath`.
11947 ///
11948 /// # Parameters
11949 ///
11950 /// * `params` - Source and destination paths for a rename within the session workspace files directory.
11951 ///
11952 /// <div class="warning">
11953 ///
11954 /// **Experimental.** This API is part of an experimental wire-protocol surface
11955 /// and may change or be removed in future SDK or CLI releases. Pin both the
11956 /// SDK and CLI versions if your code depends on it.
11957 ///
11958 /// </div>
11959 pub async fn rename_path(&self, params: WorkspacesRenamePathRequest) -> Result<(), Error> {
11960 let mut wire_params = serde_json::to_value(params)?;
11961 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11962 let _value = self
11963 .session
11964 .client()
11965 .call(
11966 rpc_methods::SESSION_WORKSPACES_RENAMEPATH,
11967 Some(wire_params),
11968 )
11969 .await?;
11970 Ok(())
11971 }
11972
11973 /// Lists workspace checkpoints in chronological order.
11974 ///
11975 /// Wire method: `session.workspaces.listCheckpoints`.
11976 ///
11977 /// # Returns
11978 ///
11979 /// Workspace checkpoints in chronological order; empty when the workspace is not enabled.
11980 ///
11981 /// <div class="warning">
11982 ///
11983 /// **Experimental.** This API is part of an experimental wire-protocol surface
11984 /// and may change or be removed in future SDK or CLI releases. Pin both the
11985 /// SDK and CLI versions if your code depends on it.
11986 ///
11987 /// </div>
11988 pub async fn list_checkpoints(&self) -> Result<WorkspacesListCheckpointsResult, Error> {
11989 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
11990 let _value = self
11991 .session
11992 .client()
11993 .call(
11994 rpc_methods::SESSION_WORKSPACES_LISTCHECKPOINTS,
11995 Some(wire_params),
11996 )
11997 .await?;
11998 Ok(serde_json::from_value(_value)?)
11999 }
12000
12001 /// Reads the content of a workspace checkpoint by number.
12002 ///
12003 /// Wire method: `session.workspaces.readCheckpoint`.
12004 ///
12005 /// # Parameters
12006 ///
12007 /// * `params` - Checkpoint number to read.
12008 ///
12009 /// # Returns
12010 ///
12011 /// Checkpoint content as a UTF-8 string, or null when the checkpoint or workspace is missing.
12012 ///
12013 /// <div class="warning">
12014 ///
12015 /// **Experimental.** This API is part of an experimental wire-protocol surface
12016 /// and may change or be removed in future SDK or CLI releases. Pin both the
12017 /// SDK and CLI versions if your code depends on it.
12018 ///
12019 /// </div>
12020 pub async fn read_checkpoint(
12021 &self,
12022 params: WorkspacesReadCheckpointRequest,
12023 ) -> Result<WorkspacesReadCheckpointResult, Error> {
12024 let mut wire_params = serde_json::to_value(params)?;
12025 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
12026 let _value = self
12027 .session
12028 .client()
12029 .call(
12030 rpc_methods::SESSION_WORKSPACES_READCHECKPOINT,
12031 Some(wire_params),
12032 )
12033 .await?;
12034 Ok(serde_json::from_value(_value)?)
12035 }
12036
12037 /// Adds a compaction summary checkpoint to the local session workspace.
12038 ///
12039 /// Wire method: `session.workspaces.addSummary`.
12040 ///
12041 /// # Parameters
12042 ///
12043 /// * `params` - Compaction summary checkpoint to persist.
12044 ///
12045 /// # Returns
12046 ///
12047 /// Persisted summary metadata and refreshed workspace metadata.
12048 ///
12049 /// <div class="warning">
12050 ///
12051 /// **Experimental.** This API is part of an experimental wire-protocol surface
12052 /// and may change or be removed in future SDK or CLI releases. Pin both the
12053 /// SDK and CLI versions if your code depends on it.
12054 ///
12055 /// </div>
12056 pub async fn add_summary(
12057 &self,
12058 params: WorkspacesAddSummaryRequest,
12059 ) -> Result<WorkspacesAddSummaryResult, Error> {
12060 let mut wire_params = serde_json::to_value(params)?;
12061 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
12062 let _value = self
12063 .session
12064 .client()
12065 .call(
12066 rpc_methods::SESSION_WORKSPACES_ADDSUMMARY,
12067 Some(wire_params),
12068 )
12069 .await?;
12070 Ok(serde_json::from_value(_value)?)
12071 }
12072
12073 /// Truncates local workspace compaction summaries after a rollback.
12074 ///
12075 /// Wire method: `session.workspaces.truncateSummaries`.
12076 ///
12077 /// # Parameters
12078 ///
12079 /// * `params` - Rollback point for local workspace summaries.
12080 ///
12081 /// # Returns
12082 ///
12083 /// Current workspace metadata for the session, including its absolute filesystem path when available.
12084 ///
12085 /// <div class="warning">
12086 ///
12087 /// **Experimental.** This API is part of an experimental wire-protocol surface
12088 /// and may change or be removed in future SDK or CLI releases. Pin both the
12089 /// SDK and CLI versions if your code depends on it.
12090 ///
12091 /// </div>
12092 pub async fn truncate_summaries(
12093 &self,
12094 params: WorkspacesTruncateSummariesRequest,
12095 ) -> Result<WorkspacesGetWorkspaceResult, Error> {
12096 let mut wire_params = serde_json::to_value(params)?;
12097 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
12098 let _value = self
12099 .session
12100 .client()
12101 .call(
12102 rpc_methods::SESSION_WORKSPACES_TRUNCATESUMMARIES,
12103 Some(wire_params),
12104 )
12105 .await?;
12106 Ok(serde_json::from_value(_value)?)
12107 }
12108
12109 /// Reads the autopilot objective state file from the local session workspace.
12110 ///
12111 /// Wire method: `session.workspaces.readAutopilotObjective`.
12112 ///
12113 /// # Returns
12114 ///
12115 /// Autopilot objective file content, or null when missing.
12116 ///
12117 /// <div class="warning">
12118 ///
12119 /// **Experimental.** This API is part of an experimental wire-protocol surface
12120 /// and may change or be removed in future SDK or CLI releases. Pin both the
12121 /// SDK and CLI versions if your code depends on it.
12122 ///
12123 /// </div>
12124 pub async fn read_autopilot_objective(
12125 &self,
12126 ) -> Result<WorkspacesReadAutopilotObjectiveResult, Error> {
12127 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
12128 let _value = self
12129 .session
12130 .client()
12131 .call(
12132 rpc_methods::SESSION_WORKSPACES_READAUTOPILOTOBJECTIVE,
12133 Some(wire_params),
12134 )
12135 .await?;
12136 Ok(serde_json::from_value(_value)?)
12137 }
12138
12139 /// Writes the autopilot objective state file in the local session workspace.
12140 ///
12141 /// Wire method: `session.workspaces.writeAutopilotObjective`.
12142 ///
12143 /// # Parameters
12144 ///
12145 /// * `params` - Autopilot objective file content to persist.
12146 ///
12147 /// # Returns
12148 ///
12149 /// Result of writing the autopilot objective file.
12150 ///
12151 /// <div class="warning">
12152 ///
12153 /// **Experimental.** This API is part of an experimental wire-protocol surface
12154 /// and may change or be removed in future SDK or CLI releases. Pin both the
12155 /// SDK and CLI versions if your code depends on it.
12156 ///
12157 /// </div>
12158 pub async fn write_autopilot_objective(
12159 &self,
12160 params: WorkspacesWriteAutopilotObjectiveRequest,
12161 ) -> Result<WorkspacesWriteAutopilotObjectiveResult, Error> {
12162 let mut wire_params = serde_json::to_value(params)?;
12163 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
12164 let _value = self
12165 .session
12166 .client()
12167 .call(
12168 rpc_methods::SESSION_WORKSPACES_WRITEAUTOPILOTOBJECTIVE,
12169 Some(wire_params),
12170 )
12171 .await?;
12172 Ok(serde_json::from_value(_value)?)
12173 }
12174
12175 /// Deletes the autopilot objective state file from the local session workspace.
12176 ///
12177 /// Wire method: `session.workspaces.deleteAutopilotObjective`.
12178 ///
12179 /// # Returns
12180 ///
12181 /// Result of deleting the autopilot objective file.
12182 ///
12183 /// <div class="warning">
12184 ///
12185 /// **Experimental.** This API is part of an experimental wire-protocol surface
12186 /// and may change or be removed in future SDK or CLI releases. Pin both the
12187 /// SDK and CLI versions if your code depends on it.
12188 ///
12189 /// </div>
12190 pub async fn delete_autopilot_objective(
12191 &self,
12192 ) -> Result<WorkspacesDeleteAutopilotObjectiveResult, Error> {
12193 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
12194 let _value = self
12195 .session
12196 .client()
12197 .call(
12198 rpc_methods::SESSION_WORKSPACES_DELETEAUTOPILOTOBJECTIVE,
12199 Some(wire_params),
12200 )
12201 .await?;
12202 Ok(serde_json::from_value(_value)?)
12203 }
12204
12205 /// Checks whether the local session workspace has an autopilot objective state file.
12206 ///
12207 /// Wire method: `session.workspaces.autopilotObjectiveExists`.
12208 ///
12209 /// # Returns
12210 ///
12211 /// Whether the autopilot objective file exists.
12212 ///
12213 /// <div class="warning">
12214 ///
12215 /// **Experimental.** This API is part of an experimental wire-protocol surface
12216 /// and may change or be removed in future SDK or CLI releases. Pin both the
12217 /// SDK and CLI versions if your code depends on it.
12218 ///
12219 /// </div>
12220 pub async fn autopilot_objective_exists(
12221 &self,
12222 ) -> Result<WorkspacesAutopilotObjectiveExistsResult, Error> {
12223 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
12224 let _value = self
12225 .session
12226 .client()
12227 .call(
12228 rpc_methods::SESSION_WORKSPACES_AUTOPILOTOBJECTIVEEXISTS,
12229 Some(wire_params),
12230 )
12231 .await?;
12232 Ok(serde_json::from_value(_value)?)
12233 }
12234
12235 /// Saves pasted content as a UTF-8 file in the session workspace.
12236 ///
12237 /// Wire method: `session.workspaces.saveLargePaste`.
12238 ///
12239 /// # Parameters
12240 ///
12241 /// * `params` - Pasted content to save as a UTF-8 file in the session workspace.
12242 ///
12243 /// # Returns
12244 ///
12245 /// Descriptor for the saved paste file, or null when the workspace is unavailable.
12246 ///
12247 /// <div class="warning">
12248 ///
12249 /// **Experimental.** This API is part of an experimental wire-protocol surface
12250 /// and may change or be removed in future SDK or CLI releases. Pin both the
12251 /// SDK and CLI versions if your code depends on it.
12252 ///
12253 /// </div>
12254 pub async fn save_large_paste(
12255 &self,
12256 params: WorkspacesSaveLargePasteRequest,
12257 ) -> Result<WorkspacesSaveLargePasteResult, Error> {
12258 let mut wire_params = serde_json::to_value(params)?;
12259 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
12260 let _value = self
12261 .session
12262 .client()
12263 .call(
12264 rpc_methods::SESSION_WORKSPACES_SAVELARGEPASTE,
12265 Some(wire_params),
12266 )
12267 .await?;
12268 Ok(serde_json::from_value(_value)?)
12269 }
12270
12271 /// 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`.
12272 ///
12273 /// Wire method: `session.workspaces.diff`.
12274 ///
12275 /// # Parameters
12276 ///
12277 /// * `params` - Parameters for computing a workspace diff.
12278 ///
12279 /// # Returns
12280 ///
12281 /// Workspace diff result for the requested mode.
12282 ///
12283 /// <div class="warning">
12284 ///
12285 /// **Experimental.** This API is part of an experimental wire-protocol surface
12286 /// and may change or be removed in future SDK or CLI releases. Pin both the
12287 /// SDK and CLI versions if your code depends on it.
12288 ///
12289 /// </div>
12290 pub async fn diff(&self, params: WorkspacesDiffRequest) -> Result<WorkspaceDiffResult, Error> {
12291 let mut wire_params = serde_json::to_value(params)?;
12292 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
12293 let _value = self
12294 .session
12295 .client()
12296 .call(rpc_methods::SESSION_WORKSPACES_DIFF, Some(wire_params))
12297 .await?;
12298 Ok(serde_json::from_value(_value)?)
12299 }
12300}