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 /// Terminates one retained catalog selection group. A selected outcome returns the native host a fresh single-use candidate handle plus the original searchId for a later explicit mcp.planInstall call; non-selected outcomes release the group without producing a planning input. Candidate state, cards, URLs, credentials and private identifiers remain inside the runtime. The model-facing catalog_select tool projects the result separately and never exposes the candidate handle or searchId.
554 ///
555 /// Wire method: `catalog.select`.
556 ///
557 /// # Parameters
558 ///
559 /// * `params` - Terminates one retained catalog selection group through an opaque reference previously returned by the model-safe search projection.
560 ///
561 /// # Returns
562 ///
563 /// Typed outcome of catalog.select. Only the selected host result carries a fresh candidate handle; the model-facing projection removes both that handle and searchId.
564 ///
565 /// <div class="warning">
566 ///
567 /// **Experimental.** This API is part of an experimental wire-protocol surface
568 /// and may change or be removed in future SDK or CLI releases. Pin both the
569 /// SDK and CLI versions if your code depends on it.
570 ///
571 /// </div>
572 pub async fn select(
573 &self,
574 params: CatalogSelectionRequest,
575 ) -> Result<CatalogSelectionResult, Error> {
576 let wire_params = serde_json::to_value(params)?;
577 let _value = self
578 .client
579 .call(rpc_methods::CATALOG_SELECT, Some(wire_params))
580 .await?;
581 Ok(serde_json::from_value(_value)?)
582 }
583}
584
585/// `commands.*` RPCs.
586#[derive(Clone, Copy)]
587pub struct ClientRpcCommands<'a> {
588 pub(crate) client: &'a Client,
589}
590
591impl<'a> ClientRpcCommands<'a> {
592 /// 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.
593 ///
594 /// Wire method: `commands.list`.
595 ///
596 /// # Returns
597 ///
598 /// Slash commands available in the session, after applying any include/exclude filters.
599 ///
600 /// <div class="warning">
601 ///
602 /// **Experimental.** This API is part of an experimental wire-protocol surface
603 /// and may change or be removed in future SDK or CLI releases. Pin both the
604 /// SDK and CLI versions if your code depends on it.
605 ///
606 /// </div>
607 pub async fn list(&self) -> Result<CommandList, Error> {
608 let wire_params = serde_json::json!({});
609 let _value = self
610 .client
611 .call(rpc_methods::COMMANDS_LIST, Some(wire_params))
612 .await?;
613 Ok(serde_json::from_value(_value)?)
614 }
615}
616
617/// `extensions.*` RPCs.
618#[derive(Clone, Copy)]
619pub struct ClientRpcExtensions<'a> {
620 pub(crate) client: &'a Client,
621}
622
623impl<'a> ClientRpcExtensions<'a> {
624 /// Discovers user and enabled installed-plugin extensions from persisted Copilot home state, including enablement preferences. Launch-scoped additional plugins are not included.
625 ///
626 /// Wire method: `extensions.discover`.
627 ///
628 /// # Returns
629 ///
630 /// Extensions discovered from persisted Copilot home state and their effective loading mode. Launch-scoped additional plugins are not included.
631 ///
632 /// <div class="warning">
633 ///
634 /// **Experimental.** This API is part of an experimental wire-protocol surface
635 /// and may change or be removed in future SDK or CLI releases. Pin both the
636 /// SDK and CLI versions if your code depends on it.
637 ///
638 /// </div>
639 pub async fn discover(&self) -> Result<DiscoveredExtensions, Error> {
640 let wire_params = serde_json::json!({});
641 let _value = self
642 .client
643 .call(rpc_methods::EXTENSIONS_DISCOVER, Some(wire_params))
644 .await?;
645 Ok(serde_json::from_value(_value)?)
646 }
647
648 /// Persistently enables extension IDs for future sessions. Active sessions are unchanged; use session.extensions.enable to update them.
649 ///
650 /// Wire method: `extensions.enable`.
651 ///
652 /// # Parameters
653 ///
654 /// * `params` - Source-qualified extension identifiers to persistently enable for future sessions.
655 ///
656 /// <div class="warning">
657 ///
658 /// **Experimental.** This API is part of an experimental wire-protocol surface
659 /// and may change or be removed in future SDK or CLI releases. Pin both the
660 /// SDK and CLI versions if your code depends on it.
661 ///
662 /// </div>
663 pub async fn enable(&self, params: DiscoveredExtensionsEnableRequest) -> Result<(), Error> {
664 let wire_params = serde_json::to_value(params)?;
665 let _value = self
666 .client
667 .call(rpc_methods::EXTENSIONS_ENABLE, Some(wire_params))
668 .await?;
669 Ok(())
670 }
671
672 /// Persistently disables extension IDs for future sessions. Active sessions are unchanged; use session.extensions.disable to update them.
673 ///
674 /// Wire method: `extensions.disable`.
675 ///
676 /// # Parameters
677 ///
678 /// * `params` - Source-qualified extension identifiers to persistently disable for future sessions.
679 ///
680 /// <div class="warning">
681 ///
682 /// **Experimental.** This API is part of an experimental wire-protocol surface
683 /// and may change or be removed in future SDK or CLI releases. Pin both the
684 /// SDK and CLI versions if your code depends on it.
685 ///
686 /// </div>
687 pub async fn disable(&self, params: DiscoveredExtensionsDisableRequest) -> Result<(), Error> {
688 let wire_params = serde_json::to_value(params)?;
689 let _value = self
690 .client
691 .call(rpc_methods::EXTENSIONS_DISABLE, Some(wire_params))
692 .await?;
693 Ok(())
694 }
695}
696
697/// `hooks.*` RPCs.
698#[derive(Clone, Copy)]
699pub struct ClientRpcHooks<'a> {
700 pub(crate) client: &'a Client,
701}
702
703impl<'a> ClientRpcHooks<'a> {
704 /// Discovers hook actions enabled under server-side discovery settings from user, repository, plugin, and managed-policy sources.
705 ///
706 /// Wire method: `hooks.discover`.
707 ///
708 /// # Parameters
709 ///
710 /// * `params` - Optional project paths and host-exclusion behavior for server-scoped hook discovery.
711 ///
712 /// # Returns
713 ///
714 /// 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.
715 ///
716 /// <div class="warning">
717 ///
718 /// **Experimental.** This API is part of an experimental wire-protocol surface
719 /// and may change or be removed in future SDK or CLI releases. Pin both the
720 /// SDK and CLI versions if your code depends on it.
721 ///
722 /// </div>
723 pub async fn discover(
724 &self,
725 params: HooksDiscoverRequest,
726 ) -> Result<HooksDiscoverResult, Error> {
727 let wire_params = serde_json::to_value(params)?;
728 let _value = self
729 .client
730 .call(rpc_methods::HOOKS_DISCOVER, Some(wire_params))
731 .await?;
732 Ok(serde_json::from_value(_value)?)
733 }
734}
735
736/// `instructions.*` RPCs.
737#[derive(Clone, Copy)]
738pub struct ClientRpcInstructions<'a> {
739 pub(crate) client: &'a Client,
740}
741
742impl<'a> ClientRpcInstructions<'a> {
743 /// Discovers instruction sources across user, repository, and plugin sources.
744 ///
745 /// Wire method: `instructions.discover`.
746 ///
747 /// # Parameters
748 ///
749 /// * `params` - Optional project paths to include in instruction discovery.
750 ///
751 /// # Returns
752 ///
753 /// Instruction sources discovered across user, repository, and plugin sources.
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 discover(
763 &self,
764 params: InstructionsDiscoverRequest,
765 ) -> Result<ServerInstructionSourceList, Error> {
766 let wire_params = serde_json::to_value(params)?;
767 let _value = self
768 .client
769 .call(rpc_methods::INSTRUCTIONS_DISCOVER, Some(wire_params))
770 .await?;
771 Ok(serde_json::from_value(_value)?)
772 }
773
774 /// 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.
775 ///
776 /// Wire method: `instructions.getDiscoveryPaths`.
777 ///
778 /// # Parameters
779 ///
780 /// * `params` - Optional project paths to include when enumerating instruction discovery targets.
781 ///
782 /// # Returns
783 ///
784 /// Canonical files and directories where custom instructions can be created so the runtime will recognize them.
785 ///
786 /// <div class="warning">
787 ///
788 /// **Experimental.** This API is part of an experimental wire-protocol surface
789 /// and may change or be removed in future SDK or CLI releases. Pin both the
790 /// SDK and CLI versions if your code depends on it.
791 ///
792 /// </div>
793 pub async fn get_discovery_paths(
794 &self,
795 params: InstructionsGetDiscoveryPathsRequest,
796 ) -> Result<InstructionDiscoveryPathList, Error> {
797 let wire_params = serde_json::to_value(params)?;
798 let _value = self
799 .client
800 .call(
801 rpc_methods::INSTRUCTIONS_GETDISCOVERYPATHS,
802 Some(wire_params),
803 )
804 .await?;
805 Ok(serde_json::from_value(_value)?)
806 }
807}
808
809/// `llmInference.*` RPCs.
810#[derive(Clone, Copy)]
811pub struct ClientRpcLlmInference<'a> {
812 pub(crate) client: &'a Client,
813}
814
815impl<'a> ClientRpcLlmInference<'a> {
816 /// Registers an SDK client as the LLM inference callback provider.
817 ///
818 /// Wire method: `llmInference.setProvider`.
819 ///
820 /// # Returns
821 ///
822 /// Indicates whether the calling client was registered as the LLM inference provider.
823 ///
824 /// <div class="warning">
825 ///
826 /// **Experimental.** This API is part of an experimental wire-protocol surface
827 /// and may change or be removed in future SDK or CLI releases. Pin both the
828 /// SDK and CLI versions if your code depends on it.
829 ///
830 /// </div>
831 pub async fn set_provider(&self) -> Result<LlmInferenceSetProviderResult, Error> {
832 let wire_params = serde_json::json!({});
833 let _value = self
834 .client
835 .call(rpc_methods::LLMINFERENCE_SETPROVIDER, Some(wire_params))
836 .await?;
837 Ok(serde_json::from_value(_value)?)
838 }
839
840 /// 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.
841 ///
842 /// Wire method: `llmInference.httpResponseStart`.
843 ///
844 /// # Parameters
845 ///
846 /// * `params` - Response head.
847 ///
848 /// # Returns
849 ///
850 /// Whether the start frame was accepted.
851 ///
852 /// <div class="warning">
853 ///
854 /// **Experimental.** This API is part of an experimental wire-protocol surface
855 /// and may change or be removed in future SDK or CLI releases. Pin both the
856 /// SDK and CLI versions if your code depends on it.
857 ///
858 /// </div>
859 pub async fn http_response_start(
860 &self,
861 params: LlmInferenceHttpResponseStartRequest,
862 ) -> Result<LlmInferenceHttpResponseStartResult, Error> {
863 let wire_params = serde_json::to_value(params)?;
864 let _value = self
865 .client
866 .call(
867 rpc_methods::LLMINFERENCE_HTTPRESPONSESTART,
868 Some(wire_params),
869 )
870 .await?;
871 Ok(serde_json::from_value(_value)?)
872 }
873
874 /// 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.
875 ///
876 /// Wire method: `llmInference.httpResponseChunk`.
877 ///
878 /// # Parameters
879 ///
880 /// * `params` - A response body chunk or terminal error.
881 ///
882 /// # Returns
883 ///
884 /// Whether the chunk was accepted.
885 ///
886 /// <div class="warning">
887 ///
888 /// **Experimental.** This API is part of an experimental wire-protocol surface
889 /// and may change or be removed in future SDK or CLI releases. Pin both the
890 /// SDK and CLI versions if your code depends on it.
891 ///
892 /// </div>
893 pub async fn http_response_chunk(
894 &self,
895 params: LlmInferenceHttpResponseChunkRequest,
896 ) -> Result<LlmInferenceHttpResponseChunkResult, Error> {
897 let wire_params = serde_json::to_value(params)?;
898 let _value = self
899 .client
900 .call(
901 rpc_methods::LLMINFERENCE_HTTPRESPONSECHUNK,
902 Some(wire_params),
903 )
904 .await?;
905 Ok(serde_json::from_value(_value)?)
906 }
907}
908
909/// `managedSettings.*` RPCs.
910#[derive(Clone, Copy)]
911pub struct ClientRpcManagedSettings<'a> {
912 pub(crate) client: &'a Client,
913}
914
915impl<'a> ClientRpcManagedSettings<'a> {
916 /// 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.
917 ///
918 /// Wire method: `managedSettings.read`.
919 ///
920 /// # Returns
921 ///
922 /// Validated device-managed settings discovered before a session exists.
923 ///
924 /// <div class="warning">
925 ///
926 /// **Experimental.** This API is part of an experimental wire-protocol surface
927 /// and may change or be removed in future SDK or CLI releases. Pin both the
928 /// SDK and CLI versions if your code depends on it.
929 ///
930 /// </div>
931 pub async fn read(&self) -> Result<ManagedSettingsReadResult, Error> {
932 let wire_params = serde_json::json!({});
933 let _value = self
934 .client
935 .call(rpc_methods::MANAGEDSETTINGS_READ, Some(wire_params))
936 .await?;
937 Ok(serde_json::from_value(_value)?)
938 }
939
940 /// 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.
941 ///
942 /// Wire method: `managedSettings.clearCache`.
943 ///
944 /// <div class="warning">
945 ///
946 /// **Experimental.** This API is part of an experimental wire-protocol surface
947 /// and may change or be removed in future SDK or CLI releases. Pin both the
948 /// SDK and CLI versions if your code depends on it.
949 ///
950 /// </div>
951 pub async fn clear_cache(&self) -> Result<(), Error> {
952 let wire_params = serde_json::json!({});
953 let _value = self
954 .client
955 .call(rpc_methods::MANAGEDSETTINGS_CLEARCACHE, Some(wire_params))
956 .await?;
957 Ok(())
958 }
959}
960
961/// `mcp.*` RPCs.
962#[derive(Clone, Copy)]
963pub struct ClientRpcMcp<'a> {
964 pub(crate) client: &'a Client,
965}
966
967impl<'a> ClientRpcMcp<'a> {
968 /// `mcp.config.*` sub-namespace.
969 pub fn config(&self) -> ClientRpcMcpConfig<'a> {
970 ClientRpcMcpConfig {
971 client: self.client,
972 }
973 }
974
975 /// Discovers MCP servers from user, workspace, plugin, and builtin sources.
976 ///
977 /// Wire method: `mcp.discover`.
978 ///
979 /// # Parameters
980 ///
981 /// * `params` - Optional working directory used as context for MCP server discovery.
982 ///
983 /// # Returns
984 ///
985 /// MCP servers discovered from user, workspace, plugin, and built-in sources.
986 ///
987 /// <div class="warning">
988 ///
989 /// **Experimental.** This API is part of an experimental wire-protocol surface
990 /// and may change or be removed in future SDK or CLI releases. Pin both the
991 /// SDK and CLI versions if your code depends on it.
992 ///
993 /// </div>
994 pub async fn discover(&self, params: McpDiscoverRequest) -> Result<McpDiscoverResult, Error> {
995 let wire_params = serde_json::to_value(params)?;
996 let _value = self
997 .client
998 .call(rpc_methods::MCP_DISCOVER, Some(wire_params))
999 .await?;
1000 Ok(serde_json::from_value(_value)?)
1001 }
1002
1003 /// 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.
1004 ///
1005 /// Wire method: `mcp.planInstall`.
1006 ///
1007 /// # Parameters
1008 ///
1009 /// * `params` - A side-effect-free request for an MCP install plan. Computing a plan never writes configuration, stores a secret, or reloads MCP servers.
1010 ///
1011 /// # Returns
1012 ///
1013 /// Outcome of an mcp.planInstall call: either a normalised plan, or one typed refusal. Nothing is written in either case.
1014 ///
1015 /// <div class="warning">
1016 ///
1017 /// **Experimental.** This API is part of an experimental wire-protocol surface
1018 /// and may change or be removed in future SDK or CLI releases. Pin both the
1019 /// SDK and CLI versions if your code depends on it.
1020 ///
1021 /// </div>
1022 pub async fn plan_install(
1023 &self,
1024 params: McpPlanInstallRequest,
1025 ) -> Result<McpPlanInstallResult, Error> {
1026 let wire_params = serde_json::to_value(params)?;
1027 let _value = self
1028 .client
1029 .call(rpc_methods::MCP_PLANINSTALL, Some(wire_params))
1030 .await?;
1031 Ok(serde_json::from_value(_value)?)
1032 }
1033}
1034
1035/// `mcp.config.*` RPCs.
1036#[derive(Clone, Copy)]
1037pub struct ClientRpcMcpConfig<'a> {
1038 pub(crate) client: &'a Client,
1039}
1040
1041impl<'a> ClientRpcMcpConfig<'a> {
1042 /// Lists MCP servers from user configuration.
1043 ///
1044 /// Wire method: `mcp.config.list`.
1045 ///
1046 /// # Returns
1047 ///
1048 /// User-configured MCP servers, keyed by server name.
1049 ///
1050 /// <div class="warning">
1051 ///
1052 /// **Experimental.** This API is part of an experimental wire-protocol surface
1053 /// and may change or be removed in future SDK or CLI releases. Pin both the
1054 /// SDK and CLI versions if your code depends on it.
1055 ///
1056 /// </div>
1057 pub async fn list(&self) -> Result<McpConfigList, Error> {
1058 let wire_params = serde_json::json!({});
1059 let _value = self
1060 .client
1061 .call(rpc_methods::MCP_CONFIG_LIST, Some(wire_params))
1062 .await?;
1063 Ok(serde_json::from_value(_value)?)
1064 }
1065
1066 /// Adds an MCP server to user configuration.
1067 ///
1068 /// Wire method: `mcp.config.add`.
1069 ///
1070 /// # Parameters
1071 ///
1072 /// * `params` - MCP server name and configuration to add to user configuration.
1073 ///
1074 /// <div class="warning">
1075 ///
1076 /// **Experimental.** This API is part of an experimental wire-protocol surface
1077 /// and may change or be removed in future SDK or CLI releases. Pin both the
1078 /// SDK and CLI versions if your code depends on it.
1079 ///
1080 /// </div>
1081 pub async fn add(&self, params: McpConfigAddRequest) -> Result<(), Error> {
1082 let wire_params = serde_json::to_value(params)?;
1083 let _value = self
1084 .client
1085 .call(rpc_methods::MCP_CONFIG_ADD, Some(wire_params))
1086 .await?;
1087 Ok(())
1088 }
1089
1090 /// Updates an MCP server in user configuration.
1091 ///
1092 /// Wire method: `mcp.config.update`.
1093 ///
1094 /// # Parameters
1095 ///
1096 /// * `params` - MCP server name and replacement configuration to write to user configuration.
1097 ///
1098 /// <div class="warning">
1099 ///
1100 /// **Experimental.** This API is part of an experimental wire-protocol surface
1101 /// and may change or be removed in future SDK or CLI releases. Pin both the
1102 /// SDK and CLI versions if your code depends on it.
1103 ///
1104 /// </div>
1105 pub async fn update(&self, params: McpConfigUpdateRequest) -> Result<(), Error> {
1106 let wire_params = serde_json::to_value(params)?;
1107 let _value = self
1108 .client
1109 .call(rpc_methods::MCP_CONFIG_UPDATE, Some(wire_params))
1110 .await?;
1111 Ok(())
1112 }
1113
1114 /// Removes an MCP server from user configuration.
1115 ///
1116 /// Wire method: `mcp.config.remove`.
1117 ///
1118 /// # Parameters
1119 ///
1120 /// * `params` - MCP server name to remove from user configuration.
1121 ///
1122 /// <div class="warning">
1123 ///
1124 /// **Experimental.** This API is part of an experimental wire-protocol surface
1125 /// and may change or be removed in future SDK or CLI releases. Pin both the
1126 /// SDK and CLI versions if your code depends on it.
1127 ///
1128 /// </div>
1129 pub async fn remove(&self, params: McpConfigRemoveRequest) -> Result<(), Error> {
1130 let wire_params = serde_json::to_value(params)?;
1131 let _value = self
1132 .client
1133 .call(rpc_methods::MCP_CONFIG_REMOVE, Some(wire_params))
1134 .await?;
1135 Ok(())
1136 }
1137
1138 /// Enables MCP servers in user configuration for new sessions.
1139 ///
1140 /// Wire method: `mcp.config.enable`.
1141 ///
1142 /// # Parameters
1143 ///
1144 /// * `params` - MCP server names to enable for new sessions.
1145 ///
1146 /// <div class="warning">
1147 ///
1148 /// **Experimental.** This API is part of an experimental wire-protocol surface
1149 /// and may change or be removed in future SDK or CLI releases. Pin both the
1150 /// SDK and CLI versions if your code depends on it.
1151 ///
1152 /// </div>
1153 pub async fn enable(&self, params: McpConfigEnableRequest) -> Result<(), Error> {
1154 let wire_params = serde_json::to_value(params)?;
1155 let _value = self
1156 .client
1157 .call(rpc_methods::MCP_CONFIG_ENABLE, Some(wire_params))
1158 .await?;
1159 Ok(())
1160 }
1161
1162 /// Disables MCP servers in user configuration for new sessions.
1163 ///
1164 /// Wire method: `mcp.config.disable`.
1165 ///
1166 /// # Parameters
1167 ///
1168 /// * `params` - MCP server names to disable for new sessions.
1169 ///
1170 /// <div class="warning">
1171 ///
1172 /// **Experimental.** This API is part of an experimental wire-protocol surface
1173 /// and may change or be removed in future SDK or CLI releases. Pin both the
1174 /// SDK and CLI versions if your code depends on it.
1175 ///
1176 /// </div>
1177 pub async fn disable(&self, params: McpConfigDisableRequest) -> Result<(), Error> {
1178 let wire_params = serde_json::to_value(params)?;
1179 let _value = self
1180 .client
1181 .call(rpc_methods::MCP_CONFIG_DISABLE, Some(wire_params))
1182 .await?;
1183 Ok(())
1184 }
1185
1186 /// Drops this runtime process's in-memory MCP server-definition cache so the next MCP config read observes disk.
1187 ///
1188 /// Wire method: `mcp.config.reload`.
1189 ///
1190 /// <div class="warning">
1191 ///
1192 /// **Experimental.** This API is part of an experimental wire-protocol surface
1193 /// and may change or be removed in future SDK or CLI releases. Pin both the
1194 /// SDK and CLI versions if your code depends on it.
1195 ///
1196 /// </div>
1197 pub async fn reload(&self) -> Result<(), Error> {
1198 let wire_params = serde_json::json!({});
1199 let _value = self
1200 .client
1201 .call(rpc_methods::MCP_CONFIG_RELOAD, Some(wire_params))
1202 .await?;
1203 Ok(())
1204 }
1205}
1206
1207/// `models.*` RPCs.
1208#[derive(Clone, Copy)]
1209pub struct ClientRpcModels<'a> {
1210 pub(crate) client: &'a Client,
1211}
1212
1213impl<'a> ClientRpcModels<'a> {
1214 /// Lists Copilot models available to the authenticated user.
1215 ///
1216 /// Wire method: `models.list`.
1217 ///
1218 /// # Returns
1219 ///
1220 /// List of Copilot models available to the resolved user, including capabilities and billing metadata.
1221 ///
1222 /// <div class="warning">
1223 ///
1224 /// **Experimental.** This API is part of an experimental wire-protocol surface
1225 /// and may change or be removed in future SDK or CLI releases. Pin both the
1226 /// SDK and CLI versions if your code depends on it.
1227 ///
1228 /// </div>
1229 pub async fn list(&self) -> Result<ModelList, Error> {
1230 let wire_params = serde_json::json!({});
1231 let _value = self
1232 .client
1233 .call(rpc_methods::MODELS_LIST, Some(wire_params))
1234 .await?;
1235 Ok(serde_json::from_value(_value)?)
1236 }
1237
1238 /// Lists Copilot models available to the authenticated user.
1239 ///
1240 /// Wire method: `models.list`.
1241 ///
1242 /// # Parameters
1243 ///
1244 /// * `params` - Optional opaque account selection or compatibility GitHub token used to list models.
1245 ///
1246 /// # Returns
1247 ///
1248 /// List of Copilot models available to the resolved user, including capabilities and billing metadata.
1249 ///
1250 /// <div class="warning">
1251 ///
1252 /// **Experimental.** This API is part of an experimental wire-protocol surface
1253 /// and may change or be removed in future SDK or CLI releases. Pin both the
1254 /// SDK and CLI versions if your code depends on it.
1255 ///
1256 /// </div>
1257 pub async fn list_with_params(&self, params: ModelsListRequest) -> Result<ModelList, Error> {
1258 let wire_params = serde_json::to_value(params)?;
1259 let _value = self
1260 .client
1261 .call(rpc_methods::MODELS_LIST, Some(wire_params))
1262 .await?;
1263 Ok(serde_json::from_value(_value)?)
1264 }
1265
1266 /// Returns the running runtime's complete catalog of well-known built-in model IDs without authentication or network access.
1267 ///
1268 /// Wire method: `models.getBuiltInCatalog`.
1269 ///
1270 /// # Returns
1271 ///
1272 /// The running runtime's complete catalog of well-known built-in model IDs, including supported models and additional IDs with built-in metadata.
1273 ///
1274 /// <div class="warning">
1275 ///
1276 /// **Experimental.** This API is part of an experimental wire-protocol surface
1277 /// and may change or be removed in future SDK or CLI releases. Pin both the
1278 /// SDK and CLI versions if your code depends on it.
1279 ///
1280 /// </div>
1281 pub async fn get_built_in_catalog(&self) -> Result<BuiltInModelCatalog, Error> {
1282 let wire_params = serde_json::json!({});
1283 let _value = self
1284 .client
1285 .call(rpc_methods::MODELS_GETBUILTINCATALOG, Some(wire_params))
1286 .await?;
1287 Ok(serde_json::from_value(_value)?)
1288 }
1289}
1290
1291/// `plugins.*` RPCs.
1292#[derive(Clone, Copy)]
1293pub struct ClientRpcPlugins<'a> {
1294 pub(crate) client: &'a Client,
1295}
1296
1297impl<'a> ClientRpcPlugins<'a> {
1298 /// `plugins.builtin.*` sub-namespace.
1299 pub fn builtin(&self) -> ClientRpcPluginsBuiltin<'a> {
1300 ClientRpcPluginsBuiltin {
1301 client: self.client,
1302 }
1303 }
1304
1305 /// `plugins.marketplaces.*` sub-namespace.
1306 pub fn marketplaces(&self) -> ClientRpcPluginsMarketplaces<'a> {
1307 ClientRpcPluginsMarketplaces {
1308 client: self.client,
1309 }
1310 }
1311
1312 /// Lists plugins installed in user/global state.
1313 ///
1314 /// Wire method: `plugins.list`.
1315 ///
1316 /// # Returns
1317 ///
1318 /// Plugins installed in user/global state.
1319 ///
1320 /// <div class="warning">
1321 ///
1322 /// **Experimental.** This API is part of an experimental wire-protocol surface
1323 /// and may change or be removed in future SDK or CLI releases. Pin both the
1324 /// SDK and CLI versions if your code depends on it.
1325 ///
1326 /// </div>
1327 pub async fn list(&self) -> Result<PluginListResult, Error> {
1328 let wire_params = serde_json::json!({});
1329 let _value = self
1330 .client
1331 .call(rpc_methods::PLUGINS_LIST, Some(wire_params))
1332 .await?;
1333 Ok(serde_json::from_value(_value)?)
1334 }
1335
1336 /// Installs a plugin from a marketplace, GitHub repo, URL, or local path.
1337 ///
1338 /// Wire method: `plugins.install`.
1339 ///
1340 /// # Parameters
1341 ///
1342 /// * `params` - Plugin source and optional working directory for relative-path resolution.
1343 ///
1344 /// # Returns
1345 ///
1346 /// Result of installing a plugin.
1347 ///
1348 /// <div class="warning">
1349 ///
1350 /// **Experimental.** This API is part of an experimental wire-protocol surface
1351 /// and may change or be removed in future SDK or CLI releases. Pin both the
1352 /// SDK and CLI versions if your code depends on it.
1353 ///
1354 /// </div>
1355 pub async fn install(
1356 &self,
1357 params: PluginsInstallRequest,
1358 ) -> Result<PluginInstallResult, Error> {
1359 let wire_params = serde_json::to_value(params)?;
1360 let _value = self
1361 .client
1362 .call(rpc_methods::PLUGINS_INSTALL, Some(wire_params))
1363 .await?;
1364 Ok(serde_json::from_value(_value)?)
1365 }
1366
1367 /// Uninstalls an installed plugin.
1368 ///
1369 /// Wire method: `plugins.uninstall`.
1370 ///
1371 /// # Parameters
1372 ///
1373 /// * `params` - Name (or spec) of the plugin to uninstall.
1374 ///
1375 /// <div class="warning">
1376 ///
1377 /// **Experimental.** This API is part of an experimental wire-protocol surface
1378 /// and may change or be removed in future SDK or CLI releases. Pin both the
1379 /// SDK and CLI versions if your code depends on it.
1380 ///
1381 /// </div>
1382 pub async fn uninstall(&self, params: PluginsUninstallRequest) -> Result<(), Error> {
1383 let wire_params = serde_json::to_value(params)?;
1384 let _value = self
1385 .client
1386 .call(rpc_methods::PLUGINS_UNINSTALL, Some(wire_params))
1387 .await?;
1388 Ok(())
1389 }
1390
1391 /// Updates an installed plugin to its latest published version.
1392 ///
1393 /// Wire method: `plugins.update`.
1394 ///
1395 /// # Parameters
1396 ///
1397 /// * `params` - Name (or spec) of the plugin to update.
1398 ///
1399 /// # Returns
1400 ///
1401 /// Result of updating a single plugin.
1402 ///
1403 /// <div class="warning">
1404 ///
1405 /// **Experimental.** This API is part of an experimental wire-protocol surface
1406 /// and may change or be removed in future SDK or CLI releases. Pin both the
1407 /// SDK and CLI versions if your code depends on it.
1408 ///
1409 /// </div>
1410 pub async fn update(&self, params: PluginsUpdateRequest) -> Result<PluginUpdateResult, Error> {
1411 let wire_params = serde_json::to_value(params)?;
1412 let _value = self
1413 .client
1414 .call(rpc_methods::PLUGINS_UPDATE, Some(wire_params))
1415 .await?;
1416 Ok(serde_json::from_value(_value)?)
1417 }
1418
1419 /// Updates every installed plugin to its latest published version.
1420 ///
1421 /// Wire method: `plugins.updateAll`.
1422 ///
1423 /// # Returns
1424 ///
1425 /// Result of updating all installed plugins.
1426 ///
1427 /// <div class="warning">
1428 ///
1429 /// **Experimental.** This API is part of an experimental wire-protocol surface
1430 /// and may change or be removed in future SDK or CLI releases. Pin both the
1431 /// SDK and CLI versions if your code depends on it.
1432 ///
1433 /// </div>
1434 pub async fn update_all(&self) -> Result<PluginUpdateAllResult, Error> {
1435 let wire_params = serde_json::json!({});
1436 let _value = self
1437 .client
1438 .call(rpc_methods::PLUGINS_UPDATEALL, Some(wire_params))
1439 .await?;
1440 Ok(serde_json::from_value(_value)?)
1441 }
1442
1443 /// Enables installed plugins for new sessions.
1444 ///
1445 /// Wire method: `plugins.enable`.
1446 ///
1447 /// # Parameters
1448 ///
1449 /// * `params` - Plugin names (or specs) to enable, plus the optional working directory the repository-controlled guard is evaluated against.
1450 ///
1451 /// <div class="warning">
1452 ///
1453 /// **Experimental.** This API is part of an experimental wire-protocol surface
1454 /// and may change or be removed in future SDK or CLI releases. Pin both the
1455 /// SDK and CLI versions if your code depends on it.
1456 ///
1457 /// </div>
1458 pub async fn enable(&self, params: PluginsEnableRequest) -> Result<(), Error> {
1459 let wire_params = serde_json::to_value(params)?;
1460 let _value = self
1461 .client
1462 .call(rpc_methods::PLUGINS_ENABLE, Some(wire_params))
1463 .await?;
1464 Ok(())
1465 }
1466
1467 /// Disables installed plugins for new sessions.
1468 ///
1469 /// Wire method: `plugins.disable`.
1470 ///
1471 /// # Parameters
1472 ///
1473 /// * `params` - Plugin names (or specs) to disable, plus the optional working directory the repository-controlled guard is evaluated against.
1474 ///
1475 /// <div class="warning">
1476 ///
1477 /// **Experimental.** This API is part of an experimental wire-protocol surface
1478 /// and may change or be removed in future SDK or CLI releases. Pin both the
1479 /// SDK and CLI versions if your code depends on it.
1480 ///
1481 /// </div>
1482 pub async fn disable(&self, params: PluginsDisableRequest) -> Result<(), Error> {
1483 let wire_params = serde_json::to_value(params)?;
1484 let _value = self
1485 .client
1486 .call(rpc_methods::PLUGINS_DISABLE, Some(wire_params))
1487 .await?;
1488 Ok(())
1489 }
1490}
1491
1492/// `plugins.builtin.*` RPCs.
1493#[derive(Clone, Copy)]
1494pub struct ClientRpcPluginsBuiltin<'a> {
1495 pub(crate) client: &'a Client,
1496}
1497
1498impl<'a> ClientRpcPluginsBuiltin<'a> {
1499 /// Replaces this server's trusted built-in plugin directories while no sessions are active.
1500 ///
1501 /// Wire method: `plugins.builtin.set`.
1502 ///
1503 /// # Parameters
1504 ///
1505 /// * `params` - Trusted built-in plugin directories to use for this runtime process.
1506 ///
1507 /// <div class="warning">
1508 ///
1509 /// **Experimental.** This API is part of an experimental wire-protocol surface
1510 /// and may change or be removed in future SDK or CLI releases. Pin both the
1511 /// SDK and CLI versions if your code depends on it.
1512 ///
1513 /// </div>
1514 pub async fn set(&self, params: PluginsBuiltinSetRequest) -> Result<(), Error> {
1515 let wire_params = serde_json::to_value(params)?;
1516 let _value = self
1517 .client
1518 .call(rpc_methods::PLUGINS_BUILTIN_SET, Some(wire_params))
1519 .await?;
1520 Ok(())
1521 }
1522}
1523
1524/// `plugins.marketplaces.*` RPCs.
1525#[derive(Clone, Copy)]
1526pub struct ClientRpcPluginsMarketplaces<'a> {
1527 pub(crate) client: &'a Client,
1528}
1529
1530impl<'a> ClientRpcPluginsMarketplaces<'a> {
1531 /// Lists all registered marketplaces (defaults + user-added).
1532 ///
1533 /// Wire method: `plugins.marketplaces.list`.
1534 ///
1535 /// # Returns
1536 ///
1537 /// All registered marketplaces, including built-in defaults.
1538 ///
1539 /// <div class="warning">
1540 ///
1541 /// **Experimental.** This API is part of an experimental wire-protocol surface
1542 /// and may change or be removed in future SDK or CLI releases. Pin both the
1543 /// SDK and CLI versions if your code depends on it.
1544 ///
1545 /// </div>
1546 pub async fn list(&self) -> Result<MarketplaceListResult, Error> {
1547 let wire_params = serde_json::json!({});
1548 let _value = self
1549 .client
1550 .call(rpc_methods::PLUGINS_MARKETPLACES_LIST, Some(wire_params))
1551 .await?;
1552 Ok(serde_json::from_value(_value)?)
1553 }
1554
1555 /// Registers a new marketplace from a source (owner/repo, URL, or local path).
1556 ///
1557 /// Wire method: `plugins.marketplaces.add`.
1558 ///
1559 /// # Parameters
1560 ///
1561 /// * `params` - Marketplace source and optional working directory for relative-path resolution.
1562 ///
1563 /// # Returns
1564 ///
1565 /// Result of registering a new marketplace.
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 add(
1575 &self,
1576 params: PluginsMarketplacesAddRequest,
1577 ) -> Result<MarketplaceAddResult, Error> {
1578 let wire_params = serde_json::to_value(params)?;
1579 let _value = self
1580 .client
1581 .call(rpc_methods::PLUGINS_MARKETPLACES_ADD, Some(wire_params))
1582 .await?;
1583 Ok(serde_json::from_value(_value)?)
1584 }
1585
1586 /// 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`.
1587 ///
1588 /// Wire method: `plugins.marketplaces.remove`.
1589 ///
1590 /// # Parameters
1591 ///
1592 /// * `params` - Name of the marketplace to remove and an optional force flag.
1593 ///
1594 /// # Returns
1595 ///
1596 /// Outcome of the remove attempt, including dependent-plugin info when applicable.
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 remove(
1606 &self,
1607 params: PluginsMarketplacesRemoveRequest,
1608 ) -> Result<MarketplaceRemoveResult, Error> {
1609 let wire_params = serde_json::to_value(params)?;
1610 let _value = self
1611 .client
1612 .call(rpc_methods::PLUGINS_MARKETPLACES_REMOVE, Some(wire_params))
1613 .await?;
1614 Ok(serde_json::from_value(_value)?)
1615 }
1616
1617 /// Lists plugins advertised by a registered marketplace.
1618 ///
1619 /// Wire method: `plugins.marketplaces.browse`.
1620 ///
1621 /// # Parameters
1622 ///
1623 /// * `params` - Name of the marketplace whose plugin catalog to fetch.
1624 ///
1625 /// # Returns
1626 ///
1627 /// Plugins advertised by the marketplace.
1628 ///
1629 /// <div class="warning">
1630 ///
1631 /// **Experimental.** This API is part of an experimental wire-protocol surface
1632 /// and may change or be removed in future SDK or CLI releases. Pin both the
1633 /// SDK and CLI versions if your code depends on it.
1634 ///
1635 /// </div>
1636 pub async fn browse(
1637 &self,
1638 params: PluginsMarketplacesBrowseRequest,
1639 ) -> Result<MarketplaceBrowseResult, Error> {
1640 let wire_params = serde_json::to_value(params)?;
1641 let _value = self
1642 .client
1643 .call(rpc_methods::PLUGINS_MARKETPLACES_BROWSE, Some(wire_params))
1644 .await?;
1645 Ok(serde_json::from_value(_value)?)
1646 }
1647
1648 /// Re-fetches one or all registered marketplace catalogs.
1649 ///
1650 /// Wire method: `plugins.marketplaces.refresh`.
1651 ///
1652 /// # Returns
1653 ///
1654 /// Result of refreshing one or more marketplace catalogs.
1655 ///
1656 /// <div class="warning">
1657 ///
1658 /// **Experimental.** This API is part of an experimental wire-protocol surface
1659 /// and may change or be removed in future SDK or CLI releases. Pin both the
1660 /// SDK and CLI versions if your code depends on it.
1661 ///
1662 /// </div>
1663 pub async fn refresh(&self) -> Result<MarketplaceRefreshResult, Error> {
1664 let wire_params = serde_json::json!({});
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 /// Re-fetches one or all registered marketplace catalogs.
1673 ///
1674 /// Wire method: `plugins.marketplaces.refresh`.
1675 ///
1676 /// # Parameters
1677 ///
1678 /// * `params` - Optional marketplace name; omit to refresh all.
1679 ///
1680 /// # Returns
1681 ///
1682 /// Result of refreshing one or more marketplace catalogs.
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 refresh_with_params(
1692 &self,
1693 params: PluginsMarketplacesRefreshRequest,
1694 ) -> Result<MarketplaceRefreshResult, Error> {
1695 let wire_params = serde_json::to_value(params)?;
1696 let _value = self
1697 .client
1698 .call(rpc_methods::PLUGINS_MARKETPLACES_REFRESH, Some(wire_params))
1699 .await?;
1700 Ok(serde_json::from_value(_value)?)
1701 }
1702}
1703
1704/// `runtime.*` RPCs.
1705#[derive(Clone, Copy)]
1706pub struct ClientRpcRuntime<'a> {
1707 pub(crate) client: &'a Client,
1708}
1709
1710impl<'a> ClientRpcRuntime<'a> {
1711 /// Gracefully shuts down an SDK-owned runtime. The response is sent only after cleanup completes; callers may then terminate the owned runtime process.
1712 ///
1713 /// Wire method: `runtime.shutdown`.
1714 ///
1715 /// <div class="warning">
1716 ///
1717 /// **Experimental.** This API is part of an experimental wire-protocol surface
1718 /// and may change or be removed in future SDK or CLI releases. Pin both the
1719 /// SDK and CLI versions if your code depends on it.
1720 ///
1721 /// </div>
1722 pub async fn shutdown(&self) -> Result<(), Error> {
1723 let wire_params = serde_json::json!({});
1724 let _value = self
1725 .client
1726 .call(rpc_methods::RUNTIME_SHUTDOWN, Some(wire_params))
1727 .await?;
1728 Ok(())
1729 }
1730}
1731
1732/// `secrets.*` RPCs.
1733#[derive(Clone, Copy)]
1734pub struct ClientRpcSecrets<'a> {
1735 pub(crate) client: &'a Client,
1736}
1737
1738impl<'a> ClientRpcSecrets<'a> {
1739 /// Registers secret values for redaction in session logs and exports. The SDK calls this to inject dynamically generated secret values (e.g., OIDC tokens).
1740 ///
1741 /// Wire method: `secrets.addFilterValues`.
1742 ///
1743 /// # Parameters
1744 ///
1745 /// * `params` - Secret values to add to the redaction filter.
1746 ///
1747 /// # Returns
1748 ///
1749 /// Confirmation that the secret values were registered.
1750 ///
1751 /// <div class="warning">
1752 ///
1753 /// **Experimental.** This API is part of an experimental wire-protocol surface
1754 /// and may change or be removed in future SDK or CLI releases. Pin both the
1755 /// SDK and CLI versions if your code depends on it.
1756 ///
1757 /// </div>
1758 pub async fn add_filter_values(
1759 &self,
1760 params: SecretsAddFilterValuesRequest,
1761 ) -> Result<SecretsAddFilterValuesResult, Error> {
1762 let wire_params = serde_json::to_value(params)?;
1763 let _value = self
1764 .client
1765 .call(rpc_methods::SECRETS_ADDFILTERVALUES, Some(wire_params))
1766 .await?;
1767 Ok(serde_json::from_value(_value)?)
1768 }
1769}
1770
1771/// `sessionFs.*` RPCs.
1772#[derive(Clone, Copy)]
1773pub struct ClientRpcSessionFs<'a> {
1774 pub(crate) client: &'a Client,
1775}
1776
1777impl<'a> ClientRpcSessionFs<'a> {
1778 /// Registers an SDK client as the session filesystem provider.
1779 ///
1780 /// Wire method: `sessionFs.setProvider`.
1781 ///
1782 /// # Parameters
1783 ///
1784 /// * `params` - Initial working directory, session-state path layout, and path conventions used to register the calling SDK client as the session filesystem provider. A registered provider is authoritative for path interpretation and filesystem facts used by workspace permission validation. Paths are interpreted lexically; home-relative paths (`~` and `~/...`) and Windows drive-relative paths such as `C:foo` are unsupported. Until provider-side canonicalization is supported, providers must not expose symlinks inside allowed roots that escape those roots.
1785 ///
1786 /// # Returns
1787 ///
1788 /// Indicates whether the calling client was registered as the session filesystem provider.
1789 ///
1790 /// <div class="warning">
1791 ///
1792 /// **Experimental.** This API is part of an experimental wire-protocol surface
1793 /// and may change or be removed in future SDK or CLI releases. Pin both the
1794 /// SDK and CLI versions if your code depends on it.
1795 ///
1796 /// </div>
1797 pub async fn set_provider(
1798 &self,
1799 params: SessionFsSetProviderRequest,
1800 ) -> Result<SessionFsSetProviderResult, Error> {
1801 let wire_params = serde_json::to_value(params)?;
1802 let _value = self
1803 .client
1804 .call(rpc_methods::SESSIONFS_SETPROVIDER, Some(wire_params))
1805 .await?;
1806 Ok(serde_json::from_value(_value)?)
1807 }
1808}
1809
1810/// `sessions.*` RPCs.
1811#[derive(Clone, Copy)]
1812pub struct ClientRpcSessions<'a> {
1813 pub(crate) client: &'a Client,
1814}
1815
1816impl<'a> ClientRpcSessions<'a> {
1817 /// Creates or resumes a local session and returns the opened session ID.
1818 ///
1819 /// Wire method: `sessions.open`.
1820 ///
1821 /// # Returns
1822 ///
1823 /// Result of opening a session.
1824 ///
1825 /// <div class="warning">
1826 ///
1827 /// **Experimental.** This API is part of an experimental wire-protocol surface
1828 /// and may change or be removed in future SDK or CLI releases. Pin both the
1829 /// SDK and CLI versions if your code depends on it.
1830 ///
1831 /// </div>
1832 pub async fn open(&self) -> Result<SessionOpenResult, Error> {
1833 let wire_params = serde_json::json!({});
1834 let _value = self
1835 .client
1836 .call(rpc_methods::SESSIONS_OPEN, Some(wire_params))
1837 .await?;
1838 Ok(serde_json::from_value(_value)?)
1839 }
1840
1841 /// Creates a new session by forking persisted history from an existing session.
1842 ///
1843 /// Wire method: `sessions.fork`.
1844 ///
1845 /// # Parameters
1846 ///
1847 /// * `params` - Source session identifier to fork from, optional event-ID boundary, and optional friendly name for the new session.
1848 ///
1849 /// # Returns
1850 ///
1851 /// Identifier and optional friendly name assigned to the newly forked session.
1852 ///
1853 /// <div class="warning">
1854 ///
1855 /// **Experimental.** This API is part of an experimental wire-protocol surface
1856 /// and may change or be removed in future SDK or CLI releases. Pin both the
1857 /// SDK and CLI versions if your code depends on it.
1858 ///
1859 /// </div>
1860 pub async fn fork(&self, params: SessionsForkRequest) -> Result<SessionsForkResult, Error> {
1861 let wire_params = serde_json::to_value(params)?;
1862 let _value = self
1863 .client
1864 .call(rpc_methods::SESSIONS_FORK, Some(wire_params))
1865 .await?;
1866 Ok(serde_json::from_value(_value)?)
1867 }
1868
1869 /// Connects to an existing remote session and exposes it as an SDK session.
1870 ///
1871 /// Wire method: `sessions.connect`.
1872 ///
1873 /// # Parameters
1874 ///
1875 /// * `params` - Remote session connection parameters.
1876 ///
1877 /// # Returns
1878 ///
1879 /// Remote session connection result.
1880 ///
1881 /// <div class="warning">
1882 ///
1883 /// **Experimental.** This API is part of an experimental wire-protocol surface
1884 /// and may change or be removed in future SDK or CLI releases. Pin both the
1885 /// SDK and CLI versions if your code depends on it.
1886 ///
1887 /// </div>
1888 pub async fn connect(
1889 &self,
1890 params: ConnectRemoteSessionParams,
1891 ) -> Result<RemoteSessionConnectionResult, Error> {
1892 let wire_params = serde_json::to_value(params)?;
1893 let _value = self
1894 .client
1895 .call(rpc_methods::SESSIONS_CONNECT, Some(wire_params))
1896 .await?;
1897 Ok(serde_json::from_value(_value)?)
1898 }
1899
1900 /// 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.).
1901 ///
1902 /// Wire method: `sessions.list`.
1903 ///
1904 /// # Returns
1905 ///
1906 /// Sessions matching the filter, ordered most-recently-modified first.
1907 ///
1908 /// <div class="warning">
1909 ///
1910 /// **Experimental.** This API is part of an experimental wire-protocol surface
1911 /// and may change or be removed in future SDK or CLI releases. Pin both the
1912 /// SDK and CLI versions if your code depends on it.
1913 ///
1914 /// </div>
1915 pub async fn list(&self) -> Result<SessionList, Error> {
1916 let wire_params = serde_json::json!({});
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 /// 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.).
1925 ///
1926 /// Wire method: `sessions.list`.
1927 ///
1928 /// # Parameters
1929 ///
1930 /// * `params` - Optional source filter, metadata-load limit, and context filter applied to the returned sessions.
1931 ///
1932 /// # Returns
1933 ///
1934 /// Sessions matching the filter, ordered most-recently-modified first.
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 async fn list_with_params(
1944 &self,
1945 params: SessionsListRequest,
1946 ) -> Result<SessionList, Error> {
1947 let wire_params = serde_json::to_value(params)?;
1948 let _value = self
1949 .client
1950 .call(rpc_methods::SESSIONS_LIST, Some(wire_params))
1951 .await?;
1952 Ok(serde_json::from_value(_value)?)
1953 }
1954
1955 /// Reads lightweight persisted metadata for one local session without opening it.
1956 ///
1957 /// Wire method: `sessions.getMetadata`.
1958 ///
1959 /// # Parameters
1960 ///
1961 /// * `params` - Session ID whose persisted metadata should be read.
1962 ///
1963 /// # Returns
1964 ///
1965 /// Persisted local session metadata when the session exists.
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(crate) async fn get_metadata(
1975 &self,
1976 params: SessionsGetMetadataRequest,
1977 ) -> Result<SessionsGetMetadataResult, Error> {
1978 let wire_params = serde_json::to_value(params)?;
1979 let _value = self
1980 .client
1981 .call(rpc_methods::SESSIONS_GETMETADATA, Some(wire_params))
1982 .await?;
1983 Ok(serde_json::from_value(_value)?)
1984 }
1985
1986 /// Reads client-owned metadata for multiple persisted local sessions without opening them. Results preserve request order and report missing, corrupt, unsupported, or temporarily unavailable sessions independently.
1987 ///
1988 /// Wire method: `sessions.getClientMetadata`.
1989 ///
1990 /// # Parameters
1991 ///
1992 /// * `params` - Bounded batch request for client-owned metadata from persisted local sessions.
1993 ///
1994 /// # Returns
1995 ///
1996 /// Ordered client metadata outcomes for the requested local sessions.
1997 ///
1998 /// <div class="warning">
1999 ///
2000 /// **Experimental.** This API is part of an experimental wire-protocol surface
2001 /// and may change or be removed in future SDK or CLI releases. Pin both the
2002 /// SDK and CLI versions if your code depends on it.
2003 ///
2004 /// </div>
2005 pub async fn get_client_metadata(
2006 &self,
2007 params: SessionsGetClientMetadataRequest,
2008 ) -> Result<SessionsGetClientMetadataResult, Error> {
2009 let wire_params = serde_json::to_value(params)?;
2010 let _value = self
2011 .client
2012 .call(rpc_methods::SESSIONS_GETCLIENTMETADATA, Some(wire_params))
2013 .await?;
2014 Ok(serde_json::from_value(_value)?)
2015 }
2016
2017 /// Reads a page of durable events directly from a local session's persisted journal without creating, resuming, or activating the session. The first read pins the currently opened journal generation and its byte-length boundary; opaque cursor continuations remain on that generation across runtime-owned compaction, truncation, and rewrite operations, which replace the live path atomically, and events appended after the boundary are excluded. For cold hydration, await the first successful page before activation and establish lossless live-event buffering before resume; merge subsequent live events by ID, preserving persisted order and letting live payloads win. Continuations are process-local, single-use capabilities bound to the originating session and storage context and must be paged sequentially; concurrent or repeated use of the same cursor expires that duplicate read rather than reading the generation twice. A complete snapshot has cursorStatus 'ok' and hasMore false. Snapshots expire after five idle minutes, with at most eight retained per process and idle-only eviction under pressure; completion and cancelled-worker exit release their handles. No transcript copy is created, but retained handles may keep replaced files' disk blocks alive until release. Pages have a soft 1 MiB serialized event-array budget including resolved binary assets; one oversized event is returned alone to guarantee progress. Working memory also includes a record/lookahead and asset resolution; resolving the first binary reference may scan the full pinned generation to build a bounded offset index. If the snapshot expires, is evicted, is cancelled before a continuation is established, or becomes unreadable after an observable unsupported in-place shortening, the continuation returns cursorStatus 'expired' with an empty terminal page and never falls back to a different generation. A missing or initially unreadable journal is an RPC error. Persisted history excludes ephemeral events and may omit payloads that are reconstructed only for an active session; use the active session event stream for post-resume live events.
2018 ///
2019 /// Wire method: `sessions.readPersistedEvents`.
2020 ///
2021 /// # Parameters
2022 ///
2023 /// * `params` - Pagination options for reading an inactive or active local session's persisted event journal.
2024 ///
2025 /// # Returns
2026 ///
2027 /// Batch of session events returned by a read, with cursor and continuation metadata.
2028 ///
2029 /// <div class="warning">
2030 ///
2031 /// **Experimental.** This API is part of an experimental wire-protocol surface
2032 /// and may change or be removed in future SDK or CLI releases. Pin both the
2033 /// SDK and CLI versions if your code depends on it.
2034 ///
2035 /// </div>
2036 pub async fn read_persisted_events(
2037 &self,
2038 params: SessionsReadPersistedEventsRequest,
2039 ) -> Result<EventsReadResult, Error> {
2040 let wire_params = serde_json::to_value(params)?;
2041 let _value = self
2042 .client
2043 .call(rpc_methods::SESSIONS_READPERSISTEDEVENTS, Some(wire_params))
2044 .await?;
2045 Ok(serde_json::from_value(_value)?)
2046 }
2047
2048 /// Lists recent local session IDs that contain user-visible history, omitting housekeeping-only sessions.
2049 ///
2050 /// Wire method: `sessions.listNonEmptySessionIds`.
2051 ///
2052 /// # Parameters
2053 ///
2054 /// * `params` - Limit for non-empty local session IDs.
2055 ///
2056 /// # Returns
2057 ///
2058 /// Recent local session IDs that contain user-visible history.
2059 ///
2060 /// <div class="warning">
2061 ///
2062 /// **Experimental.** This API is part of an experimental wire-protocol surface
2063 /// and may change or be removed in future SDK or CLI releases. Pin both the
2064 /// SDK and CLI versions if your code depends on it.
2065 ///
2066 /// </div>
2067 pub(crate) async fn list_non_empty_session_ids(
2068 &self,
2069 params: SessionsListNonEmptySessionIdsRequest,
2070 ) -> Result<SessionsListNonEmptySessionIdsResult, Error> {
2071 let wire_params = serde_json::to_value(params)?;
2072 let _value = self
2073 .client
2074 .call(
2075 rpc_methods::SESSIONS_LISTNONEMPTYSESSIONIDS,
2076 Some(wire_params),
2077 )
2078 .await?;
2079 Ok(serde_json::from_value(_value)?)
2080 }
2081
2082 /// Finds the local session bound to a GitHub task ID, if any.
2083 ///
2084 /// Wire method: `sessions.findByTaskId`.
2085 ///
2086 /// # Parameters
2087 ///
2088 /// * `params` - GitHub task ID to look up.
2089 ///
2090 /// # Returns
2091 ///
2092 /// ID of the local session bound to the given GitHub task, or omitted when none.
2093 ///
2094 /// <div class="warning">
2095 ///
2096 /// **Experimental.** This API is part of an experimental wire-protocol surface
2097 /// and may change or be removed in future SDK or CLI releases. Pin both the
2098 /// SDK and CLI versions if your code depends on it.
2099 ///
2100 /// </div>
2101 pub async fn find_by_task_id(
2102 &self,
2103 params: SessionsFindByTaskIDRequest,
2104 ) -> Result<SessionsFindByTaskIDResult, Error> {
2105 let wire_params = serde_json::to_value(params)?;
2106 let _value = self
2107 .client
2108 .call(rpc_methods::SESSIONS_FINDBYTASKID, Some(wire_params))
2109 .await?;
2110 Ok(serde_json::from_value(_value)?)
2111 }
2112
2113 /// Resolves a UUID prefix to a unique session ID, if exactly one session matches.
2114 ///
2115 /// Wire method: `sessions.findByPrefix`.
2116 ///
2117 /// # Parameters
2118 ///
2119 /// * `params` - UUID prefix to resolve to a unique session ID.
2120 ///
2121 /// # Returns
2122 ///
2123 /// Session ID matching the prefix, omitted when no unique match exists.
2124 ///
2125 /// <div class="warning">
2126 ///
2127 /// **Experimental.** This API is part of an experimental wire-protocol surface
2128 /// and may change or be removed in future SDK or CLI releases. Pin both the
2129 /// SDK and CLI versions if your code depends on it.
2130 ///
2131 /// </div>
2132 pub async fn find_by_prefix(
2133 &self,
2134 params: SessionsFindByPrefixRequest,
2135 ) -> Result<SessionsFindByPrefixResult, Error> {
2136 let wire_params = serde_json::to_value(params)?;
2137 let _value = self
2138 .client
2139 .call(rpc_methods::SESSIONS_FINDBYPREFIX, Some(wire_params))
2140 .await?;
2141 Ok(serde_json::from_value(_value)?)
2142 }
2143
2144 /// Returns the most-relevant prior session for a given working-directory context.
2145 ///
2146 /// Wire method: `sessions.getLastForContext`.
2147 ///
2148 /// # Parameters
2149 ///
2150 /// * `params` - Optional working-directory context used to score session relevance.
2151 ///
2152 /// # Returns
2153 ///
2154 /// Most-relevant session ID for the supplied context, or omitted when no sessions exist.
2155 ///
2156 /// <div class="warning">
2157 ///
2158 /// **Experimental.** This API is part of an experimental wire-protocol surface
2159 /// and may change or be removed in future SDK or CLI releases. Pin both the
2160 /// SDK and CLI versions if your code depends on it.
2161 ///
2162 /// </div>
2163 pub async fn get_last_for_context(
2164 &self,
2165 params: SessionsGetLastForContextRequest,
2166 ) -> Result<SessionsGetLastForContextResult, Error> {
2167 let wire_params = serde_json::to_value(params)?;
2168 let _value = self
2169 .client
2170 .call(rpc_methods::SESSIONS_GETLASTFORCONTEXT, Some(wire_params))
2171 .await?;
2172 Ok(serde_json::from_value(_value)?)
2173 }
2174
2175 /// 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.
2176 ///
2177 /// Wire method: `sessions.getEventFilePath`.
2178 ///
2179 /// # Parameters
2180 ///
2181 /// * `params` - Session ID whose event-log file path to compute.
2182 ///
2183 /// # Returns
2184 ///
2185 /// Absolute path to the session's events.jsonl file on disk.
2186 ///
2187 /// <div class="warning">
2188 ///
2189 /// **Experimental.** This API is part of an experimental wire-protocol surface
2190 /// and may change or be removed in future SDK or CLI releases. Pin both the
2191 /// SDK and CLI versions if your code depends on it.
2192 ///
2193 /// </div>
2194 pub(crate) async fn get_event_file_path(
2195 &self,
2196 params: SessionsGetEventFilePathRequest,
2197 ) -> Result<SessionsGetEventFilePathResult, Error> {
2198 let wire_params = serde_json::to_value(params)?;
2199 let _value = self
2200 .client
2201 .call(rpc_methods::SESSIONS_GETEVENTFILEPATH, Some(wire_params))
2202 .await?;
2203 Ok(serde_json::from_value(_value)?)
2204 }
2205
2206 /// Returns the on-disk byte size of each session's workspace directory.
2207 ///
2208 /// Wire method: `sessions.getSizes`.
2209 ///
2210 /// # Returns
2211 ///
2212 /// Map of sessionId -> on-disk size in bytes for each session's workspace directory.
2213 ///
2214 /// <div class="warning">
2215 ///
2216 /// **Experimental.** This API is part of an experimental wire-protocol surface
2217 /// and may change or be removed in future SDK or CLI releases. Pin both the
2218 /// SDK and CLI versions if your code depends on it.
2219 ///
2220 /// </div>
2221 pub async fn get_sizes(&self) -> Result<SessionSizes, Error> {
2222 let wire_params = serde_json::json!({});
2223 let _value = self
2224 .client
2225 .call(rpc_methods::SESSIONS_GETSIZES, Some(wire_params))
2226 .await?;
2227 Ok(serde_json::from_value(_value)?)
2228 }
2229
2230 /// Returns the subset of the supplied session IDs that are currently held by another running process.
2231 ///
2232 /// Wire method: `sessions.checkInUse`.
2233 ///
2234 /// # Parameters
2235 ///
2236 /// * `params` - Session IDs to test for live in-use locks.
2237 ///
2238 /// # Returns
2239 ///
2240 /// Session IDs from the input set that are currently in use by another process.
2241 ///
2242 /// <div class="warning">
2243 ///
2244 /// **Experimental.** This API is part of an experimental wire-protocol surface
2245 /// and may change or be removed in future SDK or CLI releases. Pin both the
2246 /// SDK and CLI versions if your code depends on it.
2247 ///
2248 /// </div>
2249 pub async fn check_in_use(
2250 &self,
2251 params: SessionsCheckInUseRequest,
2252 ) -> Result<SessionsCheckInUseResult, Error> {
2253 let wire_params = serde_json::to_value(params)?;
2254 let _value = self
2255 .client
2256 .call(rpc_methods::SESSIONS_CHECKINUSE, Some(wire_params))
2257 .await?;
2258 Ok(serde_json::from_value(_value)?)
2259 }
2260
2261 /// 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.
2262 ///
2263 /// Wire method: `sessions.getPersistedRemoteSteerable`.
2264 ///
2265 /// # Parameters
2266 ///
2267 /// * `params` - Session ID to look up the persisted remote-steerable flag for.
2268 ///
2269 /// # Returns
2270 ///
2271 /// The session's persisted remote-steerable flag, or omitted when no value has been persisted.
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(crate) async fn get_persisted_remote_steerable(
2281 &self,
2282 params: SessionsGetPersistedRemoteSteerableRequest,
2283 ) -> Result<SessionsGetPersistedRemoteSteerableResult, Error> {
2284 let wire_params = serde_json::to_value(params)?;
2285 let _value = self
2286 .client
2287 .call(
2288 rpc_methods::SESSIONS_GETPERSISTEDREMOTESTEERABLE,
2289 Some(wire_params),
2290 )
2291 .await?;
2292 Ok(serde_json::from_value(_value)?)
2293 }
2294
2295 /// Closes a session: emits shutdown, flushes pending events, releases the in-use lock, and disposes the active session.
2296 ///
2297 /// Wire method: `sessions.close`.
2298 ///
2299 /// # Parameters
2300 ///
2301 /// * `params` - Session ID to close.
2302 ///
2303 /// # Returns
2304 ///
2305 /// 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.
2306 ///
2307 /// <div class="warning">
2308 ///
2309 /// **Experimental.** This API is part of an experimental wire-protocol surface
2310 /// and may change or be removed in future SDK or CLI releases. Pin both the
2311 /// SDK and CLI versions if your code depends on it.
2312 ///
2313 /// </div>
2314 pub async fn close(&self, params: SessionsCloseRequest) -> Result<SessionsCloseResult, Error> {
2315 let wire_params = serde_json::to_value(params)?;
2316 let _value = self
2317 .client
2318 .call(rpc_methods::SESSIONS_CLOSE, Some(wire_params))
2319 .await?;
2320 Ok(serde_json::from_value(_value)?)
2321 }
2322
2323 /// Closes, deactivates, and deletes a set of sessions, returning the bytes freed per session.
2324 ///
2325 /// Wire method: `sessions.bulkDelete`.
2326 ///
2327 /// # Parameters
2328 ///
2329 /// * `params` - Session IDs to close, deactivate, and delete from disk.
2330 ///
2331 /// # Returns
2332 ///
2333 /// Map of sessionId -> bytes freed by removing the session's workspace directory.
2334 ///
2335 /// <div class="warning">
2336 ///
2337 /// **Experimental.** This API is part of an experimental wire-protocol surface
2338 /// and may change or be removed in future SDK or CLI releases. Pin both the
2339 /// SDK and CLI versions if your code depends on it.
2340 ///
2341 /// </div>
2342 pub async fn bulk_delete(
2343 &self,
2344 params: SessionsBulkDeleteRequest,
2345 ) -> Result<SessionBulkDeleteResult, Error> {
2346 let wire_params = serde_json::to_value(params)?;
2347 let _value = self
2348 .client
2349 .call(rpc_methods::SESSIONS_BULKDELETE, Some(wire_params))
2350 .await?;
2351 Ok(serde_json::from_value(_value)?)
2352 }
2353
2354 /// Deletes one local session from disk after running the same lifecycle hooks as the session manager.
2355 ///
2356 /// Wire method: `sessions.delete`.
2357 ///
2358 /// # Parameters
2359 ///
2360 /// * `params` - Session ID to delete from disk.
2361 ///
2362 /// <div class="warning">
2363 ///
2364 /// **Experimental.** This API is part of an experimental wire-protocol surface
2365 /// and may change or be removed in future SDK or CLI releases. Pin both the
2366 /// SDK and CLI versions if your code depends on it.
2367 ///
2368 /// </div>
2369 pub(crate) async fn delete(&self, params: SessionsDeleteRequest) -> Result<(), Error> {
2370 let wire_params = serde_json::to_value(params)?;
2371 let _value = self
2372 .client
2373 .call(rpc_methods::SESSIONS_DELETE, Some(wire_params))
2374 .await?;
2375 Ok(())
2376 }
2377
2378 /// Deletes sessions older than the given threshold, with optional dry-run and exclusion list.
2379 ///
2380 /// Wire method: `sessions.pruneOld`.
2381 ///
2382 /// # Parameters
2383 ///
2384 /// * `params` - Age threshold and optional flags controlling which old sessions are pruned (or simulated when dryRun is true).
2385 ///
2386 /// # Returns
2387 ///
2388 /// Outcome of the prune operation: deleted IDs, dry-run candidates, skipped IDs, total bytes freed, and the dry-run flag.
2389 ///
2390 /// <div class="warning">
2391 ///
2392 /// **Experimental.** This API is part of an experimental wire-protocol surface
2393 /// and may change or be removed in future SDK or CLI releases. Pin both the
2394 /// SDK and CLI versions if your code depends on it.
2395 ///
2396 /// </div>
2397 pub async fn prune_old(
2398 &self,
2399 params: SessionsPruneOldRequest,
2400 ) -> Result<SessionPruneResult, Error> {
2401 let wire_params = serde_json::to_value(params)?;
2402 let _value = self
2403 .client
2404 .call(rpc_methods::SESSIONS_PRUNEOLD, Some(wire_params))
2405 .await?;
2406 Ok(serde_json::from_value(_value)?)
2407 }
2408
2409 /// Flushes a session's pending events to disk.
2410 ///
2411 /// Wire method: `sessions.save`.
2412 ///
2413 /// # Parameters
2414 ///
2415 /// * `params` - Session ID whose pending events should be flushed to disk.
2416 ///
2417 /// # Returns
2418 ///
2419 /// Flush a session's pending events to disk. No-op when no writer exists for the session (e.g., already closed).
2420 ///
2421 /// <div class="warning">
2422 ///
2423 /// **Experimental.** This API is part of an experimental wire-protocol surface
2424 /// and may change or be removed in future SDK or CLI releases. Pin both the
2425 /// SDK and CLI versions if your code depends on it.
2426 ///
2427 /// </div>
2428 pub async fn save(&self, params: SessionsSaveRequest) -> Result<SessionsSaveResult, Error> {
2429 let wire_params = serde_json::to_value(params)?;
2430 let _value = self
2431 .client
2432 .call(rpc_methods::SESSIONS_SAVE, Some(wire_params))
2433 .await?;
2434 Ok(serde_json::from_value(_value)?)
2435 }
2436
2437 /// Releases the in-use lock held by this process for a session.
2438 ///
2439 /// Wire method: `sessions.releaseLock`.
2440 ///
2441 /// # Parameters
2442 ///
2443 /// * `params` - Session ID whose in-use lock should be released.
2444 ///
2445 /// # Returns
2446 ///
2447 /// 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.
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 release_lock(
2457 &self,
2458 params: SessionsReleaseLockRequest,
2459 ) -> Result<SessionsReleaseLockResult, Error> {
2460 let wire_params = serde_json::to_value(params)?;
2461 let _value = self
2462 .client
2463 .call(rpc_methods::SESSIONS_RELEASELOCK, Some(wire_params))
2464 .await?;
2465 Ok(serde_json::from_value(_value)?)
2466 }
2467
2468 /// Backfills missing summary and context fields on the supplied session metadata records.
2469 ///
2470 /// Wire method: `sessions.enrichMetadata`.
2471 ///
2472 /// # Parameters
2473 ///
2474 /// * `params` - Session metadata records to enrich with summary and context information.
2475 ///
2476 /// # Returns
2477 ///
2478 /// The enriched metadata records, with summary and context fields backfilled where available. Sessions confirmed empty and unnamed are omitted.
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 enrich_metadata(
2488 &self,
2489 params: SessionsEnrichMetadataRequest,
2490 ) -> Result<SessionEnrichMetadataResult, Error> {
2491 let wire_params = serde_json::to_value(params)?;
2492 let _value = self
2493 .client
2494 .call(rpc_methods::SESSIONS_ENRICHMETADATA, Some(wire_params))
2495 .await?;
2496 Ok(serde_json::from_value(_value)?)
2497 }
2498
2499 /// Reloads user, plugin, and (optionally) repo hooks on the active session.
2500 ///
2501 /// Wire method: `sessions.reloadPluginHooks`.
2502 ///
2503 /// # Parameters
2504 ///
2505 /// * `params` - Active session ID and an optional flag for deferring repo-level hooks until folder trust.
2506 ///
2507 /// # Returns
2508 ///
2509 /// 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.
2510 ///
2511 /// <div class="warning">
2512 ///
2513 /// **Experimental.** This API is part of an experimental wire-protocol surface
2514 /// and may change or be removed in future SDK or CLI releases. Pin both the
2515 /// SDK and CLI versions if your code depends on it.
2516 ///
2517 /// </div>
2518 pub async fn reload_plugin_hooks(
2519 &self,
2520 params: SessionsReloadPluginHooksRequest,
2521 ) -> Result<SessionsReloadPluginHooksResult, Error> {
2522 let wire_params = serde_json::to_value(params)?;
2523 let _value = self
2524 .client
2525 .call(rpc_methods::SESSIONS_RELOADPLUGINHOOKS, Some(wire_params))
2526 .await?;
2527 Ok(serde_json::from_value(_value)?)
2528 }
2529
2530 /// Loads previously-deferred repo-level hooks on the active session, returning queued startup prompts.
2531 ///
2532 /// Wire method: `sessions.loadDeferredRepoHooks`.
2533 ///
2534 /// # Parameters
2535 ///
2536 /// * `params` - Active session ID whose deferred repo-level hooks should be loaded.
2537 ///
2538 /// # Returns
2539 ///
2540 /// Queued repo-level startup prompts and the total hook command count after loading.
2541 ///
2542 /// <div class="warning">
2543 ///
2544 /// **Experimental.** This API is part of an experimental wire-protocol surface
2545 /// and may change or be removed in future SDK or CLI releases. Pin both the
2546 /// SDK and CLI versions if your code depends on it.
2547 ///
2548 /// </div>
2549 pub async fn load_deferred_repo_hooks(
2550 &self,
2551 params: SessionsLoadDeferredRepoHooksRequest,
2552 ) -> Result<SessionLoadDeferredRepoHooksResult, Error> {
2553 let wire_params = serde_json::to_value(params)?;
2554 let _value = self
2555 .client
2556 .call(
2557 rpc_methods::SESSIONS_LOADDEFERREDREPOHOOKS,
2558 Some(wire_params),
2559 )
2560 .await?;
2561 Ok(serde_json::from_value(_value)?)
2562 }
2563
2564 /// Replaces the manager-wide additional plugins registered with the session manager.
2565 ///
2566 /// Wire method: `sessions.setAdditionalPlugins`.
2567 ///
2568 /// # Parameters
2569 ///
2570 /// * `params` - Manager-wide additional plugins to register; replaces any previously-configured set.
2571 ///
2572 /// # Returns
2573 ///
2574 /// 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.
2575 ///
2576 /// <div class="warning">
2577 ///
2578 /// **Experimental.** This API is part of an experimental wire-protocol surface
2579 /// and may change or be removed in future SDK or CLI releases. Pin both the
2580 /// SDK and CLI versions if your code depends on it.
2581 ///
2582 /// </div>
2583 pub async fn set_additional_plugins(
2584 &self,
2585 params: SessionsSetAdditionalPluginsRequest,
2586 ) -> Result<SessionsSetAdditionalPluginsResult, Error> {
2587 let wire_params = serde_json::to_value(params)?;
2588 let _value = self
2589 .client
2590 .call(
2591 rpc_methods::SESSIONS_SETADDITIONALPLUGINS,
2592 Some(wire_params),
2593 )
2594 .await?;
2595 Ok(serde_json::from_value(_value)?)
2596 }
2597
2598 /// 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.
2599 ///
2600 /// Wire method: `sessions.getBoardEntryCount`.
2601 ///
2602 /// # Parameters
2603 ///
2604 /// * `params` - Session ID whose board entry count should be returned.
2605 ///
2606 /// # Returns
2607 ///
2608 /// Dynamic-context board entry count, when available.
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(crate) async fn get_board_entry_count(
2618 &self,
2619 params: SessionsGetBoardEntryCountRequest,
2620 ) -> Result<SessionsGetBoardEntryCountResult, Error> {
2621 let wire_params = serde_json::to_value(params)?;
2622 let _value = self
2623 .client
2624 .call(rpc_methods::SESSIONS_GETBOARDENTRYCOUNT, Some(wire_params))
2625 .await?;
2626 Ok(serde_json::from_value(_value)?)
2627 }
2628
2629 /// 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.
2630 ///
2631 /// Wire method: `sessions.startRemoteControl`.
2632 ///
2633 /// # Parameters
2634 ///
2635 /// * `params` - Parameters for attaching the remote-control singleton to a session.
2636 ///
2637 /// # Returns
2638 ///
2639 /// Wrapper for the singleton's current status.
2640 ///
2641 /// <div class="warning">
2642 ///
2643 /// **Experimental.** This API is part of an experimental wire-protocol surface
2644 /// and may change or be removed in future SDK or CLI releases. Pin both the
2645 /// SDK and CLI versions if your code depends on it.
2646 ///
2647 /// </div>
2648 pub async fn start_remote_control(
2649 &self,
2650 params: SessionsStartRemoteControlRequest,
2651 ) -> Result<RemoteControlStatusResult, Error> {
2652 let wire_params = serde_json::to_value(params)?;
2653 let _value = self
2654 .client
2655 .call(rpc_methods::SESSIONS_STARTREMOTECONTROL, Some(wire_params))
2656 .await?;
2657 Ok(serde_json::from_value(_value)?)
2658 }
2659
2660 /// 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.
2661 ///
2662 /// Wire method: `sessions.transferRemoteControl`.
2663 ///
2664 /// # Parameters
2665 ///
2666 /// * `params` - Parameters for atomically rebinding the remote-control singleton.
2667 ///
2668 /// # Returns
2669 ///
2670 /// Outcome of a transferRemoteControl call.
2671 ///
2672 /// <div class="warning">
2673 ///
2674 /// **Experimental.** This API is part of an experimental wire-protocol surface
2675 /// and may change or be removed in future SDK or CLI releases. Pin both the
2676 /// SDK and CLI versions if your code depends on it.
2677 ///
2678 /// </div>
2679 pub async fn transfer_remote_control(
2680 &self,
2681 params: SessionsTransferRemoteControlRequest,
2682 ) -> Result<RemoteControlTransferResult, Error> {
2683 let wire_params = serde_json::to_value(params)?;
2684 let _value = self
2685 .client
2686 .call(
2687 rpc_methods::SESSIONS_TRANSFERREMOTECONTROL,
2688 Some(wire_params),
2689 )
2690 .await?;
2691 Ok(serde_json::from_value(_value)?)
2692 }
2693
2694 /// 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.
2695 ///
2696 /// Wire method: `sessions.setRemoteControlSteering`.
2697 ///
2698 /// # Parameters
2699 ///
2700 /// * `params` - Patch for the singleton's steering state.
2701 ///
2702 /// # Returns
2703 ///
2704 /// Wrapper for the singleton's current status.
2705 ///
2706 /// <div class="warning">
2707 ///
2708 /// **Experimental.** This API is part of an experimental wire-protocol surface
2709 /// and may change or be removed in future SDK or CLI releases. Pin both the
2710 /// SDK and CLI versions if your code depends on it.
2711 ///
2712 /// </div>
2713 pub async fn set_remote_control_steering(
2714 &self,
2715 params: SessionsSetRemoteControlSteeringRequest,
2716 ) -> Result<RemoteControlStatusResult, Error> {
2717 let wire_params = serde_json::to_value(params)?;
2718 let _value = self
2719 .client
2720 .call(
2721 rpc_methods::SESSIONS_SETREMOTECONTROLSTEERING,
2722 Some(wire_params),
2723 )
2724 .await?;
2725 Ok(serde_json::from_value(_value)?)
2726 }
2727
2728 /// 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).
2729 ///
2730 /// Wire method: `sessions.stopRemoteControl`.
2731 ///
2732 /// # Returns
2733 ///
2734 /// Outcome of a stopRemoteControl call.
2735 ///
2736 /// <div class="warning">
2737 ///
2738 /// **Experimental.** This API is part of an experimental wire-protocol surface
2739 /// and may change or be removed in future SDK or CLI releases. Pin both the
2740 /// SDK and CLI versions if your code depends on it.
2741 ///
2742 /// </div>
2743 pub async fn stop_remote_control(&self) -> Result<RemoteControlStopResult, Error> {
2744 let wire_params = serde_json::json!({});
2745 let _value = self
2746 .client
2747 .call(rpc_methods::SESSIONS_STOPREMOTECONTROL, Some(wire_params))
2748 .await?;
2749 Ok(serde_json::from_value(_value)?)
2750 }
2751
2752 /// 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).
2753 ///
2754 /// Wire method: `sessions.stopRemoteControl`.
2755 ///
2756 /// # Parameters
2757 ///
2758 /// * `params` - Parameters for stopping the remote-control singleton.
2759 ///
2760 /// # Returns
2761 ///
2762 /// Outcome of a stopRemoteControl call.
2763 ///
2764 /// <div class="warning">
2765 ///
2766 /// **Experimental.** This API is part of an experimental wire-protocol surface
2767 /// and may change or be removed in future SDK or CLI releases. Pin both the
2768 /// SDK and CLI versions if your code depends on it.
2769 ///
2770 /// </div>
2771 pub async fn stop_remote_control_with_params(
2772 &self,
2773 params: SessionsStopRemoteControlRequest,
2774 ) -> Result<RemoteControlStopResult, Error> {
2775 let wire_params = serde_json::to_value(params)?;
2776 let _value = self
2777 .client
2778 .call(rpc_methods::SESSIONS_STOPREMOTECONTROL, Some(wire_params))
2779 .await?;
2780 Ok(serde_json::from_value(_value)?)
2781 }
2782
2783 /// Returns the current state of the remote-control singleton, including the attached session id and frontend URL when active.
2784 ///
2785 /// Wire method: `sessions.getRemoteControlStatus`.
2786 ///
2787 /// # Returns
2788 ///
2789 /// Wrapper for the singleton's current status.
2790 ///
2791 /// <div class="warning">
2792 ///
2793 /// **Experimental.** This API is part of an experimental wire-protocol surface
2794 /// and may change or be removed in future SDK or CLI releases. Pin both the
2795 /// SDK and CLI versions if your code depends on it.
2796 ///
2797 /// </div>
2798 pub async fn get_remote_control_status(&self) -> Result<RemoteControlStatusResult, Error> {
2799 let wire_params = serde_json::json!({});
2800 let _value = self
2801 .client
2802 .call(
2803 rpc_methods::SESSIONS_GETREMOTECONTROLSTATUS,
2804 Some(wire_params),
2805 )
2806 .await?;
2807 Ok(serde_json::from_value(_value)?)
2808 }
2809
2810 /// Attaches (or detaches) an in-process ExtensionController delegate for the given session in a local host adapter. Pass `controller: undefined` to detach. Internal because the controller cannot cross the JSON-RPC boundary; the runtime manages its own session extension service.
2811 ///
2812 /// Wire method: `sessions.configureSessionExtensions`.
2813 ///
2814 /// # Parameters
2815 ///
2816 /// * `params` - Params to attach or detach an in-process ExtensionController delegate.
2817 ///
2818 /// <div class="warning">
2819 ///
2820 /// **Experimental.** This API is part of an experimental wire-protocol surface
2821 /// and may change or be removed in future SDK or CLI releases. Pin both the
2822 /// SDK and CLI versions if your code depends on it.
2823 ///
2824 /// </div>
2825 pub(crate) async fn configure_session_extensions(
2826 &self,
2827 params: ConfigureSessionExtensionsParams,
2828 ) -> Result<(), Error> {
2829 let wire_params = serde_json::to_value(params)?;
2830 let _value = self
2831 .client
2832 .call(
2833 rpc_methods::SESSIONS_CONFIGURESESSIONEXTENSIONS,
2834 Some(wire_params),
2835 )
2836 .await?;
2837 Ok(())
2838 }
2839}
2840
2841/// `skills.*` RPCs.
2842#[derive(Clone, Copy)]
2843pub struct ClientRpcSkills<'a> {
2844 pub(crate) client: &'a Client,
2845}
2846
2847impl<'a> ClientRpcSkills<'a> {
2848 /// `skills.config.*` sub-namespace.
2849 pub fn config(&self) -> ClientRpcSkillsConfig<'a> {
2850 ClientRpcSkillsConfig {
2851 client: self.client,
2852 }
2853 }
2854
2855 /// Discovers skills across global and project sources.
2856 ///
2857 /// Wire method: `skills.discover`.
2858 ///
2859 /// # Parameters
2860 ///
2861 /// * `params` - Optional project paths and additional skill directories to include in discovery.
2862 ///
2863 /// # Returns
2864 ///
2865 /// Skills discovered across global and project sources.
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 discover(&self, params: SkillsDiscoverRequest) -> Result<ServerSkillList, Error> {
2875 let wire_params = serde_json::to_value(params)?;
2876 let _value = self
2877 .client
2878 .call(rpc_methods::SKILLS_DISCOVER, Some(wire_params))
2879 .await?;
2880 Ok(serde_json::from_value(_value)?)
2881 }
2882
2883 /// 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.
2884 ///
2885 /// Wire method: `skills.getDiscoveryPaths`.
2886 ///
2887 /// # Parameters
2888 ///
2889 /// * `params` - Optional project paths to enumerate.
2890 ///
2891 /// # Returns
2892 ///
2893 /// Canonical locations where skills can be created so the runtime will recognize them.
2894 ///
2895 /// <div class="warning">
2896 ///
2897 /// **Experimental.** This API is part of an experimental wire-protocol surface
2898 /// and may change or be removed in future SDK or CLI releases. Pin both the
2899 /// SDK and CLI versions if your code depends on it.
2900 ///
2901 /// </div>
2902 pub async fn get_discovery_paths(
2903 &self,
2904 params: SkillsGetDiscoveryPathsRequest,
2905 ) -> Result<SkillDiscoveryPathList, Error> {
2906 let wire_params = serde_json::to_value(params)?;
2907 let _value = self
2908 .client
2909 .call(rpc_methods::SKILLS_GETDISCOVERYPATHS, Some(wire_params))
2910 .await?;
2911 Ok(serde_json::from_value(_value)?)
2912 }
2913}
2914
2915/// `skills.config.*` RPCs.
2916#[derive(Clone, Copy)]
2917pub struct ClientRpcSkillsConfig<'a> {
2918 pub(crate) client: &'a Client,
2919}
2920
2921impl<'a> ClientRpcSkillsConfig<'a> {
2922 /// Replaces the global list of disabled skills.
2923 ///
2924 /// Wire method: `skills.config.setDisabledSkills`.
2925 ///
2926 /// # Parameters
2927 ///
2928 /// * `params` - Skill names to mark as disabled in global configuration, replacing any previous list.
2929 ///
2930 /// <div class="warning">
2931 ///
2932 /// **Experimental.** This API is part of an experimental wire-protocol surface
2933 /// and may change or be removed in future SDK or CLI releases. Pin both the
2934 /// SDK and CLI versions if your code depends on it.
2935 ///
2936 /// </div>
2937 pub async fn set_disabled_skills(
2938 &self,
2939 params: SkillsConfigSetDisabledSkillsRequest,
2940 ) -> Result<(), Error> {
2941 let wire_params = serde_json::to_value(params)?;
2942 let _value = self
2943 .client
2944 .call(
2945 rpc_methods::SKILLS_CONFIG_SETDISABLEDSKILLS,
2946 Some(wire_params),
2947 )
2948 .await?;
2949 Ok(())
2950 }
2951
2952 /// Atomically adds or removes one skill from the disabled list.
2953 ///
2954 /// Wire method: `skills.config.setSkillDisabled`.
2955 ///
2956 /// # Parameters
2957 ///
2958 /// * `params` - Adds or removes a single skill from the global disabled list, leaving every other entry untouched.
2959 ///
2960 /// <div class="warning">
2961 ///
2962 /// **Experimental.** This API is part of an experimental wire-protocol surface
2963 /// and may change or be removed in future SDK or CLI releases. Pin both the
2964 /// SDK and CLI versions if your code depends on it.
2965 ///
2966 /// </div>
2967 pub async fn set_skill_disabled(
2968 &self,
2969 params: SkillsConfigSetSkillDisabledRequest,
2970 ) -> Result<(), Error> {
2971 let wire_params = serde_json::to_value(params)?;
2972 let _value = self
2973 .client
2974 .call(
2975 rpc_methods::SKILLS_CONFIG_SETSKILLDISABLED,
2976 Some(wire_params),
2977 )
2978 .await?;
2979 Ok(())
2980 }
2981}
2982
2983/// `tools.*` RPCs.
2984#[derive(Clone, Copy)]
2985pub struct ClientRpcTools<'a> {
2986 pub(crate) client: &'a Client,
2987}
2988
2989impl<'a> ClientRpcTools<'a> {
2990 /// Lists built-in tools available for a model.
2991 ///
2992 /// Wire method: `tools.list`.
2993 ///
2994 /// # Parameters
2995 ///
2996 /// * `params` - Optional model identifier whose tool overrides should be applied to the listing.
2997 ///
2998 /// # Returns
2999 ///
3000 /// Built-in tools available for the requested model, with their parameters and instructions.
3001 ///
3002 /// <div class="warning">
3003 ///
3004 /// **Experimental.** This API is part of an experimental wire-protocol surface
3005 /// and may change or be removed in future SDK or CLI releases. Pin both the
3006 /// SDK and CLI versions if your code depends on it.
3007 ///
3008 /// </div>
3009 pub async fn list(&self, params: ToolsListRequest) -> Result<ToolList, Error> {
3010 let wire_params = serde_json::to_value(params)?;
3011 let _value = self
3012 .client
3013 .call(rpc_methods::TOOLS_LIST, Some(wire_params))
3014 .await?;
3015 Ok(serde_json::from_value(_value)?)
3016 }
3017}
3018
3019/// `user.*` RPCs.
3020#[derive(Clone, Copy)]
3021pub struct ClientRpcUser<'a> {
3022 pub(crate) client: &'a Client,
3023}
3024
3025impl<'a> ClientRpcUser<'a> {
3026 /// `user.settings.*` sub-namespace.
3027 pub fn settings(&self) -> ClientRpcUserSettings<'a> {
3028 ClientRpcUserSettings {
3029 client: self.client,
3030 }
3031 }
3032}
3033
3034/// `user.settings.*` RPCs.
3035#[derive(Clone, Copy)]
3036pub struct ClientRpcUserSettings<'a> {
3037 pub(crate) client: &'a Client,
3038}
3039
3040impl<'a> ClientRpcUserSettings<'a> {
3041 /// Drops this runtime process's in-memory user settings cache so the next settings read observes disk.
3042 ///
3043 /// Wire method: `user.settings.reload`.
3044 ///
3045 /// <div class="warning">
3046 ///
3047 /// **Experimental.** This API is part of an experimental wire-protocol surface
3048 /// and may change or be removed in future SDK or CLI releases. Pin both the
3049 /// SDK and CLI versions if your code depends on it.
3050 ///
3051 /// </div>
3052 pub async fn reload(&self) -> Result<(), Error> {
3053 let wire_params = serde_json::json!({});
3054 let _value = self
3055 .client
3056 .call(rpc_methods::USER_SETTINGS_RELOAD, Some(wire_params))
3057 .await?;
3058 Ok(())
3059 }
3060
3061 /// 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.
3062 ///
3063 /// Wire method: `user.settings.get`.
3064 ///
3065 /// # Returns
3066 ///
3067 /// 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.
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 get(&self) -> Result<UserSettingsGetResult, Error> {
3077 let wire_params = serde_json::json!({});
3078 let _value = self
3079 .client
3080 .call(rpc_methods::USER_SETTINGS_GET, Some(wire_params))
3081 .await?;
3082 Ok(serde_json::from_value(_value)?)
3083 }
3084
3085 /// 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.
3086 ///
3087 /// Wire method: `user.settings.set`.
3088 ///
3089 /// # Parameters
3090 ///
3091 /// * `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.
3092 ///
3093 /// # Returns
3094 ///
3095 /// Outcome of writing user settings.
3096 ///
3097 /// <div class="warning">
3098 ///
3099 /// **Experimental.** This API is part of an experimental wire-protocol surface
3100 /// and may change or be removed in future SDK or CLI releases. Pin both the
3101 /// SDK and CLI versions if your code depends on it.
3102 ///
3103 /// </div>
3104 pub async fn set(
3105 &self,
3106 params: UserSettingsSetRequest,
3107 ) -> Result<UserSettingsSetResult, Error> {
3108 let wire_params = serde_json::to_value(params)?;
3109 let _value = self
3110 .client
3111 .call(rpc_methods::USER_SETTINGS_SET, Some(wire_params))
3112 .await?;
3113 Ok(serde_json::from_value(_value)?)
3114 }
3115}
3116
3117/// Typed view over a [`Session`]'s RPC namespace.
3118#[derive(Clone, Copy)]
3119pub struct SessionRpc<'a> {
3120 pub(crate) session: &'a Session,
3121}
3122
3123impl<'a> SessionRpc<'a> {
3124 /// `session.agent.*` sub-namespace.
3125 pub fn agent(&self) -> SessionRpcAgent<'a> {
3126 SessionRpcAgent {
3127 session: self.session,
3128 }
3129 }
3130
3131 /// `session.autopilotObjective.*` sub-namespace.
3132 pub fn autopilot_objective(&self) -> SessionRpcAutopilotObjective<'a> {
3133 SessionRpcAutopilotObjective {
3134 session: self.session,
3135 }
3136 }
3137
3138 /// `session.canvas.*` sub-namespace.
3139 pub fn canvas(&self) -> SessionRpcCanvas<'a> {
3140 SessionRpcCanvas {
3141 session: self.session,
3142 }
3143 }
3144
3145 /// `session.commands.*` sub-namespace.
3146 pub fn commands(&self) -> SessionRpcCommands<'a> {
3147 SessionRpcCommands {
3148 session: self.session,
3149 }
3150 }
3151
3152 /// `session.completions.*` sub-namespace.
3153 pub fn completions(&self) -> SessionRpcCompletions<'a> {
3154 SessionRpcCompletions {
3155 session: self.session,
3156 }
3157 }
3158
3159 /// `session.connectors.*` sub-namespace.
3160 pub fn connectors(&self) -> SessionRpcConnectors<'a> {
3161 SessionRpcConnectors {
3162 session: self.session,
3163 }
3164 }
3165
3166 /// `session.contentExclusion.*` sub-namespace.
3167 pub fn content_exclusion(&self) -> SessionRpcContentExclusion<'a> {
3168 SessionRpcContentExclusion {
3169 session: self.session,
3170 }
3171 }
3172
3173 /// `session.debug.*` sub-namespace.
3174 pub fn debug(&self) -> SessionRpcDebug<'a> {
3175 SessionRpcDebug {
3176 session: self.session,
3177 }
3178 }
3179
3180 /// `session.eventLog.*` sub-namespace.
3181 pub fn event_log(&self) -> SessionRpcEventLog<'a> {
3182 SessionRpcEventLog {
3183 session: self.session,
3184 }
3185 }
3186
3187 /// `session.extensions.*` sub-namespace.
3188 pub fn extensions(&self) -> SessionRpcExtensions<'a> {
3189 SessionRpcExtensions {
3190 session: self.session,
3191 }
3192 }
3193
3194 /// `session.factory.*` sub-namespace.
3195 pub fn factory(&self) -> SessionRpcFactory<'a> {
3196 SessionRpcFactory {
3197 session: self.session,
3198 }
3199 }
3200
3201 /// `session.fleet.*` sub-namespace.
3202 pub fn fleet(&self) -> SessionRpcFleet<'a> {
3203 SessionRpcFleet {
3204 session: self.session,
3205 }
3206 }
3207
3208 /// `session.gitHubAuth.*` sub-namespace.
3209 pub fn git_hub_auth(&self) -> SessionRpcGitHubAuth<'a> {
3210 SessionRpcGitHubAuth {
3211 session: self.session,
3212 }
3213 }
3214
3215 /// `session.history.*` sub-namespace.
3216 pub fn history(&self) -> SessionRpcHistory<'a> {
3217 SessionRpcHistory {
3218 session: self.session,
3219 }
3220 }
3221
3222 /// `session.instructions.*` sub-namespace.
3223 pub fn instructions(&self) -> SessionRpcInstructions<'a> {
3224 SessionRpcInstructions {
3225 session: self.session,
3226 }
3227 }
3228
3229 /// `session.limitPrediction.*` sub-namespace.
3230 pub fn limit_prediction(&self) -> SessionRpcLimitPrediction<'a> {
3231 SessionRpcLimitPrediction {
3232 session: self.session,
3233 }
3234 }
3235
3236 /// `session.lsp.*` sub-namespace.
3237 pub fn lsp(&self) -> SessionRpcLsp<'a> {
3238 SessionRpcLsp {
3239 session: self.session,
3240 }
3241 }
3242
3243 /// `session.managedSettings.*` sub-namespace.
3244 pub fn managed_settings(&self) -> SessionRpcManagedSettings<'a> {
3245 SessionRpcManagedSettings {
3246 session: self.session,
3247 }
3248 }
3249
3250 /// `session.mcp.*` sub-namespace.
3251 pub fn mcp(&self) -> SessionRpcMcp<'a> {
3252 SessionRpcMcp {
3253 session: self.session,
3254 }
3255 }
3256
3257 /// `session.metadata.*` sub-namespace.
3258 pub fn metadata(&self) -> SessionRpcMetadata<'a> {
3259 SessionRpcMetadata {
3260 session: self.session,
3261 }
3262 }
3263
3264 /// `session.mode.*` sub-namespace.
3265 pub fn mode(&self) -> SessionRpcMode<'a> {
3266 SessionRpcMode {
3267 session: self.session,
3268 }
3269 }
3270
3271 /// `session.model.*` sub-namespace.
3272 pub fn model(&self) -> SessionRpcModel<'a> {
3273 SessionRpcModel {
3274 session: self.session,
3275 }
3276 }
3277
3278 /// `session.name.*` sub-namespace.
3279 pub fn name(&self) -> SessionRpcName<'a> {
3280 SessionRpcName {
3281 session: self.session,
3282 }
3283 }
3284
3285 /// `session.options.*` sub-namespace.
3286 pub fn options(&self) -> SessionRpcOptions<'a> {
3287 SessionRpcOptions {
3288 session: self.session,
3289 }
3290 }
3291
3292 /// `session.permissions.*` sub-namespace.
3293 pub fn permissions(&self) -> SessionRpcPermissions<'a> {
3294 SessionRpcPermissions {
3295 session: self.session,
3296 }
3297 }
3298
3299 /// `session.plan.*` sub-namespace.
3300 pub fn plan(&self) -> SessionRpcPlan<'a> {
3301 SessionRpcPlan {
3302 session: self.session,
3303 }
3304 }
3305
3306 /// `session.plugins.*` sub-namespace.
3307 pub fn plugins(&self) -> SessionRpcPlugins<'a> {
3308 SessionRpcPlugins {
3309 session: self.session,
3310 }
3311 }
3312
3313 /// `session.provider.*` sub-namespace.
3314 pub fn provider(&self) -> SessionRpcProvider<'a> {
3315 SessionRpcProvider {
3316 session: self.session,
3317 }
3318 }
3319
3320 /// `session.queue.*` sub-namespace.
3321 pub fn queue(&self) -> SessionRpcQueue<'a> {
3322 SessionRpcQueue {
3323 session: self.session,
3324 }
3325 }
3326
3327 /// `session.remote.*` sub-namespace.
3328 pub fn remote(&self) -> SessionRpcRemote<'a> {
3329 SessionRpcRemote {
3330 session: self.session,
3331 }
3332 }
3333
3334 /// `session.sandbox.*` sub-namespace.
3335 pub fn sandbox(&self) -> SessionRpcSandbox<'a> {
3336 SessionRpcSandbox {
3337 session: self.session,
3338 }
3339 }
3340
3341 /// `session.schedule.*` sub-namespace.
3342 pub fn schedule(&self) -> SessionRpcSchedule<'a> {
3343 SessionRpcSchedule {
3344 session: self.session,
3345 }
3346 }
3347
3348 /// `session.settings.*` sub-namespace.
3349 pub fn settings(&self) -> SessionRpcSettings<'a> {
3350 SessionRpcSettings {
3351 session: self.session,
3352 }
3353 }
3354
3355 /// `session.shell.*` sub-namespace.
3356 pub fn shell(&self) -> SessionRpcShell<'a> {
3357 SessionRpcShell {
3358 session: self.session,
3359 }
3360 }
3361
3362 /// `session.skills.*` sub-namespace.
3363 pub fn skills(&self) -> SessionRpcSkills<'a> {
3364 SessionRpcSkills {
3365 session: self.session,
3366 }
3367 }
3368
3369 /// `session.tasks.*` sub-namespace.
3370 pub fn tasks(&self) -> SessionRpcTasks<'a> {
3371 SessionRpcTasks {
3372 session: self.session,
3373 }
3374 }
3375
3376 /// `session.telemetry.*` sub-namespace.
3377 pub fn telemetry(&self) -> SessionRpcTelemetry<'a> {
3378 SessionRpcTelemetry {
3379 session: self.session,
3380 }
3381 }
3382
3383 /// `session.tools.*` sub-namespace.
3384 pub fn tools(&self) -> SessionRpcTools<'a> {
3385 SessionRpcTools {
3386 session: self.session,
3387 }
3388 }
3389
3390 /// `session.ui.*` sub-namespace.
3391 pub fn ui(&self) -> SessionRpcUi<'a> {
3392 SessionRpcUi {
3393 session: self.session,
3394 }
3395 }
3396
3397 /// `session.usage.*` sub-namespace.
3398 pub fn usage(&self) -> SessionRpcUsage<'a> {
3399 SessionRpcUsage {
3400 session: self.session,
3401 }
3402 }
3403
3404 /// `session.visibility.*` sub-namespace.
3405 pub fn visibility(&self) -> SessionRpcVisibility<'a> {
3406 SessionRpcVisibility {
3407 session: self.session,
3408 }
3409 }
3410
3411 /// `session.workflow.*` sub-namespace.
3412 pub fn workflow(&self) -> SessionRpcWorkflow<'a> {
3413 SessionRpcWorkflow {
3414 session: self.session,
3415 }
3416 }
3417
3418 /// `session.workspaces.*` sub-namespace.
3419 pub fn workspaces(&self) -> SessionRpcWorkspaces<'a> {
3420 SessionRpcWorkspaces {
3421 session: self.session,
3422 }
3423 }
3424
3425 /// Suspends the session while preserving persisted state for later resume.
3426 ///
3427 /// Wire method: `session.suspend`.
3428 ///
3429 /// <div class="warning">
3430 ///
3431 /// **Experimental.** This API is part of an experimental wire-protocol surface
3432 /// and may change or be removed in future SDK or CLI releases. Pin both the
3433 /// SDK and CLI versions if your code depends on it.
3434 ///
3435 /// </div>
3436 pub async fn suspend(&self) -> Result<(), Error> {
3437 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3438 let _value = self
3439 .session
3440 .client()
3441 .call(rpc_methods::SESSION_SUSPEND, Some(wire_params))
3442 .await?;
3443 Ok(())
3444 }
3445
3446 /// Sends a user message to the session and returns its message ID.
3447 ///
3448 /// Wire method: `session.send`.
3449 ///
3450 /// # Parameters
3451 ///
3452 /// * `params` - Parameters for sending a user message to the session
3453 ///
3454 /// # Returns
3455 ///
3456 /// Result of sending a user message
3457 ///
3458 /// <div class="warning">
3459 ///
3460 /// **Experimental.** This API is part of an experimental wire-protocol surface
3461 /// and may change or be removed in future SDK or CLI releases. Pin both the
3462 /// SDK and CLI versions if your code depends on it.
3463 ///
3464 /// </div>
3465 pub async fn send(&self, params: SendRequest) -> Result<SendResult, Error> {
3466 let mut wire_params = serde_json::to_value(params)?;
3467 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3468 let _value = self
3469 .session
3470 .client()
3471 .call(rpc_methods::SESSION_SEND, Some(wire_params))
3472 .await?;
3473 Ok(serde_json::from_value(_value)?)
3474 }
3475
3476 /// 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.
3477 ///
3478 /// Wire method: `session.sendMessages`.
3479 ///
3480 /// # Parameters
3481 ///
3482 /// * `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.
3483 ///
3484 /// # Returns
3485 ///
3486 /// Result of sending zero or more user messages
3487 ///
3488 /// <div class="warning">
3489 ///
3490 /// **Experimental.** This API is part of an experimental wire-protocol surface
3491 /// and may change or be removed in future SDK or CLI releases. Pin both the
3492 /// SDK and CLI versions if your code depends on it.
3493 ///
3494 /// </div>
3495 pub async fn send_messages(
3496 &self,
3497 params: SendMessagesRequest,
3498 ) -> Result<SendMessagesResult, Error> {
3499 let mut wire_params = serde_json::to_value(params)?;
3500 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3501 let _value = self
3502 .session
3503 .client()
3504 .call(rpc_methods::SESSION_SENDMESSAGES, Some(wire_params))
3505 .await?;
3506 Ok(serde_json::from_value(_value)?)
3507 }
3508
3509 /// Queues or sends an internal system notification to the session according to its passive policy.
3510 ///
3511 /// Wire method: `session.sendSystemNotification`.
3512 ///
3513 /// # Parameters
3514 ///
3515 /// * `params` - Internal request for sending a system notification.
3516 ///
3517 /// <div class="warning">
3518 ///
3519 /// **Experimental.** This API is part of an experimental wire-protocol surface
3520 /// and may change or be removed in future SDK or CLI releases. Pin both the
3521 /// SDK and CLI versions if your code depends on it.
3522 ///
3523 /// </div>
3524 pub(crate) async fn send_system_notification(
3525 &self,
3526 params: SendSystemNotificationRequest,
3527 ) -> Result<(), Error> {
3528 let mut wire_params = serde_json::to_value(params)?;
3529 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3530 let _value = self
3531 .session
3532 .client()
3533 .call(
3534 rpc_methods::SESSION_SENDSYSTEMNOTIFICATION,
3535 Some(wire_params),
3536 )
3537 .await?;
3538 Ok(())
3539 }
3540
3541 /// Aborts the current agent turn.
3542 ///
3543 /// Wire method: `session.abort`.
3544 ///
3545 /// # Parameters
3546 ///
3547 /// * `params` - Parameters for aborting the current turn
3548 ///
3549 /// # Returns
3550 ///
3551 /// Result of aborting the current turn
3552 ///
3553 /// <div class="warning">
3554 ///
3555 /// **Experimental.** This API is part of an experimental wire-protocol surface
3556 /// and may change or be removed in future SDK or CLI releases. Pin both the
3557 /// SDK and CLI versions if your code depends on it.
3558 ///
3559 /// </div>
3560 pub async fn abort(&self, params: AbortRequest) -> Result<AbortResult, Error> {
3561 let mut wire_params = serde_json::to_value(params)?;
3562 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3563 let _value = self
3564 .session
3565 .client()
3566 .call(rpc_methods::SESSION_ABORT, Some(wire_params))
3567 .await?;
3568 Ok(serde_json::from_value(_value)?)
3569 }
3570
3571 /// 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.
3572 ///
3573 /// Wire method: `session.interruptMainTurn`.
3574 ///
3575 /// # Parameters
3576 ///
3577 /// * `params` - Parameters for interrupting the main agent turn.
3578 ///
3579 /// # Returns
3580 ///
3581 /// Result of interrupting the main agent turn.
3582 ///
3583 /// <div class="warning">
3584 ///
3585 /// **Experimental.** This API is part of an experimental wire-protocol surface
3586 /// and may change or be removed in future SDK or CLI releases. Pin both the
3587 /// SDK and CLI versions if your code depends on it.
3588 ///
3589 /// </div>
3590 pub async fn interrupt_main_turn(
3591 &self,
3592 params: InterruptMainTurnRequest,
3593 ) -> Result<InterruptMainTurnResult, Error> {
3594 let mut wire_params = serde_json::to_value(params)?;
3595 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3596 let _value = self
3597 .session
3598 .client()
3599 .call(rpc_methods::SESSION_INTERRUPTMAINTURN, Some(wire_params))
3600 .await?;
3601 Ok(serde_json::from_value(_value)?)
3602 }
3603
3604 /// Cancels every running background agent (task-registry subagents plus sidekick agents) without interrupting the main agent loop. Promoted attached shells are left running.
3605 ///
3606 /// Wire method: `session.cancelAllBackgroundAgents`.
3607 ///
3608 /// # Returns
3609 ///
3610 /// The number of running background agents (task-registry agents) that were cancelled.
3611 ///
3612 /// <div class="warning">
3613 ///
3614 /// **Experimental.** This API is part of an experimental wire-protocol surface
3615 /// and may change or be removed in future SDK or CLI releases. Pin both the
3616 /// SDK and CLI versions if your code depends on it.
3617 ///
3618 /// </div>
3619 pub async fn cancel_all_background_agents(
3620 &self,
3621 ) -> Result<SessionCancelAllBackgroundAgentsResult, Error> {
3622 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3623 let _value = self
3624 .session
3625 .client()
3626 .call(
3627 rpc_methods::SESSION_CANCELALLBACKGROUNDAGENTS,
3628 Some(wire_params),
3629 )
3630 .await?;
3631 Ok(serde_json::from_value(_value)?)
3632 }
3633
3634 /// 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.
3635 ///
3636 /// Wire method: `session.shutdown`.
3637 ///
3638 /// # Parameters
3639 ///
3640 /// * `params` - Parameters for shutting down the session
3641 ///
3642 /// <div class="warning">
3643 ///
3644 /// **Experimental.** This API is part of an experimental wire-protocol surface
3645 /// and may change or be removed in future SDK or CLI releases. Pin both the
3646 /// SDK and CLI versions if your code depends on it.
3647 ///
3648 /// </div>
3649 pub async fn shutdown(&self, params: ShutdownRequest) -> Result<(), Error> {
3650 let mut wire_params = serde_json::to_value(params)?;
3651 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3652 let _value = self
3653 .session
3654 .client()
3655 .call(rpc_methods::SESSION_SHUTDOWN, Some(wire_params))
3656 .await?;
3657 Ok(())
3658 }
3659
3660 /// Emits a user-visible session log event.
3661 ///
3662 /// Wire method: `session.log`.
3663 ///
3664 /// # Parameters
3665 ///
3666 /// * `params` - Message text, optional severity level, persistence flag, optional follow-up URL, and optional tip.
3667 ///
3668 /// # Returns
3669 ///
3670 /// Identifier of the session event that was emitted for the log message.
3671 ///
3672 /// <div class="warning">
3673 ///
3674 /// **Experimental.** This API is part of an experimental wire-protocol surface
3675 /// and may change or be removed in future SDK or CLI releases. Pin both the
3676 /// SDK and CLI versions if your code depends on it.
3677 ///
3678 /// </div>
3679 pub async fn log(&self, params: LogRequest) -> Result<LogResult, Error> {
3680 let mut wire_params = serde_json::to_value(params)?;
3681 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3682 let _value = self
3683 .session
3684 .client()
3685 .call(rpc_methods::SESSION_LOG, Some(wire_params))
3686 .await?;
3687 Ok(serde_json::from_value(_value)?)
3688 }
3689}
3690
3691/// `session.agent.*` RPCs.
3692#[derive(Clone, Copy)]
3693pub struct SessionRpcAgent<'a> {
3694 pub(crate) session: &'a Session,
3695}
3696
3697impl<'a> SessionRpcAgent<'a> {
3698 /// Lists agents available to the session. Defaults to custom agents only; pass includeBuiltInAgents to include the effective built-in agents.
3699 ///
3700 /// Wire method: `session.agent.list`.
3701 ///
3702 /// # Returns
3703 ///
3704 /// Agents available to the session.
3705 ///
3706 /// <div class="warning">
3707 ///
3708 /// **Experimental.** This API is part of an experimental wire-protocol surface
3709 /// and may change or be removed in future SDK or CLI releases. Pin both the
3710 /// SDK and CLI versions if your code depends on it.
3711 ///
3712 /// </div>
3713 pub async fn list(&self) -> Result<AgentList, Error> {
3714 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3715 let _value = self
3716 .session
3717 .client()
3718 .call(rpc_methods::SESSION_AGENT_LIST, Some(wire_params))
3719 .await?;
3720 Ok(serde_json::from_value(_value)?)
3721 }
3722
3723 /// Lists agents available to the session. Defaults to custom agents only; pass includeBuiltInAgents to include the effective built-in agents.
3724 ///
3725 /// Wire method: `session.agent.list`.
3726 ///
3727 /// # Parameters
3728 ///
3729 /// * `params` - Controls whether built-in agents and authored prompt text are included.
3730 ///
3731 /// # Returns
3732 ///
3733 /// Agents available to the session.
3734 ///
3735 /// <div class="warning">
3736 ///
3737 /// **Experimental.** This API is part of an experimental wire-protocol surface
3738 /// and may change or be removed in future SDK or CLI releases. Pin both the
3739 /// SDK and CLI versions if your code depends on it.
3740 ///
3741 /// </div>
3742 pub async fn list_with_params(&self, params: AgentListRequest) -> Result<AgentList, Error> {
3743 let mut wire_params = serde_json::to_value(params)?;
3744 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3745 let _value = self
3746 .session
3747 .client()
3748 .call(rpc_methods::SESSION_AGENT_LIST, Some(wire_params))
3749 .await?;
3750 Ok(serde_json::from_value(_value)?)
3751 }
3752
3753 /// 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.
3754 ///
3755 /// Wire method: `session.agent.setPrompt`.
3756 ///
3757 /// # Parameters
3758 ///
3759 /// * `params` - An in-memory authored prompt override for an available agent.
3760 ///
3761 /// <div class="warning">
3762 ///
3763 /// **Experimental.** This API is part of an experimental wire-protocol surface
3764 /// and may change or be removed in future SDK or CLI releases. Pin both the
3765 /// SDK and CLI versions if your code depends on it.
3766 ///
3767 /// </div>
3768 pub async fn set_prompt(&self, params: AgentSetPromptRequest) -> Result<(), Error> {
3769 let mut wire_params = serde_json::to_value(params)?;
3770 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3771 let _value = self
3772 .session
3773 .client()
3774 .call(rpc_methods::SESSION_AGENT_SETPROMPT, Some(wire_params))
3775 .await?;
3776 Ok(())
3777 }
3778
3779 /// Gets the currently selected custom agent for the session.
3780 ///
3781 /// Wire method: `session.agent.getCurrent`.
3782 ///
3783 /// # Returns
3784 ///
3785 /// The currently selected custom agent, or null when using the default agent.
3786 ///
3787 /// <div class="warning">
3788 ///
3789 /// **Experimental.** This API is part of an experimental wire-protocol surface
3790 /// and may change or be removed in future SDK or CLI releases. Pin both the
3791 /// SDK and CLI versions if your code depends on it.
3792 ///
3793 /// </div>
3794 pub async fn get_current(&self) -> Result<AgentGetCurrentResult, Error> {
3795 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3796 let _value = self
3797 .session
3798 .client()
3799 .call(rpc_methods::SESSION_AGENT_GETCURRENT, Some(wire_params))
3800 .await?;
3801 Ok(serde_json::from_value(_value)?)
3802 }
3803
3804 /// Selects a custom agent for subsequent turns in the session.
3805 ///
3806 /// Wire method: `session.agent.select`.
3807 ///
3808 /// # Parameters
3809 ///
3810 /// * `params` - Name of the custom agent to select for subsequent turns.
3811 ///
3812 /// # Returns
3813 ///
3814 /// The newly selected custom agent.
3815 ///
3816 /// <div class="warning">
3817 ///
3818 /// **Experimental.** This API is part of an experimental wire-protocol surface
3819 /// and may change or be removed in future SDK or CLI releases. Pin both the
3820 /// SDK and CLI versions if your code depends on it.
3821 ///
3822 /// </div>
3823 pub async fn select(&self, params: AgentSelectRequest) -> Result<AgentSelectResult, Error> {
3824 let mut wire_params = serde_json::to_value(params)?;
3825 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3826 let _value = self
3827 .session
3828 .client()
3829 .call(rpc_methods::SESSION_AGENT_SELECT, Some(wire_params))
3830 .await?;
3831 Ok(serde_json::from_value(_value)?)
3832 }
3833
3834 /// Clears the selected custom agent and returns the session to the default agent.
3835 ///
3836 /// Wire method: `session.agent.deselect`.
3837 ///
3838 /// <div class="warning">
3839 ///
3840 /// **Experimental.** This API is part of an experimental wire-protocol surface
3841 /// and may change or be removed in future SDK or CLI releases. Pin both the
3842 /// SDK and CLI versions if your code depends on it.
3843 ///
3844 /// </div>
3845 pub async fn deselect(&self) -> Result<(), Error> {
3846 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3847 let _value = self
3848 .session
3849 .client()
3850 .call(rpc_methods::SESSION_AGENT_DESELECT, Some(wire_params))
3851 .await?;
3852 Ok(())
3853 }
3854
3855 /// Reloads custom agent definitions and returns the refreshed list.
3856 ///
3857 /// Wire method: `session.agent.reload`.
3858 ///
3859 /// # Returns
3860 ///
3861 /// Custom agents available to the session after reloading definitions from disk.
3862 ///
3863 /// <div class="warning">
3864 ///
3865 /// **Experimental.** This API is part of an experimental wire-protocol surface
3866 /// and may change or be removed in future SDK or CLI releases. Pin both the
3867 /// SDK and CLI versions if your code depends on it.
3868 ///
3869 /// </div>
3870 pub async fn reload(&self) -> Result<AgentReloadResult, Error> {
3871 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3872 let _value = self
3873 .session
3874 .client()
3875 .call(rpc_methods::SESSION_AGENT_RELOAD, Some(wire_params))
3876 .await?;
3877 Ok(serde_json::from_value(_value)?)
3878 }
3879}
3880
3881/// `session.autopilotObjective.*` RPCs.
3882#[derive(Clone, Copy)]
3883pub struct SessionRpcAutopilotObjective<'a> {
3884 pub(crate) session: &'a Session,
3885}
3886
3887impl<'a> SessionRpcAutopilotObjective<'a> {
3888 /// Reads the current canonical autopilot objective state for this session.
3889 ///
3890 /// Wire method: `session.autopilotObjective.getState`.
3891 ///
3892 /// # Returns
3893 ///
3894 /// Canonical runtime state for the session's current autopilot objective.
3895 ///
3896 /// <div class="warning">
3897 ///
3898 /// **Experimental.** This API is part of an experimental wire-protocol surface
3899 /// and may change or be removed in future SDK or CLI releases. Pin both the
3900 /// SDK and CLI versions if your code depends on it.
3901 ///
3902 /// </div>
3903 pub async fn get_state(&self) -> Result<AutopilotObjectiveGetStateResult, Error> {
3904 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3905 let _value = self
3906 .session
3907 .client()
3908 .call(
3909 rpc_methods::SESSION_AUTOPILOTOBJECTIVE_GETSTATE,
3910 Some(wire_params),
3911 )
3912 .await?;
3913 Ok(serde_json::from_value(_value)?)
3914 }
3915}
3916
3917/// `session.canvas.*` RPCs.
3918#[derive(Clone, Copy)]
3919pub struct SessionRpcCanvas<'a> {
3920 pub(crate) session: &'a Session,
3921}
3922
3923impl<'a> SessionRpcCanvas<'a> {
3924 /// `session.canvas.action.*` sub-namespace.
3925 pub fn action(&self) -> SessionRpcCanvasAction<'a> {
3926 SessionRpcCanvasAction {
3927 session: self.session,
3928 }
3929 }
3930
3931 /// `session.canvas.provider.*` sub-namespace.
3932 pub fn provider(&self) -> SessionRpcCanvasProvider<'a> {
3933 SessionRpcCanvasProvider {
3934 session: self.session,
3935 }
3936 }
3937
3938 /// Lists canvases declared for the session.
3939 ///
3940 /// Wire method: `session.canvas.list`.
3941 ///
3942 /// # Returns
3943 ///
3944 /// Declared canvases available in this session.
3945 ///
3946 /// <div class="warning">
3947 ///
3948 /// **Experimental.** This API is part of an experimental wire-protocol surface
3949 /// and may change or be removed in future SDK or CLI releases. Pin both the
3950 /// SDK and CLI versions if your code depends on it.
3951 ///
3952 /// </div>
3953 pub async fn list(&self) -> Result<CanvasList, Error> {
3954 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3955 let _value = self
3956 .session
3957 .client()
3958 .call(rpc_methods::SESSION_CANVAS_LIST, Some(wire_params))
3959 .await?;
3960 Ok(serde_json::from_value(_value)?)
3961 }
3962
3963 /// Lists currently open canvas instances for the live session.
3964 ///
3965 /// Wire method: `session.canvas.listOpen`.
3966 ///
3967 /// # Returns
3968 ///
3969 /// Live open-canvas snapshot.
3970 ///
3971 /// <div class="warning">
3972 ///
3973 /// **Experimental.** This API is part of an experimental wire-protocol surface
3974 /// and may change or be removed in future SDK or CLI releases. Pin both the
3975 /// SDK and CLI versions if your code depends on it.
3976 ///
3977 /// </div>
3978 pub async fn list_open(&self) -> Result<CanvasListOpenResult, Error> {
3979 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3980 let _value = self
3981 .session
3982 .client()
3983 .call(rpc_methods::SESSION_CANVAS_LISTOPEN, Some(wire_params))
3984 .await?;
3985 Ok(serde_json::from_value(_value)?)
3986 }
3987
3988 /// Opens or focuses a canvas instance.
3989 ///
3990 /// Wire method: `session.canvas.open`.
3991 ///
3992 /// # Parameters
3993 ///
3994 /// * `params` - Canvas open parameters.
3995 ///
3996 /// # Returns
3997 ///
3998 /// Open canvas instance snapshot.
3999 ///
4000 /// <div class="warning">
4001 ///
4002 /// **Experimental.** This API is part of an experimental wire-protocol surface
4003 /// and may change or be removed in future SDK or CLI releases. Pin both the
4004 /// SDK and CLI versions if your code depends on it.
4005 ///
4006 /// </div>
4007 pub async fn open(&self, params: CanvasOpenRequest) -> Result<OpenCanvasInstance, Error> {
4008 let mut wire_params = serde_json::to_value(params)?;
4009 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4010 let _value = self
4011 .session
4012 .client()
4013 .call(rpc_methods::SESSION_CANVAS_OPEN, Some(wire_params))
4014 .await?;
4015 Ok(serde_json::from_value(_value)?)
4016 }
4017
4018 /// Closes an open canvas instance.
4019 ///
4020 /// Wire method: `session.canvas.close`.
4021 ///
4022 /// # Parameters
4023 ///
4024 /// * `params` - Canvas close parameters.
4025 ///
4026 /// <div class="warning">
4027 ///
4028 /// **Experimental.** This API is part of an experimental wire-protocol surface
4029 /// and may change or be removed in future SDK or CLI releases. Pin both the
4030 /// SDK and CLI versions if your code depends on it.
4031 ///
4032 /// </div>
4033 pub async fn close(&self, params: CanvasCloseRequest) -> Result<(), Error> {
4034 let mut wire_params = serde_json::to_value(params)?;
4035 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4036 let _value = self
4037 .session
4038 .client()
4039 .call(rpc_methods::SESSION_CANVAS_CLOSE, Some(wire_params))
4040 .await?;
4041 Ok(())
4042 }
4043}
4044
4045/// `session.canvas.action.*` RPCs.
4046#[derive(Clone, Copy)]
4047pub struct SessionRpcCanvasAction<'a> {
4048 pub(crate) session: &'a Session,
4049}
4050
4051impl<'a> SessionRpcCanvasAction<'a> {
4052 /// Invokes an action on an open canvas instance.
4053 ///
4054 /// Wire method: `session.canvas.action.invoke`.
4055 ///
4056 /// # Parameters
4057 ///
4058 /// * `params` - Canvas action invocation parameters.
4059 ///
4060 /// # Returns
4061 ///
4062 /// Canvas action invocation result.
4063 ///
4064 /// <div class="warning">
4065 ///
4066 /// **Experimental.** This API is part of an experimental wire-protocol surface
4067 /// and may change or be removed in future SDK or CLI releases. Pin both the
4068 /// SDK and CLI versions if your code depends on it.
4069 ///
4070 /// </div>
4071 pub async fn invoke(
4072 &self,
4073 params: CanvasActionInvokeRequest,
4074 ) -> Result<CanvasActionInvokeResult, Error> {
4075 let mut wire_params = serde_json::to_value(params)?;
4076 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4077 let _value = self
4078 .session
4079 .client()
4080 .call(rpc_methods::SESSION_CANVAS_ACTION_INVOKE, Some(wire_params))
4081 .await?;
4082 Ok(serde_json::from_value(_value)?)
4083 }
4084}
4085
4086/// `session.canvas.provider.*` RPCs.
4087#[derive(Clone, Copy)]
4088pub struct SessionRpcCanvasProvider<'a> {
4089 pub(crate) session: &'a Session,
4090}
4091
4092impl<'a> SessionRpcCanvasProvider<'a> {
4093 /// Registers an internal canvas provider connection and its contributions.
4094 ///
4095 /// Wire method: `session.canvas.provider.register`.
4096 ///
4097 /// # Parameters
4098 ///
4099 /// * `params` - Internal canvas provider registration parameters.
4100 ///
4101 /// <div class="warning">
4102 ///
4103 /// **Experimental.** This API is part of an experimental wire-protocol surface
4104 /// and may change or be removed in future SDK or CLI releases. Pin both the
4105 /// SDK and CLI versions if your code depends on it.
4106 ///
4107 /// </div>
4108 pub(crate) async fn register(
4109 &self,
4110 params: CanvasProviderRegisterRequest,
4111 ) -> Result<(), Error> {
4112 let mut wire_params = serde_json::to_value(params)?;
4113 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4114 let _value = self
4115 .session
4116 .client()
4117 .call(
4118 rpc_methods::SESSION_CANVAS_PROVIDER_REGISTER,
4119 Some(wire_params),
4120 )
4121 .await?;
4122 Ok(())
4123 }
4124
4125 /// Unregisters an internal canvas provider connection.
4126 ///
4127 /// Wire method: `session.canvas.provider.unregister`.
4128 ///
4129 /// # Parameters
4130 ///
4131 /// * `params` - Internal canvas provider unregistration parameters.
4132 ///
4133 /// <div class="warning">
4134 ///
4135 /// **Experimental.** This API is part of an experimental wire-protocol surface
4136 /// and may change or be removed in future SDK or CLI releases. Pin both the
4137 /// SDK and CLI versions if your code depends on it.
4138 ///
4139 /// </div>
4140 pub(crate) async fn unregister(
4141 &self,
4142 params: CanvasProviderUnregisterRequest,
4143 ) -> Result<(), Error> {
4144 let mut wire_params = serde_json::to_value(params)?;
4145 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4146 let _value = self
4147 .session
4148 .client()
4149 .call(
4150 rpc_methods::SESSION_CANVAS_PROVIDER_UNREGISTER,
4151 Some(wire_params),
4152 )
4153 .await?;
4154 Ok(())
4155 }
4156}
4157
4158/// `session.commands.*` RPCs.
4159#[derive(Clone, Copy)]
4160pub struct SessionRpcCommands<'a> {
4161 pub(crate) session: &'a Session,
4162}
4163
4164impl<'a> SessionRpcCommands<'a> {
4165 /// Lists slash commands available in the session.
4166 ///
4167 /// Wire method: `session.commands.list`.
4168 ///
4169 /// # Returns
4170 ///
4171 /// Slash commands available in the session, after applying any include/exclude filters.
4172 ///
4173 /// <div class="warning">
4174 ///
4175 /// **Experimental.** This API is part of an experimental wire-protocol surface
4176 /// and may change or be removed in future SDK or CLI releases. Pin both the
4177 /// SDK and CLI versions if your code depends on it.
4178 ///
4179 /// </div>
4180 pub async fn list(&self) -> Result<CommandList, Error> {
4181 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
4182 let _value = self
4183 .session
4184 .client()
4185 .call(rpc_methods::SESSION_COMMANDS_LIST, Some(wire_params))
4186 .await?;
4187 Ok(serde_json::from_value(_value)?)
4188 }
4189
4190 /// Lists slash commands available in the session.
4191 ///
4192 /// Wire method: `session.commands.list`.
4193 ///
4194 /// # Parameters
4195 ///
4196 /// * `params` - Optional filters controlling which command sources to include in the listing.
4197 ///
4198 /// # Returns
4199 ///
4200 /// Slash commands available in the session, after applying any include/exclude filters.
4201 ///
4202 /// <div class="warning">
4203 ///
4204 /// **Experimental.** This API is part of an experimental wire-protocol surface
4205 /// and may change or be removed in future SDK or CLI releases. Pin both the
4206 /// SDK and CLI versions if your code depends on it.
4207 ///
4208 /// </div>
4209 pub async fn list_with_params(
4210 &self,
4211 params: CommandsListRequest,
4212 ) -> Result<CommandList, Error> {
4213 let mut wire_params = serde_json::to_value(params)?;
4214 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4215 let _value = self
4216 .session
4217 .client()
4218 .call(rpc_methods::SESSION_COMMANDS_LIST, Some(wire_params))
4219 .await?;
4220 Ok(serde_json::from_value(_value)?)
4221 }
4222
4223 /// Invokes a slash command in the session.
4224 ///
4225 /// Wire method: `session.commands.invoke`.
4226 ///
4227 /// # Parameters
4228 ///
4229 /// * `params` - Slash command name and optional raw input string to invoke.
4230 ///
4231 /// # Returns
4232 ///
4233 /// Result of invoking the slash command (text output, prompt to send to the agent, completion, or subcommand selection).
4234 ///
4235 /// <div class="warning">
4236 ///
4237 /// **Experimental.** This API is part of an experimental wire-protocol surface
4238 /// and may change or be removed in future SDK or CLI releases. Pin both the
4239 /// SDK and CLI versions if your code depends on it.
4240 ///
4241 /// </div>
4242 pub async fn invoke(
4243 &self,
4244 params: CommandsInvokeRequest,
4245 ) -> Result<SlashCommandInvocationResult, Error> {
4246 let mut wire_params = serde_json::to_value(params)?;
4247 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4248 let _value = self
4249 .session
4250 .client()
4251 .call(rpc_methods::SESSION_COMMANDS_INVOKE, Some(wire_params))
4252 .await?;
4253 Ok(serde_json::from_value(_value)?)
4254 }
4255
4256 /// Finalizes persistence associated with a client-applied slash-command effect.
4257 ///
4258 /// Wire method: `session.commands.finalizeInvocationEffect`.
4259 ///
4260 /// # Parameters
4261 ///
4262 /// * `params` - The pending slash-command invocation effect to finalize, plus whether the host applied or cancelled it.
4263 ///
4264 /// # Returns
4265 ///
4266 /// Whether finalizing the invocation effect succeeded, and the failure reason when it did not.
4267 ///
4268 /// <div class="warning">
4269 ///
4270 /// **Experimental.** This API is part of an experimental wire-protocol surface
4271 /// and may change or be removed in future SDK or CLI releases. Pin both the
4272 /// SDK and CLI versions if your code depends on it.
4273 ///
4274 /// </div>
4275 pub(crate) async fn finalize_invocation_effect(
4276 &self,
4277 params: CommandsFinalizeInvocationEffectRequest,
4278 ) -> Result<CommandsFinalizeInvocationEffectResult, Error> {
4279 let mut wire_params = serde_json::to_value(params)?;
4280 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4281 let _value = self
4282 .session
4283 .client()
4284 .call(
4285 rpc_methods::SESSION_COMMANDS_FINALIZEINVOCATIONEFFECT,
4286 Some(wire_params),
4287 )
4288 .await?;
4289 Ok(serde_json::from_value(_value)?)
4290 }
4291
4292 /// Reports completion of a pending client-handled slash command.
4293 ///
4294 /// Wire method: `session.commands.handlePendingCommand`.
4295 ///
4296 /// # Parameters
4297 ///
4298 /// * `params` - Pending command request ID and an optional error if the client handler failed.
4299 ///
4300 /// # Returns
4301 ///
4302 /// Indicates whether the pending client-handled command was completed successfully.
4303 ///
4304 /// <div class="warning">
4305 ///
4306 /// **Experimental.** This API is part of an experimental wire-protocol surface
4307 /// and may change or be removed in future SDK or CLI releases. Pin both the
4308 /// SDK and CLI versions if your code depends on it.
4309 ///
4310 /// </div>
4311 pub async fn handle_pending_command(
4312 &self,
4313 params: CommandsHandlePendingCommandRequest,
4314 ) -> Result<CommandsHandlePendingCommandResult, Error> {
4315 let mut wire_params = serde_json::to_value(params)?;
4316 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4317 let _value = self
4318 .session
4319 .client()
4320 .call(
4321 rpc_methods::SESSION_COMMANDS_HANDLEPENDINGCOMMAND,
4322 Some(wire_params),
4323 )
4324 .await?;
4325 Ok(serde_json::from_value(_value)?)
4326 }
4327
4328 /// Executes a slash command synchronously and returns any error.
4329 ///
4330 /// Wire method: `session.commands.execute`.
4331 ///
4332 /// # Parameters
4333 ///
4334 /// * `params` - Slash command name and argument string to execute synchronously.
4335 ///
4336 /// # Returns
4337 ///
4338 /// Error message produced while executing the command, if any.
4339 ///
4340 /// <div class="warning">
4341 ///
4342 /// **Experimental.** This API is part of an experimental wire-protocol surface
4343 /// and may change or be removed in future SDK or CLI releases. Pin both the
4344 /// SDK and CLI versions if your code depends on it.
4345 ///
4346 /// </div>
4347 pub async fn execute(
4348 &self,
4349 params: ExecuteCommandParams,
4350 ) -> Result<ExecuteCommandResult, Error> {
4351 let mut wire_params = serde_json::to_value(params)?;
4352 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4353 let _value = self
4354 .session
4355 .client()
4356 .call(rpc_methods::SESSION_COMMANDS_EXECUTE, Some(wire_params))
4357 .await?;
4358 Ok(serde_json::from_value(_value)?)
4359 }
4360
4361 /// Enqueues a slash command for FIFO processing on the local session.
4362 ///
4363 /// Wire method: `session.commands.enqueue`.
4364 ///
4365 /// # Parameters
4366 ///
4367 /// * `params` - Slash-prefixed command string to enqueue for FIFO processing.
4368 ///
4369 /// # Returns
4370 ///
4371 /// Indicates whether the command was accepted into the local execution queue.
4372 ///
4373 /// <div class="warning">
4374 ///
4375 /// **Experimental.** This API is part of an experimental wire-protocol surface
4376 /// and may change or be removed in future SDK or CLI releases. Pin both the
4377 /// SDK and CLI versions if your code depends on it.
4378 ///
4379 /// </div>
4380 pub async fn enqueue(
4381 &self,
4382 params: EnqueueCommandParams,
4383 ) -> Result<EnqueueCommandResult, Error> {
4384 let mut wire_params = serde_json::to_value(params)?;
4385 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4386 let _value = self
4387 .session
4388 .client()
4389 .call(rpc_methods::SESSION_COMMANDS_ENQUEUE, Some(wire_params))
4390 .await?;
4391 Ok(serde_json::from_value(_value)?)
4392 }
4393
4394 /// Reports whether the host actually executed a queued command and whether to continue processing.
4395 ///
4396 /// Wire method: `session.commands.respondToQueuedCommand`.
4397 ///
4398 /// # Parameters
4399 ///
4400 /// * `params` - Queued-command request ID and the result indicating whether the host executed it (and whether to stop processing further queued commands).
4401 ///
4402 /// # Returns
4403 ///
4404 /// Indicates whether the queued-command response was matched to a pending request.
4405 ///
4406 /// <div class="warning">
4407 ///
4408 /// **Experimental.** This API is part of an experimental wire-protocol surface
4409 /// and may change or be removed in future SDK or CLI releases. Pin both the
4410 /// SDK and CLI versions if your code depends on it.
4411 ///
4412 /// </div>
4413 pub async fn respond_to_queued_command(
4414 &self,
4415 params: CommandsRespondToQueuedCommandRequest,
4416 ) -> Result<CommandsRespondToQueuedCommandResult, Error> {
4417 let mut wire_params = serde_json::to_value(params)?;
4418 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4419 let _value = self
4420 .session
4421 .client()
4422 .call(
4423 rpc_methods::SESSION_COMMANDS_RESPONDTOQUEUEDCOMMAND,
4424 Some(wire_params),
4425 )
4426 .await?;
4427 Ok(serde_json::from_value(_value)?)
4428 }
4429}
4430
4431/// `session.completions.*` RPCs.
4432#[derive(Clone, Copy)]
4433pub struct SessionRpcCompletions<'a> {
4434 pub(crate) session: &'a Session,
4435}
4436
4437impl<'a> SessionRpcCompletions<'a> {
4438 /// 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).
4439 ///
4440 /// Wire method: `session.completions.getTriggerCharacters`.
4441 ///
4442 /// # Returns
4443 ///
4444 /// 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`).
4445 ///
4446 /// <div class="warning">
4447 ///
4448 /// **Experimental.** This API is part of an experimental wire-protocol surface
4449 /// and may change or be removed in future SDK or CLI releases. Pin both the
4450 /// SDK and CLI versions if your code depends on it.
4451 ///
4452 /// </div>
4453 pub async fn get_trigger_characters(
4454 &self,
4455 ) -> Result<CompletionsGetTriggerCharactersResult, Error> {
4456 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
4457 let _value = self
4458 .session
4459 .client()
4460 .call(
4461 rpc_methods::SESSION_COMPLETIONS_GETTRIGGERCHARACTERS,
4462 Some(wire_params),
4463 )
4464 .await?;
4465 Ok(serde_json::from_value(_value)?)
4466 }
4467
4468 /// 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.
4469 ///
4470 /// Wire method: `session.completions.request`.
4471 ///
4472 /// # Parameters
4473 ///
4474 /// * `params` - Request host-driven completions for the current composer input.
4475 ///
4476 /// # Returns
4477 ///
4478 /// Host-driven completion items for the current composer input. Empty when the host returns no items or does not support completions.
4479 ///
4480 /// <div class="warning">
4481 ///
4482 /// **Experimental.** This API is part of an experimental wire-protocol surface
4483 /// and may change or be removed in future SDK or CLI releases. Pin both the
4484 /// SDK and CLI versions if your code depends on it.
4485 ///
4486 /// </div>
4487 pub async fn request(
4488 &self,
4489 params: CompletionsRequestRequest,
4490 ) -> Result<CompletionsRequestResult, Error> {
4491 let mut wire_params = serde_json::to_value(params)?;
4492 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4493 let _value = self
4494 .session
4495 .client()
4496 .call(rpc_methods::SESSION_COMPLETIONS_REQUEST, Some(wire_params))
4497 .await?;
4498 Ok(serde_json::from_value(_value)?)
4499 }
4500}
4501
4502/// `session.connectors.*` RPCs.
4503#[derive(Clone, Copy)]
4504pub struct SessionRpcConnectors<'a> {
4505 pub(crate) session: &'a Session,
4506}
4507
4508impl<'a> SessionRpcConnectors<'a> {
4509 /// Returns feature availability and bounded polling limits for the EXPERIMENTAL session connector API. This method never performs a Connector service request.
4510 ///
4511 /// Wire method: `session.connectors.getCapabilities`.
4512 ///
4513 /// # Returns
4514 ///
4515 /// Feature detection and hard polling limits for the EXPERIMENTAL session connector API.
4516 ///
4517 /// <div class="warning">
4518 ///
4519 /// **Experimental.** This API is part of an experimental wire-protocol surface
4520 /// and may change or be removed in future SDK or CLI releases. Pin both the
4521 /// SDK and CLI versions if your code depends on it.
4522 ///
4523 /// </div>
4524 pub async fn get_capabilities(&self) -> Result<ConnectorCapabilities, Error> {
4525 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
4526 let _value = self
4527 .session
4528 .client()
4529 .call(
4530 rpc_methods::SESSION_CONNECTORS_GETCAPABILITIES,
4531 Some(wire_params),
4532 )
4533 .await?;
4534 Ok(serde_json::from_value(_value)?)
4535 }
4536
4537 /// Returns authoritative session Connector state from current availability, pinned account selection, cached catalog, and live MCP projection without performing a Connector service request.
4538 ///
4539 /// Wire method: `session.connectors.getStatus`.
4540 ///
4541 /// # Returns
4542 ///
4543 /// Authoritative session connector state. Account IDs are opaque routing identifiers and credentials are never included.
4544 ///
4545 /// <div class="warning">
4546 ///
4547 /// **Experimental.** This API is part of an experimental wire-protocol surface
4548 /// and may change or be removed in future SDK or CLI releases. Pin both the
4549 /// SDK and CLI versions if your code depends on it.
4550 ///
4551 /// </div>
4552 pub async fn get_status(&self) -> Result<ConnectorStatus, Error> {
4553 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
4554 let _value = self
4555 .session
4556 .client()
4557 .call(rpc_methods::SESSION_CONNECTORS_GETSTATUS, Some(wire_params))
4558 .await?;
4559 Ok(serde_json::from_value(_value)?)
4560 }
4561
4562 /// Returns the cached Connector catalog for the pinned opaque account selection, fetching it only when this session has no cached catalog.
4563 ///
4564 /// Wire method: `session.connectors.list`.
4565 ///
4566 /// # Parameters
4567 ///
4568 /// * `params` - Pins a Connector operation to one host-owned GitHub account through its opaque selection ID. Provider tokens are never accepted.
4569 ///
4570 /// # Returns
4571 ///
4572 /// Validated Connector catalog snapshot cached by the session.
4573 ///
4574 /// <div class="warning">
4575 ///
4576 /// **Experimental.** This API is part of an experimental wire-protocol surface
4577 /// and may change or be removed in future SDK or CLI releases. Pin both the
4578 /// SDK and CLI versions if your code depends on it.
4579 ///
4580 /// </div>
4581 pub async fn list(
4582 &self,
4583 params: ConnectorAccountRequest,
4584 ) -> Result<ConnectorCatalogResult, Error> {
4585 let mut wire_params = serde_json::to_value(params)?;
4586 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4587 let _value = self
4588 .session
4589 .client()
4590 .call(rpc_methods::SESSION_CONNECTORS_LIST, Some(wire_params))
4591 .await?;
4592 Ok(serde_json::from_value(_value)?)
4593 }
4594
4595 /// Refreshes and validates the Connector catalog for the pinned opaque account selection.
4596 ///
4597 /// Wire method: `session.connectors.refresh`.
4598 ///
4599 /// # Parameters
4600 ///
4601 /// * `params` - Pins a Connector operation to one host-owned GitHub account through its opaque selection ID. Provider tokens are never accepted.
4602 ///
4603 /// # Returns
4604 ///
4605 /// Validated Connector catalog snapshot cached by the session.
4606 ///
4607 /// <div class="warning">
4608 ///
4609 /// **Experimental.** This API is part of an experimental wire-protocol surface
4610 /// and may change or be removed in future SDK or CLI releases. Pin both the
4611 /// SDK and CLI versions if your code depends on it.
4612 ///
4613 /// </div>
4614 pub async fn refresh(
4615 &self,
4616 params: ConnectorAccountRequest,
4617 ) -> Result<ConnectorCatalogResult, Error> {
4618 let mut wire_params = serde_json::to_value(params)?;
4619 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4620 let _value = self
4621 .session
4622 .client()
4623 .call(rpc_methods::SESSION_CONNECTORS_REFRESH, Some(wire_params))
4624 .await?;
4625 Ok(serde_json::from_value(_value)?)
4626 }
4627
4628 /// Initiates an idempotent Connector connection request without opening a browser. Returns connected when the service is immediately authoritative, consent_required with a validated URL, or pending with an opaque continuation ID.
4629 ///
4630 /// Wire method: `session.connectors.connect`.
4631 ///
4632 /// # Parameters
4633 ///
4634 /// * `params` - Selects one Connector and the pinned host-owned account used for its service and MCP authorization.
4635 ///
4636 /// # Returns
4637 ///
4638 /// Typed result of initiating or continuing a Connector connection.
4639 ///
4640 /// <div class="warning">
4641 ///
4642 /// **Experimental.** This API is part of an experimental wire-protocol surface
4643 /// and may change or be removed in future SDK or CLI releases. Pin both the
4644 /// SDK and CLI versions if your code depends on it.
4645 ///
4646 /// </div>
4647 pub async fn connect(
4648 &self,
4649 params: ConnectorConnectRequest,
4650 ) -> Result<ConnectorConnectResult, Error> {
4651 let mut wire_params = serde_json::to_value(params)?;
4652 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4653 let _value = self
4654 .session
4655 .client()
4656 .call(rpc_methods::SESSION_CONNECTORS_CONNECT, Some(wire_params))
4657 .await?;
4658 Ok(serde_json::from_value(_value)?)
4659 }
4660
4661 /// Re-initiates an idempotent Connector connection request without browser or UI effects, with the same typed outcomes as connect.
4662 ///
4663 /// Wire method: `session.connectors.reconnect`.
4664 ///
4665 /// # Parameters
4666 ///
4667 /// * `params` - Selects one Connector and the pinned host-owned account used for its service and MCP authorization.
4668 ///
4669 /// # Returns
4670 ///
4671 /// Typed result of initiating or continuing a Connector connection.
4672 ///
4673 /// <div class="warning">
4674 ///
4675 /// **Experimental.** This API is part of an experimental wire-protocol surface
4676 /// and may change or be removed in future SDK or CLI releases. Pin both the
4677 /// SDK and CLI versions if your code depends on it.
4678 ///
4679 /// </div>
4680 pub async fn reconnect(
4681 &self,
4682 params: ConnectorConnectRequest,
4683 ) -> Result<ConnectorConnectResult, Error> {
4684 let mut wire_params = serde_json::to_value(params)?;
4685 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4686 let _value = self
4687 .session
4688 .client()
4689 .call(rpc_methods::SESSION_CONNECTORS_RECONNECT, Some(wire_params))
4690 .await?;
4691 Ok(serde_json::from_value(_value)?)
4692 }
4693
4694 /// Continues a pending Connector connection with caller-supplied attempt, interval, and deadline bounds. The runtime never opens the returned consent URL.
4695 ///
4696 /// Wire method: `session.connectors.continueConnection`.
4697 ///
4698 /// # Parameters
4699 ///
4700 /// * `params` - Explicitly bounded continuation of a pending Connector connection.
4701 ///
4702 /// # Returns
4703 ///
4704 /// Typed result of initiating or continuing a Connector connection.
4705 ///
4706 /// <div class="warning">
4707 ///
4708 /// **Experimental.** This API is part of an experimental wire-protocol surface
4709 /// and may change or be removed in future SDK or CLI releases. Pin both the
4710 /// SDK and CLI versions if your code depends on it.
4711 ///
4712 /// </div>
4713 pub async fn continue_connection(
4714 &self,
4715 params: ConnectorContinueRequest,
4716 ) -> Result<ConnectorConnectResult, Error> {
4717 let mut wire_params = serde_json::to_value(params)?;
4718 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4719 let _value = self
4720 .session
4721 .client()
4722 .call(
4723 rpc_methods::SESSION_CONNECTORS_CONTINUECONNECTION,
4724 Some(wire_params),
4725 )
4726 .await?;
4727 Ok(serde_json::from_value(_value)?)
4728 }
4729
4730 /// Disconnects one Connector for the pinned opaque account selection, refreshes the authoritative catalog, and removes its session-owned MCP projection.
4731 ///
4732 /// Wire method: `session.connectors.disconnect`.
4733 ///
4734 /// # Parameters
4735 ///
4736 /// * `params` - Selects one Connector and the pinned host-owned account used for its service and MCP authorization.
4737 ///
4738 /// # Returns
4739 ///
4740 /// Authoritative result after disconnect and MCP reconciliation.
4741 ///
4742 /// <div class="warning">
4743 ///
4744 /// **Experimental.** This API is part of an experimental wire-protocol surface
4745 /// and may change or be removed in future SDK or CLI releases. Pin both the
4746 /// SDK and CLI versions if your code depends on it.
4747 ///
4748 /// </div>
4749 pub async fn disconnect(
4750 &self,
4751 params: ConnectorConnectRequest,
4752 ) -> Result<ConnectorDisconnectResult, Error> {
4753 let mut wire_params = serde_json::to_value(params)?;
4754 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4755 let _value = self
4756 .session
4757 .client()
4758 .call(
4759 rpc_methods::SESSION_CONNECTORS_DISCONNECT,
4760 Some(wire_params),
4761 )
4762 .await?;
4763 Ok(serde_json::from_value(_value)?)
4764 }
4765
4766 /// Reconciles the authoritative cached or freshly requested Connector catalog into the session Connector MCP projection and returns live status.
4767 ///
4768 /// Wire method: `session.connectors.reconcile`.
4769 ///
4770 /// # Parameters
4771 ///
4772 /// * `params` - Requests authoritative Connector-to-MCP reconciliation for the pinned account.
4773 ///
4774 /// # Returns
4775 ///
4776 /// Authoritative session connector state. Account IDs are opaque routing identifiers and credentials are never included.
4777 ///
4778 /// <div class="warning">
4779 ///
4780 /// **Experimental.** This API is part of an experimental wire-protocol surface
4781 /// and may change or be removed in future SDK or CLI releases. Pin both the
4782 /// SDK and CLI versions if your code depends on it.
4783 ///
4784 /// </div>
4785 pub async fn reconcile(
4786 &self,
4787 params: ConnectorReconcileRequest,
4788 ) -> Result<ConnectorStatus, Error> {
4789 let mut wire_params = serde_json::to_value(params)?;
4790 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4791 let _value = self
4792 .session
4793 .client()
4794 .call(rpc_methods::SESSION_CONNECTORS_RECONCILE, Some(wire_params))
4795 .await?;
4796 Ok(serde_json::from_value(_value)?)
4797 }
4798
4799 /// Reconciles the authoritative Connector catalog into the session MCP projection during startup with a bounded deadline and fail-closed cleanup.
4800 ///
4801 /// Wire method: `session.connectors.reconcileForStartup`.
4802 ///
4803 /// # Parameters
4804 ///
4805 /// * `params` - Pins a Connector operation to one host-owned GitHub account through its opaque selection ID. Provider tokens are never accepted.
4806 ///
4807 /// # Returns
4808 ///
4809 /// Authoritative session connector state. Account IDs are opaque routing identifiers and credentials are never included.
4810 ///
4811 /// <div class="warning">
4812 ///
4813 /// **Experimental.** This API is part of an experimental wire-protocol surface
4814 /// and may change or be removed in future SDK or CLI releases. Pin both the
4815 /// SDK and CLI versions if your code depends on it.
4816 ///
4817 /// </div>
4818 pub(crate) async fn reconcile_for_startup(
4819 &self,
4820 params: ConnectorAccountRequest,
4821 ) -> Result<ConnectorStatus, Error> {
4822 let mut wire_params = serde_json::to_value(params)?;
4823 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4824 let _value = self
4825 .session
4826 .client()
4827 .call(
4828 rpc_methods::SESSION_CONNECTORS_RECONCILEFORSTARTUP,
4829 Some(wire_params),
4830 )
4831 .await?;
4832 Ok(serde_json::from_value(_value)?)
4833 }
4834
4835 /// Removes the runtime-owned Connector MCP projection without changing service-side connections.
4836 ///
4837 /// Wire method: `session.connectors.withdrawProjection`.
4838 ///
4839 /// # Returns
4840 ///
4841 /// Authoritative session connector state. Account IDs are opaque routing identifiers and credentials are never included.
4842 ///
4843 /// <div class="warning">
4844 ///
4845 /// **Experimental.** This API is part of an experimental wire-protocol surface
4846 /// and may change or be removed in future SDK or CLI releases. Pin both the
4847 /// SDK and CLI versions if your code depends on it.
4848 ///
4849 /// </div>
4850 pub(crate) async fn withdraw_projection(&self) -> Result<ConnectorStatus, Error> {
4851 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
4852 let _value = self
4853 .session
4854 .client()
4855 .call(
4856 rpc_methods::SESSION_CONNECTORS_WITHDRAWPROJECTION,
4857 Some(wire_params),
4858 )
4859 .await?;
4860 Ok(serde_json::from_value(_value)?)
4861 }
4862}
4863
4864/// `session.contentExclusion.*` RPCs.
4865#[derive(Clone, Copy)]
4866pub struct SessionRpcContentExclusion<'a> {
4867 pub(crate) session: &'a Session,
4868}
4869
4870impl<'a> SessionRpcContentExclusion<'a> {
4871 /// 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.
4872 ///
4873 /// Wire method: `session.contentExclusion.checkPaths`.
4874 ///
4875 /// # Parameters
4876 ///
4877 /// * `params` - Local file system absolute paths within the session working directory to check against its content-exclusion policy.
4878 ///
4879 /// # Returns
4880 ///
4881 /// Batch content-exclusion result. Callers must fail closed when policy evaluation is unavailable.
4882 ///
4883 /// <div class="warning">
4884 ///
4885 /// **Experimental.** This API is part of an experimental wire-protocol surface
4886 /// and may change or be removed in future SDK or CLI releases. Pin both the
4887 /// SDK and CLI versions if your code depends on it.
4888 ///
4889 /// </div>
4890 pub async fn check_paths(
4891 &self,
4892 params: ContentExclusionCheckPathsRequest,
4893 ) -> Result<ContentExclusionCheckPathsResult, Error> {
4894 let mut wire_params = serde_json::to_value(params)?;
4895 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4896 let _value = self
4897 .session
4898 .client()
4899 .call(
4900 rpc_methods::SESSION_CONTENTEXCLUSION_CHECKPATHS,
4901 Some(wire_params),
4902 )
4903 .await?;
4904 Ok(serde_json::from_value(_value)?)
4905 }
4906}
4907
4908/// `session.debug.*` RPCs.
4909#[derive(Clone, Copy)]
4910pub struct SessionRpcDebug<'a> {
4911 pub(crate) session: &'a Session,
4912}
4913
4914impl<'a> SessionRpcDebug<'a> {
4915 /// Collects a session debug log bundle into a local archive or staging directory. Logs are redacted by default; redaction can be configured per caller-provided diagnostic entry. The runtime includes session-owned logs by default and accepts caller-provided diagnostic entries so host applications can add their own files without changing this API shape.
4916 ///
4917 /// Wire method: `session.debug.collectLogs`.
4918 ///
4919 /// # Parameters
4920 ///
4921 /// * `params` - Options for collecting a session debug bundle with configurable redaction.
4922 ///
4923 /// # Returns
4924 ///
4925 /// Result of collecting a session debug bundle.
4926 ///
4927 /// <div class="warning">
4928 ///
4929 /// **Experimental.** This API is part of an experimental wire-protocol surface
4930 /// and may change or be removed in future SDK or CLI releases. Pin both the
4931 /// SDK and CLI versions if your code depends on it.
4932 ///
4933 /// </div>
4934 pub async fn collect_logs(
4935 &self,
4936 params: DebugCollectLogsRequest,
4937 ) -> Result<DebugCollectLogsResult, Error> {
4938 let mut wire_params = serde_json::to_value(params)?;
4939 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4940 let _value = self
4941 .session
4942 .client()
4943 .call(rpc_methods::SESSION_DEBUG_COLLECTLOGS, Some(wire_params))
4944 .await?;
4945 Ok(serde_json::from_value(_value)?)
4946 }
4947}
4948
4949/// `session.eventLog.*` RPCs.
4950#[derive(Clone, Copy)]
4951pub struct SessionRpcEventLog<'a> {
4952 pub(crate) session: &'a Session,
4953}
4954
4955impl<'a> SessionRpcEventLog<'a> {
4956 /// Reads a batch of session events from a cursor, optionally waiting for new events. Supports tail-first reads via `direction: backward`.
4957 ///
4958 /// Wire method: `session.eventLog.read`.
4959 ///
4960 /// # Parameters
4961 ///
4962 /// * `params` - Cursor, batch size, and optional long-poll/filter parameters for reading session events.
4963 ///
4964 /// # Returns
4965 ///
4966 /// Batch of session events returned by a read, with cursor and continuation metadata.
4967 ///
4968 /// <div class="warning">
4969 ///
4970 /// **Experimental.** This API is part of an experimental wire-protocol surface
4971 /// and may change or be removed in future SDK or CLI releases. Pin both the
4972 /// SDK and CLI versions if your code depends on it.
4973 ///
4974 /// </div>
4975 pub async fn read(&self, params: EventLogReadRequest) -> Result<EventsReadResult, Error> {
4976 let mut wire_params = serde_json::to_value(params)?;
4977 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4978 let _value = self
4979 .session
4980 .client()
4981 .call(rpc_methods::SESSION_EVENTLOG_READ, Some(wire_params))
4982 .await?;
4983 Ok(serde_json::from_value(_value)?)
4984 }
4985
4986 /// Returns a snapshot of the current tail cursor without consuming events.
4987 ///
4988 /// Wire method: `session.eventLog.tail`.
4989 ///
4990 /// # Returns
4991 ///
4992 /// 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).
4993 ///
4994 /// <div class="warning">
4995 ///
4996 /// **Experimental.** This API is part of an experimental wire-protocol surface
4997 /// and may change or be removed in future SDK or CLI releases. Pin both the
4998 /// SDK and CLI versions if your code depends on it.
4999 ///
5000 /// </div>
5001 pub async fn tail(&self) -> Result<EventLogTailResult, Error> {
5002 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5003 let _value = self
5004 .session
5005 .client()
5006 .call(rpc_methods::SESSION_EVENTLOG_TAIL, Some(wire_params))
5007 .await?;
5008 Ok(serde_json::from_value(_value)?)
5009 }
5010
5011 /// Registers consumer interest in an event type for runtime gating purposes.
5012 ///
5013 /// Wire method: `session.eventLog.registerInterest`.
5014 ///
5015 /// # Parameters
5016 ///
5017 /// * `params` - Event type to register consumer interest for, used by runtime gating logic.
5018 ///
5019 /// # Returns
5020 ///
5021 /// Opaque handle representing an event-type interest registration.
5022 ///
5023 /// <div class="warning">
5024 ///
5025 /// **Experimental.** This API is part of an experimental wire-protocol surface
5026 /// and may change or be removed in future SDK or CLI releases. Pin both the
5027 /// SDK and CLI versions if your code depends on it.
5028 ///
5029 /// </div>
5030 pub async fn register_interest(
5031 &self,
5032 params: RegisterEventInterestParams,
5033 ) -> Result<RegisterEventInterestResult, Error> {
5034 let mut wire_params = serde_json::to_value(params)?;
5035 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5036 let _value = self
5037 .session
5038 .client()
5039 .call(
5040 rpc_methods::SESSION_EVENTLOG_REGISTERINTEREST,
5041 Some(wire_params),
5042 )
5043 .await?;
5044 Ok(serde_json::from_value(_value)?)
5045 }
5046
5047 /// Releases a consumer's previously-registered interest in an event type.
5048 ///
5049 /// Wire method: `session.eventLog.releaseInterest`.
5050 ///
5051 /// # Parameters
5052 ///
5053 /// * `params` - Opaque handle previously returned by `registerInterest` to release.
5054 ///
5055 /// # Returns
5056 ///
5057 /// Indicates whether the operation succeeded.
5058 ///
5059 /// <div class="warning">
5060 ///
5061 /// **Experimental.** This API is part of an experimental wire-protocol surface
5062 /// and may change or be removed in future SDK or CLI releases. Pin both the
5063 /// SDK and CLI versions if your code depends on it.
5064 ///
5065 /// </div>
5066 pub async fn release_interest(
5067 &self,
5068 params: ReleaseEventInterestParams,
5069 ) -> Result<EventLogReleaseInterestResult, Error> {
5070 let mut wire_params = serde_json::to_value(params)?;
5071 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5072 let _value = self
5073 .session
5074 .client()
5075 .call(
5076 rpc_methods::SESSION_EVENTLOG_RELEASEINTEREST,
5077 Some(wire_params),
5078 )
5079 .await?;
5080 Ok(serde_json::from_value(_value)?)
5081 }
5082}
5083
5084/// `session.extensions.*` RPCs.
5085#[derive(Clone, Copy)]
5086pub struct SessionRpcExtensions<'a> {
5087 pub(crate) session: &'a Session,
5088}
5089
5090impl<'a> SessionRpcExtensions<'a> {
5091 /// Lists extensions discovered for the session and their current status.
5092 ///
5093 /// Wire method: `session.extensions.list`.
5094 ///
5095 /// # Returns
5096 ///
5097 /// Extensions discovered for the session, with their current status.
5098 ///
5099 /// <div class="warning">
5100 ///
5101 /// **Experimental.** This API is part of an experimental wire-protocol surface
5102 /// and may change or be removed in future SDK or CLI releases. Pin both the
5103 /// SDK and CLI versions if your code depends on it.
5104 ///
5105 /// </div>
5106 pub async fn list(&self) -> Result<ExtensionList, Error> {
5107 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5108 let _value = self
5109 .session
5110 .client()
5111 .call(rpc_methods::SESSION_EXTENSIONS_LIST, Some(wire_params))
5112 .await?;
5113 Ok(serde_json::from_value(_value)?)
5114 }
5115
5116 /// Enables an extension for the session.
5117 ///
5118 /// Wire method: `session.extensions.enable`.
5119 ///
5120 /// # Parameters
5121 ///
5122 /// * `params` - Source-qualified extension identifier to enable for the session.
5123 ///
5124 /// <div class="warning">
5125 ///
5126 /// **Experimental.** This API is part of an experimental wire-protocol surface
5127 /// and may change or be removed in future SDK or CLI releases. Pin both the
5128 /// SDK and CLI versions if your code depends on it.
5129 ///
5130 /// </div>
5131 pub async fn enable(&self, params: ExtensionsEnableRequest) -> Result<(), Error> {
5132 let mut wire_params = serde_json::to_value(params)?;
5133 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5134 let _value = self
5135 .session
5136 .client()
5137 .call(rpc_methods::SESSION_EXTENSIONS_ENABLE, Some(wire_params))
5138 .await?;
5139 Ok(())
5140 }
5141
5142 /// Disables an extension for the session.
5143 ///
5144 /// Wire method: `session.extensions.disable`.
5145 ///
5146 /// # Parameters
5147 ///
5148 /// * `params` - Source-qualified extension identifier to disable for the session.
5149 ///
5150 /// <div class="warning">
5151 ///
5152 /// **Experimental.** This API is part of an experimental wire-protocol surface
5153 /// and may change or be removed in future SDK or CLI releases. Pin both the
5154 /// SDK and CLI versions if your code depends on it.
5155 ///
5156 /// </div>
5157 pub async fn disable(&self, params: ExtensionsDisableRequest) -> Result<(), Error> {
5158 let mut wire_params = serde_json::to_value(params)?;
5159 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5160 let _value = self
5161 .session
5162 .client()
5163 .call(rpc_methods::SESSION_EXTENSIONS_DISABLE, Some(wire_params))
5164 .await?;
5165 Ok(())
5166 }
5167
5168 /// Reloads extension definitions and processes for the session.
5169 ///
5170 /// Wire method: `session.extensions.reload`.
5171 ///
5172 /// <div class="warning">
5173 ///
5174 /// **Experimental.** This API is part of an experimental wire-protocol surface
5175 /// and may change or be removed in future SDK or CLI releases. Pin both the
5176 /// SDK and CLI versions if your code depends on it.
5177 ///
5178 /// </div>
5179 pub async fn reload(&self) -> Result<(), Error> {
5180 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5181 let _value = self
5182 .session
5183 .client()
5184 .call(rpc_methods::SESSION_EXTENSIONS_RELOAD, Some(wire_params))
5185 .await?;
5186 Ok(())
5187 }
5188
5189 /// 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.
5190 ///
5191 /// Wire method: `session.extensions.sendAttachmentsToMessage`.
5192 ///
5193 /// # Parameters
5194 ///
5195 /// * `params` - Parameters for session.extensions.sendAttachmentsToMessage.
5196 ///
5197 /// <div class="warning">
5198 ///
5199 /// **Experimental.** This API is part of an experimental wire-protocol surface
5200 /// and may change or be removed in future SDK or CLI releases. Pin both the
5201 /// SDK and CLI versions if your code depends on it.
5202 ///
5203 /// </div>
5204 pub async fn send_attachments_to_message(
5205 &self,
5206 params: SendAttachmentsToMessageParams,
5207 ) -> Result<(), Error> {
5208 let mut wire_params = serde_json::to_value(params)?;
5209 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5210 let _value = self
5211 .session
5212 .client()
5213 .call(
5214 rpc_methods::SESSION_EXTENSIONS_SENDATTACHMENTSTOMESSAGE,
5215 Some(wire_params),
5216 )
5217 .await?;
5218 Ok(())
5219 }
5220}
5221
5222/// `session.factory.*` RPCs.
5223#[derive(Clone, Copy)]
5224pub struct SessionRpcFactory<'a> {
5225 pub(crate) session: &'a Session,
5226}
5227
5228impl<'a> SessionRpcFactory<'a> {
5229 /// `session.factory.journal.*` sub-namespace.
5230 pub fn journal(&self) -> SessionRpcFactoryJournal<'a> {
5231 SessionRpcFactoryJournal {
5232 session: self.session,
5233 }
5234 }
5235
5236 /// Runs a registered factory by name at the top level.
5237 ///
5238 /// Wire method: `session.factory.run`.
5239 ///
5240 /// # Parameters
5241 ///
5242 /// * `params` - Parameters for invoking a registered factory.
5243 ///
5244 /// # Returns
5245 ///
5246 /// Complete current or terminal factory run envelope.
5247 ///
5248 /// <div class="warning">
5249 ///
5250 /// **Experimental.** This API is part of an experimental wire-protocol surface
5251 /// and may change or be removed in future SDK or CLI releases. Pin both the
5252 /// SDK and CLI versions if your code depends on it.
5253 ///
5254 /// </div>
5255 pub async fn run(&self, params: FactoryRunRequest) -> Result<FactoryRunResult, Error> {
5256 let mut wire_params = serde_json::to_value(params)?;
5257 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5258 let _value = self
5259 .session
5260 .client()
5261 .call(rpc_methods::SESSION_FACTORY_RUN, Some(wire_params))
5262 .await?;
5263 Ok(serde_json::from_value(_value)?)
5264 }
5265
5266 /// Resumes a factory run using its persisted name, arguments, journal, and accounting.
5267 ///
5268 /// Wire method: `session.factory.resume`.
5269 ///
5270 /// # Parameters
5271 ///
5272 /// * `params` - Parameters for resuming a factory run from its persisted identity.
5273 ///
5274 /// # Returns
5275 ///
5276 /// Resolved persisted factory identity and resumed run envelope.
5277 ///
5278 /// <div class="warning">
5279 ///
5280 /// **Experimental.** This API is part of an experimental wire-protocol surface
5281 /// and may change or be removed in future SDK or CLI releases. Pin both the
5282 /// SDK and CLI versions if your code depends on it.
5283 ///
5284 /// </div>
5285 pub async fn resume(&self, params: FactoryResumeRequest) -> Result<FactoryResumeResult, Error> {
5286 let mut wire_params = serde_json::to_value(params)?;
5287 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5288 let _value = self
5289 .session
5290 .client()
5291 .call(rpc_methods::SESSION_FACTORY_RESUME, Some(wire_params))
5292 .await?;
5293 Ok(serde_json::from_value(_value)?)
5294 }
5295
5296 /// Internal tool-originated factory invocation.
5297 ///
5298 /// Wire method: `session.factory.runFromTool`.
5299 ///
5300 /// # Parameters
5301 ///
5302 /// * `params` - Internal parameters for invoking a registered factory from a tool.
5303 ///
5304 /// # Returns
5305 ///
5306 /// Complete current or terminal factory run envelope.
5307 ///
5308 /// <div class="warning">
5309 ///
5310 /// **Experimental.** This API is part of an experimental wire-protocol surface
5311 /// and may change or be removed in future SDK or CLI releases. Pin both the
5312 /// SDK and CLI versions if your code depends on it.
5313 ///
5314 /// </div>
5315 pub(crate) async fn run_from_tool(
5316 &self,
5317 params: FactoryToolRunRequest,
5318 ) -> Result<FactoryRunResult, Error> {
5319 let mut wire_params = serde_json::to_value(params)?;
5320 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5321 let _value = self
5322 .session
5323 .client()
5324 .call(rpc_methods::SESSION_FACTORY_RUNFROMTOOL, Some(wire_params))
5325 .await?;
5326 Ok(serde_json::from_value(_value)?)
5327 }
5328
5329 /// Internal tool-originated factory resume.
5330 ///
5331 /// Wire method: `session.factory.resumeFromTool`.
5332 ///
5333 /// # Parameters
5334 ///
5335 /// * `params` - Internal parameters for resuming a factory run from a tool.
5336 ///
5337 /// # Returns
5338 ///
5339 /// Resolved persisted factory identity and resumed run envelope.
5340 ///
5341 /// <div class="warning">
5342 ///
5343 /// **Experimental.** This API is part of an experimental wire-protocol surface
5344 /// and may change or be removed in future SDK or CLI releases. Pin both the
5345 /// SDK and CLI versions if your code depends on it.
5346 ///
5347 /// </div>
5348 pub(crate) async fn resume_from_tool(
5349 &self,
5350 params: FactoryToolResumeRequest,
5351 ) -> Result<FactoryResumeResult, Error> {
5352 let mut wire_params = serde_json::to_value(params)?;
5353 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5354 let _value = self
5355 .session
5356 .client()
5357 .call(
5358 rpc_methods::SESSION_FACTORY_RESUMEFROMTOOL,
5359 Some(wire_params),
5360 )
5361 .await?;
5362 Ok(serde_json::from_value(_value)?)
5363 }
5364
5365 /// Gets the current or settled envelope for a factory run.
5366 ///
5367 /// Wire method: `session.factory.getRun`.
5368 ///
5369 /// # Parameters
5370 ///
5371 /// * `params` - Parameters for retrieving a factory run.
5372 ///
5373 /// # Returns
5374 ///
5375 /// Complete current or terminal factory run envelope.
5376 ///
5377 /// <div class="warning">
5378 ///
5379 /// **Experimental.** This API is part of an experimental wire-protocol surface
5380 /// and may change or be removed in future SDK or CLI releases. Pin both the
5381 /// SDK and CLI versions if your code depends on it.
5382 ///
5383 /// </div>
5384 pub async fn get_run(&self, params: FactoryGetRunRequest) -> Result<FactoryRunResult, Error> {
5385 let mut wire_params = serde_json::to_value(params)?;
5386 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5387 let _value = self
5388 .session
5389 .client()
5390 .call(rpc_methods::SESSION_FACTORY_GETRUN, Some(wire_params))
5391 .await?;
5392 Ok(serde_json::from_value(_value)?)
5393 }
5394
5395 /// Lists durable factory runs for this session in creation order.
5396 ///
5397 /// Wire method: `session.factory.listRuns`.
5398 ///
5399 /// # Parameters
5400 ///
5401 /// * `params` - Parameters for paging factory runs.
5402 ///
5403 /// # Returns
5404 ///
5405 /// A page of factory runs in durable creation order.
5406 ///
5407 /// <div class="warning">
5408 ///
5409 /// **Experimental.** This API is part of an experimental wire-protocol surface
5410 /// and may change or be removed in future SDK or CLI releases. Pin both the
5411 /// SDK and CLI versions if your code depends on it.
5412 ///
5413 /// </div>
5414 pub async fn list_runs(
5415 &self,
5416 params: FactoryListRunsRequest,
5417 ) -> Result<FactoryListRunsResult, Error> {
5418 let mut wire_params = serde_json::to_value(params)?;
5419 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5420 let _value = self
5421 .session
5422 .client()
5423 .call(rpc_methods::SESSION_FACTORY_LISTRUNS, Some(wire_params))
5424 .await?;
5425 Ok(serde_json::from_value(_value)?)
5426 }
5427
5428 /// Gets durable and live observability detail for one factory run.
5429 ///
5430 /// Wire method: `session.factory.getRunDetail`.
5431 ///
5432 /// # Parameters
5433 ///
5434 /// * `params` - Parameters for retrieving a factory run.
5435 ///
5436 /// # Returns
5437 ///
5438 /// Full factory run observability detail.
5439 ///
5440 /// <div class="warning">
5441 ///
5442 /// **Experimental.** This API is part of an experimental wire-protocol surface
5443 /// and may change or be removed in future SDK or CLI releases. Pin both the
5444 /// SDK and CLI versions if your code depends on it.
5445 ///
5446 /// </div>
5447 pub async fn get_run_detail(
5448 &self,
5449 params: FactoryGetRunRequest,
5450 ) -> Result<FactoryRunDetail, Error> {
5451 let mut wire_params = serde_json::to_value(params)?;
5452 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5453 let _value = self
5454 .session
5455 .client()
5456 .call(rpc_methods::SESSION_FACTORY_GETRUNDETAIL, Some(wire_params))
5457 .await?;
5458 Ok(serde_json::from_value(_value)?)
5459 }
5460
5461 /// Pages durable progress for one factory run.
5462 ///
5463 /// Wire method: `session.factory.getRunProgress`.
5464 ///
5465 /// # Parameters
5466 ///
5467 /// * `params` - Parameters for paging factory progress.
5468 ///
5469 /// # Returns
5470 ///
5471 /// A bidirectional page of factory progress.
5472 ///
5473 /// <div class="warning">
5474 ///
5475 /// **Experimental.** This API is part of an experimental wire-protocol surface
5476 /// and may change or be removed in future SDK or CLI releases. Pin both the
5477 /// SDK and CLI versions if your code depends on it.
5478 ///
5479 /// </div>
5480 pub async fn get_run_progress(
5481 &self,
5482 params: FactoryGetRunProgressRequest,
5483 ) -> Result<FactoryProgressPage, Error> {
5484 let mut wire_params = serde_json::to_value(params)?;
5485 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5486 let _value = self
5487 .session
5488 .client()
5489 .call(
5490 rpc_methods::SESSION_FACTORY_GETRUNPROGRESS,
5491 Some(wire_params),
5492 )
5493 .await?;
5494 Ok(serde_json::from_value(_value)?)
5495 }
5496
5497 /// Requests cancellation of a factory run and returns its run envelope.
5498 ///
5499 /// Wire method: `session.factory.cancel`.
5500 ///
5501 /// # Parameters
5502 ///
5503 /// * `params` - Parameters for cancelling a factory run.
5504 ///
5505 /// # Returns
5506 ///
5507 /// Complete current or terminal factory run envelope.
5508 ///
5509 /// <div class="warning">
5510 ///
5511 /// **Experimental.** This API is part of an experimental wire-protocol surface
5512 /// and may change or be removed in future SDK or CLI releases. Pin both the
5513 /// SDK and CLI versions if your code depends on it.
5514 ///
5515 /// </div>
5516 pub async fn cancel(&self, params: FactoryCancelRequest) -> Result<FactoryRunResult, Error> {
5517 let mut wire_params = serde_json::to_value(params)?;
5518 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5519 let _value = self
5520 .session
5521 .client()
5522 .call(rpc_methods::SESSION_FACTORY_CANCEL, Some(wire_params))
5523 .await?;
5524 Ok(serde_json::from_value(_value)?)
5525 }
5526
5527 /// Pauses a running factory and returns its settled run envelope.
5528 ///
5529 /// Wire method: `session.factory.pause`.
5530 ///
5531 /// # Parameters
5532 ///
5533 /// * `params` - Parameters for pausing a running factory.
5534 ///
5535 /// # Returns
5536 ///
5537 /// Complete current or terminal factory run envelope.
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 async fn pause(&self, params: FactoryPauseRequest) -> Result<FactoryRunResult, Error> {
5547 let mut wire_params = serde_json::to_value(params)?;
5548 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5549 let _value = self
5550 .session
5551 .client()
5552 .call(rpc_methods::SESSION_FACTORY_PAUSE, Some(wire_params))
5553 .await?;
5554 Ok(serde_json::from_value(_value)?)
5555 }
5556
5557 /// Atomically pauses an owned factory attempt at a durable checkpoint.
5558 ///
5559 /// Wire method: `session.factory.pauseAtCheckpoint`.
5560 ///
5561 /// # Parameters
5562 ///
5563 /// * `params` - Parameters for an owned durable pause checkpoint.
5564 ///
5565 /// <div class="warning">
5566 ///
5567 /// **Experimental.** This API is part of an experimental wire-protocol surface
5568 /// and may change or be removed in future SDK or CLI releases. Pin both the
5569 /// SDK and CLI versions if your code depends on it.
5570 ///
5571 /// </div>
5572 pub(crate) async fn pause_at_checkpoint(
5573 &self,
5574 params: FactoryPauseCheckpointRequest,
5575 ) -> Result<FactoryPauseCheckpointResult, Error> {
5576 let mut wire_params = serde_json::to_value(params)?;
5577 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5578 let _value = self
5579 .session
5580 .client()
5581 .call(
5582 rpc_methods::SESSION_FACTORY_PAUSEATCHECKPOINT,
5583 Some(wire_params),
5584 )
5585 .await?;
5586 Ok(serde_json::from_value(_value)?)
5587 }
5588
5589 /// Records a batch of ordered factory progress lines.
5590 ///
5591 /// Wire method: `session.factory.log`.
5592 ///
5593 /// # Parameters
5594 ///
5595 /// * `params` - Parameters for recording factory progress.
5596 ///
5597 /// # Returns
5598 ///
5599 /// Acknowledgement that a factory request was accepted.
5600 ///
5601 /// <div class="warning">
5602 ///
5603 /// **Experimental.** This API is part of an experimental wire-protocol surface
5604 /// and may change or be removed in future SDK or CLI releases. Pin both the
5605 /// SDK and CLI versions if your code depends on it.
5606 ///
5607 /// </div>
5608 pub async fn log(&self, params: FactoryLogRequest) -> Result<FactoryAckResult, Error> {
5609 let mut wire_params = serde_json::to_value(params)?;
5610 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5611 let _value = self
5612 .session
5613 .client()
5614 .call(rpc_methods::SESSION_FACTORY_LOG, Some(wire_params))
5615 .await?;
5616 Ok(serde_json::from_value(_value)?)
5617 }
5618
5619 /// Runs one factory-scoped subagent and returns its result.
5620 ///
5621 /// Wire method: `session.factory.agent`.
5622 ///
5623 /// # Parameters
5624 ///
5625 /// * `params` - Parameters for one factory-scoped subagent call.
5626 ///
5627 /// # Returns
5628 ///
5629 /// Result of one factory-scoped subagent call.
5630 ///
5631 /// <div class="warning">
5632 ///
5633 /// **Experimental.** This API is part of an experimental wire-protocol surface
5634 /// and may change or be removed in future SDK or CLI releases. Pin both the
5635 /// SDK and CLI versions if your code depends on it.
5636 ///
5637 /// </div>
5638 pub async fn agent(&self, params: FactoryAgentRequest) -> Result<FactoryAgentResult, Error> {
5639 let mut wire_params = serde_json::to_value(params)?;
5640 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5641 let _value = self
5642 .session
5643 .client()
5644 .call(rpc_methods::SESSION_FACTORY_AGENT, Some(wire_params))
5645 .await?;
5646 Ok(serde_json::from_value(_value)?)
5647 }
5648}
5649
5650/// `session.factory.journal.*` RPCs.
5651#[derive(Clone, Copy)]
5652pub struct SessionRpcFactoryJournal<'a> {
5653 pub(crate) session: &'a Session,
5654}
5655
5656impl<'a> SessionRpcFactoryJournal<'a> {
5657 /// Reads a memoized factory journal entry.
5658 ///
5659 /// Wire method: `session.factory.journal.get`.
5660 ///
5661 /// # Parameters
5662 ///
5663 /// * `params` - Parameters for reading a factory journal entry.
5664 ///
5665 /// # Returns
5666 ///
5667 /// Result of reading a factory journal entry.
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 get(
5677 &self,
5678 params: FactoryJournalGetRequest,
5679 ) -> Result<FactoryJournalGetResult, 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_FACTORY_JOURNAL_GET, Some(wire_params))
5686 .await?;
5687 Ok(serde_json::from_value(_value)?)
5688 }
5689
5690 /// Stores a memoized factory journal entry.
5691 ///
5692 /// Wire method: `session.factory.journal.put`.
5693 ///
5694 /// # Parameters
5695 ///
5696 /// * `params` - Parameters for storing a factory journal entry.
5697 ///
5698 /// # Returns
5699 ///
5700 /// Acknowledgement that a factory request was accepted.
5701 ///
5702 /// <div class="warning">
5703 ///
5704 /// **Experimental.** This API is part of an experimental wire-protocol surface
5705 /// and may change or be removed in future SDK or CLI releases. Pin both the
5706 /// SDK and CLI versions if your code depends on it.
5707 ///
5708 /// </div>
5709 pub async fn put(&self, params: FactoryJournalPutRequest) -> Result<FactoryAckResult, Error> {
5710 let mut wire_params = serde_json::to_value(params)?;
5711 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5712 let _value = self
5713 .session
5714 .client()
5715 .call(rpc_methods::SESSION_FACTORY_JOURNAL_PUT, Some(wire_params))
5716 .await?;
5717 Ok(serde_json::from_value(_value)?)
5718 }
5719}
5720
5721/// `session.fleet.*` RPCs.
5722#[derive(Clone, Copy)]
5723pub struct SessionRpcFleet<'a> {
5724 pub(crate) session: &'a Session,
5725}
5726
5727impl<'a> SessionRpcFleet<'a> {
5728 /// Starts fleet mode by submitting the fleet orchestration prompt to the session.
5729 ///
5730 /// Wire method: `session.fleet.start`.
5731 ///
5732 /// # Parameters
5733 ///
5734 /// * `params` - Parameters for starting fleet orchestration: an optional user prompt combined with the fleet instructions, plus the send options forwarded to the resulting turn.
5735 ///
5736 /// # Returns
5737 ///
5738 /// Indicates whether fleet mode was successfully activated.
5739 ///
5740 /// <div class="warning">
5741 ///
5742 /// **Experimental.** This API is part of an experimental wire-protocol surface
5743 /// and may change or be removed in future SDK or CLI releases. Pin both the
5744 /// SDK and CLI versions if your code depends on it.
5745 ///
5746 /// </div>
5747 pub async fn start(&self, params: FleetStartRequest) -> Result<FleetStartResult, Error> {
5748 let mut wire_params = serde_json::to_value(params)?;
5749 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5750 let _value = self
5751 .session
5752 .client()
5753 .call(rpc_methods::SESSION_FLEET_START, Some(wire_params))
5754 .await?;
5755 Ok(serde_json::from_value(_value)?)
5756 }
5757}
5758
5759/// `session.gitHubAuth.*` RPCs.
5760#[derive(Clone, Copy)]
5761pub struct SessionRpcGitHubAuth<'a> {
5762 pub(crate) session: &'a Session,
5763}
5764
5765impl<'a> SessionRpcGitHubAuth<'a> {
5766 /// Gets authentication status and account metadata for the session.
5767 ///
5768 /// Wire method: `session.gitHubAuth.getStatus`.
5769 ///
5770 /// # Returns
5771 ///
5772 /// Authentication status and account metadata for the session.
5773 ///
5774 /// <div class="warning">
5775 ///
5776 /// **Experimental.** This API is part of an experimental wire-protocol surface
5777 /// and may change or be removed in future SDK or CLI releases. Pin both the
5778 /// SDK and CLI versions if your code depends on it.
5779 ///
5780 /// </div>
5781 pub async fn get_status(&self) -> Result<SessionAuthStatus, Error> {
5782 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5783 let _value = self
5784 .session
5785 .client()
5786 .call(rpc_methods::SESSION_GITHUBAUTH_GETSTATUS, Some(wire_params))
5787 .await?;
5788 Ok(serde_json::from_value(_value)?)
5789 }
5790
5791 /// Updates the session's auth credentials used for outbound model and API requests.
5792 ///
5793 /// Wire method: `session.gitHubAuth.setCredentials`.
5794 ///
5795 /// # Parameters
5796 ///
5797 /// * `params` - New auth credentials to install on the session. Omit to leave credentials unchanged.
5798 ///
5799 /// # Returns
5800 ///
5801 /// Indicates whether the credential update succeeded.
5802 ///
5803 /// <div class="warning">
5804 ///
5805 /// **Experimental.** This API is part of an experimental wire-protocol surface
5806 /// and may change or be removed in future SDK or CLI releases. Pin both the
5807 /// SDK and CLI versions if your code depends on it.
5808 ///
5809 /// </div>
5810 pub async fn set_credentials(
5811 &self,
5812 params: SessionSetCredentialsParams,
5813 ) -> Result<SessionSetCredentialsResult, Error> {
5814 let mut wire_params = serde_json::to_value(params)?;
5815 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5816 let _value = self
5817 .session
5818 .client()
5819 .call(
5820 rpc_methods::SESSION_GITHUBAUTH_SETCREDENTIALS,
5821 Some(wire_params),
5822 )
5823 .await?;
5824 Ok(serde_json::from_value(_value)?)
5825 }
5826
5827 /// Gets the current authentication information for internal session hosts.
5828 ///
5829 /// Wire method: `session.gitHubAuth.getCurrentAuthInfo`.
5830 ///
5831 /// # Returns
5832 ///
5833 /// Current authentication information, or null when no authentication is active.
5834 ///
5835 /// <div class="warning">
5836 ///
5837 /// **Experimental.** This API is part of an experimental wire-protocol surface
5838 /// and may change or be removed in future SDK or CLI releases. Pin both the
5839 /// SDK and CLI versions if your code depends on it.
5840 ///
5841 /// </div>
5842 pub(crate) async fn get_current_auth_info(&self) -> Result<SessionAuthInfoResult, Error> {
5843 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5844 let _value = self
5845 .session
5846 .client()
5847 .call(
5848 rpc_methods::SESSION_GITHUBAUTH_GETCURRENTAUTHINFO,
5849 Some(wire_params),
5850 )
5851 .await?;
5852 Ok(serde_json::from_value(_value)?)
5853 }
5854
5855 /// Gets all authentication accounts available to the internal session host.
5856 ///
5857 /// Wire method: `session.gitHubAuth.getAllAuthAvailable`.
5858 ///
5859 /// # Returns
5860 ///
5861 /// Authentication accounts available to the internal session host.
5862 ///
5863 /// <div class="warning">
5864 ///
5865 /// **Experimental.** This API is part of an experimental wire-protocol surface
5866 /// and may change or be removed in future SDK or CLI releases. Pin both the
5867 /// SDK and CLI versions if your code depends on it.
5868 ///
5869 /// </div>
5870 pub(crate) async fn get_all_auth_available(
5871 &self,
5872 ) -> Result<SessionGitHubAuthGetAllAuthAvailableResult, Error> {
5873 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5874 let _value = self
5875 .session
5876 .client()
5877 .call(
5878 rpc_methods::SESSION_GITHUBAUTH_GETALLAUTHAVAILABLE,
5879 Some(wire_params),
5880 )
5881 .await?;
5882 Ok(serde_json::from_value(_value)?)
5883 }
5884
5885 /// Refreshes Copilot account metadata for the current authentication.
5886 ///
5887 /// Wire method: `session.gitHubAuth.refreshCopilotUser`.
5888 ///
5889 /// # Returns
5890 ///
5891 /// Current authentication information, or null when no authentication is active.
5892 ///
5893 /// <div class="warning">
5894 ///
5895 /// **Experimental.** This API is part of an experimental wire-protocol surface
5896 /// and may change or be removed in future SDK or CLI releases. Pin both the
5897 /// SDK and CLI versions if your code depends on it.
5898 ///
5899 /// </div>
5900 pub(crate) async fn refresh_copilot_user(&self) -> Result<SessionAuthInfoResult, Error> {
5901 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5902 let _value = self
5903 .session
5904 .client()
5905 .call(
5906 rpc_methods::SESSION_GITHUBAUTH_REFRESHCOPILOTUSER,
5907 Some(wire_params),
5908 )
5909 .await?;
5910 Ok(serde_json::from_value(_value)?)
5911 }
5912
5913 /// Logs in a GitHub user through the internal session host.
5914 ///
5915 /// Wire method: `session.gitHubAuth.login`.
5916 ///
5917 /// # Parameters
5918 ///
5919 /// * `params` - Internal GitHub login parameters.
5920 ///
5921 /// # Returns
5922 ///
5923 /// Authentication credentials accepted only at native protocol ingress. Runtime outputs use credential-free `AuthIdentity` metadata.
5924 ///
5925 /// <div class="warning">
5926 ///
5927 /// **Experimental.** This API is part of an experimental wire-protocol surface
5928 /// and may change or be removed in future SDK or CLI releases. Pin both the
5929 /// SDK and CLI versions if your code depends on it.
5930 ///
5931 /// </div>
5932 pub(crate) async fn login(&self, params: SessionAuthLoginRequest) -> Result<AuthInfo, Error> {
5933 let mut wire_params = serde_json::to_value(params)?;
5934 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5935 let _value = self
5936 .session
5937 .client()
5938 .call(rpc_methods::SESSION_GITHUBAUTH_LOGIN, Some(wire_params))
5939 .await?;
5940 Ok(serde_json::from_value(_value)?)
5941 }
5942
5943 /// Switches the session to another available authentication.
5944 ///
5945 /// Wire method: `session.gitHubAuth.switchToAuth`.
5946 ///
5947 /// # Parameters
5948 ///
5949 /// * `params` - Parameters for switching the session's active authentication.
5950 ///
5951 /// <div class="warning">
5952 ///
5953 /// **Experimental.** This API is part of an experimental wire-protocol surface
5954 /// and may change or be removed in future SDK or CLI releases. Pin both the
5955 /// SDK and CLI versions if your code depends on it.
5956 ///
5957 /// </div>
5958 pub(crate) async fn switch_to_auth(
5959 &self,
5960 params: SessionAuthSwitchRequest,
5961 ) -> Result<(), Error> {
5962 let mut wire_params = serde_json::to_value(params)?;
5963 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5964 let _value = self
5965 .session
5966 .client()
5967 .call(
5968 rpc_methods::SESSION_GITHUBAUTH_SWITCHTOAUTH,
5969 Some(wire_params),
5970 )
5971 .await?;
5972 Ok(())
5973 }
5974
5975 /// Logs out the session's current GitHub authentication.
5976 ///
5977 /// Wire method: `session.gitHubAuth.logout`.
5978 ///
5979 /// # Returns
5980 ///
5981 /// Whether the current authentication was logged out.
5982 ///
5983 /// <div class="warning">
5984 ///
5985 /// **Experimental.** This API is part of an experimental wire-protocol surface
5986 /// and may change or be removed in future SDK or CLI releases. Pin both the
5987 /// SDK and CLI versions if your code depends on it.
5988 ///
5989 /// </div>
5990 pub(crate) async fn logout(&self) -> Result<SessionGitHubAuthLogoutResult, Error> {
5991 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5992 let _value = self
5993 .session
5994 .client()
5995 .call(rpc_methods::SESSION_GITHUBAUTH_LOGOUT, Some(wire_params))
5996 .await?;
5997 Ok(serde_json::from_value(_value)?)
5998 }
5999
6000 /// Logs out a specific GitHub authentication.
6001 ///
6002 /// Wire method: `session.gitHubAuth.logoutUser`.
6003 ///
6004 /// # Parameters
6005 ///
6006 /// * `params` - Parameters identifying a GitHub authentication to log out.
6007 ///
6008 /// # Returns
6009 ///
6010 /// Whether the requested authentication was logged out.
6011 ///
6012 /// <div class="warning">
6013 ///
6014 /// **Experimental.** This API is part of an experimental wire-protocol surface
6015 /// and may change or be removed in future SDK or CLI releases. Pin both the
6016 /// SDK and CLI versions if your code depends on it.
6017 ///
6018 /// </div>
6019 pub(crate) async fn logout_user(
6020 &self,
6021 params: SessionAuthLogoutUserRequest,
6022 ) -> Result<SessionGitHubAuthLogoutUserResult, Error> {
6023 let mut wire_params = serde_json::to_value(params)?;
6024 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6025 let _value = self
6026 .session
6027 .client()
6028 .call(
6029 rpc_methods::SESSION_GITHUBAUTH_LOGOUTUSER,
6030 Some(wire_params),
6031 )
6032 .await?;
6033 Ok(serde_json::from_value(_value)?)
6034 }
6035
6036 /// Gets validation errors from the most recent authentication attempt.
6037 ///
6038 /// Wire method: `session.gitHubAuth.lastAuthErrors`.
6039 ///
6040 /// # Returns
6041 ///
6042 /// Validation errors from the most recent authentication attempt.
6043 ///
6044 /// <div class="warning">
6045 ///
6046 /// **Experimental.** This API is part of an experimental wire-protocol surface
6047 /// and may change or be removed in future SDK or CLI releases. Pin both the
6048 /// SDK and CLI versions if your code depends on it.
6049 ///
6050 /// </div>
6051 pub(crate) async fn last_auth_errors(&self) -> Result<AuthValidationErrors, Error> {
6052 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6053 let _value = self
6054 .session
6055 .client()
6056 .call(
6057 rpc_methods::SESSION_GITHUBAUTH_LASTAUTHERRORS,
6058 Some(wire_params),
6059 )
6060 .await?;
6061 Ok(serde_json::from_value(_value)?)
6062 }
6063}
6064
6065/// `session.history.*` RPCs.
6066#[derive(Clone, Copy)]
6067pub struct SessionRpcHistory<'a> {
6068 pub(crate) session: &'a Session,
6069}
6070
6071impl<'a> SessionRpcHistory<'a> {
6072 /// Compacts the session history to reduce context usage.
6073 ///
6074 /// Wire method: `session.history.compact`.
6075 ///
6076 /// # Returns
6077 ///
6078 /// Compaction outcome with the number of tokens and messages removed, summary text, and the resulting context window breakdown.
6079 ///
6080 /// <div class="warning">
6081 ///
6082 /// **Experimental.** This API is part of an experimental wire-protocol surface
6083 /// and may change or be removed in future SDK or CLI releases. Pin both the
6084 /// SDK and CLI versions if your code depends on it.
6085 ///
6086 /// </div>
6087 pub async fn compact(&self) -> Result<HistoryCompactResult, Error> {
6088 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6089 let _value = self
6090 .session
6091 .client()
6092 .call(rpc_methods::SESSION_HISTORY_COMPACT, Some(wire_params))
6093 .await?;
6094 Ok(serde_json::from_value(_value)?)
6095 }
6096
6097 /// Compacts the session history to reduce context usage.
6098 ///
6099 /// Wire method: `session.history.compact`.
6100 ///
6101 /// # Parameters
6102 ///
6103 /// * `params` - Optional compaction parameters.
6104 ///
6105 /// # Returns
6106 ///
6107 /// Compaction outcome with the number of tokens and messages removed, summary text, and the resulting context window breakdown.
6108 ///
6109 /// <div class="warning">
6110 ///
6111 /// **Experimental.** This API is part of an experimental wire-protocol surface
6112 /// and may change or be removed in future SDK or CLI releases. Pin both the
6113 /// SDK and CLI versions if your code depends on it.
6114 ///
6115 /// </div>
6116 pub async fn compact_with_params(
6117 &self,
6118 params: HistoryCompactRequest,
6119 ) -> Result<HistoryCompactResult, Error> {
6120 let mut wire_params = serde_json::to_value(params)?;
6121 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6122 let _value = self
6123 .session
6124 .client()
6125 .call(rpc_methods::SESSION_HISTORY_COMPACT, Some(wire_params))
6126 .await?;
6127 Ok(serde_json::from_value(_value)?)
6128 }
6129
6130 /// Truncates persisted session history to a specific event.
6131 ///
6132 /// Wire method: `session.history.truncate`.
6133 ///
6134 /// # Parameters
6135 ///
6136 /// * `params` - Identifier of the event to truncate to; this event and all later events are removed.
6137 ///
6138 /// # Returns
6139 ///
6140 /// Number of events that were removed by the truncation.
6141 ///
6142 /// <div class="warning">
6143 ///
6144 /// **Experimental.** This API is part of an experimental wire-protocol surface
6145 /// and may change or be removed in future SDK or CLI releases. Pin both the
6146 /// SDK and CLI versions if your code depends on it.
6147 ///
6148 /// </div>
6149 pub async fn truncate(
6150 &self,
6151 params: HistoryTruncateRequest,
6152 ) -> Result<HistoryTruncateResult, Error> {
6153 let mut wire_params = serde_json::to_value(params)?;
6154 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6155 let _value = self
6156 .session
6157 .client()
6158 .call(rpc_methods::SESSION_HISTORY_TRUNCATE, Some(wire_params))
6159 .await?;
6160 Ok(serde_json::from_value(_value)?)
6161 }
6162
6163 /// 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.
6164 ///
6165 /// Wire method: `session.history.listRewindPoints`.
6166 ///
6167 /// # Returns
6168 ///
6169 /// Rewind points and file-change-tracking availability for the session.
6170 ///
6171 /// <div class="warning">
6172 ///
6173 /// **Experimental.** This API is part of an experimental wire-protocol surface
6174 /// and may change or be removed in future SDK or CLI releases. Pin both the
6175 /// SDK and CLI versions if your code depends on it.
6176 ///
6177 /// </div>
6178 pub async fn list_rewind_points(&self) -> Result<HistoryListRewindPointsResult, Error> {
6179 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6180 let _value = self
6181 .session
6182 .client()
6183 .call(
6184 rpc_methods::SESSION_HISTORY_LISTREWINDPOINTS,
6185 Some(wire_params),
6186 )
6187 .await?;
6188 Ok(serde_json::from_value(_value)?)
6189 }
6190
6191 /// Previews the files that a conversation-and-files rewind would restore.
6192 ///
6193 /// Wire method: `session.history.previewRewind`.
6194 ///
6195 /// # Parameters
6196 ///
6197 /// * `params` - Event boundary to preview for conversation-and-files rewind.
6198 ///
6199 /// # Returns
6200 ///
6201 /// Files and aggregate changes for a prospective rewind.
6202 ///
6203 /// <div class="warning">
6204 ///
6205 /// **Experimental.** This API is part of an experimental wire-protocol surface
6206 /// and may change or be removed in future SDK or CLI releases. Pin both the
6207 /// SDK and CLI versions if your code depends on it.
6208 ///
6209 /// </div>
6210 pub async fn preview_rewind(
6211 &self,
6212 params: HistoryPreviewRewindRequest,
6213 ) -> Result<HistoryPreviewRewindResult, Error> {
6214 let mut wire_params = serde_json::to_value(params)?;
6215 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6216 let _value = self
6217 .session
6218 .client()
6219 .call(
6220 rpc_methods::SESSION_HISTORY_PREVIEWREWIND,
6221 Some(wire_params),
6222 )
6223 .await?;
6224 Ok(serde_json::from_value(_value)?)
6225 }
6226
6227 /// 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.
6228 ///
6229 /// Wire method: `session.history.rewind`.
6230 ///
6231 /// # Parameters
6232 ///
6233 /// * `params` - Boundary and mode for rewinding session history.
6234 ///
6235 /// # Returns
6236 ///
6237 /// Structured outcome of a rewind request.
6238 ///
6239 /// <div class="warning">
6240 ///
6241 /// **Experimental.** This API is part of an experimental wire-protocol surface
6242 /// and may change or be removed in future SDK or CLI releases. Pin both the
6243 /// SDK and CLI versions if your code depends on it.
6244 ///
6245 /// </div>
6246 pub async fn rewind(&self, params: HistoryRewindRequest) -> Result<HistoryRewindResult, Error> {
6247 let mut wire_params = serde_json::to_value(params)?;
6248 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6249 let _value = self
6250 .session
6251 .client()
6252 .call(rpc_methods::SESSION_HISTORY_REWIND, Some(wire_params))
6253 .await?;
6254 Ok(serde_json::from_value(_value)?)
6255 }
6256
6257 /// Cancels any in-progress background compaction on a local session.
6258 ///
6259 /// Wire method: `session.history.cancelBackgroundCompaction`.
6260 ///
6261 /// # Returns
6262 ///
6263 /// Indicates whether an in-progress background compaction was cancelled.
6264 ///
6265 /// <div class="warning">
6266 ///
6267 /// **Experimental.** This API is part of an experimental wire-protocol surface
6268 /// and may change or be removed in future SDK or CLI releases. Pin both the
6269 /// SDK and CLI versions if your code depends on it.
6270 ///
6271 /// </div>
6272 pub async fn cancel_background_compaction(
6273 &self,
6274 ) -> Result<HistoryCancelBackgroundCompactionResult, Error> {
6275 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6276 let _value = self
6277 .session
6278 .client()
6279 .call(
6280 rpc_methods::SESSION_HISTORY_CANCELBACKGROUNDCOMPACTION,
6281 Some(wire_params),
6282 )
6283 .await?;
6284 Ok(serde_json::from_value(_value)?)
6285 }
6286
6287 /// Aborts any in-progress manual compaction on a local session.
6288 ///
6289 /// Wire method: `session.history.abortManualCompaction`.
6290 ///
6291 /// # Returns
6292 ///
6293 /// Indicates whether an in-progress manual compaction was aborted.
6294 ///
6295 /// <div class="warning">
6296 ///
6297 /// **Experimental.** This API is part of an experimental wire-protocol surface
6298 /// and may change or be removed in future SDK or CLI releases. Pin both the
6299 /// SDK and CLI versions if your code depends on it.
6300 ///
6301 /// </div>
6302 pub async fn abort_manual_compaction(
6303 &self,
6304 ) -> Result<HistoryAbortManualCompactionResult, Error> {
6305 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6306 let _value = self
6307 .session
6308 .client()
6309 .call(
6310 rpc_methods::SESSION_HISTORY_ABORTMANUALCOMPACTION,
6311 Some(wire_params),
6312 )
6313 .await?;
6314 Ok(serde_json::from_value(_value)?)
6315 }
6316
6317 /// Produces a markdown summary of the session's conversation context for hand-off scenarios.
6318 ///
6319 /// Wire method: `session.history.summarizeForHandoff`.
6320 ///
6321 /// # Returns
6322 ///
6323 /// Markdown summary of the conversation context (empty when not available).
6324 ///
6325 /// <div class="warning">
6326 ///
6327 /// **Experimental.** This API is part of an experimental wire-protocol surface
6328 /// and may change or be removed in future SDK or CLI releases. Pin both the
6329 /// SDK and CLI versions if your code depends on it.
6330 ///
6331 /// </div>
6332 pub async fn summarize_for_handoff(&self) -> Result<HistorySummarizeForHandoffResult, Error> {
6333 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6334 let _value = self
6335 .session
6336 .client()
6337 .call(
6338 rpc_methods::SESSION_HISTORY_SUMMARIZEFORHANDOFF,
6339 Some(wire_params),
6340 )
6341 .await?;
6342 Ok(serde_json::from_value(_value)?)
6343 }
6344
6345 /// 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.
6346 ///
6347 /// Wire method: `session.history.clearContext`.
6348 ///
6349 /// # Parameters
6350 ///
6351 /// * `params` - Parameters for clearing the conversation and seeding the window that replaces it.
6352 ///
6353 /// # Returns
6354 ///
6355 /// What a successful clear removed. A clear that could not be applied rejects instead of reporting a count.
6356 ///
6357 /// <div class="warning">
6358 ///
6359 /// **Experimental.** This API is part of an experimental wire-protocol surface
6360 /// and may change or be removed in future SDK or CLI releases. Pin both the
6361 /// SDK and CLI versions if your code depends on it.
6362 ///
6363 /// </div>
6364 pub async fn clear_context(
6365 &self,
6366 params: HistoryClearContextRequest,
6367 ) -> Result<HistoryClearContextResult, Error> {
6368 let mut wire_params = serde_json::to_value(params)?;
6369 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6370 let _value = self
6371 .session
6372 .client()
6373 .call(rpc_methods::SESSION_HISTORY_CLEARCONTEXT, Some(wire_params))
6374 .await?;
6375 Ok(serde_json::from_value(_value)?)
6376 }
6377}
6378
6379/// `session.instructions.*` RPCs.
6380#[derive(Clone, Copy)]
6381pub struct SessionRpcInstructions<'a> {
6382 pub(crate) session: &'a Session,
6383}
6384
6385impl<'a> SessionRpcInstructions<'a> {
6386 /// Gets instruction sources loaded for the session.
6387 ///
6388 /// Wire method: `session.instructions.getSources`.
6389 ///
6390 /// # Returns
6391 ///
6392 /// Instruction sources loaded for the session, in merge order.
6393 ///
6394 /// <div class="warning">
6395 ///
6396 /// **Experimental.** This API is part of an experimental wire-protocol surface
6397 /// and may change or be removed in future SDK or CLI releases. Pin both the
6398 /// SDK and CLI versions if your code depends on it.
6399 ///
6400 /// </div>
6401 pub async fn get_sources(&self) -> Result<InstructionsGetSourcesResult, Error> {
6402 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6403 let _value = self
6404 .session
6405 .client()
6406 .call(
6407 rpc_methods::SESSION_INSTRUCTIONS_GETSOURCES,
6408 Some(wire_params),
6409 )
6410 .await?;
6411 Ok(serde_json::from_value(_value)?)
6412 }
6413}
6414
6415/// `session.limitPrediction.*` RPCs.
6416#[derive(Clone, Copy)]
6417pub struct SessionRpcLimitPrediction<'a> {
6418 pub(crate) session: &'a Session,
6419}
6420
6421impl<'a> SessionRpcLimitPrediction<'a> {
6422 /// 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.
6423 ///
6424 /// Wire method: `session.limitPrediction.predict`.
6425 ///
6426 /// # Returns
6427 ///
6428 /// Prediction result. Available results include prediction details; unavailable results include an explicit reason.
6429 ///
6430 /// <div class="warning">
6431 ///
6432 /// **Experimental.** This API is part of an experimental wire-protocol surface
6433 /// and may change or be removed in future SDK or CLI releases. Pin both the
6434 /// SDK and CLI versions if your code depends on it.
6435 ///
6436 /// </div>
6437 pub async fn predict(&self) -> Result<SessionLimitPredictionResult, Error> {
6438 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6439 let _value = self
6440 .session
6441 .client()
6442 .call(
6443 rpc_methods::SESSION_LIMITPREDICTION_PREDICT,
6444 Some(wire_params),
6445 )
6446 .await?;
6447 Ok(serde_json::from_value(_value)?)
6448 }
6449
6450 /// 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.
6451 ///
6452 /// Wire method: `session.limitPrediction.predict`.
6453 ///
6454 /// # Parameters
6455 ///
6456 /// * `params` - Parameters for predicting an AI-credit session limit. Omitting `modelId` uses the session's currently selected model.
6457 ///
6458 /// # Returns
6459 ///
6460 /// Prediction result. Available results include prediction details; unavailable results include an explicit reason.
6461 ///
6462 /// <div class="warning">
6463 ///
6464 /// **Experimental.** This API is part of an experimental wire-protocol surface
6465 /// and may change or be removed in future SDK or CLI releases. Pin both the
6466 /// SDK and CLI versions if your code depends on it.
6467 ///
6468 /// </div>
6469 pub async fn predict_with_params(
6470 &self,
6471 params: SessionLimitPredictionRequest,
6472 ) -> Result<SessionLimitPredictionResult, Error> {
6473 let mut wire_params = serde_json::to_value(params)?;
6474 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6475 let _value = self
6476 .session
6477 .client()
6478 .call(
6479 rpc_methods::SESSION_LIMITPREDICTION_PREDICT,
6480 Some(wire_params),
6481 )
6482 .await?;
6483 Ok(serde_json::from_value(_value)?)
6484 }
6485}
6486
6487/// `session.lsp.*` RPCs.
6488#[derive(Clone, Copy)]
6489pub struct SessionRpcLsp<'a> {
6490 pub(crate) session: &'a Session,
6491}
6492
6493impl<'a> SessionRpcLsp<'a> {
6494 /// Loads the merged LSP configuration set for the session's working directory.
6495 ///
6496 /// Wire method: `session.lsp.initialize`.
6497 ///
6498 /// # Parameters
6499 ///
6500 /// * `params` - Parameters for (re)loading the merged LSP configuration set.
6501 ///
6502 /// <div class="warning">
6503 ///
6504 /// **Experimental.** This API is part of an experimental wire-protocol surface
6505 /// and may change or be removed in future SDK or CLI releases. Pin both the
6506 /// SDK and CLI versions if your code depends on it.
6507 ///
6508 /// </div>
6509 pub async fn initialize(&self, params: LspInitializeRequest) -> Result<(), Error> {
6510 let mut wire_params = serde_json::to_value(params)?;
6511 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6512 let _value = self
6513 .session
6514 .client()
6515 .call(rpc_methods::SESSION_LSP_INITIALIZE, Some(wire_params))
6516 .await?;
6517 Ok(())
6518 }
6519}
6520
6521/// `session.managedSettings.*` RPCs.
6522#[derive(Clone, Copy)]
6523pub struct SessionRpcManagedSettings<'a> {
6524 pub(crate) session: &'a Session,
6525}
6526
6527impl<'a> SessionRpcManagedSettings<'a> {
6528 /// Waits for the live session's in-flight managed-settings application, then returns the retained effective snapshot used by runtime enforcement and by `session.managed_settings_resolved`. It does not perform another account, device, or server resolution, and rejects when resolution has not produced a snapshot.
6529 ///
6530 /// Wire method: `session.managedSettings.get`.
6531 ///
6532 /// # Returns
6533 ///
6534 /// Enterprise managed-settings resolution: the effective managed settings the session applied and which channels contributed, so SDK clients can show users what is enterprise-managed. Fires whenever managed policy is (re)applied — at session start, on resume, and on account switch. This is an ephemeral live snapshot (delivered to subscribers but not persisted to the session event log), because at session start it resolves before `session.start` is emitted. Device values take precedence over server values, then the policy helper, per ordinary key, while permissions compose restrictively across device, server, policy-helper, and SDK-client layers. The account-scoped `getManagedSettings()` API does not include session-local client injection. Marked experimental while the managed-settings surface stabilizes.
6535 ///
6536 /// <div class="warning">
6537 ///
6538 /// **Experimental.** This API is part of an experimental wire-protocol surface
6539 /// and may change or be removed in future SDK or CLI releases. Pin both the
6540 /// SDK and CLI versions if your code depends on it.
6541 ///
6542 /// </div>
6543 pub async fn get(&self) -> Result<ManagedSettingsResolvedData, Error> {
6544 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6545 let _value = self
6546 .session
6547 .client()
6548 .call(rpc_methods::SESSION_MANAGEDSETTINGS_GET, Some(wire_params))
6549 .await?;
6550 Ok(serde_json::from_value(_value)?)
6551 }
6552}
6553
6554/// `session.mcp.*` RPCs.
6555#[derive(Clone, Copy)]
6556pub struct SessionRpcMcp<'a> {
6557 pub(crate) session: &'a Session,
6558}
6559
6560impl<'a> SessionRpcMcp<'a> {
6561 /// `session.mcp.apps.*` sub-namespace.
6562 pub fn apps(&self) -> SessionRpcMcpApps<'a> {
6563 SessionRpcMcpApps {
6564 session: self.session,
6565 }
6566 }
6567
6568 /// `session.mcp.headers.*` sub-namespace.
6569 pub fn headers(&self) -> SessionRpcMcpHeaders<'a> {
6570 SessionRpcMcpHeaders {
6571 session: self.session,
6572 }
6573 }
6574
6575 /// `session.mcp.oauth.*` sub-namespace.
6576 pub fn oauth(&self) -> SessionRpcMcpOauth<'a> {
6577 SessionRpcMcpOauth {
6578 session: self.session,
6579 }
6580 }
6581
6582 /// `session.mcp.resources.*` sub-namespace.
6583 pub fn resources(&self) -> SessionRpcMcpResources<'a> {
6584 SessionRpcMcpResources {
6585 session: self.session,
6586 }
6587 }
6588
6589 /// 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.
6590 ///
6591 /// Wire method: `session.mcp.list`.
6592 ///
6593 /// # Returns
6594 ///
6595 /// MCP servers configured for the session, with their connection status and host-level state.
6596 ///
6597 /// <div class="warning">
6598 ///
6599 /// **Experimental.** This API is part of an experimental wire-protocol surface
6600 /// and may change or be removed in future SDK or CLI releases. Pin both the
6601 /// SDK and CLI versions if your code depends on it.
6602 ///
6603 /// </div>
6604 pub async fn list(&self) -> Result<McpServerList, Error> {
6605 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6606 let _value = self
6607 .session
6608 .client()
6609 .call(rpc_methods::SESSION_MCP_LIST, Some(wire_params))
6610 .await?;
6611 Ok(serde_json::from_value(_value)?)
6612 }
6613
6614 /// 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.
6615 ///
6616 /// Wire method: `session.mcp.listTools`.
6617 ///
6618 /// # Parameters
6619 ///
6620 /// * `params` - Server name whose tool list should be returned.
6621 ///
6622 /// # Returns
6623 ///
6624 /// Tools exposed by the connected MCP server. Throws when the server is not connected.
6625 ///
6626 /// <div class="warning">
6627 ///
6628 /// **Experimental.** This API is part of an experimental wire-protocol surface
6629 /// and may change or be removed in future SDK or CLI releases. Pin both the
6630 /// SDK and CLI versions if your code depends on it.
6631 ///
6632 /// </div>
6633 pub async fn list_tools(
6634 &self,
6635 params: McpListToolsRequest,
6636 ) -> Result<McpListToolsResult, Error> {
6637 let mut wire_params = serde_json::to_value(params)?;
6638 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6639 let _value = self
6640 .session
6641 .client()
6642 .call(rpc_methods::SESSION_MCP_LISTTOOLS, Some(wire_params))
6643 .await?;
6644 Ok(serde_json::from_value(_value)?)
6645 }
6646
6647 /// Enables an MCP server for the session.
6648 ///
6649 /// Wire method: `session.mcp.enable`.
6650 ///
6651 /// # Parameters
6652 ///
6653 /// * `params` - Name of the MCP server to enable for the session.
6654 ///
6655 /// <div class="warning">
6656 ///
6657 /// **Experimental.** This API is part of an experimental wire-protocol surface
6658 /// and may change or be removed in future SDK or CLI releases. Pin both the
6659 /// SDK and CLI versions if your code depends on it.
6660 ///
6661 /// </div>
6662 pub async fn enable(&self, params: McpEnableRequest) -> Result<(), Error> {
6663 let mut wire_params = serde_json::to_value(params)?;
6664 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6665 let _value = self
6666 .session
6667 .client()
6668 .call(rpc_methods::SESSION_MCP_ENABLE, Some(wire_params))
6669 .await?;
6670 Ok(())
6671 }
6672
6673 /// Disables an MCP server for the session.
6674 ///
6675 /// Wire method: `session.mcp.disable`.
6676 ///
6677 /// # Parameters
6678 ///
6679 /// * `params` - Name of the MCP server to disable for the session.
6680 ///
6681 /// <div class="warning">
6682 ///
6683 /// **Experimental.** This API is part of an experimental wire-protocol surface
6684 /// and may change or be removed in future SDK or CLI releases. Pin both the
6685 /// SDK and CLI versions if your code depends on it.
6686 ///
6687 /// </div>
6688 pub async fn disable(&self, params: McpDisableRequest) -> Result<(), Error> {
6689 let mut wire_params = serde_json::to_value(params)?;
6690 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6691 let _value = self
6692 .session
6693 .client()
6694 .call(rpc_methods::SESSION_MCP_DISABLE, Some(wire_params))
6695 .await?;
6696 Ok(())
6697 }
6698
6699 /// Reloads MCP server connections for the session.
6700 ///
6701 /// Wire method: `session.mcp.reload`.
6702 ///
6703 /// <div class="warning">
6704 ///
6705 /// **Experimental.** This API is part of an experimental wire-protocol surface
6706 /// and may change or be removed in future SDK or CLI releases. Pin both the
6707 /// SDK and CLI versions if your code depends on it.
6708 ///
6709 /// </div>
6710 pub async fn reload(&self) -> Result<(), Error> {
6711 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6712 let _value = self
6713 .session
6714 .client()
6715 .call(rpc_methods::SESSION_MCP_RELOAD, Some(wire_params))
6716 .await?;
6717 Ok(())
6718 }
6719
6720 /// 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.
6721 ///
6722 /// Wire method: `session.mcp.moveLoadingToBackground`.
6723 ///
6724 /// # Returns
6725 ///
6726 /// Result of moving in-flight MCP loading to the background.
6727 ///
6728 /// <div class="warning">
6729 ///
6730 /// **Experimental.** This API is part of an experimental wire-protocol surface
6731 /// and may change or be removed in future SDK or CLI releases. Pin both the
6732 /// SDK and CLI versions if your code depends on it.
6733 ///
6734 /// </div>
6735 pub async fn move_loading_to_background(
6736 &self,
6737 ) -> Result<MoveMcpLoadingToBackgroundResult, Error> {
6738 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6739 let _value = self
6740 .session
6741 .client()
6742 .call(
6743 rpc_methods::SESSION_MCP_MOVELOADINGTOBACKGROUND,
6744 Some(wire_params),
6745 )
6746 .await?;
6747 Ok(serde_json::from_value(_value)?)
6748 }
6749
6750 /// Reloads MCP server connections for the session with an explicit host-provided configuration.
6751 ///
6752 /// Wire method: `session.mcp.reloadWithConfig`.
6753 ///
6754 /// # Parameters
6755 ///
6756 /// * `params` - Opaque MCP reload configuration.
6757 ///
6758 /// # Returns
6759 ///
6760 /// MCP server startup filtering result.
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(crate) async fn reload_with_config(
6770 &self,
6771 params: McpReloadWithConfigRequest,
6772 ) -> Result<McpStartServersResult, Error> {
6773 let mut wire_params = serde_json::to_value(params)?;
6774 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6775 let _value = self
6776 .session
6777 .client()
6778 .call(rpc_methods::SESSION_MCP_RELOADWITHCONFIG, Some(wire_params))
6779 .await?;
6780 Ok(serde_json::from_value(_value)?)
6781 }
6782
6783 /// Runs an MCP sampling inference on behalf of an MCP server.
6784 ///
6785 /// Wire method: `session.mcp.executeSampling`.
6786 ///
6787 /// # Parameters
6788 ///
6789 /// * `params` - Identifiers and raw MCP CreateMessageRequest params used to run a sampling inference.
6790 ///
6791 /// # Returns
6792 ///
6793 /// Outcome of an MCP sampling execution: success result, failure error, or cancellation.
6794 ///
6795 /// <div class="warning">
6796 ///
6797 /// **Experimental.** This API is part of an experimental wire-protocol surface
6798 /// and may change or be removed in future SDK or CLI releases. Pin both the
6799 /// SDK and CLI versions if your code depends on it.
6800 ///
6801 /// </div>
6802 pub async fn execute_sampling(
6803 &self,
6804 params: McpExecuteSamplingParams,
6805 ) -> Result<McpSamplingExecutionResult, Error> {
6806 let mut wire_params = serde_json::to_value(params)?;
6807 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6808 let _value = self
6809 .session
6810 .client()
6811 .call(rpc_methods::SESSION_MCP_EXECUTESAMPLING, Some(wire_params))
6812 .await?;
6813 Ok(serde_json::from_value(_value)?)
6814 }
6815
6816 /// Cancels an in-flight MCP sampling execution by request ID.
6817 ///
6818 /// Wire method: `session.mcp.cancelSamplingExecution`.
6819 ///
6820 /// # Parameters
6821 ///
6822 /// * `params` - The requestId previously passed to executeSampling that should be cancelled.
6823 ///
6824 /// # Returns
6825 ///
6826 /// Indicates whether an in-flight sampling execution with the given requestId was found and cancelled.
6827 ///
6828 /// <div class="warning">
6829 ///
6830 /// **Experimental.** This API is part of an experimental wire-protocol surface
6831 /// and may change or be removed in future SDK or CLI releases. Pin both the
6832 /// SDK and CLI versions if your code depends on it.
6833 ///
6834 /// </div>
6835 pub async fn cancel_sampling_execution(
6836 &self,
6837 params: McpCancelSamplingExecutionParams,
6838 ) -> Result<McpCancelSamplingExecutionResult, Error> {
6839 let mut wire_params = serde_json::to_value(params)?;
6840 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6841 let _value = self
6842 .session
6843 .client()
6844 .call(
6845 rpc_methods::SESSION_MCP_CANCELSAMPLINGEXECUTION,
6846 Some(wire_params),
6847 )
6848 .await?;
6849 Ok(serde_json::from_value(_value)?)
6850 }
6851
6852 /// Sets how environment-variable values supplied to MCP servers are resolved (direct or indirect).
6853 ///
6854 /// Wire method: `session.mcp.setEnvValueMode`.
6855 ///
6856 /// # Parameters
6857 ///
6858 /// * `params` - Mode controlling how MCP server env values are resolved (`direct` or `indirect`).
6859 ///
6860 /// # Returns
6861 ///
6862 /// Env-value mode recorded on the session after the update.
6863 ///
6864 /// <div class="warning">
6865 ///
6866 /// **Experimental.** This API is part of an experimental wire-protocol surface
6867 /// and may change or be removed in future SDK or CLI releases. Pin both the
6868 /// SDK and CLI versions if your code depends on it.
6869 ///
6870 /// </div>
6871 pub async fn set_env_value_mode(
6872 &self,
6873 params: McpSetEnvValueModeParams,
6874 ) -> Result<McpSetEnvValueModeResult, Error> {
6875 let mut wire_params = serde_json::to_value(params)?;
6876 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6877 let _value = self
6878 .session
6879 .client()
6880 .call(rpc_methods::SESSION_MCP_SETENVVALUEMODE, Some(wire_params))
6881 .await?;
6882 Ok(serde_json::from_value(_value)?)
6883 }
6884
6885 /// Removes the auto-managed `github` MCP server when present.
6886 ///
6887 /// Wire method: `session.mcp.removeGitHub`.
6888 ///
6889 /// # Returns
6890 ///
6891 /// Indicates whether the auto-managed `github` MCP server was removed (false when nothing to remove).
6892 ///
6893 /// <div class="warning">
6894 ///
6895 /// **Experimental.** This API is part of an experimental wire-protocol surface
6896 /// and may change or be removed in future SDK or CLI releases. Pin both the
6897 /// SDK and CLI versions if your code depends on it.
6898 ///
6899 /// </div>
6900 pub async fn remove_git_hub(&self) -> Result<McpRemoveGitHubResult, Error> {
6901 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6902 let _value = self
6903 .session
6904 .client()
6905 .call(rpc_methods::SESSION_MCP_REMOVEGITHUB, Some(wire_params))
6906 .await?;
6907 Ok(serde_json::from_value(_value)?)
6908 }
6909
6910 /// Configures the built-in GitHub MCP server for the session's current auth context.
6911 ///
6912 /// Wire method: `session.mcp.configureGitHub`.
6913 ///
6914 /// # Parameters
6915 ///
6916 /// * `params` - Credential-free authentication identity used to configure GitHub MCP.
6917 ///
6918 /// # Returns
6919 ///
6920 /// Result of configuring GitHub MCP.
6921 ///
6922 /// <div class="warning">
6923 ///
6924 /// **Experimental.** This API is part of an experimental wire-protocol surface
6925 /// and may change or be removed in future SDK or CLI releases. Pin both the
6926 /// SDK and CLI versions if your code depends on it.
6927 ///
6928 /// </div>
6929 pub(crate) async fn configure_git_hub(
6930 &self,
6931 params: McpConfigureGitHubRequest,
6932 ) -> Result<McpConfigureGitHubResult, Error> {
6933 let mut wire_params = serde_json::to_value(params)?;
6934 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6935 let _value = self
6936 .session
6937 .client()
6938 .call(rpc_methods::SESSION_MCP_CONFIGUREGITHUB, Some(wire_params))
6939 .await?;
6940 Ok(serde_json::from_value(_value)?)
6941 }
6942
6943 /// 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.
6944 ///
6945 /// Wire method: `session.mcp.startServer`.
6946 ///
6947 /// # Parameters
6948 ///
6949 /// * `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.
6950 ///
6951 /// <div class="warning">
6952 ///
6953 /// **Experimental.** This API is part of an experimental wire-protocol surface
6954 /// and may change or be removed in future SDK or CLI releases. Pin both the
6955 /// SDK and CLI versions if your code depends on it.
6956 ///
6957 /// </div>
6958 pub async fn start_server(&self, params: McpStartServerRequest) -> Result<(), Error> {
6959 let mut wire_params = serde_json::to_value(params)?;
6960 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6961 let _value = self
6962 .session
6963 .client()
6964 .call(rpc_methods::SESSION_MCP_STARTSERVER, Some(wire_params))
6965 .await?;
6966 Ok(())
6967 }
6968
6969 /// 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.*`).
6970 ///
6971 /// Wire method: `session.mcp.restartServer`.
6972 ///
6973 /// # Parameters
6974 ///
6975 /// * `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.
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 restart_server(&self, params: McpRestartServerRequest) -> Result<(), 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_RESTARTSERVER, Some(wire_params))
6991 .await?;
6992 Ok(())
6993 }
6994
6995 /// Stops an individual MCP server on the session's host.
6996 ///
6997 /// Wire method: `session.mcp.stopServer`.
6998 ///
6999 /// # Parameters
7000 ///
7001 /// * `params` - Server name for an individual MCP server stop.
7002 ///
7003 /// <div class="warning">
7004 ///
7005 /// **Experimental.** This API is part of an experimental wire-protocol surface
7006 /// and may change or be removed in future SDK or CLI releases. Pin both the
7007 /// SDK and CLI versions if your code depends on it.
7008 ///
7009 /// </div>
7010 pub async fn stop_server(&self, params: McpStopServerRequest) -> Result<(), Error> {
7011 let mut wire_params = serde_json::to_value(params)?;
7012 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7013 let _value = self
7014 .session
7015 .client()
7016 .call(rpc_methods::SESSION_MCP_STOPSERVER, Some(wire_params))
7017 .await?;
7018 Ok(())
7019 }
7020
7021 /// 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.
7022 ///
7023 /// Wire method: `session.mcp.registerExternalClient`.
7024 ///
7025 /// # Parameters
7026 ///
7027 /// * `params` - Registration parameters for an external MCP client.
7028 ///
7029 /// <div class="warning">
7030 ///
7031 /// **Experimental.** This API is part of an experimental wire-protocol surface
7032 /// and may change or be removed in future SDK or CLI releases. Pin both the
7033 /// SDK and CLI versions if your code depends on it.
7034 ///
7035 /// </div>
7036 pub(crate) async fn register_external_client(
7037 &self,
7038 params: McpRegisterExternalClientRequest,
7039 ) -> Result<(), Error> {
7040 let mut wire_params = serde_json::to_value(params)?;
7041 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7042 let _value = self
7043 .session
7044 .client()
7045 .call(
7046 rpc_methods::SESSION_MCP_REGISTEREXTERNALCLIENT,
7047 Some(wire_params),
7048 )
7049 .await?;
7050 Ok(())
7051 }
7052
7053 /// 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.
7054 ///
7055 /// Wire method: `session.mcp.unregisterExternalClient`.
7056 ///
7057 /// # Parameters
7058 ///
7059 /// * `params` - Server name identifying the external client to remove.
7060 ///
7061 /// <div class="warning">
7062 ///
7063 /// **Experimental.** This API is part of an experimental wire-protocol surface
7064 /// and may change or be removed in future SDK or CLI releases. Pin both the
7065 /// SDK and CLI versions if your code depends on it.
7066 ///
7067 /// </div>
7068 pub(crate) async fn unregister_external_client(
7069 &self,
7070 params: McpUnregisterExternalClientRequest,
7071 ) -> Result<(), Error> {
7072 let mut wire_params = serde_json::to_value(params)?;
7073 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7074 let _value = self
7075 .session
7076 .client()
7077 .call(
7078 rpc_methods::SESSION_MCP_UNREGISTEREXTERNALCLIENT,
7079 Some(wire_params),
7080 )
7081 .await?;
7082 Ok(())
7083 }
7084
7085 /// Checks whether a named MCP server is currently running on the session's host.
7086 ///
7087 /// Wire method: `session.mcp.isServerRunning`.
7088 ///
7089 /// # Parameters
7090 ///
7091 /// * `params` - Server name to check running status for.
7092 ///
7093 /// # Returns
7094 ///
7095 /// Whether the named MCP server is running.
7096 ///
7097 /// <div class="warning">
7098 ///
7099 /// **Experimental.** This API is part of an experimental wire-protocol surface
7100 /// and may change or be removed in future SDK or CLI releases. Pin both the
7101 /// SDK and CLI versions if your code depends on it.
7102 ///
7103 /// </div>
7104 pub async fn is_server_running(
7105 &self,
7106 params: McpIsServerRunningRequest,
7107 ) -> Result<McpIsServerRunningResult, Error> {
7108 let mut wire_params = serde_json::to_value(params)?;
7109 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7110 let _value = self
7111 .session
7112 .client()
7113 .call(rpc_methods::SESSION_MCP_ISSERVERRUNNING, Some(wire_params))
7114 .await?;
7115 Ok(serde_json::from_value(_value)?)
7116 }
7117}
7118
7119/// `session.mcp.apps.*` RPCs.
7120#[derive(Clone, Copy)]
7121pub struct SessionRpcMcpApps<'a> {
7122 pub(crate) session: &'a Session,
7123}
7124
7125impl<'a> SessionRpcMcpApps<'a> {
7126 /// Fetch an MCP resource (typically a `ui://` MCP App bundle, per SEP-1865) from a connected server. Requires the `mcp-apps` session capability.
7127 ///
7128 /// Wire method: `session.mcp.apps.readResource`.
7129 ///
7130 /// # Parameters
7131 ///
7132 /// * `params` - MCP server and resource URI to fetch.
7133 ///
7134 /// # Returns
7135 ///
7136 /// Resource contents returned by the MCP server.
7137 ///
7138 /// <div class="warning">
7139 ///
7140 /// **Experimental.** This API is part of an experimental wire-protocol surface
7141 /// and may change or be removed in future SDK or CLI releases. Pin both the
7142 /// SDK and CLI versions if your code depends on it.
7143 ///
7144 /// </div>
7145 pub async fn read_resource(
7146 &self,
7147 params: McpAppsReadResourceRequest,
7148 ) -> Result<McpAppsReadResourceResult, Error> {
7149 let mut wire_params = serde_json::to_value(params)?;
7150 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7151 let _value = self
7152 .session
7153 .client()
7154 .call(
7155 rpc_methods::SESSION_MCP_APPS_READRESOURCE,
7156 Some(wire_params),
7157 )
7158 .await?;
7159 Ok(serde_json::from_value(_value)?)
7160 }
7161
7162 /// 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"`.
7163 ///
7164 /// Wire method: `session.mcp.apps.listTools`.
7165 ///
7166 /// # Parameters
7167 ///
7168 /// * `params` - MCP server to list app-callable tools for.
7169 ///
7170 /// # Returns
7171 ///
7172 /// App-callable tools from the named MCP server.
7173 ///
7174 /// <div class="warning">
7175 ///
7176 /// **Experimental.** This API is part of an experimental wire-protocol surface
7177 /// and may change or be removed in future SDK or CLI releases. Pin both the
7178 /// SDK and CLI versions if your code depends on it.
7179 ///
7180 /// </div>
7181 pub async fn list_tools(
7182 &self,
7183 params: McpAppsListToolsRequest,
7184 ) -> Result<McpAppsListToolsResult, Error> {
7185 let mut wire_params = serde_json::to_value(params)?;
7186 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7187 let _value = self
7188 .session
7189 .client()
7190 .call(rpc_methods::SESSION_MCP_APPS_LISTTOOLS, Some(wire_params))
7191 .await?;
7192 Ok(serde_json::from_value(_value)?)
7193 }
7194
7195 /// 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`.
7196 ///
7197 /// Wire method: `session.mcp.apps.callTool`.
7198 ///
7199 /// # Parameters
7200 ///
7201 /// * `params` - MCP server, tool name, and arguments to invoke from an MCP App view.
7202 ///
7203 /// # Returns
7204 ///
7205 /// Standard MCP CallToolResult
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 call_tool(
7215 &self,
7216 params: McpAppsCallToolRequest,
7217 ) -> Result<SessionMcpAppsCallToolResult, Error> {
7218 let mut wire_params = serde_json::to_value(params)?;
7219 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7220 let _value = self
7221 .session
7222 .client()
7223 .call(rpc_methods::SESSION_MCP_APPS_CALLTOOL, Some(wire_params))
7224 .await?;
7225 Ok(serde_json::from_value(_value)?)
7226 }
7227
7228 /// 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.
7229 ///
7230 /// Wire method: `session.mcp.apps.setHostContext`.
7231 ///
7232 /// # Parameters
7233 ///
7234 /// * `params` - Host context to advertise to MCP App guests.
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 set_host_context(
7244 &self,
7245 params: McpAppsSetHostContextRequest,
7246 ) -> Result<(), 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(
7253 rpc_methods::SESSION_MCP_APPS_SETHOSTCONTEXT,
7254 Some(wire_params),
7255 )
7256 .await?;
7257 Ok(())
7258 }
7259
7260 /// Read the current host context advertised to MCP App guests.
7261 ///
7262 /// Wire method: `session.mcp.apps.getHostContext`.
7263 ///
7264 /// # Returns
7265 ///
7266 /// Current host context advertised to MCP App guests.
7267 ///
7268 /// <div class="warning">
7269 ///
7270 /// **Experimental.** This API is part of an experimental wire-protocol surface
7271 /// and may change or be removed in future SDK or CLI releases. Pin both the
7272 /// SDK and CLI versions if your code depends on it.
7273 ///
7274 /// </div>
7275 pub async fn get_host_context(&self) -> Result<McpAppsHostContext, Error> {
7276 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7277 let _value = self
7278 .session
7279 .client()
7280 .call(
7281 rpc_methods::SESSION_MCP_APPS_GETHOSTCONTEXT,
7282 Some(wire_params),
7283 )
7284 .await?;
7285 Ok(serde_json::from_value(_value)?)
7286 }
7287
7288 /// 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.
7289 ///
7290 /// Wire method: `session.mcp.apps.diagnose`.
7291 ///
7292 /// # Parameters
7293 ///
7294 /// * `params` - MCP server to diagnose MCP Apps wiring for.
7295 ///
7296 /// # Returns
7297 ///
7298 /// Diagnostic snapshot of MCP Apps wiring for the named server.
7299 ///
7300 /// <div class="warning">
7301 ///
7302 /// **Experimental.** This API is part of an experimental wire-protocol surface
7303 /// and may change or be removed in future SDK or CLI releases. Pin both the
7304 /// SDK and CLI versions if your code depends on it.
7305 ///
7306 /// </div>
7307 pub async fn diagnose(
7308 &self,
7309 params: McpAppsDiagnoseRequest,
7310 ) -> Result<McpAppsDiagnoseResult, Error> {
7311 let mut wire_params = serde_json::to_value(params)?;
7312 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7313 let _value = self
7314 .session
7315 .client()
7316 .call(rpc_methods::SESSION_MCP_APPS_DIAGNOSE, Some(wire_params))
7317 .await?;
7318 Ok(serde_json::from_value(_value)?)
7319 }
7320}
7321
7322/// `session.mcp.headers.*` RPCs.
7323#[derive(Clone, Copy)]
7324pub struct SessionRpcMcpHeaders<'a> {
7325 pub(crate) session: &'a Session,
7326}
7327
7328impl<'a> SessionRpcMcpHeaders<'a> {
7329 /// 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.
7330 ///
7331 /// Wire method: `session.mcp.headers.handlePendingHeadersRefreshRequest`.
7332 ///
7333 /// # Parameters
7334 ///
7335 /// * `params` - MCP headers refresh request id and the host response.
7336 ///
7337 /// # Returns
7338 ///
7339 /// Indicates whether the pending MCP headers refresh response was accepted.
7340 ///
7341 /// <div class="warning">
7342 ///
7343 /// **Experimental.** This API is part of an experimental wire-protocol surface
7344 /// and may change or be removed in future SDK or CLI releases. Pin both the
7345 /// SDK and CLI versions if your code depends on it.
7346 ///
7347 /// </div>
7348 pub async fn handle_pending_headers_refresh_request(
7349 &self,
7350 params: McpHeadersHandlePendingHeadersRefreshRequestRequest,
7351 ) -> Result<McpHeadersHandlePendingHeadersRefreshRequestResult, Error> {
7352 let mut wire_params = serde_json::to_value(params)?;
7353 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7354 let _value = self
7355 .session
7356 .client()
7357 .call(
7358 rpc_methods::SESSION_MCP_HEADERS_HANDLEPENDINGHEADERSREFRESHREQUEST,
7359 Some(wire_params),
7360 )
7361 .await?;
7362 Ok(serde_json::from_value(_value)?)
7363 }
7364}
7365
7366/// `session.mcp.oauth.*` RPCs.
7367#[derive(Clone, Copy)]
7368pub struct SessionRpcMcpOauth<'a> {
7369 pub(crate) session: &'a Session,
7370}
7371
7372impl<'a> SessionRpcMcpOauth<'a> {
7373 /// 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.
7374 ///
7375 /// Wire method: `session.mcp.oauth.handlePendingRequest`.
7376 ///
7377 /// # Parameters
7378 ///
7379 /// * `params` - Pending MCP OAuth request ID and host-provided token or cancellation response.
7380 ///
7381 /// # Returns
7382 ///
7383 /// Indicates whether the pending MCP OAuth response was accepted.
7384 ///
7385 /// <div class="warning">
7386 ///
7387 /// **Experimental.** This API is part of an experimental wire-protocol surface
7388 /// and may change or be removed in future SDK or CLI releases. Pin both the
7389 /// SDK and CLI versions if your code depends on it.
7390 ///
7391 /// </div>
7392 pub async fn handle_pending_request(
7393 &self,
7394 params: McpOauthHandlePendingRequest,
7395 ) -> Result<McpOauthHandlePendingResult, Error> {
7396 let mut wire_params = serde_json::to_value(params)?;
7397 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7398 let _value = self
7399 .session
7400 .client()
7401 .call(
7402 rpc_methods::SESSION_MCP_OAUTH_HANDLEPENDINGREQUEST,
7403 Some(wire_params),
7404 )
7405 .await?;
7406 Ok(serde_json::from_value(_value)?)
7407 }
7408
7409 /// Notifies the session that MCP OAuth authentication succeeded and updated credentials were persisted, so cached tool definitions can be refreshed.
7410 ///
7411 /// Wire method: `session.mcp.oauth.authenticationStateChanged`.
7412 ///
7413 /// # Parameters
7414 ///
7415 /// * `params` - Identifies the MCP server whose persisted OAuth credentials were updated.
7416 ///
7417 /// <div class="warning">
7418 ///
7419 /// **Experimental.** This API is part of an experimental wire-protocol surface
7420 /// and may change or be removed in future SDK or CLI releases. Pin both the
7421 /// SDK and CLI versions if your code depends on it.
7422 ///
7423 /// </div>
7424 pub async fn authentication_state_changed(
7425 &self,
7426 params: McpOauthAuthenticationStateChangedRequest,
7427 ) -> Result<(), Error> {
7428 let mut wire_params = serde_json::to_value(params)?;
7429 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7430 let _value = self
7431 .session
7432 .client()
7433 .call(
7434 rpc_methods::SESSION_MCP_OAUTH_AUTHENTICATIONSTATECHANGED,
7435 Some(wire_params),
7436 )
7437 .await?;
7438 Ok(())
7439 }
7440
7441 /// Starts OAuth authentication for a remote MCP server.
7442 ///
7443 /// Wire method: `session.mcp.oauth.login`.
7444 ///
7445 /// # Parameters
7446 ///
7447 /// * `params` - Remote MCP server name and optional overrides controlling reauthentication, OAuth client display name, callback success-page copy, and static OAuth client selection.
7448 ///
7449 /// # Returns
7450 ///
7451 /// OAuth authorization URL the caller should open, or empty when cached tokens already authenticated the server.
7452 ///
7453 /// <div class="warning">
7454 ///
7455 /// **Experimental.** This API is part of an experimental wire-protocol surface
7456 /// and may change or be removed in future SDK or CLI releases. Pin both the
7457 /// SDK and CLI versions if your code depends on it.
7458 ///
7459 /// </div>
7460 pub async fn login(&self, params: McpOauthLoginRequest) -> Result<McpOauthLoginResult, Error> {
7461 let mut wire_params = serde_json::to_value(params)?;
7462 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7463 let _value = self
7464 .session
7465 .client()
7466 .call(rpc_methods::SESSION_MCP_OAUTH_LOGIN, Some(wire_params))
7467 .await?;
7468 Ok(serde_json::from_value(_value)?)
7469 }
7470
7471 /// 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.
7472 ///
7473 /// Wire method: `session.mcp.oauth.probe`.
7474 ///
7475 /// # Parameters
7476 ///
7477 /// * `params` - Remote MCP server name for a passive OAuth status probe.
7478 ///
7479 /// # Returns
7480 ///
7481 /// 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.
7482 ///
7483 /// <div class="warning">
7484 ///
7485 /// **Experimental.** This API is part of an experimental wire-protocol surface
7486 /// and may change or be removed in future SDK or CLI releases. Pin both the
7487 /// SDK and CLI versions if your code depends on it.
7488 ///
7489 /// </div>
7490 pub async fn probe(&self, params: McpOauthProbeRequest) -> Result<McpOauthProbeResult, Error> {
7491 let mut wire_params = serde_json::to_value(params)?;
7492 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7493 let _value = self
7494 .session
7495 .client()
7496 .call(rpc_methods::SESSION_MCP_OAUTH_PROBE, Some(wire_params))
7497 .await?;
7498 Ok(serde_json::from_value(_value)?)
7499 }
7500
7501 /// Responds to a pending MCP OAuth authorization request by its request id.
7502 ///
7503 /// Wire method: `session.mcp.oauth.respond`.
7504 ///
7505 /// # Parameters
7506 ///
7507 /// * `params` - Pending MCP OAuth request id to respond to.
7508 ///
7509 /// # Returns
7510 ///
7511 /// Indicates whether the pending MCP OAuth response was accepted.
7512 ///
7513 /// <div class="warning">
7514 ///
7515 /// **Experimental.** This API is part of an experimental wire-protocol surface
7516 /// and may change or be removed in future SDK or CLI releases. Pin both the
7517 /// SDK and CLI versions if your code depends on it.
7518 ///
7519 /// </div>
7520 pub async fn respond(
7521 &self,
7522 params: McpOauthRespondRequest,
7523 ) -> Result<McpOauthRespondResult, Error> {
7524 let mut wire_params = serde_json::to_value(params)?;
7525 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7526 let _value = self
7527 .session
7528 .client()
7529 .call(rpc_methods::SESSION_MCP_OAUTH_RESPOND, Some(wire_params))
7530 .await?;
7531 Ok(serde_json::from_value(_value)?)
7532 }
7533}
7534
7535/// `session.mcp.resources.*` RPCs.
7536#[derive(Clone, Copy)]
7537pub struct SessionRpcMcpResources<'a> {
7538 pub(crate) session: &'a Session,
7539}
7540
7541impl<'a> SessionRpcMcpResources<'a> {
7542 /// Fetch an MCP resource from a connected server by URI (proxies MCP `resources/read`).
7543 ///
7544 /// Wire method: `session.mcp.resources.read`.
7545 ///
7546 /// # Parameters
7547 ///
7548 /// * `params` - MCP server and resource URI to fetch.
7549 ///
7550 /// # Returns
7551 ///
7552 /// Resource contents returned by the MCP server.
7553 ///
7554 /// <div class="warning">
7555 ///
7556 /// **Experimental.** This API is part of an experimental wire-protocol surface
7557 /// and may change or be removed in future SDK or CLI releases. Pin both the
7558 /// SDK and CLI versions if your code depends on it.
7559 ///
7560 /// </div>
7561 pub async fn read(
7562 &self,
7563 params: McpResourcesReadRequest,
7564 ) -> Result<McpResourcesReadResult, Error> {
7565 let mut wire_params = serde_json::to_value(params)?;
7566 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7567 let _value = self
7568 .session
7569 .client()
7570 .call(rpc_methods::SESSION_MCP_RESOURCES_READ, Some(wire_params))
7571 .await?;
7572 Ok(serde_json::from_value(_value)?)
7573 }
7574
7575 /// Enumerate one page of resources a connected MCP server exposes (proxies MCP `resources/list`). Pass `cursor` to continue from a prior result's `nextCursor`.
7576 ///
7577 /// Wire method: `session.mcp.resources.list`.
7578 ///
7579 /// # Parameters
7580 ///
7581 /// * `params` - MCP server whose resources to enumerate.
7582 ///
7583 /// # Returns
7584 ///
7585 /// One page of resources advertised by the named MCP server.
7586 ///
7587 /// <div class="warning">
7588 ///
7589 /// **Experimental.** This API is part of an experimental wire-protocol surface
7590 /// and may change or be removed in future SDK or CLI releases. Pin both the
7591 /// SDK and CLI versions if your code depends on it.
7592 ///
7593 /// </div>
7594 pub async fn list(
7595 &self,
7596 params: McpResourcesListRequest,
7597 ) -> Result<McpResourcesListResult, Error> {
7598 let mut wire_params = serde_json::to_value(params)?;
7599 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7600 let _value = self
7601 .session
7602 .client()
7603 .call(rpc_methods::SESSION_MCP_RESOURCES_LIST, Some(wire_params))
7604 .await?;
7605 Ok(serde_json::from_value(_value)?)
7606 }
7607
7608 /// 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`.
7609 ///
7610 /// Wire method: `session.mcp.resources.listTemplates`.
7611 ///
7612 /// # Parameters
7613 ///
7614 /// * `params` - MCP server whose resource templates to enumerate.
7615 ///
7616 /// # Returns
7617 ///
7618 /// One page of resource templates advertised by the named MCP server.
7619 ///
7620 /// <div class="warning">
7621 ///
7622 /// **Experimental.** This API is part of an experimental wire-protocol surface
7623 /// and may change or be removed in future SDK or CLI releases. Pin both the
7624 /// SDK and CLI versions if your code depends on it.
7625 ///
7626 /// </div>
7627 pub async fn list_templates(
7628 &self,
7629 params: McpResourcesListTemplatesRequest,
7630 ) -> Result<McpResourcesListTemplatesResult, Error> {
7631 let mut wire_params = serde_json::to_value(params)?;
7632 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7633 let _value = self
7634 .session
7635 .client()
7636 .call(
7637 rpc_methods::SESSION_MCP_RESOURCES_LISTTEMPLATES,
7638 Some(wire_params),
7639 )
7640 .await?;
7641 Ok(serde_json::from_value(_value)?)
7642 }
7643}
7644
7645/// `session.metadata.*` RPCs.
7646#[derive(Clone, Copy)]
7647pub struct SessionRpcMetadata<'a> {
7648 pub(crate) session: &'a Session,
7649}
7650
7651impl<'a> SessionRpcMetadata<'a> {
7652 /// Returns a snapshot of the session's identifying metadata, mode, agent, and remote info.
7653 ///
7654 /// Wire method: `session.metadata.snapshot`.
7655 ///
7656 /// # Returns
7657 ///
7658 /// Point-in-time snapshot of slow-changing session identifier and state fields
7659 ///
7660 /// <div class="warning">
7661 ///
7662 /// **Experimental.** This API is part of an experimental wire-protocol surface
7663 /// and may change or be removed in future SDK or CLI releases. Pin both the
7664 /// SDK and CLI versions if your code depends on it.
7665 ///
7666 /// </div>
7667 pub async fn snapshot(&self) -> Result<SessionMetadataSnapshot, Error> {
7668 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7669 let _value = self
7670 .session
7671 .client()
7672 .call(rpc_methods::SESSION_METADATA_SNAPSHOT, Some(wire_params))
7673 .await?;
7674 Ok(serde_json::from_value(_value)?)
7675 }
7676
7677 /// Returns the client-owned string metadata persisted with this local session. The metadata is not included in model context, events, telemetry, snapshots, or remote exports.
7678 ///
7679 /// Wire method: `session.metadata.getClientMetadata`.
7680 ///
7681 /// # Returns
7682 ///
7683 /// Client-owned, case-sensitive string metadata persisted with a local session. Clients should namespace keys by owner. Keys must be non-empty and at most 256 UTF-8 bytes; keys under `copilot/` and `github/` are reserved. Values may contain at most 16 KiB of UTF-8 data. A bag may contain at most 128 entries and its serialized sidecar may contain at most 64 KiB. The runtime stores but never interprets these values.
7684 ///
7685 /// <div class="warning">
7686 ///
7687 /// **Experimental.** This API is part of an experimental wire-protocol surface
7688 /// and may change or be removed in future SDK or CLI releases. Pin both the
7689 /// SDK and CLI versions if your code depends on it.
7690 ///
7691 /// </div>
7692 pub async fn get_client_metadata(&self) -> Result<ClientMetadata, Error> {
7693 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7694 let _value = self
7695 .session
7696 .client()
7697 .call(
7698 rpc_methods::SESSION_METADATA_GETCLIENTMETADATA,
7699 Some(wire_params),
7700 )
7701 .await?;
7702 Ok(serde_json::from_value(_value)?)
7703 }
7704
7705 /// Atomically patches the client-owned string metadata persisted with this local session and returns the committed bag.
7706 ///
7707 /// Wire method: `session.metadata.updateClientMetadata`.
7708 ///
7709 /// # Parameters
7710 ///
7711 /// * `params` - Atomic patch for client-owned session metadata. Operations apply in clear, remove, then set order. The resulting bag must satisfy the ClientMetadata entry and serialized-size limits. Local storage coordinates concurrent runtime processes; custom SessionFs providers must serialize writers that access the same session from multiple processes.
7712 ///
7713 /// # Returns
7714 ///
7715 /// Client-owned, case-sensitive string metadata persisted with a local session. Clients should namespace keys by owner. Keys must be non-empty and at most 256 UTF-8 bytes; keys under `copilot/` and `github/` are reserved. Values may contain at most 16 KiB of UTF-8 data. A bag may contain at most 128 entries and its serialized sidecar may contain at most 64 KiB. The runtime stores but never interprets these values.
7716 ///
7717 /// <div class="warning">
7718 ///
7719 /// **Experimental.** This API is part of an experimental wire-protocol surface
7720 /// and may change or be removed in future SDK or CLI releases. Pin both the
7721 /// SDK and CLI versions if your code depends on it.
7722 ///
7723 /// </div>
7724 pub async fn update_client_metadata(
7725 &self,
7726 params: MetadataUpdateClientMetadataRequest,
7727 ) -> Result<ClientMetadata, Error> {
7728 let mut wire_params = serde_json::to_value(params)?;
7729 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7730 let _value = self
7731 .session
7732 .client()
7733 .call(
7734 rpc_methods::SESSION_METADATA_UPDATECLIENTMETADATA,
7735 Some(wire_params),
7736 )
7737 .await?;
7738 Ok(serde_json::from_value(_value)?)
7739 }
7740
7741 /// Reports whether the local session is currently processing user/agent messages.
7742 ///
7743 /// Wire method: `session.metadata.isProcessing`.
7744 ///
7745 /// # Returns
7746 ///
7747 /// Indicates whether the local session is currently processing a turn or background continuation.
7748 ///
7749 /// <div class="warning">
7750 ///
7751 /// **Experimental.** This API is part of an experimental wire-protocol surface
7752 /// and may change or be removed in future SDK or CLI releases. Pin both the
7753 /// SDK and CLI versions if your code depends on it.
7754 ///
7755 /// </div>
7756 pub async fn is_processing(&self) -> Result<MetadataIsProcessingResult, Error> {
7757 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7758 let _value = self
7759 .session
7760 .client()
7761 .call(
7762 rpc_methods::SESSION_METADATA_ISPROCESSING,
7763 Some(wire_params),
7764 )
7765 .await?;
7766 Ok(serde_json::from_value(_value)?)
7767 }
7768
7769 /// Returns a snapshot of activity flags for the session.
7770 ///
7771 /// Wire method: `session.metadata.activity`.
7772 ///
7773 /// # Returns
7774 ///
7775 /// Current activity flags for the session.
7776 ///
7777 /// <div class="warning">
7778 ///
7779 /// **Experimental.** This API is part of an experimental wire-protocol surface
7780 /// and may change or be removed in future SDK or CLI releases. Pin both the
7781 /// SDK and CLI versions if your code depends on it.
7782 ///
7783 /// </div>
7784 pub async fn activity(&self) -> Result<SessionActivity, Error> {
7785 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7786 let _value = self
7787 .session
7788 .client()
7789 .call(rpc_methods::SESSION_METADATA_ACTIVITY, Some(wire_params))
7790 .await?;
7791 Ok(serde_json::from_value(_value)?)
7792 }
7793
7794 /// Returns the token breakdown for the session's current context window for a given model.
7795 ///
7796 /// Wire method: `session.metadata.contextInfo`.
7797 ///
7798 /// # Parameters
7799 ///
7800 /// * `params` - Model identifier and token limits used to compute the context-info breakdown.
7801 ///
7802 /// # Returns
7803 ///
7804 /// Token breakdown for the session's current context window, or null if uninitialized.
7805 ///
7806 /// <div class="warning">
7807 ///
7808 /// **Experimental.** This API is part of an experimental wire-protocol surface
7809 /// and may change or be removed in future SDK or CLI releases. Pin both the
7810 /// SDK and CLI versions if your code depends on it.
7811 ///
7812 /// </div>
7813 pub async fn context_info(
7814 &self,
7815 params: MetadataContextInfoRequest,
7816 ) -> Result<MetadataContextInfoResult, Error> {
7817 let mut wire_params = serde_json::to_value(params)?;
7818 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7819 let _value = self
7820 .session
7821 .client()
7822 .call(rpc_methods::SESSION_METADATA_CONTEXTINFO, Some(wire_params))
7823 .await?;
7824 Ok(serde_json::from_value(_value)?)
7825 }
7826
7827 /// 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.
7828 ///
7829 /// Wire method: `session.metadata.getContextAttribution`.
7830 ///
7831 /// # Returns
7832 ///
7833 /// Per-source attribution breakdown for the session's current context window, or null if uninitialized.
7834 ///
7835 /// <div class="warning">
7836 ///
7837 /// **Experimental.** This API is part of an experimental wire-protocol surface
7838 /// and may change or be removed in future SDK or CLI releases. Pin both the
7839 /// SDK and CLI versions if your code depends on it.
7840 ///
7841 /// </div>
7842 pub async fn get_context_attribution(&self) -> Result<MetadataContextAttributionResult, Error> {
7843 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7844 let _value = self
7845 .session
7846 .client()
7847 .call(
7848 rpc_methods::SESSION_METADATA_GETCONTEXTATTRIBUTION,
7849 Some(wire_params),
7850 )
7851 .await?;
7852 Ok(serde_json::from_value(_value)?)
7853 }
7854
7855 /// 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.
7856 ///
7857 /// Wire method: `session.metadata.getContextHeaviestMessages`.
7858 ///
7859 /// # Parameters
7860 ///
7861 /// * `params` - Parameters for the heaviest-messages query.
7862 ///
7863 /// # Returns
7864 ///
7865 /// The heaviest individual messages in the session's context window, most-expensive first.
7866 ///
7867 /// <div class="warning">
7868 ///
7869 /// **Experimental.** This API is part of an experimental wire-protocol surface
7870 /// and may change or be removed in future SDK or CLI releases. Pin both the
7871 /// SDK and CLI versions if your code depends on it.
7872 ///
7873 /// </div>
7874 pub async fn get_context_heaviest_messages(
7875 &self,
7876 params: MetadataContextHeaviestMessagesRequest,
7877 ) -> Result<MetadataContextHeaviestMessagesResult, Error> {
7878 let mut wire_params = serde_json::to_value(params)?;
7879 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7880 let _value = self
7881 .session
7882 .client()
7883 .call(
7884 rpc_methods::SESSION_METADATA_GETCONTEXTHEAVIESTMESSAGES,
7885 Some(wire_params),
7886 )
7887 .await?;
7888 Ok(serde_json::from_value(_value)?)
7889 }
7890
7891 /// 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.
7892 ///
7893 /// Wire method: `session.metadata.recordContextChange`.
7894 ///
7895 /// # Parameters
7896 ///
7897 /// * `params` - Updated working-directory/git context to record on the session.
7898 ///
7899 /// # Returns
7900 ///
7901 /// 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.
7902 ///
7903 /// <div class="warning">
7904 ///
7905 /// **Experimental.** This API is part of an experimental wire-protocol surface
7906 /// and may change or be removed in future SDK or CLI releases. Pin both the
7907 /// SDK and CLI versions if your code depends on it.
7908 ///
7909 /// </div>
7910 pub async fn record_context_change(
7911 &self,
7912 params: MetadataRecordContextChangeRequest,
7913 ) -> Result<MetadataRecordContextChangeResult, Error> {
7914 let mut wire_params = serde_json::to_value(params)?;
7915 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7916 let _value = self
7917 .session
7918 .client()
7919 .call(
7920 rpc_methods::SESSION_METADATA_RECORDCONTEXTCHANGE,
7921 Some(wire_params),
7922 )
7923 .await?;
7924 Ok(serde_json::from_value(_value)?)
7925 }
7926
7927 /// 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.
7928 ///
7929 /// Wire method: `session.metadata.setWorkingDirectory`.
7930 ///
7931 /// # Parameters
7932 ///
7933 /// * `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.
7934 ///
7935 /// # Returns
7936 ///
7937 /// 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.
7938 ///
7939 /// <div class="warning">
7940 ///
7941 /// **Experimental.** This API is part of an experimental wire-protocol surface
7942 /// and may change or be removed in future SDK or CLI releases. Pin both the
7943 /// SDK and CLI versions if your code depends on it.
7944 ///
7945 /// </div>
7946 pub async fn set_working_directory(
7947 &self,
7948 params: MetadataSetWorkingDirectoryRequest,
7949 ) -> Result<MetadataSetWorkingDirectoryResult, Error> {
7950 let mut wire_params = serde_json::to_value(params)?;
7951 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7952 let _value = self
7953 .session
7954 .client()
7955 .call(
7956 rpc_methods::SESSION_METADATA_SETWORKINGDIRECTORY,
7957 Some(wire_params),
7958 )
7959 .await?;
7960 Ok(serde_json::from_value(_value)?)
7961 }
7962
7963 /// Re-tokenizes the session's existing messages against a model and returns aggregate token totals.
7964 ///
7965 /// Wire method: `session.metadata.recomputeContextTokens`.
7966 ///
7967 /// # Parameters
7968 ///
7969 /// * `params` - Model identifier to use when re-tokenizing the session's existing messages.
7970 ///
7971 /// # Returns
7972 ///
7973 /// 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.
7974 ///
7975 /// <div class="warning">
7976 ///
7977 /// **Experimental.** This API is part of an experimental wire-protocol surface
7978 /// and may change or be removed in future SDK or CLI releases. Pin both the
7979 /// SDK and CLI versions if your code depends on it.
7980 ///
7981 /// </div>
7982 pub async fn recompute_context_tokens(
7983 &self,
7984 params: MetadataRecomputeContextTokensRequest,
7985 ) -> Result<MetadataRecomputeContextTokensResult, Error> {
7986 let mut wire_params = serde_json::to_value(params)?;
7987 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7988 let _value = self
7989 .session
7990 .client()
7991 .call(
7992 rpc_methods::SESSION_METADATA_RECOMPUTECONTEXTTOKENS,
7993 Some(wire_params),
7994 )
7995 .await?;
7996 Ok(serde_json::from_value(_value)?)
7997 }
7998}
7999
8000/// `session.mode.*` RPCs.
8001#[derive(Clone, Copy)]
8002pub struct SessionRpcMode<'a> {
8003 pub(crate) session: &'a Session,
8004}
8005
8006impl<'a> SessionRpcMode<'a> {
8007 /// Gets the current agent interaction mode.
8008 ///
8009 /// Wire method: `session.mode.get`.
8010 ///
8011 /// # Returns
8012 ///
8013 /// The session mode the agent is operating in
8014 ///
8015 /// <div class="warning">
8016 ///
8017 /// **Experimental.** This API is part of an experimental wire-protocol surface
8018 /// and may change or be removed in future SDK or CLI releases. Pin both the
8019 /// SDK and CLI versions if your code depends on it.
8020 ///
8021 /// </div>
8022 pub async fn get(&self) -> Result<SessionMode, Error> {
8023 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8024 let _value = self
8025 .session
8026 .client()
8027 .call(rpc_methods::SESSION_MODE_GET, Some(wire_params))
8028 .await?;
8029 Ok(serde_json::from_value(_value)?)
8030 }
8031
8032 /// Sets the current agent interaction mode.
8033 ///
8034 /// Wire method: `session.mode.set`.
8035 ///
8036 /// # Parameters
8037 ///
8038 /// * `params` - Agent interaction mode to apply to the session.
8039 ///
8040 /// # Returns
8041 ///
8042 /// Outcome of a session mode change, including any model switch it triggered and follow-up the host must perform.
8043 ///
8044 /// <div class="warning">
8045 ///
8046 /// **Experimental.** This API is part of an experimental wire-protocol surface
8047 /// and may change or be removed in future SDK or CLI releases. Pin both the
8048 /// SDK and CLI versions if your code depends on it.
8049 ///
8050 /// </div>
8051 pub async fn set(&self, params: ModeSetRequest) -> Result<ModeSetResult, Error> {
8052 let mut wire_params = serde_json::to_value(params)?;
8053 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8054 let _value = self
8055 .session
8056 .client()
8057 .call(rpc_methods::SESSION_MODE_SET, Some(wire_params))
8058 .await?;
8059 Ok(serde_json::from_value(_value)?)
8060 }
8061}
8062
8063/// `session.model.*` RPCs.
8064#[derive(Clone, Copy)]
8065pub struct SessionRpcModel<'a> {
8066 pub(crate) session: &'a Session,
8067}
8068
8069impl<'a> SessionRpcModel<'a> {
8070 /// Gets the session's authoritative model snapshot, including the committed Auto preference and any newer unclaimed Auto preference waiting for a future user turn.
8071 ///
8072 /// Wire method: `session.model.getCurrent`.
8073 ///
8074 /// # Returns
8075 ///
8076 /// 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.
8077 ///
8078 /// <div class="warning">
8079 ///
8080 /// **Experimental.** This API is part of an experimental wire-protocol surface
8081 /// and may change or be removed in future SDK or CLI releases. Pin both the
8082 /// SDK and CLI versions if your code depends on it.
8083 ///
8084 /// </div>
8085 pub async fn get_current(&self) -> Result<CurrentModel, Error> {
8086 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8087 let _value = self
8088 .session
8089 .client()
8090 .call(rpc_methods::SESSION_MODEL_GETCURRENT, Some(wire_params))
8091 .await?;
8092 Ok(serde_json::from_value(_value)?)
8093 }
8094
8095 /// Switches the session to a model and optional reasoning configuration.
8096 ///
8097 /// Wire method: `session.model.switchTo`.
8098 ///
8099 /// # Parameters
8100 ///
8101 /// * `params` - Target model identifier and optional reasoning effort, summary, capability overrides, and context tier.
8102 ///
8103 /// # Returns
8104 ///
8105 /// The model identifier active on the session after the switch.
8106 ///
8107 /// <div class="warning">
8108 ///
8109 /// **Experimental.** This API is part of an experimental wire-protocol surface
8110 /// and may change or be removed in future SDK or CLI releases. Pin both the
8111 /// SDK and CLI versions if your code depends on it.
8112 ///
8113 /// </div>
8114 pub async fn switch_to(
8115 &self,
8116 params: ModelSwitchToRequest,
8117 ) -> Result<ModelSwitchToResult, Error> {
8118 let mut wire_params = serde_json::to_value(params)?;
8119 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8120 let _value = self
8121 .session
8122 .client()
8123 .call(rpc_methods::SESSION_MODEL_SWITCHTO, Some(wire_params))
8124 .await?;
8125 Ok(serde_json::from_value(_value)?)
8126 }
8127
8128 /// 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`.
8129 ///
8130 /// Wire method: `session.model.switchAutoTier`.
8131 ///
8132 /// # Parameters
8133 ///
8134 /// * `params` - An Auto preference request for the session. This updates Auto configuration only; it does not change the selected model to `auto`.
8135 ///
8136 /// # Returns
8137 ///
8138 /// Immediate acknowledgement and Auto preference snapshot after a switch request. This result never implies that a pending preference committed.
8139 ///
8140 /// <div class="warning">
8141 ///
8142 /// **Experimental.** This API is part of an experimental wire-protocol surface
8143 /// and may change or be removed in future SDK or CLI releases. Pin both the
8144 /// SDK and CLI versions if your code depends on it.
8145 ///
8146 /// </div>
8147 pub async fn switch_auto_tier(
8148 &self,
8149 params: ModelSwitchAutoTierRequest,
8150 ) -> Result<ModelSwitchAutoTierResult, Error> {
8151 let mut wire_params = serde_json::to_value(params)?;
8152 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8153 let _value = self
8154 .session
8155 .client()
8156 .call(rpc_methods::SESSION_MODEL_SWITCHAUTOTIER, Some(wire_params))
8157 .await?;
8158 Ok(serde_json::from_value(_value)?)
8159 }
8160
8161 /// Resolves and applies organization-managed and repository model overlays.
8162 ///
8163 /// Wire method: `session.model.applyStartupOverlay`.
8164 ///
8165 /// # Parameters
8166 ///
8167 /// * `params` - Managed, repository, and CLI model overrides to overlay onto the session at startup.
8168 ///
8169 /// # Returns
8170 ///
8171 /// The model identifier active on the session after the switch.
8172 ///
8173 /// <div class="warning">
8174 ///
8175 /// **Experimental.** This API is part of an experimental wire-protocol surface
8176 /// and may change or be removed in future SDK or CLI releases. Pin both the
8177 /// SDK and CLI versions if your code depends on it.
8178 ///
8179 /// </div>
8180 pub(crate) async fn apply_startup_overlay(
8181 &self,
8182 params: ModelApplyStartupOverlayRequest,
8183 ) -> Result<ModelSwitchToResult, Error> {
8184 let mut wire_params = serde_json::to_value(params)?;
8185 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8186 let _value = self
8187 .session
8188 .client()
8189 .call(
8190 rpc_methods::SESSION_MODEL_APPLYSTARTUPOVERLAY,
8191 Some(wire_params),
8192 )
8193 .await?;
8194 Ok(serde_json::from_value(_value)?)
8195 }
8196
8197 /// Replaces or clears the host-supplied model allowlist for a running session.
8198 ///
8199 /// Wire method: `session.model.setAllowedModels`.
8200 ///
8201 /// # Parameters
8202 ///
8203 /// * `params` - Host-supplied exact model selection IDs to allow for this running session. CAPI IDs are intersected with repository `.github/allowed_models.txt` policy; provider-qualified IDs remain exempt from repository-only policy but are restricted by this host list. Omit or pass null to clear the host restriction; an explicit empty or disjoint list is rejected. Validation and pre-selection fallback failures preserve the previous restriction. Failures after a fallback selection commits retain the new restriction and selected model; callers should inspect current session state after such an error.
8204 ///
8205 /// # Returns
8206 ///
8207 /// The applied host allowlist and effective session model policy after intersection.
8208 ///
8209 /// <div class="warning">
8210 ///
8211 /// **Experimental.** This API is part of an experimental wire-protocol surface
8212 /// and may change or be removed in future SDK or CLI releases. Pin both the
8213 /// SDK and CLI versions if your code depends on it.
8214 ///
8215 /// </div>
8216 pub async fn set_allowed_models(
8217 &self,
8218 params: ModelSetAllowedModelsRequest,
8219 ) -> Result<ModelSetAllowedModelsResult, Error> {
8220 let mut wire_params = serde_json::to_value(params)?;
8221 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8222 let _value = self
8223 .session
8224 .client()
8225 .call(
8226 rpc_methods::SESSION_MODEL_SETALLOWEDMODELS,
8227 Some(wire_params),
8228 )
8229 .await?;
8230 Ok(serde_json::from_value(_value)?)
8231 }
8232
8233 /// Updates the session's reasoning effort without changing the selected model.
8234 ///
8235 /// Wire method: `session.model.setReasoningEffort`.
8236 ///
8237 /// # Parameters
8238 ///
8239 /// * `params` - Reasoning effort level to apply to the currently selected model.
8240 ///
8241 /// # Returns
8242 ///
8243 /// 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.
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 set_reasoning_effort(
8253 &self,
8254 params: ModelSetReasoningEffortRequest,
8255 ) -> Result<ModelSetReasoningEffortResult, 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_MODEL_SETREASONINGEFFORT,
8263 Some(wire_params),
8264 )
8265 .await?;
8266 Ok(serde_json::from_value(_value)?)
8267 }
8268
8269 /// 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.
8270 ///
8271 /// Wire method: `session.model.list`.
8272 ///
8273 /// # Returns
8274 ///
8275 /// The list of models available to this session.
8276 ///
8277 /// <div class="warning">
8278 ///
8279 /// **Experimental.** This API is part of an experimental wire-protocol surface
8280 /// and may change or be removed in future SDK or CLI releases. Pin both the
8281 /// SDK and CLI versions if your code depends on it.
8282 ///
8283 /// </div>
8284 pub async fn list(&self) -> Result<SessionModelList, Error> {
8285 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8286 let _value = self
8287 .session
8288 .client()
8289 .call(rpc_methods::SESSION_MODEL_LIST, Some(wire_params))
8290 .await?;
8291 Ok(serde_json::from_value(_value)?)
8292 }
8293
8294 /// 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.
8295 ///
8296 /// Wire method: `session.model.list`.
8297 ///
8298 /// # Parameters
8299 ///
8300 /// * `params` - Optional listing options.
8301 ///
8302 /// # Returns
8303 ///
8304 /// The list of models available to this session.
8305 ///
8306 /// <div class="warning">
8307 ///
8308 /// **Experimental.** This API is part of an experimental wire-protocol surface
8309 /// and may change or be removed in future SDK or CLI releases. Pin both the
8310 /// SDK and CLI versions if your code depends on it.
8311 ///
8312 /// </div>
8313 pub async fn list_with_params(
8314 &self,
8315 params: ModelListRequest,
8316 ) -> Result<SessionModelList, Error> {
8317 let mut wire_params = serde_json::to_value(params)?;
8318 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8319 let _value = self
8320 .session
8321 .client()
8322 .call(rpc_methods::SESSION_MODEL_LIST, Some(wire_params))
8323 .await?;
8324 Ok(serde_json::from_value(_value)?)
8325 }
8326}
8327
8328/// `session.name.*` RPCs.
8329#[derive(Clone, Copy)]
8330pub struct SessionRpcName<'a> {
8331 pub(crate) session: &'a Session,
8332}
8333
8334impl<'a> SessionRpcName<'a> {
8335 /// Gets the session's friendly name.
8336 ///
8337 /// Wire method: `session.name.get`.
8338 ///
8339 /// # Returns
8340 ///
8341 /// The session's friendly name, or null when not yet set.
8342 ///
8343 /// <div class="warning">
8344 ///
8345 /// **Experimental.** This API is part of an experimental wire-protocol surface
8346 /// and may change or be removed in future SDK or CLI releases. Pin both the
8347 /// SDK and CLI versions if your code depends on it.
8348 ///
8349 /// </div>
8350 pub async fn get(&self) -> Result<NameGetResult, Error> {
8351 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8352 let _value = self
8353 .session
8354 .client()
8355 .call(rpc_methods::SESSION_NAME_GET, Some(wire_params))
8356 .await?;
8357 Ok(serde_json::from_value(_value)?)
8358 }
8359
8360 /// Sets the session's friendly name.
8361 ///
8362 /// Wire method: `session.name.set`.
8363 ///
8364 /// # Parameters
8365 ///
8366 /// * `params` - New friendly name to apply to the session.
8367 ///
8368 /// <div class="warning">
8369 ///
8370 /// **Experimental.** This API is part of an experimental wire-protocol surface
8371 /// and may change or be removed in future SDK or CLI releases. Pin both the
8372 /// SDK and CLI versions if your code depends on it.
8373 ///
8374 /// </div>
8375 pub async fn set(&self, params: NameSetRequest) -> Result<(), Error> {
8376 let mut wire_params = serde_json::to_value(params)?;
8377 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8378 let _value = self
8379 .session
8380 .client()
8381 .call(rpc_methods::SESSION_NAME_SET, Some(wire_params))
8382 .await?;
8383 Ok(())
8384 }
8385
8386 /// Persists an auto-generated session summary as the session's name when no user-set name exists.
8387 ///
8388 /// Wire method: `session.name.setAuto`.
8389 ///
8390 /// # Parameters
8391 ///
8392 /// * `params` - Auto-generated session summary to apply as the session's name when no user-set name exists.
8393 ///
8394 /// # Returns
8395 ///
8396 /// Indicates whether the auto-generated summary was applied as the session's name.
8397 ///
8398 /// <div class="warning">
8399 ///
8400 /// **Experimental.** This API is part of an experimental wire-protocol surface
8401 /// and may change or be removed in future SDK or CLI releases. Pin both the
8402 /// SDK and CLI versions if your code depends on it.
8403 ///
8404 /// </div>
8405 pub async fn set_auto(&self, params: NameSetAutoRequest) -> Result<NameSetAutoResult, Error> {
8406 let mut wire_params = serde_json::to_value(params)?;
8407 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8408 let _value = self
8409 .session
8410 .client()
8411 .call(rpc_methods::SESSION_NAME_SETAUTO, Some(wire_params))
8412 .await?;
8413 Ok(serde_json::from_value(_value)?)
8414 }
8415}
8416
8417/// `session.options.*` RPCs.
8418#[derive(Clone, Copy)]
8419pub struct SessionRpcOptions<'a> {
8420 pub(crate) session: &'a Session,
8421}
8422
8423impl<'a> SessionRpcOptions<'a> {
8424 /// Patches the genuinely-mutable subset of session options.
8425 ///
8426 /// Wire method: `session.options.update`.
8427 ///
8428 /// # Parameters
8429 ///
8430 /// * `params` - Patch of mutable session options to apply to the running session.
8431 ///
8432 /// # Returns
8433 ///
8434 /// Indicates whether the session options patch was applied successfully.
8435 ///
8436 /// <div class="warning">
8437 ///
8438 /// **Experimental.** This API is part of an experimental wire-protocol surface
8439 /// and may change or be removed in future SDK or CLI releases. Pin both the
8440 /// SDK and CLI versions if your code depends on it.
8441 ///
8442 /// </div>
8443 pub async fn update(
8444 &self,
8445 params: SessionUpdateOptionsParams,
8446 ) -> Result<SessionUpdateOptionsResult, Error> {
8447 let mut wire_params = serde_json::to_value(params)?;
8448 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8449 let _value = self
8450 .session
8451 .client()
8452 .call(rpc_methods::SESSION_OPTIONS_UPDATE, Some(wire_params))
8453 .await?;
8454 Ok(serde_json::from_value(_value)?)
8455 }
8456}
8457
8458/// `session.permissions.*` RPCs.
8459#[derive(Clone, Copy)]
8460pub struct SessionRpcPermissions<'a> {
8461 pub(crate) session: &'a Session,
8462}
8463
8464impl<'a> SessionRpcPermissions<'a> {
8465 /// `session.permissions.folderTrust.*` sub-namespace.
8466 pub fn folder_trust(&self) -> SessionRpcPermissionsFolderTrust<'a> {
8467 SessionRpcPermissionsFolderTrust {
8468 session: self.session,
8469 }
8470 }
8471
8472 /// `session.permissions.locations.*` sub-namespace.
8473 pub fn locations(&self) -> SessionRpcPermissionsLocations<'a> {
8474 SessionRpcPermissionsLocations {
8475 session: self.session,
8476 }
8477 }
8478
8479 /// `session.permissions.paths.*` sub-namespace.
8480 pub fn paths(&self) -> SessionRpcPermissionsPaths<'a> {
8481 SessionRpcPermissionsPaths {
8482 session: self.session,
8483 }
8484 }
8485
8486 /// `session.permissions.urls.*` sub-namespace.
8487 pub fn urls(&self) -> SessionRpcPermissionsUrls<'a> {
8488 SessionRpcPermissionsUrls {
8489 session: self.session,
8490 }
8491 }
8492
8493 /// Replaces selected permission policy fields (rules, paths, URLs, exclusions, allow-all flags) on the session.
8494 ///
8495 /// Wire method: `session.permissions.configure`.
8496 ///
8497 /// # Parameters
8498 ///
8499 /// * `params` - Patch of permission policy fields to apply (omit a field to leave it unchanged).
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 configure(
8513 &self,
8514 params: PermissionsConfigureParams,
8515 ) -> Result<PermissionsConfigureResult, 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_CONFIGURE,
8523 Some(wire_params),
8524 )
8525 .await?;
8526 Ok(serde_json::from_value(_value)?)
8527 }
8528
8529 /// Provides a decision for a pending tool permission request.
8530 ///
8531 /// Wire method: `session.permissions.handlePendingPermissionRequest`.
8532 ///
8533 /// # Parameters
8534 ///
8535 /// * `params` - Pending permission request ID and the decision to apply (approve/reject and scope).
8536 ///
8537 /// # Returns
8538 ///
8539 /// Indicates whether the permission decision was applied; false when the request was already resolved.
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 handle_pending_permission_request(
8549 &self,
8550 params: PermissionDecisionRequest,
8551 ) -> Result<PermissionRequestResult, 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_HANDLEPENDINGPERMISSIONREQUEST,
8559 Some(wire_params),
8560 )
8561 .await?;
8562 Ok(serde_json::from_value(_value)?)
8563 }
8564
8565 /// Reconstructs the set of pending tool permission requests from the session's event history.
8566 ///
8567 /// Wire method: `session.permissions.pendingRequests`.
8568 ///
8569 /// # Returns
8570 ///
8571 /// List of pending permission requests reconstructed from event history.
8572 ///
8573 /// <div class="warning">
8574 ///
8575 /// **Experimental.** This API is part of an experimental wire-protocol surface
8576 /// and may change or be removed in future SDK or CLI releases. Pin both the
8577 /// SDK and CLI versions if your code depends on it.
8578 ///
8579 /// </div>
8580 pub async fn pending_requests(&self) -> Result<PendingPermissionRequestList, Error> {
8581 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8582 let _value = self
8583 .session
8584 .client()
8585 .call(
8586 rpc_methods::SESSION_PERMISSIONS_PENDINGREQUESTS,
8587 Some(wire_params),
8588 )
8589 .await?;
8590 Ok(serde_json::from_value(_value)?)
8591 }
8592
8593 /// Enables or disables automatic approval of tool permission requests for the session.
8594 ///
8595 /// Wire method: `session.permissions.setApproveAll`.
8596 ///
8597 /// # Parameters
8598 ///
8599 /// * `params` - Allow-all toggle for tool permission requests, with an optional telemetry source.
8600 ///
8601 /// # Returns
8602 ///
8603 /// Indicates whether the operation succeeded.
8604 ///
8605 /// <div class="warning">
8606 ///
8607 /// **Experimental.** This API is part of an experimental wire-protocol surface
8608 /// and may change or be removed in future SDK or CLI releases. Pin both the
8609 /// SDK and CLI versions if your code depends on it.
8610 ///
8611 /// </div>
8612 pub async fn set_approve_all(
8613 &self,
8614 params: PermissionsSetApproveAllRequest,
8615 ) -> Result<PermissionsSetApproveAllResult, Error> {
8616 let mut wire_params = serde_json::to_value(params)?;
8617 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8618 let _value = self
8619 .session
8620 .client()
8621 .call(
8622 rpc_methods::SESSION_PERMISSIONS_SETAPPROVEALL,
8623 Some(wire_params),
8624 )
8625 .await?;
8626 Ok(serde_json::from_value(_value)?)
8627 }
8628
8629 /// 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.
8630 ///
8631 /// Wire method: `session.permissions.setMode`.
8632 ///
8633 /// # Parameters
8634 ///
8635 /// * `params` - Permission mode to apply for the session.
8636 ///
8637 /// # Returns
8638 ///
8639 /// Indicates whether the requested permission mode was applied and reports the authoritative post-mutation mode.
8640 ///
8641 /// <div class="warning">
8642 ///
8643 /// **Experimental.** This API is part of an experimental wire-protocol surface
8644 /// and may change or be removed in future SDK or CLI releases. Pin both the
8645 /// SDK and CLI versions if your code depends on it.
8646 ///
8647 /// </div>
8648 pub async fn set_mode(
8649 &self,
8650 params: PermissionsSetModeRequest,
8651 ) -> Result<PermissionsSetModeResult, Error> {
8652 let mut wire_params = serde_json::to_value(params)?;
8653 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8654 let _value = self
8655 .session
8656 .client()
8657 .call(rpc_methods::SESSION_PERMISSIONS_SETMODE, Some(wire_params))
8658 .await?;
8659 Ok(serde_json::from_value(_value)?)
8660 }
8661
8662 /// Returns the current permission mode for the session.
8663 ///
8664 /// Wire method: `session.permissions.getMode`.
8665 ///
8666 /// # Returns
8667 ///
8668 /// Current permission mode.
8669 ///
8670 /// <div class="warning">
8671 ///
8672 /// **Experimental.** This API is part of an experimental wire-protocol surface
8673 /// and may change or be removed in future SDK or CLI releases. Pin both the
8674 /// SDK and CLI versions if your code depends on it.
8675 ///
8676 /// </div>
8677 pub async fn get_mode(&self) -> Result<PermissionsGetModeResult, Error> {
8678 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8679 let _value = self
8680 .session
8681 .client()
8682 .call(rpc_methods::SESSION_PERMISSIONS_GETMODE, Some(wire_params))
8683 .await?;
8684 Ok(serde_json::from_value(_value)?)
8685 }
8686
8687 /// Adds or removes session-scoped or location-scoped permission rules.
8688 ///
8689 /// Wire method: `session.permissions.modifyRules`.
8690 ///
8691 /// # Parameters
8692 ///
8693 /// * `params` - Scope and add/remove instructions for modifying session- or location-scoped permission rules.
8694 ///
8695 /// # Returns
8696 ///
8697 /// Indicates whether the operation succeeded.
8698 ///
8699 /// <div class="warning">
8700 ///
8701 /// **Experimental.** This API is part of an experimental wire-protocol surface
8702 /// and may change or be removed in future SDK or CLI releases. Pin both the
8703 /// SDK and CLI versions if your code depends on it.
8704 ///
8705 /// </div>
8706 pub async fn modify_rules(
8707 &self,
8708 params: PermissionsModifyRulesParams,
8709 ) -> Result<PermissionsModifyRulesResult, Error> {
8710 let mut wire_params = serde_json::to_value(params)?;
8711 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8712 let _value = self
8713 .session
8714 .client()
8715 .call(
8716 rpc_methods::SESSION_PERMISSIONS_MODIFYRULES,
8717 Some(wire_params),
8718 )
8719 .await?;
8720 Ok(serde_json::from_value(_value)?)
8721 }
8722
8723 /// Sets whether the client wants permission prompts bridged into session events.
8724 ///
8725 /// Wire method: `session.permissions.setRequired`.
8726 ///
8727 /// # Parameters
8728 ///
8729 /// * `params` - Toggles whether permission prompts should be bridged into session events for this client.
8730 ///
8731 /// # Returns
8732 ///
8733 /// Indicates whether the operation succeeded.
8734 ///
8735 /// <div class="warning">
8736 ///
8737 /// **Experimental.** This API is part of an experimental wire-protocol surface
8738 /// and may change or be removed in future SDK or CLI releases. Pin both the
8739 /// SDK and CLI versions if your code depends on it.
8740 ///
8741 /// </div>
8742 pub async fn set_required(
8743 &self,
8744 params: PermissionsSetRequiredRequest,
8745 ) -> Result<PermissionsSetRequiredResult, Error> {
8746 let mut wire_params = serde_json::to_value(params)?;
8747 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8748 let _value = self
8749 .session
8750 .client()
8751 .call(
8752 rpc_methods::SESSION_PERMISSIONS_SETREQUIRED,
8753 Some(wire_params),
8754 )
8755 .await?;
8756 Ok(serde_json::from_value(_value)?)
8757 }
8758
8759 /// Clears session-scoped tool approvals and, for full resets, exact session-approved paths.
8760 ///
8761 /// Wire method: `session.permissions.resetSessionApprovals`.
8762 ///
8763 /// # Parameters
8764 ///
8765 /// * `params` - Clears session-scoped tool approvals and optionally clears location-scoped approvals and exact session-approved paths.
8766 ///
8767 /// # Returns
8768 ///
8769 /// Indicates whether the operation succeeded.
8770 ///
8771 /// <div class="warning">
8772 ///
8773 /// **Experimental.** This API is part of an experimental wire-protocol surface
8774 /// and may change or be removed in future SDK or CLI releases. Pin both the
8775 /// SDK and CLI versions if your code depends on it.
8776 ///
8777 /// </div>
8778 pub async fn reset_session_approvals(
8779 &self,
8780 params: PermissionsResetSessionApprovalsRequest,
8781 ) -> Result<PermissionsResetSessionApprovalsResult, Error> {
8782 let mut wire_params = serde_json::to_value(params)?;
8783 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8784 let _value = self
8785 .session
8786 .client()
8787 .call(
8788 rpc_methods::SESSION_PERMISSIONS_RESETSESSIONAPPROVALS,
8789 Some(wire_params),
8790 )
8791 .await?;
8792 Ok(serde_json::from_value(_value)?)
8793 }
8794
8795 /// Notifies the runtime that a permission prompt UI has been shown to the user.
8796 ///
8797 /// Wire method: `session.permissions.notifyPromptShown`.
8798 ///
8799 /// # Parameters
8800 ///
8801 /// * `params` - Notification payload describing the permission prompt that the client just rendered.
8802 ///
8803 /// # Returns
8804 ///
8805 /// Indicates whether the operation succeeded.
8806 ///
8807 /// <div class="warning">
8808 ///
8809 /// **Experimental.** This API is part of an experimental wire-protocol surface
8810 /// and may change or be removed in future SDK or CLI releases. Pin both the
8811 /// SDK and CLI versions if your code depends on it.
8812 ///
8813 /// </div>
8814 pub async fn notify_prompt_shown(
8815 &self,
8816 params: PermissionPromptShownNotification,
8817 ) -> Result<PermissionsNotifyPromptShownResult, Error> {
8818 let mut wire_params = serde_json::to_value(params)?;
8819 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8820 let _value = self
8821 .session
8822 .client()
8823 .call(
8824 rpc_methods::SESSION_PERMISSIONS_NOTIFYPROMPTSHOWN,
8825 Some(wire_params),
8826 )
8827 .await?;
8828 Ok(serde_json::from_value(_value)?)
8829 }
8830}
8831
8832/// `session.permissions.folderTrust.*` RPCs.
8833#[derive(Clone, Copy)]
8834pub struct SessionRpcPermissionsFolderTrust<'a> {
8835 pub(crate) session: &'a Session,
8836}
8837
8838impl<'a> SessionRpcPermissionsFolderTrust<'a> {
8839 /// Reports whether a folder is trusted according to the user's folder trust state.
8840 ///
8841 /// Wire method: `session.permissions.folderTrust.isTrusted`.
8842 ///
8843 /// # Parameters
8844 ///
8845 /// * `params` - Folder path to check for trust.
8846 ///
8847 /// # Returns
8848 ///
8849 /// Folder trust check result.
8850 ///
8851 /// <div class="warning">
8852 ///
8853 /// **Experimental.** This API is part of an experimental wire-protocol surface
8854 /// and may change or be removed in future SDK or CLI releases. Pin both the
8855 /// SDK and CLI versions if your code depends on it.
8856 ///
8857 /// </div>
8858 pub async fn is_trusted(
8859 &self,
8860 params: FolderTrustCheckParams,
8861 ) -> Result<FolderTrustCheckResult, Error> {
8862 let mut wire_params = serde_json::to_value(params)?;
8863 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8864 let _value = self
8865 .session
8866 .client()
8867 .call(
8868 rpc_methods::SESSION_PERMISSIONS_FOLDERTRUST_ISTRUSTED,
8869 Some(wire_params),
8870 )
8871 .await?;
8872 Ok(serde_json::from_value(_value)?)
8873 }
8874
8875 /// Adds a folder to the user's trusted folders list.
8876 ///
8877 /// Wire method: `session.permissions.folderTrust.addTrusted`.
8878 ///
8879 /// # Parameters
8880 ///
8881 /// * `params` - Folder path to add to trusted folders.
8882 ///
8883 /// # Returns
8884 ///
8885 /// Indicates whether the operation succeeded.
8886 ///
8887 /// <div class="warning">
8888 ///
8889 /// **Experimental.** This API is part of an experimental wire-protocol surface
8890 /// and may change or be removed in future SDK or CLI releases. Pin both the
8891 /// SDK and CLI versions if your code depends on it.
8892 ///
8893 /// </div>
8894 pub async fn add_trusted(
8895 &self,
8896 params: FolderTrustAddParams,
8897 ) -> Result<PermissionsFolderTrustAddTrustedResult, Error> {
8898 let mut wire_params = serde_json::to_value(params)?;
8899 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8900 let _value = self
8901 .session
8902 .client()
8903 .call(
8904 rpc_methods::SESSION_PERMISSIONS_FOLDERTRUST_ADDTRUSTED,
8905 Some(wire_params),
8906 )
8907 .await?;
8908 Ok(serde_json::from_value(_value)?)
8909 }
8910}
8911
8912/// `session.permissions.locations.*` RPCs.
8913#[derive(Clone, Copy)]
8914pub struct SessionRpcPermissionsLocations<'a> {
8915 pub(crate) session: &'a Session,
8916}
8917
8918impl<'a> SessionRpcPermissionsLocations<'a> {
8919 /// Resolves the permission location key and type for a working directory.
8920 ///
8921 /// Wire method: `session.permissions.locations.resolve`.
8922 ///
8923 /// # Parameters
8924 ///
8925 /// * `params` - Working directory to resolve into a location-permissions key.
8926 ///
8927 /// # Returns
8928 ///
8929 /// Resolved location-permissions key and type.
8930 ///
8931 /// <div class="warning">
8932 ///
8933 /// **Experimental.** This API is part of an experimental wire-protocol surface
8934 /// and may change or be removed in future SDK or CLI releases. Pin both the
8935 /// SDK and CLI versions if your code depends on it.
8936 ///
8937 /// </div>
8938 pub async fn resolve(
8939 &self,
8940 params: PermissionLocationResolveParams,
8941 ) -> Result<PermissionLocationResolveResult, Error> {
8942 let mut wire_params = serde_json::to_value(params)?;
8943 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8944 let _value = self
8945 .session
8946 .client()
8947 .call(
8948 rpc_methods::SESSION_PERMISSIONS_LOCATIONS_RESOLVE,
8949 Some(wire_params),
8950 )
8951 .await?;
8952 Ok(serde_json::from_value(_value)?)
8953 }
8954
8955 /// Applies persisted location-scoped tool approvals and allowed directories for a working directory to this session's permission service.
8956 ///
8957 /// Wire method: `session.permissions.locations.apply`.
8958 ///
8959 /// # Parameters
8960 ///
8961 /// * `params` - Working directory to load persisted location permissions for.
8962 ///
8963 /// # Returns
8964 ///
8965 /// Summary of persisted location permissions applied to the session.
8966 ///
8967 /// <div class="warning">
8968 ///
8969 /// **Experimental.** This API is part of an experimental wire-protocol surface
8970 /// and may change or be removed in future SDK or CLI releases. Pin both the
8971 /// SDK and CLI versions if your code depends on it.
8972 ///
8973 /// </div>
8974 pub async fn apply(
8975 &self,
8976 params: PermissionLocationApplyParams,
8977 ) -> Result<PermissionLocationApplyResult, Error> {
8978 let mut wire_params = serde_json::to_value(params)?;
8979 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8980 let _value = self
8981 .session
8982 .client()
8983 .call(
8984 rpc_methods::SESSION_PERMISSIONS_LOCATIONS_APPLY,
8985 Some(wire_params),
8986 )
8987 .await?;
8988 Ok(serde_json::from_value(_value)?)
8989 }
8990
8991 /// Persists a tool approval for a permission location and applies its rules to this session's live permission service.
8992 ///
8993 /// Wire method: `session.permissions.locations.addToolApproval`.
8994 ///
8995 /// # Parameters
8996 ///
8997 /// * `params` - Location-scoped tool approval to persist.
8998 ///
8999 /// # Returns
9000 ///
9001 /// Indicates whether the operation succeeded.
9002 ///
9003 /// <div class="warning">
9004 ///
9005 /// **Experimental.** This API is part of an experimental wire-protocol surface
9006 /// and may change or be removed in future SDK or CLI releases. Pin both the
9007 /// SDK and CLI versions if your code depends on it.
9008 ///
9009 /// </div>
9010 pub async fn add_tool_approval(
9011 &self,
9012 params: PermissionLocationAddToolApprovalParams,
9013 ) -> Result<PermissionsLocationsAddToolApprovalResult, Error> {
9014 let mut wire_params = serde_json::to_value(params)?;
9015 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9016 let _value = self
9017 .session
9018 .client()
9019 .call(
9020 rpc_methods::SESSION_PERMISSIONS_LOCATIONS_ADDTOOLAPPROVAL,
9021 Some(wire_params),
9022 )
9023 .await?;
9024 Ok(serde_json::from_value(_value)?)
9025 }
9026}
9027
9028/// `session.permissions.paths.*` RPCs.
9029#[derive(Clone, Copy)]
9030pub struct SessionRpcPermissionsPaths<'a> {
9031 pub(crate) session: &'a Session,
9032}
9033
9034impl<'a> SessionRpcPermissionsPaths<'a> {
9035 /// Returns the session's recursive directory grants, exact session-approved paths, and primary working directory.
9036 ///
9037 /// Wire method: `session.permissions.paths.list`.
9038 ///
9039 /// # Returns
9040 ///
9041 /// Snapshot of the session's recursive directory grants, exact session-approved paths, and primary working directory.
9042 ///
9043 /// <div class="warning">
9044 ///
9045 /// **Experimental.** This API is part of an experimental wire-protocol surface
9046 /// and may change or be removed in future SDK or CLI releases. Pin both the
9047 /// SDK and CLI versions if your code depends on it.
9048 ///
9049 /// </div>
9050 pub async fn list(&self) -> Result<PermissionPathsList, Error> {
9051 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9052 let _value = self
9053 .session
9054 .client()
9055 .call(
9056 rpc_methods::SESSION_PERMISSIONS_PATHS_LIST,
9057 Some(wire_params),
9058 )
9059 .await?;
9060 Ok(serde_json::from_value(_value)?)
9061 }
9062
9063 /// Adds a directory to the session's allow-list and activates conventional skill and agent definitions under it.
9064 ///
9065 /// Wire method: `session.permissions.paths.add`.
9066 ///
9067 /// # Parameters
9068 ///
9069 /// * `params` - Directory path to add to the session's allowed directories.
9070 ///
9071 /// # Returns
9072 ///
9073 /// Indicates whether the operation succeeded.
9074 ///
9075 /// <div class="warning">
9076 ///
9077 /// **Experimental.** This API is part of an experimental wire-protocol surface
9078 /// and may change or be removed in future SDK or CLI releases. Pin both the
9079 /// SDK and CLI versions if your code depends on it.
9080 ///
9081 /// </div>
9082 pub async fn add(
9083 &self,
9084 params: PermissionPathsAddParams,
9085 ) -> Result<PermissionsPathsAddResult, Error> {
9086 let mut wire_params = serde_json::to_value(params)?;
9087 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9088 let _value = self
9089 .session
9090 .client()
9091 .call(
9092 rpc_methods::SESSION_PERMISSIONS_PATHS_ADD,
9093 Some(wire_params),
9094 )
9095 .await?;
9096 Ok(serde_json::from_value(_value)?)
9097 }
9098
9099 /// Updates the session's primary working directory used by the permission policy.
9100 ///
9101 /// Wire method: `session.permissions.paths.updatePrimary`.
9102 ///
9103 /// # Parameters
9104 ///
9105 /// * `params` - Directory path to set as the session's new primary working directory.
9106 ///
9107 /// # Returns
9108 ///
9109 /// Indicates whether the operation succeeded.
9110 ///
9111 /// <div class="warning">
9112 ///
9113 /// **Experimental.** This API is part of an experimental wire-protocol surface
9114 /// and may change or be removed in future SDK or CLI releases. Pin both the
9115 /// SDK and CLI versions if your code depends on it.
9116 ///
9117 /// </div>
9118 pub async fn update_primary(
9119 &self,
9120 params: PermissionPathsUpdatePrimaryParams,
9121 ) -> Result<PermissionsPathsUpdatePrimaryResult, Error> {
9122 let mut wire_params = serde_json::to_value(params)?;
9123 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9124 let _value = self
9125 .session
9126 .client()
9127 .call(
9128 rpc_methods::SESSION_PERMISSIONS_PATHS_UPDATEPRIMARY,
9129 Some(wire_params),
9130 )
9131 .await?;
9132 Ok(serde_json::from_value(_value)?)
9133 }
9134
9135 /// Reports whether a path falls within any of the session's allowed directories.
9136 ///
9137 /// Wire method: `session.permissions.paths.isPathWithinAllowedDirectories`.
9138 ///
9139 /// # Parameters
9140 ///
9141 /// * `params` - Path to evaluate against the session's allowed directories.
9142 ///
9143 /// # Returns
9144 ///
9145 /// Indicates whether the supplied path is within the session's allowed directories.
9146 ///
9147 /// <div class="warning">
9148 ///
9149 /// **Experimental.** This API is part of an experimental wire-protocol surface
9150 /// and may change or be removed in future SDK or CLI releases. Pin both the
9151 /// SDK and CLI versions if your code depends on it.
9152 ///
9153 /// </div>
9154 pub async fn is_path_within_allowed_directories(
9155 &self,
9156 params: PermissionPathsAllowedCheckParams,
9157 ) -> Result<PermissionPathsAllowedCheckResult, Error> {
9158 let mut wire_params = serde_json::to_value(params)?;
9159 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9160 let _value = self
9161 .session
9162 .client()
9163 .call(
9164 rpc_methods::SESSION_PERMISSIONS_PATHS_ISPATHWITHINALLOWEDDIRECTORIES,
9165 Some(wire_params),
9166 )
9167 .await?;
9168 Ok(serde_json::from_value(_value)?)
9169 }
9170
9171 /// Reports whether a path falls within the session's workspace (primary) directory.
9172 ///
9173 /// Wire method: `session.permissions.paths.isPathWithinWorkspace`.
9174 ///
9175 /// # Parameters
9176 ///
9177 /// * `params` - Path to evaluate against the session's workspace (primary) directory.
9178 ///
9179 /// # Returns
9180 ///
9181 /// Indicates whether the supplied path is within the session's workspace directory.
9182 ///
9183 /// <div class="warning">
9184 ///
9185 /// **Experimental.** This API is part of an experimental wire-protocol surface
9186 /// and may change or be removed in future SDK or CLI releases. Pin both the
9187 /// SDK and CLI versions if your code depends on it.
9188 ///
9189 /// </div>
9190 pub async fn is_path_within_workspace(
9191 &self,
9192 params: PermissionPathsWorkspaceCheckParams,
9193 ) -> Result<PermissionPathsWorkspaceCheckResult, Error> {
9194 let mut wire_params = serde_json::to_value(params)?;
9195 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9196 let _value = self
9197 .session
9198 .client()
9199 .call(
9200 rpc_methods::SESSION_PERMISSIONS_PATHS_ISPATHWITHINWORKSPACE,
9201 Some(wire_params),
9202 )
9203 .await?;
9204 Ok(serde_json::from_value(_value)?)
9205 }
9206}
9207
9208/// `session.permissions.urls.*` RPCs.
9209#[derive(Clone, Copy)]
9210pub struct SessionRpcPermissionsUrls<'a> {
9211 pub(crate) session: &'a Session,
9212}
9213
9214impl<'a> SessionRpcPermissionsUrls<'a> {
9215 /// Toggles the runtime's URL-permission policy between unrestricted and restricted modes.
9216 ///
9217 /// Wire method: `session.permissions.urls.setUnrestrictedMode`.
9218 ///
9219 /// # Parameters
9220 ///
9221 /// * `params` - Whether the URL-permission policy should run in unrestricted mode.
9222 ///
9223 /// # Returns
9224 ///
9225 /// Indicates whether the operation succeeded.
9226 ///
9227 /// <div class="warning">
9228 ///
9229 /// **Experimental.** This API is part of an experimental wire-protocol surface
9230 /// and may change or be removed in future SDK or CLI releases. Pin both the
9231 /// SDK and CLI versions if your code depends on it.
9232 ///
9233 /// </div>
9234 pub async fn set_unrestricted_mode(
9235 &self,
9236 params: PermissionUrlsSetUnrestrictedModeParams,
9237 ) -> Result<PermissionsUrlsSetUnrestrictedModeResult, Error> {
9238 let mut wire_params = serde_json::to_value(params)?;
9239 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9240 let _value = self
9241 .session
9242 .client()
9243 .call(
9244 rpc_methods::SESSION_PERMISSIONS_URLS_SETUNRESTRICTEDMODE,
9245 Some(wire_params),
9246 )
9247 .await?;
9248 Ok(serde_json::from_value(_value)?)
9249 }
9250}
9251
9252/// `session.plan.*` RPCs.
9253#[derive(Clone, Copy)]
9254pub struct SessionRpcPlan<'a> {
9255 pub(crate) session: &'a Session,
9256}
9257
9258impl<'a> SessionRpcPlan<'a> {
9259 /// Reads the session plan file from the workspace.
9260 ///
9261 /// Wire method: `session.plan.read`.
9262 ///
9263 /// # Returns
9264 ///
9265 /// Existence, contents, and resolved path of the session plan file.
9266 ///
9267 /// <div class="warning">
9268 ///
9269 /// **Experimental.** This API is part of an experimental wire-protocol surface
9270 /// and may change or be removed in future SDK or CLI releases. Pin both the
9271 /// SDK and CLI versions if your code depends on it.
9272 ///
9273 /// </div>
9274 pub async fn read(&self) -> Result<PlanReadResult, Error> {
9275 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9276 let _value = self
9277 .session
9278 .client()
9279 .call(rpc_methods::SESSION_PLAN_READ, Some(wire_params))
9280 .await?;
9281 Ok(serde_json::from_value(_value)?)
9282 }
9283
9284 /// Writes new content to the session plan file.
9285 ///
9286 /// Wire method: `session.plan.update`.
9287 ///
9288 /// # Parameters
9289 ///
9290 /// * `params` - Replacement contents to write to the session plan file.
9291 ///
9292 /// <div class="warning">
9293 ///
9294 /// **Experimental.** This API is part of an experimental wire-protocol surface
9295 /// and may change or be removed in future SDK or CLI releases. Pin both the
9296 /// SDK and CLI versions if your code depends on it.
9297 ///
9298 /// </div>
9299 pub async fn update(&self, params: PlanUpdateRequest) -> Result<(), Error> {
9300 let mut wire_params = serde_json::to_value(params)?;
9301 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9302 let _value = self
9303 .session
9304 .client()
9305 .call(rpc_methods::SESSION_PLAN_UPDATE, Some(wire_params))
9306 .await?;
9307 Ok(())
9308 }
9309
9310 /// Deletes the session plan file from the workspace.
9311 ///
9312 /// Wire method: `session.plan.delete`.
9313 ///
9314 /// <div class="warning">
9315 ///
9316 /// **Experimental.** This API is part of an experimental wire-protocol surface
9317 /// and may change or be removed in future SDK or CLI releases. Pin both the
9318 /// SDK and CLI versions if your code depends on it.
9319 ///
9320 /// </div>
9321 pub async fn delete(&self) -> Result<(), Error> {
9322 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9323 let _value = self
9324 .session
9325 .client()
9326 .call(rpc_methods::SESSION_PLAN_DELETE, Some(wire_params))
9327 .await?;
9328 Ok(())
9329 }
9330
9331 /// Reads todo rows from the session SQL database for plan rendering.
9332 ///
9333 /// Wire method: `session.plan.readSqlTodos`.
9334 ///
9335 /// # Returns
9336 ///
9337 /// Todo rows read from the session SQL database. Empty when no session database is available.
9338 ///
9339 /// <div class="warning">
9340 ///
9341 /// **Experimental.** This API is part of an experimental wire-protocol surface
9342 /// and may change or be removed in future SDK or CLI releases. Pin both the
9343 /// SDK and CLI versions if your code depends on it.
9344 ///
9345 /// </div>
9346 pub async fn read_sql_todos(&self) -> Result<PlanReadSqlTodosResult, Error> {
9347 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9348 let _value = self
9349 .session
9350 .client()
9351 .call(rpc_methods::SESSION_PLAN_READSQLTODOS, Some(wire_params))
9352 .await?;
9353 Ok(serde_json::from_value(_value)?)
9354 }
9355
9356 /// 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.
9357 ///
9358 /// Wire method: `session.plan.readSqlTodosWithDependencies`.
9359 ///
9360 /// # Returns
9361 ///
9362 /// Todo rows + dependency edges read from the session SQL database.
9363 ///
9364 /// <div class="warning">
9365 ///
9366 /// **Experimental.** This API is part of an experimental wire-protocol surface
9367 /// and may change or be removed in future SDK or CLI releases. Pin both the
9368 /// SDK and CLI versions if your code depends on it.
9369 ///
9370 /// </div>
9371 pub async fn read_sql_todos_with_dependencies(
9372 &self,
9373 ) -> Result<PlanReadSqlTodosWithDependenciesResult, Error> {
9374 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9375 let _value = self
9376 .session
9377 .client()
9378 .call(
9379 rpc_methods::SESSION_PLAN_READSQLTODOSWITHDEPENDENCIES,
9380 Some(wire_params),
9381 )
9382 .await?;
9383 Ok(serde_json::from_value(_value)?)
9384 }
9385}
9386
9387/// `session.plugins.*` RPCs.
9388#[derive(Clone, Copy)]
9389pub struct SessionRpcPlugins<'a> {
9390 pub(crate) session: &'a Session,
9391}
9392
9393impl<'a> SessionRpcPlugins<'a> {
9394 /// `session.plugins.marketplaces.*` sub-namespace.
9395 pub fn marketplaces(&self) -> SessionRpcPluginsMarketplaces<'a> {
9396 SessionRpcPluginsMarketplaces {
9397 session: self.session,
9398 }
9399 }
9400
9401 /// Lists globally installed, live, built-in, and enterprise-managed desired plugins using the live session's authoritative account, working directory, and retained managed policy.
9402 ///
9403 /// Wire method: `session.plugins.list`.
9404 ///
9405 /// # Returns
9406 ///
9407 /// Plugins installed for the session, with their enabled state and version metadata.
9408 ///
9409 /// <div class="warning">
9410 ///
9411 /// **Experimental.** This API is part of an experimental wire-protocol surface
9412 /// and may change or be removed in future SDK or CLI releases. Pin both the
9413 /// SDK and CLI versions if your code depends on it.
9414 ///
9415 /// </div>
9416 pub async fn list(&self) -> Result<PluginList, Error> {
9417 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9418 let _value = self
9419 .session
9420 .client()
9421 .call(rpc_methods::SESSION_PLUGINS_LIST, Some(wire_params))
9422 .await?;
9423 Ok(serde_json::from_value(_value)?)
9424 }
9425
9426 /// Installs a plugin using the live session's authoritative account, working directory, and retained managed policy.
9427 ///
9428 /// Wire method: `session.plugins.install`.
9429 ///
9430 /// # Parameters
9431 ///
9432 /// * `params` - Plugin source resolved relative to the session's authoritative working directory.
9433 ///
9434 /// # Returns
9435 ///
9436 /// Result of installing a plugin.
9437 ///
9438 /// <div class="warning">
9439 ///
9440 /// **Experimental.** This API is part of an experimental wire-protocol surface
9441 /// and may change or be removed in future SDK or CLI releases. Pin both the
9442 /// SDK and CLI versions if your code depends on it.
9443 ///
9444 /// </div>
9445 pub async fn install(
9446 &self,
9447 params: SessionPluginsInstallRequest,
9448 ) -> Result<PluginInstallResult, Error> {
9449 let mut wire_params = serde_json::to_value(params)?;
9450 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9451 let _value = self
9452 .session
9453 .client()
9454 .call(rpc_methods::SESSION_PLUGINS_INSTALL, Some(wire_params))
9455 .await?;
9456 Ok(serde_json::from_value(_value)?)
9457 }
9458
9459 /// Uninstalls a plugin when permitted by the live session's retained managed policy.
9460 ///
9461 /// Wire method: `session.plugins.uninstall`.
9462 ///
9463 /// # Parameters
9464 ///
9465 /// * `params` - Name (or spec) of the plugin to uninstall.
9466 ///
9467 /// <div class="warning">
9468 ///
9469 /// **Experimental.** This API is part of an experimental wire-protocol surface
9470 /// and may change or be removed in future SDK or CLI releases. Pin both the
9471 /// SDK and CLI versions if your code depends on it.
9472 ///
9473 /// </div>
9474 pub async fn uninstall(&self, params: PluginsUninstallRequest) -> Result<(), Error> {
9475 let mut wire_params = serde_json::to_value(params)?;
9476 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9477 let _value = self
9478 .session
9479 .client()
9480 .call(rpc_methods::SESSION_PLUGINS_UNINSTALL, Some(wire_params))
9481 .await?;
9482 Ok(())
9483 }
9484
9485 /// Updates an installed plugin using the live session's authoritative account, working directory, and retained managed policy.
9486 ///
9487 /// Wire method: `session.plugins.update`.
9488 ///
9489 /// # Parameters
9490 ///
9491 /// * `params` - Name (or spec) of the plugin to update.
9492 ///
9493 /// # Returns
9494 ///
9495 /// Result of updating a single plugin.
9496 ///
9497 /// <div class="warning">
9498 ///
9499 /// **Experimental.** This API is part of an experimental wire-protocol surface
9500 /// and may change or be removed in future SDK or CLI releases. Pin both the
9501 /// SDK and CLI versions if your code depends on it.
9502 ///
9503 /// </div>
9504 pub async fn update(&self, params: PluginsUpdateRequest) -> Result<PluginUpdateResult, Error> {
9505 let mut wire_params = serde_json::to_value(params)?;
9506 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9507 let _value = self
9508 .session
9509 .client()
9510 .call(rpc_methods::SESSION_PLUGINS_UPDATE, Some(wire_params))
9511 .await?;
9512 Ok(serde_json::from_value(_value)?)
9513 }
9514
9515 /// Enables installed plugins when permitted by the live session's retained managed policy.
9516 ///
9517 /// Wire method: `session.plugins.enable`.
9518 ///
9519 /// # Parameters
9520 ///
9521 /// * `params` - Plugin names (or specs) to enable in the session's authoritative working directory.
9522 ///
9523 /// <div class="warning">
9524 ///
9525 /// **Experimental.** This API is part of an experimental wire-protocol surface
9526 /// and may change or be removed in future SDK or CLI releases. Pin both the
9527 /// SDK and CLI versions if your code depends on it.
9528 ///
9529 /// </div>
9530 pub async fn enable(&self, params: SessionPluginsEnableRequest) -> Result<(), Error> {
9531 let mut wire_params = serde_json::to_value(params)?;
9532 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9533 let _value = self
9534 .session
9535 .client()
9536 .call(rpc_methods::SESSION_PLUGINS_ENABLE, Some(wire_params))
9537 .await?;
9538 Ok(())
9539 }
9540
9541 /// Disables installed plugins when permitted by the live session's retained managed policy.
9542 ///
9543 /// Wire method: `session.plugins.disable`.
9544 ///
9545 /// # Parameters
9546 ///
9547 /// * `params` - Plugin names (or specs) to disable in the session's authoritative working directory.
9548 ///
9549 /// <div class="warning">
9550 ///
9551 /// **Experimental.** This API is part of an experimental wire-protocol surface
9552 /// and may change or be removed in future SDK or CLI releases. Pin both the
9553 /// SDK and CLI versions if your code depends on it.
9554 ///
9555 /// </div>
9556 pub async fn disable(&self, params: SessionPluginsDisableRequest) -> Result<(), Error> {
9557 let mut wire_params = serde_json::to_value(params)?;
9558 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9559 let _value = self
9560 .session
9561 .client()
9562 .call(rpc_methods::SESSION_PLUGINS_DISABLE, Some(wire_params))
9563 .await?;
9564 Ok(())
9565 }
9566
9567 /// 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.
9568 ///
9569 /// Wire method: `session.plugins.reload`.
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 reload(&self) -> Result<(), Error> {
9579 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9580 let _value = self
9581 .session
9582 .client()
9583 .call(rpc_methods::SESSION_PLUGINS_RELOAD, Some(wire_params))
9584 .await?;
9585 Ok(())
9586 }
9587
9588 /// 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.
9589 ///
9590 /// Wire method: `session.plugins.reload`.
9591 ///
9592 /// # Parameters
9593 ///
9594 /// * `params` - Optional flags controlling which side effects the reload performs.
9595 ///
9596 /// <div class="warning">
9597 ///
9598 /// **Experimental.** This API is part of an experimental wire-protocol surface
9599 /// and may change or be removed in future SDK or CLI releases. Pin both the
9600 /// SDK and CLI versions if your code depends on it.
9601 ///
9602 /// </div>
9603 pub async fn reload_with_params(&self, params: PluginsReloadRequest) -> Result<(), Error> {
9604 let mut wire_params = serde_json::to_value(params)?;
9605 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9606 let _value = self
9607 .session
9608 .client()
9609 .call(rpc_methods::SESSION_PLUGINS_RELOAD, Some(wire_params))
9610 .await?;
9611 Ok(())
9612 }
9613}
9614
9615/// `session.plugins.marketplaces.*` RPCs.
9616#[derive(Clone, Copy)]
9617pub struct SessionRpcPluginsMarketplaces<'a> {
9618 pub(crate) session: &'a Session,
9619}
9620
9621impl<'a> SessionRpcPluginsMarketplaces<'a> {
9622 /// Lists registered and enterprise-managed desired marketplaces using the live session's retained policy.
9623 ///
9624 /// Wire method: `session.plugins.marketplaces.list`.
9625 ///
9626 /// # Returns
9627 ///
9628 /// All registered marketplaces, including built-in defaults.
9629 ///
9630 /// <div class="warning">
9631 ///
9632 /// **Experimental.** This API is part of an experimental wire-protocol surface
9633 /// and may change or be removed in future SDK or CLI releases. Pin both the
9634 /// SDK and CLI versions if your code depends on it.
9635 ///
9636 /// </div>
9637 pub async fn list(&self) -> Result<MarketplaceListResult, Error> {
9638 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9639 let _value = self
9640 .session
9641 .client()
9642 .call(
9643 rpc_methods::SESSION_PLUGINS_MARKETPLACES_LIST,
9644 Some(wire_params),
9645 )
9646 .await?;
9647 Ok(serde_json::from_value(_value)?)
9648 }
9649
9650 /// Adds a marketplace when permitted by the live session's retained managed policy.
9651 ///
9652 /// Wire method: `session.plugins.marketplaces.add`.
9653 ///
9654 /// # Parameters
9655 ///
9656 /// * `params` - Marketplace source and optional working directory for relative-path resolution.
9657 ///
9658 /// # Returns
9659 ///
9660 /// Result of registering a new marketplace.
9661 ///
9662 /// <div class="warning">
9663 ///
9664 /// **Experimental.** This API is part of an experimental wire-protocol surface
9665 /// and may change or be removed in future SDK or CLI releases. Pin both the
9666 /// SDK and CLI versions if your code depends on it.
9667 ///
9668 /// </div>
9669 pub async fn add(
9670 &self,
9671 params: PluginsMarketplacesAddRequest,
9672 ) -> Result<MarketplaceAddResult, Error> {
9673 let mut wire_params = serde_json::to_value(params)?;
9674 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9675 let _value = self
9676 .session
9677 .client()
9678 .call(
9679 rpc_methods::SESSION_PLUGINS_MARKETPLACES_ADD,
9680 Some(wire_params),
9681 )
9682 .await?;
9683 Ok(serde_json::from_value(_value)?)
9684 }
9685
9686 /// Removes a marketplace when permitted by the live session's retained managed policy.
9687 ///
9688 /// Wire method: `session.plugins.marketplaces.remove`.
9689 ///
9690 /// # Parameters
9691 ///
9692 /// * `params` - Name of the marketplace to remove and an optional force flag.
9693 ///
9694 /// # Returns
9695 ///
9696 /// Outcome of the remove attempt, including dependent-plugin info when applicable.
9697 ///
9698 /// <div class="warning">
9699 ///
9700 /// **Experimental.** This API is part of an experimental wire-protocol surface
9701 /// and may change or be removed in future SDK or CLI releases. Pin both the
9702 /// SDK and CLI versions if your code depends on it.
9703 ///
9704 /// </div>
9705 pub async fn remove(
9706 &self,
9707 params: PluginsMarketplacesRemoveRequest,
9708 ) -> Result<MarketplaceRemoveResult, Error> {
9709 let mut wire_params = serde_json::to_value(params)?;
9710 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9711 let _value = self
9712 .session
9713 .client()
9714 .call(
9715 rpc_methods::SESSION_PLUGINS_MARKETPLACES_REMOVE,
9716 Some(wire_params),
9717 )
9718 .await?;
9719 Ok(serde_json::from_value(_value)?)
9720 }
9721
9722 /// Browses a marketplace resolved through the live session's working directory and retained managed policy.
9723 ///
9724 /// Wire method: `session.plugins.marketplaces.browse`.
9725 ///
9726 /// # Parameters
9727 ///
9728 /// * `params` - Name of the marketplace whose plugin catalog to fetch.
9729 ///
9730 /// # Returns
9731 ///
9732 /// Plugins advertised by the marketplace.
9733 ///
9734 /// <div class="warning">
9735 ///
9736 /// **Experimental.** This API is part of an experimental wire-protocol surface
9737 /// and may change or be removed in future SDK or CLI releases. Pin both the
9738 /// SDK and CLI versions if your code depends on it.
9739 ///
9740 /// </div>
9741 pub async fn browse(
9742 &self,
9743 params: PluginsMarketplacesBrowseRequest,
9744 ) -> Result<MarketplaceBrowseResult, Error> {
9745 let mut wire_params = serde_json::to_value(params)?;
9746 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9747 let _value = self
9748 .session
9749 .client()
9750 .call(
9751 rpc_methods::SESSION_PLUGINS_MARKETPLACES_BROWSE,
9752 Some(wire_params),
9753 )
9754 .await?;
9755 Ok(serde_json::from_value(_value)?)
9756 }
9757
9758 /// Refreshes marketplaces resolved through the live session's working directory and retained managed policy.
9759 ///
9760 /// Wire method: `session.plugins.marketplaces.refresh`.
9761 ///
9762 /// # Returns
9763 ///
9764 /// Result of refreshing one or more marketplace catalogs.
9765 ///
9766 /// <div class="warning">
9767 ///
9768 /// **Experimental.** This API is part of an experimental wire-protocol surface
9769 /// and may change or be removed in future SDK or CLI releases. Pin both the
9770 /// SDK and CLI versions if your code depends on it.
9771 ///
9772 /// </div>
9773 pub async fn refresh(&self) -> Result<MarketplaceRefreshResult, Error> {
9774 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9775 let _value = self
9776 .session
9777 .client()
9778 .call(
9779 rpc_methods::SESSION_PLUGINS_MARKETPLACES_REFRESH,
9780 Some(wire_params),
9781 )
9782 .await?;
9783 Ok(serde_json::from_value(_value)?)
9784 }
9785
9786 /// Refreshes marketplaces resolved through the live session's working directory and retained managed policy.
9787 ///
9788 /// Wire method: `session.plugins.marketplaces.refresh`.
9789 ///
9790 /// # Parameters
9791 ///
9792 /// * `params` - Optional marketplace name; omit to refresh all.
9793 ///
9794 /// # Returns
9795 ///
9796 /// Result of refreshing one or more marketplace catalogs.
9797 ///
9798 /// <div class="warning">
9799 ///
9800 /// **Experimental.** This API is part of an experimental wire-protocol surface
9801 /// and may change or be removed in future SDK or CLI releases. Pin both the
9802 /// SDK and CLI versions if your code depends on it.
9803 ///
9804 /// </div>
9805 pub async fn refresh_with_params(
9806 &self,
9807 params: PluginsMarketplacesRefreshRequest,
9808 ) -> Result<MarketplaceRefreshResult, Error> {
9809 let mut wire_params = serde_json::to_value(params)?;
9810 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9811 let _value = self
9812 .session
9813 .client()
9814 .call(
9815 rpc_methods::SESSION_PLUGINS_MARKETPLACES_REFRESH,
9816 Some(wire_params),
9817 )
9818 .await?;
9819 Ok(serde_json::from_value(_value)?)
9820 }
9821}
9822
9823/// `session.provider.*` RPCs.
9824#[derive(Clone, Copy)]
9825pub struct SessionRpcProvider<'a> {
9826 pub(crate) session: &'a Session,
9827}
9828
9829impl<'a> SessionRpcProvider<'a> {
9830 /// 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.
9831 ///
9832 /// Wire method: `session.provider.getEndpoint`.
9833 ///
9834 /// # Returns
9835 ///
9836 /// A snapshot of the provider endpoint the session is currently configured to talk to.
9837 ///
9838 /// <div class="warning">
9839 ///
9840 /// **Experimental.** This API is part of an experimental wire-protocol surface
9841 /// and may change or be removed in future SDK or CLI releases. Pin both the
9842 /// SDK and CLI versions if your code depends on it.
9843 ///
9844 /// </div>
9845 pub async fn get_endpoint(&self) -> Result<ProviderEndpoint, Error> {
9846 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9847 let _value = self
9848 .session
9849 .client()
9850 .call(rpc_methods::SESSION_PROVIDER_GETENDPOINT, Some(wire_params))
9851 .await?;
9852 Ok(serde_json::from_value(_value)?)
9853 }
9854
9855 /// 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.
9856 ///
9857 /// Wire method: `session.provider.getEndpoint`.
9858 ///
9859 /// # Parameters
9860 ///
9861 /// * `params` - Optional model identifier to scope the endpoint snapshot to.
9862 ///
9863 /// # Returns
9864 ///
9865 /// A snapshot of the provider endpoint the session is currently configured to talk to.
9866 ///
9867 /// <div class="warning">
9868 ///
9869 /// **Experimental.** This API is part of an experimental wire-protocol surface
9870 /// and may change or be removed in future SDK or CLI releases. Pin both the
9871 /// SDK and CLI versions if your code depends on it.
9872 ///
9873 /// </div>
9874 pub async fn get_endpoint_with_params(
9875 &self,
9876 params: ProviderGetEndpointRequest,
9877 ) -> Result<ProviderEndpoint, Error> {
9878 let mut wire_params = serde_json::to_value(params)?;
9879 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9880 let _value = self
9881 .session
9882 .client()
9883 .call(rpc_methods::SESSION_PROVIDER_GETENDPOINT, Some(wire_params))
9884 .await?;
9885 Ok(serde_json::from_value(_value)?)
9886 }
9887
9888 /// 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.
9889 ///
9890 /// Wire method: `session.provider.add`.
9891 ///
9892 /// # Parameters
9893 ///
9894 /// * `params` - BYOK providers and/or models to add to the session's registry at runtime. Both fields are optional; provide providers, models, or both.
9895 ///
9896 /// # Returns
9897 ///
9898 /// The selectable model entries synthesized for the models added by this call.
9899 ///
9900 /// <div class="warning">
9901 ///
9902 /// **Experimental.** This API is part of an experimental wire-protocol surface
9903 /// and may change or be removed in future SDK or CLI releases. Pin both the
9904 /// SDK and CLI versions if your code depends on it.
9905 ///
9906 /// </div>
9907 pub async fn add(&self, params: ProviderAddRequest) -> Result<ProviderAddResult, Error> {
9908 let mut wire_params = serde_json::to_value(params)?;
9909 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9910 let _value = self
9911 .session
9912 .client()
9913 .call(rpc_methods::SESSION_PROVIDER_ADD, Some(wire_params))
9914 .await?;
9915 Ok(serde_json::from_value(_value)?)
9916 }
9917
9918 /// Atomically updates the session's BYOK provider and model registry by applying the supplied snapshot, replacing existing entries, updating models, or removing entries absent from the snapshot.
9919 ///
9920 /// Wire method: `session.provider.sync`.
9921 ///
9922 /// # Parameters
9923 ///
9924 /// * `params` - Authoritative BYOK provider and model registry snapshot to apply atomically to the session.
9925 ///
9926 /// # Returns
9927 ///
9928 /// The selectable model entries and selection ids synthesized for the synchronized BYOK models.
9929 ///
9930 /// <div class="warning">
9931 ///
9932 /// **Experimental.** This API is part of an experimental wire-protocol surface
9933 /// and may change or be removed in future SDK or CLI releases. Pin both the
9934 /// SDK and CLI versions if your code depends on it.
9935 ///
9936 /// </div>
9937 pub async fn sync(&self, params: ProviderSyncRequest) -> Result<ProviderSyncResult, Error> {
9938 let mut wire_params = serde_json::to_value(params)?;
9939 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9940 let _value = self
9941 .session
9942 .client()
9943 .call(rpc_methods::SESSION_PROVIDER_SYNC, Some(wire_params))
9944 .await?;
9945 Ok(serde_json::from_value(_value)?)
9946 }
9947}
9948
9949/// `session.queue.*` RPCs.
9950#[derive(Clone, Copy)]
9951pub struct SessionRpcQueue<'a> {
9952 pub(crate) session: &'a Session,
9953}
9954
9955impl<'a> SessionRpcQueue<'a> {
9956 /// Returns the local session's pending user-facing queued items and steering messages.
9957 ///
9958 /// Wire method: `session.queue.pendingItems`.
9959 ///
9960 /// # Returns
9961 ///
9962 /// Snapshot of the session's pending queued items and immediate-steering messages.
9963 ///
9964 /// <div class="warning">
9965 ///
9966 /// **Experimental.** This API is part of an experimental wire-protocol surface
9967 /// and may change or be removed in future SDK or CLI releases. Pin both the
9968 /// SDK and CLI versions if your code depends on it.
9969 ///
9970 /// </div>
9971 pub async fn pending_items(&self) -> Result<QueuePendingItemsResult, Error> {
9972 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9973 let _value = self
9974 .session
9975 .client()
9976 .call(rpc_methods::SESSION_QUEUE_PENDINGITEMS, Some(wire_params))
9977 .await?;
9978 Ok(serde_json::from_value(_value)?)
9979 }
9980
9981 /// Returns the internal native queue snapshot for in-process session orchestration.
9982 ///
9983 /// Wire method: `session.queue.snapshot`.
9984 ///
9985 /// # Returns
9986 ///
9987 /// Internal snapshot of native queue state for local session orchestration.
9988 ///
9989 /// <div class="warning">
9990 ///
9991 /// **Experimental.** This API is part of an experimental wire-protocol surface
9992 /// and may change or be removed in future SDK or CLI releases. Pin both the
9993 /// SDK and CLI versions if your code depends on it.
9994 ///
9995 /// </div>
9996 pub(crate) async fn snapshot(&self) -> Result<QueueSnapshotResult, Error> {
9997 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9998 let _value = self
9999 .session
10000 .client()
10001 .call(rpc_methods::SESSION_QUEUE_SNAPSHOT, Some(wire_params))
10002 .await?;
10003 Ok(serde_json::from_value(_value)?)
10004 }
10005
10006 /// Moves an addressable queued item to a public visible position.
10007 ///
10008 /// Wire method: `session.queue.moveItem`.
10009 ///
10010 /// # Parameters
10011 ///
10012 /// * `params` - Parameters for moving a queued item by stable id.
10013 ///
10014 /// # Returns
10015 ///
10016 /// Result of moving a queued item.
10017 ///
10018 /// <div class="warning">
10019 ///
10020 /// **Experimental.** This API is part of an experimental wire-protocol surface
10021 /// and may change or be removed in future SDK or CLI releases. Pin both the
10022 /// SDK and CLI versions if your code depends on it.
10023 ///
10024 /// </div>
10025 pub async fn move_item(
10026 &self,
10027 params: QueueMoveItemRequest,
10028 ) -> Result<QueueMoveItemResult, Error> {
10029 let mut wire_params = serde_json::to_value(params)?;
10030 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10031 let _value = self
10032 .session
10033 .client()
10034 .call(rpc_methods::SESSION_QUEUE_MOVEITEM, Some(wire_params))
10035 .await?;
10036 Ok(serde_json::from_value(_value)?)
10037 }
10038
10039 /// Inserts a new queued message at a public visible position.
10040 ///
10041 /// Wire method: `session.queue.insertAt`.
10042 ///
10043 /// # Parameters
10044 ///
10045 /// * `params` - Parameters for inserting a queued message at a public visible position.
10046 ///
10047 /// # Returns
10048 ///
10049 /// Result of inserting a queued message.
10050 ///
10051 /// <div class="warning">
10052 ///
10053 /// **Experimental.** This API is part of an experimental wire-protocol surface
10054 /// and may change or be removed in future SDK or CLI releases. Pin both the
10055 /// SDK and CLI versions if your code depends on it.
10056 ///
10057 /// </div>
10058 pub async fn insert_at(
10059 &self,
10060 params: QueueInsertAtRequest,
10061 ) -> Result<QueueInsertAtResult, Error> {
10062 let mut wire_params = serde_json::to_value(params)?;
10063 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10064 let _value = self
10065 .session
10066 .client()
10067 .call(rpc_methods::SESSION_QUEUE_INSERTAT, Some(wire_params))
10068 .await?;
10069 Ok(serde_json::from_value(_value)?)
10070 }
10071
10072 /// Removes an addressable queued item by its stable id.
10073 ///
10074 /// Wire method: `session.queue.removeAt`.
10075 ///
10076 /// # Parameters
10077 ///
10078 /// * `params` - Parameters for removing a queued item by stable id.
10079 ///
10080 /// # Returns
10081 ///
10082 /// Result of removing a queued item.
10083 ///
10084 /// <div class="warning">
10085 ///
10086 /// **Experimental.** This API is part of an experimental wire-protocol surface
10087 /// and may change or be removed in future SDK or CLI releases. Pin both the
10088 /// SDK and CLI versions if your code depends on it.
10089 ///
10090 /// </div>
10091 pub async fn remove_at(
10092 &self,
10093 params: QueueRemoveAtRequest,
10094 ) -> Result<QueueRemoveAtResult, Error> {
10095 let mut wire_params = serde_json::to_value(params)?;
10096 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10097 let _value = self
10098 .session
10099 .client()
10100 .call(rpc_methods::SESSION_QUEUE_REMOVEAT, Some(wire_params))
10101 .await?;
10102 Ok(serde_json::from_value(_value)?)
10103 }
10104
10105 /// Updates the text of an addressable single-message queue item.
10106 ///
10107 /// Wire method: `session.queue.updateText`.
10108 ///
10109 /// # Parameters
10110 ///
10111 /// * `params` - Parameters for editing a single queued message.
10112 ///
10113 /// # Returns
10114 ///
10115 /// Result of editing a queued message.
10116 ///
10117 /// <div class="warning">
10118 ///
10119 /// **Experimental.** This API is part of an experimental wire-protocol surface
10120 /// and may change or be removed in future SDK or CLI releases. Pin both the
10121 /// SDK and CLI versions if your code depends on it.
10122 ///
10123 /// </div>
10124 pub async fn update_text(
10125 &self,
10126 params: QueueUpdateTextRequest,
10127 ) -> Result<QueueUpdateTextResult, Error> {
10128 let mut wire_params = serde_json::to_value(params)?;
10129 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10130 let _value = self
10131 .session
10132 .client()
10133 .call(rpc_methods::SESSION_QUEUE_UPDATETEXT, Some(wire_params))
10134 .await?;
10135 Ok(serde_json::from_value(_value)?)
10136 }
10137
10138 /// Atomically withdraws an unchanged, unconsumed user message from the local queued or steering lane. A client retaining the original draft may restore it only when removed is true. Does not interrupt the running turn.
10139 ///
10140 /// Wire method: `session.queue.withdrawMessage`.
10141 ///
10142 /// # Parameters
10143 ///
10144 /// * `params` - Conditional withdrawal of a single user message, before the runtime claims it for delivery.
10145 ///
10146 /// # Returns
10147 ///
10148 /// Result of removing a queued item.
10149 ///
10150 /// <div class="warning">
10151 ///
10152 /// **Experimental.** This API is part of an experimental wire-protocol surface
10153 /// and may change or be removed in future SDK or CLI releases. Pin both the
10154 /// SDK and CLI versions if your code depends on it.
10155 ///
10156 /// </div>
10157 pub async fn withdraw_message(
10158 &self,
10159 params: QueueWithdrawMessageRequest,
10160 ) -> Result<QueueRemoveAtResult, Error> {
10161 let mut wire_params = serde_json::to_value(params)?;
10162 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10163 let _value = self
10164 .session
10165 .client()
10166 .call(
10167 rpc_methods::SESSION_QUEUE_WITHDRAWMESSAGE,
10168 Some(wire_params),
10169 )
10170 .await?;
10171 Ok(serde_json::from_value(_value)?)
10172 }
10173
10174 /// Atomically appends text and attachments to an unchanged, unconsumed local steering message. Returns updated=false if delivery or withdrawal already claimed the message.
10175 ///
10176 /// Wire method: `session.queue.appendSteering`.
10177 ///
10178 /// # Parameters
10179 ///
10180 /// * `params` - Append to one pending steering message without changing its identity or delivery position.
10181 ///
10182 /// # Returns
10183 ///
10184 /// Result of editing a queued message.
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 append_steering(
10194 &self,
10195 params: QueueAppendSteeringRequest,
10196 ) -> Result<QueueUpdateTextResult, Error> {
10197 let mut wire_params = serde_json::to_value(params)?;
10198 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10199 let _value = self
10200 .session
10201 .client()
10202 .call(rpc_methods::SESSION_QUEUE_APPENDSTEERING, Some(wire_params))
10203 .await?;
10204 Ok(serde_json::from_value(_value)?)
10205 }
10206
10207 /// Duplicates an addressable queued item immediately after its source.
10208 ///
10209 /// Wire method: `session.queue.duplicateAt`.
10210 ///
10211 /// # Parameters
10212 ///
10213 /// * `params` - Parameters for duplicating a queued item.
10214 ///
10215 /// # Returns
10216 ///
10217 /// Result of duplicating a queued item.
10218 ///
10219 /// <div class="warning">
10220 ///
10221 /// **Experimental.** This API is part of an experimental wire-protocol surface
10222 /// and may change or be removed in future SDK or CLI releases. Pin both the
10223 /// SDK and CLI versions if your code depends on it.
10224 ///
10225 /// </div>
10226 pub async fn duplicate_at(
10227 &self,
10228 params: QueueDuplicateAtRequest,
10229 ) -> Result<QueueDuplicateAtResult, Error> {
10230 let mut wire_params = serde_json::to_value(params)?;
10231 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10232 let _value = self
10233 .session
10234 .client()
10235 .call(rpc_methods::SESSION_QUEUE_DUPLICATEAT, Some(wire_params))
10236 .await?;
10237 Ok(serde_json::from_value(_value)?)
10238 }
10239
10240 /// Acquires or releases the queued-lane drain pause.
10241 ///
10242 /// Wire method: `session.queue.setDrainPaused`.
10243 ///
10244 /// # Parameters
10245 ///
10246 /// * `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.
10247 ///
10248 /// <div class="warning">
10249 ///
10250 /// **Experimental.** This API is part of an experimental wire-protocol surface
10251 /// and may change or be removed in future SDK or CLI releases. Pin both the
10252 /// SDK and CLI versions if your code depends on it.
10253 ///
10254 /// </div>
10255 pub async fn set_drain_paused(&self, params: QueueSetDrainPausedRequest) -> Result<(), Error> {
10256 let mut wire_params = serde_json::to_value(params)?;
10257 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10258 let _value = self
10259 .session
10260 .client()
10261 .call(rpc_methods::SESSION_QUEUE_SETDRAINPAUSED, Some(wire_params))
10262 .await?;
10263 Ok(())
10264 }
10265
10266 /// Moves an addressable queued message into the live turn's steering lane.
10267 ///
10268 /// Wire method: `session.queue.sendNow`.
10269 ///
10270 /// # Parameters
10271 ///
10272 /// * `params` - Parameters for steering a queued message into a live turn.
10273 ///
10274 /// # Returns
10275 ///
10276 /// Result of trying to steer a queued message into a live turn.
10277 ///
10278 /// <div class="warning">
10279 ///
10280 /// **Experimental.** This API is part of an experimental wire-protocol surface
10281 /// and may change or be removed in future SDK or CLI releases. Pin both the
10282 /// SDK and CLI versions if your code depends on it.
10283 ///
10284 /// </div>
10285 pub async fn send_now(&self, params: QueueSendNowRequest) -> Result<QueueSendNowResult, Error> {
10286 let mut wire_params = serde_json::to_value(params)?;
10287 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10288 let _value = self
10289 .session
10290 .client()
10291 .call(rpc_methods::SESSION_QUEUE_SENDNOW, Some(wire_params))
10292 .await?;
10293 Ok(serde_json::from_value(_value)?)
10294 }
10295
10296 /// Reports whether the local session has native queued work pending.
10297 ///
10298 /// Wire method: `session.queue.hasPending`.
10299 ///
10300 /// # Returns
10301 ///
10302 /// Whether the native queue has pending work.
10303 ///
10304 /// <div class="warning">
10305 ///
10306 /// **Experimental.** This API is part of an experimental wire-protocol surface
10307 /// and may change or be removed in future SDK or CLI releases. Pin both the
10308 /// SDK and CLI versions if your code depends on it.
10309 ///
10310 /// </div>
10311 pub(crate) async fn has_pending(&self) -> Result<QueueHasPendingResult, Error> {
10312 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10313 let _value = self
10314 .session
10315 .client()
10316 .call(rpc_methods::SESSION_QUEUE_HASPENDING, Some(wire_params))
10317 .await?;
10318 Ok(serde_json::from_value(_value)?)
10319 }
10320
10321 /// Begins a native deferred-idle drain when background work has quiesced.
10322 ///
10323 /// Wire method: `session.queue.beginDeferredIdleDrain`.
10324 ///
10325 /// # Parameters
10326 ///
10327 /// * `params` - Inputs for starting a deferred-idle drain.
10328 ///
10329 /// # Returns
10330 ///
10331 /// Whether a deferred-idle drain should run.
10332 ///
10333 /// <div class="warning">
10334 ///
10335 /// **Experimental.** This API is part of an experimental wire-protocol surface
10336 /// and may change or be removed in future SDK or CLI releases. Pin both the
10337 /// SDK and CLI versions if your code depends on it.
10338 ///
10339 /// </div>
10340 pub(crate) async fn begin_deferred_idle_drain(
10341 &self,
10342 params: QueueBeginDeferredIdleDrainRequest,
10343 ) -> Result<QueueBeginDeferredIdleDrainResult, Error> {
10344 let mut wire_params = serde_json::to_value(params)?;
10345 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10346 let _value = self
10347 .session
10348 .client()
10349 .call(
10350 rpc_methods::SESSION_QUEUE_BEGINDEFERREDIDLEDRAIN,
10351 Some(wire_params),
10352 )
10353 .await?;
10354 Ok(serde_json::from_value(_value)?)
10355 }
10356
10357 /// Finishes a native deferred-idle drain and reports whether to drain queue work or emit idle.
10358 ///
10359 /// Wire method: `session.queue.finishDeferredIdleDrain`.
10360 ///
10361 /// # Parameters
10362 ///
10363 /// * `params` - Inputs for completing a deferred-idle drain.
10364 ///
10365 /// # Returns
10366 ///
10367 /// Action selected by the native deferred-idle drain.
10368 ///
10369 /// <div class="warning">
10370 ///
10371 /// **Experimental.** This API is part of an experimental wire-protocol surface
10372 /// and may change or be removed in future SDK or CLI releases. Pin both the
10373 /// SDK and CLI versions if your code depends on it.
10374 ///
10375 /// </div>
10376 pub(crate) async fn finish_deferred_idle_drain(
10377 &self,
10378 params: QueueFinishDeferredIdleDrainRequest,
10379 ) -> Result<QueueFinishDeferredIdleDrainResult, Error> {
10380 let mut wire_params = serde_json::to_value(params)?;
10381 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10382 let _value = self
10383 .session
10384 .client()
10385 .call(
10386 rpc_methods::SESSION_QUEUE_FINISHDEFERREDIDLEDRAIN,
10387 Some(wire_params),
10388 )
10389 .await?;
10390 Ok(serde_json::from_value(_value)?)
10391 }
10392
10393 /// Marks session.idle as deferred by native background work state.
10394 ///
10395 /// Wire method: `session.queue.deferSessionIdle`.
10396 ///
10397 /// # Parameters
10398 ///
10399 /// * `params` - Inputs for marking session.idle deferred in native state.
10400 ///
10401 /// <div class="warning">
10402 ///
10403 /// **Experimental.** This API is part of an experimental wire-protocol surface
10404 /// and may change or be removed in future SDK or CLI releases. Pin both the
10405 /// SDK and CLI versions if your code depends on it.
10406 ///
10407 /// </div>
10408 pub(crate) async fn defer_session_idle(
10409 &self,
10410 params: QueueDeferSessionIdleRequest,
10411 ) -> Result<(), Error> {
10412 let mut wire_params = serde_json::to_value(params)?;
10413 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10414 let _value = self
10415 .session
10416 .client()
10417 .call(
10418 rpc_methods::SESSION_QUEUE_DEFERSESSIONIDLE,
10419 Some(wire_params),
10420 )
10421 .await?;
10422 Ok(())
10423 }
10424
10425 /// Removes the most recently queued user-facing item (LIFO).
10426 ///
10427 /// Wire method: `session.queue.removeMostRecent`.
10428 ///
10429 /// # Returns
10430 ///
10431 /// Indicates whether a user-facing pending item was removed.
10432 ///
10433 /// <div class="warning">
10434 ///
10435 /// **Experimental.** This API is part of an experimental wire-protocol surface
10436 /// and may change or be removed in future SDK or CLI releases. Pin both the
10437 /// SDK and CLI versions if your code depends on it.
10438 ///
10439 /// </div>
10440 pub async fn remove_most_recent(&self) -> Result<QueueRemoveMostRecentResult, Error> {
10441 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10442 let _value = self
10443 .session
10444 .client()
10445 .call(
10446 rpc_methods::SESSION_QUEUE_REMOVEMOSTRECENT,
10447 Some(wire_params),
10448 )
10449 .await?;
10450 Ok(serde_json::from_value(_value)?)
10451 }
10452
10453 /// Clears all pending queued items on the local session.
10454 ///
10455 /// Wire method: `session.queue.clear`.
10456 ///
10457 /// <div class="warning">
10458 ///
10459 /// **Experimental.** This API is part of an experimental wire-protocol surface
10460 /// and may change or be removed in future SDK or CLI releases. Pin both the
10461 /// SDK and CLI versions if your code depends on it.
10462 ///
10463 /// </div>
10464 pub async fn clear(&self) -> Result<(), Error> {
10465 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10466 let _value = self
10467 .session
10468 .client()
10469 .call(rpc_methods::SESSION_QUEUE_CLEAR, Some(wire_params))
10470 .await?;
10471 Ok(())
10472 }
10473
10474 /// Consumes queued native system notifications matching an internal filter.
10475 ///
10476 /// Wire method: `session.queue.consumeSystemNotifications`.
10477 ///
10478 /// # Parameters
10479 ///
10480 /// * `params` - Internal filter for consuming queued system notifications.
10481 ///
10482 /// # Returns
10483 ///
10484 /// Indicates whether a user-facing pending item was removed.
10485 ///
10486 /// <div class="warning">
10487 ///
10488 /// **Experimental.** This API is part of an experimental wire-protocol surface
10489 /// and may change or be removed in future SDK or CLI releases. Pin both the
10490 /// SDK and CLI versions if your code depends on it.
10491 ///
10492 /// </div>
10493 pub(crate) async fn consume_system_notifications(
10494 &self,
10495 params: QueueConsumeSystemNotificationsRequest,
10496 ) -> Result<QueueRemoveMostRecentResult, Error> {
10497 let mut wire_params = serde_json::to_value(params)?;
10498 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10499 let _value = self
10500 .session
10501 .client()
10502 .call(
10503 rpc_methods::SESSION_QUEUE_CONSUMESYSTEMNOTIFICATIONS,
10504 Some(wire_params),
10505 )
10506 .await?;
10507 Ok(serde_json::from_value(_value)?)
10508 }
10509
10510 /// Enqueues the internal resume-pending wake item when orphan handling needs a follow-up turn.
10511 ///
10512 /// Wire method: `session.queue.enqueueResumePending`.
10513 ///
10514 /// # Returns
10515 ///
10516 /// Result of enqueueing the resume-pending wake item.
10517 ///
10518 /// <div class="warning">
10519 ///
10520 /// **Experimental.** This API is part of an experimental wire-protocol surface
10521 /// and may change or be removed in future SDK or CLI releases. Pin both the
10522 /// SDK and CLI versions if your code depends on it.
10523 ///
10524 /// </div>
10525 pub(crate) async fn enqueue_resume_pending(
10526 &self,
10527 ) -> Result<QueueEnqueueResumePendingResult, Error> {
10528 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10529 let _value = self
10530 .session
10531 .client()
10532 .call(
10533 rpc_methods::SESSION_QUEUE_ENQUEUERESUMEPENDING,
10534 Some(wire_params),
10535 )
10536 .await?;
10537 Ok(serde_json::from_value(_value)?)
10538 }
10539
10540 /// Drains the native local-session work queue for in-process session orchestration.
10541 ///
10542 /// Wire method: `session.queue.process`.
10543 ///
10544 /// <div class="warning">
10545 ///
10546 /// **Experimental.** This API is part of an experimental wire-protocol surface
10547 /// and may change or be removed in future SDK or CLI releases. Pin both the
10548 /// SDK and CLI versions if your code depends on it.
10549 ///
10550 /// </div>
10551 pub(crate) async fn process(&self) -> Result<(), Error> {
10552 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10553 let _value = self
10554 .session
10555 .client()
10556 .call(rpc_methods::SESSION_QUEUE_PROCESS, Some(wire_params))
10557 .await?;
10558 Ok(())
10559 }
10560}
10561
10562/// `session.remote.*` RPCs.
10563#[derive(Clone, Copy)]
10564pub struct SessionRpcRemote<'a> {
10565 pub(crate) session: &'a Session,
10566}
10567
10568impl<'a> SessionRpcRemote<'a> {
10569 /// Enables remote session export or steering.
10570 ///
10571 /// Wire method: `session.remote.enable`.
10572 ///
10573 /// # Parameters
10574 ///
10575 /// * `params` - Optional remote session mode ("off", "export", or "on"); defaults to enabling both export and remote steering.
10576 ///
10577 /// # Returns
10578 ///
10579 /// GitHub URL for the session and a flag indicating whether remote steering is enabled.
10580 ///
10581 /// <div class="warning">
10582 ///
10583 /// **Experimental.** This API is part of an experimental wire-protocol surface
10584 /// and may change or be removed in future SDK or CLI releases. Pin both the
10585 /// SDK and CLI versions if your code depends on it.
10586 ///
10587 /// </div>
10588 pub async fn enable(&self, params: RemoteEnableRequest) -> Result<RemoteEnableResult, Error> {
10589 let mut wire_params = serde_json::to_value(params)?;
10590 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10591 let _value = self
10592 .session
10593 .client()
10594 .call(rpc_methods::SESSION_REMOTE_ENABLE, Some(wire_params))
10595 .await?;
10596 Ok(serde_json::from_value(_value)?)
10597 }
10598
10599 /// Disables remote session export and steering.
10600 ///
10601 /// Wire method: `session.remote.disable`.
10602 ///
10603 /// <div class="warning">
10604 ///
10605 /// **Experimental.** This API is part of an experimental wire-protocol surface
10606 /// and may change or be removed in future SDK or CLI releases. Pin both the
10607 /// SDK and CLI versions if your code depends on it.
10608 ///
10609 /// </div>
10610 pub async fn disable(&self) -> Result<(), Error> {
10611 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10612 let _value = self
10613 .session
10614 .client()
10615 .call(rpc_methods::SESSION_REMOTE_DISABLE, Some(wire_params))
10616 .await?;
10617 Ok(())
10618 }
10619
10620 /// Persists a remote-steerability change emitted by the host as a session event.
10621 ///
10622 /// Wire method: `session.remote.notifySteerableChanged`.
10623 ///
10624 /// # Parameters
10625 ///
10626 /// * `params` - New remote-steerability state to persist as a `session.remote_steerable_changed` event.
10627 ///
10628 /// # Returns
10629 ///
10630 /// 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.
10631 ///
10632 /// <div class="warning">
10633 ///
10634 /// **Experimental.** This API is part of an experimental wire-protocol surface
10635 /// and may change or be removed in future SDK or CLI releases. Pin both the
10636 /// SDK and CLI versions if your code depends on it.
10637 ///
10638 /// </div>
10639 pub async fn notify_steerable_changed(
10640 &self,
10641 params: RemoteNotifySteerableChangedRequest,
10642 ) -> Result<RemoteNotifySteerableChangedResult, Error> {
10643 let mut wire_params = serde_json::to_value(params)?;
10644 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10645 let _value = self
10646 .session
10647 .client()
10648 .call(
10649 rpc_methods::SESSION_REMOTE_NOTIFYSTEERABLECHANGED,
10650 Some(wire_params),
10651 )
10652 .await?;
10653 Ok(serde_json::from_value(_value)?)
10654 }
10655}
10656
10657/// `session.sandbox.*` RPCs.
10658#[derive(Clone, Copy)]
10659pub struct SessionRpcSandbox<'a> {
10660 pub(crate) session: &'a Session,
10661}
10662
10663impl<'a> SessionRpcSandbox<'a> {
10664 /// Returns whether managed policy requires sandbox enforcement and whether an enforcement failure has permanently blocked the session.
10665 ///
10666 /// Wire method: `session.sandbox.getEnforcementStatus`.
10667 ///
10668 /// # Returns
10669 ///
10670 /// Managed sandbox enforcement state for a session.
10671 ///
10672 /// <div class="warning">
10673 ///
10674 /// **Experimental.** This API is part of an experimental wire-protocol surface
10675 /// and may change or be removed in future SDK or CLI releases. Pin both the
10676 /// SDK and CLI versions if your code depends on it.
10677 ///
10678 /// </div>
10679 pub async fn get_enforcement_status(&self) -> Result<SandboxEnforcementStatus, Error> {
10680 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10681 let _value = self
10682 .session
10683 .client()
10684 .call(
10685 rpc_methods::SESSION_SANDBOX_GETENFORCEMENTSTATUS,
10686 Some(wire_params),
10687 )
10688 .await?;
10689 Ok(serde_json::from_value(_value)?)
10690 }
10691
10692 /// Disables sandboxing for the remainder of the current session and approves the referenced pending sandbox-bypass permission request. The request is rejected unless the exact request is still pending and the effective sandbox policy permits bypass.
10693 ///
10694 /// Wire method: `session.sandbox.disableForSession`.
10695 ///
10696 /// # Parameters
10697 ///
10698 /// * `params` - Request to disable sandboxing for the current session while resolving an active sandbox-bypass permission prompt.
10699 ///
10700 /// # Returns
10701 ///
10702 /// Result of attempting to disable sandboxing for the current session.
10703 ///
10704 /// <div class="warning">
10705 ///
10706 /// **Experimental.** This API is part of an experimental wire-protocol surface
10707 /// and may change or be removed in future SDK or CLI releases. Pin both the
10708 /// SDK and CLI versions if your code depends on it.
10709 ///
10710 /// </div>
10711 pub async fn disable_for_session(
10712 &self,
10713 params: SandboxDisableForSessionRequest,
10714 ) -> Result<SandboxDisableForSessionResult, Error> {
10715 let mut wire_params = serde_json::to_value(params)?;
10716 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10717 let _value = self
10718 .session
10719 .client()
10720 .call(
10721 rpc_methods::SESSION_SANDBOX_DISABLEFORSESSION,
10722 Some(wire_params),
10723 )
10724 .await?;
10725 Ok(serde_json::from_value(_value)?)
10726 }
10727}
10728
10729/// `session.schedule.*` RPCs.
10730#[derive(Clone, Copy)]
10731pub struct SessionRpcSchedule<'a> {
10732 pub(crate) session: &'a Session,
10733}
10734
10735impl<'a> SessionRpcSchedule<'a> {
10736 /// Lists the session's currently active scheduled prompts.
10737 ///
10738 /// Wire method: `session.schedule.list`.
10739 ///
10740 /// # Returns
10741 ///
10742 /// Snapshot of the currently active recurring prompts for this session.
10743 ///
10744 /// <div class="warning">
10745 ///
10746 /// **Experimental.** This API is part of an experimental wire-protocol surface
10747 /// and may change or be removed in future SDK or CLI releases. Pin both the
10748 /// SDK and CLI versions if your code depends on it.
10749 ///
10750 /// </div>
10751 pub async fn list(&self) -> Result<ScheduleList, Error> {
10752 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10753 let _value = self
10754 .session
10755 .client()
10756 .call(rpc_methods::SESSION_SCHEDULE_LIST, Some(wire_params))
10757 .await?;
10758 Ok(serde_json::from_value(_value)?)
10759 }
10760
10761 /// Hydrates the native schedule registry from persisted session events.
10762 ///
10763 /// Wire method: `session.schedule.hydrate`.
10764 ///
10765 /// <div class="warning">
10766 ///
10767 /// **Experimental.** This API is part of an experimental wire-protocol surface
10768 /// and may change or be removed in future SDK or CLI releases. Pin both the
10769 /// SDK and CLI versions if your code depends on it.
10770 ///
10771 /// </div>
10772 pub(crate) async fn hydrate(&self) -> Result<(), Error> {
10773 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10774 let _value = self
10775 .session
10776 .client()
10777 .call(rpc_methods::SESSION_SCHEDULE_HYDRATE, Some(wire_params))
10778 .await?;
10779 Ok(())
10780 }
10781
10782 /// Reports whether the session has an active self-paced scheduled prompt.
10783 ///
10784 /// Wire method: `session.schedule.hasSelfPaced`.
10785 ///
10786 /// # Returns
10787 ///
10788 /// Whether the session currently has an active self-paced schedule.
10789 ///
10790 /// <div class="warning">
10791 ///
10792 /// **Experimental.** This API is part of an experimental wire-protocol surface
10793 /// and may change or be removed in future SDK or CLI releases. Pin both the
10794 /// SDK and CLI versions if your code depends on it.
10795 ///
10796 /// </div>
10797 pub(crate) async fn has_self_paced(&self) -> Result<ScheduleHasSelfPacedResult, Error> {
10798 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10799 let _value = self
10800 .session
10801 .client()
10802 .call(
10803 rpc_methods::SESSION_SCHEDULE_HASSELFPACED,
10804 Some(wire_params),
10805 )
10806 .await?;
10807 Ok(serde_json::from_value(_value)?)
10808 }
10809
10810 /// Registers a relative-interval scheduled prompt.
10811 ///
10812 /// Wire method: `session.schedule.add`.
10813 ///
10814 /// # Parameters
10815 ///
10816 /// * `params` - Register a relative-interval scheduled prompt.
10817 ///
10818 /// # Returns
10819 ///
10820 /// Result of registering or re-arming a scheduled prompt.
10821 ///
10822 /// <div class="warning">
10823 ///
10824 /// **Experimental.** This API is part of an experimental wire-protocol surface
10825 /// and may change or be removed in future SDK or CLI releases. Pin both the
10826 /// SDK and CLI versions if your code depends on it.
10827 ///
10828 /// </div>
10829 pub(crate) async fn add(&self, params: ScheduleAddRequest) -> Result<ScheduleAddResult, Error> {
10830 let mut wire_params = serde_json::to_value(params)?;
10831 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10832 let _value = self
10833 .session
10834 .client()
10835 .call(rpc_methods::SESSION_SCHEDULE_ADD, Some(wire_params))
10836 .await?;
10837 Ok(serde_json::from_value(_value)?)
10838 }
10839
10840 /// Registers a recurring cron scheduled prompt.
10841 ///
10842 /// Wire method: `session.schedule.addCron`.
10843 ///
10844 /// # Parameters
10845 ///
10846 /// * `params` - Register a cron scheduled prompt.
10847 ///
10848 /// # Returns
10849 ///
10850 /// Result of registering or re-arming a scheduled prompt.
10851 ///
10852 /// <div class="warning">
10853 ///
10854 /// **Experimental.** This API is part of an experimental wire-protocol surface
10855 /// and may change or be removed in future SDK or CLI releases. Pin both the
10856 /// SDK and CLI versions if your code depends on it.
10857 ///
10858 /// </div>
10859 pub(crate) async fn add_cron(
10860 &self,
10861 params: ScheduleAddCronRequest,
10862 ) -> Result<ScheduleAddResult, Error> {
10863 let mut wire_params = serde_json::to_value(params)?;
10864 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10865 let _value = self
10866 .session
10867 .client()
10868 .call(rpc_methods::SESSION_SCHEDULE_ADDCRON, Some(wire_params))
10869 .await?;
10870 Ok(serde_json::from_value(_value)?)
10871 }
10872
10873 /// Registers an absolute-time scheduled prompt.
10874 ///
10875 /// Wire method: `session.schedule.addAt`.
10876 ///
10877 /// # Parameters
10878 ///
10879 /// * `params` - Register an absolute-time scheduled prompt.
10880 ///
10881 /// # Returns
10882 ///
10883 /// Result of registering or re-arming a scheduled prompt.
10884 ///
10885 /// <div class="warning">
10886 ///
10887 /// **Experimental.** This API is part of an experimental wire-protocol surface
10888 /// and may change or be removed in future SDK or CLI releases. Pin both the
10889 /// SDK and CLI versions if your code depends on it.
10890 ///
10891 /// </div>
10892 pub(crate) async fn add_at(
10893 &self,
10894 params: ScheduleAddAtRequest,
10895 ) -> Result<ScheduleAddResult, Error> {
10896 let mut wire_params = serde_json::to_value(params)?;
10897 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10898 let _value = self
10899 .session
10900 .client()
10901 .call(rpc_methods::SESSION_SCHEDULE_ADDAT, Some(wire_params))
10902 .await?;
10903 Ok(serde_json::from_value(_value)?)
10904 }
10905
10906 /// Registers a self-paced scheduled prompt.
10907 ///
10908 /// Wire method: `session.schedule.addSelfPaced`.
10909 ///
10910 /// # Parameters
10911 ///
10912 /// * `params` - Register a self-paced scheduled prompt.
10913 ///
10914 /// # Returns
10915 ///
10916 /// Result of registering or re-arming a scheduled prompt.
10917 ///
10918 /// <div class="warning">
10919 ///
10920 /// **Experimental.** This API is part of an experimental wire-protocol surface
10921 /// and may change or be removed in future SDK or CLI releases. Pin both the
10922 /// SDK and CLI versions if your code depends on it.
10923 ///
10924 /// </div>
10925 pub(crate) async fn add_self_paced(
10926 &self,
10927 params: ScheduleAddSelfPacedRequest,
10928 ) -> Result<ScheduleAddResult, Error> {
10929 let mut wire_params = serde_json::to_value(params)?;
10930 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10931 let _value = self
10932 .session
10933 .client()
10934 .call(
10935 rpc_methods::SESSION_SCHEDULE_ADDSELFPACED,
10936 Some(wire_params),
10937 )
10938 .await?;
10939 Ok(serde_json::from_value(_value)?)
10940 }
10941
10942 /// Re-arms an active self-paced scheduled prompt.
10943 ///
10944 /// Wire method: `session.schedule.rearmSelfPaced`.
10945 ///
10946 /// # Parameters
10947 ///
10948 /// * `params` - Re-arm a self-paced scheduled prompt.
10949 ///
10950 /// # Returns
10951 ///
10952 /// Result of registering or re-arming a scheduled prompt.
10953 ///
10954 /// <div class="warning">
10955 ///
10956 /// **Experimental.** This API is part of an experimental wire-protocol surface
10957 /// and may change or be removed in future SDK or CLI releases. Pin both the
10958 /// SDK and CLI versions if your code depends on it.
10959 ///
10960 /// </div>
10961 pub(crate) async fn rearm_self_paced(
10962 &self,
10963 params: ScheduleRearmSelfPacedRequest,
10964 ) -> Result<ScheduleAddResult, 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(
10971 rpc_methods::SESSION_SCHEDULE_REARMSELFPACED,
10972 Some(wire_params),
10973 )
10974 .await?;
10975 Ok(serde_json::from_value(_value)?)
10976 }
10977
10978 /// Removes a scheduled prompt by id.
10979 ///
10980 /// Wire method: `session.schedule.stop`.
10981 ///
10982 /// # Parameters
10983 ///
10984 /// * `params` - Identifier of the scheduled prompt to remove.
10985 ///
10986 /// # Returns
10987 ///
10988 /// Remove a scheduled prompt by id. The result entry is omitted if the id was unknown.
10989 ///
10990 /// <div class="warning">
10991 ///
10992 /// **Experimental.** This API is part of an experimental wire-protocol surface
10993 /// and may change or be removed in future SDK or CLI releases. Pin both the
10994 /// SDK and CLI versions if your code depends on it.
10995 ///
10996 /// </div>
10997 pub async fn stop(&self, params: ScheduleStopRequest) -> Result<ScheduleStopResult, 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(rpc_methods::SESSION_SCHEDULE_STOP, Some(wire_params))
11004 .await?;
11005 Ok(serde_json::from_value(_value)?)
11006 }
11007}
11008
11009/// `session.settings.*` RPCs.
11010#[derive(Clone, Copy)]
11011pub struct SessionRpcSettings<'a> {
11012 pub(crate) session: &'a Session,
11013}
11014
11015impl<'a> SessionRpcSettings<'a> {
11016 /// 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.
11017 ///
11018 /// Wire method: `session.settings.snapshot`.
11019 ///
11020 /// # Returns
11021 ///
11022 /// Redacted, serializable view of session runtime settings for SDK boundary consumers. Secrets and raw feature flags are intentionally excluded.
11023 ///
11024 /// <div class="warning">
11025 ///
11026 /// **Experimental.** This API is part of an experimental wire-protocol surface
11027 /// and may change or be removed in future SDK or CLI releases. Pin both the
11028 /// SDK and CLI versions if your code depends on it.
11029 ///
11030 /// </div>
11031 pub(crate) async fn snapshot(&self) -> Result<SessionSettingsSnapshot, Error> {
11032 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
11033 let _value = self
11034 .session
11035 .client()
11036 .call(rpc_methods::SESSION_SETTINGS_SNAPSHOT, Some(wire_params))
11037 .await?;
11038 Ok(serde_json::from_value(_value)?)
11039 }
11040
11041 /// 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.
11042 ///
11043 /// Wire method: `session.settings.evaluatePredicate`.
11044 ///
11045 /// # Parameters
11046 ///
11047 /// * `params` - Named Rust-owned settings predicate to evaluate for this session.
11048 ///
11049 /// # Returns
11050 ///
11051 /// Result of evaluating a Rust-owned settings predicate.
11052 ///
11053 /// <div class="warning">
11054 ///
11055 /// **Experimental.** This API is part of an experimental wire-protocol surface
11056 /// and may change or be removed in future SDK or CLI releases. Pin both the
11057 /// SDK and CLI versions if your code depends on it.
11058 ///
11059 /// </div>
11060 pub(crate) async fn evaluate_predicate(
11061 &self,
11062 params: SessionSettingsEvaluatePredicateRequest,
11063 ) -> Result<SessionSettingsEvaluatePredicateResult, Error> {
11064 let mut wire_params = serde_json::to_value(params)?;
11065 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11066 let _value = self
11067 .session
11068 .client()
11069 .call(
11070 rpc_methods::SESSION_SETTINGS_EVALUATEPREDICATE,
11071 Some(wire_params),
11072 )
11073 .await?;
11074 Ok(serde_json::from_value(_value)?)
11075 }
11076}
11077
11078/// `session.shell.*` RPCs.
11079#[derive(Clone, Copy)]
11080pub struct SessionRpcShell<'a> {
11081 pub(crate) session: &'a Session,
11082}
11083
11084impl<'a> SessionRpcShell<'a> {
11085 /// 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.
11086 ///
11087 /// Wire method: `session.shell.exec`.
11088 ///
11089 /// # Parameters
11090 ///
11091 /// * `params` - Shell command to run, with optional working directory and timeout in milliseconds.
11092 ///
11093 /// # Returns
11094 ///
11095 /// Identifier of the spawned process, used to correlate streamed output and exit notifications.
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 exec(&self, params: ShellExecRequest) -> Result<ShellExecResult, Error> {
11105 let mut wire_params = serde_json::to_value(params)?;
11106 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11107 let _value = self
11108 .session
11109 .client()
11110 .call(rpc_methods::SESSION_SHELL_EXEC, Some(wire_params))
11111 .await?;
11112 Ok(serde_json::from_value(_value)?)
11113 }
11114
11115 /// 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.
11116 ///
11117 /// Wire method: `session.shell.kill`.
11118 ///
11119 /// # Parameters
11120 ///
11121 /// * `params` - Identifier of a process previously returned by "shell.exec" and the signal to send.
11122 ///
11123 /// # Returns
11124 ///
11125 /// Indicates whether the signal was delivered; false if the process was unknown or already exited.
11126 ///
11127 /// <div class="warning">
11128 ///
11129 /// **Experimental.** This API is part of an experimental wire-protocol surface
11130 /// and may change or be removed in future SDK or CLI releases. Pin both the
11131 /// SDK and CLI versions if your code depends on it.
11132 ///
11133 /// </div>
11134 pub async fn kill(&self, params: ShellKillRequest) -> Result<ShellKillResult, Error> {
11135 let mut wire_params = serde_json::to_value(params)?;
11136 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11137 let _value = self
11138 .session
11139 .client()
11140 .call(rpc_methods::SESSION_SHELL_KILL, Some(wire_params))
11141 .await?;
11142 Ok(serde_json::from_value(_value)?)
11143 }
11144
11145 /// Executes a user-requested shell command through the session runtime.
11146 ///
11147 /// Wire method: `session.shell.executeUserRequested`.
11148 ///
11149 /// # Parameters
11150 ///
11151 /// * `params` - User-requested shell command and cancellation handle.
11152 ///
11153 /// # Returns
11154 ///
11155 /// Result of a user-requested shell command.
11156 ///
11157 /// <div class="warning">
11158 ///
11159 /// **Experimental.** This API is part of an experimental wire-protocol surface
11160 /// and may change or be removed in future SDK or CLI releases. Pin both the
11161 /// SDK and CLI versions if your code depends on it.
11162 ///
11163 /// </div>
11164 pub async fn execute_user_requested(
11165 &self,
11166 params: ShellExecuteUserRequestedRequest,
11167 ) -> Result<UserRequestedShellCommandResult, Error> {
11168 let mut wire_params = serde_json::to_value(params)?;
11169 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11170 let _value = self
11171 .session
11172 .client()
11173 .call(
11174 rpc_methods::SESSION_SHELL_EXECUTEUSERREQUESTED,
11175 Some(wire_params),
11176 )
11177 .await?;
11178 Ok(serde_json::from_value(_value)?)
11179 }
11180
11181 /// Cancels a user-requested shell command by request ID.
11182 ///
11183 /// Wire method: `session.shell.cancelUserRequested`.
11184 ///
11185 /// # Parameters
11186 ///
11187 /// * `params` - User-requested shell execution cancellation handle.
11188 ///
11189 /// # Returns
11190 ///
11191 /// Cancellation result for a user-requested shell command.
11192 ///
11193 /// <div class="warning">
11194 ///
11195 /// **Experimental.** This API is part of an experimental wire-protocol surface
11196 /// and may change or be removed in future SDK or CLI releases. Pin both the
11197 /// SDK and CLI versions if your code depends on it.
11198 ///
11199 /// </div>
11200 pub async fn cancel_user_requested(
11201 &self,
11202 params: ShellCancelUserRequestedRequest,
11203 ) -> Result<CancelUserRequestedShellCommandResult, Error> {
11204 let mut wire_params = serde_json::to_value(params)?;
11205 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11206 let _value = self
11207 .session
11208 .client()
11209 .call(
11210 rpc_methods::SESSION_SHELL_CANCELUSERREQUESTED,
11211 Some(wire_params),
11212 )
11213 .await?;
11214 Ok(serde_json::from_value(_value)?)
11215 }
11216}
11217
11218/// `session.skills.*` RPCs.
11219#[derive(Clone, Copy)]
11220pub struct SessionRpcSkills<'a> {
11221 pub(crate) session: &'a Session,
11222}
11223
11224impl<'a> SessionRpcSkills<'a> {
11225 /// Lists skills available to the session.
11226 ///
11227 /// Wire method: `session.skills.list`.
11228 ///
11229 /// # Returns
11230 ///
11231 /// Skills available to the session, with their enabled state.
11232 ///
11233 /// <div class="warning">
11234 ///
11235 /// **Experimental.** This API is part of an experimental wire-protocol surface
11236 /// and may change or be removed in future SDK or CLI releases. Pin both the
11237 /// SDK and CLI versions if your code depends on it.
11238 ///
11239 /// </div>
11240 pub async fn list(&self) -> Result<SkillList, Error> {
11241 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
11242 let _value = self
11243 .session
11244 .client()
11245 .call(rpc_methods::SESSION_SKILLS_LIST, Some(wire_params))
11246 .await?;
11247 Ok(serde_json::from_value(_value)?)
11248 }
11249
11250 /// Returns the skills that have been invoked during this session.
11251 ///
11252 /// Wire method: `session.skills.getInvoked`.
11253 ///
11254 /// # Returns
11255 ///
11256 /// Skills invoked during this session, ordered by invocation time (most recent last).
11257 ///
11258 /// <div class="warning">
11259 ///
11260 /// **Experimental.** This API is part of an experimental wire-protocol surface
11261 /// and may change or be removed in future SDK or CLI releases. Pin both the
11262 /// SDK and CLI versions if your code depends on it.
11263 ///
11264 /// </div>
11265 pub async fn get_invoked(&self) -> Result<SkillsGetInvokedResult, Error> {
11266 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
11267 let _value = self
11268 .session
11269 .client()
11270 .call(rpc_methods::SESSION_SKILLS_GETINVOKED, Some(wire_params))
11271 .await?;
11272 Ok(serde_json::from_value(_value)?)
11273 }
11274
11275 /// Enables a skill for the session.
11276 ///
11277 /// Wire method: `session.skills.enable`.
11278 ///
11279 /// # Parameters
11280 ///
11281 /// * `params` - Name of the skill to enable for the session.
11282 ///
11283 /// <div class="warning">
11284 ///
11285 /// **Experimental.** This API is part of an experimental wire-protocol surface
11286 /// and may change or be removed in future SDK or CLI releases. Pin both the
11287 /// SDK and CLI versions if your code depends on it.
11288 ///
11289 /// </div>
11290 pub async fn enable(&self, params: SkillsEnableRequest) -> Result<(), Error> {
11291 let mut wire_params = serde_json::to_value(params)?;
11292 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11293 let _value = self
11294 .session
11295 .client()
11296 .call(rpc_methods::SESSION_SKILLS_ENABLE, Some(wire_params))
11297 .await?;
11298 Ok(())
11299 }
11300
11301 /// Disables a skill for the session.
11302 ///
11303 /// Wire method: `session.skills.disable`.
11304 ///
11305 /// # Parameters
11306 ///
11307 /// * `params` - Name of the skill to disable for the session.
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 disable(&self, params: SkillsDisableRequest) -> Result<(), Error> {
11317 let mut wire_params = serde_json::to_value(params)?;
11318 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11319 let _value = self
11320 .session
11321 .client()
11322 .call(rpc_methods::SESSION_SKILLS_DISABLE, Some(wire_params))
11323 .await?;
11324 Ok(())
11325 }
11326
11327 /// Reloads skill definitions for the session.
11328 ///
11329 /// Wire method: `session.skills.reload`.
11330 ///
11331 /// # Returns
11332 ///
11333 /// Diagnostics from reloading skill definitions, with warnings and errors as separate lists.
11334 ///
11335 /// <div class="warning">
11336 ///
11337 /// **Experimental.** This API is part of an experimental wire-protocol surface
11338 /// and may change or be removed in future SDK or CLI releases. Pin both the
11339 /// SDK and CLI versions if your code depends on it.
11340 ///
11341 /// </div>
11342 pub async fn reload(&self) -> Result<SkillsLoadDiagnostics, Error> {
11343 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
11344 let _value = self
11345 .session
11346 .client()
11347 .call(rpc_methods::SESSION_SKILLS_RELOAD, Some(wire_params))
11348 .await?;
11349 Ok(serde_json::from_value(_value)?)
11350 }
11351
11352 /// Ensures the session's skill definitions have been loaded from disk.
11353 ///
11354 /// Wire method: `session.skills.ensureLoaded`.
11355 ///
11356 /// <div class="warning">
11357 ///
11358 /// **Experimental.** This API is part of an experimental wire-protocol surface
11359 /// and may change or be removed in future SDK or CLI releases. Pin both the
11360 /// SDK and CLI versions if your code depends on it.
11361 ///
11362 /// </div>
11363 pub async fn ensure_loaded(&self) -> Result<(), Error> {
11364 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
11365 let _value = self
11366 .session
11367 .client()
11368 .call(rpc_methods::SESSION_SKILLS_ENSURELOADED, Some(wire_params))
11369 .await?;
11370 Ok(())
11371 }
11372}
11373
11374/// `session.tasks.*` RPCs.
11375#[derive(Clone, Copy)]
11376pub struct SessionRpcTasks<'a> {
11377 pub(crate) session: &'a Session,
11378}
11379
11380impl<'a> SessionRpcTasks<'a> {
11381 /// Starts a background agent task in the session.
11382 ///
11383 /// Wire method: `session.tasks.startAgent`.
11384 ///
11385 /// # Parameters
11386 ///
11387 /// * `params` - Agent type, prompt, name, and optional description and model override for the new task.
11388 ///
11389 /// # Returns
11390 ///
11391 /// Identifier assigned to the newly started background agent task.
11392 ///
11393 /// <div class="warning">
11394 ///
11395 /// **Experimental.** This API is part of an experimental wire-protocol surface
11396 /// and may change or be removed in future SDK or CLI releases. Pin both the
11397 /// SDK and CLI versions if your code depends on it.
11398 ///
11399 /// </div>
11400 pub async fn start_agent(
11401 &self,
11402 params: TasksStartAgentRequest,
11403 ) -> Result<TasksStartAgentResult, Error> {
11404 let mut wire_params = serde_json::to_value(params)?;
11405 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11406 let _value = self
11407 .session
11408 .client()
11409 .call(rpc_methods::SESSION_TASKS_STARTAGENT, Some(wire_params))
11410 .await?;
11411 Ok(serde_json::from_value(_value)?)
11412 }
11413
11414 /// Lists background tasks tracked by the session.
11415 ///
11416 /// Wire method: `session.tasks.list`.
11417 ///
11418 /// # Returns
11419 ///
11420 /// Background tasks currently tracked by the session.
11421 ///
11422 /// <div class="warning">
11423 ///
11424 /// **Experimental.** This API is part of an experimental wire-protocol surface
11425 /// and may change or be removed in future SDK or CLI releases. Pin both the
11426 /// SDK and CLI versions if your code depends on it.
11427 ///
11428 /// </div>
11429 pub async fn list(&self) -> Result<TaskList, Error> {
11430 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
11431 let _value = self
11432 .session
11433 .client()
11434 .call(rpc_methods::SESSION_TASKS_LIST, Some(wire_params))
11435 .await?;
11436 Ok(serde_json::from_value(_value)?)
11437 }
11438
11439 /// Registers a client-owned task, or reclaims an orphaned task belonging to the same extension principal.
11440 ///
11441 /// Wire method: `session.tasks.register`.
11442 ///
11443 /// # Parameters
11444 ///
11445 /// * `params` - Registers or reclaims a client-owned task.
11446 ///
11447 /// # Returns
11448 ///
11449 /// Result of registering or reclaiming a client-owned task.
11450 ///
11451 /// <div class="warning">
11452 ///
11453 /// **Experimental.** This API is part of an experimental wire-protocol surface
11454 /// and may change or be removed in future SDK or CLI releases. Pin both the
11455 /// SDK and CLI versions if your code depends on it.
11456 ///
11457 /// </div>
11458 pub async fn register(
11459 &self,
11460 params: TasksRegisterRequest,
11461 ) -> Result<TasksRegisterResult, Error> {
11462 let mut wire_params = serde_json::to_value(params)?;
11463 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11464 let _value = self
11465 .session
11466 .client()
11467 .call(rpc_methods::SESSION_TASKS_REGISTER, Some(wire_params))
11468 .await?;
11469 Ok(serde_json::from_value(_value)?)
11470 }
11471
11472 /// Publishes generic progress or a terminal outcome for a client-owned task.
11473 ///
11474 /// Wire method: `session.tasks.update`.
11475 ///
11476 /// # Parameters
11477 ///
11478 /// * `params` - Updates a client-owned task.
11479 ///
11480 /// # Returns
11481 ///
11482 /// Result of publishing a client-owned task update.
11483 ///
11484 /// <div class="warning">
11485 ///
11486 /// **Experimental.** This API is part of an experimental wire-protocol surface
11487 /// and may change or be removed in future SDK or CLI releases. Pin both the
11488 /// SDK and CLI versions if your code depends on it.
11489 ///
11490 /// </div>
11491 pub async fn update(&self, params: TasksUpdateRequest) -> Result<TasksUpdateResult, Error> {
11492 let mut wire_params = serde_json::to_value(params)?;
11493 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11494 let _value = self
11495 .session
11496 .client()
11497 .call(rpc_methods::SESSION_TASKS_UPDATE, Some(wire_params))
11498 .await?;
11499 Ok(serde_json::from_value(_value)?)
11500 }
11501
11502 /// Refreshes metadata for any detached background shells the runtime knows about.
11503 ///
11504 /// Wire method: `session.tasks.refresh`.
11505 ///
11506 /// # Returns
11507 ///
11508 /// 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.
11509 ///
11510 /// <div class="warning">
11511 ///
11512 /// **Experimental.** This API is part of an experimental wire-protocol surface
11513 /// and may change or be removed in future SDK or CLI releases. Pin both the
11514 /// SDK and CLI versions if your code depends on it.
11515 ///
11516 /// </div>
11517 pub async fn refresh(&self) -> Result<TasksRefreshResult, Error> {
11518 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
11519 let _value = self
11520 .session
11521 .client()
11522 .call(rpc_methods::SESSION_TASKS_REFRESH, Some(wire_params))
11523 .await?;
11524 Ok(serde_json::from_value(_value)?)
11525 }
11526
11527 /// Waits for all in-flight background tasks and any follow-up turns to settle.
11528 ///
11529 /// Wire method: `session.tasks.waitForPending`.
11530 ///
11531 /// # Returns
11532 ///
11533 /// 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).
11534 ///
11535 /// <div class="warning">
11536 ///
11537 /// **Experimental.** This API is part of an experimental wire-protocol surface
11538 /// and may change or be removed in future SDK or CLI releases. Pin both the
11539 /// SDK and CLI versions if your code depends on it.
11540 ///
11541 /// </div>
11542 pub async fn wait_for_pending(&self) -> Result<TasksWaitForPendingResult, Error> {
11543 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
11544 let _value = self
11545 .session
11546 .client()
11547 .call(rpc_methods::SESSION_TASKS_WAITFORPENDING, Some(wire_params))
11548 .await?;
11549 Ok(serde_json::from_value(_value)?)
11550 }
11551
11552 /// Returns progress information for a background task by ID.
11553 ///
11554 /// Wire method: `session.tasks.getProgress`.
11555 ///
11556 /// # Parameters
11557 ///
11558 /// * `params` - Identifier of the background task to fetch progress for.
11559 ///
11560 /// # Returns
11561 ///
11562 /// Progress information for the task, or null when no task with that ID is tracked.
11563 ///
11564 /// <div class="warning">
11565 ///
11566 /// **Experimental.** This API is part of an experimental wire-protocol surface
11567 /// and may change or be removed in future SDK or CLI releases. Pin both the
11568 /// SDK and CLI versions if your code depends on it.
11569 ///
11570 /// </div>
11571 pub async fn get_progress(
11572 &self,
11573 params: TasksGetProgressRequest,
11574 ) -> Result<TasksGetProgressResult, Error> {
11575 let mut wire_params = serde_json::to_value(params)?;
11576 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11577 let _value = self
11578 .session
11579 .client()
11580 .call(rpc_methods::SESSION_TASKS_GETPROGRESS, Some(wire_params))
11581 .await?;
11582 Ok(serde_json::from_value(_value)?)
11583 }
11584
11585 /// Returns the first sync-waiting task that can currently be promoted to background mode.
11586 ///
11587 /// Wire method: `session.tasks.getCurrentPromotable`.
11588 ///
11589 /// # Returns
11590 ///
11591 /// The first sync-waiting task that can currently be promoted to background mode.
11592 ///
11593 /// <div class="warning">
11594 ///
11595 /// **Experimental.** This API is part of an experimental wire-protocol surface
11596 /// and may change or be removed in future SDK or CLI releases. Pin both the
11597 /// SDK and CLI versions if your code depends on it.
11598 ///
11599 /// </div>
11600 pub async fn get_current_promotable(&self) -> Result<TasksGetCurrentPromotableResult, Error> {
11601 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
11602 let _value = self
11603 .session
11604 .client()
11605 .call(
11606 rpc_methods::SESSION_TASKS_GETCURRENTPROMOTABLE,
11607 Some(wire_params),
11608 )
11609 .await?;
11610 Ok(serde_json::from_value(_value)?)
11611 }
11612
11613 /// Promotes an eligible synchronously-waited task so it continues running in the background.
11614 ///
11615 /// Wire method: `session.tasks.promoteToBackground`.
11616 ///
11617 /// # Parameters
11618 ///
11619 /// * `params` - Identifier of the task to promote to background mode.
11620 ///
11621 /// # Returns
11622 ///
11623 /// Indicates whether the task was successfully promoted to background mode.
11624 ///
11625 /// <div class="warning">
11626 ///
11627 /// **Experimental.** This API is part of an experimental wire-protocol surface
11628 /// and may change or be removed in future SDK or CLI releases. Pin both the
11629 /// SDK and CLI versions if your code depends on it.
11630 ///
11631 /// </div>
11632 pub async fn promote_to_background(
11633 &self,
11634 params: TasksPromoteToBackgroundRequest,
11635 ) -> Result<TasksPromoteToBackgroundResult, Error> {
11636 let mut wire_params = serde_json::to_value(params)?;
11637 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11638 let _value = self
11639 .session
11640 .client()
11641 .call(
11642 rpc_methods::SESSION_TASKS_PROMOTETOBACKGROUND,
11643 Some(wire_params),
11644 )
11645 .await?;
11646 Ok(serde_json::from_value(_value)?)
11647 }
11648
11649 /// Atomically promotes the first promotable sync-waiting task to background mode and returns it.
11650 ///
11651 /// Wire method: `session.tasks.promoteCurrentToBackground`.
11652 ///
11653 /// # Returns
11654 ///
11655 /// The promoted task as it now exists in background mode, omitted if no promotable task was waiting.
11656 ///
11657 /// <div class="warning">
11658 ///
11659 /// **Experimental.** This API is part of an experimental wire-protocol surface
11660 /// and may change or be removed in future SDK or CLI releases. Pin both the
11661 /// SDK and CLI versions if your code depends on it.
11662 ///
11663 /// </div>
11664 pub async fn promote_current_to_background(
11665 &self,
11666 ) -> Result<TasksPromoteCurrentToBackgroundResult, Error> {
11667 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
11668 let _value = self
11669 .session
11670 .client()
11671 .call(
11672 rpc_methods::SESSION_TASKS_PROMOTECURRENTTOBACKGROUND,
11673 Some(wire_params),
11674 )
11675 .await?;
11676 Ok(serde_json::from_value(_value)?)
11677 }
11678
11679 /// Cancels a background task.
11680 ///
11681 /// Wire method: `session.tasks.cancel`.
11682 ///
11683 /// # Parameters
11684 ///
11685 /// * `params` - Identifier of the background task to cancel.
11686 ///
11687 /// # Returns
11688 ///
11689 /// Indicates whether the background task was successfully cancelled.
11690 ///
11691 /// <div class="warning">
11692 ///
11693 /// **Experimental.** This API is part of an experimental wire-protocol surface
11694 /// and may change or be removed in future SDK or CLI releases. Pin both the
11695 /// SDK and CLI versions if your code depends on it.
11696 ///
11697 /// </div>
11698 pub async fn cancel(&self, params: TasksCancelRequest) -> Result<TasksCancelResult, Error> {
11699 let mut wire_params = serde_json::to_value(params)?;
11700 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11701 let _value = self
11702 .session
11703 .client()
11704 .call(rpc_methods::SESSION_TASKS_CANCEL, Some(wire_params))
11705 .await?;
11706 Ok(serde_json::from_value(_value)?)
11707 }
11708
11709 /// Removes a completed or cancelled background task from tracking.
11710 ///
11711 /// Wire method: `session.tasks.remove`.
11712 ///
11713 /// # Parameters
11714 ///
11715 /// * `params` - Identifier of the completed or cancelled task to remove from tracking.
11716 ///
11717 /// # Returns
11718 ///
11719 /// Indicates whether the task was removed. False when the task does not exist or is still running/idle.
11720 ///
11721 /// <div class="warning">
11722 ///
11723 /// **Experimental.** This API is part of an experimental wire-protocol surface
11724 /// and may change or be removed in future SDK or CLI releases. Pin both the
11725 /// SDK and CLI versions if your code depends on it.
11726 ///
11727 /// </div>
11728 pub async fn remove(&self, params: TasksRemoveRequest) -> Result<TasksRemoveResult, Error> {
11729 let mut wire_params = serde_json::to_value(params)?;
11730 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11731 let _value = self
11732 .session
11733 .client()
11734 .call(rpc_methods::SESSION_TASKS_REMOVE, Some(wire_params))
11735 .await?;
11736 Ok(serde_json::from_value(_value)?)
11737 }
11738
11739 /// Sends a message to a background agent task.
11740 ///
11741 /// Wire method: `session.tasks.sendMessage`.
11742 ///
11743 /// # Parameters
11744 ///
11745 /// * `params` - Identifier of the target agent task, message content, and optional sender agent ID.
11746 ///
11747 /// # Returns
11748 ///
11749 /// Indicates whether the message was delivered, with an error message when delivery failed.
11750 ///
11751 /// <div class="warning">
11752 ///
11753 /// **Experimental.** This API is part of an experimental wire-protocol surface
11754 /// and may change or be removed in future SDK or CLI releases. Pin both the
11755 /// SDK and CLI versions if your code depends on it.
11756 ///
11757 /// </div>
11758 pub async fn send_message(
11759 &self,
11760 params: TasksSendMessageRequest,
11761 ) -> Result<TasksSendMessageResult, Error> {
11762 let mut wire_params = serde_json::to_value(params)?;
11763 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11764 let _value = self
11765 .session
11766 .client()
11767 .call(rpc_methods::SESSION_TASKS_SENDMESSAGE, Some(wire_params))
11768 .await?;
11769 Ok(serde_json::from_value(_value)?)
11770 }
11771}
11772
11773/// `session.telemetry.*` RPCs.
11774#[derive(Clone, Copy)]
11775pub struct SessionRpcTelemetry<'a> {
11776 pub(crate) session: &'a Session,
11777}
11778
11779impl<'a> SessionRpcTelemetry<'a> {
11780 /// Gets the telemetry engagement ID currently associated with the session, when available.
11781 ///
11782 /// Wire method: `session.telemetry.getEngagementId`.
11783 ///
11784 /// # Returns
11785 ///
11786 /// Telemetry engagement ID for the session, when available.
11787 ///
11788 /// <div class="warning">
11789 ///
11790 /// **Experimental.** This API is part of an experimental wire-protocol surface
11791 /// and may change or be removed in future SDK or CLI releases. Pin both the
11792 /// SDK and CLI versions if your code depends on it.
11793 ///
11794 /// </div>
11795 pub async fn get_engagement_id(&self) -> Result<SessionTelemetryEngagement, Error> {
11796 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
11797 let _value = self
11798 .session
11799 .client()
11800 .call(
11801 rpc_methods::SESSION_TELEMETRY_GETENGAGEMENTID,
11802 Some(wire_params),
11803 )
11804 .await?;
11805 Ok(serde_json::from_value(_value)?)
11806 }
11807
11808 /// Sets feature override key/value pairs to attach to subsequent telemetry events for the session.
11809 ///
11810 /// Wire method: `session.telemetry.setFeatureOverrides`.
11811 ///
11812 /// # Parameters
11813 ///
11814 /// * `params` - Feature override key/value pairs to attach to subsequent telemetry events from this session.
11815 ///
11816 /// <div class="warning">
11817 ///
11818 /// **Experimental.** This API is part of an experimental wire-protocol surface
11819 /// and may change or be removed in future SDK or CLI releases. Pin both the
11820 /// SDK and CLI versions if your code depends on it.
11821 ///
11822 /// </div>
11823 pub async fn set_feature_overrides(
11824 &self,
11825 params: TelemetrySetFeatureOverridesRequest,
11826 ) -> Result<(), Error> {
11827 let mut wire_params = serde_json::to_value(params)?;
11828 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11829 let _value = self
11830 .session
11831 .client()
11832 .call(
11833 rpc_methods::SESSION_TELEMETRY_SETFEATUREOVERRIDES,
11834 Some(wire_params),
11835 )
11836 .await?;
11837 Ok(())
11838 }
11839}
11840
11841/// `session.tools.*` RPCs.
11842#[derive(Clone, Copy)]
11843pub struct SessionRpcTools<'a> {
11844 pub(crate) session: &'a Session,
11845}
11846
11847impl<'a> SessionRpcTools<'a> {
11848 /// Executes one tool from the session's currently offered tool set through the native invocation pipeline.
11849 ///
11850 /// Wire method: `session.tools.execute`.
11851 ///
11852 /// # Parameters
11853 ///
11854 /// * `params` - A tool name and arguments to execute through the session's native invocation pipeline.
11855 ///
11856 /// # Returns
11857 ///
11858 /// Canonical result returned by a session tool.
11859 ///
11860 /// <div class="warning">
11861 ///
11862 /// **Experimental.** This API is part of an experimental wire-protocol surface
11863 /// and may change or be removed in future SDK or CLI releases. Pin both the
11864 /// SDK and CLI versions if your code depends on it.
11865 ///
11866 /// </div>
11867 pub async fn execute(&self, params: ToolsExecuteRequest) -> Result<ToolResult, Error> {
11868 let mut wire_params = serde_json::to_value(params)?;
11869 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11870 let _value = self
11871 .session
11872 .client()
11873 .call(rpc_methods::SESSION_TOOLS_EXECUTE, Some(wire_params))
11874 .await?;
11875 Ok(serde_json::from_value(_value)?)
11876 }
11877
11878 /// Returns the Rust-owned built-in tool descriptors used to construct the session's offered tool set.
11879 ///
11880 /// Wire method: `session.tools.getBuiltinDescriptors`.
11881 ///
11882 /// # Parameters
11883 ///
11884 /// * `params` - Options controlling how Rust-owned built-in tool descriptors are materialized.
11885 ///
11886 /// # Returns
11887 ///
11888 /// Rust-owned built-in tool descriptors for the session.
11889 ///
11890 /// <div class="warning">
11891 ///
11892 /// **Experimental.** This API is part of an experimental wire-protocol surface
11893 /// and may change or be removed in future SDK or CLI releases. Pin both the
11894 /// SDK and CLI versions if your code depends on it.
11895 ///
11896 /// </div>
11897 pub async fn get_builtin_descriptors(
11898 &self,
11899 params: ToolsGetBuiltinDescriptorsRequest,
11900 ) -> Result<ToolsGetBuiltinDescriptorsResult, Error> {
11901 let mut wire_params = serde_json::to_value(params)?;
11902 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11903 let _value = self
11904 .session
11905 .client()
11906 .call(
11907 rpc_methods::SESSION_TOOLS_GETBUILTINDESCRIPTORS,
11908 Some(wire_params),
11909 )
11910 .await?;
11911 Ok(serde_json::from_value(_value)?)
11912 }
11913
11914 /// Projects a completed task_complete tool call into its label-safe session event payload.
11915 ///
11916 /// Wire method: `session.tools.taskCompleteEventData`.
11917 ///
11918 /// # Parameters
11919 ///
11920 /// * `params` - Task-completion tool arguments and final result used to build a label-safe session event payload.
11921 ///
11922 /// # Returns
11923 ///
11924 /// Task completion notification with summary from the agent
11925 ///
11926 /// <div class="warning">
11927 ///
11928 /// **Experimental.** This API is part of an experimental wire-protocol surface
11929 /// and may change or be removed in future SDK or CLI releases. Pin both the
11930 /// SDK and CLI versions if your code depends on it.
11931 ///
11932 /// </div>
11933 pub async fn task_complete_event_data(
11934 &self,
11935 params: ToolsTaskCompleteEventDataRequest,
11936 ) -> Result<TaskCompleteData, Error> {
11937 let mut wire_params = serde_json::to_value(params)?;
11938 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
11939 let _value = self
11940 .session
11941 .client()
11942 .call(
11943 rpc_methods::SESSION_TOOLS_TASKCOMPLETEEVENTDATA,
11944 Some(wire_params),
11945 )
11946 .await?;
11947 Ok(serde_json::from_value(_value)?)
11948 }
11949
11950 /// Provides the result for a pending external tool call.
11951 ///
11952 /// Wire method: `session.tools.handlePendingToolCall`.
11953 ///
11954 /// # Parameters
11955 ///
11956 /// * `params` - Pending external tool call request ID, with the tool result or an error describing why it failed.
11957 ///
11958 /// # Returns
11959 ///
11960 /// Indicates whether the external tool call result was handled successfully.
11961 ///
11962 /// <div class="warning">
11963 ///
11964 /// **Experimental.** This API is part of an experimental wire-protocol surface
11965 /// and may change or be removed in future SDK or CLI releases. Pin both the
11966 /// SDK and CLI versions if your code depends on it.
11967 ///
11968 /// </div>
11969 pub async fn handle_pending_tool_call(
11970 &self,
11971 params: HandlePendingToolCallRequest,
11972 ) -> Result<HandlePendingToolCallResult, 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(
11979 rpc_methods::SESSION_TOOLS_HANDLEPENDINGTOOLCALL,
11980 Some(wire_params),
11981 )
11982 .await?;
11983 Ok(serde_json::from_value(_value)?)
11984 }
11985
11986 /// Resolves, builds, and validates the runtime tool list for the session.
11987 ///
11988 /// Wire method: `session.tools.initializeAndValidate`.
11989 ///
11990 /// # Returns
11991 ///
11992 /// 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.
11993 ///
11994 /// <div class="warning">
11995 ///
11996 /// **Experimental.** This API is part of an experimental wire-protocol surface
11997 /// and may change or be removed in future SDK or CLI releases. Pin both the
11998 /// SDK and CLI versions if your code depends on it.
11999 ///
12000 /// </div>
12001 pub async fn initialize_and_validate(&self) -> Result<ToolsInitializeAndValidateResult, Error> {
12002 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
12003 let _value = self
12004 .session
12005 .client()
12006 .call(
12007 rpc_methods::SESSION_TOOLS_INITIALIZEANDVALIDATE,
12008 Some(wire_params),
12009 )
12010 .await?;
12011 Ok(serde_json::from_value(_value)?)
12012 }
12013
12014 /// Returns lightweight metadata for the session's currently initialized tools.
12015 ///
12016 /// Wire method: `session.tools.getCurrentMetadata`.
12017 ///
12018 /// # Returns
12019 ///
12020 /// Current lightweight tool metadata snapshot for the session.
12021 ///
12022 /// <div class="warning">
12023 ///
12024 /// **Experimental.** This API is part of an experimental wire-protocol surface
12025 /// and may change or be removed in future SDK or CLI releases. Pin both the
12026 /// SDK and CLI versions if your code depends on it.
12027 ///
12028 /// </div>
12029 pub async fn get_current_metadata(&self) -> Result<ToolsGetCurrentMetadataResult, Error> {
12030 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
12031 let _value = self
12032 .session
12033 .client()
12034 .call(
12035 rpc_methods::SESSION_TOOLS_GETCURRENTMETADATA,
12036 Some(wire_params),
12037 )
12038 .await?;
12039 Ok(serde_json::from_value(_value)?)
12040 }
12041
12042 /// 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.
12043 ///
12044 /// Wire method: `session.tools.set`.
12045 ///
12046 /// # Parameters
12047 ///
12048 /// * `params` - Complete externally implemented tool list for the calling connection. An empty list removes every tool previously supplied by that connection.
12049 ///
12050 /// # Returns
12051 ///
12052 /// Empty result after replacing the calling connection's externally implemented tools.
12053 ///
12054 /// <div class="warning">
12055 ///
12056 /// **Experimental.** This API is part of an experimental wire-protocol surface
12057 /// and may change or be removed in future SDK or CLI releases. Pin both the
12058 /// SDK and CLI versions if your code depends on it.
12059 ///
12060 /// </div>
12061 pub async fn set(&self, params: ToolsSetRequest) -> Result<ToolsSetResult, Error> {
12062 let mut wire_params = serde_json::to_value(params)?;
12063 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
12064 let _value = self
12065 .session
12066 .client()
12067 .call(rpc_methods::SESSION_TOOLS_SET, Some(wire_params))
12068 .await?;
12069 Ok(serde_json::from_value(_value)?)
12070 }
12071
12072 /// Sets the current session's live subagent settings override, which takes precedence over persisted user settings until cleared. Persisted user settings remain the source of truth for future sessions.
12073 ///
12074 /// Wire method: `session.tools.updateSubagentSettings`.
12075 ///
12076 /// # Parameters
12077 ///
12078 /// * `params` - Subagent settings to apply to the current session
12079 ///
12080 /// # Returns
12081 ///
12082 /// Empty result after applying subagent settings
12083 ///
12084 /// <div class="warning">
12085 ///
12086 /// **Experimental.** This API is part of an experimental wire-protocol surface
12087 /// and may change or be removed in future SDK or CLI releases. Pin both the
12088 /// SDK and CLI versions if your code depends on it.
12089 ///
12090 /// </div>
12091 pub async fn update_subagent_settings(
12092 &self,
12093 params: UpdateSubagentSettingsRequest,
12094 ) -> Result<ToolsUpdateSubagentSettingsResult, Error> {
12095 let mut wire_params = serde_json::to_value(params)?;
12096 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
12097 let _value = self
12098 .session
12099 .client()
12100 .call(
12101 rpc_methods::SESSION_TOOLS_UPDATESUBAGENTSETTINGS,
12102 Some(wire_params),
12103 )
12104 .await?;
12105 Ok(serde_json::from_value(_value)?)
12106 }
12107}
12108
12109/// `session.ui.*` RPCs.
12110#[derive(Clone, Copy)]
12111pub struct SessionRpcUi<'a> {
12112 pub(crate) session: &'a Session,
12113}
12114
12115impl<'a> SessionRpcUi<'a> {
12116 /// Runs a transient no-tools model query against the current conversation context.
12117 ///
12118 /// Wire method: `session.ui.ephemeralQuery`.
12119 ///
12120 /// # Parameters
12121 ///
12122 /// * `params` - Transient question to answer without adding it to conversation history.
12123 ///
12124 /// # Returns
12125 ///
12126 /// Completed transient query. Ordered chunks and the terminal outcome are also delivered through `ui.ephemeral_query` session events while it runs.
12127 ///
12128 /// <div class="warning">
12129 ///
12130 /// **Experimental.** This API is part of an experimental wire-protocol surface
12131 /// and may change or be removed in future SDK or CLI releases. Pin both the
12132 /// SDK and CLI versions if your code depends on it.
12133 ///
12134 /// </div>
12135 pub async fn ephemeral_query(
12136 &self,
12137 params: UIEphemeralQueryRequest,
12138 ) -> Result<UIEphemeralQueryResult, Error> {
12139 let mut wire_params = serde_json::to_value(params)?;
12140 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
12141 let _value = self
12142 .session
12143 .client()
12144 .call(rpc_methods::SESSION_UI_EPHEMERALQUERY, Some(wire_params))
12145 .await?;
12146 Ok(serde_json::from_value(_value)?)
12147 }
12148
12149 /// Requests structured input from a UI-capable client.
12150 ///
12151 /// Wire method: `session.ui.elicitation`.
12152 ///
12153 /// # Parameters
12154 ///
12155 /// * `params` - Prompt message and JSON schema describing the form fields to elicit from the user.
12156 ///
12157 /// # Returns
12158 ///
12159 /// The elicitation response (accept with form values, decline, or cancel)
12160 ///
12161 /// <div class="warning">
12162 ///
12163 /// **Experimental.** This API is part of an experimental wire-protocol surface
12164 /// and may change or be removed in future SDK or CLI releases. Pin both the
12165 /// SDK and CLI versions if your code depends on it.
12166 ///
12167 /// </div>
12168 pub async fn elicitation(
12169 &self,
12170 params: UIElicitationRequest,
12171 ) -> Result<UIElicitationResponse, Error> {
12172 let mut wire_params = serde_json::to_value(params)?;
12173 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
12174 let _value = self
12175 .session
12176 .client()
12177 .call(rpc_methods::SESSION_UI_ELICITATION, Some(wire_params))
12178 .await?;
12179 Ok(serde_json::from_value(_value)?)
12180 }
12181
12182 /// Provides the user response for a pending elicitation request.
12183 ///
12184 /// Wire method: `session.ui.handlePendingElicitation`.
12185 ///
12186 /// # Parameters
12187 ///
12188 /// * `params` - Pending elicitation request ID and the user's response (accept/decline/cancel + form values).
12189 ///
12190 /// # Returns
12191 ///
12192 /// Indicates whether the elicitation response was accepted; false if it was already resolved by another client.
12193 ///
12194 /// <div class="warning">
12195 ///
12196 /// **Experimental.** This API is part of an experimental wire-protocol surface
12197 /// and may change or be removed in future SDK or CLI releases. Pin both the
12198 /// SDK and CLI versions if your code depends on it.
12199 ///
12200 /// </div>
12201 pub async fn handle_pending_elicitation(
12202 &self,
12203 params: UIHandlePendingElicitationRequest,
12204 ) -> Result<UIElicitationResult, Error> {
12205 let mut wire_params = serde_json::to_value(params)?;
12206 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
12207 let _value = self
12208 .session
12209 .client()
12210 .call(
12211 rpc_methods::SESSION_UI_HANDLEPENDINGELICITATION,
12212 Some(wire_params),
12213 )
12214 .await?;
12215 Ok(serde_json::from_value(_value)?)
12216 }
12217
12218 /// Resolves a pending `user_input.requested` event with the user's response.
12219 ///
12220 /// Wire method: `session.ui.handlePendingUserInput`.
12221 ///
12222 /// # Parameters
12223 ///
12224 /// * `params` - Request ID of a pending `user_input.requested` event and the user's response.
12225 ///
12226 /// # Returns
12227 ///
12228 /// Indicates whether the pending UI request was resolved by this call.
12229 ///
12230 /// <div class="warning">
12231 ///
12232 /// **Experimental.** This API is part of an experimental wire-protocol surface
12233 /// and may change or be removed in future SDK or CLI releases. Pin both the
12234 /// SDK and CLI versions if your code depends on it.
12235 ///
12236 /// </div>
12237 pub async fn handle_pending_user_input(
12238 &self,
12239 params: UIHandlePendingUserInputRequest,
12240 ) -> Result<UIHandlePendingResult, Error> {
12241 let mut wire_params = serde_json::to_value(params)?;
12242 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
12243 let _value = self
12244 .session
12245 .client()
12246 .call(
12247 rpc_methods::SESSION_UI_HANDLEPENDINGUSERINPUT,
12248 Some(wire_params),
12249 )
12250 .await?;
12251 Ok(serde_json::from_value(_value)?)
12252 }
12253
12254 /// Resolves a pending `sampling.requested` event with a sampling result, or rejects it.
12255 ///
12256 /// Wire method: `session.ui.handlePendingSampling`.
12257 ///
12258 /// # Parameters
12259 ///
12260 /// * `params` - Request ID of a pending `sampling.requested` event and an optional sampling result payload (omit to reject).
12261 ///
12262 /// # Returns
12263 ///
12264 /// Indicates whether the pending UI request was resolved by this call.
12265 ///
12266 /// <div class="warning">
12267 ///
12268 /// **Experimental.** This API is part of an experimental wire-protocol surface
12269 /// and may change or be removed in future SDK or CLI releases. Pin both the
12270 /// SDK and CLI versions if your code depends on it.
12271 ///
12272 /// </div>
12273 pub async fn handle_pending_sampling(
12274 &self,
12275 params: UIHandlePendingSamplingRequest,
12276 ) -> Result<UIHandlePendingResult, Error> {
12277 let mut wire_params = serde_json::to_value(params)?;
12278 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
12279 let _value = self
12280 .session
12281 .client()
12282 .call(
12283 rpc_methods::SESSION_UI_HANDLEPENDINGSAMPLING,
12284 Some(wire_params),
12285 )
12286 .await?;
12287 Ok(serde_json::from_value(_value)?)
12288 }
12289
12290 /// Resolves a pending `auto_mode_switch.requested` event with the user's accept/decline decision.
12291 ///
12292 /// Wire method: `session.ui.handlePendingAutoModeSwitch`.
12293 ///
12294 /// # Parameters
12295 ///
12296 /// * `params` - Request ID of a pending `auto_mode_switch.requested` event and the user's response.
12297 ///
12298 /// # Returns
12299 ///
12300 /// Indicates whether the pending UI request was resolved by this call.
12301 ///
12302 /// <div class="warning">
12303 ///
12304 /// **Experimental.** This API is part of an experimental wire-protocol surface
12305 /// and may change or be removed in future SDK or CLI releases. Pin both the
12306 /// SDK and CLI versions if your code depends on it.
12307 ///
12308 /// </div>
12309 pub async fn handle_pending_auto_mode_switch(
12310 &self,
12311 params: UIHandlePendingAutoModeSwitchRequest,
12312 ) -> Result<UIHandlePendingResult, Error> {
12313 let mut wire_params = serde_json::to_value(params)?;
12314 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
12315 let _value = self
12316 .session
12317 .client()
12318 .call(
12319 rpc_methods::SESSION_UI_HANDLEPENDINGAUTOMODESWITCH,
12320 Some(wire_params),
12321 )
12322 .await?;
12323 Ok(serde_json::from_value(_value)?)
12324 }
12325
12326 /// Resolves a pending `session_limits_exhausted.requested` event with the user's selected limit action.
12327 ///
12328 /// Wire method: `session.ui.handlePendingSessionLimitsExhausted`.
12329 ///
12330 /// # Parameters
12331 ///
12332 /// * `params` - Request ID of a pending `session_limits_exhausted.requested` event and the user's selected limit action.
12333 ///
12334 /// # Returns
12335 ///
12336 /// Indicates whether the pending UI request was resolved by this call.
12337 ///
12338 /// <div class="warning">
12339 ///
12340 /// **Experimental.** This API is part of an experimental wire-protocol surface
12341 /// and may change or be removed in future SDK or CLI releases. Pin both the
12342 /// SDK and CLI versions if your code depends on it.
12343 ///
12344 /// </div>
12345 pub async fn handle_pending_session_limits_exhausted(
12346 &self,
12347 params: UIHandlePendingSessionLimitsExhaustedRequest,
12348 ) -> Result<UIHandlePendingResult, Error> {
12349 let mut wire_params = serde_json::to_value(params)?;
12350 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
12351 let _value = self
12352 .session
12353 .client()
12354 .call(
12355 rpc_methods::SESSION_UI_HANDLEPENDINGSESSIONLIMITSEXHAUSTED,
12356 Some(wire_params),
12357 )
12358 .await?;
12359 Ok(serde_json::from_value(_value)?)
12360 }
12361
12362 /// Resolves a pending `exit_plan_mode.requested` event with the user's response.
12363 ///
12364 /// Wire method: `session.ui.handlePendingExitPlanMode`.
12365 ///
12366 /// # Parameters
12367 ///
12368 /// * `params` - Request ID of a pending `exit_plan_mode.requested` event and the user's response.
12369 ///
12370 /// # Returns
12371 ///
12372 /// Indicates whether the pending UI request was resolved by this call.
12373 ///
12374 /// <div class="warning">
12375 ///
12376 /// **Experimental.** This API is part of an experimental wire-protocol surface
12377 /// and may change or be removed in future SDK or CLI releases. Pin both the
12378 /// SDK and CLI versions if your code depends on it.
12379 ///
12380 /// </div>
12381 pub async fn handle_pending_exit_plan_mode(
12382 &self,
12383 params: UIHandlePendingExitPlanModeRequest,
12384 ) -> Result<UIHandlePendingResult, Error> {
12385 let mut wire_params = serde_json::to_value(params)?;
12386 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
12387 let _value = self
12388 .session
12389 .client()
12390 .call(
12391 rpc_methods::SESSION_UI_HANDLEPENDINGEXITPLANMODE,
12392 Some(wire_params),
12393 )
12394 .await?;
12395 Ok(serde_json::from_value(_value)?)
12396 }
12397
12398 /// Registers an in-process handler for auto-mode-switch requests so the server bridge skips dispatch.
12399 ///
12400 /// Wire method: `session.ui.registerDirectAutoModeSwitchHandler`.
12401 ///
12402 /// # Returns
12403 ///
12404 /// 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).
12405 ///
12406 /// <div class="warning">
12407 ///
12408 /// **Experimental.** This API is part of an experimental wire-protocol surface
12409 /// and may change or be removed in future SDK or CLI releases. Pin both the
12410 /// SDK and CLI versions if your code depends on it.
12411 ///
12412 /// </div>
12413 pub async fn register_direct_auto_mode_switch_handler(
12414 &self,
12415 ) -> Result<UIRegisterDirectAutoModeSwitchHandlerResult, Error> {
12416 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
12417 let _value = self
12418 .session
12419 .client()
12420 .call(
12421 rpc_methods::SESSION_UI_REGISTERDIRECTAUTOMODESWITCHHANDLER,
12422 Some(wire_params),
12423 )
12424 .await?;
12425 Ok(serde_json::from_value(_value)?)
12426 }
12427
12428 /// Unregisters a previously-registered in-process auto-mode-switch handler by its opaque handle.
12429 ///
12430 /// Wire method: `session.ui.unregisterDirectAutoModeSwitchHandler`.
12431 ///
12432 /// # Parameters
12433 ///
12434 /// * `params` - Opaque handle previously returned by `registerDirectAutoModeSwitchHandler` to release.
12435 ///
12436 /// # Returns
12437 ///
12438 /// Indicates whether the handle was active and the registration count was decremented.
12439 ///
12440 /// <div class="warning">
12441 ///
12442 /// **Experimental.** This API is part of an experimental wire-protocol surface
12443 /// and may change or be removed in future SDK or CLI releases. Pin both the
12444 /// SDK and CLI versions if your code depends on it.
12445 ///
12446 /// </div>
12447 pub async fn unregister_direct_auto_mode_switch_handler(
12448 &self,
12449 params: UIUnregisterDirectAutoModeSwitchHandlerRequest,
12450 ) -> Result<UIUnregisterDirectAutoModeSwitchHandlerResult, Error> {
12451 let mut wire_params = serde_json::to_value(params)?;
12452 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
12453 let _value = self
12454 .session
12455 .client()
12456 .call(
12457 rpc_methods::SESSION_UI_UNREGISTERDIRECTAUTOMODESWITCHHANDLER,
12458 Some(wire_params),
12459 )
12460 .await?;
12461 Ok(serde_json::from_value(_value)?)
12462 }
12463}
12464
12465/// `session.usage.*` RPCs.
12466#[derive(Clone, Copy)]
12467pub struct SessionRpcUsage<'a> {
12468 pub(crate) session: &'a Session,
12469}
12470
12471impl<'a> SessionRpcUsage<'a> {
12472 /// Gets accumulated usage metrics for the session.
12473 ///
12474 /// Wire method: `session.usage.getMetrics`.
12475 ///
12476 /// # Returns
12477 ///
12478 /// Accumulated session usage metrics, including premium request cost, token counts, model breakdown, and code-change totals.
12479 ///
12480 /// <div class="warning">
12481 ///
12482 /// **Experimental.** This API is part of an experimental wire-protocol surface
12483 /// and may change or be removed in future SDK or CLI releases. Pin both the
12484 /// SDK and CLI versions if your code depends on it.
12485 ///
12486 /// </div>
12487 pub async fn get_metrics(&self) -> Result<UsageGetMetricsResult, Error> {
12488 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
12489 let _value = self
12490 .session
12491 .client()
12492 .call(rpc_methods::SESSION_USAGE_GETMETRICS, Some(wire_params))
12493 .await?;
12494 Ok(serde_json::from_value(_value)?)
12495 }
12496}
12497
12498/// `session.visibility.*` RPCs.
12499#[derive(Clone, Copy)]
12500pub struct SessionRpcVisibility<'a> {
12501 pub(crate) session: &'a Session,
12502}
12503
12504impl<'a> SessionRpcVisibility<'a> {
12505 /// 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").
12506 ///
12507 /// Wire method: `session.visibility.get`.
12508 ///
12509 /// # Returns
12510 ///
12511 /// Current sharing status and shareable GitHub URL for a session.
12512 ///
12513 /// <div class="warning">
12514 ///
12515 /// **Experimental.** This API is part of an experimental wire-protocol surface
12516 /// and may change or be removed in future SDK or CLI releases. Pin both the
12517 /// SDK and CLI versions if your code depends on it.
12518 ///
12519 /// </div>
12520 pub async fn get(&self) -> Result<VisibilityGetResult, Error> {
12521 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
12522 let _value = self
12523 .session
12524 .client()
12525 .call(rpc_methods::SESSION_VISIBILITY_GET, Some(wire_params))
12526 .await?;
12527 Ok(serde_json::from_value(_value)?)
12528 }
12529
12530 /// 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.
12531 ///
12532 /// Wire method: `session.visibility.set`.
12533 ///
12534 /// # Parameters
12535 ///
12536 /// * `params` - Desired sharing status for the session.
12537 ///
12538 /// # Returns
12539 ///
12540 /// Effective sharing status and shareable GitHub URL after updating session visibility.
12541 ///
12542 /// <div class="warning">
12543 ///
12544 /// **Experimental.** This API is part of an experimental wire-protocol surface
12545 /// and may change or be removed in future SDK or CLI releases. Pin both the
12546 /// SDK and CLI versions if your code depends on it.
12547 ///
12548 /// </div>
12549 pub async fn set(&self, params: VisibilitySetRequest) -> Result<VisibilitySetResult, Error> {
12550 let mut wire_params = serde_json::to_value(params)?;
12551 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
12552 let _value = self
12553 .session
12554 .client()
12555 .call(rpc_methods::SESSION_VISIBILITY_SET, Some(wire_params))
12556 .await?;
12557 Ok(serde_json::from_value(_value)?)
12558 }
12559}
12560
12561/// `session.workflow.*` RPCs.
12562#[derive(Clone, Copy)]
12563pub struct SessionRpcWorkflow<'a> {
12564 pub(crate) session: &'a Session,
12565}
12566
12567impl<'a> SessionRpcWorkflow<'a> {
12568 /// `session.workflow.journal.*` sub-namespace.
12569 pub fn journal(&self) -> SessionRpcWorkflowJournal<'a> {
12570 SessionRpcWorkflowJournal {
12571 session: self.session,
12572 }
12573 }
12574
12575 /// Runs a registered dynamic workflow by name at the top level.
12576 ///
12577 /// Wire method: `session.workflow.run`.
12578 ///
12579 /// # Parameters
12580 ///
12581 /// * `params` - Parameters for invoking a registered workflow.
12582 ///
12583 /// # Returns
12584 ///
12585 /// Complete current or terminal workflow run envelope.
12586 ///
12587 /// <div class="warning">
12588 ///
12589 /// **Experimental.** This API is part of an experimental wire-protocol surface
12590 /// and may change or be removed in future SDK or CLI releases. Pin both the
12591 /// SDK and CLI versions if your code depends on it.
12592 ///
12593 /// </div>
12594 pub async fn run(&self, params: WorkflowRunRequest) -> Result<WorkflowRunResult, Error> {
12595 let mut wire_params = serde_json::to_value(params)?;
12596 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
12597 let _value = self
12598 .session
12599 .client()
12600 .call(rpc_methods::SESSION_WORKFLOW_RUN, Some(wire_params))
12601 .await?;
12602 Ok(serde_json::from_value(_value)?)
12603 }
12604
12605 /// Resumes a dynamic workflow run using its persisted name, arguments, journal, and accounting.
12606 ///
12607 /// Wire method: `session.workflow.resume`.
12608 ///
12609 /// # Parameters
12610 ///
12611 /// * `params` - Parameters for resuming a workflow run from its persisted identity.
12612 ///
12613 /// # Returns
12614 ///
12615 /// Resolved persisted workflow identity and resumed run envelope.
12616 ///
12617 /// <div class="warning">
12618 ///
12619 /// **Experimental.** This API is part of an experimental wire-protocol surface
12620 /// and may change or be removed in future SDK or CLI releases. Pin both the
12621 /// SDK and CLI versions if your code depends on it.
12622 ///
12623 /// </div>
12624 pub async fn resume(
12625 &self,
12626 params: WorkflowResumeRequest,
12627 ) -> Result<WorkflowResumeResult, Error> {
12628 let mut wire_params = serde_json::to_value(params)?;
12629 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
12630 let _value = self
12631 .session
12632 .client()
12633 .call(rpc_methods::SESSION_WORKFLOW_RESUME, Some(wire_params))
12634 .await?;
12635 Ok(serde_json::from_value(_value)?)
12636 }
12637
12638 /// Internal tool-originated dynamic workflow invocation.
12639 ///
12640 /// Wire method: `session.workflow.runFromTool`.
12641 ///
12642 /// # Parameters
12643 ///
12644 /// * `params` - Internal parameters for invoking a registered workflow from a tool.
12645 ///
12646 /// # Returns
12647 ///
12648 /// Complete current or terminal workflow run envelope.
12649 ///
12650 /// <div class="warning">
12651 ///
12652 /// **Experimental.** This API is part of an experimental wire-protocol surface
12653 /// and may change or be removed in future SDK or CLI releases. Pin both the
12654 /// SDK and CLI versions if your code depends on it.
12655 ///
12656 /// </div>
12657 pub(crate) async fn run_from_tool(
12658 &self,
12659 params: WorkflowToolRunRequest,
12660 ) -> Result<WorkflowRunResult, Error> {
12661 let mut wire_params = serde_json::to_value(params)?;
12662 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
12663 let _value = self
12664 .session
12665 .client()
12666 .call(rpc_methods::SESSION_WORKFLOW_RUNFROMTOOL, Some(wire_params))
12667 .await?;
12668 Ok(serde_json::from_value(_value)?)
12669 }
12670
12671 /// Internal tool-originated dynamic workflow resume.
12672 ///
12673 /// Wire method: `session.workflow.resumeFromTool`.
12674 ///
12675 /// # Parameters
12676 ///
12677 /// * `params` - Internal parameters for resuming a workflow run from a tool.
12678 ///
12679 /// # Returns
12680 ///
12681 /// Resolved persisted workflow identity and resumed run envelope.
12682 ///
12683 /// <div class="warning">
12684 ///
12685 /// **Experimental.** This API is part of an experimental wire-protocol surface
12686 /// and may change or be removed in future SDK or CLI releases. Pin both the
12687 /// SDK and CLI versions if your code depends on it.
12688 ///
12689 /// </div>
12690 pub(crate) async fn resume_from_tool(
12691 &self,
12692 params: WorkflowToolResumeRequest,
12693 ) -> Result<WorkflowResumeResult, Error> {
12694 let mut wire_params = serde_json::to_value(params)?;
12695 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
12696 let _value = self
12697 .session
12698 .client()
12699 .call(
12700 rpc_methods::SESSION_WORKFLOW_RESUMEFROMTOOL,
12701 Some(wire_params),
12702 )
12703 .await?;
12704 Ok(serde_json::from_value(_value)?)
12705 }
12706
12707 /// Gets the current or settled envelope for a dynamic workflow run.
12708 ///
12709 /// Wire method: `session.workflow.getRun`.
12710 ///
12711 /// # Parameters
12712 ///
12713 /// * `params` - Parameters for retrieving a workflow run.
12714 ///
12715 /// # Returns
12716 ///
12717 /// Complete current or terminal workflow run envelope.
12718 ///
12719 /// <div class="warning">
12720 ///
12721 /// **Experimental.** This API is part of an experimental wire-protocol surface
12722 /// and may change or be removed in future SDK or CLI releases. Pin both the
12723 /// SDK and CLI versions if your code depends on it.
12724 ///
12725 /// </div>
12726 pub async fn get_run(&self, params: WorkflowGetRunRequest) -> Result<WorkflowRunResult, Error> {
12727 let mut wire_params = serde_json::to_value(params)?;
12728 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
12729 let _value = self
12730 .session
12731 .client()
12732 .call(rpc_methods::SESSION_WORKFLOW_GETRUN, Some(wire_params))
12733 .await?;
12734 Ok(serde_json::from_value(_value)?)
12735 }
12736
12737 /// Lists durable dynamic workflow runs for this session in creation order.
12738 ///
12739 /// Wire method: `session.workflow.listRuns`.
12740 ///
12741 /// # Parameters
12742 ///
12743 /// * `params` - Parameters for paging workflow runs.
12744 ///
12745 /// # Returns
12746 ///
12747 /// A page of workflow runs in durable creation order.
12748 ///
12749 /// <div class="warning">
12750 ///
12751 /// **Experimental.** This API is part of an experimental wire-protocol surface
12752 /// and may change or be removed in future SDK or CLI releases. Pin both the
12753 /// SDK and CLI versions if your code depends on it.
12754 ///
12755 /// </div>
12756 pub async fn list_runs(
12757 &self,
12758 params: WorkflowListRunsRequest,
12759 ) -> Result<WorkflowListRunsResult, Error> {
12760 let mut wire_params = serde_json::to_value(params)?;
12761 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
12762 let _value = self
12763 .session
12764 .client()
12765 .call(rpc_methods::SESSION_WORKFLOW_LISTRUNS, Some(wire_params))
12766 .await?;
12767 Ok(serde_json::from_value(_value)?)
12768 }
12769
12770 /// Gets durable and live observability detail for one dynamic workflow run.
12771 ///
12772 /// Wire method: `session.workflow.getRunDetail`.
12773 ///
12774 /// # Parameters
12775 ///
12776 /// * `params` - Parameters for retrieving a workflow run.
12777 ///
12778 /// # Returns
12779 ///
12780 /// Full workflow run observability detail.
12781 ///
12782 /// <div class="warning">
12783 ///
12784 /// **Experimental.** This API is part of an experimental wire-protocol surface
12785 /// and may change or be removed in future SDK or CLI releases. Pin both the
12786 /// SDK and CLI versions if your code depends on it.
12787 ///
12788 /// </div>
12789 pub async fn get_run_detail(
12790 &self,
12791 params: WorkflowGetRunRequest,
12792 ) -> Result<WorkflowRunDetail, Error> {
12793 let mut wire_params = serde_json::to_value(params)?;
12794 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
12795 let _value = self
12796 .session
12797 .client()
12798 .call(
12799 rpc_methods::SESSION_WORKFLOW_GETRUNDETAIL,
12800 Some(wire_params),
12801 )
12802 .await?;
12803 Ok(serde_json::from_value(_value)?)
12804 }
12805
12806 /// Pages durable progress for one dynamic workflow run.
12807 ///
12808 /// Wire method: `session.workflow.getRunProgress`.
12809 ///
12810 /// # Parameters
12811 ///
12812 /// * `params` - Parameters for paging workflow progress.
12813 ///
12814 /// # Returns
12815 ///
12816 /// A bidirectional page of workflow progress.
12817 ///
12818 /// <div class="warning">
12819 ///
12820 /// **Experimental.** This API is part of an experimental wire-protocol surface
12821 /// and may change or be removed in future SDK or CLI releases. Pin both the
12822 /// SDK and CLI versions if your code depends on it.
12823 ///
12824 /// </div>
12825 pub async fn get_run_progress(
12826 &self,
12827 params: WorkflowGetRunProgressRequest,
12828 ) -> Result<WorkflowProgressPage, Error> {
12829 let mut wire_params = serde_json::to_value(params)?;
12830 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
12831 let _value = self
12832 .session
12833 .client()
12834 .call(
12835 rpc_methods::SESSION_WORKFLOW_GETRUNPROGRESS,
12836 Some(wire_params),
12837 )
12838 .await?;
12839 Ok(serde_json::from_value(_value)?)
12840 }
12841
12842 /// Requests cancellation of a dynamic workflow run and returns its run envelope.
12843 ///
12844 /// Wire method: `session.workflow.cancel`.
12845 ///
12846 /// # Parameters
12847 ///
12848 /// * `params` - Parameters for cancelling a workflow run.
12849 ///
12850 /// # Returns
12851 ///
12852 /// Complete current or terminal workflow run envelope.
12853 ///
12854 /// <div class="warning">
12855 ///
12856 /// **Experimental.** This API is part of an experimental wire-protocol surface
12857 /// and may change or be removed in future SDK or CLI releases. Pin both the
12858 /// SDK and CLI versions if your code depends on it.
12859 ///
12860 /// </div>
12861 pub async fn cancel(&self, params: WorkflowCancelRequest) -> Result<WorkflowRunResult, Error> {
12862 let mut wire_params = serde_json::to_value(params)?;
12863 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
12864 let _value = self
12865 .session
12866 .client()
12867 .call(rpc_methods::SESSION_WORKFLOW_CANCEL, Some(wire_params))
12868 .await?;
12869 Ok(serde_json::from_value(_value)?)
12870 }
12871
12872 /// Pauses a running dynamic workflow and returns its settled run envelope.
12873 ///
12874 /// Wire method: `session.workflow.pause`.
12875 ///
12876 /// # Parameters
12877 ///
12878 /// * `params` - Parameters for pausing a running workflow.
12879 ///
12880 /// # Returns
12881 ///
12882 /// Complete current or terminal workflow run envelope.
12883 ///
12884 /// <div class="warning">
12885 ///
12886 /// **Experimental.** This API is part of an experimental wire-protocol surface
12887 /// and may change or be removed in future SDK or CLI releases. Pin both the
12888 /// SDK and CLI versions if your code depends on it.
12889 ///
12890 /// </div>
12891 pub async fn pause(&self, params: WorkflowPauseRequest) -> Result<WorkflowRunResult, Error> {
12892 let mut wire_params = serde_json::to_value(params)?;
12893 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
12894 let _value = self
12895 .session
12896 .client()
12897 .call(rpc_methods::SESSION_WORKFLOW_PAUSE, Some(wire_params))
12898 .await?;
12899 Ok(serde_json::from_value(_value)?)
12900 }
12901
12902 /// Atomically pauses an owned dynamic workflow attempt at a durable checkpoint.
12903 ///
12904 /// Wire method: `session.workflow.pauseAtCheckpoint`.
12905 ///
12906 /// # Parameters
12907 ///
12908 /// * `params` - Parameters for an owned durable pause checkpoint.
12909 ///
12910 /// <div class="warning">
12911 ///
12912 /// **Experimental.** This API is part of an experimental wire-protocol surface
12913 /// and may change or be removed in future SDK or CLI releases. Pin both the
12914 /// SDK and CLI versions if your code depends on it.
12915 ///
12916 /// </div>
12917 pub(crate) async fn pause_at_checkpoint(
12918 &self,
12919 params: WorkflowPauseCheckpointRequest,
12920 ) -> Result<WorkflowPauseCheckpointResult, Error> {
12921 let mut wire_params = serde_json::to_value(params)?;
12922 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
12923 let _value = self
12924 .session
12925 .client()
12926 .call(
12927 rpc_methods::SESSION_WORKFLOW_PAUSEATCHECKPOINT,
12928 Some(wire_params),
12929 )
12930 .await?;
12931 Ok(serde_json::from_value(_value)?)
12932 }
12933
12934 /// Records a batch of ordered dynamic workflow progress lines.
12935 ///
12936 /// Wire method: `session.workflow.log`.
12937 ///
12938 /// # Parameters
12939 ///
12940 /// * `params` - Parameters for recording workflow progress.
12941 ///
12942 /// # Returns
12943 ///
12944 /// Acknowledgement that a workflow request was accepted.
12945 ///
12946 /// <div class="warning">
12947 ///
12948 /// **Experimental.** This API is part of an experimental wire-protocol surface
12949 /// and may change or be removed in future SDK or CLI releases. Pin both the
12950 /// SDK and CLI versions if your code depends on it.
12951 ///
12952 /// </div>
12953 pub async fn log(&self, params: WorkflowLogRequest) -> Result<WorkflowAckResult, Error> {
12954 let mut wire_params = serde_json::to_value(params)?;
12955 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
12956 let _value = self
12957 .session
12958 .client()
12959 .call(rpc_methods::SESSION_WORKFLOW_LOG, Some(wire_params))
12960 .await?;
12961 Ok(serde_json::from_value(_value)?)
12962 }
12963
12964 /// Runs one dynamic-workflow-scoped subagent and returns its result.
12965 ///
12966 /// Wire method: `session.workflow.agent`.
12967 ///
12968 /// # Parameters
12969 ///
12970 /// * `params` - Parameters for one workflow-scoped subagent call.
12971 ///
12972 /// # Returns
12973 ///
12974 /// Result of one workflow-scoped subagent call.
12975 ///
12976 /// <div class="warning">
12977 ///
12978 /// **Experimental.** This API is part of an experimental wire-protocol surface
12979 /// and may change or be removed in future SDK or CLI releases. Pin both the
12980 /// SDK and CLI versions if your code depends on it.
12981 ///
12982 /// </div>
12983 pub async fn agent(&self, params: WorkflowAgentRequest) -> Result<WorkflowAgentResult, Error> {
12984 let mut wire_params = serde_json::to_value(params)?;
12985 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
12986 let _value = self
12987 .session
12988 .client()
12989 .call(rpc_methods::SESSION_WORKFLOW_AGENT, Some(wire_params))
12990 .await?;
12991 Ok(serde_json::from_value(_value)?)
12992 }
12993}
12994
12995/// `session.workflow.journal.*` RPCs.
12996#[derive(Clone, Copy)]
12997pub struct SessionRpcWorkflowJournal<'a> {
12998 pub(crate) session: &'a Session,
12999}
13000
13001impl<'a> SessionRpcWorkflowJournal<'a> {
13002 /// Reads a memoized dynamic workflow journal entry.
13003 ///
13004 /// Wire method: `session.workflow.journal.get`.
13005 ///
13006 /// # Parameters
13007 ///
13008 /// * `params` - Parameters for reading a workflow journal entry.
13009 ///
13010 /// # Returns
13011 ///
13012 /// Result of reading a workflow journal entry.
13013 ///
13014 /// <div class="warning">
13015 ///
13016 /// **Experimental.** This API is part of an experimental wire-protocol surface
13017 /// and may change or be removed in future SDK or CLI releases. Pin both the
13018 /// SDK and CLI versions if your code depends on it.
13019 ///
13020 /// </div>
13021 pub async fn get(
13022 &self,
13023 params: WorkflowJournalGetRequest,
13024 ) -> Result<WorkflowJournalGetResult, Error> {
13025 let mut wire_params = serde_json::to_value(params)?;
13026 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
13027 let _value = self
13028 .session
13029 .client()
13030 .call(rpc_methods::SESSION_WORKFLOW_JOURNAL_GET, Some(wire_params))
13031 .await?;
13032 Ok(serde_json::from_value(_value)?)
13033 }
13034
13035 /// Stores a memoized dynamic workflow journal entry.
13036 ///
13037 /// Wire method: `session.workflow.journal.put`.
13038 ///
13039 /// # Parameters
13040 ///
13041 /// * `params` - Parameters for storing a workflow journal entry.
13042 ///
13043 /// # Returns
13044 ///
13045 /// Acknowledgement that a workflow request was accepted.
13046 ///
13047 /// <div class="warning">
13048 ///
13049 /// **Experimental.** This API is part of an experimental wire-protocol surface
13050 /// and may change or be removed in future SDK or CLI releases. Pin both the
13051 /// SDK and CLI versions if your code depends on it.
13052 ///
13053 /// </div>
13054 pub async fn put(&self, params: WorkflowJournalPutRequest) -> Result<WorkflowAckResult, Error> {
13055 let mut wire_params = serde_json::to_value(params)?;
13056 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
13057 let _value = self
13058 .session
13059 .client()
13060 .call(rpc_methods::SESSION_WORKFLOW_JOURNAL_PUT, Some(wire_params))
13061 .await?;
13062 Ok(serde_json::from_value(_value)?)
13063 }
13064}
13065
13066/// `session.workspaces.*` RPCs.
13067#[derive(Clone, Copy)]
13068pub struct SessionRpcWorkspaces<'a> {
13069 pub(crate) session: &'a Session,
13070}
13071
13072impl<'a> SessionRpcWorkspaces<'a> {
13073 /// Gets current workspace metadata for the session.
13074 ///
13075 /// Wire method: `session.workspaces.getWorkspace`.
13076 ///
13077 /// # Returns
13078 ///
13079 /// Current workspace metadata for the session, including its absolute filesystem path when available.
13080 ///
13081 /// <div class="warning">
13082 ///
13083 /// **Experimental.** This API is part of an experimental wire-protocol surface
13084 /// and may change or be removed in future SDK or CLI releases. Pin both the
13085 /// SDK and CLI versions if your code depends on it.
13086 ///
13087 /// </div>
13088 pub async fn get_workspace(&self) -> Result<WorkspacesGetWorkspaceResult, Error> {
13089 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
13090 let _value = self
13091 .session
13092 .client()
13093 .call(
13094 rpc_methods::SESSION_WORKSPACES_GETWORKSPACE,
13095 Some(wire_params),
13096 )
13097 .await?;
13098 Ok(serde_json::from_value(_value)?)
13099 }
13100
13101 /// Updates workspace metadata for a local session and returns the refreshed workspace.
13102 ///
13103 /// Wire method: `session.workspaces.updateMetadata`.
13104 ///
13105 /// # Parameters
13106 ///
13107 /// * `params` - Workspace metadata fields to update.
13108 ///
13109 /// # Returns
13110 ///
13111 /// Current workspace metadata for the session, including its absolute filesystem path when available.
13112 ///
13113 /// <div class="warning">
13114 ///
13115 /// **Experimental.** This API is part of an experimental wire-protocol surface
13116 /// and may change or be removed in future SDK or CLI releases. Pin both the
13117 /// SDK and CLI versions if your code depends on it.
13118 ///
13119 /// </div>
13120 pub async fn update_metadata(
13121 &self,
13122 params: WorkspacesUpdateMetadataRequest,
13123 ) -> Result<WorkspacesGetWorkspaceResult, Error> {
13124 let mut wire_params = serde_json::to_value(params)?;
13125 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
13126 let _value = self
13127 .session
13128 .client()
13129 .call(
13130 rpc_methods::SESSION_WORKSPACES_UPDATEMETADATA,
13131 Some(wire_params),
13132 )
13133 .await?;
13134 Ok(serde_json::from_value(_value)?)
13135 }
13136
13137 /// Ensures a local session workspace exists and returns it.
13138 ///
13139 /// Wire method: `session.workspaces.ensure`.
13140 ///
13141 /// # Parameters
13142 ///
13143 /// * `params` - Optional session context used when creating a local workspace.
13144 ///
13145 /// # Returns
13146 ///
13147 /// Current workspace metadata for the session, including its absolute filesystem path when available.
13148 ///
13149 /// <div class="warning">
13150 ///
13151 /// **Experimental.** This API is part of an experimental wire-protocol surface
13152 /// and may change or be removed in future SDK or CLI releases. Pin both the
13153 /// SDK and CLI versions if your code depends on it.
13154 ///
13155 /// </div>
13156 pub async fn ensure(
13157 &self,
13158 params: WorkspacesEnsureRequest,
13159 ) -> Result<WorkspacesGetWorkspaceResult, Error> {
13160 let mut wire_params = serde_json::to_value(params)?;
13161 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
13162 let _value = self
13163 .session
13164 .client()
13165 .call(rpc_methods::SESSION_WORKSPACES_ENSURE, Some(wire_params))
13166 .await?;
13167 Ok(serde_json::from_value(_value)?)
13168 }
13169
13170 /// Lists files stored in the session workspace files directory.
13171 ///
13172 /// Wire method: `session.workspaces.listFiles`.
13173 ///
13174 /// # Returns
13175 ///
13176 /// Relative paths of files stored in the session workspace files directory.
13177 ///
13178 /// <div class="warning">
13179 ///
13180 /// **Experimental.** This API is part of an experimental wire-protocol surface
13181 /// and may change or be removed in future SDK or CLI releases. Pin both the
13182 /// SDK and CLI versions if your code depends on it.
13183 ///
13184 /// </div>
13185 pub async fn list_files(&self) -> Result<WorkspacesListFilesResult, Error> {
13186 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
13187 let _value = self
13188 .session
13189 .client()
13190 .call(rpc_methods::SESSION_WORKSPACES_LISTFILES, Some(wire_params))
13191 .await?;
13192 Ok(serde_json::from_value(_value)?)
13193 }
13194
13195 /// Reads a file from the session workspace files directory.
13196 ///
13197 /// Wire method: `session.workspaces.readFile`.
13198 ///
13199 /// # Parameters
13200 ///
13201 /// * `params` - Relative path of the workspace file to read.
13202 ///
13203 /// # Returns
13204 ///
13205 /// Contents of the requested workspace file as a UTF-8 string.
13206 ///
13207 /// <div class="warning">
13208 ///
13209 /// **Experimental.** This API is part of an experimental wire-protocol surface
13210 /// and may change or be removed in future SDK or CLI releases. Pin both the
13211 /// SDK and CLI versions if your code depends on it.
13212 ///
13213 /// </div>
13214 pub async fn read_file(
13215 &self,
13216 params: WorkspacesReadFileRequest,
13217 ) -> Result<WorkspacesReadFileResult, Error> {
13218 let mut wire_params = serde_json::to_value(params)?;
13219 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
13220 let _value = self
13221 .session
13222 .client()
13223 .call(rpc_methods::SESSION_WORKSPACES_READFILE, Some(wire_params))
13224 .await?;
13225 Ok(serde_json::from_value(_value)?)
13226 }
13227
13228 /// Creates or overwrites a file in the session workspace files directory.
13229 ///
13230 /// Wire method: `session.workspaces.createFile`.
13231 ///
13232 /// # Parameters
13233 ///
13234 /// * `params` - Relative path and UTF-8 content for the workspace file to create or overwrite.
13235 ///
13236 /// <div class="warning">
13237 ///
13238 /// **Experimental.** This API is part of an experimental wire-protocol surface
13239 /// and may change or be removed in future SDK or CLI releases. Pin both the
13240 /// SDK and CLI versions if your code depends on it.
13241 ///
13242 /// </div>
13243 pub async fn create_file(&self, params: WorkspacesCreateFileRequest) -> Result<(), Error> {
13244 let mut wire_params = serde_json::to_value(params)?;
13245 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
13246 let _value = self
13247 .session
13248 .client()
13249 .call(
13250 rpc_methods::SESSION_WORKSPACES_CREATEFILE,
13251 Some(wire_params),
13252 )
13253 .await?;
13254 Ok(())
13255 }
13256
13257 /// Returns metadata for a file or directory in the session workspace files directory.
13258 ///
13259 /// Wire method: `session.workspaces.statFile`.
13260 ///
13261 /// # Parameters
13262 ///
13263 /// * `params` - Relative path of the workspace file or directory to inspect.
13264 ///
13265 /// # Returns
13266 ///
13267 /// Filesystem metadata for a path in the session workspace files directory.
13268 ///
13269 /// <div class="warning">
13270 ///
13271 /// **Experimental.** This API is part of an experimental wire-protocol surface
13272 /// and may change or be removed in future SDK or CLI releases. Pin both the
13273 /// SDK and CLI versions if your code depends on it.
13274 ///
13275 /// </div>
13276 pub async fn stat_file(
13277 &self,
13278 params: WorkspacesStatFileRequest,
13279 ) -> Result<WorkspacesStatFileResult, Error> {
13280 let mut wire_params = serde_json::to_value(params)?;
13281 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
13282 let _value = self
13283 .session
13284 .client()
13285 .call(rpc_methods::SESSION_WORKSPACES_STATFILE, Some(wire_params))
13286 .await?;
13287 Ok(serde_json::from_value(_value)?)
13288 }
13289
13290 /// Creates a directory in the session workspace files directory.
13291 ///
13292 /// Wire method: `session.workspaces.createDirectory`.
13293 ///
13294 /// # Parameters
13295 ///
13296 /// * `params` - Directory to create within the session workspace files directory.
13297 ///
13298 /// <div class="warning">
13299 ///
13300 /// **Experimental.** This API is part of an experimental wire-protocol surface
13301 /// and may change or be removed in future SDK or CLI releases. Pin both the
13302 /// SDK and CLI versions if your code depends on it.
13303 ///
13304 /// </div>
13305 pub async fn create_directory(
13306 &self,
13307 params: WorkspacesCreateDirectoryRequest,
13308 ) -> Result<(), Error> {
13309 let mut wire_params = serde_json::to_value(params)?;
13310 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
13311 let _value = self
13312 .session
13313 .client()
13314 .call(
13315 rpc_methods::SESSION_WORKSPACES_CREATEDIRECTORY,
13316 Some(wire_params),
13317 )
13318 .await?;
13319 Ok(())
13320 }
13321
13322 /// Removes a file or directory from the session workspace files directory.
13323 ///
13324 /// Wire method: `session.workspaces.removePath`.
13325 ///
13326 /// # Parameters
13327 ///
13328 /// * `params` - File or directory to remove from the session workspace files directory.
13329 ///
13330 /// <div class="warning">
13331 ///
13332 /// **Experimental.** This API is part of an experimental wire-protocol surface
13333 /// and may change or be removed in future SDK or CLI releases. Pin both the
13334 /// SDK and CLI versions if your code depends on it.
13335 ///
13336 /// </div>
13337 pub async fn remove_path(&self, params: WorkspacesRemovePathRequest) -> Result<(), Error> {
13338 let mut wire_params = serde_json::to_value(params)?;
13339 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
13340 let _value = self
13341 .session
13342 .client()
13343 .call(
13344 rpc_methods::SESSION_WORKSPACES_REMOVEPATH,
13345 Some(wire_params),
13346 )
13347 .await?;
13348 Ok(())
13349 }
13350
13351 /// Renames a file or directory within the session workspace files directory.
13352 ///
13353 /// Wire method: `session.workspaces.renamePath`.
13354 ///
13355 /// # Parameters
13356 ///
13357 /// * `params` - Source and destination paths for a rename within the session workspace files directory.
13358 ///
13359 /// <div class="warning">
13360 ///
13361 /// **Experimental.** This API is part of an experimental wire-protocol surface
13362 /// and may change or be removed in future SDK or CLI releases. Pin both the
13363 /// SDK and CLI versions if your code depends on it.
13364 ///
13365 /// </div>
13366 pub async fn rename_path(&self, params: WorkspacesRenamePathRequest) -> Result<(), Error> {
13367 let mut wire_params = serde_json::to_value(params)?;
13368 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
13369 let _value = self
13370 .session
13371 .client()
13372 .call(
13373 rpc_methods::SESSION_WORKSPACES_RENAMEPATH,
13374 Some(wire_params),
13375 )
13376 .await?;
13377 Ok(())
13378 }
13379
13380 /// Lists workspace checkpoints in chronological order.
13381 ///
13382 /// Wire method: `session.workspaces.listCheckpoints`.
13383 ///
13384 /// # Returns
13385 ///
13386 /// Workspace checkpoints in chronological order; empty when the workspace is not enabled.
13387 ///
13388 /// <div class="warning">
13389 ///
13390 /// **Experimental.** This API is part of an experimental wire-protocol surface
13391 /// and may change or be removed in future SDK or CLI releases. Pin both the
13392 /// SDK and CLI versions if your code depends on it.
13393 ///
13394 /// </div>
13395 pub async fn list_checkpoints(&self) -> Result<WorkspacesListCheckpointsResult, Error> {
13396 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
13397 let _value = self
13398 .session
13399 .client()
13400 .call(
13401 rpc_methods::SESSION_WORKSPACES_LISTCHECKPOINTS,
13402 Some(wire_params),
13403 )
13404 .await?;
13405 Ok(serde_json::from_value(_value)?)
13406 }
13407
13408 /// Reads the content of a workspace checkpoint by number.
13409 ///
13410 /// Wire method: `session.workspaces.readCheckpoint`.
13411 ///
13412 /// # Parameters
13413 ///
13414 /// * `params` - Checkpoint number to read.
13415 ///
13416 /// # Returns
13417 ///
13418 /// Checkpoint content as a UTF-8 string, or null when the checkpoint or workspace is missing.
13419 ///
13420 /// <div class="warning">
13421 ///
13422 /// **Experimental.** This API is part of an experimental wire-protocol surface
13423 /// and may change or be removed in future SDK or CLI releases. Pin both the
13424 /// SDK and CLI versions if your code depends on it.
13425 ///
13426 /// </div>
13427 pub async fn read_checkpoint(
13428 &self,
13429 params: WorkspacesReadCheckpointRequest,
13430 ) -> Result<WorkspacesReadCheckpointResult, Error> {
13431 let mut wire_params = serde_json::to_value(params)?;
13432 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
13433 let _value = self
13434 .session
13435 .client()
13436 .call(
13437 rpc_methods::SESSION_WORKSPACES_READCHECKPOINT,
13438 Some(wire_params),
13439 )
13440 .await?;
13441 Ok(serde_json::from_value(_value)?)
13442 }
13443
13444 /// Adds a compaction summary checkpoint to the local session workspace.
13445 ///
13446 /// Wire method: `session.workspaces.addSummary`.
13447 ///
13448 /// # Parameters
13449 ///
13450 /// * `params` - Compaction summary checkpoint to persist.
13451 ///
13452 /// # Returns
13453 ///
13454 /// Persisted summary metadata and refreshed workspace metadata.
13455 ///
13456 /// <div class="warning">
13457 ///
13458 /// **Experimental.** This API is part of an experimental wire-protocol surface
13459 /// and may change or be removed in future SDK or CLI releases. Pin both the
13460 /// SDK and CLI versions if your code depends on it.
13461 ///
13462 /// </div>
13463 pub async fn add_summary(
13464 &self,
13465 params: WorkspacesAddSummaryRequest,
13466 ) -> Result<WorkspacesAddSummaryResult, Error> {
13467 let mut wire_params = serde_json::to_value(params)?;
13468 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
13469 let _value = self
13470 .session
13471 .client()
13472 .call(
13473 rpc_methods::SESSION_WORKSPACES_ADDSUMMARY,
13474 Some(wire_params),
13475 )
13476 .await?;
13477 Ok(serde_json::from_value(_value)?)
13478 }
13479
13480 /// Truncates local workspace compaction summaries after a rollback.
13481 ///
13482 /// Wire method: `session.workspaces.truncateSummaries`.
13483 ///
13484 /// # Parameters
13485 ///
13486 /// * `params` - Rollback point for local workspace summaries.
13487 ///
13488 /// # Returns
13489 ///
13490 /// Current workspace metadata for the session, including its absolute filesystem path when available.
13491 ///
13492 /// <div class="warning">
13493 ///
13494 /// **Experimental.** This API is part of an experimental wire-protocol surface
13495 /// and may change or be removed in future SDK or CLI releases. Pin both the
13496 /// SDK and CLI versions if your code depends on it.
13497 ///
13498 /// </div>
13499 pub async fn truncate_summaries(
13500 &self,
13501 params: WorkspacesTruncateSummariesRequest,
13502 ) -> Result<WorkspacesGetWorkspaceResult, Error> {
13503 let mut wire_params = serde_json::to_value(params)?;
13504 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
13505 let _value = self
13506 .session
13507 .client()
13508 .call(
13509 rpc_methods::SESSION_WORKSPACES_TRUNCATESUMMARIES,
13510 Some(wire_params),
13511 )
13512 .await?;
13513 Ok(serde_json::from_value(_value)?)
13514 }
13515
13516 /// Reads the autopilot objective state file from the local session workspace.
13517 ///
13518 /// Wire method: `session.workspaces.readAutopilotObjective`.
13519 ///
13520 /// # Returns
13521 ///
13522 /// Autopilot objective file content, or null when missing.
13523 ///
13524 /// <div class="warning">
13525 ///
13526 /// **Experimental.** This API is part of an experimental wire-protocol surface
13527 /// and may change or be removed in future SDK or CLI releases. Pin both the
13528 /// SDK and CLI versions if your code depends on it.
13529 ///
13530 /// </div>
13531 pub async fn read_autopilot_objective(
13532 &self,
13533 ) -> Result<WorkspacesReadAutopilotObjectiveResult, Error> {
13534 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
13535 let _value = self
13536 .session
13537 .client()
13538 .call(
13539 rpc_methods::SESSION_WORKSPACES_READAUTOPILOTOBJECTIVE,
13540 Some(wire_params),
13541 )
13542 .await?;
13543 Ok(serde_json::from_value(_value)?)
13544 }
13545
13546 /// Writes the autopilot objective state file in the local session workspace.
13547 ///
13548 /// Wire method: `session.workspaces.writeAutopilotObjective`.
13549 ///
13550 /// # Parameters
13551 ///
13552 /// * `params` - Autopilot objective file content to persist.
13553 ///
13554 /// # Returns
13555 ///
13556 /// Result of writing the autopilot objective file.
13557 ///
13558 /// <div class="warning">
13559 ///
13560 /// **Experimental.** This API is part of an experimental wire-protocol surface
13561 /// and may change or be removed in future SDK or CLI releases. Pin both the
13562 /// SDK and CLI versions if your code depends on it.
13563 ///
13564 /// </div>
13565 pub async fn write_autopilot_objective(
13566 &self,
13567 params: WorkspacesWriteAutopilotObjectiveRequest,
13568 ) -> Result<WorkspacesWriteAutopilotObjectiveResult, Error> {
13569 let mut wire_params = serde_json::to_value(params)?;
13570 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
13571 let _value = self
13572 .session
13573 .client()
13574 .call(
13575 rpc_methods::SESSION_WORKSPACES_WRITEAUTOPILOTOBJECTIVE,
13576 Some(wire_params),
13577 )
13578 .await?;
13579 Ok(serde_json::from_value(_value)?)
13580 }
13581
13582 /// Deletes the autopilot objective state file from the local session workspace.
13583 ///
13584 /// Wire method: `session.workspaces.deleteAutopilotObjective`.
13585 ///
13586 /// # Returns
13587 ///
13588 /// Result of deleting the autopilot objective file.
13589 ///
13590 /// <div class="warning">
13591 ///
13592 /// **Experimental.** This API is part of an experimental wire-protocol surface
13593 /// and may change or be removed in future SDK or CLI releases. Pin both the
13594 /// SDK and CLI versions if your code depends on it.
13595 ///
13596 /// </div>
13597 pub async fn delete_autopilot_objective(
13598 &self,
13599 ) -> Result<WorkspacesDeleteAutopilotObjectiveResult, Error> {
13600 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
13601 let _value = self
13602 .session
13603 .client()
13604 .call(
13605 rpc_methods::SESSION_WORKSPACES_DELETEAUTOPILOTOBJECTIVE,
13606 Some(wire_params),
13607 )
13608 .await?;
13609 Ok(serde_json::from_value(_value)?)
13610 }
13611
13612 /// Checks whether the local session workspace has an autopilot objective state file.
13613 ///
13614 /// Wire method: `session.workspaces.autopilotObjectiveExists`.
13615 ///
13616 /// # Returns
13617 ///
13618 /// Whether the autopilot objective file exists.
13619 ///
13620 /// <div class="warning">
13621 ///
13622 /// **Experimental.** This API is part of an experimental wire-protocol surface
13623 /// and may change or be removed in future SDK or CLI releases. Pin both the
13624 /// SDK and CLI versions if your code depends on it.
13625 ///
13626 /// </div>
13627 pub async fn autopilot_objective_exists(
13628 &self,
13629 ) -> Result<WorkspacesAutopilotObjectiveExistsResult, Error> {
13630 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
13631 let _value = self
13632 .session
13633 .client()
13634 .call(
13635 rpc_methods::SESSION_WORKSPACES_AUTOPILOTOBJECTIVEEXISTS,
13636 Some(wire_params),
13637 )
13638 .await?;
13639 Ok(serde_json::from_value(_value)?)
13640 }
13641
13642 /// Saves pasted content as a UTF-8 file in the session workspace.
13643 ///
13644 /// Wire method: `session.workspaces.saveLargePaste`.
13645 ///
13646 /// # Parameters
13647 ///
13648 /// * `params` - Pasted content to save as a UTF-8 file in the session workspace.
13649 ///
13650 /// # Returns
13651 ///
13652 /// Descriptor for the saved paste file, or null when the workspace is unavailable.
13653 ///
13654 /// <div class="warning">
13655 ///
13656 /// **Experimental.** This API is part of an experimental wire-protocol surface
13657 /// and may change or be removed in future SDK or CLI releases. Pin both the
13658 /// SDK and CLI versions if your code depends on it.
13659 ///
13660 /// </div>
13661 pub async fn save_large_paste(
13662 &self,
13663 params: WorkspacesSaveLargePasteRequest,
13664 ) -> Result<WorkspacesSaveLargePasteResult, Error> {
13665 let mut wire_params = serde_json::to_value(params)?;
13666 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
13667 let _value = self
13668 .session
13669 .client()
13670 .call(
13671 rpc_methods::SESSION_WORKSPACES_SAVELARGEPASTE,
13672 Some(wire_params),
13673 )
13674 .await?;
13675 Ok(serde_json::from_value(_value)?)
13676 }
13677
13678 /// 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`.
13679 ///
13680 /// Wire method: `session.workspaces.diff`.
13681 ///
13682 /// # Parameters
13683 ///
13684 /// * `params` - Parameters for computing a workspace diff.
13685 ///
13686 /// # Returns
13687 ///
13688 /// Workspace diff result for the requested mode.
13689 ///
13690 /// <div class="warning">
13691 ///
13692 /// **Experimental.** This API is part of an experimental wire-protocol surface
13693 /// and may change or be removed in future SDK or CLI releases. Pin both the
13694 /// SDK and CLI versions if your code depends on it.
13695 ///
13696 /// </div>
13697 pub async fn diff(&self, params: WorkspacesDiffRequest) -> Result<WorkspaceDiffResult, Error> {
13698 let mut wire_params = serde_json::to_value(params)?;
13699 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
13700 let _value = self
13701 .session
13702 .client()
13703 .call(rpc_methods::SESSION_WORKSPACES_DIFF, Some(wire_params))
13704 .await?;
13705 Ok(serde_json::from_value(_value)?)
13706 }
13707}