github_copilot_sdk/generated/rpc.rs
1//! Auto-generated typed JSON-RPC namespace — do not edit manually.
2//!
3//! Generated from `api.schema.json` by `scripts/codegen/rust.ts`. The
4//! [`ClientRpc`] and [`SessionRpc`] view structs let callers reach every
5//! protocol method through a typed namespace tree, so wire method names
6//! and request/response shapes live in exactly one place — this file.
7
8#![allow(missing_docs)]
9#![allow(clippy::too_many_arguments)]
10#![allow(deprecated)]
11#![allow(dead_code)]
12
13use super::api_types::{rpc_methods, *};
14use super::session_events::SessionMode;
15use crate::session::Session;
16use crate::{Client, Error};
17
18/// Typed view over the [`Client`]'s server-level RPC namespace.
19#[derive(Clone, Copy)]
20pub struct ClientRpc<'a> {
21 pub(crate) client: &'a Client,
22}
23
24impl<'a> ClientRpc<'a> {
25 /// `account.*` sub-namespace.
26 pub fn account(&self) -> ClientRpcAccount<'a> {
27 ClientRpcAccount {
28 client: self.client,
29 }
30 }
31
32 /// `agentRegistry.*` sub-namespace.
33 pub fn agent_registry(&self) -> ClientRpcAgentRegistry<'a> {
34 ClientRpcAgentRegistry {
35 client: self.client,
36 }
37 }
38
39 /// `agents.*` sub-namespace.
40 pub fn agents(&self) -> ClientRpcAgents<'a> {
41 ClientRpcAgents {
42 client: self.client,
43 }
44 }
45
46 /// `catalog.*` sub-namespace.
47 pub fn catalog(&self) -> ClientRpcCatalog<'a> {
48 ClientRpcCatalog {
49 client: self.client,
50 }
51 }
52
53 /// `commands.*` sub-namespace.
54 pub fn commands(&self) -> ClientRpcCommands<'a> {
55 ClientRpcCommands {
56 client: self.client,
57 }
58 }
59
60 /// `extensions.*` sub-namespace.
61 pub fn extensions(&self) -> ClientRpcExtensions<'a> {
62 ClientRpcExtensions {
63 client: self.client,
64 }
65 }
66
67 /// `hooks.*` sub-namespace.
68 pub fn hooks(&self) -> ClientRpcHooks<'a> {
69 ClientRpcHooks {
70 client: self.client,
71 }
72 }
73
74 /// `instructions.*` sub-namespace.
75 pub fn instructions(&self) -> ClientRpcInstructions<'a> {
76 ClientRpcInstructions {
77 client: self.client,
78 }
79 }
80
81 /// `llmInference.*` sub-namespace.
82 pub fn llm_inference(&self) -> ClientRpcLlmInference<'a> {
83 ClientRpcLlmInference {
84 client: self.client,
85 }
86 }
87
88 /// `managedSettings.*` sub-namespace.
89 pub fn managed_settings(&self) -> ClientRpcManagedSettings<'a> {
90 ClientRpcManagedSettings {
91 client: self.client,
92 }
93 }
94
95 /// `mcp.*` sub-namespace.
96 pub fn mcp(&self) -> ClientRpcMcp<'a> {
97 ClientRpcMcp {
98 client: self.client,
99 }
100 }
101
102 /// `models.*` sub-namespace.
103 pub fn models(&self) -> ClientRpcModels<'a> {
104 ClientRpcModels {
105 client: self.client,
106 }
107 }
108
109 /// `plugins.*` sub-namespace.
110 pub fn plugins(&self) -> ClientRpcPlugins<'a> {
111 ClientRpcPlugins {
112 client: self.client,
113 }
114 }
115
116 /// `runtime.*` sub-namespace.
117 pub fn runtime(&self) -> ClientRpcRuntime<'a> {
118 ClientRpcRuntime {
119 client: self.client,
120 }
121 }
122
123 /// `secrets.*` sub-namespace.
124 pub fn secrets(&self) -> ClientRpcSecrets<'a> {
125 ClientRpcSecrets {
126 client: self.client,
127 }
128 }
129
130 /// `sessionFs.*` sub-namespace.
131 pub fn session_fs(&self) -> ClientRpcSessionFs<'a> {
132 ClientRpcSessionFs {
133 client: self.client,
134 }
135 }
136
137 /// `sessions.*` sub-namespace.
138 pub fn sessions(&self) -> ClientRpcSessions<'a> {
139 ClientRpcSessions {
140 client: self.client,
141 }
142 }
143
144 /// `skills.*` sub-namespace.
145 pub fn skills(&self) -> ClientRpcSkills<'a> {
146 ClientRpcSkills {
147 client: self.client,
148 }
149 }
150
151 /// `tools.*` sub-namespace.
152 pub fn tools(&self) -> ClientRpcTools<'a> {
153 ClientRpcTools {
154 client: self.client,
155 }
156 }
157
158 /// `user.*` sub-namespace.
159 pub fn user(&self) -> ClientRpcUser<'a> {
160 ClientRpcUser {
161 client: self.client,
162 }
163 }
164
165 /// Checks server responsiveness and returns protocol information.
166 ///
167 /// Wire method: `ping`.
168 ///
169 /// # Parameters
170 ///
171 /// * `params` - Optional message to echo back to the caller.
172 ///
173 /// # Returns
174 ///
175 /// Server liveness response, including the echoed message, current server timestamp, and protocol version.
176 ///
177 /// <div class="warning">
178 ///
179 /// **Experimental.** This API is part of an experimental wire-protocol surface
180 /// and may change or be removed in future SDK or CLI releases. Pin both the
181 /// SDK and CLI versions if your code depends on it.
182 ///
183 /// </div>
184 pub async fn ping(&self, params: PingRequest) -> Result<PingResult, Error> {
185 let wire_params = serde_json::to_value(params)?;
186 let _value = self
187 .client
188 .call(rpc_methods::PING, Some(wire_params))
189 .await?;
190 Ok(serde_json::from_value(_value)?)
191 }
192
193 /// Performs the SDK server connection handshake and validates the optional connection token. Marked internal because this is JSON-RPC transport plumbing invoked automatically by an SDK client's own `connect()` wrapper, not a user-facing method. Stays internal as long as the SDK client owns the handshake; would only become public if the SDK ever exposed the raw schema surface to consumers without a connection wrapper.
194 ///
195 /// Wire method: `connect`.
196 ///
197 /// # Parameters
198 ///
199 /// * `params` - Connection-level opt-ins for the `server.connect` handshake. Transport authentication is consumed by the native protocol boundary before dispatch.
200 ///
201 /// # Returns
202 ///
203 /// Handshake result reporting the server's protocol version and package version on success.
204 ///
205 /// <div class="warning">
206 ///
207 /// **Experimental.** This API is part of an experimental wire-protocol surface
208 /// and may change or be removed in future SDK or CLI releases. Pin both the
209 /// SDK and CLI versions if your code depends on it.
210 ///
211 /// </div>
212 pub(crate) async fn connect(&self, params: ConnectRequest) -> Result<ConnectResult, Error> {
213 let wire_params = serde_json::to_value(params)?;
214 let _value = self
215 .client
216 .call(rpc_methods::CONNECT, Some(wire_params))
217 .await?;
218 Ok(serde_json::from_value(_value)?)
219 }
220
221 /// Registers the calling SDK client as the per-entrypoint extension launch provider. Call before creating any sessions. When omitted, the runtime uses its built-in extension launcher.
222 ///
223 /// Wire method: `registerExtensionLaunchProvider`.
224 ///
225 /// <div class="warning">
226 ///
227 /// **Experimental.** This API is part of an experimental wire-protocol surface
228 /// and may change or be removed in future SDK or CLI releases. Pin both the
229 /// SDK and CLI versions if your code depends on it.
230 ///
231 /// </div>
232 pub async fn register_extension_launch_provider(&self) -> Result<(), Error> {
233 let wire_params = serde_json::json!({});
234 let _value = self
235 .client
236 .call(
237 rpc_methods::REGISTEREXTENSIONLAUNCHPROVIDER,
238 Some(wire_params),
239 )
240 .await?;
241 Ok(())
242 }
243}
244
245/// `account.*` RPCs.
246#[derive(Clone, Copy)]
247pub struct ClientRpcAccount<'a> {
248 pub(crate) client: &'a Client,
249}
250
251impl<'a> ClientRpcAccount<'a> {
252 /// Gets Copilot quota usage for the current or opaquely selected authenticated user.
253 ///
254 /// Wire method: `account.getQuota`.
255 ///
256 /// # Returns
257 ///
258 /// Quota usage snapshots for the resolved user, keyed by quota type.
259 ///
260 /// <div class="warning">
261 ///
262 /// **Experimental.** This API is part of an experimental wire-protocol surface
263 /// and may change or be removed in future SDK or CLI releases. Pin both the
264 /// SDK and CLI versions if your code depends on it.
265 ///
266 /// </div>
267 pub async fn get_quota(&self) -> Result<AccountGetQuotaResult, Error> {
268 let wire_params = serde_json::json!({});
269 let _value = self
270 .client
271 .call(rpc_methods::ACCOUNT_GETQUOTA, Some(wire_params))
272 .await?;
273 Ok(serde_json::from_value(_value)?)
274 }
275
276 /// Gets Copilot quota usage for the current or opaquely selected authenticated user.
277 ///
278 /// Wire method: `account.getQuota`.
279 ///
280 /// # Parameters
281 ///
282 /// * `params` - Optional opaque account selection or compatibility GitHub token used to look up quota.
283 ///
284 /// # Returns
285 ///
286 /// Quota usage snapshots for the resolved user, keyed by quota type.
287 ///
288 /// <div class="warning">
289 ///
290 /// **Experimental.** This API is part of an experimental wire-protocol surface
291 /// and may change or be removed in future SDK or CLI releases. Pin both the
292 /// SDK and CLI versions if your code depends on it.
293 ///
294 /// </div>
295 pub async fn get_quota_with_params(
296 &self,
297 params: AccountGetQuotaRequest,
298 ) -> Result<AccountGetQuotaResult, Error> {
299 let wire_params = serde_json::to_value(params)?;
300 let _value = self
301 .client
302 .call(rpc_methods::ACCOUNT_GETQUOTA, Some(wire_params))
303 .await?;
304 Ok(serde_json::from_value(_value)?)
305 }
306
307 /// Gets the currently active authentication credentials from the global auth manager.
308 ///
309 /// Wire method: `account.getCurrentAuth`.
310 ///
311 /// # Returns
312 ///
313 /// Current authentication state
314 ///
315 /// <div class="warning">
316 ///
317 /// **Experimental.** This API is part of an experimental wire-protocol surface
318 /// and may change or be removed in future SDK or CLI releases. Pin both the
319 /// SDK and CLI versions if your code depends on it.
320 ///
321 /// </div>
322 pub async fn get_current_auth(&self) -> Result<AccountGetCurrentAuthResult, Error> {
323 let wire_params = serde_json::json!({});
324 let _value = self
325 .client
326 .call(rpc_methods::ACCOUNT_GETCURRENTAUTH, Some(wire_params))
327 .await?;
328 Ok(serde_json::from_value(_value)?)
329 }
330
331 /// Gets all authenticated users available for account switching.
332 ///
333 /// Wire method: `account.getAllUsers`.
334 ///
335 /// # Returns
336 ///
337 /// List of all authenticated users
338 ///
339 /// <div class="warning">
340 ///
341 /// **Experimental.** This API is part of an experimental wire-protocol surface
342 /// and may change or be removed in future SDK or CLI releases. Pin both the
343 /// SDK and CLI versions if your code depends on it.
344 ///
345 /// </div>
346 pub async fn get_all_users(&self) -> Result<AccountGetAllUsersResult, Error> {
347 let wire_params = serde_json::json!({});
348 let _value = self
349 .client
350 .call(rpc_methods::ACCOUNT_GETALLUSERS, Some(wire_params))
351 .await?;
352 Ok(serde_json::from_value(_value)?)
353 }
354
355 /// Validates and stores authentication credentials. When login is omitted, resolves the authenticated user from the token before persistence.
356 ///
357 /// Wire method: `account.login`.
358 ///
359 /// # Parameters
360 ///
361 /// * `params` - Credentials to validate and store. Omit login to resolve the authenticated user from the token.
362 ///
363 /// # Returns
364 ///
365 /// Result of a successful login; throws on failure
366 ///
367 /// <div class="warning">
368 ///
369 /// **Experimental.** This API is part of an experimental wire-protocol surface
370 /// and may change or be removed in future SDK or CLI releases. Pin both the
371 /// SDK and CLI versions if your code depends on it.
372 ///
373 /// </div>
374 pub async fn login(&self, params: AccountLoginRequest) -> Result<AccountLoginResult, Error> {
375 let wire_params = serde_json::to_value(params)?;
376 let _value = self
377 .client
378 .call(rpc_methods::ACCOUNT_LOGIN, Some(wire_params))
379 .await?;
380 Ok(serde_json::from_value(_value)?)
381 }
382
383 /// Removes user authentication from keychain and persisted state.
384 ///
385 /// Wire method: `account.logout`.
386 ///
387 /// # Parameters
388 ///
389 /// * `params` - User to log out
390 ///
391 /// # Returns
392 ///
393 /// Logout result indicating if more users remain
394 ///
395 /// <div class="warning">
396 ///
397 /// **Experimental.** This API is part of an experimental wire-protocol surface
398 /// and may change or be removed in future SDK or CLI releases. Pin both the
399 /// SDK and CLI versions if your code depends on it.
400 ///
401 /// </div>
402 pub async fn logout(&self, params: AccountLogoutRequest) -> Result<AccountLogoutResult, Error> {
403 let wire_params = serde_json::to_value(params)?;
404 let _value = self
405 .client
406 .call(rpc_methods::ACCOUNT_LOGOUT, Some(wire_params))
407 .await?;
408 Ok(serde_json::from_value(_value)?)
409 }
410}
411
412/// `agentRegistry.*` RPCs.
413#[derive(Clone, Copy)]
414pub struct ClientRpcAgentRegistry<'a> {
415 pub(crate) client: &'a Client,
416}
417
418impl<'a> ClientRpcAgentRegistry<'a> {
419 /// Spawns a managed-server child with the supplied configuration and returns a discriminated-union result. The caller (typically the CLI controller) is responsible for attaching to the spawned child and sending any follow-up prompt. When the controller-local spawn gate is closed the server returns JSON-RPC MethodNotFound.
420 ///
421 /// Wire method: `agentRegistry.spawn`.
422 ///
423 /// # Parameters
424 ///
425 /// * `params` - Inputs to spawn a managed-server child via the controller's spawn delegate.
426 ///
427 /// # Returns
428 ///
429 /// Outcome of an agentRegistry.spawn call.
430 ///
431 /// <div class="warning">
432 ///
433 /// **Experimental.** This API is part of an experimental wire-protocol surface
434 /// and may change or be removed in future SDK or CLI releases. Pin both the
435 /// SDK and CLI versions if your code depends on it.
436 ///
437 /// </div>
438 pub async fn spawn(
439 &self,
440 params: AgentRegistrySpawnRequest,
441 ) -> Result<AgentRegistrySpawnResult, Error> {
442 let wire_params = serde_json::to_value(params)?;
443 let _value = self
444 .client
445 .call(rpc_methods::AGENTREGISTRY_SPAWN, Some(wire_params))
446 .await?;
447 Ok(serde_json::from_value(_value)?)
448 }
449}
450
451/// `agents.*` RPCs.
452#[derive(Clone, Copy)]
453pub struct ClientRpcAgents<'a> {
454 pub(crate) client: &'a Client,
455}
456
457impl<'a> ClientRpcAgents<'a> {
458 /// Discovers custom agents across user, project, plugin, and remote sources.
459 ///
460 /// Wire method: `agents.discover`.
461 ///
462 /// # Parameters
463 ///
464 /// * `params` - Optional project paths to include in agent discovery.
465 ///
466 /// # Returns
467 ///
468 /// Agents discovered across user, project, plugin, and remote sources.
469 ///
470 /// <div class="warning">
471 ///
472 /// **Experimental.** This API is part of an experimental wire-protocol surface
473 /// and may change or be removed in future SDK or CLI releases. Pin both the
474 /// SDK and CLI versions if your code depends on it.
475 ///
476 /// </div>
477 pub async fn discover(&self, params: AgentsDiscoverRequest) -> Result<ServerAgentList, Error> {
478 let wire_params = serde_json::to_value(params)?;
479 let _value = self
480 .client
481 .call(rpc_methods::AGENTS_DISCOVER, Some(wire_params))
482 .await?;
483 Ok(serde_json::from_value(_value)?)
484 }
485
486 /// Returns the canonical directories where a client may create custom agents that the runtime will recognize, including ones that do not exist yet. Project directories become active once created.
487 ///
488 /// Wire method: `agents.getDiscoveryPaths`.
489 ///
490 /// # Parameters
491 ///
492 /// * `params` - Optional project paths to include when enumerating agent discovery directories.
493 ///
494 /// # Returns
495 ///
496 /// Canonical locations where custom agents can be created so the runtime will recognize them.
497 ///
498 /// <div class="warning">
499 ///
500 /// **Experimental.** This API is part of an experimental wire-protocol surface
501 /// and may change or be removed in future SDK or CLI releases. Pin both the
502 /// SDK and CLI versions if your code depends on it.
503 ///
504 /// </div>
505 pub async fn get_discovery_paths(
506 &self,
507 params: AgentsGetDiscoveryPathsRequest,
508 ) -> Result<AgentDiscoveryPathList, Error> {
509 let wire_params = serde_json::to_value(params)?;
510 let _value = self
511 .client
512 .call(rpc_methods::AGENTS_GETDISCOVERYPATHS, Some(wire_params))
513 .await?;
514 Ok(serde_json::from_value(_value)?)
515 }
516}
517
518/// `catalog.*` RPCs.
519#[derive(Clone, Copy)]
520pub struct ClientRpcCatalog<'a> {
521 pub(crate) client: &'a Client,
522}
523
524impl<'a> ClientRpcCatalog<'a> {
525 /// Requests a bounded catalog search. This host-implemented server method is available through SDK/TUI hosts; standalone and C-ABI runtimes whose host does not implement server-method dispatch return JSON-RPC MethodNotFound. A runtime with search available returns inert candidate summaries, each with an opaque single-use handle scoped to this runtime instance; a runtime without it returns the typed search-unavailable result. Public authorities may be searched anonymously, while an authority that requires credentials yields the typed authentication-required result. All returned text, URLs, and package metadata are untrusted external data and can never trigger instructions, tools, or installation. Read-only: nothing is installed, configured, or persisted.
526 ///
527 /// Wire method: `catalog.search`.
528 ///
529 /// # Parameters
530 ///
531 /// * `params` - A bounded catalog search. Both the query length and the result count are capped by the schema so a caller cannot request an unbounded scan.
532 ///
533 /// # Returns
534 ///
535 /// Outcome of a catalog.search call: either bounded inert candidates, or one typed refusal. Never a partial success.
536 ///
537 /// <div class="warning">
538 ///
539 /// **Experimental.** This API is part of an experimental wire-protocol surface
540 /// and may change or be removed in future SDK or CLI releases. Pin both the
541 /// SDK and CLI versions if your code depends on it.
542 ///
543 /// </div>
544 pub async fn search(&self, params: CatalogSearchRequest) -> Result<CatalogSearchResult, Error> {
545 let wire_params = serde_json::to_value(params)?;
546 let _value = self
547 .client
548 .call(rpc_methods::CATALOG_SEARCH, Some(wire_params))
549 .await?;
550 Ok(serde_json::from_value(_value)?)
551 }
552}
553
554/// `commands.*` RPCs.
555#[derive(Clone, Copy)]
556pub struct ClientRpcCommands<'a> {
557 pub(crate) client: &'a Client,
558}
559
560impl<'a> ClientRpcCommands<'a> {
561 /// Lists the well-known built-in slash commands that work as the first message in a new session (e.g. /plan, /env), without requiring an active session. Commands that depend on session state, authentication, or a synced session are omitted.
562 ///
563 /// Wire method: `commands.list`.
564 ///
565 /// # Returns
566 ///
567 /// Slash commands available in the session, after applying any include/exclude filters.
568 ///
569 /// <div class="warning">
570 ///
571 /// **Experimental.** This API is part of an experimental wire-protocol surface
572 /// and may change or be removed in future SDK or CLI releases. Pin both the
573 /// SDK and CLI versions if your code depends on it.
574 ///
575 /// </div>
576 pub async fn list(&self) -> Result<CommandList, Error> {
577 let wire_params = serde_json::json!({});
578 let _value = self
579 .client
580 .call(rpc_methods::COMMANDS_LIST, Some(wire_params))
581 .await?;
582 Ok(serde_json::from_value(_value)?)
583 }
584}
585
586/// `extensions.*` RPCs.
587#[derive(Clone, Copy)]
588pub struct ClientRpcExtensions<'a> {
589 pub(crate) client: &'a Client,
590}
591
592impl<'a> ClientRpcExtensions<'a> {
593 /// Discovers user and enabled installed-plugin extensions from persisted Copilot home state, including enablement preferences. Launch-scoped additional plugins are not included.
594 ///
595 /// Wire method: `extensions.discover`.
596 ///
597 /// # Returns
598 ///
599 /// Extensions discovered from persisted Copilot home state and their effective loading mode. Launch-scoped additional plugins are not included.
600 ///
601 /// <div class="warning">
602 ///
603 /// **Experimental.** This API is part of an experimental wire-protocol surface
604 /// and may change or be removed in future SDK or CLI releases. Pin both the
605 /// SDK and CLI versions if your code depends on it.
606 ///
607 /// </div>
608 pub async fn discover(&self) -> Result<DiscoveredExtensions, Error> {
609 let wire_params = serde_json::json!({});
610 let _value = self
611 .client
612 .call(rpc_methods::EXTENSIONS_DISCOVER, Some(wire_params))
613 .await?;
614 Ok(serde_json::from_value(_value)?)
615 }
616
617 /// Persistently enables extension IDs for future sessions. Active sessions are unchanged; use session.extensions.enable to update them.
618 ///
619 /// Wire method: `extensions.enable`.
620 ///
621 /// # Parameters
622 ///
623 /// * `params` - Source-qualified extension identifiers to persistently enable for future sessions.
624 ///
625 /// <div class="warning">
626 ///
627 /// **Experimental.** This API is part of an experimental wire-protocol surface
628 /// and may change or be removed in future SDK or CLI releases. Pin both the
629 /// SDK and CLI versions if your code depends on it.
630 ///
631 /// </div>
632 pub async fn enable(&self, params: DiscoveredExtensionsEnableRequest) -> Result<(), Error> {
633 let wire_params = serde_json::to_value(params)?;
634 let _value = self
635 .client
636 .call(rpc_methods::EXTENSIONS_ENABLE, Some(wire_params))
637 .await?;
638 Ok(())
639 }
640
641 /// Persistently disables extension IDs for future sessions. Active sessions are unchanged; use session.extensions.disable to update them.
642 ///
643 /// Wire method: `extensions.disable`.
644 ///
645 /// # Parameters
646 ///
647 /// * `params` - Source-qualified extension identifiers to persistently disable for future sessions.
648 ///
649 /// <div class="warning">
650 ///
651 /// **Experimental.** This API is part of an experimental wire-protocol surface
652 /// and may change or be removed in future SDK or CLI releases. Pin both the
653 /// SDK and CLI versions if your code depends on it.
654 ///
655 /// </div>
656 pub async fn disable(&self, params: DiscoveredExtensionsDisableRequest) -> Result<(), Error> {
657 let wire_params = serde_json::to_value(params)?;
658 let _value = self
659 .client
660 .call(rpc_methods::EXTENSIONS_DISABLE, Some(wire_params))
661 .await?;
662 Ok(())
663 }
664}
665
666/// `hooks.*` RPCs.
667#[derive(Clone, Copy)]
668pub struct ClientRpcHooks<'a> {
669 pub(crate) client: &'a Client,
670}
671
672impl<'a> ClientRpcHooks<'a> {
673 /// Discovers hook actions enabled under server-side discovery settings from user, repository, plugin, and managed-policy sources.
674 ///
675 /// Wire method: `hooks.discover`.
676 ///
677 /// # Parameters
678 ///
679 /// * `params` - Optional project paths and host-exclusion behavior for server-scoped hook discovery.
680 ///
681 /// # Returns
682 ///
683 /// Server-discovered hook actions and partial-load diagnostics from user, repository, plugin, and managed-policy sources. Concrete sessions may include additional session-specific hook sources.
684 ///
685 /// <div class="warning">
686 ///
687 /// **Experimental.** This API is part of an experimental wire-protocol surface
688 /// and may change or be removed in future SDK or CLI releases. Pin both the
689 /// SDK and CLI versions if your code depends on it.
690 ///
691 /// </div>
692 pub async fn discover(
693 &self,
694 params: HooksDiscoverRequest,
695 ) -> Result<HooksDiscoverResult, Error> {
696 let wire_params = serde_json::to_value(params)?;
697 let _value = self
698 .client
699 .call(rpc_methods::HOOKS_DISCOVER, Some(wire_params))
700 .await?;
701 Ok(serde_json::from_value(_value)?)
702 }
703}
704
705/// `instructions.*` RPCs.
706#[derive(Clone, Copy)]
707pub struct ClientRpcInstructions<'a> {
708 pub(crate) client: &'a Client,
709}
710
711impl<'a> ClientRpcInstructions<'a> {
712 /// Discovers instruction sources across user, repository, and plugin sources.
713 ///
714 /// Wire method: `instructions.discover`.
715 ///
716 /// # Parameters
717 ///
718 /// * `params` - Optional project paths to include in instruction discovery.
719 ///
720 /// # Returns
721 ///
722 /// Instruction sources discovered across user, repository, and plugin sources.
723 ///
724 /// <div class="warning">
725 ///
726 /// **Experimental.** This API is part of an experimental wire-protocol surface
727 /// and may change or be removed in future SDK or CLI releases. Pin both the
728 /// SDK and CLI versions if your code depends on it.
729 ///
730 /// </div>
731 pub async fn discover(
732 &self,
733 params: InstructionsDiscoverRequest,
734 ) -> Result<ServerInstructionSourceList, Error> {
735 let wire_params = serde_json::to_value(params)?;
736 let _value = self
737 .client
738 .call(rpc_methods::INSTRUCTIONS_DISCOVER, Some(wire_params))
739 .await?;
740 Ok(serde_json::from_value(_value)?)
741 }
742
743 /// Returns the canonical files and directories where a client may create custom instructions that the runtime will recognize, including ones that do not exist yet. Repository targets become active once created.
744 ///
745 /// Wire method: `instructions.getDiscoveryPaths`.
746 ///
747 /// # Parameters
748 ///
749 /// * `params` - Optional project paths to include when enumerating instruction discovery targets.
750 ///
751 /// # Returns
752 ///
753 /// Canonical files and directories where custom instructions can be created so the runtime will recognize them.
754 ///
755 /// <div class="warning">
756 ///
757 /// **Experimental.** This API is part of an experimental wire-protocol surface
758 /// and may change or be removed in future SDK or CLI releases. Pin both the
759 /// SDK and CLI versions if your code depends on it.
760 ///
761 /// </div>
762 pub async fn get_discovery_paths(
763 &self,
764 params: InstructionsGetDiscoveryPathsRequest,
765 ) -> Result<InstructionDiscoveryPathList, Error> {
766 let wire_params = serde_json::to_value(params)?;
767 let _value = self
768 .client
769 .call(
770 rpc_methods::INSTRUCTIONS_GETDISCOVERYPATHS,
771 Some(wire_params),
772 )
773 .await?;
774 Ok(serde_json::from_value(_value)?)
775 }
776}
777
778/// `llmInference.*` RPCs.
779#[derive(Clone, Copy)]
780pub struct ClientRpcLlmInference<'a> {
781 pub(crate) client: &'a Client,
782}
783
784impl<'a> ClientRpcLlmInference<'a> {
785 /// Registers an SDK client as the LLM inference callback provider.
786 ///
787 /// Wire method: `llmInference.setProvider`.
788 ///
789 /// # Returns
790 ///
791 /// Indicates whether the calling client was registered as the LLM inference provider.
792 ///
793 /// <div class="warning">
794 ///
795 /// **Experimental.** This API is part of an experimental wire-protocol surface
796 /// and may change or be removed in future SDK or CLI releases. Pin both the
797 /// SDK and CLI versions if your code depends on it.
798 ///
799 /// </div>
800 pub async fn set_provider(&self) -> Result<LlmInferenceSetProviderResult, Error> {
801 let wire_params = serde_json::json!({});
802 let _value = self
803 .client
804 .call(rpc_methods::LLMINFERENCE_SETPROVIDER, Some(wire_params))
805 .await?;
806 Ok(serde_json::from_value(_value)?)
807 }
808
809 /// Delivers the response head (status + headers) for an in-flight request, correlated by the requestId the runtime supplied in httpRequestStart. Must be called exactly once per request before any httpResponseChunk frames.
810 ///
811 /// Wire method: `llmInference.httpResponseStart`.
812 ///
813 /// # Parameters
814 ///
815 /// * `params` - Response head.
816 ///
817 /// # Returns
818 ///
819 /// Whether the start frame was accepted.
820 ///
821 /// <div class="warning">
822 ///
823 /// **Experimental.** This API is part of an experimental wire-protocol surface
824 /// and may change or be removed in future SDK or CLI releases. Pin both the
825 /// SDK and CLI versions if your code depends on it.
826 ///
827 /// </div>
828 pub async fn http_response_start(
829 &self,
830 params: LlmInferenceHttpResponseStartRequest,
831 ) -> Result<LlmInferenceHttpResponseStartResult, Error> {
832 let wire_params = serde_json::to_value(params)?;
833 let _value = self
834 .client
835 .call(
836 rpc_methods::LLMINFERENCE_HTTPRESPONSESTART,
837 Some(wire_params),
838 )
839 .await?;
840 Ok(serde_json::from_value(_value)?)
841 }
842
843 /// Delivers a body byte range (or a terminal transport error) for an in-flight response, correlated by requestId. Set `end` true on the last chunk. When `error` is set the response terminates with a transport-level failure and the runtime raises an APIConnectionError.
844 ///
845 /// Wire method: `llmInference.httpResponseChunk`.
846 ///
847 /// # Parameters
848 ///
849 /// * `params` - A response body chunk or terminal error.
850 ///
851 /// # Returns
852 ///
853 /// Whether the chunk was accepted.
854 ///
855 /// <div class="warning">
856 ///
857 /// **Experimental.** This API is part of an experimental wire-protocol surface
858 /// and may change or be removed in future SDK or CLI releases. Pin both the
859 /// SDK and CLI versions if your code depends on it.
860 ///
861 /// </div>
862 pub async fn http_response_chunk(
863 &self,
864 params: LlmInferenceHttpResponseChunkRequest,
865 ) -> Result<LlmInferenceHttpResponseChunkResult, Error> {
866 let wire_params = serde_json::to_value(params)?;
867 let _value = self
868 .client
869 .call(
870 rpc_methods::LLMINFERENCE_HTTPRESPONSECHUNK,
871 Some(wire_params),
872 )
873 .await?;
874 Ok(serde_json::from_value(_value)?)
875 }
876}
877
878/// `managedSettings.*` RPCs.
879#[derive(Clone, Copy)]
880pub struct ClientRpcManagedSettings<'a> {
881 pub(crate) client: &'a Client,
882}
883
884impl<'a> ClientRpcManagedSettings<'a> {
885 /// Discovers device-managed settings from production MDM and managed-file sources, validates them against the runtime-owned managed-settings schema, and returns the canonical JSON without requiring a session.
886 ///
887 /// Wire method: `managedSettings.read`.
888 ///
889 /// # Returns
890 ///
891 /// Validated device-managed settings discovered before a session exists.
892 ///
893 /// <div class="warning">
894 ///
895 /// **Experimental.** This API is part of an experimental wire-protocol surface
896 /// and may change or be removed in future SDK or CLI releases. Pin both the
897 /// SDK and CLI versions if your code depends on it.
898 ///
899 /// </div>
900 pub async fn read(&self) -> Result<ManagedSettingsReadResult, Error> {
901 let wire_params = serde_json::json!({});
902 let _value = self
903 .client
904 .call(rpc_methods::MANAGEDSETTINGS_READ, Some(wire_params))
905 .await?;
906 Ok(serde_json::from_value(_value)?)
907 }
908
909 /// Force-refreshes enterprise managed settings for every account: wipes the persistent server-policy cache (the whole `<cacheHome>/managed-settings` directory) and drops this runtime process's in-memory retained server policy. It does not itself fetch policy — the effect is that the next time a session resolves managed settings for an account, that resolution re-fetches the account's org policy from the network instead of serving a cached response. Note that `managedSettings.read` returns only device/MDM settings and never triggers the account server-policy fetch, so a host implementing "sync account policy" should start a fresh session resolution rather than treat a subsequent `managedSettings.read` as the refreshed org policy. Mirrors the invalidation a sign-out performs, broadened from the one signing-out account to all of them; device/MDM layers describe the machine, not the account, and are left untouched. Rejects if the on-disk cache cannot be removed.
910 ///
911 /// Wire method: `managedSettings.clearCache`.
912 ///
913 /// <div class="warning">
914 ///
915 /// **Experimental.** This API is part of an experimental wire-protocol surface
916 /// and may change or be removed in future SDK or CLI releases. Pin both the
917 /// SDK and CLI versions if your code depends on it.
918 ///
919 /// </div>
920 pub async fn clear_cache(&self) -> Result<(), Error> {
921 let wire_params = serde_json::json!({});
922 let _value = self
923 .client
924 .call(rpc_methods::MANAGEDSETTINGS_CLEARCACHE, Some(wire_params))
925 .await?;
926 Ok(())
927 }
928}
929
930/// `mcp.*` RPCs.
931#[derive(Clone, Copy)]
932pub struct ClientRpcMcp<'a> {
933 pub(crate) client: &'a Client,
934}
935
936impl<'a> ClientRpcMcp<'a> {
937 /// `mcp.config.*` sub-namespace.
938 pub fn config(&self) -> ClientRpcMcpConfig<'a> {
939 ClientRpcMcpConfig {
940 client: self.client,
941 }
942 }
943
944 /// Discovers MCP servers from user, workspace, plugin, and builtin sources.
945 ///
946 /// Wire method: `mcp.discover`.
947 ///
948 /// # Parameters
949 ///
950 /// * `params` - Optional working directory used as context for MCP server discovery.
951 ///
952 /// # Returns
953 ///
954 /// MCP servers discovered from user, workspace, plugin, and built-in sources.
955 ///
956 /// <div class="warning">
957 ///
958 /// **Experimental.** This API is part of an experimental wire-protocol surface
959 /// and may change or be removed in future SDK or CLI releases. Pin both the
960 /// SDK and CLI versions if your code depends on it.
961 ///
962 /// </div>
963 pub async fn discover(&self, params: McpDiscoverRequest) -> Result<McpDiscoverResult, Error> {
964 let wire_params = serde_json::to_value(params)?;
965 let _value = self
966 .client
967 .call(rpc_methods::MCP_DISCOVER, Some(wire_params))
968 .await?;
969 Ok(serde_json::from_value(_value)?)
970 }
971
972 /// Requests a side-effect-free MCP install plan from a catalog candidate handle or a caller-supplied card. This host-implemented server method is available through SDK/TUI hosts; standalone and C-ABI runtimes whose host does not implement server-method dispatch return JSON-RPC MethodNotFound. A runtime with planning available returns a normalised plan and opaque single-use plan handle; a runtime without it returns the typed planning-unavailable result. A completed plan reports resource identity, provenance, eligible transport choices, the user-scope target, required typed values and secret placeholders, the policy result, the configuration changes installing would make, and whether a reload would be needed. Planning never writes configuration, stores a secret, or reloads MCP servers, so abandoning a plan needs no call and leaves nothing behind.
973 ///
974 /// Wire method: `mcp.planInstall`.
975 ///
976 /// # Parameters
977 ///
978 /// * `params` - A side-effect-free request for an MCP install plan. Computing a plan never writes configuration, stores a secret, or reloads MCP servers.
979 ///
980 /// # Returns
981 ///
982 /// Outcome of an mcp.planInstall call: either a normalised plan, or one typed refusal. Nothing is written in either case.
983 ///
984 /// <div class="warning">
985 ///
986 /// **Experimental.** This API is part of an experimental wire-protocol surface
987 /// and may change or be removed in future SDK or CLI releases. Pin both the
988 /// SDK and CLI versions if your code depends on it.
989 ///
990 /// </div>
991 pub async fn plan_install(
992 &self,
993 params: McpPlanInstallRequest,
994 ) -> Result<McpPlanInstallResult, Error> {
995 let wire_params = serde_json::to_value(params)?;
996 let _value = self
997 .client
998 .call(rpc_methods::MCP_PLANINSTALL, Some(wire_params))
999 .await?;
1000 Ok(serde_json::from_value(_value)?)
1001 }
1002}
1003
1004/// `mcp.config.*` RPCs.
1005#[derive(Clone, Copy)]
1006pub struct ClientRpcMcpConfig<'a> {
1007 pub(crate) client: &'a Client,
1008}
1009
1010impl<'a> ClientRpcMcpConfig<'a> {
1011 /// Lists MCP servers from user configuration.
1012 ///
1013 /// Wire method: `mcp.config.list`.
1014 ///
1015 /// # Returns
1016 ///
1017 /// User-configured MCP servers, keyed by server name.
1018 ///
1019 /// <div class="warning">
1020 ///
1021 /// **Experimental.** This API is part of an experimental wire-protocol surface
1022 /// and may change or be removed in future SDK or CLI releases. Pin both the
1023 /// SDK and CLI versions if your code depends on it.
1024 ///
1025 /// </div>
1026 pub async fn list(&self) -> Result<McpConfigList, Error> {
1027 let wire_params = serde_json::json!({});
1028 let _value = self
1029 .client
1030 .call(rpc_methods::MCP_CONFIG_LIST, Some(wire_params))
1031 .await?;
1032 Ok(serde_json::from_value(_value)?)
1033 }
1034
1035 /// Adds an MCP server to user configuration.
1036 ///
1037 /// Wire method: `mcp.config.add`.
1038 ///
1039 /// # Parameters
1040 ///
1041 /// * `params` - MCP server name and configuration to add to user configuration.
1042 ///
1043 /// <div class="warning">
1044 ///
1045 /// **Experimental.** This API is part of an experimental wire-protocol surface
1046 /// and may change or be removed in future SDK or CLI releases. Pin both the
1047 /// SDK and CLI versions if your code depends on it.
1048 ///
1049 /// </div>
1050 pub async fn add(&self, params: McpConfigAddRequest) -> Result<(), Error> {
1051 let wire_params = serde_json::to_value(params)?;
1052 let _value = self
1053 .client
1054 .call(rpc_methods::MCP_CONFIG_ADD, Some(wire_params))
1055 .await?;
1056 Ok(())
1057 }
1058
1059 /// Updates an MCP server in user configuration.
1060 ///
1061 /// Wire method: `mcp.config.update`.
1062 ///
1063 /// # Parameters
1064 ///
1065 /// * `params` - MCP server name and replacement configuration to write to user configuration.
1066 ///
1067 /// <div class="warning">
1068 ///
1069 /// **Experimental.** This API is part of an experimental wire-protocol surface
1070 /// and may change or be removed in future SDK or CLI releases. Pin both the
1071 /// SDK and CLI versions if your code depends on it.
1072 ///
1073 /// </div>
1074 pub async fn update(&self, params: McpConfigUpdateRequest) -> Result<(), Error> {
1075 let wire_params = serde_json::to_value(params)?;
1076 let _value = self
1077 .client
1078 .call(rpc_methods::MCP_CONFIG_UPDATE, Some(wire_params))
1079 .await?;
1080 Ok(())
1081 }
1082
1083 /// Removes an MCP server from user configuration.
1084 ///
1085 /// Wire method: `mcp.config.remove`.
1086 ///
1087 /// # Parameters
1088 ///
1089 /// * `params` - MCP server name to remove from user configuration.
1090 ///
1091 /// <div class="warning">
1092 ///
1093 /// **Experimental.** This API is part of an experimental wire-protocol surface
1094 /// and may change or be removed in future SDK or CLI releases. Pin both the
1095 /// SDK and CLI versions if your code depends on it.
1096 ///
1097 /// </div>
1098 pub async fn remove(&self, params: McpConfigRemoveRequest) -> Result<(), Error> {
1099 let wire_params = serde_json::to_value(params)?;
1100 let _value = self
1101 .client
1102 .call(rpc_methods::MCP_CONFIG_REMOVE, Some(wire_params))
1103 .await?;
1104 Ok(())
1105 }
1106
1107 /// Enables MCP servers in user configuration for new sessions.
1108 ///
1109 /// Wire method: `mcp.config.enable`.
1110 ///
1111 /// # Parameters
1112 ///
1113 /// * `params` - MCP server names to enable for new sessions.
1114 ///
1115 /// <div class="warning">
1116 ///
1117 /// **Experimental.** This API is part of an experimental wire-protocol surface
1118 /// and may change or be removed in future SDK or CLI releases. Pin both the
1119 /// SDK and CLI versions if your code depends on it.
1120 ///
1121 /// </div>
1122 pub async fn enable(&self, params: McpConfigEnableRequest) -> Result<(), Error> {
1123 let wire_params = serde_json::to_value(params)?;
1124 let _value = self
1125 .client
1126 .call(rpc_methods::MCP_CONFIG_ENABLE, Some(wire_params))
1127 .await?;
1128 Ok(())
1129 }
1130
1131 /// Disables MCP servers in user configuration for new sessions.
1132 ///
1133 /// Wire method: `mcp.config.disable`.
1134 ///
1135 /// # Parameters
1136 ///
1137 /// * `params` - MCP server names to disable for new sessions.
1138 ///
1139 /// <div class="warning">
1140 ///
1141 /// **Experimental.** This API is part of an experimental wire-protocol surface
1142 /// and may change or be removed in future SDK or CLI releases. Pin both the
1143 /// SDK and CLI versions if your code depends on it.
1144 ///
1145 /// </div>
1146 pub async fn disable(&self, params: McpConfigDisableRequest) -> Result<(), Error> {
1147 let wire_params = serde_json::to_value(params)?;
1148 let _value = self
1149 .client
1150 .call(rpc_methods::MCP_CONFIG_DISABLE, Some(wire_params))
1151 .await?;
1152 Ok(())
1153 }
1154
1155 /// Drops this runtime process's in-memory MCP server-definition cache so the next MCP config read observes disk.
1156 ///
1157 /// Wire method: `mcp.config.reload`.
1158 ///
1159 /// <div class="warning">
1160 ///
1161 /// **Experimental.** This API is part of an experimental wire-protocol surface
1162 /// and may change or be removed in future SDK or CLI releases. Pin both the
1163 /// SDK and CLI versions if your code depends on it.
1164 ///
1165 /// </div>
1166 pub async fn reload(&self) -> Result<(), Error> {
1167 let wire_params = serde_json::json!({});
1168 let _value = self
1169 .client
1170 .call(rpc_methods::MCP_CONFIG_RELOAD, Some(wire_params))
1171 .await?;
1172 Ok(())
1173 }
1174}
1175
1176/// `models.*` RPCs.
1177#[derive(Clone, Copy)]
1178pub struct ClientRpcModels<'a> {
1179 pub(crate) client: &'a Client,
1180}
1181
1182impl<'a> ClientRpcModels<'a> {
1183 /// Lists Copilot models available to the authenticated user.
1184 ///
1185 /// Wire method: `models.list`.
1186 ///
1187 /// # Returns
1188 ///
1189 /// List of Copilot models available to the resolved user, including capabilities and billing metadata.
1190 ///
1191 /// <div class="warning">
1192 ///
1193 /// **Experimental.** This API is part of an experimental wire-protocol surface
1194 /// and may change or be removed in future SDK or CLI releases. Pin both the
1195 /// SDK and CLI versions if your code depends on it.
1196 ///
1197 /// </div>
1198 pub async fn list(&self) -> Result<ModelList, Error> {
1199 let wire_params = serde_json::json!({});
1200 let _value = self
1201 .client
1202 .call(rpc_methods::MODELS_LIST, Some(wire_params))
1203 .await?;
1204 Ok(serde_json::from_value(_value)?)
1205 }
1206
1207 /// Lists Copilot models available to the authenticated user.
1208 ///
1209 /// Wire method: `models.list`.
1210 ///
1211 /// # Parameters
1212 ///
1213 /// * `params` - Optional opaque account selection or compatibility GitHub token used to list models.
1214 ///
1215 /// # Returns
1216 ///
1217 /// List of Copilot models available to the resolved user, including capabilities and billing metadata.
1218 ///
1219 /// <div class="warning">
1220 ///
1221 /// **Experimental.** This API is part of an experimental wire-protocol surface
1222 /// and may change or be removed in future SDK or CLI releases. Pin both the
1223 /// SDK and CLI versions if your code depends on it.
1224 ///
1225 /// </div>
1226 pub async fn list_with_params(&self, params: ModelsListRequest) -> Result<ModelList, Error> {
1227 let wire_params = serde_json::to_value(params)?;
1228 let _value = self
1229 .client
1230 .call(rpc_methods::MODELS_LIST, Some(wire_params))
1231 .await?;
1232 Ok(serde_json::from_value(_value)?)
1233 }
1234
1235 /// Returns the running runtime's complete catalog of well-known built-in model IDs without authentication or network access.
1236 ///
1237 /// Wire method: `models.getBuiltInCatalog`.
1238 ///
1239 /// # Returns
1240 ///
1241 /// The running runtime's complete catalog of well-known built-in model IDs, including supported models and additional IDs with built-in metadata.
1242 ///
1243 /// <div class="warning">
1244 ///
1245 /// **Experimental.** This API is part of an experimental wire-protocol surface
1246 /// and may change or be removed in future SDK or CLI releases. Pin both the
1247 /// SDK and CLI versions if your code depends on it.
1248 ///
1249 /// </div>
1250 pub async fn get_built_in_catalog(&self) -> Result<BuiltInModelCatalog, Error> {
1251 let wire_params = serde_json::json!({});
1252 let _value = self
1253 .client
1254 .call(rpc_methods::MODELS_GETBUILTINCATALOG, Some(wire_params))
1255 .await?;
1256 Ok(serde_json::from_value(_value)?)
1257 }
1258}
1259
1260/// `plugins.*` RPCs.
1261#[derive(Clone, Copy)]
1262pub struct ClientRpcPlugins<'a> {
1263 pub(crate) client: &'a Client,
1264}
1265
1266impl<'a> ClientRpcPlugins<'a> {
1267 /// `plugins.builtin.*` sub-namespace.
1268 pub fn builtin(&self) -> ClientRpcPluginsBuiltin<'a> {
1269 ClientRpcPluginsBuiltin {
1270 client: self.client,
1271 }
1272 }
1273
1274 /// `plugins.marketplaces.*` sub-namespace.
1275 pub fn marketplaces(&self) -> ClientRpcPluginsMarketplaces<'a> {
1276 ClientRpcPluginsMarketplaces {
1277 client: self.client,
1278 }
1279 }
1280
1281 /// Lists plugins installed in user/global state.
1282 ///
1283 /// Wire method: `plugins.list`.
1284 ///
1285 /// # Returns
1286 ///
1287 /// Plugins installed in user/global state.
1288 ///
1289 /// <div class="warning">
1290 ///
1291 /// **Experimental.** This API is part of an experimental wire-protocol surface
1292 /// and may change or be removed in future SDK or CLI releases. Pin both the
1293 /// SDK and CLI versions if your code depends on it.
1294 ///
1295 /// </div>
1296 pub async fn list(&self) -> Result<PluginListResult, Error> {
1297 let wire_params = serde_json::json!({});
1298 let _value = self
1299 .client
1300 .call(rpc_methods::PLUGINS_LIST, Some(wire_params))
1301 .await?;
1302 Ok(serde_json::from_value(_value)?)
1303 }
1304
1305 /// Installs a plugin from a marketplace, GitHub repo, URL, or local path.
1306 ///
1307 /// Wire method: `plugins.install`.
1308 ///
1309 /// # Parameters
1310 ///
1311 /// * `params` - Plugin source and optional working directory for relative-path resolution.
1312 ///
1313 /// # Returns
1314 ///
1315 /// Result of installing a plugin.
1316 ///
1317 /// <div class="warning">
1318 ///
1319 /// **Experimental.** This API is part of an experimental wire-protocol surface
1320 /// and may change or be removed in future SDK or CLI releases. Pin both the
1321 /// SDK and CLI versions if your code depends on it.
1322 ///
1323 /// </div>
1324 pub async fn install(
1325 &self,
1326 params: PluginsInstallRequest,
1327 ) -> Result<PluginInstallResult, Error> {
1328 let wire_params = serde_json::to_value(params)?;
1329 let _value = self
1330 .client
1331 .call(rpc_methods::PLUGINS_INSTALL, Some(wire_params))
1332 .await?;
1333 Ok(serde_json::from_value(_value)?)
1334 }
1335
1336 /// Uninstalls an installed plugin.
1337 ///
1338 /// Wire method: `plugins.uninstall`.
1339 ///
1340 /// # Parameters
1341 ///
1342 /// * `params` - Name (or spec) of the plugin to uninstall.
1343 ///
1344 /// <div class="warning">
1345 ///
1346 /// **Experimental.** This API is part of an experimental wire-protocol surface
1347 /// and may change or be removed in future SDK or CLI releases. Pin both the
1348 /// SDK and CLI versions if your code depends on it.
1349 ///
1350 /// </div>
1351 pub async fn uninstall(&self, params: PluginsUninstallRequest) -> Result<(), Error> {
1352 let wire_params = serde_json::to_value(params)?;
1353 let _value = self
1354 .client
1355 .call(rpc_methods::PLUGINS_UNINSTALL, Some(wire_params))
1356 .await?;
1357 Ok(())
1358 }
1359
1360 /// Updates an installed plugin to its latest published version.
1361 ///
1362 /// Wire method: `plugins.update`.
1363 ///
1364 /// # Parameters
1365 ///
1366 /// * `params` - Name (or spec) of the plugin to update.
1367 ///
1368 /// # Returns
1369 ///
1370 /// Result of updating a single plugin.
1371 ///
1372 /// <div class="warning">
1373 ///
1374 /// **Experimental.** This API is part of an experimental wire-protocol surface
1375 /// and may change or be removed in future SDK or CLI releases. Pin both the
1376 /// SDK and CLI versions if your code depends on it.
1377 ///
1378 /// </div>
1379 pub async fn update(&self, params: PluginsUpdateRequest) -> Result<PluginUpdateResult, Error> {
1380 let wire_params = serde_json::to_value(params)?;
1381 let _value = self
1382 .client
1383 .call(rpc_methods::PLUGINS_UPDATE, Some(wire_params))
1384 .await?;
1385 Ok(serde_json::from_value(_value)?)
1386 }
1387
1388 /// Updates every installed plugin to its latest published version.
1389 ///
1390 /// Wire method: `plugins.updateAll`.
1391 ///
1392 /// # Returns
1393 ///
1394 /// Result of updating all installed plugins.
1395 ///
1396 /// <div class="warning">
1397 ///
1398 /// **Experimental.** This API is part of an experimental wire-protocol surface
1399 /// and may change or be removed in future SDK or CLI releases. Pin both the
1400 /// SDK and CLI versions if your code depends on it.
1401 ///
1402 /// </div>
1403 pub async fn update_all(&self) -> Result<PluginUpdateAllResult, Error> {
1404 let wire_params = serde_json::json!({});
1405 let _value = self
1406 .client
1407 .call(rpc_methods::PLUGINS_UPDATEALL, Some(wire_params))
1408 .await?;
1409 Ok(serde_json::from_value(_value)?)
1410 }
1411
1412 /// Enables installed plugins for new sessions.
1413 ///
1414 /// Wire method: `plugins.enable`.
1415 ///
1416 /// # Parameters
1417 ///
1418 /// * `params` - Plugin names (or specs) to enable.
1419 ///
1420 /// <div class="warning">
1421 ///
1422 /// **Experimental.** This API is part of an experimental wire-protocol surface
1423 /// and may change or be removed in future SDK or CLI releases. Pin both the
1424 /// SDK and CLI versions if your code depends on it.
1425 ///
1426 /// </div>
1427 pub async fn enable(&self, params: PluginsEnableRequest) -> Result<(), Error> {
1428 let wire_params = serde_json::to_value(params)?;
1429 let _value = self
1430 .client
1431 .call(rpc_methods::PLUGINS_ENABLE, Some(wire_params))
1432 .await?;
1433 Ok(())
1434 }
1435
1436 /// Disables installed plugins for new sessions.
1437 ///
1438 /// Wire method: `plugins.disable`.
1439 ///
1440 /// # Parameters
1441 ///
1442 /// * `params` - Plugin names (or specs) to disable.
1443 ///
1444 /// <div class="warning">
1445 ///
1446 /// **Experimental.** This API is part of an experimental wire-protocol surface
1447 /// and may change or be removed in future SDK or CLI releases. Pin both the
1448 /// SDK and CLI versions if your code depends on it.
1449 ///
1450 /// </div>
1451 pub async fn disable(&self, params: PluginsDisableRequest) -> Result<(), Error> {
1452 let wire_params = serde_json::to_value(params)?;
1453 let _value = self
1454 .client
1455 .call(rpc_methods::PLUGINS_DISABLE, Some(wire_params))
1456 .await?;
1457 Ok(())
1458 }
1459}
1460
1461/// `plugins.builtin.*` RPCs.
1462#[derive(Clone, Copy)]
1463pub struct ClientRpcPluginsBuiltin<'a> {
1464 pub(crate) client: &'a Client,
1465}
1466
1467impl<'a> ClientRpcPluginsBuiltin<'a> {
1468 /// Replaces this server's trusted built-in plugin directories while no sessions are active.
1469 ///
1470 /// Wire method: `plugins.builtin.set`.
1471 ///
1472 /// # Parameters
1473 ///
1474 /// * `params` - Trusted built-in plugin directories to use for this runtime process.
1475 ///
1476 /// <div class="warning">
1477 ///
1478 /// **Experimental.** This API is part of an experimental wire-protocol surface
1479 /// and may change or be removed in future SDK or CLI releases. Pin both the
1480 /// SDK and CLI versions if your code depends on it.
1481 ///
1482 /// </div>
1483 pub async fn set(&self, params: PluginsBuiltinSetRequest) -> Result<(), Error> {
1484 let wire_params = serde_json::to_value(params)?;
1485 let _value = self
1486 .client
1487 .call(rpc_methods::PLUGINS_BUILTIN_SET, Some(wire_params))
1488 .await?;
1489 Ok(())
1490 }
1491}
1492
1493/// `plugins.marketplaces.*` RPCs.
1494#[derive(Clone, Copy)]
1495pub struct ClientRpcPluginsMarketplaces<'a> {
1496 pub(crate) client: &'a Client,
1497}
1498
1499impl<'a> ClientRpcPluginsMarketplaces<'a> {
1500 /// Lists all registered marketplaces (defaults + user-added).
1501 ///
1502 /// Wire method: `plugins.marketplaces.list`.
1503 ///
1504 /// # Returns
1505 ///
1506 /// All registered marketplaces, including built-in defaults.
1507 ///
1508 /// <div class="warning">
1509 ///
1510 /// **Experimental.** This API is part of an experimental wire-protocol surface
1511 /// and may change or be removed in future SDK or CLI releases. Pin both the
1512 /// SDK and CLI versions if your code depends on it.
1513 ///
1514 /// </div>
1515 pub async fn list(&self) -> Result<MarketplaceListResult, Error> {
1516 let wire_params = serde_json::json!({});
1517 let _value = self
1518 .client
1519 .call(rpc_methods::PLUGINS_MARKETPLACES_LIST, Some(wire_params))
1520 .await?;
1521 Ok(serde_json::from_value(_value)?)
1522 }
1523
1524 /// Registers a new marketplace from a source (owner/repo, URL, or local path).
1525 ///
1526 /// Wire method: `plugins.marketplaces.add`.
1527 ///
1528 /// # Parameters
1529 ///
1530 /// * `params` - Marketplace source and optional working directory for relative-path resolution.
1531 ///
1532 /// # Returns
1533 ///
1534 /// Result of registering a new marketplace.
1535 ///
1536 /// <div class="warning">
1537 ///
1538 /// **Experimental.** This API is part of an experimental wire-protocol surface
1539 /// and may change or be removed in future SDK or CLI releases. Pin both the
1540 /// SDK and CLI versions if your code depends on it.
1541 ///
1542 /// </div>
1543 pub async fn add(
1544 &self,
1545 params: PluginsMarketplacesAddRequest,
1546 ) -> Result<MarketplaceAddResult, Error> {
1547 let wire_params = serde_json::to_value(params)?;
1548 let _value = self
1549 .client
1550 .call(rpc_methods::PLUGINS_MARKETPLACES_ADD, Some(wire_params))
1551 .await?;
1552 Ok(serde_json::from_value(_value)?)
1553 }
1554
1555 /// Removes a previously-registered marketplace. When the marketplace has dependent plugins and `force` is not set, the marketplace is left intact and the result lists the dependents so the caller can decide whether to retry with `force=true`.
1556 ///
1557 /// Wire method: `plugins.marketplaces.remove`.
1558 ///
1559 /// # Parameters
1560 ///
1561 /// * `params` - Name of the marketplace to remove and an optional force flag.
1562 ///
1563 /// # Returns
1564 ///
1565 /// Outcome of the remove attempt, including dependent-plugin info when applicable.
1566 ///
1567 /// <div class="warning">
1568 ///
1569 /// **Experimental.** This API is part of an experimental wire-protocol surface
1570 /// and may change or be removed in future SDK or CLI releases. Pin both the
1571 /// SDK and CLI versions if your code depends on it.
1572 ///
1573 /// </div>
1574 pub async fn remove(
1575 &self,
1576 params: PluginsMarketplacesRemoveRequest,
1577 ) -> Result<MarketplaceRemoveResult, Error> {
1578 let wire_params = serde_json::to_value(params)?;
1579 let _value = self
1580 .client
1581 .call(rpc_methods::PLUGINS_MARKETPLACES_REMOVE, Some(wire_params))
1582 .await?;
1583 Ok(serde_json::from_value(_value)?)
1584 }
1585
1586 /// Lists plugins advertised by a registered marketplace.
1587 ///
1588 /// Wire method: `plugins.marketplaces.browse`.
1589 ///
1590 /// # Parameters
1591 ///
1592 /// * `params` - Name of the marketplace whose plugin catalog to fetch.
1593 ///
1594 /// # Returns
1595 ///
1596 /// Plugins advertised by the marketplace.
1597 ///
1598 /// <div class="warning">
1599 ///
1600 /// **Experimental.** This API is part of an experimental wire-protocol surface
1601 /// and may change or be removed in future SDK or CLI releases. Pin both the
1602 /// SDK and CLI versions if your code depends on it.
1603 ///
1604 /// </div>
1605 pub async fn browse(
1606 &self,
1607 params: PluginsMarketplacesBrowseRequest,
1608 ) -> Result<MarketplaceBrowseResult, Error> {
1609 let wire_params = serde_json::to_value(params)?;
1610 let _value = self
1611 .client
1612 .call(rpc_methods::PLUGINS_MARKETPLACES_BROWSE, Some(wire_params))
1613 .await?;
1614 Ok(serde_json::from_value(_value)?)
1615 }
1616
1617 /// Re-fetches one or all registered marketplace catalogs.
1618 ///
1619 /// Wire method: `plugins.marketplaces.refresh`.
1620 ///
1621 /// # Returns
1622 ///
1623 /// Result of refreshing one or more marketplace catalogs.
1624 ///
1625 /// <div class="warning">
1626 ///
1627 /// **Experimental.** This API is part of an experimental wire-protocol surface
1628 /// and may change or be removed in future SDK or CLI releases. Pin both the
1629 /// SDK and CLI versions if your code depends on it.
1630 ///
1631 /// </div>
1632 pub async fn refresh(&self) -> Result<MarketplaceRefreshResult, Error> {
1633 let wire_params = serde_json::json!({});
1634 let _value = self
1635 .client
1636 .call(rpc_methods::PLUGINS_MARKETPLACES_REFRESH, Some(wire_params))
1637 .await?;
1638 Ok(serde_json::from_value(_value)?)
1639 }
1640
1641 /// Re-fetches one or all registered marketplace catalogs.
1642 ///
1643 /// Wire method: `plugins.marketplaces.refresh`.
1644 ///
1645 /// # Parameters
1646 ///
1647 /// * `params` - Optional marketplace name; omit to refresh all.
1648 ///
1649 /// # Returns
1650 ///
1651 /// Result of refreshing one or more marketplace catalogs.
1652 ///
1653 /// <div class="warning">
1654 ///
1655 /// **Experimental.** This API is part of an experimental wire-protocol surface
1656 /// and may change or be removed in future SDK or CLI releases. Pin both the
1657 /// SDK and CLI versions if your code depends on it.
1658 ///
1659 /// </div>
1660 pub async fn refresh_with_params(
1661 &self,
1662 params: PluginsMarketplacesRefreshRequest,
1663 ) -> Result<MarketplaceRefreshResult, Error> {
1664 let wire_params = serde_json::to_value(params)?;
1665 let _value = self
1666 .client
1667 .call(rpc_methods::PLUGINS_MARKETPLACES_REFRESH, Some(wire_params))
1668 .await?;
1669 Ok(serde_json::from_value(_value)?)
1670 }
1671}
1672
1673/// `runtime.*` RPCs.
1674#[derive(Clone, Copy)]
1675pub struct ClientRpcRuntime<'a> {
1676 pub(crate) client: &'a Client,
1677}
1678
1679impl<'a> ClientRpcRuntime<'a> {
1680 /// Gracefully shuts down an SDK-owned runtime. The response is sent only after cleanup completes; callers may then terminate the owned runtime process.
1681 ///
1682 /// Wire method: `runtime.shutdown`.
1683 ///
1684 /// <div class="warning">
1685 ///
1686 /// **Experimental.** This API is part of an experimental wire-protocol surface
1687 /// and may change or be removed in future SDK or CLI releases. Pin both the
1688 /// SDK and CLI versions if your code depends on it.
1689 ///
1690 /// </div>
1691 pub async fn shutdown(&self) -> Result<(), Error> {
1692 let wire_params = serde_json::json!({});
1693 let _value = self
1694 .client
1695 .call(rpc_methods::RUNTIME_SHUTDOWN, Some(wire_params))
1696 .await?;
1697 Ok(())
1698 }
1699}
1700
1701/// `secrets.*` RPCs.
1702#[derive(Clone, Copy)]
1703pub struct ClientRpcSecrets<'a> {
1704 pub(crate) client: &'a Client,
1705}
1706
1707impl<'a> ClientRpcSecrets<'a> {
1708 /// Registers secret values for redaction in session logs and exports. The SDK calls this to inject dynamically generated secret values (e.g., OIDC tokens).
1709 ///
1710 /// Wire method: `secrets.addFilterValues`.
1711 ///
1712 /// # Parameters
1713 ///
1714 /// * `params` - Secret values to add to the redaction filter.
1715 ///
1716 /// # Returns
1717 ///
1718 /// Confirmation that the secret values were registered.
1719 ///
1720 /// <div class="warning">
1721 ///
1722 /// **Experimental.** This API is part of an experimental wire-protocol surface
1723 /// and may change or be removed in future SDK or CLI releases. Pin both the
1724 /// SDK and CLI versions if your code depends on it.
1725 ///
1726 /// </div>
1727 pub async fn add_filter_values(
1728 &self,
1729 params: SecretsAddFilterValuesRequest,
1730 ) -> Result<SecretsAddFilterValuesResult, Error> {
1731 let wire_params = serde_json::to_value(params)?;
1732 let _value = self
1733 .client
1734 .call(rpc_methods::SECRETS_ADDFILTERVALUES, Some(wire_params))
1735 .await?;
1736 Ok(serde_json::from_value(_value)?)
1737 }
1738}
1739
1740/// `sessionFs.*` RPCs.
1741#[derive(Clone, Copy)]
1742pub struct ClientRpcSessionFs<'a> {
1743 pub(crate) client: &'a Client,
1744}
1745
1746impl<'a> ClientRpcSessionFs<'a> {
1747 /// Registers an SDK client as the session filesystem provider.
1748 ///
1749 /// Wire method: `sessionFs.setProvider`.
1750 ///
1751 /// # Parameters
1752 ///
1753 /// * `params` - Initial working directory, session-state path layout, and path conventions used to register the calling SDK client as the session filesystem provider.
1754 ///
1755 /// # Returns
1756 ///
1757 /// Indicates whether the calling client was registered as the session filesystem provider.
1758 ///
1759 /// <div class="warning">
1760 ///
1761 /// **Experimental.** This API is part of an experimental wire-protocol surface
1762 /// and may change or be removed in future SDK or CLI releases. Pin both the
1763 /// SDK and CLI versions if your code depends on it.
1764 ///
1765 /// </div>
1766 pub async fn set_provider(
1767 &self,
1768 params: SessionFsSetProviderRequest,
1769 ) -> Result<SessionFsSetProviderResult, Error> {
1770 let wire_params = serde_json::to_value(params)?;
1771 let _value = self
1772 .client
1773 .call(rpc_methods::SESSIONFS_SETPROVIDER, Some(wire_params))
1774 .await?;
1775 Ok(serde_json::from_value(_value)?)
1776 }
1777}
1778
1779/// `sessions.*` RPCs.
1780#[derive(Clone, Copy)]
1781pub struct ClientRpcSessions<'a> {
1782 pub(crate) client: &'a Client,
1783}
1784
1785impl<'a> ClientRpcSessions<'a> {
1786 /// Creates or resumes a local session and returns the opened session ID.
1787 ///
1788 /// Wire method: `sessions.open`.
1789 ///
1790 /// # Returns
1791 ///
1792 /// Result of opening a session.
1793 ///
1794 /// <div class="warning">
1795 ///
1796 /// **Experimental.** This API is part of an experimental wire-protocol surface
1797 /// and may change or be removed in future SDK or CLI releases. Pin both the
1798 /// SDK and CLI versions if your code depends on it.
1799 ///
1800 /// </div>
1801 pub async fn open(&self) -> Result<SessionOpenResult, Error> {
1802 let wire_params = serde_json::json!({});
1803 let _value = self
1804 .client
1805 .call(rpc_methods::SESSIONS_OPEN, Some(wire_params))
1806 .await?;
1807 Ok(serde_json::from_value(_value)?)
1808 }
1809
1810 /// Creates a new session by forking persisted history from an existing session.
1811 ///
1812 /// Wire method: `sessions.fork`.
1813 ///
1814 /// # Parameters
1815 ///
1816 /// * `params` - Source session identifier to fork from, optional event-ID boundary, and optional friendly name for the new session.
1817 ///
1818 /// # Returns
1819 ///
1820 /// Identifier and optional friendly name assigned to the newly forked session.
1821 ///
1822 /// <div class="warning">
1823 ///
1824 /// **Experimental.** This API is part of an experimental wire-protocol surface
1825 /// and may change or be removed in future SDK or CLI releases. Pin both the
1826 /// SDK and CLI versions if your code depends on it.
1827 ///
1828 /// </div>
1829 pub async fn fork(&self, params: SessionsForkRequest) -> Result<SessionsForkResult, Error> {
1830 let wire_params = serde_json::to_value(params)?;
1831 let _value = self
1832 .client
1833 .call(rpc_methods::SESSIONS_FORK, Some(wire_params))
1834 .await?;
1835 Ok(serde_json::from_value(_value)?)
1836 }
1837
1838 /// Connects to an existing remote session and exposes it as an SDK session.
1839 ///
1840 /// Wire method: `sessions.connect`.
1841 ///
1842 /// # Parameters
1843 ///
1844 /// * `params` - Remote session connection parameters.
1845 ///
1846 /// # Returns
1847 ///
1848 /// Remote session connection result.
1849 ///
1850 /// <div class="warning">
1851 ///
1852 /// **Experimental.** This API is part of an experimental wire-protocol surface
1853 /// and may change or be removed in future SDK or CLI releases. Pin both the
1854 /// SDK and CLI versions if your code depends on it.
1855 ///
1856 /// </div>
1857 pub async fn connect(
1858 &self,
1859 params: ConnectRemoteSessionParams,
1860 ) -> Result<RemoteSessionConnectionResult, Error> {
1861 let wire_params = serde_json::to_value(params)?;
1862 let _value = self
1863 .client
1864 .call(rpc_methods::SESSIONS_CONNECT, Some(wire_params))
1865 .await?;
1866 Ok(serde_json::from_value(_value)?)
1867 }
1868
1869 /// Lists sessions, optionally filtered by source and working-directory context. Returned entries are discriminated by `isRemote`: local entries carry only the lightweight `LocalSessionMetadataValue` shape; remote entries carry the full `RemoteSessionMetadataValue` shape (repository, PR number, taskType, etc.).
1870 ///
1871 /// Wire method: `sessions.list`.
1872 ///
1873 /// # Returns
1874 ///
1875 /// Sessions matching the filter, ordered most-recently-modified first.
1876 ///
1877 /// <div class="warning">
1878 ///
1879 /// **Experimental.** This API is part of an experimental wire-protocol surface
1880 /// and may change or be removed in future SDK or CLI releases. Pin both the
1881 /// SDK and CLI versions if your code depends on it.
1882 ///
1883 /// </div>
1884 pub async fn list(&self) -> Result<SessionList, Error> {
1885 let wire_params = serde_json::json!({});
1886 let _value = self
1887 .client
1888 .call(rpc_methods::SESSIONS_LIST, Some(wire_params))
1889 .await?;
1890 Ok(serde_json::from_value(_value)?)
1891 }
1892
1893 /// Lists sessions, optionally filtered by source and working-directory context. Returned entries are discriminated by `isRemote`: local entries carry only the lightweight `LocalSessionMetadataValue` shape; remote entries carry the full `RemoteSessionMetadataValue` shape (repository, PR number, taskType, etc.).
1894 ///
1895 /// Wire method: `sessions.list`.
1896 ///
1897 /// # Parameters
1898 ///
1899 /// * `params` - Optional source filter, metadata-load limit, and context filter applied to the returned sessions.
1900 ///
1901 /// # Returns
1902 ///
1903 /// Sessions matching the filter, ordered most-recently-modified first.
1904 ///
1905 /// <div class="warning">
1906 ///
1907 /// **Experimental.** This API is part of an experimental wire-protocol surface
1908 /// and may change or be removed in future SDK or CLI releases. Pin both the
1909 /// SDK and CLI versions if your code depends on it.
1910 ///
1911 /// </div>
1912 pub async fn list_with_params(
1913 &self,
1914 params: SessionsListRequest,
1915 ) -> Result<SessionList, Error> {
1916 let wire_params = serde_json::to_value(params)?;
1917 let _value = self
1918 .client
1919 .call(rpc_methods::SESSIONS_LIST, Some(wire_params))
1920 .await?;
1921 Ok(serde_json::from_value(_value)?)
1922 }
1923
1924 /// Reads lightweight persisted metadata for one local session without opening it.
1925 ///
1926 /// Wire method: `sessions.getMetadata`.
1927 ///
1928 /// # Parameters
1929 ///
1930 /// * `params` - Session ID whose persisted metadata should be read.
1931 ///
1932 /// # Returns
1933 ///
1934 /// Persisted local session metadata when the session exists.
1935 ///
1936 /// <div class="warning">
1937 ///
1938 /// **Experimental.** This API is part of an experimental wire-protocol surface
1939 /// and may change or be removed in future SDK or CLI releases. Pin both the
1940 /// SDK and CLI versions if your code depends on it.
1941 ///
1942 /// </div>
1943 pub(crate) async fn get_metadata(
1944 &self,
1945 params: SessionsGetMetadataRequest,
1946 ) -> Result<SessionsGetMetadataResult, Error> {
1947 let wire_params = serde_json::to_value(params)?;
1948 let _value = self
1949 .client
1950 .call(rpc_methods::SESSIONS_GETMETADATA, Some(wire_params))
1951 .await?;
1952 Ok(serde_json::from_value(_value)?)
1953 }
1954
1955 /// Reads a page of durable events directly from a local session's persisted journal without creating, resuming, or activating the session. The initial backward read uses a bounded tail scan for fast first paint; cursor continuations preserve the session event-log paging semantics. Persisted events may omit payloads that are reconstructed only for an active session.
1956 ///
1957 /// Wire method: `sessions.readPersistedEvents`.
1958 ///
1959 /// # Parameters
1960 ///
1961 /// * `params` - Pagination options for reading an inactive or active local session's persisted event journal.
1962 ///
1963 /// # Returns
1964 ///
1965 /// Batch of session events returned by a read, with cursor and continuation metadata.
1966 ///
1967 /// <div class="warning">
1968 ///
1969 /// **Experimental.** This API is part of an experimental wire-protocol surface
1970 /// and may change or be removed in future SDK or CLI releases. Pin both the
1971 /// SDK and CLI versions if your code depends on it.
1972 ///
1973 /// </div>
1974 pub async fn read_persisted_events(
1975 &self,
1976 params: SessionsReadPersistedEventsRequest,
1977 ) -> Result<EventsReadResult, Error> {
1978 let wire_params = serde_json::to_value(params)?;
1979 let _value = self
1980 .client
1981 .call(rpc_methods::SESSIONS_READPERSISTEDEVENTS, Some(wire_params))
1982 .await?;
1983 Ok(serde_json::from_value(_value)?)
1984 }
1985
1986 /// Lists recent local session IDs that contain user-visible history, omitting housekeeping-only sessions.
1987 ///
1988 /// Wire method: `sessions.listNonEmptySessionIds`.
1989 ///
1990 /// # Parameters
1991 ///
1992 /// * `params` - Limit for non-empty local session IDs.
1993 ///
1994 /// # Returns
1995 ///
1996 /// Recent local session IDs that contain user-visible history.
1997 ///
1998 /// <div class="warning">
1999 ///
2000 /// **Experimental.** This API is part of an experimental wire-protocol surface
2001 /// and may change or be removed in future SDK or CLI releases. Pin both the
2002 /// SDK and CLI versions if your code depends on it.
2003 ///
2004 /// </div>
2005 pub(crate) async fn list_non_empty_session_ids(
2006 &self,
2007 params: SessionsListNonEmptySessionIdsRequest,
2008 ) -> Result<SessionsListNonEmptySessionIdsResult, Error> {
2009 let wire_params = serde_json::to_value(params)?;
2010 let _value = self
2011 .client
2012 .call(
2013 rpc_methods::SESSIONS_LISTNONEMPTYSESSIONIDS,
2014 Some(wire_params),
2015 )
2016 .await?;
2017 Ok(serde_json::from_value(_value)?)
2018 }
2019
2020 /// Finds the local session bound to a GitHub task ID, if any.
2021 ///
2022 /// Wire method: `sessions.findByTaskId`.
2023 ///
2024 /// # Parameters
2025 ///
2026 /// * `params` - GitHub task ID to look up.
2027 ///
2028 /// # Returns
2029 ///
2030 /// ID of the local session bound to the given GitHub task, or omitted when none.
2031 ///
2032 /// <div class="warning">
2033 ///
2034 /// **Experimental.** This API is part of an experimental wire-protocol surface
2035 /// and may change or be removed in future SDK or CLI releases. Pin both the
2036 /// SDK and CLI versions if your code depends on it.
2037 ///
2038 /// </div>
2039 pub async fn find_by_task_id(
2040 &self,
2041 params: SessionsFindByTaskIDRequest,
2042 ) -> Result<SessionsFindByTaskIDResult, Error> {
2043 let wire_params = serde_json::to_value(params)?;
2044 let _value = self
2045 .client
2046 .call(rpc_methods::SESSIONS_FINDBYTASKID, Some(wire_params))
2047 .await?;
2048 Ok(serde_json::from_value(_value)?)
2049 }
2050
2051 /// Resolves a UUID prefix to a unique session ID, if exactly one session matches.
2052 ///
2053 /// Wire method: `sessions.findByPrefix`.
2054 ///
2055 /// # Parameters
2056 ///
2057 /// * `params` - UUID prefix to resolve to a unique session ID.
2058 ///
2059 /// # Returns
2060 ///
2061 /// Session ID matching the prefix, omitted when no unique match exists.
2062 ///
2063 /// <div class="warning">
2064 ///
2065 /// **Experimental.** This API is part of an experimental wire-protocol surface
2066 /// and may change or be removed in future SDK or CLI releases. Pin both the
2067 /// SDK and CLI versions if your code depends on it.
2068 ///
2069 /// </div>
2070 pub async fn find_by_prefix(
2071 &self,
2072 params: SessionsFindByPrefixRequest,
2073 ) -> Result<SessionsFindByPrefixResult, Error> {
2074 let wire_params = serde_json::to_value(params)?;
2075 let _value = self
2076 .client
2077 .call(rpc_methods::SESSIONS_FINDBYPREFIX, Some(wire_params))
2078 .await?;
2079 Ok(serde_json::from_value(_value)?)
2080 }
2081
2082 /// Returns the most-relevant prior session for a given working-directory context.
2083 ///
2084 /// Wire method: `sessions.getLastForContext`.
2085 ///
2086 /// # Parameters
2087 ///
2088 /// * `params` - Optional working-directory context used to score session relevance.
2089 ///
2090 /// # Returns
2091 ///
2092 /// Most-relevant session ID for the supplied context, or omitted when no sessions exist.
2093 ///
2094 /// <div class="warning">
2095 ///
2096 /// **Experimental.** This API is part of an experimental wire-protocol surface
2097 /// and may change or be removed in future SDK or CLI releases. Pin both the
2098 /// SDK and CLI versions if your code depends on it.
2099 ///
2100 /// </div>
2101 pub async fn get_last_for_context(
2102 &self,
2103 params: SessionsGetLastForContextRequest,
2104 ) -> Result<SessionsGetLastForContextResult, Error> {
2105 let wire_params = serde_json::to_value(params)?;
2106 let _value = self
2107 .client
2108 .call(rpc_methods::SESSIONS_GETLASTFORCONTEXT, Some(wire_params))
2109 .await?;
2110 Ok(serde_json::from_value(_value)?)
2111 }
2112
2113 /// 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.
2114 ///
2115 /// Wire method: `sessions.getEventFilePath`.
2116 ///
2117 /// # Parameters
2118 ///
2119 /// * `params` - Session ID whose event-log file path to compute.
2120 ///
2121 /// # Returns
2122 ///
2123 /// Absolute path to the session's events.jsonl file on disk.
2124 ///
2125 /// <div class="warning">
2126 ///
2127 /// **Experimental.** This API is part of an experimental wire-protocol surface
2128 /// and may change or be removed in future SDK or CLI releases. Pin both the
2129 /// SDK and CLI versions if your code depends on it.
2130 ///
2131 /// </div>
2132 pub(crate) async fn get_event_file_path(
2133 &self,
2134 params: SessionsGetEventFilePathRequest,
2135 ) -> Result<SessionsGetEventFilePathResult, Error> {
2136 let wire_params = serde_json::to_value(params)?;
2137 let _value = self
2138 .client
2139 .call(rpc_methods::SESSIONS_GETEVENTFILEPATH, Some(wire_params))
2140 .await?;
2141 Ok(serde_json::from_value(_value)?)
2142 }
2143
2144 /// Returns the on-disk byte size of each session's workspace directory.
2145 ///
2146 /// Wire method: `sessions.getSizes`.
2147 ///
2148 /// # Returns
2149 ///
2150 /// Map of sessionId -> on-disk size in bytes for each session's workspace directory.
2151 ///
2152 /// <div class="warning">
2153 ///
2154 /// **Experimental.** This API is part of an experimental wire-protocol surface
2155 /// and may change or be removed in future SDK or CLI releases. Pin both the
2156 /// SDK and CLI versions if your code depends on it.
2157 ///
2158 /// </div>
2159 pub async fn get_sizes(&self) -> Result<SessionSizes, Error> {
2160 let wire_params = serde_json::json!({});
2161 let _value = self
2162 .client
2163 .call(rpc_methods::SESSIONS_GETSIZES, Some(wire_params))
2164 .await?;
2165 Ok(serde_json::from_value(_value)?)
2166 }
2167
2168 /// Returns the subset of the supplied session IDs that are currently held by another running process.
2169 ///
2170 /// Wire method: `sessions.checkInUse`.
2171 ///
2172 /// # Parameters
2173 ///
2174 /// * `params` - Session IDs to test for live in-use locks.
2175 ///
2176 /// # Returns
2177 ///
2178 /// Session IDs from the input set that are currently in use by another process.
2179 ///
2180 /// <div class="warning">
2181 ///
2182 /// **Experimental.** This API is part of an experimental wire-protocol surface
2183 /// and may change or be removed in future SDK or CLI releases. Pin both the
2184 /// SDK and CLI versions if your code depends on it.
2185 ///
2186 /// </div>
2187 pub async fn check_in_use(
2188 &self,
2189 params: SessionsCheckInUseRequest,
2190 ) -> Result<SessionsCheckInUseResult, Error> {
2191 let wire_params = serde_json::to_value(params)?;
2192 let _value = self
2193 .client
2194 .call(rpc_methods::SESSIONS_CHECKINUSE, Some(wire_params))
2195 .await?;
2196 Ok(serde_json::from_value(_value)?)
2197 }
2198
2199 /// 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.
2200 ///
2201 /// Wire method: `sessions.getPersistedRemoteSteerable`.
2202 ///
2203 /// # Parameters
2204 ///
2205 /// * `params` - Session ID to look up the persisted remote-steerable flag for.
2206 ///
2207 /// # Returns
2208 ///
2209 /// The session's persisted remote-steerable flag, or omitted when no value has been persisted.
2210 ///
2211 /// <div class="warning">
2212 ///
2213 /// **Experimental.** This API is part of an experimental wire-protocol surface
2214 /// and may change or be removed in future SDK or CLI releases. Pin both the
2215 /// SDK and CLI versions if your code depends on it.
2216 ///
2217 /// </div>
2218 pub(crate) async fn get_persisted_remote_steerable(
2219 &self,
2220 params: SessionsGetPersistedRemoteSteerableRequest,
2221 ) -> Result<SessionsGetPersistedRemoteSteerableResult, Error> {
2222 let wire_params = serde_json::to_value(params)?;
2223 let _value = self
2224 .client
2225 .call(
2226 rpc_methods::SESSIONS_GETPERSISTEDREMOTESTEERABLE,
2227 Some(wire_params),
2228 )
2229 .await?;
2230 Ok(serde_json::from_value(_value)?)
2231 }
2232
2233 /// Closes a session: emits shutdown, flushes pending events, releases the in-use lock, and disposes the active session.
2234 ///
2235 /// Wire method: `sessions.close`.
2236 ///
2237 /// # Parameters
2238 ///
2239 /// * `params` - Session ID to close.
2240 ///
2241 /// # Returns
2242 ///
2243 /// 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.
2244 ///
2245 /// <div class="warning">
2246 ///
2247 /// **Experimental.** This API is part of an experimental wire-protocol surface
2248 /// and may change or be removed in future SDK or CLI releases. Pin both the
2249 /// SDK and CLI versions if your code depends on it.
2250 ///
2251 /// </div>
2252 pub async fn close(&self, params: SessionsCloseRequest) -> Result<SessionsCloseResult, Error> {
2253 let wire_params = serde_json::to_value(params)?;
2254 let _value = self
2255 .client
2256 .call(rpc_methods::SESSIONS_CLOSE, Some(wire_params))
2257 .await?;
2258 Ok(serde_json::from_value(_value)?)
2259 }
2260
2261 /// Closes, deactivates, and deletes a set of sessions, returning the bytes freed per session.
2262 ///
2263 /// Wire method: `sessions.bulkDelete`.
2264 ///
2265 /// # Parameters
2266 ///
2267 /// * `params` - Session IDs to close, deactivate, and delete from disk.
2268 ///
2269 /// # Returns
2270 ///
2271 /// Map of sessionId -> bytes freed by removing the session's workspace directory.
2272 ///
2273 /// <div class="warning">
2274 ///
2275 /// **Experimental.** This API is part of an experimental wire-protocol surface
2276 /// and may change or be removed in future SDK or CLI releases. Pin both the
2277 /// SDK and CLI versions if your code depends on it.
2278 ///
2279 /// </div>
2280 pub async fn bulk_delete(
2281 &self,
2282 params: SessionsBulkDeleteRequest,
2283 ) -> Result<SessionBulkDeleteResult, Error> {
2284 let wire_params = serde_json::to_value(params)?;
2285 let _value = self
2286 .client
2287 .call(rpc_methods::SESSIONS_BULKDELETE, Some(wire_params))
2288 .await?;
2289 Ok(serde_json::from_value(_value)?)
2290 }
2291
2292 /// Deletes one local session from disk after running the same lifecycle hooks as the session manager.
2293 ///
2294 /// Wire method: `sessions.delete`.
2295 ///
2296 /// # Parameters
2297 ///
2298 /// * `params` - Session ID to delete from disk.
2299 ///
2300 /// <div class="warning">
2301 ///
2302 /// **Experimental.** This API is part of an experimental wire-protocol surface
2303 /// and may change or be removed in future SDK or CLI releases. Pin both the
2304 /// SDK and CLI versions if your code depends on it.
2305 ///
2306 /// </div>
2307 pub(crate) async fn delete(&self, params: SessionsDeleteRequest) -> Result<(), Error> {
2308 let wire_params = serde_json::to_value(params)?;
2309 let _value = self
2310 .client
2311 .call(rpc_methods::SESSIONS_DELETE, Some(wire_params))
2312 .await?;
2313 Ok(())
2314 }
2315
2316 /// Deletes sessions older than the given threshold, with optional dry-run and exclusion list.
2317 ///
2318 /// Wire method: `sessions.pruneOld`.
2319 ///
2320 /// # Parameters
2321 ///
2322 /// * `params` - Age threshold and optional flags controlling which old sessions are pruned (or simulated when dryRun is true).
2323 ///
2324 /// # Returns
2325 ///
2326 /// Outcome of the prune operation: deleted IDs, dry-run candidates, skipped IDs, total bytes freed, and the dry-run flag.
2327 ///
2328 /// <div class="warning">
2329 ///
2330 /// **Experimental.** This API is part of an experimental wire-protocol surface
2331 /// and may change or be removed in future SDK or CLI releases. Pin both the
2332 /// SDK and CLI versions if your code depends on it.
2333 ///
2334 /// </div>
2335 pub async fn prune_old(
2336 &self,
2337 params: SessionsPruneOldRequest,
2338 ) -> Result<SessionPruneResult, Error> {
2339 let wire_params = serde_json::to_value(params)?;
2340 let _value = self
2341 .client
2342 .call(rpc_methods::SESSIONS_PRUNEOLD, Some(wire_params))
2343 .await?;
2344 Ok(serde_json::from_value(_value)?)
2345 }
2346
2347 /// Flushes a session's pending events to disk.
2348 ///
2349 /// Wire method: `sessions.save`.
2350 ///
2351 /// # Parameters
2352 ///
2353 /// * `params` - Session ID whose pending events should be flushed to disk.
2354 ///
2355 /// # Returns
2356 ///
2357 /// Flush a session's pending events to disk. No-op when no writer exists for the session (e.g., already closed).
2358 ///
2359 /// <div class="warning">
2360 ///
2361 /// **Experimental.** This API is part of an experimental wire-protocol surface
2362 /// and may change or be removed in future SDK or CLI releases. Pin both the
2363 /// SDK and CLI versions if your code depends on it.
2364 ///
2365 /// </div>
2366 pub async fn save(&self, params: SessionsSaveRequest) -> Result<SessionsSaveResult, Error> {
2367 let wire_params = serde_json::to_value(params)?;
2368 let _value = self
2369 .client
2370 .call(rpc_methods::SESSIONS_SAVE, Some(wire_params))
2371 .await?;
2372 Ok(serde_json::from_value(_value)?)
2373 }
2374
2375 /// Releases the in-use lock held by this process for a session.
2376 ///
2377 /// Wire method: `sessions.releaseLock`.
2378 ///
2379 /// # Parameters
2380 ///
2381 /// * `params` - Session ID whose in-use lock should be released.
2382 ///
2383 /// # Returns
2384 ///
2385 /// 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.
2386 ///
2387 /// <div class="warning">
2388 ///
2389 /// **Experimental.** This API is part of an experimental wire-protocol surface
2390 /// and may change or be removed in future SDK or CLI releases. Pin both the
2391 /// SDK and CLI versions if your code depends on it.
2392 ///
2393 /// </div>
2394 pub async fn release_lock(
2395 &self,
2396 params: SessionsReleaseLockRequest,
2397 ) -> Result<SessionsReleaseLockResult, Error> {
2398 let wire_params = serde_json::to_value(params)?;
2399 let _value = self
2400 .client
2401 .call(rpc_methods::SESSIONS_RELEASELOCK, Some(wire_params))
2402 .await?;
2403 Ok(serde_json::from_value(_value)?)
2404 }
2405
2406 /// Backfills missing summary and context fields on the supplied session metadata records.
2407 ///
2408 /// Wire method: `sessions.enrichMetadata`.
2409 ///
2410 /// # Parameters
2411 ///
2412 /// * `params` - Session metadata records to enrich with summary and context information.
2413 ///
2414 /// # Returns
2415 ///
2416 /// The enriched metadata records, with summary and context fields backfilled where available. Sessions confirmed empty and unnamed are omitted.
2417 ///
2418 /// <div class="warning">
2419 ///
2420 /// **Experimental.** This API is part of an experimental wire-protocol surface
2421 /// and may change or be removed in future SDK or CLI releases. Pin both the
2422 /// SDK and CLI versions if your code depends on it.
2423 ///
2424 /// </div>
2425 pub async fn enrich_metadata(
2426 &self,
2427 params: SessionsEnrichMetadataRequest,
2428 ) -> Result<SessionEnrichMetadataResult, Error> {
2429 let wire_params = serde_json::to_value(params)?;
2430 let _value = self
2431 .client
2432 .call(rpc_methods::SESSIONS_ENRICHMETADATA, Some(wire_params))
2433 .await?;
2434 Ok(serde_json::from_value(_value)?)
2435 }
2436
2437 /// Reloads user, plugin, and (optionally) repo hooks on the active session.
2438 ///
2439 /// Wire method: `sessions.reloadPluginHooks`.
2440 ///
2441 /// # Parameters
2442 ///
2443 /// * `params` - Active session ID and an optional flag for deferring repo-level hooks until folder trust.
2444 ///
2445 /// # Returns
2446 ///
2447 /// 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.
2448 ///
2449 /// <div class="warning">
2450 ///
2451 /// **Experimental.** This API is part of an experimental wire-protocol surface
2452 /// and may change or be removed in future SDK or CLI releases. Pin both the
2453 /// SDK and CLI versions if your code depends on it.
2454 ///
2455 /// </div>
2456 pub async fn reload_plugin_hooks(
2457 &self,
2458 params: SessionsReloadPluginHooksRequest,
2459 ) -> Result<SessionsReloadPluginHooksResult, Error> {
2460 let wire_params = serde_json::to_value(params)?;
2461 let _value = self
2462 .client
2463 .call(rpc_methods::SESSIONS_RELOADPLUGINHOOKS, Some(wire_params))
2464 .await?;
2465 Ok(serde_json::from_value(_value)?)
2466 }
2467
2468 /// Loads previously-deferred repo-level hooks on the active session, returning queued startup prompts.
2469 ///
2470 /// Wire method: `sessions.loadDeferredRepoHooks`.
2471 ///
2472 /// # Parameters
2473 ///
2474 /// * `params` - Active session ID whose deferred repo-level hooks should be loaded.
2475 ///
2476 /// # Returns
2477 ///
2478 /// Queued repo-level startup prompts and the total hook command count after loading.
2479 ///
2480 /// <div class="warning">
2481 ///
2482 /// **Experimental.** This API is part of an experimental wire-protocol surface
2483 /// and may change or be removed in future SDK or CLI releases. Pin both the
2484 /// SDK and CLI versions if your code depends on it.
2485 ///
2486 /// </div>
2487 pub async fn load_deferred_repo_hooks(
2488 &self,
2489 params: SessionsLoadDeferredRepoHooksRequest,
2490 ) -> Result<SessionLoadDeferredRepoHooksResult, Error> {
2491 let wire_params = serde_json::to_value(params)?;
2492 let _value = self
2493 .client
2494 .call(
2495 rpc_methods::SESSIONS_LOADDEFERREDREPOHOOKS,
2496 Some(wire_params),
2497 )
2498 .await?;
2499 Ok(serde_json::from_value(_value)?)
2500 }
2501
2502 /// Replaces the manager-wide additional plugins registered with the session manager.
2503 ///
2504 /// Wire method: `sessions.setAdditionalPlugins`.
2505 ///
2506 /// # Parameters
2507 ///
2508 /// * `params` - Manager-wide additional plugins to register; replaces any previously-configured set.
2509 ///
2510 /// # Returns
2511 ///
2512 /// 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.
2513 ///
2514 /// <div class="warning">
2515 ///
2516 /// **Experimental.** This API is part of an experimental wire-protocol surface
2517 /// and may change or be removed in future SDK or CLI releases. Pin both the
2518 /// SDK and CLI versions if your code depends on it.
2519 ///
2520 /// </div>
2521 pub async fn set_additional_plugins(
2522 &self,
2523 params: SessionsSetAdditionalPluginsRequest,
2524 ) -> Result<SessionsSetAdditionalPluginsResult, Error> {
2525 let wire_params = serde_json::to_value(params)?;
2526 let _value = self
2527 .client
2528 .call(
2529 rpc_methods::SESSIONS_SETADDITIONALPLUGINS,
2530 Some(wire_params),
2531 )
2532 .await?;
2533 Ok(serde_json::from_value(_value)?)
2534 }
2535
2536 /// 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.
2537 ///
2538 /// Wire method: `sessions.getBoardEntryCount`.
2539 ///
2540 /// # Parameters
2541 ///
2542 /// * `params` - Session ID whose board entry count should be returned.
2543 ///
2544 /// # Returns
2545 ///
2546 /// Dynamic-context board entry count, when available.
2547 ///
2548 /// <div class="warning">
2549 ///
2550 /// **Experimental.** This API is part of an experimental wire-protocol surface
2551 /// and may change or be removed in future SDK or CLI releases. Pin both the
2552 /// SDK and CLI versions if your code depends on it.
2553 ///
2554 /// </div>
2555 pub(crate) async fn get_board_entry_count(
2556 &self,
2557 params: SessionsGetBoardEntryCountRequest,
2558 ) -> Result<SessionsGetBoardEntryCountResult, Error> {
2559 let wire_params = serde_json::to_value(params)?;
2560 let _value = self
2561 .client
2562 .call(rpc_methods::SESSIONS_GETBOARDENTRYCOUNT, Some(wire_params))
2563 .await?;
2564 Ok(serde_json::from_value(_value)?)
2565 }
2566
2567 /// 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.
2568 ///
2569 /// Wire method: `sessions.startRemoteControl`.
2570 ///
2571 /// # Parameters
2572 ///
2573 /// * `params` - Parameters for attaching the remote-control singleton to a session.
2574 ///
2575 /// # Returns
2576 ///
2577 /// Wrapper for the singleton's current status.
2578 ///
2579 /// <div class="warning">
2580 ///
2581 /// **Experimental.** This API is part of an experimental wire-protocol surface
2582 /// and may change or be removed in future SDK or CLI releases. Pin both the
2583 /// SDK and CLI versions if your code depends on it.
2584 ///
2585 /// </div>
2586 pub async fn start_remote_control(
2587 &self,
2588 params: SessionsStartRemoteControlRequest,
2589 ) -> Result<RemoteControlStatusResult, Error> {
2590 let wire_params = serde_json::to_value(params)?;
2591 let _value = self
2592 .client
2593 .call(rpc_methods::SESSIONS_STARTREMOTECONTROL, Some(wire_params))
2594 .await?;
2595 Ok(serde_json::from_value(_value)?)
2596 }
2597
2598 /// 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.
2599 ///
2600 /// Wire method: `sessions.transferRemoteControl`.
2601 ///
2602 /// # Parameters
2603 ///
2604 /// * `params` - Parameters for atomically rebinding the remote-control singleton.
2605 ///
2606 /// # Returns
2607 ///
2608 /// Outcome of a transferRemoteControl call.
2609 ///
2610 /// <div class="warning">
2611 ///
2612 /// **Experimental.** This API is part of an experimental wire-protocol surface
2613 /// and may change or be removed in future SDK or CLI releases. Pin both the
2614 /// SDK and CLI versions if your code depends on it.
2615 ///
2616 /// </div>
2617 pub async fn transfer_remote_control(
2618 &self,
2619 params: SessionsTransferRemoteControlRequest,
2620 ) -> Result<RemoteControlTransferResult, Error> {
2621 let wire_params = serde_json::to_value(params)?;
2622 let _value = self
2623 .client
2624 .call(
2625 rpc_methods::SESSIONS_TRANSFERREMOTECONTROL,
2626 Some(wire_params),
2627 )
2628 .await?;
2629 Ok(serde_json::from_value(_value)?)
2630 }
2631
2632 /// 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.
2633 ///
2634 /// Wire method: `sessions.setRemoteControlSteering`.
2635 ///
2636 /// # Parameters
2637 ///
2638 /// * `params` - Patch for the singleton's steering state.
2639 ///
2640 /// # Returns
2641 ///
2642 /// Wrapper for the singleton's current status.
2643 ///
2644 /// <div class="warning">
2645 ///
2646 /// **Experimental.** This API is part of an experimental wire-protocol surface
2647 /// and may change or be removed in future SDK or CLI releases. Pin both the
2648 /// SDK and CLI versions if your code depends on it.
2649 ///
2650 /// </div>
2651 pub async fn set_remote_control_steering(
2652 &self,
2653 params: SessionsSetRemoteControlSteeringRequest,
2654 ) -> Result<RemoteControlStatusResult, Error> {
2655 let wire_params = serde_json::to_value(params)?;
2656 let _value = self
2657 .client
2658 .call(
2659 rpc_methods::SESSIONS_SETREMOTECONTROLSTEERING,
2660 Some(wire_params),
2661 )
2662 .await?;
2663 Ok(serde_json::from_value(_value)?)
2664 }
2665
2666 /// 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).
2667 ///
2668 /// Wire method: `sessions.stopRemoteControl`.
2669 ///
2670 /// # Returns
2671 ///
2672 /// Outcome of a stopRemoteControl call.
2673 ///
2674 /// <div class="warning">
2675 ///
2676 /// **Experimental.** This API is part of an experimental wire-protocol surface
2677 /// and may change or be removed in future SDK or CLI releases. Pin both the
2678 /// SDK and CLI versions if your code depends on it.
2679 ///
2680 /// </div>
2681 pub async fn stop_remote_control(&self) -> Result<RemoteControlStopResult, Error> {
2682 let wire_params = serde_json::json!({});
2683 let _value = self
2684 .client
2685 .call(rpc_methods::SESSIONS_STOPREMOTECONTROL, Some(wire_params))
2686 .await?;
2687 Ok(serde_json::from_value(_value)?)
2688 }
2689
2690 /// 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).
2691 ///
2692 /// Wire method: `sessions.stopRemoteControl`.
2693 ///
2694 /// # Parameters
2695 ///
2696 /// * `params` - Parameters for stopping the remote-control singleton.
2697 ///
2698 /// # Returns
2699 ///
2700 /// Outcome of a stopRemoteControl call.
2701 ///
2702 /// <div class="warning">
2703 ///
2704 /// **Experimental.** This API is part of an experimental wire-protocol surface
2705 /// and may change or be removed in future SDK or CLI releases. Pin both the
2706 /// SDK and CLI versions if your code depends on it.
2707 ///
2708 /// </div>
2709 pub async fn stop_remote_control_with_params(
2710 &self,
2711 params: SessionsStopRemoteControlRequest,
2712 ) -> Result<RemoteControlStopResult, Error> {
2713 let wire_params = serde_json::to_value(params)?;
2714 let _value = self
2715 .client
2716 .call(rpc_methods::SESSIONS_STOPREMOTECONTROL, Some(wire_params))
2717 .await?;
2718 Ok(serde_json::from_value(_value)?)
2719 }
2720
2721 /// Returns the current state of the remote-control singleton, including the attached session id and frontend URL when active.
2722 ///
2723 /// Wire method: `sessions.getRemoteControlStatus`.
2724 ///
2725 /// # Returns
2726 ///
2727 /// Wrapper for the singleton's current status.
2728 ///
2729 /// <div class="warning">
2730 ///
2731 /// **Experimental.** This API is part of an experimental wire-protocol surface
2732 /// and may change or be removed in future SDK or CLI releases. Pin both the
2733 /// SDK and CLI versions if your code depends on it.
2734 ///
2735 /// </div>
2736 pub async fn get_remote_control_status(&self) -> Result<RemoteControlStatusResult, Error> {
2737 let wire_params = serde_json::json!({});
2738 let _value = self
2739 .client
2740 .call(
2741 rpc_methods::SESSIONS_GETREMOTECONTROLSTATUS,
2742 Some(wire_params),
2743 )
2744 .await?;
2745 Ok(serde_json::from_value(_value)?)
2746 }
2747
2748 /// 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.
2749 ///
2750 /// Wire method: `sessions.registerExtensionToolsOnSession`.
2751 ///
2752 /// # Parameters
2753 ///
2754 /// * `params` - Params to attach an extension loader's tools to a session.
2755 ///
2756 /// # Returns
2757 ///
2758 /// Handle for releasing the extension tool registration.
2759 ///
2760 /// <div class="warning">
2761 ///
2762 /// **Experimental.** This API is part of an experimental wire-protocol surface
2763 /// and may change or be removed in future SDK or CLI releases. Pin both the
2764 /// SDK and CLI versions if your code depends on it.
2765 ///
2766 /// </div>
2767 pub(crate) async fn register_extension_tools_on_session(
2768 &self,
2769 params: RegisterExtensionToolsParams,
2770 ) -> Result<RegisterExtensionToolsResult, Error> {
2771 let wire_params = serde_json::to_value(params)?;
2772 let _value = self
2773 .client
2774 .call(
2775 rpc_methods::SESSIONS_REGISTEREXTENSIONTOOLSONSESSION,
2776 Some(wire_params),
2777 )
2778 .await?;
2779 Ok(serde_json::from_value(_value)?)
2780 }
2781
2782 /// 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.
2783 ///
2784 /// Wire method: `sessions.configureSessionExtensions`.
2785 ///
2786 /// # Parameters
2787 ///
2788 /// * `params` - Params to attach or detach an in-process ExtensionController delegate.
2789 ///
2790 /// <div class="warning">
2791 ///
2792 /// **Experimental.** This API is part of an experimental wire-protocol surface
2793 /// and may change or be removed in future SDK or CLI releases. Pin both the
2794 /// SDK and CLI versions if your code depends on it.
2795 ///
2796 /// </div>
2797 pub(crate) async fn configure_session_extensions(
2798 &self,
2799 params: ConfigureSessionExtensionsParams,
2800 ) -> Result<(), Error> {
2801 let wire_params = serde_json::to_value(params)?;
2802 let _value = self
2803 .client
2804 .call(
2805 rpc_methods::SESSIONS_CONFIGURESESSIONEXTENSIONS,
2806 Some(wire_params),
2807 )
2808 .await?;
2809 Ok(())
2810 }
2811}
2812
2813/// `skills.*` RPCs.
2814#[derive(Clone, Copy)]
2815pub struct ClientRpcSkills<'a> {
2816 pub(crate) client: &'a Client,
2817}
2818
2819impl<'a> ClientRpcSkills<'a> {
2820 /// `skills.config.*` sub-namespace.
2821 pub fn config(&self) -> ClientRpcSkillsConfig<'a> {
2822 ClientRpcSkillsConfig {
2823 client: self.client,
2824 }
2825 }
2826
2827 /// Discovers skills across global and project sources.
2828 ///
2829 /// Wire method: `skills.discover`.
2830 ///
2831 /// # Parameters
2832 ///
2833 /// * `params` - Optional project paths and additional skill directories to include in discovery.
2834 ///
2835 /// # Returns
2836 ///
2837 /// Skills discovered across global and project sources.
2838 ///
2839 /// <div class="warning">
2840 ///
2841 /// **Experimental.** This API is part of an experimental wire-protocol surface
2842 /// and may change or be removed in future SDK or CLI releases. Pin both the
2843 /// SDK and CLI versions if your code depends on it.
2844 ///
2845 /// </div>
2846 pub async fn discover(&self, params: SkillsDiscoverRequest) -> Result<ServerSkillList, Error> {
2847 let wire_params = serde_json::to_value(params)?;
2848 let _value = self
2849 .client
2850 .call(rpc_methods::SKILLS_DISCOVER, Some(wire_params))
2851 .await?;
2852 Ok(serde_json::from_value(_value)?)
2853 }
2854
2855 /// 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.
2856 ///
2857 /// Wire method: `skills.getDiscoveryPaths`.
2858 ///
2859 /// # Parameters
2860 ///
2861 /// * `params` - Optional project paths to enumerate.
2862 ///
2863 /// # Returns
2864 ///
2865 /// Canonical locations where skills can be created so the runtime will recognize them.
2866 ///
2867 /// <div class="warning">
2868 ///
2869 /// **Experimental.** This API is part of an experimental wire-protocol surface
2870 /// and may change or be removed in future SDK or CLI releases. Pin both the
2871 /// SDK and CLI versions if your code depends on it.
2872 ///
2873 /// </div>
2874 pub async fn get_discovery_paths(
2875 &self,
2876 params: SkillsGetDiscoveryPathsRequest,
2877 ) -> Result<SkillDiscoveryPathList, Error> {
2878 let wire_params = serde_json::to_value(params)?;
2879 let _value = self
2880 .client
2881 .call(rpc_methods::SKILLS_GETDISCOVERYPATHS, Some(wire_params))
2882 .await?;
2883 Ok(serde_json::from_value(_value)?)
2884 }
2885}
2886
2887/// `skills.config.*` RPCs.
2888#[derive(Clone, Copy)]
2889pub struct ClientRpcSkillsConfig<'a> {
2890 pub(crate) client: &'a Client,
2891}
2892
2893impl<'a> ClientRpcSkillsConfig<'a> {
2894 /// Replaces the global list of disabled skills.
2895 ///
2896 /// Wire method: `skills.config.setDisabledSkills`.
2897 ///
2898 /// # Parameters
2899 ///
2900 /// * `params` - Skill names to mark as disabled in global configuration, replacing any previous list.
2901 ///
2902 /// <div class="warning">
2903 ///
2904 /// **Experimental.** This API is part of an experimental wire-protocol surface
2905 /// and may change or be removed in future SDK or CLI releases. Pin both the
2906 /// SDK and CLI versions if your code depends on it.
2907 ///
2908 /// </div>
2909 pub async fn set_disabled_skills(
2910 &self,
2911 params: SkillsConfigSetDisabledSkillsRequest,
2912 ) -> Result<(), Error> {
2913 let wire_params = serde_json::to_value(params)?;
2914 let _value = self
2915 .client
2916 .call(
2917 rpc_methods::SKILLS_CONFIG_SETDISABLEDSKILLS,
2918 Some(wire_params),
2919 )
2920 .await?;
2921 Ok(())
2922 }
2923
2924 /// Atomically adds or removes one skill from the disabled list.
2925 ///
2926 /// Wire method: `skills.config.setSkillDisabled`.
2927 ///
2928 /// # Parameters
2929 ///
2930 /// * `params` - Adds or removes a single skill from the global disabled list, leaving every other entry untouched.
2931 ///
2932 /// <div class="warning">
2933 ///
2934 /// **Experimental.** This API is part of an experimental wire-protocol surface
2935 /// and may change or be removed in future SDK or CLI releases. Pin both the
2936 /// SDK and CLI versions if your code depends on it.
2937 ///
2938 /// </div>
2939 pub async fn set_skill_disabled(
2940 &self,
2941 params: SkillsConfigSetSkillDisabledRequest,
2942 ) -> Result<(), Error> {
2943 let wire_params = serde_json::to_value(params)?;
2944 let _value = self
2945 .client
2946 .call(
2947 rpc_methods::SKILLS_CONFIG_SETSKILLDISABLED,
2948 Some(wire_params),
2949 )
2950 .await?;
2951 Ok(())
2952 }
2953}
2954
2955/// `tools.*` RPCs.
2956#[derive(Clone, Copy)]
2957pub struct ClientRpcTools<'a> {
2958 pub(crate) client: &'a Client,
2959}
2960
2961impl<'a> ClientRpcTools<'a> {
2962 /// Lists built-in tools available for a model.
2963 ///
2964 /// Wire method: `tools.list`.
2965 ///
2966 /// # Parameters
2967 ///
2968 /// * `params` - Optional model identifier whose tool overrides should be applied to the listing.
2969 ///
2970 /// # Returns
2971 ///
2972 /// Built-in tools available for the requested model, with their parameters and instructions.
2973 ///
2974 /// <div class="warning">
2975 ///
2976 /// **Experimental.** This API is part of an experimental wire-protocol surface
2977 /// and may change or be removed in future SDK or CLI releases. Pin both the
2978 /// SDK and CLI versions if your code depends on it.
2979 ///
2980 /// </div>
2981 pub async fn list(&self, params: ToolsListRequest) -> Result<ToolList, Error> {
2982 let wire_params = serde_json::to_value(params)?;
2983 let _value = self
2984 .client
2985 .call(rpc_methods::TOOLS_LIST, Some(wire_params))
2986 .await?;
2987 Ok(serde_json::from_value(_value)?)
2988 }
2989}
2990
2991/// `user.*` RPCs.
2992#[derive(Clone, Copy)]
2993pub struct ClientRpcUser<'a> {
2994 pub(crate) client: &'a Client,
2995}
2996
2997impl<'a> ClientRpcUser<'a> {
2998 /// `user.settings.*` sub-namespace.
2999 pub fn settings(&self) -> ClientRpcUserSettings<'a> {
3000 ClientRpcUserSettings {
3001 client: self.client,
3002 }
3003 }
3004}
3005
3006/// `user.settings.*` RPCs.
3007#[derive(Clone, Copy)]
3008pub struct ClientRpcUserSettings<'a> {
3009 pub(crate) client: &'a Client,
3010}
3011
3012impl<'a> ClientRpcUserSettings<'a> {
3013 /// Drops this runtime process's in-memory user settings cache so the next settings read observes disk.
3014 ///
3015 /// Wire method: `user.settings.reload`.
3016 ///
3017 /// <div class="warning">
3018 ///
3019 /// **Experimental.** This API is part of an experimental wire-protocol surface
3020 /// and may change or be removed in future SDK or CLI releases. Pin both the
3021 /// SDK and CLI versions if your code depends on it.
3022 ///
3023 /// </div>
3024 pub async fn reload(&self) -> Result<(), Error> {
3025 let wire_params = serde_json::json!({});
3026 let _value = self
3027 .client
3028 .call(rpc_methods::USER_SETTINGS_RELOAD, Some(wire_params))
3029 .await?;
3030 Ok(())
3031 }
3032
3033 /// 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.
3034 ///
3035 /// Wire method: `user.settings.get`.
3036 ///
3037 /// # Returns
3038 ///
3039 /// 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.
3040 ///
3041 /// <div class="warning">
3042 ///
3043 /// **Experimental.** This API is part of an experimental wire-protocol surface
3044 /// and may change or be removed in future SDK or CLI releases. Pin both the
3045 /// SDK and CLI versions if your code depends on it.
3046 ///
3047 /// </div>
3048 pub async fn get(&self) -> Result<UserSettingsGetResult, Error> {
3049 let wire_params = serde_json::json!({});
3050 let _value = self
3051 .client
3052 .call(rpc_methods::USER_SETTINGS_GET, Some(wire_params))
3053 .await?;
3054 Ok(serde_json::from_value(_value)?)
3055 }
3056
3057 /// 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.
3058 ///
3059 /// Wire method: `user.settings.set`.
3060 ///
3061 /// # Parameters
3062 ///
3063 /// * `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.
3064 ///
3065 /// # Returns
3066 ///
3067 /// Outcome of writing user settings.
3068 ///
3069 /// <div class="warning">
3070 ///
3071 /// **Experimental.** This API is part of an experimental wire-protocol surface
3072 /// and may change or be removed in future SDK or CLI releases. Pin both the
3073 /// SDK and CLI versions if your code depends on it.
3074 ///
3075 /// </div>
3076 pub async fn set(
3077 &self,
3078 params: UserSettingsSetRequest,
3079 ) -> Result<UserSettingsSetResult, Error> {
3080 let wire_params = serde_json::to_value(params)?;
3081 let _value = self
3082 .client
3083 .call(rpc_methods::USER_SETTINGS_SET, Some(wire_params))
3084 .await?;
3085 Ok(serde_json::from_value(_value)?)
3086 }
3087}
3088
3089/// Typed view over a [`Session`]'s RPC namespace.
3090#[derive(Clone, Copy)]
3091pub struct SessionRpc<'a> {
3092 pub(crate) session: &'a Session,
3093}
3094
3095impl<'a> SessionRpc<'a> {
3096 /// `session.agent.*` sub-namespace.
3097 pub fn agent(&self) -> SessionRpcAgent<'a> {
3098 SessionRpcAgent {
3099 session: self.session,
3100 }
3101 }
3102
3103 /// `session.autopilotObjective.*` sub-namespace.
3104 pub fn autopilot_objective(&self) -> SessionRpcAutopilotObjective<'a> {
3105 SessionRpcAutopilotObjective {
3106 session: self.session,
3107 }
3108 }
3109
3110 /// `session.canvas.*` sub-namespace.
3111 pub fn canvas(&self) -> SessionRpcCanvas<'a> {
3112 SessionRpcCanvas {
3113 session: self.session,
3114 }
3115 }
3116
3117 /// `session.commands.*` sub-namespace.
3118 pub fn commands(&self) -> SessionRpcCommands<'a> {
3119 SessionRpcCommands {
3120 session: self.session,
3121 }
3122 }
3123
3124 /// `session.completions.*` sub-namespace.
3125 pub fn completions(&self) -> SessionRpcCompletions<'a> {
3126 SessionRpcCompletions {
3127 session: self.session,
3128 }
3129 }
3130
3131 /// `session.contentExclusion.*` sub-namespace.
3132 pub fn content_exclusion(&self) -> SessionRpcContentExclusion<'a> {
3133 SessionRpcContentExclusion {
3134 session: self.session,
3135 }
3136 }
3137
3138 /// `session.debug.*` sub-namespace.
3139 pub fn debug(&self) -> SessionRpcDebug<'a> {
3140 SessionRpcDebug {
3141 session: self.session,
3142 }
3143 }
3144
3145 /// `session.eventLog.*` sub-namespace.
3146 pub fn event_log(&self) -> SessionRpcEventLog<'a> {
3147 SessionRpcEventLog {
3148 session: self.session,
3149 }
3150 }
3151
3152 /// `session.extensions.*` sub-namespace.
3153 pub fn extensions(&self) -> SessionRpcExtensions<'a> {
3154 SessionRpcExtensions {
3155 session: self.session,
3156 }
3157 }
3158
3159 /// `session.factory.*` sub-namespace.
3160 pub fn factory(&self) -> SessionRpcFactory<'a> {
3161 SessionRpcFactory {
3162 session: self.session,
3163 }
3164 }
3165
3166 /// `session.fleet.*` sub-namespace.
3167 pub fn fleet(&self) -> SessionRpcFleet<'a> {
3168 SessionRpcFleet {
3169 session: self.session,
3170 }
3171 }
3172
3173 /// `session.gitHubAuth.*` sub-namespace.
3174 pub fn git_hub_auth(&self) -> SessionRpcGitHubAuth<'a> {
3175 SessionRpcGitHubAuth {
3176 session: self.session,
3177 }
3178 }
3179
3180 /// `session.history.*` sub-namespace.
3181 pub fn history(&self) -> SessionRpcHistory<'a> {
3182 SessionRpcHistory {
3183 session: self.session,
3184 }
3185 }
3186
3187 /// `session.instructions.*` sub-namespace.
3188 pub fn instructions(&self) -> SessionRpcInstructions<'a> {
3189 SessionRpcInstructions {
3190 session: self.session,
3191 }
3192 }
3193
3194 /// `session.limitPrediction.*` sub-namespace.
3195 pub fn limit_prediction(&self) -> SessionRpcLimitPrediction<'a> {
3196 SessionRpcLimitPrediction {
3197 session: self.session,
3198 }
3199 }
3200
3201 /// `session.lsp.*` sub-namespace.
3202 pub fn lsp(&self) -> SessionRpcLsp<'a> {
3203 SessionRpcLsp {
3204 session: self.session,
3205 }
3206 }
3207
3208 /// `session.mcp.*` sub-namespace.
3209 pub fn mcp(&self) -> SessionRpcMcp<'a> {
3210 SessionRpcMcp {
3211 session: self.session,
3212 }
3213 }
3214
3215 /// `session.metadata.*` sub-namespace.
3216 pub fn metadata(&self) -> SessionRpcMetadata<'a> {
3217 SessionRpcMetadata {
3218 session: self.session,
3219 }
3220 }
3221
3222 /// `session.mode.*` sub-namespace.
3223 pub fn mode(&self) -> SessionRpcMode<'a> {
3224 SessionRpcMode {
3225 session: self.session,
3226 }
3227 }
3228
3229 /// `session.model.*` sub-namespace.
3230 pub fn model(&self) -> SessionRpcModel<'a> {
3231 SessionRpcModel {
3232 session: self.session,
3233 }
3234 }
3235
3236 /// `session.name.*` sub-namespace.
3237 pub fn name(&self) -> SessionRpcName<'a> {
3238 SessionRpcName {
3239 session: self.session,
3240 }
3241 }
3242
3243 /// `session.options.*` sub-namespace.
3244 pub fn options(&self) -> SessionRpcOptions<'a> {
3245 SessionRpcOptions {
3246 session: self.session,
3247 }
3248 }
3249
3250 /// `session.permissions.*` sub-namespace.
3251 pub fn permissions(&self) -> SessionRpcPermissions<'a> {
3252 SessionRpcPermissions {
3253 session: self.session,
3254 }
3255 }
3256
3257 /// `session.plan.*` sub-namespace.
3258 pub fn plan(&self) -> SessionRpcPlan<'a> {
3259 SessionRpcPlan {
3260 session: self.session,
3261 }
3262 }
3263
3264 /// `session.plugins.*` sub-namespace.
3265 pub fn plugins(&self) -> SessionRpcPlugins<'a> {
3266 SessionRpcPlugins {
3267 session: self.session,
3268 }
3269 }
3270
3271 /// `session.provider.*` sub-namespace.
3272 pub fn provider(&self) -> SessionRpcProvider<'a> {
3273 SessionRpcProvider {
3274 session: self.session,
3275 }
3276 }
3277
3278 /// `session.queue.*` sub-namespace.
3279 pub fn queue(&self) -> SessionRpcQueue<'a> {
3280 SessionRpcQueue {
3281 session: self.session,
3282 }
3283 }
3284
3285 /// `session.remote.*` sub-namespace.
3286 pub fn remote(&self) -> SessionRpcRemote<'a> {
3287 SessionRpcRemote {
3288 session: self.session,
3289 }
3290 }
3291
3292 /// `session.sandbox.*` sub-namespace.
3293 pub fn sandbox(&self) -> SessionRpcSandbox<'a> {
3294 SessionRpcSandbox {
3295 session: self.session,
3296 }
3297 }
3298
3299 /// `session.schedule.*` sub-namespace.
3300 pub fn schedule(&self) -> SessionRpcSchedule<'a> {
3301 SessionRpcSchedule {
3302 session: self.session,
3303 }
3304 }
3305
3306 /// `session.settings.*` sub-namespace.
3307 pub fn settings(&self) -> SessionRpcSettings<'a> {
3308 SessionRpcSettings {
3309 session: self.session,
3310 }
3311 }
3312
3313 /// `session.shell.*` sub-namespace.
3314 pub fn shell(&self) -> SessionRpcShell<'a> {
3315 SessionRpcShell {
3316 session: self.session,
3317 }
3318 }
3319
3320 /// `session.skills.*` sub-namespace.
3321 pub fn skills(&self) -> SessionRpcSkills<'a> {
3322 SessionRpcSkills {
3323 session: self.session,
3324 }
3325 }
3326
3327 /// `session.tasks.*` sub-namespace.
3328 pub fn tasks(&self) -> SessionRpcTasks<'a> {
3329 SessionRpcTasks {
3330 session: self.session,
3331 }
3332 }
3333
3334 /// `session.telemetry.*` sub-namespace.
3335 pub fn telemetry(&self) -> SessionRpcTelemetry<'a> {
3336 SessionRpcTelemetry {
3337 session: self.session,
3338 }
3339 }
3340
3341 /// `session.tools.*` sub-namespace.
3342 pub fn tools(&self) -> SessionRpcTools<'a> {
3343 SessionRpcTools {
3344 session: self.session,
3345 }
3346 }
3347
3348 /// `session.ui.*` sub-namespace.
3349 pub fn ui(&self) -> SessionRpcUi<'a> {
3350 SessionRpcUi {
3351 session: self.session,
3352 }
3353 }
3354
3355 /// `session.usage.*` sub-namespace.
3356 pub fn usage(&self) -> SessionRpcUsage<'a> {
3357 SessionRpcUsage {
3358 session: self.session,
3359 }
3360 }
3361
3362 /// `session.visibility.*` sub-namespace.
3363 pub fn visibility(&self) -> SessionRpcVisibility<'a> {
3364 SessionRpcVisibility {
3365 session: self.session,
3366 }
3367 }
3368
3369 /// `session.workspaces.*` sub-namespace.
3370 pub fn workspaces(&self) -> SessionRpcWorkspaces<'a> {
3371 SessionRpcWorkspaces {
3372 session: self.session,
3373 }
3374 }
3375
3376 /// Suspends the session while preserving persisted state for later resume.
3377 ///
3378 /// Wire method: `session.suspend`.
3379 ///
3380 /// <div class="warning">
3381 ///
3382 /// **Experimental.** This API is part of an experimental wire-protocol surface
3383 /// and may change or be removed in future SDK or CLI releases. Pin both the
3384 /// SDK and CLI versions if your code depends on it.
3385 ///
3386 /// </div>
3387 pub async fn suspend(&self) -> Result<(), Error> {
3388 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3389 let _value = self
3390 .session
3391 .client()
3392 .call(rpc_methods::SESSION_SUSPEND, Some(wire_params))
3393 .await?;
3394 Ok(())
3395 }
3396
3397 /// Sends a user message to the session and returns its message ID.
3398 ///
3399 /// Wire method: `session.send`.
3400 ///
3401 /// # Parameters
3402 ///
3403 /// * `params` - Parameters for sending a user message to the session
3404 ///
3405 /// # Returns
3406 ///
3407 /// Result of sending a user message
3408 ///
3409 /// <div class="warning">
3410 ///
3411 /// **Experimental.** This API is part of an experimental wire-protocol surface
3412 /// and may change or be removed in future SDK or CLI releases. Pin both the
3413 /// SDK and CLI versions if your code depends on it.
3414 ///
3415 /// </div>
3416 pub async fn send(&self, params: SendRequest) -> Result<SendResult, Error> {
3417 let mut wire_params = serde_json::to_value(params)?;
3418 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3419 let _value = self
3420 .session
3421 .client()
3422 .call(rpc_methods::SESSION_SEND, Some(wire_params))
3423 .await?;
3424 Ok(serde_json::from_value(_value)?)
3425 }
3426
3427 /// 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.
3428 ///
3429 /// Wire method: `session.sendMessages`.
3430 ///
3431 /// # Parameters
3432 ///
3433 /// * `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.
3434 ///
3435 /// # Returns
3436 ///
3437 /// Result of sending zero or more user messages
3438 ///
3439 /// <div class="warning">
3440 ///
3441 /// **Experimental.** This API is part of an experimental wire-protocol surface
3442 /// and may change or be removed in future SDK or CLI releases. Pin both the
3443 /// SDK and CLI versions if your code depends on it.
3444 ///
3445 /// </div>
3446 pub async fn send_messages(
3447 &self,
3448 params: SendMessagesRequest,
3449 ) -> Result<SendMessagesResult, Error> {
3450 let mut wire_params = serde_json::to_value(params)?;
3451 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3452 let _value = self
3453 .session
3454 .client()
3455 .call(rpc_methods::SESSION_SENDMESSAGES, Some(wire_params))
3456 .await?;
3457 Ok(serde_json::from_value(_value)?)
3458 }
3459
3460 /// Queues or sends an internal system notification to the session according to its passive policy.
3461 ///
3462 /// Wire method: `session.sendSystemNotification`.
3463 ///
3464 /// # Parameters
3465 ///
3466 /// * `params` - Internal request for sending a system notification.
3467 ///
3468 /// <div class="warning">
3469 ///
3470 /// **Experimental.** This API is part of an experimental wire-protocol surface
3471 /// and may change or be removed in future SDK or CLI releases. Pin both the
3472 /// SDK and CLI versions if your code depends on it.
3473 ///
3474 /// </div>
3475 pub(crate) async fn send_system_notification(
3476 &self,
3477 params: SendSystemNotificationRequest,
3478 ) -> Result<(), Error> {
3479 let mut wire_params = serde_json::to_value(params)?;
3480 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3481 let _value = self
3482 .session
3483 .client()
3484 .call(
3485 rpc_methods::SESSION_SENDSYSTEMNOTIFICATION,
3486 Some(wire_params),
3487 )
3488 .await?;
3489 Ok(())
3490 }
3491
3492 /// Aborts the current agent turn.
3493 ///
3494 /// Wire method: `session.abort`.
3495 ///
3496 /// # Parameters
3497 ///
3498 /// * `params` - Parameters for aborting the current turn
3499 ///
3500 /// # Returns
3501 ///
3502 /// Result of aborting the current turn
3503 ///
3504 /// <div class="warning">
3505 ///
3506 /// **Experimental.** This API is part of an experimental wire-protocol surface
3507 /// and may change or be removed in future SDK or CLI releases. Pin both the
3508 /// SDK and CLI versions if your code depends on it.
3509 ///
3510 /// </div>
3511 pub async fn abort(&self, params: AbortRequest) -> Result<AbortResult, Error> {
3512 let mut wire_params = serde_json::to_value(params)?;
3513 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3514 let _value = self
3515 .session
3516 .client()
3517 .call(rpc_methods::SESSION_ABORT, Some(wire_params))
3518 .await?;
3519 Ok(serde_json::from_value(_value)?)
3520 }
3521
3522 /// 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.
3523 ///
3524 /// Wire method: `session.interruptMainTurn`.
3525 ///
3526 /// # Parameters
3527 ///
3528 /// * `params` - Parameters for interrupting the main agent turn.
3529 ///
3530 /// # Returns
3531 ///
3532 /// Result of interrupting the main agent turn.
3533 ///
3534 /// <div class="warning">
3535 ///
3536 /// **Experimental.** This API is part of an experimental wire-protocol surface
3537 /// and may change or be removed in future SDK or CLI releases. Pin both the
3538 /// SDK and CLI versions if your code depends on it.
3539 ///
3540 /// </div>
3541 pub async fn interrupt_main_turn(
3542 &self,
3543 params: InterruptMainTurnRequest,
3544 ) -> Result<InterruptMainTurnResult, Error> {
3545 let mut wire_params = serde_json::to_value(params)?;
3546 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3547 let _value = self
3548 .session
3549 .client()
3550 .call(rpc_methods::SESSION_INTERRUPTMAINTURN, Some(wire_params))
3551 .await?;
3552 Ok(serde_json::from_value(_value)?)
3553 }
3554
3555 /// Cancels every running background agent (task-registry subagents plus sidekick agents) without interrupting the main agent loop. Promoted attached shells are left running.
3556 ///
3557 /// Wire method: `session.cancelAllBackgroundAgents`.
3558 ///
3559 /// # Returns
3560 ///
3561 /// The number of running background agents (task-registry agents) that were cancelled.
3562 ///
3563 /// <div class="warning">
3564 ///
3565 /// **Experimental.** This API is part of an experimental wire-protocol surface
3566 /// and may change or be removed in future SDK or CLI releases. Pin both the
3567 /// SDK and CLI versions if your code depends on it.
3568 ///
3569 /// </div>
3570 pub async fn cancel_all_background_agents(
3571 &self,
3572 ) -> Result<SessionCancelAllBackgroundAgentsResult, Error> {
3573 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3574 let _value = self
3575 .session
3576 .client()
3577 .call(
3578 rpc_methods::SESSION_CANCELALLBACKGROUNDAGENTS,
3579 Some(wire_params),
3580 )
3581 .await?;
3582 Ok(serde_json::from_value(_value)?)
3583 }
3584
3585 /// 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.
3586 ///
3587 /// Wire method: `session.shutdown`.
3588 ///
3589 /// # Parameters
3590 ///
3591 /// * `params` - Parameters for shutting down the session
3592 ///
3593 /// <div class="warning">
3594 ///
3595 /// **Experimental.** This API is part of an experimental wire-protocol surface
3596 /// and may change or be removed in future SDK or CLI releases. Pin both the
3597 /// SDK and CLI versions if your code depends on it.
3598 ///
3599 /// </div>
3600 pub async fn shutdown(&self, params: ShutdownRequest) -> Result<(), Error> {
3601 let mut wire_params = serde_json::to_value(params)?;
3602 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3603 let _value = self
3604 .session
3605 .client()
3606 .call(rpc_methods::SESSION_SHUTDOWN, Some(wire_params))
3607 .await?;
3608 Ok(())
3609 }
3610
3611 /// Emits a user-visible session log event.
3612 ///
3613 /// Wire method: `session.log`.
3614 ///
3615 /// # Parameters
3616 ///
3617 /// * `params` - Message text, optional severity level, persistence flag, optional follow-up URL, and optional tip.
3618 ///
3619 /// # Returns
3620 ///
3621 /// Identifier of the session event that was emitted for the log message.
3622 ///
3623 /// <div class="warning">
3624 ///
3625 /// **Experimental.** This API is part of an experimental wire-protocol surface
3626 /// and may change or be removed in future SDK or CLI releases. Pin both the
3627 /// SDK and CLI versions if your code depends on it.
3628 ///
3629 /// </div>
3630 pub async fn log(&self, params: LogRequest) -> Result<LogResult, Error> {
3631 let mut wire_params = serde_json::to_value(params)?;
3632 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3633 let _value = self
3634 .session
3635 .client()
3636 .call(rpc_methods::SESSION_LOG, Some(wire_params))
3637 .await?;
3638 Ok(serde_json::from_value(_value)?)
3639 }
3640}
3641
3642/// `session.agent.*` RPCs.
3643#[derive(Clone, Copy)]
3644pub struct SessionRpcAgent<'a> {
3645 pub(crate) session: &'a Session,
3646}
3647
3648impl<'a> SessionRpcAgent<'a> {
3649 /// Lists agents available to the session. Defaults to custom agents only; pass includeBuiltInAgents to include the effective built-in agents.
3650 ///
3651 /// Wire method: `session.agent.list`.
3652 ///
3653 /// # Returns
3654 ///
3655 /// Agents available to the session.
3656 ///
3657 /// <div class="warning">
3658 ///
3659 /// **Experimental.** This API is part of an experimental wire-protocol surface
3660 /// and may change or be removed in future SDK or CLI releases. Pin both the
3661 /// SDK and CLI versions if your code depends on it.
3662 ///
3663 /// </div>
3664 pub async fn list(&self) -> Result<AgentList, Error> {
3665 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3666 let _value = self
3667 .session
3668 .client()
3669 .call(rpc_methods::SESSION_AGENT_LIST, Some(wire_params))
3670 .await?;
3671 Ok(serde_json::from_value(_value)?)
3672 }
3673
3674 /// Lists agents available to the session. Defaults to custom agents only; pass includeBuiltInAgents to include the effective built-in agents.
3675 ///
3676 /// Wire method: `session.agent.list`.
3677 ///
3678 /// # Parameters
3679 ///
3680 /// * `params` - Controls whether built-in agents and authored prompt text are included.
3681 ///
3682 /// # Returns
3683 ///
3684 /// Agents available to the session.
3685 ///
3686 /// <div class="warning">
3687 ///
3688 /// **Experimental.** This API is part of an experimental wire-protocol surface
3689 /// and may change or be removed in future SDK or CLI releases. Pin both the
3690 /// SDK and CLI versions if your code depends on it.
3691 ///
3692 /// </div>
3693 pub async fn list_with_params(&self, params: AgentListRequest) -> Result<AgentList, Error> {
3694 let mut wire_params = serde_json::to_value(params)?;
3695 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3696 let _value = self
3697 .session
3698 .client()
3699 .call(rpc_methods::SESSION_AGENT_LIST, Some(wire_params))
3700 .await?;
3701 Ok(serde_json::from_value(_value)?)
3702 }
3703
3704 /// 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.
3705 ///
3706 /// Wire method: `session.agent.setPrompt`.
3707 ///
3708 /// # Parameters
3709 ///
3710 /// * `params` - An in-memory authored prompt override for an available agent.
3711 ///
3712 /// <div class="warning">
3713 ///
3714 /// **Experimental.** This API is part of an experimental wire-protocol surface
3715 /// and may change or be removed in future SDK or CLI releases. Pin both the
3716 /// SDK and CLI versions if your code depends on it.
3717 ///
3718 /// </div>
3719 pub async fn set_prompt(&self, params: AgentSetPromptRequest) -> Result<(), Error> {
3720 let mut wire_params = serde_json::to_value(params)?;
3721 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3722 let _value = self
3723 .session
3724 .client()
3725 .call(rpc_methods::SESSION_AGENT_SETPROMPT, Some(wire_params))
3726 .await?;
3727 Ok(())
3728 }
3729
3730 /// Gets the currently selected custom agent for the session.
3731 ///
3732 /// Wire method: `session.agent.getCurrent`.
3733 ///
3734 /// # Returns
3735 ///
3736 /// The currently selected custom agent, or null when using the default agent.
3737 ///
3738 /// <div class="warning">
3739 ///
3740 /// **Experimental.** This API is part of an experimental wire-protocol surface
3741 /// and may change or be removed in future SDK or CLI releases. Pin both the
3742 /// SDK and CLI versions if your code depends on it.
3743 ///
3744 /// </div>
3745 pub async fn get_current(&self) -> Result<AgentGetCurrentResult, Error> {
3746 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3747 let _value = self
3748 .session
3749 .client()
3750 .call(rpc_methods::SESSION_AGENT_GETCURRENT, Some(wire_params))
3751 .await?;
3752 Ok(serde_json::from_value(_value)?)
3753 }
3754
3755 /// Selects a custom agent for subsequent turns in the session.
3756 ///
3757 /// Wire method: `session.agent.select`.
3758 ///
3759 /// # Parameters
3760 ///
3761 /// * `params` - Name of the custom agent to select for subsequent turns.
3762 ///
3763 /// # Returns
3764 ///
3765 /// The newly selected custom agent.
3766 ///
3767 /// <div class="warning">
3768 ///
3769 /// **Experimental.** This API is part of an experimental wire-protocol surface
3770 /// and may change or be removed in future SDK or CLI releases. Pin both the
3771 /// SDK and CLI versions if your code depends on it.
3772 ///
3773 /// </div>
3774 pub async fn select(&self, params: AgentSelectRequest) -> Result<AgentSelectResult, Error> {
3775 let mut wire_params = serde_json::to_value(params)?;
3776 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3777 let _value = self
3778 .session
3779 .client()
3780 .call(rpc_methods::SESSION_AGENT_SELECT, Some(wire_params))
3781 .await?;
3782 Ok(serde_json::from_value(_value)?)
3783 }
3784
3785 /// Clears the selected custom agent and returns the session to the default agent.
3786 ///
3787 /// Wire method: `session.agent.deselect`.
3788 ///
3789 /// <div class="warning">
3790 ///
3791 /// **Experimental.** This API is part of an experimental wire-protocol surface
3792 /// and may change or be removed in future SDK or CLI releases. Pin both the
3793 /// SDK and CLI versions if your code depends on it.
3794 ///
3795 /// </div>
3796 pub async fn deselect(&self) -> Result<(), Error> {
3797 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3798 let _value = self
3799 .session
3800 .client()
3801 .call(rpc_methods::SESSION_AGENT_DESELECT, Some(wire_params))
3802 .await?;
3803 Ok(())
3804 }
3805
3806 /// Reloads custom agent definitions and returns the refreshed list.
3807 ///
3808 /// Wire method: `session.agent.reload`.
3809 ///
3810 /// # Returns
3811 ///
3812 /// Custom agents available to the session after reloading definitions from disk.
3813 ///
3814 /// <div class="warning">
3815 ///
3816 /// **Experimental.** This API is part of an experimental wire-protocol surface
3817 /// and may change or be removed in future SDK or CLI releases. Pin both the
3818 /// SDK and CLI versions if your code depends on it.
3819 ///
3820 /// </div>
3821 pub async fn reload(&self) -> Result<AgentReloadResult, Error> {
3822 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3823 let _value = self
3824 .session
3825 .client()
3826 .call(rpc_methods::SESSION_AGENT_RELOAD, Some(wire_params))
3827 .await?;
3828 Ok(serde_json::from_value(_value)?)
3829 }
3830}
3831
3832/// `session.autopilotObjective.*` RPCs.
3833#[derive(Clone, Copy)]
3834pub struct SessionRpcAutopilotObjective<'a> {
3835 pub(crate) session: &'a Session,
3836}
3837
3838impl<'a> SessionRpcAutopilotObjective<'a> {
3839 /// Reads the current canonical autopilot objective state for this session.
3840 ///
3841 /// Wire method: `session.autopilotObjective.getState`.
3842 ///
3843 /// # Returns
3844 ///
3845 /// Canonical runtime state for the session's current autopilot objective.
3846 ///
3847 /// <div class="warning">
3848 ///
3849 /// **Experimental.** This API is part of an experimental wire-protocol surface
3850 /// and may change or be removed in future SDK or CLI releases. Pin both the
3851 /// SDK and CLI versions if your code depends on it.
3852 ///
3853 /// </div>
3854 pub async fn get_state(&self) -> Result<AutopilotObjectiveGetStateResult, Error> {
3855 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3856 let _value = self
3857 .session
3858 .client()
3859 .call(
3860 rpc_methods::SESSION_AUTOPILOTOBJECTIVE_GETSTATE,
3861 Some(wire_params),
3862 )
3863 .await?;
3864 Ok(serde_json::from_value(_value)?)
3865 }
3866}
3867
3868/// `session.canvas.*` RPCs.
3869#[derive(Clone, Copy)]
3870pub struct SessionRpcCanvas<'a> {
3871 pub(crate) session: &'a Session,
3872}
3873
3874impl<'a> SessionRpcCanvas<'a> {
3875 /// `session.canvas.action.*` sub-namespace.
3876 pub fn action(&self) -> SessionRpcCanvasAction<'a> {
3877 SessionRpcCanvasAction {
3878 session: self.session,
3879 }
3880 }
3881
3882 /// `session.canvas.provider.*` sub-namespace.
3883 pub fn provider(&self) -> SessionRpcCanvasProvider<'a> {
3884 SessionRpcCanvasProvider {
3885 session: self.session,
3886 }
3887 }
3888
3889 /// Lists canvases declared for the session.
3890 ///
3891 /// Wire method: `session.canvas.list`.
3892 ///
3893 /// # Returns
3894 ///
3895 /// Declared canvases available in this session.
3896 ///
3897 /// <div class="warning">
3898 ///
3899 /// **Experimental.** This API is part of an experimental wire-protocol surface
3900 /// and may change or be removed in future SDK or CLI releases. Pin both the
3901 /// SDK and CLI versions if your code depends on it.
3902 ///
3903 /// </div>
3904 pub async fn list(&self) -> Result<CanvasList, Error> {
3905 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3906 let _value = self
3907 .session
3908 .client()
3909 .call(rpc_methods::SESSION_CANVAS_LIST, Some(wire_params))
3910 .await?;
3911 Ok(serde_json::from_value(_value)?)
3912 }
3913
3914 /// Lists currently open canvas instances for the live session.
3915 ///
3916 /// Wire method: `session.canvas.listOpen`.
3917 ///
3918 /// # Returns
3919 ///
3920 /// Live open-canvas snapshot.
3921 ///
3922 /// <div class="warning">
3923 ///
3924 /// **Experimental.** This API is part of an experimental wire-protocol surface
3925 /// and may change or be removed in future SDK or CLI releases. Pin both the
3926 /// SDK and CLI versions if your code depends on it.
3927 ///
3928 /// </div>
3929 pub async fn list_open(&self) -> Result<CanvasListOpenResult, Error> {
3930 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3931 let _value = self
3932 .session
3933 .client()
3934 .call(rpc_methods::SESSION_CANVAS_LISTOPEN, Some(wire_params))
3935 .await?;
3936 Ok(serde_json::from_value(_value)?)
3937 }
3938
3939 /// Opens or focuses a canvas instance.
3940 ///
3941 /// Wire method: `session.canvas.open`.
3942 ///
3943 /// # Parameters
3944 ///
3945 /// * `params` - Canvas open parameters.
3946 ///
3947 /// # Returns
3948 ///
3949 /// Open canvas instance snapshot.
3950 ///
3951 /// <div class="warning">
3952 ///
3953 /// **Experimental.** This API is part of an experimental wire-protocol surface
3954 /// and may change or be removed in future SDK or CLI releases. Pin both the
3955 /// SDK and CLI versions if your code depends on it.
3956 ///
3957 /// </div>
3958 pub async fn open(&self, params: CanvasOpenRequest) -> Result<OpenCanvasInstance, Error> {
3959 let mut wire_params = serde_json::to_value(params)?;
3960 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3961 let _value = self
3962 .session
3963 .client()
3964 .call(rpc_methods::SESSION_CANVAS_OPEN, Some(wire_params))
3965 .await?;
3966 Ok(serde_json::from_value(_value)?)
3967 }
3968
3969 /// Closes an open canvas instance.
3970 ///
3971 /// Wire method: `session.canvas.close`.
3972 ///
3973 /// # Parameters
3974 ///
3975 /// * `params` - Canvas close parameters.
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 close(&self, params: CanvasCloseRequest) -> Result<(), Error> {
3985 let mut wire_params = serde_json::to_value(params)?;
3986 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3987 let _value = self
3988 .session
3989 .client()
3990 .call(rpc_methods::SESSION_CANVAS_CLOSE, Some(wire_params))
3991 .await?;
3992 Ok(())
3993 }
3994}
3995
3996/// `session.canvas.action.*` RPCs.
3997#[derive(Clone, Copy)]
3998pub struct SessionRpcCanvasAction<'a> {
3999 pub(crate) session: &'a Session,
4000}
4001
4002impl<'a> SessionRpcCanvasAction<'a> {
4003 /// Invokes an action on an open canvas instance.
4004 ///
4005 /// Wire method: `session.canvas.action.invoke`.
4006 ///
4007 /// # Parameters
4008 ///
4009 /// * `params` - Canvas action invocation parameters.
4010 ///
4011 /// # Returns
4012 ///
4013 /// Canvas action invocation result.
4014 ///
4015 /// <div class="warning">
4016 ///
4017 /// **Experimental.** This API is part of an experimental wire-protocol surface
4018 /// and may change or be removed in future SDK or CLI releases. Pin both the
4019 /// SDK and CLI versions if your code depends on it.
4020 ///
4021 /// </div>
4022 pub async fn invoke(
4023 &self,
4024 params: CanvasActionInvokeRequest,
4025 ) -> Result<CanvasActionInvokeResult, Error> {
4026 let mut wire_params = serde_json::to_value(params)?;
4027 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4028 let _value = self
4029 .session
4030 .client()
4031 .call(rpc_methods::SESSION_CANVAS_ACTION_INVOKE, Some(wire_params))
4032 .await?;
4033 Ok(serde_json::from_value(_value)?)
4034 }
4035}
4036
4037/// `session.canvas.provider.*` RPCs.
4038#[derive(Clone, Copy)]
4039pub struct SessionRpcCanvasProvider<'a> {
4040 pub(crate) session: &'a Session,
4041}
4042
4043impl<'a> SessionRpcCanvasProvider<'a> {
4044 /// Registers an internal canvas provider connection and its contributions.
4045 ///
4046 /// Wire method: `session.canvas.provider.register`.
4047 ///
4048 /// # Parameters
4049 ///
4050 /// * `params` - Internal canvas provider registration parameters.
4051 ///
4052 /// <div class="warning">
4053 ///
4054 /// **Experimental.** This API is part of an experimental wire-protocol surface
4055 /// and may change or be removed in future SDK or CLI releases. Pin both the
4056 /// SDK and CLI versions if your code depends on it.
4057 ///
4058 /// </div>
4059 pub(crate) async fn register(
4060 &self,
4061 params: CanvasProviderRegisterRequest,
4062 ) -> Result<(), Error> {
4063 let mut wire_params = serde_json::to_value(params)?;
4064 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4065 let _value = self
4066 .session
4067 .client()
4068 .call(
4069 rpc_methods::SESSION_CANVAS_PROVIDER_REGISTER,
4070 Some(wire_params),
4071 )
4072 .await?;
4073 Ok(())
4074 }
4075
4076 /// Unregisters an internal canvas provider connection.
4077 ///
4078 /// Wire method: `session.canvas.provider.unregister`.
4079 ///
4080 /// # Parameters
4081 ///
4082 /// * `params` - Internal canvas provider unregistration parameters.
4083 ///
4084 /// <div class="warning">
4085 ///
4086 /// **Experimental.** This API is part of an experimental wire-protocol surface
4087 /// and may change or be removed in future SDK or CLI releases. Pin both the
4088 /// SDK and CLI versions if your code depends on it.
4089 ///
4090 /// </div>
4091 pub(crate) async fn unregister(
4092 &self,
4093 params: CanvasProviderUnregisterRequest,
4094 ) -> Result<(), Error> {
4095 let mut wire_params = serde_json::to_value(params)?;
4096 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4097 let _value = self
4098 .session
4099 .client()
4100 .call(
4101 rpc_methods::SESSION_CANVAS_PROVIDER_UNREGISTER,
4102 Some(wire_params),
4103 )
4104 .await?;
4105 Ok(())
4106 }
4107}
4108
4109/// `session.commands.*` RPCs.
4110#[derive(Clone, Copy)]
4111pub struct SessionRpcCommands<'a> {
4112 pub(crate) session: &'a Session,
4113}
4114
4115impl<'a> SessionRpcCommands<'a> {
4116 /// Lists slash commands available in the session.
4117 ///
4118 /// Wire method: `session.commands.list`.
4119 ///
4120 /// # Returns
4121 ///
4122 /// Slash commands available in the session, after applying any include/exclude filters.
4123 ///
4124 /// <div class="warning">
4125 ///
4126 /// **Experimental.** This API is part of an experimental wire-protocol surface
4127 /// and may change or be removed in future SDK or CLI releases. Pin both the
4128 /// SDK and CLI versions if your code depends on it.
4129 ///
4130 /// </div>
4131 pub async fn list(&self) -> Result<CommandList, Error> {
4132 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
4133 let _value = self
4134 .session
4135 .client()
4136 .call(rpc_methods::SESSION_COMMANDS_LIST, Some(wire_params))
4137 .await?;
4138 Ok(serde_json::from_value(_value)?)
4139 }
4140
4141 /// Lists slash commands available in the session.
4142 ///
4143 /// Wire method: `session.commands.list`.
4144 ///
4145 /// # Parameters
4146 ///
4147 /// * `params` - Optional filters controlling which command sources to include in the listing.
4148 ///
4149 /// # Returns
4150 ///
4151 /// Slash commands available in the session, after applying any include/exclude filters.
4152 ///
4153 /// <div class="warning">
4154 ///
4155 /// **Experimental.** This API is part of an experimental wire-protocol surface
4156 /// and may change or be removed in future SDK or CLI releases. Pin both the
4157 /// SDK and CLI versions if your code depends on it.
4158 ///
4159 /// </div>
4160 pub async fn list_with_params(
4161 &self,
4162 params: CommandsListRequest,
4163 ) -> Result<CommandList, Error> {
4164 let mut wire_params = serde_json::to_value(params)?;
4165 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4166 let _value = self
4167 .session
4168 .client()
4169 .call(rpc_methods::SESSION_COMMANDS_LIST, Some(wire_params))
4170 .await?;
4171 Ok(serde_json::from_value(_value)?)
4172 }
4173
4174 /// Invokes a slash command in the session.
4175 ///
4176 /// Wire method: `session.commands.invoke`.
4177 ///
4178 /// # Parameters
4179 ///
4180 /// * `params` - Slash command name and optional raw input string to invoke.
4181 ///
4182 /// # Returns
4183 ///
4184 /// Result of invoking the slash command (text output, prompt to send to the agent, completion, or subcommand selection).
4185 ///
4186 /// <div class="warning">
4187 ///
4188 /// **Experimental.** This API is part of an experimental wire-protocol surface
4189 /// and may change or be removed in future SDK or CLI releases. Pin both the
4190 /// SDK and CLI versions if your code depends on it.
4191 ///
4192 /// </div>
4193 pub async fn invoke(
4194 &self,
4195 params: CommandsInvokeRequest,
4196 ) -> Result<SlashCommandInvocationResult, Error> {
4197 let mut wire_params = serde_json::to_value(params)?;
4198 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4199 let _value = self
4200 .session
4201 .client()
4202 .call(rpc_methods::SESSION_COMMANDS_INVOKE, Some(wire_params))
4203 .await?;
4204 Ok(serde_json::from_value(_value)?)
4205 }
4206
4207 /// Finalizes persistence associated with a client-applied slash-command effect.
4208 ///
4209 /// Wire method: `session.commands.finalizeInvocationEffect`.
4210 ///
4211 /// # Parameters
4212 ///
4213 /// * `params` - The pending slash-command invocation effect to finalize, plus whether the host applied or cancelled it.
4214 ///
4215 /// # Returns
4216 ///
4217 /// Whether finalizing the invocation effect succeeded, and the failure reason when it did not.
4218 ///
4219 /// <div class="warning">
4220 ///
4221 /// **Experimental.** This API is part of an experimental wire-protocol surface
4222 /// and may change or be removed in future SDK or CLI releases. Pin both the
4223 /// SDK and CLI versions if your code depends on it.
4224 ///
4225 /// </div>
4226 pub(crate) async fn finalize_invocation_effect(
4227 &self,
4228 params: CommandsFinalizeInvocationEffectRequest,
4229 ) -> Result<CommandsFinalizeInvocationEffectResult, Error> {
4230 let mut wire_params = serde_json::to_value(params)?;
4231 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4232 let _value = self
4233 .session
4234 .client()
4235 .call(
4236 rpc_methods::SESSION_COMMANDS_FINALIZEINVOCATIONEFFECT,
4237 Some(wire_params),
4238 )
4239 .await?;
4240 Ok(serde_json::from_value(_value)?)
4241 }
4242
4243 /// Reports completion of a pending client-handled slash command.
4244 ///
4245 /// Wire method: `session.commands.handlePendingCommand`.
4246 ///
4247 /// # Parameters
4248 ///
4249 /// * `params` - Pending command request ID and an optional error if the client handler failed.
4250 ///
4251 /// # Returns
4252 ///
4253 /// Indicates whether the pending client-handled command was completed successfully.
4254 ///
4255 /// <div class="warning">
4256 ///
4257 /// **Experimental.** This API is part of an experimental wire-protocol surface
4258 /// and may change or be removed in future SDK or CLI releases. Pin both the
4259 /// SDK and CLI versions if your code depends on it.
4260 ///
4261 /// </div>
4262 pub async fn handle_pending_command(
4263 &self,
4264 params: CommandsHandlePendingCommandRequest,
4265 ) -> Result<CommandsHandlePendingCommandResult, Error> {
4266 let mut wire_params = serde_json::to_value(params)?;
4267 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4268 let _value = self
4269 .session
4270 .client()
4271 .call(
4272 rpc_methods::SESSION_COMMANDS_HANDLEPENDINGCOMMAND,
4273 Some(wire_params),
4274 )
4275 .await?;
4276 Ok(serde_json::from_value(_value)?)
4277 }
4278
4279 /// Executes a slash command synchronously and returns any error.
4280 ///
4281 /// Wire method: `session.commands.execute`.
4282 ///
4283 /// # Parameters
4284 ///
4285 /// * `params` - Slash command name and argument string to execute synchronously.
4286 ///
4287 /// # Returns
4288 ///
4289 /// Error message produced while executing the command, if any.
4290 ///
4291 /// <div class="warning">
4292 ///
4293 /// **Experimental.** This API is part of an experimental wire-protocol surface
4294 /// and may change or be removed in future SDK or CLI releases. Pin both the
4295 /// SDK and CLI versions if your code depends on it.
4296 ///
4297 /// </div>
4298 pub async fn execute(
4299 &self,
4300 params: ExecuteCommandParams,
4301 ) -> Result<ExecuteCommandResult, Error> {
4302 let mut wire_params = serde_json::to_value(params)?;
4303 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4304 let _value = self
4305 .session
4306 .client()
4307 .call(rpc_methods::SESSION_COMMANDS_EXECUTE, Some(wire_params))
4308 .await?;
4309 Ok(serde_json::from_value(_value)?)
4310 }
4311
4312 /// Enqueues a slash command for FIFO processing on the local session.
4313 ///
4314 /// Wire method: `session.commands.enqueue`.
4315 ///
4316 /// # Parameters
4317 ///
4318 /// * `params` - Slash-prefixed command string to enqueue for FIFO processing.
4319 ///
4320 /// # Returns
4321 ///
4322 /// Indicates whether the command was accepted into the local execution queue.
4323 ///
4324 /// <div class="warning">
4325 ///
4326 /// **Experimental.** This API is part of an experimental wire-protocol surface
4327 /// and may change or be removed in future SDK or CLI releases. Pin both the
4328 /// SDK and CLI versions if your code depends on it.
4329 ///
4330 /// </div>
4331 pub async fn enqueue(
4332 &self,
4333 params: EnqueueCommandParams,
4334 ) -> Result<EnqueueCommandResult, Error> {
4335 let mut wire_params = serde_json::to_value(params)?;
4336 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4337 let _value = self
4338 .session
4339 .client()
4340 .call(rpc_methods::SESSION_COMMANDS_ENQUEUE, Some(wire_params))
4341 .await?;
4342 Ok(serde_json::from_value(_value)?)
4343 }
4344
4345 /// Reports whether the host actually executed a queued command and whether to continue processing.
4346 ///
4347 /// Wire method: `session.commands.respondToQueuedCommand`.
4348 ///
4349 /// # Parameters
4350 ///
4351 /// * `params` - Queued-command request ID and the result indicating whether the host executed it (and whether to stop processing further queued commands).
4352 ///
4353 /// # Returns
4354 ///
4355 /// Indicates whether the queued-command response was matched to a pending request.
4356 ///
4357 /// <div class="warning">
4358 ///
4359 /// **Experimental.** This API is part of an experimental wire-protocol surface
4360 /// and may change or be removed in future SDK or CLI releases. Pin both the
4361 /// SDK and CLI versions if your code depends on it.
4362 ///
4363 /// </div>
4364 pub async fn respond_to_queued_command(
4365 &self,
4366 params: CommandsRespondToQueuedCommandRequest,
4367 ) -> Result<CommandsRespondToQueuedCommandResult, Error> {
4368 let mut wire_params = serde_json::to_value(params)?;
4369 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4370 let _value = self
4371 .session
4372 .client()
4373 .call(
4374 rpc_methods::SESSION_COMMANDS_RESPONDTOQUEUEDCOMMAND,
4375 Some(wire_params),
4376 )
4377 .await?;
4378 Ok(serde_json::from_value(_value)?)
4379 }
4380}
4381
4382/// `session.completions.*` RPCs.
4383#[derive(Clone, Copy)]
4384pub struct SessionRpcCompletions<'a> {
4385 pub(crate) session: &'a Session,
4386}
4387
4388impl<'a> SessionRpcCompletions<'a> {
4389 /// 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).
4390 ///
4391 /// Wire method: `session.completions.getTriggerCharacters`.
4392 ///
4393 /// # Returns
4394 ///
4395 /// 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`).
4396 ///
4397 /// <div class="warning">
4398 ///
4399 /// **Experimental.** This API is part of an experimental wire-protocol surface
4400 /// and may change or be removed in future SDK or CLI releases. Pin both the
4401 /// SDK and CLI versions if your code depends on it.
4402 ///
4403 /// </div>
4404 pub async fn get_trigger_characters(
4405 &self,
4406 ) -> Result<CompletionsGetTriggerCharactersResult, Error> {
4407 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
4408 let _value = self
4409 .session
4410 .client()
4411 .call(
4412 rpc_methods::SESSION_COMPLETIONS_GETTRIGGERCHARACTERS,
4413 Some(wire_params),
4414 )
4415 .await?;
4416 Ok(serde_json::from_value(_value)?)
4417 }
4418
4419 /// 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.
4420 ///
4421 /// Wire method: `session.completions.request`.
4422 ///
4423 /// # Parameters
4424 ///
4425 /// * `params` - Request host-driven completions for the current composer input.
4426 ///
4427 /// # Returns
4428 ///
4429 /// Host-driven completion items for the current composer input. Empty when the host returns no items or does not support completions.
4430 ///
4431 /// <div class="warning">
4432 ///
4433 /// **Experimental.** This API is part of an experimental wire-protocol surface
4434 /// and may change or be removed in future SDK or CLI releases. Pin both the
4435 /// SDK and CLI versions if your code depends on it.
4436 ///
4437 /// </div>
4438 pub async fn request(
4439 &self,
4440 params: CompletionsRequestRequest,
4441 ) -> Result<CompletionsRequestResult, Error> {
4442 let mut wire_params = serde_json::to_value(params)?;
4443 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4444 let _value = self
4445 .session
4446 .client()
4447 .call(rpc_methods::SESSION_COMPLETIONS_REQUEST, Some(wire_params))
4448 .await?;
4449 Ok(serde_json::from_value(_value)?)
4450 }
4451}
4452
4453/// `session.contentExclusion.*` RPCs.
4454#[derive(Clone, Copy)]
4455pub struct SessionRpcContentExclusion<'a> {
4456 pub(crate) session: &'a Session,
4457}
4458
4459impl<'a> SessionRpcContentExclusion<'a> {
4460 /// 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.
4461 ///
4462 /// Wire method: `session.contentExclusion.checkPaths`.
4463 ///
4464 /// # Parameters
4465 ///
4466 /// * `params` - Local file system absolute paths within the session working directory to check against its content-exclusion policy.
4467 ///
4468 /// # Returns
4469 ///
4470 /// Batch content-exclusion result. Callers must fail closed when policy evaluation is unavailable.
4471 ///
4472 /// <div class="warning">
4473 ///
4474 /// **Experimental.** This API is part of an experimental wire-protocol surface
4475 /// and may change or be removed in future SDK or CLI releases. Pin both the
4476 /// SDK and CLI versions if your code depends on it.
4477 ///
4478 /// </div>
4479 pub async fn check_paths(
4480 &self,
4481 params: ContentExclusionCheckPathsRequest,
4482 ) -> Result<ContentExclusionCheckPathsResult, Error> {
4483 let mut wire_params = serde_json::to_value(params)?;
4484 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4485 let _value = self
4486 .session
4487 .client()
4488 .call(
4489 rpc_methods::SESSION_CONTENTEXCLUSION_CHECKPATHS,
4490 Some(wire_params),
4491 )
4492 .await?;
4493 Ok(serde_json::from_value(_value)?)
4494 }
4495}
4496
4497/// `session.debug.*` RPCs.
4498#[derive(Clone, Copy)]
4499pub struct SessionRpcDebug<'a> {
4500 pub(crate) session: &'a Session,
4501}
4502
4503impl<'a> SessionRpcDebug<'a> {
4504 /// 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.
4505 ///
4506 /// Wire method: `session.debug.collectLogs`.
4507 ///
4508 /// # Parameters
4509 ///
4510 /// * `params` - Options for collecting a redacted session debug bundle.
4511 ///
4512 /// # Returns
4513 ///
4514 /// Result of collecting a redacted debug bundle.
4515 ///
4516 /// <div class="warning">
4517 ///
4518 /// **Experimental.** This API is part of an experimental wire-protocol surface
4519 /// and may change or be removed in future SDK or CLI releases. Pin both the
4520 /// SDK and CLI versions if your code depends on it.
4521 ///
4522 /// </div>
4523 pub async fn collect_logs(
4524 &self,
4525 params: DebugCollectLogsRequest,
4526 ) -> Result<DebugCollectLogsResult, Error> {
4527 let mut wire_params = serde_json::to_value(params)?;
4528 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4529 let _value = self
4530 .session
4531 .client()
4532 .call(rpc_methods::SESSION_DEBUG_COLLECTLOGS, Some(wire_params))
4533 .await?;
4534 Ok(serde_json::from_value(_value)?)
4535 }
4536}
4537
4538/// `session.eventLog.*` RPCs.
4539#[derive(Clone, Copy)]
4540pub struct SessionRpcEventLog<'a> {
4541 pub(crate) session: &'a Session,
4542}
4543
4544impl<'a> SessionRpcEventLog<'a> {
4545 /// Reads a batch of session events from a cursor, optionally waiting for new events. Supports tail-first reads via `direction: backward`.
4546 ///
4547 /// Wire method: `session.eventLog.read`.
4548 ///
4549 /// # Parameters
4550 ///
4551 /// * `params` - Cursor, batch size, and optional long-poll/filter parameters for reading session events.
4552 ///
4553 /// # Returns
4554 ///
4555 /// Batch of session events returned by a read, with cursor and continuation metadata.
4556 ///
4557 /// <div class="warning">
4558 ///
4559 /// **Experimental.** This API is part of an experimental wire-protocol surface
4560 /// and may change or be removed in future SDK or CLI releases. Pin both the
4561 /// SDK and CLI versions if your code depends on it.
4562 ///
4563 /// </div>
4564 pub async fn read(&self, params: EventLogReadRequest) -> Result<EventsReadResult, Error> {
4565 let mut wire_params = serde_json::to_value(params)?;
4566 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4567 let _value = self
4568 .session
4569 .client()
4570 .call(rpc_methods::SESSION_EVENTLOG_READ, Some(wire_params))
4571 .await?;
4572 Ok(serde_json::from_value(_value)?)
4573 }
4574
4575 /// Returns a snapshot of the current tail cursor without consuming events.
4576 ///
4577 /// Wire method: `session.eventLog.tail`.
4578 ///
4579 /// # Returns
4580 ///
4581 /// 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).
4582 ///
4583 /// <div class="warning">
4584 ///
4585 /// **Experimental.** This API is part of an experimental wire-protocol surface
4586 /// and may change or be removed in future SDK or CLI releases. Pin both the
4587 /// SDK and CLI versions if your code depends on it.
4588 ///
4589 /// </div>
4590 pub async fn tail(&self) -> Result<EventLogTailResult, Error> {
4591 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
4592 let _value = self
4593 .session
4594 .client()
4595 .call(rpc_methods::SESSION_EVENTLOG_TAIL, Some(wire_params))
4596 .await?;
4597 Ok(serde_json::from_value(_value)?)
4598 }
4599
4600 /// Registers consumer interest in an event type for runtime gating purposes.
4601 ///
4602 /// Wire method: `session.eventLog.registerInterest`.
4603 ///
4604 /// # Parameters
4605 ///
4606 /// * `params` - Event type to register consumer interest for, used by runtime gating logic.
4607 ///
4608 /// # Returns
4609 ///
4610 /// Opaque handle representing an event-type interest registration.
4611 ///
4612 /// <div class="warning">
4613 ///
4614 /// **Experimental.** This API is part of an experimental wire-protocol surface
4615 /// and may change or be removed in future SDK or CLI releases. Pin both the
4616 /// SDK and CLI versions if your code depends on it.
4617 ///
4618 /// </div>
4619 pub async fn register_interest(
4620 &self,
4621 params: RegisterEventInterestParams,
4622 ) -> Result<RegisterEventInterestResult, Error> {
4623 let mut wire_params = serde_json::to_value(params)?;
4624 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4625 let _value = self
4626 .session
4627 .client()
4628 .call(
4629 rpc_methods::SESSION_EVENTLOG_REGISTERINTEREST,
4630 Some(wire_params),
4631 )
4632 .await?;
4633 Ok(serde_json::from_value(_value)?)
4634 }
4635
4636 /// Releases a consumer's previously-registered interest in an event type.
4637 ///
4638 /// Wire method: `session.eventLog.releaseInterest`.
4639 ///
4640 /// # Parameters
4641 ///
4642 /// * `params` - Opaque handle previously returned by `registerInterest` to release.
4643 ///
4644 /// # Returns
4645 ///
4646 /// Indicates whether the operation succeeded.
4647 ///
4648 /// <div class="warning">
4649 ///
4650 /// **Experimental.** This API is part of an experimental wire-protocol surface
4651 /// and may change or be removed in future SDK or CLI releases. Pin both the
4652 /// SDK and CLI versions if your code depends on it.
4653 ///
4654 /// </div>
4655 pub async fn release_interest(
4656 &self,
4657 params: ReleaseEventInterestParams,
4658 ) -> Result<EventLogReleaseInterestResult, Error> {
4659 let mut wire_params = serde_json::to_value(params)?;
4660 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4661 let _value = self
4662 .session
4663 .client()
4664 .call(
4665 rpc_methods::SESSION_EVENTLOG_RELEASEINTEREST,
4666 Some(wire_params),
4667 )
4668 .await?;
4669 Ok(serde_json::from_value(_value)?)
4670 }
4671}
4672
4673/// `session.extensions.*` RPCs.
4674#[derive(Clone, Copy)]
4675pub struct SessionRpcExtensions<'a> {
4676 pub(crate) session: &'a Session,
4677}
4678
4679impl<'a> SessionRpcExtensions<'a> {
4680 /// Lists extensions discovered for the session and their current status.
4681 ///
4682 /// Wire method: `session.extensions.list`.
4683 ///
4684 /// # Returns
4685 ///
4686 /// Extensions discovered for the session, with their current status.
4687 ///
4688 /// <div class="warning">
4689 ///
4690 /// **Experimental.** This API is part of an experimental wire-protocol surface
4691 /// and may change or be removed in future SDK or CLI releases. Pin both the
4692 /// SDK and CLI versions if your code depends on it.
4693 ///
4694 /// </div>
4695 pub async fn list(&self) -> Result<ExtensionList, Error> {
4696 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
4697 let _value = self
4698 .session
4699 .client()
4700 .call(rpc_methods::SESSION_EXTENSIONS_LIST, Some(wire_params))
4701 .await?;
4702 Ok(serde_json::from_value(_value)?)
4703 }
4704
4705 /// Enables an extension for the session.
4706 ///
4707 /// Wire method: `session.extensions.enable`.
4708 ///
4709 /// # Parameters
4710 ///
4711 /// * `params` - Source-qualified extension identifier to enable for the session.
4712 ///
4713 /// <div class="warning">
4714 ///
4715 /// **Experimental.** This API is part of an experimental wire-protocol surface
4716 /// and may change or be removed in future SDK or CLI releases. Pin both the
4717 /// SDK and CLI versions if your code depends on it.
4718 ///
4719 /// </div>
4720 pub async fn enable(&self, params: ExtensionsEnableRequest) -> Result<(), Error> {
4721 let mut wire_params = serde_json::to_value(params)?;
4722 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4723 let _value = self
4724 .session
4725 .client()
4726 .call(rpc_methods::SESSION_EXTENSIONS_ENABLE, Some(wire_params))
4727 .await?;
4728 Ok(())
4729 }
4730
4731 /// Disables an extension for the session.
4732 ///
4733 /// Wire method: `session.extensions.disable`.
4734 ///
4735 /// # Parameters
4736 ///
4737 /// * `params` - Source-qualified extension identifier to disable for the session.
4738 ///
4739 /// <div class="warning">
4740 ///
4741 /// **Experimental.** This API is part of an experimental wire-protocol surface
4742 /// and may change or be removed in future SDK or CLI releases. Pin both the
4743 /// SDK and CLI versions if your code depends on it.
4744 ///
4745 /// </div>
4746 pub async fn disable(&self, params: ExtensionsDisableRequest) -> Result<(), Error> {
4747 let mut wire_params = serde_json::to_value(params)?;
4748 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4749 let _value = self
4750 .session
4751 .client()
4752 .call(rpc_methods::SESSION_EXTENSIONS_DISABLE, Some(wire_params))
4753 .await?;
4754 Ok(())
4755 }
4756
4757 /// Reloads extension definitions and processes for the session.
4758 ///
4759 /// Wire method: `session.extensions.reload`.
4760 ///
4761 /// <div class="warning">
4762 ///
4763 /// **Experimental.** This API is part of an experimental wire-protocol surface
4764 /// and may change or be removed in future SDK or CLI releases. Pin both the
4765 /// SDK and CLI versions if your code depends on it.
4766 ///
4767 /// </div>
4768 pub async fn reload(&self) -> Result<(), Error> {
4769 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
4770 let _value = self
4771 .session
4772 .client()
4773 .call(rpc_methods::SESSION_EXTENSIONS_RELOAD, Some(wire_params))
4774 .await?;
4775 Ok(())
4776 }
4777
4778 /// 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.
4779 ///
4780 /// Wire method: `session.extensions.sendAttachmentsToMessage`.
4781 ///
4782 /// # Parameters
4783 ///
4784 /// * `params` - Parameters for session.extensions.sendAttachmentsToMessage.
4785 ///
4786 /// <div class="warning">
4787 ///
4788 /// **Experimental.** This API is part of an experimental wire-protocol surface
4789 /// and may change or be removed in future SDK or CLI releases. Pin both the
4790 /// SDK and CLI versions if your code depends on it.
4791 ///
4792 /// </div>
4793 pub async fn send_attachments_to_message(
4794 &self,
4795 params: SendAttachmentsToMessageParams,
4796 ) -> Result<(), Error> {
4797 let mut wire_params = serde_json::to_value(params)?;
4798 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4799 let _value = self
4800 .session
4801 .client()
4802 .call(
4803 rpc_methods::SESSION_EXTENSIONS_SENDATTACHMENTSTOMESSAGE,
4804 Some(wire_params),
4805 )
4806 .await?;
4807 Ok(())
4808 }
4809}
4810
4811/// `session.factory.*` RPCs.
4812#[derive(Clone, Copy)]
4813pub struct SessionRpcFactory<'a> {
4814 pub(crate) session: &'a Session,
4815}
4816
4817impl<'a> SessionRpcFactory<'a> {
4818 /// `session.factory.journal.*` sub-namespace.
4819 pub fn journal(&self) -> SessionRpcFactoryJournal<'a> {
4820 SessionRpcFactoryJournal {
4821 session: self.session,
4822 }
4823 }
4824
4825 /// Runs a registered factory by name at the top level.
4826 ///
4827 /// Wire method: `session.factory.run`.
4828 ///
4829 /// # Parameters
4830 ///
4831 /// * `params` - Parameters for invoking a registered factory.
4832 ///
4833 /// # Returns
4834 ///
4835 /// Complete current or terminal factory run envelope.
4836 ///
4837 /// <div class="warning">
4838 ///
4839 /// **Experimental.** This API is part of an experimental wire-protocol surface
4840 /// and may change or be removed in future SDK or CLI releases. Pin both the
4841 /// SDK and CLI versions if your code depends on it.
4842 ///
4843 /// </div>
4844 pub async fn run(&self, params: FactoryRunRequest) -> Result<FactoryRunResult, Error> {
4845 let mut wire_params = serde_json::to_value(params)?;
4846 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4847 let _value = self
4848 .session
4849 .client()
4850 .call(rpc_methods::SESSION_FACTORY_RUN, Some(wire_params))
4851 .await?;
4852 Ok(serde_json::from_value(_value)?)
4853 }
4854
4855 /// Resumes a factory run using its persisted name, arguments, journal, and accounting.
4856 ///
4857 /// Wire method: `session.factory.resume`.
4858 ///
4859 /// # Parameters
4860 ///
4861 /// * `params` - Parameters for resuming a factory run from its persisted identity.
4862 ///
4863 /// # Returns
4864 ///
4865 /// Resolved persisted factory identity and resumed run envelope.
4866 ///
4867 /// <div class="warning">
4868 ///
4869 /// **Experimental.** This API is part of an experimental wire-protocol surface
4870 /// and may change or be removed in future SDK or CLI releases. Pin both the
4871 /// SDK and CLI versions if your code depends on it.
4872 ///
4873 /// </div>
4874 pub async fn resume(&self, params: FactoryResumeRequest) -> Result<FactoryResumeResult, Error> {
4875 let mut wire_params = serde_json::to_value(params)?;
4876 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4877 let _value = self
4878 .session
4879 .client()
4880 .call(rpc_methods::SESSION_FACTORY_RESUME, Some(wire_params))
4881 .await?;
4882 Ok(serde_json::from_value(_value)?)
4883 }
4884
4885 /// Internal tool-originated factory invocation.
4886 ///
4887 /// Wire method: `session.factory.runFromTool`.
4888 ///
4889 /// # Parameters
4890 ///
4891 /// * `params` - Internal parameters for invoking a registered factory from a tool.
4892 ///
4893 /// # Returns
4894 ///
4895 /// Complete current or terminal factory run envelope.
4896 ///
4897 /// <div class="warning">
4898 ///
4899 /// **Experimental.** This API is part of an experimental wire-protocol surface
4900 /// and may change or be removed in future SDK or CLI releases. Pin both the
4901 /// SDK and CLI versions if your code depends on it.
4902 ///
4903 /// </div>
4904 pub(crate) async fn run_from_tool(
4905 &self,
4906 params: FactoryToolRunRequest,
4907 ) -> Result<FactoryRunResult, Error> {
4908 let mut wire_params = serde_json::to_value(params)?;
4909 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4910 let _value = self
4911 .session
4912 .client()
4913 .call(rpc_methods::SESSION_FACTORY_RUNFROMTOOL, Some(wire_params))
4914 .await?;
4915 Ok(serde_json::from_value(_value)?)
4916 }
4917
4918 /// Internal tool-originated factory resume.
4919 ///
4920 /// Wire method: `session.factory.resumeFromTool`.
4921 ///
4922 /// # Parameters
4923 ///
4924 /// * `params` - Internal parameters for resuming a factory run from a tool.
4925 ///
4926 /// # Returns
4927 ///
4928 /// Resolved persisted factory identity and resumed run envelope.
4929 ///
4930 /// <div class="warning">
4931 ///
4932 /// **Experimental.** This API is part of an experimental wire-protocol surface
4933 /// and may change or be removed in future SDK or CLI releases. Pin both the
4934 /// SDK and CLI versions if your code depends on it.
4935 ///
4936 /// </div>
4937 pub(crate) async fn resume_from_tool(
4938 &self,
4939 params: FactoryToolResumeRequest,
4940 ) -> Result<FactoryResumeResult, Error> {
4941 let mut wire_params = serde_json::to_value(params)?;
4942 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4943 let _value = self
4944 .session
4945 .client()
4946 .call(
4947 rpc_methods::SESSION_FACTORY_RESUMEFROMTOOL,
4948 Some(wire_params),
4949 )
4950 .await?;
4951 Ok(serde_json::from_value(_value)?)
4952 }
4953
4954 /// Gets the current or settled envelope for a factory run.
4955 ///
4956 /// Wire method: `session.factory.getRun`.
4957 ///
4958 /// # Parameters
4959 ///
4960 /// * `params` - Parameters for retrieving a factory run.
4961 ///
4962 /// # Returns
4963 ///
4964 /// Complete current or terminal factory run envelope.
4965 ///
4966 /// <div class="warning">
4967 ///
4968 /// **Experimental.** This API is part of an experimental wire-protocol surface
4969 /// and may change or be removed in future SDK or CLI releases. Pin both the
4970 /// SDK and CLI versions if your code depends on it.
4971 ///
4972 /// </div>
4973 pub async fn get_run(&self, params: FactoryGetRunRequest) -> Result<FactoryRunResult, Error> {
4974 let mut wire_params = serde_json::to_value(params)?;
4975 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4976 let _value = self
4977 .session
4978 .client()
4979 .call(rpc_methods::SESSION_FACTORY_GETRUN, Some(wire_params))
4980 .await?;
4981 Ok(serde_json::from_value(_value)?)
4982 }
4983
4984 /// Lists durable factory runs for this session in creation order.
4985 ///
4986 /// Wire method: `session.factory.listRuns`.
4987 ///
4988 /// # Parameters
4989 ///
4990 /// * `params` - Parameters for paging factory runs.
4991 ///
4992 /// # Returns
4993 ///
4994 /// A page of factory runs in durable creation order.
4995 ///
4996 /// <div class="warning">
4997 ///
4998 /// **Experimental.** This API is part of an experimental wire-protocol surface
4999 /// and may change or be removed in future SDK or CLI releases. Pin both the
5000 /// SDK and CLI versions if your code depends on it.
5001 ///
5002 /// </div>
5003 pub async fn list_runs(
5004 &self,
5005 params: FactoryListRunsRequest,
5006 ) -> Result<FactoryListRunsResult, Error> {
5007 let mut wire_params = serde_json::to_value(params)?;
5008 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5009 let _value = self
5010 .session
5011 .client()
5012 .call(rpc_methods::SESSION_FACTORY_LISTRUNS, Some(wire_params))
5013 .await?;
5014 Ok(serde_json::from_value(_value)?)
5015 }
5016
5017 /// Gets durable and live observability detail for one factory run.
5018 ///
5019 /// Wire method: `session.factory.getRunDetail`.
5020 ///
5021 /// # Parameters
5022 ///
5023 /// * `params` - Parameters for retrieving a factory run.
5024 ///
5025 /// # Returns
5026 ///
5027 /// Full factory run observability detail.
5028 ///
5029 /// <div class="warning">
5030 ///
5031 /// **Experimental.** This API is part of an experimental wire-protocol surface
5032 /// and may change or be removed in future SDK or CLI releases. Pin both the
5033 /// SDK and CLI versions if your code depends on it.
5034 ///
5035 /// </div>
5036 pub async fn get_run_detail(
5037 &self,
5038 params: FactoryGetRunRequest,
5039 ) -> Result<FactoryRunDetail, Error> {
5040 let mut wire_params = serde_json::to_value(params)?;
5041 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5042 let _value = self
5043 .session
5044 .client()
5045 .call(rpc_methods::SESSION_FACTORY_GETRUNDETAIL, Some(wire_params))
5046 .await?;
5047 Ok(serde_json::from_value(_value)?)
5048 }
5049
5050 /// Pages durable progress for one factory run.
5051 ///
5052 /// Wire method: `session.factory.getRunProgress`.
5053 ///
5054 /// # Parameters
5055 ///
5056 /// * `params` - Parameters for paging factory progress.
5057 ///
5058 /// # Returns
5059 ///
5060 /// A bidirectional page of factory progress.
5061 ///
5062 /// <div class="warning">
5063 ///
5064 /// **Experimental.** This API is part of an experimental wire-protocol surface
5065 /// and may change or be removed in future SDK or CLI releases. Pin both the
5066 /// SDK and CLI versions if your code depends on it.
5067 ///
5068 /// </div>
5069 pub async fn get_run_progress(
5070 &self,
5071 params: FactoryGetRunProgressRequest,
5072 ) -> Result<FactoryProgressPage, Error> {
5073 let mut wire_params = serde_json::to_value(params)?;
5074 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5075 let _value = self
5076 .session
5077 .client()
5078 .call(
5079 rpc_methods::SESSION_FACTORY_GETRUNPROGRESS,
5080 Some(wire_params),
5081 )
5082 .await?;
5083 Ok(serde_json::from_value(_value)?)
5084 }
5085
5086 /// Requests cancellation of a factory run and returns its run envelope.
5087 ///
5088 /// Wire method: `session.factory.cancel`.
5089 ///
5090 /// # Parameters
5091 ///
5092 /// * `params` - Parameters for cancelling a factory run.
5093 ///
5094 /// # Returns
5095 ///
5096 /// Complete current or terminal factory run envelope.
5097 ///
5098 /// <div class="warning">
5099 ///
5100 /// **Experimental.** This API is part of an experimental wire-protocol surface
5101 /// and may change or be removed in future SDK or CLI releases. Pin both the
5102 /// SDK and CLI versions if your code depends on it.
5103 ///
5104 /// </div>
5105 pub async fn cancel(&self, params: FactoryCancelRequest) -> Result<FactoryRunResult, Error> {
5106 let mut wire_params = serde_json::to_value(params)?;
5107 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5108 let _value = self
5109 .session
5110 .client()
5111 .call(rpc_methods::SESSION_FACTORY_CANCEL, Some(wire_params))
5112 .await?;
5113 Ok(serde_json::from_value(_value)?)
5114 }
5115
5116 /// Records a batch of ordered factory progress lines.
5117 ///
5118 /// Wire method: `session.factory.log`.
5119 ///
5120 /// # Parameters
5121 ///
5122 /// * `params` - Parameters for recording factory progress.
5123 ///
5124 /// # Returns
5125 ///
5126 /// Acknowledgement that a factory request was accepted.
5127 ///
5128 /// <div class="warning">
5129 ///
5130 /// **Experimental.** This API is part of an experimental wire-protocol surface
5131 /// and may change or be removed in future SDK or CLI releases. Pin both the
5132 /// SDK and CLI versions if your code depends on it.
5133 ///
5134 /// </div>
5135 pub async fn log(&self, params: FactoryLogRequest) -> Result<FactoryAckResult, Error> {
5136 let mut wire_params = serde_json::to_value(params)?;
5137 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5138 let _value = self
5139 .session
5140 .client()
5141 .call(rpc_methods::SESSION_FACTORY_LOG, Some(wire_params))
5142 .await?;
5143 Ok(serde_json::from_value(_value)?)
5144 }
5145
5146 /// Runs one factory-scoped subagent and returns its result.
5147 ///
5148 /// Wire method: `session.factory.agent`.
5149 ///
5150 /// # Parameters
5151 ///
5152 /// * `params` - Parameters for one factory-scoped subagent call.
5153 ///
5154 /// # Returns
5155 ///
5156 /// Result of one factory-scoped subagent call.
5157 ///
5158 /// <div class="warning">
5159 ///
5160 /// **Experimental.** This API is part of an experimental wire-protocol surface
5161 /// and may change or be removed in future SDK or CLI releases. Pin both the
5162 /// SDK and CLI versions if your code depends on it.
5163 ///
5164 /// </div>
5165 pub async fn agent(&self, params: FactoryAgentRequest) -> Result<FactoryAgentResult, Error> {
5166 let mut wire_params = serde_json::to_value(params)?;
5167 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5168 let _value = self
5169 .session
5170 .client()
5171 .call(rpc_methods::SESSION_FACTORY_AGENT, Some(wire_params))
5172 .await?;
5173 Ok(serde_json::from_value(_value)?)
5174 }
5175}
5176
5177/// `session.factory.journal.*` RPCs.
5178#[derive(Clone, Copy)]
5179pub struct SessionRpcFactoryJournal<'a> {
5180 pub(crate) session: &'a Session,
5181}
5182
5183impl<'a> SessionRpcFactoryJournal<'a> {
5184 /// Reads a memoized factory journal entry.
5185 ///
5186 /// Wire method: `session.factory.journal.get`.
5187 ///
5188 /// # Parameters
5189 ///
5190 /// * `params` - Parameters for reading a factory journal entry.
5191 ///
5192 /// # Returns
5193 ///
5194 /// Result of reading a factory journal entry.
5195 ///
5196 /// <div class="warning">
5197 ///
5198 /// **Experimental.** This API is part of an experimental wire-protocol surface
5199 /// and may change or be removed in future SDK or CLI releases. Pin both the
5200 /// SDK and CLI versions if your code depends on it.
5201 ///
5202 /// </div>
5203 pub async fn get(
5204 &self,
5205 params: FactoryJournalGetRequest,
5206 ) -> Result<FactoryJournalGetResult, Error> {
5207 let mut wire_params = serde_json::to_value(params)?;
5208 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5209 let _value = self
5210 .session
5211 .client()
5212 .call(rpc_methods::SESSION_FACTORY_JOURNAL_GET, Some(wire_params))
5213 .await?;
5214 Ok(serde_json::from_value(_value)?)
5215 }
5216
5217 /// Stores a memoized factory journal entry.
5218 ///
5219 /// Wire method: `session.factory.journal.put`.
5220 ///
5221 /// # Parameters
5222 ///
5223 /// * `params` - Parameters for storing a factory journal entry.
5224 ///
5225 /// # Returns
5226 ///
5227 /// Acknowledgement that a factory request was accepted.
5228 ///
5229 /// <div class="warning">
5230 ///
5231 /// **Experimental.** This API is part of an experimental wire-protocol surface
5232 /// and may change or be removed in future SDK or CLI releases. Pin both the
5233 /// SDK and CLI versions if your code depends on it.
5234 ///
5235 /// </div>
5236 pub async fn put(&self, params: FactoryJournalPutRequest) -> Result<FactoryAckResult, Error> {
5237 let mut wire_params = serde_json::to_value(params)?;
5238 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5239 let _value = self
5240 .session
5241 .client()
5242 .call(rpc_methods::SESSION_FACTORY_JOURNAL_PUT, Some(wire_params))
5243 .await?;
5244 Ok(serde_json::from_value(_value)?)
5245 }
5246}
5247
5248/// `session.fleet.*` RPCs.
5249#[derive(Clone, Copy)]
5250pub struct SessionRpcFleet<'a> {
5251 pub(crate) session: &'a Session,
5252}
5253
5254impl<'a> SessionRpcFleet<'a> {
5255 /// Starts fleet mode by submitting the fleet orchestration prompt to the session.
5256 ///
5257 /// Wire method: `session.fleet.start`.
5258 ///
5259 /// # Parameters
5260 ///
5261 /// * `params` - Optional user prompt to combine with the fleet orchestration instructions.
5262 ///
5263 /// # Returns
5264 ///
5265 /// Indicates whether fleet mode was successfully activated.
5266 ///
5267 /// <div class="warning">
5268 ///
5269 /// **Experimental.** This API is part of an experimental wire-protocol surface
5270 /// and may change or be removed in future SDK or CLI releases. Pin both the
5271 /// SDK and CLI versions if your code depends on it.
5272 ///
5273 /// </div>
5274 pub async fn start(&self, params: FleetStartRequest) -> Result<FleetStartResult, Error> {
5275 let mut wire_params = serde_json::to_value(params)?;
5276 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5277 let _value = self
5278 .session
5279 .client()
5280 .call(rpc_methods::SESSION_FLEET_START, Some(wire_params))
5281 .await?;
5282 Ok(serde_json::from_value(_value)?)
5283 }
5284}
5285
5286/// `session.gitHubAuth.*` RPCs.
5287#[derive(Clone, Copy)]
5288pub struct SessionRpcGitHubAuth<'a> {
5289 pub(crate) session: &'a Session,
5290}
5291
5292impl<'a> SessionRpcGitHubAuth<'a> {
5293 /// Gets authentication status and account metadata for the session.
5294 ///
5295 /// Wire method: `session.gitHubAuth.getStatus`.
5296 ///
5297 /// # Returns
5298 ///
5299 /// Authentication status and account metadata for the session.
5300 ///
5301 /// <div class="warning">
5302 ///
5303 /// **Experimental.** This API is part of an experimental wire-protocol surface
5304 /// and may change or be removed in future SDK or CLI releases. Pin both the
5305 /// SDK and CLI versions if your code depends on it.
5306 ///
5307 /// </div>
5308 pub async fn get_status(&self) -> Result<SessionAuthStatus, Error> {
5309 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5310 let _value = self
5311 .session
5312 .client()
5313 .call(rpc_methods::SESSION_GITHUBAUTH_GETSTATUS, Some(wire_params))
5314 .await?;
5315 Ok(serde_json::from_value(_value)?)
5316 }
5317
5318 /// Updates the session's auth credentials used for outbound model and API requests.
5319 ///
5320 /// Wire method: `session.gitHubAuth.setCredentials`.
5321 ///
5322 /// # Parameters
5323 ///
5324 /// * `params` - New auth credentials to install on the session. Omit to leave credentials unchanged.
5325 ///
5326 /// # Returns
5327 ///
5328 /// Indicates whether the credential update succeeded.
5329 ///
5330 /// <div class="warning">
5331 ///
5332 /// **Experimental.** This API is part of an experimental wire-protocol surface
5333 /// and may change or be removed in future SDK or CLI releases. Pin both the
5334 /// SDK and CLI versions if your code depends on it.
5335 ///
5336 /// </div>
5337 pub async fn set_credentials(
5338 &self,
5339 params: SessionSetCredentialsParams,
5340 ) -> Result<SessionSetCredentialsResult, Error> {
5341 let mut wire_params = serde_json::to_value(params)?;
5342 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5343 let _value = self
5344 .session
5345 .client()
5346 .call(
5347 rpc_methods::SESSION_GITHUBAUTH_SETCREDENTIALS,
5348 Some(wire_params),
5349 )
5350 .await?;
5351 Ok(serde_json::from_value(_value)?)
5352 }
5353
5354 /// Gets the current authentication information for internal session hosts.
5355 ///
5356 /// Wire method: `session.gitHubAuth.getCurrentAuthInfo`.
5357 ///
5358 /// # Returns
5359 ///
5360 /// Current authentication information, or null when no authentication is active.
5361 ///
5362 /// <div class="warning">
5363 ///
5364 /// **Experimental.** This API is part of an experimental wire-protocol surface
5365 /// and may change or be removed in future SDK or CLI releases. Pin both the
5366 /// SDK and CLI versions if your code depends on it.
5367 ///
5368 /// </div>
5369 pub(crate) async fn get_current_auth_info(&self) -> Result<SessionAuthInfoResult, Error> {
5370 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5371 let _value = self
5372 .session
5373 .client()
5374 .call(
5375 rpc_methods::SESSION_GITHUBAUTH_GETCURRENTAUTHINFO,
5376 Some(wire_params),
5377 )
5378 .await?;
5379 Ok(serde_json::from_value(_value)?)
5380 }
5381
5382 /// Gets all authentication accounts available to the internal session host.
5383 ///
5384 /// Wire method: `session.gitHubAuth.getAllAuthAvailable`.
5385 ///
5386 /// # Returns
5387 ///
5388 /// Authentication accounts available to the internal session host.
5389 ///
5390 /// <div class="warning">
5391 ///
5392 /// **Experimental.** This API is part of an experimental wire-protocol surface
5393 /// and may change or be removed in future SDK or CLI releases. Pin both the
5394 /// SDK and CLI versions if your code depends on it.
5395 ///
5396 /// </div>
5397 pub(crate) async fn get_all_auth_available(
5398 &self,
5399 ) -> Result<SessionGitHubAuthGetAllAuthAvailableResult, Error> {
5400 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5401 let _value = self
5402 .session
5403 .client()
5404 .call(
5405 rpc_methods::SESSION_GITHUBAUTH_GETALLAUTHAVAILABLE,
5406 Some(wire_params),
5407 )
5408 .await?;
5409 Ok(serde_json::from_value(_value)?)
5410 }
5411
5412 /// Refreshes Copilot account metadata for the current authentication.
5413 ///
5414 /// Wire method: `session.gitHubAuth.refreshCopilotUser`.
5415 ///
5416 /// # Returns
5417 ///
5418 /// Current authentication information, or null when no authentication is active.
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(crate) async fn refresh_copilot_user(&self) -> Result<SessionAuthInfoResult, Error> {
5428 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5429 let _value = self
5430 .session
5431 .client()
5432 .call(
5433 rpc_methods::SESSION_GITHUBAUTH_REFRESHCOPILOTUSER,
5434 Some(wire_params),
5435 )
5436 .await?;
5437 Ok(serde_json::from_value(_value)?)
5438 }
5439
5440 /// Logs in a GitHub user through the internal session host.
5441 ///
5442 /// Wire method: `session.gitHubAuth.login`.
5443 ///
5444 /// # Parameters
5445 ///
5446 /// * `params` - Internal GitHub login parameters.
5447 ///
5448 /// # Returns
5449 ///
5450 /// Authentication credentials accepted only at native protocol ingress. Runtime outputs use credential-free `AuthIdentity` metadata.
5451 ///
5452 /// <div class="warning">
5453 ///
5454 /// **Experimental.** This API is part of an experimental wire-protocol surface
5455 /// and may change or be removed in future SDK or CLI releases. Pin both the
5456 /// SDK and CLI versions if your code depends on it.
5457 ///
5458 /// </div>
5459 pub(crate) async fn login(&self, params: SessionAuthLoginRequest) -> Result<AuthInfo, Error> {
5460 let mut wire_params = serde_json::to_value(params)?;
5461 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5462 let _value = self
5463 .session
5464 .client()
5465 .call(rpc_methods::SESSION_GITHUBAUTH_LOGIN, Some(wire_params))
5466 .await?;
5467 Ok(serde_json::from_value(_value)?)
5468 }
5469
5470 /// Switches the session to another available authentication.
5471 ///
5472 /// Wire method: `session.gitHubAuth.switchToAuth`.
5473 ///
5474 /// # Parameters
5475 ///
5476 /// * `params` - Parameters for switching the session's active authentication.
5477 ///
5478 /// <div class="warning">
5479 ///
5480 /// **Experimental.** This API is part of an experimental wire-protocol surface
5481 /// and may change or be removed in future SDK or CLI releases. Pin both the
5482 /// SDK and CLI versions if your code depends on it.
5483 ///
5484 /// </div>
5485 pub(crate) async fn switch_to_auth(
5486 &self,
5487 params: SessionAuthSwitchRequest,
5488 ) -> Result<(), Error> {
5489 let mut wire_params = serde_json::to_value(params)?;
5490 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5491 let _value = self
5492 .session
5493 .client()
5494 .call(
5495 rpc_methods::SESSION_GITHUBAUTH_SWITCHTOAUTH,
5496 Some(wire_params),
5497 )
5498 .await?;
5499 Ok(())
5500 }
5501
5502 /// Logs out the session's current GitHub authentication.
5503 ///
5504 /// Wire method: `session.gitHubAuth.logout`.
5505 ///
5506 /// # Returns
5507 ///
5508 /// Whether the current authentication was logged out.
5509 ///
5510 /// <div class="warning">
5511 ///
5512 /// **Experimental.** This API is part of an experimental wire-protocol surface
5513 /// and may change or be removed in future SDK or CLI releases. Pin both the
5514 /// SDK and CLI versions if your code depends on it.
5515 ///
5516 /// </div>
5517 pub(crate) async fn logout(&self) -> Result<SessionGitHubAuthLogoutResult, Error> {
5518 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5519 let _value = self
5520 .session
5521 .client()
5522 .call(rpc_methods::SESSION_GITHUBAUTH_LOGOUT, Some(wire_params))
5523 .await?;
5524 Ok(serde_json::from_value(_value)?)
5525 }
5526
5527 /// Logs out a specific GitHub authentication.
5528 ///
5529 /// Wire method: `session.gitHubAuth.logoutUser`.
5530 ///
5531 /// # Parameters
5532 ///
5533 /// * `params` - Parameters identifying a GitHub authentication to log out.
5534 ///
5535 /// # Returns
5536 ///
5537 /// Whether the requested authentication was logged out.
5538 ///
5539 /// <div class="warning">
5540 ///
5541 /// **Experimental.** This API is part of an experimental wire-protocol surface
5542 /// and may change or be removed in future SDK or CLI releases. Pin both the
5543 /// SDK and CLI versions if your code depends on it.
5544 ///
5545 /// </div>
5546 pub(crate) async fn logout_user(
5547 &self,
5548 params: SessionAuthLogoutUserRequest,
5549 ) -> Result<SessionGitHubAuthLogoutUserResult, Error> {
5550 let mut wire_params = serde_json::to_value(params)?;
5551 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5552 let _value = self
5553 .session
5554 .client()
5555 .call(
5556 rpc_methods::SESSION_GITHUBAUTH_LOGOUTUSER,
5557 Some(wire_params),
5558 )
5559 .await?;
5560 Ok(serde_json::from_value(_value)?)
5561 }
5562
5563 /// Gets validation errors from the most recent authentication attempt.
5564 ///
5565 /// Wire method: `session.gitHubAuth.lastAuthErrors`.
5566 ///
5567 /// # Returns
5568 ///
5569 /// Validation errors from the most recent authentication attempt.
5570 ///
5571 /// <div class="warning">
5572 ///
5573 /// **Experimental.** This API is part of an experimental wire-protocol surface
5574 /// and may change or be removed in future SDK or CLI releases. Pin both the
5575 /// SDK and CLI versions if your code depends on it.
5576 ///
5577 /// </div>
5578 pub(crate) async fn last_auth_errors(&self) -> Result<AuthValidationErrors, Error> {
5579 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5580 let _value = self
5581 .session
5582 .client()
5583 .call(
5584 rpc_methods::SESSION_GITHUBAUTH_LASTAUTHERRORS,
5585 Some(wire_params),
5586 )
5587 .await?;
5588 Ok(serde_json::from_value(_value)?)
5589 }
5590}
5591
5592/// `session.history.*` RPCs.
5593#[derive(Clone, Copy)]
5594pub struct SessionRpcHistory<'a> {
5595 pub(crate) session: &'a Session,
5596}
5597
5598impl<'a> SessionRpcHistory<'a> {
5599 /// Compacts the session history to reduce context usage.
5600 ///
5601 /// Wire method: `session.history.compact`.
5602 ///
5603 /// # Returns
5604 ///
5605 /// Compaction outcome with the number of tokens and messages removed, summary text, and the resulting context window breakdown.
5606 ///
5607 /// <div class="warning">
5608 ///
5609 /// **Experimental.** This API is part of an experimental wire-protocol surface
5610 /// and may change or be removed in future SDK or CLI releases. Pin both the
5611 /// SDK and CLI versions if your code depends on it.
5612 ///
5613 /// </div>
5614 pub async fn compact(&self) -> Result<HistoryCompactResult, Error> {
5615 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5616 let _value = self
5617 .session
5618 .client()
5619 .call(rpc_methods::SESSION_HISTORY_COMPACT, Some(wire_params))
5620 .await?;
5621 Ok(serde_json::from_value(_value)?)
5622 }
5623
5624 /// Compacts the session history to reduce context usage.
5625 ///
5626 /// Wire method: `session.history.compact`.
5627 ///
5628 /// # Parameters
5629 ///
5630 /// * `params` - Optional compaction parameters.
5631 ///
5632 /// # Returns
5633 ///
5634 /// Compaction outcome with the number of tokens and messages removed, summary text, and the resulting context window breakdown.
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 compact_with_params(
5644 &self,
5645 params: HistoryCompactRequest,
5646 ) -> Result<HistoryCompactResult, Error> {
5647 let mut wire_params = serde_json::to_value(params)?;
5648 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5649 let _value = self
5650 .session
5651 .client()
5652 .call(rpc_methods::SESSION_HISTORY_COMPACT, Some(wire_params))
5653 .await?;
5654 Ok(serde_json::from_value(_value)?)
5655 }
5656
5657 /// Truncates persisted session history to a specific event.
5658 ///
5659 /// Wire method: `session.history.truncate`.
5660 ///
5661 /// # Parameters
5662 ///
5663 /// * `params` - Identifier of the event to truncate to; this event and all later events are removed.
5664 ///
5665 /// # Returns
5666 ///
5667 /// Number of events that were removed by the truncation.
5668 ///
5669 /// <div class="warning">
5670 ///
5671 /// **Experimental.** This API is part of an experimental wire-protocol surface
5672 /// and may change or be removed in future SDK or CLI releases. Pin both the
5673 /// SDK and CLI versions if your code depends on it.
5674 ///
5675 /// </div>
5676 pub async fn truncate(
5677 &self,
5678 params: HistoryTruncateRequest,
5679 ) -> Result<HistoryTruncateResult, Error> {
5680 let mut wire_params = serde_json::to_value(params)?;
5681 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5682 let _value = self
5683 .session
5684 .client()
5685 .call(rpc_methods::SESSION_HISTORY_TRUNCATE, Some(wire_params))
5686 .await?;
5687 Ok(serde_json::from_value(_value)?)
5688 }
5689
5690 /// 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.
5691 ///
5692 /// Wire method: `session.history.listRewindPoints`.
5693 ///
5694 /// # Returns
5695 ///
5696 /// Rewind points and file-change-tracking availability for the session.
5697 ///
5698 /// <div class="warning">
5699 ///
5700 /// **Experimental.** This API is part of an experimental wire-protocol surface
5701 /// and may change or be removed in future SDK or CLI releases. Pin both the
5702 /// SDK and CLI versions if your code depends on it.
5703 ///
5704 /// </div>
5705 pub async fn list_rewind_points(&self) -> Result<HistoryListRewindPointsResult, Error> {
5706 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5707 let _value = self
5708 .session
5709 .client()
5710 .call(
5711 rpc_methods::SESSION_HISTORY_LISTREWINDPOINTS,
5712 Some(wire_params),
5713 )
5714 .await?;
5715 Ok(serde_json::from_value(_value)?)
5716 }
5717
5718 /// Previews the files that a conversation-and-files rewind would restore.
5719 ///
5720 /// Wire method: `session.history.previewRewind`.
5721 ///
5722 /// # Parameters
5723 ///
5724 /// * `params` - Event boundary to preview for conversation-and-files rewind.
5725 ///
5726 /// # Returns
5727 ///
5728 /// Files and aggregate changes for a prospective rewind.
5729 ///
5730 /// <div class="warning">
5731 ///
5732 /// **Experimental.** This API is part of an experimental wire-protocol surface
5733 /// and may change or be removed in future SDK or CLI releases. Pin both the
5734 /// SDK and CLI versions if your code depends on it.
5735 ///
5736 /// </div>
5737 pub async fn preview_rewind(
5738 &self,
5739 params: HistoryPreviewRewindRequest,
5740 ) -> Result<HistoryPreviewRewindResult, Error> {
5741 let mut wire_params = serde_json::to_value(params)?;
5742 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5743 let _value = self
5744 .session
5745 .client()
5746 .call(
5747 rpc_methods::SESSION_HISTORY_PREVIEWREWIND,
5748 Some(wire_params),
5749 )
5750 .await?;
5751 Ok(serde_json::from_value(_value)?)
5752 }
5753
5754 /// 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.
5755 ///
5756 /// Wire method: `session.history.rewind`.
5757 ///
5758 /// # Parameters
5759 ///
5760 /// * `params` - Boundary and mode for rewinding session history.
5761 ///
5762 /// # Returns
5763 ///
5764 /// Structured outcome of a rewind request.
5765 ///
5766 /// <div class="warning">
5767 ///
5768 /// **Experimental.** This API is part of an experimental wire-protocol surface
5769 /// and may change or be removed in future SDK or CLI releases. Pin both the
5770 /// SDK and CLI versions if your code depends on it.
5771 ///
5772 /// </div>
5773 pub async fn rewind(&self, params: HistoryRewindRequest) -> Result<HistoryRewindResult, Error> {
5774 let mut wire_params = serde_json::to_value(params)?;
5775 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5776 let _value = self
5777 .session
5778 .client()
5779 .call(rpc_methods::SESSION_HISTORY_REWIND, Some(wire_params))
5780 .await?;
5781 Ok(serde_json::from_value(_value)?)
5782 }
5783
5784 /// Cancels any in-progress background compaction on a local session.
5785 ///
5786 /// Wire method: `session.history.cancelBackgroundCompaction`.
5787 ///
5788 /// # Returns
5789 ///
5790 /// Indicates whether an in-progress background compaction was cancelled.
5791 ///
5792 /// <div class="warning">
5793 ///
5794 /// **Experimental.** This API is part of an experimental wire-protocol surface
5795 /// and may change or be removed in future SDK or CLI releases. Pin both the
5796 /// SDK and CLI versions if your code depends on it.
5797 ///
5798 /// </div>
5799 pub async fn cancel_background_compaction(
5800 &self,
5801 ) -> Result<HistoryCancelBackgroundCompactionResult, Error> {
5802 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5803 let _value = self
5804 .session
5805 .client()
5806 .call(
5807 rpc_methods::SESSION_HISTORY_CANCELBACKGROUNDCOMPACTION,
5808 Some(wire_params),
5809 )
5810 .await?;
5811 Ok(serde_json::from_value(_value)?)
5812 }
5813
5814 /// Aborts any in-progress manual compaction on a local session.
5815 ///
5816 /// Wire method: `session.history.abortManualCompaction`.
5817 ///
5818 /// # Returns
5819 ///
5820 /// Indicates whether an in-progress manual compaction was aborted.
5821 ///
5822 /// <div class="warning">
5823 ///
5824 /// **Experimental.** This API is part of an experimental wire-protocol surface
5825 /// and may change or be removed in future SDK or CLI releases. Pin both the
5826 /// SDK and CLI versions if your code depends on it.
5827 ///
5828 /// </div>
5829 pub async fn abort_manual_compaction(
5830 &self,
5831 ) -> Result<HistoryAbortManualCompactionResult, Error> {
5832 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5833 let _value = self
5834 .session
5835 .client()
5836 .call(
5837 rpc_methods::SESSION_HISTORY_ABORTMANUALCOMPACTION,
5838 Some(wire_params),
5839 )
5840 .await?;
5841 Ok(serde_json::from_value(_value)?)
5842 }
5843
5844 /// Produces a markdown summary of the session's conversation context for hand-off scenarios.
5845 ///
5846 /// Wire method: `session.history.summarizeForHandoff`.
5847 ///
5848 /// # Returns
5849 ///
5850 /// Markdown summary of the conversation context (empty when not available).
5851 ///
5852 /// <div class="warning">
5853 ///
5854 /// **Experimental.** This API is part of an experimental wire-protocol surface
5855 /// and may change or be removed in future SDK or CLI releases. Pin both the
5856 /// SDK and CLI versions if your code depends on it.
5857 ///
5858 /// </div>
5859 pub async fn summarize_for_handoff(&self) -> Result<HistorySummarizeForHandoffResult, Error> {
5860 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5861 let _value = self
5862 .session
5863 .client()
5864 .call(
5865 rpc_methods::SESSION_HISTORY_SUMMARIZEFORHANDOFF,
5866 Some(wire_params),
5867 )
5868 .await?;
5869 Ok(serde_json::from_value(_value)?)
5870 }
5871
5872 /// 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.
5873 ///
5874 /// Wire method: `session.history.clearContext`.
5875 ///
5876 /// # Parameters
5877 ///
5878 /// * `params` - Parameters for clearing the conversation and seeding the window that replaces it.
5879 ///
5880 /// # Returns
5881 ///
5882 /// What a successful clear removed. A clear that could not be applied rejects instead of reporting a count.
5883 ///
5884 /// <div class="warning">
5885 ///
5886 /// **Experimental.** This API is part of an experimental wire-protocol surface
5887 /// and may change or be removed in future SDK or CLI releases. Pin both the
5888 /// SDK and CLI versions if your code depends on it.
5889 ///
5890 /// </div>
5891 pub async fn clear_context(
5892 &self,
5893 params: HistoryClearContextRequest,
5894 ) -> Result<HistoryClearContextResult, Error> {
5895 let mut wire_params = serde_json::to_value(params)?;
5896 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5897 let _value = self
5898 .session
5899 .client()
5900 .call(rpc_methods::SESSION_HISTORY_CLEARCONTEXT, Some(wire_params))
5901 .await?;
5902 Ok(serde_json::from_value(_value)?)
5903 }
5904}
5905
5906/// `session.instructions.*` RPCs.
5907#[derive(Clone, Copy)]
5908pub struct SessionRpcInstructions<'a> {
5909 pub(crate) session: &'a Session,
5910}
5911
5912impl<'a> SessionRpcInstructions<'a> {
5913 /// Gets instruction sources loaded for the session.
5914 ///
5915 /// Wire method: `session.instructions.getSources`.
5916 ///
5917 /// # Returns
5918 ///
5919 /// Instruction sources loaded for the session, in merge order.
5920 ///
5921 /// <div class="warning">
5922 ///
5923 /// **Experimental.** This API is part of an experimental wire-protocol surface
5924 /// and may change or be removed in future SDK or CLI releases. Pin both the
5925 /// SDK and CLI versions if your code depends on it.
5926 ///
5927 /// </div>
5928 pub async fn get_sources(&self) -> Result<InstructionsGetSourcesResult, Error> {
5929 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5930 let _value = self
5931 .session
5932 .client()
5933 .call(
5934 rpc_methods::SESSION_INSTRUCTIONS_GETSOURCES,
5935 Some(wire_params),
5936 )
5937 .await?;
5938 Ok(serde_json::from_value(_value)?)
5939 }
5940}
5941
5942/// `session.limitPrediction.*` RPCs.
5943#[derive(Clone, Copy)]
5944pub struct SessionRpcLimitPrediction<'a> {
5945 pub(crate) session: &'a Session,
5946}
5947
5948impl<'a> SessionRpcLimitPrediction<'a> {
5949 /// 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.
5950 ///
5951 /// Wire method: `session.limitPrediction.predict`.
5952 ///
5953 /// # Returns
5954 ///
5955 /// Prediction result. Available results include prediction details; unavailable results include an explicit reason.
5956 ///
5957 /// <div class="warning">
5958 ///
5959 /// **Experimental.** This API is part of an experimental wire-protocol surface
5960 /// and may change or be removed in future SDK or CLI releases. Pin both the
5961 /// SDK and CLI versions if your code depends on it.
5962 ///
5963 /// </div>
5964 pub async fn predict(&self) -> Result<SessionLimitPredictionResult, Error> {
5965 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5966 let _value = self
5967 .session
5968 .client()
5969 .call(
5970 rpc_methods::SESSION_LIMITPREDICTION_PREDICT,
5971 Some(wire_params),
5972 )
5973 .await?;
5974 Ok(serde_json::from_value(_value)?)
5975 }
5976
5977 /// 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.
5978 ///
5979 /// Wire method: `session.limitPrediction.predict`.
5980 ///
5981 /// # Parameters
5982 ///
5983 /// * `params` - Parameters for predicting an AI-credit session limit. Omitting `modelId` uses the session's currently selected model.
5984 ///
5985 /// # Returns
5986 ///
5987 /// Prediction result. Available results include prediction details; unavailable results include an explicit reason.
5988 ///
5989 /// <div class="warning">
5990 ///
5991 /// **Experimental.** This API is part of an experimental wire-protocol surface
5992 /// and may change or be removed in future SDK or CLI releases. Pin both the
5993 /// SDK and CLI versions if your code depends on it.
5994 ///
5995 /// </div>
5996 pub async fn predict_with_params(
5997 &self,
5998 params: SessionLimitPredictionRequest,
5999 ) -> Result<SessionLimitPredictionResult, Error> {
6000 let mut wire_params = serde_json::to_value(params)?;
6001 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6002 let _value = self
6003 .session
6004 .client()
6005 .call(
6006 rpc_methods::SESSION_LIMITPREDICTION_PREDICT,
6007 Some(wire_params),
6008 )
6009 .await?;
6010 Ok(serde_json::from_value(_value)?)
6011 }
6012}
6013
6014/// `session.lsp.*` RPCs.
6015#[derive(Clone, Copy)]
6016pub struct SessionRpcLsp<'a> {
6017 pub(crate) session: &'a Session,
6018}
6019
6020impl<'a> SessionRpcLsp<'a> {
6021 /// Loads the merged LSP configuration set for the session's working directory.
6022 ///
6023 /// Wire method: `session.lsp.initialize`.
6024 ///
6025 /// # Parameters
6026 ///
6027 /// * `params` - Parameters for (re)loading the merged LSP configuration set.
6028 ///
6029 /// <div class="warning">
6030 ///
6031 /// **Experimental.** This API is part of an experimental wire-protocol surface
6032 /// and may change or be removed in future SDK or CLI releases. Pin both the
6033 /// SDK and CLI versions if your code depends on it.
6034 ///
6035 /// </div>
6036 pub async fn initialize(&self, params: LspInitializeRequest) -> Result<(), Error> {
6037 let mut wire_params = serde_json::to_value(params)?;
6038 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6039 let _value = self
6040 .session
6041 .client()
6042 .call(rpc_methods::SESSION_LSP_INITIALIZE, Some(wire_params))
6043 .await?;
6044 Ok(())
6045 }
6046}
6047
6048/// `session.mcp.*` RPCs.
6049#[derive(Clone, Copy)]
6050pub struct SessionRpcMcp<'a> {
6051 pub(crate) session: &'a Session,
6052}
6053
6054impl<'a> SessionRpcMcp<'a> {
6055 /// `session.mcp.apps.*` sub-namespace.
6056 pub fn apps(&self) -> SessionRpcMcpApps<'a> {
6057 SessionRpcMcpApps {
6058 session: self.session,
6059 }
6060 }
6061
6062 /// `session.mcp.headers.*` sub-namespace.
6063 pub fn headers(&self) -> SessionRpcMcpHeaders<'a> {
6064 SessionRpcMcpHeaders {
6065 session: self.session,
6066 }
6067 }
6068
6069 /// `session.mcp.oauth.*` sub-namespace.
6070 pub fn oauth(&self) -> SessionRpcMcpOauth<'a> {
6071 SessionRpcMcpOauth {
6072 session: self.session,
6073 }
6074 }
6075
6076 /// `session.mcp.resources.*` sub-namespace.
6077 pub fn resources(&self) -> SessionRpcMcpResources<'a> {
6078 SessionRpcMcpResources {
6079 session: self.session,
6080 }
6081 }
6082
6083 /// 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.
6084 ///
6085 /// Wire method: `session.mcp.list`.
6086 ///
6087 /// # Returns
6088 ///
6089 /// MCP servers configured for the session, with their connection status and host-level state.
6090 ///
6091 /// <div class="warning">
6092 ///
6093 /// **Experimental.** This API is part of an experimental wire-protocol surface
6094 /// and may change or be removed in future SDK or CLI releases. Pin both the
6095 /// SDK and CLI versions if your code depends on it.
6096 ///
6097 /// </div>
6098 pub async fn list(&self) -> Result<McpServerList, Error> {
6099 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6100 let _value = self
6101 .session
6102 .client()
6103 .call(rpc_methods::SESSION_MCP_LIST, Some(wire_params))
6104 .await?;
6105 Ok(serde_json::from_value(_value)?)
6106 }
6107
6108 /// 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.
6109 ///
6110 /// Wire method: `session.mcp.listTools`.
6111 ///
6112 /// # Parameters
6113 ///
6114 /// * `params` - Server name whose tool list should be returned.
6115 ///
6116 /// # Returns
6117 ///
6118 /// Tools exposed by the connected MCP server. Throws when the server is not connected.
6119 ///
6120 /// <div class="warning">
6121 ///
6122 /// **Experimental.** This API is part of an experimental wire-protocol surface
6123 /// and may change or be removed in future SDK or CLI releases. Pin both the
6124 /// SDK and CLI versions if your code depends on it.
6125 ///
6126 /// </div>
6127 pub async fn list_tools(
6128 &self,
6129 params: McpListToolsRequest,
6130 ) -> Result<McpListToolsResult, Error> {
6131 let mut wire_params = serde_json::to_value(params)?;
6132 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6133 let _value = self
6134 .session
6135 .client()
6136 .call(rpc_methods::SESSION_MCP_LISTTOOLS, Some(wire_params))
6137 .await?;
6138 Ok(serde_json::from_value(_value)?)
6139 }
6140
6141 /// Enables an MCP server for the session.
6142 ///
6143 /// Wire method: `session.mcp.enable`.
6144 ///
6145 /// # Parameters
6146 ///
6147 /// * `params` - Name of the MCP server to enable for the session.
6148 ///
6149 /// <div class="warning">
6150 ///
6151 /// **Experimental.** This API is part of an experimental wire-protocol surface
6152 /// and may change or be removed in future SDK or CLI releases. Pin both the
6153 /// SDK and CLI versions if your code depends on it.
6154 ///
6155 /// </div>
6156 pub async fn enable(&self, params: McpEnableRequest) -> Result<(), Error> {
6157 let mut wire_params = serde_json::to_value(params)?;
6158 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6159 let _value = self
6160 .session
6161 .client()
6162 .call(rpc_methods::SESSION_MCP_ENABLE, Some(wire_params))
6163 .await?;
6164 Ok(())
6165 }
6166
6167 /// Disables an MCP server for the session.
6168 ///
6169 /// Wire method: `session.mcp.disable`.
6170 ///
6171 /// # Parameters
6172 ///
6173 /// * `params` - Name of the MCP server to disable for the session.
6174 ///
6175 /// <div class="warning">
6176 ///
6177 /// **Experimental.** This API is part of an experimental wire-protocol surface
6178 /// and may change or be removed in future SDK or CLI releases. Pin both the
6179 /// SDK and CLI versions if your code depends on it.
6180 ///
6181 /// </div>
6182 pub async fn disable(&self, params: McpDisableRequest) -> Result<(), Error> {
6183 let mut wire_params = serde_json::to_value(params)?;
6184 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6185 let _value = self
6186 .session
6187 .client()
6188 .call(rpc_methods::SESSION_MCP_DISABLE, Some(wire_params))
6189 .await?;
6190 Ok(())
6191 }
6192
6193 /// Reloads MCP server connections for the session.
6194 ///
6195 /// Wire method: `session.mcp.reload`.
6196 ///
6197 /// <div class="warning">
6198 ///
6199 /// **Experimental.** This API is part of an experimental wire-protocol surface
6200 /// and may change or be removed in future SDK or CLI releases. Pin both the
6201 /// SDK and CLI versions if your code depends on it.
6202 ///
6203 /// </div>
6204 pub async fn reload(&self) -> Result<(), Error> {
6205 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6206 let _value = self
6207 .session
6208 .client()
6209 .call(rpc_methods::SESSION_MCP_RELOAD, Some(wire_params))
6210 .await?;
6211 Ok(())
6212 }
6213
6214 /// 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.
6215 ///
6216 /// Wire method: `session.mcp.moveLoadingToBackground`.
6217 ///
6218 /// # Returns
6219 ///
6220 /// Result of moving in-flight MCP loading to the background.
6221 ///
6222 /// <div class="warning">
6223 ///
6224 /// **Experimental.** This API is part of an experimental wire-protocol surface
6225 /// and may change or be removed in future SDK or CLI releases. Pin both the
6226 /// SDK and CLI versions if your code depends on it.
6227 ///
6228 /// </div>
6229 pub async fn move_loading_to_background(
6230 &self,
6231 ) -> Result<MoveMcpLoadingToBackgroundResult, Error> {
6232 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6233 let _value = self
6234 .session
6235 .client()
6236 .call(
6237 rpc_methods::SESSION_MCP_MOVELOADINGTOBACKGROUND,
6238 Some(wire_params),
6239 )
6240 .await?;
6241 Ok(serde_json::from_value(_value)?)
6242 }
6243
6244 /// Reloads MCP server connections for the session with an explicit host-provided configuration.
6245 ///
6246 /// Wire method: `session.mcp.reloadWithConfig`.
6247 ///
6248 /// # Parameters
6249 ///
6250 /// * `params` - Opaque MCP reload configuration.
6251 ///
6252 /// # Returns
6253 ///
6254 /// MCP server startup filtering result.
6255 ///
6256 /// <div class="warning">
6257 ///
6258 /// **Experimental.** This API is part of an experimental wire-protocol surface
6259 /// and may change or be removed in future SDK or CLI releases. Pin both the
6260 /// SDK and CLI versions if your code depends on it.
6261 ///
6262 /// </div>
6263 pub(crate) async fn reload_with_config(
6264 &self,
6265 params: McpReloadWithConfigRequest,
6266 ) -> Result<McpStartServersResult, Error> {
6267 let mut wire_params = serde_json::to_value(params)?;
6268 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6269 let _value = self
6270 .session
6271 .client()
6272 .call(rpc_methods::SESSION_MCP_RELOADWITHCONFIG, Some(wire_params))
6273 .await?;
6274 Ok(serde_json::from_value(_value)?)
6275 }
6276
6277 /// Runs an MCP sampling inference on behalf of an MCP server.
6278 ///
6279 /// Wire method: `session.mcp.executeSampling`.
6280 ///
6281 /// # Parameters
6282 ///
6283 /// * `params` - Identifiers and raw MCP CreateMessageRequest params used to run a sampling inference.
6284 ///
6285 /// # Returns
6286 ///
6287 /// Outcome of an MCP sampling execution: success result, failure error, or cancellation.
6288 ///
6289 /// <div class="warning">
6290 ///
6291 /// **Experimental.** This API is part of an experimental wire-protocol surface
6292 /// and may change or be removed in future SDK or CLI releases. Pin both the
6293 /// SDK and CLI versions if your code depends on it.
6294 ///
6295 /// </div>
6296 pub async fn execute_sampling(
6297 &self,
6298 params: McpExecuteSamplingParams,
6299 ) -> Result<McpSamplingExecutionResult, Error> {
6300 let mut wire_params = serde_json::to_value(params)?;
6301 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6302 let _value = self
6303 .session
6304 .client()
6305 .call(rpc_methods::SESSION_MCP_EXECUTESAMPLING, Some(wire_params))
6306 .await?;
6307 Ok(serde_json::from_value(_value)?)
6308 }
6309
6310 /// Cancels an in-flight MCP sampling execution by request ID.
6311 ///
6312 /// Wire method: `session.mcp.cancelSamplingExecution`.
6313 ///
6314 /// # Parameters
6315 ///
6316 /// * `params` - The requestId previously passed to executeSampling that should be cancelled.
6317 ///
6318 /// # Returns
6319 ///
6320 /// Indicates whether an in-flight sampling execution with the given requestId was found and cancelled.
6321 ///
6322 /// <div class="warning">
6323 ///
6324 /// **Experimental.** This API is part of an experimental wire-protocol surface
6325 /// and may change or be removed in future SDK or CLI releases. Pin both the
6326 /// SDK and CLI versions if your code depends on it.
6327 ///
6328 /// </div>
6329 pub async fn cancel_sampling_execution(
6330 &self,
6331 params: McpCancelSamplingExecutionParams,
6332 ) -> Result<McpCancelSamplingExecutionResult, Error> {
6333 let mut wire_params = serde_json::to_value(params)?;
6334 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6335 let _value = self
6336 .session
6337 .client()
6338 .call(
6339 rpc_methods::SESSION_MCP_CANCELSAMPLINGEXECUTION,
6340 Some(wire_params),
6341 )
6342 .await?;
6343 Ok(serde_json::from_value(_value)?)
6344 }
6345
6346 /// Sets how environment-variable values supplied to MCP servers are resolved (direct or indirect).
6347 ///
6348 /// Wire method: `session.mcp.setEnvValueMode`.
6349 ///
6350 /// # Parameters
6351 ///
6352 /// * `params` - Mode controlling how MCP server env values are resolved (`direct` or `indirect`).
6353 ///
6354 /// # Returns
6355 ///
6356 /// Env-value mode recorded on the session after the update.
6357 ///
6358 /// <div class="warning">
6359 ///
6360 /// **Experimental.** This API is part of an experimental wire-protocol surface
6361 /// and may change or be removed in future SDK or CLI releases. Pin both the
6362 /// SDK and CLI versions if your code depends on it.
6363 ///
6364 /// </div>
6365 pub async fn set_env_value_mode(
6366 &self,
6367 params: McpSetEnvValueModeParams,
6368 ) -> Result<McpSetEnvValueModeResult, Error> {
6369 let mut wire_params = serde_json::to_value(params)?;
6370 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6371 let _value = self
6372 .session
6373 .client()
6374 .call(rpc_methods::SESSION_MCP_SETENVVALUEMODE, Some(wire_params))
6375 .await?;
6376 Ok(serde_json::from_value(_value)?)
6377 }
6378
6379 /// Removes the auto-managed `github` MCP server when present.
6380 ///
6381 /// Wire method: `session.mcp.removeGitHub`.
6382 ///
6383 /// # Returns
6384 ///
6385 /// Indicates whether the auto-managed `github` MCP server was removed (false when nothing to remove).
6386 ///
6387 /// <div class="warning">
6388 ///
6389 /// **Experimental.** This API is part of an experimental wire-protocol surface
6390 /// and may change or be removed in future SDK or CLI releases. Pin both the
6391 /// SDK and CLI versions if your code depends on it.
6392 ///
6393 /// </div>
6394 pub async fn remove_git_hub(&self) -> Result<McpRemoveGitHubResult, Error> {
6395 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6396 let _value = self
6397 .session
6398 .client()
6399 .call(rpc_methods::SESSION_MCP_REMOVEGITHUB, Some(wire_params))
6400 .await?;
6401 Ok(serde_json::from_value(_value)?)
6402 }
6403
6404 /// Configures the built-in GitHub MCP server for the session's current auth context.
6405 ///
6406 /// Wire method: `session.mcp.configureGitHub`.
6407 ///
6408 /// # Parameters
6409 ///
6410 /// * `params` - Credential-free authentication identity used to configure GitHub MCP.
6411 ///
6412 /// # Returns
6413 ///
6414 /// Result of configuring GitHub MCP.
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(crate) async fn configure_git_hub(
6424 &self,
6425 params: McpConfigureGitHubRequest,
6426 ) -> Result<McpConfigureGitHubResult, 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(rpc_methods::SESSION_MCP_CONFIGUREGITHUB, Some(wire_params))
6433 .await?;
6434 Ok(serde_json::from_value(_value)?)
6435 }
6436
6437 /// 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.
6438 ///
6439 /// Wire method: `session.mcp.startServer`.
6440 ///
6441 /// # Parameters
6442 ///
6443 /// * `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.
6444 ///
6445 /// <div class="warning">
6446 ///
6447 /// **Experimental.** This API is part of an experimental wire-protocol surface
6448 /// and may change or be removed in future SDK or CLI releases. Pin both the
6449 /// SDK and CLI versions if your code depends on it.
6450 ///
6451 /// </div>
6452 pub async fn start_server(&self, params: McpStartServerRequest) -> Result<(), Error> {
6453 let mut wire_params = serde_json::to_value(params)?;
6454 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6455 let _value = self
6456 .session
6457 .client()
6458 .call(rpc_methods::SESSION_MCP_STARTSERVER, Some(wire_params))
6459 .await?;
6460 Ok(())
6461 }
6462
6463 /// 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.*`).
6464 ///
6465 /// Wire method: `session.mcp.restartServer`.
6466 ///
6467 /// # Parameters
6468 ///
6469 /// * `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.
6470 ///
6471 /// <div class="warning">
6472 ///
6473 /// **Experimental.** This API is part of an experimental wire-protocol surface
6474 /// and may change or be removed in future SDK or CLI releases. Pin both the
6475 /// SDK and CLI versions if your code depends on it.
6476 ///
6477 /// </div>
6478 pub async fn restart_server(&self, params: McpRestartServerRequest) -> Result<(), Error> {
6479 let mut wire_params = serde_json::to_value(params)?;
6480 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6481 let _value = self
6482 .session
6483 .client()
6484 .call(rpc_methods::SESSION_MCP_RESTARTSERVER, Some(wire_params))
6485 .await?;
6486 Ok(())
6487 }
6488
6489 /// Stops an individual MCP server on the session's host.
6490 ///
6491 /// Wire method: `session.mcp.stopServer`.
6492 ///
6493 /// # Parameters
6494 ///
6495 /// * `params` - Server name for an individual MCP server stop.
6496 ///
6497 /// <div class="warning">
6498 ///
6499 /// **Experimental.** This API is part of an experimental wire-protocol surface
6500 /// and may change or be removed in future SDK or CLI releases. Pin both the
6501 /// SDK and CLI versions if your code depends on it.
6502 ///
6503 /// </div>
6504 pub async fn stop_server(&self, params: McpStopServerRequest) -> Result<(), Error> {
6505 let mut wire_params = serde_json::to_value(params)?;
6506 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6507 let _value = self
6508 .session
6509 .client()
6510 .call(rpc_methods::SESSION_MCP_STOPSERVER, Some(wire_params))
6511 .await?;
6512 Ok(())
6513 }
6514
6515 /// 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.
6516 ///
6517 /// Wire method: `session.mcp.registerExternalClient`.
6518 ///
6519 /// # Parameters
6520 ///
6521 /// * `params` - Registration parameters for an external MCP client.
6522 ///
6523 /// <div class="warning">
6524 ///
6525 /// **Experimental.** This API is part of an experimental wire-protocol surface
6526 /// and may change or be removed in future SDK or CLI releases. Pin both the
6527 /// SDK and CLI versions if your code depends on it.
6528 ///
6529 /// </div>
6530 pub(crate) async fn register_external_client(
6531 &self,
6532 params: McpRegisterExternalClientRequest,
6533 ) -> Result<(), Error> {
6534 let mut wire_params = serde_json::to_value(params)?;
6535 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6536 let _value = self
6537 .session
6538 .client()
6539 .call(
6540 rpc_methods::SESSION_MCP_REGISTEREXTERNALCLIENT,
6541 Some(wire_params),
6542 )
6543 .await?;
6544 Ok(())
6545 }
6546
6547 /// 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.
6548 ///
6549 /// Wire method: `session.mcp.unregisterExternalClient`.
6550 ///
6551 /// # Parameters
6552 ///
6553 /// * `params` - Server name identifying the external client to remove.
6554 ///
6555 /// <div class="warning">
6556 ///
6557 /// **Experimental.** This API is part of an experimental wire-protocol surface
6558 /// and may change or be removed in future SDK or CLI releases. Pin both the
6559 /// SDK and CLI versions if your code depends on it.
6560 ///
6561 /// </div>
6562 pub(crate) async fn unregister_external_client(
6563 &self,
6564 params: McpUnregisterExternalClientRequest,
6565 ) -> Result<(), Error> {
6566 let mut wire_params = serde_json::to_value(params)?;
6567 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6568 let _value = self
6569 .session
6570 .client()
6571 .call(
6572 rpc_methods::SESSION_MCP_UNREGISTEREXTERNALCLIENT,
6573 Some(wire_params),
6574 )
6575 .await?;
6576 Ok(())
6577 }
6578
6579 /// Checks whether a named MCP server is currently running on the session's host.
6580 ///
6581 /// Wire method: `session.mcp.isServerRunning`.
6582 ///
6583 /// # Parameters
6584 ///
6585 /// * `params` - Server name to check running status for.
6586 ///
6587 /// # Returns
6588 ///
6589 /// Whether the named MCP server is running.
6590 ///
6591 /// <div class="warning">
6592 ///
6593 /// **Experimental.** This API is part of an experimental wire-protocol surface
6594 /// and may change or be removed in future SDK or CLI releases. Pin both the
6595 /// SDK and CLI versions if your code depends on it.
6596 ///
6597 /// </div>
6598 pub async fn is_server_running(
6599 &self,
6600 params: McpIsServerRunningRequest,
6601 ) -> Result<McpIsServerRunningResult, Error> {
6602 let mut wire_params = serde_json::to_value(params)?;
6603 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6604 let _value = self
6605 .session
6606 .client()
6607 .call(rpc_methods::SESSION_MCP_ISSERVERRUNNING, Some(wire_params))
6608 .await?;
6609 Ok(serde_json::from_value(_value)?)
6610 }
6611}
6612
6613/// `session.mcp.apps.*` RPCs.
6614#[derive(Clone, Copy)]
6615pub struct SessionRpcMcpApps<'a> {
6616 pub(crate) session: &'a Session,
6617}
6618
6619impl<'a> SessionRpcMcpApps<'a> {
6620 /// Fetch an MCP resource (typically a `ui://` MCP App bundle, per SEP-1865) from a connected server. Requires the `mcp-apps` session capability.
6621 ///
6622 /// Wire method: `session.mcp.apps.readResource`.
6623 ///
6624 /// # Parameters
6625 ///
6626 /// * `params` - MCP server and resource URI to fetch.
6627 ///
6628 /// # Returns
6629 ///
6630 /// Resource contents returned by the MCP server.
6631 ///
6632 /// <div class="warning">
6633 ///
6634 /// **Experimental.** This API is part of an experimental wire-protocol surface
6635 /// and may change or be removed in future SDK or CLI releases. Pin both the
6636 /// SDK and CLI versions if your code depends on it.
6637 ///
6638 /// </div>
6639 pub async fn read_resource(
6640 &self,
6641 params: McpAppsReadResourceRequest,
6642 ) -> Result<McpAppsReadResourceResult, Error> {
6643 let mut wire_params = serde_json::to_value(params)?;
6644 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6645 let _value = self
6646 .session
6647 .client()
6648 .call(
6649 rpc_methods::SESSION_MCP_APPS_READRESOURCE,
6650 Some(wire_params),
6651 )
6652 .await?;
6653 Ok(serde_json::from_value(_value)?)
6654 }
6655
6656 /// 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"`.
6657 ///
6658 /// Wire method: `session.mcp.apps.listTools`.
6659 ///
6660 /// # Parameters
6661 ///
6662 /// * `params` - MCP server to list app-callable tools for.
6663 ///
6664 /// # Returns
6665 ///
6666 /// App-callable tools from the named MCP server.
6667 ///
6668 /// <div class="warning">
6669 ///
6670 /// **Experimental.** This API is part of an experimental wire-protocol surface
6671 /// and may change or be removed in future SDK or CLI releases. Pin both the
6672 /// SDK and CLI versions if your code depends on it.
6673 ///
6674 /// </div>
6675 pub async fn list_tools(
6676 &self,
6677 params: McpAppsListToolsRequest,
6678 ) -> Result<McpAppsListToolsResult, Error> {
6679 let mut wire_params = serde_json::to_value(params)?;
6680 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6681 let _value = self
6682 .session
6683 .client()
6684 .call(rpc_methods::SESSION_MCP_APPS_LISTTOOLS, Some(wire_params))
6685 .await?;
6686 Ok(serde_json::from_value(_value)?)
6687 }
6688
6689 /// 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`.
6690 ///
6691 /// Wire method: `session.mcp.apps.callTool`.
6692 ///
6693 /// # Parameters
6694 ///
6695 /// * `params` - MCP server, tool name, and arguments to invoke from an MCP App view.
6696 ///
6697 /// # Returns
6698 ///
6699 /// Standard MCP CallToolResult
6700 ///
6701 /// <div class="warning">
6702 ///
6703 /// **Experimental.** This API is part of an experimental wire-protocol surface
6704 /// and may change or be removed in future SDK or CLI releases. Pin both the
6705 /// SDK and CLI versions if your code depends on it.
6706 ///
6707 /// </div>
6708 pub async fn call_tool(
6709 &self,
6710 params: McpAppsCallToolRequest,
6711 ) -> Result<SessionMcpAppsCallToolResult, Error> {
6712 let mut wire_params = serde_json::to_value(params)?;
6713 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6714 let _value = self
6715 .session
6716 .client()
6717 .call(rpc_methods::SESSION_MCP_APPS_CALLTOOL, Some(wire_params))
6718 .await?;
6719 Ok(serde_json::from_value(_value)?)
6720 }
6721
6722 /// 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.
6723 ///
6724 /// Wire method: `session.mcp.apps.setHostContext`.
6725 ///
6726 /// # Parameters
6727 ///
6728 /// * `params` - Host context to advertise to MCP App guests.
6729 ///
6730 /// <div class="warning">
6731 ///
6732 /// **Experimental.** This API is part of an experimental wire-protocol surface
6733 /// and may change or be removed in future SDK or CLI releases. Pin both the
6734 /// SDK and CLI versions if your code depends on it.
6735 ///
6736 /// </div>
6737 pub async fn set_host_context(
6738 &self,
6739 params: McpAppsSetHostContextRequest,
6740 ) -> Result<(), Error> {
6741 let mut wire_params = serde_json::to_value(params)?;
6742 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6743 let _value = self
6744 .session
6745 .client()
6746 .call(
6747 rpc_methods::SESSION_MCP_APPS_SETHOSTCONTEXT,
6748 Some(wire_params),
6749 )
6750 .await?;
6751 Ok(())
6752 }
6753
6754 /// Read the current host context advertised to MCP App guests.
6755 ///
6756 /// Wire method: `session.mcp.apps.getHostContext`.
6757 ///
6758 /// # Returns
6759 ///
6760 /// Current host context advertised to MCP App guests.
6761 ///
6762 /// <div class="warning">
6763 ///
6764 /// **Experimental.** This API is part of an experimental wire-protocol surface
6765 /// and may change or be removed in future SDK or CLI releases. Pin both the
6766 /// SDK and CLI versions if your code depends on it.
6767 ///
6768 /// </div>
6769 pub async fn get_host_context(&self) -> Result<McpAppsHostContext, Error> {
6770 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6771 let _value = self
6772 .session
6773 .client()
6774 .call(
6775 rpc_methods::SESSION_MCP_APPS_GETHOSTCONTEXT,
6776 Some(wire_params),
6777 )
6778 .await?;
6779 Ok(serde_json::from_value(_value)?)
6780 }
6781
6782 /// 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.
6783 ///
6784 /// Wire method: `session.mcp.apps.diagnose`.
6785 ///
6786 /// # Parameters
6787 ///
6788 /// * `params` - MCP server to diagnose MCP Apps wiring for.
6789 ///
6790 /// # Returns
6791 ///
6792 /// Diagnostic snapshot of MCP Apps wiring for the named server.
6793 ///
6794 /// <div class="warning">
6795 ///
6796 /// **Experimental.** This API is part of an experimental wire-protocol surface
6797 /// and may change or be removed in future SDK or CLI releases. Pin both the
6798 /// SDK and CLI versions if your code depends on it.
6799 ///
6800 /// </div>
6801 pub async fn diagnose(
6802 &self,
6803 params: McpAppsDiagnoseRequest,
6804 ) -> Result<McpAppsDiagnoseResult, Error> {
6805 let mut wire_params = serde_json::to_value(params)?;
6806 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6807 let _value = self
6808 .session
6809 .client()
6810 .call(rpc_methods::SESSION_MCP_APPS_DIAGNOSE, Some(wire_params))
6811 .await?;
6812 Ok(serde_json::from_value(_value)?)
6813 }
6814}
6815
6816/// `session.mcp.headers.*` RPCs.
6817#[derive(Clone, Copy)]
6818pub struct SessionRpcMcpHeaders<'a> {
6819 pub(crate) session: &'a Session,
6820}
6821
6822impl<'a> SessionRpcMcpHeaders<'a> {
6823 /// 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.
6824 ///
6825 /// Wire method: `session.mcp.headers.handlePendingHeadersRefreshRequest`.
6826 ///
6827 /// # Parameters
6828 ///
6829 /// * `params` - MCP headers refresh request id and the host response.
6830 ///
6831 /// # Returns
6832 ///
6833 /// Indicates whether the pending MCP headers refresh response was accepted.
6834 ///
6835 /// <div class="warning">
6836 ///
6837 /// **Experimental.** This API is part of an experimental wire-protocol surface
6838 /// and may change or be removed in future SDK or CLI releases. Pin both the
6839 /// SDK and CLI versions if your code depends on it.
6840 ///
6841 /// </div>
6842 pub async fn handle_pending_headers_refresh_request(
6843 &self,
6844 params: McpHeadersHandlePendingHeadersRefreshRequestRequest,
6845 ) -> Result<McpHeadersHandlePendingHeadersRefreshRequestResult, Error> {
6846 let mut wire_params = serde_json::to_value(params)?;
6847 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6848 let _value = self
6849 .session
6850 .client()
6851 .call(
6852 rpc_methods::SESSION_MCP_HEADERS_HANDLEPENDINGHEADERSREFRESHREQUEST,
6853 Some(wire_params),
6854 )
6855 .await?;
6856 Ok(serde_json::from_value(_value)?)
6857 }
6858}
6859
6860/// `session.mcp.oauth.*` RPCs.
6861#[derive(Clone, Copy)]
6862pub struct SessionRpcMcpOauth<'a> {
6863 pub(crate) session: &'a Session,
6864}
6865
6866impl<'a> SessionRpcMcpOauth<'a> {
6867 /// 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.
6868 ///
6869 /// Wire method: `session.mcp.oauth.handlePendingRequest`.
6870 ///
6871 /// # Parameters
6872 ///
6873 /// * `params` - Pending MCP OAuth request ID and host-provided token or cancellation response.
6874 ///
6875 /// # Returns
6876 ///
6877 /// Indicates whether the pending MCP OAuth response was accepted.
6878 ///
6879 /// <div class="warning">
6880 ///
6881 /// **Experimental.** This API is part of an experimental wire-protocol surface
6882 /// and may change or be removed in future SDK or CLI releases. Pin both the
6883 /// SDK and CLI versions if your code depends on it.
6884 ///
6885 /// </div>
6886 pub async fn handle_pending_request(
6887 &self,
6888 params: McpOauthHandlePendingRequest,
6889 ) -> Result<McpOauthHandlePendingResult, Error> {
6890 let mut wire_params = serde_json::to_value(params)?;
6891 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6892 let _value = self
6893 .session
6894 .client()
6895 .call(
6896 rpc_methods::SESSION_MCP_OAUTH_HANDLEPENDINGREQUEST,
6897 Some(wire_params),
6898 )
6899 .await?;
6900 Ok(serde_json::from_value(_value)?)
6901 }
6902
6903 /// Notifies the session that MCP OAuth authentication succeeded and updated credentials were persisted, so cached tool definitions can be refreshed.
6904 ///
6905 /// Wire method: `session.mcp.oauth.authenticationStateChanged`.
6906 ///
6907 /// # Parameters
6908 ///
6909 /// * `params` - Identifies the MCP server whose persisted OAuth credentials were updated.
6910 ///
6911 /// <div class="warning">
6912 ///
6913 /// **Experimental.** This API is part of an experimental wire-protocol surface
6914 /// and may change or be removed in future SDK or CLI releases. Pin both the
6915 /// SDK and CLI versions if your code depends on it.
6916 ///
6917 /// </div>
6918 pub async fn authentication_state_changed(
6919 &self,
6920 params: McpOauthAuthenticationStateChangedRequest,
6921 ) -> Result<(), Error> {
6922 let mut wire_params = serde_json::to_value(params)?;
6923 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6924 let _value = self
6925 .session
6926 .client()
6927 .call(
6928 rpc_methods::SESSION_MCP_OAUTH_AUTHENTICATIONSTATECHANGED,
6929 Some(wire_params),
6930 )
6931 .await?;
6932 Ok(())
6933 }
6934
6935 /// Starts OAuth authentication for a remote MCP server.
6936 ///
6937 /// Wire method: `session.mcp.oauth.login`.
6938 ///
6939 /// # Parameters
6940 ///
6941 /// * `params` - Remote MCP server name and optional overrides controlling reauthentication, OAuth client display name, callback success-page copy, and static OAuth client selection.
6942 ///
6943 /// # Returns
6944 ///
6945 /// OAuth authorization URL the caller should open, or empty when cached tokens already authenticated the server.
6946 ///
6947 /// <div class="warning">
6948 ///
6949 /// **Experimental.** This API is part of an experimental wire-protocol surface
6950 /// and may change or be removed in future SDK or CLI releases. Pin both the
6951 /// SDK and CLI versions if your code depends on it.
6952 ///
6953 /// </div>
6954 pub async fn login(&self, params: McpOauthLoginRequest) -> Result<McpOauthLoginResult, Error> {
6955 let mut wire_params = serde_json::to_value(params)?;
6956 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6957 let _value = self
6958 .session
6959 .client()
6960 .call(rpc_methods::SESSION_MCP_OAUTH_LOGIN, Some(wire_params))
6961 .await?;
6962 Ok(serde_json::from_value(_value)?)
6963 }
6964
6965 /// 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.
6966 ///
6967 /// Wire method: `session.mcp.oauth.probe`.
6968 ///
6969 /// # Parameters
6970 ///
6971 /// * `params` - Remote MCP server name for a passive OAuth status probe.
6972 ///
6973 /// # Returns
6974 ///
6975 /// 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.
6976 ///
6977 /// <div class="warning">
6978 ///
6979 /// **Experimental.** This API is part of an experimental wire-protocol surface
6980 /// and may change or be removed in future SDK or CLI releases. Pin both the
6981 /// SDK and CLI versions if your code depends on it.
6982 ///
6983 /// </div>
6984 pub async fn probe(&self, params: McpOauthProbeRequest) -> Result<McpOauthProbeResult, Error> {
6985 let mut wire_params = serde_json::to_value(params)?;
6986 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6987 let _value = self
6988 .session
6989 .client()
6990 .call(rpc_methods::SESSION_MCP_OAUTH_PROBE, Some(wire_params))
6991 .await?;
6992 Ok(serde_json::from_value(_value)?)
6993 }
6994
6995 /// Responds to a pending MCP OAuth authorization request by its request id.
6996 ///
6997 /// Wire method: `session.mcp.oauth.respond`.
6998 ///
6999 /// # Parameters
7000 ///
7001 /// * `params` - Pending MCP OAuth request id to respond to.
7002 ///
7003 /// # Returns
7004 ///
7005 /// Indicates whether the pending MCP OAuth response was accepted.
7006 ///
7007 /// <div class="warning">
7008 ///
7009 /// **Experimental.** This API is part of an experimental wire-protocol surface
7010 /// and may change or be removed in future SDK or CLI releases. Pin both the
7011 /// SDK and CLI versions if your code depends on it.
7012 ///
7013 /// </div>
7014 pub async fn respond(
7015 &self,
7016 params: McpOauthRespondRequest,
7017 ) -> Result<McpOauthRespondResult, Error> {
7018 let mut wire_params = serde_json::to_value(params)?;
7019 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7020 let _value = self
7021 .session
7022 .client()
7023 .call(rpc_methods::SESSION_MCP_OAUTH_RESPOND, Some(wire_params))
7024 .await?;
7025 Ok(serde_json::from_value(_value)?)
7026 }
7027}
7028
7029/// `session.mcp.resources.*` RPCs.
7030#[derive(Clone, Copy)]
7031pub struct SessionRpcMcpResources<'a> {
7032 pub(crate) session: &'a Session,
7033}
7034
7035impl<'a> SessionRpcMcpResources<'a> {
7036 /// Fetch an MCP resource from a connected server by URI (proxies MCP `resources/read`).
7037 ///
7038 /// Wire method: `session.mcp.resources.read`.
7039 ///
7040 /// # Parameters
7041 ///
7042 /// * `params` - MCP server and resource URI to fetch.
7043 ///
7044 /// # Returns
7045 ///
7046 /// Resource contents returned by the MCP server.
7047 ///
7048 /// <div class="warning">
7049 ///
7050 /// **Experimental.** This API is part of an experimental wire-protocol surface
7051 /// and may change or be removed in future SDK or CLI releases. Pin both the
7052 /// SDK and CLI versions if your code depends on it.
7053 ///
7054 /// </div>
7055 pub async fn read(
7056 &self,
7057 params: McpResourcesReadRequest,
7058 ) -> Result<McpResourcesReadResult, Error> {
7059 let mut wire_params = serde_json::to_value(params)?;
7060 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7061 let _value = self
7062 .session
7063 .client()
7064 .call(rpc_methods::SESSION_MCP_RESOURCES_READ, Some(wire_params))
7065 .await?;
7066 Ok(serde_json::from_value(_value)?)
7067 }
7068
7069 /// Enumerate one page of resources a connected MCP server exposes (proxies MCP `resources/list`). Pass `cursor` to continue from a prior result's `nextCursor`.
7070 ///
7071 /// Wire method: `session.mcp.resources.list`.
7072 ///
7073 /// # Parameters
7074 ///
7075 /// * `params` - MCP server whose resources to enumerate.
7076 ///
7077 /// # Returns
7078 ///
7079 /// One page of resources advertised by the named MCP server.
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 list(
7089 &self,
7090 params: McpResourcesListRequest,
7091 ) -> Result<McpResourcesListResult, 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(rpc_methods::SESSION_MCP_RESOURCES_LIST, Some(wire_params))
7098 .await?;
7099 Ok(serde_json::from_value(_value)?)
7100 }
7101
7102 /// 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`.
7103 ///
7104 /// Wire method: `session.mcp.resources.listTemplates`.
7105 ///
7106 /// # Parameters
7107 ///
7108 /// * `params` - MCP server whose resource templates to enumerate.
7109 ///
7110 /// # Returns
7111 ///
7112 /// One page of resource templates advertised by the named MCP server.
7113 ///
7114 /// <div class="warning">
7115 ///
7116 /// **Experimental.** This API is part of an experimental wire-protocol surface
7117 /// and may change or be removed in future SDK or CLI releases. Pin both the
7118 /// SDK and CLI versions if your code depends on it.
7119 ///
7120 /// </div>
7121 pub async fn list_templates(
7122 &self,
7123 params: McpResourcesListTemplatesRequest,
7124 ) -> Result<McpResourcesListTemplatesResult, Error> {
7125 let mut wire_params = serde_json::to_value(params)?;
7126 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7127 let _value = self
7128 .session
7129 .client()
7130 .call(
7131 rpc_methods::SESSION_MCP_RESOURCES_LISTTEMPLATES,
7132 Some(wire_params),
7133 )
7134 .await?;
7135 Ok(serde_json::from_value(_value)?)
7136 }
7137}
7138
7139/// `session.metadata.*` RPCs.
7140#[derive(Clone, Copy)]
7141pub struct SessionRpcMetadata<'a> {
7142 pub(crate) session: &'a Session,
7143}
7144
7145impl<'a> SessionRpcMetadata<'a> {
7146 /// Returns a snapshot of the session's identifying metadata, mode, agent, and remote info.
7147 ///
7148 /// Wire method: `session.metadata.snapshot`.
7149 ///
7150 /// # Returns
7151 ///
7152 /// Point-in-time snapshot of slow-changing session identifier and state fields
7153 ///
7154 /// <div class="warning">
7155 ///
7156 /// **Experimental.** This API is part of an experimental wire-protocol surface
7157 /// and may change or be removed in future SDK or CLI releases. Pin both the
7158 /// SDK and CLI versions if your code depends on it.
7159 ///
7160 /// </div>
7161 pub async fn snapshot(&self) -> Result<SessionMetadataSnapshot, Error> {
7162 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7163 let _value = self
7164 .session
7165 .client()
7166 .call(rpc_methods::SESSION_METADATA_SNAPSHOT, Some(wire_params))
7167 .await?;
7168 Ok(serde_json::from_value(_value)?)
7169 }
7170
7171 /// Reports whether the local session is currently processing user/agent messages.
7172 ///
7173 /// Wire method: `session.metadata.isProcessing`.
7174 ///
7175 /// # Returns
7176 ///
7177 /// Indicates whether the local session is currently processing a turn or background continuation.
7178 ///
7179 /// <div class="warning">
7180 ///
7181 /// **Experimental.** This API is part of an experimental wire-protocol surface
7182 /// and may change or be removed in future SDK or CLI releases. Pin both the
7183 /// SDK and CLI versions if your code depends on it.
7184 ///
7185 /// </div>
7186 pub async fn is_processing(&self) -> Result<MetadataIsProcessingResult, Error> {
7187 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7188 let _value = self
7189 .session
7190 .client()
7191 .call(
7192 rpc_methods::SESSION_METADATA_ISPROCESSING,
7193 Some(wire_params),
7194 )
7195 .await?;
7196 Ok(serde_json::from_value(_value)?)
7197 }
7198
7199 /// Returns a snapshot of activity flags for the session.
7200 ///
7201 /// Wire method: `session.metadata.activity`.
7202 ///
7203 /// # Returns
7204 ///
7205 /// Current activity flags for the session.
7206 ///
7207 /// <div class="warning">
7208 ///
7209 /// **Experimental.** This API is part of an experimental wire-protocol surface
7210 /// and may change or be removed in future SDK or CLI releases. Pin both the
7211 /// SDK and CLI versions if your code depends on it.
7212 ///
7213 /// </div>
7214 pub async fn activity(&self) -> Result<SessionActivity, Error> {
7215 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7216 let _value = self
7217 .session
7218 .client()
7219 .call(rpc_methods::SESSION_METADATA_ACTIVITY, Some(wire_params))
7220 .await?;
7221 Ok(serde_json::from_value(_value)?)
7222 }
7223
7224 /// Returns the token breakdown for the session's current context window for a given model.
7225 ///
7226 /// Wire method: `session.metadata.contextInfo`.
7227 ///
7228 /// # Parameters
7229 ///
7230 /// * `params` - Model identifier and token limits used to compute the context-info breakdown.
7231 ///
7232 /// # Returns
7233 ///
7234 /// Token breakdown for the session's current context window, or null if uninitialized.
7235 ///
7236 /// <div class="warning">
7237 ///
7238 /// **Experimental.** This API is part of an experimental wire-protocol surface
7239 /// and may change or be removed in future SDK or CLI releases. Pin both the
7240 /// SDK and CLI versions if your code depends on it.
7241 ///
7242 /// </div>
7243 pub async fn context_info(
7244 &self,
7245 params: MetadataContextInfoRequest,
7246 ) -> Result<MetadataContextInfoResult, Error> {
7247 let mut wire_params = serde_json::to_value(params)?;
7248 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7249 let _value = self
7250 .session
7251 .client()
7252 .call(rpc_methods::SESSION_METADATA_CONTEXTINFO, Some(wire_params))
7253 .await?;
7254 Ok(serde_json::from_value(_value)?)
7255 }
7256
7257 /// 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.
7258 ///
7259 /// Wire method: `session.metadata.getContextAttribution`.
7260 ///
7261 /// # Returns
7262 ///
7263 /// Per-source attribution breakdown for the session's current context window, or null if uninitialized.
7264 ///
7265 /// <div class="warning">
7266 ///
7267 /// **Experimental.** This API is part of an experimental wire-protocol surface
7268 /// and may change or be removed in future SDK or CLI releases. Pin both the
7269 /// SDK and CLI versions if your code depends on it.
7270 ///
7271 /// </div>
7272 pub async fn get_context_attribution(&self) -> Result<MetadataContextAttributionResult, Error> {
7273 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7274 let _value = self
7275 .session
7276 .client()
7277 .call(
7278 rpc_methods::SESSION_METADATA_GETCONTEXTATTRIBUTION,
7279 Some(wire_params),
7280 )
7281 .await?;
7282 Ok(serde_json::from_value(_value)?)
7283 }
7284
7285 /// 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.
7286 ///
7287 /// Wire method: `session.metadata.getContextHeaviestMessages`.
7288 ///
7289 /// # Parameters
7290 ///
7291 /// * `params` - Parameters for the heaviest-messages query.
7292 ///
7293 /// # Returns
7294 ///
7295 /// The heaviest individual messages in the session's context window, most-expensive first.
7296 ///
7297 /// <div class="warning">
7298 ///
7299 /// **Experimental.** This API is part of an experimental wire-protocol surface
7300 /// and may change or be removed in future SDK or CLI releases. Pin both the
7301 /// SDK and CLI versions if your code depends on it.
7302 ///
7303 /// </div>
7304 pub async fn get_context_heaviest_messages(
7305 &self,
7306 params: MetadataContextHeaviestMessagesRequest,
7307 ) -> Result<MetadataContextHeaviestMessagesResult, Error> {
7308 let mut wire_params = serde_json::to_value(params)?;
7309 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7310 let _value = self
7311 .session
7312 .client()
7313 .call(
7314 rpc_methods::SESSION_METADATA_GETCONTEXTHEAVIESTMESSAGES,
7315 Some(wire_params),
7316 )
7317 .await?;
7318 Ok(serde_json::from_value(_value)?)
7319 }
7320
7321 /// 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.
7322 ///
7323 /// Wire method: `session.metadata.recordContextChange`.
7324 ///
7325 /// # Parameters
7326 ///
7327 /// * `params` - Updated working-directory/git context to record on the session.
7328 ///
7329 /// # Returns
7330 ///
7331 /// 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.
7332 ///
7333 /// <div class="warning">
7334 ///
7335 /// **Experimental.** This API is part of an experimental wire-protocol surface
7336 /// and may change or be removed in future SDK or CLI releases. Pin both the
7337 /// SDK and CLI versions if your code depends on it.
7338 ///
7339 /// </div>
7340 pub async fn record_context_change(
7341 &self,
7342 params: MetadataRecordContextChangeRequest,
7343 ) -> Result<MetadataRecordContextChangeResult, Error> {
7344 let mut wire_params = serde_json::to_value(params)?;
7345 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7346 let _value = self
7347 .session
7348 .client()
7349 .call(
7350 rpc_methods::SESSION_METADATA_RECORDCONTEXTCHANGE,
7351 Some(wire_params),
7352 )
7353 .await?;
7354 Ok(serde_json::from_value(_value)?)
7355 }
7356
7357 /// 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.
7358 ///
7359 /// Wire method: `session.metadata.setWorkingDirectory`.
7360 ///
7361 /// # Parameters
7362 ///
7363 /// * `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.
7364 ///
7365 /// # Returns
7366 ///
7367 /// 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.
7368 ///
7369 /// <div class="warning">
7370 ///
7371 /// **Experimental.** This API is part of an experimental wire-protocol surface
7372 /// and may change or be removed in future SDK or CLI releases. Pin both the
7373 /// SDK and CLI versions if your code depends on it.
7374 ///
7375 /// </div>
7376 pub async fn set_working_directory(
7377 &self,
7378 params: MetadataSetWorkingDirectoryRequest,
7379 ) -> Result<MetadataSetWorkingDirectoryResult, Error> {
7380 let mut wire_params = serde_json::to_value(params)?;
7381 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7382 let _value = self
7383 .session
7384 .client()
7385 .call(
7386 rpc_methods::SESSION_METADATA_SETWORKINGDIRECTORY,
7387 Some(wire_params),
7388 )
7389 .await?;
7390 Ok(serde_json::from_value(_value)?)
7391 }
7392
7393 /// Re-tokenizes the session's existing messages against a model and returns aggregate token totals.
7394 ///
7395 /// Wire method: `session.metadata.recomputeContextTokens`.
7396 ///
7397 /// # Parameters
7398 ///
7399 /// * `params` - Model identifier to use when re-tokenizing the session's existing messages.
7400 ///
7401 /// # Returns
7402 ///
7403 /// 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.
7404 ///
7405 /// <div class="warning">
7406 ///
7407 /// **Experimental.** This API is part of an experimental wire-protocol surface
7408 /// and may change or be removed in future SDK or CLI releases. Pin both the
7409 /// SDK and CLI versions if your code depends on it.
7410 ///
7411 /// </div>
7412 pub async fn recompute_context_tokens(
7413 &self,
7414 params: MetadataRecomputeContextTokensRequest,
7415 ) -> Result<MetadataRecomputeContextTokensResult, Error> {
7416 let mut wire_params = serde_json::to_value(params)?;
7417 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7418 let _value = self
7419 .session
7420 .client()
7421 .call(
7422 rpc_methods::SESSION_METADATA_RECOMPUTECONTEXTTOKENS,
7423 Some(wire_params),
7424 )
7425 .await?;
7426 Ok(serde_json::from_value(_value)?)
7427 }
7428}
7429
7430/// `session.mode.*` RPCs.
7431#[derive(Clone, Copy)]
7432pub struct SessionRpcMode<'a> {
7433 pub(crate) session: &'a Session,
7434}
7435
7436impl<'a> SessionRpcMode<'a> {
7437 /// Gets the current agent interaction mode.
7438 ///
7439 /// Wire method: `session.mode.get`.
7440 ///
7441 /// # Returns
7442 ///
7443 /// The session mode the agent is operating in
7444 ///
7445 /// <div class="warning">
7446 ///
7447 /// **Experimental.** This API is part of an experimental wire-protocol surface
7448 /// and may change or be removed in future SDK or CLI releases. Pin both the
7449 /// SDK and CLI versions if your code depends on it.
7450 ///
7451 /// </div>
7452 pub async fn get(&self) -> Result<SessionMode, Error> {
7453 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7454 let _value = self
7455 .session
7456 .client()
7457 .call(rpc_methods::SESSION_MODE_GET, Some(wire_params))
7458 .await?;
7459 Ok(serde_json::from_value(_value)?)
7460 }
7461
7462 /// Sets the current agent interaction mode.
7463 ///
7464 /// Wire method: `session.mode.set`.
7465 ///
7466 /// # Parameters
7467 ///
7468 /// * `params` - Agent interaction mode to apply to the session.
7469 ///
7470 /// # Returns
7471 ///
7472 /// Outcome of a session mode change, including any model switch it triggered and follow-up the host must perform.
7473 ///
7474 /// <div class="warning">
7475 ///
7476 /// **Experimental.** This API is part of an experimental wire-protocol surface
7477 /// and may change or be removed in future SDK or CLI releases. Pin both the
7478 /// SDK and CLI versions if your code depends on it.
7479 ///
7480 /// </div>
7481 pub async fn set(&self, params: ModeSetRequest) -> Result<ModeSetResult, Error> {
7482 let mut wire_params = serde_json::to_value(params)?;
7483 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7484 let _value = self
7485 .session
7486 .client()
7487 .call(rpc_methods::SESSION_MODE_SET, Some(wire_params))
7488 .await?;
7489 Ok(serde_json::from_value(_value)?)
7490 }
7491}
7492
7493/// `session.model.*` RPCs.
7494#[derive(Clone, Copy)]
7495pub struct SessionRpcModel<'a> {
7496 pub(crate) session: &'a Session,
7497}
7498
7499impl<'a> SessionRpcModel<'a> {
7500 /// Gets the session's authoritative model snapshot, including the committed Auto preference and any newer unclaimed Auto preference waiting for a future user turn.
7501 ///
7502 /// Wire method: `session.model.getCurrent`.
7503 ///
7504 /// # Returns
7505 ///
7506 /// The session's authoritative model snapshot. Auto preference fields are configuration for the virtual `auto` model and do not change the selected model identifier. The context tier reflects `Session.getContextTier()`, restored from the session journal on resume.
7507 ///
7508 /// <div class="warning">
7509 ///
7510 /// **Experimental.** This API is part of an experimental wire-protocol surface
7511 /// and may change or be removed in future SDK or CLI releases. Pin both the
7512 /// SDK and CLI versions if your code depends on it.
7513 ///
7514 /// </div>
7515 pub async fn get_current(&self) -> Result<CurrentModel, Error> {
7516 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7517 let _value = self
7518 .session
7519 .client()
7520 .call(rpc_methods::SESSION_MODEL_GETCURRENT, Some(wire_params))
7521 .await?;
7522 Ok(serde_json::from_value(_value)?)
7523 }
7524
7525 /// Switches the session to a model and optional reasoning configuration.
7526 ///
7527 /// Wire method: `session.model.switchTo`.
7528 ///
7529 /// # Parameters
7530 ///
7531 /// * `params` - Target model identifier and optional reasoning effort, summary, capability overrides, and context tier.
7532 ///
7533 /// # Returns
7534 ///
7535 /// The model identifier active on the session after the switch.
7536 ///
7537 /// <div class="warning">
7538 ///
7539 /// **Experimental.** This API is part of an experimental wire-protocol surface
7540 /// and may change or be removed in future SDK or CLI releases. Pin both the
7541 /// SDK and CLI versions if your code depends on it.
7542 ///
7543 /// </div>
7544 pub async fn switch_to(
7545 &self,
7546 params: ModelSwitchToRequest,
7547 ) -> Result<ModelSwitchToResult, Error> {
7548 let mut wire_params = serde_json::to_value(params)?;
7549 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7550 let _value = self
7551 .session
7552 .client()
7553 .call(rpc_methods::SESSION_MODEL_SWITCHTO, Some(wire_params))
7554 .await?;
7555 Ok(serde_json::from_value(_value)?)
7556 }
7557
7558 /// Requests an Auto preference change without changing the session's selected model. The latest unclaimed request wins; the runtime commits it only after a later prompt using the `auto` model mints a usable model and token pair. A `pending` response confirms that the request was accepted, not that it committed. Observe eventual success through `session.model_change`, failure through the ephemeral `session.auto_tier_switch_failed` event, or current unclaimed state through `session.model.getCurrent`.
7559 ///
7560 /// Wire method: `session.model.switchAutoTier`.
7561 ///
7562 /// # Parameters
7563 ///
7564 /// * `params` - An Auto preference request for the session. This updates Auto configuration only; it does not change the selected model to `auto`.
7565 ///
7566 /// # Returns
7567 ///
7568 /// Immediate acknowledgement and Auto preference snapshot after a switch request. This result never implies that a pending preference committed.
7569 ///
7570 /// <div class="warning">
7571 ///
7572 /// **Experimental.** This API is part of an experimental wire-protocol surface
7573 /// and may change or be removed in future SDK or CLI releases. Pin both the
7574 /// SDK and CLI versions if your code depends on it.
7575 ///
7576 /// </div>
7577 pub async fn switch_auto_tier(
7578 &self,
7579 params: ModelSwitchAutoTierRequest,
7580 ) -> Result<ModelSwitchAutoTierResult, Error> {
7581 let mut wire_params = serde_json::to_value(params)?;
7582 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7583 let _value = self
7584 .session
7585 .client()
7586 .call(rpc_methods::SESSION_MODEL_SWITCHAUTOTIER, Some(wire_params))
7587 .await?;
7588 Ok(serde_json::from_value(_value)?)
7589 }
7590
7591 /// Resolves and applies organization-managed and repository model overlays.
7592 ///
7593 /// Wire method: `session.model.applyStartupOverlay`.
7594 ///
7595 /// # Parameters
7596 ///
7597 /// * `params` - Managed, repository, and CLI model overrides to overlay onto the session at startup.
7598 ///
7599 /// # Returns
7600 ///
7601 /// The model identifier active on the session after the switch.
7602 ///
7603 /// <div class="warning">
7604 ///
7605 /// **Experimental.** This API is part of an experimental wire-protocol surface
7606 /// and may change or be removed in future SDK or CLI releases. Pin both the
7607 /// SDK and CLI versions if your code depends on it.
7608 ///
7609 /// </div>
7610 pub(crate) async fn apply_startup_overlay(
7611 &self,
7612 params: ModelApplyStartupOverlayRequest,
7613 ) -> Result<ModelSwitchToResult, Error> {
7614 let mut wire_params = serde_json::to_value(params)?;
7615 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7616 let _value = self
7617 .session
7618 .client()
7619 .call(
7620 rpc_methods::SESSION_MODEL_APPLYSTARTUPOVERLAY,
7621 Some(wire_params),
7622 )
7623 .await?;
7624 Ok(serde_json::from_value(_value)?)
7625 }
7626
7627 /// Updates the session's reasoning effort without changing the selected model.
7628 ///
7629 /// Wire method: `session.model.setReasoningEffort`.
7630 ///
7631 /// # Parameters
7632 ///
7633 /// * `params` - Reasoning effort level to apply to the currently selected model.
7634 ///
7635 /// # Returns
7636 ///
7637 /// 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.
7638 ///
7639 /// <div class="warning">
7640 ///
7641 /// **Experimental.** This API is part of an experimental wire-protocol surface
7642 /// and may change or be removed in future SDK or CLI releases. Pin both the
7643 /// SDK and CLI versions if your code depends on it.
7644 ///
7645 /// </div>
7646 pub async fn set_reasoning_effort(
7647 &self,
7648 params: ModelSetReasoningEffortRequest,
7649 ) -> Result<ModelSetReasoningEffortResult, Error> {
7650 let mut wire_params = serde_json::to_value(params)?;
7651 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7652 let _value = self
7653 .session
7654 .client()
7655 .call(
7656 rpc_methods::SESSION_MODEL_SETREASONINGEFFORT,
7657 Some(wire_params),
7658 )
7659 .await?;
7660 Ok(serde_json::from_value(_value)?)
7661 }
7662
7663 /// 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.
7664 ///
7665 /// Wire method: `session.model.list`.
7666 ///
7667 /// # Returns
7668 ///
7669 /// The list of models available to this session.
7670 ///
7671 /// <div class="warning">
7672 ///
7673 /// **Experimental.** This API is part of an experimental wire-protocol surface
7674 /// and may change or be removed in future SDK or CLI releases. Pin both the
7675 /// SDK and CLI versions if your code depends on it.
7676 ///
7677 /// </div>
7678 pub async fn list(&self) -> Result<SessionModelList, Error> {
7679 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7680 let _value = self
7681 .session
7682 .client()
7683 .call(rpc_methods::SESSION_MODEL_LIST, Some(wire_params))
7684 .await?;
7685 Ok(serde_json::from_value(_value)?)
7686 }
7687
7688 /// 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.
7689 ///
7690 /// Wire method: `session.model.list`.
7691 ///
7692 /// # Parameters
7693 ///
7694 /// * `params` - Optional listing options.
7695 ///
7696 /// # Returns
7697 ///
7698 /// The list of models available to this session.
7699 ///
7700 /// <div class="warning">
7701 ///
7702 /// **Experimental.** This API is part of an experimental wire-protocol surface
7703 /// and may change or be removed in future SDK or CLI releases. Pin both the
7704 /// SDK and CLI versions if your code depends on it.
7705 ///
7706 /// </div>
7707 pub async fn list_with_params(
7708 &self,
7709 params: ModelListRequest,
7710 ) -> Result<SessionModelList, Error> {
7711 let mut wire_params = serde_json::to_value(params)?;
7712 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7713 let _value = self
7714 .session
7715 .client()
7716 .call(rpc_methods::SESSION_MODEL_LIST, Some(wire_params))
7717 .await?;
7718 Ok(serde_json::from_value(_value)?)
7719 }
7720}
7721
7722/// `session.name.*` RPCs.
7723#[derive(Clone, Copy)]
7724pub struct SessionRpcName<'a> {
7725 pub(crate) session: &'a Session,
7726}
7727
7728impl<'a> SessionRpcName<'a> {
7729 /// Gets the session's friendly name.
7730 ///
7731 /// Wire method: `session.name.get`.
7732 ///
7733 /// # Returns
7734 ///
7735 /// The session's friendly name, or null when not yet set.
7736 ///
7737 /// <div class="warning">
7738 ///
7739 /// **Experimental.** This API is part of an experimental wire-protocol surface
7740 /// and may change or be removed in future SDK or CLI releases. Pin both the
7741 /// SDK and CLI versions if your code depends on it.
7742 ///
7743 /// </div>
7744 pub async fn get(&self) -> Result<NameGetResult, Error> {
7745 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7746 let _value = self
7747 .session
7748 .client()
7749 .call(rpc_methods::SESSION_NAME_GET, Some(wire_params))
7750 .await?;
7751 Ok(serde_json::from_value(_value)?)
7752 }
7753
7754 /// Sets the session's friendly name.
7755 ///
7756 /// Wire method: `session.name.set`.
7757 ///
7758 /// # Parameters
7759 ///
7760 /// * `params` - New friendly name to apply to the session.
7761 ///
7762 /// <div class="warning">
7763 ///
7764 /// **Experimental.** This API is part of an experimental wire-protocol surface
7765 /// and may change or be removed in future SDK or CLI releases. Pin both the
7766 /// SDK and CLI versions if your code depends on it.
7767 ///
7768 /// </div>
7769 pub async fn set(&self, params: NameSetRequest) -> Result<(), Error> {
7770 let mut wire_params = serde_json::to_value(params)?;
7771 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7772 let _value = self
7773 .session
7774 .client()
7775 .call(rpc_methods::SESSION_NAME_SET, Some(wire_params))
7776 .await?;
7777 Ok(())
7778 }
7779
7780 /// Persists an auto-generated session summary as the session's name when no user-set name exists.
7781 ///
7782 /// Wire method: `session.name.setAuto`.
7783 ///
7784 /// # Parameters
7785 ///
7786 /// * `params` - Auto-generated session summary to apply as the session's name when no user-set name exists.
7787 ///
7788 /// # Returns
7789 ///
7790 /// Indicates whether the auto-generated summary was applied as the session's name.
7791 ///
7792 /// <div class="warning">
7793 ///
7794 /// **Experimental.** This API is part of an experimental wire-protocol surface
7795 /// and may change or be removed in future SDK or CLI releases. Pin both the
7796 /// SDK and CLI versions if your code depends on it.
7797 ///
7798 /// </div>
7799 pub async fn set_auto(&self, params: NameSetAutoRequest) -> Result<NameSetAutoResult, Error> {
7800 let mut wire_params = serde_json::to_value(params)?;
7801 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7802 let _value = self
7803 .session
7804 .client()
7805 .call(rpc_methods::SESSION_NAME_SETAUTO, Some(wire_params))
7806 .await?;
7807 Ok(serde_json::from_value(_value)?)
7808 }
7809}
7810
7811/// `session.options.*` RPCs.
7812#[derive(Clone, Copy)]
7813pub struct SessionRpcOptions<'a> {
7814 pub(crate) session: &'a Session,
7815}
7816
7817impl<'a> SessionRpcOptions<'a> {
7818 /// Patches the genuinely-mutable subset of session options.
7819 ///
7820 /// Wire method: `session.options.update`.
7821 ///
7822 /// # Parameters
7823 ///
7824 /// * `params` - Patch of mutable session options to apply to the running session.
7825 ///
7826 /// # Returns
7827 ///
7828 /// Indicates whether the session options patch was applied successfully.
7829 ///
7830 /// <div class="warning">
7831 ///
7832 /// **Experimental.** This API is part of an experimental wire-protocol surface
7833 /// and may change or be removed in future SDK or CLI releases. Pin both the
7834 /// SDK and CLI versions if your code depends on it.
7835 ///
7836 /// </div>
7837 pub async fn update(
7838 &self,
7839 params: SessionUpdateOptionsParams,
7840 ) -> Result<SessionUpdateOptionsResult, Error> {
7841 let mut wire_params = serde_json::to_value(params)?;
7842 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7843 let _value = self
7844 .session
7845 .client()
7846 .call(rpc_methods::SESSION_OPTIONS_UPDATE, Some(wire_params))
7847 .await?;
7848 Ok(serde_json::from_value(_value)?)
7849 }
7850}
7851
7852/// `session.permissions.*` RPCs.
7853#[derive(Clone, Copy)]
7854pub struct SessionRpcPermissions<'a> {
7855 pub(crate) session: &'a Session,
7856}
7857
7858impl<'a> SessionRpcPermissions<'a> {
7859 /// `session.permissions.folderTrust.*` sub-namespace.
7860 pub fn folder_trust(&self) -> SessionRpcPermissionsFolderTrust<'a> {
7861 SessionRpcPermissionsFolderTrust {
7862 session: self.session,
7863 }
7864 }
7865
7866 /// `session.permissions.locations.*` sub-namespace.
7867 pub fn locations(&self) -> SessionRpcPermissionsLocations<'a> {
7868 SessionRpcPermissionsLocations {
7869 session: self.session,
7870 }
7871 }
7872
7873 /// `session.permissions.paths.*` sub-namespace.
7874 pub fn paths(&self) -> SessionRpcPermissionsPaths<'a> {
7875 SessionRpcPermissionsPaths {
7876 session: self.session,
7877 }
7878 }
7879
7880 /// `session.permissions.urls.*` sub-namespace.
7881 pub fn urls(&self) -> SessionRpcPermissionsUrls<'a> {
7882 SessionRpcPermissionsUrls {
7883 session: self.session,
7884 }
7885 }
7886
7887 /// Replaces selected permission policy fields (rules, paths, URLs, exclusions, allow-all flags) on the session.
7888 ///
7889 /// Wire method: `session.permissions.configure`.
7890 ///
7891 /// # Parameters
7892 ///
7893 /// * `params` - Patch of permission policy fields to apply (omit a field to leave it unchanged).
7894 ///
7895 /// # Returns
7896 ///
7897 /// Indicates whether the operation succeeded.
7898 ///
7899 /// <div class="warning">
7900 ///
7901 /// **Experimental.** This API is part of an experimental wire-protocol surface
7902 /// and may change or be removed in future SDK or CLI releases. Pin both the
7903 /// SDK and CLI versions if your code depends on it.
7904 ///
7905 /// </div>
7906 pub async fn configure(
7907 &self,
7908 params: PermissionsConfigureParams,
7909 ) -> Result<PermissionsConfigureResult, Error> {
7910 let mut wire_params = serde_json::to_value(params)?;
7911 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7912 let _value = self
7913 .session
7914 .client()
7915 .call(
7916 rpc_methods::SESSION_PERMISSIONS_CONFIGURE,
7917 Some(wire_params),
7918 )
7919 .await?;
7920 Ok(serde_json::from_value(_value)?)
7921 }
7922
7923 /// Provides a decision for a pending tool permission request.
7924 ///
7925 /// Wire method: `session.permissions.handlePendingPermissionRequest`.
7926 ///
7927 /// # Parameters
7928 ///
7929 /// * `params` - Pending permission request ID and the decision to apply (approve/reject and scope).
7930 ///
7931 /// # Returns
7932 ///
7933 /// Indicates whether the permission decision was applied; false when the request was already resolved.
7934 ///
7935 /// <div class="warning">
7936 ///
7937 /// **Experimental.** This API is part of an experimental wire-protocol surface
7938 /// and may change or be removed in future SDK or CLI releases. Pin both the
7939 /// SDK and CLI versions if your code depends on it.
7940 ///
7941 /// </div>
7942 pub async fn handle_pending_permission_request(
7943 &self,
7944 params: PermissionDecisionRequest,
7945 ) -> Result<PermissionRequestResult, Error> {
7946 let mut wire_params = serde_json::to_value(params)?;
7947 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7948 let _value = self
7949 .session
7950 .client()
7951 .call(
7952 rpc_methods::SESSION_PERMISSIONS_HANDLEPENDINGPERMISSIONREQUEST,
7953 Some(wire_params),
7954 )
7955 .await?;
7956 Ok(serde_json::from_value(_value)?)
7957 }
7958
7959 /// Reconstructs the set of pending tool permission requests from the session's event history.
7960 ///
7961 /// Wire method: `session.permissions.pendingRequests`.
7962 ///
7963 /// # Returns
7964 ///
7965 /// List of pending permission requests reconstructed from event history.
7966 ///
7967 /// <div class="warning">
7968 ///
7969 /// **Experimental.** This API is part of an experimental wire-protocol surface
7970 /// and may change or be removed in future SDK or CLI releases. Pin both the
7971 /// SDK and CLI versions if your code depends on it.
7972 ///
7973 /// </div>
7974 pub async fn pending_requests(&self) -> Result<PendingPermissionRequestList, Error> {
7975 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7976 let _value = self
7977 .session
7978 .client()
7979 .call(
7980 rpc_methods::SESSION_PERMISSIONS_PENDINGREQUESTS,
7981 Some(wire_params),
7982 )
7983 .await?;
7984 Ok(serde_json::from_value(_value)?)
7985 }
7986
7987 /// Enables or disables automatic approval of tool permission requests for the session.
7988 ///
7989 /// Wire method: `session.permissions.setApproveAll`.
7990 ///
7991 /// # Parameters
7992 ///
7993 /// * `params` - Allow-all toggle for tool permission requests, with an optional telemetry source.
7994 ///
7995 /// # Returns
7996 ///
7997 /// Indicates whether the operation succeeded.
7998 ///
7999 /// <div class="warning">
8000 ///
8001 /// **Experimental.** This API is part of an experimental wire-protocol surface
8002 /// and may change or be removed in future SDK or CLI releases. Pin both the
8003 /// SDK and CLI versions if your code depends on it.
8004 ///
8005 /// </div>
8006 pub async fn set_approve_all(
8007 &self,
8008 params: PermissionsSetApproveAllRequest,
8009 ) -> Result<PermissionsSetApproveAllResult, Error> {
8010 let mut wire_params = serde_json::to_value(params)?;
8011 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8012 let _value = self
8013 .session
8014 .client()
8015 .call(
8016 rpc_methods::SESSION_PERMISSIONS_SETAPPROVEALL,
8017 Some(wire_params),
8018 )
8019 .await?;
8020 Ok(serde_json::from_value(_value)?)
8021 }
8022
8023 /// 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.
8024 ///
8025 /// Wire method: `session.permissions.setMode`.
8026 ///
8027 /// # Parameters
8028 ///
8029 /// * `params` - Permission mode to apply for the session.
8030 ///
8031 /// # Returns
8032 ///
8033 /// Indicates whether the requested permission mode was applied and reports the authoritative post-mutation mode.
8034 ///
8035 /// <div class="warning">
8036 ///
8037 /// **Experimental.** This API is part of an experimental wire-protocol surface
8038 /// and may change or be removed in future SDK or CLI releases. Pin both the
8039 /// SDK and CLI versions if your code depends on it.
8040 ///
8041 /// </div>
8042 pub async fn set_mode(
8043 &self,
8044 params: PermissionsSetModeRequest,
8045 ) -> Result<PermissionsSetModeResult, Error> {
8046 let mut wire_params = serde_json::to_value(params)?;
8047 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8048 let _value = self
8049 .session
8050 .client()
8051 .call(rpc_methods::SESSION_PERMISSIONS_SETMODE, Some(wire_params))
8052 .await?;
8053 Ok(serde_json::from_value(_value)?)
8054 }
8055
8056 /// Returns the current permission mode for the session.
8057 ///
8058 /// Wire method: `session.permissions.getMode`.
8059 ///
8060 /// # Returns
8061 ///
8062 /// Current permission mode.
8063 ///
8064 /// <div class="warning">
8065 ///
8066 /// **Experimental.** This API is part of an experimental wire-protocol surface
8067 /// and may change or be removed in future SDK or CLI releases. Pin both the
8068 /// SDK and CLI versions if your code depends on it.
8069 ///
8070 /// </div>
8071 pub async fn get_mode(&self) -> Result<PermissionsGetModeResult, Error> {
8072 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8073 let _value = self
8074 .session
8075 .client()
8076 .call(rpc_methods::SESSION_PERMISSIONS_GETMODE, Some(wire_params))
8077 .await?;
8078 Ok(serde_json::from_value(_value)?)
8079 }
8080
8081 /// Adds or removes session-scoped or location-scoped permission rules.
8082 ///
8083 /// Wire method: `session.permissions.modifyRules`.
8084 ///
8085 /// # Parameters
8086 ///
8087 /// * `params` - Scope and add/remove instructions for modifying session- or location-scoped permission rules.
8088 ///
8089 /// # Returns
8090 ///
8091 /// Indicates whether the operation succeeded.
8092 ///
8093 /// <div class="warning">
8094 ///
8095 /// **Experimental.** This API is part of an experimental wire-protocol surface
8096 /// and may change or be removed in future SDK or CLI releases. Pin both the
8097 /// SDK and CLI versions if your code depends on it.
8098 ///
8099 /// </div>
8100 pub async fn modify_rules(
8101 &self,
8102 params: PermissionsModifyRulesParams,
8103 ) -> Result<PermissionsModifyRulesResult, Error> {
8104 let mut wire_params = serde_json::to_value(params)?;
8105 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8106 let _value = self
8107 .session
8108 .client()
8109 .call(
8110 rpc_methods::SESSION_PERMISSIONS_MODIFYRULES,
8111 Some(wire_params),
8112 )
8113 .await?;
8114 Ok(serde_json::from_value(_value)?)
8115 }
8116
8117 /// Sets whether the client wants permission prompts bridged into session events.
8118 ///
8119 /// Wire method: `session.permissions.setRequired`.
8120 ///
8121 /// # Parameters
8122 ///
8123 /// * `params` - Toggles whether permission prompts should be bridged into session events for this client.
8124 ///
8125 /// # Returns
8126 ///
8127 /// Indicates whether the operation succeeded.
8128 ///
8129 /// <div class="warning">
8130 ///
8131 /// **Experimental.** This API is part of an experimental wire-protocol surface
8132 /// and may change or be removed in future SDK or CLI releases. Pin both the
8133 /// SDK and CLI versions if your code depends on it.
8134 ///
8135 /// </div>
8136 pub async fn set_required(
8137 &self,
8138 params: PermissionsSetRequiredRequest,
8139 ) -> Result<PermissionsSetRequiredResult, Error> {
8140 let mut wire_params = serde_json::to_value(params)?;
8141 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8142 let _value = self
8143 .session
8144 .client()
8145 .call(
8146 rpc_methods::SESSION_PERMISSIONS_SETREQUIRED,
8147 Some(wire_params),
8148 )
8149 .await?;
8150 Ok(serde_json::from_value(_value)?)
8151 }
8152
8153 /// Clears session-scoped tool permission approvals.
8154 ///
8155 /// Wire method: `session.permissions.resetSessionApprovals`.
8156 ///
8157 /// # Parameters
8158 ///
8159 /// * `params` - Clears session-scoped tool permission approvals, and optionally the location-scoped ones.
8160 ///
8161 /// # Returns
8162 ///
8163 /// Indicates whether the operation succeeded.
8164 ///
8165 /// <div class="warning">
8166 ///
8167 /// **Experimental.** This API is part of an experimental wire-protocol surface
8168 /// and may change or be removed in future SDK or CLI releases. Pin both the
8169 /// SDK and CLI versions if your code depends on it.
8170 ///
8171 /// </div>
8172 pub async fn reset_session_approvals(
8173 &self,
8174 params: PermissionsResetSessionApprovalsRequest,
8175 ) -> Result<PermissionsResetSessionApprovalsResult, Error> {
8176 let mut wire_params = serde_json::to_value(params)?;
8177 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8178 let _value = self
8179 .session
8180 .client()
8181 .call(
8182 rpc_methods::SESSION_PERMISSIONS_RESETSESSIONAPPROVALS,
8183 Some(wire_params),
8184 )
8185 .await?;
8186 Ok(serde_json::from_value(_value)?)
8187 }
8188
8189 /// Notifies the runtime that a permission prompt UI has been shown to the user.
8190 ///
8191 /// Wire method: `session.permissions.notifyPromptShown`.
8192 ///
8193 /// # Parameters
8194 ///
8195 /// * `params` - Notification payload describing the permission prompt that the client just rendered.
8196 ///
8197 /// # Returns
8198 ///
8199 /// Indicates whether the operation succeeded.
8200 ///
8201 /// <div class="warning">
8202 ///
8203 /// **Experimental.** This API is part of an experimental wire-protocol surface
8204 /// and may change or be removed in future SDK or CLI releases. Pin both the
8205 /// SDK and CLI versions if your code depends on it.
8206 ///
8207 /// </div>
8208 pub async fn notify_prompt_shown(
8209 &self,
8210 params: PermissionPromptShownNotification,
8211 ) -> Result<PermissionsNotifyPromptShownResult, Error> {
8212 let mut wire_params = serde_json::to_value(params)?;
8213 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8214 let _value = self
8215 .session
8216 .client()
8217 .call(
8218 rpc_methods::SESSION_PERMISSIONS_NOTIFYPROMPTSHOWN,
8219 Some(wire_params),
8220 )
8221 .await?;
8222 Ok(serde_json::from_value(_value)?)
8223 }
8224}
8225
8226/// `session.permissions.folderTrust.*` RPCs.
8227#[derive(Clone, Copy)]
8228pub struct SessionRpcPermissionsFolderTrust<'a> {
8229 pub(crate) session: &'a Session,
8230}
8231
8232impl<'a> SessionRpcPermissionsFolderTrust<'a> {
8233 /// Reports whether a folder is trusted according to the user's folder trust state.
8234 ///
8235 /// Wire method: `session.permissions.folderTrust.isTrusted`.
8236 ///
8237 /// # Parameters
8238 ///
8239 /// * `params` - Folder path to check for trust.
8240 ///
8241 /// # Returns
8242 ///
8243 /// Folder trust check result.
8244 ///
8245 /// <div class="warning">
8246 ///
8247 /// **Experimental.** This API is part of an experimental wire-protocol surface
8248 /// and may change or be removed in future SDK or CLI releases. Pin both the
8249 /// SDK and CLI versions if your code depends on it.
8250 ///
8251 /// </div>
8252 pub async fn is_trusted(
8253 &self,
8254 params: FolderTrustCheckParams,
8255 ) -> Result<FolderTrustCheckResult, Error> {
8256 let mut wire_params = serde_json::to_value(params)?;
8257 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8258 let _value = self
8259 .session
8260 .client()
8261 .call(
8262 rpc_methods::SESSION_PERMISSIONS_FOLDERTRUST_ISTRUSTED,
8263 Some(wire_params),
8264 )
8265 .await?;
8266 Ok(serde_json::from_value(_value)?)
8267 }
8268
8269 /// Adds a folder to the user's trusted folders list.
8270 ///
8271 /// Wire method: `session.permissions.folderTrust.addTrusted`.
8272 ///
8273 /// # Parameters
8274 ///
8275 /// * `params` - Folder path to add to trusted folders.
8276 ///
8277 /// # Returns
8278 ///
8279 /// Indicates whether the operation succeeded.
8280 ///
8281 /// <div class="warning">
8282 ///
8283 /// **Experimental.** This API is part of an experimental wire-protocol surface
8284 /// and may change or be removed in future SDK or CLI releases. Pin both the
8285 /// SDK and CLI versions if your code depends on it.
8286 ///
8287 /// </div>
8288 pub async fn add_trusted(
8289 &self,
8290 params: FolderTrustAddParams,
8291 ) -> Result<PermissionsFolderTrustAddTrustedResult, Error> {
8292 let mut wire_params = serde_json::to_value(params)?;
8293 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8294 let _value = self
8295 .session
8296 .client()
8297 .call(
8298 rpc_methods::SESSION_PERMISSIONS_FOLDERTRUST_ADDTRUSTED,
8299 Some(wire_params),
8300 )
8301 .await?;
8302 Ok(serde_json::from_value(_value)?)
8303 }
8304}
8305
8306/// `session.permissions.locations.*` RPCs.
8307#[derive(Clone, Copy)]
8308pub struct SessionRpcPermissionsLocations<'a> {
8309 pub(crate) session: &'a Session,
8310}
8311
8312impl<'a> SessionRpcPermissionsLocations<'a> {
8313 /// Resolves the permission location key and type for a working directory.
8314 ///
8315 /// Wire method: `session.permissions.locations.resolve`.
8316 ///
8317 /// # Parameters
8318 ///
8319 /// * `params` - Working directory to resolve into a location-permissions key.
8320 ///
8321 /// # Returns
8322 ///
8323 /// Resolved location-permissions key and type.
8324 ///
8325 /// <div class="warning">
8326 ///
8327 /// **Experimental.** This API is part of an experimental wire-protocol surface
8328 /// and may change or be removed in future SDK or CLI releases. Pin both the
8329 /// SDK and CLI versions if your code depends on it.
8330 ///
8331 /// </div>
8332 pub async fn resolve(
8333 &self,
8334 params: PermissionLocationResolveParams,
8335 ) -> Result<PermissionLocationResolveResult, Error> {
8336 let mut wire_params = serde_json::to_value(params)?;
8337 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8338 let _value = self
8339 .session
8340 .client()
8341 .call(
8342 rpc_methods::SESSION_PERMISSIONS_LOCATIONS_RESOLVE,
8343 Some(wire_params),
8344 )
8345 .await?;
8346 Ok(serde_json::from_value(_value)?)
8347 }
8348
8349 /// Applies persisted location-scoped tool approvals and allowed directories for a working directory to this session's permission service.
8350 ///
8351 /// Wire method: `session.permissions.locations.apply`.
8352 ///
8353 /// # Parameters
8354 ///
8355 /// * `params` - Working directory to load persisted location permissions for.
8356 ///
8357 /// # Returns
8358 ///
8359 /// Summary of persisted location permissions applied to the session.
8360 ///
8361 /// <div class="warning">
8362 ///
8363 /// **Experimental.** This API is part of an experimental wire-protocol surface
8364 /// and may change or be removed in future SDK or CLI releases. Pin both the
8365 /// SDK and CLI versions if your code depends on it.
8366 ///
8367 /// </div>
8368 pub async fn apply(
8369 &self,
8370 params: PermissionLocationApplyParams,
8371 ) -> Result<PermissionLocationApplyResult, Error> {
8372 let mut wire_params = serde_json::to_value(params)?;
8373 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8374 let _value = self
8375 .session
8376 .client()
8377 .call(
8378 rpc_methods::SESSION_PERMISSIONS_LOCATIONS_APPLY,
8379 Some(wire_params),
8380 )
8381 .await?;
8382 Ok(serde_json::from_value(_value)?)
8383 }
8384
8385 /// Persists a tool approval for a permission location and applies its rules to this session's live permission service.
8386 ///
8387 /// Wire method: `session.permissions.locations.addToolApproval`.
8388 ///
8389 /// # Parameters
8390 ///
8391 /// * `params` - Location-scoped tool approval to persist.
8392 ///
8393 /// # Returns
8394 ///
8395 /// Indicates whether the operation succeeded.
8396 ///
8397 /// <div class="warning">
8398 ///
8399 /// **Experimental.** This API is part of an experimental wire-protocol surface
8400 /// and may change or be removed in future SDK or CLI releases. Pin both the
8401 /// SDK and CLI versions if your code depends on it.
8402 ///
8403 /// </div>
8404 pub async fn add_tool_approval(
8405 &self,
8406 params: PermissionLocationAddToolApprovalParams,
8407 ) -> Result<PermissionsLocationsAddToolApprovalResult, Error> {
8408 let mut wire_params = serde_json::to_value(params)?;
8409 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8410 let _value = self
8411 .session
8412 .client()
8413 .call(
8414 rpc_methods::SESSION_PERMISSIONS_LOCATIONS_ADDTOOLAPPROVAL,
8415 Some(wire_params),
8416 )
8417 .await?;
8418 Ok(serde_json::from_value(_value)?)
8419 }
8420}
8421
8422/// `session.permissions.paths.*` RPCs.
8423#[derive(Clone, Copy)]
8424pub struct SessionRpcPermissionsPaths<'a> {
8425 pub(crate) session: &'a Session,
8426}
8427
8428impl<'a> SessionRpcPermissionsPaths<'a> {
8429 /// Returns the session's allowed directories and primary working directory.
8430 ///
8431 /// Wire method: `session.permissions.paths.list`.
8432 ///
8433 /// # Returns
8434 ///
8435 /// Snapshot of the session's allow-listed directories and primary working directory.
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 list(&self) -> Result<PermissionPathsList, Error> {
8445 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8446 let _value = self
8447 .session
8448 .client()
8449 .call(
8450 rpc_methods::SESSION_PERMISSIONS_PATHS_LIST,
8451 Some(wire_params),
8452 )
8453 .await?;
8454 Ok(serde_json::from_value(_value)?)
8455 }
8456
8457 /// Adds a directory to the session's allow-list and activates conventional skill and agent definitions under it.
8458 ///
8459 /// Wire method: `session.permissions.paths.add`.
8460 ///
8461 /// # Parameters
8462 ///
8463 /// * `params` - Directory path to add to the session's allowed directories.
8464 ///
8465 /// # Returns
8466 ///
8467 /// Indicates whether the operation succeeded.
8468 ///
8469 /// <div class="warning">
8470 ///
8471 /// **Experimental.** This API is part of an experimental wire-protocol surface
8472 /// and may change or be removed in future SDK or CLI releases. Pin both the
8473 /// SDK and CLI versions if your code depends on it.
8474 ///
8475 /// </div>
8476 pub async fn add(
8477 &self,
8478 params: PermissionPathsAddParams,
8479 ) -> Result<PermissionsPathsAddResult, Error> {
8480 let mut wire_params = serde_json::to_value(params)?;
8481 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8482 let _value = self
8483 .session
8484 .client()
8485 .call(
8486 rpc_methods::SESSION_PERMISSIONS_PATHS_ADD,
8487 Some(wire_params),
8488 )
8489 .await?;
8490 Ok(serde_json::from_value(_value)?)
8491 }
8492
8493 /// Updates the session's primary working directory used by the permission policy.
8494 ///
8495 /// Wire method: `session.permissions.paths.updatePrimary`.
8496 ///
8497 /// # Parameters
8498 ///
8499 /// * `params` - Directory path to set as the session's new primary working directory.
8500 ///
8501 /// # Returns
8502 ///
8503 /// Indicates whether the operation succeeded.
8504 ///
8505 /// <div class="warning">
8506 ///
8507 /// **Experimental.** This API is part of an experimental wire-protocol surface
8508 /// and may change or be removed in future SDK or CLI releases. Pin both the
8509 /// SDK and CLI versions if your code depends on it.
8510 ///
8511 /// </div>
8512 pub async fn update_primary(
8513 &self,
8514 params: PermissionPathsUpdatePrimaryParams,
8515 ) -> Result<PermissionsPathsUpdatePrimaryResult, Error> {
8516 let mut wire_params = serde_json::to_value(params)?;
8517 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8518 let _value = self
8519 .session
8520 .client()
8521 .call(
8522 rpc_methods::SESSION_PERMISSIONS_PATHS_UPDATEPRIMARY,
8523 Some(wire_params),
8524 )
8525 .await?;
8526 Ok(serde_json::from_value(_value)?)
8527 }
8528
8529 /// Reports whether a path falls within any of the session's allowed directories.
8530 ///
8531 /// Wire method: `session.permissions.paths.isPathWithinAllowedDirectories`.
8532 ///
8533 /// # Parameters
8534 ///
8535 /// * `params` - Path to evaluate against the session's allowed directories.
8536 ///
8537 /// # Returns
8538 ///
8539 /// Indicates whether the supplied path is within the session's allowed directories.
8540 ///
8541 /// <div class="warning">
8542 ///
8543 /// **Experimental.** This API is part of an experimental wire-protocol surface
8544 /// and may change or be removed in future SDK or CLI releases. Pin both the
8545 /// SDK and CLI versions if your code depends on it.
8546 ///
8547 /// </div>
8548 pub async fn is_path_within_allowed_directories(
8549 &self,
8550 params: PermissionPathsAllowedCheckParams,
8551 ) -> Result<PermissionPathsAllowedCheckResult, Error> {
8552 let mut wire_params = serde_json::to_value(params)?;
8553 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8554 let _value = self
8555 .session
8556 .client()
8557 .call(
8558 rpc_methods::SESSION_PERMISSIONS_PATHS_ISPATHWITHINALLOWEDDIRECTORIES,
8559 Some(wire_params),
8560 )
8561 .await?;
8562 Ok(serde_json::from_value(_value)?)
8563 }
8564
8565 /// Reports whether a path falls within the session's workspace (primary) directory.
8566 ///
8567 /// Wire method: `session.permissions.paths.isPathWithinWorkspace`.
8568 ///
8569 /// # Parameters
8570 ///
8571 /// * `params` - Path to evaluate against the session's workspace (primary) directory.
8572 ///
8573 /// # Returns
8574 ///
8575 /// Indicates whether the supplied path is within the session's workspace directory.
8576 ///
8577 /// <div class="warning">
8578 ///
8579 /// **Experimental.** This API is part of an experimental wire-protocol surface
8580 /// and may change or be removed in future SDK or CLI releases. Pin both the
8581 /// SDK and CLI versions if your code depends on it.
8582 ///
8583 /// </div>
8584 pub async fn is_path_within_workspace(
8585 &self,
8586 params: PermissionPathsWorkspaceCheckParams,
8587 ) -> Result<PermissionPathsWorkspaceCheckResult, Error> {
8588 let mut wire_params = serde_json::to_value(params)?;
8589 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8590 let _value = self
8591 .session
8592 .client()
8593 .call(
8594 rpc_methods::SESSION_PERMISSIONS_PATHS_ISPATHWITHINWORKSPACE,
8595 Some(wire_params),
8596 )
8597 .await?;
8598 Ok(serde_json::from_value(_value)?)
8599 }
8600}
8601
8602/// `session.permissions.urls.*` RPCs.
8603#[derive(Clone, Copy)]
8604pub struct SessionRpcPermissionsUrls<'a> {
8605 pub(crate) session: &'a Session,
8606}
8607
8608impl<'a> SessionRpcPermissionsUrls<'a> {
8609 /// Toggles the runtime's URL-permission policy between unrestricted and restricted modes.
8610 ///
8611 /// Wire method: `session.permissions.urls.setUnrestrictedMode`.
8612 ///
8613 /// # Parameters
8614 ///
8615 /// * `params` - Whether the URL-permission policy should run in unrestricted mode.
8616 ///
8617 /// # Returns
8618 ///
8619 /// Indicates whether the operation succeeded.
8620 ///
8621 /// <div class="warning">
8622 ///
8623 /// **Experimental.** This API is part of an experimental wire-protocol surface
8624 /// and may change or be removed in future SDK or CLI releases. Pin both the
8625 /// SDK and CLI versions if your code depends on it.
8626 ///
8627 /// </div>
8628 pub async fn set_unrestricted_mode(
8629 &self,
8630 params: PermissionUrlsSetUnrestrictedModeParams,
8631 ) -> Result<PermissionsUrlsSetUnrestrictedModeResult, Error> {
8632 let mut wire_params = serde_json::to_value(params)?;
8633 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8634 let _value = self
8635 .session
8636 .client()
8637 .call(
8638 rpc_methods::SESSION_PERMISSIONS_URLS_SETUNRESTRICTEDMODE,
8639 Some(wire_params),
8640 )
8641 .await?;
8642 Ok(serde_json::from_value(_value)?)
8643 }
8644}
8645
8646/// `session.plan.*` RPCs.
8647#[derive(Clone, Copy)]
8648pub struct SessionRpcPlan<'a> {
8649 pub(crate) session: &'a Session,
8650}
8651
8652impl<'a> SessionRpcPlan<'a> {
8653 /// Reads the session plan file from the workspace.
8654 ///
8655 /// Wire method: `session.plan.read`.
8656 ///
8657 /// # Returns
8658 ///
8659 /// Existence, contents, and resolved path of the session plan file.
8660 ///
8661 /// <div class="warning">
8662 ///
8663 /// **Experimental.** This API is part of an experimental wire-protocol surface
8664 /// and may change or be removed in future SDK or CLI releases. Pin both the
8665 /// SDK and CLI versions if your code depends on it.
8666 ///
8667 /// </div>
8668 pub async fn read(&self) -> Result<PlanReadResult, Error> {
8669 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8670 let _value = self
8671 .session
8672 .client()
8673 .call(rpc_methods::SESSION_PLAN_READ, Some(wire_params))
8674 .await?;
8675 Ok(serde_json::from_value(_value)?)
8676 }
8677
8678 /// Writes new content to the session plan file.
8679 ///
8680 /// Wire method: `session.plan.update`.
8681 ///
8682 /// # Parameters
8683 ///
8684 /// * `params` - Replacement contents to write to the session plan file.
8685 ///
8686 /// <div class="warning">
8687 ///
8688 /// **Experimental.** This API is part of an experimental wire-protocol surface
8689 /// and may change or be removed in future SDK or CLI releases. Pin both the
8690 /// SDK and CLI versions if your code depends on it.
8691 ///
8692 /// </div>
8693 pub async fn update(&self, params: PlanUpdateRequest) -> Result<(), Error> {
8694 let mut wire_params = serde_json::to_value(params)?;
8695 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8696 let _value = self
8697 .session
8698 .client()
8699 .call(rpc_methods::SESSION_PLAN_UPDATE, Some(wire_params))
8700 .await?;
8701 Ok(())
8702 }
8703
8704 /// Deletes the session plan file from the workspace.
8705 ///
8706 /// Wire method: `session.plan.delete`.
8707 ///
8708 /// <div class="warning">
8709 ///
8710 /// **Experimental.** This API is part of an experimental wire-protocol surface
8711 /// and may change or be removed in future SDK or CLI releases. Pin both the
8712 /// SDK and CLI versions if your code depends on it.
8713 ///
8714 /// </div>
8715 pub async fn delete(&self) -> Result<(), Error> {
8716 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8717 let _value = self
8718 .session
8719 .client()
8720 .call(rpc_methods::SESSION_PLAN_DELETE, Some(wire_params))
8721 .await?;
8722 Ok(())
8723 }
8724
8725 /// Reads todo rows from the session SQL database for plan rendering.
8726 ///
8727 /// Wire method: `session.plan.readSqlTodos`.
8728 ///
8729 /// # Returns
8730 ///
8731 /// Todo rows read from the session SQL database. Empty when no session database is available.
8732 ///
8733 /// <div class="warning">
8734 ///
8735 /// **Experimental.** This API is part of an experimental wire-protocol surface
8736 /// and may change or be removed in future SDK or CLI releases. Pin both the
8737 /// SDK and CLI versions if your code depends on it.
8738 ///
8739 /// </div>
8740 pub async fn read_sql_todos(&self) -> Result<PlanReadSqlTodosResult, Error> {
8741 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8742 let _value = self
8743 .session
8744 .client()
8745 .call(rpc_methods::SESSION_PLAN_READSQLTODOS, Some(wire_params))
8746 .await?;
8747 Ok(serde_json::from_value(_value)?)
8748 }
8749
8750 /// 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.
8751 ///
8752 /// Wire method: `session.plan.readSqlTodosWithDependencies`.
8753 ///
8754 /// # Returns
8755 ///
8756 /// Todo rows + dependency edges read from the session SQL database.
8757 ///
8758 /// <div class="warning">
8759 ///
8760 /// **Experimental.** This API is part of an experimental wire-protocol surface
8761 /// and may change or be removed in future SDK or CLI releases. Pin both the
8762 /// SDK and CLI versions if your code depends on it.
8763 ///
8764 /// </div>
8765 pub async fn read_sql_todos_with_dependencies(
8766 &self,
8767 ) -> Result<PlanReadSqlTodosWithDependenciesResult, Error> {
8768 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8769 let _value = self
8770 .session
8771 .client()
8772 .call(
8773 rpc_methods::SESSION_PLAN_READSQLTODOSWITHDEPENDENCIES,
8774 Some(wire_params),
8775 )
8776 .await?;
8777 Ok(serde_json::from_value(_value)?)
8778 }
8779}
8780
8781/// `session.plugins.*` RPCs.
8782#[derive(Clone, Copy)]
8783pub struct SessionRpcPlugins<'a> {
8784 pub(crate) session: &'a Session,
8785}
8786
8787impl<'a> SessionRpcPlugins<'a> {
8788 /// Lists plugins installed for the session.
8789 ///
8790 /// Wire method: `session.plugins.list`.
8791 ///
8792 /// # Returns
8793 ///
8794 /// Plugins installed for the session, with their enabled state and version metadata.
8795 ///
8796 /// <div class="warning">
8797 ///
8798 /// **Experimental.** This API is part of an experimental wire-protocol surface
8799 /// and may change or be removed in future SDK or CLI releases. Pin both the
8800 /// SDK and CLI versions if your code depends on it.
8801 ///
8802 /// </div>
8803 pub async fn list(&self) -> Result<PluginList, Error> {
8804 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8805 let _value = self
8806 .session
8807 .client()
8808 .call(rpc_methods::SESSION_PLUGINS_LIST, Some(wire_params))
8809 .await?;
8810 Ok(serde_json::from_value(_value)?)
8811 }
8812
8813 /// 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.
8814 ///
8815 /// Wire method: `session.plugins.reload`.
8816 ///
8817 /// <div class="warning">
8818 ///
8819 /// **Experimental.** This API is part of an experimental wire-protocol surface
8820 /// and may change or be removed in future SDK or CLI releases. Pin both the
8821 /// SDK and CLI versions if your code depends on it.
8822 ///
8823 /// </div>
8824 pub async fn reload(&self) -> Result<(), Error> {
8825 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8826 let _value = self
8827 .session
8828 .client()
8829 .call(rpc_methods::SESSION_PLUGINS_RELOAD, Some(wire_params))
8830 .await?;
8831 Ok(())
8832 }
8833
8834 /// 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.
8835 ///
8836 /// Wire method: `session.plugins.reload`.
8837 ///
8838 /// # Parameters
8839 ///
8840 /// * `params` - Optional flags controlling which side effects the reload performs.
8841 ///
8842 /// <div class="warning">
8843 ///
8844 /// **Experimental.** This API is part of an experimental wire-protocol surface
8845 /// and may change or be removed in future SDK or CLI releases. Pin both the
8846 /// SDK and CLI versions if your code depends on it.
8847 ///
8848 /// </div>
8849 pub async fn reload_with_params(&self, params: PluginsReloadRequest) -> Result<(), Error> {
8850 let mut wire_params = serde_json::to_value(params)?;
8851 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8852 let _value = self
8853 .session
8854 .client()
8855 .call(rpc_methods::SESSION_PLUGINS_RELOAD, Some(wire_params))
8856 .await?;
8857 Ok(())
8858 }
8859}
8860
8861/// `session.provider.*` RPCs.
8862#[derive(Clone, Copy)]
8863pub struct SessionRpcProvider<'a> {
8864 pub(crate) session: &'a Session,
8865}
8866
8867impl<'a> SessionRpcProvider<'a> {
8868 /// 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.
8869 ///
8870 /// Wire method: `session.provider.getEndpoint`.
8871 ///
8872 /// # Returns
8873 ///
8874 /// A snapshot of the provider endpoint the session is currently configured to talk to.
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 get_endpoint(&self) -> Result<ProviderEndpoint, Error> {
8884 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8885 let _value = self
8886 .session
8887 .client()
8888 .call(rpc_methods::SESSION_PROVIDER_GETENDPOINT, Some(wire_params))
8889 .await?;
8890 Ok(serde_json::from_value(_value)?)
8891 }
8892
8893 /// 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.
8894 ///
8895 /// Wire method: `session.provider.getEndpoint`.
8896 ///
8897 /// # Parameters
8898 ///
8899 /// * `params` - Optional model identifier to scope the endpoint snapshot to.
8900 ///
8901 /// # Returns
8902 ///
8903 /// A snapshot of the provider endpoint the session is currently configured to talk to.
8904 ///
8905 /// <div class="warning">
8906 ///
8907 /// **Experimental.** This API is part of an experimental wire-protocol surface
8908 /// and may change or be removed in future SDK or CLI releases. Pin both the
8909 /// SDK and CLI versions if your code depends on it.
8910 ///
8911 /// </div>
8912 pub async fn get_endpoint_with_params(
8913 &self,
8914 params: ProviderGetEndpointRequest,
8915 ) -> Result<ProviderEndpoint, Error> {
8916 let mut wire_params = serde_json::to_value(params)?;
8917 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8918 let _value = self
8919 .session
8920 .client()
8921 .call(rpc_methods::SESSION_PROVIDER_GETENDPOINT, Some(wire_params))
8922 .await?;
8923 Ok(serde_json::from_value(_value)?)
8924 }
8925
8926 /// 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.
8927 ///
8928 /// Wire method: `session.provider.add`.
8929 ///
8930 /// # Parameters
8931 ///
8932 /// * `params` - BYOK providers and/or models to add to the session's registry at runtime. Both fields are optional; provide providers, models, or both.
8933 ///
8934 /// # Returns
8935 ///
8936 /// The selectable model entries synthesized for the models added by this call.
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 add(&self, params: ProviderAddRequest) -> Result<ProviderAddResult, 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_PROVIDER_ADD, Some(wire_params))
8952 .await?;
8953 Ok(serde_json::from_value(_value)?)
8954 }
8955}
8956
8957/// `session.queue.*` RPCs.
8958#[derive(Clone, Copy)]
8959pub struct SessionRpcQueue<'a> {
8960 pub(crate) session: &'a Session,
8961}
8962
8963impl<'a> SessionRpcQueue<'a> {
8964 /// Returns the local session's pending user-facing queued items and steering messages.
8965 ///
8966 /// Wire method: `session.queue.pendingItems`.
8967 ///
8968 /// # Returns
8969 ///
8970 /// Snapshot of the session's pending queued items and immediate-steering messages.
8971 ///
8972 /// <div class="warning">
8973 ///
8974 /// **Experimental.** This API is part of an experimental wire-protocol surface
8975 /// and may change or be removed in future SDK or CLI releases. Pin both the
8976 /// SDK and CLI versions if your code depends on it.
8977 ///
8978 /// </div>
8979 pub async fn pending_items(&self) -> Result<QueuePendingItemsResult, Error> {
8980 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8981 let _value = self
8982 .session
8983 .client()
8984 .call(rpc_methods::SESSION_QUEUE_PENDINGITEMS, Some(wire_params))
8985 .await?;
8986 Ok(serde_json::from_value(_value)?)
8987 }
8988
8989 /// Returns the internal native queue snapshot for in-process session orchestration.
8990 ///
8991 /// Wire method: `session.queue.snapshot`.
8992 ///
8993 /// # Returns
8994 ///
8995 /// Internal snapshot of native queue state for local session orchestration.
8996 ///
8997 /// <div class="warning">
8998 ///
8999 /// **Experimental.** This API is part of an experimental wire-protocol surface
9000 /// and may change or be removed in future SDK or CLI releases. Pin both the
9001 /// SDK and CLI versions if your code depends on it.
9002 ///
9003 /// </div>
9004 pub(crate) async fn snapshot(&self) -> Result<QueueSnapshotResult, Error> {
9005 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9006 let _value = self
9007 .session
9008 .client()
9009 .call(rpc_methods::SESSION_QUEUE_SNAPSHOT, Some(wire_params))
9010 .await?;
9011 Ok(serde_json::from_value(_value)?)
9012 }
9013
9014 /// Moves an addressable queued item to a public visible position.
9015 ///
9016 /// Wire method: `session.queue.moveItem`.
9017 ///
9018 /// # Parameters
9019 ///
9020 /// * `params` - Parameters for moving a queued item by stable id.
9021 ///
9022 /// # Returns
9023 ///
9024 /// Result of moving a queued item.
9025 ///
9026 /// <div class="warning">
9027 ///
9028 /// **Experimental.** This API is part of an experimental wire-protocol surface
9029 /// and may change or be removed in future SDK or CLI releases. Pin both the
9030 /// SDK and CLI versions if your code depends on it.
9031 ///
9032 /// </div>
9033 pub async fn move_item(
9034 &self,
9035 params: QueueMoveItemRequest,
9036 ) -> Result<QueueMoveItemResult, Error> {
9037 let mut wire_params = serde_json::to_value(params)?;
9038 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9039 let _value = self
9040 .session
9041 .client()
9042 .call(rpc_methods::SESSION_QUEUE_MOVEITEM, Some(wire_params))
9043 .await?;
9044 Ok(serde_json::from_value(_value)?)
9045 }
9046
9047 /// Inserts a new queued message at a public visible position.
9048 ///
9049 /// Wire method: `session.queue.insertAt`.
9050 ///
9051 /// # Parameters
9052 ///
9053 /// * `params` - Parameters for inserting a queued message at a public visible position.
9054 ///
9055 /// # Returns
9056 ///
9057 /// Result of inserting a queued message.
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 async fn insert_at(
9067 &self,
9068 params: QueueInsertAtRequest,
9069 ) -> Result<QueueInsertAtResult, 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(rpc_methods::SESSION_QUEUE_INSERTAT, Some(wire_params))
9076 .await?;
9077 Ok(serde_json::from_value(_value)?)
9078 }
9079
9080 /// Removes an addressable queued item by its stable id.
9081 ///
9082 /// Wire method: `session.queue.removeAt`.
9083 ///
9084 /// # Parameters
9085 ///
9086 /// * `params` - Parameters for removing a queued item by stable id.
9087 ///
9088 /// # Returns
9089 ///
9090 /// Result of removing a queued item.
9091 ///
9092 /// <div class="warning">
9093 ///
9094 /// **Experimental.** This API is part of an experimental wire-protocol surface
9095 /// and may change or be removed in future SDK or CLI releases. Pin both the
9096 /// SDK and CLI versions if your code depends on it.
9097 ///
9098 /// </div>
9099 pub async fn remove_at(
9100 &self,
9101 params: QueueRemoveAtRequest,
9102 ) -> Result<QueueRemoveAtResult, Error> {
9103 let mut wire_params = serde_json::to_value(params)?;
9104 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9105 let _value = self
9106 .session
9107 .client()
9108 .call(rpc_methods::SESSION_QUEUE_REMOVEAT, Some(wire_params))
9109 .await?;
9110 Ok(serde_json::from_value(_value)?)
9111 }
9112
9113 /// Updates the text of an addressable single-message queue item.
9114 ///
9115 /// Wire method: `session.queue.updateText`.
9116 ///
9117 /// # Parameters
9118 ///
9119 /// * `params` - Parameters for editing a single queued message.
9120 ///
9121 /// # Returns
9122 ///
9123 /// Result of editing a queued message.
9124 ///
9125 /// <div class="warning">
9126 ///
9127 /// **Experimental.** This API is part of an experimental wire-protocol surface
9128 /// and may change or be removed in future SDK or CLI releases. Pin both the
9129 /// SDK and CLI versions if your code depends on it.
9130 ///
9131 /// </div>
9132 pub async fn update_text(
9133 &self,
9134 params: QueueUpdateTextRequest,
9135 ) -> Result<QueueUpdateTextResult, Error> {
9136 let mut wire_params = serde_json::to_value(params)?;
9137 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9138 let _value = self
9139 .session
9140 .client()
9141 .call(rpc_methods::SESSION_QUEUE_UPDATETEXT, Some(wire_params))
9142 .await?;
9143 Ok(serde_json::from_value(_value)?)
9144 }
9145
9146 /// Duplicates an addressable queued item immediately after its source.
9147 ///
9148 /// Wire method: `session.queue.duplicateAt`.
9149 ///
9150 /// # Parameters
9151 ///
9152 /// * `params` - Parameters for duplicating a queued item.
9153 ///
9154 /// # Returns
9155 ///
9156 /// Result of duplicating a queued item.
9157 ///
9158 /// <div class="warning">
9159 ///
9160 /// **Experimental.** This API is part of an experimental wire-protocol surface
9161 /// and may change or be removed in future SDK or CLI releases. Pin both the
9162 /// SDK and CLI versions if your code depends on it.
9163 ///
9164 /// </div>
9165 pub async fn duplicate_at(
9166 &self,
9167 params: QueueDuplicateAtRequest,
9168 ) -> Result<QueueDuplicateAtResult, Error> {
9169 let mut wire_params = serde_json::to_value(params)?;
9170 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9171 let _value = self
9172 .session
9173 .client()
9174 .call(rpc_methods::SESSION_QUEUE_DUPLICATEAT, Some(wire_params))
9175 .await?;
9176 Ok(serde_json::from_value(_value)?)
9177 }
9178
9179 /// Acquires or releases the queued-lane drain pause.
9180 ///
9181 /// Wire method: `session.queue.setDrainPaused`.
9182 ///
9183 /// # Parameters
9184 ///
9185 /// * `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.
9186 ///
9187 /// <div class="warning">
9188 ///
9189 /// **Experimental.** This API is part of an experimental wire-protocol surface
9190 /// and may change or be removed in future SDK or CLI releases. Pin both the
9191 /// SDK and CLI versions if your code depends on it.
9192 ///
9193 /// </div>
9194 pub async fn set_drain_paused(&self, params: QueueSetDrainPausedRequest) -> Result<(), Error> {
9195 let mut wire_params = serde_json::to_value(params)?;
9196 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9197 let _value = self
9198 .session
9199 .client()
9200 .call(rpc_methods::SESSION_QUEUE_SETDRAINPAUSED, Some(wire_params))
9201 .await?;
9202 Ok(())
9203 }
9204
9205 /// Moves an addressable queued message into the live turn's steering lane.
9206 ///
9207 /// Wire method: `session.queue.sendNow`.
9208 ///
9209 /// # Parameters
9210 ///
9211 /// * `params` - Parameters for steering a queued message into a live turn.
9212 ///
9213 /// # Returns
9214 ///
9215 /// Result of trying to steer a queued message into a live turn.
9216 ///
9217 /// <div class="warning">
9218 ///
9219 /// **Experimental.** This API is part of an experimental wire-protocol surface
9220 /// and may change or be removed in future SDK or CLI releases. Pin both the
9221 /// SDK and CLI versions if your code depends on it.
9222 ///
9223 /// </div>
9224 pub async fn send_now(&self, params: QueueSendNowRequest) -> Result<QueueSendNowResult, Error> {
9225 let mut wire_params = serde_json::to_value(params)?;
9226 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9227 let _value = self
9228 .session
9229 .client()
9230 .call(rpc_methods::SESSION_QUEUE_SENDNOW, Some(wire_params))
9231 .await?;
9232 Ok(serde_json::from_value(_value)?)
9233 }
9234
9235 /// Reports whether the local session has native queued work pending.
9236 ///
9237 /// Wire method: `session.queue.hasPending`.
9238 ///
9239 /// # Returns
9240 ///
9241 /// Whether the native queue has pending work.
9242 ///
9243 /// <div class="warning">
9244 ///
9245 /// **Experimental.** This API is part of an experimental wire-protocol surface
9246 /// and may change or be removed in future SDK or CLI releases. Pin both the
9247 /// SDK and CLI versions if your code depends on it.
9248 ///
9249 /// </div>
9250 pub(crate) async fn has_pending(&self) -> Result<QueueHasPendingResult, Error> {
9251 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9252 let _value = self
9253 .session
9254 .client()
9255 .call(rpc_methods::SESSION_QUEUE_HASPENDING, Some(wire_params))
9256 .await?;
9257 Ok(serde_json::from_value(_value)?)
9258 }
9259
9260 /// Begins a native deferred-idle drain when background work has quiesced.
9261 ///
9262 /// Wire method: `session.queue.beginDeferredIdleDrain`.
9263 ///
9264 /// # Parameters
9265 ///
9266 /// * `params` - Inputs for starting a deferred-idle drain.
9267 ///
9268 /// # Returns
9269 ///
9270 /// Whether a deferred-idle drain should run.
9271 ///
9272 /// <div class="warning">
9273 ///
9274 /// **Experimental.** This API is part of an experimental wire-protocol surface
9275 /// and may change or be removed in future SDK or CLI releases. Pin both the
9276 /// SDK and CLI versions if your code depends on it.
9277 ///
9278 /// </div>
9279 pub(crate) async fn begin_deferred_idle_drain(
9280 &self,
9281 params: QueueBeginDeferredIdleDrainRequest,
9282 ) -> Result<QueueBeginDeferredIdleDrainResult, Error> {
9283 let mut wire_params = serde_json::to_value(params)?;
9284 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9285 let _value = self
9286 .session
9287 .client()
9288 .call(
9289 rpc_methods::SESSION_QUEUE_BEGINDEFERREDIDLEDRAIN,
9290 Some(wire_params),
9291 )
9292 .await?;
9293 Ok(serde_json::from_value(_value)?)
9294 }
9295
9296 /// Finishes a native deferred-idle drain and reports whether to drain queue work or emit idle.
9297 ///
9298 /// Wire method: `session.queue.finishDeferredIdleDrain`.
9299 ///
9300 /// # Parameters
9301 ///
9302 /// * `params` - Inputs for completing a deferred-idle drain.
9303 ///
9304 /// # Returns
9305 ///
9306 /// Action selected by the native deferred-idle drain.
9307 ///
9308 /// <div class="warning">
9309 ///
9310 /// **Experimental.** This API is part of an experimental wire-protocol surface
9311 /// and may change or be removed in future SDK or CLI releases. Pin both the
9312 /// SDK and CLI versions if your code depends on it.
9313 ///
9314 /// </div>
9315 pub(crate) async fn finish_deferred_idle_drain(
9316 &self,
9317 params: QueueFinishDeferredIdleDrainRequest,
9318 ) -> Result<QueueFinishDeferredIdleDrainResult, Error> {
9319 let mut wire_params = serde_json::to_value(params)?;
9320 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9321 let _value = self
9322 .session
9323 .client()
9324 .call(
9325 rpc_methods::SESSION_QUEUE_FINISHDEFERREDIDLEDRAIN,
9326 Some(wire_params),
9327 )
9328 .await?;
9329 Ok(serde_json::from_value(_value)?)
9330 }
9331
9332 /// Marks session.idle as deferred by native background work state.
9333 ///
9334 /// Wire method: `session.queue.deferSessionIdle`.
9335 ///
9336 /// # Parameters
9337 ///
9338 /// * `params` - Inputs for marking session.idle deferred in native state.
9339 ///
9340 /// <div class="warning">
9341 ///
9342 /// **Experimental.** This API is part of an experimental wire-protocol surface
9343 /// and may change or be removed in future SDK or CLI releases. Pin both the
9344 /// SDK and CLI versions if your code depends on it.
9345 ///
9346 /// </div>
9347 pub(crate) async fn defer_session_idle(
9348 &self,
9349 params: QueueDeferSessionIdleRequest,
9350 ) -> Result<(), Error> {
9351 let mut wire_params = serde_json::to_value(params)?;
9352 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9353 let _value = self
9354 .session
9355 .client()
9356 .call(
9357 rpc_methods::SESSION_QUEUE_DEFERSESSIONIDLE,
9358 Some(wire_params),
9359 )
9360 .await?;
9361 Ok(())
9362 }
9363
9364 /// Removes the most recently queued user-facing item (LIFO).
9365 ///
9366 /// Wire method: `session.queue.removeMostRecent`.
9367 ///
9368 /// # Returns
9369 ///
9370 /// Indicates whether a user-facing pending item was removed.
9371 ///
9372 /// <div class="warning">
9373 ///
9374 /// **Experimental.** This API is part of an experimental wire-protocol surface
9375 /// and may change or be removed in future SDK or CLI releases. Pin both the
9376 /// SDK and CLI versions if your code depends on it.
9377 ///
9378 /// </div>
9379 pub async fn remove_most_recent(&self) -> Result<QueueRemoveMostRecentResult, Error> {
9380 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9381 let _value = self
9382 .session
9383 .client()
9384 .call(
9385 rpc_methods::SESSION_QUEUE_REMOVEMOSTRECENT,
9386 Some(wire_params),
9387 )
9388 .await?;
9389 Ok(serde_json::from_value(_value)?)
9390 }
9391
9392 /// Clears all pending queued items on the local session.
9393 ///
9394 /// Wire method: `session.queue.clear`.
9395 ///
9396 /// <div class="warning">
9397 ///
9398 /// **Experimental.** This API is part of an experimental wire-protocol surface
9399 /// and may change or be removed in future SDK or CLI releases. Pin both the
9400 /// SDK and CLI versions if your code depends on it.
9401 ///
9402 /// </div>
9403 pub async fn clear(&self) -> Result<(), Error> {
9404 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9405 let _value = self
9406 .session
9407 .client()
9408 .call(rpc_methods::SESSION_QUEUE_CLEAR, Some(wire_params))
9409 .await?;
9410 Ok(())
9411 }
9412
9413 /// Consumes queued native system notifications matching an internal filter.
9414 ///
9415 /// Wire method: `session.queue.consumeSystemNotifications`.
9416 ///
9417 /// # Parameters
9418 ///
9419 /// * `params` - Internal filter for consuming queued system notifications.
9420 ///
9421 /// # Returns
9422 ///
9423 /// Indicates whether a user-facing pending item was removed.
9424 ///
9425 /// <div class="warning">
9426 ///
9427 /// **Experimental.** This API is part of an experimental wire-protocol surface
9428 /// and may change or be removed in future SDK or CLI releases. Pin both the
9429 /// SDK and CLI versions if your code depends on it.
9430 ///
9431 /// </div>
9432 pub(crate) async fn consume_system_notifications(
9433 &self,
9434 params: QueueConsumeSystemNotificationsRequest,
9435 ) -> Result<QueueRemoveMostRecentResult, Error> {
9436 let mut wire_params = serde_json::to_value(params)?;
9437 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9438 let _value = self
9439 .session
9440 .client()
9441 .call(
9442 rpc_methods::SESSION_QUEUE_CONSUMESYSTEMNOTIFICATIONS,
9443 Some(wire_params),
9444 )
9445 .await?;
9446 Ok(serde_json::from_value(_value)?)
9447 }
9448
9449 /// Enqueues the internal resume-pending wake item when orphan handling needs a follow-up turn.
9450 ///
9451 /// Wire method: `session.queue.enqueueResumePending`.
9452 ///
9453 /// # Returns
9454 ///
9455 /// Result of enqueueing the resume-pending wake item.
9456 ///
9457 /// <div class="warning">
9458 ///
9459 /// **Experimental.** This API is part of an experimental wire-protocol surface
9460 /// and may change or be removed in future SDK or CLI releases. Pin both the
9461 /// SDK and CLI versions if your code depends on it.
9462 ///
9463 /// </div>
9464 pub(crate) async fn enqueue_resume_pending(
9465 &self,
9466 ) -> Result<QueueEnqueueResumePendingResult, Error> {
9467 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9468 let _value = self
9469 .session
9470 .client()
9471 .call(
9472 rpc_methods::SESSION_QUEUE_ENQUEUERESUMEPENDING,
9473 Some(wire_params),
9474 )
9475 .await?;
9476 Ok(serde_json::from_value(_value)?)
9477 }
9478
9479 /// Drains the native local-session work queue for in-process session orchestration.
9480 ///
9481 /// Wire method: `session.queue.process`.
9482 ///
9483 /// <div class="warning">
9484 ///
9485 /// **Experimental.** This API is part of an experimental wire-protocol surface
9486 /// and may change or be removed in future SDK or CLI releases. Pin both the
9487 /// SDK and CLI versions if your code depends on it.
9488 ///
9489 /// </div>
9490 pub(crate) async fn process(&self) -> Result<(), Error> {
9491 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9492 let _value = self
9493 .session
9494 .client()
9495 .call(rpc_methods::SESSION_QUEUE_PROCESS, Some(wire_params))
9496 .await?;
9497 Ok(())
9498 }
9499}
9500
9501/// `session.remote.*` RPCs.
9502#[derive(Clone, Copy)]
9503pub struct SessionRpcRemote<'a> {
9504 pub(crate) session: &'a Session,
9505}
9506
9507impl<'a> SessionRpcRemote<'a> {
9508 /// Enables remote session export or steering.
9509 ///
9510 /// Wire method: `session.remote.enable`.
9511 ///
9512 /// # Parameters
9513 ///
9514 /// * `params` - Optional remote session mode ("off", "export", or "on"); defaults to enabling both export and remote steering.
9515 ///
9516 /// # Returns
9517 ///
9518 /// GitHub URL for the session and a flag indicating whether remote steering is enabled.
9519 ///
9520 /// <div class="warning">
9521 ///
9522 /// **Experimental.** This API is part of an experimental wire-protocol surface
9523 /// and may change or be removed in future SDK or CLI releases. Pin both the
9524 /// SDK and CLI versions if your code depends on it.
9525 ///
9526 /// </div>
9527 pub async fn enable(&self, params: RemoteEnableRequest) -> Result<RemoteEnableResult, Error> {
9528 let mut wire_params = serde_json::to_value(params)?;
9529 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9530 let _value = self
9531 .session
9532 .client()
9533 .call(rpc_methods::SESSION_REMOTE_ENABLE, Some(wire_params))
9534 .await?;
9535 Ok(serde_json::from_value(_value)?)
9536 }
9537
9538 /// Disables remote session export and steering.
9539 ///
9540 /// Wire method: `session.remote.disable`.
9541 ///
9542 /// <div class="warning">
9543 ///
9544 /// **Experimental.** This API is part of an experimental wire-protocol surface
9545 /// and may change or be removed in future SDK or CLI releases. Pin both the
9546 /// SDK and CLI versions if your code depends on it.
9547 ///
9548 /// </div>
9549 pub async fn disable(&self) -> Result<(), Error> {
9550 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9551 let _value = self
9552 .session
9553 .client()
9554 .call(rpc_methods::SESSION_REMOTE_DISABLE, Some(wire_params))
9555 .await?;
9556 Ok(())
9557 }
9558
9559 /// Persists a remote-steerability change emitted by the host as a session event.
9560 ///
9561 /// Wire method: `session.remote.notifySteerableChanged`.
9562 ///
9563 /// # Parameters
9564 ///
9565 /// * `params` - New remote-steerability state to persist as a `session.remote_steerable_changed` event.
9566 ///
9567 /// # Returns
9568 ///
9569 /// 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.
9570 ///
9571 /// <div class="warning">
9572 ///
9573 /// **Experimental.** This API is part of an experimental wire-protocol surface
9574 /// and may change or be removed in future SDK or CLI releases. Pin both the
9575 /// SDK and CLI versions if your code depends on it.
9576 ///
9577 /// </div>
9578 pub async fn notify_steerable_changed(
9579 &self,
9580 params: RemoteNotifySteerableChangedRequest,
9581 ) -> Result<RemoteNotifySteerableChangedResult, Error> {
9582 let mut wire_params = serde_json::to_value(params)?;
9583 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9584 let _value = self
9585 .session
9586 .client()
9587 .call(
9588 rpc_methods::SESSION_REMOTE_NOTIFYSTEERABLECHANGED,
9589 Some(wire_params),
9590 )
9591 .await?;
9592 Ok(serde_json::from_value(_value)?)
9593 }
9594}
9595
9596/// `session.sandbox.*` RPCs.
9597#[derive(Clone, Copy)]
9598pub struct SessionRpcSandbox<'a> {
9599 pub(crate) session: &'a Session,
9600}
9601
9602impl<'a> SessionRpcSandbox<'a> {
9603 /// Returns whether managed policy requires sandbox enforcement and whether an enforcement failure has permanently blocked the session.
9604 ///
9605 /// Wire method: `session.sandbox.getEnforcementStatus`.
9606 ///
9607 /// # Returns
9608 ///
9609 /// Managed sandbox enforcement state for a session.
9610 ///
9611 /// <div class="warning">
9612 ///
9613 /// **Experimental.** This API is part of an experimental wire-protocol surface
9614 /// and may change or be removed in future SDK or CLI releases. Pin both the
9615 /// SDK and CLI versions if your code depends on it.
9616 ///
9617 /// </div>
9618 pub async fn get_enforcement_status(&self) -> Result<SandboxEnforcementStatus, Error> {
9619 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9620 let _value = self
9621 .session
9622 .client()
9623 .call(
9624 rpc_methods::SESSION_SANDBOX_GETENFORCEMENTSTATUS,
9625 Some(wire_params),
9626 )
9627 .await?;
9628 Ok(serde_json::from_value(_value)?)
9629 }
9630}
9631
9632/// `session.schedule.*` RPCs.
9633#[derive(Clone, Copy)]
9634pub struct SessionRpcSchedule<'a> {
9635 pub(crate) session: &'a Session,
9636}
9637
9638impl<'a> SessionRpcSchedule<'a> {
9639 /// Lists the session's currently active scheduled prompts.
9640 ///
9641 /// Wire method: `session.schedule.list`.
9642 ///
9643 /// # Returns
9644 ///
9645 /// Snapshot of the currently active recurring prompts for this session.
9646 ///
9647 /// <div class="warning">
9648 ///
9649 /// **Experimental.** This API is part of an experimental wire-protocol surface
9650 /// and may change or be removed in future SDK or CLI releases. Pin both the
9651 /// SDK and CLI versions if your code depends on it.
9652 ///
9653 /// </div>
9654 pub async fn list(&self) -> Result<ScheduleList, Error> {
9655 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9656 let _value = self
9657 .session
9658 .client()
9659 .call(rpc_methods::SESSION_SCHEDULE_LIST, Some(wire_params))
9660 .await?;
9661 Ok(serde_json::from_value(_value)?)
9662 }
9663
9664 /// Hydrates the native schedule registry from persisted session events.
9665 ///
9666 /// Wire method: `session.schedule.hydrate`.
9667 ///
9668 /// <div class="warning">
9669 ///
9670 /// **Experimental.** This API is part of an experimental wire-protocol surface
9671 /// and may change or be removed in future SDK or CLI releases. Pin both the
9672 /// SDK and CLI versions if your code depends on it.
9673 ///
9674 /// </div>
9675 pub(crate) async fn hydrate(&self) -> Result<(), Error> {
9676 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9677 let _value = self
9678 .session
9679 .client()
9680 .call(rpc_methods::SESSION_SCHEDULE_HYDRATE, Some(wire_params))
9681 .await?;
9682 Ok(())
9683 }
9684
9685 /// Reports whether the session has an active self-paced scheduled prompt.
9686 ///
9687 /// Wire method: `session.schedule.hasSelfPaced`.
9688 ///
9689 /// # Returns
9690 ///
9691 /// Whether the session currently has an active self-paced schedule.
9692 ///
9693 /// <div class="warning">
9694 ///
9695 /// **Experimental.** This API is part of an experimental wire-protocol surface
9696 /// and may change or be removed in future SDK or CLI releases. Pin both the
9697 /// SDK and CLI versions if your code depends on it.
9698 ///
9699 /// </div>
9700 pub(crate) async fn has_self_paced(&self) -> Result<ScheduleHasSelfPacedResult, Error> {
9701 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9702 let _value = self
9703 .session
9704 .client()
9705 .call(
9706 rpc_methods::SESSION_SCHEDULE_HASSELFPACED,
9707 Some(wire_params),
9708 )
9709 .await?;
9710 Ok(serde_json::from_value(_value)?)
9711 }
9712
9713 /// Registers a relative-interval scheduled prompt.
9714 ///
9715 /// Wire method: `session.schedule.add`.
9716 ///
9717 /// # Parameters
9718 ///
9719 /// * `params` - Register a relative-interval scheduled prompt.
9720 ///
9721 /// # Returns
9722 ///
9723 /// Result of registering or re-arming a scheduled prompt.
9724 ///
9725 /// <div class="warning">
9726 ///
9727 /// **Experimental.** This API is part of an experimental wire-protocol surface
9728 /// and may change or be removed in future SDK or CLI releases. Pin both the
9729 /// SDK and CLI versions if your code depends on it.
9730 ///
9731 /// </div>
9732 pub(crate) async fn add(&self, params: ScheduleAddRequest) -> Result<ScheduleAddResult, Error> {
9733 let mut wire_params = serde_json::to_value(params)?;
9734 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9735 let _value = self
9736 .session
9737 .client()
9738 .call(rpc_methods::SESSION_SCHEDULE_ADD, Some(wire_params))
9739 .await?;
9740 Ok(serde_json::from_value(_value)?)
9741 }
9742
9743 /// Registers a recurring cron scheduled prompt.
9744 ///
9745 /// Wire method: `session.schedule.addCron`.
9746 ///
9747 /// # Parameters
9748 ///
9749 /// * `params` - Register a cron scheduled prompt.
9750 ///
9751 /// # Returns
9752 ///
9753 /// Result of registering or re-arming a scheduled prompt.
9754 ///
9755 /// <div class="warning">
9756 ///
9757 /// **Experimental.** This API is part of an experimental wire-protocol surface
9758 /// and may change or be removed in future SDK or CLI releases. Pin both the
9759 /// SDK and CLI versions if your code depends on it.
9760 ///
9761 /// </div>
9762 pub(crate) async fn add_cron(
9763 &self,
9764 params: ScheduleAddCronRequest,
9765 ) -> Result<ScheduleAddResult, Error> {
9766 let mut wire_params = serde_json::to_value(params)?;
9767 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9768 let _value = self
9769 .session
9770 .client()
9771 .call(rpc_methods::SESSION_SCHEDULE_ADDCRON, Some(wire_params))
9772 .await?;
9773 Ok(serde_json::from_value(_value)?)
9774 }
9775
9776 /// Registers an absolute-time scheduled prompt.
9777 ///
9778 /// Wire method: `session.schedule.addAt`.
9779 ///
9780 /// # Parameters
9781 ///
9782 /// * `params` - Register an absolute-time scheduled prompt.
9783 ///
9784 /// # Returns
9785 ///
9786 /// Result of registering or re-arming a scheduled prompt.
9787 ///
9788 /// <div class="warning">
9789 ///
9790 /// **Experimental.** This API is part of an experimental wire-protocol surface
9791 /// and may change or be removed in future SDK or CLI releases. Pin both the
9792 /// SDK and CLI versions if your code depends on it.
9793 ///
9794 /// </div>
9795 pub(crate) async fn add_at(
9796 &self,
9797 params: ScheduleAddAtRequest,
9798 ) -> Result<ScheduleAddResult, Error> {
9799 let mut wire_params = serde_json::to_value(params)?;
9800 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9801 let _value = self
9802 .session
9803 .client()
9804 .call(rpc_methods::SESSION_SCHEDULE_ADDAT, Some(wire_params))
9805 .await?;
9806 Ok(serde_json::from_value(_value)?)
9807 }
9808
9809 /// Registers a self-paced scheduled prompt.
9810 ///
9811 /// Wire method: `session.schedule.addSelfPaced`.
9812 ///
9813 /// # Parameters
9814 ///
9815 /// * `params` - Register a self-paced scheduled prompt.
9816 ///
9817 /// # Returns
9818 ///
9819 /// Result of registering or re-arming a scheduled prompt.
9820 ///
9821 /// <div class="warning">
9822 ///
9823 /// **Experimental.** This API is part of an experimental wire-protocol surface
9824 /// and may change or be removed in future SDK or CLI releases. Pin both the
9825 /// SDK and CLI versions if your code depends on it.
9826 ///
9827 /// </div>
9828 pub(crate) async fn add_self_paced(
9829 &self,
9830 params: ScheduleAddSelfPacedRequest,
9831 ) -> Result<ScheduleAddResult, Error> {
9832 let mut wire_params = serde_json::to_value(params)?;
9833 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9834 let _value = self
9835 .session
9836 .client()
9837 .call(
9838 rpc_methods::SESSION_SCHEDULE_ADDSELFPACED,
9839 Some(wire_params),
9840 )
9841 .await?;
9842 Ok(serde_json::from_value(_value)?)
9843 }
9844
9845 /// Re-arms an active self-paced scheduled prompt.
9846 ///
9847 /// Wire method: `session.schedule.rearmSelfPaced`.
9848 ///
9849 /// # Parameters
9850 ///
9851 /// * `params` - Re-arm a self-paced scheduled prompt.
9852 ///
9853 /// # Returns
9854 ///
9855 /// Result of registering or re-arming a scheduled prompt.
9856 ///
9857 /// <div class="warning">
9858 ///
9859 /// **Experimental.** This API is part of an experimental wire-protocol surface
9860 /// and may change or be removed in future SDK or CLI releases. Pin both the
9861 /// SDK and CLI versions if your code depends on it.
9862 ///
9863 /// </div>
9864 pub(crate) async fn rearm_self_paced(
9865 &self,
9866 params: ScheduleRearmSelfPacedRequest,
9867 ) -> Result<ScheduleAddResult, Error> {
9868 let mut wire_params = serde_json::to_value(params)?;
9869 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9870 let _value = self
9871 .session
9872 .client()
9873 .call(
9874 rpc_methods::SESSION_SCHEDULE_REARMSELFPACED,
9875 Some(wire_params),
9876 )
9877 .await?;
9878 Ok(serde_json::from_value(_value)?)
9879 }
9880
9881 /// Removes a scheduled prompt by id.
9882 ///
9883 /// Wire method: `session.schedule.stop`.
9884 ///
9885 /// # Parameters
9886 ///
9887 /// * `params` - Identifier of the scheduled prompt to remove.
9888 ///
9889 /// # Returns
9890 ///
9891 /// Remove a scheduled prompt by id. The result entry is omitted if the id was unknown.
9892 ///
9893 /// <div class="warning">
9894 ///
9895 /// **Experimental.** This API is part of an experimental wire-protocol surface
9896 /// and may change or be removed in future SDK or CLI releases. Pin both the
9897 /// SDK and CLI versions if your code depends on it.
9898 ///
9899 /// </div>
9900 pub async fn stop(&self, params: ScheduleStopRequest) -> Result<ScheduleStopResult, Error> {
9901 let mut wire_params = serde_json::to_value(params)?;
9902 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9903 let _value = self
9904 .session
9905 .client()
9906 .call(rpc_methods::SESSION_SCHEDULE_STOP, Some(wire_params))
9907 .await?;
9908 Ok(serde_json::from_value(_value)?)
9909 }
9910}
9911
9912/// `session.settings.*` RPCs.
9913#[derive(Clone, Copy)]
9914pub struct SessionRpcSettings<'a> {
9915 pub(crate) session: &'a Session,
9916}
9917
9918impl<'a> SessionRpcSettings<'a> {
9919 /// 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.
9920 ///
9921 /// Wire method: `session.settings.snapshot`.
9922 ///
9923 /// # Returns
9924 ///
9925 /// Redacted, serializable view of session runtime settings for SDK boundary consumers. Secrets and raw feature flags are intentionally excluded.
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(crate) async fn snapshot(&self) -> Result<SessionSettingsSnapshot, Error> {
9935 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9936 let _value = self
9937 .session
9938 .client()
9939 .call(rpc_methods::SESSION_SETTINGS_SNAPSHOT, Some(wire_params))
9940 .await?;
9941 Ok(serde_json::from_value(_value)?)
9942 }
9943
9944 /// 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.
9945 ///
9946 /// Wire method: `session.settings.evaluatePredicate`.
9947 ///
9948 /// # Parameters
9949 ///
9950 /// * `params` - Named Rust-owned settings predicate to evaluate for this session.
9951 ///
9952 /// # Returns
9953 ///
9954 /// Result of evaluating a Rust-owned settings predicate.
9955 ///
9956 /// <div class="warning">
9957 ///
9958 /// **Experimental.** This API is part of an experimental wire-protocol surface
9959 /// and may change or be removed in future SDK or CLI releases. Pin both the
9960 /// SDK and CLI versions if your code depends on it.
9961 ///
9962 /// </div>
9963 pub(crate) async fn evaluate_predicate(
9964 &self,
9965 params: SessionSettingsEvaluatePredicateRequest,
9966 ) -> Result<SessionSettingsEvaluatePredicateResult, Error> {
9967 let mut wire_params = serde_json::to_value(params)?;
9968 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9969 let _value = self
9970 .session
9971 .client()
9972 .call(
9973 rpc_methods::SESSION_SETTINGS_EVALUATEPREDICATE,
9974 Some(wire_params),
9975 )
9976 .await?;
9977 Ok(serde_json::from_value(_value)?)
9978 }
9979}
9980
9981/// `session.shell.*` RPCs.
9982#[derive(Clone, Copy)]
9983pub struct SessionRpcShell<'a> {
9984 pub(crate) session: &'a Session,
9985}
9986
9987impl<'a> SessionRpcShell<'a> {
9988 /// 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.
9989 ///
9990 /// Wire method: `session.shell.exec`.
9991 ///
9992 /// # Parameters
9993 ///
9994 /// * `params` - Shell command to run, with optional working directory and timeout in milliseconds.
9995 ///
9996 /// # Returns
9997 ///
9998 /// Identifier of the spawned process, used to correlate streamed output and exit notifications.
9999 ///
10000 /// <div class="warning">
10001 ///
10002 /// **Experimental.** This API is part of an experimental wire-protocol surface
10003 /// and may change or be removed in future SDK or CLI releases. Pin both the
10004 /// SDK and CLI versions if your code depends on it.
10005 ///
10006 /// </div>
10007 pub async fn exec(&self, params: ShellExecRequest) -> Result<ShellExecResult, Error> {
10008 let mut wire_params = serde_json::to_value(params)?;
10009 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10010 let _value = self
10011 .session
10012 .client()
10013 .call(rpc_methods::SESSION_SHELL_EXEC, Some(wire_params))
10014 .await?;
10015 Ok(serde_json::from_value(_value)?)
10016 }
10017
10018 /// 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.
10019 ///
10020 /// Wire method: `session.shell.kill`.
10021 ///
10022 /// # Parameters
10023 ///
10024 /// * `params` - Identifier of a process previously returned by "shell.exec" and the signal to send.
10025 ///
10026 /// # Returns
10027 ///
10028 /// Indicates whether the signal was delivered; false if the process was unknown or already exited.
10029 ///
10030 /// <div class="warning">
10031 ///
10032 /// **Experimental.** This API is part of an experimental wire-protocol surface
10033 /// and may change or be removed in future SDK or CLI releases. Pin both the
10034 /// SDK and CLI versions if your code depends on it.
10035 ///
10036 /// </div>
10037 pub async fn kill(&self, params: ShellKillRequest) -> Result<ShellKillResult, Error> {
10038 let mut wire_params = serde_json::to_value(params)?;
10039 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10040 let _value = self
10041 .session
10042 .client()
10043 .call(rpc_methods::SESSION_SHELL_KILL, Some(wire_params))
10044 .await?;
10045 Ok(serde_json::from_value(_value)?)
10046 }
10047
10048 /// Executes a user-requested shell command through the session runtime.
10049 ///
10050 /// Wire method: `session.shell.executeUserRequested`.
10051 ///
10052 /// # Parameters
10053 ///
10054 /// * `params` - User-requested shell command and cancellation handle.
10055 ///
10056 /// # Returns
10057 ///
10058 /// Result of a user-requested shell command.
10059 ///
10060 /// <div class="warning">
10061 ///
10062 /// **Experimental.** This API is part of an experimental wire-protocol surface
10063 /// and may change or be removed in future SDK or CLI releases. Pin both the
10064 /// SDK and CLI versions if your code depends on it.
10065 ///
10066 /// </div>
10067 pub async fn execute_user_requested(
10068 &self,
10069 params: ShellExecuteUserRequestedRequest,
10070 ) -> Result<UserRequestedShellCommandResult, Error> {
10071 let mut wire_params = serde_json::to_value(params)?;
10072 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10073 let _value = self
10074 .session
10075 .client()
10076 .call(
10077 rpc_methods::SESSION_SHELL_EXECUTEUSERREQUESTED,
10078 Some(wire_params),
10079 )
10080 .await?;
10081 Ok(serde_json::from_value(_value)?)
10082 }
10083
10084 /// Cancels a user-requested shell command by request ID.
10085 ///
10086 /// Wire method: `session.shell.cancelUserRequested`.
10087 ///
10088 /// # Parameters
10089 ///
10090 /// * `params` - User-requested shell execution cancellation handle.
10091 ///
10092 /// # Returns
10093 ///
10094 /// Cancellation result for a user-requested shell command.
10095 ///
10096 /// <div class="warning">
10097 ///
10098 /// **Experimental.** This API is part of an experimental wire-protocol surface
10099 /// and may change or be removed in future SDK or CLI releases. Pin both the
10100 /// SDK and CLI versions if your code depends on it.
10101 ///
10102 /// </div>
10103 pub async fn cancel_user_requested(
10104 &self,
10105 params: ShellCancelUserRequestedRequest,
10106 ) -> Result<CancelUserRequestedShellCommandResult, Error> {
10107 let mut wire_params = serde_json::to_value(params)?;
10108 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10109 let _value = self
10110 .session
10111 .client()
10112 .call(
10113 rpc_methods::SESSION_SHELL_CANCELUSERREQUESTED,
10114 Some(wire_params),
10115 )
10116 .await?;
10117 Ok(serde_json::from_value(_value)?)
10118 }
10119}
10120
10121/// `session.skills.*` RPCs.
10122#[derive(Clone, Copy)]
10123pub struct SessionRpcSkills<'a> {
10124 pub(crate) session: &'a Session,
10125}
10126
10127impl<'a> SessionRpcSkills<'a> {
10128 /// Lists skills available to the session.
10129 ///
10130 /// Wire method: `session.skills.list`.
10131 ///
10132 /// # Returns
10133 ///
10134 /// Skills available to the session, with their enabled state.
10135 ///
10136 /// <div class="warning">
10137 ///
10138 /// **Experimental.** This API is part of an experimental wire-protocol surface
10139 /// and may change or be removed in future SDK or CLI releases. Pin both the
10140 /// SDK and CLI versions if your code depends on it.
10141 ///
10142 /// </div>
10143 pub async fn list(&self) -> Result<SkillList, Error> {
10144 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10145 let _value = self
10146 .session
10147 .client()
10148 .call(rpc_methods::SESSION_SKILLS_LIST, Some(wire_params))
10149 .await?;
10150 Ok(serde_json::from_value(_value)?)
10151 }
10152
10153 /// Returns the skills that have been invoked during this session.
10154 ///
10155 /// Wire method: `session.skills.getInvoked`.
10156 ///
10157 /// # Returns
10158 ///
10159 /// Skills invoked during this session, ordered by invocation time (most recent last).
10160 ///
10161 /// <div class="warning">
10162 ///
10163 /// **Experimental.** This API is part of an experimental wire-protocol surface
10164 /// and may change or be removed in future SDK or CLI releases. Pin both the
10165 /// SDK and CLI versions if your code depends on it.
10166 ///
10167 /// </div>
10168 pub async fn get_invoked(&self) -> Result<SkillsGetInvokedResult, Error> {
10169 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10170 let _value = self
10171 .session
10172 .client()
10173 .call(rpc_methods::SESSION_SKILLS_GETINVOKED, Some(wire_params))
10174 .await?;
10175 Ok(serde_json::from_value(_value)?)
10176 }
10177
10178 /// Enables a skill for the session.
10179 ///
10180 /// Wire method: `session.skills.enable`.
10181 ///
10182 /// # Parameters
10183 ///
10184 /// * `params` - Name of the skill to enable for the session.
10185 ///
10186 /// <div class="warning">
10187 ///
10188 /// **Experimental.** This API is part of an experimental wire-protocol surface
10189 /// and may change or be removed in future SDK or CLI releases. Pin both the
10190 /// SDK and CLI versions if your code depends on it.
10191 ///
10192 /// </div>
10193 pub async fn enable(&self, params: SkillsEnableRequest) -> Result<(), Error> {
10194 let mut wire_params = serde_json::to_value(params)?;
10195 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10196 let _value = self
10197 .session
10198 .client()
10199 .call(rpc_methods::SESSION_SKILLS_ENABLE, Some(wire_params))
10200 .await?;
10201 Ok(())
10202 }
10203
10204 /// Disables a skill for the session.
10205 ///
10206 /// Wire method: `session.skills.disable`.
10207 ///
10208 /// # Parameters
10209 ///
10210 /// * `params` - Name of the skill to disable for the session.
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 disable(&self, params: SkillsDisableRequest) -> Result<(), Error> {
10220 let mut wire_params = serde_json::to_value(params)?;
10221 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10222 let _value = self
10223 .session
10224 .client()
10225 .call(rpc_methods::SESSION_SKILLS_DISABLE, Some(wire_params))
10226 .await?;
10227 Ok(())
10228 }
10229
10230 /// Reloads skill definitions for the session.
10231 ///
10232 /// Wire method: `session.skills.reload`.
10233 ///
10234 /// # Returns
10235 ///
10236 /// Diagnostics from reloading skill definitions, with warnings and errors as separate lists.
10237 ///
10238 /// <div class="warning">
10239 ///
10240 /// **Experimental.** This API is part of an experimental wire-protocol surface
10241 /// and may change or be removed in future SDK or CLI releases. Pin both the
10242 /// SDK and CLI versions if your code depends on it.
10243 ///
10244 /// </div>
10245 pub async fn reload(&self) -> Result<SkillsLoadDiagnostics, Error> {
10246 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10247 let _value = self
10248 .session
10249 .client()
10250 .call(rpc_methods::SESSION_SKILLS_RELOAD, Some(wire_params))
10251 .await?;
10252 Ok(serde_json::from_value(_value)?)
10253 }
10254
10255 /// Ensures the session's skill definitions have been loaded from disk.
10256 ///
10257 /// Wire method: `session.skills.ensureLoaded`.
10258 ///
10259 /// <div class="warning">
10260 ///
10261 /// **Experimental.** This API is part of an experimental wire-protocol surface
10262 /// and may change or be removed in future SDK or CLI releases. Pin both the
10263 /// SDK and CLI versions if your code depends on it.
10264 ///
10265 /// </div>
10266 pub async fn ensure_loaded(&self) -> Result<(), Error> {
10267 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10268 let _value = self
10269 .session
10270 .client()
10271 .call(rpc_methods::SESSION_SKILLS_ENSURELOADED, Some(wire_params))
10272 .await?;
10273 Ok(())
10274 }
10275}
10276
10277/// `session.tasks.*` RPCs.
10278#[derive(Clone, Copy)]
10279pub struct SessionRpcTasks<'a> {
10280 pub(crate) session: &'a Session,
10281}
10282
10283impl<'a> SessionRpcTasks<'a> {
10284 /// Starts a background agent task in the session.
10285 ///
10286 /// Wire method: `session.tasks.startAgent`.
10287 ///
10288 /// # Parameters
10289 ///
10290 /// * `params` - Agent type, prompt, name, and optional description and model override for the new task.
10291 ///
10292 /// # Returns
10293 ///
10294 /// Identifier assigned to the newly started background agent task.
10295 ///
10296 /// <div class="warning">
10297 ///
10298 /// **Experimental.** This API is part of an experimental wire-protocol surface
10299 /// and may change or be removed in future SDK or CLI releases. Pin both the
10300 /// SDK and CLI versions if your code depends on it.
10301 ///
10302 /// </div>
10303 pub async fn start_agent(
10304 &self,
10305 params: TasksStartAgentRequest,
10306 ) -> Result<TasksStartAgentResult, Error> {
10307 let mut wire_params = serde_json::to_value(params)?;
10308 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10309 let _value = self
10310 .session
10311 .client()
10312 .call(rpc_methods::SESSION_TASKS_STARTAGENT, Some(wire_params))
10313 .await?;
10314 Ok(serde_json::from_value(_value)?)
10315 }
10316
10317 /// Lists background tasks tracked by the session.
10318 ///
10319 /// Wire method: `session.tasks.list`.
10320 ///
10321 /// # Returns
10322 ///
10323 /// Background tasks currently tracked by the session.
10324 ///
10325 /// <div class="warning">
10326 ///
10327 /// **Experimental.** This API is part of an experimental wire-protocol surface
10328 /// and may change or be removed in future SDK or CLI releases. Pin both the
10329 /// SDK and CLI versions if your code depends on it.
10330 ///
10331 /// </div>
10332 pub async fn list(&self) -> Result<TaskList, Error> {
10333 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10334 let _value = self
10335 .session
10336 .client()
10337 .call(rpc_methods::SESSION_TASKS_LIST, Some(wire_params))
10338 .await?;
10339 Ok(serde_json::from_value(_value)?)
10340 }
10341
10342 /// Registers a client-owned task, or reclaims an orphaned task belonging to the same extension principal.
10343 ///
10344 /// Wire method: `session.tasks.register`.
10345 ///
10346 /// # Parameters
10347 ///
10348 /// * `params` - Registers or reclaims a client-owned task.
10349 ///
10350 /// # Returns
10351 ///
10352 /// Result of registering or reclaiming a client-owned task.
10353 ///
10354 /// <div class="warning">
10355 ///
10356 /// **Experimental.** This API is part of an experimental wire-protocol surface
10357 /// and may change or be removed in future SDK or CLI releases. Pin both the
10358 /// SDK and CLI versions if your code depends on it.
10359 ///
10360 /// </div>
10361 pub async fn register(
10362 &self,
10363 params: TasksRegisterRequest,
10364 ) -> Result<TasksRegisterResult, Error> {
10365 let mut wire_params = serde_json::to_value(params)?;
10366 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10367 let _value = self
10368 .session
10369 .client()
10370 .call(rpc_methods::SESSION_TASKS_REGISTER, Some(wire_params))
10371 .await?;
10372 Ok(serde_json::from_value(_value)?)
10373 }
10374
10375 /// Publishes generic progress or a terminal outcome for a client-owned task.
10376 ///
10377 /// Wire method: `session.tasks.update`.
10378 ///
10379 /// # Parameters
10380 ///
10381 /// * `params` - Updates a client-owned task.
10382 ///
10383 /// # Returns
10384 ///
10385 /// Result of publishing a client-owned task update.
10386 ///
10387 /// <div class="warning">
10388 ///
10389 /// **Experimental.** This API is part of an experimental wire-protocol surface
10390 /// and may change or be removed in future SDK or CLI releases. Pin both the
10391 /// SDK and CLI versions if your code depends on it.
10392 ///
10393 /// </div>
10394 pub async fn update(&self, params: TasksUpdateRequest) -> Result<TasksUpdateResult, Error> {
10395 let mut wire_params = serde_json::to_value(params)?;
10396 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10397 let _value = self
10398 .session
10399 .client()
10400 .call(rpc_methods::SESSION_TASKS_UPDATE, Some(wire_params))
10401 .await?;
10402 Ok(serde_json::from_value(_value)?)
10403 }
10404
10405 /// Refreshes metadata for any detached background shells the runtime knows about.
10406 ///
10407 /// Wire method: `session.tasks.refresh`.
10408 ///
10409 /// # Returns
10410 ///
10411 /// 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.
10412 ///
10413 /// <div class="warning">
10414 ///
10415 /// **Experimental.** This API is part of an experimental wire-protocol surface
10416 /// and may change or be removed in future SDK or CLI releases. Pin both the
10417 /// SDK and CLI versions if your code depends on it.
10418 ///
10419 /// </div>
10420 pub async fn refresh(&self) -> Result<TasksRefreshResult, Error> {
10421 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10422 let _value = self
10423 .session
10424 .client()
10425 .call(rpc_methods::SESSION_TASKS_REFRESH, Some(wire_params))
10426 .await?;
10427 Ok(serde_json::from_value(_value)?)
10428 }
10429
10430 /// Waits for all in-flight background tasks and any follow-up turns to settle.
10431 ///
10432 /// Wire method: `session.tasks.waitForPending`.
10433 ///
10434 /// # Returns
10435 ///
10436 /// 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).
10437 ///
10438 /// <div class="warning">
10439 ///
10440 /// **Experimental.** This API is part of an experimental wire-protocol surface
10441 /// and may change or be removed in future SDK or CLI releases. Pin both the
10442 /// SDK and CLI versions if your code depends on it.
10443 ///
10444 /// </div>
10445 pub async fn wait_for_pending(&self) -> Result<TasksWaitForPendingResult, Error> {
10446 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10447 let _value = self
10448 .session
10449 .client()
10450 .call(rpc_methods::SESSION_TASKS_WAITFORPENDING, Some(wire_params))
10451 .await?;
10452 Ok(serde_json::from_value(_value)?)
10453 }
10454
10455 /// Returns progress information for a background task by ID.
10456 ///
10457 /// Wire method: `session.tasks.getProgress`.
10458 ///
10459 /// # Parameters
10460 ///
10461 /// * `params` - Identifier of the background task to fetch progress for.
10462 ///
10463 /// # Returns
10464 ///
10465 /// Progress information for the task, or null when no task with that ID is tracked.
10466 ///
10467 /// <div class="warning">
10468 ///
10469 /// **Experimental.** This API is part of an experimental wire-protocol surface
10470 /// and may change or be removed in future SDK or CLI releases. Pin both the
10471 /// SDK and CLI versions if your code depends on it.
10472 ///
10473 /// </div>
10474 pub async fn get_progress(
10475 &self,
10476 params: TasksGetProgressRequest,
10477 ) -> Result<TasksGetProgressResult, Error> {
10478 let mut wire_params = serde_json::to_value(params)?;
10479 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10480 let _value = self
10481 .session
10482 .client()
10483 .call(rpc_methods::SESSION_TASKS_GETPROGRESS, Some(wire_params))
10484 .await?;
10485 Ok(serde_json::from_value(_value)?)
10486 }
10487
10488 /// Returns the first sync-waiting task that can currently be promoted to background mode.
10489 ///
10490 /// Wire method: `session.tasks.getCurrentPromotable`.
10491 ///
10492 /// # Returns
10493 ///
10494 /// The first sync-waiting task that can currently be promoted to background mode.
10495 ///
10496 /// <div class="warning">
10497 ///
10498 /// **Experimental.** This API is part of an experimental wire-protocol surface
10499 /// and may change or be removed in future SDK or CLI releases. Pin both the
10500 /// SDK and CLI versions if your code depends on it.
10501 ///
10502 /// </div>
10503 pub async fn get_current_promotable(&self) -> Result<TasksGetCurrentPromotableResult, Error> {
10504 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10505 let _value = self
10506 .session
10507 .client()
10508 .call(
10509 rpc_methods::SESSION_TASKS_GETCURRENTPROMOTABLE,
10510 Some(wire_params),
10511 )
10512 .await?;
10513 Ok(serde_json::from_value(_value)?)
10514 }
10515
10516 /// Promotes an eligible synchronously-waited task so it continues running in the background.
10517 ///
10518 /// Wire method: `session.tasks.promoteToBackground`.
10519 ///
10520 /// # Parameters
10521 ///
10522 /// * `params` - Identifier of the task to promote to background mode.
10523 ///
10524 /// # Returns
10525 ///
10526 /// Indicates whether the task was successfully promoted to background mode.
10527 ///
10528 /// <div class="warning">
10529 ///
10530 /// **Experimental.** This API is part of an experimental wire-protocol surface
10531 /// and may change or be removed in future SDK or CLI releases. Pin both the
10532 /// SDK and CLI versions if your code depends on it.
10533 ///
10534 /// </div>
10535 pub async fn promote_to_background(
10536 &self,
10537 params: TasksPromoteToBackgroundRequest,
10538 ) -> Result<TasksPromoteToBackgroundResult, Error> {
10539 let mut wire_params = serde_json::to_value(params)?;
10540 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10541 let _value = self
10542 .session
10543 .client()
10544 .call(
10545 rpc_methods::SESSION_TASKS_PROMOTETOBACKGROUND,
10546 Some(wire_params),
10547 )
10548 .await?;
10549 Ok(serde_json::from_value(_value)?)
10550 }
10551
10552 /// Atomically promotes the first promotable sync-waiting task to background mode and returns it.
10553 ///
10554 /// Wire method: `session.tasks.promoteCurrentToBackground`.
10555 ///
10556 /// # Returns
10557 ///
10558 /// The promoted task as it now exists in background mode, omitted if no promotable task was waiting.
10559 ///
10560 /// <div class="warning">
10561 ///
10562 /// **Experimental.** This API is part of an experimental wire-protocol surface
10563 /// and may change or be removed in future SDK or CLI releases. Pin both the
10564 /// SDK and CLI versions if your code depends on it.
10565 ///
10566 /// </div>
10567 pub async fn promote_current_to_background(
10568 &self,
10569 ) -> Result<TasksPromoteCurrentToBackgroundResult, Error> {
10570 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10571 let _value = self
10572 .session
10573 .client()
10574 .call(
10575 rpc_methods::SESSION_TASKS_PROMOTECURRENTTOBACKGROUND,
10576 Some(wire_params),
10577 )
10578 .await?;
10579 Ok(serde_json::from_value(_value)?)
10580 }
10581
10582 /// Cancels a background task.
10583 ///
10584 /// Wire method: `session.tasks.cancel`.
10585 ///
10586 /// # Parameters
10587 ///
10588 /// * `params` - Identifier of the background task to cancel.
10589 ///
10590 /// # Returns
10591 ///
10592 /// Indicates whether the background task was successfully cancelled.
10593 ///
10594 /// <div class="warning">
10595 ///
10596 /// **Experimental.** This API is part of an experimental wire-protocol surface
10597 /// and may change or be removed in future SDK or CLI releases. Pin both the
10598 /// SDK and CLI versions if your code depends on it.
10599 ///
10600 /// </div>
10601 pub async fn cancel(&self, params: TasksCancelRequest) -> Result<TasksCancelResult, Error> {
10602 let mut wire_params = serde_json::to_value(params)?;
10603 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10604 let _value = self
10605 .session
10606 .client()
10607 .call(rpc_methods::SESSION_TASKS_CANCEL, Some(wire_params))
10608 .await?;
10609 Ok(serde_json::from_value(_value)?)
10610 }
10611
10612 /// Removes a completed or cancelled background task from tracking.
10613 ///
10614 /// Wire method: `session.tasks.remove`.
10615 ///
10616 /// # Parameters
10617 ///
10618 /// * `params` - Identifier of the completed or cancelled task to remove from tracking.
10619 ///
10620 /// # Returns
10621 ///
10622 /// Indicates whether the task was removed. False when the task does not exist or is still running/idle.
10623 ///
10624 /// <div class="warning">
10625 ///
10626 /// **Experimental.** This API is part of an experimental wire-protocol surface
10627 /// and may change or be removed in future SDK or CLI releases. Pin both the
10628 /// SDK and CLI versions if your code depends on it.
10629 ///
10630 /// </div>
10631 pub async fn remove(&self, params: TasksRemoveRequest) -> Result<TasksRemoveResult, Error> {
10632 let mut wire_params = serde_json::to_value(params)?;
10633 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10634 let _value = self
10635 .session
10636 .client()
10637 .call(rpc_methods::SESSION_TASKS_REMOVE, Some(wire_params))
10638 .await?;
10639 Ok(serde_json::from_value(_value)?)
10640 }
10641
10642 /// Sends a message to a background agent task.
10643 ///
10644 /// Wire method: `session.tasks.sendMessage`.
10645 ///
10646 /// # Parameters
10647 ///
10648 /// * `params` - Identifier of the target agent task, message content, and optional sender agent ID.
10649 ///
10650 /// # Returns
10651 ///
10652 /// Indicates whether the message was delivered, with an error message when delivery failed.
10653 ///
10654 /// <div class="warning">
10655 ///
10656 /// **Experimental.** This API is part of an experimental wire-protocol surface
10657 /// and may change or be removed in future SDK or CLI releases. Pin both the
10658 /// SDK and CLI versions if your code depends on it.
10659 ///
10660 /// </div>
10661 pub async fn send_message(
10662 &self,
10663 params: TasksSendMessageRequest,
10664 ) -> Result<TasksSendMessageResult, Error> {
10665 let mut wire_params = serde_json::to_value(params)?;
10666 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10667 let _value = self
10668 .session
10669 .client()
10670 .call(rpc_methods::SESSION_TASKS_SENDMESSAGE, Some(wire_params))
10671 .await?;
10672 Ok(serde_json::from_value(_value)?)
10673 }
10674}
10675
10676/// `session.telemetry.*` RPCs.
10677#[derive(Clone, Copy)]
10678pub struct SessionRpcTelemetry<'a> {
10679 pub(crate) session: &'a Session,
10680}
10681
10682impl<'a> SessionRpcTelemetry<'a> {
10683 /// Gets the telemetry engagement ID currently associated with the session, when available.
10684 ///
10685 /// Wire method: `session.telemetry.getEngagementId`.
10686 ///
10687 /// # Returns
10688 ///
10689 /// Telemetry engagement ID for the session, when available.
10690 ///
10691 /// <div class="warning">
10692 ///
10693 /// **Experimental.** This API is part of an experimental wire-protocol surface
10694 /// and may change or be removed in future SDK or CLI releases. Pin both the
10695 /// SDK and CLI versions if your code depends on it.
10696 ///
10697 /// </div>
10698 pub async fn get_engagement_id(&self) -> Result<SessionTelemetryEngagement, Error> {
10699 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10700 let _value = self
10701 .session
10702 .client()
10703 .call(
10704 rpc_methods::SESSION_TELEMETRY_GETENGAGEMENTID,
10705 Some(wire_params),
10706 )
10707 .await?;
10708 Ok(serde_json::from_value(_value)?)
10709 }
10710
10711 /// Sets feature override key/value pairs to attach to subsequent telemetry events for the session.
10712 ///
10713 /// Wire method: `session.telemetry.setFeatureOverrides`.
10714 ///
10715 /// # Parameters
10716 ///
10717 /// * `params` - Feature override key/value pairs to attach to subsequent telemetry events from this session.
10718 ///
10719 /// <div class="warning">
10720 ///
10721 /// **Experimental.** This API is part of an experimental wire-protocol surface
10722 /// and may change or be removed in future SDK or CLI releases. Pin both the
10723 /// SDK and CLI versions if your code depends on it.
10724 ///
10725 /// </div>
10726 pub async fn set_feature_overrides(
10727 &self,
10728 params: TelemetrySetFeatureOverridesRequest,
10729 ) -> Result<(), Error> {
10730 let mut wire_params = serde_json::to_value(params)?;
10731 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10732 let _value = self
10733 .session
10734 .client()
10735 .call(
10736 rpc_methods::SESSION_TELEMETRY_SETFEATUREOVERRIDES,
10737 Some(wire_params),
10738 )
10739 .await?;
10740 Ok(())
10741 }
10742}
10743
10744/// `session.tools.*` RPCs.
10745#[derive(Clone, Copy)]
10746pub struct SessionRpcTools<'a> {
10747 pub(crate) session: &'a Session,
10748}
10749
10750impl<'a> SessionRpcTools<'a> {
10751 /// Executes one tool from the session's currently offered tool set through the native invocation pipeline.
10752 ///
10753 /// Wire method: `session.tools.execute`.
10754 ///
10755 /// # Parameters
10756 ///
10757 /// * `params` - A tool name and arguments to execute through the session's native invocation pipeline.
10758 ///
10759 /// # Returns
10760 ///
10761 /// Canonical result returned by a session tool.
10762 ///
10763 /// <div class="warning">
10764 ///
10765 /// **Experimental.** This API is part of an experimental wire-protocol surface
10766 /// and may change or be removed in future SDK or CLI releases. Pin both the
10767 /// SDK and CLI versions if your code depends on it.
10768 ///
10769 /// </div>
10770 pub async fn execute(&self, params: ToolsExecuteRequest) -> Result<ToolResult, Error> {
10771 let mut wire_params = serde_json::to_value(params)?;
10772 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10773 let _value = self
10774 .session
10775 .client()
10776 .call(rpc_methods::SESSION_TOOLS_EXECUTE, Some(wire_params))
10777 .await?;
10778 Ok(serde_json::from_value(_value)?)
10779 }
10780
10781 /// Returns the Rust-owned built-in tool descriptors used to construct the session's offered tool set.
10782 ///
10783 /// Wire method: `session.tools.getBuiltinDescriptors`.
10784 ///
10785 /// # Parameters
10786 ///
10787 /// * `params` - Options controlling how Rust-owned built-in tool descriptors are materialized.
10788 ///
10789 /// # Returns
10790 ///
10791 /// Rust-owned built-in tool descriptors for the session.
10792 ///
10793 /// <div class="warning">
10794 ///
10795 /// **Experimental.** This API is part of an experimental wire-protocol surface
10796 /// and may change or be removed in future SDK or CLI releases. Pin both the
10797 /// SDK and CLI versions if your code depends on it.
10798 ///
10799 /// </div>
10800 pub async fn get_builtin_descriptors(
10801 &self,
10802 params: ToolsGetBuiltinDescriptorsRequest,
10803 ) -> Result<ToolsGetBuiltinDescriptorsResult, Error> {
10804 let mut wire_params = serde_json::to_value(params)?;
10805 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10806 let _value = self
10807 .session
10808 .client()
10809 .call(
10810 rpc_methods::SESSION_TOOLS_GETBUILTINDESCRIPTORS,
10811 Some(wire_params),
10812 )
10813 .await?;
10814 Ok(serde_json::from_value(_value)?)
10815 }
10816
10817 /// Projects a completed task_complete tool call into its label-safe session event payload.
10818 ///
10819 /// Wire method: `session.tools.taskCompleteEventData`.
10820 ///
10821 /// # Parameters
10822 ///
10823 /// * `params` - Task-completion tool arguments and final result used to build a label-safe session event payload.
10824 ///
10825 /// # Returns
10826 ///
10827 /// Task completion notification with summary from the agent
10828 ///
10829 /// <div class="warning">
10830 ///
10831 /// **Experimental.** This API is part of an experimental wire-protocol surface
10832 /// and may change or be removed in future SDK or CLI releases. Pin both the
10833 /// SDK and CLI versions if your code depends on it.
10834 ///
10835 /// </div>
10836 pub async fn task_complete_event_data(
10837 &self,
10838 params: ToolsTaskCompleteEventDataRequest,
10839 ) -> Result<TaskCompleteData, Error> {
10840 let mut wire_params = serde_json::to_value(params)?;
10841 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10842 let _value = self
10843 .session
10844 .client()
10845 .call(
10846 rpc_methods::SESSION_TOOLS_TASKCOMPLETEEVENTDATA,
10847 Some(wire_params),
10848 )
10849 .await?;
10850 Ok(serde_json::from_value(_value)?)
10851 }
10852
10853 /// Provides the result for a pending external tool call.
10854 ///
10855 /// Wire method: `session.tools.handlePendingToolCall`.
10856 ///
10857 /// # Parameters
10858 ///
10859 /// * `params` - Pending external tool call request ID, with the tool result or an error describing why it failed.
10860 ///
10861 /// # Returns
10862 ///
10863 /// Indicates whether the external tool call result was handled successfully.
10864 ///
10865 /// <div class="warning">
10866 ///
10867 /// **Experimental.** This API is part of an experimental wire-protocol surface
10868 /// and may change or be removed in future SDK or CLI releases. Pin both the
10869 /// SDK and CLI versions if your code depends on it.
10870 ///
10871 /// </div>
10872 pub async fn handle_pending_tool_call(
10873 &self,
10874 params: HandlePendingToolCallRequest,
10875 ) -> Result<HandlePendingToolCallResult, Error> {
10876 let mut wire_params = serde_json::to_value(params)?;
10877 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10878 let _value = self
10879 .session
10880 .client()
10881 .call(
10882 rpc_methods::SESSION_TOOLS_HANDLEPENDINGTOOLCALL,
10883 Some(wire_params),
10884 )
10885 .await?;
10886 Ok(serde_json::from_value(_value)?)
10887 }
10888
10889 /// Resolves, builds, and validates the runtime tool list for the session.
10890 ///
10891 /// Wire method: `session.tools.initializeAndValidate`.
10892 ///
10893 /// # Returns
10894 ///
10895 /// 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.
10896 ///
10897 /// <div class="warning">
10898 ///
10899 /// **Experimental.** This API is part of an experimental wire-protocol surface
10900 /// and may change or be removed in future SDK or CLI releases. Pin both the
10901 /// SDK and CLI versions if your code depends on it.
10902 ///
10903 /// </div>
10904 pub async fn initialize_and_validate(&self) -> Result<ToolsInitializeAndValidateResult, Error> {
10905 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10906 let _value = self
10907 .session
10908 .client()
10909 .call(
10910 rpc_methods::SESSION_TOOLS_INITIALIZEANDVALIDATE,
10911 Some(wire_params),
10912 )
10913 .await?;
10914 Ok(serde_json::from_value(_value)?)
10915 }
10916
10917 /// Returns lightweight metadata for the session's currently initialized tools.
10918 ///
10919 /// Wire method: `session.tools.getCurrentMetadata`.
10920 ///
10921 /// # Returns
10922 ///
10923 /// Current lightweight tool metadata snapshot for the session.
10924 ///
10925 /// <div class="warning">
10926 ///
10927 /// **Experimental.** This API is part of an experimental wire-protocol surface
10928 /// and may change or be removed in future SDK or CLI releases. Pin both the
10929 /// SDK and CLI versions if your code depends on it.
10930 ///
10931 /// </div>
10932 pub async fn get_current_metadata(&self) -> Result<ToolsGetCurrentMetadataResult, Error> {
10933 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10934 let _value = self
10935 .session
10936 .client()
10937 .call(
10938 rpc_methods::SESSION_TOOLS_GETCURRENTMETADATA,
10939 Some(wire_params),
10940 )
10941 .await?;
10942 Ok(serde_json::from_value(_value)?)
10943 }
10944
10945 /// 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.
10946 ///
10947 /// Wire method: `session.tools.set`.
10948 ///
10949 /// # Parameters
10950 ///
10951 /// * `params` - Complete externally implemented tool list for the calling connection. An empty list removes every tool previously supplied by that connection.
10952 ///
10953 /// # Returns
10954 ///
10955 /// Empty result after replacing the calling connection's externally implemented tools.
10956 ///
10957 /// <div class="warning">
10958 ///
10959 /// **Experimental.** This API is part of an experimental wire-protocol surface
10960 /// and may change or be removed in future SDK or CLI releases. Pin both the
10961 /// SDK and CLI versions if your code depends on it.
10962 ///
10963 /// </div>
10964 pub async fn set(&self, params: ToolsSetRequest) -> Result<ToolsSetResult, Error> {
10965 let mut wire_params = serde_json::to_value(params)?;
10966 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10967 let _value = self
10968 .session
10969 .client()
10970 .call(rpc_methods::SESSION_TOOLS_SET, Some(wire_params))
10971 .await?;
10972 Ok(serde_json::from_value(_value)?)
10973 }
10974
10975 /// Updates the current session's live subagent settings after user settings change. The persisted user settings remain the source of truth for future sessions.
10976 ///
10977 /// Wire method: `session.tools.updateSubagentSettings`.
10978 ///
10979 /// # Parameters
10980 ///
10981 /// * `params` - Subagent settings to apply to the current session
10982 ///
10983 /// # Returns
10984 ///
10985 /// Empty result after applying subagent settings
10986 ///
10987 /// <div class="warning">
10988 ///
10989 /// **Experimental.** This API is part of an experimental wire-protocol surface
10990 /// and may change or be removed in future SDK or CLI releases. Pin both the
10991 /// SDK and CLI versions if your code depends on it.
10992 ///
10993 /// </div>
10994 pub async fn update_subagent_settings(
10995 &self,
10996 params: UpdateSubagentSettingsRequest,
10997 ) -> Result<ToolsUpdateSubagentSettingsResult, Error> {
10998 let mut wire_params = serde_json::to_value(params)?;
10999 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11000 let _value = self
11001 .session
11002 .client()
11003 .call(
11004 rpc_methods::SESSION_TOOLS_UPDATESUBAGENTSETTINGS,
11005 Some(wire_params),
11006 )
11007 .await?;
11008 Ok(serde_json::from_value(_value)?)
11009 }
11010}
11011
11012/// `session.ui.*` RPCs.
11013#[derive(Clone, Copy)]
11014pub struct SessionRpcUi<'a> {
11015 pub(crate) session: &'a Session,
11016}
11017
11018impl<'a> SessionRpcUi<'a> {
11019 /// Runs a transient no-tools model query against the current conversation context.
11020 ///
11021 /// Wire method: `session.ui.ephemeralQuery`.
11022 ///
11023 /// # Parameters
11024 ///
11025 /// * `params` - Transient question to answer without adding it to conversation history.
11026 ///
11027 /// # Returns
11028 ///
11029 /// Completed transient query. Ordered chunks and the terminal outcome are also delivered through `ui.ephemeral_query` session events while it runs.
11030 ///
11031 /// <div class="warning">
11032 ///
11033 /// **Experimental.** This API is part of an experimental wire-protocol surface
11034 /// and may change or be removed in future SDK or CLI releases. Pin both the
11035 /// SDK and CLI versions if your code depends on it.
11036 ///
11037 /// </div>
11038 pub async fn ephemeral_query(
11039 &self,
11040 params: UIEphemeralQueryRequest,
11041 ) -> Result<UIEphemeralQueryResult, Error> {
11042 let mut wire_params = serde_json::to_value(params)?;
11043 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11044 let _value = self
11045 .session
11046 .client()
11047 .call(rpc_methods::SESSION_UI_EPHEMERALQUERY, Some(wire_params))
11048 .await?;
11049 Ok(serde_json::from_value(_value)?)
11050 }
11051
11052 /// Requests structured input from a UI-capable client.
11053 ///
11054 /// Wire method: `session.ui.elicitation`.
11055 ///
11056 /// # Parameters
11057 ///
11058 /// * `params` - Prompt message and JSON schema describing the form fields to elicit from the user.
11059 ///
11060 /// # Returns
11061 ///
11062 /// The elicitation response (accept with form values, decline, or cancel)
11063 ///
11064 /// <div class="warning">
11065 ///
11066 /// **Experimental.** This API is part of an experimental wire-protocol surface
11067 /// and may change or be removed in future SDK or CLI releases. Pin both the
11068 /// SDK and CLI versions if your code depends on it.
11069 ///
11070 /// </div>
11071 pub async fn elicitation(
11072 &self,
11073 params: UIElicitationRequest,
11074 ) -> Result<UIElicitationResponse, Error> {
11075 let mut wire_params = serde_json::to_value(params)?;
11076 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11077 let _value = self
11078 .session
11079 .client()
11080 .call(rpc_methods::SESSION_UI_ELICITATION, Some(wire_params))
11081 .await?;
11082 Ok(serde_json::from_value(_value)?)
11083 }
11084
11085 /// Provides the user response for a pending elicitation request.
11086 ///
11087 /// Wire method: `session.ui.handlePendingElicitation`.
11088 ///
11089 /// # Parameters
11090 ///
11091 /// * `params` - Pending elicitation request ID and the user's response (accept/decline/cancel + form values).
11092 ///
11093 /// # Returns
11094 ///
11095 /// Indicates whether the elicitation response was accepted; false if it was already resolved by another client.
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 handle_pending_elicitation(
11105 &self,
11106 params: UIHandlePendingElicitationRequest,
11107 ) -> Result<UIElicitationResult, Error> {
11108 let mut wire_params = serde_json::to_value(params)?;
11109 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11110 let _value = self
11111 .session
11112 .client()
11113 .call(
11114 rpc_methods::SESSION_UI_HANDLEPENDINGELICITATION,
11115 Some(wire_params),
11116 )
11117 .await?;
11118 Ok(serde_json::from_value(_value)?)
11119 }
11120
11121 /// Resolves a pending `user_input.requested` event with the user's response.
11122 ///
11123 /// Wire method: `session.ui.handlePendingUserInput`.
11124 ///
11125 /// # Parameters
11126 ///
11127 /// * `params` - Request ID of a pending `user_input.requested` event and the user's response.
11128 ///
11129 /// # Returns
11130 ///
11131 /// Indicates whether the pending UI request was resolved by this call.
11132 ///
11133 /// <div class="warning">
11134 ///
11135 /// **Experimental.** This API is part of an experimental wire-protocol surface
11136 /// and may change or be removed in future SDK or CLI releases. Pin both the
11137 /// SDK and CLI versions if your code depends on it.
11138 ///
11139 /// </div>
11140 pub async fn handle_pending_user_input(
11141 &self,
11142 params: UIHandlePendingUserInputRequest,
11143 ) -> Result<UIHandlePendingResult, Error> {
11144 let mut wire_params = serde_json::to_value(params)?;
11145 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11146 let _value = self
11147 .session
11148 .client()
11149 .call(
11150 rpc_methods::SESSION_UI_HANDLEPENDINGUSERINPUT,
11151 Some(wire_params),
11152 )
11153 .await?;
11154 Ok(serde_json::from_value(_value)?)
11155 }
11156
11157 /// Resolves a pending `sampling.requested` event with a sampling result, or rejects it.
11158 ///
11159 /// Wire method: `session.ui.handlePendingSampling`.
11160 ///
11161 /// # Parameters
11162 ///
11163 /// * `params` - Request ID of a pending `sampling.requested` event and an optional sampling result payload (omit to reject).
11164 ///
11165 /// # Returns
11166 ///
11167 /// Indicates whether the pending UI request was resolved by this call.
11168 ///
11169 /// <div class="warning">
11170 ///
11171 /// **Experimental.** This API is part of an experimental wire-protocol surface
11172 /// and may change or be removed in future SDK or CLI releases. Pin both the
11173 /// SDK and CLI versions if your code depends on it.
11174 ///
11175 /// </div>
11176 pub async fn handle_pending_sampling(
11177 &self,
11178 params: UIHandlePendingSamplingRequest,
11179 ) -> Result<UIHandlePendingResult, Error> {
11180 let mut wire_params = serde_json::to_value(params)?;
11181 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11182 let _value = self
11183 .session
11184 .client()
11185 .call(
11186 rpc_methods::SESSION_UI_HANDLEPENDINGSAMPLING,
11187 Some(wire_params),
11188 )
11189 .await?;
11190 Ok(serde_json::from_value(_value)?)
11191 }
11192
11193 /// Resolves a pending `auto_mode_switch.requested` event with the user's accept/decline decision.
11194 ///
11195 /// Wire method: `session.ui.handlePendingAutoModeSwitch`.
11196 ///
11197 /// # Parameters
11198 ///
11199 /// * `params` - Request ID of a pending `auto_mode_switch.requested` event and the user's response.
11200 ///
11201 /// # Returns
11202 ///
11203 /// Indicates whether the pending UI request was resolved by this call.
11204 ///
11205 /// <div class="warning">
11206 ///
11207 /// **Experimental.** This API is part of an experimental wire-protocol surface
11208 /// and may change or be removed in future SDK or CLI releases. Pin both the
11209 /// SDK and CLI versions if your code depends on it.
11210 ///
11211 /// </div>
11212 pub async fn handle_pending_auto_mode_switch(
11213 &self,
11214 params: UIHandlePendingAutoModeSwitchRequest,
11215 ) -> Result<UIHandlePendingResult, Error> {
11216 let mut wire_params = serde_json::to_value(params)?;
11217 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11218 let _value = self
11219 .session
11220 .client()
11221 .call(
11222 rpc_methods::SESSION_UI_HANDLEPENDINGAUTOMODESWITCH,
11223 Some(wire_params),
11224 )
11225 .await?;
11226 Ok(serde_json::from_value(_value)?)
11227 }
11228
11229 /// Resolves a pending `session_limits_exhausted.requested` event with the user's selected limit action.
11230 ///
11231 /// Wire method: `session.ui.handlePendingSessionLimitsExhausted`.
11232 ///
11233 /// # Parameters
11234 ///
11235 /// * `params` - Request ID of a pending `session_limits_exhausted.requested` event and the user's selected limit action.
11236 ///
11237 /// # Returns
11238 ///
11239 /// Indicates whether the pending UI request was resolved by this call.
11240 ///
11241 /// <div class="warning">
11242 ///
11243 /// **Experimental.** This API is part of an experimental wire-protocol surface
11244 /// and may change or be removed in future SDK or CLI releases. Pin both the
11245 /// SDK and CLI versions if your code depends on it.
11246 ///
11247 /// </div>
11248 pub async fn handle_pending_session_limits_exhausted(
11249 &self,
11250 params: UIHandlePendingSessionLimitsExhaustedRequest,
11251 ) -> Result<UIHandlePendingResult, Error> {
11252 let mut wire_params = serde_json::to_value(params)?;
11253 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11254 let _value = self
11255 .session
11256 .client()
11257 .call(
11258 rpc_methods::SESSION_UI_HANDLEPENDINGSESSIONLIMITSEXHAUSTED,
11259 Some(wire_params),
11260 )
11261 .await?;
11262 Ok(serde_json::from_value(_value)?)
11263 }
11264
11265 /// Resolves a pending `exit_plan_mode.requested` event with the user's response.
11266 ///
11267 /// Wire method: `session.ui.handlePendingExitPlanMode`.
11268 ///
11269 /// # Parameters
11270 ///
11271 /// * `params` - Request ID of a pending `exit_plan_mode.requested` event and the user's response.
11272 ///
11273 /// # Returns
11274 ///
11275 /// Indicates whether the pending UI request was resolved by this call.
11276 ///
11277 /// <div class="warning">
11278 ///
11279 /// **Experimental.** This API is part of an experimental wire-protocol surface
11280 /// and may change or be removed in future SDK or CLI releases. Pin both the
11281 /// SDK and CLI versions if your code depends on it.
11282 ///
11283 /// </div>
11284 pub async fn handle_pending_exit_plan_mode(
11285 &self,
11286 params: UIHandlePendingExitPlanModeRequest,
11287 ) -> Result<UIHandlePendingResult, Error> {
11288 let mut wire_params = serde_json::to_value(params)?;
11289 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11290 let _value = self
11291 .session
11292 .client()
11293 .call(
11294 rpc_methods::SESSION_UI_HANDLEPENDINGEXITPLANMODE,
11295 Some(wire_params),
11296 )
11297 .await?;
11298 Ok(serde_json::from_value(_value)?)
11299 }
11300
11301 /// Registers an in-process handler for auto-mode-switch requests so the server bridge skips dispatch.
11302 ///
11303 /// Wire method: `session.ui.registerDirectAutoModeSwitchHandler`.
11304 ///
11305 /// # Returns
11306 ///
11307 /// 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).
11308 ///
11309 /// <div class="warning">
11310 ///
11311 /// **Experimental.** This API is part of an experimental wire-protocol surface
11312 /// and may change or be removed in future SDK or CLI releases. Pin both the
11313 /// SDK and CLI versions if your code depends on it.
11314 ///
11315 /// </div>
11316 pub async fn register_direct_auto_mode_switch_handler(
11317 &self,
11318 ) -> Result<UIRegisterDirectAutoModeSwitchHandlerResult, Error> {
11319 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
11320 let _value = self
11321 .session
11322 .client()
11323 .call(
11324 rpc_methods::SESSION_UI_REGISTERDIRECTAUTOMODESWITCHHANDLER,
11325 Some(wire_params),
11326 )
11327 .await?;
11328 Ok(serde_json::from_value(_value)?)
11329 }
11330
11331 /// Unregisters a previously-registered in-process auto-mode-switch handler by its opaque handle.
11332 ///
11333 /// Wire method: `session.ui.unregisterDirectAutoModeSwitchHandler`.
11334 ///
11335 /// # Parameters
11336 ///
11337 /// * `params` - Opaque handle previously returned by `registerDirectAutoModeSwitchHandler` to release.
11338 ///
11339 /// # Returns
11340 ///
11341 /// Indicates whether the handle was active and the registration count was decremented.
11342 ///
11343 /// <div class="warning">
11344 ///
11345 /// **Experimental.** This API is part of an experimental wire-protocol surface
11346 /// and may change or be removed in future SDK or CLI releases. Pin both the
11347 /// SDK and CLI versions if your code depends on it.
11348 ///
11349 /// </div>
11350 pub async fn unregister_direct_auto_mode_switch_handler(
11351 &self,
11352 params: UIUnregisterDirectAutoModeSwitchHandlerRequest,
11353 ) -> Result<UIUnregisterDirectAutoModeSwitchHandlerResult, Error> {
11354 let mut wire_params = serde_json::to_value(params)?;
11355 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11356 let _value = self
11357 .session
11358 .client()
11359 .call(
11360 rpc_methods::SESSION_UI_UNREGISTERDIRECTAUTOMODESWITCHHANDLER,
11361 Some(wire_params),
11362 )
11363 .await?;
11364 Ok(serde_json::from_value(_value)?)
11365 }
11366}
11367
11368/// `session.usage.*` RPCs.
11369#[derive(Clone, Copy)]
11370pub struct SessionRpcUsage<'a> {
11371 pub(crate) session: &'a Session,
11372}
11373
11374impl<'a> SessionRpcUsage<'a> {
11375 /// Gets accumulated usage metrics for the session.
11376 ///
11377 /// Wire method: `session.usage.getMetrics`.
11378 ///
11379 /// # Returns
11380 ///
11381 /// Accumulated session usage metrics, including premium request cost, token counts, model breakdown, and code-change totals.
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 get_metrics(&self) -> Result<UsageGetMetricsResult, Error> {
11391 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
11392 let _value = self
11393 .session
11394 .client()
11395 .call(rpc_methods::SESSION_USAGE_GETMETRICS, Some(wire_params))
11396 .await?;
11397 Ok(serde_json::from_value(_value)?)
11398 }
11399}
11400
11401/// `session.visibility.*` RPCs.
11402#[derive(Clone, Copy)]
11403pub struct SessionRpcVisibility<'a> {
11404 pub(crate) session: &'a Session,
11405}
11406
11407impl<'a> SessionRpcVisibility<'a> {
11408 /// 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").
11409 ///
11410 /// Wire method: `session.visibility.get`.
11411 ///
11412 /// # Returns
11413 ///
11414 /// Current sharing status and shareable GitHub URL for a session.
11415 ///
11416 /// <div class="warning">
11417 ///
11418 /// **Experimental.** This API is part of an experimental wire-protocol surface
11419 /// and may change or be removed in future SDK or CLI releases. Pin both the
11420 /// SDK and CLI versions if your code depends on it.
11421 ///
11422 /// </div>
11423 pub async fn get(&self) -> Result<VisibilityGetResult, Error> {
11424 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
11425 let _value = self
11426 .session
11427 .client()
11428 .call(rpc_methods::SESSION_VISIBILITY_GET, Some(wire_params))
11429 .await?;
11430 Ok(serde_json::from_value(_value)?)
11431 }
11432
11433 /// 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.
11434 ///
11435 /// Wire method: `session.visibility.set`.
11436 ///
11437 /// # Parameters
11438 ///
11439 /// * `params` - Desired sharing status for the session.
11440 ///
11441 /// # Returns
11442 ///
11443 /// Effective sharing status and shareable GitHub URL after updating session visibility.
11444 ///
11445 /// <div class="warning">
11446 ///
11447 /// **Experimental.** This API is part of an experimental wire-protocol surface
11448 /// and may change or be removed in future SDK or CLI releases. Pin both the
11449 /// SDK and CLI versions if your code depends on it.
11450 ///
11451 /// </div>
11452 pub async fn set(&self, params: VisibilitySetRequest) -> Result<VisibilitySetResult, Error> {
11453 let mut wire_params = serde_json::to_value(params)?;
11454 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11455 let _value = self
11456 .session
11457 .client()
11458 .call(rpc_methods::SESSION_VISIBILITY_SET, Some(wire_params))
11459 .await?;
11460 Ok(serde_json::from_value(_value)?)
11461 }
11462}
11463
11464/// `session.workspaces.*` RPCs.
11465#[derive(Clone, Copy)]
11466pub struct SessionRpcWorkspaces<'a> {
11467 pub(crate) session: &'a Session,
11468}
11469
11470impl<'a> SessionRpcWorkspaces<'a> {
11471 /// Gets current workspace metadata for the session.
11472 ///
11473 /// Wire method: `session.workspaces.getWorkspace`.
11474 ///
11475 /// # Returns
11476 ///
11477 /// Current workspace metadata for the session, including its absolute filesystem path when available.
11478 ///
11479 /// <div class="warning">
11480 ///
11481 /// **Experimental.** This API is part of an experimental wire-protocol surface
11482 /// and may change or be removed in future SDK or CLI releases. Pin both the
11483 /// SDK and CLI versions if your code depends on it.
11484 ///
11485 /// </div>
11486 pub async fn get_workspace(&self) -> Result<WorkspacesGetWorkspaceResult, Error> {
11487 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
11488 let _value = self
11489 .session
11490 .client()
11491 .call(
11492 rpc_methods::SESSION_WORKSPACES_GETWORKSPACE,
11493 Some(wire_params),
11494 )
11495 .await?;
11496 Ok(serde_json::from_value(_value)?)
11497 }
11498
11499 /// Updates workspace metadata for a local session and returns the refreshed workspace.
11500 ///
11501 /// Wire method: `session.workspaces.updateMetadata`.
11502 ///
11503 /// # Parameters
11504 ///
11505 /// * `params` - Workspace metadata fields to update.
11506 ///
11507 /// # Returns
11508 ///
11509 /// Current workspace metadata for the session, including its absolute filesystem path when available.
11510 ///
11511 /// <div class="warning">
11512 ///
11513 /// **Experimental.** This API is part of an experimental wire-protocol surface
11514 /// and may change or be removed in future SDK or CLI releases. Pin both the
11515 /// SDK and CLI versions if your code depends on it.
11516 ///
11517 /// </div>
11518 pub async fn update_metadata(
11519 &self,
11520 params: WorkspacesUpdateMetadataRequest,
11521 ) -> Result<WorkspacesGetWorkspaceResult, Error> {
11522 let mut wire_params = serde_json::to_value(params)?;
11523 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11524 let _value = self
11525 .session
11526 .client()
11527 .call(
11528 rpc_methods::SESSION_WORKSPACES_UPDATEMETADATA,
11529 Some(wire_params),
11530 )
11531 .await?;
11532 Ok(serde_json::from_value(_value)?)
11533 }
11534
11535 /// Ensures a local session workspace exists and returns it.
11536 ///
11537 /// Wire method: `session.workspaces.ensure`.
11538 ///
11539 /// # Parameters
11540 ///
11541 /// * `params` - Optional session context used when creating a local workspace.
11542 ///
11543 /// # Returns
11544 ///
11545 /// Current workspace metadata for the session, including its absolute filesystem path when available.
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 ensure(
11555 &self,
11556 params: WorkspacesEnsureRequest,
11557 ) -> Result<WorkspacesGetWorkspaceResult, Error> {
11558 let mut wire_params = serde_json::to_value(params)?;
11559 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11560 let _value = self
11561 .session
11562 .client()
11563 .call(rpc_methods::SESSION_WORKSPACES_ENSURE, Some(wire_params))
11564 .await?;
11565 Ok(serde_json::from_value(_value)?)
11566 }
11567
11568 /// Lists files stored in the session workspace files directory.
11569 ///
11570 /// Wire method: `session.workspaces.listFiles`.
11571 ///
11572 /// # Returns
11573 ///
11574 /// Relative paths of files stored in the session workspace files directory.
11575 ///
11576 /// <div class="warning">
11577 ///
11578 /// **Experimental.** This API is part of an experimental wire-protocol surface
11579 /// and may change or be removed in future SDK or CLI releases. Pin both the
11580 /// SDK and CLI versions if your code depends on it.
11581 ///
11582 /// </div>
11583 pub async fn list_files(&self) -> Result<WorkspacesListFilesResult, Error> {
11584 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
11585 let _value = self
11586 .session
11587 .client()
11588 .call(rpc_methods::SESSION_WORKSPACES_LISTFILES, Some(wire_params))
11589 .await?;
11590 Ok(serde_json::from_value(_value)?)
11591 }
11592
11593 /// Reads a file from the session workspace files directory.
11594 ///
11595 /// Wire method: `session.workspaces.readFile`.
11596 ///
11597 /// # Parameters
11598 ///
11599 /// * `params` - Relative path of the workspace file to read.
11600 ///
11601 /// # Returns
11602 ///
11603 /// Contents of the requested workspace file as a UTF-8 string.
11604 ///
11605 /// <div class="warning">
11606 ///
11607 /// **Experimental.** This API is part of an experimental wire-protocol surface
11608 /// and may change or be removed in future SDK or CLI releases. Pin both the
11609 /// SDK and CLI versions if your code depends on it.
11610 ///
11611 /// </div>
11612 pub async fn read_file(
11613 &self,
11614 params: WorkspacesReadFileRequest,
11615 ) -> Result<WorkspacesReadFileResult, Error> {
11616 let mut wire_params = serde_json::to_value(params)?;
11617 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11618 let _value = self
11619 .session
11620 .client()
11621 .call(rpc_methods::SESSION_WORKSPACES_READFILE, Some(wire_params))
11622 .await?;
11623 Ok(serde_json::from_value(_value)?)
11624 }
11625
11626 /// Creates or overwrites a file in the session workspace files directory.
11627 ///
11628 /// Wire method: `session.workspaces.createFile`.
11629 ///
11630 /// # Parameters
11631 ///
11632 /// * `params` - Relative path and UTF-8 content for the workspace file to create or overwrite.
11633 ///
11634 /// <div class="warning">
11635 ///
11636 /// **Experimental.** This API is part of an experimental wire-protocol surface
11637 /// and may change or be removed in future SDK or CLI releases. Pin both the
11638 /// SDK and CLI versions if your code depends on it.
11639 ///
11640 /// </div>
11641 pub async fn create_file(&self, params: WorkspacesCreateFileRequest) -> Result<(), Error> {
11642 let mut wire_params = serde_json::to_value(params)?;
11643 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11644 let _value = self
11645 .session
11646 .client()
11647 .call(
11648 rpc_methods::SESSION_WORKSPACES_CREATEFILE,
11649 Some(wire_params),
11650 )
11651 .await?;
11652 Ok(())
11653 }
11654
11655 /// Lists workspace checkpoints in chronological order.
11656 ///
11657 /// Wire method: `session.workspaces.listCheckpoints`.
11658 ///
11659 /// # Returns
11660 ///
11661 /// Workspace checkpoints in chronological order; empty when the workspace is not enabled.
11662 ///
11663 /// <div class="warning">
11664 ///
11665 /// **Experimental.** This API is part of an experimental wire-protocol surface
11666 /// and may change or be removed in future SDK or CLI releases. Pin both the
11667 /// SDK and CLI versions if your code depends on it.
11668 ///
11669 /// </div>
11670 pub async fn list_checkpoints(&self) -> Result<WorkspacesListCheckpointsResult, Error> {
11671 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
11672 let _value = self
11673 .session
11674 .client()
11675 .call(
11676 rpc_methods::SESSION_WORKSPACES_LISTCHECKPOINTS,
11677 Some(wire_params),
11678 )
11679 .await?;
11680 Ok(serde_json::from_value(_value)?)
11681 }
11682
11683 /// Reads the content of a workspace checkpoint by number.
11684 ///
11685 /// Wire method: `session.workspaces.readCheckpoint`.
11686 ///
11687 /// # Parameters
11688 ///
11689 /// * `params` - Checkpoint number to read.
11690 ///
11691 /// # Returns
11692 ///
11693 /// Checkpoint content as a UTF-8 string, or null when the checkpoint or workspace is missing.
11694 ///
11695 /// <div class="warning">
11696 ///
11697 /// **Experimental.** This API is part of an experimental wire-protocol surface
11698 /// and may change or be removed in future SDK or CLI releases. Pin both the
11699 /// SDK and CLI versions if your code depends on it.
11700 ///
11701 /// </div>
11702 pub async fn read_checkpoint(
11703 &self,
11704 params: WorkspacesReadCheckpointRequest,
11705 ) -> Result<WorkspacesReadCheckpointResult, Error> {
11706 let mut wire_params = serde_json::to_value(params)?;
11707 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11708 let _value = self
11709 .session
11710 .client()
11711 .call(
11712 rpc_methods::SESSION_WORKSPACES_READCHECKPOINT,
11713 Some(wire_params),
11714 )
11715 .await?;
11716 Ok(serde_json::from_value(_value)?)
11717 }
11718
11719 /// Adds a compaction summary checkpoint to the local session workspace.
11720 ///
11721 /// Wire method: `session.workspaces.addSummary`.
11722 ///
11723 /// # Parameters
11724 ///
11725 /// * `params` - Compaction summary checkpoint to persist.
11726 ///
11727 /// # Returns
11728 ///
11729 /// Persisted summary metadata and refreshed workspace metadata.
11730 ///
11731 /// <div class="warning">
11732 ///
11733 /// **Experimental.** This API is part of an experimental wire-protocol surface
11734 /// and may change or be removed in future SDK or CLI releases. Pin both the
11735 /// SDK and CLI versions if your code depends on it.
11736 ///
11737 /// </div>
11738 pub async fn add_summary(
11739 &self,
11740 params: WorkspacesAddSummaryRequest,
11741 ) -> Result<WorkspacesAddSummaryResult, Error> {
11742 let mut wire_params = serde_json::to_value(params)?;
11743 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11744 let _value = self
11745 .session
11746 .client()
11747 .call(
11748 rpc_methods::SESSION_WORKSPACES_ADDSUMMARY,
11749 Some(wire_params),
11750 )
11751 .await?;
11752 Ok(serde_json::from_value(_value)?)
11753 }
11754
11755 /// Truncates local workspace compaction summaries after a rollback.
11756 ///
11757 /// Wire method: `session.workspaces.truncateSummaries`.
11758 ///
11759 /// # Parameters
11760 ///
11761 /// * `params` - Rollback point for local workspace summaries.
11762 ///
11763 /// # Returns
11764 ///
11765 /// Current workspace metadata for the session, including its absolute filesystem path when available.
11766 ///
11767 /// <div class="warning">
11768 ///
11769 /// **Experimental.** This API is part of an experimental wire-protocol surface
11770 /// and may change or be removed in future SDK or CLI releases. Pin both the
11771 /// SDK and CLI versions if your code depends on it.
11772 ///
11773 /// </div>
11774 pub async fn truncate_summaries(
11775 &self,
11776 params: WorkspacesTruncateSummariesRequest,
11777 ) -> Result<WorkspacesGetWorkspaceResult, Error> {
11778 let mut wire_params = serde_json::to_value(params)?;
11779 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11780 let _value = self
11781 .session
11782 .client()
11783 .call(
11784 rpc_methods::SESSION_WORKSPACES_TRUNCATESUMMARIES,
11785 Some(wire_params),
11786 )
11787 .await?;
11788 Ok(serde_json::from_value(_value)?)
11789 }
11790
11791 /// Reads the autopilot objective state file from the local session workspace.
11792 ///
11793 /// Wire method: `session.workspaces.readAutopilotObjective`.
11794 ///
11795 /// # Returns
11796 ///
11797 /// Autopilot objective file content, or null when missing.
11798 ///
11799 /// <div class="warning">
11800 ///
11801 /// **Experimental.** This API is part of an experimental wire-protocol surface
11802 /// and may change or be removed in future SDK or CLI releases. Pin both the
11803 /// SDK and CLI versions if your code depends on it.
11804 ///
11805 /// </div>
11806 pub async fn read_autopilot_objective(
11807 &self,
11808 ) -> Result<WorkspacesReadAutopilotObjectiveResult, Error> {
11809 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
11810 let _value = self
11811 .session
11812 .client()
11813 .call(
11814 rpc_methods::SESSION_WORKSPACES_READAUTOPILOTOBJECTIVE,
11815 Some(wire_params),
11816 )
11817 .await?;
11818 Ok(serde_json::from_value(_value)?)
11819 }
11820
11821 /// Writes the autopilot objective state file in the local session workspace.
11822 ///
11823 /// Wire method: `session.workspaces.writeAutopilotObjective`.
11824 ///
11825 /// # Parameters
11826 ///
11827 /// * `params` - Autopilot objective file content to persist.
11828 ///
11829 /// # Returns
11830 ///
11831 /// Result of writing the autopilot objective file.
11832 ///
11833 /// <div class="warning">
11834 ///
11835 /// **Experimental.** This API is part of an experimental wire-protocol surface
11836 /// and may change or be removed in future SDK or CLI releases. Pin both the
11837 /// SDK and CLI versions if your code depends on it.
11838 ///
11839 /// </div>
11840 pub async fn write_autopilot_objective(
11841 &self,
11842 params: WorkspacesWriteAutopilotObjectiveRequest,
11843 ) -> Result<WorkspacesWriteAutopilotObjectiveResult, Error> {
11844 let mut wire_params = serde_json::to_value(params)?;
11845 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11846 let _value = self
11847 .session
11848 .client()
11849 .call(
11850 rpc_methods::SESSION_WORKSPACES_WRITEAUTOPILOTOBJECTIVE,
11851 Some(wire_params),
11852 )
11853 .await?;
11854 Ok(serde_json::from_value(_value)?)
11855 }
11856
11857 /// Deletes the autopilot objective state file from the local session workspace.
11858 ///
11859 /// Wire method: `session.workspaces.deleteAutopilotObjective`.
11860 ///
11861 /// # Returns
11862 ///
11863 /// Result of deleting the autopilot objective file.
11864 ///
11865 /// <div class="warning">
11866 ///
11867 /// **Experimental.** This API is part of an experimental wire-protocol surface
11868 /// and may change or be removed in future SDK or CLI releases. Pin both the
11869 /// SDK and CLI versions if your code depends on it.
11870 ///
11871 /// </div>
11872 pub async fn delete_autopilot_objective(
11873 &self,
11874 ) -> Result<WorkspacesDeleteAutopilotObjectiveResult, Error> {
11875 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
11876 let _value = self
11877 .session
11878 .client()
11879 .call(
11880 rpc_methods::SESSION_WORKSPACES_DELETEAUTOPILOTOBJECTIVE,
11881 Some(wire_params),
11882 )
11883 .await?;
11884 Ok(serde_json::from_value(_value)?)
11885 }
11886
11887 /// Checks whether the local session workspace has an autopilot objective state file.
11888 ///
11889 /// Wire method: `session.workspaces.autopilotObjectiveExists`.
11890 ///
11891 /// # Returns
11892 ///
11893 /// Whether the autopilot objective file exists.
11894 ///
11895 /// <div class="warning">
11896 ///
11897 /// **Experimental.** This API is part of an experimental wire-protocol surface
11898 /// and may change or be removed in future SDK or CLI releases. Pin both the
11899 /// SDK and CLI versions if your code depends on it.
11900 ///
11901 /// </div>
11902 pub async fn autopilot_objective_exists(
11903 &self,
11904 ) -> Result<WorkspacesAutopilotObjectiveExistsResult, Error> {
11905 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
11906 let _value = self
11907 .session
11908 .client()
11909 .call(
11910 rpc_methods::SESSION_WORKSPACES_AUTOPILOTOBJECTIVEEXISTS,
11911 Some(wire_params),
11912 )
11913 .await?;
11914 Ok(serde_json::from_value(_value)?)
11915 }
11916
11917 /// Saves pasted content as a UTF-8 file in the session workspace.
11918 ///
11919 /// Wire method: `session.workspaces.saveLargePaste`.
11920 ///
11921 /// # Parameters
11922 ///
11923 /// * `params` - Pasted content to save as a UTF-8 file in the session workspace.
11924 ///
11925 /// # Returns
11926 ///
11927 /// Descriptor for the saved paste file, or null when the workspace is unavailable.
11928 ///
11929 /// <div class="warning">
11930 ///
11931 /// **Experimental.** This API is part of an experimental wire-protocol surface
11932 /// and may change or be removed in future SDK or CLI releases. Pin both the
11933 /// SDK and CLI versions if your code depends on it.
11934 ///
11935 /// </div>
11936 pub async fn save_large_paste(
11937 &self,
11938 params: WorkspacesSaveLargePasteRequest,
11939 ) -> Result<WorkspacesSaveLargePasteResult, Error> {
11940 let mut wire_params = serde_json::to_value(params)?;
11941 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11942 let _value = self
11943 .session
11944 .client()
11945 .call(
11946 rpc_methods::SESSION_WORKSPACES_SAVELARGEPASTE,
11947 Some(wire_params),
11948 )
11949 .await?;
11950 Ok(serde_json::from_value(_value)?)
11951 }
11952
11953 /// 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`.
11954 ///
11955 /// Wire method: `session.workspaces.diff`.
11956 ///
11957 /// # Parameters
11958 ///
11959 /// * `params` - Parameters for computing a workspace diff.
11960 ///
11961 /// # Returns
11962 ///
11963 /// Workspace diff result for the requested mode.
11964 ///
11965 /// <div class="warning">
11966 ///
11967 /// **Experimental.** This API is part of an experimental wire-protocol surface
11968 /// and may change or be removed in future SDK or CLI releases. Pin both the
11969 /// SDK and CLI versions if your code depends on it.
11970 ///
11971 /// </div>
11972 pub async fn diff(&self, params: WorkspacesDiffRequest) -> Result<WorkspaceDiffResult, Error> {
11973 let mut wire_params = serde_json::to_value(params)?;
11974 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11975 let _value = self
11976 .session
11977 .client()
11978 .call(rpc_methods::SESSION_WORKSPACES_DIFF, Some(wire_params))
11979 .await?;
11980 Ok(serde_json::from_value(_value)?)
11981 }
11982}