github_copilot_sdk/generated/rpc.rs
1//! Auto-generated typed JSON-RPC namespace — do not edit manually.
2//!
3//! Generated from `api.schema.json` by `scripts/codegen/rust.ts`. The
4//! [`ClientRpc`] and [`SessionRpc`] view structs let callers reach every
5//! protocol method through a typed namespace tree, so wire method names
6//! and request/response shapes live in exactly one place — this file.
7
8#![allow(missing_docs)]
9#![allow(clippy::too_many_arguments)]
10#![allow(deprecated)]
11#![allow(dead_code)]
12
13use super::api_types::{rpc_methods, *};
14use super::session_events::SessionMode;
15use crate::session::Session;
16use crate::{Client, Error};
17
18/// Typed view over the [`Client`]'s server-level RPC namespace.
19#[derive(Clone, Copy)]
20pub struct ClientRpc<'a> {
21 pub(crate) client: &'a Client,
22}
23
24impl<'a> ClientRpc<'a> {
25 /// `account.*` sub-namespace.
26 pub fn account(&self) -> ClientRpcAccount<'a> {
27 ClientRpcAccount {
28 client: self.client,
29 }
30 }
31
32 /// `agentRegistry.*` sub-namespace.
33 pub fn agent_registry(&self) -> ClientRpcAgentRegistry<'a> {
34 ClientRpcAgentRegistry {
35 client: self.client,
36 }
37 }
38
39 /// `agents.*` sub-namespace.
40 pub fn agents(&self) -> ClientRpcAgents<'a> {
41 ClientRpcAgents {
42 client: self.client,
43 }
44 }
45
46 /// `catalog.*` sub-namespace.
47 pub fn catalog(&self) -> ClientRpcCatalog<'a> {
48 ClientRpcCatalog {
49 client: self.client,
50 }
51 }
52
53 /// `commands.*` sub-namespace.
54 pub fn commands(&self) -> ClientRpcCommands<'a> {
55 ClientRpcCommands {
56 client: self.client,
57 }
58 }
59
60 /// `extensions.*` sub-namespace.
61 pub fn extensions(&self) -> ClientRpcExtensions<'a> {
62 ClientRpcExtensions {
63 client: self.client,
64 }
65 }
66
67 /// `instructions.*` sub-namespace.
68 pub fn instructions(&self) -> ClientRpcInstructions<'a> {
69 ClientRpcInstructions {
70 client: self.client,
71 }
72 }
73
74 /// `llmInference.*` sub-namespace.
75 pub fn llm_inference(&self) -> ClientRpcLlmInference<'a> {
76 ClientRpcLlmInference {
77 client: self.client,
78 }
79 }
80
81 /// `managedSettings.*` sub-namespace.
82 pub fn managed_settings(&self) -> ClientRpcManagedSettings<'a> {
83 ClientRpcManagedSettings {
84 client: self.client,
85 }
86 }
87
88 /// `mcp.*` sub-namespace.
89 pub fn mcp(&self) -> ClientRpcMcp<'a> {
90 ClientRpcMcp {
91 client: self.client,
92 }
93 }
94
95 /// `models.*` sub-namespace.
96 pub fn models(&self) -> ClientRpcModels<'a> {
97 ClientRpcModels {
98 client: self.client,
99 }
100 }
101
102 /// `plugins.*` sub-namespace.
103 pub fn plugins(&self) -> ClientRpcPlugins<'a> {
104 ClientRpcPlugins {
105 client: self.client,
106 }
107 }
108
109 /// `runtime.*` sub-namespace.
110 pub fn runtime(&self) -> ClientRpcRuntime<'a> {
111 ClientRpcRuntime {
112 client: self.client,
113 }
114 }
115
116 /// `secrets.*` sub-namespace.
117 pub fn secrets(&self) -> ClientRpcSecrets<'a> {
118 ClientRpcSecrets {
119 client: self.client,
120 }
121 }
122
123 /// `sessionFs.*` sub-namespace.
124 pub fn session_fs(&self) -> ClientRpcSessionFs<'a> {
125 ClientRpcSessionFs {
126 client: self.client,
127 }
128 }
129
130 /// `sessions.*` sub-namespace.
131 pub fn sessions(&self) -> ClientRpcSessions<'a> {
132 ClientRpcSessions {
133 client: self.client,
134 }
135 }
136
137 /// `skills.*` sub-namespace.
138 pub fn skills(&self) -> ClientRpcSkills<'a> {
139 ClientRpcSkills {
140 client: self.client,
141 }
142 }
143
144 /// `tools.*` sub-namespace.
145 pub fn tools(&self) -> ClientRpcTools<'a> {
146 ClientRpcTools {
147 client: self.client,
148 }
149 }
150
151 /// `user.*` sub-namespace.
152 pub fn user(&self) -> ClientRpcUser<'a> {
153 ClientRpcUser {
154 client: self.client,
155 }
156 }
157
158 /// Checks server responsiveness and returns protocol information.
159 ///
160 /// Wire method: `ping`.
161 ///
162 /// # Parameters
163 ///
164 /// * `params` - Optional message to echo back to the caller.
165 ///
166 /// # Returns
167 ///
168 /// Server liveness response, including the echoed message, current server timestamp, and protocol version.
169 ///
170 /// <div class="warning">
171 ///
172 /// **Experimental.** This API is part of an experimental wire-protocol surface
173 /// and may change or be removed in future SDK or CLI releases. Pin both the
174 /// SDK and CLI versions if your code depends on it.
175 ///
176 /// </div>
177 pub async fn ping(&self, params: PingRequest) -> Result<PingResult, Error> {
178 let wire_params = serde_json::to_value(params)?;
179 let _value = self
180 .client
181 .call(rpc_methods::PING, Some(wire_params))
182 .await?;
183 Ok(serde_json::from_value(_value)?)
184 }
185
186 /// Performs the SDK server connection handshake and validates the optional connection token. Marked internal because this is JSON-RPC transport plumbing invoked automatically by an SDK client's own `connect()` wrapper, not a user-facing method. Stays internal as long as the SDK client owns the handshake; would only become public if the SDK ever exposed the raw schema surface to consumers without a connection wrapper.
187 ///
188 /// Wire method: `connect`.
189 ///
190 /// # Parameters
191 ///
192 /// * `params` - Connection-level opt-ins for the `server.connect` handshake. Transport authentication is consumed by the native protocol boundary before dispatch.
193 ///
194 /// # Returns
195 ///
196 /// Handshake result reporting the server's protocol version and package version on success.
197 ///
198 /// <div class="warning">
199 ///
200 /// **Experimental.** This API is part of an experimental wire-protocol surface
201 /// and may change or be removed in future SDK or CLI releases. Pin both the
202 /// SDK and CLI versions if your code depends on it.
203 ///
204 /// </div>
205 pub(crate) async fn connect(&self, params: ConnectRequest) -> Result<ConnectResult, Error> {
206 let wire_params = serde_json::to_value(params)?;
207 let _value = self
208 .client
209 .call(rpc_methods::CONNECT, Some(wire_params))
210 .await?;
211 Ok(serde_json::from_value(_value)?)
212 }
213
214 /// Registers the calling SDK client as the per-entrypoint extension launch provider. Call before creating any sessions. When omitted, the runtime temporarily falls back to its built-in Node launcher for backward compatibility.
215 ///
216 /// Wire method: `registerExtensionLaunchProvider`.
217 ///
218 /// <div class="warning">
219 ///
220 /// **Experimental.** This API is part of an experimental wire-protocol surface
221 /// and may change or be removed in future SDK or CLI releases. Pin both the
222 /// SDK and CLI versions if your code depends on it.
223 ///
224 /// </div>
225 pub async fn register_extension_launch_provider(&self) -> Result<(), Error> {
226 let wire_params = serde_json::json!({});
227 let _value = self
228 .client
229 .call(
230 rpc_methods::REGISTEREXTENSIONLAUNCHPROVIDER,
231 Some(wire_params),
232 )
233 .await?;
234 Ok(())
235 }
236}
237
238/// `account.*` RPCs.
239#[derive(Clone, Copy)]
240pub struct ClientRpcAccount<'a> {
241 pub(crate) client: &'a Client,
242}
243
244impl<'a> ClientRpcAccount<'a> {
245 /// Gets Copilot quota usage for the current or opaquely selected authenticated user.
246 ///
247 /// Wire method: `account.getQuota`.
248 ///
249 /// # Returns
250 ///
251 /// Quota usage snapshots for the resolved user, keyed by quota type.
252 ///
253 /// <div class="warning">
254 ///
255 /// **Experimental.** This API is part of an experimental wire-protocol surface
256 /// and may change or be removed in future SDK or CLI releases. Pin both the
257 /// SDK and CLI versions if your code depends on it.
258 ///
259 /// </div>
260 pub async fn get_quota(&self) -> Result<AccountGetQuotaResult, Error> {
261 let wire_params = serde_json::json!({});
262 let _value = self
263 .client
264 .call(rpc_methods::ACCOUNT_GETQUOTA, Some(wire_params))
265 .await?;
266 Ok(serde_json::from_value(_value)?)
267 }
268
269 /// Gets Copilot quota usage for the current or opaquely selected authenticated user.
270 ///
271 /// Wire method: `account.getQuota`.
272 ///
273 /// # Parameters
274 ///
275 /// * `params` - Optional opaque account selection or compatibility GitHub token used to look up quota.
276 ///
277 /// # Returns
278 ///
279 /// Quota usage snapshots for the resolved user, keyed by quota type.
280 ///
281 /// <div class="warning">
282 ///
283 /// **Experimental.** This API is part of an experimental wire-protocol surface
284 /// and may change or be removed in future SDK or CLI releases. Pin both the
285 /// SDK and CLI versions if your code depends on it.
286 ///
287 /// </div>
288 pub async fn get_quota_with_params(
289 &self,
290 params: AccountGetQuotaRequest,
291 ) -> Result<AccountGetQuotaResult, Error> {
292 let wire_params = serde_json::to_value(params)?;
293 let _value = self
294 .client
295 .call(rpc_methods::ACCOUNT_GETQUOTA, Some(wire_params))
296 .await?;
297 Ok(serde_json::from_value(_value)?)
298 }
299
300 /// Gets the currently active authentication credentials from the global auth manager.
301 ///
302 /// Wire method: `account.getCurrentAuth`.
303 ///
304 /// # Returns
305 ///
306 /// Current authentication state
307 ///
308 /// <div class="warning">
309 ///
310 /// **Experimental.** This API is part of an experimental wire-protocol surface
311 /// and may change or be removed in future SDK or CLI releases. Pin both the
312 /// SDK and CLI versions if your code depends on it.
313 ///
314 /// </div>
315 pub async fn get_current_auth(&self) -> Result<AccountGetCurrentAuthResult, Error> {
316 let wire_params = serde_json::json!({});
317 let _value = self
318 .client
319 .call(rpc_methods::ACCOUNT_GETCURRENTAUTH, Some(wire_params))
320 .await?;
321 Ok(serde_json::from_value(_value)?)
322 }
323
324 /// Gets all authenticated users available for account switching.
325 ///
326 /// Wire method: `account.getAllUsers`.
327 ///
328 /// # Returns
329 ///
330 /// List of all authenticated users
331 ///
332 /// <div class="warning">
333 ///
334 /// **Experimental.** This API is part of an experimental wire-protocol surface
335 /// and may change or be removed in future SDK or CLI releases. Pin both the
336 /// SDK and CLI versions if your code depends on it.
337 ///
338 /// </div>
339 pub async fn get_all_users(&self) -> Result<AccountGetAllUsersResult, Error> {
340 let wire_params = serde_json::json!({});
341 let _value = self
342 .client
343 .call(rpc_methods::ACCOUNT_GETALLUSERS, Some(wire_params))
344 .await?;
345 Ok(serde_json::from_value(_value)?)
346 }
347
348 /// Validates and stores authentication credentials. When login is omitted, resolves the authenticated user from the token before persistence.
349 ///
350 /// Wire method: `account.login`.
351 ///
352 /// # Parameters
353 ///
354 /// * `params` - Credentials to validate and store. Omit login to resolve the authenticated user from the token.
355 ///
356 /// # Returns
357 ///
358 /// Result of a successful login; throws on failure
359 ///
360 /// <div class="warning">
361 ///
362 /// **Experimental.** This API is part of an experimental wire-protocol surface
363 /// and may change or be removed in future SDK or CLI releases. Pin both the
364 /// SDK and CLI versions if your code depends on it.
365 ///
366 /// </div>
367 pub async fn login(&self, params: AccountLoginRequest) -> Result<AccountLoginResult, Error> {
368 let wire_params = serde_json::to_value(params)?;
369 let _value = self
370 .client
371 .call(rpc_methods::ACCOUNT_LOGIN, Some(wire_params))
372 .await?;
373 Ok(serde_json::from_value(_value)?)
374 }
375
376 /// Removes user authentication from keychain and persisted state.
377 ///
378 /// Wire method: `account.logout`.
379 ///
380 /// # Parameters
381 ///
382 /// * `params` - User to log out
383 ///
384 /// # Returns
385 ///
386 /// Logout result indicating if more users remain
387 ///
388 /// <div class="warning">
389 ///
390 /// **Experimental.** This API is part of an experimental wire-protocol surface
391 /// and may change or be removed in future SDK or CLI releases. Pin both the
392 /// SDK and CLI versions if your code depends on it.
393 ///
394 /// </div>
395 pub async fn logout(&self, params: AccountLogoutRequest) -> Result<AccountLogoutResult, Error> {
396 let wire_params = serde_json::to_value(params)?;
397 let _value = self
398 .client
399 .call(rpc_methods::ACCOUNT_LOGOUT, Some(wire_params))
400 .await?;
401 Ok(serde_json::from_value(_value)?)
402 }
403}
404
405/// `agentRegistry.*` RPCs.
406#[derive(Clone, Copy)]
407pub struct ClientRpcAgentRegistry<'a> {
408 pub(crate) client: &'a Client,
409}
410
411impl<'a> ClientRpcAgentRegistry<'a> {
412 /// Spawns a managed-server child with the supplied configuration and returns a discriminated-union result. The caller (typically the CLI controller) is responsible for attaching to the spawned child and sending any follow-up prompt. When the controller-local spawn gate is closed the server returns JSON-RPC MethodNotFound.
413 ///
414 /// Wire method: `agentRegistry.spawn`.
415 ///
416 /// # Parameters
417 ///
418 /// * `params` - Inputs to spawn a managed-server child via the controller's spawn delegate.
419 ///
420 /// # Returns
421 ///
422 /// Outcome of an agentRegistry.spawn call.
423 ///
424 /// <div class="warning">
425 ///
426 /// **Experimental.** This API is part of an experimental wire-protocol surface
427 /// and may change or be removed in future SDK or CLI releases. Pin both the
428 /// SDK and CLI versions if your code depends on it.
429 ///
430 /// </div>
431 pub async fn spawn(
432 &self,
433 params: AgentRegistrySpawnRequest,
434 ) -> Result<AgentRegistrySpawnResult, Error> {
435 let wire_params = serde_json::to_value(params)?;
436 let _value = self
437 .client
438 .call(rpc_methods::AGENTREGISTRY_SPAWN, Some(wire_params))
439 .await?;
440 Ok(serde_json::from_value(_value)?)
441 }
442}
443
444/// `agents.*` RPCs.
445#[derive(Clone, Copy)]
446pub struct ClientRpcAgents<'a> {
447 pub(crate) client: &'a Client,
448}
449
450impl<'a> ClientRpcAgents<'a> {
451 /// Discovers custom agents across user, project, plugin, and remote sources.
452 ///
453 /// Wire method: `agents.discover`.
454 ///
455 /// # Parameters
456 ///
457 /// * `params` - Optional project paths to include in agent discovery.
458 ///
459 /// # Returns
460 ///
461 /// Agents discovered across user, project, plugin, and remote sources.
462 ///
463 /// <div class="warning">
464 ///
465 /// **Experimental.** This API is part of an experimental wire-protocol surface
466 /// and may change or be removed in future SDK or CLI releases. Pin both the
467 /// SDK and CLI versions if your code depends on it.
468 ///
469 /// </div>
470 pub async fn discover(&self, params: AgentsDiscoverRequest) -> Result<ServerAgentList, Error> {
471 let wire_params = serde_json::to_value(params)?;
472 let _value = self
473 .client
474 .call(rpc_methods::AGENTS_DISCOVER, Some(wire_params))
475 .await?;
476 Ok(serde_json::from_value(_value)?)
477 }
478
479 /// Returns the canonical directories where a client may create custom agents that the runtime will recognize, including ones that do not exist yet. Project directories become active once created.
480 ///
481 /// Wire method: `agents.getDiscoveryPaths`.
482 ///
483 /// # Parameters
484 ///
485 /// * `params` - Optional project paths to include when enumerating agent discovery directories.
486 ///
487 /// # Returns
488 ///
489 /// Canonical locations where custom agents can be created so the runtime will recognize them.
490 ///
491 /// <div class="warning">
492 ///
493 /// **Experimental.** This API is part of an experimental wire-protocol surface
494 /// and may change or be removed in future SDK or CLI releases. Pin both the
495 /// SDK and CLI versions if your code depends on it.
496 ///
497 /// </div>
498 pub async fn get_discovery_paths(
499 &self,
500 params: AgentsGetDiscoveryPathsRequest,
501 ) -> Result<AgentDiscoveryPathList, Error> {
502 let wire_params = serde_json::to_value(params)?;
503 let _value = self
504 .client
505 .call(rpc_methods::AGENTS_GETDISCOVERYPATHS, Some(wire_params))
506 .await?;
507 Ok(serde_json::from_value(_value)?)
508 }
509}
510
511/// `catalog.*` RPCs.
512#[derive(Clone, Copy)]
513pub struct ClientRpcCatalog<'a> {
514 pub(crate) client: &'a Client,
515}
516
517impl<'a> ClientRpcCatalog<'a> {
518 /// Requests a bounded catalog search. This host-implemented server method is available through SDK/TUI hosts; standalone and C-ABI runtimes whose host does not implement server-method dispatch return JSON-RPC MethodNotFound. A runtime with search available returns inert candidate summaries, each with an opaque single-use handle scoped to this runtime instance; a runtime without it returns the typed search-unavailable result. Public authorities may be searched anonymously, while an authority that requires credentials yields the typed authentication-required result. All returned text, URLs, and package metadata are untrusted external data and can never trigger instructions, tools, or installation. Read-only: nothing is installed, configured, or persisted.
519 ///
520 /// Wire method: `catalog.search`.
521 ///
522 /// # Parameters
523 ///
524 /// * `params` - A bounded catalog search. Both the query length and the result count are capped by the schema so a caller cannot request an unbounded scan.
525 ///
526 /// # Returns
527 ///
528 /// Outcome of a catalog.search call: either bounded inert candidates, or one typed refusal. Never a partial success.
529 ///
530 /// <div class="warning">
531 ///
532 /// **Experimental.** This API is part of an experimental wire-protocol surface
533 /// and may change or be removed in future SDK or CLI releases. Pin both the
534 /// SDK and CLI versions if your code depends on it.
535 ///
536 /// </div>
537 pub async fn search(&self, params: CatalogSearchRequest) -> Result<CatalogSearchResult, Error> {
538 let wire_params = serde_json::to_value(params)?;
539 let _value = self
540 .client
541 .call(rpc_methods::CATALOG_SEARCH, Some(wire_params))
542 .await?;
543 Ok(serde_json::from_value(_value)?)
544 }
545}
546
547/// `commands.*` RPCs.
548#[derive(Clone, Copy)]
549pub struct ClientRpcCommands<'a> {
550 pub(crate) client: &'a Client,
551}
552
553impl<'a> ClientRpcCommands<'a> {
554 /// Lists the well-known built-in slash commands that work as the first message in a new session (e.g. /plan, /env), without requiring an active session. Commands that depend on session state, authentication, or a synced session are omitted.
555 ///
556 /// Wire method: `commands.list`.
557 ///
558 /// # Returns
559 ///
560 /// Slash commands available in the session, after applying any include/exclude filters.
561 ///
562 /// <div class="warning">
563 ///
564 /// **Experimental.** This API is part of an experimental wire-protocol surface
565 /// and may change or be removed in future SDK or CLI releases. Pin both the
566 /// SDK and CLI versions if your code depends on it.
567 ///
568 /// </div>
569 pub async fn list(&self) -> Result<CommandList, Error> {
570 let wire_params = serde_json::json!({});
571 let _value = self
572 .client
573 .call(rpc_methods::COMMANDS_LIST, Some(wire_params))
574 .await?;
575 Ok(serde_json::from_value(_value)?)
576 }
577}
578
579/// `extensions.*` RPCs.
580#[derive(Clone, Copy)]
581pub struct ClientRpcExtensions<'a> {
582 pub(crate) client: &'a Client,
583}
584
585impl<'a> ClientRpcExtensions<'a> {
586 /// Discovers user and enabled installed-plugin extensions from persisted Copilot home state, including enablement preferences. Launch-scoped additional plugins are not included.
587 ///
588 /// Wire method: `extensions.discover`.
589 ///
590 /// # Returns
591 ///
592 /// Extensions discovered from persisted Copilot home state and their effective loading mode. Launch-scoped additional plugins are not included.
593 ///
594 /// <div class="warning">
595 ///
596 /// **Experimental.** This API is part of an experimental wire-protocol surface
597 /// and may change or be removed in future SDK or CLI releases. Pin both the
598 /// SDK and CLI versions if your code depends on it.
599 ///
600 /// </div>
601 pub async fn discover(&self) -> Result<DiscoveredExtensions, Error> {
602 let wire_params = serde_json::json!({});
603 let _value = self
604 .client
605 .call(rpc_methods::EXTENSIONS_DISCOVER, Some(wire_params))
606 .await?;
607 Ok(serde_json::from_value(_value)?)
608 }
609
610 /// Persistently enables extension IDs for future sessions. Active sessions are unchanged; use session.extensions.enable to update them.
611 ///
612 /// Wire method: `extensions.enable`.
613 ///
614 /// # Parameters
615 ///
616 /// * `params` - Source-qualified extension identifiers to persistently enable for future sessions.
617 ///
618 /// <div class="warning">
619 ///
620 /// **Experimental.** This API is part of an experimental wire-protocol surface
621 /// and may change or be removed in future SDK or CLI releases. Pin both the
622 /// SDK and CLI versions if your code depends on it.
623 ///
624 /// </div>
625 pub async fn enable(&self, params: DiscoveredExtensionsEnableRequest) -> Result<(), Error> {
626 let wire_params = serde_json::to_value(params)?;
627 let _value = self
628 .client
629 .call(rpc_methods::EXTENSIONS_ENABLE, Some(wire_params))
630 .await?;
631 Ok(())
632 }
633
634 /// Persistently disables extension IDs for future sessions. Active sessions are unchanged; use session.extensions.disable to update them.
635 ///
636 /// Wire method: `extensions.disable`.
637 ///
638 /// # Parameters
639 ///
640 /// * `params` - Source-qualified extension identifiers to persistently disable for future sessions.
641 ///
642 /// <div class="warning">
643 ///
644 /// **Experimental.** This API is part of an experimental wire-protocol surface
645 /// and may change or be removed in future SDK or CLI releases. Pin both the
646 /// SDK and CLI versions if your code depends on it.
647 ///
648 /// </div>
649 pub async fn disable(&self, params: DiscoveredExtensionsDisableRequest) -> Result<(), Error> {
650 let wire_params = serde_json::to_value(params)?;
651 let _value = self
652 .client
653 .call(rpc_methods::EXTENSIONS_DISABLE, Some(wire_params))
654 .await?;
655 Ok(())
656 }
657}
658
659/// `instructions.*` RPCs.
660#[derive(Clone, Copy)]
661pub struct ClientRpcInstructions<'a> {
662 pub(crate) client: &'a Client,
663}
664
665impl<'a> ClientRpcInstructions<'a> {
666 /// Discovers instruction sources across user, repository, and plugin sources.
667 ///
668 /// Wire method: `instructions.discover`.
669 ///
670 /// # Parameters
671 ///
672 /// * `params` - Optional project paths to include in instruction discovery.
673 ///
674 /// # Returns
675 ///
676 /// Instruction sources discovered across user, repository, and plugin sources.
677 ///
678 /// <div class="warning">
679 ///
680 /// **Experimental.** This API is part of an experimental wire-protocol surface
681 /// and may change or be removed in future SDK or CLI releases. Pin both the
682 /// SDK and CLI versions if your code depends on it.
683 ///
684 /// </div>
685 pub async fn discover(
686 &self,
687 params: InstructionsDiscoverRequest,
688 ) -> Result<ServerInstructionSourceList, Error> {
689 let wire_params = serde_json::to_value(params)?;
690 let _value = self
691 .client
692 .call(rpc_methods::INSTRUCTIONS_DISCOVER, Some(wire_params))
693 .await?;
694 Ok(serde_json::from_value(_value)?)
695 }
696
697 /// Returns the canonical files and directories where a client may create custom instructions that the runtime will recognize, including ones that do not exist yet. Repository targets become active once created.
698 ///
699 /// Wire method: `instructions.getDiscoveryPaths`.
700 ///
701 /// # Parameters
702 ///
703 /// * `params` - Optional project paths to include when enumerating instruction discovery targets.
704 ///
705 /// # Returns
706 ///
707 /// Canonical files and directories where custom instructions can be created so the runtime will recognize them.
708 ///
709 /// <div class="warning">
710 ///
711 /// **Experimental.** This API is part of an experimental wire-protocol surface
712 /// and may change or be removed in future SDK or CLI releases. Pin both the
713 /// SDK and CLI versions if your code depends on it.
714 ///
715 /// </div>
716 pub async fn get_discovery_paths(
717 &self,
718 params: InstructionsGetDiscoveryPathsRequest,
719 ) -> Result<InstructionDiscoveryPathList, Error> {
720 let wire_params = serde_json::to_value(params)?;
721 let _value = self
722 .client
723 .call(
724 rpc_methods::INSTRUCTIONS_GETDISCOVERYPATHS,
725 Some(wire_params),
726 )
727 .await?;
728 Ok(serde_json::from_value(_value)?)
729 }
730}
731
732/// `llmInference.*` RPCs.
733#[derive(Clone, Copy)]
734pub struct ClientRpcLlmInference<'a> {
735 pub(crate) client: &'a Client,
736}
737
738impl<'a> ClientRpcLlmInference<'a> {
739 /// Registers an SDK client as the LLM inference callback provider.
740 ///
741 /// Wire method: `llmInference.setProvider`.
742 ///
743 /// # Returns
744 ///
745 /// Indicates whether the calling client was registered as the LLM inference provider.
746 ///
747 /// <div class="warning">
748 ///
749 /// **Experimental.** This API is part of an experimental wire-protocol surface
750 /// and may change or be removed in future SDK or CLI releases. Pin both the
751 /// SDK and CLI versions if your code depends on it.
752 ///
753 /// </div>
754 pub async fn set_provider(&self) -> Result<LlmInferenceSetProviderResult, Error> {
755 let wire_params = serde_json::json!({});
756 let _value = self
757 .client
758 .call(rpc_methods::LLMINFERENCE_SETPROVIDER, Some(wire_params))
759 .await?;
760 Ok(serde_json::from_value(_value)?)
761 }
762
763 /// Delivers the response head (status + headers) for an in-flight request, correlated by the requestId the runtime supplied in httpRequestStart. Must be called exactly once per request before any httpResponseChunk frames.
764 ///
765 /// Wire method: `llmInference.httpResponseStart`.
766 ///
767 /// # Parameters
768 ///
769 /// * `params` - Response head.
770 ///
771 /// # Returns
772 ///
773 /// Whether the start frame was accepted.
774 ///
775 /// <div class="warning">
776 ///
777 /// **Experimental.** This API is part of an experimental wire-protocol surface
778 /// and may change or be removed in future SDK or CLI releases. Pin both the
779 /// SDK and CLI versions if your code depends on it.
780 ///
781 /// </div>
782 pub async fn http_response_start(
783 &self,
784 params: LlmInferenceHttpResponseStartRequest,
785 ) -> Result<LlmInferenceHttpResponseStartResult, Error> {
786 let wire_params = serde_json::to_value(params)?;
787 let _value = self
788 .client
789 .call(
790 rpc_methods::LLMINFERENCE_HTTPRESPONSESTART,
791 Some(wire_params),
792 )
793 .await?;
794 Ok(serde_json::from_value(_value)?)
795 }
796
797 /// Delivers a body byte range (or a terminal transport error) for an in-flight response, correlated by requestId. Set `end` true on the last chunk. When `error` is set the response terminates with a transport-level failure and the runtime raises an APIConnectionError.
798 ///
799 /// Wire method: `llmInference.httpResponseChunk`.
800 ///
801 /// # Parameters
802 ///
803 /// * `params` - A response body chunk or terminal error.
804 ///
805 /// # Returns
806 ///
807 /// Whether the chunk was accepted.
808 ///
809 /// <div class="warning">
810 ///
811 /// **Experimental.** This API is part of an experimental wire-protocol surface
812 /// and may change or be removed in future SDK or CLI releases. Pin both the
813 /// SDK and CLI versions if your code depends on it.
814 ///
815 /// </div>
816 pub async fn http_response_chunk(
817 &self,
818 params: LlmInferenceHttpResponseChunkRequest,
819 ) -> Result<LlmInferenceHttpResponseChunkResult, Error> {
820 let wire_params = serde_json::to_value(params)?;
821 let _value = self
822 .client
823 .call(
824 rpc_methods::LLMINFERENCE_HTTPRESPONSECHUNK,
825 Some(wire_params),
826 )
827 .await?;
828 Ok(serde_json::from_value(_value)?)
829 }
830}
831
832/// `managedSettings.*` RPCs.
833#[derive(Clone, Copy)]
834pub struct ClientRpcManagedSettings<'a> {
835 pub(crate) client: &'a Client,
836}
837
838impl<'a> ClientRpcManagedSettings<'a> {
839 /// Discovers device-managed settings from production MDM and managed-file sources, validates them against the runtime-owned managed-settings schema, and returns the canonical JSON without requiring a session.
840 ///
841 /// Wire method: `managedSettings.read`.
842 ///
843 /// # Returns
844 ///
845 /// Validated device-managed settings discovered before a session exists.
846 ///
847 /// <div class="warning">
848 ///
849 /// **Experimental.** This API is part of an experimental wire-protocol surface
850 /// and may change or be removed in future SDK or CLI releases. Pin both the
851 /// SDK and CLI versions if your code depends on it.
852 ///
853 /// </div>
854 pub async fn read(&self) -> Result<ManagedSettingsReadResult, Error> {
855 let wire_params = serde_json::json!({});
856 let _value = self
857 .client
858 .call(rpc_methods::MANAGEDSETTINGS_READ, Some(wire_params))
859 .await?;
860 Ok(serde_json::from_value(_value)?)
861 }
862}
863
864/// `mcp.*` RPCs.
865#[derive(Clone, Copy)]
866pub struct ClientRpcMcp<'a> {
867 pub(crate) client: &'a Client,
868}
869
870impl<'a> ClientRpcMcp<'a> {
871 /// `mcp.config.*` sub-namespace.
872 pub fn config(&self) -> ClientRpcMcpConfig<'a> {
873 ClientRpcMcpConfig {
874 client: self.client,
875 }
876 }
877
878 /// Discovers MCP servers from user, workspace, plugin, and builtin sources.
879 ///
880 /// Wire method: `mcp.discover`.
881 ///
882 /// # Parameters
883 ///
884 /// * `params` - Optional working directory used as context for MCP server discovery.
885 ///
886 /// # Returns
887 ///
888 /// MCP servers discovered from user, workspace, plugin, and built-in sources.
889 ///
890 /// <div class="warning">
891 ///
892 /// **Experimental.** This API is part of an experimental wire-protocol surface
893 /// and may change or be removed in future SDK or CLI releases. Pin both the
894 /// SDK and CLI versions if your code depends on it.
895 ///
896 /// </div>
897 pub async fn discover(&self, params: McpDiscoverRequest) -> Result<McpDiscoverResult, Error> {
898 let wire_params = serde_json::to_value(params)?;
899 let _value = self
900 .client
901 .call(rpc_methods::MCP_DISCOVER, Some(wire_params))
902 .await?;
903 Ok(serde_json::from_value(_value)?)
904 }
905
906 /// Requests a side-effect-free MCP install plan from a catalog candidate handle or a caller-supplied card. This host-implemented server method is available through SDK/TUI hosts; standalone and C-ABI runtimes whose host does not implement server-method dispatch return JSON-RPC MethodNotFound. A runtime with planning available returns a normalised plan and opaque single-use plan handle; a runtime without it returns the typed planning-unavailable result. A completed plan reports resource identity, provenance, eligible transport choices, the user-scope target, required typed values and secret placeholders, the policy result, the configuration changes installing would make, and whether a reload would be needed. Planning never writes configuration, stores a secret, or reloads MCP servers, so abandoning a plan needs no call and leaves nothing behind.
907 ///
908 /// Wire method: `mcp.planInstall`.
909 ///
910 /// # Parameters
911 ///
912 /// * `params` - A side-effect-free request for an MCP install plan. Computing a plan never writes configuration, stores a secret, or reloads MCP servers.
913 ///
914 /// # Returns
915 ///
916 /// Outcome of an mcp.planInstall call: either a normalised plan, or one typed refusal. Nothing is written in either case.
917 ///
918 /// <div class="warning">
919 ///
920 /// **Experimental.** This API is part of an experimental wire-protocol surface
921 /// and may change or be removed in future SDK or CLI releases. Pin both the
922 /// SDK and CLI versions if your code depends on it.
923 ///
924 /// </div>
925 pub async fn plan_install(
926 &self,
927 params: McpPlanInstallRequest,
928 ) -> Result<McpPlanInstallResult, Error> {
929 let wire_params = serde_json::to_value(params)?;
930 let _value = self
931 .client
932 .call(rpc_methods::MCP_PLANINSTALL, Some(wire_params))
933 .await?;
934 Ok(serde_json::from_value(_value)?)
935 }
936}
937
938/// `mcp.config.*` RPCs.
939#[derive(Clone, Copy)]
940pub struct ClientRpcMcpConfig<'a> {
941 pub(crate) client: &'a Client,
942}
943
944impl<'a> ClientRpcMcpConfig<'a> {
945 /// Lists MCP servers from user configuration.
946 ///
947 /// Wire method: `mcp.config.list`.
948 ///
949 /// # Returns
950 ///
951 /// User-configured MCP servers, keyed by server name.
952 ///
953 /// <div class="warning">
954 ///
955 /// **Experimental.** This API is part of an experimental wire-protocol surface
956 /// and may change or be removed in future SDK or CLI releases. Pin both the
957 /// SDK and CLI versions if your code depends on it.
958 ///
959 /// </div>
960 pub async fn list(&self) -> Result<McpConfigList, Error> {
961 let wire_params = serde_json::json!({});
962 let _value = self
963 .client
964 .call(rpc_methods::MCP_CONFIG_LIST, Some(wire_params))
965 .await?;
966 Ok(serde_json::from_value(_value)?)
967 }
968
969 /// Adds an MCP server to user configuration.
970 ///
971 /// Wire method: `mcp.config.add`.
972 ///
973 /// # Parameters
974 ///
975 /// * `params` - MCP server name and configuration to add to user configuration.
976 ///
977 /// <div class="warning">
978 ///
979 /// **Experimental.** This API is part of an experimental wire-protocol surface
980 /// and may change or be removed in future SDK or CLI releases. Pin both the
981 /// SDK and CLI versions if your code depends on it.
982 ///
983 /// </div>
984 pub async fn add(&self, params: McpConfigAddRequest) -> Result<(), Error> {
985 let wire_params = serde_json::to_value(params)?;
986 let _value = self
987 .client
988 .call(rpc_methods::MCP_CONFIG_ADD, Some(wire_params))
989 .await?;
990 Ok(())
991 }
992
993 /// Updates an MCP server in user configuration.
994 ///
995 /// Wire method: `mcp.config.update`.
996 ///
997 /// # Parameters
998 ///
999 /// * `params` - MCP server name and replacement configuration to write to user configuration.
1000 ///
1001 /// <div class="warning">
1002 ///
1003 /// **Experimental.** This API is part of an experimental wire-protocol surface
1004 /// and may change or be removed in future SDK or CLI releases. Pin both the
1005 /// SDK and CLI versions if your code depends on it.
1006 ///
1007 /// </div>
1008 pub async fn update(&self, params: McpConfigUpdateRequest) -> Result<(), Error> {
1009 let wire_params = serde_json::to_value(params)?;
1010 let _value = self
1011 .client
1012 .call(rpc_methods::MCP_CONFIG_UPDATE, Some(wire_params))
1013 .await?;
1014 Ok(())
1015 }
1016
1017 /// Removes an MCP server from user configuration.
1018 ///
1019 /// Wire method: `mcp.config.remove`.
1020 ///
1021 /// # Parameters
1022 ///
1023 /// * `params` - MCP server name to remove from user configuration.
1024 ///
1025 /// <div class="warning">
1026 ///
1027 /// **Experimental.** This API is part of an experimental wire-protocol surface
1028 /// and may change or be removed in future SDK or CLI releases. Pin both the
1029 /// SDK and CLI versions if your code depends on it.
1030 ///
1031 /// </div>
1032 pub async fn remove(&self, params: McpConfigRemoveRequest) -> Result<(), Error> {
1033 let wire_params = serde_json::to_value(params)?;
1034 let _value = self
1035 .client
1036 .call(rpc_methods::MCP_CONFIG_REMOVE, Some(wire_params))
1037 .await?;
1038 Ok(())
1039 }
1040
1041 /// Enables MCP servers in user configuration for new sessions.
1042 ///
1043 /// Wire method: `mcp.config.enable`.
1044 ///
1045 /// # Parameters
1046 ///
1047 /// * `params` - MCP server names to enable for new sessions.
1048 ///
1049 /// <div class="warning">
1050 ///
1051 /// **Experimental.** This API is part of an experimental wire-protocol surface
1052 /// and may change or be removed in future SDK or CLI releases. Pin both the
1053 /// SDK and CLI versions if your code depends on it.
1054 ///
1055 /// </div>
1056 pub async fn enable(&self, params: McpConfigEnableRequest) -> Result<(), Error> {
1057 let wire_params = serde_json::to_value(params)?;
1058 let _value = self
1059 .client
1060 .call(rpc_methods::MCP_CONFIG_ENABLE, Some(wire_params))
1061 .await?;
1062 Ok(())
1063 }
1064
1065 /// Disables MCP servers in user configuration for new sessions.
1066 ///
1067 /// Wire method: `mcp.config.disable`.
1068 ///
1069 /// # Parameters
1070 ///
1071 /// * `params` - MCP server names to disable for new sessions.
1072 ///
1073 /// <div class="warning">
1074 ///
1075 /// **Experimental.** This API is part of an experimental wire-protocol surface
1076 /// and may change or be removed in future SDK or CLI releases. Pin both the
1077 /// SDK and CLI versions if your code depends on it.
1078 ///
1079 /// </div>
1080 pub async fn disable(&self, params: McpConfigDisableRequest) -> Result<(), Error> {
1081 let wire_params = serde_json::to_value(params)?;
1082 let _value = self
1083 .client
1084 .call(rpc_methods::MCP_CONFIG_DISABLE, Some(wire_params))
1085 .await?;
1086 Ok(())
1087 }
1088
1089 /// Drops this runtime process's in-memory MCP server-definition cache so the next MCP config read observes disk.
1090 ///
1091 /// Wire method: `mcp.config.reload`.
1092 ///
1093 /// <div class="warning">
1094 ///
1095 /// **Experimental.** This API is part of an experimental wire-protocol surface
1096 /// and may change or be removed in future SDK or CLI releases. Pin both the
1097 /// SDK and CLI versions if your code depends on it.
1098 ///
1099 /// </div>
1100 pub async fn reload(&self) -> Result<(), Error> {
1101 let wire_params = serde_json::json!({});
1102 let _value = self
1103 .client
1104 .call(rpc_methods::MCP_CONFIG_RELOAD, Some(wire_params))
1105 .await?;
1106 Ok(())
1107 }
1108}
1109
1110/// `models.*` RPCs.
1111#[derive(Clone, Copy)]
1112pub struct ClientRpcModels<'a> {
1113 pub(crate) client: &'a Client,
1114}
1115
1116impl<'a> ClientRpcModels<'a> {
1117 /// Lists Copilot models available to the authenticated user.
1118 ///
1119 /// Wire method: `models.list`.
1120 ///
1121 /// # Returns
1122 ///
1123 /// List of Copilot models available to the resolved user, including capabilities and billing metadata.
1124 ///
1125 /// <div class="warning">
1126 ///
1127 /// **Experimental.** This API is part of an experimental wire-protocol surface
1128 /// and may change or be removed in future SDK or CLI releases. Pin both the
1129 /// SDK and CLI versions if your code depends on it.
1130 ///
1131 /// </div>
1132 pub async fn list(&self) -> Result<ModelList, Error> {
1133 let wire_params = serde_json::json!({});
1134 let _value = self
1135 .client
1136 .call(rpc_methods::MODELS_LIST, Some(wire_params))
1137 .await?;
1138 Ok(serde_json::from_value(_value)?)
1139 }
1140
1141 /// Lists Copilot models available to the authenticated user.
1142 ///
1143 /// Wire method: `models.list`.
1144 ///
1145 /// # Parameters
1146 ///
1147 /// * `params` - Optional opaque account selection or compatibility GitHub token used to list models.
1148 ///
1149 /// # Returns
1150 ///
1151 /// List of Copilot models available to the resolved user, including capabilities and billing metadata.
1152 ///
1153 /// <div class="warning">
1154 ///
1155 /// **Experimental.** This API is part of an experimental wire-protocol surface
1156 /// and may change or be removed in future SDK or CLI releases. Pin both the
1157 /// SDK and CLI versions if your code depends on it.
1158 ///
1159 /// </div>
1160 pub async fn list_with_params(&self, params: ModelsListRequest) -> Result<ModelList, Error> {
1161 let wire_params = serde_json::to_value(params)?;
1162 let _value = self
1163 .client
1164 .call(rpc_methods::MODELS_LIST, Some(wire_params))
1165 .await?;
1166 Ok(serde_json::from_value(_value)?)
1167 }
1168
1169 /// Returns the running runtime's complete catalog of well-known built-in model IDs without authentication or network access.
1170 ///
1171 /// Wire method: `models.getBuiltInCatalog`.
1172 ///
1173 /// # Returns
1174 ///
1175 /// The running runtime's complete catalog of well-known built-in model IDs, including supported models and additional IDs with built-in metadata.
1176 ///
1177 /// <div class="warning">
1178 ///
1179 /// **Experimental.** This API is part of an experimental wire-protocol surface
1180 /// and may change or be removed in future SDK or CLI releases. Pin both the
1181 /// SDK and CLI versions if your code depends on it.
1182 ///
1183 /// </div>
1184 pub async fn get_built_in_catalog(&self) -> Result<BuiltInModelCatalog, Error> {
1185 let wire_params = serde_json::json!({});
1186 let _value = self
1187 .client
1188 .call(rpc_methods::MODELS_GETBUILTINCATALOG, Some(wire_params))
1189 .await?;
1190 Ok(serde_json::from_value(_value)?)
1191 }
1192}
1193
1194/// `plugins.*` RPCs.
1195#[derive(Clone, Copy)]
1196pub struct ClientRpcPlugins<'a> {
1197 pub(crate) client: &'a Client,
1198}
1199
1200impl<'a> ClientRpcPlugins<'a> {
1201 /// `plugins.builtin.*` sub-namespace.
1202 pub fn builtin(&self) -> ClientRpcPluginsBuiltin<'a> {
1203 ClientRpcPluginsBuiltin {
1204 client: self.client,
1205 }
1206 }
1207
1208 /// `plugins.marketplaces.*` sub-namespace.
1209 pub fn marketplaces(&self) -> ClientRpcPluginsMarketplaces<'a> {
1210 ClientRpcPluginsMarketplaces {
1211 client: self.client,
1212 }
1213 }
1214
1215 /// Lists plugins installed in user/global state.
1216 ///
1217 /// Wire method: `plugins.list`.
1218 ///
1219 /// # Returns
1220 ///
1221 /// Plugins installed in user/global state.
1222 ///
1223 /// <div class="warning">
1224 ///
1225 /// **Experimental.** This API is part of an experimental wire-protocol surface
1226 /// and may change or be removed in future SDK or CLI releases. Pin both the
1227 /// SDK and CLI versions if your code depends on it.
1228 ///
1229 /// </div>
1230 pub async fn list(&self) -> Result<PluginListResult, Error> {
1231 let wire_params = serde_json::json!({});
1232 let _value = self
1233 .client
1234 .call(rpc_methods::PLUGINS_LIST, Some(wire_params))
1235 .await?;
1236 Ok(serde_json::from_value(_value)?)
1237 }
1238
1239 /// Installs a plugin from a marketplace, GitHub repo, URL, or local path.
1240 ///
1241 /// Wire method: `plugins.install`.
1242 ///
1243 /// # Parameters
1244 ///
1245 /// * `params` - Plugin source and optional working directory for relative-path resolution.
1246 ///
1247 /// # Returns
1248 ///
1249 /// Result of installing a plugin.
1250 ///
1251 /// <div class="warning">
1252 ///
1253 /// **Experimental.** This API is part of an experimental wire-protocol surface
1254 /// and may change or be removed in future SDK or CLI releases. Pin both the
1255 /// SDK and CLI versions if your code depends on it.
1256 ///
1257 /// </div>
1258 pub async fn install(
1259 &self,
1260 params: PluginsInstallRequest,
1261 ) -> Result<PluginInstallResult, Error> {
1262 let wire_params = serde_json::to_value(params)?;
1263 let _value = self
1264 .client
1265 .call(rpc_methods::PLUGINS_INSTALL, Some(wire_params))
1266 .await?;
1267 Ok(serde_json::from_value(_value)?)
1268 }
1269
1270 /// Uninstalls an installed plugin.
1271 ///
1272 /// Wire method: `plugins.uninstall`.
1273 ///
1274 /// # Parameters
1275 ///
1276 /// * `params` - Name (or spec) of the plugin to uninstall.
1277 ///
1278 /// <div class="warning">
1279 ///
1280 /// **Experimental.** This API is part of an experimental wire-protocol surface
1281 /// and may change or be removed in future SDK or CLI releases. Pin both the
1282 /// SDK and CLI versions if your code depends on it.
1283 ///
1284 /// </div>
1285 pub async fn uninstall(&self, params: PluginsUninstallRequest) -> Result<(), Error> {
1286 let wire_params = serde_json::to_value(params)?;
1287 let _value = self
1288 .client
1289 .call(rpc_methods::PLUGINS_UNINSTALL, Some(wire_params))
1290 .await?;
1291 Ok(())
1292 }
1293
1294 /// Updates an installed plugin to its latest published version.
1295 ///
1296 /// Wire method: `plugins.update`.
1297 ///
1298 /// # Parameters
1299 ///
1300 /// * `params` - Name (or spec) of the plugin to update.
1301 ///
1302 /// # Returns
1303 ///
1304 /// Result of updating a single plugin.
1305 ///
1306 /// <div class="warning">
1307 ///
1308 /// **Experimental.** This API is part of an experimental wire-protocol surface
1309 /// and may change or be removed in future SDK or CLI releases. Pin both the
1310 /// SDK and CLI versions if your code depends on it.
1311 ///
1312 /// </div>
1313 pub async fn update(&self, params: PluginsUpdateRequest) -> Result<PluginUpdateResult, Error> {
1314 let wire_params = serde_json::to_value(params)?;
1315 let _value = self
1316 .client
1317 .call(rpc_methods::PLUGINS_UPDATE, Some(wire_params))
1318 .await?;
1319 Ok(serde_json::from_value(_value)?)
1320 }
1321
1322 /// Updates every installed plugin to its latest published version.
1323 ///
1324 /// Wire method: `plugins.updateAll`.
1325 ///
1326 /// # Returns
1327 ///
1328 /// Result of updating all installed plugins.
1329 ///
1330 /// <div class="warning">
1331 ///
1332 /// **Experimental.** This API is part of an experimental wire-protocol surface
1333 /// and may change or be removed in future SDK or CLI releases. Pin both the
1334 /// SDK and CLI versions if your code depends on it.
1335 ///
1336 /// </div>
1337 pub async fn update_all(&self) -> Result<PluginUpdateAllResult, Error> {
1338 let wire_params = serde_json::json!({});
1339 let _value = self
1340 .client
1341 .call(rpc_methods::PLUGINS_UPDATEALL, Some(wire_params))
1342 .await?;
1343 Ok(serde_json::from_value(_value)?)
1344 }
1345
1346 /// Enables installed plugins for new sessions.
1347 ///
1348 /// Wire method: `plugins.enable`.
1349 ///
1350 /// # Parameters
1351 ///
1352 /// * `params` - Plugin names (or specs) to enable.
1353 ///
1354 /// <div class="warning">
1355 ///
1356 /// **Experimental.** This API is part of an experimental wire-protocol surface
1357 /// and may change or be removed in future SDK or CLI releases. Pin both the
1358 /// SDK and CLI versions if your code depends on it.
1359 ///
1360 /// </div>
1361 pub async fn enable(&self, params: PluginsEnableRequest) -> Result<(), Error> {
1362 let wire_params = serde_json::to_value(params)?;
1363 let _value = self
1364 .client
1365 .call(rpc_methods::PLUGINS_ENABLE, Some(wire_params))
1366 .await?;
1367 Ok(())
1368 }
1369
1370 /// Disables installed plugins for new sessions.
1371 ///
1372 /// Wire method: `plugins.disable`.
1373 ///
1374 /// # Parameters
1375 ///
1376 /// * `params` - Plugin names (or specs) to disable.
1377 ///
1378 /// <div class="warning">
1379 ///
1380 /// **Experimental.** This API is part of an experimental wire-protocol surface
1381 /// and may change or be removed in future SDK or CLI releases. Pin both the
1382 /// SDK and CLI versions if your code depends on it.
1383 ///
1384 /// </div>
1385 pub async fn disable(&self, params: PluginsDisableRequest) -> Result<(), Error> {
1386 let wire_params = serde_json::to_value(params)?;
1387 let _value = self
1388 .client
1389 .call(rpc_methods::PLUGINS_DISABLE, Some(wire_params))
1390 .await?;
1391 Ok(())
1392 }
1393}
1394
1395/// `plugins.builtin.*` RPCs.
1396#[derive(Clone, Copy)]
1397pub struct ClientRpcPluginsBuiltin<'a> {
1398 pub(crate) client: &'a Client,
1399}
1400
1401impl<'a> ClientRpcPluginsBuiltin<'a> {
1402 /// Replaces this server's trusted built-in plugin directories while no sessions are active.
1403 ///
1404 /// Wire method: `plugins.builtin.set`.
1405 ///
1406 /// # Parameters
1407 ///
1408 /// * `params` - Trusted built-in plugin directories to use for this runtime process.
1409 ///
1410 /// <div class="warning">
1411 ///
1412 /// **Experimental.** This API is part of an experimental wire-protocol surface
1413 /// and may change or be removed in future SDK or CLI releases. Pin both the
1414 /// SDK and CLI versions if your code depends on it.
1415 ///
1416 /// </div>
1417 pub async fn set(&self, params: PluginsBuiltinSetRequest) -> Result<(), Error> {
1418 let wire_params = serde_json::to_value(params)?;
1419 let _value = self
1420 .client
1421 .call(rpc_methods::PLUGINS_BUILTIN_SET, Some(wire_params))
1422 .await?;
1423 Ok(())
1424 }
1425}
1426
1427/// `plugins.marketplaces.*` RPCs.
1428#[derive(Clone, Copy)]
1429pub struct ClientRpcPluginsMarketplaces<'a> {
1430 pub(crate) client: &'a Client,
1431}
1432
1433impl<'a> ClientRpcPluginsMarketplaces<'a> {
1434 /// Lists all registered marketplaces (defaults + user-added).
1435 ///
1436 /// Wire method: `plugins.marketplaces.list`.
1437 ///
1438 /// # Returns
1439 ///
1440 /// All registered marketplaces, including built-in defaults.
1441 ///
1442 /// <div class="warning">
1443 ///
1444 /// **Experimental.** This API is part of an experimental wire-protocol surface
1445 /// and may change or be removed in future SDK or CLI releases. Pin both the
1446 /// SDK and CLI versions if your code depends on it.
1447 ///
1448 /// </div>
1449 pub async fn list(&self) -> Result<MarketplaceListResult, Error> {
1450 let wire_params = serde_json::json!({});
1451 let _value = self
1452 .client
1453 .call(rpc_methods::PLUGINS_MARKETPLACES_LIST, Some(wire_params))
1454 .await?;
1455 Ok(serde_json::from_value(_value)?)
1456 }
1457
1458 /// Registers a new marketplace from a source (owner/repo, URL, or local path).
1459 ///
1460 /// Wire method: `plugins.marketplaces.add`.
1461 ///
1462 /// # Parameters
1463 ///
1464 /// * `params` - Marketplace source and optional working directory for relative-path resolution.
1465 ///
1466 /// # Returns
1467 ///
1468 /// Result of registering a new marketplace.
1469 ///
1470 /// <div class="warning">
1471 ///
1472 /// **Experimental.** This API is part of an experimental wire-protocol surface
1473 /// and may change or be removed in future SDK or CLI releases. Pin both the
1474 /// SDK and CLI versions if your code depends on it.
1475 ///
1476 /// </div>
1477 pub async fn add(
1478 &self,
1479 params: PluginsMarketplacesAddRequest,
1480 ) -> Result<MarketplaceAddResult, Error> {
1481 let wire_params = serde_json::to_value(params)?;
1482 let _value = self
1483 .client
1484 .call(rpc_methods::PLUGINS_MARKETPLACES_ADD, Some(wire_params))
1485 .await?;
1486 Ok(serde_json::from_value(_value)?)
1487 }
1488
1489 /// Removes a previously-registered marketplace. When the marketplace has dependent plugins and `force` is not set, the marketplace is left intact and the result lists the dependents so the caller can decide whether to retry with `force=true`.
1490 ///
1491 /// Wire method: `plugins.marketplaces.remove`.
1492 ///
1493 /// # Parameters
1494 ///
1495 /// * `params` - Name of the marketplace to remove and an optional force flag.
1496 ///
1497 /// # Returns
1498 ///
1499 /// Outcome of the remove attempt, including dependent-plugin info when applicable.
1500 ///
1501 /// <div class="warning">
1502 ///
1503 /// **Experimental.** This API is part of an experimental wire-protocol surface
1504 /// and may change or be removed in future SDK or CLI releases. Pin both the
1505 /// SDK and CLI versions if your code depends on it.
1506 ///
1507 /// </div>
1508 pub async fn remove(
1509 &self,
1510 params: PluginsMarketplacesRemoveRequest,
1511 ) -> Result<MarketplaceRemoveResult, Error> {
1512 let wire_params = serde_json::to_value(params)?;
1513 let _value = self
1514 .client
1515 .call(rpc_methods::PLUGINS_MARKETPLACES_REMOVE, Some(wire_params))
1516 .await?;
1517 Ok(serde_json::from_value(_value)?)
1518 }
1519
1520 /// Lists plugins advertised by a registered marketplace.
1521 ///
1522 /// Wire method: `plugins.marketplaces.browse`.
1523 ///
1524 /// # Parameters
1525 ///
1526 /// * `params` - Name of the marketplace whose plugin catalog to fetch.
1527 ///
1528 /// # Returns
1529 ///
1530 /// Plugins advertised by the marketplace.
1531 ///
1532 /// <div class="warning">
1533 ///
1534 /// **Experimental.** This API is part of an experimental wire-protocol surface
1535 /// and may change or be removed in future SDK or CLI releases. Pin both the
1536 /// SDK and CLI versions if your code depends on it.
1537 ///
1538 /// </div>
1539 pub async fn browse(
1540 &self,
1541 params: PluginsMarketplacesBrowseRequest,
1542 ) -> Result<MarketplaceBrowseResult, Error> {
1543 let wire_params = serde_json::to_value(params)?;
1544 let _value = self
1545 .client
1546 .call(rpc_methods::PLUGINS_MARKETPLACES_BROWSE, Some(wire_params))
1547 .await?;
1548 Ok(serde_json::from_value(_value)?)
1549 }
1550
1551 /// Re-fetches one or all registered marketplace catalogs.
1552 ///
1553 /// Wire method: `plugins.marketplaces.refresh`.
1554 ///
1555 /// # Returns
1556 ///
1557 /// Result of refreshing one or more marketplace catalogs.
1558 ///
1559 /// <div class="warning">
1560 ///
1561 /// **Experimental.** This API is part of an experimental wire-protocol surface
1562 /// and may change or be removed in future SDK or CLI releases. Pin both the
1563 /// SDK and CLI versions if your code depends on it.
1564 ///
1565 /// </div>
1566 pub async fn refresh(&self) -> Result<MarketplaceRefreshResult, Error> {
1567 let wire_params = serde_json::json!({});
1568 let _value = self
1569 .client
1570 .call(rpc_methods::PLUGINS_MARKETPLACES_REFRESH, Some(wire_params))
1571 .await?;
1572 Ok(serde_json::from_value(_value)?)
1573 }
1574
1575 /// Re-fetches one or all registered marketplace catalogs.
1576 ///
1577 /// Wire method: `plugins.marketplaces.refresh`.
1578 ///
1579 /// # Parameters
1580 ///
1581 /// * `params` - Optional marketplace name; omit to refresh all.
1582 ///
1583 /// # Returns
1584 ///
1585 /// Result of refreshing one or more marketplace catalogs.
1586 ///
1587 /// <div class="warning">
1588 ///
1589 /// **Experimental.** This API is part of an experimental wire-protocol surface
1590 /// and may change or be removed in future SDK or CLI releases. Pin both the
1591 /// SDK and CLI versions if your code depends on it.
1592 ///
1593 /// </div>
1594 pub async fn refresh_with_params(
1595 &self,
1596 params: PluginsMarketplacesRefreshRequest,
1597 ) -> Result<MarketplaceRefreshResult, Error> {
1598 let wire_params = serde_json::to_value(params)?;
1599 let _value = self
1600 .client
1601 .call(rpc_methods::PLUGINS_MARKETPLACES_REFRESH, Some(wire_params))
1602 .await?;
1603 Ok(serde_json::from_value(_value)?)
1604 }
1605}
1606
1607/// `runtime.*` RPCs.
1608#[derive(Clone, Copy)]
1609pub struct ClientRpcRuntime<'a> {
1610 pub(crate) client: &'a Client,
1611}
1612
1613impl<'a> ClientRpcRuntime<'a> {
1614 /// Gracefully shuts down an SDK-owned runtime. The response is sent only after cleanup completes; callers may then terminate the owned runtime process.
1615 ///
1616 /// Wire method: `runtime.shutdown`.
1617 ///
1618 /// <div class="warning">
1619 ///
1620 /// **Experimental.** This API is part of an experimental wire-protocol surface
1621 /// and may change or be removed in future SDK or CLI releases. Pin both the
1622 /// SDK and CLI versions if your code depends on it.
1623 ///
1624 /// </div>
1625 pub async fn shutdown(&self) -> Result<(), Error> {
1626 let wire_params = serde_json::json!({});
1627 let _value = self
1628 .client
1629 .call(rpc_methods::RUNTIME_SHUTDOWN, Some(wire_params))
1630 .await?;
1631 Ok(())
1632 }
1633}
1634
1635/// `secrets.*` RPCs.
1636#[derive(Clone, Copy)]
1637pub struct ClientRpcSecrets<'a> {
1638 pub(crate) client: &'a Client,
1639}
1640
1641impl<'a> ClientRpcSecrets<'a> {
1642 /// Registers secret values for redaction in session logs and exports. The SDK calls this to inject dynamically generated secret values (e.g., OIDC tokens).
1643 ///
1644 /// Wire method: `secrets.addFilterValues`.
1645 ///
1646 /// # Parameters
1647 ///
1648 /// * `params` - Secret values to add to the redaction filter.
1649 ///
1650 /// # Returns
1651 ///
1652 /// Confirmation that the secret values were registered.
1653 ///
1654 /// <div class="warning">
1655 ///
1656 /// **Experimental.** This API is part of an experimental wire-protocol surface
1657 /// and may change or be removed in future SDK or CLI releases. Pin both the
1658 /// SDK and CLI versions if your code depends on it.
1659 ///
1660 /// </div>
1661 pub async fn add_filter_values(
1662 &self,
1663 params: SecretsAddFilterValuesRequest,
1664 ) -> Result<SecretsAddFilterValuesResult, Error> {
1665 let wire_params = serde_json::to_value(params)?;
1666 let _value = self
1667 .client
1668 .call(rpc_methods::SECRETS_ADDFILTERVALUES, Some(wire_params))
1669 .await?;
1670 Ok(serde_json::from_value(_value)?)
1671 }
1672}
1673
1674/// `sessionFs.*` RPCs.
1675#[derive(Clone, Copy)]
1676pub struct ClientRpcSessionFs<'a> {
1677 pub(crate) client: &'a Client,
1678}
1679
1680impl<'a> ClientRpcSessionFs<'a> {
1681 /// Registers an SDK client as the session filesystem provider.
1682 ///
1683 /// Wire method: `sessionFs.setProvider`.
1684 ///
1685 /// # Parameters
1686 ///
1687 /// * `params` - Initial working directory, session-state path layout, and path conventions used to register the calling SDK client as the session filesystem provider.
1688 ///
1689 /// # Returns
1690 ///
1691 /// Indicates whether the calling client was registered as the session filesystem provider.
1692 ///
1693 /// <div class="warning">
1694 ///
1695 /// **Experimental.** This API is part of an experimental wire-protocol surface
1696 /// and may change or be removed in future SDK or CLI releases. Pin both the
1697 /// SDK and CLI versions if your code depends on it.
1698 ///
1699 /// </div>
1700 pub async fn set_provider(
1701 &self,
1702 params: SessionFsSetProviderRequest,
1703 ) -> Result<SessionFsSetProviderResult, Error> {
1704 let wire_params = serde_json::to_value(params)?;
1705 let _value = self
1706 .client
1707 .call(rpc_methods::SESSIONFS_SETPROVIDER, Some(wire_params))
1708 .await?;
1709 Ok(serde_json::from_value(_value)?)
1710 }
1711}
1712
1713/// `sessions.*` RPCs.
1714#[derive(Clone, Copy)]
1715pub struct ClientRpcSessions<'a> {
1716 pub(crate) client: &'a Client,
1717}
1718
1719impl<'a> ClientRpcSessions<'a> {
1720 /// Creates or resumes a local session and returns the opened session ID.
1721 ///
1722 /// Wire method: `sessions.open`.
1723 ///
1724 /// # Returns
1725 ///
1726 /// Result of opening a session.
1727 ///
1728 /// <div class="warning">
1729 ///
1730 /// **Experimental.** This API is part of an experimental wire-protocol surface
1731 /// and may change or be removed in future SDK or CLI releases. Pin both the
1732 /// SDK and CLI versions if your code depends on it.
1733 ///
1734 /// </div>
1735 pub async fn open(&self) -> Result<SessionOpenResult, Error> {
1736 let wire_params = serde_json::json!({});
1737 let _value = self
1738 .client
1739 .call(rpc_methods::SESSIONS_OPEN, Some(wire_params))
1740 .await?;
1741 Ok(serde_json::from_value(_value)?)
1742 }
1743
1744 /// Creates a new session by forking persisted history from an existing session.
1745 ///
1746 /// Wire method: `sessions.fork`.
1747 ///
1748 /// # Parameters
1749 ///
1750 /// * `params` - Source session identifier to fork from, optional event-ID boundary, and optional friendly name for the new session.
1751 ///
1752 /// # Returns
1753 ///
1754 /// Identifier and optional friendly name assigned to the newly forked session.
1755 ///
1756 /// <div class="warning">
1757 ///
1758 /// **Experimental.** This API is part of an experimental wire-protocol surface
1759 /// and may change or be removed in future SDK or CLI releases. Pin both the
1760 /// SDK and CLI versions if your code depends on it.
1761 ///
1762 /// </div>
1763 pub async fn fork(&self, params: SessionsForkRequest) -> Result<SessionsForkResult, Error> {
1764 let wire_params = serde_json::to_value(params)?;
1765 let _value = self
1766 .client
1767 .call(rpc_methods::SESSIONS_FORK, Some(wire_params))
1768 .await?;
1769 Ok(serde_json::from_value(_value)?)
1770 }
1771
1772 /// Connects to an existing remote session and exposes it as an SDK session.
1773 ///
1774 /// Wire method: `sessions.connect`.
1775 ///
1776 /// # Parameters
1777 ///
1778 /// * `params` - Remote session connection parameters.
1779 ///
1780 /// # Returns
1781 ///
1782 /// Remote session connection result.
1783 ///
1784 /// <div class="warning">
1785 ///
1786 /// **Experimental.** This API is part of an experimental wire-protocol surface
1787 /// and may change or be removed in future SDK or CLI releases. Pin both the
1788 /// SDK and CLI versions if your code depends on it.
1789 ///
1790 /// </div>
1791 pub async fn connect(
1792 &self,
1793 params: ConnectRemoteSessionParams,
1794 ) -> Result<RemoteSessionConnectionResult, Error> {
1795 let wire_params = serde_json::to_value(params)?;
1796 let _value = self
1797 .client
1798 .call(rpc_methods::SESSIONS_CONNECT, Some(wire_params))
1799 .await?;
1800 Ok(serde_json::from_value(_value)?)
1801 }
1802
1803 /// Lists sessions, optionally filtered by source and working-directory context. Returned entries are discriminated by `isRemote`: local entries carry only the lightweight `LocalSessionMetadataValue` shape; remote entries carry the full `RemoteSessionMetadataValue` shape (repository, PR number, taskType, etc.).
1804 ///
1805 /// Wire method: `sessions.list`.
1806 ///
1807 /// # Returns
1808 ///
1809 /// Sessions matching the filter, ordered most-recently-modified first.
1810 ///
1811 /// <div class="warning">
1812 ///
1813 /// **Experimental.** This API is part of an experimental wire-protocol surface
1814 /// and may change or be removed in future SDK or CLI releases. Pin both the
1815 /// SDK and CLI versions if your code depends on it.
1816 ///
1817 /// </div>
1818 pub async fn list(&self) -> Result<SessionList, Error> {
1819 let wire_params = serde_json::json!({});
1820 let _value = self
1821 .client
1822 .call(rpc_methods::SESSIONS_LIST, Some(wire_params))
1823 .await?;
1824 Ok(serde_json::from_value(_value)?)
1825 }
1826
1827 /// Lists sessions, optionally filtered by source and working-directory context. Returned entries are discriminated by `isRemote`: local entries carry only the lightweight `LocalSessionMetadataValue` shape; remote entries carry the full `RemoteSessionMetadataValue` shape (repository, PR number, taskType, etc.).
1828 ///
1829 /// Wire method: `sessions.list`.
1830 ///
1831 /// # Parameters
1832 ///
1833 /// * `params` - Optional source filter, metadata-load limit, and context filter applied to the returned sessions.
1834 ///
1835 /// # Returns
1836 ///
1837 /// Sessions matching the filter, ordered most-recently-modified first.
1838 ///
1839 /// <div class="warning">
1840 ///
1841 /// **Experimental.** This API is part of an experimental wire-protocol surface
1842 /// and may change or be removed in future SDK or CLI releases. Pin both the
1843 /// SDK and CLI versions if your code depends on it.
1844 ///
1845 /// </div>
1846 pub async fn list_with_params(
1847 &self,
1848 params: SessionsListRequest,
1849 ) -> Result<SessionList, Error> {
1850 let wire_params = serde_json::to_value(params)?;
1851 let _value = self
1852 .client
1853 .call(rpc_methods::SESSIONS_LIST, Some(wire_params))
1854 .await?;
1855 Ok(serde_json::from_value(_value)?)
1856 }
1857
1858 /// Reads lightweight persisted metadata for one local session without opening it.
1859 ///
1860 /// Wire method: `sessions.getMetadata`.
1861 ///
1862 /// # Parameters
1863 ///
1864 /// * `params` - Session ID whose persisted metadata should be read.
1865 ///
1866 /// # Returns
1867 ///
1868 /// Persisted local session metadata when the session exists.
1869 ///
1870 /// <div class="warning">
1871 ///
1872 /// **Experimental.** This API is part of an experimental wire-protocol surface
1873 /// and may change or be removed in future SDK or CLI releases. Pin both the
1874 /// SDK and CLI versions if your code depends on it.
1875 ///
1876 /// </div>
1877 pub(crate) async fn get_metadata(
1878 &self,
1879 params: SessionsGetMetadataRequest,
1880 ) -> Result<SessionsGetMetadataResult, Error> {
1881 let wire_params = serde_json::to_value(params)?;
1882 let _value = self
1883 .client
1884 .call(rpc_methods::SESSIONS_GETMETADATA, Some(wire_params))
1885 .await?;
1886 Ok(serde_json::from_value(_value)?)
1887 }
1888
1889 /// Lists recent local session IDs that contain user-visible history, omitting housekeeping-only sessions.
1890 ///
1891 /// Wire method: `sessions.listNonEmptySessionIds`.
1892 ///
1893 /// # Parameters
1894 ///
1895 /// * `params` - Limit for non-empty local session IDs.
1896 ///
1897 /// # Returns
1898 ///
1899 /// Recent local session IDs that contain user-visible history.
1900 ///
1901 /// <div class="warning">
1902 ///
1903 /// **Experimental.** This API is part of an experimental wire-protocol surface
1904 /// and may change or be removed in future SDK or CLI releases. Pin both the
1905 /// SDK and CLI versions if your code depends on it.
1906 ///
1907 /// </div>
1908 pub(crate) async fn list_non_empty_session_ids(
1909 &self,
1910 params: SessionsListNonEmptySessionIdsRequest,
1911 ) -> Result<SessionsListNonEmptySessionIdsResult, Error> {
1912 let wire_params = serde_json::to_value(params)?;
1913 let _value = self
1914 .client
1915 .call(
1916 rpc_methods::SESSIONS_LISTNONEMPTYSESSIONIDS,
1917 Some(wire_params),
1918 )
1919 .await?;
1920 Ok(serde_json::from_value(_value)?)
1921 }
1922
1923 /// Finds the local session bound to a GitHub task ID, if any.
1924 ///
1925 /// Wire method: `sessions.findByTaskId`.
1926 ///
1927 /// # Parameters
1928 ///
1929 /// * `params` - GitHub task ID to look up.
1930 ///
1931 /// # Returns
1932 ///
1933 /// ID of the local session bound to the given GitHub task, or omitted when none.
1934 ///
1935 /// <div class="warning">
1936 ///
1937 /// **Experimental.** This API is part of an experimental wire-protocol surface
1938 /// and may change or be removed in future SDK or CLI releases. Pin both the
1939 /// SDK and CLI versions if your code depends on it.
1940 ///
1941 /// </div>
1942 pub async fn find_by_task_id(
1943 &self,
1944 params: SessionsFindByTaskIDRequest,
1945 ) -> Result<SessionsFindByTaskIDResult, Error> {
1946 let wire_params = serde_json::to_value(params)?;
1947 let _value = self
1948 .client
1949 .call(rpc_methods::SESSIONS_FINDBYTASKID, Some(wire_params))
1950 .await?;
1951 Ok(serde_json::from_value(_value)?)
1952 }
1953
1954 /// Resolves a UUID prefix to a unique session ID, if exactly one session matches.
1955 ///
1956 /// Wire method: `sessions.findByPrefix`.
1957 ///
1958 /// # Parameters
1959 ///
1960 /// * `params` - UUID prefix to resolve to a unique session ID.
1961 ///
1962 /// # Returns
1963 ///
1964 /// Session ID matching the prefix, omitted when no unique match exists.
1965 ///
1966 /// <div class="warning">
1967 ///
1968 /// **Experimental.** This API is part of an experimental wire-protocol surface
1969 /// and may change or be removed in future SDK or CLI releases. Pin both the
1970 /// SDK and CLI versions if your code depends on it.
1971 ///
1972 /// </div>
1973 pub async fn find_by_prefix(
1974 &self,
1975 params: SessionsFindByPrefixRequest,
1976 ) -> Result<SessionsFindByPrefixResult, Error> {
1977 let wire_params = serde_json::to_value(params)?;
1978 let _value = self
1979 .client
1980 .call(rpc_methods::SESSIONS_FINDBYPREFIX, Some(wire_params))
1981 .await?;
1982 Ok(serde_json::from_value(_value)?)
1983 }
1984
1985 /// Returns the most-relevant prior session for a given working-directory context.
1986 ///
1987 /// Wire method: `sessions.getLastForContext`.
1988 ///
1989 /// # Parameters
1990 ///
1991 /// * `params` - Optional working-directory context used to score session relevance.
1992 ///
1993 /// # Returns
1994 ///
1995 /// Most-relevant session ID for the supplied context, or omitted when no sessions exist.
1996 ///
1997 /// <div class="warning">
1998 ///
1999 /// **Experimental.** This API is part of an experimental wire-protocol surface
2000 /// and may change or be removed in future SDK or CLI releases. Pin both the
2001 /// SDK and CLI versions if your code depends on it.
2002 ///
2003 /// </div>
2004 pub async fn get_last_for_context(
2005 &self,
2006 params: SessionsGetLastForContextRequest,
2007 ) -> Result<SessionsGetLastForContextResult, Error> {
2008 let wire_params = serde_json::to_value(params)?;
2009 let _value = self
2010 .client
2011 .call(rpc_methods::SESSIONS_GETLASTFORCONTEXT, Some(wire_params))
2012 .await?;
2013 Ok(serde_json::from_value(_value)?)
2014 }
2015
2016 /// Computes the absolute path to a session's persisted events.jsonl file. Internal: filesystem paths are only meaningful in-process (CLI and runtime share a filesystem). Currently used by the CLI's contribution-graph feature to read historical events directly. Remote SDK consumers must not depend on this; a proper event-query API would replace it if the contribution graph ever needed to work over the wire.
2017 ///
2018 /// Wire method: `sessions.getEventFilePath`.
2019 ///
2020 /// # Parameters
2021 ///
2022 /// * `params` - Session ID whose event-log file path to compute.
2023 ///
2024 /// # Returns
2025 ///
2026 /// Absolute path to the session's events.jsonl file on disk.
2027 ///
2028 /// <div class="warning">
2029 ///
2030 /// **Experimental.** This API is part of an experimental wire-protocol surface
2031 /// and may change or be removed in future SDK or CLI releases. Pin both the
2032 /// SDK and CLI versions if your code depends on it.
2033 ///
2034 /// </div>
2035 pub(crate) async fn get_event_file_path(
2036 &self,
2037 params: SessionsGetEventFilePathRequest,
2038 ) -> Result<SessionsGetEventFilePathResult, Error> {
2039 let wire_params = serde_json::to_value(params)?;
2040 let _value = self
2041 .client
2042 .call(rpc_methods::SESSIONS_GETEVENTFILEPATH, Some(wire_params))
2043 .await?;
2044 Ok(serde_json::from_value(_value)?)
2045 }
2046
2047 /// Returns the on-disk byte size of each session's workspace directory.
2048 ///
2049 /// Wire method: `sessions.getSizes`.
2050 ///
2051 /// # Returns
2052 ///
2053 /// Map of sessionId -> on-disk size in bytes for each session's workspace directory.
2054 ///
2055 /// <div class="warning">
2056 ///
2057 /// **Experimental.** This API is part of an experimental wire-protocol surface
2058 /// and may change or be removed in future SDK or CLI releases. Pin both the
2059 /// SDK and CLI versions if your code depends on it.
2060 ///
2061 /// </div>
2062 pub async fn get_sizes(&self) -> Result<SessionSizes, Error> {
2063 let wire_params = serde_json::json!({});
2064 let _value = self
2065 .client
2066 .call(rpc_methods::SESSIONS_GETSIZES, Some(wire_params))
2067 .await?;
2068 Ok(serde_json::from_value(_value)?)
2069 }
2070
2071 /// Returns the subset of the supplied session IDs that are currently held by another running process.
2072 ///
2073 /// Wire method: `sessions.checkInUse`.
2074 ///
2075 /// # Parameters
2076 ///
2077 /// * `params` - Session IDs to test for live in-use locks.
2078 ///
2079 /// # Returns
2080 ///
2081 /// Session IDs from the input set that are currently in use by another process.
2082 ///
2083 /// <div class="warning">
2084 ///
2085 /// **Experimental.** This API is part of an experimental wire-protocol surface
2086 /// and may change or be removed in future SDK or CLI releases. Pin both the
2087 /// SDK and CLI versions if your code depends on it.
2088 ///
2089 /// </div>
2090 pub async fn check_in_use(
2091 &self,
2092 params: SessionsCheckInUseRequest,
2093 ) -> Result<SessionsCheckInUseResult, Error> {
2094 let wire_params = serde_json::to_value(params)?;
2095 let _value = self
2096 .client
2097 .call(rpc_methods::SESSIONS_CHECKINUSE, Some(wire_params))
2098 .await?;
2099 Ok(serde_json::from_value(_value)?)
2100 }
2101
2102 /// Returns a session's persisted remote-steerable flag, if any has been recorded. Internal: this is CLI-specific book-keeping used by `--continue` / `--resume` to inherit the prior session's remote-steerable preference. SDK consumers that want similar behavior should manage their own persistence around start/stop calls rather than relying on this runtime-side flag.
2103 ///
2104 /// Wire method: `sessions.getPersistedRemoteSteerable`.
2105 ///
2106 /// # Parameters
2107 ///
2108 /// * `params` - Session ID to look up the persisted remote-steerable flag for.
2109 ///
2110 /// # Returns
2111 ///
2112 /// The session's persisted remote-steerable flag, or omitted when no value has been persisted.
2113 ///
2114 /// <div class="warning">
2115 ///
2116 /// **Experimental.** This API is part of an experimental wire-protocol surface
2117 /// and may change or be removed in future SDK or CLI releases. Pin both the
2118 /// SDK and CLI versions if your code depends on it.
2119 ///
2120 /// </div>
2121 pub(crate) async fn get_persisted_remote_steerable(
2122 &self,
2123 params: SessionsGetPersistedRemoteSteerableRequest,
2124 ) -> Result<SessionsGetPersistedRemoteSteerableResult, Error> {
2125 let wire_params = serde_json::to_value(params)?;
2126 let _value = self
2127 .client
2128 .call(
2129 rpc_methods::SESSIONS_GETPERSISTEDREMOTESTEERABLE,
2130 Some(wire_params),
2131 )
2132 .await?;
2133 Ok(serde_json::from_value(_value)?)
2134 }
2135
2136 /// Closes a session: emits shutdown, flushes pending events, releases the in-use lock, and disposes the active session.
2137 ///
2138 /// Wire method: `sessions.close`.
2139 ///
2140 /// # Parameters
2141 ///
2142 /// * `params` - Session ID to close.
2143 ///
2144 /// # Returns
2145 ///
2146 /// Closes a session: emits shutdown, flushes pending events to disk, releases the in-use lock, disposes the active session. Idempotent: succeeds even if the session is not currently active.
2147 ///
2148 /// <div class="warning">
2149 ///
2150 /// **Experimental.** This API is part of an experimental wire-protocol surface
2151 /// and may change or be removed in future SDK or CLI releases. Pin both the
2152 /// SDK and CLI versions if your code depends on it.
2153 ///
2154 /// </div>
2155 pub async fn close(&self, params: SessionsCloseRequest) -> Result<SessionsCloseResult, Error> {
2156 let wire_params = serde_json::to_value(params)?;
2157 let _value = self
2158 .client
2159 .call(rpc_methods::SESSIONS_CLOSE, Some(wire_params))
2160 .await?;
2161 Ok(serde_json::from_value(_value)?)
2162 }
2163
2164 /// Closes, deactivates, and deletes a set of sessions, returning the bytes freed per session.
2165 ///
2166 /// Wire method: `sessions.bulkDelete`.
2167 ///
2168 /// # Parameters
2169 ///
2170 /// * `params` - Session IDs to close, deactivate, and delete from disk.
2171 ///
2172 /// # Returns
2173 ///
2174 /// Map of sessionId -> bytes freed by removing the session's workspace directory.
2175 ///
2176 /// <div class="warning">
2177 ///
2178 /// **Experimental.** This API is part of an experimental wire-protocol surface
2179 /// and may change or be removed in future SDK or CLI releases. Pin both the
2180 /// SDK and CLI versions if your code depends on it.
2181 ///
2182 /// </div>
2183 pub async fn bulk_delete(
2184 &self,
2185 params: SessionsBulkDeleteRequest,
2186 ) -> Result<SessionBulkDeleteResult, Error> {
2187 let wire_params = serde_json::to_value(params)?;
2188 let _value = self
2189 .client
2190 .call(rpc_methods::SESSIONS_BULKDELETE, Some(wire_params))
2191 .await?;
2192 Ok(serde_json::from_value(_value)?)
2193 }
2194
2195 /// Deletes one local session from disk after running the same lifecycle hooks as the session manager.
2196 ///
2197 /// Wire method: `sessions.delete`.
2198 ///
2199 /// # Parameters
2200 ///
2201 /// * `params` - Session ID to delete from disk.
2202 ///
2203 /// <div class="warning">
2204 ///
2205 /// **Experimental.** This API is part of an experimental wire-protocol surface
2206 /// and may change or be removed in future SDK or CLI releases. Pin both the
2207 /// SDK and CLI versions if your code depends on it.
2208 ///
2209 /// </div>
2210 pub(crate) async fn delete(&self, params: SessionsDeleteRequest) -> Result<(), Error> {
2211 let wire_params = serde_json::to_value(params)?;
2212 let _value = self
2213 .client
2214 .call(rpc_methods::SESSIONS_DELETE, Some(wire_params))
2215 .await?;
2216 Ok(())
2217 }
2218
2219 /// Deletes sessions older than the given threshold, with optional dry-run and exclusion list.
2220 ///
2221 /// Wire method: `sessions.pruneOld`.
2222 ///
2223 /// # Parameters
2224 ///
2225 /// * `params` - Age threshold and optional flags controlling which old sessions are pruned (or simulated when dryRun is true).
2226 ///
2227 /// # Returns
2228 ///
2229 /// Outcome of the prune operation: deleted IDs, dry-run candidates, skipped IDs, total bytes freed, and the dry-run flag.
2230 ///
2231 /// <div class="warning">
2232 ///
2233 /// **Experimental.** This API is part of an experimental wire-protocol surface
2234 /// and may change or be removed in future SDK or CLI releases. Pin both the
2235 /// SDK and CLI versions if your code depends on it.
2236 ///
2237 /// </div>
2238 pub async fn prune_old(
2239 &self,
2240 params: SessionsPruneOldRequest,
2241 ) -> Result<SessionPruneResult, Error> {
2242 let wire_params = serde_json::to_value(params)?;
2243 let _value = self
2244 .client
2245 .call(rpc_methods::SESSIONS_PRUNEOLD, Some(wire_params))
2246 .await?;
2247 Ok(serde_json::from_value(_value)?)
2248 }
2249
2250 /// Flushes a session's pending events to disk.
2251 ///
2252 /// Wire method: `sessions.save`.
2253 ///
2254 /// # Parameters
2255 ///
2256 /// * `params` - Session ID whose pending events should be flushed to disk.
2257 ///
2258 /// # Returns
2259 ///
2260 /// Flush a session's pending events to disk. No-op when no writer exists for the session (e.g., already closed).
2261 ///
2262 /// <div class="warning">
2263 ///
2264 /// **Experimental.** This API is part of an experimental wire-protocol surface
2265 /// and may change or be removed in future SDK or CLI releases. Pin both the
2266 /// SDK and CLI versions if your code depends on it.
2267 ///
2268 /// </div>
2269 pub async fn save(&self, params: SessionsSaveRequest) -> Result<SessionsSaveResult, Error> {
2270 let wire_params = serde_json::to_value(params)?;
2271 let _value = self
2272 .client
2273 .call(rpc_methods::SESSIONS_SAVE, Some(wire_params))
2274 .await?;
2275 Ok(serde_json::from_value(_value)?)
2276 }
2277
2278 /// Releases the in-use lock held by this process for a session.
2279 ///
2280 /// Wire method: `sessions.releaseLock`.
2281 ///
2282 /// # Parameters
2283 ///
2284 /// * `params` - Session ID whose in-use lock should be released.
2285 ///
2286 /// # Returns
2287 ///
2288 /// Release the in-use lock held by this process for the given session. No-op when this process does not currently hold a lock for the session.
2289 ///
2290 /// <div class="warning">
2291 ///
2292 /// **Experimental.** This API is part of an experimental wire-protocol surface
2293 /// and may change or be removed in future SDK or CLI releases. Pin both the
2294 /// SDK and CLI versions if your code depends on it.
2295 ///
2296 /// </div>
2297 pub async fn release_lock(
2298 &self,
2299 params: SessionsReleaseLockRequest,
2300 ) -> Result<SessionsReleaseLockResult, Error> {
2301 let wire_params = serde_json::to_value(params)?;
2302 let _value = self
2303 .client
2304 .call(rpc_methods::SESSIONS_RELEASELOCK, Some(wire_params))
2305 .await?;
2306 Ok(serde_json::from_value(_value)?)
2307 }
2308
2309 /// Backfills missing summary and context fields on the supplied session metadata records.
2310 ///
2311 /// Wire method: `sessions.enrichMetadata`.
2312 ///
2313 /// # Parameters
2314 ///
2315 /// * `params` - Session metadata records to enrich with summary and context information.
2316 ///
2317 /// # Returns
2318 ///
2319 /// The enriched metadata records, with summary and context fields backfilled where available. Sessions confirmed empty and unnamed are omitted.
2320 ///
2321 /// <div class="warning">
2322 ///
2323 /// **Experimental.** This API is part of an experimental wire-protocol surface
2324 /// and may change or be removed in future SDK or CLI releases. Pin both the
2325 /// SDK and CLI versions if your code depends on it.
2326 ///
2327 /// </div>
2328 pub async fn enrich_metadata(
2329 &self,
2330 params: SessionsEnrichMetadataRequest,
2331 ) -> Result<SessionEnrichMetadataResult, Error> {
2332 let wire_params = serde_json::to_value(params)?;
2333 let _value = self
2334 .client
2335 .call(rpc_methods::SESSIONS_ENRICHMETADATA, Some(wire_params))
2336 .await?;
2337 Ok(serde_json::from_value(_value)?)
2338 }
2339
2340 /// Reloads user, plugin, and (optionally) repo hooks on the active session.
2341 ///
2342 /// Wire method: `sessions.reloadPluginHooks`.
2343 ///
2344 /// # Parameters
2345 ///
2346 /// * `params` - Active session ID and an optional flag for deferring repo-level hooks until folder trust.
2347 ///
2348 /// # Returns
2349 ///
2350 /// Reload all hooks (user, plugin, optionally repo) and apply them to the active session. Call after installing or removing plugins so their hooks take effect immediately. No-op when no active session matches the given sessionId.
2351 ///
2352 /// <div class="warning">
2353 ///
2354 /// **Experimental.** This API is part of an experimental wire-protocol surface
2355 /// and may change or be removed in future SDK or CLI releases. Pin both the
2356 /// SDK and CLI versions if your code depends on it.
2357 ///
2358 /// </div>
2359 pub async fn reload_plugin_hooks(
2360 &self,
2361 params: SessionsReloadPluginHooksRequest,
2362 ) -> Result<SessionsReloadPluginHooksResult, Error> {
2363 let wire_params = serde_json::to_value(params)?;
2364 let _value = self
2365 .client
2366 .call(rpc_methods::SESSIONS_RELOADPLUGINHOOKS, Some(wire_params))
2367 .await?;
2368 Ok(serde_json::from_value(_value)?)
2369 }
2370
2371 /// Loads previously-deferred repo-level hooks on the active session, returning queued startup prompts.
2372 ///
2373 /// Wire method: `sessions.loadDeferredRepoHooks`.
2374 ///
2375 /// # Parameters
2376 ///
2377 /// * `params` - Active session ID whose deferred repo-level hooks should be loaded.
2378 ///
2379 /// # Returns
2380 ///
2381 /// Queued repo-level startup prompts and the total hook command count after loading.
2382 ///
2383 /// <div class="warning">
2384 ///
2385 /// **Experimental.** This API is part of an experimental wire-protocol surface
2386 /// and may change or be removed in future SDK or CLI releases. Pin both the
2387 /// SDK and CLI versions if your code depends on it.
2388 ///
2389 /// </div>
2390 pub async fn load_deferred_repo_hooks(
2391 &self,
2392 params: SessionsLoadDeferredRepoHooksRequest,
2393 ) -> Result<SessionLoadDeferredRepoHooksResult, Error> {
2394 let wire_params = serde_json::to_value(params)?;
2395 let _value = self
2396 .client
2397 .call(
2398 rpc_methods::SESSIONS_LOADDEFERREDREPOHOOKS,
2399 Some(wire_params),
2400 )
2401 .await?;
2402 Ok(serde_json::from_value(_value)?)
2403 }
2404
2405 /// Replaces the manager-wide additional plugins registered with the session manager.
2406 ///
2407 /// Wire method: `sessions.setAdditionalPlugins`.
2408 ///
2409 /// # Parameters
2410 ///
2411 /// * `params` - Manager-wide additional plugins to register; replaces any previously-configured set.
2412 ///
2413 /// # Returns
2414 ///
2415 /// Replace the manager-wide additional plugins. New session creations and subsequent hook reloads see the new set; already-running sessions keep their existing hook installation until the next reload.
2416 ///
2417 /// <div class="warning">
2418 ///
2419 /// **Experimental.** This API is part of an experimental wire-protocol surface
2420 /// and may change or be removed in future SDK or CLI releases. Pin both the
2421 /// SDK and CLI versions if your code depends on it.
2422 ///
2423 /// </div>
2424 pub async fn set_additional_plugins(
2425 &self,
2426 params: SessionsSetAdditionalPluginsRequest,
2427 ) -> Result<SessionsSetAdditionalPluginsResult, Error> {
2428 let wire_params = serde_json::to_value(params)?;
2429 let _value = self
2430 .client
2431 .call(
2432 rpc_methods::SESSIONS_SETADDITIONALPLUGINS,
2433 Some(wire_params),
2434 )
2435 .await?;
2436 Ok(serde_json::from_value(_value)?)
2437 }
2438
2439 /// Gets the dynamic-context board entry count associated with a session, when available. Internal: this exists solely so CLI telemetry events (`rem_spawn_gate`, `rem_consolidation_complete`) can pair START / END board counts around the detached rem-agent spawn. "Dynamic context board" is a runtime-internal concept that is not part of the public SDK contract; the long-term plan is to relocate the telemetry emission into the runtime so this method can be deleted entirely.
2440 ///
2441 /// Wire method: `sessions.getBoardEntryCount`.
2442 ///
2443 /// # Parameters
2444 ///
2445 /// * `params` - Session ID whose board entry count should be returned.
2446 ///
2447 /// # Returns
2448 ///
2449 /// Dynamic-context board entry count, when available.
2450 ///
2451 /// <div class="warning">
2452 ///
2453 /// **Experimental.** This API is part of an experimental wire-protocol surface
2454 /// and may change or be removed in future SDK or CLI releases. Pin both the
2455 /// SDK and CLI versions if your code depends on it.
2456 ///
2457 /// </div>
2458 pub(crate) async fn get_board_entry_count(
2459 &self,
2460 params: SessionsGetBoardEntryCountRequest,
2461 ) -> Result<SessionsGetBoardEntryCountResult, Error> {
2462 let wire_params = serde_json::to_value(params)?;
2463 let _value = self
2464 .client
2465 .call(rpc_methods::SESSIONS_GETBOARDENTRYCOUNT, Some(wire_params))
2466 .await?;
2467 Ok(serde_json::from_value(_value)?)
2468 }
2469
2470 /// Attaches the runtime-managed remote-control singleton to a session, awaiting initial setup. If remote control is already attached to a different session, the singleton is transferred (preserving the underlying Mission Control connection). Returns the final status.
2471 ///
2472 /// Wire method: `sessions.startRemoteControl`.
2473 ///
2474 /// # Parameters
2475 ///
2476 /// * `params` - Parameters for attaching the remote-control singleton to a session.
2477 ///
2478 /// # Returns
2479 ///
2480 /// Wrapper for the singleton's current status.
2481 ///
2482 /// <div class="warning">
2483 ///
2484 /// **Experimental.** This API is part of an experimental wire-protocol surface
2485 /// and may change or be removed in future SDK or CLI releases. Pin both the
2486 /// SDK and CLI versions if your code depends on it.
2487 ///
2488 /// </div>
2489 pub async fn start_remote_control(
2490 &self,
2491 params: SessionsStartRemoteControlRequest,
2492 ) -> Result<RemoteControlStatusResult, Error> {
2493 let wire_params = serde_json::to_value(params)?;
2494 let _value = self
2495 .client
2496 .call(rpc_methods::SESSIONS_STARTREMOTECONTROL, Some(wire_params))
2497 .await?;
2498 Ok(serde_json::from_value(_value)?)
2499 }
2500
2501 /// Atomically rebinds the remote-control singleton to a different session, preserving the underlying Mission Control connection. When `expectedFromSessionId` is provided and does not match the singleton's current `attachedSessionId`, the transfer is rejected with `transferred: false` and the current status is returned unchanged.
2502 ///
2503 /// Wire method: `sessions.transferRemoteControl`.
2504 ///
2505 /// # Parameters
2506 ///
2507 /// * `params` - Parameters for atomically rebinding the remote-control singleton.
2508 ///
2509 /// # Returns
2510 ///
2511 /// Outcome of a transferRemoteControl call.
2512 ///
2513 /// <div class="warning">
2514 ///
2515 /// **Experimental.** This API is part of an experimental wire-protocol surface
2516 /// and may change or be removed in future SDK or CLI releases. Pin both the
2517 /// SDK and CLI versions if your code depends on it.
2518 ///
2519 /// </div>
2520 pub async fn transfer_remote_control(
2521 &self,
2522 params: SessionsTransferRemoteControlRequest,
2523 ) -> Result<RemoteControlTransferResult, Error> {
2524 let wire_params = serde_json::to_value(params)?;
2525 let _value = self
2526 .client
2527 .call(
2528 rpc_methods::SESSIONS_TRANSFERREMOTECONTROL,
2529 Some(wire_params),
2530 )
2531 .await?;
2532 Ok(serde_json::from_value(_value)?)
2533 }
2534
2535 /// Patches the steering state of the active remote-control singleton. When remote control is off, this is a no-op and the off status is returned. Today only `enabled: true` is actionable on the underlying exporter; passing `false` is reserved for future use.
2536 ///
2537 /// Wire method: `sessions.setRemoteControlSteering`.
2538 ///
2539 /// # Parameters
2540 ///
2541 /// * `params` - Patch for the singleton's steering state.
2542 ///
2543 /// # Returns
2544 ///
2545 /// Wrapper for the singleton's current status.
2546 ///
2547 /// <div class="warning">
2548 ///
2549 /// **Experimental.** This API is part of an experimental wire-protocol surface
2550 /// and may change or be removed in future SDK or CLI releases. Pin both the
2551 /// SDK and CLI versions if your code depends on it.
2552 ///
2553 /// </div>
2554 pub async fn set_remote_control_steering(
2555 &self,
2556 params: SessionsSetRemoteControlSteeringRequest,
2557 ) -> Result<RemoteControlStatusResult, Error> {
2558 let wire_params = serde_json::to_value(params)?;
2559 let _value = self
2560 .client
2561 .call(
2562 rpc_methods::SESSIONS_SETREMOTECONTROLSTEERING,
2563 Some(wire_params),
2564 )
2565 .await?;
2566 Ok(serde_json::from_value(_value)?)
2567 }
2568
2569 /// Stops the remote-control singleton. When `expectedSessionId` is provided and does not match the singleton's current `attachedSessionId`, the stop is rejected with `stopped: false` and the current status is returned unchanged (unless `force` is set, in which case the singleton is unconditionally torn down).
2570 ///
2571 /// Wire method: `sessions.stopRemoteControl`.
2572 ///
2573 /// # Returns
2574 ///
2575 /// Outcome of a stopRemoteControl call.
2576 ///
2577 /// <div class="warning">
2578 ///
2579 /// **Experimental.** This API is part of an experimental wire-protocol surface
2580 /// and may change or be removed in future SDK or CLI releases. Pin both the
2581 /// SDK and CLI versions if your code depends on it.
2582 ///
2583 /// </div>
2584 pub async fn stop_remote_control(&self) -> Result<RemoteControlStopResult, Error> {
2585 let wire_params = serde_json::json!({});
2586 let _value = self
2587 .client
2588 .call(rpc_methods::SESSIONS_STOPREMOTECONTROL, Some(wire_params))
2589 .await?;
2590 Ok(serde_json::from_value(_value)?)
2591 }
2592
2593 /// Stops the remote-control singleton. When `expectedSessionId` is provided and does not match the singleton's current `attachedSessionId`, the stop is rejected with `stopped: false` and the current status is returned unchanged (unless `force` is set, in which case the singleton is unconditionally torn down).
2594 ///
2595 /// Wire method: `sessions.stopRemoteControl`.
2596 ///
2597 /// # Parameters
2598 ///
2599 /// * `params` - Parameters for stopping the remote-control singleton.
2600 ///
2601 /// # Returns
2602 ///
2603 /// Outcome of a stopRemoteControl call.
2604 ///
2605 /// <div class="warning">
2606 ///
2607 /// **Experimental.** This API is part of an experimental wire-protocol surface
2608 /// and may change or be removed in future SDK or CLI releases. Pin both the
2609 /// SDK and CLI versions if your code depends on it.
2610 ///
2611 /// </div>
2612 pub async fn stop_remote_control_with_params(
2613 &self,
2614 params: SessionsStopRemoteControlRequest,
2615 ) -> Result<RemoteControlStopResult, Error> {
2616 let wire_params = serde_json::to_value(params)?;
2617 let _value = self
2618 .client
2619 .call(rpc_methods::SESSIONS_STOPREMOTECONTROL, Some(wire_params))
2620 .await?;
2621 Ok(serde_json::from_value(_value)?)
2622 }
2623
2624 /// Returns the current state of the remote-control singleton, including the attached session id and frontend URL when active.
2625 ///
2626 /// Wire method: `sessions.getRemoteControlStatus`.
2627 ///
2628 /// # Returns
2629 ///
2630 /// Wrapper for the singleton's current status.
2631 ///
2632 /// <div class="warning">
2633 ///
2634 /// **Experimental.** This API is part of an experimental wire-protocol surface
2635 /// and may change or be removed in future SDK or CLI releases. Pin both the
2636 /// SDK and CLI versions if your code depends on it.
2637 ///
2638 /// </div>
2639 pub async fn get_remote_control_status(&self) -> Result<RemoteControlStatusResult, Error> {
2640 let wire_params = serde_json::json!({});
2641 let _value = self
2642 .client
2643 .call(
2644 rpc_methods::SESSIONS_GETREMOTECONTROLSTATUS,
2645 Some(wire_params),
2646 )
2647 .await?;
2648 Ok(serde_json::from_value(_value)?)
2649 }
2650
2651 /// Registers extension-provided tools on the given session, gated by an optional `enabled` callback. Returns an opaque unsubscribe function the caller must invoke to deregister the tools when the extension is torn down. Marked internal because `loader`, `enabled`, and the returned `unsubscribe` are in-process handles that cannot cross the JSON-RPC boundary. Disappears once extension discovery / launch / tool registration are owned by the runtime: SDK consumers will pass pure config (search paths, disabled ids) via `SessionOptions` and the runtime will resolve, launch, register, and tear down extensions itself.
2652 ///
2653 /// Wire method: `sessions.registerExtensionToolsOnSession`.
2654 ///
2655 /// # Parameters
2656 ///
2657 /// * `params` - Params to attach an extension loader's tools to a session.
2658 ///
2659 /// # Returns
2660 ///
2661 /// Handle for releasing the extension tool registration.
2662 ///
2663 /// <div class="warning">
2664 ///
2665 /// **Experimental.** This API is part of an experimental wire-protocol surface
2666 /// and may change or be removed in future SDK or CLI releases. Pin both the
2667 /// SDK and CLI versions if your code depends on it.
2668 ///
2669 /// </div>
2670 pub(crate) async fn register_extension_tools_on_session(
2671 &self,
2672 params: RegisterExtensionToolsParams,
2673 ) -> Result<RegisterExtensionToolsResult, Error> {
2674 let wire_params = serde_json::to_value(params)?;
2675 let _value = self
2676 .client
2677 .call(
2678 rpc_methods::SESSIONS_REGISTEREXTENSIONTOOLSONSESSION,
2679 Some(wire_params),
2680 )
2681 .await?;
2682 Ok(serde_json::from_value(_value)?)
2683 }
2684
2685 /// Attaches (or detaches) an in-process ExtensionController delegate for the given session, used by shared-API surfaces that need to query or modify the session's extension state. Pass `controller: undefined` to detach. Marked internal because the controller is an in-process object that cannot cross the JSON-RPC boundary. Disappears alongside `registerExtensionToolsOnSession`: once the runtime owns extension management, the public surface exposes list/enable/disable/reload as dedicated RPCs served by the runtime.
2686 ///
2687 /// Wire method: `sessions.configureSessionExtensions`.
2688 ///
2689 /// # Parameters
2690 ///
2691 /// * `params` - Params to attach or detach an in-process ExtensionController delegate.
2692 ///
2693 /// <div class="warning">
2694 ///
2695 /// **Experimental.** This API is part of an experimental wire-protocol surface
2696 /// and may change or be removed in future SDK or CLI releases. Pin both the
2697 /// SDK and CLI versions if your code depends on it.
2698 ///
2699 /// </div>
2700 pub(crate) async fn configure_session_extensions(
2701 &self,
2702 params: ConfigureSessionExtensionsParams,
2703 ) -> Result<(), Error> {
2704 let wire_params = serde_json::to_value(params)?;
2705 let _value = self
2706 .client
2707 .call(
2708 rpc_methods::SESSIONS_CONFIGURESESSIONEXTENSIONS,
2709 Some(wire_params),
2710 )
2711 .await?;
2712 Ok(())
2713 }
2714}
2715
2716/// `skills.*` RPCs.
2717#[derive(Clone, Copy)]
2718pub struct ClientRpcSkills<'a> {
2719 pub(crate) client: &'a Client,
2720}
2721
2722impl<'a> ClientRpcSkills<'a> {
2723 /// `skills.config.*` sub-namespace.
2724 pub fn config(&self) -> ClientRpcSkillsConfig<'a> {
2725 ClientRpcSkillsConfig {
2726 client: self.client,
2727 }
2728 }
2729
2730 /// Discovers skills across global and project sources.
2731 ///
2732 /// Wire method: `skills.discover`.
2733 ///
2734 /// # Parameters
2735 ///
2736 /// * `params` - Optional project paths and additional skill directories to include in discovery.
2737 ///
2738 /// # Returns
2739 ///
2740 /// Skills discovered across global and project sources.
2741 ///
2742 /// <div class="warning">
2743 ///
2744 /// **Experimental.** This API is part of an experimental wire-protocol surface
2745 /// and may change or be removed in future SDK or CLI releases. Pin both the
2746 /// SDK and CLI versions if your code depends on it.
2747 ///
2748 /// </div>
2749 pub async fn discover(&self, params: SkillsDiscoverRequest) -> Result<ServerSkillList, Error> {
2750 let wire_params = serde_json::to_value(params)?;
2751 let _value = self
2752 .client
2753 .call(rpc_methods::SKILLS_DISCOVER, Some(wire_params))
2754 .await?;
2755 Ok(serde_json::from_value(_value)?)
2756 }
2757
2758 /// Returns the canonical directories where a client may create skills that the runtime will recognize, including ones that do not exist yet. Project directories become active once created.
2759 ///
2760 /// Wire method: `skills.getDiscoveryPaths`.
2761 ///
2762 /// # Parameters
2763 ///
2764 /// * `params` - Optional project paths to enumerate.
2765 ///
2766 /// # Returns
2767 ///
2768 /// Canonical locations where skills can be created so the runtime will recognize them.
2769 ///
2770 /// <div class="warning">
2771 ///
2772 /// **Experimental.** This API is part of an experimental wire-protocol surface
2773 /// and may change or be removed in future SDK or CLI releases. Pin both the
2774 /// SDK and CLI versions if your code depends on it.
2775 ///
2776 /// </div>
2777 pub async fn get_discovery_paths(
2778 &self,
2779 params: SkillsGetDiscoveryPathsRequest,
2780 ) -> Result<SkillDiscoveryPathList, Error> {
2781 let wire_params = serde_json::to_value(params)?;
2782 let _value = self
2783 .client
2784 .call(rpc_methods::SKILLS_GETDISCOVERYPATHS, Some(wire_params))
2785 .await?;
2786 Ok(serde_json::from_value(_value)?)
2787 }
2788}
2789
2790/// `skills.config.*` RPCs.
2791#[derive(Clone, Copy)]
2792pub struct ClientRpcSkillsConfig<'a> {
2793 pub(crate) client: &'a Client,
2794}
2795
2796impl<'a> ClientRpcSkillsConfig<'a> {
2797 /// Replaces the global list of disabled skills.
2798 ///
2799 /// Wire method: `skills.config.setDisabledSkills`.
2800 ///
2801 /// # Parameters
2802 ///
2803 /// * `params` - Skill names to mark as disabled in global configuration, replacing any previous list.
2804 ///
2805 /// <div class="warning">
2806 ///
2807 /// **Experimental.** This API is part of an experimental wire-protocol surface
2808 /// and may change or be removed in future SDK or CLI releases. Pin both the
2809 /// SDK and CLI versions if your code depends on it.
2810 ///
2811 /// </div>
2812 pub async fn set_disabled_skills(
2813 &self,
2814 params: SkillsConfigSetDisabledSkillsRequest,
2815 ) -> Result<(), Error> {
2816 let wire_params = serde_json::to_value(params)?;
2817 let _value = self
2818 .client
2819 .call(
2820 rpc_methods::SKILLS_CONFIG_SETDISABLEDSKILLS,
2821 Some(wire_params),
2822 )
2823 .await?;
2824 Ok(())
2825 }
2826
2827 /// Atomically adds or removes one skill from the disabled list.
2828 ///
2829 /// Wire method: `skills.config.setSkillDisabled`.
2830 ///
2831 /// # Parameters
2832 ///
2833 /// * `params` - Adds or removes a single skill from the global disabled list, leaving every other entry untouched.
2834 ///
2835 /// <div class="warning">
2836 ///
2837 /// **Experimental.** This API is part of an experimental wire-protocol surface
2838 /// and may change or be removed in future SDK or CLI releases. Pin both the
2839 /// SDK and CLI versions if your code depends on it.
2840 ///
2841 /// </div>
2842 pub async fn set_skill_disabled(
2843 &self,
2844 params: SkillsConfigSetSkillDisabledRequest,
2845 ) -> Result<(), Error> {
2846 let wire_params = serde_json::to_value(params)?;
2847 let _value = self
2848 .client
2849 .call(
2850 rpc_methods::SKILLS_CONFIG_SETSKILLDISABLED,
2851 Some(wire_params),
2852 )
2853 .await?;
2854 Ok(())
2855 }
2856}
2857
2858/// `tools.*` RPCs.
2859#[derive(Clone, Copy)]
2860pub struct ClientRpcTools<'a> {
2861 pub(crate) client: &'a Client,
2862}
2863
2864impl<'a> ClientRpcTools<'a> {
2865 /// Lists built-in tools available for a model.
2866 ///
2867 /// Wire method: `tools.list`.
2868 ///
2869 /// # Parameters
2870 ///
2871 /// * `params` - Optional model identifier whose tool overrides should be applied to the listing.
2872 ///
2873 /// # Returns
2874 ///
2875 /// Built-in tools available for the requested model, with their parameters and instructions.
2876 ///
2877 /// <div class="warning">
2878 ///
2879 /// **Experimental.** This API is part of an experimental wire-protocol surface
2880 /// and may change or be removed in future SDK or CLI releases. Pin both the
2881 /// SDK and CLI versions if your code depends on it.
2882 ///
2883 /// </div>
2884 pub async fn list(&self, params: ToolsListRequest) -> Result<ToolList, Error> {
2885 let wire_params = serde_json::to_value(params)?;
2886 let _value = self
2887 .client
2888 .call(rpc_methods::TOOLS_LIST, Some(wire_params))
2889 .await?;
2890 Ok(serde_json::from_value(_value)?)
2891 }
2892}
2893
2894/// `user.*` RPCs.
2895#[derive(Clone, Copy)]
2896pub struct ClientRpcUser<'a> {
2897 pub(crate) client: &'a Client,
2898}
2899
2900impl<'a> ClientRpcUser<'a> {
2901 /// `user.settings.*` sub-namespace.
2902 pub fn settings(&self) -> ClientRpcUserSettings<'a> {
2903 ClientRpcUserSettings {
2904 client: self.client,
2905 }
2906 }
2907}
2908
2909/// `user.settings.*` RPCs.
2910#[derive(Clone, Copy)]
2911pub struct ClientRpcUserSettings<'a> {
2912 pub(crate) client: &'a Client,
2913}
2914
2915impl<'a> ClientRpcUserSettings<'a> {
2916 /// Drops this runtime process's in-memory user settings cache so the next settings read observes disk.
2917 ///
2918 /// Wire method: `user.settings.reload`.
2919 ///
2920 /// <div class="warning">
2921 ///
2922 /// **Experimental.** This API is part of an experimental wire-protocol surface
2923 /// and may change or be removed in future SDK or CLI releases. Pin both the
2924 /// SDK and CLI versions if your code depends on it.
2925 ///
2926 /// </div>
2927 pub async fn reload(&self) -> Result<(), Error> {
2928 let wire_params = serde_json::json!({});
2929 let _value = self
2930 .client
2931 .call(rpc_methods::USER_SETTINGS_RELOAD, Some(wire_params))
2932 .await?;
2933 Ok(())
2934 }
2935
2936 /// Lists every known user setting (settings.json overlaid with the legacy config.json, config.json wins), each with its effective value, its default, and whether it is at the default — so settings the user has never set still appear with their default value. Does not include repository- or enterprise-managed overrides that the runtime layers on top at session time.
2937 ///
2938 /// Wire method: `user.settings.get`.
2939 ///
2940 /// # Returns
2941 ///
2942 /// Per-key metadata for every known user setting (settings.json overlaid with the legacy config.json, config.json wins), including settings left at their default. Excludes repository- and enterprise-managed overrides.
2943 ///
2944 /// <div class="warning">
2945 ///
2946 /// **Experimental.** This API is part of an experimental wire-protocol surface
2947 /// and may change or be removed in future SDK or CLI releases. Pin both the
2948 /// SDK and CLI versions if your code depends on it.
2949 ///
2950 /// </div>
2951 pub async fn get(&self) -> Result<UserSettingsGetResult, Error> {
2952 let wire_params = serde_json::json!({});
2953 let _value = self
2954 .client
2955 .call(rpc_methods::USER_SETTINGS_GET, Some(wire_params))
2956 .await?;
2957 Ok(serde_json::from_value(_value)?)
2958 }
2959
2960 /// Writes one or more user settings to settings.json, replacing each provided top-level key. A key whose value is null is removed. Returns the keys whose new value is shadowed by a legacy config.json entry (config.json wins on read), which the runtime leaves in place — such writes do not take effect until the legacy value is removed.
2961 ///
2962 /// Wire method: `user.settings.set`.
2963 ///
2964 /// # Parameters
2965 ///
2966 /// * `params` - Partial user settings to write to settings.json. Each top-level key is written individually, replacing the existing value; a key whose value is null is removed.
2967 ///
2968 /// # Returns
2969 ///
2970 /// Outcome of writing user settings.
2971 ///
2972 /// <div class="warning">
2973 ///
2974 /// **Experimental.** This API is part of an experimental wire-protocol surface
2975 /// and may change or be removed in future SDK or CLI releases. Pin both the
2976 /// SDK and CLI versions if your code depends on it.
2977 ///
2978 /// </div>
2979 pub async fn set(
2980 &self,
2981 params: UserSettingsSetRequest,
2982 ) -> Result<UserSettingsSetResult, Error> {
2983 let wire_params = serde_json::to_value(params)?;
2984 let _value = self
2985 .client
2986 .call(rpc_methods::USER_SETTINGS_SET, Some(wire_params))
2987 .await?;
2988 Ok(serde_json::from_value(_value)?)
2989 }
2990}
2991
2992/// Typed view over a [`Session`]'s RPC namespace.
2993#[derive(Clone, Copy)]
2994pub struct SessionRpc<'a> {
2995 pub(crate) session: &'a Session,
2996}
2997
2998impl<'a> SessionRpc<'a> {
2999 /// `session.agent.*` sub-namespace.
3000 pub fn agent(&self) -> SessionRpcAgent<'a> {
3001 SessionRpcAgent {
3002 session: self.session,
3003 }
3004 }
3005
3006 /// `session.canvas.*` sub-namespace.
3007 pub fn canvas(&self) -> SessionRpcCanvas<'a> {
3008 SessionRpcCanvas {
3009 session: self.session,
3010 }
3011 }
3012
3013 /// `session.commands.*` sub-namespace.
3014 pub fn commands(&self) -> SessionRpcCommands<'a> {
3015 SessionRpcCommands {
3016 session: self.session,
3017 }
3018 }
3019
3020 /// `session.completions.*` sub-namespace.
3021 pub fn completions(&self) -> SessionRpcCompletions<'a> {
3022 SessionRpcCompletions {
3023 session: self.session,
3024 }
3025 }
3026
3027 /// `session.contentExclusion.*` sub-namespace.
3028 pub fn content_exclusion(&self) -> SessionRpcContentExclusion<'a> {
3029 SessionRpcContentExclusion {
3030 session: self.session,
3031 }
3032 }
3033
3034 /// `session.debug.*` sub-namespace.
3035 pub fn debug(&self) -> SessionRpcDebug<'a> {
3036 SessionRpcDebug {
3037 session: self.session,
3038 }
3039 }
3040
3041 /// `session.eventLog.*` sub-namespace.
3042 pub fn event_log(&self) -> SessionRpcEventLog<'a> {
3043 SessionRpcEventLog {
3044 session: self.session,
3045 }
3046 }
3047
3048 /// `session.extensions.*` sub-namespace.
3049 pub fn extensions(&self) -> SessionRpcExtensions<'a> {
3050 SessionRpcExtensions {
3051 session: self.session,
3052 }
3053 }
3054
3055 /// `session.factory.*` sub-namespace.
3056 pub fn factory(&self) -> SessionRpcFactory<'a> {
3057 SessionRpcFactory {
3058 session: self.session,
3059 }
3060 }
3061
3062 /// `session.fleet.*` sub-namespace.
3063 pub fn fleet(&self) -> SessionRpcFleet<'a> {
3064 SessionRpcFleet {
3065 session: self.session,
3066 }
3067 }
3068
3069 /// `session.gitHubAuth.*` sub-namespace.
3070 pub fn git_hub_auth(&self) -> SessionRpcGitHubAuth<'a> {
3071 SessionRpcGitHubAuth {
3072 session: self.session,
3073 }
3074 }
3075
3076 /// `session.history.*` sub-namespace.
3077 pub fn history(&self) -> SessionRpcHistory<'a> {
3078 SessionRpcHistory {
3079 session: self.session,
3080 }
3081 }
3082
3083 /// `session.instructions.*` sub-namespace.
3084 pub fn instructions(&self) -> SessionRpcInstructions<'a> {
3085 SessionRpcInstructions {
3086 session: self.session,
3087 }
3088 }
3089
3090 /// `session.limitPrediction.*` sub-namespace.
3091 pub fn limit_prediction(&self) -> SessionRpcLimitPrediction<'a> {
3092 SessionRpcLimitPrediction {
3093 session: self.session,
3094 }
3095 }
3096
3097 /// `session.lsp.*` sub-namespace.
3098 pub fn lsp(&self) -> SessionRpcLsp<'a> {
3099 SessionRpcLsp {
3100 session: self.session,
3101 }
3102 }
3103
3104 /// `session.mcp.*` sub-namespace.
3105 pub fn mcp(&self) -> SessionRpcMcp<'a> {
3106 SessionRpcMcp {
3107 session: self.session,
3108 }
3109 }
3110
3111 /// `session.metadata.*` sub-namespace.
3112 pub fn metadata(&self) -> SessionRpcMetadata<'a> {
3113 SessionRpcMetadata {
3114 session: self.session,
3115 }
3116 }
3117
3118 /// `session.mode.*` sub-namespace.
3119 pub fn mode(&self) -> SessionRpcMode<'a> {
3120 SessionRpcMode {
3121 session: self.session,
3122 }
3123 }
3124
3125 /// `session.model.*` sub-namespace.
3126 pub fn model(&self) -> SessionRpcModel<'a> {
3127 SessionRpcModel {
3128 session: self.session,
3129 }
3130 }
3131
3132 /// `session.name.*` sub-namespace.
3133 pub fn name(&self) -> SessionRpcName<'a> {
3134 SessionRpcName {
3135 session: self.session,
3136 }
3137 }
3138
3139 /// `session.options.*` sub-namespace.
3140 pub fn options(&self) -> SessionRpcOptions<'a> {
3141 SessionRpcOptions {
3142 session: self.session,
3143 }
3144 }
3145
3146 /// `session.permissions.*` sub-namespace.
3147 pub fn permissions(&self) -> SessionRpcPermissions<'a> {
3148 SessionRpcPermissions {
3149 session: self.session,
3150 }
3151 }
3152
3153 /// `session.plan.*` sub-namespace.
3154 pub fn plan(&self) -> SessionRpcPlan<'a> {
3155 SessionRpcPlan {
3156 session: self.session,
3157 }
3158 }
3159
3160 /// `session.plugins.*` sub-namespace.
3161 pub fn plugins(&self) -> SessionRpcPlugins<'a> {
3162 SessionRpcPlugins {
3163 session: self.session,
3164 }
3165 }
3166
3167 /// `session.provider.*` sub-namespace.
3168 pub fn provider(&self) -> SessionRpcProvider<'a> {
3169 SessionRpcProvider {
3170 session: self.session,
3171 }
3172 }
3173
3174 /// `session.queue.*` sub-namespace.
3175 pub fn queue(&self) -> SessionRpcQueue<'a> {
3176 SessionRpcQueue {
3177 session: self.session,
3178 }
3179 }
3180
3181 /// `session.remote.*` sub-namespace.
3182 pub fn remote(&self) -> SessionRpcRemote<'a> {
3183 SessionRpcRemote {
3184 session: self.session,
3185 }
3186 }
3187
3188 /// `session.schedule.*` sub-namespace.
3189 pub fn schedule(&self) -> SessionRpcSchedule<'a> {
3190 SessionRpcSchedule {
3191 session: self.session,
3192 }
3193 }
3194
3195 /// `session.settings.*` sub-namespace.
3196 pub fn settings(&self) -> SessionRpcSettings<'a> {
3197 SessionRpcSettings {
3198 session: self.session,
3199 }
3200 }
3201
3202 /// `session.shell.*` sub-namespace.
3203 pub fn shell(&self) -> SessionRpcShell<'a> {
3204 SessionRpcShell {
3205 session: self.session,
3206 }
3207 }
3208
3209 /// `session.skills.*` sub-namespace.
3210 pub fn skills(&self) -> SessionRpcSkills<'a> {
3211 SessionRpcSkills {
3212 session: self.session,
3213 }
3214 }
3215
3216 /// `session.tasks.*` sub-namespace.
3217 pub fn tasks(&self) -> SessionRpcTasks<'a> {
3218 SessionRpcTasks {
3219 session: self.session,
3220 }
3221 }
3222
3223 /// `session.telemetry.*` sub-namespace.
3224 pub fn telemetry(&self) -> SessionRpcTelemetry<'a> {
3225 SessionRpcTelemetry {
3226 session: self.session,
3227 }
3228 }
3229
3230 /// `session.tools.*` sub-namespace.
3231 pub fn tools(&self) -> SessionRpcTools<'a> {
3232 SessionRpcTools {
3233 session: self.session,
3234 }
3235 }
3236
3237 /// `session.ui.*` sub-namespace.
3238 pub fn ui(&self) -> SessionRpcUi<'a> {
3239 SessionRpcUi {
3240 session: self.session,
3241 }
3242 }
3243
3244 /// `session.usage.*` sub-namespace.
3245 pub fn usage(&self) -> SessionRpcUsage<'a> {
3246 SessionRpcUsage {
3247 session: self.session,
3248 }
3249 }
3250
3251 /// `session.visibility.*` sub-namespace.
3252 pub fn visibility(&self) -> SessionRpcVisibility<'a> {
3253 SessionRpcVisibility {
3254 session: self.session,
3255 }
3256 }
3257
3258 /// `session.workspaces.*` sub-namespace.
3259 pub fn workspaces(&self) -> SessionRpcWorkspaces<'a> {
3260 SessionRpcWorkspaces {
3261 session: self.session,
3262 }
3263 }
3264
3265 /// Suspends the session while preserving persisted state for later resume.
3266 ///
3267 /// Wire method: `session.suspend`.
3268 ///
3269 /// <div class="warning">
3270 ///
3271 /// **Experimental.** This API is part of an experimental wire-protocol surface
3272 /// and may change or be removed in future SDK or CLI releases. Pin both the
3273 /// SDK and CLI versions if your code depends on it.
3274 ///
3275 /// </div>
3276 pub async fn suspend(&self) -> Result<(), Error> {
3277 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3278 let _value = self
3279 .session
3280 .client()
3281 .call(rpc_methods::SESSION_SUSPEND, Some(wire_params))
3282 .await?;
3283 Ok(())
3284 }
3285
3286 /// Sends a user message to the session and returns its message ID.
3287 ///
3288 /// Wire method: `session.send`.
3289 ///
3290 /// # Parameters
3291 ///
3292 /// * `params` - Parameters for sending a user message to the session
3293 ///
3294 /// # Returns
3295 ///
3296 /// Result of sending a user message
3297 ///
3298 /// <div class="warning">
3299 ///
3300 /// **Experimental.** This API is part of an experimental wire-protocol surface
3301 /// and may change or be removed in future SDK or CLI releases. Pin both the
3302 /// SDK and CLI versions if your code depends on it.
3303 ///
3304 /// </div>
3305 pub async fn send(&self, params: SendRequest) -> Result<SendResult, Error> {
3306 let mut wire_params = serde_json::to_value(params)?;
3307 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3308 let _value = self
3309 .session
3310 .client()
3311 .call(rpc_methods::SESSION_SEND, Some(wire_params))
3312 .await?;
3313 Ok(serde_json::from_value(_value)?)
3314 }
3315
3316 /// 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.
3317 ///
3318 /// Wire method: `session.sendMessages`.
3319 ///
3320 /// # Parameters
3321 ///
3322 /// * `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.
3323 ///
3324 /// # Returns
3325 ///
3326 /// Result of sending zero or more user messages
3327 ///
3328 /// <div class="warning">
3329 ///
3330 /// **Experimental.** This API is part of an experimental wire-protocol surface
3331 /// and may change or be removed in future SDK or CLI releases. Pin both the
3332 /// SDK and CLI versions if your code depends on it.
3333 ///
3334 /// </div>
3335 pub async fn send_messages(
3336 &self,
3337 params: SendMessagesRequest,
3338 ) -> Result<SendMessagesResult, Error> {
3339 let mut wire_params = serde_json::to_value(params)?;
3340 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3341 let _value = self
3342 .session
3343 .client()
3344 .call(rpc_methods::SESSION_SENDMESSAGES, Some(wire_params))
3345 .await?;
3346 Ok(serde_json::from_value(_value)?)
3347 }
3348
3349 /// Queues or sends an internal system notification to the session according to its passive policy.
3350 ///
3351 /// Wire method: `session.sendSystemNotification`.
3352 ///
3353 /// # Parameters
3354 ///
3355 /// * `params` - Internal request for sending a system notification.
3356 ///
3357 /// <div class="warning">
3358 ///
3359 /// **Experimental.** This API is part of an experimental wire-protocol surface
3360 /// and may change or be removed in future SDK or CLI releases. Pin both the
3361 /// SDK and CLI versions if your code depends on it.
3362 ///
3363 /// </div>
3364 pub(crate) async fn send_system_notification(
3365 &self,
3366 params: SendSystemNotificationRequest,
3367 ) -> Result<(), Error> {
3368 let mut wire_params = serde_json::to_value(params)?;
3369 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3370 let _value = self
3371 .session
3372 .client()
3373 .call(
3374 rpc_methods::SESSION_SENDSYSTEMNOTIFICATION,
3375 Some(wire_params),
3376 )
3377 .await?;
3378 Ok(())
3379 }
3380
3381 /// Aborts the current agent turn.
3382 ///
3383 /// Wire method: `session.abort`.
3384 ///
3385 /// # Parameters
3386 ///
3387 /// * `params` - Parameters for aborting the current turn
3388 ///
3389 /// # Returns
3390 ///
3391 /// Result of aborting the current turn
3392 ///
3393 /// <div class="warning">
3394 ///
3395 /// **Experimental.** This API is part of an experimental wire-protocol surface
3396 /// and may change or be removed in future SDK or CLI releases. Pin both the
3397 /// SDK and CLI versions if your code depends on it.
3398 ///
3399 /// </div>
3400 pub async fn abort(&self, params: AbortRequest) -> Result<AbortResult, Error> {
3401 let mut wire_params = serde_json::to_value(params)?;
3402 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3403 let _value = self
3404 .session
3405 .client()
3406 .call(rpc_methods::SESSION_ABORT, Some(wire_params))
3407 .await?;
3408 Ok(serde_json::from_value(_value)?)
3409 }
3410
3411 /// 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.
3412 ///
3413 /// Wire method: `session.interruptMainTurn`.
3414 ///
3415 /// # Parameters
3416 ///
3417 /// * `params` - Parameters for interrupting the main agent turn.
3418 ///
3419 /// # Returns
3420 ///
3421 /// Result of interrupting the main agent turn.
3422 ///
3423 /// <div class="warning">
3424 ///
3425 /// **Experimental.** This API is part of an experimental wire-protocol surface
3426 /// and may change or be removed in future SDK or CLI releases. Pin both the
3427 /// SDK and CLI versions if your code depends on it.
3428 ///
3429 /// </div>
3430 pub async fn interrupt_main_turn(
3431 &self,
3432 params: InterruptMainTurnRequest,
3433 ) -> Result<InterruptMainTurnResult, Error> {
3434 let mut wire_params = serde_json::to_value(params)?;
3435 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3436 let _value = self
3437 .session
3438 .client()
3439 .call(rpc_methods::SESSION_INTERRUPTMAINTURN, Some(wire_params))
3440 .await?;
3441 Ok(serde_json::from_value(_value)?)
3442 }
3443
3444 /// Cancels every running background agent (task-registry subagents plus sidekick agents) without interrupting the main agent loop. Promoted attached shells are left running.
3445 ///
3446 /// Wire method: `session.cancelAllBackgroundAgents`.
3447 ///
3448 /// # Returns
3449 ///
3450 /// The number of running background agents (task-registry agents) that were cancelled.
3451 ///
3452 /// <div class="warning">
3453 ///
3454 /// **Experimental.** This API is part of an experimental wire-protocol surface
3455 /// and may change or be removed in future SDK or CLI releases. Pin both the
3456 /// SDK and CLI versions if your code depends on it.
3457 ///
3458 /// </div>
3459 pub async fn cancel_all_background_agents(
3460 &self,
3461 ) -> Result<SessionCancelAllBackgroundAgentsResult, Error> {
3462 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3463 let _value = self
3464 .session
3465 .client()
3466 .call(
3467 rpc_methods::SESSION_CANCELALLBACKGROUNDAGENTS,
3468 Some(wire_params),
3469 )
3470 .await?;
3471 Ok(serde_json::from_value(_value)?)
3472 }
3473
3474 /// 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.
3475 ///
3476 /// Wire method: `session.shutdown`.
3477 ///
3478 /// # Parameters
3479 ///
3480 /// * `params` - Parameters for shutting down the session
3481 ///
3482 /// <div class="warning">
3483 ///
3484 /// **Experimental.** This API is part of an experimental wire-protocol surface
3485 /// and may change or be removed in future SDK or CLI releases. Pin both the
3486 /// SDK and CLI versions if your code depends on it.
3487 ///
3488 /// </div>
3489 pub async fn shutdown(&self, params: ShutdownRequest) -> Result<(), Error> {
3490 let mut wire_params = serde_json::to_value(params)?;
3491 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3492 let _value = self
3493 .session
3494 .client()
3495 .call(rpc_methods::SESSION_SHUTDOWN, Some(wire_params))
3496 .await?;
3497 Ok(())
3498 }
3499
3500 /// Emits a user-visible session log event.
3501 ///
3502 /// Wire method: `session.log`.
3503 ///
3504 /// # Parameters
3505 ///
3506 /// * `params` - Message text, optional severity level, persistence flag, optional follow-up URL, and optional tip.
3507 ///
3508 /// # Returns
3509 ///
3510 /// Identifier of the session event that was emitted for the log message.
3511 ///
3512 /// <div class="warning">
3513 ///
3514 /// **Experimental.** This API is part of an experimental wire-protocol surface
3515 /// and may change or be removed in future SDK or CLI releases. Pin both the
3516 /// SDK and CLI versions if your code depends on it.
3517 ///
3518 /// </div>
3519 pub async fn log(&self, params: LogRequest) -> Result<LogResult, Error> {
3520 let mut wire_params = serde_json::to_value(params)?;
3521 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3522 let _value = self
3523 .session
3524 .client()
3525 .call(rpc_methods::SESSION_LOG, Some(wire_params))
3526 .await?;
3527 Ok(serde_json::from_value(_value)?)
3528 }
3529}
3530
3531/// `session.agent.*` RPCs.
3532#[derive(Clone, Copy)]
3533pub struct SessionRpcAgent<'a> {
3534 pub(crate) session: &'a Session,
3535}
3536
3537impl<'a> SessionRpcAgent<'a> {
3538 /// Lists agents available to the session. Defaults to custom agents only; pass includeBuiltInAgents to include the effective built-in agents.
3539 ///
3540 /// Wire method: `session.agent.list`.
3541 ///
3542 /// # Returns
3543 ///
3544 /// Agents available to the session.
3545 ///
3546 /// <div class="warning">
3547 ///
3548 /// **Experimental.** This API is part of an experimental wire-protocol surface
3549 /// and may change or be removed in future SDK or CLI releases. Pin both the
3550 /// SDK and CLI versions if your code depends on it.
3551 ///
3552 /// </div>
3553 pub async fn list(&self) -> Result<AgentList, Error> {
3554 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3555 let _value = self
3556 .session
3557 .client()
3558 .call(rpc_methods::SESSION_AGENT_LIST, Some(wire_params))
3559 .await?;
3560 Ok(serde_json::from_value(_value)?)
3561 }
3562
3563 /// Lists agents available to the session. Defaults to custom agents only; pass includeBuiltInAgents to include the effective built-in agents.
3564 ///
3565 /// Wire method: `session.agent.list`.
3566 ///
3567 /// # Parameters
3568 ///
3569 /// * `params` - Controls whether built-in agents and authored prompt text are included.
3570 ///
3571 /// # Returns
3572 ///
3573 /// Agents available to the session.
3574 ///
3575 /// <div class="warning">
3576 ///
3577 /// **Experimental.** This API is part of an experimental wire-protocol surface
3578 /// and may change or be removed in future SDK or CLI releases. Pin both the
3579 /// SDK and CLI versions if your code depends on it.
3580 ///
3581 /// </div>
3582 pub async fn list_with_params(&self, params: AgentListRequest) -> Result<AgentList, Error> {
3583 let mut wire_params = serde_json::to_value(params)?;
3584 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3585 let _value = self
3586 .session
3587 .client()
3588 .call(rpc_methods::SESSION_AGENT_LIST, Some(wire_params))
3589 .await?;
3590 Ok(serde_json::from_value(_value)?)
3591 }
3592
3593 /// 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.
3594 ///
3595 /// Wire method: `session.agent.setPrompt`.
3596 ///
3597 /// # Parameters
3598 ///
3599 /// * `params` - An in-memory authored prompt override for an available agent.
3600 ///
3601 /// <div class="warning">
3602 ///
3603 /// **Experimental.** This API is part of an experimental wire-protocol surface
3604 /// and may change or be removed in future SDK or CLI releases. Pin both the
3605 /// SDK and CLI versions if your code depends on it.
3606 ///
3607 /// </div>
3608 pub async fn set_prompt(&self, params: AgentSetPromptRequest) -> Result<(), Error> {
3609 let mut wire_params = serde_json::to_value(params)?;
3610 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3611 let _value = self
3612 .session
3613 .client()
3614 .call(rpc_methods::SESSION_AGENT_SETPROMPT, Some(wire_params))
3615 .await?;
3616 Ok(())
3617 }
3618
3619 /// Gets the currently selected custom agent for the session.
3620 ///
3621 /// Wire method: `session.agent.getCurrent`.
3622 ///
3623 /// # Returns
3624 ///
3625 /// The currently selected custom agent, or null when using the default agent.
3626 ///
3627 /// <div class="warning">
3628 ///
3629 /// **Experimental.** This API is part of an experimental wire-protocol surface
3630 /// and may change or be removed in future SDK or CLI releases. Pin both the
3631 /// SDK and CLI versions if your code depends on it.
3632 ///
3633 /// </div>
3634 pub async fn get_current(&self) -> Result<AgentGetCurrentResult, Error> {
3635 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3636 let _value = self
3637 .session
3638 .client()
3639 .call(rpc_methods::SESSION_AGENT_GETCURRENT, Some(wire_params))
3640 .await?;
3641 Ok(serde_json::from_value(_value)?)
3642 }
3643
3644 /// Selects a custom agent for subsequent turns in the session.
3645 ///
3646 /// Wire method: `session.agent.select`.
3647 ///
3648 /// # Parameters
3649 ///
3650 /// * `params` - Name of the custom agent to select for subsequent turns.
3651 ///
3652 /// # Returns
3653 ///
3654 /// The newly selected custom agent.
3655 ///
3656 /// <div class="warning">
3657 ///
3658 /// **Experimental.** This API is part of an experimental wire-protocol surface
3659 /// and may change or be removed in future SDK or CLI releases. Pin both the
3660 /// SDK and CLI versions if your code depends on it.
3661 ///
3662 /// </div>
3663 pub async fn select(&self, params: AgentSelectRequest) -> Result<AgentSelectResult, Error> {
3664 let mut wire_params = serde_json::to_value(params)?;
3665 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3666 let _value = self
3667 .session
3668 .client()
3669 .call(rpc_methods::SESSION_AGENT_SELECT, Some(wire_params))
3670 .await?;
3671 Ok(serde_json::from_value(_value)?)
3672 }
3673
3674 /// Clears the selected custom agent and returns the session to the default agent.
3675 ///
3676 /// Wire method: `session.agent.deselect`.
3677 ///
3678 /// <div class="warning">
3679 ///
3680 /// **Experimental.** This API is part of an experimental wire-protocol surface
3681 /// and may change or be removed in future SDK or CLI releases. Pin both the
3682 /// SDK and CLI versions if your code depends on it.
3683 ///
3684 /// </div>
3685 pub async fn deselect(&self) -> Result<(), Error> {
3686 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3687 let _value = self
3688 .session
3689 .client()
3690 .call(rpc_methods::SESSION_AGENT_DESELECT, Some(wire_params))
3691 .await?;
3692 Ok(())
3693 }
3694
3695 /// Reloads custom agent definitions and returns the refreshed list.
3696 ///
3697 /// Wire method: `session.agent.reload`.
3698 ///
3699 /// # Returns
3700 ///
3701 /// Custom agents available to the session after reloading definitions from disk.
3702 ///
3703 /// <div class="warning">
3704 ///
3705 /// **Experimental.** This API is part of an experimental wire-protocol surface
3706 /// and may change or be removed in future SDK or CLI releases. Pin both the
3707 /// SDK and CLI versions if your code depends on it.
3708 ///
3709 /// </div>
3710 pub async fn reload(&self) -> Result<AgentReloadResult, Error> {
3711 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3712 let _value = self
3713 .session
3714 .client()
3715 .call(rpc_methods::SESSION_AGENT_RELOAD, Some(wire_params))
3716 .await?;
3717 Ok(serde_json::from_value(_value)?)
3718 }
3719}
3720
3721/// `session.canvas.*` RPCs.
3722#[derive(Clone, Copy)]
3723pub struct SessionRpcCanvas<'a> {
3724 pub(crate) session: &'a Session,
3725}
3726
3727impl<'a> SessionRpcCanvas<'a> {
3728 /// `session.canvas.action.*` sub-namespace.
3729 pub fn action(&self) -> SessionRpcCanvasAction<'a> {
3730 SessionRpcCanvasAction {
3731 session: self.session,
3732 }
3733 }
3734
3735 /// `session.canvas.provider.*` sub-namespace.
3736 pub fn provider(&self) -> SessionRpcCanvasProvider<'a> {
3737 SessionRpcCanvasProvider {
3738 session: self.session,
3739 }
3740 }
3741
3742 /// Lists canvases declared for the session.
3743 ///
3744 /// Wire method: `session.canvas.list`.
3745 ///
3746 /// # Returns
3747 ///
3748 /// Declared canvases available in this session.
3749 ///
3750 /// <div class="warning">
3751 ///
3752 /// **Experimental.** This API is part of an experimental wire-protocol surface
3753 /// and may change or be removed in future SDK or CLI releases. Pin both the
3754 /// SDK and CLI versions if your code depends on it.
3755 ///
3756 /// </div>
3757 pub async fn list(&self) -> Result<CanvasList, Error> {
3758 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3759 let _value = self
3760 .session
3761 .client()
3762 .call(rpc_methods::SESSION_CANVAS_LIST, Some(wire_params))
3763 .await?;
3764 Ok(serde_json::from_value(_value)?)
3765 }
3766
3767 /// Lists currently open canvas instances for the live session.
3768 ///
3769 /// Wire method: `session.canvas.listOpen`.
3770 ///
3771 /// # Returns
3772 ///
3773 /// Live open-canvas snapshot.
3774 ///
3775 /// <div class="warning">
3776 ///
3777 /// **Experimental.** This API is part of an experimental wire-protocol surface
3778 /// and may change or be removed in future SDK or CLI releases. Pin both the
3779 /// SDK and CLI versions if your code depends on it.
3780 ///
3781 /// </div>
3782 pub async fn list_open(&self) -> Result<CanvasListOpenResult, Error> {
3783 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3784 let _value = self
3785 .session
3786 .client()
3787 .call(rpc_methods::SESSION_CANVAS_LISTOPEN, Some(wire_params))
3788 .await?;
3789 Ok(serde_json::from_value(_value)?)
3790 }
3791
3792 /// Opens or focuses a canvas instance.
3793 ///
3794 /// Wire method: `session.canvas.open`.
3795 ///
3796 /// # Parameters
3797 ///
3798 /// * `params` - Canvas open parameters.
3799 ///
3800 /// # Returns
3801 ///
3802 /// Open canvas instance snapshot.
3803 ///
3804 /// <div class="warning">
3805 ///
3806 /// **Experimental.** This API is part of an experimental wire-protocol surface
3807 /// and may change or be removed in future SDK or CLI releases. Pin both the
3808 /// SDK and CLI versions if your code depends on it.
3809 ///
3810 /// </div>
3811 pub async fn open(&self, params: CanvasOpenRequest) -> Result<OpenCanvasInstance, Error> {
3812 let mut wire_params = serde_json::to_value(params)?;
3813 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3814 let _value = self
3815 .session
3816 .client()
3817 .call(rpc_methods::SESSION_CANVAS_OPEN, Some(wire_params))
3818 .await?;
3819 Ok(serde_json::from_value(_value)?)
3820 }
3821
3822 /// Closes an open canvas instance.
3823 ///
3824 /// Wire method: `session.canvas.close`.
3825 ///
3826 /// # Parameters
3827 ///
3828 /// * `params` - Canvas close parameters.
3829 ///
3830 /// <div class="warning">
3831 ///
3832 /// **Experimental.** This API is part of an experimental wire-protocol surface
3833 /// and may change or be removed in future SDK or CLI releases. Pin both the
3834 /// SDK and CLI versions if your code depends on it.
3835 ///
3836 /// </div>
3837 pub async fn close(&self, params: CanvasCloseRequest) -> Result<(), Error> {
3838 let mut wire_params = serde_json::to_value(params)?;
3839 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3840 let _value = self
3841 .session
3842 .client()
3843 .call(rpc_methods::SESSION_CANVAS_CLOSE, Some(wire_params))
3844 .await?;
3845 Ok(())
3846 }
3847}
3848
3849/// `session.canvas.action.*` RPCs.
3850#[derive(Clone, Copy)]
3851pub struct SessionRpcCanvasAction<'a> {
3852 pub(crate) session: &'a Session,
3853}
3854
3855impl<'a> SessionRpcCanvasAction<'a> {
3856 /// Invokes an action on an open canvas instance.
3857 ///
3858 /// Wire method: `session.canvas.action.invoke`.
3859 ///
3860 /// # Parameters
3861 ///
3862 /// * `params` - Canvas action invocation parameters.
3863 ///
3864 /// # Returns
3865 ///
3866 /// Canvas action invocation result.
3867 ///
3868 /// <div class="warning">
3869 ///
3870 /// **Experimental.** This API is part of an experimental wire-protocol surface
3871 /// and may change or be removed in future SDK or CLI releases. Pin both the
3872 /// SDK and CLI versions if your code depends on it.
3873 ///
3874 /// </div>
3875 pub async fn invoke(
3876 &self,
3877 params: CanvasActionInvokeRequest,
3878 ) -> Result<CanvasActionInvokeResult, Error> {
3879 let mut wire_params = serde_json::to_value(params)?;
3880 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3881 let _value = self
3882 .session
3883 .client()
3884 .call(rpc_methods::SESSION_CANVAS_ACTION_INVOKE, Some(wire_params))
3885 .await?;
3886 Ok(serde_json::from_value(_value)?)
3887 }
3888}
3889
3890/// `session.canvas.provider.*` RPCs.
3891#[derive(Clone, Copy)]
3892pub struct SessionRpcCanvasProvider<'a> {
3893 pub(crate) session: &'a Session,
3894}
3895
3896impl<'a> SessionRpcCanvasProvider<'a> {
3897 /// Registers an internal canvas provider connection and its contributions.
3898 ///
3899 /// Wire method: `session.canvas.provider.register`.
3900 ///
3901 /// # Parameters
3902 ///
3903 /// * `params` - Internal canvas provider registration parameters.
3904 ///
3905 /// <div class="warning">
3906 ///
3907 /// **Experimental.** This API is part of an experimental wire-protocol surface
3908 /// and may change or be removed in future SDK or CLI releases. Pin both the
3909 /// SDK and CLI versions if your code depends on it.
3910 ///
3911 /// </div>
3912 pub(crate) async fn register(
3913 &self,
3914 params: CanvasProviderRegisterRequest,
3915 ) -> Result<(), Error> {
3916 let mut wire_params = serde_json::to_value(params)?;
3917 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3918 let _value = self
3919 .session
3920 .client()
3921 .call(
3922 rpc_methods::SESSION_CANVAS_PROVIDER_REGISTER,
3923 Some(wire_params),
3924 )
3925 .await?;
3926 Ok(())
3927 }
3928
3929 /// Unregisters an internal canvas provider connection.
3930 ///
3931 /// Wire method: `session.canvas.provider.unregister`.
3932 ///
3933 /// # Parameters
3934 ///
3935 /// * `params` - Internal canvas provider unregistration parameters.
3936 ///
3937 /// <div class="warning">
3938 ///
3939 /// **Experimental.** This API is part of an experimental wire-protocol surface
3940 /// and may change or be removed in future SDK or CLI releases. Pin both the
3941 /// SDK and CLI versions if your code depends on it.
3942 ///
3943 /// </div>
3944 pub(crate) async fn unregister(
3945 &self,
3946 params: CanvasProviderUnregisterRequest,
3947 ) -> Result<(), Error> {
3948 let mut wire_params = serde_json::to_value(params)?;
3949 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3950 let _value = self
3951 .session
3952 .client()
3953 .call(
3954 rpc_methods::SESSION_CANVAS_PROVIDER_UNREGISTER,
3955 Some(wire_params),
3956 )
3957 .await?;
3958 Ok(())
3959 }
3960}
3961
3962/// `session.commands.*` RPCs.
3963#[derive(Clone, Copy)]
3964pub struct SessionRpcCommands<'a> {
3965 pub(crate) session: &'a Session,
3966}
3967
3968impl<'a> SessionRpcCommands<'a> {
3969 /// Lists slash commands available in the session.
3970 ///
3971 /// Wire method: `session.commands.list`.
3972 ///
3973 /// # Returns
3974 ///
3975 /// Slash commands available in the session, after applying any include/exclude filters.
3976 ///
3977 /// <div class="warning">
3978 ///
3979 /// **Experimental.** This API is part of an experimental wire-protocol surface
3980 /// and may change or be removed in future SDK or CLI releases. Pin both the
3981 /// SDK and CLI versions if your code depends on it.
3982 ///
3983 /// </div>
3984 pub async fn list(&self) -> Result<CommandList, Error> {
3985 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3986 let _value = self
3987 .session
3988 .client()
3989 .call(rpc_methods::SESSION_COMMANDS_LIST, Some(wire_params))
3990 .await?;
3991 Ok(serde_json::from_value(_value)?)
3992 }
3993
3994 /// Lists slash commands available in the session.
3995 ///
3996 /// Wire method: `session.commands.list`.
3997 ///
3998 /// # Parameters
3999 ///
4000 /// * `params` - Optional filters controlling which command sources to include in the listing.
4001 ///
4002 /// # Returns
4003 ///
4004 /// Slash commands available in the session, after applying any include/exclude filters.
4005 ///
4006 /// <div class="warning">
4007 ///
4008 /// **Experimental.** This API is part of an experimental wire-protocol surface
4009 /// and may change or be removed in future SDK or CLI releases. Pin both the
4010 /// SDK and CLI versions if your code depends on it.
4011 ///
4012 /// </div>
4013 pub async fn list_with_params(
4014 &self,
4015 params: CommandsListRequest,
4016 ) -> Result<CommandList, Error> {
4017 let mut wire_params = serde_json::to_value(params)?;
4018 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4019 let _value = self
4020 .session
4021 .client()
4022 .call(rpc_methods::SESSION_COMMANDS_LIST, Some(wire_params))
4023 .await?;
4024 Ok(serde_json::from_value(_value)?)
4025 }
4026
4027 /// Invokes a slash command in the session.
4028 ///
4029 /// Wire method: `session.commands.invoke`.
4030 ///
4031 /// # Parameters
4032 ///
4033 /// * `params` - Slash command name and optional raw input string to invoke.
4034 ///
4035 /// # Returns
4036 ///
4037 /// Result of invoking the slash command (text output, prompt to send to the agent, completion, or subcommand selection).
4038 ///
4039 /// <div class="warning">
4040 ///
4041 /// **Experimental.** This API is part of an experimental wire-protocol surface
4042 /// and may change or be removed in future SDK or CLI releases. Pin both the
4043 /// SDK and CLI versions if your code depends on it.
4044 ///
4045 /// </div>
4046 pub async fn invoke(
4047 &self,
4048 params: CommandsInvokeRequest,
4049 ) -> Result<SlashCommandInvocationResult, Error> {
4050 let mut wire_params = serde_json::to_value(params)?;
4051 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4052 let _value = self
4053 .session
4054 .client()
4055 .call(rpc_methods::SESSION_COMMANDS_INVOKE, Some(wire_params))
4056 .await?;
4057 Ok(serde_json::from_value(_value)?)
4058 }
4059
4060 /// Finalizes persistence associated with a client-applied slash-command effect.
4061 ///
4062 /// Wire method: `session.commands.finalizeInvocationEffect`.
4063 ///
4064 /// # Parameters
4065 ///
4066 /// * `params` - The pending slash-command invocation effect to finalize, plus whether the host applied or cancelled it.
4067 ///
4068 /// # Returns
4069 ///
4070 /// Whether finalizing the invocation effect succeeded, and the failure reason when it did not.
4071 ///
4072 /// <div class="warning">
4073 ///
4074 /// **Experimental.** This API is part of an experimental wire-protocol surface
4075 /// and may change or be removed in future SDK or CLI releases. Pin both the
4076 /// SDK and CLI versions if your code depends on it.
4077 ///
4078 /// </div>
4079 pub(crate) async fn finalize_invocation_effect(
4080 &self,
4081 params: CommandsFinalizeInvocationEffectRequest,
4082 ) -> Result<CommandsFinalizeInvocationEffectResult, Error> {
4083 let mut wire_params = serde_json::to_value(params)?;
4084 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4085 let _value = self
4086 .session
4087 .client()
4088 .call(
4089 rpc_methods::SESSION_COMMANDS_FINALIZEINVOCATIONEFFECT,
4090 Some(wire_params),
4091 )
4092 .await?;
4093 Ok(serde_json::from_value(_value)?)
4094 }
4095
4096 /// Reports completion of a pending client-handled slash command.
4097 ///
4098 /// Wire method: `session.commands.handlePendingCommand`.
4099 ///
4100 /// # Parameters
4101 ///
4102 /// * `params` - Pending command request ID and an optional error if the client handler failed.
4103 ///
4104 /// # Returns
4105 ///
4106 /// Indicates whether the pending client-handled command was completed successfully.
4107 ///
4108 /// <div class="warning">
4109 ///
4110 /// **Experimental.** This API is part of an experimental wire-protocol surface
4111 /// and may change or be removed in future SDK or CLI releases. Pin both the
4112 /// SDK and CLI versions if your code depends on it.
4113 ///
4114 /// </div>
4115 pub async fn handle_pending_command(
4116 &self,
4117 params: CommandsHandlePendingCommandRequest,
4118 ) -> Result<CommandsHandlePendingCommandResult, Error> {
4119 let mut wire_params = serde_json::to_value(params)?;
4120 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4121 let _value = self
4122 .session
4123 .client()
4124 .call(
4125 rpc_methods::SESSION_COMMANDS_HANDLEPENDINGCOMMAND,
4126 Some(wire_params),
4127 )
4128 .await?;
4129 Ok(serde_json::from_value(_value)?)
4130 }
4131
4132 /// Executes a slash command synchronously and returns any error.
4133 ///
4134 /// Wire method: `session.commands.execute`.
4135 ///
4136 /// # Parameters
4137 ///
4138 /// * `params` - Slash command name and argument string to execute synchronously.
4139 ///
4140 /// # Returns
4141 ///
4142 /// Error message produced while executing the command, if any.
4143 ///
4144 /// <div class="warning">
4145 ///
4146 /// **Experimental.** This API is part of an experimental wire-protocol surface
4147 /// and may change or be removed in future SDK or CLI releases. Pin both the
4148 /// SDK and CLI versions if your code depends on it.
4149 ///
4150 /// </div>
4151 pub async fn execute(
4152 &self,
4153 params: ExecuteCommandParams,
4154 ) -> Result<ExecuteCommandResult, Error> {
4155 let mut wire_params = serde_json::to_value(params)?;
4156 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4157 let _value = self
4158 .session
4159 .client()
4160 .call(rpc_methods::SESSION_COMMANDS_EXECUTE, Some(wire_params))
4161 .await?;
4162 Ok(serde_json::from_value(_value)?)
4163 }
4164
4165 /// Enqueues a slash command for FIFO processing on the local session.
4166 ///
4167 /// Wire method: `session.commands.enqueue`.
4168 ///
4169 /// # Parameters
4170 ///
4171 /// * `params` - Slash-prefixed command string to enqueue for FIFO processing.
4172 ///
4173 /// # Returns
4174 ///
4175 /// Indicates whether the command was accepted into the local execution queue.
4176 ///
4177 /// <div class="warning">
4178 ///
4179 /// **Experimental.** This API is part of an experimental wire-protocol surface
4180 /// and may change or be removed in future SDK or CLI releases. Pin both the
4181 /// SDK and CLI versions if your code depends on it.
4182 ///
4183 /// </div>
4184 pub async fn enqueue(
4185 &self,
4186 params: EnqueueCommandParams,
4187 ) -> Result<EnqueueCommandResult, Error> {
4188 let mut wire_params = serde_json::to_value(params)?;
4189 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4190 let _value = self
4191 .session
4192 .client()
4193 .call(rpc_methods::SESSION_COMMANDS_ENQUEUE, Some(wire_params))
4194 .await?;
4195 Ok(serde_json::from_value(_value)?)
4196 }
4197
4198 /// Reports whether the host actually executed a queued command and whether to continue processing.
4199 ///
4200 /// Wire method: `session.commands.respondToQueuedCommand`.
4201 ///
4202 /// # Parameters
4203 ///
4204 /// * `params` - Queued-command request ID and the result indicating whether the host executed it (and whether to stop processing further queued commands).
4205 ///
4206 /// # Returns
4207 ///
4208 /// Indicates whether the queued-command response was matched to a pending request.
4209 ///
4210 /// <div class="warning">
4211 ///
4212 /// **Experimental.** This API is part of an experimental wire-protocol surface
4213 /// and may change or be removed in future SDK or CLI releases. Pin both the
4214 /// SDK and CLI versions if your code depends on it.
4215 ///
4216 /// </div>
4217 pub async fn respond_to_queued_command(
4218 &self,
4219 params: CommandsRespondToQueuedCommandRequest,
4220 ) -> Result<CommandsRespondToQueuedCommandResult, Error> {
4221 let mut wire_params = serde_json::to_value(params)?;
4222 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4223 let _value = self
4224 .session
4225 .client()
4226 .call(
4227 rpc_methods::SESSION_COMMANDS_RESPONDTOQUEUEDCOMMAND,
4228 Some(wire_params),
4229 )
4230 .await?;
4231 Ok(serde_json::from_value(_value)?)
4232 }
4233}
4234
4235/// `session.completions.*` RPCs.
4236#[derive(Clone, Copy)]
4237pub struct SessionRpcCompletions<'a> {
4238 pub(crate) session: &'a Session,
4239}
4240
4241impl<'a> SessionRpcCompletions<'a> {
4242 /// 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).
4243 ///
4244 /// Wire method: `session.completions.getTriggerCharacters`.
4245 ///
4246 /// # Returns
4247 ///
4248 /// 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`).
4249 ///
4250 /// <div class="warning">
4251 ///
4252 /// **Experimental.** This API is part of an experimental wire-protocol surface
4253 /// and may change or be removed in future SDK or CLI releases. Pin both the
4254 /// SDK and CLI versions if your code depends on it.
4255 ///
4256 /// </div>
4257 pub async fn get_trigger_characters(
4258 &self,
4259 ) -> Result<CompletionsGetTriggerCharactersResult, Error> {
4260 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
4261 let _value = self
4262 .session
4263 .client()
4264 .call(
4265 rpc_methods::SESSION_COMPLETIONS_GETTRIGGERCHARACTERS,
4266 Some(wire_params),
4267 )
4268 .await?;
4269 Ok(serde_json::from_value(_value)?)
4270 }
4271
4272 /// 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.
4273 ///
4274 /// Wire method: `session.completions.request`.
4275 ///
4276 /// # Parameters
4277 ///
4278 /// * `params` - Request host-driven completions for the current composer input.
4279 ///
4280 /// # Returns
4281 ///
4282 /// Host-driven completion items for the current composer input. Empty when the host returns no items or does not support completions.
4283 ///
4284 /// <div class="warning">
4285 ///
4286 /// **Experimental.** This API is part of an experimental wire-protocol surface
4287 /// and may change or be removed in future SDK or CLI releases. Pin both the
4288 /// SDK and CLI versions if your code depends on it.
4289 ///
4290 /// </div>
4291 pub async fn request(
4292 &self,
4293 params: CompletionsRequestRequest,
4294 ) -> Result<CompletionsRequestResult, Error> {
4295 let mut wire_params = serde_json::to_value(params)?;
4296 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4297 let _value = self
4298 .session
4299 .client()
4300 .call(rpc_methods::SESSION_COMPLETIONS_REQUEST, Some(wire_params))
4301 .await?;
4302 Ok(serde_json::from_value(_value)?)
4303 }
4304}
4305
4306/// `session.contentExclusion.*` RPCs.
4307#[derive(Clone, Copy)]
4308pub struct SessionRpcContentExclusion<'a> {
4309 pub(crate) session: &'a Session,
4310}
4311
4312impl<'a> SessionRpcContentExclusion<'a> {
4313 /// 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.
4314 ///
4315 /// Wire method: `session.contentExclusion.checkPaths`.
4316 ///
4317 /// # Parameters
4318 ///
4319 /// * `params` - Local file system absolute paths within the session working directory to check against its content-exclusion policy.
4320 ///
4321 /// # Returns
4322 ///
4323 /// Batch content-exclusion result. Callers must fail closed when policy evaluation is unavailable.
4324 ///
4325 /// <div class="warning">
4326 ///
4327 /// **Experimental.** This API is part of an experimental wire-protocol surface
4328 /// and may change or be removed in future SDK or CLI releases. Pin both the
4329 /// SDK and CLI versions if your code depends on it.
4330 ///
4331 /// </div>
4332 pub async fn check_paths(
4333 &self,
4334 params: ContentExclusionCheckPathsRequest,
4335 ) -> Result<ContentExclusionCheckPathsResult, Error> {
4336 let mut wire_params = serde_json::to_value(params)?;
4337 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4338 let _value = self
4339 .session
4340 .client()
4341 .call(
4342 rpc_methods::SESSION_CONTENTEXCLUSION_CHECKPATHS,
4343 Some(wire_params),
4344 )
4345 .await?;
4346 Ok(serde_json::from_value(_value)?)
4347 }
4348}
4349
4350/// `session.debug.*` RPCs.
4351#[derive(Clone, Copy)]
4352pub struct SessionRpcDebug<'a> {
4353 pub(crate) session: &'a Session,
4354}
4355
4356impl<'a> SessionRpcDebug<'a> {
4357 /// Collects a redacted session debug log bundle into a local archive or staging directory. The runtime includes session-owned logs by default and accepts caller-provided diagnostic entries so host applications can add their own files without changing this API shape.
4358 ///
4359 /// Wire method: `session.debug.collectLogs`.
4360 ///
4361 /// # Parameters
4362 ///
4363 /// * `params` - Options for collecting a redacted session debug bundle.
4364 ///
4365 /// # Returns
4366 ///
4367 /// Result of collecting a redacted debug bundle.
4368 ///
4369 /// <div class="warning">
4370 ///
4371 /// **Experimental.** This API is part of an experimental wire-protocol surface
4372 /// and may change or be removed in future SDK or CLI releases. Pin both the
4373 /// SDK and CLI versions if your code depends on it.
4374 ///
4375 /// </div>
4376 pub async fn collect_logs(
4377 &self,
4378 params: DebugCollectLogsRequest,
4379 ) -> Result<DebugCollectLogsResult, Error> {
4380 let mut wire_params = serde_json::to_value(params)?;
4381 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4382 let _value = self
4383 .session
4384 .client()
4385 .call(rpc_methods::SESSION_DEBUG_COLLECTLOGS, Some(wire_params))
4386 .await?;
4387 Ok(serde_json::from_value(_value)?)
4388 }
4389}
4390
4391/// `session.eventLog.*` RPCs.
4392#[derive(Clone, Copy)]
4393pub struct SessionRpcEventLog<'a> {
4394 pub(crate) session: &'a Session,
4395}
4396
4397impl<'a> SessionRpcEventLog<'a> {
4398 /// Reads a batch of session events from a cursor, optionally waiting for new events. Supports tail-first reads via `direction: backward`.
4399 ///
4400 /// Wire method: `session.eventLog.read`.
4401 ///
4402 /// # Parameters
4403 ///
4404 /// * `params` - Cursor, batch size, and optional long-poll/filter parameters for reading session events.
4405 ///
4406 /// # Returns
4407 ///
4408 /// Batch of session events returned by a read, with cursor and continuation metadata.
4409 ///
4410 /// <div class="warning">
4411 ///
4412 /// **Experimental.** This API is part of an experimental wire-protocol surface
4413 /// and may change or be removed in future SDK or CLI releases. Pin both the
4414 /// SDK and CLI versions if your code depends on it.
4415 ///
4416 /// </div>
4417 pub async fn read(&self, params: EventLogReadRequest) -> Result<EventsReadResult, Error> {
4418 let mut wire_params = serde_json::to_value(params)?;
4419 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4420 let _value = self
4421 .session
4422 .client()
4423 .call(rpc_methods::SESSION_EVENTLOG_READ, Some(wire_params))
4424 .await?;
4425 Ok(serde_json::from_value(_value)?)
4426 }
4427
4428 /// Returns a snapshot of the current tail cursor without consuming events.
4429 ///
4430 /// Wire method: `session.eventLog.tail`.
4431 ///
4432 /// # Returns
4433 ///
4434 /// 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).
4435 ///
4436 /// <div class="warning">
4437 ///
4438 /// **Experimental.** This API is part of an experimental wire-protocol surface
4439 /// and may change or be removed in future SDK or CLI releases. Pin both the
4440 /// SDK and CLI versions if your code depends on it.
4441 ///
4442 /// </div>
4443 pub async fn tail(&self) -> Result<EventLogTailResult, Error> {
4444 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
4445 let _value = self
4446 .session
4447 .client()
4448 .call(rpc_methods::SESSION_EVENTLOG_TAIL, Some(wire_params))
4449 .await?;
4450 Ok(serde_json::from_value(_value)?)
4451 }
4452
4453 /// Registers consumer interest in an event type for runtime gating purposes.
4454 ///
4455 /// Wire method: `session.eventLog.registerInterest`.
4456 ///
4457 /// # Parameters
4458 ///
4459 /// * `params` - Event type to register consumer interest for, used by runtime gating logic.
4460 ///
4461 /// # Returns
4462 ///
4463 /// Opaque handle representing an event-type interest registration.
4464 ///
4465 /// <div class="warning">
4466 ///
4467 /// **Experimental.** This API is part of an experimental wire-protocol surface
4468 /// and may change or be removed in future SDK or CLI releases. Pin both the
4469 /// SDK and CLI versions if your code depends on it.
4470 ///
4471 /// </div>
4472 pub async fn register_interest(
4473 &self,
4474 params: RegisterEventInterestParams,
4475 ) -> Result<RegisterEventInterestResult, Error> {
4476 let mut wire_params = serde_json::to_value(params)?;
4477 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4478 let _value = self
4479 .session
4480 .client()
4481 .call(
4482 rpc_methods::SESSION_EVENTLOG_REGISTERINTEREST,
4483 Some(wire_params),
4484 )
4485 .await?;
4486 Ok(serde_json::from_value(_value)?)
4487 }
4488
4489 /// Releases a consumer's previously-registered interest in an event type.
4490 ///
4491 /// Wire method: `session.eventLog.releaseInterest`.
4492 ///
4493 /// # Parameters
4494 ///
4495 /// * `params` - Opaque handle previously returned by `registerInterest` to release.
4496 ///
4497 /// # Returns
4498 ///
4499 /// Indicates whether the operation succeeded.
4500 ///
4501 /// <div class="warning">
4502 ///
4503 /// **Experimental.** This API is part of an experimental wire-protocol surface
4504 /// and may change or be removed in future SDK or CLI releases. Pin both the
4505 /// SDK and CLI versions if your code depends on it.
4506 ///
4507 /// </div>
4508 pub async fn release_interest(
4509 &self,
4510 params: ReleaseEventInterestParams,
4511 ) -> Result<EventLogReleaseInterestResult, Error> {
4512 let mut wire_params = serde_json::to_value(params)?;
4513 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4514 let _value = self
4515 .session
4516 .client()
4517 .call(
4518 rpc_methods::SESSION_EVENTLOG_RELEASEINTEREST,
4519 Some(wire_params),
4520 )
4521 .await?;
4522 Ok(serde_json::from_value(_value)?)
4523 }
4524}
4525
4526/// `session.extensions.*` RPCs.
4527#[derive(Clone, Copy)]
4528pub struct SessionRpcExtensions<'a> {
4529 pub(crate) session: &'a Session,
4530}
4531
4532impl<'a> SessionRpcExtensions<'a> {
4533 /// Lists extensions discovered for the session and their current status.
4534 ///
4535 /// Wire method: `session.extensions.list`.
4536 ///
4537 /// # Returns
4538 ///
4539 /// Extensions discovered for the session, with their current status.
4540 ///
4541 /// <div class="warning">
4542 ///
4543 /// **Experimental.** This API is part of an experimental wire-protocol surface
4544 /// and may change or be removed in future SDK or CLI releases. Pin both the
4545 /// SDK and CLI versions if your code depends on it.
4546 ///
4547 /// </div>
4548 pub async fn list(&self) -> Result<ExtensionList, Error> {
4549 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
4550 let _value = self
4551 .session
4552 .client()
4553 .call(rpc_methods::SESSION_EXTENSIONS_LIST, Some(wire_params))
4554 .await?;
4555 Ok(serde_json::from_value(_value)?)
4556 }
4557
4558 /// Enables an extension for the session.
4559 ///
4560 /// Wire method: `session.extensions.enable`.
4561 ///
4562 /// # Parameters
4563 ///
4564 /// * `params` - Source-qualified extension identifier to enable for the session.
4565 ///
4566 /// <div class="warning">
4567 ///
4568 /// **Experimental.** This API is part of an experimental wire-protocol surface
4569 /// and may change or be removed in future SDK or CLI releases. Pin both the
4570 /// SDK and CLI versions if your code depends on it.
4571 ///
4572 /// </div>
4573 pub async fn enable(&self, params: ExtensionsEnableRequest) -> Result<(), Error> {
4574 let mut wire_params = serde_json::to_value(params)?;
4575 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4576 let _value = self
4577 .session
4578 .client()
4579 .call(rpc_methods::SESSION_EXTENSIONS_ENABLE, Some(wire_params))
4580 .await?;
4581 Ok(())
4582 }
4583
4584 /// Disables an extension for the session.
4585 ///
4586 /// Wire method: `session.extensions.disable`.
4587 ///
4588 /// # Parameters
4589 ///
4590 /// * `params` - Source-qualified extension identifier to disable for the session.
4591 ///
4592 /// <div class="warning">
4593 ///
4594 /// **Experimental.** This API is part of an experimental wire-protocol surface
4595 /// and may change or be removed in future SDK or CLI releases. Pin both the
4596 /// SDK and CLI versions if your code depends on it.
4597 ///
4598 /// </div>
4599 pub async fn disable(&self, params: ExtensionsDisableRequest) -> Result<(), Error> {
4600 let mut wire_params = serde_json::to_value(params)?;
4601 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4602 let _value = self
4603 .session
4604 .client()
4605 .call(rpc_methods::SESSION_EXTENSIONS_DISABLE, Some(wire_params))
4606 .await?;
4607 Ok(())
4608 }
4609
4610 /// Reloads extension definitions and processes for the session.
4611 ///
4612 /// Wire method: `session.extensions.reload`.
4613 ///
4614 /// <div class="warning">
4615 ///
4616 /// **Experimental.** This API is part of an experimental wire-protocol surface
4617 /// and may change or be removed in future SDK or CLI releases. Pin both the
4618 /// SDK and CLI versions if your code depends on it.
4619 ///
4620 /// </div>
4621 pub async fn reload(&self) -> Result<(), Error> {
4622 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
4623 let _value = self
4624 .session
4625 .client()
4626 .call(rpc_methods::SESSION_EXTENSIONS_RELOAD, Some(wire_params))
4627 .await?;
4628 Ok(())
4629 }
4630
4631 /// 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.
4632 ///
4633 /// Wire method: `session.extensions.sendAttachmentsToMessage`.
4634 ///
4635 /// # Parameters
4636 ///
4637 /// * `params` - Parameters for session.extensions.sendAttachmentsToMessage.
4638 ///
4639 /// <div class="warning">
4640 ///
4641 /// **Experimental.** This API is part of an experimental wire-protocol surface
4642 /// and may change or be removed in future SDK or CLI releases. Pin both the
4643 /// SDK and CLI versions if your code depends on it.
4644 ///
4645 /// </div>
4646 pub async fn send_attachments_to_message(
4647 &self,
4648 params: SendAttachmentsToMessageParams,
4649 ) -> Result<(), Error> {
4650 let mut wire_params = serde_json::to_value(params)?;
4651 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4652 let _value = self
4653 .session
4654 .client()
4655 .call(
4656 rpc_methods::SESSION_EXTENSIONS_SENDATTACHMENTSTOMESSAGE,
4657 Some(wire_params),
4658 )
4659 .await?;
4660 Ok(())
4661 }
4662}
4663
4664/// `session.factory.*` RPCs.
4665#[derive(Clone, Copy)]
4666pub struct SessionRpcFactory<'a> {
4667 pub(crate) session: &'a Session,
4668}
4669
4670impl<'a> SessionRpcFactory<'a> {
4671 /// `session.factory.journal.*` sub-namespace.
4672 pub fn journal(&self) -> SessionRpcFactoryJournal<'a> {
4673 SessionRpcFactoryJournal {
4674 session: self.session,
4675 }
4676 }
4677
4678 /// Runs a registered factory by name at the top level.
4679 ///
4680 /// Wire method: `session.factory.run`.
4681 ///
4682 /// # Parameters
4683 ///
4684 /// * `params` - Parameters for invoking a registered factory.
4685 ///
4686 /// # Returns
4687 ///
4688 /// Complete current or terminal factory run envelope.
4689 ///
4690 /// <div class="warning">
4691 ///
4692 /// **Experimental.** This API is part of an experimental wire-protocol surface
4693 /// and may change or be removed in future SDK or CLI releases. Pin both the
4694 /// SDK and CLI versions if your code depends on it.
4695 ///
4696 /// </div>
4697 pub async fn run(&self, params: FactoryRunRequest) -> Result<FactoryRunResult, Error> {
4698 let mut wire_params = serde_json::to_value(params)?;
4699 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4700 let _value = self
4701 .session
4702 .client()
4703 .call(rpc_methods::SESSION_FACTORY_RUN, Some(wire_params))
4704 .await?;
4705 Ok(serde_json::from_value(_value)?)
4706 }
4707
4708 /// Resumes a factory run using its persisted name, arguments, journal, and accounting.
4709 ///
4710 /// Wire method: `session.factory.resume`.
4711 ///
4712 /// # Parameters
4713 ///
4714 /// * `params` - Parameters for resuming a factory run from its persisted identity.
4715 ///
4716 /// # Returns
4717 ///
4718 /// Resolved persisted factory identity and resumed run envelope.
4719 ///
4720 /// <div class="warning">
4721 ///
4722 /// **Experimental.** This API is part of an experimental wire-protocol surface
4723 /// and may change or be removed in future SDK or CLI releases. Pin both the
4724 /// SDK and CLI versions if your code depends on it.
4725 ///
4726 /// </div>
4727 pub async fn resume(&self, params: FactoryResumeRequest) -> Result<FactoryResumeResult, Error> {
4728 let mut wire_params = serde_json::to_value(params)?;
4729 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4730 let _value = self
4731 .session
4732 .client()
4733 .call(rpc_methods::SESSION_FACTORY_RESUME, Some(wire_params))
4734 .await?;
4735 Ok(serde_json::from_value(_value)?)
4736 }
4737
4738 /// Gets the current or settled envelope for a factory run.
4739 ///
4740 /// Wire method: `session.factory.getRun`.
4741 ///
4742 /// # Parameters
4743 ///
4744 /// * `params` - Parameters for retrieving a factory run.
4745 ///
4746 /// # Returns
4747 ///
4748 /// Complete current or terminal factory run envelope.
4749 ///
4750 /// <div class="warning">
4751 ///
4752 /// **Experimental.** This API is part of an experimental wire-protocol surface
4753 /// and may change or be removed in future SDK or CLI releases. Pin both the
4754 /// SDK and CLI versions if your code depends on it.
4755 ///
4756 /// </div>
4757 pub async fn get_run(&self, params: FactoryGetRunRequest) -> Result<FactoryRunResult, Error> {
4758 let mut wire_params = serde_json::to_value(params)?;
4759 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4760 let _value = self
4761 .session
4762 .client()
4763 .call(rpc_methods::SESSION_FACTORY_GETRUN, Some(wire_params))
4764 .await?;
4765 Ok(serde_json::from_value(_value)?)
4766 }
4767
4768 /// Lists durable factory runs for this session in creation order.
4769 ///
4770 /// Wire method: `session.factory.listRuns`.
4771 ///
4772 /// # Parameters
4773 ///
4774 /// * `params` - Parameters for paging factory runs.
4775 ///
4776 /// # Returns
4777 ///
4778 /// A page of factory runs in durable creation order.
4779 ///
4780 /// <div class="warning">
4781 ///
4782 /// **Experimental.** This API is part of an experimental wire-protocol surface
4783 /// and may change or be removed in future SDK or CLI releases. Pin both the
4784 /// SDK and CLI versions if your code depends on it.
4785 ///
4786 /// </div>
4787 pub async fn list_runs(
4788 &self,
4789 params: FactoryListRunsRequest,
4790 ) -> Result<FactoryListRunsResult, Error> {
4791 let mut wire_params = serde_json::to_value(params)?;
4792 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4793 let _value = self
4794 .session
4795 .client()
4796 .call(rpc_methods::SESSION_FACTORY_LISTRUNS, Some(wire_params))
4797 .await?;
4798 Ok(serde_json::from_value(_value)?)
4799 }
4800
4801 /// Gets durable and live observability detail for one factory run.
4802 ///
4803 /// Wire method: `session.factory.getRunDetail`.
4804 ///
4805 /// # Parameters
4806 ///
4807 /// * `params` - Parameters for retrieving a factory run.
4808 ///
4809 /// # Returns
4810 ///
4811 /// Full factory run observability detail.
4812 ///
4813 /// <div class="warning">
4814 ///
4815 /// **Experimental.** This API is part of an experimental wire-protocol surface
4816 /// and may change or be removed in future SDK or CLI releases. Pin both the
4817 /// SDK and CLI versions if your code depends on it.
4818 ///
4819 /// </div>
4820 pub async fn get_run_detail(
4821 &self,
4822 params: FactoryGetRunRequest,
4823 ) -> Result<FactoryRunDetail, Error> {
4824 let mut wire_params = serde_json::to_value(params)?;
4825 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4826 let _value = self
4827 .session
4828 .client()
4829 .call(rpc_methods::SESSION_FACTORY_GETRUNDETAIL, Some(wire_params))
4830 .await?;
4831 Ok(serde_json::from_value(_value)?)
4832 }
4833
4834 /// Pages durable progress for one factory run.
4835 ///
4836 /// Wire method: `session.factory.getRunProgress`.
4837 ///
4838 /// # Parameters
4839 ///
4840 /// * `params` - Parameters for paging factory progress.
4841 ///
4842 /// # Returns
4843 ///
4844 /// A bidirectional page of factory progress.
4845 ///
4846 /// <div class="warning">
4847 ///
4848 /// **Experimental.** This API is part of an experimental wire-protocol surface
4849 /// and may change or be removed in future SDK or CLI releases. Pin both the
4850 /// SDK and CLI versions if your code depends on it.
4851 ///
4852 /// </div>
4853 pub async fn get_run_progress(
4854 &self,
4855 params: FactoryGetRunProgressRequest,
4856 ) -> Result<FactoryProgressPage, Error> {
4857 let mut wire_params = serde_json::to_value(params)?;
4858 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4859 let _value = self
4860 .session
4861 .client()
4862 .call(
4863 rpc_methods::SESSION_FACTORY_GETRUNPROGRESS,
4864 Some(wire_params),
4865 )
4866 .await?;
4867 Ok(serde_json::from_value(_value)?)
4868 }
4869
4870 /// Requests cancellation of a factory run and returns its run envelope.
4871 ///
4872 /// Wire method: `session.factory.cancel`.
4873 ///
4874 /// # Parameters
4875 ///
4876 /// * `params` - Parameters for cancelling a factory run.
4877 ///
4878 /// # Returns
4879 ///
4880 /// Complete current or terminal factory run envelope.
4881 ///
4882 /// <div class="warning">
4883 ///
4884 /// **Experimental.** This API is part of an experimental wire-protocol surface
4885 /// and may change or be removed in future SDK or CLI releases. Pin both the
4886 /// SDK and CLI versions if your code depends on it.
4887 ///
4888 /// </div>
4889 pub async fn cancel(&self, params: FactoryCancelRequest) -> Result<FactoryRunResult, Error> {
4890 let mut wire_params = serde_json::to_value(params)?;
4891 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4892 let _value = self
4893 .session
4894 .client()
4895 .call(rpc_methods::SESSION_FACTORY_CANCEL, Some(wire_params))
4896 .await?;
4897 Ok(serde_json::from_value(_value)?)
4898 }
4899
4900 /// Records a batch of ordered factory progress lines.
4901 ///
4902 /// Wire method: `session.factory.log`.
4903 ///
4904 /// # Parameters
4905 ///
4906 /// * `params` - Parameters for recording factory progress.
4907 ///
4908 /// # Returns
4909 ///
4910 /// Acknowledgement that a factory request was accepted.
4911 ///
4912 /// <div class="warning">
4913 ///
4914 /// **Experimental.** This API is part of an experimental wire-protocol surface
4915 /// and may change or be removed in future SDK or CLI releases. Pin both the
4916 /// SDK and CLI versions if your code depends on it.
4917 ///
4918 /// </div>
4919 pub async fn log(&self, params: FactoryLogRequest) -> Result<FactoryAckResult, Error> {
4920 let mut wire_params = serde_json::to_value(params)?;
4921 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4922 let _value = self
4923 .session
4924 .client()
4925 .call(rpc_methods::SESSION_FACTORY_LOG, Some(wire_params))
4926 .await?;
4927 Ok(serde_json::from_value(_value)?)
4928 }
4929
4930 /// Runs one factory-scoped subagent and returns its result.
4931 ///
4932 /// Wire method: `session.factory.agent`.
4933 ///
4934 /// # Parameters
4935 ///
4936 /// * `params` - Parameters for one factory-scoped subagent call.
4937 ///
4938 /// # Returns
4939 ///
4940 /// Result of one factory-scoped subagent call.
4941 ///
4942 /// <div class="warning">
4943 ///
4944 /// **Experimental.** This API is part of an experimental wire-protocol surface
4945 /// and may change or be removed in future SDK or CLI releases. Pin both the
4946 /// SDK and CLI versions if your code depends on it.
4947 ///
4948 /// </div>
4949 pub async fn agent(&self, params: FactoryAgentRequest) -> Result<FactoryAgentResult, Error> {
4950 let mut wire_params = serde_json::to_value(params)?;
4951 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4952 let _value = self
4953 .session
4954 .client()
4955 .call(rpc_methods::SESSION_FACTORY_AGENT, Some(wire_params))
4956 .await?;
4957 Ok(serde_json::from_value(_value)?)
4958 }
4959}
4960
4961/// `session.factory.journal.*` RPCs.
4962#[derive(Clone, Copy)]
4963pub struct SessionRpcFactoryJournal<'a> {
4964 pub(crate) session: &'a Session,
4965}
4966
4967impl<'a> SessionRpcFactoryJournal<'a> {
4968 /// Reads a memoized factory journal entry.
4969 ///
4970 /// Wire method: `session.factory.journal.get`.
4971 ///
4972 /// # Parameters
4973 ///
4974 /// * `params` - Parameters for reading a factory journal entry.
4975 ///
4976 /// # Returns
4977 ///
4978 /// Result of reading a factory journal entry.
4979 ///
4980 /// <div class="warning">
4981 ///
4982 /// **Experimental.** This API is part of an experimental wire-protocol surface
4983 /// and may change or be removed in future SDK or CLI releases. Pin both the
4984 /// SDK and CLI versions if your code depends on it.
4985 ///
4986 /// </div>
4987 pub async fn get(
4988 &self,
4989 params: FactoryJournalGetRequest,
4990 ) -> Result<FactoryJournalGetResult, Error> {
4991 let mut wire_params = serde_json::to_value(params)?;
4992 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4993 let _value = self
4994 .session
4995 .client()
4996 .call(rpc_methods::SESSION_FACTORY_JOURNAL_GET, Some(wire_params))
4997 .await?;
4998 Ok(serde_json::from_value(_value)?)
4999 }
5000
5001 /// Stores a memoized factory journal entry.
5002 ///
5003 /// Wire method: `session.factory.journal.put`.
5004 ///
5005 /// # Parameters
5006 ///
5007 /// * `params` - Parameters for storing a factory journal entry.
5008 ///
5009 /// # Returns
5010 ///
5011 /// Acknowledgement that a factory request was accepted.
5012 ///
5013 /// <div class="warning">
5014 ///
5015 /// **Experimental.** This API is part of an experimental wire-protocol surface
5016 /// and may change or be removed in future SDK or CLI releases. Pin both the
5017 /// SDK and CLI versions if your code depends on it.
5018 ///
5019 /// </div>
5020 pub async fn put(&self, params: FactoryJournalPutRequest) -> Result<FactoryAckResult, Error> {
5021 let mut wire_params = serde_json::to_value(params)?;
5022 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5023 let _value = self
5024 .session
5025 .client()
5026 .call(rpc_methods::SESSION_FACTORY_JOURNAL_PUT, Some(wire_params))
5027 .await?;
5028 Ok(serde_json::from_value(_value)?)
5029 }
5030}
5031
5032/// `session.fleet.*` RPCs.
5033#[derive(Clone, Copy)]
5034pub struct SessionRpcFleet<'a> {
5035 pub(crate) session: &'a Session,
5036}
5037
5038impl<'a> SessionRpcFleet<'a> {
5039 /// Starts fleet mode by submitting the fleet orchestration prompt to the session.
5040 ///
5041 /// Wire method: `session.fleet.start`.
5042 ///
5043 /// # Parameters
5044 ///
5045 /// * `params` - Optional user prompt to combine with the fleet orchestration instructions.
5046 ///
5047 /// # Returns
5048 ///
5049 /// Indicates whether fleet mode was successfully activated.
5050 ///
5051 /// <div class="warning">
5052 ///
5053 /// **Experimental.** This API is part of an experimental wire-protocol surface
5054 /// and may change or be removed in future SDK or CLI releases. Pin both the
5055 /// SDK and CLI versions if your code depends on it.
5056 ///
5057 /// </div>
5058 pub async fn start(&self, params: FleetStartRequest) -> Result<FleetStartResult, Error> {
5059 let mut wire_params = serde_json::to_value(params)?;
5060 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5061 let _value = self
5062 .session
5063 .client()
5064 .call(rpc_methods::SESSION_FLEET_START, Some(wire_params))
5065 .await?;
5066 Ok(serde_json::from_value(_value)?)
5067 }
5068}
5069
5070/// `session.gitHubAuth.*` RPCs.
5071#[derive(Clone, Copy)]
5072pub struct SessionRpcGitHubAuth<'a> {
5073 pub(crate) session: &'a Session,
5074}
5075
5076impl<'a> SessionRpcGitHubAuth<'a> {
5077 /// Gets authentication status and account metadata for the session.
5078 ///
5079 /// Wire method: `session.gitHubAuth.getStatus`.
5080 ///
5081 /// # Returns
5082 ///
5083 /// Authentication status and account metadata for the session.
5084 ///
5085 /// <div class="warning">
5086 ///
5087 /// **Experimental.** This API is part of an experimental wire-protocol surface
5088 /// and may change or be removed in future SDK or CLI releases. Pin both the
5089 /// SDK and CLI versions if your code depends on it.
5090 ///
5091 /// </div>
5092 pub async fn get_status(&self) -> Result<SessionAuthStatus, Error> {
5093 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5094 let _value = self
5095 .session
5096 .client()
5097 .call(rpc_methods::SESSION_GITHUBAUTH_GETSTATUS, Some(wire_params))
5098 .await?;
5099 Ok(serde_json::from_value(_value)?)
5100 }
5101
5102 /// Updates the session's auth credentials used for outbound model and API requests.
5103 ///
5104 /// Wire method: `session.gitHubAuth.setCredentials`.
5105 ///
5106 /// # Parameters
5107 ///
5108 /// * `params` - New auth credentials to install on the session. Omit to leave credentials unchanged.
5109 ///
5110 /// # Returns
5111 ///
5112 /// Indicates whether the credential update succeeded.
5113 ///
5114 /// <div class="warning">
5115 ///
5116 /// **Experimental.** This API is part of an experimental wire-protocol surface
5117 /// and may change or be removed in future SDK or CLI releases. Pin both the
5118 /// SDK and CLI versions if your code depends on it.
5119 ///
5120 /// </div>
5121 pub async fn set_credentials(
5122 &self,
5123 params: SessionSetCredentialsParams,
5124 ) -> Result<SessionSetCredentialsResult, Error> {
5125 let mut wire_params = serde_json::to_value(params)?;
5126 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5127 let _value = self
5128 .session
5129 .client()
5130 .call(
5131 rpc_methods::SESSION_GITHUBAUTH_SETCREDENTIALS,
5132 Some(wire_params),
5133 )
5134 .await?;
5135 Ok(serde_json::from_value(_value)?)
5136 }
5137
5138 /// Gets the current authentication information for internal session hosts.
5139 ///
5140 /// Wire method: `session.gitHubAuth.getCurrentAuthInfo`.
5141 ///
5142 /// # Returns
5143 ///
5144 /// Current authentication information, or null when no authentication is active.
5145 ///
5146 /// <div class="warning">
5147 ///
5148 /// **Experimental.** This API is part of an experimental wire-protocol surface
5149 /// and may change or be removed in future SDK or CLI releases. Pin both the
5150 /// SDK and CLI versions if your code depends on it.
5151 ///
5152 /// </div>
5153 pub(crate) async fn get_current_auth_info(&self) -> Result<SessionAuthInfoResult, Error> {
5154 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5155 let _value = self
5156 .session
5157 .client()
5158 .call(
5159 rpc_methods::SESSION_GITHUBAUTH_GETCURRENTAUTHINFO,
5160 Some(wire_params),
5161 )
5162 .await?;
5163 Ok(serde_json::from_value(_value)?)
5164 }
5165
5166 /// Gets all authentication accounts available to the internal session host.
5167 ///
5168 /// Wire method: `session.gitHubAuth.getAllAuthAvailable`.
5169 ///
5170 /// # Returns
5171 ///
5172 /// Authentication accounts available to the internal session host.
5173 ///
5174 /// <div class="warning">
5175 ///
5176 /// **Experimental.** This API is part of an experimental wire-protocol surface
5177 /// and may change or be removed in future SDK or CLI releases. Pin both the
5178 /// SDK and CLI versions if your code depends on it.
5179 ///
5180 /// </div>
5181 pub(crate) async fn get_all_auth_available(
5182 &self,
5183 ) -> Result<SessionGitHubAuthGetAllAuthAvailableResult, Error> {
5184 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5185 let _value = self
5186 .session
5187 .client()
5188 .call(
5189 rpc_methods::SESSION_GITHUBAUTH_GETALLAUTHAVAILABLE,
5190 Some(wire_params),
5191 )
5192 .await?;
5193 Ok(serde_json::from_value(_value)?)
5194 }
5195
5196 /// Refreshes Copilot account metadata for the current authentication.
5197 ///
5198 /// Wire method: `session.gitHubAuth.refreshCopilotUser`.
5199 ///
5200 /// # Returns
5201 ///
5202 /// Current authentication information, or null when no authentication is active.
5203 ///
5204 /// <div class="warning">
5205 ///
5206 /// **Experimental.** This API is part of an experimental wire-protocol surface
5207 /// and may change or be removed in future SDK or CLI releases. Pin both the
5208 /// SDK and CLI versions if your code depends on it.
5209 ///
5210 /// </div>
5211 pub(crate) async fn refresh_copilot_user(&self) -> Result<SessionAuthInfoResult, Error> {
5212 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5213 let _value = self
5214 .session
5215 .client()
5216 .call(
5217 rpc_methods::SESSION_GITHUBAUTH_REFRESHCOPILOTUSER,
5218 Some(wire_params),
5219 )
5220 .await?;
5221 Ok(serde_json::from_value(_value)?)
5222 }
5223
5224 /// Logs in a GitHub user through the internal session host.
5225 ///
5226 /// Wire method: `session.gitHubAuth.login`.
5227 ///
5228 /// # Parameters
5229 ///
5230 /// * `params` - Internal GitHub login parameters.
5231 ///
5232 /// # Returns
5233 ///
5234 /// Authentication credentials accepted only at native protocol ingress. Runtime outputs use credential-free `AuthIdentity` metadata.
5235 ///
5236 /// <div class="warning">
5237 ///
5238 /// **Experimental.** This API is part of an experimental wire-protocol surface
5239 /// and may change or be removed in future SDK or CLI releases. Pin both the
5240 /// SDK and CLI versions if your code depends on it.
5241 ///
5242 /// </div>
5243 pub(crate) async fn login(&self, params: SessionAuthLoginRequest) -> Result<AuthInfo, Error> {
5244 let mut wire_params = serde_json::to_value(params)?;
5245 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5246 let _value = self
5247 .session
5248 .client()
5249 .call(rpc_methods::SESSION_GITHUBAUTH_LOGIN, Some(wire_params))
5250 .await?;
5251 Ok(serde_json::from_value(_value)?)
5252 }
5253
5254 /// Switches the session to another available authentication.
5255 ///
5256 /// Wire method: `session.gitHubAuth.switchToAuth`.
5257 ///
5258 /// # Parameters
5259 ///
5260 /// * `params` - Parameters for switching the session's active authentication.
5261 ///
5262 /// <div class="warning">
5263 ///
5264 /// **Experimental.** This API is part of an experimental wire-protocol surface
5265 /// and may change or be removed in future SDK or CLI releases. Pin both the
5266 /// SDK and CLI versions if your code depends on it.
5267 ///
5268 /// </div>
5269 pub(crate) async fn switch_to_auth(
5270 &self,
5271 params: SessionAuthSwitchRequest,
5272 ) -> Result<(), Error> {
5273 let mut wire_params = serde_json::to_value(params)?;
5274 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5275 let _value = self
5276 .session
5277 .client()
5278 .call(
5279 rpc_methods::SESSION_GITHUBAUTH_SWITCHTOAUTH,
5280 Some(wire_params),
5281 )
5282 .await?;
5283 Ok(())
5284 }
5285
5286 /// Logs out the session's current GitHub authentication.
5287 ///
5288 /// Wire method: `session.gitHubAuth.logout`.
5289 ///
5290 /// # Returns
5291 ///
5292 /// Whether the current authentication was logged out.
5293 ///
5294 /// <div class="warning">
5295 ///
5296 /// **Experimental.** This API is part of an experimental wire-protocol surface
5297 /// and may change or be removed in future SDK or CLI releases. Pin both the
5298 /// SDK and CLI versions if your code depends on it.
5299 ///
5300 /// </div>
5301 pub(crate) async fn logout(&self) -> Result<SessionGitHubAuthLogoutResult, Error> {
5302 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5303 let _value = self
5304 .session
5305 .client()
5306 .call(rpc_methods::SESSION_GITHUBAUTH_LOGOUT, Some(wire_params))
5307 .await?;
5308 Ok(serde_json::from_value(_value)?)
5309 }
5310
5311 /// Logs out a specific GitHub authentication.
5312 ///
5313 /// Wire method: `session.gitHubAuth.logoutUser`.
5314 ///
5315 /// # Parameters
5316 ///
5317 /// * `params` - Parameters identifying a GitHub authentication to log out.
5318 ///
5319 /// # Returns
5320 ///
5321 /// Whether the requested authentication was logged out.
5322 ///
5323 /// <div class="warning">
5324 ///
5325 /// **Experimental.** This API is part of an experimental wire-protocol surface
5326 /// and may change or be removed in future SDK or CLI releases. Pin both the
5327 /// SDK and CLI versions if your code depends on it.
5328 ///
5329 /// </div>
5330 pub(crate) async fn logout_user(
5331 &self,
5332 params: SessionAuthLogoutUserRequest,
5333 ) -> Result<SessionGitHubAuthLogoutUserResult, 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(
5340 rpc_methods::SESSION_GITHUBAUTH_LOGOUTUSER,
5341 Some(wire_params),
5342 )
5343 .await?;
5344 Ok(serde_json::from_value(_value)?)
5345 }
5346
5347 /// Gets validation errors from the most recent authentication attempt.
5348 ///
5349 /// Wire method: `session.gitHubAuth.lastAuthErrors`.
5350 ///
5351 /// # Returns
5352 ///
5353 /// Validation errors from the most recent authentication attempt.
5354 ///
5355 /// <div class="warning">
5356 ///
5357 /// **Experimental.** This API is part of an experimental wire-protocol surface
5358 /// and may change or be removed in future SDK or CLI releases. Pin both the
5359 /// SDK and CLI versions if your code depends on it.
5360 ///
5361 /// </div>
5362 pub(crate) async fn last_auth_errors(&self) -> Result<AuthValidationErrors, Error> {
5363 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5364 let _value = self
5365 .session
5366 .client()
5367 .call(
5368 rpc_methods::SESSION_GITHUBAUTH_LASTAUTHERRORS,
5369 Some(wire_params),
5370 )
5371 .await?;
5372 Ok(serde_json::from_value(_value)?)
5373 }
5374}
5375
5376/// `session.history.*` RPCs.
5377#[derive(Clone, Copy)]
5378pub struct SessionRpcHistory<'a> {
5379 pub(crate) session: &'a Session,
5380}
5381
5382impl<'a> SessionRpcHistory<'a> {
5383 /// Compacts the session history to reduce context usage.
5384 ///
5385 /// Wire method: `session.history.compact`.
5386 ///
5387 /// # Returns
5388 ///
5389 /// Compaction outcome with the number of tokens and messages removed, summary text, and the resulting context window breakdown.
5390 ///
5391 /// <div class="warning">
5392 ///
5393 /// **Experimental.** This API is part of an experimental wire-protocol surface
5394 /// and may change or be removed in future SDK or CLI releases. Pin both the
5395 /// SDK and CLI versions if your code depends on it.
5396 ///
5397 /// </div>
5398 pub async fn compact(&self) -> Result<HistoryCompactResult, Error> {
5399 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5400 let _value = self
5401 .session
5402 .client()
5403 .call(rpc_methods::SESSION_HISTORY_COMPACT, Some(wire_params))
5404 .await?;
5405 Ok(serde_json::from_value(_value)?)
5406 }
5407
5408 /// Compacts the session history to reduce context usage.
5409 ///
5410 /// Wire method: `session.history.compact`.
5411 ///
5412 /// # Parameters
5413 ///
5414 /// * `params` - Optional compaction parameters.
5415 ///
5416 /// # Returns
5417 ///
5418 /// Compaction outcome with the number of tokens and messages removed, summary text, and the resulting context window breakdown.
5419 ///
5420 /// <div class="warning">
5421 ///
5422 /// **Experimental.** This API is part of an experimental wire-protocol surface
5423 /// and may change or be removed in future SDK or CLI releases. Pin both the
5424 /// SDK and CLI versions if your code depends on it.
5425 ///
5426 /// </div>
5427 pub async fn compact_with_params(
5428 &self,
5429 params: HistoryCompactRequest,
5430 ) -> Result<HistoryCompactResult, Error> {
5431 let mut wire_params = serde_json::to_value(params)?;
5432 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5433 let _value = self
5434 .session
5435 .client()
5436 .call(rpc_methods::SESSION_HISTORY_COMPACT, Some(wire_params))
5437 .await?;
5438 Ok(serde_json::from_value(_value)?)
5439 }
5440
5441 /// Truncates persisted session history to a specific event.
5442 ///
5443 /// Wire method: `session.history.truncate`.
5444 ///
5445 /// # Parameters
5446 ///
5447 /// * `params` - Identifier of the event to truncate to; this event and all later events are removed.
5448 ///
5449 /// # Returns
5450 ///
5451 /// Number of events that were removed by the truncation.
5452 ///
5453 /// <div class="warning">
5454 ///
5455 /// **Experimental.** This API is part of an experimental wire-protocol surface
5456 /// and may change or be removed in future SDK or CLI releases. Pin both the
5457 /// SDK and CLI versions if your code depends on it.
5458 ///
5459 /// </div>
5460 pub async fn truncate(
5461 &self,
5462 params: HistoryTruncateRequest,
5463 ) -> Result<HistoryTruncateResult, Error> {
5464 let mut wire_params = serde_json::to_value(params)?;
5465 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5466 let _value = self
5467 .session
5468 .client()
5469 .call(rpc_methods::SESSION_HISTORY_TRUNCATE, Some(wire_params))
5470 .await?;
5471 Ok(serde_json::from_value(_value)?)
5472 }
5473
5474 /// 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.
5475 ///
5476 /// Wire method: `session.history.listRewindPoints`.
5477 ///
5478 /// # Returns
5479 ///
5480 /// Rewind points and file-change-tracking availability for the session.
5481 ///
5482 /// <div class="warning">
5483 ///
5484 /// **Experimental.** This API is part of an experimental wire-protocol surface
5485 /// and may change or be removed in future SDK or CLI releases. Pin both the
5486 /// SDK and CLI versions if your code depends on it.
5487 ///
5488 /// </div>
5489 pub async fn list_rewind_points(&self) -> Result<HistoryListRewindPointsResult, Error> {
5490 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5491 let _value = self
5492 .session
5493 .client()
5494 .call(
5495 rpc_methods::SESSION_HISTORY_LISTREWINDPOINTS,
5496 Some(wire_params),
5497 )
5498 .await?;
5499 Ok(serde_json::from_value(_value)?)
5500 }
5501
5502 /// Previews the files that a conversation-and-files rewind would restore.
5503 ///
5504 /// Wire method: `session.history.previewRewind`.
5505 ///
5506 /// # Parameters
5507 ///
5508 /// * `params` - Event boundary to preview for conversation-and-files rewind.
5509 ///
5510 /// # Returns
5511 ///
5512 /// Files and aggregate changes for a prospective rewind.
5513 ///
5514 /// <div class="warning">
5515 ///
5516 /// **Experimental.** This API is part of an experimental wire-protocol surface
5517 /// and may change or be removed in future SDK or CLI releases. Pin both the
5518 /// SDK and CLI versions if your code depends on it.
5519 ///
5520 /// </div>
5521 pub async fn preview_rewind(
5522 &self,
5523 params: HistoryPreviewRewindRequest,
5524 ) -> Result<HistoryPreviewRewindResult, Error> {
5525 let mut wire_params = serde_json::to_value(params)?;
5526 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5527 let _value = self
5528 .session
5529 .client()
5530 .call(
5531 rpc_methods::SESSION_HISTORY_PREVIEWREWIND,
5532 Some(wire_params),
5533 )
5534 .await?;
5535 Ok(serde_json::from_value(_value)?)
5536 }
5537
5538 /// 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.
5539 ///
5540 /// Wire method: `session.history.rewind`.
5541 ///
5542 /// # Parameters
5543 ///
5544 /// * `params` - Boundary and mode for rewinding session history.
5545 ///
5546 /// # Returns
5547 ///
5548 /// Structured outcome of a rewind request.
5549 ///
5550 /// <div class="warning">
5551 ///
5552 /// **Experimental.** This API is part of an experimental wire-protocol surface
5553 /// and may change or be removed in future SDK or CLI releases. Pin both the
5554 /// SDK and CLI versions if your code depends on it.
5555 ///
5556 /// </div>
5557 pub async fn rewind(&self, params: HistoryRewindRequest) -> Result<HistoryRewindResult, Error> {
5558 let mut wire_params = serde_json::to_value(params)?;
5559 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5560 let _value = self
5561 .session
5562 .client()
5563 .call(rpc_methods::SESSION_HISTORY_REWIND, Some(wire_params))
5564 .await?;
5565 Ok(serde_json::from_value(_value)?)
5566 }
5567
5568 /// Cancels any in-progress background compaction on a local session.
5569 ///
5570 /// Wire method: `session.history.cancelBackgroundCompaction`.
5571 ///
5572 /// # Returns
5573 ///
5574 /// Indicates whether an in-progress background compaction was cancelled.
5575 ///
5576 /// <div class="warning">
5577 ///
5578 /// **Experimental.** This API is part of an experimental wire-protocol surface
5579 /// and may change or be removed in future SDK or CLI releases. Pin both the
5580 /// SDK and CLI versions if your code depends on it.
5581 ///
5582 /// </div>
5583 pub async fn cancel_background_compaction(
5584 &self,
5585 ) -> Result<HistoryCancelBackgroundCompactionResult, Error> {
5586 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5587 let _value = self
5588 .session
5589 .client()
5590 .call(
5591 rpc_methods::SESSION_HISTORY_CANCELBACKGROUNDCOMPACTION,
5592 Some(wire_params),
5593 )
5594 .await?;
5595 Ok(serde_json::from_value(_value)?)
5596 }
5597
5598 /// Aborts any in-progress manual compaction on a local session.
5599 ///
5600 /// Wire method: `session.history.abortManualCompaction`.
5601 ///
5602 /// # Returns
5603 ///
5604 /// Indicates whether an in-progress manual compaction was aborted.
5605 ///
5606 /// <div class="warning">
5607 ///
5608 /// **Experimental.** This API is part of an experimental wire-protocol surface
5609 /// and may change or be removed in future SDK or CLI releases. Pin both the
5610 /// SDK and CLI versions if your code depends on it.
5611 ///
5612 /// </div>
5613 pub async fn abort_manual_compaction(
5614 &self,
5615 ) -> Result<HistoryAbortManualCompactionResult, Error> {
5616 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5617 let _value = self
5618 .session
5619 .client()
5620 .call(
5621 rpc_methods::SESSION_HISTORY_ABORTMANUALCOMPACTION,
5622 Some(wire_params),
5623 )
5624 .await?;
5625 Ok(serde_json::from_value(_value)?)
5626 }
5627
5628 /// Produces a markdown summary of the session's conversation context for hand-off scenarios.
5629 ///
5630 /// Wire method: `session.history.summarizeForHandoff`.
5631 ///
5632 /// # Returns
5633 ///
5634 /// Markdown summary of the conversation context (empty when not available).
5635 ///
5636 /// <div class="warning">
5637 ///
5638 /// **Experimental.** This API is part of an experimental wire-protocol surface
5639 /// and may change or be removed in future SDK or CLI releases. Pin both the
5640 /// SDK and CLI versions if your code depends on it.
5641 ///
5642 /// </div>
5643 pub async fn summarize_for_handoff(&self) -> Result<HistorySummarizeForHandoffResult, Error> {
5644 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5645 let _value = self
5646 .session
5647 .client()
5648 .call(
5649 rpc_methods::SESSION_HISTORY_SUMMARIZEFORHANDOFF,
5650 Some(wire_params),
5651 )
5652 .await?;
5653 Ok(serde_json::from_value(_value)?)
5654 }
5655
5656 /// 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.
5657 ///
5658 /// Wire method: `session.history.clearContext`.
5659 ///
5660 /// # Parameters
5661 ///
5662 /// * `params` - Parameters for clearing the conversation and seeding the window that replaces it.
5663 ///
5664 /// # Returns
5665 ///
5666 /// What a successful clear removed. A clear that could not be applied rejects instead of reporting a count.
5667 ///
5668 /// <div class="warning">
5669 ///
5670 /// **Experimental.** This API is part of an experimental wire-protocol surface
5671 /// and may change or be removed in future SDK or CLI releases. Pin both the
5672 /// SDK and CLI versions if your code depends on it.
5673 ///
5674 /// </div>
5675 pub async fn clear_context(
5676 &self,
5677 params: HistoryClearContextRequest,
5678 ) -> Result<HistoryClearContextResult, Error> {
5679 let mut wire_params = serde_json::to_value(params)?;
5680 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5681 let _value = self
5682 .session
5683 .client()
5684 .call(rpc_methods::SESSION_HISTORY_CLEARCONTEXT, Some(wire_params))
5685 .await?;
5686 Ok(serde_json::from_value(_value)?)
5687 }
5688}
5689
5690/// `session.instructions.*` RPCs.
5691#[derive(Clone, Copy)]
5692pub struct SessionRpcInstructions<'a> {
5693 pub(crate) session: &'a Session,
5694}
5695
5696impl<'a> SessionRpcInstructions<'a> {
5697 /// Gets instruction sources loaded for the session.
5698 ///
5699 /// Wire method: `session.instructions.getSources`.
5700 ///
5701 /// # Returns
5702 ///
5703 /// Instruction sources loaded for the session, in merge order.
5704 ///
5705 /// <div class="warning">
5706 ///
5707 /// **Experimental.** This API is part of an experimental wire-protocol surface
5708 /// and may change or be removed in future SDK or CLI releases. Pin both the
5709 /// SDK and CLI versions if your code depends on it.
5710 ///
5711 /// </div>
5712 pub async fn get_sources(&self) -> Result<InstructionsGetSourcesResult, Error> {
5713 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5714 let _value = self
5715 .session
5716 .client()
5717 .call(
5718 rpc_methods::SESSION_INSTRUCTIONS_GETSOURCES,
5719 Some(wire_params),
5720 )
5721 .await?;
5722 Ok(serde_json::from_value(_value)?)
5723 }
5724}
5725
5726/// `session.limitPrediction.*` RPCs.
5727#[derive(Clone, Copy)]
5728pub struct SessionRpcLimitPrediction<'a> {
5729 pub(crate) session: &'a Session,
5730}
5731
5732impl<'a> SessionRpcLimitPrediction<'a> {
5733 /// 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.
5734 ///
5735 /// Wire method: `session.limitPrediction.predict`.
5736 ///
5737 /// # Returns
5738 ///
5739 /// Prediction result. Available results include prediction details; unavailable results include an explicit reason.
5740 ///
5741 /// <div class="warning">
5742 ///
5743 /// **Experimental.** This API is part of an experimental wire-protocol surface
5744 /// and may change or be removed in future SDK or CLI releases. Pin both the
5745 /// SDK and CLI versions if your code depends on it.
5746 ///
5747 /// </div>
5748 pub async fn predict(&self) -> Result<SessionLimitPredictionResult, Error> {
5749 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5750 let _value = self
5751 .session
5752 .client()
5753 .call(
5754 rpc_methods::SESSION_LIMITPREDICTION_PREDICT,
5755 Some(wire_params),
5756 )
5757 .await?;
5758 Ok(serde_json::from_value(_value)?)
5759 }
5760
5761 /// 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.
5762 ///
5763 /// Wire method: `session.limitPrediction.predict`.
5764 ///
5765 /// # Parameters
5766 ///
5767 /// * `params` - Parameters for predicting an AI-credit session limit. Omitting `modelId` uses the session's currently selected model.
5768 ///
5769 /// # Returns
5770 ///
5771 /// Prediction result. Available results include prediction details; unavailable results include an explicit reason.
5772 ///
5773 /// <div class="warning">
5774 ///
5775 /// **Experimental.** This API is part of an experimental wire-protocol surface
5776 /// and may change or be removed in future SDK or CLI releases. Pin both the
5777 /// SDK and CLI versions if your code depends on it.
5778 ///
5779 /// </div>
5780 pub async fn predict_with_params(
5781 &self,
5782 params: SessionLimitPredictionRequest,
5783 ) -> Result<SessionLimitPredictionResult, Error> {
5784 let mut wire_params = serde_json::to_value(params)?;
5785 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5786 let _value = self
5787 .session
5788 .client()
5789 .call(
5790 rpc_methods::SESSION_LIMITPREDICTION_PREDICT,
5791 Some(wire_params),
5792 )
5793 .await?;
5794 Ok(serde_json::from_value(_value)?)
5795 }
5796}
5797
5798/// `session.lsp.*` RPCs.
5799#[derive(Clone, Copy)]
5800pub struct SessionRpcLsp<'a> {
5801 pub(crate) session: &'a Session,
5802}
5803
5804impl<'a> SessionRpcLsp<'a> {
5805 /// Loads the merged LSP configuration set for the session's working directory.
5806 ///
5807 /// Wire method: `session.lsp.initialize`.
5808 ///
5809 /// # Parameters
5810 ///
5811 /// * `params` - Parameters for (re)loading the merged LSP configuration set.
5812 ///
5813 /// <div class="warning">
5814 ///
5815 /// **Experimental.** This API is part of an experimental wire-protocol surface
5816 /// and may change or be removed in future SDK or CLI releases. Pin both the
5817 /// SDK and CLI versions if your code depends on it.
5818 ///
5819 /// </div>
5820 pub async fn initialize(&self, params: LspInitializeRequest) -> Result<(), Error> {
5821 let mut wire_params = serde_json::to_value(params)?;
5822 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5823 let _value = self
5824 .session
5825 .client()
5826 .call(rpc_methods::SESSION_LSP_INITIALIZE, Some(wire_params))
5827 .await?;
5828 Ok(())
5829 }
5830}
5831
5832/// `session.mcp.*` RPCs.
5833#[derive(Clone, Copy)]
5834pub struct SessionRpcMcp<'a> {
5835 pub(crate) session: &'a Session,
5836}
5837
5838impl<'a> SessionRpcMcp<'a> {
5839 /// `session.mcp.apps.*` sub-namespace.
5840 pub fn apps(&self) -> SessionRpcMcpApps<'a> {
5841 SessionRpcMcpApps {
5842 session: self.session,
5843 }
5844 }
5845
5846 /// `session.mcp.headers.*` sub-namespace.
5847 pub fn headers(&self) -> SessionRpcMcpHeaders<'a> {
5848 SessionRpcMcpHeaders {
5849 session: self.session,
5850 }
5851 }
5852
5853 /// `session.mcp.oauth.*` sub-namespace.
5854 pub fn oauth(&self) -> SessionRpcMcpOauth<'a> {
5855 SessionRpcMcpOauth {
5856 session: self.session,
5857 }
5858 }
5859
5860 /// `session.mcp.resources.*` sub-namespace.
5861 pub fn resources(&self) -> SessionRpcMcpResources<'a> {
5862 SessionRpcMcpResources {
5863 session: self.session,
5864 }
5865 }
5866
5867 /// 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.
5868 ///
5869 /// Wire method: `session.mcp.list`.
5870 ///
5871 /// # Returns
5872 ///
5873 /// MCP servers configured for the session, with their connection status and host-level state.
5874 ///
5875 /// <div class="warning">
5876 ///
5877 /// **Experimental.** This API is part of an experimental wire-protocol surface
5878 /// and may change or be removed in future SDK or CLI releases. Pin both the
5879 /// SDK and CLI versions if your code depends on it.
5880 ///
5881 /// </div>
5882 pub async fn list(&self) -> Result<McpServerList, Error> {
5883 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5884 let _value = self
5885 .session
5886 .client()
5887 .call(rpc_methods::SESSION_MCP_LIST, Some(wire_params))
5888 .await?;
5889 Ok(serde_json::from_value(_value)?)
5890 }
5891
5892 /// 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.
5893 ///
5894 /// Wire method: `session.mcp.listTools`.
5895 ///
5896 /// # Parameters
5897 ///
5898 /// * `params` - Server name whose tool list should be returned.
5899 ///
5900 /// # Returns
5901 ///
5902 /// Tools exposed by the connected MCP server. Throws when the server is not connected.
5903 ///
5904 /// <div class="warning">
5905 ///
5906 /// **Experimental.** This API is part of an experimental wire-protocol surface
5907 /// and may change or be removed in future SDK or CLI releases. Pin both the
5908 /// SDK and CLI versions if your code depends on it.
5909 ///
5910 /// </div>
5911 pub async fn list_tools(
5912 &self,
5913 params: McpListToolsRequest,
5914 ) -> Result<McpListToolsResult, Error> {
5915 let mut wire_params = serde_json::to_value(params)?;
5916 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5917 let _value = self
5918 .session
5919 .client()
5920 .call(rpc_methods::SESSION_MCP_LISTTOOLS, Some(wire_params))
5921 .await?;
5922 Ok(serde_json::from_value(_value)?)
5923 }
5924
5925 /// Enables an MCP server for the session.
5926 ///
5927 /// Wire method: `session.mcp.enable`.
5928 ///
5929 /// # Parameters
5930 ///
5931 /// * `params` - Name of the MCP server to enable for the session.
5932 ///
5933 /// <div class="warning">
5934 ///
5935 /// **Experimental.** This API is part of an experimental wire-protocol surface
5936 /// and may change or be removed in future SDK or CLI releases. Pin both the
5937 /// SDK and CLI versions if your code depends on it.
5938 ///
5939 /// </div>
5940 pub async fn enable(&self, params: McpEnableRequest) -> Result<(), Error> {
5941 let mut wire_params = serde_json::to_value(params)?;
5942 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5943 let _value = self
5944 .session
5945 .client()
5946 .call(rpc_methods::SESSION_MCP_ENABLE, Some(wire_params))
5947 .await?;
5948 Ok(())
5949 }
5950
5951 /// Disables an MCP server for the session.
5952 ///
5953 /// Wire method: `session.mcp.disable`.
5954 ///
5955 /// # Parameters
5956 ///
5957 /// * `params` - Name of the MCP server to disable for the session.
5958 ///
5959 /// <div class="warning">
5960 ///
5961 /// **Experimental.** This API is part of an experimental wire-protocol surface
5962 /// and may change or be removed in future SDK or CLI releases. Pin both the
5963 /// SDK and CLI versions if your code depends on it.
5964 ///
5965 /// </div>
5966 pub async fn disable(&self, params: McpDisableRequest) -> Result<(), Error> {
5967 let mut wire_params = serde_json::to_value(params)?;
5968 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5969 let _value = self
5970 .session
5971 .client()
5972 .call(rpc_methods::SESSION_MCP_DISABLE, Some(wire_params))
5973 .await?;
5974 Ok(())
5975 }
5976
5977 /// Reloads MCP server connections for the session.
5978 ///
5979 /// Wire method: `session.mcp.reload`.
5980 ///
5981 /// <div class="warning">
5982 ///
5983 /// **Experimental.** This API is part of an experimental wire-protocol surface
5984 /// and may change or be removed in future SDK or CLI releases. Pin both the
5985 /// SDK and CLI versions if your code depends on it.
5986 ///
5987 /// </div>
5988 pub async fn reload(&self) -> Result<(), Error> {
5989 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5990 let _value = self
5991 .session
5992 .client()
5993 .call(rpc_methods::SESSION_MCP_RELOAD, Some(wire_params))
5994 .await?;
5995 Ok(())
5996 }
5997
5998 /// 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.
5999 ///
6000 /// Wire method: `session.mcp.moveLoadingToBackground`.
6001 ///
6002 /// # Returns
6003 ///
6004 /// Result of moving in-flight MCP loading to the background.
6005 ///
6006 /// <div class="warning">
6007 ///
6008 /// **Experimental.** This API is part of an experimental wire-protocol surface
6009 /// and may change or be removed in future SDK or CLI releases. Pin both the
6010 /// SDK and CLI versions if your code depends on it.
6011 ///
6012 /// </div>
6013 pub async fn move_loading_to_background(
6014 &self,
6015 ) -> Result<MoveMcpLoadingToBackgroundResult, Error> {
6016 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6017 let _value = self
6018 .session
6019 .client()
6020 .call(
6021 rpc_methods::SESSION_MCP_MOVELOADINGTOBACKGROUND,
6022 Some(wire_params),
6023 )
6024 .await?;
6025 Ok(serde_json::from_value(_value)?)
6026 }
6027
6028 /// Reloads MCP server connections for the session with an explicit host-provided configuration.
6029 ///
6030 /// Wire method: `session.mcp.reloadWithConfig`.
6031 ///
6032 /// # Parameters
6033 ///
6034 /// * `params` - Opaque MCP reload configuration.
6035 ///
6036 /// # Returns
6037 ///
6038 /// MCP server startup filtering result.
6039 ///
6040 /// <div class="warning">
6041 ///
6042 /// **Experimental.** This API is part of an experimental wire-protocol surface
6043 /// and may change or be removed in future SDK or CLI releases. Pin both the
6044 /// SDK and CLI versions if your code depends on it.
6045 ///
6046 /// </div>
6047 pub(crate) async fn reload_with_config(
6048 &self,
6049 params: McpReloadWithConfigRequest,
6050 ) -> Result<McpStartServersResult, Error> {
6051 let mut wire_params = serde_json::to_value(params)?;
6052 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6053 let _value = self
6054 .session
6055 .client()
6056 .call(rpc_methods::SESSION_MCP_RELOADWITHCONFIG, Some(wire_params))
6057 .await?;
6058 Ok(serde_json::from_value(_value)?)
6059 }
6060
6061 /// Runs an MCP sampling inference on behalf of an MCP server.
6062 ///
6063 /// Wire method: `session.mcp.executeSampling`.
6064 ///
6065 /// # Parameters
6066 ///
6067 /// * `params` - Identifiers and raw MCP CreateMessageRequest params used to run a sampling inference.
6068 ///
6069 /// # Returns
6070 ///
6071 /// Outcome of an MCP sampling execution: success result, failure error, or cancellation.
6072 ///
6073 /// <div class="warning">
6074 ///
6075 /// **Experimental.** This API is part of an experimental wire-protocol surface
6076 /// and may change or be removed in future SDK or CLI releases. Pin both the
6077 /// SDK and CLI versions if your code depends on it.
6078 ///
6079 /// </div>
6080 pub async fn execute_sampling(
6081 &self,
6082 params: McpExecuteSamplingParams,
6083 ) -> Result<McpSamplingExecutionResult, Error> {
6084 let mut wire_params = serde_json::to_value(params)?;
6085 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6086 let _value = self
6087 .session
6088 .client()
6089 .call(rpc_methods::SESSION_MCP_EXECUTESAMPLING, Some(wire_params))
6090 .await?;
6091 Ok(serde_json::from_value(_value)?)
6092 }
6093
6094 /// Cancels an in-flight MCP sampling execution by request ID.
6095 ///
6096 /// Wire method: `session.mcp.cancelSamplingExecution`.
6097 ///
6098 /// # Parameters
6099 ///
6100 /// * `params` - The requestId previously passed to executeSampling that should be cancelled.
6101 ///
6102 /// # Returns
6103 ///
6104 /// Indicates whether an in-flight sampling execution with the given requestId was found and cancelled.
6105 ///
6106 /// <div class="warning">
6107 ///
6108 /// **Experimental.** This API is part of an experimental wire-protocol surface
6109 /// and may change or be removed in future SDK or CLI releases. Pin both the
6110 /// SDK and CLI versions if your code depends on it.
6111 ///
6112 /// </div>
6113 pub async fn cancel_sampling_execution(
6114 &self,
6115 params: McpCancelSamplingExecutionParams,
6116 ) -> Result<McpCancelSamplingExecutionResult, Error> {
6117 let mut wire_params = serde_json::to_value(params)?;
6118 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6119 let _value = self
6120 .session
6121 .client()
6122 .call(
6123 rpc_methods::SESSION_MCP_CANCELSAMPLINGEXECUTION,
6124 Some(wire_params),
6125 )
6126 .await?;
6127 Ok(serde_json::from_value(_value)?)
6128 }
6129
6130 /// Sets how environment-variable values supplied to MCP servers are resolved (direct or indirect).
6131 ///
6132 /// Wire method: `session.mcp.setEnvValueMode`.
6133 ///
6134 /// # Parameters
6135 ///
6136 /// * `params` - Mode controlling how MCP server env values are resolved (`direct` or `indirect`).
6137 ///
6138 /// # Returns
6139 ///
6140 /// Env-value mode recorded on the session after the update.
6141 ///
6142 /// <div class="warning">
6143 ///
6144 /// **Experimental.** This API is part of an experimental wire-protocol surface
6145 /// and may change or be removed in future SDK or CLI releases. Pin both the
6146 /// SDK and CLI versions if your code depends on it.
6147 ///
6148 /// </div>
6149 pub async fn set_env_value_mode(
6150 &self,
6151 params: McpSetEnvValueModeParams,
6152 ) -> Result<McpSetEnvValueModeResult, Error> {
6153 let mut wire_params = serde_json::to_value(params)?;
6154 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6155 let _value = self
6156 .session
6157 .client()
6158 .call(rpc_methods::SESSION_MCP_SETENVVALUEMODE, Some(wire_params))
6159 .await?;
6160 Ok(serde_json::from_value(_value)?)
6161 }
6162
6163 /// Removes the auto-managed `github` MCP server when present.
6164 ///
6165 /// Wire method: `session.mcp.removeGitHub`.
6166 ///
6167 /// # Returns
6168 ///
6169 /// Indicates whether the auto-managed `github` MCP server was removed (false when nothing to remove).
6170 ///
6171 /// <div class="warning">
6172 ///
6173 /// **Experimental.** This API is part of an experimental wire-protocol surface
6174 /// and may change or be removed in future SDK or CLI releases. Pin both the
6175 /// SDK and CLI versions if your code depends on it.
6176 ///
6177 /// </div>
6178 pub async fn remove_git_hub(&self) -> Result<McpRemoveGitHubResult, Error> {
6179 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6180 let _value = self
6181 .session
6182 .client()
6183 .call(rpc_methods::SESSION_MCP_REMOVEGITHUB, Some(wire_params))
6184 .await?;
6185 Ok(serde_json::from_value(_value)?)
6186 }
6187
6188 /// Configures the built-in GitHub MCP server for the session's current auth context.
6189 ///
6190 /// Wire method: `session.mcp.configureGitHub`.
6191 ///
6192 /// # Parameters
6193 ///
6194 /// * `params` - Credential-free authentication identity used to configure GitHub MCP.
6195 ///
6196 /// # Returns
6197 ///
6198 /// Result of configuring GitHub MCP.
6199 ///
6200 /// <div class="warning">
6201 ///
6202 /// **Experimental.** This API is part of an experimental wire-protocol surface
6203 /// and may change or be removed in future SDK or CLI releases. Pin both the
6204 /// SDK and CLI versions if your code depends on it.
6205 ///
6206 /// </div>
6207 pub(crate) async fn configure_git_hub(
6208 &self,
6209 params: McpConfigureGitHubRequest,
6210 ) -> Result<McpConfigureGitHubResult, Error> {
6211 let mut wire_params = serde_json::to_value(params)?;
6212 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6213 let _value = self
6214 .session
6215 .client()
6216 .call(rpc_methods::SESSION_MCP_CONFIGUREGITHUB, Some(wire_params))
6217 .await?;
6218 Ok(serde_json::from_value(_value)?)
6219 }
6220
6221 /// 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.
6222 ///
6223 /// Wire method: `session.mcp.startServer`.
6224 ///
6225 /// # Parameters
6226 ///
6227 /// * `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.
6228 ///
6229 /// <div class="warning">
6230 ///
6231 /// **Experimental.** This API is part of an experimental wire-protocol surface
6232 /// and may change or be removed in future SDK or CLI releases. Pin both the
6233 /// SDK and CLI versions if your code depends on it.
6234 ///
6235 /// </div>
6236 pub async fn start_server(&self, params: McpStartServerRequest) -> Result<(), Error> {
6237 let mut wire_params = serde_json::to_value(params)?;
6238 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6239 let _value = self
6240 .session
6241 .client()
6242 .call(rpc_methods::SESSION_MCP_STARTSERVER, Some(wire_params))
6243 .await?;
6244 Ok(())
6245 }
6246
6247 /// 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.*`).
6248 ///
6249 /// Wire method: `session.mcp.restartServer`.
6250 ///
6251 /// # Parameters
6252 ///
6253 /// * `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.
6254 ///
6255 /// <div class="warning">
6256 ///
6257 /// **Experimental.** This API is part of an experimental wire-protocol surface
6258 /// and may change or be removed in future SDK or CLI releases. Pin both the
6259 /// SDK and CLI versions if your code depends on it.
6260 ///
6261 /// </div>
6262 pub async fn restart_server(&self, params: McpRestartServerRequest) -> Result<(), Error> {
6263 let mut wire_params = serde_json::to_value(params)?;
6264 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6265 let _value = self
6266 .session
6267 .client()
6268 .call(rpc_methods::SESSION_MCP_RESTARTSERVER, Some(wire_params))
6269 .await?;
6270 Ok(())
6271 }
6272
6273 /// Stops an individual MCP server on the session's host.
6274 ///
6275 /// Wire method: `session.mcp.stopServer`.
6276 ///
6277 /// # Parameters
6278 ///
6279 /// * `params` - Server name for an individual MCP server stop.
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 stop_server(&self, params: McpStopServerRequest) -> Result<(), Error> {
6289 let mut wire_params = serde_json::to_value(params)?;
6290 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6291 let _value = self
6292 .session
6293 .client()
6294 .call(rpc_methods::SESSION_MCP_STOPSERVER, Some(wire_params))
6295 .await?;
6296 Ok(())
6297 }
6298
6299 /// 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.
6300 ///
6301 /// Wire method: `session.mcp.registerExternalClient`.
6302 ///
6303 /// # Parameters
6304 ///
6305 /// * `params` - Registration parameters for an external MCP client.
6306 ///
6307 /// <div class="warning">
6308 ///
6309 /// **Experimental.** This API is part of an experimental wire-protocol surface
6310 /// and may change or be removed in future SDK or CLI releases. Pin both the
6311 /// SDK and CLI versions if your code depends on it.
6312 ///
6313 /// </div>
6314 pub(crate) async fn register_external_client(
6315 &self,
6316 params: McpRegisterExternalClientRequest,
6317 ) -> Result<(), Error> {
6318 let mut wire_params = serde_json::to_value(params)?;
6319 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6320 let _value = self
6321 .session
6322 .client()
6323 .call(
6324 rpc_methods::SESSION_MCP_REGISTEREXTERNALCLIENT,
6325 Some(wire_params),
6326 )
6327 .await?;
6328 Ok(())
6329 }
6330
6331 /// 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.
6332 ///
6333 /// Wire method: `session.mcp.unregisterExternalClient`.
6334 ///
6335 /// # Parameters
6336 ///
6337 /// * `params` - Server name identifying the external client to remove.
6338 ///
6339 /// <div class="warning">
6340 ///
6341 /// **Experimental.** This API is part of an experimental wire-protocol surface
6342 /// and may change or be removed in future SDK or CLI releases. Pin both the
6343 /// SDK and CLI versions if your code depends on it.
6344 ///
6345 /// </div>
6346 pub(crate) async fn unregister_external_client(
6347 &self,
6348 params: McpUnregisterExternalClientRequest,
6349 ) -> Result<(), Error> {
6350 let mut wire_params = serde_json::to_value(params)?;
6351 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6352 let _value = self
6353 .session
6354 .client()
6355 .call(
6356 rpc_methods::SESSION_MCP_UNREGISTEREXTERNALCLIENT,
6357 Some(wire_params),
6358 )
6359 .await?;
6360 Ok(())
6361 }
6362
6363 /// Checks whether a named MCP server is currently running on the session's host.
6364 ///
6365 /// Wire method: `session.mcp.isServerRunning`.
6366 ///
6367 /// # Parameters
6368 ///
6369 /// * `params` - Server name to check running status for.
6370 ///
6371 /// # Returns
6372 ///
6373 /// Whether the named MCP server is running.
6374 ///
6375 /// <div class="warning">
6376 ///
6377 /// **Experimental.** This API is part of an experimental wire-protocol surface
6378 /// and may change or be removed in future SDK or CLI releases. Pin both the
6379 /// SDK and CLI versions if your code depends on it.
6380 ///
6381 /// </div>
6382 pub async fn is_server_running(
6383 &self,
6384 params: McpIsServerRunningRequest,
6385 ) -> Result<McpIsServerRunningResult, Error> {
6386 let mut wire_params = serde_json::to_value(params)?;
6387 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6388 let _value = self
6389 .session
6390 .client()
6391 .call(rpc_methods::SESSION_MCP_ISSERVERRUNNING, Some(wire_params))
6392 .await?;
6393 Ok(serde_json::from_value(_value)?)
6394 }
6395}
6396
6397/// `session.mcp.apps.*` RPCs.
6398#[derive(Clone, Copy)]
6399pub struct SessionRpcMcpApps<'a> {
6400 pub(crate) session: &'a Session,
6401}
6402
6403impl<'a> SessionRpcMcpApps<'a> {
6404 /// Fetch an MCP resource (typically a `ui://` MCP App bundle, per SEP-1865) from a connected server. Requires the `mcp-apps` session capability.
6405 ///
6406 /// Wire method: `session.mcp.apps.readResource`.
6407 ///
6408 /// # Parameters
6409 ///
6410 /// * `params` - MCP server and resource URI to fetch.
6411 ///
6412 /// # Returns
6413 ///
6414 /// Resource contents returned by the MCP server.
6415 ///
6416 /// <div class="warning">
6417 ///
6418 /// **Experimental.** This API is part of an experimental wire-protocol surface
6419 /// and may change or be removed in future SDK or CLI releases. Pin both the
6420 /// SDK and CLI versions if your code depends on it.
6421 ///
6422 /// </div>
6423 pub async fn read_resource(
6424 &self,
6425 params: McpAppsReadResourceRequest,
6426 ) -> Result<McpAppsReadResourceResult, Error> {
6427 let mut wire_params = serde_json::to_value(params)?;
6428 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6429 let _value = self
6430 .session
6431 .client()
6432 .call(
6433 rpc_methods::SESSION_MCP_APPS_READRESOURCE,
6434 Some(wire_params),
6435 )
6436 .await?;
6437 Ok(serde_json::from_value(_value)?)
6438 }
6439
6440 /// 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"`.
6441 ///
6442 /// Wire method: `session.mcp.apps.listTools`.
6443 ///
6444 /// # Parameters
6445 ///
6446 /// * `params` - MCP server to list app-callable tools for.
6447 ///
6448 /// # Returns
6449 ///
6450 /// App-callable tools from the named MCP server.
6451 ///
6452 /// <div class="warning">
6453 ///
6454 /// **Experimental.** This API is part of an experimental wire-protocol surface
6455 /// and may change or be removed in future SDK or CLI releases. Pin both the
6456 /// SDK and CLI versions if your code depends on it.
6457 ///
6458 /// </div>
6459 pub async fn list_tools(
6460 &self,
6461 params: McpAppsListToolsRequest,
6462 ) -> Result<McpAppsListToolsResult, Error> {
6463 let mut wire_params = serde_json::to_value(params)?;
6464 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6465 let _value = self
6466 .session
6467 .client()
6468 .call(rpc_methods::SESSION_MCP_APPS_LISTTOOLS, Some(wire_params))
6469 .await?;
6470 Ok(serde_json::from_value(_value)?)
6471 }
6472
6473 /// 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`.
6474 ///
6475 /// Wire method: `session.mcp.apps.callTool`.
6476 ///
6477 /// # Parameters
6478 ///
6479 /// * `params` - MCP server, tool name, and arguments to invoke from an MCP App view.
6480 ///
6481 /// # Returns
6482 ///
6483 /// Standard MCP CallToolResult
6484 ///
6485 /// <div class="warning">
6486 ///
6487 /// **Experimental.** This API is part of an experimental wire-protocol surface
6488 /// and may change or be removed in future SDK or CLI releases. Pin both the
6489 /// SDK and CLI versions if your code depends on it.
6490 ///
6491 /// </div>
6492 pub async fn call_tool(
6493 &self,
6494 params: McpAppsCallToolRequest,
6495 ) -> Result<SessionMcpAppsCallToolResult, Error> {
6496 let mut wire_params = serde_json::to_value(params)?;
6497 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6498 let _value = self
6499 .session
6500 .client()
6501 .call(rpc_methods::SESSION_MCP_APPS_CALLTOOL, Some(wire_params))
6502 .await?;
6503 Ok(serde_json::from_value(_value)?)
6504 }
6505
6506 /// 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.
6507 ///
6508 /// Wire method: `session.mcp.apps.setHostContext`.
6509 ///
6510 /// # Parameters
6511 ///
6512 /// * `params` - Host context to advertise to MCP App guests.
6513 ///
6514 /// <div class="warning">
6515 ///
6516 /// **Experimental.** This API is part of an experimental wire-protocol surface
6517 /// and may change or be removed in future SDK or CLI releases. Pin both the
6518 /// SDK and CLI versions if your code depends on it.
6519 ///
6520 /// </div>
6521 pub async fn set_host_context(
6522 &self,
6523 params: McpAppsSetHostContextRequest,
6524 ) -> Result<(), Error> {
6525 let mut wire_params = serde_json::to_value(params)?;
6526 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6527 let _value = self
6528 .session
6529 .client()
6530 .call(
6531 rpc_methods::SESSION_MCP_APPS_SETHOSTCONTEXT,
6532 Some(wire_params),
6533 )
6534 .await?;
6535 Ok(())
6536 }
6537
6538 /// Read the current host context advertised to MCP App guests.
6539 ///
6540 /// Wire method: `session.mcp.apps.getHostContext`.
6541 ///
6542 /// # Returns
6543 ///
6544 /// Current host context advertised to MCP App guests.
6545 ///
6546 /// <div class="warning">
6547 ///
6548 /// **Experimental.** This API is part of an experimental wire-protocol surface
6549 /// and may change or be removed in future SDK or CLI releases. Pin both the
6550 /// SDK and CLI versions if your code depends on it.
6551 ///
6552 /// </div>
6553 pub async fn get_host_context(&self) -> Result<McpAppsHostContext, Error> {
6554 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6555 let _value = self
6556 .session
6557 .client()
6558 .call(
6559 rpc_methods::SESSION_MCP_APPS_GETHOSTCONTEXT,
6560 Some(wire_params),
6561 )
6562 .await?;
6563 Ok(serde_json::from_value(_value)?)
6564 }
6565
6566 /// 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.
6567 ///
6568 /// Wire method: `session.mcp.apps.diagnose`.
6569 ///
6570 /// # Parameters
6571 ///
6572 /// * `params` - MCP server to diagnose MCP Apps wiring for.
6573 ///
6574 /// # Returns
6575 ///
6576 /// Diagnostic snapshot of MCP Apps wiring for the named server.
6577 ///
6578 /// <div class="warning">
6579 ///
6580 /// **Experimental.** This API is part of an experimental wire-protocol surface
6581 /// and may change or be removed in future SDK or CLI releases. Pin both the
6582 /// SDK and CLI versions if your code depends on it.
6583 ///
6584 /// </div>
6585 pub async fn diagnose(
6586 &self,
6587 params: McpAppsDiagnoseRequest,
6588 ) -> Result<McpAppsDiagnoseResult, Error> {
6589 let mut wire_params = serde_json::to_value(params)?;
6590 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6591 let _value = self
6592 .session
6593 .client()
6594 .call(rpc_methods::SESSION_MCP_APPS_DIAGNOSE, Some(wire_params))
6595 .await?;
6596 Ok(serde_json::from_value(_value)?)
6597 }
6598}
6599
6600/// `session.mcp.headers.*` RPCs.
6601#[derive(Clone, Copy)]
6602pub struct SessionRpcMcpHeaders<'a> {
6603 pub(crate) session: &'a Session,
6604}
6605
6606impl<'a> SessionRpcMcpHeaders<'a> {
6607 /// 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.
6608 ///
6609 /// Wire method: `session.mcp.headers.handlePendingHeadersRefreshRequest`.
6610 ///
6611 /// # Parameters
6612 ///
6613 /// * `params` - MCP headers refresh request id and the host response.
6614 ///
6615 /// # Returns
6616 ///
6617 /// Indicates whether the pending MCP headers refresh response was accepted.
6618 ///
6619 /// <div class="warning">
6620 ///
6621 /// **Experimental.** This API is part of an experimental wire-protocol surface
6622 /// and may change or be removed in future SDK or CLI releases. Pin both the
6623 /// SDK and CLI versions if your code depends on it.
6624 ///
6625 /// </div>
6626 pub async fn handle_pending_headers_refresh_request(
6627 &self,
6628 params: McpHeadersHandlePendingHeadersRefreshRequestRequest,
6629 ) -> Result<McpHeadersHandlePendingHeadersRefreshRequestResult, Error> {
6630 let mut wire_params = serde_json::to_value(params)?;
6631 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6632 let _value = self
6633 .session
6634 .client()
6635 .call(
6636 rpc_methods::SESSION_MCP_HEADERS_HANDLEPENDINGHEADERSREFRESHREQUEST,
6637 Some(wire_params),
6638 )
6639 .await?;
6640 Ok(serde_json::from_value(_value)?)
6641 }
6642}
6643
6644/// `session.mcp.oauth.*` RPCs.
6645#[derive(Clone, Copy)]
6646pub struct SessionRpcMcpOauth<'a> {
6647 pub(crate) session: &'a Session,
6648}
6649
6650impl<'a> SessionRpcMcpOauth<'a> {
6651 /// 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.
6652 ///
6653 /// Wire method: `session.mcp.oauth.handlePendingRequest`.
6654 ///
6655 /// # Parameters
6656 ///
6657 /// * `params` - Pending MCP OAuth request ID and host-provided token or cancellation response.
6658 ///
6659 /// # Returns
6660 ///
6661 /// Indicates whether the pending MCP OAuth response was accepted.
6662 ///
6663 /// <div class="warning">
6664 ///
6665 /// **Experimental.** This API is part of an experimental wire-protocol surface
6666 /// and may change or be removed in future SDK or CLI releases. Pin both the
6667 /// SDK and CLI versions if your code depends on it.
6668 ///
6669 /// </div>
6670 pub async fn handle_pending_request(
6671 &self,
6672 params: McpOauthHandlePendingRequest,
6673 ) -> Result<McpOauthHandlePendingResult, Error> {
6674 let mut wire_params = serde_json::to_value(params)?;
6675 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6676 let _value = self
6677 .session
6678 .client()
6679 .call(
6680 rpc_methods::SESSION_MCP_OAUTH_HANDLEPENDINGREQUEST,
6681 Some(wire_params),
6682 )
6683 .await?;
6684 Ok(serde_json::from_value(_value)?)
6685 }
6686
6687 /// Notifies the session that MCP OAuth authentication succeeded and updated credentials were persisted, so cached tool definitions can be refreshed.
6688 ///
6689 /// Wire method: `session.mcp.oauth.authenticationStateChanged`.
6690 ///
6691 /// # Parameters
6692 ///
6693 /// * `params` - Identifies the MCP server whose persisted OAuth credentials were updated.
6694 ///
6695 /// <div class="warning">
6696 ///
6697 /// **Experimental.** This API is part of an experimental wire-protocol surface
6698 /// and may change or be removed in future SDK or CLI releases. Pin both the
6699 /// SDK and CLI versions if your code depends on it.
6700 ///
6701 /// </div>
6702 pub async fn authentication_state_changed(
6703 &self,
6704 params: McpOauthAuthenticationStateChangedRequest,
6705 ) -> Result<(), Error> {
6706 let mut wire_params = serde_json::to_value(params)?;
6707 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6708 let _value = self
6709 .session
6710 .client()
6711 .call(
6712 rpc_methods::SESSION_MCP_OAUTH_AUTHENTICATIONSTATECHANGED,
6713 Some(wire_params),
6714 )
6715 .await?;
6716 Ok(())
6717 }
6718
6719 /// Starts OAuth authentication for a remote MCP server.
6720 ///
6721 /// Wire method: `session.mcp.oauth.login`.
6722 ///
6723 /// # Parameters
6724 ///
6725 /// * `params` - Remote MCP server name and optional overrides controlling reauthentication, OAuth client display name, callback success-page copy, and static OAuth client selection.
6726 ///
6727 /// # Returns
6728 ///
6729 /// OAuth authorization URL the caller should open, or empty when cached tokens already authenticated the server.
6730 ///
6731 /// <div class="warning">
6732 ///
6733 /// **Experimental.** This API is part of an experimental wire-protocol surface
6734 /// and may change or be removed in future SDK or CLI releases. Pin both the
6735 /// SDK and CLI versions if your code depends on it.
6736 ///
6737 /// </div>
6738 pub async fn login(&self, params: McpOauthLoginRequest) -> Result<McpOauthLoginResult, Error> {
6739 let mut wire_params = serde_json::to_value(params)?;
6740 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6741 let _value = self
6742 .session
6743 .client()
6744 .call(rpc_methods::SESSION_MCP_OAUTH_LOGIN, Some(wire_params))
6745 .await?;
6746 Ok(serde_json::from_value(_value)?)
6747 }
6748
6749 /// 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.
6750 ///
6751 /// Wire method: `session.mcp.oauth.probe`.
6752 ///
6753 /// # Parameters
6754 ///
6755 /// * `params` - Remote MCP server name for a passive OAuth status probe.
6756 ///
6757 /// # Returns
6758 ///
6759 /// 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.
6760 ///
6761 /// <div class="warning">
6762 ///
6763 /// **Experimental.** This API is part of an experimental wire-protocol surface
6764 /// and may change or be removed in future SDK or CLI releases. Pin both the
6765 /// SDK and CLI versions if your code depends on it.
6766 ///
6767 /// </div>
6768 pub async fn probe(&self, params: McpOauthProbeRequest) -> Result<McpOauthProbeResult, Error> {
6769 let mut wire_params = serde_json::to_value(params)?;
6770 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6771 let _value = self
6772 .session
6773 .client()
6774 .call(rpc_methods::SESSION_MCP_OAUTH_PROBE, Some(wire_params))
6775 .await?;
6776 Ok(serde_json::from_value(_value)?)
6777 }
6778
6779 /// Responds to a pending MCP OAuth authorization request by its request id.
6780 ///
6781 /// Wire method: `session.mcp.oauth.respond`.
6782 ///
6783 /// # Parameters
6784 ///
6785 /// * `params` - Pending MCP OAuth request id to respond to.
6786 ///
6787 /// # Returns
6788 ///
6789 /// Indicates whether the pending MCP OAuth response was accepted.
6790 ///
6791 /// <div class="warning">
6792 ///
6793 /// **Experimental.** This API is part of an experimental wire-protocol surface
6794 /// and may change or be removed in future SDK or CLI releases. Pin both the
6795 /// SDK and CLI versions if your code depends on it.
6796 ///
6797 /// </div>
6798 pub async fn respond(
6799 &self,
6800 params: McpOauthRespondRequest,
6801 ) -> Result<McpOauthRespondResult, Error> {
6802 let mut wire_params = serde_json::to_value(params)?;
6803 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6804 let _value = self
6805 .session
6806 .client()
6807 .call(rpc_methods::SESSION_MCP_OAUTH_RESPOND, Some(wire_params))
6808 .await?;
6809 Ok(serde_json::from_value(_value)?)
6810 }
6811}
6812
6813/// `session.mcp.resources.*` RPCs.
6814#[derive(Clone, Copy)]
6815pub struct SessionRpcMcpResources<'a> {
6816 pub(crate) session: &'a Session,
6817}
6818
6819impl<'a> SessionRpcMcpResources<'a> {
6820 /// Fetch an MCP resource from a connected server by URI (proxies MCP `resources/read`).
6821 ///
6822 /// Wire method: `session.mcp.resources.read`.
6823 ///
6824 /// # Parameters
6825 ///
6826 /// * `params` - MCP server and resource URI to fetch.
6827 ///
6828 /// # Returns
6829 ///
6830 /// Resource contents returned by the MCP server.
6831 ///
6832 /// <div class="warning">
6833 ///
6834 /// **Experimental.** This API is part of an experimental wire-protocol surface
6835 /// and may change or be removed in future SDK or CLI releases. Pin both the
6836 /// SDK and CLI versions if your code depends on it.
6837 ///
6838 /// </div>
6839 pub async fn read(
6840 &self,
6841 params: McpResourcesReadRequest,
6842 ) -> Result<McpResourcesReadResult, Error> {
6843 let mut wire_params = serde_json::to_value(params)?;
6844 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6845 let _value = self
6846 .session
6847 .client()
6848 .call(rpc_methods::SESSION_MCP_RESOURCES_READ, Some(wire_params))
6849 .await?;
6850 Ok(serde_json::from_value(_value)?)
6851 }
6852
6853 /// Enumerate one page of resources a connected MCP server exposes (proxies MCP `resources/list`). Pass `cursor` to continue from a prior result's `nextCursor`.
6854 ///
6855 /// Wire method: `session.mcp.resources.list`.
6856 ///
6857 /// # Parameters
6858 ///
6859 /// * `params` - MCP server whose resources to enumerate.
6860 ///
6861 /// # Returns
6862 ///
6863 /// One page of resources advertised by the named MCP server.
6864 ///
6865 /// <div class="warning">
6866 ///
6867 /// **Experimental.** This API is part of an experimental wire-protocol surface
6868 /// and may change or be removed in future SDK or CLI releases. Pin both the
6869 /// SDK and CLI versions if your code depends on it.
6870 ///
6871 /// </div>
6872 pub async fn list(
6873 &self,
6874 params: McpResourcesListRequest,
6875 ) -> Result<McpResourcesListResult, Error> {
6876 let mut wire_params = serde_json::to_value(params)?;
6877 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6878 let _value = self
6879 .session
6880 .client()
6881 .call(rpc_methods::SESSION_MCP_RESOURCES_LIST, Some(wire_params))
6882 .await?;
6883 Ok(serde_json::from_value(_value)?)
6884 }
6885
6886 /// 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`.
6887 ///
6888 /// Wire method: `session.mcp.resources.listTemplates`.
6889 ///
6890 /// # Parameters
6891 ///
6892 /// * `params` - MCP server whose resource templates to enumerate.
6893 ///
6894 /// # Returns
6895 ///
6896 /// One page of resource templates advertised by the named MCP server.
6897 ///
6898 /// <div class="warning">
6899 ///
6900 /// **Experimental.** This API is part of an experimental wire-protocol surface
6901 /// and may change or be removed in future SDK or CLI releases. Pin both the
6902 /// SDK and CLI versions if your code depends on it.
6903 ///
6904 /// </div>
6905 pub async fn list_templates(
6906 &self,
6907 params: McpResourcesListTemplatesRequest,
6908 ) -> Result<McpResourcesListTemplatesResult, Error> {
6909 let mut wire_params = serde_json::to_value(params)?;
6910 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6911 let _value = self
6912 .session
6913 .client()
6914 .call(
6915 rpc_methods::SESSION_MCP_RESOURCES_LISTTEMPLATES,
6916 Some(wire_params),
6917 )
6918 .await?;
6919 Ok(serde_json::from_value(_value)?)
6920 }
6921}
6922
6923/// `session.metadata.*` RPCs.
6924#[derive(Clone, Copy)]
6925pub struct SessionRpcMetadata<'a> {
6926 pub(crate) session: &'a Session,
6927}
6928
6929impl<'a> SessionRpcMetadata<'a> {
6930 /// Returns a snapshot of the session's identifying metadata, mode, agent, and remote info.
6931 ///
6932 /// Wire method: `session.metadata.snapshot`.
6933 ///
6934 /// # Returns
6935 ///
6936 /// Point-in-time snapshot of slow-changing session identifier and state fields
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 snapshot(&self) -> Result<SessionMetadataSnapshot, Error> {
6946 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6947 let _value = self
6948 .session
6949 .client()
6950 .call(rpc_methods::SESSION_METADATA_SNAPSHOT, Some(wire_params))
6951 .await?;
6952 Ok(serde_json::from_value(_value)?)
6953 }
6954
6955 /// Reports whether the local session is currently processing user/agent messages.
6956 ///
6957 /// Wire method: `session.metadata.isProcessing`.
6958 ///
6959 /// # Returns
6960 ///
6961 /// Indicates whether the local session is currently processing a turn or background continuation.
6962 ///
6963 /// <div class="warning">
6964 ///
6965 /// **Experimental.** This API is part of an experimental wire-protocol surface
6966 /// and may change or be removed in future SDK or CLI releases. Pin both the
6967 /// SDK and CLI versions if your code depends on it.
6968 ///
6969 /// </div>
6970 pub async fn is_processing(&self) -> Result<MetadataIsProcessingResult, Error> {
6971 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6972 let _value = self
6973 .session
6974 .client()
6975 .call(
6976 rpc_methods::SESSION_METADATA_ISPROCESSING,
6977 Some(wire_params),
6978 )
6979 .await?;
6980 Ok(serde_json::from_value(_value)?)
6981 }
6982
6983 /// Returns a snapshot of activity flags for the session.
6984 ///
6985 /// Wire method: `session.metadata.activity`.
6986 ///
6987 /// # Returns
6988 ///
6989 /// Current activity flags for the session.
6990 ///
6991 /// <div class="warning">
6992 ///
6993 /// **Experimental.** This API is part of an experimental wire-protocol surface
6994 /// and may change or be removed in future SDK or CLI releases. Pin both the
6995 /// SDK and CLI versions if your code depends on it.
6996 ///
6997 /// </div>
6998 pub async fn activity(&self) -> Result<SessionActivity, Error> {
6999 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7000 let _value = self
7001 .session
7002 .client()
7003 .call(rpc_methods::SESSION_METADATA_ACTIVITY, Some(wire_params))
7004 .await?;
7005 Ok(serde_json::from_value(_value)?)
7006 }
7007
7008 /// Returns the token breakdown for the session's current context window for a given model.
7009 ///
7010 /// Wire method: `session.metadata.contextInfo`.
7011 ///
7012 /// # Parameters
7013 ///
7014 /// * `params` - Model identifier and token limits used to compute the context-info breakdown.
7015 ///
7016 /// # Returns
7017 ///
7018 /// Token breakdown for the session's current context window, or null if uninitialized.
7019 ///
7020 /// <div class="warning">
7021 ///
7022 /// **Experimental.** This API is part of an experimental wire-protocol surface
7023 /// and may change or be removed in future SDK or CLI releases. Pin both the
7024 /// SDK and CLI versions if your code depends on it.
7025 ///
7026 /// </div>
7027 pub async fn context_info(
7028 &self,
7029 params: MetadataContextInfoRequest,
7030 ) -> Result<MetadataContextInfoResult, Error> {
7031 let mut wire_params = serde_json::to_value(params)?;
7032 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7033 let _value = self
7034 .session
7035 .client()
7036 .call(rpc_methods::SESSION_METADATA_CONTEXTINFO, Some(wire_params))
7037 .await?;
7038 Ok(serde_json::from_value(_value)?)
7039 }
7040
7041 /// 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.
7042 ///
7043 /// Wire method: `session.metadata.getContextAttribution`.
7044 ///
7045 /// # Returns
7046 ///
7047 /// Per-source attribution breakdown for the session's current context window, or null if uninitialized.
7048 ///
7049 /// <div class="warning">
7050 ///
7051 /// **Experimental.** This API is part of an experimental wire-protocol surface
7052 /// and may change or be removed in future SDK or CLI releases. Pin both the
7053 /// SDK and CLI versions if your code depends on it.
7054 ///
7055 /// </div>
7056 pub async fn get_context_attribution(&self) -> Result<MetadataContextAttributionResult, Error> {
7057 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7058 let _value = self
7059 .session
7060 .client()
7061 .call(
7062 rpc_methods::SESSION_METADATA_GETCONTEXTATTRIBUTION,
7063 Some(wire_params),
7064 )
7065 .await?;
7066 Ok(serde_json::from_value(_value)?)
7067 }
7068
7069 /// 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.
7070 ///
7071 /// Wire method: `session.metadata.getContextHeaviestMessages`.
7072 ///
7073 /// # Parameters
7074 ///
7075 /// * `params` - Parameters for the heaviest-messages query.
7076 ///
7077 /// # Returns
7078 ///
7079 /// The heaviest individual messages in the session's context window, most-expensive first.
7080 ///
7081 /// <div class="warning">
7082 ///
7083 /// **Experimental.** This API is part of an experimental wire-protocol surface
7084 /// and may change or be removed in future SDK or CLI releases. Pin both the
7085 /// SDK and CLI versions if your code depends on it.
7086 ///
7087 /// </div>
7088 pub async fn get_context_heaviest_messages(
7089 &self,
7090 params: MetadataContextHeaviestMessagesRequest,
7091 ) -> Result<MetadataContextHeaviestMessagesResult, Error> {
7092 let mut wire_params = serde_json::to_value(params)?;
7093 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7094 let _value = self
7095 .session
7096 .client()
7097 .call(
7098 rpc_methods::SESSION_METADATA_GETCONTEXTHEAVIESTMESSAGES,
7099 Some(wire_params),
7100 )
7101 .await?;
7102 Ok(serde_json::from_value(_value)?)
7103 }
7104
7105 /// 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.
7106 ///
7107 /// Wire method: `session.metadata.recordContextChange`.
7108 ///
7109 /// # Parameters
7110 ///
7111 /// * `params` - Updated working-directory/git context to record on the session.
7112 ///
7113 /// # Returns
7114 ///
7115 /// 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.
7116 ///
7117 /// <div class="warning">
7118 ///
7119 /// **Experimental.** This API is part of an experimental wire-protocol surface
7120 /// and may change or be removed in future SDK or CLI releases. Pin both the
7121 /// SDK and CLI versions if your code depends on it.
7122 ///
7123 /// </div>
7124 pub async fn record_context_change(
7125 &self,
7126 params: MetadataRecordContextChangeRequest,
7127 ) -> Result<MetadataRecordContextChangeResult, Error> {
7128 let mut wire_params = serde_json::to_value(params)?;
7129 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7130 let _value = self
7131 .session
7132 .client()
7133 .call(
7134 rpc_methods::SESSION_METADATA_RECORDCONTEXTCHANGE,
7135 Some(wire_params),
7136 )
7137 .await?;
7138 Ok(serde_json::from_value(_value)?)
7139 }
7140
7141 /// 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.
7142 ///
7143 /// Wire method: `session.metadata.setWorkingDirectory`.
7144 ///
7145 /// # Parameters
7146 ///
7147 /// * `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.
7148 ///
7149 /// # Returns
7150 ///
7151 /// 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.
7152 ///
7153 /// <div class="warning">
7154 ///
7155 /// **Experimental.** This API is part of an experimental wire-protocol surface
7156 /// and may change or be removed in future SDK or CLI releases. Pin both the
7157 /// SDK and CLI versions if your code depends on it.
7158 ///
7159 /// </div>
7160 pub async fn set_working_directory(
7161 &self,
7162 params: MetadataSetWorkingDirectoryRequest,
7163 ) -> Result<MetadataSetWorkingDirectoryResult, Error> {
7164 let mut wire_params = serde_json::to_value(params)?;
7165 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7166 let _value = self
7167 .session
7168 .client()
7169 .call(
7170 rpc_methods::SESSION_METADATA_SETWORKINGDIRECTORY,
7171 Some(wire_params),
7172 )
7173 .await?;
7174 Ok(serde_json::from_value(_value)?)
7175 }
7176
7177 /// Re-tokenizes the session's existing messages against a model and returns aggregate token totals.
7178 ///
7179 /// Wire method: `session.metadata.recomputeContextTokens`.
7180 ///
7181 /// # Parameters
7182 ///
7183 /// * `params` - Model identifier to use when re-tokenizing the session's existing messages.
7184 ///
7185 /// # Returns
7186 ///
7187 /// 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.
7188 ///
7189 /// <div class="warning">
7190 ///
7191 /// **Experimental.** This API is part of an experimental wire-protocol surface
7192 /// and may change or be removed in future SDK or CLI releases. Pin both the
7193 /// SDK and CLI versions if your code depends on it.
7194 ///
7195 /// </div>
7196 pub async fn recompute_context_tokens(
7197 &self,
7198 params: MetadataRecomputeContextTokensRequest,
7199 ) -> Result<MetadataRecomputeContextTokensResult, Error> {
7200 let mut wire_params = serde_json::to_value(params)?;
7201 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7202 let _value = self
7203 .session
7204 .client()
7205 .call(
7206 rpc_methods::SESSION_METADATA_RECOMPUTECONTEXTTOKENS,
7207 Some(wire_params),
7208 )
7209 .await?;
7210 Ok(serde_json::from_value(_value)?)
7211 }
7212}
7213
7214/// `session.mode.*` RPCs.
7215#[derive(Clone, Copy)]
7216pub struct SessionRpcMode<'a> {
7217 pub(crate) session: &'a Session,
7218}
7219
7220impl<'a> SessionRpcMode<'a> {
7221 /// Gets the current agent interaction mode.
7222 ///
7223 /// Wire method: `session.mode.get`.
7224 ///
7225 /// # Returns
7226 ///
7227 /// The session mode the agent is operating in
7228 ///
7229 /// <div class="warning">
7230 ///
7231 /// **Experimental.** This API is part of an experimental wire-protocol surface
7232 /// and may change or be removed in future SDK or CLI releases. Pin both the
7233 /// SDK and CLI versions if your code depends on it.
7234 ///
7235 /// </div>
7236 pub async fn get(&self) -> Result<SessionMode, Error> {
7237 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7238 let _value = self
7239 .session
7240 .client()
7241 .call(rpc_methods::SESSION_MODE_GET, Some(wire_params))
7242 .await?;
7243 Ok(serde_json::from_value(_value)?)
7244 }
7245
7246 /// Sets the current agent interaction mode.
7247 ///
7248 /// Wire method: `session.mode.set`.
7249 ///
7250 /// # Parameters
7251 ///
7252 /// * `params` - Agent interaction mode to apply to the session.
7253 ///
7254 /// # Returns
7255 ///
7256 /// Outcome of a session mode change, including any model switch it triggered and follow-up the host must perform.
7257 ///
7258 /// <div class="warning">
7259 ///
7260 /// **Experimental.** This API is part of an experimental wire-protocol surface
7261 /// and may change or be removed in future SDK or CLI releases. Pin both the
7262 /// SDK and CLI versions if your code depends on it.
7263 ///
7264 /// </div>
7265 pub async fn set(&self, params: ModeSetRequest) -> Result<ModeSetResult, Error> {
7266 let mut wire_params = serde_json::to_value(params)?;
7267 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7268 let _value = self
7269 .session
7270 .client()
7271 .call(rpc_methods::SESSION_MODE_SET, Some(wire_params))
7272 .await?;
7273 Ok(serde_json::from_value(_value)?)
7274 }
7275}
7276
7277/// `session.model.*` RPCs.
7278#[derive(Clone, Copy)]
7279pub struct SessionRpcModel<'a> {
7280 pub(crate) session: &'a Session,
7281}
7282
7283impl<'a> SessionRpcModel<'a> {
7284 /// Gets the currently selected model for the session.
7285 ///
7286 /// Wire method: `session.model.getCurrent`.
7287 ///
7288 /// # Returns
7289 ///
7290 /// The currently selected model, reasoning effort, and context tier for the session. The context tier reflects `Session.getContextTier()`, restored from the session journal on resume.
7291 ///
7292 /// <div class="warning">
7293 ///
7294 /// **Experimental.** This API is part of an experimental wire-protocol surface
7295 /// and may change or be removed in future SDK or CLI releases. Pin both the
7296 /// SDK and CLI versions if your code depends on it.
7297 ///
7298 /// </div>
7299 pub async fn get_current(&self) -> Result<CurrentModel, Error> {
7300 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7301 let _value = self
7302 .session
7303 .client()
7304 .call(rpc_methods::SESSION_MODEL_GETCURRENT, Some(wire_params))
7305 .await?;
7306 Ok(serde_json::from_value(_value)?)
7307 }
7308
7309 /// Switches the session to a model and optional reasoning configuration.
7310 ///
7311 /// Wire method: `session.model.switchTo`.
7312 ///
7313 /// # Parameters
7314 ///
7315 /// * `params` - Target model identifier and optional reasoning effort, summary, capability overrides, and context tier.
7316 ///
7317 /// # Returns
7318 ///
7319 /// The model identifier active on the session after the switch.
7320 ///
7321 /// <div class="warning">
7322 ///
7323 /// **Experimental.** This API is part of an experimental wire-protocol surface
7324 /// and may change or be removed in future SDK or CLI releases. Pin both the
7325 /// SDK and CLI versions if your code depends on it.
7326 ///
7327 /// </div>
7328 pub async fn switch_to(
7329 &self,
7330 params: ModelSwitchToRequest,
7331 ) -> Result<ModelSwitchToResult, Error> {
7332 let mut wire_params = serde_json::to_value(params)?;
7333 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7334 let _value = self
7335 .session
7336 .client()
7337 .call(rpc_methods::SESSION_MODEL_SWITCHTO, Some(wire_params))
7338 .await?;
7339 Ok(serde_json::from_value(_value)?)
7340 }
7341
7342 /// Resolves and applies organization-managed and repository model overlays.
7343 ///
7344 /// Wire method: `session.model.applyStartupOverlay`.
7345 ///
7346 /// # Parameters
7347 ///
7348 /// * `params` - Managed, repository, and CLI model overrides to overlay onto the session at startup.
7349 ///
7350 /// # Returns
7351 ///
7352 /// The model identifier active on the session after the switch.
7353 ///
7354 /// <div class="warning">
7355 ///
7356 /// **Experimental.** This API is part of an experimental wire-protocol surface
7357 /// and may change or be removed in future SDK or CLI releases. Pin both the
7358 /// SDK and CLI versions if your code depends on it.
7359 ///
7360 /// </div>
7361 pub(crate) async fn apply_startup_overlay(
7362 &self,
7363 params: ModelApplyStartupOverlayRequest,
7364 ) -> Result<ModelSwitchToResult, Error> {
7365 let mut wire_params = serde_json::to_value(params)?;
7366 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7367 let _value = self
7368 .session
7369 .client()
7370 .call(
7371 rpc_methods::SESSION_MODEL_APPLYSTARTUPOVERLAY,
7372 Some(wire_params),
7373 )
7374 .await?;
7375 Ok(serde_json::from_value(_value)?)
7376 }
7377
7378 /// Updates the session's reasoning effort without changing the selected model.
7379 ///
7380 /// Wire method: `session.model.setReasoningEffort`.
7381 ///
7382 /// # Parameters
7383 ///
7384 /// * `params` - Reasoning effort level to apply to the currently selected model.
7385 ///
7386 /// # Returns
7387 ///
7388 /// 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.
7389 ///
7390 /// <div class="warning">
7391 ///
7392 /// **Experimental.** This API is part of an experimental wire-protocol surface
7393 /// and may change or be removed in future SDK or CLI releases. Pin both the
7394 /// SDK and CLI versions if your code depends on it.
7395 ///
7396 /// </div>
7397 pub async fn set_reasoning_effort(
7398 &self,
7399 params: ModelSetReasoningEffortRequest,
7400 ) -> Result<ModelSetReasoningEffortResult, Error> {
7401 let mut wire_params = serde_json::to_value(params)?;
7402 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7403 let _value = self
7404 .session
7405 .client()
7406 .call(
7407 rpc_methods::SESSION_MODEL_SETREASONINGEFFORT,
7408 Some(wire_params),
7409 )
7410 .await?;
7411 Ok(serde_json::from_value(_value)?)
7412 }
7413
7414 /// 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.
7415 ///
7416 /// Wire method: `session.model.list`.
7417 ///
7418 /// # Returns
7419 ///
7420 /// The list of models available to this session.
7421 ///
7422 /// <div class="warning">
7423 ///
7424 /// **Experimental.** This API is part of an experimental wire-protocol surface
7425 /// and may change or be removed in future SDK or CLI releases. Pin both the
7426 /// SDK and CLI versions if your code depends on it.
7427 ///
7428 /// </div>
7429 pub async fn list(&self) -> Result<SessionModelList, Error> {
7430 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7431 let _value = self
7432 .session
7433 .client()
7434 .call(rpc_methods::SESSION_MODEL_LIST, Some(wire_params))
7435 .await?;
7436 Ok(serde_json::from_value(_value)?)
7437 }
7438
7439 /// 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.
7440 ///
7441 /// Wire method: `session.model.list`.
7442 ///
7443 /// # Parameters
7444 ///
7445 /// * `params` - Optional listing options.
7446 ///
7447 /// # Returns
7448 ///
7449 /// The list of models available to this session.
7450 ///
7451 /// <div class="warning">
7452 ///
7453 /// **Experimental.** This API is part of an experimental wire-protocol surface
7454 /// and may change or be removed in future SDK or CLI releases. Pin both the
7455 /// SDK and CLI versions if your code depends on it.
7456 ///
7457 /// </div>
7458 pub async fn list_with_params(
7459 &self,
7460 params: ModelListRequest,
7461 ) -> Result<SessionModelList, Error> {
7462 let mut wire_params = serde_json::to_value(params)?;
7463 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7464 let _value = self
7465 .session
7466 .client()
7467 .call(rpc_methods::SESSION_MODEL_LIST, Some(wire_params))
7468 .await?;
7469 Ok(serde_json::from_value(_value)?)
7470 }
7471}
7472
7473/// `session.name.*` RPCs.
7474#[derive(Clone, Copy)]
7475pub struct SessionRpcName<'a> {
7476 pub(crate) session: &'a Session,
7477}
7478
7479impl<'a> SessionRpcName<'a> {
7480 /// Gets the session's friendly name.
7481 ///
7482 /// Wire method: `session.name.get`.
7483 ///
7484 /// # Returns
7485 ///
7486 /// The session's friendly name, or null when not yet set.
7487 ///
7488 /// <div class="warning">
7489 ///
7490 /// **Experimental.** This API is part of an experimental wire-protocol surface
7491 /// and may change or be removed in future SDK or CLI releases. Pin both the
7492 /// SDK and CLI versions if your code depends on it.
7493 ///
7494 /// </div>
7495 pub async fn get(&self) -> Result<NameGetResult, Error> {
7496 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7497 let _value = self
7498 .session
7499 .client()
7500 .call(rpc_methods::SESSION_NAME_GET, Some(wire_params))
7501 .await?;
7502 Ok(serde_json::from_value(_value)?)
7503 }
7504
7505 /// Sets the session's friendly name.
7506 ///
7507 /// Wire method: `session.name.set`.
7508 ///
7509 /// # Parameters
7510 ///
7511 /// * `params` - New friendly name to apply to the session.
7512 ///
7513 /// <div class="warning">
7514 ///
7515 /// **Experimental.** This API is part of an experimental wire-protocol surface
7516 /// and may change or be removed in future SDK or CLI releases. Pin both the
7517 /// SDK and CLI versions if your code depends on it.
7518 ///
7519 /// </div>
7520 pub async fn set(&self, params: NameSetRequest) -> Result<(), Error> {
7521 let mut wire_params = serde_json::to_value(params)?;
7522 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7523 let _value = self
7524 .session
7525 .client()
7526 .call(rpc_methods::SESSION_NAME_SET, Some(wire_params))
7527 .await?;
7528 Ok(())
7529 }
7530
7531 /// Persists an auto-generated session summary as the session's name when no user-set name exists.
7532 ///
7533 /// Wire method: `session.name.setAuto`.
7534 ///
7535 /// # Parameters
7536 ///
7537 /// * `params` - Auto-generated session summary to apply as the session's name when no user-set name exists.
7538 ///
7539 /// # Returns
7540 ///
7541 /// Indicates whether the auto-generated summary was applied as the session's name.
7542 ///
7543 /// <div class="warning">
7544 ///
7545 /// **Experimental.** This API is part of an experimental wire-protocol surface
7546 /// and may change or be removed in future SDK or CLI releases. Pin both the
7547 /// SDK and CLI versions if your code depends on it.
7548 ///
7549 /// </div>
7550 pub async fn set_auto(&self, params: NameSetAutoRequest) -> Result<NameSetAutoResult, Error> {
7551 let mut wire_params = serde_json::to_value(params)?;
7552 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7553 let _value = self
7554 .session
7555 .client()
7556 .call(rpc_methods::SESSION_NAME_SETAUTO, Some(wire_params))
7557 .await?;
7558 Ok(serde_json::from_value(_value)?)
7559 }
7560}
7561
7562/// `session.options.*` RPCs.
7563#[derive(Clone, Copy)]
7564pub struct SessionRpcOptions<'a> {
7565 pub(crate) session: &'a Session,
7566}
7567
7568impl<'a> SessionRpcOptions<'a> {
7569 /// Patches the genuinely-mutable subset of session options.
7570 ///
7571 /// Wire method: `session.options.update`.
7572 ///
7573 /// # Parameters
7574 ///
7575 /// * `params` - Patch of mutable session options to apply to the running session.
7576 ///
7577 /// # Returns
7578 ///
7579 /// Indicates whether the session options patch was applied successfully.
7580 ///
7581 /// <div class="warning">
7582 ///
7583 /// **Experimental.** This API is part of an experimental wire-protocol surface
7584 /// and may change or be removed in future SDK or CLI releases. Pin both the
7585 /// SDK and CLI versions if your code depends on it.
7586 ///
7587 /// </div>
7588 pub async fn update(
7589 &self,
7590 params: SessionUpdateOptionsParams,
7591 ) -> Result<SessionUpdateOptionsResult, Error> {
7592 let mut wire_params = serde_json::to_value(params)?;
7593 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7594 let _value = self
7595 .session
7596 .client()
7597 .call(rpc_methods::SESSION_OPTIONS_UPDATE, Some(wire_params))
7598 .await?;
7599 Ok(serde_json::from_value(_value)?)
7600 }
7601}
7602
7603/// `session.permissions.*` RPCs.
7604#[derive(Clone, Copy)]
7605pub struct SessionRpcPermissions<'a> {
7606 pub(crate) session: &'a Session,
7607}
7608
7609impl<'a> SessionRpcPermissions<'a> {
7610 /// `session.permissions.folderTrust.*` sub-namespace.
7611 pub fn folder_trust(&self) -> SessionRpcPermissionsFolderTrust<'a> {
7612 SessionRpcPermissionsFolderTrust {
7613 session: self.session,
7614 }
7615 }
7616
7617 /// `session.permissions.locations.*` sub-namespace.
7618 pub fn locations(&self) -> SessionRpcPermissionsLocations<'a> {
7619 SessionRpcPermissionsLocations {
7620 session: self.session,
7621 }
7622 }
7623
7624 /// `session.permissions.paths.*` sub-namespace.
7625 pub fn paths(&self) -> SessionRpcPermissionsPaths<'a> {
7626 SessionRpcPermissionsPaths {
7627 session: self.session,
7628 }
7629 }
7630
7631 /// `session.permissions.urls.*` sub-namespace.
7632 pub fn urls(&self) -> SessionRpcPermissionsUrls<'a> {
7633 SessionRpcPermissionsUrls {
7634 session: self.session,
7635 }
7636 }
7637
7638 /// Replaces selected permission policy fields (rules, paths, URLs, exclusions, allow-all flags) on the session.
7639 ///
7640 /// Wire method: `session.permissions.configure`.
7641 ///
7642 /// # Parameters
7643 ///
7644 /// * `params` - Patch of permission policy fields to apply (omit a field to leave it unchanged).
7645 ///
7646 /// # Returns
7647 ///
7648 /// Indicates whether the operation succeeded.
7649 ///
7650 /// <div class="warning">
7651 ///
7652 /// **Experimental.** This API is part of an experimental wire-protocol surface
7653 /// and may change or be removed in future SDK or CLI releases. Pin both the
7654 /// SDK and CLI versions if your code depends on it.
7655 ///
7656 /// </div>
7657 pub async fn configure(
7658 &self,
7659 params: PermissionsConfigureParams,
7660 ) -> Result<PermissionsConfigureResult, Error> {
7661 let mut wire_params = serde_json::to_value(params)?;
7662 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7663 let _value = self
7664 .session
7665 .client()
7666 .call(
7667 rpc_methods::SESSION_PERMISSIONS_CONFIGURE,
7668 Some(wire_params),
7669 )
7670 .await?;
7671 Ok(serde_json::from_value(_value)?)
7672 }
7673
7674 /// Provides a decision for a pending tool permission request.
7675 ///
7676 /// Wire method: `session.permissions.handlePendingPermissionRequest`.
7677 ///
7678 /// # Parameters
7679 ///
7680 /// * `params` - Pending permission request ID and the decision to apply (approve/reject and scope).
7681 ///
7682 /// # Returns
7683 ///
7684 /// Indicates whether the permission decision was applied; false when the request was already resolved.
7685 ///
7686 /// <div class="warning">
7687 ///
7688 /// **Experimental.** This API is part of an experimental wire-protocol surface
7689 /// and may change or be removed in future SDK or CLI releases. Pin both the
7690 /// SDK and CLI versions if your code depends on it.
7691 ///
7692 /// </div>
7693 pub async fn handle_pending_permission_request(
7694 &self,
7695 params: PermissionDecisionRequest,
7696 ) -> Result<PermissionRequestResult, Error> {
7697 let mut wire_params = serde_json::to_value(params)?;
7698 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7699 let _value = self
7700 .session
7701 .client()
7702 .call(
7703 rpc_methods::SESSION_PERMISSIONS_HANDLEPENDINGPERMISSIONREQUEST,
7704 Some(wire_params),
7705 )
7706 .await?;
7707 Ok(serde_json::from_value(_value)?)
7708 }
7709
7710 /// Reconstructs the set of pending tool permission requests from the session's event history.
7711 ///
7712 /// Wire method: `session.permissions.pendingRequests`.
7713 ///
7714 /// # Returns
7715 ///
7716 /// List of pending permission requests reconstructed from event history.
7717 ///
7718 /// <div class="warning">
7719 ///
7720 /// **Experimental.** This API is part of an experimental wire-protocol surface
7721 /// and may change or be removed in future SDK or CLI releases. Pin both the
7722 /// SDK and CLI versions if your code depends on it.
7723 ///
7724 /// </div>
7725 pub async fn pending_requests(&self) -> Result<PendingPermissionRequestList, Error> {
7726 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7727 let _value = self
7728 .session
7729 .client()
7730 .call(
7731 rpc_methods::SESSION_PERMISSIONS_PENDINGREQUESTS,
7732 Some(wire_params),
7733 )
7734 .await?;
7735 Ok(serde_json::from_value(_value)?)
7736 }
7737
7738 /// Enables or disables automatic approval of tool permission requests for the session.
7739 ///
7740 /// Wire method: `session.permissions.setApproveAll`.
7741 ///
7742 /// # Parameters
7743 ///
7744 /// * `params` - Allow-all toggle for tool permission requests, with an optional telemetry source.
7745 ///
7746 /// # Returns
7747 ///
7748 /// Indicates whether the operation succeeded.
7749 ///
7750 /// <div class="warning">
7751 ///
7752 /// **Experimental.** This API is part of an experimental wire-protocol surface
7753 /// and may change or be removed in future SDK or CLI releases. Pin both the
7754 /// SDK and CLI versions if your code depends on it.
7755 ///
7756 /// </div>
7757 pub async fn set_approve_all(
7758 &self,
7759 params: PermissionsSetApproveAllRequest,
7760 ) -> Result<PermissionsSetApproveAllResult, Error> {
7761 let mut wire_params = serde_json::to_value(params)?;
7762 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7763 let _value = self
7764 .session
7765 .client()
7766 .call(
7767 rpc_methods::SESSION_PERMISSIONS_SETAPPROVEALL,
7768 Some(wire_params),
7769 )
7770 .await?;
7771 Ok(serde_json::from_value(_value)?)
7772 }
7773
7774 /// 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.
7775 ///
7776 /// Wire method: `session.permissions.setMode`.
7777 ///
7778 /// # Parameters
7779 ///
7780 /// * `params` - Permission mode to apply for the session.
7781 ///
7782 /// # Returns
7783 ///
7784 /// Indicates whether the requested permission mode was applied and reports the authoritative post-mutation mode.
7785 ///
7786 /// <div class="warning">
7787 ///
7788 /// **Experimental.** This API is part of an experimental wire-protocol surface
7789 /// and may change or be removed in future SDK or CLI releases. Pin both the
7790 /// SDK and CLI versions if your code depends on it.
7791 ///
7792 /// </div>
7793 pub async fn set_mode(
7794 &self,
7795 params: PermissionsSetModeRequest,
7796 ) -> Result<PermissionsSetModeResult, Error> {
7797 let mut wire_params = serde_json::to_value(params)?;
7798 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7799 let _value = self
7800 .session
7801 .client()
7802 .call(rpc_methods::SESSION_PERMISSIONS_SETMODE, Some(wire_params))
7803 .await?;
7804 Ok(serde_json::from_value(_value)?)
7805 }
7806
7807 /// Returns the current permission mode for the session.
7808 ///
7809 /// Wire method: `session.permissions.getMode`.
7810 ///
7811 /// # Returns
7812 ///
7813 /// Current permission mode.
7814 ///
7815 /// <div class="warning">
7816 ///
7817 /// **Experimental.** This API is part of an experimental wire-protocol surface
7818 /// and may change or be removed in future SDK or CLI releases. Pin both the
7819 /// SDK and CLI versions if your code depends on it.
7820 ///
7821 /// </div>
7822 pub async fn get_mode(&self) -> Result<PermissionsGetModeResult, Error> {
7823 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7824 let _value = self
7825 .session
7826 .client()
7827 .call(rpc_methods::SESSION_PERMISSIONS_GETMODE, Some(wire_params))
7828 .await?;
7829 Ok(serde_json::from_value(_value)?)
7830 }
7831
7832 /// Adds or removes session-scoped or location-scoped permission rules.
7833 ///
7834 /// Wire method: `session.permissions.modifyRules`.
7835 ///
7836 /// # Parameters
7837 ///
7838 /// * `params` - Scope and add/remove instructions for modifying session- or location-scoped permission rules.
7839 ///
7840 /// # Returns
7841 ///
7842 /// Indicates whether the operation succeeded.
7843 ///
7844 /// <div class="warning">
7845 ///
7846 /// **Experimental.** This API is part of an experimental wire-protocol surface
7847 /// and may change or be removed in future SDK or CLI releases. Pin both the
7848 /// SDK and CLI versions if your code depends on it.
7849 ///
7850 /// </div>
7851 pub async fn modify_rules(
7852 &self,
7853 params: PermissionsModifyRulesParams,
7854 ) -> Result<PermissionsModifyRulesResult, Error> {
7855 let mut wire_params = serde_json::to_value(params)?;
7856 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7857 let _value = self
7858 .session
7859 .client()
7860 .call(
7861 rpc_methods::SESSION_PERMISSIONS_MODIFYRULES,
7862 Some(wire_params),
7863 )
7864 .await?;
7865 Ok(serde_json::from_value(_value)?)
7866 }
7867
7868 /// Sets whether the client wants permission prompts bridged into session events.
7869 ///
7870 /// Wire method: `session.permissions.setRequired`.
7871 ///
7872 /// # Parameters
7873 ///
7874 /// * `params` - Toggles whether permission prompts should be bridged into session events for this client.
7875 ///
7876 /// # Returns
7877 ///
7878 /// Indicates whether the operation succeeded.
7879 ///
7880 /// <div class="warning">
7881 ///
7882 /// **Experimental.** This API is part of an experimental wire-protocol surface
7883 /// and may change or be removed in future SDK or CLI releases. Pin both the
7884 /// SDK and CLI versions if your code depends on it.
7885 ///
7886 /// </div>
7887 pub async fn set_required(
7888 &self,
7889 params: PermissionsSetRequiredRequest,
7890 ) -> Result<PermissionsSetRequiredResult, Error> {
7891 let mut wire_params = serde_json::to_value(params)?;
7892 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7893 let _value = self
7894 .session
7895 .client()
7896 .call(
7897 rpc_methods::SESSION_PERMISSIONS_SETREQUIRED,
7898 Some(wire_params),
7899 )
7900 .await?;
7901 Ok(serde_json::from_value(_value)?)
7902 }
7903
7904 /// Clears session-scoped tool permission approvals.
7905 ///
7906 /// Wire method: `session.permissions.resetSessionApprovals`.
7907 ///
7908 /// # Parameters
7909 ///
7910 /// * `params` - Clears session-scoped tool permission approvals, and optionally the location-scoped ones.
7911 ///
7912 /// # Returns
7913 ///
7914 /// Indicates whether the operation succeeded.
7915 ///
7916 /// <div class="warning">
7917 ///
7918 /// **Experimental.** This API is part of an experimental wire-protocol surface
7919 /// and may change or be removed in future SDK or CLI releases. Pin both the
7920 /// SDK and CLI versions if your code depends on it.
7921 ///
7922 /// </div>
7923 pub async fn reset_session_approvals(
7924 &self,
7925 params: PermissionsResetSessionApprovalsRequest,
7926 ) -> Result<PermissionsResetSessionApprovalsResult, Error> {
7927 let mut wire_params = serde_json::to_value(params)?;
7928 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7929 let _value = self
7930 .session
7931 .client()
7932 .call(
7933 rpc_methods::SESSION_PERMISSIONS_RESETSESSIONAPPROVALS,
7934 Some(wire_params),
7935 )
7936 .await?;
7937 Ok(serde_json::from_value(_value)?)
7938 }
7939
7940 /// Notifies the runtime that a permission prompt UI has been shown to the user.
7941 ///
7942 /// Wire method: `session.permissions.notifyPromptShown`.
7943 ///
7944 /// # Parameters
7945 ///
7946 /// * `params` - Notification payload describing the permission prompt that the client just rendered.
7947 ///
7948 /// # Returns
7949 ///
7950 /// Indicates whether the operation succeeded.
7951 ///
7952 /// <div class="warning">
7953 ///
7954 /// **Experimental.** This API is part of an experimental wire-protocol surface
7955 /// and may change or be removed in future SDK or CLI releases. Pin both the
7956 /// SDK and CLI versions if your code depends on it.
7957 ///
7958 /// </div>
7959 pub async fn notify_prompt_shown(
7960 &self,
7961 params: PermissionPromptShownNotification,
7962 ) -> Result<PermissionsNotifyPromptShownResult, Error> {
7963 let mut wire_params = serde_json::to_value(params)?;
7964 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7965 let _value = self
7966 .session
7967 .client()
7968 .call(
7969 rpc_methods::SESSION_PERMISSIONS_NOTIFYPROMPTSHOWN,
7970 Some(wire_params),
7971 )
7972 .await?;
7973 Ok(serde_json::from_value(_value)?)
7974 }
7975}
7976
7977/// `session.permissions.folderTrust.*` RPCs.
7978#[derive(Clone, Copy)]
7979pub struct SessionRpcPermissionsFolderTrust<'a> {
7980 pub(crate) session: &'a Session,
7981}
7982
7983impl<'a> SessionRpcPermissionsFolderTrust<'a> {
7984 /// Reports whether a folder is trusted according to the user's folder trust state.
7985 ///
7986 /// Wire method: `session.permissions.folderTrust.isTrusted`.
7987 ///
7988 /// # Parameters
7989 ///
7990 /// * `params` - Folder path to check for trust.
7991 ///
7992 /// # Returns
7993 ///
7994 /// Folder trust check result.
7995 ///
7996 /// <div class="warning">
7997 ///
7998 /// **Experimental.** This API is part of an experimental wire-protocol surface
7999 /// and may change or be removed in future SDK or CLI releases. Pin both the
8000 /// SDK and CLI versions if your code depends on it.
8001 ///
8002 /// </div>
8003 pub async fn is_trusted(
8004 &self,
8005 params: FolderTrustCheckParams,
8006 ) -> Result<FolderTrustCheckResult, Error> {
8007 let mut wire_params = serde_json::to_value(params)?;
8008 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8009 let _value = self
8010 .session
8011 .client()
8012 .call(
8013 rpc_methods::SESSION_PERMISSIONS_FOLDERTRUST_ISTRUSTED,
8014 Some(wire_params),
8015 )
8016 .await?;
8017 Ok(serde_json::from_value(_value)?)
8018 }
8019
8020 /// Adds a folder to the user's trusted folders list.
8021 ///
8022 /// Wire method: `session.permissions.folderTrust.addTrusted`.
8023 ///
8024 /// # Parameters
8025 ///
8026 /// * `params` - Folder path to add to trusted folders.
8027 ///
8028 /// # Returns
8029 ///
8030 /// Indicates whether the operation succeeded.
8031 ///
8032 /// <div class="warning">
8033 ///
8034 /// **Experimental.** This API is part of an experimental wire-protocol surface
8035 /// and may change or be removed in future SDK or CLI releases. Pin both the
8036 /// SDK and CLI versions if your code depends on it.
8037 ///
8038 /// </div>
8039 pub async fn add_trusted(
8040 &self,
8041 params: FolderTrustAddParams,
8042 ) -> Result<PermissionsFolderTrustAddTrustedResult, Error> {
8043 let mut wire_params = serde_json::to_value(params)?;
8044 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8045 let _value = self
8046 .session
8047 .client()
8048 .call(
8049 rpc_methods::SESSION_PERMISSIONS_FOLDERTRUST_ADDTRUSTED,
8050 Some(wire_params),
8051 )
8052 .await?;
8053 Ok(serde_json::from_value(_value)?)
8054 }
8055}
8056
8057/// `session.permissions.locations.*` RPCs.
8058#[derive(Clone, Copy)]
8059pub struct SessionRpcPermissionsLocations<'a> {
8060 pub(crate) session: &'a Session,
8061}
8062
8063impl<'a> SessionRpcPermissionsLocations<'a> {
8064 /// Resolves the permission location key and type for a working directory.
8065 ///
8066 /// Wire method: `session.permissions.locations.resolve`.
8067 ///
8068 /// # Parameters
8069 ///
8070 /// * `params` - Working directory to resolve into a location-permissions key.
8071 ///
8072 /// # Returns
8073 ///
8074 /// Resolved location-permissions key and type.
8075 ///
8076 /// <div class="warning">
8077 ///
8078 /// **Experimental.** This API is part of an experimental wire-protocol surface
8079 /// and may change or be removed in future SDK or CLI releases. Pin both the
8080 /// SDK and CLI versions if your code depends on it.
8081 ///
8082 /// </div>
8083 pub async fn resolve(
8084 &self,
8085 params: PermissionLocationResolveParams,
8086 ) -> Result<PermissionLocationResolveResult, Error> {
8087 let mut wire_params = serde_json::to_value(params)?;
8088 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8089 let _value = self
8090 .session
8091 .client()
8092 .call(
8093 rpc_methods::SESSION_PERMISSIONS_LOCATIONS_RESOLVE,
8094 Some(wire_params),
8095 )
8096 .await?;
8097 Ok(serde_json::from_value(_value)?)
8098 }
8099
8100 /// Applies persisted location-scoped tool approvals and allowed directories for a working directory to this session's permission service.
8101 ///
8102 /// Wire method: `session.permissions.locations.apply`.
8103 ///
8104 /// # Parameters
8105 ///
8106 /// * `params` - Working directory to load persisted location permissions for.
8107 ///
8108 /// # Returns
8109 ///
8110 /// Summary of persisted location permissions applied to the session.
8111 ///
8112 /// <div class="warning">
8113 ///
8114 /// **Experimental.** This API is part of an experimental wire-protocol surface
8115 /// and may change or be removed in future SDK or CLI releases. Pin both the
8116 /// SDK and CLI versions if your code depends on it.
8117 ///
8118 /// </div>
8119 pub async fn apply(
8120 &self,
8121 params: PermissionLocationApplyParams,
8122 ) -> Result<PermissionLocationApplyResult, Error> {
8123 let mut wire_params = serde_json::to_value(params)?;
8124 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8125 let _value = self
8126 .session
8127 .client()
8128 .call(
8129 rpc_methods::SESSION_PERMISSIONS_LOCATIONS_APPLY,
8130 Some(wire_params),
8131 )
8132 .await?;
8133 Ok(serde_json::from_value(_value)?)
8134 }
8135
8136 /// Persists a tool approval for a permission location and applies its rules to this session's live permission service.
8137 ///
8138 /// Wire method: `session.permissions.locations.addToolApproval`.
8139 ///
8140 /// # Parameters
8141 ///
8142 /// * `params` - Location-scoped tool approval to persist.
8143 ///
8144 /// # Returns
8145 ///
8146 /// Indicates whether the operation succeeded.
8147 ///
8148 /// <div class="warning">
8149 ///
8150 /// **Experimental.** This API is part of an experimental wire-protocol surface
8151 /// and may change or be removed in future SDK or CLI releases. Pin both the
8152 /// SDK and CLI versions if your code depends on it.
8153 ///
8154 /// </div>
8155 pub async fn add_tool_approval(
8156 &self,
8157 params: PermissionLocationAddToolApprovalParams,
8158 ) -> Result<PermissionsLocationsAddToolApprovalResult, Error> {
8159 let mut wire_params = serde_json::to_value(params)?;
8160 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8161 let _value = self
8162 .session
8163 .client()
8164 .call(
8165 rpc_methods::SESSION_PERMISSIONS_LOCATIONS_ADDTOOLAPPROVAL,
8166 Some(wire_params),
8167 )
8168 .await?;
8169 Ok(serde_json::from_value(_value)?)
8170 }
8171}
8172
8173/// `session.permissions.paths.*` RPCs.
8174#[derive(Clone, Copy)]
8175pub struct SessionRpcPermissionsPaths<'a> {
8176 pub(crate) session: &'a Session,
8177}
8178
8179impl<'a> SessionRpcPermissionsPaths<'a> {
8180 /// Returns the session's allowed directories and primary working directory.
8181 ///
8182 /// Wire method: `session.permissions.paths.list`.
8183 ///
8184 /// # Returns
8185 ///
8186 /// Snapshot of the session's allow-listed directories and primary working directory.
8187 ///
8188 /// <div class="warning">
8189 ///
8190 /// **Experimental.** This API is part of an experimental wire-protocol surface
8191 /// and may change or be removed in future SDK or CLI releases. Pin both the
8192 /// SDK and CLI versions if your code depends on it.
8193 ///
8194 /// </div>
8195 pub async fn list(&self) -> Result<PermissionPathsList, Error> {
8196 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8197 let _value = self
8198 .session
8199 .client()
8200 .call(
8201 rpc_methods::SESSION_PERMISSIONS_PATHS_LIST,
8202 Some(wire_params),
8203 )
8204 .await?;
8205 Ok(serde_json::from_value(_value)?)
8206 }
8207
8208 /// Adds a directory to the session's allow-list.
8209 ///
8210 /// Wire method: `session.permissions.paths.add`.
8211 ///
8212 /// # Parameters
8213 ///
8214 /// * `params` - Directory path to add to the session's allowed directories.
8215 ///
8216 /// # Returns
8217 ///
8218 /// Indicates whether the operation succeeded.
8219 ///
8220 /// <div class="warning">
8221 ///
8222 /// **Experimental.** This API is part of an experimental wire-protocol surface
8223 /// and may change or be removed in future SDK or CLI releases. Pin both the
8224 /// SDK and CLI versions if your code depends on it.
8225 ///
8226 /// </div>
8227 pub async fn add(
8228 &self,
8229 params: PermissionPathsAddParams,
8230 ) -> Result<PermissionsPathsAddResult, Error> {
8231 let mut wire_params = serde_json::to_value(params)?;
8232 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8233 let _value = self
8234 .session
8235 .client()
8236 .call(
8237 rpc_methods::SESSION_PERMISSIONS_PATHS_ADD,
8238 Some(wire_params),
8239 )
8240 .await?;
8241 Ok(serde_json::from_value(_value)?)
8242 }
8243
8244 /// Updates the session's primary working directory used by the permission policy.
8245 ///
8246 /// Wire method: `session.permissions.paths.updatePrimary`.
8247 ///
8248 /// # Parameters
8249 ///
8250 /// * `params` - Directory path to set as the session's new primary working directory.
8251 ///
8252 /// # Returns
8253 ///
8254 /// Indicates whether the operation succeeded.
8255 ///
8256 /// <div class="warning">
8257 ///
8258 /// **Experimental.** This API is part of an experimental wire-protocol surface
8259 /// and may change or be removed in future SDK or CLI releases. Pin both the
8260 /// SDK and CLI versions if your code depends on it.
8261 ///
8262 /// </div>
8263 pub async fn update_primary(
8264 &self,
8265 params: PermissionPathsUpdatePrimaryParams,
8266 ) -> Result<PermissionsPathsUpdatePrimaryResult, Error> {
8267 let mut wire_params = serde_json::to_value(params)?;
8268 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8269 let _value = self
8270 .session
8271 .client()
8272 .call(
8273 rpc_methods::SESSION_PERMISSIONS_PATHS_UPDATEPRIMARY,
8274 Some(wire_params),
8275 )
8276 .await?;
8277 Ok(serde_json::from_value(_value)?)
8278 }
8279
8280 /// Reports whether a path falls within any of the session's allowed directories.
8281 ///
8282 /// Wire method: `session.permissions.paths.isPathWithinAllowedDirectories`.
8283 ///
8284 /// # Parameters
8285 ///
8286 /// * `params` - Path to evaluate against the session's allowed directories.
8287 ///
8288 /// # Returns
8289 ///
8290 /// Indicates whether the supplied path is within the session's allowed directories.
8291 ///
8292 /// <div class="warning">
8293 ///
8294 /// **Experimental.** This API is part of an experimental wire-protocol surface
8295 /// and may change or be removed in future SDK or CLI releases. Pin both the
8296 /// SDK and CLI versions if your code depends on it.
8297 ///
8298 /// </div>
8299 pub async fn is_path_within_allowed_directories(
8300 &self,
8301 params: PermissionPathsAllowedCheckParams,
8302 ) -> Result<PermissionPathsAllowedCheckResult, Error> {
8303 let mut wire_params = serde_json::to_value(params)?;
8304 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8305 let _value = self
8306 .session
8307 .client()
8308 .call(
8309 rpc_methods::SESSION_PERMISSIONS_PATHS_ISPATHWITHINALLOWEDDIRECTORIES,
8310 Some(wire_params),
8311 )
8312 .await?;
8313 Ok(serde_json::from_value(_value)?)
8314 }
8315
8316 /// Reports whether a path falls within the session's workspace (primary) directory.
8317 ///
8318 /// Wire method: `session.permissions.paths.isPathWithinWorkspace`.
8319 ///
8320 /// # Parameters
8321 ///
8322 /// * `params` - Path to evaluate against the session's workspace (primary) directory.
8323 ///
8324 /// # Returns
8325 ///
8326 /// Indicates whether the supplied path is within the session's workspace directory.
8327 ///
8328 /// <div class="warning">
8329 ///
8330 /// **Experimental.** This API is part of an experimental wire-protocol surface
8331 /// and may change or be removed in future SDK or CLI releases. Pin both the
8332 /// SDK and CLI versions if your code depends on it.
8333 ///
8334 /// </div>
8335 pub async fn is_path_within_workspace(
8336 &self,
8337 params: PermissionPathsWorkspaceCheckParams,
8338 ) -> Result<PermissionPathsWorkspaceCheckResult, Error> {
8339 let mut wire_params = serde_json::to_value(params)?;
8340 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8341 let _value = self
8342 .session
8343 .client()
8344 .call(
8345 rpc_methods::SESSION_PERMISSIONS_PATHS_ISPATHWITHINWORKSPACE,
8346 Some(wire_params),
8347 )
8348 .await?;
8349 Ok(serde_json::from_value(_value)?)
8350 }
8351}
8352
8353/// `session.permissions.urls.*` RPCs.
8354#[derive(Clone, Copy)]
8355pub struct SessionRpcPermissionsUrls<'a> {
8356 pub(crate) session: &'a Session,
8357}
8358
8359impl<'a> SessionRpcPermissionsUrls<'a> {
8360 /// Toggles the runtime's URL-permission policy between unrestricted and restricted modes.
8361 ///
8362 /// Wire method: `session.permissions.urls.setUnrestrictedMode`.
8363 ///
8364 /// # Parameters
8365 ///
8366 /// * `params` - Whether the URL-permission policy should run in unrestricted mode.
8367 ///
8368 /// # Returns
8369 ///
8370 /// Indicates whether the operation succeeded.
8371 ///
8372 /// <div class="warning">
8373 ///
8374 /// **Experimental.** This API is part of an experimental wire-protocol surface
8375 /// and may change or be removed in future SDK or CLI releases. Pin both the
8376 /// SDK and CLI versions if your code depends on it.
8377 ///
8378 /// </div>
8379 pub async fn set_unrestricted_mode(
8380 &self,
8381 params: PermissionUrlsSetUnrestrictedModeParams,
8382 ) -> Result<PermissionsUrlsSetUnrestrictedModeResult, Error> {
8383 let mut wire_params = serde_json::to_value(params)?;
8384 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8385 let _value = self
8386 .session
8387 .client()
8388 .call(
8389 rpc_methods::SESSION_PERMISSIONS_URLS_SETUNRESTRICTEDMODE,
8390 Some(wire_params),
8391 )
8392 .await?;
8393 Ok(serde_json::from_value(_value)?)
8394 }
8395}
8396
8397/// `session.plan.*` RPCs.
8398#[derive(Clone, Copy)]
8399pub struct SessionRpcPlan<'a> {
8400 pub(crate) session: &'a Session,
8401}
8402
8403impl<'a> SessionRpcPlan<'a> {
8404 /// Reads the session plan file from the workspace.
8405 ///
8406 /// Wire method: `session.plan.read`.
8407 ///
8408 /// # Returns
8409 ///
8410 /// Existence, contents, and resolved path of the session plan file.
8411 ///
8412 /// <div class="warning">
8413 ///
8414 /// **Experimental.** This API is part of an experimental wire-protocol surface
8415 /// and may change or be removed in future SDK or CLI releases. Pin both the
8416 /// SDK and CLI versions if your code depends on it.
8417 ///
8418 /// </div>
8419 pub async fn read(&self) -> Result<PlanReadResult, Error> {
8420 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8421 let _value = self
8422 .session
8423 .client()
8424 .call(rpc_methods::SESSION_PLAN_READ, Some(wire_params))
8425 .await?;
8426 Ok(serde_json::from_value(_value)?)
8427 }
8428
8429 /// Writes new content to the session plan file.
8430 ///
8431 /// Wire method: `session.plan.update`.
8432 ///
8433 /// # Parameters
8434 ///
8435 /// * `params` - Replacement contents to write to the session plan file.
8436 ///
8437 /// <div class="warning">
8438 ///
8439 /// **Experimental.** This API is part of an experimental wire-protocol surface
8440 /// and may change or be removed in future SDK or CLI releases. Pin both the
8441 /// SDK and CLI versions if your code depends on it.
8442 ///
8443 /// </div>
8444 pub async fn update(&self, params: PlanUpdateRequest) -> Result<(), Error> {
8445 let mut wire_params = serde_json::to_value(params)?;
8446 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8447 let _value = self
8448 .session
8449 .client()
8450 .call(rpc_methods::SESSION_PLAN_UPDATE, Some(wire_params))
8451 .await?;
8452 Ok(())
8453 }
8454
8455 /// Deletes the session plan file from the workspace.
8456 ///
8457 /// Wire method: `session.plan.delete`.
8458 ///
8459 /// <div class="warning">
8460 ///
8461 /// **Experimental.** This API is part of an experimental wire-protocol surface
8462 /// and may change or be removed in future SDK or CLI releases. Pin both the
8463 /// SDK and CLI versions if your code depends on it.
8464 ///
8465 /// </div>
8466 pub async fn delete(&self) -> Result<(), Error> {
8467 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8468 let _value = self
8469 .session
8470 .client()
8471 .call(rpc_methods::SESSION_PLAN_DELETE, Some(wire_params))
8472 .await?;
8473 Ok(())
8474 }
8475
8476 /// Reads todo rows from the session SQL database for plan rendering.
8477 ///
8478 /// Wire method: `session.plan.readSqlTodos`.
8479 ///
8480 /// # Returns
8481 ///
8482 /// Todo rows read from the session SQL database. Empty when no session database is available.
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 read_sql_todos(&self) -> Result<PlanReadSqlTodosResult, Error> {
8492 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8493 let _value = self
8494 .session
8495 .client()
8496 .call(rpc_methods::SESSION_PLAN_READSQLTODOS, Some(wire_params))
8497 .await?;
8498 Ok(serde_json::from_value(_value)?)
8499 }
8500
8501 /// 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.
8502 ///
8503 /// Wire method: `session.plan.readSqlTodosWithDependencies`.
8504 ///
8505 /// # Returns
8506 ///
8507 /// Todo rows + dependency edges read from the session SQL database.
8508 ///
8509 /// <div class="warning">
8510 ///
8511 /// **Experimental.** This API is part of an experimental wire-protocol surface
8512 /// and may change or be removed in future SDK or CLI releases. Pin both the
8513 /// SDK and CLI versions if your code depends on it.
8514 ///
8515 /// </div>
8516 pub async fn read_sql_todos_with_dependencies(
8517 &self,
8518 ) -> Result<PlanReadSqlTodosWithDependenciesResult, Error> {
8519 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8520 let _value = self
8521 .session
8522 .client()
8523 .call(
8524 rpc_methods::SESSION_PLAN_READSQLTODOSWITHDEPENDENCIES,
8525 Some(wire_params),
8526 )
8527 .await?;
8528 Ok(serde_json::from_value(_value)?)
8529 }
8530}
8531
8532/// `session.plugins.*` RPCs.
8533#[derive(Clone, Copy)]
8534pub struct SessionRpcPlugins<'a> {
8535 pub(crate) session: &'a Session,
8536}
8537
8538impl<'a> SessionRpcPlugins<'a> {
8539 /// Lists plugins installed for the session.
8540 ///
8541 /// Wire method: `session.plugins.list`.
8542 ///
8543 /// # Returns
8544 ///
8545 /// Plugins installed for the session, with their enabled state and version metadata.
8546 ///
8547 /// <div class="warning">
8548 ///
8549 /// **Experimental.** This API is part of an experimental wire-protocol surface
8550 /// and may change or be removed in future SDK or CLI releases. Pin both the
8551 /// SDK and CLI versions if your code depends on it.
8552 ///
8553 /// </div>
8554 pub async fn list(&self) -> Result<PluginList, Error> {
8555 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8556 let _value = self
8557 .session
8558 .client()
8559 .call(rpc_methods::SESSION_PLUGINS_LIST, Some(wire_params))
8560 .await?;
8561 Ok(serde_json::from_value(_value)?)
8562 }
8563
8564 /// 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.
8565 ///
8566 /// Wire method: `session.plugins.reload`.
8567 ///
8568 /// <div class="warning">
8569 ///
8570 /// **Experimental.** This API is part of an experimental wire-protocol surface
8571 /// and may change or be removed in future SDK or CLI releases. Pin both the
8572 /// SDK and CLI versions if your code depends on it.
8573 ///
8574 /// </div>
8575 pub async fn reload(&self) -> Result<(), Error> {
8576 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8577 let _value = self
8578 .session
8579 .client()
8580 .call(rpc_methods::SESSION_PLUGINS_RELOAD, Some(wire_params))
8581 .await?;
8582 Ok(())
8583 }
8584
8585 /// 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.
8586 ///
8587 /// Wire method: `session.plugins.reload`.
8588 ///
8589 /// # Parameters
8590 ///
8591 /// * `params` - Optional flags controlling which side effects the reload performs.
8592 ///
8593 /// <div class="warning">
8594 ///
8595 /// **Experimental.** This API is part of an experimental wire-protocol surface
8596 /// and may change or be removed in future SDK or CLI releases. Pin both the
8597 /// SDK and CLI versions if your code depends on it.
8598 ///
8599 /// </div>
8600 pub async fn reload_with_params(&self, params: PluginsReloadRequest) -> Result<(), Error> {
8601 let mut wire_params = serde_json::to_value(params)?;
8602 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8603 let _value = self
8604 .session
8605 .client()
8606 .call(rpc_methods::SESSION_PLUGINS_RELOAD, Some(wire_params))
8607 .await?;
8608 Ok(())
8609 }
8610}
8611
8612/// `session.provider.*` RPCs.
8613#[derive(Clone, Copy)]
8614pub struct SessionRpcProvider<'a> {
8615 pub(crate) session: &'a Session,
8616}
8617
8618impl<'a> SessionRpcProvider<'a> {
8619 /// 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.
8620 ///
8621 /// Wire method: `session.provider.getEndpoint`.
8622 ///
8623 /// # Returns
8624 ///
8625 /// A snapshot of the provider endpoint the session is currently configured to talk to.
8626 ///
8627 /// <div class="warning">
8628 ///
8629 /// **Experimental.** This API is part of an experimental wire-protocol surface
8630 /// and may change or be removed in future SDK or CLI releases. Pin both the
8631 /// SDK and CLI versions if your code depends on it.
8632 ///
8633 /// </div>
8634 pub async fn get_endpoint(&self) -> Result<ProviderEndpoint, Error> {
8635 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8636 let _value = self
8637 .session
8638 .client()
8639 .call(rpc_methods::SESSION_PROVIDER_GETENDPOINT, Some(wire_params))
8640 .await?;
8641 Ok(serde_json::from_value(_value)?)
8642 }
8643
8644 /// 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.
8645 ///
8646 /// Wire method: `session.provider.getEndpoint`.
8647 ///
8648 /// # Parameters
8649 ///
8650 /// * `params` - Optional model identifier to scope the endpoint snapshot to.
8651 ///
8652 /// # Returns
8653 ///
8654 /// A snapshot of the provider endpoint the session is currently configured to talk to.
8655 ///
8656 /// <div class="warning">
8657 ///
8658 /// **Experimental.** This API is part of an experimental wire-protocol surface
8659 /// and may change or be removed in future SDK or CLI releases. Pin both the
8660 /// SDK and CLI versions if your code depends on it.
8661 ///
8662 /// </div>
8663 pub async fn get_endpoint_with_params(
8664 &self,
8665 params: ProviderGetEndpointRequest,
8666 ) -> Result<ProviderEndpoint, Error> {
8667 let mut wire_params = serde_json::to_value(params)?;
8668 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8669 let _value = self
8670 .session
8671 .client()
8672 .call(rpc_methods::SESSION_PROVIDER_GETENDPOINT, Some(wire_params))
8673 .await?;
8674 Ok(serde_json::from_value(_value)?)
8675 }
8676
8677 /// 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.
8678 ///
8679 /// Wire method: `session.provider.add`.
8680 ///
8681 /// # Parameters
8682 ///
8683 /// * `params` - BYOK providers and/or models to add to the session's registry at runtime. Both fields are optional; provide providers, models, or both.
8684 ///
8685 /// # Returns
8686 ///
8687 /// The selectable model entries synthesized for the models added by this call.
8688 ///
8689 /// <div class="warning">
8690 ///
8691 /// **Experimental.** This API is part of an experimental wire-protocol surface
8692 /// and may change or be removed in future SDK or CLI releases. Pin both the
8693 /// SDK and CLI versions if your code depends on it.
8694 ///
8695 /// </div>
8696 pub async fn add(&self, params: ProviderAddRequest) -> Result<ProviderAddResult, Error> {
8697 let mut wire_params = serde_json::to_value(params)?;
8698 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8699 let _value = self
8700 .session
8701 .client()
8702 .call(rpc_methods::SESSION_PROVIDER_ADD, Some(wire_params))
8703 .await?;
8704 Ok(serde_json::from_value(_value)?)
8705 }
8706}
8707
8708/// `session.queue.*` RPCs.
8709#[derive(Clone, Copy)]
8710pub struct SessionRpcQueue<'a> {
8711 pub(crate) session: &'a Session,
8712}
8713
8714impl<'a> SessionRpcQueue<'a> {
8715 /// Returns the local session's pending user-facing queued items and steering messages.
8716 ///
8717 /// Wire method: `session.queue.pendingItems`.
8718 ///
8719 /// # Returns
8720 ///
8721 /// Snapshot of the session's pending queued items and immediate-steering messages.
8722 ///
8723 /// <div class="warning">
8724 ///
8725 /// **Experimental.** This API is part of an experimental wire-protocol surface
8726 /// and may change or be removed in future SDK or CLI releases. Pin both the
8727 /// SDK and CLI versions if your code depends on it.
8728 ///
8729 /// </div>
8730 pub async fn pending_items(&self) -> Result<QueuePendingItemsResult, Error> {
8731 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8732 let _value = self
8733 .session
8734 .client()
8735 .call(rpc_methods::SESSION_QUEUE_PENDINGITEMS, Some(wire_params))
8736 .await?;
8737 Ok(serde_json::from_value(_value)?)
8738 }
8739
8740 /// Returns the internal native queue snapshot for in-process session orchestration.
8741 ///
8742 /// Wire method: `session.queue.snapshot`.
8743 ///
8744 /// # Returns
8745 ///
8746 /// Internal snapshot of native queue state for local session orchestration.
8747 ///
8748 /// <div class="warning">
8749 ///
8750 /// **Experimental.** This API is part of an experimental wire-protocol surface
8751 /// and may change or be removed in future SDK or CLI releases. Pin both the
8752 /// SDK and CLI versions if your code depends on it.
8753 ///
8754 /// </div>
8755 pub(crate) async fn snapshot(&self) -> Result<QueueSnapshotResult, Error> {
8756 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8757 let _value = self
8758 .session
8759 .client()
8760 .call(rpc_methods::SESSION_QUEUE_SNAPSHOT, Some(wire_params))
8761 .await?;
8762 Ok(serde_json::from_value(_value)?)
8763 }
8764
8765 /// Moves an addressable queued item to a public visible position.
8766 ///
8767 /// Wire method: `session.queue.moveItem`.
8768 ///
8769 /// # Parameters
8770 ///
8771 /// * `params` - Parameters for moving a queued item by stable id.
8772 ///
8773 /// # Returns
8774 ///
8775 /// Result of moving a queued item.
8776 ///
8777 /// <div class="warning">
8778 ///
8779 /// **Experimental.** This API is part of an experimental wire-protocol surface
8780 /// and may change or be removed in future SDK or CLI releases. Pin both the
8781 /// SDK and CLI versions if your code depends on it.
8782 ///
8783 /// </div>
8784 pub async fn move_item(
8785 &self,
8786 params: QueueMoveItemRequest,
8787 ) -> Result<QueueMoveItemResult, Error> {
8788 let mut wire_params = serde_json::to_value(params)?;
8789 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8790 let _value = self
8791 .session
8792 .client()
8793 .call(rpc_methods::SESSION_QUEUE_MOVEITEM, Some(wire_params))
8794 .await?;
8795 Ok(serde_json::from_value(_value)?)
8796 }
8797
8798 /// Inserts a new queued message at a public visible position.
8799 ///
8800 /// Wire method: `session.queue.insertAt`.
8801 ///
8802 /// # Parameters
8803 ///
8804 /// * `params` - Parameters for inserting a queued message at a public visible position.
8805 ///
8806 /// # Returns
8807 ///
8808 /// Result of inserting a queued message.
8809 ///
8810 /// <div class="warning">
8811 ///
8812 /// **Experimental.** This API is part of an experimental wire-protocol surface
8813 /// and may change or be removed in future SDK or CLI releases. Pin both the
8814 /// SDK and CLI versions if your code depends on it.
8815 ///
8816 /// </div>
8817 pub async fn insert_at(
8818 &self,
8819 params: QueueInsertAtRequest,
8820 ) -> Result<QueueInsertAtResult, Error> {
8821 let mut wire_params = serde_json::to_value(params)?;
8822 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8823 let _value = self
8824 .session
8825 .client()
8826 .call(rpc_methods::SESSION_QUEUE_INSERTAT, Some(wire_params))
8827 .await?;
8828 Ok(serde_json::from_value(_value)?)
8829 }
8830
8831 /// Removes an addressable queued item by its stable id.
8832 ///
8833 /// Wire method: `session.queue.removeAt`.
8834 ///
8835 /// # Parameters
8836 ///
8837 /// * `params` - Parameters for removing a queued item by stable id.
8838 ///
8839 /// # Returns
8840 ///
8841 /// Result of removing a queued item.
8842 ///
8843 /// <div class="warning">
8844 ///
8845 /// **Experimental.** This API is part of an experimental wire-protocol surface
8846 /// and may change or be removed in future SDK or CLI releases. Pin both the
8847 /// SDK and CLI versions if your code depends on it.
8848 ///
8849 /// </div>
8850 pub async fn remove_at(
8851 &self,
8852 params: QueueRemoveAtRequest,
8853 ) -> Result<QueueRemoveAtResult, Error> {
8854 let mut wire_params = serde_json::to_value(params)?;
8855 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8856 let _value = self
8857 .session
8858 .client()
8859 .call(rpc_methods::SESSION_QUEUE_REMOVEAT, Some(wire_params))
8860 .await?;
8861 Ok(serde_json::from_value(_value)?)
8862 }
8863
8864 /// Updates the text of an addressable single-message queue item.
8865 ///
8866 /// Wire method: `session.queue.updateText`.
8867 ///
8868 /// # Parameters
8869 ///
8870 /// * `params` - Parameters for editing a single queued message.
8871 ///
8872 /// # Returns
8873 ///
8874 /// Result of editing a queued message.
8875 ///
8876 /// <div class="warning">
8877 ///
8878 /// **Experimental.** This API is part of an experimental wire-protocol surface
8879 /// and may change or be removed in future SDK or CLI releases. Pin both the
8880 /// SDK and CLI versions if your code depends on it.
8881 ///
8882 /// </div>
8883 pub async fn update_text(
8884 &self,
8885 params: QueueUpdateTextRequest,
8886 ) -> Result<QueueUpdateTextResult, Error> {
8887 let mut wire_params = serde_json::to_value(params)?;
8888 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8889 let _value = self
8890 .session
8891 .client()
8892 .call(rpc_methods::SESSION_QUEUE_UPDATETEXT, Some(wire_params))
8893 .await?;
8894 Ok(serde_json::from_value(_value)?)
8895 }
8896
8897 /// Duplicates an addressable queued item immediately after its source.
8898 ///
8899 /// Wire method: `session.queue.duplicateAt`.
8900 ///
8901 /// # Parameters
8902 ///
8903 /// * `params` - Parameters for duplicating a queued item.
8904 ///
8905 /// # Returns
8906 ///
8907 /// Result of duplicating a queued item.
8908 ///
8909 /// <div class="warning">
8910 ///
8911 /// **Experimental.** This API is part of an experimental wire-protocol surface
8912 /// and may change or be removed in future SDK or CLI releases. Pin both the
8913 /// SDK and CLI versions if your code depends on it.
8914 ///
8915 /// </div>
8916 pub async fn duplicate_at(
8917 &self,
8918 params: QueueDuplicateAtRequest,
8919 ) -> Result<QueueDuplicateAtResult, Error> {
8920 let mut wire_params = serde_json::to_value(params)?;
8921 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8922 let _value = self
8923 .session
8924 .client()
8925 .call(rpc_methods::SESSION_QUEUE_DUPLICATEAT, Some(wire_params))
8926 .await?;
8927 Ok(serde_json::from_value(_value)?)
8928 }
8929
8930 /// Acquires or releases the queued-lane drain pause.
8931 ///
8932 /// Wire method: `session.queue.setDrainPaused`.
8933 ///
8934 /// # Parameters
8935 ///
8936 /// * `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.
8937 ///
8938 /// <div class="warning">
8939 ///
8940 /// **Experimental.** This API is part of an experimental wire-protocol surface
8941 /// and may change or be removed in future SDK or CLI releases. Pin both the
8942 /// SDK and CLI versions if your code depends on it.
8943 ///
8944 /// </div>
8945 pub async fn set_drain_paused(&self, params: QueueSetDrainPausedRequest) -> Result<(), Error> {
8946 let mut wire_params = serde_json::to_value(params)?;
8947 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8948 let _value = self
8949 .session
8950 .client()
8951 .call(rpc_methods::SESSION_QUEUE_SETDRAINPAUSED, Some(wire_params))
8952 .await?;
8953 Ok(())
8954 }
8955
8956 /// Moves an addressable queued message into the live turn's steering lane.
8957 ///
8958 /// Wire method: `session.queue.sendNow`.
8959 ///
8960 /// # Parameters
8961 ///
8962 /// * `params` - Parameters for steering a queued message into a live turn.
8963 ///
8964 /// # Returns
8965 ///
8966 /// Result of trying to steer a queued message into a live turn.
8967 ///
8968 /// <div class="warning">
8969 ///
8970 /// **Experimental.** This API is part of an experimental wire-protocol surface
8971 /// and may change or be removed in future SDK or CLI releases. Pin both the
8972 /// SDK and CLI versions if your code depends on it.
8973 ///
8974 /// </div>
8975 pub async fn send_now(&self, params: QueueSendNowRequest) -> Result<QueueSendNowResult, Error> {
8976 let mut wire_params = serde_json::to_value(params)?;
8977 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8978 let _value = self
8979 .session
8980 .client()
8981 .call(rpc_methods::SESSION_QUEUE_SENDNOW, Some(wire_params))
8982 .await?;
8983 Ok(serde_json::from_value(_value)?)
8984 }
8985
8986 /// Reports whether the local session has native queued work pending.
8987 ///
8988 /// Wire method: `session.queue.hasPending`.
8989 ///
8990 /// # Returns
8991 ///
8992 /// Whether the native queue has pending work.
8993 ///
8994 /// <div class="warning">
8995 ///
8996 /// **Experimental.** This API is part of an experimental wire-protocol surface
8997 /// and may change or be removed in future SDK or CLI releases. Pin both the
8998 /// SDK and CLI versions if your code depends on it.
8999 ///
9000 /// </div>
9001 pub(crate) async fn has_pending(&self) -> Result<QueueHasPendingResult, Error> {
9002 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9003 let _value = self
9004 .session
9005 .client()
9006 .call(rpc_methods::SESSION_QUEUE_HASPENDING, Some(wire_params))
9007 .await?;
9008 Ok(serde_json::from_value(_value)?)
9009 }
9010
9011 /// Begins a native deferred-idle drain when background work has quiesced.
9012 ///
9013 /// Wire method: `session.queue.beginDeferredIdleDrain`.
9014 ///
9015 /// # Parameters
9016 ///
9017 /// * `params` - Inputs for starting a deferred-idle drain.
9018 ///
9019 /// # Returns
9020 ///
9021 /// Whether a deferred-idle drain should run.
9022 ///
9023 /// <div class="warning">
9024 ///
9025 /// **Experimental.** This API is part of an experimental wire-protocol surface
9026 /// and may change or be removed in future SDK or CLI releases. Pin both the
9027 /// SDK and CLI versions if your code depends on it.
9028 ///
9029 /// </div>
9030 pub(crate) async fn begin_deferred_idle_drain(
9031 &self,
9032 params: QueueBeginDeferredIdleDrainRequest,
9033 ) -> Result<QueueBeginDeferredIdleDrainResult, Error> {
9034 let mut wire_params = serde_json::to_value(params)?;
9035 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9036 let _value = self
9037 .session
9038 .client()
9039 .call(
9040 rpc_methods::SESSION_QUEUE_BEGINDEFERREDIDLEDRAIN,
9041 Some(wire_params),
9042 )
9043 .await?;
9044 Ok(serde_json::from_value(_value)?)
9045 }
9046
9047 /// Finishes a native deferred-idle drain and reports whether to drain queue work or emit idle.
9048 ///
9049 /// Wire method: `session.queue.finishDeferredIdleDrain`.
9050 ///
9051 /// # Parameters
9052 ///
9053 /// * `params` - Inputs for completing a deferred-idle drain.
9054 ///
9055 /// # Returns
9056 ///
9057 /// Action selected by the native deferred-idle drain.
9058 ///
9059 /// <div class="warning">
9060 ///
9061 /// **Experimental.** This API is part of an experimental wire-protocol surface
9062 /// and may change or be removed in future SDK or CLI releases. Pin both the
9063 /// SDK and CLI versions if your code depends on it.
9064 ///
9065 /// </div>
9066 pub(crate) async fn finish_deferred_idle_drain(
9067 &self,
9068 params: QueueFinishDeferredIdleDrainRequest,
9069 ) -> Result<QueueFinishDeferredIdleDrainResult, Error> {
9070 let mut wire_params = serde_json::to_value(params)?;
9071 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9072 let _value = self
9073 .session
9074 .client()
9075 .call(
9076 rpc_methods::SESSION_QUEUE_FINISHDEFERREDIDLEDRAIN,
9077 Some(wire_params),
9078 )
9079 .await?;
9080 Ok(serde_json::from_value(_value)?)
9081 }
9082
9083 /// Marks session.idle as deferred by native background work state.
9084 ///
9085 /// Wire method: `session.queue.deferSessionIdle`.
9086 ///
9087 /// # Parameters
9088 ///
9089 /// * `params` - Inputs for marking session.idle deferred in native state.
9090 ///
9091 /// <div class="warning">
9092 ///
9093 /// **Experimental.** This API is part of an experimental wire-protocol surface
9094 /// and may change or be removed in future SDK or CLI releases. Pin both the
9095 /// SDK and CLI versions if your code depends on it.
9096 ///
9097 /// </div>
9098 pub(crate) async fn defer_session_idle(
9099 &self,
9100 params: QueueDeferSessionIdleRequest,
9101 ) -> Result<(), Error> {
9102 let mut wire_params = serde_json::to_value(params)?;
9103 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9104 let _value = self
9105 .session
9106 .client()
9107 .call(
9108 rpc_methods::SESSION_QUEUE_DEFERSESSIONIDLE,
9109 Some(wire_params),
9110 )
9111 .await?;
9112 Ok(())
9113 }
9114
9115 /// Removes the most recently queued user-facing item (LIFO).
9116 ///
9117 /// Wire method: `session.queue.removeMostRecent`.
9118 ///
9119 /// # Returns
9120 ///
9121 /// Indicates whether a user-facing pending item was removed.
9122 ///
9123 /// <div class="warning">
9124 ///
9125 /// **Experimental.** This API is part of an experimental wire-protocol surface
9126 /// and may change or be removed in future SDK or CLI releases. Pin both the
9127 /// SDK and CLI versions if your code depends on it.
9128 ///
9129 /// </div>
9130 pub async fn remove_most_recent(&self) -> Result<QueueRemoveMostRecentResult, Error> {
9131 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9132 let _value = self
9133 .session
9134 .client()
9135 .call(
9136 rpc_methods::SESSION_QUEUE_REMOVEMOSTRECENT,
9137 Some(wire_params),
9138 )
9139 .await?;
9140 Ok(serde_json::from_value(_value)?)
9141 }
9142
9143 /// Clears all pending queued items on the local session.
9144 ///
9145 /// Wire method: `session.queue.clear`.
9146 ///
9147 /// <div class="warning">
9148 ///
9149 /// **Experimental.** This API is part of an experimental wire-protocol surface
9150 /// and may change or be removed in future SDK or CLI releases. Pin both the
9151 /// SDK and CLI versions if your code depends on it.
9152 ///
9153 /// </div>
9154 pub async fn clear(&self) -> Result<(), Error> {
9155 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9156 let _value = self
9157 .session
9158 .client()
9159 .call(rpc_methods::SESSION_QUEUE_CLEAR, Some(wire_params))
9160 .await?;
9161 Ok(())
9162 }
9163
9164 /// Consumes queued native system notifications matching an internal filter.
9165 ///
9166 /// Wire method: `session.queue.consumeSystemNotifications`.
9167 ///
9168 /// # Parameters
9169 ///
9170 /// * `params` - Internal filter for consuming queued system notifications.
9171 ///
9172 /// # Returns
9173 ///
9174 /// Indicates whether a user-facing pending item was removed.
9175 ///
9176 /// <div class="warning">
9177 ///
9178 /// **Experimental.** This API is part of an experimental wire-protocol surface
9179 /// and may change or be removed in future SDK or CLI releases. Pin both the
9180 /// SDK and CLI versions if your code depends on it.
9181 ///
9182 /// </div>
9183 pub(crate) async fn consume_system_notifications(
9184 &self,
9185 params: QueueConsumeSystemNotificationsRequest,
9186 ) -> Result<QueueRemoveMostRecentResult, Error> {
9187 let mut wire_params = serde_json::to_value(params)?;
9188 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9189 let _value = self
9190 .session
9191 .client()
9192 .call(
9193 rpc_methods::SESSION_QUEUE_CONSUMESYSTEMNOTIFICATIONS,
9194 Some(wire_params),
9195 )
9196 .await?;
9197 Ok(serde_json::from_value(_value)?)
9198 }
9199
9200 /// Enqueues the internal resume-pending wake item when orphan handling needs a follow-up turn.
9201 ///
9202 /// Wire method: `session.queue.enqueueResumePending`.
9203 ///
9204 /// # Returns
9205 ///
9206 /// Result of enqueueing the resume-pending wake item.
9207 ///
9208 /// <div class="warning">
9209 ///
9210 /// **Experimental.** This API is part of an experimental wire-protocol surface
9211 /// and may change or be removed in future SDK or CLI releases. Pin both the
9212 /// SDK and CLI versions if your code depends on it.
9213 ///
9214 /// </div>
9215 pub(crate) async fn enqueue_resume_pending(
9216 &self,
9217 ) -> Result<QueueEnqueueResumePendingResult, Error> {
9218 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9219 let _value = self
9220 .session
9221 .client()
9222 .call(
9223 rpc_methods::SESSION_QUEUE_ENQUEUERESUMEPENDING,
9224 Some(wire_params),
9225 )
9226 .await?;
9227 Ok(serde_json::from_value(_value)?)
9228 }
9229
9230 /// Drains the native local-session work queue for in-process session orchestration.
9231 ///
9232 /// Wire method: `session.queue.process`.
9233 ///
9234 /// <div class="warning">
9235 ///
9236 /// **Experimental.** This API is part of an experimental wire-protocol surface
9237 /// and may change or be removed in future SDK or CLI releases. Pin both the
9238 /// SDK and CLI versions if your code depends on it.
9239 ///
9240 /// </div>
9241 pub(crate) async fn process(&self) -> Result<(), Error> {
9242 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9243 let _value = self
9244 .session
9245 .client()
9246 .call(rpc_methods::SESSION_QUEUE_PROCESS, Some(wire_params))
9247 .await?;
9248 Ok(())
9249 }
9250}
9251
9252/// `session.remote.*` RPCs.
9253#[derive(Clone, Copy)]
9254pub struct SessionRpcRemote<'a> {
9255 pub(crate) session: &'a Session,
9256}
9257
9258impl<'a> SessionRpcRemote<'a> {
9259 /// Enables remote session export or steering.
9260 ///
9261 /// Wire method: `session.remote.enable`.
9262 ///
9263 /// # Parameters
9264 ///
9265 /// * `params` - Optional remote session mode ("off", "export", or "on"); defaults to enabling both export and remote steering.
9266 ///
9267 /// # Returns
9268 ///
9269 /// GitHub URL for the session and a flag indicating whether remote steering is enabled.
9270 ///
9271 /// <div class="warning">
9272 ///
9273 /// **Experimental.** This API is part of an experimental wire-protocol surface
9274 /// and may change or be removed in future SDK or CLI releases. Pin both the
9275 /// SDK and CLI versions if your code depends on it.
9276 ///
9277 /// </div>
9278 pub async fn enable(&self, params: RemoteEnableRequest) -> Result<RemoteEnableResult, Error> {
9279 let mut wire_params = serde_json::to_value(params)?;
9280 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9281 let _value = self
9282 .session
9283 .client()
9284 .call(rpc_methods::SESSION_REMOTE_ENABLE, Some(wire_params))
9285 .await?;
9286 Ok(serde_json::from_value(_value)?)
9287 }
9288
9289 /// Disables remote session export and steering.
9290 ///
9291 /// Wire method: `session.remote.disable`.
9292 ///
9293 /// <div class="warning">
9294 ///
9295 /// **Experimental.** This API is part of an experimental wire-protocol surface
9296 /// and may change or be removed in future SDK or CLI releases. Pin both the
9297 /// SDK and CLI versions if your code depends on it.
9298 ///
9299 /// </div>
9300 pub async fn disable(&self) -> Result<(), Error> {
9301 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9302 let _value = self
9303 .session
9304 .client()
9305 .call(rpc_methods::SESSION_REMOTE_DISABLE, Some(wire_params))
9306 .await?;
9307 Ok(())
9308 }
9309
9310 /// Persists a remote-steerability change emitted by the host as a session event.
9311 ///
9312 /// Wire method: `session.remote.notifySteerableChanged`.
9313 ///
9314 /// # Parameters
9315 ///
9316 /// * `params` - New remote-steerability state to persist as a `session.remote_steerable_changed` event.
9317 ///
9318 /// # Returns
9319 ///
9320 /// 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.
9321 ///
9322 /// <div class="warning">
9323 ///
9324 /// **Experimental.** This API is part of an experimental wire-protocol surface
9325 /// and may change or be removed in future SDK or CLI releases. Pin both the
9326 /// SDK and CLI versions if your code depends on it.
9327 ///
9328 /// </div>
9329 pub async fn notify_steerable_changed(
9330 &self,
9331 params: RemoteNotifySteerableChangedRequest,
9332 ) -> Result<RemoteNotifySteerableChangedResult, Error> {
9333 let mut wire_params = serde_json::to_value(params)?;
9334 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9335 let _value = self
9336 .session
9337 .client()
9338 .call(
9339 rpc_methods::SESSION_REMOTE_NOTIFYSTEERABLECHANGED,
9340 Some(wire_params),
9341 )
9342 .await?;
9343 Ok(serde_json::from_value(_value)?)
9344 }
9345}
9346
9347/// `session.schedule.*` RPCs.
9348#[derive(Clone, Copy)]
9349pub struct SessionRpcSchedule<'a> {
9350 pub(crate) session: &'a Session,
9351}
9352
9353impl<'a> SessionRpcSchedule<'a> {
9354 /// Lists the session's currently active scheduled prompts.
9355 ///
9356 /// Wire method: `session.schedule.list`.
9357 ///
9358 /// # Returns
9359 ///
9360 /// Snapshot of the currently active recurring prompts for this session.
9361 ///
9362 /// <div class="warning">
9363 ///
9364 /// **Experimental.** This API is part of an experimental wire-protocol surface
9365 /// and may change or be removed in future SDK or CLI releases. Pin both the
9366 /// SDK and CLI versions if your code depends on it.
9367 ///
9368 /// </div>
9369 pub async fn list(&self) -> Result<ScheduleList, Error> {
9370 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9371 let _value = self
9372 .session
9373 .client()
9374 .call(rpc_methods::SESSION_SCHEDULE_LIST, Some(wire_params))
9375 .await?;
9376 Ok(serde_json::from_value(_value)?)
9377 }
9378
9379 /// Hydrates the native schedule registry from persisted session events.
9380 ///
9381 /// Wire method: `session.schedule.hydrate`.
9382 ///
9383 /// <div class="warning">
9384 ///
9385 /// **Experimental.** This API is part of an experimental wire-protocol surface
9386 /// and may change or be removed in future SDK or CLI releases. Pin both the
9387 /// SDK and CLI versions if your code depends on it.
9388 ///
9389 /// </div>
9390 pub(crate) async fn hydrate(&self) -> Result<(), Error> {
9391 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9392 let _value = self
9393 .session
9394 .client()
9395 .call(rpc_methods::SESSION_SCHEDULE_HYDRATE, Some(wire_params))
9396 .await?;
9397 Ok(())
9398 }
9399
9400 /// Reports whether the session has an active self-paced scheduled prompt.
9401 ///
9402 /// Wire method: `session.schedule.hasSelfPaced`.
9403 ///
9404 /// # Returns
9405 ///
9406 /// Whether the session currently has an active self-paced schedule.
9407 ///
9408 /// <div class="warning">
9409 ///
9410 /// **Experimental.** This API is part of an experimental wire-protocol surface
9411 /// and may change or be removed in future SDK or CLI releases. Pin both the
9412 /// SDK and CLI versions if your code depends on it.
9413 ///
9414 /// </div>
9415 pub(crate) async fn has_self_paced(&self) -> Result<ScheduleHasSelfPacedResult, Error> {
9416 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9417 let _value = self
9418 .session
9419 .client()
9420 .call(
9421 rpc_methods::SESSION_SCHEDULE_HASSELFPACED,
9422 Some(wire_params),
9423 )
9424 .await?;
9425 Ok(serde_json::from_value(_value)?)
9426 }
9427
9428 /// Registers a relative-interval scheduled prompt.
9429 ///
9430 /// Wire method: `session.schedule.add`.
9431 ///
9432 /// # Parameters
9433 ///
9434 /// * `params` - Register a relative-interval scheduled prompt.
9435 ///
9436 /// # Returns
9437 ///
9438 /// Result of registering or re-arming a scheduled prompt.
9439 ///
9440 /// <div class="warning">
9441 ///
9442 /// **Experimental.** This API is part of an experimental wire-protocol surface
9443 /// and may change or be removed in future SDK or CLI releases. Pin both the
9444 /// SDK and CLI versions if your code depends on it.
9445 ///
9446 /// </div>
9447 pub(crate) async fn add(&self, params: ScheduleAddRequest) -> Result<ScheduleAddResult, Error> {
9448 let mut wire_params = serde_json::to_value(params)?;
9449 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9450 let _value = self
9451 .session
9452 .client()
9453 .call(rpc_methods::SESSION_SCHEDULE_ADD, Some(wire_params))
9454 .await?;
9455 Ok(serde_json::from_value(_value)?)
9456 }
9457
9458 /// Registers a recurring cron scheduled prompt.
9459 ///
9460 /// Wire method: `session.schedule.addCron`.
9461 ///
9462 /// # Parameters
9463 ///
9464 /// * `params` - Register a cron scheduled prompt.
9465 ///
9466 /// # Returns
9467 ///
9468 /// Result of registering or re-arming a scheduled prompt.
9469 ///
9470 /// <div class="warning">
9471 ///
9472 /// **Experimental.** This API is part of an experimental wire-protocol surface
9473 /// and may change or be removed in future SDK or CLI releases. Pin both the
9474 /// SDK and CLI versions if your code depends on it.
9475 ///
9476 /// </div>
9477 pub(crate) async fn add_cron(
9478 &self,
9479 params: ScheduleAddCronRequest,
9480 ) -> Result<ScheduleAddResult, Error> {
9481 let mut wire_params = serde_json::to_value(params)?;
9482 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9483 let _value = self
9484 .session
9485 .client()
9486 .call(rpc_methods::SESSION_SCHEDULE_ADDCRON, Some(wire_params))
9487 .await?;
9488 Ok(serde_json::from_value(_value)?)
9489 }
9490
9491 /// Registers an absolute-time scheduled prompt.
9492 ///
9493 /// Wire method: `session.schedule.addAt`.
9494 ///
9495 /// # Parameters
9496 ///
9497 /// * `params` - Register an absolute-time scheduled prompt.
9498 ///
9499 /// # Returns
9500 ///
9501 /// Result of registering or re-arming a scheduled prompt.
9502 ///
9503 /// <div class="warning">
9504 ///
9505 /// **Experimental.** This API is part of an experimental wire-protocol surface
9506 /// and may change or be removed in future SDK or CLI releases. Pin both the
9507 /// SDK and CLI versions if your code depends on it.
9508 ///
9509 /// </div>
9510 pub(crate) async fn add_at(
9511 &self,
9512 params: ScheduleAddAtRequest,
9513 ) -> Result<ScheduleAddResult, Error> {
9514 let mut wire_params = serde_json::to_value(params)?;
9515 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9516 let _value = self
9517 .session
9518 .client()
9519 .call(rpc_methods::SESSION_SCHEDULE_ADDAT, Some(wire_params))
9520 .await?;
9521 Ok(serde_json::from_value(_value)?)
9522 }
9523
9524 /// Registers a self-paced scheduled prompt.
9525 ///
9526 /// Wire method: `session.schedule.addSelfPaced`.
9527 ///
9528 /// # Parameters
9529 ///
9530 /// * `params` - Register a self-paced scheduled prompt.
9531 ///
9532 /// # Returns
9533 ///
9534 /// Result of registering or re-arming a scheduled prompt.
9535 ///
9536 /// <div class="warning">
9537 ///
9538 /// **Experimental.** This API is part of an experimental wire-protocol surface
9539 /// and may change or be removed in future SDK or CLI releases. Pin both the
9540 /// SDK and CLI versions if your code depends on it.
9541 ///
9542 /// </div>
9543 pub(crate) async fn add_self_paced(
9544 &self,
9545 params: ScheduleAddSelfPacedRequest,
9546 ) -> Result<ScheduleAddResult, Error> {
9547 let mut wire_params = serde_json::to_value(params)?;
9548 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9549 let _value = self
9550 .session
9551 .client()
9552 .call(
9553 rpc_methods::SESSION_SCHEDULE_ADDSELFPACED,
9554 Some(wire_params),
9555 )
9556 .await?;
9557 Ok(serde_json::from_value(_value)?)
9558 }
9559
9560 /// Re-arms an active self-paced scheduled prompt.
9561 ///
9562 /// Wire method: `session.schedule.rearmSelfPaced`.
9563 ///
9564 /// # Parameters
9565 ///
9566 /// * `params` - Re-arm a self-paced scheduled prompt.
9567 ///
9568 /// # Returns
9569 ///
9570 /// Result of registering or re-arming a scheduled prompt.
9571 ///
9572 /// <div class="warning">
9573 ///
9574 /// **Experimental.** This API is part of an experimental wire-protocol surface
9575 /// and may change or be removed in future SDK or CLI releases. Pin both the
9576 /// SDK and CLI versions if your code depends on it.
9577 ///
9578 /// </div>
9579 pub(crate) async fn rearm_self_paced(
9580 &self,
9581 params: ScheduleRearmSelfPacedRequest,
9582 ) -> Result<ScheduleAddResult, Error> {
9583 let mut wire_params = serde_json::to_value(params)?;
9584 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9585 let _value = self
9586 .session
9587 .client()
9588 .call(
9589 rpc_methods::SESSION_SCHEDULE_REARMSELFPACED,
9590 Some(wire_params),
9591 )
9592 .await?;
9593 Ok(serde_json::from_value(_value)?)
9594 }
9595
9596 /// Removes a scheduled prompt by id.
9597 ///
9598 /// Wire method: `session.schedule.stop`.
9599 ///
9600 /// # Parameters
9601 ///
9602 /// * `params` - Identifier of the scheduled prompt to remove.
9603 ///
9604 /// # Returns
9605 ///
9606 /// Remove a scheduled prompt by id. The result entry is omitted if the id was unknown.
9607 ///
9608 /// <div class="warning">
9609 ///
9610 /// **Experimental.** This API is part of an experimental wire-protocol surface
9611 /// and may change or be removed in future SDK or CLI releases. Pin both the
9612 /// SDK and CLI versions if your code depends on it.
9613 ///
9614 /// </div>
9615 pub async fn stop(&self, params: ScheduleStopRequest) -> Result<ScheduleStopResult, Error> {
9616 let mut wire_params = serde_json::to_value(params)?;
9617 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9618 let _value = self
9619 .session
9620 .client()
9621 .call(rpc_methods::SESSION_SCHEDULE_STOP, Some(wire_params))
9622 .await?;
9623 Ok(serde_json::from_value(_value)?)
9624 }
9625}
9626
9627/// `session.settings.*` RPCs.
9628#[derive(Clone, Copy)]
9629pub struct SessionRpcSettings<'a> {
9630 pub(crate) session: &'a Session,
9631}
9632
9633impl<'a> SessionRpcSettings<'a> {
9634 /// 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.
9635 ///
9636 /// Wire method: `session.settings.snapshot`.
9637 ///
9638 /// # Returns
9639 ///
9640 /// Redacted, serializable view of session runtime settings for SDK boundary consumers. Secrets and raw feature flags are intentionally excluded.
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 snapshot(&self) -> Result<SessionSettingsSnapshot, 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_SETTINGS_SNAPSHOT, Some(wire_params))
9655 .await?;
9656 Ok(serde_json::from_value(_value)?)
9657 }
9658
9659 /// 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.
9660 ///
9661 /// Wire method: `session.settings.evaluatePredicate`.
9662 ///
9663 /// # Parameters
9664 ///
9665 /// * `params` - Named Rust-owned settings predicate to evaluate for this session.
9666 ///
9667 /// # Returns
9668 ///
9669 /// Result of evaluating a Rust-owned settings predicate.
9670 ///
9671 /// <div class="warning">
9672 ///
9673 /// **Experimental.** This API is part of an experimental wire-protocol surface
9674 /// and may change or be removed in future SDK or CLI releases. Pin both the
9675 /// SDK and CLI versions if your code depends on it.
9676 ///
9677 /// </div>
9678 pub(crate) async fn evaluate_predicate(
9679 &self,
9680 params: SessionSettingsEvaluatePredicateRequest,
9681 ) -> Result<SessionSettingsEvaluatePredicateResult, Error> {
9682 let mut wire_params = serde_json::to_value(params)?;
9683 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9684 let _value = self
9685 .session
9686 .client()
9687 .call(
9688 rpc_methods::SESSION_SETTINGS_EVALUATEPREDICATE,
9689 Some(wire_params),
9690 )
9691 .await?;
9692 Ok(serde_json::from_value(_value)?)
9693 }
9694}
9695
9696/// `session.shell.*` RPCs.
9697#[derive(Clone, Copy)]
9698pub struct SessionRpcShell<'a> {
9699 pub(crate) session: &'a Session,
9700}
9701
9702impl<'a> SessionRpcShell<'a> {
9703 /// 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.
9704 ///
9705 /// Wire method: `session.shell.exec`.
9706 ///
9707 /// # Parameters
9708 ///
9709 /// * `params` - Shell command to run, with optional working directory and timeout in milliseconds.
9710 ///
9711 /// # Returns
9712 ///
9713 /// Identifier of the spawned process, used to correlate streamed output and exit notifications.
9714 ///
9715 /// <div class="warning">
9716 ///
9717 /// **Experimental.** This API is part of an experimental wire-protocol surface
9718 /// and may change or be removed in future SDK or CLI releases. Pin both the
9719 /// SDK and CLI versions if your code depends on it.
9720 ///
9721 /// </div>
9722 pub async fn exec(&self, params: ShellExecRequest) -> Result<ShellExecResult, Error> {
9723 let mut wire_params = serde_json::to_value(params)?;
9724 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9725 let _value = self
9726 .session
9727 .client()
9728 .call(rpc_methods::SESSION_SHELL_EXEC, Some(wire_params))
9729 .await?;
9730 Ok(serde_json::from_value(_value)?)
9731 }
9732
9733 /// 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.
9734 ///
9735 /// Wire method: `session.shell.kill`.
9736 ///
9737 /// # Parameters
9738 ///
9739 /// * `params` - Identifier of a process previously returned by "shell.exec" and the signal to send.
9740 ///
9741 /// # Returns
9742 ///
9743 /// Indicates whether the signal was delivered; false if the process was unknown or already exited.
9744 ///
9745 /// <div class="warning">
9746 ///
9747 /// **Experimental.** This API is part of an experimental wire-protocol surface
9748 /// and may change or be removed in future SDK or CLI releases. Pin both the
9749 /// SDK and CLI versions if your code depends on it.
9750 ///
9751 /// </div>
9752 pub async fn kill(&self, params: ShellKillRequest) -> Result<ShellKillResult, Error> {
9753 let mut wire_params = serde_json::to_value(params)?;
9754 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9755 let _value = self
9756 .session
9757 .client()
9758 .call(rpc_methods::SESSION_SHELL_KILL, Some(wire_params))
9759 .await?;
9760 Ok(serde_json::from_value(_value)?)
9761 }
9762
9763 /// Executes a user-requested shell command through the session runtime.
9764 ///
9765 /// Wire method: `session.shell.executeUserRequested`.
9766 ///
9767 /// # Parameters
9768 ///
9769 /// * `params` - User-requested shell command and cancellation handle.
9770 ///
9771 /// # Returns
9772 ///
9773 /// Result of a user-requested shell command.
9774 ///
9775 /// <div class="warning">
9776 ///
9777 /// **Experimental.** This API is part of an experimental wire-protocol surface
9778 /// and may change or be removed in future SDK or CLI releases. Pin both the
9779 /// SDK and CLI versions if your code depends on it.
9780 ///
9781 /// </div>
9782 pub async fn execute_user_requested(
9783 &self,
9784 params: ShellExecuteUserRequestedRequest,
9785 ) -> Result<UserRequestedShellCommandResult, Error> {
9786 let mut wire_params = serde_json::to_value(params)?;
9787 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9788 let _value = self
9789 .session
9790 .client()
9791 .call(
9792 rpc_methods::SESSION_SHELL_EXECUTEUSERREQUESTED,
9793 Some(wire_params),
9794 )
9795 .await?;
9796 Ok(serde_json::from_value(_value)?)
9797 }
9798
9799 /// Cancels a user-requested shell command by request ID.
9800 ///
9801 /// Wire method: `session.shell.cancelUserRequested`.
9802 ///
9803 /// # Parameters
9804 ///
9805 /// * `params` - User-requested shell execution cancellation handle.
9806 ///
9807 /// # Returns
9808 ///
9809 /// Cancellation result for a user-requested shell command.
9810 ///
9811 /// <div class="warning">
9812 ///
9813 /// **Experimental.** This API is part of an experimental wire-protocol surface
9814 /// and may change or be removed in future SDK or CLI releases. Pin both the
9815 /// SDK and CLI versions if your code depends on it.
9816 ///
9817 /// </div>
9818 pub async fn cancel_user_requested(
9819 &self,
9820 params: ShellCancelUserRequestedRequest,
9821 ) -> Result<CancelUserRequestedShellCommandResult, Error> {
9822 let mut wire_params = serde_json::to_value(params)?;
9823 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9824 let _value = self
9825 .session
9826 .client()
9827 .call(
9828 rpc_methods::SESSION_SHELL_CANCELUSERREQUESTED,
9829 Some(wire_params),
9830 )
9831 .await?;
9832 Ok(serde_json::from_value(_value)?)
9833 }
9834}
9835
9836/// `session.skills.*` RPCs.
9837#[derive(Clone, Copy)]
9838pub struct SessionRpcSkills<'a> {
9839 pub(crate) session: &'a Session,
9840}
9841
9842impl<'a> SessionRpcSkills<'a> {
9843 /// Lists skills available to the session.
9844 ///
9845 /// Wire method: `session.skills.list`.
9846 ///
9847 /// # Returns
9848 ///
9849 /// Skills available to the session, with their enabled state.
9850 ///
9851 /// <div class="warning">
9852 ///
9853 /// **Experimental.** This API is part of an experimental wire-protocol surface
9854 /// and may change or be removed in future SDK or CLI releases. Pin both the
9855 /// SDK and CLI versions if your code depends on it.
9856 ///
9857 /// </div>
9858 pub async fn list(&self) -> Result<SkillList, Error> {
9859 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9860 let _value = self
9861 .session
9862 .client()
9863 .call(rpc_methods::SESSION_SKILLS_LIST, Some(wire_params))
9864 .await?;
9865 Ok(serde_json::from_value(_value)?)
9866 }
9867
9868 /// Returns the skills that have been invoked during this session.
9869 ///
9870 /// Wire method: `session.skills.getInvoked`.
9871 ///
9872 /// # Returns
9873 ///
9874 /// Skills invoked during this session, ordered by invocation time (most recent last).
9875 ///
9876 /// <div class="warning">
9877 ///
9878 /// **Experimental.** This API is part of an experimental wire-protocol surface
9879 /// and may change or be removed in future SDK or CLI releases. Pin both the
9880 /// SDK and CLI versions if your code depends on it.
9881 ///
9882 /// </div>
9883 pub async fn get_invoked(&self) -> Result<SkillsGetInvokedResult, Error> {
9884 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9885 let _value = self
9886 .session
9887 .client()
9888 .call(rpc_methods::SESSION_SKILLS_GETINVOKED, Some(wire_params))
9889 .await?;
9890 Ok(serde_json::from_value(_value)?)
9891 }
9892
9893 /// Enables a skill for the session.
9894 ///
9895 /// Wire method: `session.skills.enable`.
9896 ///
9897 /// # Parameters
9898 ///
9899 /// * `params` - Name of the skill to enable for the session.
9900 ///
9901 /// <div class="warning">
9902 ///
9903 /// **Experimental.** This API is part of an experimental wire-protocol surface
9904 /// and may change or be removed in future SDK or CLI releases. Pin both the
9905 /// SDK and CLI versions if your code depends on it.
9906 ///
9907 /// </div>
9908 pub async fn enable(&self, params: SkillsEnableRequest) -> Result<(), Error> {
9909 let mut wire_params = serde_json::to_value(params)?;
9910 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9911 let _value = self
9912 .session
9913 .client()
9914 .call(rpc_methods::SESSION_SKILLS_ENABLE, Some(wire_params))
9915 .await?;
9916 Ok(())
9917 }
9918
9919 /// Disables a skill for the session.
9920 ///
9921 /// Wire method: `session.skills.disable`.
9922 ///
9923 /// # Parameters
9924 ///
9925 /// * `params` - Name of the skill to disable for the session.
9926 ///
9927 /// <div class="warning">
9928 ///
9929 /// **Experimental.** This API is part of an experimental wire-protocol surface
9930 /// and may change or be removed in future SDK or CLI releases. Pin both the
9931 /// SDK and CLI versions if your code depends on it.
9932 ///
9933 /// </div>
9934 pub async fn disable(&self, params: SkillsDisableRequest) -> Result<(), Error> {
9935 let mut wire_params = serde_json::to_value(params)?;
9936 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9937 let _value = self
9938 .session
9939 .client()
9940 .call(rpc_methods::SESSION_SKILLS_DISABLE, Some(wire_params))
9941 .await?;
9942 Ok(())
9943 }
9944
9945 /// Reloads skill definitions for the session.
9946 ///
9947 /// Wire method: `session.skills.reload`.
9948 ///
9949 /// # Returns
9950 ///
9951 /// Diagnostics from reloading skill definitions, with warnings and errors as separate lists.
9952 ///
9953 /// <div class="warning">
9954 ///
9955 /// **Experimental.** This API is part of an experimental wire-protocol surface
9956 /// and may change or be removed in future SDK or CLI releases. Pin both the
9957 /// SDK and CLI versions if your code depends on it.
9958 ///
9959 /// </div>
9960 pub async fn reload(&self) -> Result<SkillsLoadDiagnostics, Error> {
9961 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9962 let _value = self
9963 .session
9964 .client()
9965 .call(rpc_methods::SESSION_SKILLS_RELOAD, Some(wire_params))
9966 .await?;
9967 Ok(serde_json::from_value(_value)?)
9968 }
9969
9970 /// Ensures the session's skill definitions have been loaded from disk.
9971 ///
9972 /// Wire method: `session.skills.ensureLoaded`.
9973 ///
9974 /// <div class="warning">
9975 ///
9976 /// **Experimental.** This API is part of an experimental wire-protocol surface
9977 /// and may change or be removed in future SDK or CLI releases. Pin both the
9978 /// SDK and CLI versions if your code depends on it.
9979 ///
9980 /// </div>
9981 pub async fn ensure_loaded(&self) -> Result<(), Error> {
9982 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9983 let _value = self
9984 .session
9985 .client()
9986 .call(rpc_methods::SESSION_SKILLS_ENSURELOADED, Some(wire_params))
9987 .await?;
9988 Ok(())
9989 }
9990}
9991
9992/// `session.tasks.*` RPCs.
9993#[derive(Clone, Copy)]
9994pub struct SessionRpcTasks<'a> {
9995 pub(crate) session: &'a Session,
9996}
9997
9998impl<'a> SessionRpcTasks<'a> {
9999 /// Starts a background agent task in the session.
10000 ///
10001 /// Wire method: `session.tasks.startAgent`.
10002 ///
10003 /// # Parameters
10004 ///
10005 /// * `params` - Agent type, prompt, name, and optional description and model override for the new task.
10006 ///
10007 /// # Returns
10008 ///
10009 /// Identifier assigned to the newly started background agent task.
10010 ///
10011 /// <div class="warning">
10012 ///
10013 /// **Experimental.** This API is part of an experimental wire-protocol surface
10014 /// and may change or be removed in future SDK or CLI releases. Pin both the
10015 /// SDK and CLI versions if your code depends on it.
10016 ///
10017 /// </div>
10018 pub async fn start_agent(
10019 &self,
10020 params: TasksStartAgentRequest,
10021 ) -> Result<TasksStartAgentResult, Error> {
10022 let mut wire_params = serde_json::to_value(params)?;
10023 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10024 let _value = self
10025 .session
10026 .client()
10027 .call(rpc_methods::SESSION_TASKS_STARTAGENT, Some(wire_params))
10028 .await?;
10029 Ok(serde_json::from_value(_value)?)
10030 }
10031
10032 /// Lists background tasks tracked by the session.
10033 ///
10034 /// Wire method: `session.tasks.list`.
10035 ///
10036 /// # Returns
10037 ///
10038 /// Background tasks currently tracked by the session.
10039 ///
10040 /// <div class="warning">
10041 ///
10042 /// **Experimental.** This API is part of an experimental wire-protocol surface
10043 /// and may change or be removed in future SDK or CLI releases. Pin both the
10044 /// SDK and CLI versions if your code depends on it.
10045 ///
10046 /// </div>
10047 pub async fn list(&self) -> Result<TaskList, Error> {
10048 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10049 let _value = self
10050 .session
10051 .client()
10052 .call(rpc_methods::SESSION_TASKS_LIST, Some(wire_params))
10053 .await?;
10054 Ok(serde_json::from_value(_value)?)
10055 }
10056
10057 /// Refreshes metadata for any detached background shells the runtime knows about.
10058 ///
10059 /// Wire method: `session.tasks.refresh`.
10060 ///
10061 /// # Returns
10062 ///
10063 /// 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.
10064 ///
10065 /// <div class="warning">
10066 ///
10067 /// **Experimental.** This API is part of an experimental wire-protocol surface
10068 /// and may change or be removed in future SDK or CLI releases. Pin both the
10069 /// SDK and CLI versions if your code depends on it.
10070 ///
10071 /// </div>
10072 pub async fn refresh(&self) -> Result<TasksRefreshResult, Error> {
10073 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10074 let _value = self
10075 .session
10076 .client()
10077 .call(rpc_methods::SESSION_TASKS_REFRESH, Some(wire_params))
10078 .await?;
10079 Ok(serde_json::from_value(_value)?)
10080 }
10081
10082 /// Waits for all in-flight background tasks and any follow-up turns to settle.
10083 ///
10084 /// Wire method: `session.tasks.waitForPending`.
10085 ///
10086 /// # Returns
10087 ///
10088 /// 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).
10089 ///
10090 /// <div class="warning">
10091 ///
10092 /// **Experimental.** This API is part of an experimental wire-protocol surface
10093 /// and may change or be removed in future SDK or CLI releases. Pin both the
10094 /// SDK and CLI versions if your code depends on it.
10095 ///
10096 /// </div>
10097 pub async fn wait_for_pending(&self) -> Result<TasksWaitForPendingResult, Error> {
10098 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10099 let _value = self
10100 .session
10101 .client()
10102 .call(rpc_methods::SESSION_TASKS_WAITFORPENDING, Some(wire_params))
10103 .await?;
10104 Ok(serde_json::from_value(_value)?)
10105 }
10106
10107 /// Returns progress information for a background task by ID.
10108 ///
10109 /// Wire method: `session.tasks.getProgress`.
10110 ///
10111 /// # Parameters
10112 ///
10113 /// * `params` - Identifier of the background task to fetch progress for.
10114 ///
10115 /// # Returns
10116 ///
10117 /// Progress information for the task, or null when no task with that ID is tracked.
10118 ///
10119 /// <div class="warning">
10120 ///
10121 /// **Experimental.** This API is part of an experimental wire-protocol surface
10122 /// and may change or be removed in future SDK or CLI releases. Pin both the
10123 /// SDK and CLI versions if your code depends on it.
10124 ///
10125 /// </div>
10126 pub async fn get_progress(
10127 &self,
10128 params: TasksGetProgressRequest,
10129 ) -> Result<TasksGetProgressResult, Error> {
10130 let mut wire_params = serde_json::to_value(params)?;
10131 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10132 let _value = self
10133 .session
10134 .client()
10135 .call(rpc_methods::SESSION_TASKS_GETPROGRESS, Some(wire_params))
10136 .await?;
10137 Ok(serde_json::from_value(_value)?)
10138 }
10139
10140 /// Returns the first sync-waiting task that can currently be promoted to background mode.
10141 ///
10142 /// Wire method: `session.tasks.getCurrentPromotable`.
10143 ///
10144 /// # Returns
10145 ///
10146 /// The first sync-waiting task that can currently be promoted to background mode.
10147 ///
10148 /// <div class="warning">
10149 ///
10150 /// **Experimental.** This API is part of an experimental wire-protocol surface
10151 /// and may change or be removed in future SDK or CLI releases. Pin both the
10152 /// SDK and CLI versions if your code depends on it.
10153 ///
10154 /// </div>
10155 pub async fn get_current_promotable(&self) -> Result<TasksGetCurrentPromotableResult, Error> {
10156 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10157 let _value = self
10158 .session
10159 .client()
10160 .call(
10161 rpc_methods::SESSION_TASKS_GETCURRENTPROMOTABLE,
10162 Some(wire_params),
10163 )
10164 .await?;
10165 Ok(serde_json::from_value(_value)?)
10166 }
10167
10168 /// Promotes an eligible synchronously-waited task so it continues running in the background.
10169 ///
10170 /// Wire method: `session.tasks.promoteToBackground`.
10171 ///
10172 /// # Parameters
10173 ///
10174 /// * `params` - Identifier of the task to promote to background mode.
10175 ///
10176 /// # Returns
10177 ///
10178 /// Indicates whether the task was successfully promoted to background mode.
10179 ///
10180 /// <div class="warning">
10181 ///
10182 /// **Experimental.** This API is part of an experimental wire-protocol surface
10183 /// and may change or be removed in future SDK or CLI releases. Pin both the
10184 /// SDK and CLI versions if your code depends on it.
10185 ///
10186 /// </div>
10187 pub async fn promote_to_background(
10188 &self,
10189 params: TasksPromoteToBackgroundRequest,
10190 ) -> Result<TasksPromoteToBackgroundResult, Error> {
10191 let mut wire_params = serde_json::to_value(params)?;
10192 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10193 let _value = self
10194 .session
10195 .client()
10196 .call(
10197 rpc_methods::SESSION_TASKS_PROMOTETOBACKGROUND,
10198 Some(wire_params),
10199 )
10200 .await?;
10201 Ok(serde_json::from_value(_value)?)
10202 }
10203
10204 /// Atomically promotes the first promotable sync-waiting task to background mode and returns it.
10205 ///
10206 /// Wire method: `session.tasks.promoteCurrentToBackground`.
10207 ///
10208 /// # Returns
10209 ///
10210 /// The promoted task as it now exists in background mode, omitted if no promotable task was waiting.
10211 ///
10212 /// <div class="warning">
10213 ///
10214 /// **Experimental.** This API is part of an experimental wire-protocol surface
10215 /// and may change or be removed in future SDK or CLI releases. Pin both the
10216 /// SDK and CLI versions if your code depends on it.
10217 ///
10218 /// </div>
10219 pub async fn promote_current_to_background(
10220 &self,
10221 ) -> Result<TasksPromoteCurrentToBackgroundResult, Error> {
10222 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10223 let _value = self
10224 .session
10225 .client()
10226 .call(
10227 rpc_methods::SESSION_TASKS_PROMOTECURRENTTOBACKGROUND,
10228 Some(wire_params),
10229 )
10230 .await?;
10231 Ok(serde_json::from_value(_value)?)
10232 }
10233
10234 /// Cancels a background task.
10235 ///
10236 /// Wire method: `session.tasks.cancel`.
10237 ///
10238 /// # Parameters
10239 ///
10240 /// * `params` - Identifier of the background task to cancel.
10241 ///
10242 /// # Returns
10243 ///
10244 /// Indicates whether the background task was successfully cancelled.
10245 ///
10246 /// <div class="warning">
10247 ///
10248 /// **Experimental.** This API is part of an experimental wire-protocol surface
10249 /// and may change or be removed in future SDK or CLI releases. Pin both the
10250 /// SDK and CLI versions if your code depends on it.
10251 ///
10252 /// </div>
10253 pub async fn cancel(&self, params: TasksCancelRequest) -> Result<TasksCancelResult, Error> {
10254 let mut wire_params = serde_json::to_value(params)?;
10255 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10256 let _value = self
10257 .session
10258 .client()
10259 .call(rpc_methods::SESSION_TASKS_CANCEL, Some(wire_params))
10260 .await?;
10261 Ok(serde_json::from_value(_value)?)
10262 }
10263
10264 /// Removes a completed or cancelled background task from tracking.
10265 ///
10266 /// Wire method: `session.tasks.remove`.
10267 ///
10268 /// # Parameters
10269 ///
10270 /// * `params` - Identifier of the completed or cancelled task to remove from tracking.
10271 ///
10272 /// # Returns
10273 ///
10274 /// Indicates whether the task was removed. False when the task does not exist or is still running/idle.
10275 ///
10276 /// <div class="warning">
10277 ///
10278 /// **Experimental.** This API is part of an experimental wire-protocol surface
10279 /// and may change or be removed in future SDK or CLI releases. Pin both the
10280 /// SDK and CLI versions if your code depends on it.
10281 ///
10282 /// </div>
10283 pub async fn remove(&self, params: TasksRemoveRequest) -> Result<TasksRemoveResult, Error> {
10284 let mut wire_params = serde_json::to_value(params)?;
10285 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10286 let _value = self
10287 .session
10288 .client()
10289 .call(rpc_methods::SESSION_TASKS_REMOVE, Some(wire_params))
10290 .await?;
10291 Ok(serde_json::from_value(_value)?)
10292 }
10293
10294 /// Sends a message to a background agent task.
10295 ///
10296 /// Wire method: `session.tasks.sendMessage`.
10297 ///
10298 /// # Parameters
10299 ///
10300 /// * `params` - Identifier of the target agent task, message content, and optional sender agent ID.
10301 ///
10302 /// # Returns
10303 ///
10304 /// Indicates whether the message was delivered, with an error message when delivery failed.
10305 ///
10306 /// <div class="warning">
10307 ///
10308 /// **Experimental.** This API is part of an experimental wire-protocol surface
10309 /// and may change or be removed in future SDK or CLI releases. Pin both the
10310 /// SDK and CLI versions if your code depends on it.
10311 ///
10312 /// </div>
10313 pub async fn send_message(
10314 &self,
10315 params: TasksSendMessageRequest,
10316 ) -> Result<TasksSendMessageResult, Error> {
10317 let mut wire_params = serde_json::to_value(params)?;
10318 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10319 let _value = self
10320 .session
10321 .client()
10322 .call(rpc_methods::SESSION_TASKS_SENDMESSAGE, Some(wire_params))
10323 .await?;
10324 Ok(serde_json::from_value(_value)?)
10325 }
10326}
10327
10328/// `session.telemetry.*` RPCs.
10329#[derive(Clone, Copy)]
10330pub struct SessionRpcTelemetry<'a> {
10331 pub(crate) session: &'a Session,
10332}
10333
10334impl<'a> SessionRpcTelemetry<'a> {
10335 /// Gets the telemetry engagement ID currently associated with the session, when available.
10336 ///
10337 /// Wire method: `session.telemetry.getEngagementId`.
10338 ///
10339 /// # Returns
10340 ///
10341 /// Telemetry engagement ID for the session, when available.
10342 ///
10343 /// <div class="warning">
10344 ///
10345 /// **Experimental.** This API is part of an experimental wire-protocol surface
10346 /// and may change or be removed in future SDK or CLI releases. Pin both the
10347 /// SDK and CLI versions if your code depends on it.
10348 ///
10349 /// </div>
10350 pub async fn get_engagement_id(&self) -> Result<SessionTelemetryEngagement, Error> {
10351 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10352 let _value = self
10353 .session
10354 .client()
10355 .call(
10356 rpc_methods::SESSION_TELEMETRY_GETENGAGEMENTID,
10357 Some(wire_params),
10358 )
10359 .await?;
10360 Ok(serde_json::from_value(_value)?)
10361 }
10362
10363 /// Sets feature override key/value pairs to attach to subsequent telemetry events for the session.
10364 ///
10365 /// Wire method: `session.telemetry.setFeatureOverrides`.
10366 ///
10367 /// # Parameters
10368 ///
10369 /// * `params` - Feature override key/value pairs to attach to subsequent telemetry events from this session.
10370 ///
10371 /// <div class="warning">
10372 ///
10373 /// **Experimental.** This API is part of an experimental wire-protocol surface
10374 /// and may change or be removed in future SDK or CLI releases. Pin both the
10375 /// SDK and CLI versions if your code depends on it.
10376 ///
10377 /// </div>
10378 pub async fn set_feature_overrides(
10379 &self,
10380 params: TelemetrySetFeatureOverridesRequest,
10381 ) -> Result<(), Error> {
10382 let mut wire_params = serde_json::to_value(params)?;
10383 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10384 let _value = self
10385 .session
10386 .client()
10387 .call(
10388 rpc_methods::SESSION_TELEMETRY_SETFEATUREOVERRIDES,
10389 Some(wire_params),
10390 )
10391 .await?;
10392 Ok(())
10393 }
10394}
10395
10396/// `session.tools.*` RPCs.
10397#[derive(Clone, Copy)]
10398pub struct SessionRpcTools<'a> {
10399 pub(crate) session: &'a Session,
10400}
10401
10402impl<'a> SessionRpcTools<'a> {
10403 /// Executes one tool from the session's currently offered tool set through the native invocation pipeline.
10404 ///
10405 /// Wire method: `session.tools.execute`.
10406 ///
10407 /// # Parameters
10408 ///
10409 /// * `params` - A tool name and arguments to execute through the session's native invocation pipeline.
10410 ///
10411 /// # Returns
10412 ///
10413 /// Canonical result returned by a session tool.
10414 ///
10415 /// <div class="warning">
10416 ///
10417 /// **Experimental.** This API is part of an experimental wire-protocol surface
10418 /// and may change or be removed in future SDK or CLI releases. Pin both the
10419 /// SDK and CLI versions if your code depends on it.
10420 ///
10421 /// </div>
10422 pub async fn execute(&self, params: ToolsExecuteRequest) -> Result<ToolResult, Error> {
10423 let mut wire_params = serde_json::to_value(params)?;
10424 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10425 let _value = self
10426 .session
10427 .client()
10428 .call(rpc_methods::SESSION_TOOLS_EXECUTE, Some(wire_params))
10429 .await?;
10430 Ok(serde_json::from_value(_value)?)
10431 }
10432
10433 /// Returns the Rust-owned built-in tool descriptors used to construct the session's offered tool set.
10434 ///
10435 /// Wire method: `session.tools.getBuiltinDescriptors`.
10436 ///
10437 /// # Parameters
10438 ///
10439 /// * `params` - Options controlling how Rust-owned built-in tool descriptors are materialized.
10440 ///
10441 /// # Returns
10442 ///
10443 /// Rust-owned built-in tool descriptors for the session.
10444 ///
10445 /// <div class="warning">
10446 ///
10447 /// **Experimental.** This API is part of an experimental wire-protocol surface
10448 /// and may change or be removed in future SDK or CLI releases. Pin both the
10449 /// SDK and CLI versions if your code depends on it.
10450 ///
10451 /// </div>
10452 pub async fn get_builtin_descriptors(
10453 &self,
10454 params: ToolsGetBuiltinDescriptorsRequest,
10455 ) -> Result<ToolsGetBuiltinDescriptorsResult, Error> {
10456 let mut wire_params = serde_json::to_value(params)?;
10457 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10458 let _value = self
10459 .session
10460 .client()
10461 .call(
10462 rpc_methods::SESSION_TOOLS_GETBUILTINDESCRIPTORS,
10463 Some(wire_params),
10464 )
10465 .await?;
10466 Ok(serde_json::from_value(_value)?)
10467 }
10468
10469 /// Projects a completed task_complete tool call into its label-safe session event payload.
10470 ///
10471 /// Wire method: `session.tools.taskCompleteEventData`.
10472 ///
10473 /// # Parameters
10474 ///
10475 /// * `params` - Task-completion tool arguments and final result used to build a label-safe session event payload.
10476 ///
10477 /// # Returns
10478 ///
10479 /// Task completion notification with summary from the agent
10480 ///
10481 /// <div class="warning">
10482 ///
10483 /// **Experimental.** This API is part of an experimental wire-protocol surface
10484 /// and may change or be removed in future SDK or CLI releases. Pin both the
10485 /// SDK and CLI versions if your code depends on it.
10486 ///
10487 /// </div>
10488 pub async fn task_complete_event_data(
10489 &self,
10490 params: ToolsTaskCompleteEventDataRequest,
10491 ) -> Result<TaskCompleteData, Error> {
10492 let mut wire_params = serde_json::to_value(params)?;
10493 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10494 let _value = self
10495 .session
10496 .client()
10497 .call(
10498 rpc_methods::SESSION_TOOLS_TASKCOMPLETEEVENTDATA,
10499 Some(wire_params),
10500 )
10501 .await?;
10502 Ok(serde_json::from_value(_value)?)
10503 }
10504
10505 /// Provides the result for a pending external tool call.
10506 ///
10507 /// Wire method: `session.tools.handlePendingToolCall`.
10508 ///
10509 /// # Parameters
10510 ///
10511 /// * `params` - Pending external tool call request ID, with the tool result or an error describing why it failed.
10512 ///
10513 /// # Returns
10514 ///
10515 /// Indicates whether the external tool call result was handled successfully.
10516 ///
10517 /// <div class="warning">
10518 ///
10519 /// **Experimental.** This API is part of an experimental wire-protocol surface
10520 /// and may change or be removed in future SDK or CLI releases. Pin both the
10521 /// SDK and CLI versions if your code depends on it.
10522 ///
10523 /// </div>
10524 pub async fn handle_pending_tool_call(
10525 &self,
10526 params: HandlePendingToolCallRequest,
10527 ) -> Result<HandlePendingToolCallResult, Error> {
10528 let mut wire_params = serde_json::to_value(params)?;
10529 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10530 let _value = self
10531 .session
10532 .client()
10533 .call(
10534 rpc_methods::SESSION_TOOLS_HANDLEPENDINGTOOLCALL,
10535 Some(wire_params),
10536 )
10537 .await?;
10538 Ok(serde_json::from_value(_value)?)
10539 }
10540
10541 /// Resolves, builds, and validates the runtime tool list for the session.
10542 ///
10543 /// Wire method: `session.tools.initializeAndValidate`.
10544 ///
10545 /// # Returns
10546 ///
10547 /// 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.
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 initialize_and_validate(&self) -> Result<ToolsInitializeAndValidateResult, Error> {
10557 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10558 let _value = self
10559 .session
10560 .client()
10561 .call(
10562 rpc_methods::SESSION_TOOLS_INITIALIZEANDVALIDATE,
10563 Some(wire_params),
10564 )
10565 .await?;
10566 Ok(serde_json::from_value(_value)?)
10567 }
10568
10569 /// Returns lightweight metadata for the session's currently initialized tools.
10570 ///
10571 /// Wire method: `session.tools.getCurrentMetadata`.
10572 ///
10573 /// # Returns
10574 ///
10575 /// Current lightweight tool metadata snapshot for the session.
10576 ///
10577 /// <div class="warning">
10578 ///
10579 /// **Experimental.** This API is part of an experimental wire-protocol surface
10580 /// and may change or be removed in future SDK or CLI releases. Pin both the
10581 /// SDK and CLI versions if your code depends on it.
10582 ///
10583 /// </div>
10584 pub async fn get_current_metadata(&self) -> Result<ToolsGetCurrentMetadataResult, Error> {
10585 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10586 let _value = self
10587 .session
10588 .client()
10589 .call(
10590 rpc_methods::SESSION_TOOLS_GETCURRENTMETADATA,
10591 Some(wire_params),
10592 )
10593 .await?;
10594 Ok(serde_json::from_value(_value)?)
10595 }
10596
10597 /// 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.
10598 ///
10599 /// Wire method: `session.tools.set`.
10600 ///
10601 /// # Parameters
10602 ///
10603 /// * `params` - Complete externally implemented tool list for the calling connection. An empty list removes every tool previously supplied by that connection.
10604 ///
10605 /// # Returns
10606 ///
10607 /// Empty result after replacing the calling connection's externally implemented tools.
10608 ///
10609 /// <div class="warning">
10610 ///
10611 /// **Experimental.** This API is part of an experimental wire-protocol surface
10612 /// and may change or be removed in future SDK or CLI releases. Pin both the
10613 /// SDK and CLI versions if your code depends on it.
10614 ///
10615 /// </div>
10616 pub async fn set(&self, params: ToolsSetRequest) -> Result<ToolsSetResult, Error> {
10617 let mut wire_params = serde_json::to_value(params)?;
10618 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10619 let _value = self
10620 .session
10621 .client()
10622 .call(rpc_methods::SESSION_TOOLS_SET, Some(wire_params))
10623 .await?;
10624 Ok(serde_json::from_value(_value)?)
10625 }
10626
10627 /// Updates the current session's live subagent settings after user settings change. The persisted user settings remain the source of truth for future sessions.
10628 ///
10629 /// Wire method: `session.tools.updateSubagentSettings`.
10630 ///
10631 /// # Parameters
10632 ///
10633 /// * `params` - Subagent settings to apply to the current session
10634 ///
10635 /// # Returns
10636 ///
10637 /// Empty result after applying subagent settings
10638 ///
10639 /// <div class="warning">
10640 ///
10641 /// **Experimental.** This API is part of an experimental wire-protocol surface
10642 /// and may change or be removed in future SDK or CLI releases. Pin both the
10643 /// SDK and CLI versions if your code depends on it.
10644 ///
10645 /// </div>
10646 pub async fn update_subagent_settings(
10647 &self,
10648 params: UpdateSubagentSettingsRequest,
10649 ) -> Result<ToolsUpdateSubagentSettingsResult, Error> {
10650 let mut wire_params = serde_json::to_value(params)?;
10651 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10652 let _value = self
10653 .session
10654 .client()
10655 .call(
10656 rpc_methods::SESSION_TOOLS_UPDATESUBAGENTSETTINGS,
10657 Some(wire_params),
10658 )
10659 .await?;
10660 Ok(serde_json::from_value(_value)?)
10661 }
10662}
10663
10664/// `session.ui.*` RPCs.
10665#[derive(Clone, Copy)]
10666pub struct SessionRpcUi<'a> {
10667 pub(crate) session: &'a Session,
10668}
10669
10670impl<'a> SessionRpcUi<'a> {
10671 /// Runs a transient no-tools model query against the current conversation context.
10672 ///
10673 /// Wire method: `session.ui.ephemeralQuery`.
10674 ///
10675 /// # Parameters
10676 ///
10677 /// * `params` - Transient question to answer without adding it to conversation history.
10678 ///
10679 /// # Returns
10680 ///
10681 /// Completed transient query. Ordered chunks and the terminal outcome are also delivered through `ui.ephemeral_query` session events while it runs.
10682 ///
10683 /// <div class="warning">
10684 ///
10685 /// **Experimental.** This API is part of an experimental wire-protocol surface
10686 /// and may change or be removed in future SDK or CLI releases. Pin both the
10687 /// SDK and CLI versions if your code depends on it.
10688 ///
10689 /// </div>
10690 pub async fn ephemeral_query(
10691 &self,
10692 params: UIEphemeralQueryRequest,
10693 ) -> Result<UIEphemeralQueryResult, Error> {
10694 let mut wire_params = serde_json::to_value(params)?;
10695 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10696 let _value = self
10697 .session
10698 .client()
10699 .call(rpc_methods::SESSION_UI_EPHEMERALQUERY, Some(wire_params))
10700 .await?;
10701 Ok(serde_json::from_value(_value)?)
10702 }
10703
10704 /// Requests structured input from a UI-capable client.
10705 ///
10706 /// Wire method: `session.ui.elicitation`.
10707 ///
10708 /// # Parameters
10709 ///
10710 /// * `params` - Prompt message and JSON schema describing the form fields to elicit from the user.
10711 ///
10712 /// # Returns
10713 ///
10714 /// The elicitation response (accept with form values, decline, or cancel)
10715 ///
10716 /// <div class="warning">
10717 ///
10718 /// **Experimental.** This API is part of an experimental wire-protocol surface
10719 /// and may change or be removed in future SDK or CLI releases. Pin both the
10720 /// SDK and CLI versions if your code depends on it.
10721 ///
10722 /// </div>
10723 pub async fn elicitation(
10724 &self,
10725 params: UIElicitationRequest,
10726 ) -> Result<UIElicitationResponse, Error> {
10727 let mut wire_params = serde_json::to_value(params)?;
10728 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10729 let _value = self
10730 .session
10731 .client()
10732 .call(rpc_methods::SESSION_UI_ELICITATION, Some(wire_params))
10733 .await?;
10734 Ok(serde_json::from_value(_value)?)
10735 }
10736
10737 /// Provides the user response for a pending elicitation request.
10738 ///
10739 /// Wire method: `session.ui.handlePendingElicitation`.
10740 ///
10741 /// # Parameters
10742 ///
10743 /// * `params` - Pending elicitation request ID and the user's response (accept/decline/cancel + form values).
10744 ///
10745 /// # Returns
10746 ///
10747 /// Indicates whether the elicitation response was accepted; false if it was already resolved by another client.
10748 ///
10749 /// <div class="warning">
10750 ///
10751 /// **Experimental.** This API is part of an experimental wire-protocol surface
10752 /// and may change or be removed in future SDK or CLI releases. Pin both the
10753 /// SDK and CLI versions if your code depends on it.
10754 ///
10755 /// </div>
10756 pub async fn handle_pending_elicitation(
10757 &self,
10758 params: UIHandlePendingElicitationRequest,
10759 ) -> Result<UIElicitationResult, Error> {
10760 let mut wire_params = serde_json::to_value(params)?;
10761 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10762 let _value = self
10763 .session
10764 .client()
10765 .call(
10766 rpc_methods::SESSION_UI_HANDLEPENDINGELICITATION,
10767 Some(wire_params),
10768 )
10769 .await?;
10770 Ok(serde_json::from_value(_value)?)
10771 }
10772
10773 /// Resolves a pending `user_input.requested` event with the user's response.
10774 ///
10775 /// Wire method: `session.ui.handlePendingUserInput`.
10776 ///
10777 /// # Parameters
10778 ///
10779 /// * `params` - Request ID of a pending `user_input.requested` event and the user's response.
10780 ///
10781 /// # Returns
10782 ///
10783 /// Indicates whether the pending UI request was resolved by this call.
10784 ///
10785 /// <div class="warning">
10786 ///
10787 /// **Experimental.** This API is part of an experimental wire-protocol surface
10788 /// and may change or be removed in future SDK or CLI releases. Pin both the
10789 /// SDK and CLI versions if your code depends on it.
10790 ///
10791 /// </div>
10792 pub async fn handle_pending_user_input(
10793 &self,
10794 params: UIHandlePendingUserInputRequest,
10795 ) -> Result<UIHandlePendingResult, Error> {
10796 let mut wire_params = serde_json::to_value(params)?;
10797 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10798 let _value = self
10799 .session
10800 .client()
10801 .call(
10802 rpc_methods::SESSION_UI_HANDLEPENDINGUSERINPUT,
10803 Some(wire_params),
10804 )
10805 .await?;
10806 Ok(serde_json::from_value(_value)?)
10807 }
10808
10809 /// Resolves a pending `sampling.requested` event with a sampling result, or rejects it.
10810 ///
10811 /// Wire method: `session.ui.handlePendingSampling`.
10812 ///
10813 /// # Parameters
10814 ///
10815 /// * `params` - Request ID of a pending `sampling.requested` event and an optional sampling result payload (omit to reject).
10816 ///
10817 /// # Returns
10818 ///
10819 /// Indicates whether the pending UI request was resolved by this call.
10820 ///
10821 /// <div class="warning">
10822 ///
10823 /// **Experimental.** This API is part of an experimental wire-protocol surface
10824 /// and may change or be removed in future SDK or CLI releases. Pin both the
10825 /// SDK and CLI versions if your code depends on it.
10826 ///
10827 /// </div>
10828 pub async fn handle_pending_sampling(
10829 &self,
10830 params: UIHandlePendingSamplingRequest,
10831 ) -> Result<UIHandlePendingResult, Error> {
10832 let mut wire_params = serde_json::to_value(params)?;
10833 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10834 let _value = self
10835 .session
10836 .client()
10837 .call(
10838 rpc_methods::SESSION_UI_HANDLEPENDINGSAMPLING,
10839 Some(wire_params),
10840 )
10841 .await?;
10842 Ok(serde_json::from_value(_value)?)
10843 }
10844
10845 /// Resolves a pending `auto_mode_switch.requested` event with the user's accept/decline decision.
10846 ///
10847 /// Wire method: `session.ui.handlePendingAutoModeSwitch`.
10848 ///
10849 /// # Parameters
10850 ///
10851 /// * `params` - Request ID of a pending `auto_mode_switch.requested` event and the user's response.
10852 ///
10853 /// # Returns
10854 ///
10855 /// Indicates whether the pending UI request was resolved by this call.
10856 ///
10857 /// <div class="warning">
10858 ///
10859 /// **Experimental.** This API is part of an experimental wire-protocol surface
10860 /// and may change or be removed in future SDK or CLI releases. Pin both the
10861 /// SDK and CLI versions if your code depends on it.
10862 ///
10863 /// </div>
10864 pub async fn handle_pending_auto_mode_switch(
10865 &self,
10866 params: UIHandlePendingAutoModeSwitchRequest,
10867 ) -> Result<UIHandlePendingResult, Error> {
10868 let mut wire_params = serde_json::to_value(params)?;
10869 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10870 let _value = self
10871 .session
10872 .client()
10873 .call(
10874 rpc_methods::SESSION_UI_HANDLEPENDINGAUTOMODESWITCH,
10875 Some(wire_params),
10876 )
10877 .await?;
10878 Ok(serde_json::from_value(_value)?)
10879 }
10880
10881 /// Resolves a pending `session_limits_exhausted.requested` event with the user's selected limit action.
10882 ///
10883 /// Wire method: `session.ui.handlePendingSessionLimitsExhausted`.
10884 ///
10885 /// # Parameters
10886 ///
10887 /// * `params` - Request ID of a pending `session_limits_exhausted.requested` event and the user's selected limit action.
10888 ///
10889 /// # Returns
10890 ///
10891 /// Indicates whether the pending UI request was resolved by this call.
10892 ///
10893 /// <div class="warning">
10894 ///
10895 /// **Experimental.** This API is part of an experimental wire-protocol surface
10896 /// and may change or be removed in future SDK or CLI releases. Pin both the
10897 /// SDK and CLI versions if your code depends on it.
10898 ///
10899 /// </div>
10900 pub async fn handle_pending_session_limits_exhausted(
10901 &self,
10902 params: UIHandlePendingSessionLimitsExhaustedRequest,
10903 ) -> Result<UIHandlePendingResult, Error> {
10904 let mut wire_params = serde_json::to_value(params)?;
10905 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10906 let _value = self
10907 .session
10908 .client()
10909 .call(
10910 rpc_methods::SESSION_UI_HANDLEPENDINGSESSIONLIMITSEXHAUSTED,
10911 Some(wire_params),
10912 )
10913 .await?;
10914 Ok(serde_json::from_value(_value)?)
10915 }
10916
10917 /// Resolves a pending `exit_plan_mode.requested` event with the user's response.
10918 ///
10919 /// Wire method: `session.ui.handlePendingExitPlanMode`.
10920 ///
10921 /// # Parameters
10922 ///
10923 /// * `params` - Request ID of a pending `exit_plan_mode.requested` event and the user's response.
10924 ///
10925 /// # Returns
10926 ///
10927 /// Indicates whether the pending UI request was resolved by this call.
10928 ///
10929 /// <div class="warning">
10930 ///
10931 /// **Experimental.** This API is part of an experimental wire-protocol surface
10932 /// and may change or be removed in future SDK or CLI releases. Pin both the
10933 /// SDK and CLI versions if your code depends on it.
10934 ///
10935 /// </div>
10936 pub async fn handle_pending_exit_plan_mode(
10937 &self,
10938 params: UIHandlePendingExitPlanModeRequest,
10939 ) -> Result<UIHandlePendingResult, Error> {
10940 let mut wire_params = serde_json::to_value(params)?;
10941 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10942 let _value = self
10943 .session
10944 .client()
10945 .call(
10946 rpc_methods::SESSION_UI_HANDLEPENDINGEXITPLANMODE,
10947 Some(wire_params),
10948 )
10949 .await?;
10950 Ok(serde_json::from_value(_value)?)
10951 }
10952
10953 /// Registers an in-process handler for auto-mode-switch requests so the server bridge skips dispatch.
10954 ///
10955 /// Wire method: `session.ui.registerDirectAutoModeSwitchHandler`.
10956 ///
10957 /// # Returns
10958 ///
10959 /// 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).
10960 ///
10961 /// <div class="warning">
10962 ///
10963 /// **Experimental.** This API is part of an experimental wire-protocol surface
10964 /// and may change or be removed in future SDK or CLI releases. Pin both the
10965 /// SDK and CLI versions if your code depends on it.
10966 ///
10967 /// </div>
10968 pub async fn register_direct_auto_mode_switch_handler(
10969 &self,
10970 ) -> Result<UIRegisterDirectAutoModeSwitchHandlerResult, Error> {
10971 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10972 let _value = self
10973 .session
10974 .client()
10975 .call(
10976 rpc_methods::SESSION_UI_REGISTERDIRECTAUTOMODESWITCHHANDLER,
10977 Some(wire_params),
10978 )
10979 .await?;
10980 Ok(serde_json::from_value(_value)?)
10981 }
10982
10983 /// Unregisters a previously-registered in-process auto-mode-switch handler by its opaque handle.
10984 ///
10985 /// Wire method: `session.ui.unregisterDirectAutoModeSwitchHandler`.
10986 ///
10987 /// # Parameters
10988 ///
10989 /// * `params` - Opaque handle previously returned by `registerDirectAutoModeSwitchHandler` to release.
10990 ///
10991 /// # Returns
10992 ///
10993 /// Indicates whether the handle was active and the registration count was decremented.
10994 ///
10995 /// <div class="warning">
10996 ///
10997 /// **Experimental.** This API is part of an experimental wire-protocol surface
10998 /// and may change or be removed in future SDK or CLI releases. Pin both the
10999 /// SDK and CLI versions if your code depends on it.
11000 ///
11001 /// </div>
11002 pub async fn unregister_direct_auto_mode_switch_handler(
11003 &self,
11004 params: UIUnregisterDirectAutoModeSwitchHandlerRequest,
11005 ) -> Result<UIUnregisterDirectAutoModeSwitchHandlerResult, Error> {
11006 let mut wire_params = serde_json::to_value(params)?;
11007 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11008 let _value = self
11009 .session
11010 .client()
11011 .call(
11012 rpc_methods::SESSION_UI_UNREGISTERDIRECTAUTOMODESWITCHHANDLER,
11013 Some(wire_params),
11014 )
11015 .await?;
11016 Ok(serde_json::from_value(_value)?)
11017 }
11018}
11019
11020/// `session.usage.*` RPCs.
11021#[derive(Clone, Copy)]
11022pub struct SessionRpcUsage<'a> {
11023 pub(crate) session: &'a Session,
11024}
11025
11026impl<'a> SessionRpcUsage<'a> {
11027 /// Gets accumulated usage metrics for the session.
11028 ///
11029 /// Wire method: `session.usage.getMetrics`.
11030 ///
11031 /// # Returns
11032 ///
11033 /// Accumulated session usage metrics, including premium request cost, token counts, model breakdown, and code-change totals.
11034 ///
11035 /// <div class="warning">
11036 ///
11037 /// **Experimental.** This API is part of an experimental wire-protocol surface
11038 /// and may change or be removed in future SDK or CLI releases. Pin both the
11039 /// SDK and CLI versions if your code depends on it.
11040 ///
11041 /// </div>
11042 pub async fn get_metrics(&self) -> Result<UsageGetMetricsResult, Error> {
11043 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
11044 let _value = self
11045 .session
11046 .client()
11047 .call(rpc_methods::SESSION_USAGE_GETMETRICS, Some(wire_params))
11048 .await?;
11049 Ok(serde_json::from_value(_value)?)
11050 }
11051}
11052
11053/// `session.visibility.*` RPCs.
11054#[derive(Clone, Copy)]
11055pub struct SessionRpcVisibility<'a> {
11056 pub(crate) session: &'a Session,
11057}
11058
11059impl<'a> SessionRpcVisibility<'a> {
11060 /// 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").
11061 ///
11062 /// Wire method: `session.visibility.get`.
11063 ///
11064 /// # Returns
11065 ///
11066 /// Current sharing status and shareable GitHub URL for a session.
11067 ///
11068 /// <div class="warning">
11069 ///
11070 /// **Experimental.** This API is part of an experimental wire-protocol surface
11071 /// and may change or be removed in future SDK or CLI releases. Pin both the
11072 /// SDK and CLI versions if your code depends on it.
11073 ///
11074 /// </div>
11075 pub async fn get(&self) -> Result<VisibilityGetResult, Error> {
11076 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
11077 let _value = self
11078 .session
11079 .client()
11080 .call(rpc_methods::SESSION_VISIBILITY_GET, Some(wire_params))
11081 .await?;
11082 Ok(serde_json::from_value(_value)?)
11083 }
11084
11085 /// 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.
11086 ///
11087 /// Wire method: `session.visibility.set`.
11088 ///
11089 /// # Parameters
11090 ///
11091 /// * `params` - Desired sharing status for the session.
11092 ///
11093 /// # Returns
11094 ///
11095 /// Effective sharing status and shareable GitHub URL after updating session visibility.
11096 ///
11097 /// <div class="warning">
11098 ///
11099 /// **Experimental.** This API is part of an experimental wire-protocol surface
11100 /// and may change or be removed in future SDK or CLI releases. Pin both the
11101 /// SDK and CLI versions if your code depends on it.
11102 ///
11103 /// </div>
11104 pub async fn set(&self, params: VisibilitySetRequest) -> Result<VisibilitySetResult, Error> {
11105 let mut wire_params = serde_json::to_value(params)?;
11106 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11107 let _value = self
11108 .session
11109 .client()
11110 .call(rpc_methods::SESSION_VISIBILITY_SET, Some(wire_params))
11111 .await?;
11112 Ok(serde_json::from_value(_value)?)
11113 }
11114}
11115
11116/// `session.workspaces.*` RPCs.
11117#[derive(Clone, Copy)]
11118pub struct SessionRpcWorkspaces<'a> {
11119 pub(crate) session: &'a Session,
11120}
11121
11122impl<'a> SessionRpcWorkspaces<'a> {
11123 /// Gets current workspace metadata for the session.
11124 ///
11125 /// Wire method: `session.workspaces.getWorkspace`.
11126 ///
11127 /// # Returns
11128 ///
11129 /// Current workspace metadata for the session, including its absolute filesystem path when available.
11130 ///
11131 /// <div class="warning">
11132 ///
11133 /// **Experimental.** This API is part of an experimental wire-protocol surface
11134 /// and may change or be removed in future SDK or CLI releases. Pin both the
11135 /// SDK and CLI versions if your code depends on it.
11136 ///
11137 /// </div>
11138 pub async fn get_workspace(&self) -> Result<WorkspacesGetWorkspaceResult, Error> {
11139 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
11140 let _value = self
11141 .session
11142 .client()
11143 .call(
11144 rpc_methods::SESSION_WORKSPACES_GETWORKSPACE,
11145 Some(wire_params),
11146 )
11147 .await?;
11148 Ok(serde_json::from_value(_value)?)
11149 }
11150
11151 /// Updates workspace metadata for a local session and returns the refreshed workspace.
11152 ///
11153 /// Wire method: `session.workspaces.updateMetadata`.
11154 ///
11155 /// # Parameters
11156 ///
11157 /// * `params` - Workspace metadata fields to update.
11158 ///
11159 /// # Returns
11160 ///
11161 /// Current workspace metadata for the session, including its absolute filesystem path when available.
11162 ///
11163 /// <div class="warning">
11164 ///
11165 /// **Experimental.** This API is part of an experimental wire-protocol surface
11166 /// and may change or be removed in future SDK or CLI releases. Pin both the
11167 /// SDK and CLI versions if your code depends on it.
11168 ///
11169 /// </div>
11170 pub async fn update_metadata(
11171 &self,
11172 params: WorkspacesUpdateMetadataRequest,
11173 ) -> Result<WorkspacesGetWorkspaceResult, Error> {
11174 let mut wire_params = serde_json::to_value(params)?;
11175 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11176 let _value = self
11177 .session
11178 .client()
11179 .call(
11180 rpc_methods::SESSION_WORKSPACES_UPDATEMETADATA,
11181 Some(wire_params),
11182 )
11183 .await?;
11184 Ok(serde_json::from_value(_value)?)
11185 }
11186
11187 /// Ensures a local session workspace exists and returns it.
11188 ///
11189 /// Wire method: `session.workspaces.ensure`.
11190 ///
11191 /// # Parameters
11192 ///
11193 /// * `params` - Optional session context used when creating a local workspace.
11194 ///
11195 /// # Returns
11196 ///
11197 /// Current workspace metadata for the session, including its absolute filesystem path when available.
11198 ///
11199 /// <div class="warning">
11200 ///
11201 /// **Experimental.** This API is part of an experimental wire-protocol surface
11202 /// and may change or be removed in future SDK or CLI releases. Pin both the
11203 /// SDK and CLI versions if your code depends on it.
11204 ///
11205 /// </div>
11206 pub async fn ensure(
11207 &self,
11208 params: WorkspacesEnsureRequest,
11209 ) -> Result<WorkspacesGetWorkspaceResult, Error> {
11210 let mut wire_params = serde_json::to_value(params)?;
11211 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11212 let _value = self
11213 .session
11214 .client()
11215 .call(rpc_methods::SESSION_WORKSPACES_ENSURE, Some(wire_params))
11216 .await?;
11217 Ok(serde_json::from_value(_value)?)
11218 }
11219
11220 /// Lists files stored in the session workspace files directory.
11221 ///
11222 /// Wire method: `session.workspaces.listFiles`.
11223 ///
11224 /// # Returns
11225 ///
11226 /// Relative paths of files stored in the session workspace files directory.
11227 ///
11228 /// <div class="warning">
11229 ///
11230 /// **Experimental.** This API is part of an experimental wire-protocol surface
11231 /// and may change or be removed in future SDK or CLI releases. Pin both the
11232 /// SDK and CLI versions if your code depends on it.
11233 ///
11234 /// </div>
11235 pub async fn list_files(&self) -> Result<WorkspacesListFilesResult, Error> {
11236 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
11237 let _value = self
11238 .session
11239 .client()
11240 .call(rpc_methods::SESSION_WORKSPACES_LISTFILES, Some(wire_params))
11241 .await?;
11242 Ok(serde_json::from_value(_value)?)
11243 }
11244
11245 /// Reads a file from the session workspace files directory.
11246 ///
11247 /// Wire method: `session.workspaces.readFile`.
11248 ///
11249 /// # Parameters
11250 ///
11251 /// * `params` - Relative path of the workspace file to read.
11252 ///
11253 /// # Returns
11254 ///
11255 /// Contents of the requested workspace file as a UTF-8 string.
11256 ///
11257 /// <div class="warning">
11258 ///
11259 /// **Experimental.** This API is part of an experimental wire-protocol surface
11260 /// and may change or be removed in future SDK or CLI releases. Pin both the
11261 /// SDK and CLI versions if your code depends on it.
11262 ///
11263 /// </div>
11264 pub async fn read_file(
11265 &self,
11266 params: WorkspacesReadFileRequest,
11267 ) -> Result<WorkspacesReadFileResult, Error> {
11268 let mut wire_params = serde_json::to_value(params)?;
11269 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11270 let _value = self
11271 .session
11272 .client()
11273 .call(rpc_methods::SESSION_WORKSPACES_READFILE, Some(wire_params))
11274 .await?;
11275 Ok(serde_json::from_value(_value)?)
11276 }
11277
11278 /// Creates or overwrites a file in the session workspace files directory.
11279 ///
11280 /// Wire method: `session.workspaces.createFile`.
11281 ///
11282 /// # Parameters
11283 ///
11284 /// * `params` - Relative path and UTF-8 content for the workspace file to create or overwrite.
11285 ///
11286 /// <div class="warning">
11287 ///
11288 /// **Experimental.** This API is part of an experimental wire-protocol surface
11289 /// and may change or be removed in future SDK or CLI releases. Pin both the
11290 /// SDK and CLI versions if your code depends on it.
11291 ///
11292 /// </div>
11293 pub async fn create_file(&self, params: WorkspacesCreateFileRequest) -> Result<(), Error> {
11294 let mut wire_params = serde_json::to_value(params)?;
11295 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11296 let _value = self
11297 .session
11298 .client()
11299 .call(
11300 rpc_methods::SESSION_WORKSPACES_CREATEFILE,
11301 Some(wire_params),
11302 )
11303 .await?;
11304 Ok(())
11305 }
11306
11307 /// Lists workspace checkpoints in chronological order.
11308 ///
11309 /// Wire method: `session.workspaces.listCheckpoints`.
11310 ///
11311 /// # Returns
11312 ///
11313 /// Workspace checkpoints in chronological order; empty when the workspace is not enabled.
11314 ///
11315 /// <div class="warning">
11316 ///
11317 /// **Experimental.** This API is part of an experimental wire-protocol surface
11318 /// and may change or be removed in future SDK or CLI releases. Pin both the
11319 /// SDK and CLI versions if your code depends on it.
11320 ///
11321 /// </div>
11322 pub async fn list_checkpoints(&self) -> Result<WorkspacesListCheckpointsResult, Error> {
11323 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
11324 let _value = self
11325 .session
11326 .client()
11327 .call(
11328 rpc_methods::SESSION_WORKSPACES_LISTCHECKPOINTS,
11329 Some(wire_params),
11330 )
11331 .await?;
11332 Ok(serde_json::from_value(_value)?)
11333 }
11334
11335 /// Reads the content of a workspace checkpoint by number.
11336 ///
11337 /// Wire method: `session.workspaces.readCheckpoint`.
11338 ///
11339 /// # Parameters
11340 ///
11341 /// * `params` - Checkpoint number to read.
11342 ///
11343 /// # Returns
11344 ///
11345 /// Checkpoint content as a UTF-8 string, or null when the checkpoint or workspace is missing.
11346 ///
11347 /// <div class="warning">
11348 ///
11349 /// **Experimental.** This API is part of an experimental wire-protocol surface
11350 /// and may change or be removed in future SDK or CLI releases. Pin both the
11351 /// SDK and CLI versions if your code depends on it.
11352 ///
11353 /// </div>
11354 pub async fn read_checkpoint(
11355 &self,
11356 params: WorkspacesReadCheckpointRequest,
11357 ) -> Result<WorkspacesReadCheckpointResult, Error> {
11358 let mut wire_params = serde_json::to_value(params)?;
11359 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11360 let _value = self
11361 .session
11362 .client()
11363 .call(
11364 rpc_methods::SESSION_WORKSPACES_READCHECKPOINT,
11365 Some(wire_params),
11366 )
11367 .await?;
11368 Ok(serde_json::from_value(_value)?)
11369 }
11370
11371 /// Adds a compaction summary checkpoint to the local session workspace.
11372 ///
11373 /// Wire method: `session.workspaces.addSummary`.
11374 ///
11375 /// # Parameters
11376 ///
11377 /// * `params` - Compaction summary checkpoint to persist.
11378 ///
11379 /// # Returns
11380 ///
11381 /// Persisted summary metadata and refreshed workspace metadata.
11382 ///
11383 /// <div class="warning">
11384 ///
11385 /// **Experimental.** This API is part of an experimental wire-protocol surface
11386 /// and may change or be removed in future SDK or CLI releases. Pin both the
11387 /// SDK and CLI versions if your code depends on it.
11388 ///
11389 /// </div>
11390 pub async fn add_summary(
11391 &self,
11392 params: WorkspacesAddSummaryRequest,
11393 ) -> Result<WorkspacesAddSummaryResult, Error> {
11394 let mut wire_params = serde_json::to_value(params)?;
11395 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11396 let _value = self
11397 .session
11398 .client()
11399 .call(
11400 rpc_methods::SESSION_WORKSPACES_ADDSUMMARY,
11401 Some(wire_params),
11402 )
11403 .await?;
11404 Ok(serde_json::from_value(_value)?)
11405 }
11406
11407 /// Truncates local workspace compaction summaries after a rollback.
11408 ///
11409 /// Wire method: `session.workspaces.truncateSummaries`.
11410 ///
11411 /// # Parameters
11412 ///
11413 /// * `params` - Rollback point for local workspace summaries.
11414 ///
11415 /// # Returns
11416 ///
11417 /// Current workspace metadata for the session, including its absolute filesystem path when available.
11418 ///
11419 /// <div class="warning">
11420 ///
11421 /// **Experimental.** This API is part of an experimental wire-protocol surface
11422 /// and may change or be removed in future SDK or CLI releases. Pin both the
11423 /// SDK and CLI versions if your code depends on it.
11424 ///
11425 /// </div>
11426 pub async fn truncate_summaries(
11427 &self,
11428 params: WorkspacesTruncateSummariesRequest,
11429 ) -> Result<WorkspacesGetWorkspaceResult, Error> {
11430 let mut wire_params = serde_json::to_value(params)?;
11431 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11432 let _value = self
11433 .session
11434 .client()
11435 .call(
11436 rpc_methods::SESSION_WORKSPACES_TRUNCATESUMMARIES,
11437 Some(wire_params),
11438 )
11439 .await?;
11440 Ok(serde_json::from_value(_value)?)
11441 }
11442
11443 /// Reads the autopilot objective state file from the local session workspace.
11444 ///
11445 /// Wire method: `session.workspaces.readAutopilotObjective`.
11446 ///
11447 /// # Returns
11448 ///
11449 /// Autopilot objective file content, or null when missing.
11450 ///
11451 /// <div class="warning">
11452 ///
11453 /// **Experimental.** This API is part of an experimental wire-protocol surface
11454 /// and may change or be removed in future SDK or CLI releases. Pin both the
11455 /// SDK and CLI versions if your code depends on it.
11456 ///
11457 /// </div>
11458 pub async fn read_autopilot_objective(
11459 &self,
11460 ) -> Result<WorkspacesReadAutopilotObjectiveResult, Error> {
11461 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
11462 let _value = self
11463 .session
11464 .client()
11465 .call(
11466 rpc_methods::SESSION_WORKSPACES_READAUTOPILOTOBJECTIVE,
11467 Some(wire_params),
11468 )
11469 .await?;
11470 Ok(serde_json::from_value(_value)?)
11471 }
11472
11473 /// Writes the autopilot objective state file in the local session workspace.
11474 ///
11475 /// Wire method: `session.workspaces.writeAutopilotObjective`.
11476 ///
11477 /// # Parameters
11478 ///
11479 /// * `params` - Autopilot objective file content to persist.
11480 ///
11481 /// # Returns
11482 ///
11483 /// Result of writing the autopilot objective file.
11484 ///
11485 /// <div class="warning">
11486 ///
11487 /// **Experimental.** This API is part of an experimental wire-protocol surface
11488 /// and may change or be removed in future SDK or CLI releases. Pin both the
11489 /// SDK and CLI versions if your code depends on it.
11490 ///
11491 /// </div>
11492 pub async fn write_autopilot_objective(
11493 &self,
11494 params: WorkspacesWriteAutopilotObjectiveRequest,
11495 ) -> Result<WorkspacesWriteAutopilotObjectiveResult, Error> {
11496 let mut wire_params = serde_json::to_value(params)?;
11497 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11498 let _value = self
11499 .session
11500 .client()
11501 .call(
11502 rpc_methods::SESSION_WORKSPACES_WRITEAUTOPILOTOBJECTIVE,
11503 Some(wire_params),
11504 )
11505 .await?;
11506 Ok(serde_json::from_value(_value)?)
11507 }
11508
11509 /// Deletes the autopilot objective state file from the local session workspace.
11510 ///
11511 /// Wire method: `session.workspaces.deleteAutopilotObjective`.
11512 ///
11513 /// # Returns
11514 ///
11515 /// Result of deleting the autopilot objective file.
11516 ///
11517 /// <div class="warning">
11518 ///
11519 /// **Experimental.** This API is part of an experimental wire-protocol surface
11520 /// and may change or be removed in future SDK or CLI releases. Pin both the
11521 /// SDK and CLI versions if your code depends on it.
11522 ///
11523 /// </div>
11524 pub async fn delete_autopilot_objective(
11525 &self,
11526 ) -> Result<WorkspacesDeleteAutopilotObjectiveResult, Error> {
11527 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
11528 let _value = self
11529 .session
11530 .client()
11531 .call(
11532 rpc_methods::SESSION_WORKSPACES_DELETEAUTOPILOTOBJECTIVE,
11533 Some(wire_params),
11534 )
11535 .await?;
11536 Ok(serde_json::from_value(_value)?)
11537 }
11538
11539 /// Checks whether the local session workspace has an autopilot objective state file.
11540 ///
11541 /// Wire method: `session.workspaces.autopilotObjectiveExists`.
11542 ///
11543 /// # Returns
11544 ///
11545 /// Whether the autopilot objective file exists.
11546 ///
11547 /// <div class="warning">
11548 ///
11549 /// **Experimental.** This API is part of an experimental wire-protocol surface
11550 /// and may change or be removed in future SDK or CLI releases. Pin both the
11551 /// SDK and CLI versions if your code depends on it.
11552 ///
11553 /// </div>
11554 pub async fn autopilot_objective_exists(
11555 &self,
11556 ) -> Result<WorkspacesAutopilotObjectiveExistsResult, Error> {
11557 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
11558 let _value = self
11559 .session
11560 .client()
11561 .call(
11562 rpc_methods::SESSION_WORKSPACES_AUTOPILOTOBJECTIVEEXISTS,
11563 Some(wire_params),
11564 )
11565 .await?;
11566 Ok(serde_json::from_value(_value)?)
11567 }
11568
11569 /// Saves pasted content as a UTF-8 file in the session workspace.
11570 ///
11571 /// Wire method: `session.workspaces.saveLargePaste`.
11572 ///
11573 /// # Parameters
11574 ///
11575 /// * `params` - Pasted content to save as a UTF-8 file in the session workspace.
11576 ///
11577 /// # Returns
11578 ///
11579 /// Descriptor for the saved paste file, or null when the workspace is unavailable.
11580 ///
11581 /// <div class="warning">
11582 ///
11583 /// **Experimental.** This API is part of an experimental wire-protocol surface
11584 /// and may change or be removed in future SDK or CLI releases. Pin both the
11585 /// SDK and CLI versions if your code depends on it.
11586 ///
11587 /// </div>
11588 pub async fn save_large_paste(
11589 &self,
11590 params: WorkspacesSaveLargePasteRequest,
11591 ) -> Result<WorkspacesSaveLargePasteResult, Error> {
11592 let mut wire_params = serde_json::to_value(params)?;
11593 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11594 let _value = self
11595 .session
11596 .client()
11597 .call(
11598 rpc_methods::SESSION_WORKSPACES_SAVELARGEPASTE,
11599 Some(wire_params),
11600 )
11601 .await?;
11602 Ok(serde_json::from_value(_value)?)
11603 }
11604
11605 /// 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`.
11606 ///
11607 /// Wire method: `session.workspaces.diff`.
11608 ///
11609 /// # Parameters
11610 ///
11611 /// * `params` - Parameters for computing a workspace diff.
11612 ///
11613 /// # Returns
11614 ///
11615 /// Workspace diff result for the requested mode.
11616 ///
11617 /// <div class="warning">
11618 ///
11619 /// **Experimental.** This API is part of an experimental wire-protocol surface
11620 /// and may change or be removed in future SDK or CLI releases. Pin both the
11621 /// SDK and CLI versions if your code depends on it.
11622 ///
11623 /// </div>
11624 pub async fn diff(&self, params: WorkspacesDiffRequest) -> Result<WorkspaceDiffResult, Error> {
11625 let mut wire_params = serde_json::to_value(params)?;
11626 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11627 let _value = self
11628 .session
11629 .client()
11630 .call(rpc_methods::SESSION_WORKSPACES_DIFF, Some(wire_params))
11631 .await?;
11632 Ok(serde_json::from_value(_value)?)
11633 }
11634}