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 /// `instructions.*` sub-namespace.
47 pub fn instructions(&self) -> ClientRpcInstructions<'a> {
48 ClientRpcInstructions {
49 client: self.client,
50 }
51 }
52
53 /// `llmInference.*` sub-namespace.
54 pub fn llm_inference(&self) -> ClientRpcLlmInference<'a> {
55 ClientRpcLlmInference {
56 client: self.client,
57 }
58 }
59
60 /// `mcp.*` sub-namespace.
61 pub fn mcp(&self) -> ClientRpcMcp<'a> {
62 ClientRpcMcp {
63 client: self.client,
64 }
65 }
66
67 /// `models.*` sub-namespace.
68 pub fn models(&self) -> ClientRpcModels<'a> {
69 ClientRpcModels {
70 client: self.client,
71 }
72 }
73
74 /// `plugins.*` sub-namespace.
75 pub fn plugins(&self) -> ClientRpcPlugins<'a> {
76 ClientRpcPlugins {
77 client: self.client,
78 }
79 }
80
81 /// `runtime.*` sub-namespace.
82 pub fn runtime(&self) -> ClientRpcRuntime<'a> {
83 ClientRpcRuntime {
84 client: self.client,
85 }
86 }
87
88 /// `secrets.*` sub-namespace.
89 pub fn secrets(&self) -> ClientRpcSecrets<'a> {
90 ClientRpcSecrets {
91 client: self.client,
92 }
93 }
94
95 /// `sessionFs.*` sub-namespace.
96 pub fn session_fs(&self) -> ClientRpcSessionFs<'a> {
97 ClientRpcSessionFs {
98 client: self.client,
99 }
100 }
101
102 /// `sessions.*` sub-namespace.
103 pub fn sessions(&self) -> ClientRpcSessions<'a> {
104 ClientRpcSessions {
105 client: self.client,
106 }
107 }
108
109 /// `skills.*` sub-namespace.
110 pub fn skills(&self) -> ClientRpcSkills<'a> {
111 ClientRpcSkills {
112 client: self.client,
113 }
114 }
115
116 /// `tools.*` sub-namespace.
117 pub fn tools(&self) -> ClientRpcTools<'a> {
118 ClientRpcTools {
119 client: self.client,
120 }
121 }
122
123 /// `user.*` sub-namespace.
124 pub fn user(&self) -> ClientRpcUser<'a> {
125 ClientRpcUser {
126 client: self.client,
127 }
128 }
129
130 /// Checks server responsiveness and returns protocol information.
131 ///
132 /// Wire method: `ping`.
133 ///
134 /// # Parameters
135 ///
136 /// * `params` - Optional message to echo back to the caller.
137 ///
138 /// # Returns
139 ///
140 /// Server liveness response, including the echoed message, current server timestamp, and protocol version.
141 ///
142 /// <div class="warning">
143 ///
144 /// **Experimental.** This API is part of an experimental wire-protocol surface
145 /// and may change or be removed in future SDK or CLI releases. Pin both the
146 /// SDK and CLI versions if your code depends on it.
147 ///
148 /// </div>
149 pub async fn ping(&self, params: PingRequest) -> Result<PingResult, Error> {
150 let wire_params = serde_json::to_value(params)?;
151 let _value = self
152 .client
153 .call(rpc_methods::PING, Some(wire_params))
154 .await?;
155 Ok(serde_json::from_value(_value)?)
156 }
157
158 /// 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.
159 ///
160 /// Wire method: `connect`.
161 ///
162 /// # Parameters
163 ///
164 /// * `params` - Optional connection token presented by the SDK client during the handshake.
165 ///
166 /// # Returns
167 ///
168 /// Handshake result reporting the server's protocol version and package version on success.
169 ///
170 /// <div class="warning">
171 ///
172 /// **Experimental.** This API is part of an experimental wire-protocol surface
173 /// and may change or be removed in future SDK or CLI releases. Pin both the
174 /// SDK and CLI versions if your code depends on it.
175 ///
176 /// </div>
177 pub(crate) async fn connect(&self, params: ConnectRequest) -> Result<ConnectResult, Error> {
178 let wire_params = serde_json::to_value(params)?;
179 let _value = self
180 .client
181 .call(rpc_methods::CONNECT, Some(wire_params))
182 .await?;
183 Ok(serde_json::from_value(_value)?)
184 }
185}
186
187/// `account.*` RPCs.
188#[derive(Clone, Copy)]
189pub struct ClientRpcAccount<'a> {
190 pub(crate) client: &'a Client,
191}
192
193impl<'a> ClientRpcAccount<'a> {
194 /// Gets Copilot quota usage for the authenticated user or supplied GitHub token.
195 ///
196 /// Wire method: `account.getQuota`.
197 ///
198 /// # Returns
199 ///
200 /// Quota usage snapshots for the resolved user, keyed by quota type.
201 ///
202 /// <div class="warning">
203 ///
204 /// **Experimental.** This API is part of an experimental wire-protocol surface
205 /// and may change or be removed in future SDK or CLI releases. Pin both the
206 /// SDK and CLI versions if your code depends on it.
207 ///
208 /// </div>
209 pub async fn get_quota(&self) -> Result<AccountGetQuotaResult, Error> {
210 let wire_params = serde_json::json!({});
211 let _value = self
212 .client
213 .call(rpc_methods::ACCOUNT_GETQUOTA, Some(wire_params))
214 .await?;
215 Ok(serde_json::from_value(_value)?)
216 }
217
218 /// Gets Copilot quota usage for the authenticated user or supplied GitHub token.
219 ///
220 /// Wire method: `account.getQuota`.
221 ///
222 /// # Parameters
223 ///
224 /// * `params` - Optional GitHub token used to look up quota for a specific user instead of the global auth context.
225 ///
226 /// # Returns
227 ///
228 /// Quota usage snapshots for the resolved user, keyed by quota type.
229 ///
230 /// <div class="warning">
231 ///
232 /// **Experimental.** This API is part of an experimental wire-protocol surface
233 /// and may change or be removed in future SDK or CLI releases. Pin both the
234 /// SDK and CLI versions if your code depends on it.
235 ///
236 /// </div>
237 pub async fn get_quota_with_params(
238 &self,
239 params: AccountGetQuotaRequest,
240 ) -> Result<AccountGetQuotaResult, Error> {
241 let wire_params = serde_json::to_value(params)?;
242 let _value = self
243 .client
244 .call(rpc_methods::ACCOUNT_GETQUOTA, Some(wire_params))
245 .await?;
246 Ok(serde_json::from_value(_value)?)
247 }
248
249 /// Gets the currently active authentication credentials from the global auth manager.
250 ///
251 /// Wire method: `account.getCurrentAuth`.
252 ///
253 /// # Returns
254 ///
255 /// Current authentication state
256 ///
257 /// <div class="warning">
258 ///
259 /// **Experimental.** This API is part of an experimental wire-protocol surface
260 /// and may change or be removed in future SDK or CLI releases. Pin both the
261 /// SDK and CLI versions if your code depends on it.
262 ///
263 /// </div>
264 pub async fn get_current_auth(&self) -> Result<AccountGetCurrentAuthResult, Error> {
265 let wire_params = serde_json::json!({});
266 let _value = self
267 .client
268 .call(rpc_methods::ACCOUNT_GETCURRENTAUTH, Some(wire_params))
269 .await?;
270 Ok(serde_json::from_value(_value)?)
271 }
272
273 /// Gets all authenticated users available for account switching.
274 ///
275 /// Wire method: `account.getAllUsers`.
276 ///
277 /// # Returns
278 ///
279 /// List of all authenticated users
280 ///
281 /// <div class="warning">
282 ///
283 /// **Experimental.** This API is part of an experimental wire-protocol surface
284 /// and may change or be removed in future SDK or CLI releases. Pin both the
285 /// SDK and CLI versions if your code depends on it.
286 ///
287 /// </div>
288 pub async fn get_all_users(&self) -> Result<AccountGetAllUsersResult, Error> {
289 let wire_params = serde_json::json!({});
290 let _value = self
291 .client
292 .call(rpc_methods::ACCOUNT_GETALLUSERS, Some(wire_params))
293 .await?;
294 Ok(serde_json::from_value(_value)?)
295 }
296
297 /// Stores authentication credentials after successful login (e.g., device code flow).
298 ///
299 /// Wire method: `account.login`.
300 ///
301 /// # Parameters
302 ///
303 /// * `params` - Credentials to store after successful authentication
304 ///
305 /// # Returns
306 ///
307 /// Result of a successful login; throws on failure
308 ///
309 /// <div class="warning">
310 ///
311 /// **Experimental.** This API is part of an experimental wire-protocol surface
312 /// and may change or be removed in future SDK or CLI releases. Pin both the
313 /// SDK and CLI versions if your code depends on it.
314 ///
315 /// </div>
316 pub async fn login(&self, params: AccountLoginRequest) -> Result<AccountLoginResult, Error> {
317 let wire_params = serde_json::to_value(params)?;
318 let _value = self
319 .client
320 .call(rpc_methods::ACCOUNT_LOGIN, Some(wire_params))
321 .await?;
322 Ok(serde_json::from_value(_value)?)
323 }
324
325 /// Removes user authentication from keychain and persisted state.
326 ///
327 /// Wire method: `account.logout`.
328 ///
329 /// # Parameters
330 ///
331 /// * `params` - User to log out
332 ///
333 /// # Returns
334 ///
335 /// Logout result indicating if more users remain
336 ///
337 /// <div class="warning">
338 ///
339 /// **Experimental.** This API is part of an experimental wire-protocol surface
340 /// and may change or be removed in future SDK or CLI releases. Pin both the
341 /// SDK and CLI versions if your code depends on it.
342 ///
343 /// </div>
344 pub async fn logout(&self, params: AccountLogoutRequest) -> Result<AccountLogoutResult, Error> {
345 let wire_params = serde_json::to_value(params)?;
346 let _value = self
347 .client
348 .call(rpc_methods::ACCOUNT_LOGOUT, Some(wire_params))
349 .await?;
350 Ok(serde_json::from_value(_value)?)
351 }
352}
353
354/// `agentRegistry.*` RPCs.
355#[derive(Clone, Copy)]
356pub struct ClientRpcAgentRegistry<'a> {
357 pub(crate) client: &'a Client,
358}
359
360impl<'a> ClientRpcAgentRegistry<'a> {
361 /// 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.
362 ///
363 /// Wire method: `agentRegistry.spawn`.
364 ///
365 /// # Parameters
366 ///
367 /// * `params` - Inputs to spawn a managed-server child via the controller's spawn delegate.
368 ///
369 /// # Returns
370 ///
371 /// Outcome of an agentRegistry.spawn call.
372 ///
373 /// <div class="warning">
374 ///
375 /// **Experimental.** This API is part of an experimental wire-protocol surface
376 /// and may change or be removed in future SDK or CLI releases. Pin both the
377 /// SDK and CLI versions if your code depends on it.
378 ///
379 /// </div>
380 pub async fn spawn(
381 &self,
382 params: AgentRegistrySpawnRequest,
383 ) -> Result<AgentRegistrySpawnResult, Error> {
384 let wire_params = serde_json::to_value(params)?;
385 let _value = self
386 .client
387 .call(rpc_methods::AGENTREGISTRY_SPAWN, Some(wire_params))
388 .await?;
389 Ok(serde_json::from_value(_value)?)
390 }
391}
392
393/// `agents.*` RPCs.
394#[derive(Clone, Copy)]
395pub struct ClientRpcAgents<'a> {
396 pub(crate) client: &'a Client,
397}
398
399impl<'a> ClientRpcAgents<'a> {
400 /// Discovers custom agents across user, project, plugin, and remote sources.
401 ///
402 /// Wire method: `agents.discover`.
403 ///
404 /// # Parameters
405 ///
406 /// * `params` - Optional project paths to include in agent discovery.
407 ///
408 /// # Returns
409 ///
410 /// Agents discovered across user, project, plugin, and remote sources.
411 ///
412 /// <div class="warning">
413 ///
414 /// **Experimental.** This API is part of an experimental wire-protocol surface
415 /// and may change or be removed in future SDK or CLI releases. Pin both the
416 /// SDK and CLI versions if your code depends on it.
417 ///
418 /// </div>
419 pub async fn discover(&self, params: AgentsDiscoverRequest) -> Result<ServerAgentList, Error> {
420 let wire_params = serde_json::to_value(params)?;
421 let _value = self
422 .client
423 .call(rpc_methods::AGENTS_DISCOVER, Some(wire_params))
424 .await?;
425 Ok(serde_json::from_value(_value)?)
426 }
427
428 /// 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.
429 ///
430 /// Wire method: `agents.getDiscoveryPaths`.
431 ///
432 /// # Parameters
433 ///
434 /// * `params` - Optional project paths to include when enumerating agent discovery directories.
435 ///
436 /// # Returns
437 ///
438 /// Canonical locations where custom agents can be created so the runtime will recognize them.
439 ///
440 /// <div class="warning">
441 ///
442 /// **Experimental.** This API is part of an experimental wire-protocol surface
443 /// and may change or be removed in future SDK or CLI releases. Pin both the
444 /// SDK and CLI versions if your code depends on it.
445 ///
446 /// </div>
447 pub async fn get_discovery_paths(
448 &self,
449 params: AgentsGetDiscoveryPathsRequest,
450 ) -> Result<AgentDiscoveryPathList, Error> {
451 let wire_params = serde_json::to_value(params)?;
452 let _value = self
453 .client
454 .call(rpc_methods::AGENTS_GETDISCOVERYPATHS, Some(wire_params))
455 .await?;
456 Ok(serde_json::from_value(_value)?)
457 }
458}
459
460/// `instructions.*` RPCs.
461#[derive(Clone, Copy)]
462pub struct ClientRpcInstructions<'a> {
463 pub(crate) client: &'a Client,
464}
465
466impl<'a> ClientRpcInstructions<'a> {
467 /// Discovers instruction sources across user, repository, and plugin sources.
468 ///
469 /// Wire method: `instructions.discover`.
470 ///
471 /// # Parameters
472 ///
473 /// * `params` - Optional project paths to include in instruction discovery.
474 ///
475 /// # Returns
476 ///
477 /// Instruction sources discovered across user, repository, and plugin sources.
478 ///
479 /// <div class="warning">
480 ///
481 /// **Experimental.** This API is part of an experimental wire-protocol surface
482 /// and may change or be removed in future SDK or CLI releases. Pin both the
483 /// SDK and CLI versions if your code depends on it.
484 ///
485 /// </div>
486 pub async fn discover(
487 &self,
488 params: InstructionsDiscoverRequest,
489 ) -> Result<ServerInstructionSourceList, Error> {
490 let wire_params = serde_json::to_value(params)?;
491 let _value = self
492 .client
493 .call(rpc_methods::INSTRUCTIONS_DISCOVER, Some(wire_params))
494 .await?;
495 Ok(serde_json::from_value(_value)?)
496 }
497
498 /// 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.
499 ///
500 /// Wire method: `instructions.getDiscoveryPaths`.
501 ///
502 /// # Parameters
503 ///
504 /// * `params` - Optional project paths to include when enumerating instruction discovery targets.
505 ///
506 /// # Returns
507 ///
508 /// Canonical files and directories where custom instructions can be created so the runtime will recognize them.
509 ///
510 /// <div class="warning">
511 ///
512 /// **Experimental.** This API is part of an experimental wire-protocol surface
513 /// and may change or be removed in future SDK or CLI releases. Pin both the
514 /// SDK and CLI versions if your code depends on it.
515 ///
516 /// </div>
517 pub async fn get_discovery_paths(
518 &self,
519 params: InstructionsGetDiscoveryPathsRequest,
520 ) -> Result<InstructionDiscoveryPathList, Error> {
521 let wire_params = serde_json::to_value(params)?;
522 let _value = self
523 .client
524 .call(
525 rpc_methods::INSTRUCTIONS_GETDISCOVERYPATHS,
526 Some(wire_params),
527 )
528 .await?;
529 Ok(serde_json::from_value(_value)?)
530 }
531}
532
533/// `llmInference.*` RPCs.
534#[derive(Clone, Copy)]
535pub struct ClientRpcLlmInference<'a> {
536 pub(crate) client: &'a Client,
537}
538
539impl<'a> ClientRpcLlmInference<'a> {
540 /// Registers an SDK client as the LLM inference callback provider.
541 ///
542 /// Wire method: `llmInference.setProvider`.
543 ///
544 /// # Returns
545 ///
546 /// Indicates whether the calling client was registered as the LLM inference provider.
547 ///
548 /// <div class="warning">
549 ///
550 /// **Experimental.** This API is part of an experimental wire-protocol surface
551 /// and may change or be removed in future SDK or CLI releases. Pin both the
552 /// SDK and CLI versions if your code depends on it.
553 ///
554 /// </div>
555 pub async fn set_provider(&self) -> Result<LlmInferenceSetProviderResult, Error> {
556 let wire_params = serde_json::json!({});
557 let _value = self
558 .client
559 .call(rpc_methods::LLMINFERENCE_SETPROVIDER, Some(wire_params))
560 .await?;
561 Ok(serde_json::from_value(_value)?)
562 }
563
564 /// 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.
565 ///
566 /// Wire method: `llmInference.httpResponseStart`.
567 ///
568 /// # Parameters
569 ///
570 /// * `params` - Response head.
571 ///
572 /// # Returns
573 ///
574 /// Whether the start frame was accepted.
575 ///
576 /// <div class="warning">
577 ///
578 /// **Experimental.** This API is part of an experimental wire-protocol surface
579 /// and may change or be removed in future SDK or CLI releases. Pin both the
580 /// SDK and CLI versions if your code depends on it.
581 ///
582 /// </div>
583 pub async fn http_response_start(
584 &self,
585 params: LlmInferenceHttpResponseStartRequest,
586 ) -> Result<LlmInferenceHttpResponseStartResult, Error> {
587 let wire_params = serde_json::to_value(params)?;
588 let _value = self
589 .client
590 .call(
591 rpc_methods::LLMINFERENCE_HTTPRESPONSESTART,
592 Some(wire_params),
593 )
594 .await?;
595 Ok(serde_json::from_value(_value)?)
596 }
597
598 /// 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.
599 ///
600 /// Wire method: `llmInference.httpResponseChunk`.
601 ///
602 /// # Parameters
603 ///
604 /// * `params` - A response body chunk or terminal error.
605 ///
606 /// # Returns
607 ///
608 /// Whether the chunk was accepted.
609 ///
610 /// <div class="warning">
611 ///
612 /// **Experimental.** This API is part of an experimental wire-protocol surface
613 /// and may change or be removed in future SDK or CLI releases. Pin both the
614 /// SDK and CLI versions if your code depends on it.
615 ///
616 /// </div>
617 pub async fn http_response_chunk(
618 &self,
619 params: LlmInferenceHttpResponseChunkRequest,
620 ) -> Result<LlmInferenceHttpResponseChunkResult, Error> {
621 let wire_params = serde_json::to_value(params)?;
622 let _value = self
623 .client
624 .call(
625 rpc_methods::LLMINFERENCE_HTTPRESPONSECHUNK,
626 Some(wire_params),
627 )
628 .await?;
629 Ok(serde_json::from_value(_value)?)
630 }
631}
632
633/// `mcp.*` RPCs.
634#[derive(Clone, Copy)]
635pub struct ClientRpcMcp<'a> {
636 pub(crate) client: &'a Client,
637}
638
639impl<'a> ClientRpcMcp<'a> {
640 /// `mcp.config.*` sub-namespace.
641 pub fn config(&self) -> ClientRpcMcpConfig<'a> {
642 ClientRpcMcpConfig {
643 client: self.client,
644 }
645 }
646
647 /// Discovers MCP servers from user, workspace, plugin, and builtin sources.
648 ///
649 /// Wire method: `mcp.discover`.
650 ///
651 /// # Parameters
652 ///
653 /// * `params` - Optional working directory used as context for MCP server discovery.
654 ///
655 /// # Returns
656 ///
657 /// MCP servers discovered from user, workspace, plugin, and built-in sources.
658 ///
659 /// <div class="warning">
660 ///
661 /// **Experimental.** This API is part of an experimental wire-protocol surface
662 /// and may change or be removed in future SDK or CLI releases. Pin both the
663 /// SDK and CLI versions if your code depends on it.
664 ///
665 /// </div>
666 pub async fn discover(&self, params: McpDiscoverRequest) -> Result<McpDiscoverResult, Error> {
667 let wire_params = serde_json::to_value(params)?;
668 let _value = self
669 .client
670 .call(rpc_methods::MCP_DISCOVER, Some(wire_params))
671 .await?;
672 Ok(serde_json::from_value(_value)?)
673 }
674}
675
676/// `mcp.config.*` RPCs.
677#[derive(Clone, Copy)]
678pub struct ClientRpcMcpConfig<'a> {
679 pub(crate) client: &'a Client,
680}
681
682impl<'a> ClientRpcMcpConfig<'a> {
683 /// Lists MCP servers from user configuration.
684 ///
685 /// Wire method: `mcp.config.list`.
686 ///
687 /// # Returns
688 ///
689 /// User-configured MCP servers, keyed by server name.
690 ///
691 /// <div class="warning">
692 ///
693 /// **Experimental.** This API is part of an experimental wire-protocol surface
694 /// and may change or be removed in future SDK or CLI releases. Pin both the
695 /// SDK and CLI versions if your code depends on it.
696 ///
697 /// </div>
698 pub async fn list(&self) -> Result<McpConfigList, Error> {
699 let wire_params = serde_json::json!({});
700 let _value = self
701 .client
702 .call(rpc_methods::MCP_CONFIG_LIST, Some(wire_params))
703 .await?;
704 Ok(serde_json::from_value(_value)?)
705 }
706
707 /// Adds an MCP server to user configuration.
708 ///
709 /// Wire method: `mcp.config.add`.
710 ///
711 /// # Parameters
712 ///
713 /// * `params` - MCP server name and configuration to add to user configuration.
714 ///
715 /// <div class="warning">
716 ///
717 /// **Experimental.** This API is part of an experimental wire-protocol surface
718 /// and may change or be removed in future SDK or CLI releases. Pin both the
719 /// SDK and CLI versions if your code depends on it.
720 ///
721 /// </div>
722 pub async fn add(&self, params: McpConfigAddRequest) -> Result<(), Error> {
723 let wire_params = serde_json::to_value(params)?;
724 let _value = self
725 .client
726 .call(rpc_methods::MCP_CONFIG_ADD, Some(wire_params))
727 .await?;
728 Ok(())
729 }
730
731 /// Updates an MCP server in user configuration.
732 ///
733 /// Wire method: `mcp.config.update`.
734 ///
735 /// # Parameters
736 ///
737 /// * `params` - MCP server name and replacement configuration to write to user configuration.
738 ///
739 /// <div class="warning">
740 ///
741 /// **Experimental.** This API is part of an experimental wire-protocol surface
742 /// and may change or be removed in future SDK or CLI releases. Pin both the
743 /// SDK and CLI versions if your code depends on it.
744 ///
745 /// </div>
746 pub async fn update(&self, params: McpConfigUpdateRequest) -> Result<(), Error> {
747 let wire_params = serde_json::to_value(params)?;
748 let _value = self
749 .client
750 .call(rpc_methods::MCP_CONFIG_UPDATE, Some(wire_params))
751 .await?;
752 Ok(())
753 }
754
755 /// Removes an MCP server from user configuration.
756 ///
757 /// Wire method: `mcp.config.remove`.
758 ///
759 /// # Parameters
760 ///
761 /// * `params` - MCP server name to remove from user configuration.
762 ///
763 /// <div class="warning">
764 ///
765 /// **Experimental.** This API is part of an experimental wire-protocol surface
766 /// and may change or be removed in future SDK or CLI releases. Pin both the
767 /// SDK and CLI versions if your code depends on it.
768 ///
769 /// </div>
770 pub async fn remove(&self, params: McpConfigRemoveRequest) -> Result<(), Error> {
771 let wire_params = serde_json::to_value(params)?;
772 let _value = self
773 .client
774 .call(rpc_methods::MCP_CONFIG_REMOVE, Some(wire_params))
775 .await?;
776 Ok(())
777 }
778
779 /// Enables MCP servers in user configuration for new sessions.
780 ///
781 /// Wire method: `mcp.config.enable`.
782 ///
783 /// # Parameters
784 ///
785 /// * `params` - MCP server names to enable for new sessions.
786 ///
787 /// <div class="warning">
788 ///
789 /// **Experimental.** This API is part of an experimental wire-protocol surface
790 /// and may change or be removed in future SDK or CLI releases. Pin both the
791 /// SDK and CLI versions if your code depends on it.
792 ///
793 /// </div>
794 pub async fn enable(&self, params: McpConfigEnableRequest) -> Result<(), Error> {
795 let wire_params = serde_json::to_value(params)?;
796 let _value = self
797 .client
798 .call(rpc_methods::MCP_CONFIG_ENABLE, Some(wire_params))
799 .await?;
800 Ok(())
801 }
802
803 /// Disables MCP servers in user configuration for new sessions.
804 ///
805 /// Wire method: `mcp.config.disable`.
806 ///
807 /// # Parameters
808 ///
809 /// * `params` - MCP server names to disable for new sessions.
810 ///
811 /// <div class="warning">
812 ///
813 /// **Experimental.** This API is part of an experimental wire-protocol surface
814 /// and may change or be removed in future SDK or CLI releases. Pin both the
815 /// SDK and CLI versions if your code depends on it.
816 ///
817 /// </div>
818 pub async fn disable(&self, params: McpConfigDisableRequest) -> Result<(), Error> {
819 let wire_params = serde_json::to_value(params)?;
820 let _value = self
821 .client
822 .call(rpc_methods::MCP_CONFIG_DISABLE, Some(wire_params))
823 .await?;
824 Ok(())
825 }
826
827 /// Drops this runtime process's in-memory MCP server-definition cache so the next MCP config read observes disk.
828 ///
829 /// Wire method: `mcp.config.reload`.
830 ///
831 /// <div class="warning">
832 ///
833 /// **Experimental.** This API is part of an experimental wire-protocol surface
834 /// and may change or be removed in future SDK or CLI releases. Pin both the
835 /// SDK and CLI versions if your code depends on it.
836 ///
837 /// </div>
838 pub async fn reload(&self) -> Result<(), Error> {
839 let wire_params = serde_json::json!({});
840 let _value = self
841 .client
842 .call(rpc_methods::MCP_CONFIG_RELOAD, Some(wire_params))
843 .await?;
844 Ok(())
845 }
846}
847
848/// `models.*` RPCs.
849#[derive(Clone, Copy)]
850pub struct ClientRpcModels<'a> {
851 pub(crate) client: &'a Client,
852}
853
854impl<'a> ClientRpcModels<'a> {
855 /// Lists Copilot models available to the authenticated user.
856 ///
857 /// Wire method: `models.list`.
858 ///
859 /// # Returns
860 ///
861 /// List of Copilot models available to the resolved user, including capabilities and billing metadata.
862 ///
863 /// <div class="warning">
864 ///
865 /// **Experimental.** This API is part of an experimental wire-protocol surface
866 /// and may change or be removed in future SDK or CLI releases. Pin both the
867 /// SDK and CLI versions if your code depends on it.
868 ///
869 /// </div>
870 pub async fn list(&self) -> Result<ModelList, Error> {
871 let wire_params = serde_json::json!({});
872 let _value = self
873 .client
874 .call(rpc_methods::MODELS_LIST, Some(wire_params))
875 .await?;
876 Ok(serde_json::from_value(_value)?)
877 }
878
879 /// Lists Copilot models available to the authenticated user.
880 ///
881 /// Wire method: `models.list`.
882 ///
883 /// # Parameters
884 ///
885 /// * `params` - Optional GitHub token used to list models for a specific user instead of the global auth context.
886 ///
887 /// # Returns
888 ///
889 /// List of Copilot models available to the resolved user, including capabilities and billing metadata.
890 ///
891 /// <div class="warning">
892 ///
893 /// **Experimental.** This API is part of an experimental wire-protocol surface
894 /// and may change or be removed in future SDK or CLI releases. Pin both the
895 /// SDK and CLI versions if your code depends on it.
896 ///
897 /// </div>
898 pub async fn list_with_params(&self, params: ModelsListRequest) -> Result<ModelList, Error> {
899 let wire_params = serde_json::to_value(params)?;
900 let _value = self
901 .client
902 .call(rpc_methods::MODELS_LIST, Some(wire_params))
903 .await?;
904 Ok(serde_json::from_value(_value)?)
905 }
906}
907
908/// `plugins.*` RPCs.
909#[derive(Clone, Copy)]
910pub struct ClientRpcPlugins<'a> {
911 pub(crate) client: &'a Client,
912}
913
914impl<'a> ClientRpcPlugins<'a> {
915 /// `plugins.marketplaces.*` sub-namespace.
916 pub fn marketplaces(&self) -> ClientRpcPluginsMarketplaces<'a> {
917 ClientRpcPluginsMarketplaces {
918 client: self.client,
919 }
920 }
921
922 /// Lists plugins installed in user/global state.
923 ///
924 /// Wire method: `plugins.list`.
925 ///
926 /// # Returns
927 ///
928 /// Plugins installed in user/global state.
929 ///
930 /// <div class="warning">
931 ///
932 /// **Experimental.** This API is part of an experimental wire-protocol surface
933 /// and may change or be removed in future SDK or CLI releases. Pin both the
934 /// SDK and CLI versions if your code depends on it.
935 ///
936 /// </div>
937 pub async fn list(&self) -> Result<PluginListResult, Error> {
938 let wire_params = serde_json::json!({});
939 let _value = self
940 .client
941 .call(rpc_methods::PLUGINS_LIST, Some(wire_params))
942 .await?;
943 Ok(serde_json::from_value(_value)?)
944 }
945
946 /// Installs a plugin from a marketplace, GitHub repo, URL, or local path.
947 ///
948 /// Wire method: `plugins.install`.
949 ///
950 /// # Parameters
951 ///
952 /// * `params` - Plugin source and optional working directory for relative-path resolution.
953 ///
954 /// # Returns
955 ///
956 /// Result of installing a plugin.
957 ///
958 /// <div class="warning">
959 ///
960 /// **Experimental.** This API is part of an experimental wire-protocol surface
961 /// and may change or be removed in future SDK or CLI releases. Pin both the
962 /// SDK and CLI versions if your code depends on it.
963 ///
964 /// </div>
965 pub async fn install(
966 &self,
967 params: PluginsInstallRequest,
968 ) -> Result<PluginInstallResult, Error> {
969 let wire_params = serde_json::to_value(params)?;
970 let _value = self
971 .client
972 .call(rpc_methods::PLUGINS_INSTALL, Some(wire_params))
973 .await?;
974 Ok(serde_json::from_value(_value)?)
975 }
976
977 /// Uninstalls an installed plugin.
978 ///
979 /// Wire method: `plugins.uninstall`.
980 ///
981 /// # Parameters
982 ///
983 /// * `params` - Name (or spec) of the plugin to uninstall.
984 ///
985 /// <div class="warning">
986 ///
987 /// **Experimental.** This API is part of an experimental wire-protocol surface
988 /// and may change or be removed in future SDK or CLI releases. Pin both the
989 /// SDK and CLI versions if your code depends on it.
990 ///
991 /// </div>
992 pub async fn uninstall(&self, params: PluginsUninstallRequest) -> Result<(), Error> {
993 let wire_params = serde_json::to_value(params)?;
994 let _value = self
995 .client
996 .call(rpc_methods::PLUGINS_UNINSTALL, Some(wire_params))
997 .await?;
998 Ok(())
999 }
1000
1001 /// Updates an installed plugin to its latest published version.
1002 ///
1003 /// Wire method: `plugins.update`.
1004 ///
1005 /// # Parameters
1006 ///
1007 /// * `params` - Name (or spec) of the plugin to update.
1008 ///
1009 /// # Returns
1010 ///
1011 /// Result of updating a single plugin.
1012 ///
1013 /// <div class="warning">
1014 ///
1015 /// **Experimental.** This API is part of an experimental wire-protocol surface
1016 /// and may change or be removed in future SDK or CLI releases. Pin both the
1017 /// SDK and CLI versions if your code depends on it.
1018 ///
1019 /// </div>
1020 pub async fn update(&self, params: PluginsUpdateRequest) -> Result<PluginUpdateResult, Error> {
1021 let wire_params = serde_json::to_value(params)?;
1022 let _value = self
1023 .client
1024 .call(rpc_methods::PLUGINS_UPDATE, Some(wire_params))
1025 .await?;
1026 Ok(serde_json::from_value(_value)?)
1027 }
1028
1029 /// Updates every installed plugin to its latest published version.
1030 ///
1031 /// Wire method: `plugins.updateAll`.
1032 ///
1033 /// # Returns
1034 ///
1035 /// Result of updating all installed plugins.
1036 ///
1037 /// <div class="warning">
1038 ///
1039 /// **Experimental.** This API is part of an experimental wire-protocol surface
1040 /// and may change or be removed in future SDK or CLI releases. Pin both the
1041 /// SDK and CLI versions if your code depends on it.
1042 ///
1043 /// </div>
1044 pub async fn update_all(&self) -> Result<PluginUpdateAllResult, Error> {
1045 let wire_params = serde_json::json!({});
1046 let _value = self
1047 .client
1048 .call(rpc_methods::PLUGINS_UPDATEALL, Some(wire_params))
1049 .await?;
1050 Ok(serde_json::from_value(_value)?)
1051 }
1052
1053 /// Enables installed plugins for new sessions.
1054 ///
1055 /// Wire method: `plugins.enable`.
1056 ///
1057 /// # Parameters
1058 ///
1059 /// * `params` - Plugin names (or specs) to enable.
1060 ///
1061 /// <div class="warning">
1062 ///
1063 /// **Experimental.** This API is part of an experimental wire-protocol surface
1064 /// and may change or be removed in future SDK or CLI releases. Pin both the
1065 /// SDK and CLI versions if your code depends on it.
1066 ///
1067 /// </div>
1068 pub async fn enable(&self, params: PluginsEnableRequest) -> Result<(), Error> {
1069 let wire_params = serde_json::to_value(params)?;
1070 let _value = self
1071 .client
1072 .call(rpc_methods::PLUGINS_ENABLE, Some(wire_params))
1073 .await?;
1074 Ok(())
1075 }
1076
1077 /// Disables installed plugins for new sessions.
1078 ///
1079 /// Wire method: `plugins.disable`.
1080 ///
1081 /// # Parameters
1082 ///
1083 /// * `params` - Plugin names (or specs) to disable.
1084 ///
1085 /// <div class="warning">
1086 ///
1087 /// **Experimental.** This API is part of an experimental wire-protocol surface
1088 /// and may change or be removed in future SDK or CLI releases. Pin both the
1089 /// SDK and CLI versions if your code depends on it.
1090 ///
1091 /// </div>
1092 pub async fn disable(&self, params: PluginsDisableRequest) -> Result<(), Error> {
1093 let wire_params = serde_json::to_value(params)?;
1094 let _value = self
1095 .client
1096 .call(rpc_methods::PLUGINS_DISABLE, Some(wire_params))
1097 .await?;
1098 Ok(())
1099 }
1100}
1101
1102/// `plugins.marketplaces.*` RPCs.
1103#[derive(Clone, Copy)]
1104pub struct ClientRpcPluginsMarketplaces<'a> {
1105 pub(crate) client: &'a Client,
1106}
1107
1108impl<'a> ClientRpcPluginsMarketplaces<'a> {
1109 /// Lists all registered marketplaces (defaults + user-added).
1110 ///
1111 /// Wire method: `plugins.marketplaces.list`.
1112 ///
1113 /// # Returns
1114 ///
1115 /// All registered marketplaces, including built-in defaults.
1116 ///
1117 /// <div class="warning">
1118 ///
1119 /// **Experimental.** This API is part of an experimental wire-protocol surface
1120 /// and may change or be removed in future SDK or CLI releases. Pin both the
1121 /// SDK and CLI versions if your code depends on it.
1122 ///
1123 /// </div>
1124 pub async fn list(&self) -> Result<MarketplaceListResult, Error> {
1125 let wire_params = serde_json::json!({});
1126 let _value = self
1127 .client
1128 .call(rpc_methods::PLUGINS_MARKETPLACES_LIST, Some(wire_params))
1129 .await?;
1130 Ok(serde_json::from_value(_value)?)
1131 }
1132
1133 /// Registers a new marketplace from a source (owner/repo, URL, or local path).
1134 ///
1135 /// Wire method: `plugins.marketplaces.add`.
1136 ///
1137 /// # Parameters
1138 ///
1139 /// * `params` - Marketplace source to register.
1140 ///
1141 /// # Returns
1142 ///
1143 /// Result of registering a new marketplace.
1144 ///
1145 /// <div class="warning">
1146 ///
1147 /// **Experimental.** This API is part of an experimental wire-protocol surface
1148 /// and may change or be removed in future SDK or CLI releases. Pin both the
1149 /// SDK and CLI versions if your code depends on it.
1150 ///
1151 /// </div>
1152 pub async fn add(
1153 &self,
1154 params: PluginsMarketplacesAddRequest,
1155 ) -> Result<MarketplaceAddResult, Error> {
1156 let wire_params = serde_json::to_value(params)?;
1157 let _value = self
1158 .client
1159 .call(rpc_methods::PLUGINS_MARKETPLACES_ADD, Some(wire_params))
1160 .await?;
1161 Ok(serde_json::from_value(_value)?)
1162 }
1163
1164 /// 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`.
1165 ///
1166 /// Wire method: `plugins.marketplaces.remove`.
1167 ///
1168 /// # Parameters
1169 ///
1170 /// * `params` - Name of the marketplace to remove and an optional force flag.
1171 ///
1172 /// # Returns
1173 ///
1174 /// Outcome of the remove attempt, including dependent-plugin info when applicable.
1175 ///
1176 /// <div class="warning">
1177 ///
1178 /// **Experimental.** This API is part of an experimental wire-protocol surface
1179 /// and may change or be removed in future SDK or CLI releases. Pin both the
1180 /// SDK and CLI versions if your code depends on it.
1181 ///
1182 /// </div>
1183 pub async fn remove(
1184 &self,
1185 params: PluginsMarketplacesRemoveRequest,
1186 ) -> Result<MarketplaceRemoveResult, Error> {
1187 let wire_params = serde_json::to_value(params)?;
1188 let _value = self
1189 .client
1190 .call(rpc_methods::PLUGINS_MARKETPLACES_REMOVE, Some(wire_params))
1191 .await?;
1192 Ok(serde_json::from_value(_value)?)
1193 }
1194
1195 /// Lists plugins advertised by a registered marketplace.
1196 ///
1197 /// Wire method: `plugins.marketplaces.browse`.
1198 ///
1199 /// # Parameters
1200 ///
1201 /// * `params` - Name of the marketplace whose plugin catalog to fetch.
1202 ///
1203 /// # Returns
1204 ///
1205 /// Plugins advertised by the marketplace.
1206 ///
1207 /// <div class="warning">
1208 ///
1209 /// **Experimental.** This API is part of an experimental wire-protocol surface
1210 /// and may change or be removed in future SDK or CLI releases. Pin both the
1211 /// SDK and CLI versions if your code depends on it.
1212 ///
1213 /// </div>
1214 pub async fn browse(
1215 &self,
1216 params: PluginsMarketplacesBrowseRequest,
1217 ) -> Result<MarketplaceBrowseResult, Error> {
1218 let wire_params = serde_json::to_value(params)?;
1219 let _value = self
1220 .client
1221 .call(rpc_methods::PLUGINS_MARKETPLACES_BROWSE, Some(wire_params))
1222 .await?;
1223 Ok(serde_json::from_value(_value)?)
1224 }
1225
1226 /// Re-fetches one or all registered marketplace catalogs.
1227 ///
1228 /// Wire method: `plugins.marketplaces.refresh`.
1229 ///
1230 /// # Returns
1231 ///
1232 /// Result of refreshing one or more marketplace catalogs.
1233 ///
1234 /// <div class="warning">
1235 ///
1236 /// **Experimental.** This API is part of an experimental wire-protocol surface
1237 /// and may change or be removed in future SDK or CLI releases. Pin both the
1238 /// SDK and CLI versions if your code depends on it.
1239 ///
1240 /// </div>
1241 pub async fn refresh(&self) -> Result<MarketplaceRefreshResult, Error> {
1242 let wire_params = serde_json::json!({});
1243 let _value = self
1244 .client
1245 .call(rpc_methods::PLUGINS_MARKETPLACES_REFRESH, Some(wire_params))
1246 .await?;
1247 Ok(serde_json::from_value(_value)?)
1248 }
1249
1250 /// Re-fetches one or all registered marketplace catalogs.
1251 ///
1252 /// Wire method: `plugins.marketplaces.refresh`.
1253 ///
1254 /// # Parameters
1255 ///
1256 /// * `params` - Optional marketplace name; omit to refresh all.
1257 ///
1258 /// # Returns
1259 ///
1260 /// Result of refreshing one or more marketplace catalogs.
1261 ///
1262 /// <div class="warning">
1263 ///
1264 /// **Experimental.** This API is part of an experimental wire-protocol surface
1265 /// and may change or be removed in future SDK or CLI releases. Pin both the
1266 /// SDK and CLI versions if your code depends on it.
1267 ///
1268 /// </div>
1269 pub async fn refresh_with_params(
1270 &self,
1271 params: PluginsMarketplacesRefreshRequest,
1272 ) -> Result<MarketplaceRefreshResult, Error> {
1273 let wire_params = serde_json::to_value(params)?;
1274 let _value = self
1275 .client
1276 .call(rpc_methods::PLUGINS_MARKETPLACES_REFRESH, Some(wire_params))
1277 .await?;
1278 Ok(serde_json::from_value(_value)?)
1279 }
1280}
1281
1282/// `runtime.*` RPCs.
1283#[derive(Clone, Copy)]
1284pub struct ClientRpcRuntime<'a> {
1285 pub(crate) client: &'a Client,
1286}
1287
1288impl<'a> ClientRpcRuntime<'a> {
1289 /// Gracefully shuts down an SDK-owned runtime. The response is sent only after cleanup completes; callers may then terminate the owned runtime process.
1290 ///
1291 /// Wire method: `runtime.shutdown`.
1292 ///
1293 /// <div class="warning">
1294 ///
1295 /// **Experimental.** This API is part of an experimental wire-protocol surface
1296 /// and may change or be removed in future SDK or CLI releases. Pin both the
1297 /// SDK and CLI versions if your code depends on it.
1298 ///
1299 /// </div>
1300 pub async fn shutdown(&self) -> Result<(), Error> {
1301 let wire_params = serde_json::json!({});
1302 let _value = self
1303 .client
1304 .call(rpc_methods::RUNTIME_SHUTDOWN, Some(wire_params))
1305 .await?;
1306 Ok(())
1307 }
1308}
1309
1310/// `secrets.*` RPCs.
1311#[derive(Clone, Copy)]
1312pub struct ClientRpcSecrets<'a> {
1313 pub(crate) client: &'a Client,
1314}
1315
1316impl<'a> ClientRpcSecrets<'a> {
1317 /// Registers secret values for redaction in session logs and exports. The SDK calls this to inject dynamically generated secret values (e.g., OIDC tokens).
1318 ///
1319 /// Wire method: `secrets.addFilterValues`.
1320 ///
1321 /// # Parameters
1322 ///
1323 /// * `params` - Secret values to add to the redaction filter.
1324 ///
1325 /// # Returns
1326 ///
1327 /// Confirmation that the secret values were registered.
1328 ///
1329 /// <div class="warning">
1330 ///
1331 /// **Experimental.** This API is part of an experimental wire-protocol surface
1332 /// and may change or be removed in future SDK or CLI releases. Pin both the
1333 /// SDK and CLI versions if your code depends on it.
1334 ///
1335 /// </div>
1336 pub async fn add_filter_values(
1337 &self,
1338 params: SecretsAddFilterValuesRequest,
1339 ) -> Result<SecretsAddFilterValuesResult, Error> {
1340 let wire_params = serde_json::to_value(params)?;
1341 let _value = self
1342 .client
1343 .call(rpc_methods::SECRETS_ADDFILTERVALUES, Some(wire_params))
1344 .await?;
1345 Ok(serde_json::from_value(_value)?)
1346 }
1347}
1348
1349/// `sessionFs.*` RPCs.
1350#[derive(Clone, Copy)]
1351pub struct ClientRpcSessionFs<'a> {
1352 pub(crate) client: &'a Client,
1353}
1354
1355impl<'a> ClientRpcSessionFs<'a> {
1356 /// Registers an SDK client as the session filesystem provider.
1357 ///
1358 /// Wire method: `sessionFs.setProvider`.
1359 ///
1360 /// # Parameters
1361 ///
1362 /// * `params` - Initial working directory, session-state path layout, and path conventions used to register the calling SDK client as the session filesystem provider.
1363 ///
1364 /// # Returns
1365 ///
1366 /// Indicates whether the calling client was registered as the session filesystem provider.
1367 ///
1368 /// <div class="warning">
1369 ///
1370 /// **Experimental.** This API is part of an experimental wire-protocol surface
1371 /// and may change or be removed in future SDK or CLI releases. Pin both the
1372 /// SDK and CLI versions if your code depends on it.
1373 ///
1374 /// </div>
1375 pub async fn set_provider(
1376 &self,
1377 params: SessionFsSetProviderRequest,
1378 ) -> Result<SessionFsSetProviderResult, Error> {
1379 let wire_params = serde_json::to_value(params)?;
1380 let _value = self
1381 .client
1382 .call(rpc_methods::SESSIONFS_SETPROVIDER, Some(wire_params))
1383 .await?;
1384 Ok(serde_json::from_value(_value)?)
1385 }
1386}
1387
1388/// `sessions.*` RPCs.
1389#[derive(Clone, Copy)]
1390pub struct ClientRpcSessions<'a> {
1391 pub(crate) client: &'a Client,
1392}
1393
1394impl<'a> ClientRpcSessions<'a> {
1395 /// Creates or resumes a local session and returns the opened session ID.
1396 ///
1397 /// Wire method: `sessions.open`.
1398 ///
1399 /// # Returns
1400 ///
1401 /// Result of opening a session.
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 open(&self) -> Result<SessionOpenResult, Error> {
1411 let wire_params = serde_json::json!({});
1412 let _value = self
1413 .client
1414 .call(rpc_methods::SESSIONS_OPEN, Some(wire_params))
1415 .await?;
1416 Ok(serde_json::from_value(_value)?)
1417 }
1418
1419 /// Creates a new session by forking persisted history from an existing session.
1420 ///
1421 /// Wire method: `sessions.fork`.
1422 ///
1423 /// # Parameters
1424 ///
1425 /// * `params` - Source session identifier to fork from, optional event-ID boundary, and optional friendly name for the new session.
1426 ///
1427 /// # Returns
1428 ///
1429 /// Identifier and optional friendly name assigned to the newly forked session.
1430 ///
1431 /// <div class="warning">
1432 ///
1433 /// **Experimental.** This API is part of an experimental wire-protocol surface
1434 /// and may change or be removed in future SDK or CLI releases. Pin both the
1435 /// SDK and CLI versions if your code depends on it.
1436 ///
1437 /// </div>
1438 pub async fn fork(&self, params: SessionsForkRequest) -> Result<SessionsForkResult, Error> {
1439 let wire_params = serde_json::to_value(params)?;
1440 let _value = self
1441 .client
1442 .call(rpc_methods::SESSIONS_FORK, Some(wire_params))
1443 .await?;
1444 Ok(serde_json::from_value(_value)?)
1445 }
1446
1447 /// Connects to an existing remote session and exposes it as an SDK session.
1448 ///
1449 /// Wire method: `sessions.connect`.
1450 ///
1451 /// # Parameters
1452 ///
1453 /// * `params` - Remote session connection parameters.
1454 ///
1455 /// # Returns
1456 ///
1457 /// Remote session connection result.
1458 ///
1459 /// <div class="warning">
1460 ///
1461 /// **Experimental.** This API is part of an experimental wire-protocol surface
1462 /// and may change or be removed in future SDK or CLI releases. Pin both the
1463 /// SDK and CLI versions if your code depends on it.
1464 ///
1465 /// </div>
1466 pub async fn connect(
1467 &self,
1468 params: ConnectRemoteSessionParams,
1469 ) -> Result<RemoteSessionConnectionResult, Error> {
1470 let wire_params = serde_json::to_value(params)?;
1471 let _value = self
1472 .client
1473 .call(rpc_methods::SESSIONS_CONNECT, Some(wire_params))
1474 .await?;
1475 Ok(serde_json::from_value(_value)?)
1476 }
1477
1478 /// 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.).
1479 ///
1480 /// Wire method: `sessions.list`.
1481 ///
1482 /// # Returns
1483 ///
1484 /// Sessions matching the filter, ordered most-recently-modified first.
1485 ///
1486 /// <div class="warning">
1487 ///
1488 /// **Experimental.** This API is part of an experimental wire-protocol surface
1489 /// and may change or be removed in future SDK or CLI releases. Pin both the
1490 /// SDK and CLI versions if your code depends on it.
1491 ///
1492 /// </div>
1493 pub async fn list(&self) -> Result<SessionList, Error> {
1494 let wire_params = serde_json::json!({});
1495 let _value = self
1496 .client
1497 .call(rpc_methods::SESSIONS_LIST, Some(wire_params))
1498 .await?;
1499 Ok(serde_json::from_value(_value)?)
1500 }
1501
1502 /// 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.).
1503 ///
1504 /// Wire method: `sessions.list`.
1505 ///
1506 /// # Parameters
1507 ///
1508 /// * `params` - Optional source filter, metadata-load limit, and context filter applied to the returned sessions.
1509 ///
1510 /// # Returns
1511 ///
1512 /// Sessions matching the filter, ordered most-recently-modified first.
1513 ///
1514 /// <div class="warning">
1515 ///
1516 /// **Experimental.** This API is part of an experimental wire-protocol surface
1517 /// and may change or be removed in future SDK or CLI releases. Pin both the
1518 /// SDK and CLI versions if your code depends on it.
1519 ///
1520 /// </div>
1521 pub async fn list_with_params(
1522 &self,
1523 params: SessionsListRequest,
1524 ) -> Result<SessionList, Error> {
1525 let wire_params = serde_json::to_value(params)?;
1526 let _value = self
1527 .client
1528 .call(rpc_methods::SESSIONS_LIST, Some(wire_params))
1529 .await?;
1530 Ok(serde_json::from_value(_value)?)
1531 }
1532
1533 /// Finds the local session bound to a GitHub task ID, if any.
1534 ///
1535 /// Wire method: `sessions.findByTaskId`.
1536 ///
1537 /// # Parameters
1538 ///
1539 /// * `params` - GitHub task ID to look up.
1540 ///
1541 /// # Returns
1542 ///
1543 /// ID of the local session bound to the given GitHub task, or omitted when none.
1544 ///
1545 /// <div class="warning">
1546 ///
1547 /// **Experimental.** This API is part of an experimental wire-protocol surface
1548 /// and may change or be removed in future SDK or CLI releases. Pin both the
1549 /// SDK and CLI versions if your code depends on it.
1550 ///
1551 /// </div>
1552 pub async fn find_by_task_id(
1553 &self,
1554 params: SessionsFindByTaskIDRequest,
1555 ) -> Result<SessionsFindByTaskIDResult, Error> {
1556 let wire_params = serde_json::to_value(params)?;
1557 let _value = self
1558 .client
1559 .call(rpc_methods::SESSIONS_FINDBYTASKID, Some(wire_params))
1560 .await?;
1561 Ok(serde_json::from_value(_value)?)
1562 }
1563
1564 /// Resolves a UUID prefix to a unique session ID, if exactly one session matches.
1565 ///
1566 /// Wire method: `sessions.findByPrefix`.
1567 ///
1568 /// # Parameters
1569 ///
1570 /// * `params` - UUID prefix to resolve to a unique session ID.
1571 ///
1572 /// # Returns
1573 ///
1574 /// Session ID matching the prefix, omitted when no unique match exists.
1575 ///
1576 /// <div class="warning">
1577 ///
1578 /// **Experimental.** This API is part of an experimental wire-protocol surface
1579 /// and may change or be removed in future SDK or CLI releases. Pin both the
1580 /// SDK and CLI versions if your code depends on it.
1581 ///
1582 /// </div>
1583 pub async fn find_by_prefix(
1584 &self,
1585 params: SessionsFindByPrefixRequest,
1586 ) -> Result<SessionsFindByPrefixResult, Error> {
1587 let wire_params = serde_json::to_value(params)?;
1588 let _value = self
1589 .client
1590 .call(rpc_methods::SESSIONS_FINDBYPREFIX, Some(wire_params))
1591 .await?;
1592 Ok(serde_json::from_value(_value)?)
1593 }
1594
1595 /// Returns the most-relevant prior session for a given working-directory context.
1596 ///
1597 /// Wire method: `sessions.getLastForContext`.
1598 ///
1599 /// # Parameters
1600 ///
1601 /// * `params` - Optional working-directory context used to score session relevance.
1602 ///
1603 /// # Returns
1604 ///
1605 /// Most-relevant session ID for the supplied context, or omitted when no sessions exist.
1606 ///
1607 /// <div class="warning">
1608 ///
1609 /// **Experimental.** This API is part of an experimental wire-protocol surface
1610 /// and may change or be removed in future SDK or CLI releases. Pin both the
1611 /// SDK and CLI versions if your code depends on it.
1612 ///
1613 /// </div>
1614 pub async fn get_last_for_context(
1615 &self,
1616 params: SessionsGetLastForContextRequest,
1617 ) -> Result<SessionsGetLastForContextResult, Error> {
1618 let wire_params = serde_json::to_value(params)?;
1619 let _value = self
1620 .client
1621 .call(rpc_methods::SESSIONS_GETLASTFORCONTEXT, Some(wire_params))
1622 .await?;
1623 Ok(serde_json::from_value(_value)?)
1624 }
1625
1626 /// 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.
1627 ///
1628 /// Wire method: `sessions.getEventFilePath`.
1629 ///
1630 /// # Parameters
1631 ///
1632 /// * `params` - Session ID whose event-log file path to compute.
1633 ///
1634 /// # Returns
1635 ///
1636 /// Absolute path to the session's events.jsonl file on disk.
1637 ///
1638 /// <div class="warning">
1639 ///
1640 /// **Experimental.** This API is part of an experimental wire-protocol surface
1641 /// and may change or be removed in future SDK or CLI releases. Pin both the
1642 /// SDK and CLI versions if your code depends on it.
1643 ///
1644 /// </div>
1645 pub(crate) async fn get_event_file_path(
1646 &self,
1647 params: SessionsGetEventFilePathRequest,
1648 ) -> Result<SessionsGetEventFilePathResult, Error> {
1649 let wire_params = serde_json::to_value(params)?;
1650 let _value = self
1651 .client
1652 .call(rpc_methods::SESSIONS_GETEVENTFILEPATH, Some(wire_params))
1653 .await?;
1654 Ok(serde_json::from_value(_value)?)
1655 }
1656
1657 /// Returns the on-disk byte size of each session's workspace directory.
1658 ///
1659 /// Wire method: `sessions.getSizes`.
1660 ///
1661 /// # Returns
1662 ///
1663 /// Map of sessionId -> on-disk size in bytes for each session's workspace directory.
1664 ///
1665 /// <div class="warning">
1666 ///
1667 /// **Experimental.** This API is part of an experimental wire-protocol surface
1668 /// and may change or be removed in future SDK or CLI releases. Pin both the
1669 /// SDK and CLI versions if your code depends on it.
1670 ///
1671 /// </div>
1672 pub async fn get_sizes(&self) -> Result<SessionSizes, Error> {
1673 let wire_params = serde_json::json!({});
1674 let _value = self
1675 .client
1676 .call(rpc_methods::SESSIONS_GETSIZES, Some(wire_params))
1677 .await?;
1678 Ok(serde_json::from_value(_value)?)
1679 }
1680
1681 /// Returns the subset of the supplied session IDs that are currently held by another running process.
1682 ///
1683 /// Wire method: `sessions.checkInUse`.
1684 ///
1685 /// # Parameters
1686 ///
1687 /// * `params` - Session IDs to test for live in-use locks.
1688 ///
1689 /// # Returns
1690 ///
1691 /// Session IDs from the input set that are currently in use by another process.
1692 ///
1693 /// <div class="warning">
1694 ///
1695 /// **Experimental.** This API is part of an experimental wire-protocol surface
1696 /// and may change or be removed in future SDK or CLI releases. Pin both the
1697 /// SDK and CLI versions if your code depends on it.
1698 ///
1699 /// </div>
1700 pub async fn check_in_use(
1701 &self,
1702 params: SessionsCheckInUseRequest,
1703 ) -> Result<SessionsCheckInUseResult, Error> {
1704 let wire_params = serde_json::to_value(params)?;
1705 let _value = self
1706 .client
1707 .call(rpc_methods::SESSIONS_CHECKINUSE, Some(wire_params))
1708 .await?;
1709 Ok(serde_json::from_value(_value)?)
1710 }
1711
1712 /// 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.
1713 ///
1714 /// Wire method: `sessions.getPersistedRemoteSteerable`.
1715 ///
1716 /// # Parameters
1717 ///
1718 /// * `params` - Session ID to look up the persisted remote-steerable flag for.
1719 ///
1720 /// # Returns
1721 ///
1722 /// The session's persisted remote-steerable flag, or omitted when no value has been persisted.
1723 ///
1724 /// <div class="warning">
1725 ///
1726 /// **Experimental.** This API is part of an experimental wire-protocol surface
1727 /// and may change or be removed in future SDK or CLI releases. Pin both the
1728 /// SDK and CLI versions if your code depends on it.
1729 ///
1730 /// </div>
1731 pub(crate) async fn get_persisted_remote_steerable(
1732 &self,
1733 params: SessionsGetPersistedRemoteSteerableRequest,
1734 ) -> Result<SessionsGetPersistedRemoteSteerableResult, Error> {
1735 let wire_params = serde_json::to_value(params)?;
1736 let _value = self
1737 .client
1738 .call(
1739 rpc_methods::SESSIONS_GETPERSISTEDREMOTESTEERABLE,
1740 Some(wire_params),
1741 )
1742 .await?;
1743 Ok(serde_json::from_value(_value)?)
1744 }
1745
1746 /// Closes a session: emits shutdown, flushes pending events, releases the in-use lock, and disposes the active session.
1747 ///
1748 /// Wire method: `sessions.close`.
1749 ///
1750 /// # Parameters
1751 ///
1752 /// * `params` - Session ID to close.
1753 ///
1754 /// # Returns
1755 ///
1756 /// 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.
1757 ///
1758 /// <div class="warning">
1759 ///
1760 /// **Experimental.** This API is part of an experimental wire-protocol surface
1761 /// and may change or be removed in future SDK or CLI releases. Pin both the
1762 /// SDK and CLI versions if your code depends on it.
1763 ///
1764 /// </div>
1765 pub async fn close(&self, params: SessionsCloseRequest) -> Result<SessionsCloseResult, Error> {
1766 let wire_params = serde_json::to_value(params)?;
1767 let _value = self
1768 .client
1769 .call(rpc_methods::SESSIONS_CLOSE, Some(wire_params))
1770 .await?;
1771 Ok(serde_json::from_value(_value)?)
1772 }
1773
1774 /// Closes, deactivates, and deletes a set of sessions, returning the bytes freed per session.
1775 ///
1776 /// Wire method: `sessions.bulkDelete`.
1777 ///
1778 /// # Parameters
1779 ///
1780 /// * `params` - Session IDs to close, deactivate, and delete from disk.
1781 ///
1782 /// # Returns
1783 ///
1784 /// Map of sessionId -> bytes freed by removing the session's workspace directory.
1785 ///
1786 /// <div class="warning">
1787 ///
1788 /// **Experimental.** This API is part of an experimental wire-protocol surface
1789 /// and may change or be removed in future SDK or CLI releases. Pin both the
1790 /// SDK and CLI versions if your code depends on it.
1791 ///
1792 /// </div>
1793 pub async fn bulk_delete(
1794 &self,
1795 params: SessionsBulkDeleteRequest,
1796 ) -> Result<SessionBulkDeleteResult, Error> {
1797 let wire_params = serde_json::to_value(params)?;
1798 let _value = self
1799 .client
1800 .call(rpc_methods::SESSIONS_BULKDELETE, Some(wire_params))
1801 .await?;
1802 Ok(serde_json::from_value(_value)?)
1803 }
1804
1805 /// Deletes sessions older than the given threshold, with optional dry-run and exclusion list.
1806 ///
1807 /// Wire method: `sessions.pruneOld`.
1808 ///
1809 /// # Parameters
1810 ///
1811 /// * `params` - Age threshold and optional flags controlling which old sessions are pruned (or simulated when dryRun is true).
1812 ///
1813 /// # Returns
1814 ///
1815 /// Outcome of the prune operation: deleted IDs, dry-run candidates, skipped IDs, total bytes freed, and the dry-run flag.
1816 ///
1817 /// <div class="warning">
1818 ///
1819 /// **Experimental.** This API is part of an experimental wire-protocol surface
1820 /// and may change or be removed in future SDK or CLI releases. Pin both the
1821 /// SDK and CLI versions if your code depends on it.
1822 ///
1823 /// </div>
1824 pub async fn prune_old(
1825 &self,
1826 params: SessionsPruneOldRequest,
1827 ) -> Result<SessionPruneResult, Error> {
1828 let wire_params = serde_json::to_value(params)?;
1829 let _value = self
1830 .client
1831 .call(rpc_methods::SESSIONS_PRUNEOLD, Some(wire_params))
1832 .await?;
1833 Ok(serde_json::from_value(_value)?)
1834 }
1835
1836 /// Flushes a session's pending events to disk.
1837 ///
1838 /// Wire method: `sessions.save`.
1839 ///
1840 /// # Parameters
1841 ///
1842 /// * `params` - Session ID whose pending events should be flushed to disk.
1843 ///
1844 /// # Returns
1845 ///
1846 /// Flush a session's pending events to disk. No-op when no writer exists for the session (e.g., already closed).
1847 ///
1848 /// <div class="warning">
1849 ///
1850 /// **Experimental.** This API is part of an experimental wire-protocol surface
1851 /// and may change or be removed in future SDK or CLI releases. Pin both the
1852 /// SDK and CLI versions if your code depends on it.
1853 ///
1854 /// </div>
1855 pub async fn save(&self, params: SessionsSaveRequest) -> Result<SessionsSaveResult, Error> {
1856 let wire_params = serde_json::to_value(params)?;
1857 let _value = self
1858 .client
1859 .call(rpc_methods::SESSIONS_SAVE, Some(wire_params))
1860 .await?;
1861 Ok(serde_json::from_value(_value)?)
1862 }
1863
1864 /// Releases the in-use lock held by this process for a session.
1865 ///
1866 /// Wire method: `sessions.releaseLock`.
1867 ///
1868 /// # Parameters
1869 ///
1870 /// * `params` - Session ID whose in-use lock should be released.
1871 ///
1872 /// # Returns
1873 ///
1874 /// 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.
1875 ///
1876 /// <div class="warning">
1877 ///
1878 /// **Experimental.** This API is part of an experimental wire-protocol surface
1879 /// and may change or be removed in future SDK or CLI releases. Pin both the
1880 /// SDK and CLI versions if your code depends on it.
1881 ///
1882 /// </div>
1883 pub async fn release_lock(
1884 &self,
1885 params: SessionsReleaseLockRequest,
1886 ) -> Result<SessionsReleaseLockResult, Error> {
1887 let wire_params = serde_json::to_value(params)?;
1888 let _value = self
1889 .client
1890 .call(rpc_methods::SESSIONS_RELEASELOCK, Some(wire_params))
1891 .await?;
1892 Ok(serde_json::from_value(_value)?)
1893 }
1894
1895 /// Backfills missing summary and context fields on the supplied session metadata records.
1896 ///
1897 /// Wire method: `sessions.enrichMetadata`.
1898 ///
1899 /// # Parameters
1900 ///
1901 /// * `params` - Session metadata records to enrich with summary and context information.
1902 ///
1903 /// # Returns
1904 ///
1905 /// The enriched metadata records, with summary and context fields backfilled where available. Sessions confirmed empty and unnamed are omitted.
1906 ///
1907 /// <div class="warning">
1908 ///
1909 /// **Experimental.** This API is part of an experimental wire-protocol surface
1910 /// and may change or be removed in future SDK or CLI releases. Pin both the
1911 /// SDK and CLI versions if your code depends on it.
1912 ///
1913 /// </div>
1914 pub async fn enrich_metadata(
1915 &self,
1916 params: SessionsEnrichMetadataRequest,
1917 ) -> Result<SessionEnrichMetadataResult, Error> {
1918 let wire_params = serde_json::to_value(params)?;
1919 let _value = self
1920 .client
1921 .call(rpc_methods::SESSIONS_ENRICHMETADATA, Some(wire_params))
1922 .await?;
1923 Ok(serde_json::from_value(_value)?)
1924 }
1925
1926 /// Reloads user, plugin, and (optionally) repo hooks on the active session.
1927 ///
1928 /// Wire method: `sessions.reloadPluginHooks`.
1929 ///
1930 /// # Parameters
1931 ///
1932 /// * `params` - Active session ID and an optional flag for deferring repo-level hooks until folder trust.
1933 ///
1934 /// # Returns
1935 ///
1936 /// 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.
1937 ///
1938 /// <div class="warning">
1939 ///
1940 /// **Experimental.** This API is part of an experimental wire-protocol surface
1941 /// and may change or be removed in future SDK or CLI releases. Pin both the
1942 /// SDK and CLI versions if your code depends on it.
1943 ///
1944 /// </div>
1945 pub async fn reload_plugin_hooks(
1946 &self,
1947 params: SessionsReloadPluginHooksRequest,
1948 ) -> Result<SessionsReloadPluginHooksResult, Error> {
1949 let wire_params = serde_json::to_value(params)?;
1950 let _value = self
1951 .client
1952 .call(rpc_methods::SESSIONS_RELOADPLUGINHOOKS, Some(wire_params))
1953 .await?;
1954 Ok(serde_json::from_value(_value)?)
1955 }
1956
1957 /// Loads previously-deferred repo-level hooks on the active session, returning queued startup prompts.
1958 ///
1959 /// Wire method: `sessions.loadDeferredRepoHooks`.
1960 ///
1961 /// # Parameters
1962 ///
1963 /// * `params` - Active session ID whose deferred repo-level hooks should be loaded.
1964 ///
1965 /// # Returns
1966 ///
1967 /// Queued repo-level startup prompts and the total hook command count after loading.
1968 ///
1969 /// <div class="warning">
1970 ///
1971 /// **Experimental.** This API is part of an experimental wire-protocol surface
1972 /// and may change or be removed in future SDK or CLI releases. Pin both the
1973 /// SDK and CLI versions if your code depends on it.
1974 ///
1975 /// </div>
1976 pub async fn load_deferred_repo_hooks(
1977 &self,
1978 params: SessionsLoadDeferredRepoHooksRequest,
1979 ) -> Result<SessionLoadDeferredRepoHooksResult, Error> {
1980 let wire_params = serde_json::to_value(params)?;
1981 let _value = self
1982 .client
1983 .call(
1984 rpc_methods::SESSIONS_LOADDEFERREDREPOHOOKS,
1985 Some(wire_params),
1986 )
1987 .await?;
1988 Ok(serde_json::from_value(_value)?)
1989 }
1990
1991 /// Replaces the manager-wide additional plugins registered with the session manager.
1992 ///
1993 /// Wire method: `sessions.setAdditionalPlugins`.
1994 ///
1995 /// # Parameters
1996 ///
1997 /// * `params` - Manager-wide additional plugins to register; replaces any previously-configured set.
1998 ///
1999 /// # Returns
2000 ///
2001 /// 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.
2002 ///
2003 /// <div class="warning">
2004 ///
2005 /// **Experimental.** This API is part of an experimental wire-protocol surface
2006 /// and may change or be removed in future SDK or CLI releases. Pin both the
2007 /// SDK and CLI versions if your code depends on it.
2008 ///
2009 /// </div>
2010 pub async fn set_additional_plugins(
2011 &self,
2012 params: SessionsSetAdditionalPluginsRequest,
2013 ) -> Result<SessionsSetAdditionalPluginsResult, Error> {
2014 let wire_params = serde_json::to_value(params)?;
2015 let _value = self
2016 .client
2017 .call(
2018 rpc_methods::SESSIONS_SETADDITIONALPLUGINS,
2019 Some(wire_params),
2020 )
2021 .await?;
2022 Ok(serde_json::from_value(_value)?)
2023 }
2024
2025 /// 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.
2026 ///
2027 /// Wire method: `sessions.getBoardEntryCount`.
2028 ///
2029 /// # Parameters
2030 ///
2031 /// * `params` - Session ID whose board entry count should be returned.
2032 ///
2033 /// # Returns
2034 ///
2035 /// Dynamic-context board entry count, when available.
2036 ///
2037 /// <div class="warning">
2038 ///
2039 /// **Experimental.** This API is part of an experimental wire-protocol surface
2040 /// and may change or be removed in future SDK or CLI releases. Pin both the
2041 /// SDK and CLI versions if your code depends on it.
2042 ///
2043 /// </div>
2044 pub(crate) async fn get_board_entry_count(
2045 &self,
2046 params: SessionsGetBoardEntryCountRequest,
2047 ) -> Result<SessionsGetBoardEntryCountResult, Error> {
2048 let wire_params = serde_json::to_value(params)?;
2049 let _value = self
2050 .client
2051 .call(rpc_methods::SESSIONS_GETBOARDENTRYCOUNT, Some(wire_params))
2052 .await?;
2053 Ok(serde_json::from_value(_value)?)
2054 }
2055
2056 /// 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.
2057 ///
2058 /// Wire method: `sessions.startRemoteControl`.
2059 ///
2060 /// # Parameters
2061 ///
2062 /// * `params` - Parameters for attaching the remote-control singleton to a session.
2063 ///
2064 /// # Returns
2065 ///
2066 /// Wrapper for the singleton's current status.
2067 ///
2068 /// <div class="warning">
2069 ///
2070 /// **Experimental.** This API is part of an experimental wire-protocol surface
2071 /// and may change or be removed in future SDK or CLI releases. Pin both the
2072 /// SDK and CLI versions if your code depends on it.
2073 ///
2074 /// </div>
2075 pub async fn start_remote_control(
2076 &self,
2077 params: SessionsStartRemoteControlRequest,
2078 ) -> Result<RemoteControlStatusResult, Error> {
2079 let wire_params = serde_json::to_value(params)?;
2080 let _value = self
2081 .client
2082 .call(rpc_methods::SESSIONS_STARTREMOTECONTROL, Some(wire_params))
2083 .await?;
2084 Ok(serde_json::from_value(_value)?)
2085 }
2086
2087 /// 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.
2088 ///
2089 /// Wire method: `sessions.transferRemoteControl`.
2090 ///
2091 /// # Parameters
2092 ///
2093 /// * `params` - Parameters for atomically rebinding the remote-control singleton.
2094 ///
2095 /// # Returns
2096 ///
2097 /// Outcome of a transferRemoteControl call.
2098 ///
2099 /// <div class="warning">
2100 ///
2101 /// **Experimental.** This API is part of an experimental wire-protocol surface
2102 /// and may change or be removed in future SDK or CLI releases. Pin both the
2103 /// SDK and CLI versions if your code depends on it.
2104 ///
2105 /// </div>
2106 pub async fn transfer_remote_control(
2107 &self,
2108 params: SessionsTransferRemoteControlRequest,
2109 ) -> Result<RemoteControlTransferResult, Error> {
2110 let wire_params = serde_json::to_value(params)?;
2111 let _value = self
2112 .client
2113 .call(
2114 rpc_methods::SESSIONS_TRANSFERREMOTECONTROL,
2115 Some(wire_params),
2116 )
2117 .await?;
2118 Ok(serde_json::from_value(_value)?)
2119 }
2120
2121 /// 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.
2122 ///
2123 /// Wire method: `sessions.setRemoteControlSteering`.
2124 ///
2125 /// # Parameters
2126 ///
2127 /// * `params` - Patch for the singleton's steering state.
2128 ///
2129 /// # Returns
2130 ///
2131 /// Wrapper for the singleton's current status.
2132 ///
2133 /// <div class="warning">
2134 ///
2135 /// **Experimental.** This API is part of an experimental wire-protocol surface
2136 /// and may change or be removed in future SDK or CLI releases. Pin both the
2137 /// SDK and CLI versions if your code depends on it.
2138 ///
2139 /// </div>
2140 pub async fn set_remote_control_steering(
2141 &self,
2142 params: SessionsSetRemoteControlSteeringRequest,
2143 ) -> Result<RemoteControlStatusResult, Error> {
2144 let wire_params = serde_json::to_value(params)?;
2145 let _value = self
2146 .client
2147 .call(
2148 rpc_methods::SESSIONS_SETREMOTECONTROLSTEERING,
2149 Some(wire_params),
2150 )
2151 .await?;
2152 Ok(serde_json::from_value(_value)?)
2153 }
2154
2155 /// 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).
2156 ///
2157 /// Wire method: `sessions.stopRemoteControl`.
2158 ///
2159 /// # Returns
2160 ///
2161 /// Outcome of a stopRemoteControl call.
2162 ///
2163 /// <div class="warning">
2164 ///
2165 /// **Experimental.** This API is part of an experimental wire-protocol surface
2166 /// and may change or be removed in future SDK or CLI releases. Pin both the
2167 /// SDK and CLI versions if your code depends on it.
2168 ///
2169 /// </div>
2170 pub async fn stop_remote_control(&self) -> Result<RemoteControlStopResult, Error> {
2171 let wire_params = serde_json::json!({});
2172 let _value = self
2173 .client
2174 .call(rpc_methods::SESSIONS_STOPREMOTECONTROL, Some(wire_params))
2175 .await?;
2176 Ok(serde_json::from_value(_value)?)
2177 }
2178
2179 /// 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).
2180 ///
2181 /// Wire method: `sessions.stopRemoteControl`.
2182 ///
2183 /// # Parameters
2184 ///
2185 /// * `params` - Parameters for stopping the remote-control singleton.
2186 ///
2187 /// # Returns
2188 ///
2189 /// Outcome of a stopRemoteControl call.
2190 ///
2191 /// <div class="warning">
2192 ///
2193 /// **Experimental.** This API is part of an experimental wire-protocol surface
2194 /// and may change or be removed in future SDK or CLI releases. Pin both the
2195 /// SDK and CLI versions if your code depends on it.
2196 ///
2197 /// </div>
2198 pub async fn stop_remote_control_with_params(
2199 &self,
2200 params: SessionsStopRemoteControlRequest,
2201 ) -> Result<RemoteControlStopResult, Error> {
2202 let wire_params = serde_json::to_value(params)?;
2203 let _value = self
2204 .client
2205 .call(rpc_methods::SESSIONS_STOPREMOTECONTROL, Some(wire_params))
2206 .await?;
2207 Ok(serde_json::from_value(_value)?)
2208 }
2209
2210 /// Returns the current state of the remote-control singleton, including the attached session id and frontend URL when active.
2211 ///
2212 /// Wire method: `sessions.getRemoteControlStatus`.
2213 ///
2214 /// # Returns
2215 ///
2216 /// Wrapper for the singleton's current status.
2217 ///
2218 /// <div class="warning">
2219 ///
2220 /// **Experimental.** This API is part of an experimental wire-protocol surface
2221 /// and may change or be removed in future SDK or CLI releases. Pin both the
2222 /// SDK and CLI versions if your code depends on it.
2223 ///
2224 /// </div>
2225 pub async fn get_remote_control_status(&self) -> Result<RemoteControlStatusResult, Error> {
2226 let wire_params = serde_json::json!({});
2227 let _value = self
2228 .client
2229 .call(
2230 rpc_methods::SESSIONS_GETREMOTECONTROLSTATUS,
2231 Some(wire_params),
2232 )
2233 .await?;
2234 Ok(serde_json::from_value(_value)?)
2235 }
2236
2237 /// Cursor-based long-poll for sessions spawned by the runtime (e.g. in response to a Mission Control `start_session` command). The cursor is an opaque token; pass it back to receive only spawn events that occurred AFTER the cursor was issued. Omit the cursor on the first call to receive any events buffered since the runtime started. Internal: this is a CLI background-daemon plumbing primitive. SDK consumers that need to react to runtime-spawned sessions should subscribe to a higher-level event stream rather than driving a long-poll loop.
2238 ///
2239 /// Wire method: `sessions.pollSpawnedSessions`.
2240 ///
2241 /// # Returns
2242 ///
2243 /// Batch of spawn events plus a cursor for follow-up polls.
2244 ///
2245 /// <div class="warning">
2246 ///
2247 /// **Experimental.** This API is part of an experimental wire-protocol surface
2248 /// and may change or be removed in future SDK or CLI releases. Pin both the
2249 /// SDK and CLI versions if your code depends on it.
2250 ///
2251 /// </div>
2252 pub(crate) async fn poll_spawned_sessions(&self) -> Result<PollSpawnedSessionsResult, Error> {
2253 let wire_params = serde_json::json!({});
2254 let _value = self
2255 .client
2256 .call(rpc_methods::SESSIONS_POLLSPAWNEDSESSIONS, Some(wire_params))
2257 .await?;
2258 Ok(serde_json::from_value(_value)?)
2259 }
2260
2261 /// Cursor-based long-poll for sessions spawned by the runtime (e.g. in response to a Mission Control `start_session` command). The cursor is an opaque token; pass it back to receive only spawn events that occurred AFTER the cursor was issued. Omit the cursor on the first call to receive any events buffered since the runtime started. Internal: this is a CLI background-daemon plumbing primitive. SDK consumers that need to react to runtime-spawned sessions should subscribe to a higher-level event stream rather than driving a long-poll loop.
2262 ///
2263 /// Wire method: `sessions.pollSpawnedSessions`.
2264 ///
2265 /// # Parameters
2266 ///
2267 /// * `params` - Cursor and optional long-poll wait for polling runtime-spawned sessions.
2268 ///
2269 /// # Returns
2270 ///
2271 /// Batch of spawn events plus a cursor for follow-up polls.
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 poll_spawned_sessions_with_params(
2281 &self,
2282 params: SessionsPollSpawnedSessionsRequest,
2283 ) -> Result<PollSpawnedSessionsResult, Error> {
2284 let wire_params = serde_json::to_value(params)?;
2285 let _value = self
2286 .client
2287 .call(rpc_methods::SESSIONS_POLLSPAWNEDSESSIONS, Some(wire_params))
2288 .await?;
2289 Ok(serde_json::from_value(_value)?)
2290 }
2291
2292 /// Registers extension-provided tools on the given session, gated by an optional `enabled` callback. Returns an opaque unsubscribe function the caller must invoke to deregister the tools when the extension is torn down. Marked internal because `loader`, `enabled`, and the returned `unsubscribe` are in-process handles that cannot cross the JSON-RPC boundary. Disappears once extension discovery / launch / tool registration are owned by the runtime: SDK consumers will pass pure config (search paths, disabled ids) via `SessionOptions` and the runtime will resolve, launch, register, and tear down extensions itself.
2293 ///
2294 /// Wire method: `sessions.registerExtensionToolsOnSession`.
2295 ///
2296 /// # Parameters
2297 ///
2298 /// * `params` - Params to attach an extension loader's tools to a session.
2299 ///
2300 /// # Returns
2301 ///
2302 /// Handle for releasing the extension tool registration.
2303 ///
2304 /// <div class="warning">
2305 ///
2306 /// **Experimental.** This API is part of an experimental wire-protocol surface
2307 /// and may change or be removed in future SDK or CLI releases. Pin both the
2308 /// SDK and CLI versions if your code depends on it.
2309 ///
2310 /// </div>
2311 pub(crate) async fn register_extension_tools_on_session(
2312 &self,
2313 params: RegisterExtensionToolsParams,
2314 ) -> Result<RegisterExtensionToolsResult, Error> {
2315 let wire_params = serde_json::to_value(params)?;
2316 let _value = self
2317 .client
2318 .call(
2319 rpc_methods::SESSIONS_REGISTEREXTENSIONTOOLSONSESSION,
2320 Some(wire_params),
2321 )
2322 .await?;
2323 Ok(serde_json::from_value(_value)?)
2324 }
2325
2326 /// Attaches (or detaches) an in-process ExtensionController delegate for the given session, used by shared-API surfaces that need to query or modify the session's extension state. Pass `controller: undefined` to detach. Marked internal because the controller is an in-process object that cannot cross the JSON-RPC boundary. Disappears alongside `registerExtensionToolsOnSession`: once the runtime owns extension management, the public surface exposes list/enable/disable/reload as dedicated RPCs served by the runtime.
2327 ///
2328 /// Wire method: `sessions.configureSessionExtensions`.
2329 ///
2330 /// # Parameters
2331 ///
2332 /// * `params` - Params to attach or detach an in-process ExtensionController delegate.
2333 ///
2334 /// <div class="warning">
2335 ///
2336 /// **Experimental.** This API is part of an experimental wire-protocol surface
2337 /// and may change or be removed in future SDK or CLI releases. Pin both the
2338 /// SDK and CLI versions if your code depends on it.
2339 ///
2340 /// </div>
2341 pub(crate) async fn configure_session_extensions(
2342 &self,
2343 params: ConfigureSessionExtensionsParams,
2344 ) -> Result<(), Error> {
2345 let wire_params = serde_json::to_value(params)?;
2346 let _value = self
2347 .client
2348 .call(
2349 rpc_methods::SESSIONS_CONFIGURESESSIONEXTENSIONS,
2350 Some(wire_params),
2351 )
2352 .await?;
2353 Ok(())
2354 }
2355}
2356
2357/// `skills.*` RPCs.
2358#[derive(Clone, Copy)]
2359pub struct ClientRpcSkills<'a> {
2360 pub(crate) client: &'a Client,
2361}
2362
2363impl<'a> ClientRpcSkills<'a> {
2364 /// `skills.config.*` sub-namespace.
2365 pub fn config(&self) -> ClientRpcSkillsConfig<'a> {
2366 ClientRpcSkillsConfig {
2367 client: self.client,
2368 }
2369 }
2370
2371 /// Discovers skills across global and project sources.
2372 ///
2373 /// Wire method: `skills.discover`.
2374 ///
2375 /// # Parameters
2376 ///
2377 /// * `params` - Optional project paths and additional skill directories to include in discovery.
2378 ///
2379 /// # Returns
2380 ///
2381 /// Skills discovered across global and project sources.
2382 ///
2383 /// <div class="warning">
2384 ///
2385 /// **Experimental.** This API is part of an experimental wire-protocol surface
2386 /// and may change or be removed in future SDK or CLI releases. Pin both the
2387 /// SDK and CLI versions if your code depends on it.
2388 ///
2389 /// </div>
2390 pub async fn discover(&self, params: SkillsDiscoverRequest) -> Result<ServerSkillList, Error> {
2391 let wire_params = serde_json::to_value(params)?;
2392 let _value = self
2393 .client
2394 .call(rpc_methods::SKILLS_DISCOVER, Some(wire_params))
2395 .await?;
2396 Ok(serde_json::from_value(_value)?)
2397 }
2398
2399 /// 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.
2400 ///
2401 /// Wire method: `skills.getDiscoveryPaths`.
2402 ///
2403 /// # Parameters
2404 ///
2405 /// * `params` - Optional project paths to enumerate.
2406 ///
2407 /// # Returns
2408 ///
2409 /// Canonical locations where skills can be created so the runtime will recognize them.
2410 ///
2411 /// <div class="warning">
2412 ///
2413 /// **Experimental.** This API is part of an experimental wire-protocol surface
2414 /// and may change or be removed in future SDK or CLI releases. Pin both the
2415 /// SDK and CLI versions if your code depends on it.
2416 ///
2417 /// </div>
2418 pub async fn get_discovery_paths(
2419 &self,
2420 params: SkillsGetDiscoveryPathsRequest,
2421 ) -> Result<SkillDiscoveryPathList, Error> {
2422 let wire_params = serde_json::to_value(params)?;
2423 let _value = self
2424 .client
2425 .call(rpc_methods::SKILLS_GETDISCOVERYPATHS, Some(wire_params))
2426 .await?;
2427 Ok(serde_json::from_value(_value)?)
2428 }
2429}
2430
2431/// `skills.config.*` RPCs.
2432#[derive(Clone, Copy)]
2433pub struct ClientRpcSkillsConfig<'a> {
2434 pub(crate) client: &'a Client,
2435}
2436
2437impl<'a> ClientRpcSkillsConfig<'a> {
2438 /// Replaces the global list of disabled skills.
2439 ///
2440 /// Wire method: `skills.config.setDisabledSkills`.
2441 ///
2442 /// # Parameters
2443 ///
2444 /// * `params` - Skill names to mark as disabled in global configuration, replacing any previous list.
2445 ///
2446 /// <div class="warning">
2447 ///
2448 /// **Experimental.** This API is part of an experimental wire-protocol surface
2449 /// and may change or be removed in future SDK or CLI releases. Pin both the
2450 /// SDK and CLI versions if your code depends on it.
2451 ///
2452 /// </div>
2453 pub async fn set_disabled_skills(
2454 &self,
2455 params: SkillsConfigSetDisabledSkillsRequest,
2456 ) -> Result<(), Error> {
2457 let wire_params = serde_json::to_value(params)?;
2458 let _value = self
2459 .client
2460 .call(
2461 rpc_methods::SKILLS_CONFIG_SETDISABLEDSKILLS,
2462 Some(wire_params),
2463 )
2464 .await?;
2465 Ok(())
2466 }
2467}
2468
2469/// `tools.*` RPCs.
2470#[derive(Clone, Copy)]
2471pub struct ClientRpcTools<'a> {
2472 pub(crate) client: &'a Client,
2473}
2474
2475impl<'a> ClientRpcTools<'a> {
2476 /// Lists built-in tools available for a model.
2477 ///
2478 /// Wire method: `tools.list`.
2479 ///
2480 /// # Parameters
2481 ///
2482 /// * `params` - Optional model identifier whose tool overrides should be applied to the listing.
2483 ///
2484 /// # Returns
2485 ///
2486 /// Built-in tools available for the requested model, with their parameters and instructions.
2487 ///
2488 /// <div class="warning">
2489 ///
2490 /// **Experimental.** This API is part of an experimental wire-protocol surface
2491 /// and may change or be removed in future SDK or CLI releases. Pin both the
2492 /// SDK and CLI versions if your code depends on it.
2493 ///
2494 /// </div>
2495 pub async fn list(&self, params: ToolsListRequest) -> Result<ToolList, Error> {
2496 let wire_params = serde_json::to_value(params)?;
2497 let _value = self
2498 .client
2499 .call(rpc_methods::TOOLS_LIST, Some(wire_params))
2500 .await?;
2501 Ok(serde_json::from_value(_value)?)
2502 }
2503}
2504
2505/// `user.*` RPCs.
2506#[derive(Clone, Copy)]
2507pub struct ClientRpcUser<'a> {
2508 pub(crate) client: &'a Client,
2509}
2510
2511impl<'a> ClientRpcUser<'a> {
2512 /// `user.settings.*` sub-namespace.
2513 pub fn settings(&self) -> ClientRpcUserSettings<'a> {
2514 ClientRpcUserSettings {
2515 client: self.client,
2516 }
2517 }
2518}
2519
2520/// `user.settings.*` RPCs.
2521#[derive(Clone, Copy)]
2522pub struct ClientRpcUserSettings<'a> {
2523 pub(crate) client: &'a Client,
2524}
2525
2526impl<'a> ClientRpcUserSettings<'a> {
2527 /// Drops this runtime process's in-memory user settings cache so the next settings read observes disk.
2528 ///
2529 /// Wire method: `user.settings.reload`.
2530 ///
2531 /// <div class="warning">
2532 ///
2533 /// **Experimental.** This API is part of an experimental wire-protocol surface
2534 /// and may change or be removed in future SDK or CLI releases. Pin both the
2535 /// SDK and CLI versions if your code depends on it.
2536 ///
2537 /// </div>
2538 pub async fn reload(&self) -> Result<(), Error> {
2539 let wire_params = serde_json::json!({});
2540 let _value = self
2541 .client
2542 .call(rpc_methods::USER_SETTINGS_RELOAD, Some(wire_params))
2543 .await?;
2544 Ok(())
2545 }
2546
2547 /// 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.
2548 ///
2549 /// Wire method: `user.settings.get`.
2550 ///
2551 /// # Returns
2552 ///
2553 /// 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.
2554 ///
2555 /// <div class="warning">
2556 ///
2557 /// **Experimental.** This API is part of an experimental wire-protocol surface
2558 /// and may change or be removed in future SDK or CLI releases. Pin both the
2559 /// SDK and CLI versions if your code depends on it.
2560 ///
2561 /// </div>
2562 pub async fn get(&self) -> Result<UserSettingsGetResult, Error> {
2563 let wire_params = serde_json::json!({});
2564 let _value = self
2565 .client
2566 .call(rpc_methods::USER_SETTINGS_GET, Some(wire_params))
2567 .await?;
2568 Ok(serde_json::from_value(_value)?)
2569 }
2570
2571 /// 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.
2572 ///
2573 /// Wire method: `user.settings.set`.
2574 ///
2575 /// # Parameters
2576 ///
2577 /// * `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.
2578 ///
2579 /// # Returns
2580 ///
2581 /// Outcome of writing user settings.
2582 ///
2583 /// <div class="warning">
2584 ///
2585 /// **Experimental.** This API is part of an experimental wire-protocol surface
2586 /// and may change or be removed in future SDK or CLI releases. Pin both the
2587 /// SDK and CLI versions if your code depends on it.
2588 ///
2589 /// </div>
2590 pub async fn set(
2591 &self,
2592 params: UserSettingsSetRequest,
2593 ) -> Result<UserSettingsSetResult, Error> {
2594 let wire_params = serde_json::to_value(params)?;
2595 let _value = self
2596 .client
2597 .call(rpc_methods::USER_SETTINGS_SET, Some(wire_params))
2598 .await?;
2599 Ok(serde_json::from_value(_value)?)
2600 }
2601}
2602
2603/// Typed view over a [`Session`]'s RPC namespace.
2604#[derive(Clone, Copy)]
2605pub struct SessionRpc<'a> {
2606 pub(crate) session: &'a Session,
2607}
2608
2609impl<'a> SessionRpc<'a> {
2610 /// `session.agent.*` sub-namespace.
2611 pub fn agent(&self) -> SessionRpcAgent<'a> {
2612 SessionRpcAgent {
2613 session: self.session,
2614 }
2615 }
2616
2617 /// `session.canvas.*` sub-namespace.
2618 pub fn canvas(&self) -> SessionRpcCanvas<'a> {
2619 SessionRpcCanvas {
2620 session: self.session,
2621 }
2622 }
2623
2624 /// `session.commands.*` sub-namespace.
2625 pub fn commands(&self) -> SessionRpcCommands<'a> {
2626 SessionRpcCommands {
2627 session: self.session,
2628 }
2629 }
2630
2631 /// `session.eventLog.*` sub-namespace.
2632 pub fn event_log(&self) -> SessionRpcEventLog<'a> {
2633 SessionRpcEventLog {
2634 session: self.session,
2635 }
2636 }
2637
2638 /// `session.extensions.*` sub-namespace.
2639 pub fn extensions(&self) -> SessionRpcExtensions<'a> {
2640 SessionRpcExtensions {
2641 session: self.session,
2642 }
2643 }
2644
2645 /// `session.fleet.*` sub-namespace.
2646 pub fn fleet(&self) -> SessionRpcFleet<'a> {
2647 SessionRpcFleet {
2648 session: self.session,
2649 }
2650 }
2651
2652 /// `session.gitHubAuth.*` sub-namespace.
2653 pub fn git_hub_auth(&self) -> SessionRpcGitHubAuth<'a> {
2654 SessionRpcGitHubAuth {
2655 session: self.session,
2656 }
2657 }
2658
2659 /// `session.history.*` sub-namespace.
2660 pub fn history(&self) -> SessionRpcHistory<'a> {
2661 SessionRpcHistory {
2662 session: self.session,
2663 }
2664 }
2665
2666 /// `session.instructions.*` sub-namespace.
2667 pub fn instructions(&self) -> SessionRpcInstructions<'a> {
2668 SessionRpcInstructions {
2669 session: self.session,
2670 }
2671 }
2672
2673 /// `session.lsp.*` sub-namespace.
2674 pub fn lsp(&self) -> SessionRpcLsp<'a> {
2675 SessionRpcLsp {
2676 session: self.session,
2677 }
2678 }
2679
2680 /// `session.mcp.*` sub-namespace.
2681 pub fn mcp(&self) -> SessionRpcMcp<'a> {
2682 SessionRpcMcp {
2683 session: self.session,
2684 }
2685 }
2686
2687 /// `session.metadata.*` sub-namespace.
2688 pub fn metadata(&self) -> SessionRpcMetadata<'a> {
2689 SessionRpcMetadata {
2690 session: self.session,
2691 }
2692 }
2693
2694 /// `session.mode.*` sub-namespace.
2695 pub fn mode(&self) -> SessionRpcMode<'a> {
2696 SessionRpcMode {
2697 session: self.session,
2698 }
2699 }
2700
2701 /// `session.model.*` sub-namespace.
2702 pub fn model(&self) -> SessionRpcModel<'a> {
2703 SessionRpcModel {
2704 session: self.session,
2705 }
2706 }
2707
2708 /// `session.name.*` sub-namespace.
2709 pub fn name(&self) -> SessionRpcName<'a> {
2710 SessionRpcName {
2711 session: self.session,
2712 }
2713 }
2714
2715 /// `session.options.*` sub-namespace.
2716 pub fn options(&self) -> SessionRpcOptions<'a> {
2717 SessionRpcOptions {
2718 session: self.session,
2719 }
2720 }
2721
2722 /// `session.permissions.*` sub-namespace.
2723 pub fn permissions(&self) -> SessionRpcPermissions<'a> {
2724 SessionRpcPermissions {
2725 session: self.session,
2726 }
2727 }
2728
2729 /// `session.plan.*` sub-namespace.
2730 pub fn plan(&self) -> SessionRpcPlan<'a> {
2731 SessionRpcPlan {
2732 session: self.session,
2733 }
2734 }
2735
2736 /// `session.plugins.*` sub-namespace.
2737 pub fn plugins(&self) -> SessionRpcPlugins<'a> {
2738 SessionRpcPlugins {
2739 session: self.session,
2740 }
2741 }
2742
2743 /// `session.provider.*` sub-namespace.
2744 pub fn provider(&self) -> SessionRpcProvider<'a> {
2745 SessionRpcProvider {
2746 session: self.session,
2747 }
2748 }
2749
2750 /// `session.queue.*` sub-namespace.
2751 pub fn queue(&self) -> SessionRpcQueue<'a> {
2752 SessionRpcQueue {
2753 session: self.session,
2754 }
2755 }
2756
2757 /// `session.remote.*` sub-namespace.
2758 pub fn remote(&self) -> SessionRpcRemote<'a> {
2759 SessionRpcRemote {
2760 session: self.session,
2761 }
2762 }
2763
2764 /// `session.schedule.*` sub-namespace.
2765 pub fn schedule(&self) -> SessionRpcSchedule<'a> {
2766 SessionRpcSchedule {
2767 session: self.session,
2768 }
2769 }
2770
2771 /// `session.shell.*` sub-namespace.
2772 pub fn shell(&self) -> SessionRpcShell<'a> {
2773 SessionRpcShell {
2774 session: self.session,
2775 }
2776 }
2777
2778 /// `session.skills.*` sub-namespace.
2779 pub fn skills(&self) -> SessionRpcSkills<'a> {
2780 SessionRpcSkills {
2781 session: self.session,
2782 }
2783 }
2784
2785 /// `session.tasks.*` sub-namespace.
2786 pub fn tasks(&self) -> SessionRpcTasks<'a> {
2787 SessionRpcTasks {
2788 session: self.session,
2789 }
2790 }
2791
2792 /// `session.telemetry.*` sub-namespace.
2793 pub fn telemetry(&self) -> SessionRpcTelemetry<'a> {
2794 SessionRpcTelemetry {
2795 session: self.session,
2796 }
2797 }
2798
2799 /// `session.tools.*` sub-namespace.
2800 pub fn tools(&self) -> SessionRpcTools<'a> {
2801 SessionRpcTools {
2802 session: self.session,
2803 }
2804 }
2805
2806 /// `session.ui.*` sub-namespace.
2807 pub fn ui(&self) -> SessionRpcUi<'a> {
2808 SessionRpcUi {
2809 session: self.session,
2810 }
2811 }
2812
2813 /// `session.usage.*` sub-namespace.
2814 pub fn usage(&self) -> SessionRpcUsage<'a> {
2815 SessionRpcUsage {
2816 session: self.session,
2817 }
2818 }
2819
2820 /// `session.visibility.*` sub-namespace.
2821 pub fn visibility(&self) -> SessionRpcVisibility<'a> {
2822 SessionRpcVisibility {
2823 session: self.session,
2824 }
2825 }
2826
2827 /// `session.workspaces.*` sub-namespace.
2828 pub fn workspaces(&self) -> SessionRpcWorkspaces<'a> {
2829 SessionRpcWorkspaces {
2830 session: self.session,
2831 }
2832 }
2833
2834 /// Suspends the session while preserving persisted state for later resume.
2835 ///
2836 /// Wire method: `session.suspend`.
2837 ///
2838 /// <div class="warning">
2839 ///
2840 /// **Experimental.** This API is part of an experimental wire-protocol surface
2841 /// and may change or be removed in future SDK or CLI releases. Pin both the
2842 /// SDK and CLI versions if your code depends on it.
2843 ///
2844 /// </div>
2845 pub async fn suspend(&self) -> Result<(), Error> {
2846 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
2847 let _value = self
2848 .session
2849 .client()
2850 .call(rpc_methods::SESSION_SUSPEND, Some(wire_params))
2851 .await?;
2852 Ok(())
2853 }
2854
2855 /// Sends a user message to the session and returns its message ID.
2856 ///
2857 /// Wire method: `session.send`.
2858 ///
2859 /// # Parameters
2860 ///
2861 /// * `params` - Parameters for sending a user message to the session
2862 ///
2863 /// # Returns
2864 ///
2865 /// Result of sending a user message
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 send(&self, params: SendRequest) -> Result<SendResult, Error> {
2875 let mut wire_params = serde_json::to_value(params)?;
2876 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
2877 let _value = self
2878 .session
2879 .client()
2880 .call(rpc_methods::SESSION_SEND, Some(wire_params))
2881 .await?;
2882 Ok(serde_json::from_value(_value)?)
2883 }
2884
2885 /// Aborts the current agent turn.
2886 ///
2887 /// Wire method: `session.abort`.
2888 ///
2889 /// # Parameters
2890 ///
2891 /// * `params` - Parameters for aborting the current turn
2892 ///
2893 /// # Returns
2894 ///
2895 /// Result of aborting the current turn
2896 ///
2897 /// <div class="warning">
2898 ///
2899 /// **Experimental.** This API is part of an experimental wire-protocol surface
2900 /// and may change or be removed in future SDK or CLI releases. Pin both the
2901 /// SDK and CLI versions if your code depends on it.
2902 ///
2903 /// </div>
2904 pub async fn abort(&self, params: AbortRequest) -> Result<AbortResult, Error> {
2905 let mut wire_params = serde_json::to_value(params)?;
2906 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
2907 let _value = self
2908 .session
2909 .client()
2910 .call(rpc_methods::SESSION_ABORT, Some(wire_params))
2911 .await?;
2912 Ok(serde_json::from_value(_value)?)
2913 }
2914
2915 /// 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.
2916 ///
2917 /// Wire method: `session.shutdown`.
2918 ///
2919 /// # Parameters
2920 ///
2921 /// * `params` - Parameters for shutting down the session
2922 ///
2923 /// <div class="warning">
2924 ///
2925 /// **Experimental.** This API is part of an experimental wire-protocol surface
2926 /// and may change or be removed in future SDK or CLI releases. Pin both the
2927 /// SDK and CLI versions if your code depends on it.
2928 ///
2929 /// </div>
2930 pub async fn shutdown(&self, params: ShutdownRequest) -> Result<(), Error> {
2931 let mut wire_params = serde_json::to_value(params)?;
2932 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
2933 let _value = self
2934 .session
2935 .client()
2936 .call(rpc_methods::SESSION_SHUTDOWN, Some(wire_params))
2937 .await?;
2938 Ok(())
2939 }
2940
2941 /// Emits a user-visible session log event.
2942 ///
2943 /// Wire method: `session.log`.
2944 ///
2945 /// # Parameters
2946 ///
2947 /// * `params` - Message text, optional severity level, persistence flag, optional follow-up URL, and optional tip.
2948 ///
2949 /// # Returns
2950 ///
2951 /// Identifier of the session event that was emitted for the log message.
2952 ///
2953 /// <div class="warning">
2954 ///
2955 /// **Experimental.** This API is part of an experimental wire-protocol surface
2956 /// and may change or be removed in future SDK or CLI releases. Pin both the
2957 /// SDK and CLI versions if your code depends on it.
2958 ///
2959 /// </div>
2960 pub async fn log(&self, params: LogRequest) -> Result<LogResult, Error> {
2961 let mut wire_params = serde_json::to_value(params)?;
2962 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
2963 let _value = self
2964 .session
2965 .client()
2966 .call(rpc_methods::SESSION_LOG, Some(wire_params))
2967 .await?;
2968 Ok(serde_json::from_value(_value)?)
2969 }
2970}
2971
2972/// `session.agent.*` RPCs.
2973#[derive(Clone, Copy)]
2974pub struct SessionRpcAgent<'a> {
2975 pub(crate) session: &'a Session,
2976}
2977
2978impl<'a> SessionRpcAgent<'a> {
2979 /// Lists custom agents available to the session.
2980 ///
2981 /// Wire method: `session.agent.list`.
2982 ///
2983 /// # Returns
2984 ///
2985 /// Custom agents available to the session.
2986 ///
2987 /// <div class="warning">
2988 ///
2989 /// **Experimental.** This API is part of an experimental wire-protocol surface
2990 /// and may change or be removed in future SDK or CLI releases. Pin both the
2991 /// SDK and CLI versions if your code depends on it.
2992 ///
2993 /// </div>
2994 pub async fn list(&self) -> Result<AgentList, Error> {
2995 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
2996 let _value = self
2997 .session
2998 .client()
2999 .call(rpc_methods::SESSION_AGENT_LIST, Some(wire_params))
3000 .await?;
3001 Ok(serde_json::from_value(_value)?)
3002 }
3003
3004 /// Gets the currently selected custom agent for the session.
3005 ///
3006 /// Wire method: `session.agent.getCurrent`.
3007 ///
3008 /// # Returns
3009 ///
3010 /// The currently selected custom agent, or null when using the default agent.
3011 ///
3012 /// <div class="warning">
3013 ///
3014 /// **Experimental.** This API is part of an experimental wire-protocol surface
3015 /// and may change or be removed in future SDK or CLI releases. Pin both the
3016 /// SDK and CLI versions if your code depends on it.
3017 ///
3018 /// </div>
3019 pub async fn get_current(&self) -> Result<AgentGetCurrentResult, Error> {
3020 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3021 let _value = self
3022 .session
3023 .client()
3024 .call(rpc_methods::SESSION_AGENT_GETCURRENT, Some(wire_params))
3025 .await?;
3026 Ok(serde_json::from_value(_value)?)
3027 }
3028
3029 /// Selects a custom agent for subsequent turns in the session.
3030 ///
3031 /// Wire method: `session.agent.select`.
3032 ///
3033 /// # Parameters
3034 ///
3035 /// * `params` - Name of the custom agent to select for subsequent turns.
3036 ///
3037 /// # Returns
3038 ///
3039 /// The newly selected custom agent.
3040 ///
3041 /// <div class="warning">
3042 ///
3043 /// **Experimental.** This API is part of an experimental wire-protocol surface
3044 /// and may change or be removed in future SDK or CLI releases. Pin both the
3045 /// SDK and CLI versions if your code depends on it.
3046 ///
3047 /// </div>
3048 pub async fn select(&self, params: AgentSelectRequest) -> Result<AgentSelectResult, Error> {
3049 let mut wire_params = serde_json::to_value(params)?;
3050 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3051 let _value = self
3052 .session
3053 .client()
3054 .call(rpc_methods::SESSION_AGENT_SELECT, Some(wire_params))
3055 .await?;
3056 Ok(serde_json::from_value(_value)?)
3057 }
3058
3059 /// Clears the selected custom agent and returns the session to the default agent.
3060 ///
3061 /// Wire method: `session.agent.deselect`.
3062 ///
3063 /// <div class="warning">
3064 ///
3065 /// **Experimental.** This API is part of an experimental wire-protocol surface
3066 /// and may change or be removed in future SDK or CLI releases. Pin both the
3067 /// SDK and CLI versions if your code depends on it.
3068 ///
3069 /// </div>
3070 pub async fn deselect(&self) -> Result<(), Error> {
3071 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3072 let _value = self
3073 .session
3074 .client()
3075 .call(rpc_methods::SESSION_AGENT_DESELECT, Some(wire_params))
3076 .await?;
3077 Ok(())
3078 }
3079
3080 /// Reloads custom agent definitions and returns the refreshed list.
3081 ///
3082 /// Wire method: `session.agent.reload`.
3083 ///
3084 /// # Returns
3085 ///
3086 /// Custom agents available to the session after reloading definitions from disk.
3087 ///
3088 /// <div class="warning">
3089 ///
3090 /// **Experimental.** This API is part of an experimental wire-protocol surface
3091 /// and may change or be removed in future SDK or CLI releases. Pin both the
3092 /// SDK and CLI versions if your code depends on it.
3093 ///
3094 /// </div>
3095 pub async fn reload(&self) -> Result<AgentReloadResult, Error> {
3096 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3097 let _value = self
3098 .session
3099 .client()
3100 .call(rpc_methods::SESSION_AGENT_RELOAD, Some(wire_params))
3101 .await?;
3102 Ok(serde_json::from_value(_value)?)
3103 }
3104}
3105
3106/// `session.canvas.*` RPCs.
3107#[derive(Clone, Copy)]
3108pub struct SessionRpcCanvas<'a> {
3109 pub(crate) session: &'a Session,
3110}
3111
3112impl<'a> SessionRpcCanvas<'a> {
3113 /// `session.canvas.action.*` sub-namespace.
3114 pub fn action(&self) -> SessionRpcCanvasAction<'a> {
3115 SessionRpcCanvasAction {
3116 session: self.session,
3117 }
3118 }
3119
3120 /// Lists canvases declared for the session.
3121 ///
3122 /// Wire method: `session.canvas.list`.
3123 ///
3124 /// # Returns
3125 ///
3126 /// Declared canvases available in this session.
3127 ///
3128 /// <div class="warning">
3129 ///
3130 /// **Experimental.** This API is part of an experimental wire-protocol surface
3131 /// and may change or be removed in future SDK or CLI releases. Pin both the
3132 /// SDK and CLI versions if your code depends on it.
3133 ///
3134 /// </div>
3135 pub async fn list(&self) -> Result<CanvasList, Error> {
3136 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3137 let _value = self
3138 .session
3139 .client()
3140 .call(rpc_methods::SESSION_CANVAS_LIST, Some(wire_params))
3141 .await?;
3142 Ok(serde_json::from_value(_value)?)
3143 }
3144
3145 /// Lists currently open canvas instances for the live session.
3146 ///
3147 /// Wire method: `session.canvas.listOpen`.
3148 ///
3149 /// # Returns
3150 ///
3151 /// Live open-canvas snapshot.
3152 ///
3153 /// <div class="warning">
3154 ///
3155 /// **Experimental.** This API is part of an experimental wire-protocol surface
3156 /// and may change or be removed in future SDK or CLI releases. Pin both the
3157 /// SDK and CLI versions if your code depends on it.
3158 ///
3159 /// </div>
3160 pub async fn list_open(&self) -> Result<CanvasListOpenResult, Error> {
3161 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3162 let _value = self
3163 .session
3164 .client()
3165 .call(rpc_methods::SESSION_CANVAS_LISTOPEN, Some(wire_params))
3166 .await?;
3167 Ok(serde_json::from_value(_value)?)
3168 }
3169
3170 /// Opens or focuses a canvas instance.
3171 ///
3172 /// Wire method: `session.canvas.open`.
3173 ///
3174 /// # Parameters
3175 ///
3176 /// * `params` - Canvas open parameters.
3177 ///
3178 /// # Returns
3179 ///
3180 /// Open canvas instance snapshot.
3181 ///
3182 /// <div class="warning">
3183 ///
3184 /// **Experimental.** This API is part of an experimental wire-protocol surface
3185 /// and may change or be removed in future SDK or CLI releases. Pin both the
3186 /// SDK and CLI versions if your code depends on it.
3187 ///
3188 /// </div>
3189 pub async fn open(&self, params: CanvasOpenRequest) -> Result<OpenCanvasInstance, Error> {
3190 let mut wire_params = serde_json::to_value(params)?;
3191 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3192 let _value = self
3193 .session
3194 .client()
3195 .call(rpc_methods::SESSION_CANVAS_OPEN, Some(wire_params))
3196 .await?;
3197 Ok(serde_json::from_value(_value)?)
3198 }
3199
3200 /// Closes an open canvas instance.
3201 ///
3202 /// Wire method: `session.canvas.close`.
3203 ///
3204 /// # Parameters
3205 ///
3206 /// * `params` - Canvas close parameters.
3207 ///
3208 /// <div class="warning">
3209 ///
3210 /// **Experimental.** This API is part of an experimental wire-protocol surface
3211 /// and may change or be removed in future SDK or CLI releases. Pin both the
3212 /// SDK and CLI versions if your code depends on it.
3213 ///
3214 /// </div>
3215 pub async fn close(&self, params: CanvasCloseRequest) -> Result<(), Error> {
3216 let mut wire_params = serde_json::to_value(params)?;
3217 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3218 let _value = self
3219 .session
3220 .client()
3221 .call(rpc_methods::SESSION_CANVAS_CLOSE, Some(wire_params))
3222 .await?;
3223 Ok(())
3224 }
3225}
3226
3227/// `session.canvas.action.*` RPCs.
3228#[derive(Clone, Copy)]
3229pub struct SessionRpcCanvasAction<'a> {
3230 pub(crate) session: &'a Session,
3231}
3232
3233impl<'a> SessionRpcCanvasAction<'a> {
3234 /// Invokes an action on an open canvas instance.
3235 ///
3236 /// Wire method: `session.canvas.action.invoke`.
3237 ///
3238 /// # Parameters
3239 ///
3240 /// * `params` - Canvas action invocation parameters.
3241 ///
3242 /// # Returns
3243 ///
3244 /// Canvas action invocation result.
3245 ///
3246 /// <div class="warning">
3247 ///
3248 /// **Experimental.** This API is part of an experimental wire-protocol surface
3249 /// and may change or be removed in future SDK or CLI releases. Pin both the
3250 /// SDK and CLI versions if your code depends on it.
3251 ///
3252 /// </div>
3253 pub async fn invoke(
3254 &self,
3255 params: CanvasActionInvokeRequest,
3256 ) -> Result<CanvasActionInvokeResult, Error> {
3257 let mut wire_params = serde_json::to_value(params)?;
3258 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3259 let _value = self
3260 .session
3261 .client()
3262 .call(rpc_methods::SESSION_CANVAS_ACTION_INVOKE, Some(wire_params))
3263 .await?;
3264 Ok(serde_json::from_value(_value)?)
3265 }
3266}
3267
3268/// `session.commands.*` RPCs.
3269#[derive(Clone, Copy)]
3270pub struct SessionRpcCommands<'a> {
3271 pub(crate) session: &'a Session,
3272}
3273
3274impl<'a> SessionRpcCommands<'a> {
3275 /// Lists slash commands available in the session.
3276 ///
3277 /// Wire method: `session.commands.list`.
3278 ///
3279 /// # Returns
3280 ///
3281 /// Slash commands available in the session, after applying any include/exclude filters.
3282 ///
3283 /// <div class="warning">
3284 ///
3285 /// **Experimental.** This API is part of an experimental wire-protocol surface
3286 /// and may change or be removed in future SDK or CLI releases. Pin both the
3287 /// SDK and CLI versions if your code depends on it.
3288 ///
3289 /// </div>
3290 pub async fn list(&self) -> Result<CommandList, Error> {
3291 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3292 let _value = self
3293 .session
3294 .client()
3295 .call(rpc_methods::SESSION_COMMANDS_LIST, Some(wire_params))
3296 .await?;
3297 Ok(serde_json::from_value(_value)?)
3298 }
3299
3300 /// Lists slash commands available in the session.
3301 ///
3302 /// Wire method: `session.commands.list`.
3303 ///
3304 /// # Parameters
3305 ///
3306 /// * `params` - Optional filters controlling which command sources to include in the listing.
3307 ///
3308 /// # Returns
3309 ///
3310 /// Slash commands available in the session, after applying any include/exclude filters.
3311 ///
3312 /// <div class="warning">
3313 ///
3314 /// **Experimental.** This API is part of an experimental wire-protocol surface
3315 /// and may change or be removed in future SDK or CLI releases. Pin both the
3316 /// SDK and CLI versions if your code depends on it.
3317 ///
3318 /// </div>
3319 pub async fn list_with_params(
3320 &self,
3321 params: CommandsListRequest,
3322 ) -> Result<CommandList, Error> {
3323 let mut wire_params = serde_json::to_value(params)?;
3324 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3325 let _value = self
3326 .session
3327 .client()
3328 .call(rpc_methods::SESSION_COMMANDS_LIST, Some(wire_params))
3329 .await?;
3330 Ok(serde_json::from_value(_value)?)
3331 }
3332
3333 /// Invokes a slash command in the session.
3334 ///
3335 /// Wire method: `session.commands.invoke`.
3336 ///
3337 /// # Parameters
3338 ///
3339 /// * `params` - Slash command name and optional raw input string to invoke.
3340 ///
3341 /// # Returns
3342 ///
3343 /// Result of invoking the slash command (text output, prompt to send to the agent, completion, or subcommand selection).
3344 ///
3345 /// <div class="warning">
3346 ///
3347 /// **Experimental.** This API is part of an experimental wire-protocol surface
3348 /// and may change or be removed in future SDK or CLI releases. Pin both the
3349 /// SDK and CLI versions if your code depends on it.
3350 ///
3351 /// </div>
3352 pub async fn invoke(
3353 &self,
3354 params: CommandsInvokeRequest,
3355 ) -> Result<SlashCommandInvocationResult, Error> {
3356 let mut wire_params = serde_json::to_value(params)?;
3357 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3358 let _value = self
3359 .session
3360 .client()
3361 .call(rpc_methods::SESSION_COMMANDS_INVOKE, Some(wire_params))
3362 .await?;
3363 Ok(serde_json::from_value(_value)?)
3364 }
3365
3366 /// Reports completion of a pending client-handled slash command.
3367 ///
3368 /// Wire method: `session.commands.handlePendingCommand`.
3369 ///
3370 /// # Parameters
3371 ///
3372 /// * `params` - Pending command request ID and an optional error if the client handler failed.
3373 ///
3374 /// # Returns
3375 ///
3376 /// Indicates whether the pending client-handled command was completed successfully.
3377 ///
3378 /// <div class="warning">
3379 ///
3380 /// **Experimental.** This API is part of an experimental wire-protocol surface
3381 /// and may change or be removed in future SDK or CLI releases. Pin both the
3382 /// SDK and CLI versions if your code depends on it.
3383 ///
3384 /// </div>
3385 pub async fn handle_pending_command(
3386 &self,
3387 params: CommandsHandlePendingCommandRequest,
3388 ) -> Result<CommandsHandlePendingCommandResult, Error> {
3389 let mut wire_params = serde_json::to_value(params)?;
3390 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3391 let _value = self
3392 .session
3393 .client()
3394 .call(
3395 rpc_methods::SESSION_COMMANDS_HANDLEPENDINGCOMMAND,
3396 Some(wire_params),
3397 )
3398 .await?;
3399 Ok(serde_json::from_value(_value)?)
3400 }
3401
3402 /// Executes a slash command synchronously and returns any error.
3403 ///
3404 /// Wire method: `session.commands.execute`.
3405 ///
3406 /// # Parameters
3407 ///
3408 /// * `params` - Slash command name and argument string to execute synchronously.
3409 ///
3410 /// # Returns
3411 ///
3412 /// Error message produced while executing the command, if any.
3413 ///
3414 /// <div class="warning">
3415 ///
3416 /// **Experimental.** This API is part of an experimental wire-protocol surface
3417 /// and may change or be removed in future SDK or CLI releases. Pin both the
3418 /// SDK and CLI versions if your code depends on it.
3419 ///
3420 /// </div>
3421 pub async fn execute(
3422 &self,
3423 params: ExecuteCommandParams,
3424 ) -> Result<ExecuteCommandResult, Error> {
3425 let mut wire_params = serde_json::to_value(params)?;
3426 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3427 let _value = self
3428 .session
3429 .client()
3430 .call(rpc_methods::SESSION_COMMANDS_EXECUTE, Some(wire_params))
3431 .await?;
3432 Ok(serde_json::from_value(_value)?)
3433 }
3434
3435 /// Enqueues a slash command for FIFO processing on the local session.
3436 ///
3437 /// Wire method: `session.commands.enqueue`.
3438 ///
3439 /// # Parameters
3440 ///
3441 /// * `params` - Slash-prefixed command string to enqueue for FIFO processing.
3442 ///
3443 /// # Returns
3444 ///
3445 /// Indicates whether the command was accepted into the local execution queue.
3446 ///
3447 /// <div class="warning">
3448 ///
3449 /// **Experimental.** This API is part of an experimental wire-protocol surface
3450 /// and may change or be removed in future SDK or CLI releases. Pin both the
3451 /// SDK and CLI versions if your code depends on it.
3452 ///
3453 /// </div>
3454 pub async fn enqueue(
3455 &self,
3456 params: EnqueueCommandParams,
3457 ) -> Result<EnqueueCommandResult, Error> {
3458 let mut wire_params = serde_json::to_value(params)?;
3459 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3460 let _value = self
3461 .session
3462 .client()
3463 .call(rpc_methods::SESSION_COMMANDS_ENQUEUE, Some(wire_params))
3464 .await?;
3465 Ok(serde_json::from_value(_value)?)
3466 }
3467
3468 /// Reports whether the host actually executed a queued command and whether to continue processing.
3469 ///
3470 /// Wire method: `session.commands.respondToQueuedCommand`.
3471 ///
3472 /// # Parameters
3473 ///
3474 /// * `params` - Queued-command request ID and the result indicating whether the host executed it (and whether to stop processing further queued commands).
3475 ///
3476 /// # Returns
3477 ///
3478 /// Indicates whether the queued-command response was matched to a pending request.
3479 ///
3480 /// <div class="warning">
3481 ///
3482 /// **Experimental.** This API is part of an experimental wire-protocol surface
3483 /// and may change or be removed in future SDK or CLI releases. Pin both the
3484 /// SDK and CLI versions if your code depends on it.
3485 ///
3486 /// </div>
3487 pub async fn respond_to_queued_command(
3488 &self,
3489 params: CommandsRespondToQueuedCommandRequest,
3490 ) -> Result<CommandsRespondToQueuedCommandResult, Error> {
3491 let mut wire_params = serde_json::to_value(params)?;
3492 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3493 let _value = self
3494 .session
3495 .client()
3496 .call(
3497 rpc_methods::SESSION_COMMANDS_RESPONDTOQUEUEDCOMMAND,
3498 Some(wire_params),
3499 )
3500 .await?;
3501 Ok(serde_json::from_value(_value)?)
3502 }
3503}
3504
3505/// `session.eventLog.*` RPCs.
3506#[derive(Clone, Copy)]
3507pub struct SessionRpcEventLog<'a> {
3508 pub(crate) session: &'a Session,
3509}
3510
3511impl<'a> SessionRpcEventLog<'a> {
3512 /// Reads a batch of session events from a cursor, optionally waiting for new events.
3513 ///
3514 /// Wire method: `session.eventLog.read`.
3515 ///
3516 /// # Parameters
3517 ///
3518 /// * `params` - Cursor, batch size, and optional long-poll/filter parameters for reading session events.
3519 ///
3520 /// # Returns
3521 ///
3522 /// Batch of session events returned by a read, with cursor and continuation metadata.
3523 ///
3524 /// <div class="warning">
3525 ///
3526 /// **Experimental.** This API is part of an experimental wire-protocol surface
3527 /// and may change or be removed in future SDK or CLI releases. Pin both the
3528 /// SDK and CLI versions if your code depends on it.
3529 ///
3530 /// </div>
3531 pub async fn read(&self, params: EventLogReadRequest) -> Result<EventsReadResult, Error> {
3532 let mut wire_params = serde_json::to_value(params)?;
3533 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3534 let _value = self
3535 .session
3536 .client()
3537 .call(rpc_methods::SESSION_EVENTLOG_READ, Some(wire_params))
3538 .await?;
3539 Ok(serde_json::from_value(_value)?)
3540 }
3541
3542 /// Returns a snapshot of the current tail cursor without consuming events.
3543 ///
3544 /// Wire method: `session.eventLog.tail`.
3545 ///
3546 /// # Returns
3547 ///
3548 /// 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).
3549 ///
3550 /// <div class="warning">
3551 ///
3552 /// **Experimental.** This API is part of an experimental wire-protocol surface
3553 /// and may change or be removed in future SDK or CLI releases. Pin both the
3554 /// SDK and CLI versions if your code depends on it.
3555 ///
3556 /// </div>
3557 pub async fn tail(&self) -> Result<EventLogTailResult, Error> {
3558 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3559 let _value = self
3560 .session
3561 .client()
3562 .call(rpc_methods::SESSION_EVENTLOG_TAIL, Some(wire_params))
3563 .await?;
3564 Ok(serde_json::from_value(_value)?)
3565 }
3566
3567 /// Registers consumer interest in an event type for runtime gating purposes.
3568 ///
3569 /// Wire method: `session.eventLog.registerInterest`.
3570 ///
3571 /// # Parameters
3572 ///
3573 /// * `params` - Event type to register consumer interest for, used by runtime gating logic.
3574 ///
3575 /// # Returns
3576 ///
3577 /// Opaque handle representing an event-type interest registration.
3578 ///
3579 /// <div class="warning">
3580 ///
3581 /// **Experimental.** This API is part of an experimental wire-protocol surface
3582 /// and may change or be removed in future SDK or CLI releases. Pin both the
3583 /// SDK and CLI versions if your code depends on it.
3584 ///
3585 /// </div>
3586 pub async fn register_interest(
3587 &self,
3588 params: RegisterEventInterestParams,
3589 ) -> Result<RegisterEventInterestResult, Error> {
3590 let mut wire_params = serde_json::to_value(params)?;
3591 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3592 let _value = self
3593 .session
3594 .client()
3595 .call(
3596 rpc_methods::SESSION_EVENTLOG_REGISTERINTEREST,
3597 Some(wire_params),
3598 )
3599 .await?;
3600 Ok(serde_json::from_value(_value)?)
3601 }
3602
3603 /// Releases a consumer's previously-registered interest in an event type.
3604 ///
3605 /// Wire method: `session.eventLog.releaseInterest`.
3606 ///
3607 /// # Parameters
3608 ///
3609 /// * `params` - Opaque handle previously returned by `registerInterest` to release.
3610 ///
3611 /// # Returns
3612 ///
3613 /// Indicates whether the operation succeeded.
3614 ///
3615 /// <div class="warning">
3616 ///
3617 /// **Experimental.** This API is part of an experimental wire-protocol surface
3618 /// and may change or be removed in future SDK or CLI releases. Pin both the
3619 /// SDK and CLI versions if your code depends on it.
3620 ///
3621 /// </div>
3622 pub async fn release_interest(
3623 &self,
3624 params: ReleaseEventInterestParams,
3625 ) -> Result<EventLogReleaseInterestResult, Error> {
3626 let mut wire_params = serde_json::to_value(params)?;
3627 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3628 let _value = self
3629 .session
3630 .client()
3631 .call(
3632 rpc_methods::SESSION_EVENTLOG_RELEASEINTEREST,
3633 Some(wire_params),
3634 )
3635 .await?;
3636 Ok(serde_json::from_value(_value)?)
3637 }
3638}
3639
3640/// `session.extensions.*` RPCs.
3641#[derive(Clone, Copy)]
3642pub struct SessionRpcExtensions<'a> {
3643 pub(crate) session: &'a Session,
3644}
3645
3646impl<'a> SessionRpcExtensions<'a> {
3647 /// Lists extensions discovered for the session and their current status.
3648 ///
3649 /// Wire method: `session.extensions.list`.
3650 ///
3651 /// # Returns
3652 ///
3653 /// Extensions discovered for the session, with their current status.
3654 ///
3655 /// <div class="warning">
3656 ///
3657 /// **Experimental.** This API is part of an experimental wire-protocol surface
3658 /// and may change or be removed in future SDK or CLI releases. Pin both the
3659 /// SDK and CLI versions if your code depends on it.
3660 ///
3661 /// </div>
3662 pub async fn list(&self) -> Result<ExtensionList, Error> {
3663 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3664 let _value = self
3665 .session
3666 .client()
3667 .call(rpc_methods::SESSION_EXTENSIONS_LIST, Some(wire_params))
3668 .await?;
3669 Ok(serde_json::from_value(_value)?)
3670 }
3671
3672 /// Enables an extension for the session.
3673 ///
3674 /// Wire method: `session.extensions.enable`.
3675 ///
3676 /// # Parameters
3677 ///
3678 /// * `params` - Source-qualified extension identifier to enable for the session.
3679 ///
3680 /// <div class="warning">
3681 ///
3682 /// **Experimental.** This API is part of an experimental wire-protocol surface
3683 /// and may change or be removed in future SDK or CLI releases. Pin both the
3684 /// SDK and CLI versions if your code depends on it.
3685 ///
3686 /// </div>
3687 pub async fn enable(&self, params: ExtensionsEnableRequest) -> Result<(), Error> {
3688 let mut wire_params = serde_json::to_value(params)?;
3689 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3690 let _value = self
3691 .session
3692 .client()
3693 .call(rpc_methods::SESSION_EXTENSIONS_ENABLE, Some(wire_params))
3694 .await?;
3695 Ok(())
3696 }
3697
3698 /// Disables an extension for the session.
3699 ///
3700 /// Wire method: `session.extensions.disable`.
3701 ///
3702 /// # Parameters
3703 ///
3704 /// * `params` - Source-qualified extension identifier to disable for 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 disable(&self, params: ExtensionsDisableRequest) -> Result<(), Error> {
3714 let mut wire_params = serde_json::to_value(params)?;
3715 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3716 let _value = self
3717 .session
3718 .client()
3719 .call(rpc_methods::SESSION_EXTENSIONS_DISABLE, Some(wire_params))
3720 .await?;
3721 Ok(())
3722 }
3723
3724 /// Reloads extension definitions and processes for the session.
3725 ///
3726 /// Wire method: `session.extensions.reload`.
3727 ///
3728 /// <div class="warning">
3729 ///
3730 /// **Experimental.** This API is part of an experimental wire-protocol surface
3731 /// and may change or be removed in future SDK or CLI releases. Pin both the
3732 /// SDK and CLI versions if your code depends on it.
3733 ///
3734 /// </div>
3735 pub async fn reload(&self) -> Result<(), Error> {
3736 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3737 let _value = self
3738 .session
3739 .client()
3740 .call(rpc_methods::SESSION_EXTENSIONS_RELOAD, Some(wire_params))
3741 .await?;
3742 Ok(())
3743 }
3744
3745 /// 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.
3746 ///
3747 /// Wire method: `session.extensions.sendAttachmentsToMessage`.
3748 ///
3749 /// # Parameters
3750 ///
3751 /// * `params` - Parameters for session.extensions.sendAttachmentsToMessage.
3752 ///
3753 /// <div class="warning">
3754 ///
3755 /// **Experimental.** This API is part of an experimental wire-protocol surface
3756 /// and may change or be removed in future SDK or CLI releases. Pin both the
3757 /// SDK and CLI versions if your code depends on it.
3758 ///
3759 /// </div>
3760 pub async fn send_attachments_to_message(
3761 &self,
3762 params: SendAttachmentsToMessageParams,
3763 ) -> Result<(), Error> {
3764 let mut wire_params = serde_json::to_value(params)?;
3765 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3766 let _value = self
3767 .session
3768 .client()
3769 .call(
3770 rpc_methods::SESSION_EXTENSIONS_SENDATTACHMENTSTOMESSAGE,
3771 Some(wire_params),
3772 )
3773 .await?;
3774 Ok(())
3775 }
3776}
3777
3778/// `session.fleet.*` RPCs.
3779#[derive(Clone, Copy)]
3780pub struct SessionRpcFleet<'a> {
3781 pub(crate) session: &'a Session,
3782}
3783
3784impl<'a> SessionRpcFleet<'a> {
3785 /// Starts fleet mode by submitting the fleet orchestration prompt to the session.
3786 ///
3787 /// Wire method: `session.fleet.start`.
3788 ///
3789 /// # Parameters
3790 ///
3791 /// * `params` - Optional user prompt to combine with the fleet orchestration instructions.
3792 ///
3793 /// # Returns
3794 ///
3795 /// Indicates whether fleet mode was successfully activated.
3796 ///
3797 /// <div class="warning">
3798 ///
3799 /// **Experimental.** This API is part of an experimental wire-protocol surface
3800 /// and may change or be removed in future SDK or CLI releases. Pin both the
3801 /// SDK and CLI versions if your code depends on it.
3802 ///
3803 /// </div>
3804 pub async fn start(&self, params: FleetStartRequest) -> Result<FleetStartResult, Error> {
3805 let mut wire_params = serde_json::to_value(params)?;
3806 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3807 let _value = self
3808 .session
3809 .client()
3810 .call(rpc_methods::SESSION_FLEET_START, Some(wire_params))
3811 .await?;
3812 Ok(serde_json::from_value(_value)?)
3813 }
3814}
3815
3816/// `session.gitHubAuth.*` RPCs.
3817#[derive(Clone, Copy)]
3818pub struct SessionRpcGitHubAuth<'a> {
3819 pub(crate) session: &'a Session,
3820}
3821
3822impl<'a> SessionRpcGitHubAuth<'a> {
3823 /// Gets authentication status and account metadata for the session.
3824 ///
3825 /// Wire method: `session.gitHubAuth.getStatus`.
3826 ///
3827 /// # Returns
3828 ///
3829 /// Authentication status and account metadata for the session.
3830 ///
3831 /// <div class="warning">
3832 ///
3833 /// **Experimental.** This API is part of an experimental wire-protocol surface
3834 /// and may change or be removed in future SDK or CLI releases. Pin both the
3835 /// SDK and CLI versions if your code depends on it.
3836 ///
3837 /// </div>
3838 pub async fn get_status(&self) -> Result<SessionAuthStatus, Error> {
3839 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3840 let _value = self
3841 .session
3842 .client()
3843 .call(rpc_methods::SESSION_GITHUBAUTH_GETSTATUS, Some(wire_params))
3844 .await?;
3845 Ok(serde_json::from_value(_value)?)
3846 }
3847
3848 /// Updates the session's auth credentials used for outbound model and API requests.
3849 ///
3850 /// Wire method: `session.gitHubAuth.setCredentials`.
3851 ///
3852 /// # Parameters
3853 ///
3854 /// * `params` - New auth credentials to install on the session. Omit to leave credentials unchanged.
3855 ///
3856 /// # Returns
3857 ///
3858 /// Indicates whether the credential update succeeded.
3859 ///
3860 /// <div class="warning">
3861 ///
3862 /// **Experimental.** This API is part of an experimental wire-protocol surface
3863 /// and may change or be removed in future SDK or CLI releases. Pin both the
3864 /// SDK and CLI versions if your code depends on it.
3865 ///
3866 /// </div>
3867 pub async fn set_credentials(
3868 &self,
3869 params: SessionSetCredentialsParams,
3870 ) -> Result<SessionSetCredentialsResult, Error> {
3871 let mut wire_params = serde_json::to_value(params)?;
3872 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3873 let _value = self
3874 .session
3875 .client()
3876 .call(
3877 rpc_methods::SESSION_GITHUBAUTH_SETCREDENTIALS,
3878 Some(wire_params),
3879 )
3880 .await?;
3881 Ok(serde_json::from_value(_value)?)
3882 }
3883}
3884
3885/// `session.history.*` RPCs.
3886#[derive(Clone, Copy)]
3887pub struct SessionRpcHistory<'a> {
3888 pub(crate) session: &'a Session,
3889}
3890
3891impl<'a> SessionRpcHistory<'a> {
3892 /// Compacts the session history to reduce context usage.
3893 ///
3894 /// Wire method: `session.history.compact`.
3895 ///
3896 /// # Returns
3897 ///
3898 /// Compaction outcome with the number of tokens and messages removed, summary text, and the resulting context window breakdown.
3899 ///
3900 /// <div class="warning">
3901 ///
3902 /// **Experimental.** This API is part of an experimental wire-protocol surface
3903 /// and may change or be removed in future SDK or CLI releases. Pin both the
3904 /// SDK and CLI versions if your code depends on it.
3905 ///
3906 /// </div>
3907 pub async fn compact(&self) -> Result<HistoryCompactResult, Error> {
3908 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3909 let _value = self
3910 .session
3911 .client()
3912 .call(rpc_methods::SESSION_HISTORY_COMPACT, Some(wire_params))
3913 .await?;
3914 Ok(serde_json::from_value(_value)?)
3915 }
3916
3917 /// Compacts the session history to reduce context usage.
3918 ///
3919 /// Wire method: `session.history.compact`.
3920 ///
3921 /// # Parameters
3922 ///
3923 /// * `params` - Optional compaction parameters.
3924 ///
3925 /// # Returns
3926 ///
3927 /// Compaction outcome with the number of tokens and messages removed, summary text, and the resulting context window breakdown.
3928 ///
3929 /// <div class="warning">
3930 ///
3931 /// **Experimental.** This API is part of an experimental wire-protocol surface
3932 /// and may change or be removed in future SDK or CLI releases. Pin both the
3933 /// SDK and CLI versions if your code depends on it.
3934 ///
3935 /// </div>
3936 pub async fn compact_with_params(
3937 &self,
3938 params: HistoryCompactRequest,
3939 ) -> Result<HistoryCompactResult, Error> {
3940 let mut wire_params = serde_json::to_value(params)?;
3941 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3942 let _value = self
3943 .session
3944 .client()
3945 .call(rpc_methods::SESSION_HISTORY_COMPACT, Some(wire_params))
3946 .await?;
3947 Ok(serde_json::from_value(_value)?)
3948 }
3949
3950 /// Truncates persisted session history to a specific event.
3951 ///
3952 /// Wire method: `session.history.truncate`.
3953 ///
3954 /// # Parameters
3955 ///
3956 /// * `params` - Identifier of the event to truncate to; this event and all later events are removed.
3957 ///
3958 /// # Returns
3959 ///
3960 /// Number of events that were removed by the truncation.
3961 ///
3962 /// <div class="warning">
3963 ///
3964 /// **Experimental.** This API is part of an experimental wire-protocol surface
3965 /// and may change or be removed in future SDK or CLI releases. Pin both the
3966 /// SDK and CLI versions if your code depends on it.
3967 ///
3968 /// </div>
3969 pub async fn truncate(
3970 &self,
3971 params: HistoryTruncateRequest,
3972 ) -> Result<HistoryTruncateResult, Error> {
3973 let mut wire_params = serde_json::to_value(params)?;
3974 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3975 let _value = self
3976 .session
3977 .client()
3978 .call(rpc_methods::SESSION_HISTORY_TRUNCATE, Some(wire_params))
3979 .await?;
3980 Ok(serde_json::from_value(_value)?)
3981 }
3982
3983 /// Cancels any in-progress background compaction on a local session.
3984 ///
3985 /// Wire method: `session.history.cancelBackgroundCompaction`.
3986 ///
3987 /// # Returns
3988 ///
3989 /// Indicates whether an in-progress background compaction was cancelled.
3990 ///
3991 /// <div class="warning">
3992 ///
3993 /// **Experimental.** This API is part of an experimental wire-protocol surface
3994 /// and may change or be removed in future SDK or CLI releases. Pin both the
3995 /// SDK and CLI versions if your code depends on it.
3996 ///
3997 /// </div>
3998 pub async fn cancel_background_compaction(
3999 &self,
4000 ) -> Result<HistoryCancelBackgroundCompactionResult, Error> {
4001 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
4002 let _value = self
4003 .session
4004 .client()
4005 .call(
4006 rpc_methods::SESSION_HISTORY_CANCELBACKGROUNDCOMPACTION,
4007 Some(wire_params),
4008 )
4009 .await?;
4010 Ok(serde_json::from_value(_value)?)
4011 }
4012
4013 /// Aborts any in-progress manual compaction on a local session.
4014 ///
4015 /// Wire method: `session.history.abortManualCompaction`.
4016 ///
4017 /// # Returns
4018 ///
4019 /// Indicates whether an in-progress manual compaction was aborted.
4020 ///
4021 /// <div class="warning">
4022 ///
4023 /// **Experimental.** This API is part of an experimental wire-protocol surface
4024 /// and may change or be removed in future SDK or CLI releases. Pin both the
4025 /// SDK and CLI versions if your code depends on it.
4026 ///
4027 /// </div>
4028 pub async fn abort_manual_compaction(
4029 &self,
4030 ) -> Result<HistoryAbortManualCompactionResult, Error> {
4031 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
4032 let _value = self
4033 .session
4034 .client()
4035 .call(
4036 rpc_methods::SESSION_HISTORY_ABORTMANUALCOMPACTION,
4037 Some(wire_params),
4038 )
4039 .await?;
4040 Ok(serde_json::from_value(_value)?)
4041 }
4042
4043 /// Produces a markdown summary of the session's conversation context for hand-off scenarios.
4044 ///
4045 /// Wire method: `session.history.summarizeForHandoff`.
4046 ///
4047 /// # Returns
4048 ///
4049 /// Markdown summary of the conversation context (empty when not available).
4050 ///
4051 /// <div class="warning">
4052 ///
4053 /// **Experimental.** This API is part of an experimental wire-protocol surface
4054 /// and may change or be removed in future SDK or CLI releases. Pin both the
4055 /// SDK and CLI versions if your code depends on it.
4056 ///
4057 /// </div>
4058 pub async fn summarize_for_handoff(&self) -> Result<HistorySummarizeForHandoffResult, Error> {
4059 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
4060 let _value = self
4061 .session
4062 .client()
4063 .call(
4064 rpc_methods::SESSION_HISTORY_SUMMARIZEFORHANDOFF,
4065 Some(wire_params),
4066 )
4067 .await?;
4068 Ok(serde_json::from_value(_value)?)
4069 }
4070}
4071
4072/// `session.instructions.*` RPCs.
4073#[derive(Clone, Copy)]
4074pub struct SessionRpcInstructions<'a> {
4075 pub(crate) session: &'a Session,
4076}
4077
4078impl<'a> SessionRpcInstructions<'a> {
4079 /// Gets instruction sources loaded for the session.
4080 ///
4081 /// Wire method: `session.instructions.getSources`.
4082 ///
4083 /// # Returns
4084 ///
4085 /// Instruction sources loaded for the session, in merge order.
4086 ///
4087 /// <div class="warning">
4088 ///
4089 /// **Experimental.** This API is part of an experimental wire-protocol surface
4090 /// and may change or be removed in future SDK or CLI releases. Pin both the
4091 /// SDK and CLI versions if your code depends on it.
4092 ///
4093 /// </div>
4094 pub async fn get_sources(&self) -> Result<InstructionsGetSourcesResult, Error> {
4095 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
4096 let _value = self
4097 .session
4098 .client()
4099 .call(
4100 rpc_methods::SESSION_INSTRUCTIONS_GETSOURCES,
4101 Some(wire_params),
4102 )
4103 .await?;
4104 Ok(serde_json::from_value(_value)?)
4105 }
4106}
4107
4108/// `session.lsp.*` RPCs.
4109#[derive(Clone, Copy)]
4110pub struct SessionRpcLsp<'a> {
4111 pub(crate) session: &'a Session,
4112}
4113
4114impl<'a> SessionRpcLsp<'a> {
4115 /// Loads the merged LSP configuration set for the session's working directory.
4116 ///
4117 /// Wire method: `session.lsp.initialize`.
4118 ///
4119 /// # Parameters
4120 ///
4121 /// * `params` - Parameters for (re)loading the merged LSP configuration set.
4122 ///
4123 /// <div class="warning">
4124 ///
4125 /// **Experimental.** This API is part of an experimental wire-protocol surface
4126 /// and may change or be removed in future SDK or CLI releases. Pin both the
4127 /// SDK and CLI versions if your code depends on it.
4128 ///
4129 /// </div>
4130 pub async fn initialize(&self, params: LspInitializeRequest) -> Result<(), Error> {
4131 let mut wire_params = serde_json::to_value(params)?;
4132 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4133 let _value = self
4134 .session
4135 .client()
4136 .call(rpc_methods::SESSION_LSP_INITIALIZE, Some(wire_params))
4137 .await?;
4138 Ok(())
4139 }
4140}
4141
4142/// `session.mcp.*` RPCs.
4143#[derive(Clone, Copy)]
4144pub struct SessionRpcMcp<'a> {
4145 pub(crate) session: &'a Session,
4146}
4147
4148impl<'a> SessionRpcMcp<'a> {
4149 /// `session.mcp.apps.*` sub-namespace.
4150 pub fn apps(&self) -> SessionRpcMcpApps<'a> {
4151 SessionRpcMcpApps {
4152 session: self.session,
4153 }
4154 }
4155
4156 /// `session.mcp.headers.*` sub-namespace.
4157 pub fn headers(&self) -> SessionRpcMcpHeaders<'a> {
4158 SessionRpcMcpHeaders {
4159 session: self.session,
4160 }
4161 }
4162
4163 /// `session.mcp.oauth.*` sub-namespace.
4164 pub fn oauth(&self) -> SessionRpcMcpOauth<'a> {
4165 SessionRpcMcpOauth {
4166 session: self.session,
4167 }
4168 }
4169
4170 /// 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.
4171 ///
4172 /// Wire method: `session.mcp.list`.
4173 ///
4174 /// # Returns
4175 ///
4176 /// MCP servers configured for the session, with their connection status and host-level state.
4177 ///
4178 /// <div class="warning">
4179 ///
4180 /// **Experimental.** This API is part of an experimental wire-protocol surface
4181 /// and may change or be removed in future SDK or CLI releases. Pin both the
4182 /// SDK and CLI versions if your code depends on it.
4183 ///
4184 /// </div>
4185 pub async fn list(&self) -> Result<McpServerList, Error> {
4186 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
4187 let _value = self
4188 .session
4189 .client()
4190 .call(rpc_methods::SESSION_MCP_LIST, Some(wire_params))
4191 .await?;
4192 Ok(serde_json::from_value(_value)?)
4193 }
4194
4195 /// Lists the tools exposed by a connected MCP server on this session's host.
4196 ///
4197 /// Wire method: `session.mcp.listTools`.
4198 ///
4199 /// # Parameters
4200 ///
4201 /// * `params` - Server name whose tool list should be returned.
4202 ///
4203 /// # Returns
4204 ///
4205 /// Tools exposed by the connected MCP server. Throws when the server is not connected.
4206 ///
4207 /// <div class="warning">
4208 ///
4209 /// **Experimental.** This API is part of an experimental wire-protocol surface
4210 /// and may change or be removed in future SDK or CLI releases. Pin both the
4211 /// SDK and CLI versions if your code depends on it.
4212 ///
4213 /// </div>
4214 pub async fn list_tools(
4215 &self,
4216 params: McpListToolsRequest,
4217 ) -> Result<McpListToolsResult, Error> {
4218 let mut wire_params = serde_json::to_value(params)?;
4219 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4220 let _value = self
4221 .session
4222 .client()
4223 .call(rpc_methods::SESSION_MCP_LISTTOOLS, Some(wire_params))
4224 .await?;
4225 Ok(serde_json::from_value(_value)?)
4226 }
4227
4228 /// Enables an MCP server for the session.
4229 ///
4230 /// Wire method: `session.mcp.enable`.
4231 ///
4232 /// # Parameters
4233 ///
4234 /// * `params` - Name of the MCP server to enable for the session.
4235 ///
4236 /// <div class="warning">
4237 ///
4238 /// **Experimental.** This API is part of an experimental wire-protocol surface
4239 /// and may change or be removed in future SDK or CLI releases. Pin both the
4240 /// SDK and CLI versions if your code depends on it.
4241 ///
4242 /// </div>
4243 pub async fn enable(&self, params: McpEnableRequest) -> Result<(), Error> {
4244 let mut wire_params = serde_json::to_value(params)?;
4245 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4246 let _value = self
4247 .session
4248 .client()
4249 .call(rpc_methods::SESSION_MCP_ENABLE, Some(wire_params))
4250 .await?;
4251 Ok(())
4252 }
4253
4254 /// Disables an MCP server for the session.
4255 ///
4256 /// Wire method: `session.mcp.disable`.
4257 ///
4258 /// # Parameters
4259 ///
4260 /// * `params` - Name of the MCP server to disable for the session.
4261 ///
4262 /// <div class="warning">
4263 ///
4264 /// **Experimental.** This API is part of an experimental wire-protocol surface
4265 /// and may change or be removed in future SDK or CLI releases. Pin both the
4266 /// SDK and CLI versions if your code depends on it.
4267 ///
4268 /// </div>
4269 pub async fn disable(&self, params: McpDisableRequest) -> Result<(), Error> {
4270 let mut wire_params = serde_json::to_value(params)?;
4271 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4272 let _value = self
4273 .session
4274 .client()
4275 .call(rpc_methods::SESSION_MCP_DISABLE, Some(wire_params))
4276 .await?;
4277 Ok(())
4278 }
4279
4280 /// Reloads MCP server connections for the session.
4281 ///
4282 /// Wire method: `session.mcp.reload`.
4283 ///
4284 /// <div class="warning">
4285 ///
4286 /// **Experimental.** This API is part of an experimental wire-protocol surface
4287 /// and may change or be removed in future SDK or CLI releases. Pin both the
4288 /// SDK and CLI versions if your code depends on it.
4289 ///
4290 /// </div>
4291 pub async fn reload(&self) -> Result<(), Error> {
4292 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
4293 let _value = self
4294 .session
4295 .client()
4296 .call(rpc_methods::SESSION_MCP_RELOAD, Some(wire_params))
4297 .await?;
4298 Ok(())
4299 }
4300
4301 /// Reloads MCP server connections for the session with an explicit host-provided configuration.
4302 ///
4303 /// Wire method: `session.mcp.reloadWithConfig`.
4304 ///
4305 /// # Parameters
4306 ///
4307 /// * `params` - Opaque MCP reload configuration.
4308 ///
4309 /// # Returns
4310 ///
4311 /// MCP server startup filtering result.
4312 ///
4313 /// <div class="warning">
4314 ///
4315 /// **Experimental.** This API is part of an experimental wire-protocol surface
4316 /// and may change or be removed in future SDK or CLI releases. Pin both the
4317 /// SDK and CLI versions if your code depends on it.
4318 ///
4319 /// </div>
4320 pub(crate) async fn reload_with_config(
4321 &self,
4322 params: McpReloadWithConfigRequest,
4323 ) -> Result<McpStartServersResult, Error> {
4324 let mut wire_params = serde_json::to_value(params)?;
4325 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4326 let _value = self
4327 .session
4328 .client()
4329 .call(rpc_methods::SESSION_MCP_RELOADWITHCONFIG, Some(wire_params))
4330 .await?;
4331 Ok(serde_json::from_value(_value)?)
4332 }
4333
4334 /// Runs an MCP sampling inference on behalf of an MCP server.
4335 ///
4336 /// Wire method: `session.mcp.executeSampling`.
4337 ///
4338 /// # Parameters
4339 ///
4340 /// * `params` - Identifiers and raw MCP CreateMessageRequest params used to run a sampling inference.
4341 ///
4342 /// # Returns
4343 ///
4344 /// Outcome of an MCP sampling execution: success result, failure error, or cancellation.
4345 ///
4346 /// <div class="warning">
4347 ///
4348 /// **Experimental.** This API is part of an experimental wire-protocol surface
4349 /// and may change or be removed in future SDK or CLI releases. Pin both the
4350 /// SDK and CLI versions if your code depends on it.
4351 ///
4352 /// </div>
4353 pub async fn execute_sampling(
4354 &self,
4355 params: McpExecuteSamplingParams,
4356 ) -> Result<McpSamplingExecutionResult, Error> {
4357 let mut wire_params = serde_json::to_value(params)?;
4358 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4359 let _value = self
4360 .session
4361 .client()
4362 .call(rpc_methods::SESSION_MCP_EXECUTESAMPLING, Some(wire_params))
4363 .await?;
4364 Ok(serde_json::from_value(_value)?)
4365 }
4366
4367 /// Cancels an in-flight MCP sampling execution by request ID.
4368 ///
4369 /// Wire method: `session.mcp.cancelSamplingExecution`.
4370 ///
4371 /// # Parameters
4372 ///
4373 /// * `params` - The requestId previously passed to executeSampling that should be cancelled.
4374 ///
4375 /// # Returns
4376 ///
4377 /// Indicates whether an in-flight sampling execution with the given requestId was found and cancelled.
4378 ///
4379 /// <div class="warning">
4380 ///
4381 /// **Experimental.** This API is part of an experimental wire-protocol surface
4382 /// and may change or be removed in future SDK or CLI releases. Pin both the
4383 /// SDK and CLI versions if your code depends on it.
4384 ///
4385 /// </div>
4386 pub async fn cancel_sampling_execution(
4387 &self,
4388 params: McpCancelSamplingExecutionParams,
4389 ) -> Result<McpCancelSamplingExecutionResult, Error> {
4390 let mut wire_params = serde_json::to_value(params)?;
4391 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4392 let _value = self
4393 .session
4394 .client()
4395 .call(
4396 rpc_methods::SESSION_MCP_CANCELSAMPLINGEXECUTION,
4397 Some(wire_params),
4398 )
4399 .await?;
4400 Ok(serde_json::from_value(_value)?)
4401 }
4402
4403 /// Sets how environment-variable values supplied to MCP servers are resolved (direct or indirect).
4404 ///
4405 /// Wire method: `session.mcp.setEnvValueMode`.
4406 ///
4407 /// # Parameters
4408 ///
4409 /// * `params` - Mode controlling how MCP server env values are resolved (`direct` or `indirect`).
4410 ///
4411 /// # Returns
4412 ///
4413 /// Env-value mode recorded on the session after the update.
4414 ///
4415 /// <div class="warning">
4416 ///
4417 /// **Experimental.** This API is part of an experimental wire-protocol surface
4418 /// and may change or be removed in future SDK or CLI releases. Pin both the
4419 /// SDK and CLI versions if your code depends on it.
4420 ///
4421 /// </div>
4422 pub async fn set_env_value_mode(
4423 &self,
4424 params: McpSetEnvValueModeParams,
4425 ) -> Result<McpSetEnvValueModeResult, Error> {
4426 let mut wire_params = serde_json::to_value(params)?;
4427 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4428 let _value = self
4429 .session
4430 .client()
4431 .call(rpc_methods::SESSION_MCP_SETENVVALUEMODE, Some(wire_params))
4432 .await?;
4433 Ok(serde_json::from_value(_value)?)
4434 }
4435
4436 /// Removes the auto-managed `github` MCP server when present.
4437 ///
4438 /// Wire method: `session.mcp.removeGitHub`.
4439 ///
4440 /// # Returns
4441 ///
4442 /// Indicates whether the auto-managed `github` MCP server was removed (false when nothing to remove).
4443 ///
4444 /// <div class="warning">
4445 ///
4446 /// **Experimental.** This API is part of an experimental wire-protocol surface
4447 /// and may change or be removed in future SDK or CLI releases. Pin both the
4448 /// SDK and CLI versions if your code depends on it.
4449 ///
4450 /// </div>
4451 pub async fn remove_git_hub(&self) -> Result<McpRemoveGitHubResult, Error> {
4452 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
4453 let _value = self
4454 .session
4455 .client()
4456 .call(rpc_methods::SESSION_MCP_REMOVEGITHUB, Some(wire_params))
4457 .await?;
4458 Ok(serde_json::from_value(_value)?)
4459 }
4460
4461 /// Configures the built-in GitHub MCP server for the session's current auth context.
4462 ///
4463 /// Wire method: `session.mcp.configureGitHub`.
4464 ///
4465 /// # Parameters
4466 ///
4467 /// * `params` - Opaque auth info used to configure GitHub MCP.
4468 ///
4469 /// # Returns
4470 ///
4471 /// Result of configuring GitHub MCP.
4472 ///
4473 /// <div class="warning">
4474 ///
4475 /// **Experimental.** This API is part of an experimental wire-protocol surface
4476 /// and may change or be removed in future SDK or CLI releases. Pin both the
4477 /// SDK and CLI versions if your code depends on it.
4478 ///
4479 /// </div>
4480 pub(crate) async fn configure_git_hub(
4481 &self,
4482 params: McpConfigureGitHubRequest,
4483 ) -> Result<McpConfigureGitHubResult, Error> {
4484 let mut wire_params = serde_json::to_value(params)?;
4485 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4486 let _value = self
4487 .session
4488 .client()
4489 .call(rpc_methods::SESSION_MCP_CONFIGUREGITHUB, Some(wire_params))
4490 .await?;
4491 Ok(serde_json::from_value(_value)?)
4492 }
4493
4494 /// Starts an individual MCP server on the session's host.
4495 ///
4496 /// Wire method: `session.mcp.startServer`.
4497 ///
4498 /// # Parameters
4499 ///
4500 /// * `params` - Server name and opaque configuration for an individual MCP server start.
4501 ///
4502 /// <div class="warning">
4503 ///
4504 /// **Experimental.** This API is part of an experimental wire-protocol surface
4505 /// and may change or be removed in future SDK or CLI releases. Pin both the
4506 /// SDK and CLI versions if your code depends on it.
4507 ///
4508 /// </div>
4509 pub(crate) async fn start_server(&self, params: McpStartServerRequest) -> Result<(), Error> {
4510 let mut wire_params = serde_json::to_value(params)?;
4511 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4512 let _value = self
4513 .session
4514 .client()
4515 .call(rpc_methods::SESSION_MCP_STARTSERVER, Some(wire_params))
4516 .await?;
4517 Ok(())
4518 }
4519
4520 /// Restarts an individual MCP server on the session's host (stops then starts).
4521 ///
4522 /// Wire method: `session.mcp.restartServer`.
4523 ///
4524 /// # Parameters
4525 ///
4526 /// * `params` - Server name and opaque configuration for an individual MCP server restart.
4527 ///
4528 /// <div class="warning">
4529 ///
4530 /// **Experimental.** This API is part of an experimental wire-protocol surface
4531 /// and may change or be removed in future SDK or CLI releases. Pin both the
4532 /// SDK and CLI versions if your code depends on it.
4533 ///
4534 /// </div>
4535 pub(crate) async fn restart_server(
4536 &self,
4537 params: McpRestartServerRequest,
4538 ) -> Result<(), Error> {
4539 let mut wire_params = serde_json::to_value(params)?;
4540 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4541 let _value = self
4542 .session
4543 .client()
4544 .call(rpc_methods::SESSION_MCP_RESTARTSERVER, Some(wire_params))
4545 .await?;
4546 Ok(())
4547 }
4548
4549 /// Stops an individual MCP server on the session's host.
4550 ///
4551 /// Wire method: `session.mcp.stopServer`.
4552 ///
4553 /// # Parameters
4554 ///
4555 /// * `params` - Server name for an individual MCP server stop.
4556 ///
4557 /// <div class="warning">
4558 ///
4559 /// **Experimental.** This API is part of an experimental wire-protocol surface
4560 /// and may change or be removed in future SDK or CLI releases. Pin both the
4561 /// SDK and CLI versions if your code depends on it.
4562 ///
4563 /// </div>
4564 pub async fn stop_server(&self, params: McpStopServerRequest) -> Result<(), Error> {
4565 let mut wire_params = serde_json::to_value(params)?;
4566 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4567 let _value = self
4568 .session
4569 .client()
4570 .call(rpc_methods::SESSION_MCP_STOPSERVER, Some(wire_params))
4571 .await?;
4572 Ok(())
4573 }
4574
4575 /// 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.
4576 ///
4577 /// Wire method: `session.mcp.registerExternalClient`.
4578 ///
4579 /// # Parameters
4580 ///
4581 /// * `params` - Registration parameters for an external MCP client.
4582 ///
4583 /// <div class="warning">
4584 ///
4585 /// **Experimental.** This API is part of an experimental wire-protocol surface
4586 /// and may change or be removed in future SDK or CLI releases. Pin both the
4587 /// SDK and CLI versions if your code depends on it.
4588 ///
4589 /// </div>
4590 pub(crate) async fn register_external_client(
4591 &self,
4592 params: McpRegisterExternalClientRequest,
4593 ) -> Result<(), Error> {
4594 let mut wire_params = serde_json::to_value(params)?;
4595 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4596 let _value = self
4597 .session
4598 .client()
4599 .call(
4600 rpc_methods::SESSION_MCP_REGISTEREXTERNALCLIENT,
4601 Some(wire_params),
4602 )
4603 .await?;
4604 Ok(())
4605 }
4606
4607 /// 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.
4608 ///
4609 /// Wire method: `session.mcp.unregisterExternalClient`.
4610 ///
4611 /// # Parameters
4612 ///
4613 /// * `params` - Server name identifying the external client to remove.
4614 ///
4615 /// <div class="warning">
4616 ///
4617 /// **Experimental.** This API is part of an experimental wire-protocol surface
4618 /// and may change or be removed in future SDK or CLI releases. Pin both the
4619 /// SDK and CLI versions if your code depends on it.
4620 ///
4621 /// </div>
4622 pub(crate) async fn unregister_external_client(
4623 &self,
4624 params: McpUnregisterExternalClientRequest,
4625 ) -> Result<(), Error> {
4626 let mut wire_params = serde_json::to_value(params)?;
4627 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4628 let _value = self
4629 .session
4630 .client()
4631 .call(
4632 rpc_methods::SESSION_MCP_UNREGISTEREXTERNALCLIENT,
4633 Some(wire_params),
4634 )
4635 .await?;
4636 Ok(())
4637 }
4638
4639 /// Checks whether a named MCP server is currently running on the session's host.
4640 ///
4641 /// Wire method: `session.mcp.isServerRunning`.
4642 ///
4643 /// # Parameters
4644 ///
4645 /// * `params` - Server name to check running status for.
4646 ///
4647 /// # Returns
4648 ///
4649 /// Whether the named MCP server is running.
4650 ///
4651 /// <div class="warning">
4652 ///
4653 /// **Experimental.** This API is part of an experimental wire-protocol surface
4654 /// and may change or be removed in future SDK or CLI releases. Pin both the
4655 /// SDK and CLI versions if your code depends on it.
4656 ///
4657 /// </div>
4658 pub async fn is_server_running(
4659 &self,
4660 params: McpIsServerRunningRequest,
4661 ) -> Result<McpIsServerRunningResult, Error> {
4662 let mut wire_params = serde_json::to_value(params)?;
4663 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4664 let _value = self
4665 .session
4666 .client()
4667 .call(rpc_methods::SESSION_MCP_ISSERVERRUNNING, Some(wire_params))
4668 .await?;
4669 Ok(serde_json::from_value(_value)?)
4670 }
4671}
4672
4673/// `session.mcp.apps.*` RPCs.
4674#[derive(Clone, Copy)]
4675pub struct SessionRpcMcpApps<'a> {
4676 pub(crate) session: &'a Session,
4677}
4678
4679impl<'a> SessionRpcMcpApps<'a> {
4680 /// Fetch an MCP resource (typically a `ui://` MCP App bundle, per SEP-1865) from a connected server. Requires the `mcp-apps` session capability.
4681 ///
4682 /// Wire method: `session.mcp.apps.readResource`.
4683 ///
4684 /// # Parameters
4685 ///
4686 /// * `params` - MCP server and resource URI to fetch.
4687 ///
4688 /// # Returns
4689 ///
4690 /// Resource contents returned by the MCP server.
4691 ///
4692 /// <div class="warning">
4693 ///
4694 /// **Experimental.** This API is part of an experimental wire-protocol surface
4695 /// and may change or be removed in future SDK or CLI releases. Pin both the
4696 /// SDK and CLI versions if your code depends on it.
4697 ///
4698 /// </div>
4699 pub async fn read_resource(
4700 &self,
4701 params: McpAppsReadResourceRequest,
4702 ) -> Result<McpAppsReadResourceResult, Error> {
4703 let mut wire_params = serde_json::to_value(params)?;
4704 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4705 let _value = self
4706 .session
4707 .client()
4708 .call(
4709 rpc_methods::SESSION_MCP_APPS_READRESOURCE,
4710 Some(wire_params),
4711 )
4712 .await?;
4713 Ok(serde_json::from_value(_value)?)
4714 }
4715
4716 /// 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"`.
4717 ///
4718 /// Wire method: `session.mcp.apps.listTools`.
4719 ///
4720 /// # Parameters
4721 ///
4722 /// * `params` - MCP server to list app-callable tools for.
4723 ///
4724 /// # Returns
4725 ///
4726 /// App-callable tools from the named MCP server.
4727 ///
4728 /// <div class="warning">
4729 ///
4730 /// **Experimental.** This API is part of an experimental wire-protocol surface
4731 /// and may change or be removed in future SDK or CLI releases. Pin both the
4732 /// SDK and CLI versions if your code depends on it.
4733 ///
4734 /// </div>
4735 pub async fn list_tools(
4736 &self,
4737 params: McpAppsListToolsRequest,
4738 ) -> Result<McpAppsListToolsResult, Error> {
4739 let mut wire_params = serde_json::to_value(params)?;
4740 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4741 let _value = self
4742 .session
4743 .client()
4744 .call(rpc_methods::SESSION_MCP_APPS_LISTTOOLS, Some(wire_params))
4745 .await?;
4746 Ok(serde_json::from_value(_value)?)
4747 }
4748
4749 /// 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`.
4750 ///
4751 /// Wire method: `session.mcp.apps.callTool`.
4752 ///
4753 /// # Parameters
4754 ///
4755 /// * `params` - MCP server, tool name, and arguments to invoke from an MCP App view.
4756 ///
4757 /// # Returns
4758 ///
4759 /// Standard MCP CallToolResult
4760 ///
4761 /// <div class="warning">
4762 ///
4763 /// **Experimental.** This API is part of an experimental wire-protocol surface
4764 /// and may change or be removed in future SDK or CLI releases. Pin both the
4765 /// SDK and CLI versions if your code depends on it.
4766 ///
4767 /// </div>
4768 pub async fn call_tool(
4769 &self,
4770 params: McpAppsCallToolRequest,
4771 ) -> Result<SessionMcpAppsCallToolResult, Error> {
4772 let mut wire_params = serde_json::to_value(params)?;
4773 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4774 let _value = self
4775 .session
4776 .client()
4777 .call(rpc_methods::SESSION_MCP_APPS_CALLTOOL, Some(wire_params))
4778 .await?;
4779 Ok(serde_json::from_value(_value)?)
4780 }
4781
4782 /// 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.
4783 ///
4784 /// Wire method: `session.mcp.apps.setHostContext`.
4785 ///
4786 /// # Parameters
4787 ///
4788 /// * `params` - Host context to advertise to MCP App guests.
4789 ///
4790 /// <div class="warning">
4791 ///
4792 /// **Experimental.** This API is part of an experimental wire-protocol surface
4793 /// and may change or be removed in future SDK or CLI releases. Pin both the
4794 /// SDK and CLI versions if your code depends on it.
4795 ///
4796 /// </div>
4797 pub async fn set_host_context(
4798 &self,
4799 params: McpAppsSetHostContextRequest,
4800 ) -> Result<(), Error> {
4801 let mut wire_params = serde_json::to_value(params)?;
4802 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4803 let _value = self
4804 .session
4805 .client()
4806 .call(
4807 rpc_methods::SESSION_MCP_APPS_SETHOSTCONTEXT,
4808 Some(wire_params),
4809 )
4810 .await?;
4811 Ok(())
4812 }
4813
4814 /// Read the current host context advertised to MCP App guests.
4815 ///
4816 /// Wire method: `session.mcp.apps.getHostContext`.
4817 ///
4818 /// # Returns
4819 ///
4820 /// Current host context advertised to MCP App guests.
4821 ///
4822 /// <div class="warning">
4823 ///
4824 /// **Experimental.** This API is part of an experimental wire-protocol surface
4825 /// and may change or be removed in future SDK or CLI releases. Pin both the
4826 /// SDK and CLI versions if your code depends on it.
4827 ///
4828 /// </div>
4829 pub async fn get_host_context(&self) -> Result<McpAppsHostContext, Error> {
4830 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
4831 let _value = self
4832 .session
4833 .client()
4834 .call(
4835 rpc_methods::SESSION_MCP_APPS_GETHOSTCONTEXT,
4836 Some(wire_params),
4837 )
4838 .await?;
4839 Ok(serde_json::from_value(_value)?)
4840 }
4841
4842 /// 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.
4843 ///
4844 /// Wire method: `session.mcp.apps.diagnose`.
4845 ///
4846 /// # Parameters
4847 ///
4848 /// * `params` - MCP server to diagnose MCP Apps wiring for.
4849 ///
4850 /// # Returns
4851 ///
4852 /// Diagnostic snapshot of MCP Apps wiring for the named server.
4853 ///
4854 /// <div class="warning">
4855 ///
4856 /// **Experimental.** This API is part of an experimental wire-protocol surface
4857 /// and may change or be removed in future SDK or CLI releases. Pin both the
4858 /// SDK and CLI versions if your code depends on it.
4859 ///
4860 /// </div>
4861 pub async fn diagnose(
4862 &self,
4863 params: McpAppsDiagnoseRequest,
4864 ) -> Result<McpAppsDiagnoseResult, Error> {
4865 let mut wire_params = serde_json::to_value(params)?;
4866 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4867 let _value = self
4868 .session
4869 .client()
4870 .call(rpc_methods::SESSION_MCP_APPS_DIAGNOSE, Some(wire_params))
4871 .await?;
4872 Ok(serde_json::from_value(_value)?)
4873 }
4874}
4875
4876/// `session.mcp.headers.*` RPCs.
4877#[derive(Clone, Copy)]
4878pub struct SessionRpcMcpHeaders<'a> {
4879 pub(crate) session: &'a Session,
4880}
4881
4882impl<'a> SessionRpcMcpHeaders<'a> {
4883 /// 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.
4884 ///
4885 /// Wire method: `session.mcp.headers.handlePendingHeadersRefreshRequest`.
4886 ///
4887 /// # Parameters
4888 ///
4889 /// * `params` - MCP headers refresh request id and the host response.
4890 ///
4891 /// # Returns
4892 ///
4893 /// Indicates whether the pending MCP headers refresh response was accepted.
4894 ///
4895 /// <div class="warning">
4896 ///
4897 /// **Experimental.** This API is part of an experimental wire-protocol surface
4898 /// and may change or be removed in future SDK or CLI releases. Pin both the
4899 /// SDK and CLI versions if your code depends on it.
4900 ///
4901 /// </div>
4902 pub async fn handle_pending_headers_refresh_request(
4903 &self,
4904 params: McpHeadersHandlePendingHeadersRefreshRequestRequest,
4905 ) -> Result<McpHeadersHandlePendingHeadersRefreshRequestResult, Error> {
4906 let mut wire_params = serde_json::to_value(params)?;
4907 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4908 let _value = self
4909 .session
4910 .client()
4911 .call(
4912 rpc_methods::SESSION_MCP_HEADERS_HANDLEPENDINGHEADERSREFRESHREQUEST,
4913 Some(wire_params),
4914 )
4915 .await?;
4916 Ok(serde_json::from_value(_value)?)
4917 }
4918}
4919
4920/// `session.mcp.oauth.*` RPCs.
4921#[derive(Clone, Copy)]
4922pub struct SessionRpcMcpOauth<'a> {
4923 pub(crate) session: &'a Session,
4924}
4925
4926impl<'a> SessionRpcMcpOauth<'a> {
4927 /// Responds to a pending MCP OAuth request with an in-process provider. This internal CLI-only API accepts a live OAuthClientProvider instance and cannot be used over the SDK JSON-RPC boundary. Use session.mcp.oauth.handlePendingRequest instead for the public SDK-safe response path.
4928 ///
4929 /// Wire method: `session.mcp.oauth.respond`.
4930 ///
4931 /// # Parameters
4932 ///
4933 /// * `params` - MCP OAuth request id and optional provider response.
4934 ///
4935 /// # Returns
4936 ///
4937 /// Empty result after recording the MCP OAuth response.
4938 ///
4939 /// <div class="warning">
4940 ///
4941 /// **Experimental.** This API is part of an experimental wire-protocol surface
4942 /// and may change or be removed in future SDK or CLI releases. Pin both the
4943 /// SDK and CLI versions if your code depends on it.
4944 ///
4945 /// </div>
4946 pub(crate) async fn respond(
4947 &self,
4948 params: McpOauthRespondRequest,
4949 ) -> Result<McpOauthRespondResult, Error> {
4950 let mut wire_params = serde_json::to_value(params)?;
4951 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4952 let _value = self
4953 .session
4954 .client()
4955 .call(rpc_methods::SESSION_MCP_OAUTH_RESPOND, Some(wire_params))
4956 .await?;
4957 Ok(serde_json::from_value(_value)?)
4958 }
4959
4960 /// 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.
4961 ///
4962 /// Wire method: `session.mcp.oauth.handlePendingRequest`.
4963 ///
4964 /// # Parameters
4965 ///
4966 /// * `params` - Pending MCP OAuth request ID and host-provided token or cancellation response.
4967 ///
4968 /// # Returns
4969 ///
4970 /// Indicates whether the pending MCP OAuth response was accepted.
4971 ///
4972 /// <div class="warning">
4973 ///
4974 /// **Experimental.** This API is part of an experimental wire-protocol surface
4975 /// and may change or be removed in future SDK or CLI releases. Pin both the
4976 /// SDK and CLI versions if your code depends on it.
4977 ///
4978 /// </div>
4979 pub async fn handle_pending_request(
4980 &self,
4981 params: McpOauthHandlePendingRequest,
4982 ) -> Result<McpOauthHandlePendingResult, Error> {
4983 let mut wire_params = serde_json::to_value(params)?;
4984 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4985 let _value = self
4986 .session
4987 .client()
4988 .call(
4989 rpc_methods::SESSION_MCP_OAUTH_HANDLEPENDINGREQUEST,
4990 Some(wire_params),
4991 )
4992 .await?;
4993 Ok(serde_json::from_value(_value)?)
4994 }
4995
4996 /// Starts OAuth authentication for a remote MCP server.
4997 ///
4998 /// Wire method: `session.mcp.oauth.login`.
4999 ///
5000 /// # Parameters
5001 ///
5002 /// * `params` - Remote MCP server name and optional overrides controlling reauthentication, OAuth client display name, callback success-page copy, and static OAuth client selection.
5003 ///
5004 /// # Returns
5005 ///
5006 /// OAuth authorization URL the caller should open, or empty when cached tokens already authenticated the server.
5007 ///
5008 /// <div class="warning">
5009 ///
5010 /// **Experimental.** This API is part of an experimental wire-protocol surface
5011 /// and may change or be removed in future SDK or CLI releases. Pin both the
5012 /// SDK and CLI versions if your code depends on it.
5013 ///
5014 /// </div>
5015 pub async fn login(&self, params: McpOauthLoginRequest) -> Result<McpOauthLoginResult, Error> {
5016 let mut wire_params = serde_json::to_value(params)?;
5017 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5018 let _value = self
5019 .session
5020 .client()
5021 .call(rpc_methods::SESSION_MCP_OAUTH_LOGIN, Some(wire_params))
5022 .await?;
5023 Ok(serde_json::from_value(_value)?)
5024 }
5025}
5026
5027/// `session.metadata.*` RPCs.
5028#[derive(Clone, Copy)]
5029pub struct SessionRpcMetadata<'a> {
5030 pub(crate) session: &'a Session,
5031}
5032
5033impl<'a> SessionRpcMetadata<'a> {
5034 /// Returns a snapshot of the session's identifying metadata, mode, agent, and remote info.
5035 ///
5036 /// Wire method: `session.metadata.snapshot`.
5037 ///
5038 /// # Returns
5039 ///
5040 /// Point-in-time snapshot of slow-changing session identifier and state fields
5041 ///
5042 /// <div class="warning">
5043 ///
5044 /// **Experimental.** This API is part of an experimental wire-protocol surface
5045 /// and may change or be removed in future SDK or CLI releases. Pin both the
5046 /// SDK and CLI versions if your code depends on it.
5047 ///
5048 /// </div>
5049 pub async fn snapshot(&self) -> Result<SessionMetadataSnapshot, Error> {
5050 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5051 let _value = self
5052 .session
5053 .client()
5054 .call(rpc_methods::SESSION_METADATA_SNAPSHOT, Some(wire_params))
5055 .await?;
5056 Ok(serde_json::from_value(_value)?)
5057 }
5058
5059 /// Reports whether the local session is currently processing user/agent messages.
5060 ///
5061 /// Wire method: `session.metadata.isProcessing`.
5062 ///
5063 /// # Returns
5064 ///
5065 /// Indicates whether the local session is currently processing a turn or background continuation.
5066 ///
5067 /// <div class="warning">
5068 ///
5069 /// **Experimental.** This API is part of an experimental wire-protocol surface
5070 /// and may change or be removed in future SDK or CLI releases. Pin both the
5071 /// SDK and CLI versions if your code depends on it.
5072 ///
5073 /// </div>
5074 pub async fn is_processing(&self) -> Result<MetadataIsProcessingResult, Error> {
5075 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5076 let _value = self
5077 .session
5078 .client()
5079 .call(
5080 rpc_methods::SESSION_METADATA_ISPROCESSING,
5081 Some(wire_params),
5082 )
5083 .await?;
5084 Ok(serde_json::from_value(_value)?)
5085 }
5086
5087 /// Returns a snapshot of activity flags for the session.
5088 ///
5089 /// Wire method: `session.metadata.activity`.
5090 ///
5091 /// # Returns
5092 ///
5093 /// Current activity flags for the session.
5094 ///
5095 /// <div class="warning">
5096 ///
5097 /// **Experimental.** This API is part of an experimental wire-protocol surface
5098 /// and may change or be removed in future SDK or CLI releases. Pin both the
5099 /// SDK and CLI versions if your code depends on it.
5100 ///
5101 /// </div>
5102 pub async fn activity(&self) -> Result<SessionActivity, Error> {
5103 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5104 let _value = self
5105 .session
5106 .client()
5107 .call(rpc_methods::SESSION_METADATA_ACTIVITY, Some(wire_params))
5108 .await?;
5109 Ok(serde_json::from_value(_value)?)
5110 }
5111
5112 /// Returns the token breakdown for the session's current context window for a given model.
5113 ///
5114 /// Wire method: `session.metadata.contextInfo`.
5115 ///
5116 /// # Parameters
5117 ///
5118 /// * `params` - Model identifier and token limits used to compute the context-info breakdown.
5119 ///
5120 /// # Returns
5121 ///
5122 /// Token breakdown for the session's current context window, or null if uninitialized.
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 context_info(
5132 &self,
5133 params: MetadataContextInfoRequest,
5134 ) -> Result<MetadataContextInfoResult, Error> {
5135 let mut wire_params = serde_json::to_value(params)?;
5136 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5137 let _value = self
5138 .session
5139 .client()
5140 .call(rpc_methods::SESSION_METADATA_CONTEXTINFO, Some(wire_params))
5141 .await?;
5142 Ok(serde_json::from_value(_value)?)
5143 }
5144
5145 /// Records a working-directory/git context change and emits a `session.context_changed` event.
5146 ///
5147 /// Wire method: `session.metadata.recordContextChange`.
5148 ///
5149 /// # Parameters
5150 ///
5151 /// * `params` - Updated working-directory/git context to record on the session.
5152 ///
5153 /// # Returns
5154 ///
5155 /// 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).
5156 ///
5157 /// <div class="warning">
5158 ///
5159 /// **Experimental.** This API is part of an experimental wire-protocol surface
5160 /// and may change or be removed in future SDK or CLI releases. Pin both the
5161 /// SDK and CLI versions if your code depends on it.
5162 ///
5163 /// </div>
5164 pub async fn record_context_change(
5165 &self,
5166 params: MetadataRecordContextChangeRequest,
5167 ) -> Result<MetadataRecordContextChangeResult, Error> {
5168 let mut wire_params = serde_json::to_value(params)?;
5169 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5170 let _value = self
5171 .session
5172 .client()
5173 .call(
5174 rpc_methods::SESSION_METADATA_RECORDCONTEXTCHANGE,
5175 Some(wire_params),
5176 )
5177 .await?;
5178 Ok(serde_json::from_value(_value)?)
5179 }
5180
5181 /// Updates the session's recorded working directory.
5182 ///
5183 /// Wire method: `session.metadata.setWorkingDirectory`.
5184 ///
5185 /// # Parameters
5186 ///
5187 /// * `params` - Absolute path to set as the session's new working directory.
5188 ///
5189 /// # Returns
5190 ///
5191 /// 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 `process.chdir` and any related side-effects (file index, etc.); this method only updates the session's own recorded path.
5192 ///
5193 /// <div class="warning">
5194 ///
5195 /// **Experimental.** This API is part of an experimental wire-protocol surface
5196 /// and may change or be removed in future SDK or CLI releases. Pin both the
5197 /// SDK and CLI versions if your code depends on it.
5198 ///
5199 /// </div>
5200 pub async fn set_working_directory(
5201 &self,
5202 params: MetadataSetWorkingDirectoryRequest,
5203 ) -> Result<MetadataSetWorkingDirectoryResult, Error> {
5204 let mut wire_params = serde_json::to_value(params)?;
5205 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5206 let _value = self
5207 .session
5208 .client()
5209 .call(
5210 rpc_methods::SESSION_METADATA_SETWORKINGDIRECTORY,
5211 Some(wire_params),
5212 )
5213 .await?;
5214 Ok(serde_json::from_value(_value)?)
5215 }
5216
5217 /// Re-tokenizes the session's existing messages against a model and returns aggregate token totals.
5218 ///
5219 /// Wire method: `session.metadata.recomputeContextTokens`.
5220 ///
5221 /// # Parameters
5222 ///
5223 /// * `params` - Model identifier to use when re-tokenizing the session's existing messages.
5224 ///
5225 /// # Returns
5226 ///
5227 /// 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.
5228 ///
5229 /// <div class="warning">
5230 ///
5231 /// **Experimental.** This API is part of an experimental wire-protocol surface
5232 /// and may change or be removed in future SDK or CLI releases. Pin both the
5233 /// SDK and CLI versions if your code depends on it.
5234 ///
5235 /// </div>
5236 pub async fn recompute_context_tokens(
5237 &self,
5238 params: MetadataRecomputeContextTokensRequest,
5239 ) -> Result<MetadataRecomputeContextTokensResult, Error> {
5240 let mut wire_params = serde_json::to_value(params)?;
5241 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5242 let _value = self
5243 .session
5244 .client()
5245 .call(
5246 rpc_methods::SESSION_METADATA_RECOMPUTECONTEXTTOKENS,
5247 Some(wire_params),
5248 )
5249 .await?;
5250 Ok(serde_json::from_value(_value)?)
5251 }
5252}
5253
5254/// `session.mode.*` RPCs.
5255#[derive(Clone, Copy)]
5256pub struct SessionRpcMode<'a> {
5257 pub(crate) session: &'a Session,
5258}
5259
5260impl<'a> SessionRpcMode<'a> {
5261 /// Gets the current agent interaction mode.
5262 ///
5263 /// Wire method: `session.mode.get`.
5264 ///
5265 /// # Returns
5266 ///
5267 /// The session mode the agent is operating in
5268 ///
5269 /// <div class="warning">
5270 ///
5271 /// **Experimental.** This API is part of an experimental wire-protocol surface
5272 /// and may change or be removed in future SDK or CLI releases. Pin both the
5273 /// SDK and CLI versions if your code depends on it.
5274 ///
5275 /// </div>
5276 pub async fn get(&self) -> Result<SessionMode, Error> {
5277 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5278 let _value = self
5279 .session
5280 .client()
5281 .call(rpc_methods::SESSION_MODE_GET, Some(wire_params))
5282 .await?;
5283 Ok(serde_json::from_value(_value)?)
5284 }
5285
5286 /// Sets the current agent interaction mode.
5287 ///
5288 /// Wire method: `session.mode.set`.
5289 ///
5290 /// # Parameters
5291 ///
5292 /// * `params` - Agent interaction mode to apply to the session.
5293 ///
5294 /// <div class="warning">
5295 ///
5296 /// **Experimental.** This API is part of an experimental wire-protocol surface
5297 /// and may change or be removed in future SDK or CLI releases. Pin both the
5298 /// SDK and CLI versions if your code depends on it.
5299 ///
5300 /// </div>
5301 pub async fn set(&self, params: ModeSetRequest) -> Result<(), Error> {
5302 let mut wire_params = serde_json::to_value(params)?;
5303 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5304 let _value = self
5305 .session
5306 .client()
5307 .call(rpc_methods::SESSION_MODE_SET, Some(wire_params))
5308 .await?;
5309 Ok(())
5310 }
5311}
5312
5313/// `session.model.*` RPCs.
5314#[derive(Clone, Copy)]
5315pub struct SessionRpcModel<'a> {
5316 pub(crate) session: &'a Session,
5317}
5318
5319impl<'a> SessionRpcModel<'a> {
5320 /// Gets the currently selected model for the session.
5321 ///
5322 /// Wire method: `session.model.getCurrent`.
5323 ///
5324 /// # Returns
5325 ///
5326 /// The currently selected model, reasoning effort, and context tier for the session. The context tier reflects `Session.getContextTier()`, restored from the session journal on resume.
5327 ///
5328 /// <div class="warning">
5329 ///
5330 /// **Experimental.** This API is part of an experimental wire-protocol surface
5331 /// and may change or be removed in future SDK or CLI releases. Pin both the
5332 /// SDK and CLI versions if your code depends on it.
5333 ///
5334 /// </div>
5335 pub async fn get_current(&self) -> Result<CurrentModel, Error> {
5336 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5337 let _value = self
5338 .session
5339 .client()
5340 .call(rpc_methods::SESSION_MODEL_GETCURRENT, Some(wire_params))
5341 .await?;
5342 Ok(serde_json::from_value(_value)?)
5343 }
5344
5345 /// Switches the session to a model and optional reasoning configuration.
5346 ///
5347 /// Wire method: `session.model.switchTo`.
5348 ///
5349 /// # Parameters
5350 ///
5351 /// * `params` - Target model identifier and optional reasoning effort, summary, capability overrides, and context tier.
5352 ///
5353 /// # Returns
5354 ///
5355 /// The model identifier active on the session after the switch.
5356 ///
5357 /// <div class="warning">
5358 ///
5359 /// **Experimental.** This API is part of an experimental wire-protocol surface
5360 /// and may change or be removed in future SDK or CLI releases. Pin both the
5361 /// SDK and CLI versions if your code depends on it.
5362 ///
5363 /// </div>
5364 pub async fn switch_to(
5365 &self,
5366 params: ModelSwitchToRequest,
5367 ) -> Result<ModelSwitchToResult, Error> {
5368 let mut wire_params = serde_json::to_value(params)?;
5369 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5370 let _value = self
5371 .session
5372 .client()
5373 .call(rpc_methods::SESSION_MODEL_SWITCHTO, Some(wire_params))
5374 .await?;
5375 Ok(serde_json::from_value(_value)?)
5376 }
5377
5378 /// Updates the session's reasoning effort without changing the selected model.
5379 ///
5380 /// Wire method: `session.model.setReasoningEffort`.
5381 ///
5382 /// # Parameters
5383 ///
5384 /// * `params` - Reasoning effort level to apply to the currently selected model.
5385 ///
5386 /// # Returns
5387 ///
5388 /// 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.
5389 ///
5390 /// <div class="warning">
5391 ///
5392 /// **Experimental.** This API is part of an experimental wire-protocol surface
5393 /// and may change or be removed in future SDK or CLI releases. Pin both the
5394 /// SDK and CLI versions if your code depends on it.
5395 ///
5396 /// </div>
5397 pub async fn set_reasoning_effort(
5398 &self,
5399 params: ModelSetReasoningEffortRequest,
5400 ) -> Result<ModelSetReasoningEffortResult, Error> {
5401 let mut wire_params = serde_json::to_value(params)?;
5402 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5403 let _value = self
5404 .session
5405 .client()
5406 .call(
5407 rpc_methods::SESSION_MODEL_SETREASONINGEFFORT,
5408 Some(wire_params),
5409 )
5410 .await?;
5411 Ok(serde_json::from_value(_value)?)
5412 }
5413
5414 /// 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.
5415 ///
5416 /// Wire method: `session.model.list`.
5417 ///
5418 /// # Returns
5419 ///
5420 /// The list of models available to this session.
5421 ///
5422 /// <div class="warning">
5423 ///
5424 /// **Experimental.** This API is part of an experimental wire-protocol surface
5425 /// and may change or be removed in future SDK or CLI releases. Pin both the
5426 /// SDK and CLI versions if your code depends on it.
5427 ///
5428 /// </div>
5429 pub async fn list(&self) -> Result<SessionModelList, Error> {
5430 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5431 let _value = self
5432 .session
5433 .client()
5434 .call(rpc_methods::SESSION_MODEL_LIST, Some(wire_params))
5435 .await?;
5436 Ok(serde_json::from_value(_value)?)
5437 }
5438
5439 /// 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.
5440 ///
5441 /// Wire method: `session.model.list`.
5442 ///
5443 /// # Parameters
5444 ///
5445 /// * `params` - Optional listing options.
5446 ///
5447 /// # Returns
5448 ///
5449 /// The list of models available to this session.
5450 ///
5451 /// <div class="warning">
5452 ///
5453 /// **Experimental.** This API is part of an experimental wire-protocol surface
5454 /// and may change or be removed in future SDK or CLI releases. Pin both the
5455 /// SDK and CLI versions if your code depends on it.
5456 ///
5457 /// </div>
5458 pub async fn list_with_params(
5459 &self,
5460 params: ModelListRequest,
5461 ) -> Result<SessionModelList, Error> {
5462 let mut wire_params = serde_json::to_value(params)?;
5463 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5464 let _value = self
5465 .session
5466 .client()
5467 .call(rpc_methods::SESSION_MODEL_LIST, Some(wire_params))
5468 .await?;
5469 Ok(serde_json::from_value(_value)?)
5470 }
5471}
5472
5473/// `session.name.*` RPCs.
5474#[derive(Clone, Copy)]
5475pub struct SessionRpcName<'a> {
5476 pub(crate) session: &'a Session,
5477}
5478
5479impl<'a> SessionRpcName<'a> {
5480 /// Gets the session's friendly name.
5481 ///
5482 /// Wire method: `session.name.get`.
5483 ///
5484 /// # Returns
5485 ///
5486 /// The session's friendly name, or null when not yet set.
5487 ///
5488 /// <div class="warning">
5489 ///
5490 /// **Experimental.** This API is part of an experimental wire-protocol surface
5491 /// and may change or be removed in future SDK or CLI releases. Pin both the
5492 /// SDK and CLI versions if your code depends on it.
5493 ///
5494 /// </div>
5495 pub async fn get(&self) -> Result<NameGetResult, Error> {
5496 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5497 let _value = self
5498 .session
5499 .client()
5500 .call(rpc_methods::SESSION_NAME_GET, Some(wire_params))
5501 .await?;
5502 Ok(serde_json::from_value(_value)?)
5503 }
5504
5505 /// Sets the session's friendly name.
5506 ///
5507 /// Wire method: `session.name.set`.
5508 ///
5509 /// # Parameters
5510 ///
5511 /// * `params` - New friendly name to apply to the session.
5512 ///
5513 /// <div class="warning">
5514 ///
5515 /// **Experimental.** This API is part of an experimental wire-protocol surface
5516 /// and may change or be removed in future SDK or CLI releases. Pin both the
5517 /// SDK and CLI versions if your code depends on it.
5518 ///
5519 /// </div>
5520 pub async fn set(&self, params: NameSetRequest) -> Result<(), Error> {
5521 let mut wire_params = serde_json::to_value(params)?;
5522 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5523 let _value = self
5524 .session
5525 .client()
5526 .call(rpc_methods::SESSION_NAME_SET, Some(wire_params))
5527 .await?;
5528 Ok(())
5529 }
5530
5531 /// Persists an auto-generated session summary as the session's name when no user-set name exists.
5532 ///
5533 /// Wire method: `session.name.setAuto`.
5534 ///
5535 /// # Parameters
5536 ///
5537 /// * `params` - Auto-generated session summary to apply as the session's name when no user-set name exists.
5538 ///
5539 /// # Returns
5540 ///
5541 /// Indicates whether the auto-generated summary was applied as the session's name.
5542 ///
5543 /// <div class="warning">
5544 ///
5545 /// **Experimental.** This API is part of an experimental wire-protocol surface
5546 /// and may change or be removed in future SDK or CLI releases. Pin both the
5547 /// SDK and CLI versions if your code depends on it.
5548 ///
5549 /// </div>
5550 pub async fn set_auto(&self, params: NameSetAutoRequest) -> Result<NameSetAutoResult, Error> {
5551 let mut wire_params = serde_json::to_value(params)?;
5552 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5553 let _value = self
5554 .session
5555 .client()
5556 .call(rpc_methods::SESSION_NAME_SETAUTO, Some(wire_params))
5557 .await?;
5558 Ok(serde_json::from_value(_value)?)
5559 }
5560}
5561
5562/// `session.options.*` RPCs.
5563#[derive(Clone, Copy)]
5564pub struct SessionRpcOptions<'a> {
5565 pub(crate) session: &'a Session,
5566}
5567
5568impl<'a> SessionRpcOptions<'a> {
5569 /// Patches the genuinely-mutable subset of session options.
5570 ///
5571 /// Wire method: `session.options.update`.
5572 ///
5573 /// # Parameters
5574 ///
5575 /// * `params` - Patch of mutable session options to apply to the running session.
5576 ///
5577 /// # Returns
5578 ///
5579 /// Indicates whether the session options patch was applied successfully.
5580 ///
5581 /// <div class="warning">
5582 ///
5583 /// **Experimental.** This API is part of an experimental wire-protocol surface
5584 /// and may change or be removed in future SDK or CLI releases. Pin both the
5585 /// SDK and CLI versions if your code depends on it.
5586 ///
5587 /// </div>
5588 pub async fn update(
5589 &self,
5590 params: SessionUpdateOptionsParams,
5591 ) -> Result<SessionUpdateOptionsResult, Error> {
5592 let mut wire_params = serde_json::to_value(params)?;
5593 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5594 let _value = self
5595 .session
5596 .client()
5597 .call(rpc_methods::SESSION_OPTIONS_UPDATE, Some(wire_params))
5598 .await?;
5599 Ok(serde_json::from_value(_value)?)
5600 }
5601}
5602
5603/// `session.permissions.*` RPCs.
5604#[derive(Clone, Copy)]
5605pub struct SessionRpcPermissions<'a> {
5606 pub(crate) session: &'a Session,
5607}
5608
5609impl<'a> SessionRpcPermissions<'a> {
5610 /// `session.permissions.folderTrust.*` sub-namespace.
5611 pub fn folder_trust(&self) -> SessionRpcPermissionsFolderTrust<'a> {
5612 SessionRpcPermissionsFolderTrust {
5613 session: self.session,
5614 }
5615 }
5616
5617 /// `session.permissions.locations.*` sub-namespace.
5618 pub fn locations(&self) -> SessionRpcPermissionsLocations<'a> {
5619 SessionRpcPermissionsLocations {
5620 session: self.session,
5621 }
5622 }
5623
5624 /// `session.permissions.paths.*` sub-namespace.
5625 pub fn paths(&self) -> SessionRpcPermissionsPaths<'a> {
5626 SessionRpcPermissionsPaths {
5627 session: self.session,
5628 }
5629 }
5630
5631 /// `session.permissions.urls.*` sub-namespace.
5632 pub fn urls(&self) -> SessionRpcPermissionsUrls<'a> {
5633 SessionRpcPermissionsUrls {
5634 session: self.session,
5635 }
5636 }
5637
5638 /// Replaces selected permission policy fields (rules, paths, URLs, exclusions, allow-all flags) on the session.
5639 ///
5640 /// Wire method: `session.permissions.configure`.
5641 ///
5642 /// # Parameters
5643 ///
5644 /// * `params` - Patch of permission policy fields to apply (omit a field to leave it unchanged).
5645 ///
5646 /// # Returns
5647 ///
5648 /// Indicates whether the operation succeeded.
5649 ///
5650 /// <div class="warning">
5651 ///
5652 /// **Experimental.** This API is part of an experimental wire-protocol surface
5653 /// and may change or be removed in future SDK or CLI releases. Pin both the
5654 /// SDK and CLI versions if your code depends on it.
5655 ///
5656 /// </div>
5657 pub async fn configure(
5658 &self,
5659 params: PermissionsConfigureParams,
5660 ) -> Result<PermissionsConfigureResult, Error> {
5661 let mut wire_params = serde_json::to_value(params)?;
5662 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5663 let _value = self
5664 .session
5665 .client()
5666 .call(
5667 rpc_methods::SESSION_PERMISSIONS_CONFIGURE,
5668 Some(wire_params),
5669 )
5670 .await?;
5671 Ok(serde_json::from_value(_value)?)
5672 }
5673
5674 /// Provides a decision for a pending tool permission request.
5675 ///
5676 /// Wire method: `session.permissions.handlePendingPermissionRequest`.
5677 ///
5678 /// # Parameters
5679 ///
5680 /// * `params` - Pending permission request ID and the decision to apply (approve/reject and scope).
5681 ///
5682 /// # Returns
5683 ///
5684 /// Indicates whether the permission decision was applied; false when the request was already resolved.
5685 ///
5686 /// <div class="warning">
5687 ///
5688 /// **Experimental.** This API is part of an experimental wire-protocol surface
5689 /// and may change or be removed in future SDK or CLI releases. Pin both the
5690 /// SDK and CLI versions if your code depends on it.
5691 ///
5692 /// </div>
5693 pub async fn handle_pending_permission_request(
5694 &self,
5695 params: PermissionDecisionRequest,
5696 ) -> Result<PermissionRequestResult, Error> {
5697 let mut wire_params = serde_json::to_value(params)?;
5698 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5699 let _value = self
5700 .session
5701 .client()
5702 .call(
5703 rpc_methods::SESSION_PERMISSIONS_HANDLEPENDINGPERMISSIONREQUEST,
5704 Some(wire_params),
5705 )
5706 .await?;
5707 Ok(serde_json::from_value(_value)?)
5708 }
5709
5710 /// Reconstructs the set of pending tool permission requests from the session's event history.
5711 ///
5712 /// Wire method: `session.permissions.pendingRequests`.
5713 ///
5714 /// # Returns
5715 ///
5716 /// List of pending permission requests reconstructed from event history.
5717 ///
5718 /// <div class="warning">
5719 ///
5720 /// **Experimental.** This API is part of an experimental wire-protocol surface
5721 /// and may change or be removed in future SDK or CLI releases. Pin both the
5722 /// SDK and CLI versions if your code depends on it.
5723 ///
5724 /// </div>
5725 pub async fn pending_requests(&self) -> Result<PendingPermissionRequestList, Error> {
5726 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5727 let _value = self
5728 .session
5729 .client()
5730 .call(
5731 rpc_methods::SESSION_PERMISSIONS_PENDINGREQUESTS,
5732 Some(wire_params),
5733 )
5734 .await?;
5735 Ok(serde_json::from_value(_value)?)
5736 }
5737
5738 /// Enables or disables automatic approval of tool permission requests for the session.
5739 ///
5740 /// Wire method: `session.permissions.setApproveAll`.
5741 ///
5742 /// # Parameters
5743 ///
5744 /// * `params` - Allow-all toggle for tool permission requests, with an optional telemetry source.
5745 ///
5746 /// # Returns
5747 ///
5748 /// Indicates whether the operation succeeded.
5749 ///
5750 /// <div class="warning">
5751 ///
5752 /// **Experimental.** This API is part of an experimental wire-protocol surface
5753 /// and may change or be removed in future SDK or CLI releases. Pin both the
5754 /// SDK and CLI versions if your code depends on it.
5755 ///
5756 /// </div>
5757 pub async fn set_approve_all(
5758 &self,
5759 params: PermissionsSetApproveAllRequest,
5760 ) -> Result<PermissionsSetApproveAllResult, Error> {
5761 let mut wire_params = serde_json::to_value(params)?;
5762 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5763 let _value = self
5764 .session
5765 .client()
5766 .call(
5767 rpc_methods::SESSION_PERMISSIONS_SETAPPROVEALL,
5768 Some(wire_params),
5769 )
5770 .await?;
5771 Ok(serde_json::from_value(_value)?)
5772 }
5773
5774 /// Enables or disables full allow-all permissions (tools, paths, and URLs) for the session. Used by attach-mode clients (e.g. LocalRpcSession's `/allow-all` forwarder) to flip the target session's permission state. Unlike `setApproveAll`, this swaps in the unrestricted path and URL managers and emits `session.permissions_changed` on transition. The result returns the authoritative post-mutation state so callers can update their local mirrors without racing the `session.permissions_changed` notification on the same wire.
5775 ///
5776 /// Wire method: `session.permissions.setAllowAll`.
5777 ///
5778 /// # Parameters
5779 ///
5780 /// * `params` - Whether to enable full allow-all permissions for the session.
5781 ///
5782 /// # Returns
5783 ///
5784 /// Indicates whether the operation succeeded and reports the post-mutation state.
5785 ///
5786 /// <div class="warning">
5787 ///
5788 /// **Experimental.** This API is part of an experimental wire-protocol surface
5789 /// and may change or be removed in future SDK or CLI releases. Pin both the
5790 /// SDK and CLI versions if your code depends on it.
5791 ///
5792 /// </div>
5793 pub async fn set_allow_all(
5794 &self,
5795 params: PermissionsSetAllowAllRequest,
5796 ) -> Result<AllowAllPermissionSetResult, Error> {
5797 let mut wire_params = serde_json::to_value(params)?;
5798 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5799 let _value = self
5800 .session
5801 .client()
5802 .call(
5803 rpc_methods::SESSION_PERMISSIONS_SETALLOWALL,
5804 Some(wire_params),
5805 )
5806 .await?;
5807 Ok(serde_json::from_value(_value)?)
5808 }
5809
5810 /// Returns whether full allow-all permissions are currently active for the session.
5811 ///
5812 /// Wire method: `session.permissions.getAllowAll`.
5813 ///
5814 /// # Returns
5815 ///
5816 /// Current full allow-all permission state.
5817 ///
5818 /// <div class="warning">
5819 ///
5820 /// **Experimental.** This API is part of an experimental wire-protocol surface
5821 /// and may change or be removed in future SDK or CLI releases. Pin both the
5822 /// SDK and CLI versions if your code depends on it.
5823 ///
5824 /// </div>
5825 pub async fn get_allow_all(&self) -> Result<AllowAllPermissionState, Error> {
5826 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5827 let _value = self
5828 .session
5829 .client()
5830 .call(
5831 rpc_methods::SESSION_PERMISSIONS_GETALLOWALL,
5832 Some(wire_params),
5833 )
5834 .await?;
5835 Ok(serde_json::from_value(_value)?)
5836 }
5837
5838 /// Adds or removes session-scoped or location-scoped permission rules.
5839 ///
5840 /// Wire method: `session.permissions.modifyRules`.
5841 ///
5842 /// # Parameters
5843 ///
5844 /// * `params` - Scope and add/remove instructions for modifying session- or location-scoped permission rules.
5845 ///
5846 /// # Returns
5847 ///
5848 /// Indicates whether the operation succeeded.
5849 ///
5850 /// <div class="warning">
5851 ///
5852 /// **Experimental.** This API is part of an experimental wire-protocol surface
5853 /// and may change or be removed in future SDK or CLI releases. Pin both the
5854 /// SDK and CLI versions if your code depends on it.
5855 ///
5856 /// </div>
5857 pub async fn modify_rules(
5858 &self,
5859 params: PermissionsModifyRulesParams,
5860 ) -> Result<PermissionsModifyRulesResult, Error> {
5861 let mut wire_params = serde_json::to_value(params)?;
5862 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5863 let _value = self
5864 .session
5865 .client()
5866 .call(
5867 rpc_methods::SESSION_PERMISSIONS_MODIFYRULES,
5868 Some(wire_params),
5869 )
5870 .await?;
5871 Ok(serde_json::from_value(_value)?)
5872 }
5873
5874 /// Sets whether the client wants permission prompts bridged into session events.
5875 ///
5876 /// Wire method: `session.permissions.setRequired`.
5877 ///
5878 /// # Parameters
5879 ///
5880 /// * `params` - Toggles whether permission prompts should be bridged into session events for this client.
5881 ///
5882 /// # Returns
5883 ///
5884 /// Indicates whether the operation succeeded.
5885 ///
5886 /// <div class="warning">
5887 ///
5888 /// **Experimental.** This API is part of an experimental wire-protocol surface
5889 /// and may change or be removed in future SDK or CLI releases. Pin both the
5890 /// SDK and CLI versions if your code depends on it.
5891 ///
5892 /// </div>
5893 pub async fn set_required(
5894 &self,
5895 params: PermissionsSetRequiredRequest,
5896 ) -> Result<PermissionsSetRequiredResult, Error> {
5897 let mut wire_params = serde_json::to_value(params)?;
5898 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5899 let _value = self
5900 .session
5901 .client()
5902 .call(
5903 rpc_methods::SESSION_PERMISSIONS_SETREQUIRED,
5904 Some(wire_params),
5905 )
5906 .await?;
5907 Ok(serde_json::from_value(_value)?)
5908 }
5909
5910 /// Clears session-scoped tool permission approvals.
5911 ///
5912 /// Wire method: `session.permissions.resetSessionApprovals`.
5913 ///
5914 /// # Returns
5915 ///
5916 /// Indicates whether the operation succeeded.
5917 ///
5918 /// <div class="warning">
5919 ///
5920 /// **Experimental.** This API is part of an experimental wire-protocol surface
5921 /// and may change or be removed in future SDK or CLI releases. Pin both the
5922 /// SDK and CLI versions if your code depends on it.
5923 ///
5924 /// </div>
5925 pub async fn reset_session_approvals(
5926 &self,
5927 ) -> Result<PermissionsResetSessionApprovalsResult, Error> {
5928 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5929 let _value = self
5930 .session
5931 .client()
5932 .call(
5933 rpc_methods::SESSION_PERMISSIONS_RESETSESSIONAPPROVALS,
5934 Some(wire_params),
5935 )
5936 .await?;
5937 Ok(serde_json::from_value(_value)?)
5938 }
5939
5940 /// Notifies the runtime that a permission prompt UI has been shown to the user.
5941 ///
5942 /// Wire method: `session.permissions.notifyPromptShown`.
5943 ///
5944 /// # Parameters
5945 ///
5946 /// * `params` - Notification payload describing the permission prompt that the client just rendered.
5947 ///
5948 /// # Returns
5949 ///
5950 /// Indicates whether the operation succeeded.
5951 ///
5952 /// <div class="warning">
5953 ///
5954 /// **Experimental.** This API is part of an experimental wire-protocol surface
5955 /// and may change or be removed in future SDK or CLI releases. Pin both the
5956 /// SDK and CLI versions if your code depends on it.
5957 ///
5958 /// </div>
5959 pub async fn notify_prompt_shown(
5960 &self,
5961 params: PermissionPromptShownNotification,
5962 ) -> Result<PermissionsNotifyPromptShownResult, Error> {
5963 let mut wire_params = serde_json::to_value(params)?;
5964 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5965 let _value = self
5966 .session
5967 .client()
5968 .call(
5969 rpc_methods::SESSION_PERMISSIONS_NOTIFYPROMPTSHOWN,
5970 Some(wire_params),
5971 )
5972 .await?;
5973 Ok(serde_json::from_value(_value)?)
5974 }
5975}
5976
5977/// `session.permissions.folderTrust.*` RPCs.
5978#[derive(Clone, Copy)]
5979pub struct SessionRpcPermissionsFolderTrust<'a> {
5980 pub(crate) session: &'a Session,
5981}
5982
5983impl<'a> SessionRpcPermissionsFolderTrust<'a> {
5984 /// Reports whether a folder is trusted according to the user's folder trust state.
5985 ///
5986 /// Wire method: `session.permissions.folderTrust.isTrusted`.
5987 ///
5988 /// # Parameters
5989 ///
5990 /// * `params` - Folder path to check for trust.
5991 ///
5992 /// # Returns
5993 ///
5994 /// Folder trust check result.
5995 ///
5996 /// <div class="warning">
5997 ///
5998 /// **Experimental.** This API is part of an experimental wire-protocol surface
5999 /// and may change or be removed in future SDK or CLI releases. Pin both the
6000 /// SDK and CLI versions if your code depends on it.
6001 ///
6002 /// </div>
6003 pub async fn is_trusted(
6004 &self,
6005 params: FolderTrustCheckParams,
6006 ) -> Result<FolderTrustCheckResult, Error> {
6007 let mut wire_params = serde_json::to_value(params)?;
6008 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6009 let _value = self
6010 .session
6011 .client()
6012 .call(
6013 rpc_methods::SESSION_PERMISSIONS_FOLDERTRUST_ISTRUSTED,
6014 Some(wire_params),
6015 )
6016 .await?;
6017 Ok(serde_json::from_value(_value)?)
6018 }
6019
6020 /// Adds a folder to the user's trusted folders list.
6021 ///
6022 /// Wire method: `session.permissions.folderTrust.addTrusted`.
6023 ///
6024 /// # Parameters
6025 ///
6026 /// * `params` - Folder path to add to trusted folders.
6027 ///
6028 /// # Returns
6029 ///
6030 /// Indicates whether the operation succeeded.
6031 ///
6032 /// <div class="warning">
6033 ///
6034 /// **Experimental.** This API is part of an experimental wire-protocol surface
6035 /// and may change or be removed in future SDK or CLI releases. Pin both the
6036 /// SDK and CLI versions if your code depends on it.
6037 ///
6038 /// </div>
6039 pub async fn add_trusted(
6040 &self,
6041 params: FolderTrustAddParams,
6042 ) -> Result<PermissionsFolderTrustAddTrustedResult, Error> {
6043 let mut wire_params = serde_json::to_value(params)?;
6044 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6045 let _value = self
6046 .session
6047 .client()
6048 .call(
6049 rpc_methods::SESSION_PERMISSIONS_FOLDERTRUST_ADDTRUSTED,
6050 Some(wire_params),
6051 )
6052 .await?;
6053 Ok(serde_json::from_value(_value)?)
6054 }
6055}
6056
6057/// `session.permissions.locations.*` RPCs.
6058#[derive(Clone, Copy)]
6059pub struct SessionRpcPermissionsLocations<'a> {
6060 pub(crate) session: &'a Session,
6061}
6062
6063impl<'a> SessionRpcPermissionsLocations<'a> {
6064 /// Resolves the permission location key and type for a working directory.
6065 ///
6066 /// Wire method: `session.permissions.locations.resolve`.
6067 ///
6068 /// # Parameters
6069 ///
6070 /// * `params` - Working directory to resolve into a location-permissions key.
6071 ///
6072 /// # Returns
6073 ///
6074 /// Resolved location-permissions key and type.
6075 ///
6076 /// <div class="warning">
6077 ///
6078 /// **Experimental.** This API is part of an experimental wire-protocol surface
6079 /// and may change or be removed in future SDK or CLI releases. Pin both the
6080 /// SDK and CLI versions if your code depends on it.
6081 ///
6082 /// </div>
6083 pub async fn resolve(
6084 &self,
6085 params: PermissionLocationResolveParams,
6086 ) -> Result<PermissionLocationResolveResult, Error> {
6087 let mut wire_params = serde_json::to_value(params)?;
6088 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6089 let _value = self
6090 .session
6091 .client()
6092 .call(
6093 rpc_methods::SESSION_PERMISSIONS_LOCATIONS_RESOLVE,
6094 Some(wire_params),
6095 )
6096 .await?;
6097 Ok(serde_json::from_value(_value)?)
6098 }
6099
6100 /// Applies persisted location-scoped tool approvals and allowed directories for a working directory to this session's permission service.
6101 ///
6102 /// Wire method: `session.permissions.locations.apply`.
6103 ///
6104 /// # Parameters
6105 ///
6106 /// * `params` - Working directory to load persisted location permissions for.
6107 ///
6108 /// # Returns
6109 ///
6110 /// Summary of persisted location permissions applied to the session.
6111 ///
6112 /// <div class="warning">
6113 ///
6114 /// **Experimental.** This API is part of an experimental wire-protocol surface
6115 /// and may change or be removed in future SDK or CLI releases. Pin both the
6116 /// SDK and CLI versions if your code depends on it.
6117 ///
6118 /// </div>
6119 pub async fn apply(
6120 &self,
6121 params: PermissionLocationApplyParams,
6122 ) -> Result<PermissionLocationApplyResult, Error> {
6123 let mut wire_params = serde_json::to_value(params)?;
6124 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6125 let _value = self
6126 .session
6127 .client()
6128 .call(
6129 rpc_methods::SESSION_PERMISSIONS_LOCATIONS_APPLY,
6130 Some(wire_params),
6131 )
6132 .await?;
6133 Ok(serde_json::from_value(_value)?)
6134 }
6135
6136 /// Persists a tool approval for a permission location and applies its rules to this session's live permission service.
6137 ///
6138 /// Wire method: `session.permissions.locations.addToolApproval`.
6139 ///
6140 /// # Parameters
6141 ///
6142 /// * `params` - Location-scoped tool approval to persist.
6143 ///
6144 /// # Returns
6145 ///
6146 /// Indicates whether the operation succeeded.
6147 ///
6148 /// <div class="warning">
6149 ///
6150 /// **Experimental.** This API is part of an experimental wire-protocol surface
6151 /// and may change or be removed in future SDK or CLI releases. Pin both the
6152 /// SDK and CLI versions if your code depends on it.
6153 ///
6154 /// </div>
6155 pub async fn add_tool_approval(
6156 &self,
6157 params: PermissionLocationAddToolApprovalParams,
6158 ) -> Result<PermissionsLocationsAddToolApprovalResult, Error> {
6159 let mut wire_params = serde_json::to_value(params)?;
6160 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6161 let _value = self
6162 .session
6163 .client()
6164 .call(
6165 rpc_methods::SESSION_PERMISSIONS_LOCATIONS_ADDTOOLAPPROVAL,
6166 Some(wire_params),
6167 )
6168 .await?;
6169 Ok(serde_json::from_value(_value)?)
6170 }
6171}
6172
6173/// `session.permissions.paths.*` RPCs.
6174#[derive(Clone, Copy)]
6175pub struct SessionRpcPermissionsPaths<'a> {
6176 pub(crate) session: &'a Session,
6177}
6178
6179impl<'a> SessionRpcPermissionsPaths<'a> {
6180 /// Returns the session's allowed directories and primary working directory.
6181 ///
6182 /// Wire method: `session.permissions.paths.list`.
6183 ///
6184 /// # Returns
6185 ///
6186 /// Snapshot of the session's allow-listed directories and primary working directory.
6187 ///
6188 /// <div class="warning">
6189 ///
6190 /// **Experimental.** This API is part of an experimental wire-protocol surface
6191 /// and may change or be removed in future SDK or CLI releases. Pin both the
6192 /// SDK and CLI versions if your code depends on it.
6193 ///
6194 /// </div>
6195 pub async fn list(&self) -> Result<PermissionPathsList, Error> {
6196 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6197 let _value = self
6198 .session
6199 .client()
6200 .call(
6201 rpc_methods::SESSION_PERMISSIONS_PATHS_LIST,
6202 Some(wire_params),
6203 )
6204 .await?;
6205 Ok(serde_json::from_value(_value)?)
6206 }
6207
6208 /// Adds a directory to the session's allow-list.
6209 ///
6210 /// Wire method: `session.permissions.paths.add`.
6211 ///
6212 /// # Parameters
6213 ///
6214 /// * `params` - Directory path to add to the session's allowed directories.
6215 ///
6216 /// # Returns
6217 ///
6218 /// Indicates whether the operation succeeded.
6219 ///
6220 /// <div class="warning">
6221 ///
6222 /// **Experimental.** This API is part of an experimental wire-protocol surface
6223 /// and may change or be removed in future SDK or CLI releases. Pin both the
6224 /// SDK and CLI versions if your code depends on it.
6225 ///
6226 /// </div>
6227 pub async fn add(
6228 &self,
6229 params: PermissionPathsAddParams,
6230 ) -> Result<PermissionsPathsAddResult, Error> {
6231 let mut wire_params = serde_json::to_value(params)?;
6232 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6233 let _value = self
6234 .session
6235 .client()
6236 .call(
6237 rpc_methods::SESSION_PERMISSIONS_PATHS_ADD,
6238 Some(wire_params),
6239 )
6240 .await?;
6241 Ok(serde_json::from_value(_value)?)
6242 }
6243
6244 /// Updates the session's primary working directory used by the permission policy.
6245 ///
6246 /// Wire method: `session.permissions.paths.updatePrimary`.
6247 ///
6248 /// # Parameters
6249 ///
6250 /// * `params` - Directory path to set as the session's new primary working directory.
6251 ///
6252 /// # Returns
6253 ///
6254 /// Indicates whether the operation succeeded.
6255 ///
6256 /// <div class="warning">
6257 ///
6258 /// **Experimental.** This API is part of an experimental wire-protocol surface
6259 /// and may change or be removed in future SDK or CLI releases. Pin both the
6260 /// SDK and CLI versions if your code depends on it.
6261 ///
6262 /// </div>
6263 pub async fn update_primary(
6264 &self,
6265 params: PermissionPathsUpdatePrimaryParams,
6266 ) -> Result<PermissionsPathsUpdatePrimaryResult, Error> {
6267 let mut wire_params = serde_json::to_value(params)?;
6268 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6269 let _value = self
6270 .session
6271 .client()
6272 .call(
6273 rpc_methods::SESSION_PERMISSIONS_PATHS_UPDATEPRIMARY,
6274 Some(wire_params),
6275 )
6276 .await?;
6277 Ok(serde_json::from_value(_value)?)
6278 }
6279
6280 /// Reports whether a path falls within any of the session's allowed directories.
6281 ///
6282 /// Wire method: `session.permissions.paths.isPathWithinAllowedDirectories`.
6283 ///
6284 /// # Parameters
6285 ///
6286 /// * `params` - Path to evaluate against the session's allowed directories.
6287 ///
6288 /// # Returns
6289 ///
6290 /// Indicates whether the supplied path is within the session's allowed directories.
6291 ///
6292 /// <div class="warning">
6293 ///
6294 /// **Experimental.** This API is part of an experimental wire-protocol surface
6295 /// and may change or be removed in future SDK or CLI releases. Pin both the
6296 /// SDK and CLI versions if your code depends on it.
6297 ///
6298 /// </div>
6299 pub async fn is_path_within_allowed_directories(
6300 &self,
6301 params: PermissionPathsAllowedCheckParams,
6302 ) -> Result<PermissionPathsAllowedCheckResult, Error> {
6303 let mut wire_params = serde_json::to_value(params)?;
6304 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6305 let _value = self
6306 .session
6307 .client()
6308 .call(
6309 rpc_methods::SESSION_PERMISSIONS_PATHS_ISPATHWITHINALLOWEDDIRECTORIES,
6310 Some(wire_params),
6311 )
6312 .await?;
6313 Ok(serde_json::from_value(_value)?)
6314 }
6315
6316 /// Reports whether a path falls within the session's workspace (primary) directory.
6317 ///
6318 /// Wire method: `session.permissions.paths.isPathWithinWorkspace`.
6319 ///
6320 /// # Parameters
6321 ///
6322 /// * `params` - Path to evaluate against the session's workspace (primary) directory.
6323 ///
6324 /// # Returns
6325 ///
6326 /// Indicates whether the supplied path is within the session's workspace directory.
6327 ///
6328 /// <div class="warning">
6329 ///
6330 /// **Experimental.** This API is part of an experimental wire-protocol surface
6331 /// and may change or be removed in future SDK or CLI releases. Pin both the
6332 /// SDK and CLI versions if your code depends on it.
6333 ///
6334 /// </div>
6335 pub async fn is_path_within_workspace(
6336 &self,
6337 params: PermissionPathsWorkspaceCheckParams,
6338 ) -> Result<PermissionPathsWorkspaceCheckResult, Error> {
6339 let mut wire_params = serde_json::to_value(params)?;
6340 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6341 let _value = self
6342 .session
6343 .client()
6344 .call(
6345 rpc_methods::SESSION_PERMISSIONS_PATHS_ISPATHWITHINWORKSPACE,
6346 Some(wire_params),
6347 )
6348 .await?;
6349 Ok(serde_json::from_value(_value)?)
6350 }
6351}
6352
6353/// `session.permissions.urls.*` RPCs.
6354#[derive(Clone, Copy)]
6355pub struct SessionRpcPermissionsUrls<'a> {
6356 pub(crate) session: &'a Session,
6357}
6358
6359impl<'a> SessionRpcPermissionsUrls<'a> {
6360 /// Toggles the runtime's URL-permission policy between unrestricted and restricted modes.
6361 ///
6362 /// Wire method: `session.permissions.urls.setUnrestrictedMode`.
6363 ///
6364 /// # Parameters
6365 ///
6366 /// * `params` - Whether the URL-permission policy should run in unrestricted mode.
6367 ///
6368 /// # Returns
6369 ///
6370 /// Indicates whether the operation succeeded.
6371 ///
6372 /// <div class="warning">
6373 ///
6374 /// **Experimental.** This API is part of an experimental wire-protocol surface
6375 /// and may change or be removed in future SDK or CLI releases. Pin both the
6376 /// SDK and CLI versions if your code depends on it.
6377 ///
6378 /// </div>
6379 pub async fn set_unrestricted_mode(
6380 &self,
6381 params: PermissionUrlsSetUnrestrictedModeParams,
6382 ) -> Result<PermissionsUrlsSetUnrestrictedModeResult, Error> {
6383 let mut wire_params = serde_json::to_value(params)?;
6384 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6385 let _value = self
6386 .session
6387 .client()
6388 .call(
6389 rpc_methods::SESSION_PERMISSIONS_URLS_SETUNRESTRICTEDMODE,
6390 Some(wire_params),
6391 )
6392 .await?;
6393 Ok(serde_json::from_value(_value)?)
6394 }
6395}
6396
6397/// `session.plan.*` RPCs.
6398#[derive(Clone, Copy)]
6399pub struct SessionRpcPlan<'a> {
6400 pub(crate) session: &'a Session,
6401}
6402
6403impl<'a> SessionRpcPlan<'a> {
6404 /// Reads the session plan file from the workspace.
6405 ///
6406 /// Wire method: `session.plan.read`.
6407 ///
6408 /// # Returns
6409 ///
6410 /// Existence, contents, and resolved path of the session plan file.
6411 ///
6412 /// <div class="warning">
6413 ///
6414 /// **Experimental.** This API is part of an experimental wire-protocol surface
6415 /// and may change or be removed in future SDK or CLI releases. Pin both the
6416 /// SDK and CLI versions if your code depends on it.
6417 ///
6418 /// </div>
6419 pub async fn read(&self) -> Result<PlanReadResult, Error> {
6420 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6421 let _value = self
6422 .session
6423 .client()
6424 .call(rpc_methods::SESSION_PLAN_READ, Some(wire_params))
6425 .await?;
6426 Ok(serde_json::from_value(_value)?)
6427 }
6428
6429 /// Writes new content to the session plan file.
6430 ///
6431 /// Wire method: `session.plan.update`.
6432 ///
6433 /// # Parameters
6434 ///
6435 /// * `params` - Replacement contents to write to the session plan file.
6436 ///
6437 /// <div class="warning">
6438 ///
6439 /// **Experimental.** This API is part of an experimental wire-protocol surface
6440 /// and may change or be removed in future SDK or CLI releases. Pin both the
6441 /// SDK and CLI versions if your code depends on it.
6442 ///
6443 /// </div>
6444 pub async fn update(&self, params: PlanUpdateRequest) -> Result<(), Error> {
6445 let mut wire_params = serde_json::to_value(params)?;
6446 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6447 let _value = self
6448 .session
6449 .client()
6450 .call(rpc_methods::SESSION_PLAN_UPDATE, Some(wire_params))
6451 .await?;
6452 Ok(())
6453 }
6454
6455 /// Deletes the session plan file from the workspace.
6456 ///
6457 /// Wire method: `session.plan.delete`.
6458 ///
6459 /// <div class="warning">
6460 ///
6461 /// **Experimental.** This API is part of an experimental wire-protocol surface
6462 /// and may change or be removed in future SDK or CLI releases. Pin both the
6463 /// SDK and CLI versions if your code depends on it.
6464 ///
6465 /// </div>
6466 pub async fn delete(&self) -> Result<(), Error> {
6467 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6468 let _value = self
6469 .session
6470 .client()
6471 .call(rpc_methods::SESSION_PLAN_DELETE, Some(wire_params))
6472 .await?;
6473 Ok(())
6474 }
6475
6476 /// Reads todo rows from the session SQL database for plan rendering.
6477 ///
6478 /// Wire method: `session.plan.readSqlTodos`.
6479 ///
6480 /// # Returns
6481 ///
6482 /// Todo rows read from the session SQL database. Empty when no session database is available.
6483 ///
6484 /// <div class="warning">
6485 ///
6486 /// **Experimental.** This API is part of an experimental wire-protocol surface
6487 /// and may change or be removed in future SDK or CLI releases. Pin both the
6488 /// SDK and CLI versions if your code depends on it.
6489 ///
6490 /// </div>
6491 pub async fn read_sql_todos(&self) -> Result<PlanReadSqlTodosResult, Error> {
6492 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6493 let _value = self
6494 .session
6495 .client()
6496 .call(rpc_methods::SESSION_PLAN_READSQLTODOS, Some(wire_params))
6497 .await?;
6498 Ok(serde_json::from_value(_value)?)
6499 }
6500
6501 /// 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.
6502 ///
6503 /// Wire method: `session.plan.readSqlTodosWithDependencies`.
6504 ///
6505 /// # Returns
6506 ///
6507 /// Todo rows + dependency edges read from the session SQL database.
6508 ///
6509 /// <div class="warning">
6510 ///
6511 /// **Experimental.** This API is part of an experimental wire-protocol surface
6512 /// and may change or be removed in future SDK or CLI releases. Pin both the
6513 /// SDK and CLI versions if your code depends on it.
6514 ///
6515 /// </div>
6516 pub async fn read_sql_todos_with_dependencies(
6517 &self,
6518 ) -> Result<PlanReadSqlTodosWithDependenciesResult, Error> {
6519 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6520 let _value = self
6521 .session
6522 .client()
6523 .call(
6524 rpc_methods::SESSION_PLAN_READSQLTODOSWITHDEPENDENCIES,
6525 Some(wire_params),
6526 )
6527 .await?;
6528 Ok(serde_json::from_value(_value)?)
6529 }
6530}
6531
6532/// `session.plugins.*` RPCs.
6533#[derive(Clone, Copy)]
6534pub struct SessionRpcPlugins<'a> {
6535 pub(crate) session: &'a Session,
6536}
6537
6538impl<'a> SessionRpcPlugins<'a> {
6539 /// Lists plugins installed for the session.
6540 ///
6541 /// Wire method: `session.plugins.list`.
6542 ///
6543 /// # Returns
6544 ///
6545 /// Plugins installed for the session, with their enabled state and version metadata.
6546 ///
6547 /// <div class="warning">
6548 ///
6549 /// **Experimental.** This API is part of an experimental wire-protocol surface
6550 /// and may change or be removed in future SDK or CLI releases. Pin both the
6551 /// SDK and CLI versions if your code depends on it.
6552 ///
6553 /// </div>
6554 pub async fn list(&self) -> Result<PluginList, Error> {
6555 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6556 let _value = self
6557 .session
6558 .client()
6559 .call(rpc_methods::SESSION_PLUGINS_LIST, Some(wire_params))
6560 .await?;
6561 Ok(serde_json::from_value(_value)?)
6562 }
6563
6564 /// 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.
6565 ///
6566 /// Wire method: `session.plugins.reload`.
6567 ///
6568 /// <div class="warning">
6569 ///
6570 /// **Experimental.** This API is part of an experimental wire-protocol surface
6571 /// and may change or be removed in future SDK or CLI releases. Pin both the
6572 /// SDK and CLI versions if your code depends on it.
6573 ///
6574 /// </div>
6575 pub async fn reload(&self) -> Result<(), Error> {
6576 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6577 let _value = self
6578 .session
6579 .client()
6580 .call(rpc_methods::SESSION_PLUGINS_RELOAD, Some(wire_params))
6581 .await?;
6582 Ok(())
6583 }
6584
6585 /// 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.
6586 ///
6587 /// Wire method: `session.plugins.reload`.
6588 ///
6589 /// # Parameters
6590 ///
6591 /// * `params` - Optional flags controlling which side effects the reload performs.
6592 ///
6593 /// <div class="warning">
6594 ///
6595 /// **Experimental.** This API is part of an experimental wire-protocol surface
6596 /// and may change or be removed in future SDK or CLI releases. Pin both the
6597 /// SDK and CLI versions if your code depends on it.
6598 ///
6599 /// </div>
6600 pub async fn reload_with_params(&self, params: PluginsReloadRequest) -> Result<(), Error> {
6601 let mut wire_params = serde_json::to_value(params)?;
6602 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6603 let _value = self
6604 .session
6605 .client()
6606 .call(rpc_methods::SESSION_PLUGINS_RELOAD, Some(wire_params))
6607 .await?;
6608 Ok(())
6609 }
6610}
6611
6612/// `session.provider.*` RPCs.
6613#[derive(Clone, Copy)]
6614pub struct SessionRpcProvider<'a> {
6615 pub(crate) session: &'a Session,
6616}
6617
6618impl<'a> SessionRpcProvider<'a> {
6619 /// 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.
6620 ///
6621 /// Wire method: `session.provider.getEndpoint`.
6622 ///
6623 /// # Returns
6624 ///
6625 /// A snapshot of the provider endpoint the session is currently configured to talk to.
6626 ///
6627 /// <div class="warning">
6628 ///
6629 /// **Experimental.** This API is part of an experimental wire-protocol surface
6630 /// and may change or be removed in future SDK or CLI releases. Pin both the
6631 /// SDK and CLI versions if your code depends on it.
6632 ///
6633 /// </div>
6634 pub async fn get_endpoint(&self) -> Result<ProviderEndpoint, Error> {
6635 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6636 let _value = self
6637 .session
6638 .client()
6639 .call(rpc_methods::SESSION_PROVIDER_GETENDPOINT, Some(wire_params))
6640 .await?;
6641 Ok(serde_json::from_value(_value)?)
6642 }
6643
6644 /// 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.
6645 ///
6646 /// Wire method: `session.provider.getEndpoint`.
6647 ///
6648 /// # Parameters
6649 ///
6650 /// * `params` - Optional model identifier to scope the endpoint snapshot to.
6651 ///
6652 /// # Returns
6653 ///
6654 /// A snapshot of the provider endpoint the session is currently configured to talk to.
6655 ///
6656 /// <div class="warning">
6657 ///
6658 /// **Experimental.** This API is part of an experimental wire-protocol surface
6659 /// and may change or be removed in future SDK or CLI releases. Pin both the
6660 /// SDK and CLI versions if your code depends on it.
6661 ///
6662 /// </div>
6663 pub async fn get_endpoint_with_params(
6664 &self,
6665 params: ProviderGetEndpointRequest,
6666 ) -> Result<ProviderEndpoint, Error> {
6667 let mut wire_params = serde_json::to_value(params)?;
6668 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6669 let _value = self
6670 .session
6671 .client()
6672 .call(rpc_methods::SESSION_PROVIDER_GETENDPOINT, Some(wire_params))
6673 .await?;
6674 Ok(serde_json::from_value(_value)?)
6675 }
6676
6677 /// 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.
6678 ///
6679 /// Wire method: `session.provider.add`.
6680 ///
6681 /// # Parameters
6682 ///
6683 /// * `params` - BYOK providers and/or models to add to the session's registry at runtime. Both fields are optional; provide providers, models, or both.
6684 ///
6685 /// # Returns
6686 ///
6687 /// The selectable model entries synthesized for the models added by this call.
6688 ///
6689 /// <div class="warning">
6690 ///
6691 /// **Experimental.** This API is part of an experimental wire-protocol surface
6692 /// and may change or be removed in future SDK or CLI releases. Pin both the
6693 /// SDK and CLI versions if your code depends on it.
6694 ///
6695 /// </div>
6696 pub async fn add(&self, params: ProviderAddRequest) -> Result<ProviderAddResult, Error> {
6697 let mut wire_params = serde_json::to_value(params)?;
6698 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6699 let _value = self
6700 .session
6701 .client()
6702 .call(rpc_methods::SESSION_PROVIDER_ADD, Some(wire_params))
6703 .await?;
6704 Ok(serde_json::from_value(_value)?)
6705 }
6706}
6707
6708/// `session.queue.*` RPCs.
6709#[derive(Clone, Copy)]
6710pub struct SessionRpcQueue<'a> {
6711 pub(crate) session: &'a Session,
6712}
6713
6714impl<'a> SessionRpcQueue<'a> {
6715 /// Returns the local session's pending user-facing queued items and steering messages.
6716 ///
6717 /// Wire method: `session.queue.pendingItems`.
6718 ///
6719 /// # Returns
6720 ///
6721 /// Snapshot of the session's pending queued items and immediate-steering messages.
6722 ///
6723 /// <div class="warning">
6724 ///
6725 /// **Experimental.** This API is part of an experimental wire-protocol surface
6726 /// and may change or be removed in future SDK or CLI releases. Pin both the
6727 /// SDK and CLI versions if your code depends on it.
6728 ///
6729 /// </div>
6730 pub async fn pending_items(&self) -> Result<QueuePendingItemsResult, Error> {
6731 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6732 let _value = self
6733 .session
6734 .client()
6735 .call(rpc_methods::SESSION_QUEUE_PENDINGITEMS, Some(wire_params))
6736 .await?;
6737 Ok(serde_json::from_value(_value)?)
6738 }
6739
6740 /// Removes the most recently queued user-facing item (LIFO).
6741 ///
6742 /// Wire method: `session.queue.removeMostRecent`.
6743 ///
6744 /// # Returns
6745 ///
6746 /// Indicates whether a user-facing pending item was removed.
6747 ///
6748 /// <div class="warning">
6749 ///
6750 /// **Experimental.** This API is part of an experimental wire-protocol surface
6751 /// and may change or be removed in future SDK or CLI releases. Pin both the
6752 /// SDK and CLI versions if your code depends on it.
6753 ///
6754 /// </div>
6755 pub async fn remove_most_recent(&self) -> Result<QueueRemoveMostRecentResult, Error> {
6756 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6757 let _value = self
6758 .session
6759 .client()
6760 .call(
6761 rpc_methods::SESSION_QUEUE_REMOVEMOSTRECENT,
6762 Some(wire_params),
6763 )
6764 .await?;
6765 Ok(serde_json::from_value(_value)?)
6766 }
6767
6768 /// Clears all pending queued items on the local session.
6769 ///
6770 /// Wire method: `session.queue.clear`.
6771 ///
6772 /// <div class="warning">
6773 ///
6774 /// **Experimental.** This API is part of an experimental wire-protocol surface
6775 /// and may change or be removed in future SDK or CLI releases. Pin both the
6776 /// SDK and CLI versions if your code depends on it.
6777 ///
6778 /// </div>
6779 pub async fn clear(&self) -> Result<(), Error> {
6780 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6781 let _value = self
6782 .session
6783 .client()
6784 .call(rpc_methods::SESSION_QUEUE_CLEAR, Some(wire_params))
6785 .await?;
6786 Ok(())
6787 }
6788}
6789
6790/// `session.remote.*` RPCs.
6791#[derive(Clone, Copy)]
6792pub struct SessionRpcRemote<'a> {
6793 pub(crate) session: &'a Session,
6794}
6795
6796impl<'a> SessionRpcRemote<'a> {
6797 /// Enables remote session export or steering.
6798 ///
6799 /// Wire method: `session.remote.enable`.
6800 ///
6801 /// # Parameters
6802 ///
6803 /// * `params` - Optional remote session mode ("off", "export", or "on"); defaults to enabling both export and remote steering.
6804 ///
6805 /// # Returns
6806 ///
6807 /// GitHub URL for the session and a flag indicating whether remote steering is enabled.
6808 ///
6809 /// <div class="warning">
6810 ///
6811 /// **Experimental.** This API is part of an experimental wire-protocol surface
6812 /// and may change or be removed in future SDK or CLI releases. Pin both the
6813 /// SDK and CLI versions if your code depends on it.
6814 ///
6815 /// </div>
6816 pub async fn enable(&self, params: RemoteEnableRequest) -> Result<RemoteEnableResult, Error> {
6817 let mut wire_params = serde_json::to_value(params)?;
6818 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6819 let _value = self
6820 .session
6821 .client()
6822 .call(rpc_methods::SESSION_REMOTE_ENABLE, Some(wire_params))
6823 .await?;
6824 Ok(serde_json::from_value(_value)?)
6825 }
6826
6827 /// Disables remote session export and steering.
6828 ///
6829 /// Wire method: `session.remote.disable`.
6830 ///
6831 /// <div class="warning">
6832 ///
6833 /// **Experimental.** This API is part of an experimental wire-protocol surface
6834 /// and may change or be removed in future SDK or CLI releases. Pin both the
6835 /// SDK and CLI versions if your code depends on it.
6836 ///
6837 /// </div>
6838 pub async fn disable(&self) -> Result<(), Error> {
6839 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6840 let _value = self
6841 .session
6842 .client()
6843 .call(rpc_methods::SESSION_REMOTE_DISABLE, Some(wire_params))
6844 .await?;
6845 Ok(())
6846 }
6847
6848 /// Persists a remote-steerability change emitted by the host as a session event.
6849 ///
6850 /// Wire method: `session.remote.notifySteerableChanged`.
6851 ///
6852 /// # Parameters
6853 ///
6854 /// * `params` - New remote-steerability state to persist as a `session.remote_steerable_changed` event.
6855 ///
6856 /// # Returns
6857 ///
6858 /// 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.
6859 ///
6860 /// <div class="warning">
6861 ///
6862 /// **Experimental.** This API is part of an experimental wire-protocol surface
6863 /// and may change or be removed in future SDK or CLI releases. Pin both the
6864 /// SDK and CLI versions if your code depends on it.
6865 ///
6866 /// </div>
6867 pub async fn notify_steerable_changed(
6868 &self,
6869 params: RemoteNotifySteerableChangedRequest,
6870 ) -> Result<RemoteNotifySteerableChangedResult, Error> {
6871 let mut wire_params = serde_json::to_value(params)?;
6872 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6873 let _value = self
6874 .session
6875 .client()
6876 .call(
6877 rpc_methods::SESSION_REMOTE_NOTIFYSTEERABLECHANGED,
6878 Some(wire_params),
6879 )
6880 .await?;
6881 Ok(serde_json::from_value(_value)?)
6882 }
6883}
6884
6885/// `session.schedule.*` RPCs.
6886#[derive(Clone, Copy)]
6887pub struct SessionRpcSchedule<'a> {
6888 pub(crate) session: &'a Session,
6889}
6890
6891impl<'a> SessionRpcSchedule<'a> {
6892 /// Lists the session's currently active scheduled prompts.
6893 ///
6894 /// Wire method: `session.schedule.list`.
6895 ///
6896 /// # Returns
6897 ///
6898 /// Snapshot of the currently active recurring prompts for this session.
6899 ///
6900 /// <div class="warning">
6901 ///
6902 /// **Experimental.** This API is part of an experimental wire-protocol surface
6903 /// and may change or be removed in future SDK or CLI releases. Pin both the
6904 /// SDK and CLI versions if your code depends on it.
6905 ///
6906 /// </div>
6907 pub async fn list(&self) -> Result<ScheduleList, Error> {
6908 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6909 let _value = self
6910 .session
6911 .client()
6912 .call(rpc_methods::SESSION_SCHEDULE_LIST, Some(wire_params))
6913 .await?;
6914 Ok(serde_json::from_value(_value)?)
6915 }
6916
6917 /// Removes a scheduled prompt by id.
6918 ///
6919 /// Wire method: `session.schedule.stop`.
6920 ///
6921 /// # Parameters
6922 ///
6923 /// * `params` - Identifier of the scheduled prompt to remove.
6924 ///
6925 /// # Returns
6926 ///
6927 /// Remove a scheduled prompt by id. The result entry is omitted if the id was unknown.
6928 ///
6929 /// <div class="warning">
6930 ///
6931 /// **Experimental.** This API is part of an experimental wire-protocol surface
6932 /// and may change or be removed in future SDK or CLI releases. Pin both the
6933 /// SDK and CLI versions if your code depends on it.
6934 ///
6935 /// </div>
6936 pub async fn stop(&self, params: ScheduleStopRequest) -> Result<ScheduleStopResult, Error> {
6937 let mut wire_params = serde_json::to_value(params)?;
6938 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6939 let _value = self
6940 .session
6941 .client()
6942 .call(rpc_methods::SESSION_SCHEDULE_STOP, Some(wire_params))
6943 .await?;
6944 Ok(serde_json::from_value(_value)?)
6945 }
6946}
6947
6948/// `session.shell.*` RPCs.
6949#[derive(Clone, Copy)]
6950pub struct SessionRpcShell<'a> {
6951 pub(crate) session: &'a Session,
6952}
6953
6954impl<'a> SessionRpcShell<'a> {
6955 /// Starts a shell command and streams output through session notifications.
6956 ///
6957 /// Wire method: `session.shell.exec`.
6958 ///
6959 /// # Parameters
6960 ///
6961 /// * `params` - Shell command to run, with optional working directory and timeout in milliseconds.
6962 ///
6963 /// # Returns
6964 ///
6965 /// Identifier of the spawned process, used to correlate streamed output and exit notifications.
6966 ///
6967 /// <div class="warning">
6968 ///
6969 /// **Experimental.** This API is part of an experimental wire-protocol surface
6970 /// and may change or be removed in future SDK or CLI releases. Pin both the
6971 /// SDK and CLI versions if your code depends on it.
6972 ///
6973 /// </div>
6974 pub async fn exec(&self, params: ShellExecRequest) -> Result<ShellExecResult, Error> {
6975 let mut wire_params = serde_json::to_value(params)?;
6976 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6977 let _value = self
6978 .session
6979 .client()
6980 .call(rpc_methods::SESSION_SHELL_EXEC, Some(wire_params))
6981 .await?;
6982 Ok(serde_json::from_value(_value)?)
6983 }
6984
6985 /// Sends a signal to a shell process previously started via "shell.exec".
6986 ///
6987 /// Wire method: `session.shell.kill`.
6988 ///
6989 /// # Parameters
6990 ///
6991 /// * `params` - Identifier of a process previously returned by "shell.exec" and the signal to send.
6992 ///
6993 /// # Returns
6994 ///
6995 /// Indicates whether the signal was delivered; false if the process was unknown or already exited.
6996 ///
6997 /// <div class="warning">
6998 ///
6999 /// **Experimental.** This API is part of an experimental wire-protocol surface
7000 /// and may change or be removed in future SDK or CLI releases. Pin both the
7001 /// SDK and CLI versions if your code depends on it.
7002 ///
7003 /// </div>
7004 pub async fn kill(&self, params: ShellKillRequest) -> Result<ShellKillResult, Error> {
7005 let mut wire_params = serde_json::to_value(params)?;
7006 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7007 let _value = self
7008 .session
7009 .client()
7010 .call(rpc_methods::SESSION_SHELL_KILL, Some(wire_params))
7011 .await?;
7012 Ok(serde_json::from_value(_value)?)
7013 }
7014
7015 /// Executes a user-requested shell command through the session runtime.
7016 ///
7017 /// Wire method: `session.shell.executeUserRequested`.
7018 ///
7019 /// # Parameters
7020 ///
7021 /// * `params` - User-requested shell command and cancellation handle.
7022 ///
7023 /// # Returns
7024 ///
7025 /// Result of a user-requested shell command.
7026 ///
7027 /// <div class="warning">
7028 ///
7029 /// **Experimental.** This API is part of an experimental wire-protocol surface
7030 /// and may change or be removed in future SDK or CLI releases. Pin both the
7031 /// SDK and CLI versions if your code depends on it.
7032 ///
7033 /// </div>
7034 pub async fn execute_user_requested(
7035 &self,
7036 params: ShellExecuteUserRequestedRequest,
7037 ) -> Result<UserRequestedShellCommandResult, Error> {
7038 let mut wire_params = serde_json::to_value(params)?;
7039 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7040 let _value = self
7041 .session
7042 .client()
7043 .call(
7044 rpc_methods::SESSION_SHELL_EXECUTEUSERREQUESTED,
7045 Some(wire_params),
7046 )
7047 .await?;
7048 Ok(serde_json::from_value(_value)?)
7049 }
7050
7051 /// Cancels a user-requested shell command by request ID.
7052 ///
7053 /// Wire method: `session.shell.cancelUserRequested`.
7054 ///
7055 /// # Parameters
7056 ///
7057 /// * `params` - User-requested shell execution cancellation handle.
7058 ///
7059 /// # Returns
7060 ///
7061 /// Cancellation result for a user-requested shell command.
7062 ///
7063 /// <div class="warning">
7064 ///
7065 /// **Experimental.** This API is part of an experimental wire-protocol surface
7066 /// and may change or be removed in future SDK or CLI releases. Pin both the
7067 /// SDK and CLI versions if your code depends on it.
7068 ///
7069 /// </div>
7070 pub async fn cancel_user_requested(
7071 &self,
7072 params: ShellCancelUserRequestedRequest,
7073 ) -> Result<CancelUserRequestedShellCommandResult, Error> {
7074 let mut wire_params = serde_json::to_value(params)?;
7075 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7076 let _value = self
7077 .session
7078 .client()
7079 .call(
7080 rpc_methods::SESSION_SHELL_CANCELUSERREQUESTED,
7081 Some(wire_params),
7082 )
7083 .await?;
7084 Ok(serde_json::from_value(_value)?)
7085 }
7086}
7087
7088/// `session.skills.*` RPCs.
7089#[derive(Clone, Copy)]
7090pub struct SessionRpcSkills<'a> {
7091 pub(crate) session: &'a Session,
7092}
7093
7094impl<'a> SessionRpcSkills<'a> {
7095 /// Lists skills available to the session.
7096 ///
7097 /// Wire method: `session.skills.list`.
7098 ///
7099 /// # Returns
7100 ///
7101 /// Skills available to the session, with their enabled state.
7102 ///
7103 /// <div class="warning">
7104 ///
7105 /// **Experimental.** This API is part of an experimental wire-protocol surface
7106 /// and may change or be removed in future SDK or CLI releases. Pin both the
7107 /// SDK and CLI versions if your code depends on it.
7108 ///
7109 /// </div>
7110 pub async fn list(&self) -> Result<SkillList, Error> {
7111 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7112 let _value = self
7113 .session
7114 .client()
7115 .call(rpc_methods::SESSION_SKILLS_LIST, Some(wire_params))
7116 .await?;
7117 Ok(serde_json::from_value(_value)?)
7118 }
7119
7120 /// Returns the skills that have been invoked during this session.
7121 ///
7122 /// Wire method: `session.skills.getInvoked`.
7123 ///
7124 /// # Returns
7125 ///
7126 /// Skills invoked during this session, ordered by invocation time (most recent last).
7127 ///
7128 /// <div class="warning">
7129 ///
7130 /// **Experimental.** This API is part of an experimental wire-protocol surface
7131 /// and may change or be removed in future SDK or CLI releases. Pin both the
7132 /// SDK and CLI versions if your code depends on it.
7133 ///
7134 /// </div>
7135 pub async fn get_invoked(&self) -> Result<SkillsGetInvokedResult, Error> {
7136 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7137 let _value = self
7138 .session
7139 .client()
7140 .call(rpc_methods::SESSION_SKILLS_GETINVOKED, Some(wire_params))
7141 .await?;
7142 Ok(serde_json::from_value(_value)?)
7143 }
7144
7145 /// Enables a skill for the session.
7146 ///
7147 /// Wire method: `session.skills.enable`.
7148 ///
7149 /// # Parameters
7150 ///
7151 /// * `params` - Name of the skill to enable for the session.
7152 ///
7153 /// <div class="warning">
7154 ///
7155 /// **Experimental.** This API is part of an experimental wire-protocol surface
7156 /// and may change or be removed in future SDK or CLI releases. Pin both the
7157 /// SDK and CLI versions if your code depends on it.
7158 ///
7159 /// </div>
7160 pub async fn enable(&self, params: SkillsEnableRequest) -> Result<(), Error> {
7161 let mut wire_params = serde_json::to_value(params)?;
7162 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7163 let _value = self
7164 .session
7165 .client()
7166 .call(rpc_methods::SESSION_SKILLS_ENABLE, Some(wire_params))
7167 .await?;
7168 Ok(())
7169 }
7170
7171 /// Disables a skill for the session.
7172 ///
7173 /// Wire method: `session.skills.disable`.
7174 ///
7175 /// # Parameters
7176 ///
7177 /// * `params` - Name of the skill to disable for the session.
7178 ///
7179 /// <div class="warning">
7180 ///
7181 /// **Experimental.** This API is part of an experimental wire-protocol surface
7182 /// and may change or be removed in future SDK or CLI releases. Pin both the
7183 /// SDK and CLI versions if your code depends on it.
7184 ///
7185 /// </div>
7186 pub async fn disable(&self, params: SkillsDisableRequest) -> Result<(), Error> {
7187 let mut wire_params = serde_json::to_value(params)?;
7188 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7189 let _value = self
7190 .session
7191 .client()
7192 .call(rpc_methods::SESSION_SKILLS_DISABLE, Some(wire_params))
7193 .await?;
7194 Ok(())
7195 }
7196
7197 /// Reloads skill definitions for the session.
7198 ///
7199 /// Wire method: `session.skills.reload`.
7200 ///
7201 /// # Returns
7202 ///
7203 /// Diagnostics from reloading skill definitions, with warnings and errors as separate lists.
7204 ///
7205 /// <div class="warning">
7206 ///
7207 /// **Experimental.** This API is part of an experimental wire-protocol surface
7208 /// and may change or be removed in future SDK or CLI releases. Pin both the
7209 /// SDK and CLI versions if your code depends on it.
7210 ///
7211 /// </div>
7212 pub async fn reload(&self) -> Result<SkillsLoadDiagnostics, Error> {
7213 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7214 let _value = self
7215 .session
7216 .client()
7217 .call(rpc_methods::SESSION_SKILLS_RELOAD, Some(wire_params))
7218 .await?;
7219 Ok(serde_json::from_value(_value)?)
7220 }
7221
7222 /// Ensures the session's skill definitions have been loaded from disk.
7223 ///
7224 /// Wire method: `session.skills.ensureLoaded`.
7225 ///
7226 /// <div class="warning">
7227 ///
7228 /// **Experimental.** This API is part of an experimental wire-protocol surface
7229 /// and may change or be removed in future SDK or CLI releases. Pin both the
7230 /// SDK and CLI versions if your code depends on it.
7231 ///
7232 /// </div>
7233 pub async fn ensure_loaded(&self) -> Result<(), Error> {
7234 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7235 let _value = self
7236 .session
7237 .client()
7238 .call(rpc_methods::SESSION_SKILLS_ENSURELOADED, Some(wire_params))
7239 .await?;
7240 Ok(())
7241 }
7242}
7243
7244/// `session.tasks.*` RPCs.
7245#[derive(Clone, Copy)]
7246pub struct SessionRpcTasks<'a> {
7247 pub(crate) session: &'a Session,
7248}
7249
7250impl<'a> SessionRpcTasks<'a> {
7251 /// Starts a background agent task in the session.
7252 ///
7253 /// Wire method: `session.tasks.startAgent`.
7254 ///
7255 /// # Parameters
7256 ///
7257 /// * `params` - Agent type, prompt, name, and optional description and model override for the new task.
7258 ///
7259 /// # Returns
7260 ///
7261 /// Identifier assigned to the newly started background agent task.
7262 ///
7263 /// <div class="warning">
7264 ///
7265 /// **Experimental.** This API is part of an experimental wire-protocol surface
7266 /// and may change or be removed in future SDK or CLI releases. Pin both the
7267 /// SDK and CLI versions if your code depends on it.
7268 ///
7269 /// </div>
7270 pub async fn start_agent(
7271 &self,
7272 params: TasksStartAgentRequest,
7273 ) -> Result<TasksStartAgentResult, Error> {
7274 let mut wire_params = serde_json::to_value(params)?;
7275 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7276 let _value = self
7277 .session
7278 .client()
7279 .call(rpc_methods::SESSION_TASKS_STARTAGENT, Some(wire_params))
7280 .await?;
7281 Ok(serde_json::from_value(_value)?)
7282 }
7283
7284 /// Lists background tasks tracked by the session.
7285 ///
7286 /// Wire method: `session.tasks.list`.
7287 ///
7288 /// # Returns
7289 ///
7290 /// Background tasks currently tracked by the session.
7291 ///
7292 /// <div class="warning">
7293 ///
7294 /// **Experimental.** This API is part of an experimental wire-protocol surface
7295 /// and may change or be removed in future SDK or CLI releases. Pin both the
7296 /// SDK and CLI versions if your code depends on it.
7297 ///
7298 /// </div>
7299 pub async fn list(&self) -> Result<TaskList, Error> {
7300 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7301 let _value = self
7302 .session
7303 .client()
7304 .call(rpc_methods::SESSION_TASKS_LIST, Some(wire_params))
7305 .await?;
7306 Ok(serde_json::from_value(_value)?)
7307 }
7308
7309 /// Refreshes metadata for any detached background shells the runtime knows about.
7310 ///
7311 /// Wire method: `session.tasks.refresh`.
7312 ///
7313 /// # Returns
7314 ///
7315 /// 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.
7316 ///
7317 /// <div class="warning">
7318 ///
7319 /// **Experimental.** This API is part of an experimental wire-protocol surface
7320 /// and may change or be removed in future SDK or CLI releases. Pin both the
7321 /// SDK and CLI versions if your code depends on it.
7322 ///
7323 /// </div>
7324 pub async fn refresh(&self) -> Result<TasksRefreshResult, Error> {
7325 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7326 let _value = self
7327 .session
7328 .client()
7329 .call(rpc_methods::SESSION_TASKS_REFRESH, Some(wire_params))
7330 .await?;
7331 Ok(serde_json::from_value(_value)?)
7332 }
7333
7334 /// Waits for all in-flight background tasks and any follow-up turns to settle.
7335 ///
7336 /// Wire method: `session.tasks.waitForPending`.
7337 ///
7338 /// # Returns
7339 ///
7340 /// 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).
7341 ///
7342 /// <div class="warning">
7343 ///
7344 /// **Experimental.** This API is part of an experimental wire-protocol surface
7345 /// and may change or be removed in future SDK or CLI releases. Pin both the
7346 /// SDK and CLI versions if your code depends on it.
7347 ///
7348 /// </div>
7349 pub async fn wait_for_pending(&self) -> Result<TasksWaitForPendingResult, Error> {
7350 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7351 let _value = self
7352 .session
7353 .client()
7354 .call(rpc_methods::SESSION_TASKS_WAITFORPENDING, Some(wire_params))
7355 .await?;
7356 Ok(serde_json::from_value(_value)?)
7357 }
7358
7359 /// Returns progress information for a background task by ID.
7360 ///
7361 /// Wire method: `session.tasks.getProgress`.
7362 ///
7363 /// # Parameters
7364 ///
7365 /// * `params` - Identifier of the background task to fetch progress for.
7366 ///
7367 /// # Returns
7368 ///
7369 /// Progress information for the task, or null when no task with that ID is tracked.
7370 ///
7371 /// <div class="warning">
7372 ///
7373 /// **Experimental.** This API is part of an experimental wire-protocol surface
7374 /// and may change or be removed in future SDK or CLI releases. Pin both the
7375 /// SDK and CLI versions if your code depends on it.
7376 ///
7377 /// </div>
7378 pub async fn get_progress(
7379 &self,
7380 params: TasksGetProgressRequest,
7381 ) -> Result<TasksGetProgressResult, Error> {
7382 let mut wire_params = serde_json::to_value(params)?;
7383 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7384 let _value = self
7385 .session
7386 .client()
7387 .call(rpc_methods::SESSION_TASKS_GETPROGRESS, Some(wire_params))
7388 .await?;
7389 Ok(serde_json::from_value(_value)?)
7390 }
7391
7392 /// Returns the first sync-waiting task that can currently be promoted to background mode.
7393 ///
7394 /// Wire method: `session.tasks.getCurrentPromotable`.
7395 ///
7396 /// # Returns
7397 ///
7398 /// The first sync-waiting task that can currently be promoted to background mode.
7399 ///
7400 /// <div class="warning">
7401 ///
7402 /// **Experimental.** This API is part of an experimental wire-protocol surface
7403 /// and may change or be removed in future SDK or CLI releases. Pin both the
7404 /// SDK and CLI versions if your code depends on it.
7405 ///
7406 /// </div>
7407 pub async fn get_current_promotable(&self) -> Result<TasksGetCurrentPromotableResult, Error> {
7408 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7409 let _value = self
7410 .session
7411 .client()
7412 .call(
7413 rpc_methods::SESSION_TASKS_GETCURRENTPROMOTABLE,
7414 Some(wire_params),
7415 )
7416 .await?;
7417 Ok(serde_json::from_value(_value)?)
7418 }
7419
7420 /// Promotes an eligible synchronously-waited task so it continues running in the background.
7421 ///
7422 /// Wire method: `session.tasks.promoteToBackground`.
7423 ///
7424 /// # Parameters
7425 ///
7426 /// * `params` - Identifier of the task to promote to background mode.
7427 ///
7428 /// # Returns
7429 ///
7430 /// Indicates whether the task was successfully promoted to background mode.
7431 ///
7432 /// <div class="warning">
7433 ///
7434 /// **Experimental.** This API is part of an experimental wire-protocol surface
7435 /// and may change or be removed in future SDK or CLI releases. Pin both the
7436 /// SDK and CLI versions if your code depends on it.
7437 ///
7438 /// </div>
7439 pub async fn promote_to_background(
7440 &self,
7441 params: TasksPromoteToBackgroundRequest,
7442 ) -> Result<TasksPromoteToBackgroundResult, Error> {
7443 let mut wire_params = serde_json::to_value(params)?;
7444 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7445 let _value = self
7446 .session
7447 .client()
7448 .call(
7449 rpc_methods::SESSION_TASKS_PROMOTETOBACKGROUND,
7450 Some(wire_params),
7451 )
7452 .await?;
7453 Ok(serde_json::from_value(_value)?)
7454 }
7455
7456 /// Atomically promotes the first promotable sync-waiting task to background mode and returns it.
7457 ///
7458 /// Wire method: `session.tasks.promoteCurrentToBackground`.
7459 ///
7460 /// # Returns
7461 ///
7462 /// The promoted task as it now exists in background mode, omitted if no promotable task was waiting.
7463 ///
7464 /// <div class="warning">
7465 ///
7466 /// **Experimental.** This API is part of an experimental wire-protocol surface
7467 /// and may change or be removed in future SDK or CLI releases. Pin both the
7468 /// SDK and CLI versions if your code depends on it.
7469 ///
7470 /// </div>
7471 pub async fn promote_current_to_background(
7472 &self,
7473 ) -> Result<TasksPromoteCurrentToBackgroundResult, Error> {
7474 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7475 let _value = self
7476 .session
7477 .client()
7478 .call(
7479 rpc_methods::SESSION_TASKS_PROMOTECURRENTTOBACKGROUND,
7480 Some(wire_params),
7481 )
7482 .await?;
7483 Ok(serde_json::from_value(_value)?)
7484 }
7485
7486 /// Cancels a background task.
7487 ///
7488 /// Wire method: `session.tasks.cancel`.
7489 ///
7490 /// # Parameters
7491 ///
7492 /// * `params` - Identifier of the background task to cancel.
7493 ///
7494 /// # Returns
7495 ///
7496 /// Indicates whether the background task was successfully cancelled.
7497 ///
7498 /// <div class="warning">
7499 ///
7500 /// **Experimental.** This API is part of an experimental wire-protocol surface
7501 /// and may change or be removed in future SDK or CLI releases. Pin both the
7502 /// SDK and CLI versions if your code depends on it.
7503 ///
7504 /// </div>
7505 pub async fn cancel(&self, params: TasksCancelRequest) -> Result<TasksCancelResult, Error> {
7506 let mut wire_params = serde_json::to_value(params)?;
7507 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7508 let _value = self
7509 .session
7510 .client()
7511 .call(rpc_methods::SESSION_TASKS_CANCEL, Some(wire_params))
7512 .await?;
7513 Ok(serde_json::from_value(_value)?)
7514 }
7515
7516 /// Removes a completed or cancelled background task from tracking.
7517 ///
7518 /// Wire method: `session.tasks.remove`.
7519 ///
7520 /// # Parameters
7521 ///
7522 /// * `params` - Identifier of the completed or cancelled task to remove from tracking.
7523 ///
7524 /// # Returns
7525 ///
7526 /// Indicates whether the task was removed. False when the task does not exist or is still running/idle.
7527 ///
7528 /// <div class="warning">
7529 ///
7530 /// **Experimental.** This API is part of an experimental wire-protocol surface
7531 /// and may change or be removed in future SDK or CLI releases. Pin both the
7532 /// SDK and CLI versions if your code depends on it.
7533 ///
7534 /// </div>
7535 pub async fn remove(&self, params: TasksRemoveRequest) -> Result<TasksRemoveResult, Error> {
7536 let mut wire_params = serde_json::to_value(params)?;
7537 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7538 let _value = self
7539 .session
7540 .client()
7541 .call(rpc_methods::SESSION_TASKS_REMOVE, Some(wire_params))
7542 .await?;
7543 Ok(serde_json::from_value(_value)?)
7544 }
7545
7546 /// Sends a message to a background agent task.
7547 ///
7548 /// Wire method: `session.tasks.sendMessage`.
7549 ///
7550 /// # Parameters
7551 ///
7552 /// * `params` - Identifier of the target agent task, message content, and optional sender agent ID.
7553 ///
7554 /// # Returns
7555 ///
7556 /// Indicates whether the message was delivered, with an error message when delivery failed.
7557 ///
7558 /// <div class="warning">
7559 ///
7560 /// **Experimental.** This API is part of an experimental wire-protocol surface
7561 /// and may change or be removed in future SDK or CLI releases. Pin both the
7562 /// SDK and CLI versions if your code depends on it.
7563 ///
7564 /// </div>
7565 pub async fn send_message(
7566 &self,
7567 params: TasksSendMessageRequest,
7568 ) -> Result<TasksSendMessageResult, Error> {
7569 let mut wire_params = serde_json::to_value(params)?;
7570 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7571 let _value = self
7572 .session
7573 .client()
7574 .call(rpc_methods::SESSION_TASKS_SENDMESSAGE, Some(wire_params))
7575 .await?;
7576 Ok(serde_json::from_value(_value)?)
7577 }
7578}
7579
7580/// `session.telemetry.*` RPCs.
7581#[derive(Clone, Copy)]
7582pub struct SessionRpcTelemetry<'a> {
7583 pub(crate) session: &'a Session,
7584}
7585
7586impl<'a> SessionRpcTelemetry<'a> {
7587 /// Gets the telemetry engagement ID currently associated with the session, when available.
7588 ///
7589 /// Wire method: `session.telemetry.getEngagementId`.
7590 ///
7591 /// # Returns
7592 ///
7593 /// Telemetry engagement ID for the session, when available.
7594 ///
7595 /// <div class="warning">
7596 ///
7597 /// **Experimental.** This API is part of an experimental wire-protocol surface
7598 /// and may change or be removed in future SDK or CLI releases. Pin both the
7599 /// SDK and CLI versions if your code depends on it.
7600 ///
7601 /// </div>
7602 pub async fn get_engagement_id(&self) -> Result<SessionTelemetryEngagement, Error> {
7603 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7604 let _value = self
7605 .session
7606 .client()
7607 .call(
7608 rpc_methods::SESSION_TELEMETRY_GETENGAGEMENTID,
7609 Some(wire_params),
7610 )
7611 .await?;
7612 Ok(serde_json::from_value(_value)?)
7613 }
7614
7615 /// Sets feature override key/value pairs to attach to subsequent telemetry events for the session.
7616 ///
7617 /// Wire method: `session.telemetry.setFeatureOverrides`.
7618 ///
7619 /// # Parameters
7620 ///
7621 /// * `params` - Feature override key/value pairs to attach to subsequent telemetry events from this session.
7622 ///
7623 /// <div class="warning">
7624 ///
7625 /// **Experimental.** This API is part of an experimental wire-protocol surface
7626 /// and may change or be removed in future SDK or CLI releases. Pin both the
7627 /// SDK and CLI versions if your code depends on it.
7628 ///
7629 /// </div>
7630 pub async fn set_feature_overrides(
7631 &self,
7632 params: TelemetrySetFeatureOverridesRequest,
7633 ) -> Result<(), Error> {
7634 let mut wire_params = serde_json::to_value(params)?;
7635 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7636 let _value = self
7637 .session
7638 .client()
7639 .call(
7640 rpc_methods::SESSION_TELEMETRY_SETFEATUREOVERRIDES,
7641 Some(wire_params),
7642 )
7643 .await?;
7644 Ok(())
7645 }
7646}
7647
7648/// `session.tools.*` RPCs.
7649#[derive(Clone, Copy)]
7650pub struct SessionRpcTools<'a> {
7651 pub(crate) session: &'a Session,
7652}
7653
7654impl<'a> SessionRpcTools<'a> {
7655 /// Provides the result for a pending external tool call.
7656 ///
7657 /// Wire method: `session.tools.handlePendingToolCall`.
7658 ///
7659 /// # Parameters
7660 ///
7661 /// * `params` - Pending external tool call request ID, with the tool result or an error describing why it failed.
7662 ///
7663 /// # Returns
7664 ///
7665 /// Indicates whether the external tool call result was handled successfully.
7666 ///
7667 /// <div class="warning">
7668 ///
7669 /// **Experimental.** This API is part of an experimental wire-protocol surface
7670 /// and may change or be removed in future SDK or CLI releases. Pin both the
7671 /// SDK and CLI versions if your code depends on it.
7672 ///
7673 /// </div>
7674 pub async fn handle_pending_tool_call(
7675 &self,
7676 params: HandlePendingToolCallRequest,
7677 ) -> Result<HandlePendingToolCallResult, Error> {
7678 let mut wire_params = serde_json::to_value(params)?;
7679 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7680 let _value = self
7681 .session
7682 .client()
7683 .call(
7684 rpc_methods::SESSION_TOOLS_HANDLEPENDINGTOOLCALL,
7685 Some(wire_params),
7686 )
7687 .await?;
7688 Ok(serde_json::from_value(_value)?)
7689 }
7690
7691 /// Resolves, builds, and validates the runtime tool list for the session.
7692 ///
7693 /// Wire method: `session.tools.initializeAndValidate`.
7694 ///
7695 /// # Returns
7696 ///
7697 /// 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.
7698 ///
7699 /// <div class="warning">
7700 ///
7701 /// **Experimental.** This API is part of an experimental wire-protocol surface
7702 /// and may change or be removed in future SDK or CLI releases. Pin both the
7703 /// SDK and CLI versions if your code depends on it.
7704 ///
7705 /// </div>
7706 pub async fn initialize_and_validate(&self) -> Result<ToolsInitializeAndValidateResult, Error> {
7707 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7708 let _value = self
7709 .session
7710 .client()
7711 .call(
7712 rpc_methods::SESSION_TOOLS_INITIALIZEANDVALIDATE,
7713 Some(wire_params),
7714 )
7715 .await?;
7716 Ok(serde_json::from_value(_value)?)
7717 }
7718
7719 /// Returns lightweight metadata for the session's currently initialized tools.
7720 ///
7721 /// Wire method: `session.tools.getCurrentMetadata`.
7722 ///
7723 /// # Returns
7724 ///
7725 /// Current lightweight tool metadata snapshot for the session.
7726 ///
7727 /// <div class="warning">
7728 ///
7729 /// **Experimental.** This API is part of an experimental wire-protocol surface
7730 /// and may change or be removed in future SDK or CLI releases. Pin both the
7731 /// SDK and CLI versions if your code depends on it.
7732 ///
7733 /// </div>
7734 pub async fn get_current_metadata(&self) -> Result<ToolsGetCurrentMetadataResult, Error> {
7735 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7736 let _value = self
7737 .session
7738 .client()
7739 .call(
7740 rpc_methods::SESSION_TOOLS_GETCURRENTMETADATA,
7741 Some(wire_params),
7742 )
7743 .await?;
7744 Ok(serde_json::from_value(_value)?)
7745 }
7746
7747 /// Updates the current session's live subagent settings after user settings change. The persisted user settings remain the source of truth for future sessions.
7748 ///
7749 /// Wire method: `session.tools.updateSubagentSettings`.
7750 ///
7751 /// # Parameters
7752 ///
7753 /// * `params` - Subagent settings to apply to the current session
7754 ///
7755 /// # Returns
7756 ///
7757 /// Empty result after applying subagent settings
7758 ///
7759 /// <div class="warning">
7760 ///
7761 /// **Experimental.** This API is part of an experimental wire-protocol surface
7762 /// and may change or be removed in future SDK or CLI releases. Pin both the
7763 /// SDK and CLI versions if your code depends on it.
7764 ///
7765 /// </div>
7766 pub async fn update_subagent_settings(
7767 &self,
7768 params: UpdateSubagentSettingsRequest,
7769 ) -> Result<ToolsUpdateSubagentSettingsResult, Error> {
7770 let mut wire_params = serde_json::to_value(params)?;
7771 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7772 let _value = self
7773 .session
7774 .client()
7775 .call(
7776 rpc_methods::SESSION_TOOLS_UPDATESUBAGENTSETTINGS,
7777 Some(wire_params),
7778 )
7779 .await?;
7780 Ok(serde_json::from_value(_value)?)
7781 }
7782}
7783
7784/// `session.ui.*` RPCs.
7785#[derive(Clone, Copy)]
7786pub struct SessionRpcUi<'a> {
7787 pub(crate) session: &'a Session,
7788}
7789
7790impl<'a> SessionRpcUi<'a> {
7791 /// Runs a transient no-tools model query against the current conversation context.
7792 ///
7793 /// Wire method: `session.ui.ephemeralQuery`.
7794 ///
7795 /// # Parameters
7796 ///
7797 /// * `params` - Transient question to answer without adding it to conversation history.
7798 ///
7799 /// # Returns
7800 ///
7801 /// Transient answer generated from current conversation context.
7802 ///
7803 /// <div class="warning">
7804 ///
7805 /// **Experimental.** This API is part of an experimental wire-protocol surface
7806 /// and may change or be removed in future SDK or CLI releases. Pin both the
7807 /// SDK and CLI versions if your code depends on it.
7808 ///
7809 /// </div>
7810 pub async fn ephemeral_query(
7811 &self,
7812 params: UIEphemeralQueryRequest,
7813 ) -> Result<UIEphemeralQueryResult, Error> {
7814 let mut wire_params = serde_json::to_value(params)?;
7815 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7816 let _value = self
7817 .session
7818 .client()
7819 .call(rpc_methods::SESSION_UI_EPHEMERALQUERY, Some(wire_params))
7820 .await?;
7821 Ok(serde_json::from_value(_value)?)
7822 }
7823
7824 /// Requests structured input from a UI-capable client.
7825 ///
7826 /// Wire method: `session.ui.elicitation`.
7827 ///
7828 /// # Parameters
7829 ///
7830 /// * `params` - Prompt message and JSON schema describing the form fields to elicit from the user.
7831 ///
7832 /// # Returns
7833 ///
7834 /// The elicitation response (accept with form values, decline, or cancel)
7835 ///
7836 /// <div class="warning">
7837 ///
7838 /// **Experimental.** This API is part of an experimental wire-protocol surface
7839 /// and may change or be removed in future SDK or CLI releases. Pin both the
7840 /// SDK and CLI versions if your code depends on it.
7841 ///
7842 /// </div>
7843 pub async fn elicitation(
7844 &self,
7845 params: UIElicitationRequest,
7846 ) -> Result<UIElicitationResponse, Error> {
7847 let mut wire_params = serde_json::to_value(params)?;
7848 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7849 let _value = self
7850 .session
7851 .client()
7852 .call(rpc_methods::SESSION_UI_ELICITATION, Some(wire_params))
7853 .await?;
7854 Ok(serde_json::from_value(_value)?)
7855 }
7856
7857 /// Provides the user response for a pending elicitation request.
7858 ///
7859 /// Wire method: `session.ui.handlePendingElicitation`.
7860 ///
7861 /// # Parameters
7862 ///
7863 /// * `params` - Pending elicitation request ID and the user's response (accept/decline/cancel + form values).
7864 ///
7865 /// # Returns
7866 ///
7867 /// Indicates whether the elicitation response was accepted; false if it was already resolved by another client.
7868 ///
7869 /// <div class="warning">
7870 ///
7871 /// **Experimental.** This API is part of an experimental wire-protocol surface
7872 /// and may change or be removed in future SDK or CLI releases. Pin both the
7873 /// SDK and CLI versions if your code depends on it.
7874 ///
7875 /// </div>
7876 pub async fn handle_pending_elicitation(
7877 &self,
7878 params: UIHandlePendingElicitationRequest,
7879 ) -> Result<UIElicitationResult, Error> {
7880 let mut wire_params = serde_json::to_value(params)?;
7881 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7882 let _value = self
7883 .session
7884 .client()
7885 .call(
7886 rpc_methods::SESSION_UI_HANDLEPENDINGELICITATION,
7887 Some(wire_params),
7888 )
7889 .await?;
7890 Ok(serde_json::from_value(_value)?)
7891 }
7892
7893 /// Resolves a pending `user_input.requested` event with the user's response.
7894 ///
7895 /// Wire method: `session.ui.handlePendingUserInput`.
7896 ///
7897 /// # Parameters
7898 ///
7899 /// * `params` - Request ID of a pending `user_input.requested` event and the user's response.
7900 ///
7901 /// # Returns
7902 ///
7903 /// Indicates whether the pending UI request was resolved by this call.
7904 ///
7905 /// <div class="warning">
7906 ///
7907 /// **Experimental.** This API is part of an experimental wire-protocol surface
7908 /// and may change or be removed in future SDK or CLI releases. Pin both the
7909 /// SDK and CLI versions if your code depends on it.
7910 ///
7911 /// </div>
7912 pub async fn handle_pending_user_input(
7913 &self,
7914 params: UIHandlePendingUserInputRequest,
7915 ) -> Result<UIHandlePendingResult, Error> {
7916 let mut wire_params = serde_json::to_value(params)?;
7917 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7918 let _value = self
7919 .session
7920 .client()
7921 .call(
7922 rpc_methods::SESSION_UI_HANDLEPENDINGUSERINPUT,
7923 Some(wire_params),
7924 )
7925 .await?;
7926 Ok(serde_json::from_value(_value)?)
7927 }
7928
7929 /// Resolves a pending `sampling.requested` event with a sampling result, or rejects it.
7930 ///
7931 /// Wire method: `session.ui.handlePendingSampling`.
7932 ///
7933 /// # Parameters
7934 ///
7935 /// * `params` - Request ID of a pending `sampling.requested` event and an optional sampling result payload (omit to reject).
7936 ///
7937 /// # Returns
7938 ///
7939 /// Indicates whether the pending UI request was resolved by this call.
7940 ///
7941 /// <div class="warning">
7942 ///
7943 /// **Experimental.** This API is part of an experimental wire-protocol surface
7944 /// and may change or be removed in future SDK or CLI releases. Pin both the
7945 /// SDK and CLI versions if your code depends on it.
7946 ///
7947 /// </div>
7948 pub async fn handle_pending_sampling(
7949 &self,
7950 params: UIHandlePendingSamplingRequest,
7951 ) -> Result<UIHandlePendingResult, Error> {
7952 let mut wire_params = serde_json::to_value(params)?;
7953 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7954 let _value = self
7955 .session
7956 .client()
7957 .call(
7958 rpc_methods::SESSION_UI_HANDLEPENDINGSAMPLING,
7959 Some(wire_params),
7960 )
7961 .await?;
7962 Ok(serde_json::from_value(_value)?)
7963 }
7964
7965 /// Resolves a pending `auto_mode_switch.requested` event with the user's accept/decline decision.
7966 ///
7967 /// Wire method: `session.ui.handlePendingAutoModeSwitch`.
7968 ///
7969 /// # Parameters
7970 ///
7971 /// * `params` - Request ID of a pending `auto_mode_switch.requested` event and the user's response.
7972 ///
7973 /// # Returns
7974 ///
7975 /// Indicates whether the pending UI request was resolved by this call.
7976 ///
7977 /// <div class="warning">
7978 ///
7979 /// **Experimental.** This API is part of an experimental wire-protocol surface
7980 /// and may change or be removed in future SDK or CLI releases. Pin both the
7981 /// SDK and CLI versions if your code depends on it.
7982 ///
7983 /// </div>
7984 pub async fn handle_pending_auto_mode_switch(
7985 &self,
7986 params: UIHandlePendingAutoModeSwitchRequest,
7987 ) -> Result<UIHandlePendingResult, Error> {
7988 let mut wire_params = serde_json::to_value(params)?;
7989 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7990 let _value = self
7991 .session
7992 .client()
7993 .call(
7994 rpc_methods::SESSION_UI_HANDLEPENDINGAUTOMODESWITCH,
7995 Some(wire_params),
7996 )
7997 .await?;
7998 Ok(serde_json::from_value(_value)?)
7999 }
8000
8001 /// Resolves a pending `exit_plan_mode.requested` event with the user's response.
8002 ///
8003 /// Wire method: `session.ui.handlePendingExitPlanMode`.
8004 ///
8005 /// # Parameters
8006 ///
8007 /// * `params` - Request ID of a pending `exit_plan_mode.requested` event and the user's response.
8008 ///
8009 /// # Returns
8010 ///
8011 /// Indicates whether the pending UI request was resolved by this call.
8012 ///
8013 /// <div class="warning">
8014 ///
8015 /// **Experimental.** This API is part of an experimental wire-protocol surface
8016 /// and may change or be removed in future SDK or CLI releases. Pin both the
8017 /// SDK and CLI versions if your code depends on it.
8018 ///
8019 /// </div>
8020 pub async fn handle_pending_exit_plan_mode(
8021 &self,
8022 params: UIHandlePendingExitPlanModeRequest,
8023 ) -> Result<UIHandlePendingResult, Error> {
8024 let mut wire_params = serde_json::to_value(params)?;
8025 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8026 let _value = self
8027 .session
8028 .client()
8029 .call(
8030 rpc_methods::SESSION_UI_HANDLEPENDINGEXITPLANMODE,
8031 Some(wire_params),
8032 )
8033 .await?;
8034 Ok(serde_json::from_value(_value)?)
8035 }
8036
8037 /// Registers an in-process handler for auto-mode-switch requests so the server bridge skips dispatch.
8038 ///
8039 /// Wire method: `session.ui.registerDirectAutoModeSwitchHandler`.
8040 ///
8041 /// # Returns
8042 ///
8043 /// 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).
8044 ///
8045 /// <div class="warning">
8046 ///
8047 /// **Experimental.** This API is part of an experimental wire-protocol surface
8048 /// and may change or be removed in future SDK or CLI releases. Pin both the
8049 /// SDK and CLI versions if your code depends on it.
8050 ///
8051 /// </div>
8052 pub async fn register_direct_auto_mode_switch_handler(
8053 &self,
8054 ) -> Result<UIRegisterDirectAutoModeSwitchHandlerResult, Error> {
8055 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8056 let _value = self
8057 .session
8058 .client()
8059 .call(
8060 rpc_methods::SESSION_UI_REGISTERDIRECTAUTOMODESWITCHHANDLER,
8061 Some(wire_params),
8062 )
8063 .await?;
8064 Ok(serde_json::from_value(_value)?)
8065 }
8066
8067 /// Unregisters a previously-registered in-process auto-mode-switch handler by its opaque handle.
8068 ///
8069 /// Wire method: `session.ui.unregisterDirectAutoModeSwitchHandler`.
8070 ///
8071 /// # Parameters
8072 ///
8073 /// * `params` - Opaque handle previously returned by `registerDirectAutoModeSwitchHandler` to release.
8074 ///
8075 /// # Returns
8076 ///
8077 /// Indicates whether the handle was active and the registration count was decremented.
8078 ///
8079 /// <div class="warning">
8080 ///
8081 /// **Experimental.** This API is part of an experimental wire-protocol surface
8082 /// and may change or be removed in future SDK or CLI releases. Pin both the
8083 /// SDK and CLI versions if your code depends on it.
8084 ///
8085 /// </div>
8086 pub async fn unregister_direct_auto_mode_switch_handler(
8087 &self,
8088 params: UIUnregisterDirectAutoModeSwitchHandlerRequest,
8089 ) -> Result<UIUnregisterDirectAutoModeSwitchHandlerResult, Error> {
8090 let mut wire_params = serde_json::to_value(params)?;
8091 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8092 let _value = self
8093 .session
8094 .client()
8095 .call(
8096 rpc_methods::SESSION_UI_UNREGISTERDIRECTAUTOMODESWITCHHANDLER,
8097 Some(wire_params),
8098 )
8099 .await?;
8100 Ok(serde_json::from_value(_value)?)
8101 }
8102}
8103
8104/// `session.usage.*` RPCs.
8105#[derive(Clone, Copy)]
8106pub struct SessionRpcUsage<'a> {
8107 pub(crate) session: &'a Session,
8108}
8109
8110impl<'a> SessionRpcUsage<'a> {
8111 /// Gets accumulated usage metrics for the session.
8112 ///
8113 /// Wire method: `session.usage.getMetrics`.
8114 ///
8115 /// # Returns
8116 ///
8117 /// Accumulated session usage metrics, including premium request cost, token counts, model breakdown, and code-change totals.
8118 ///
8119 /// <div class="warning">
8120 ///
8121 /// **Experimental.** This API is part of an experimental wire-protocol surface
8122 /// and may change or be removed in future SDK or CLI releases. Pin both the
8123 /// SDK and CLI versions if your code depends on it.
8124 ///
8125 /// </div>
8126 pub async fn get_metrics(&self) -> Result<UsageGetMetricsResult, Error> {
8127 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8128 let _value = self
8129 .session
8130 .client()
8131 .call(rpc_methods::SESSION_USAGE_GETMETRICS, Some(wire_params))
8132 .await?;
8133 Ok(serde_json::from_value(_value)?)
8134 }
8135}
8136
8137/// `session.visibility.*` RPCs.
8138#[derive(Clone, Copy)]
8139pub struct SessionRpcVisibility<'a> {
8140 pub(crate) session: &'a Session,
8141}
8142
8143impl<'a> SessionRpcVisibility<'a> {
8144 /// 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").
8145 ///
8146 /// Wire method: `session.visibility.get`.
8147 ///
8148 /// # Returns
8149 ///
8150 /// Current sharing status and shareable GitHub URL for a session.
8151 ///
8152 /// <div class="warning">
8153 ///
8154 /// **Experimental.** This API is part of an experimental wire-protocol surface
8155 /// and may change or be removed in future SDK or CLI releases. Pin both the
8156 /// SDK and CLI versions if your code depends on it.
8157 ///
8158 /// </div>
8159 pub async fn get(&self) -> Result<VisibilityGetResult, Error> {
8160 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8161 let _value = self
8162 .session
8163 .client()
8164 .call(rpc_methods::SESSION_VISIBILITY_GET, Some(wire_params))
8165 .await?;
8166 Ok(serde_json::from_value(_value)?)
8167 }
8168
8169 /// 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.
8170 ///
8171 /// Wire method: `session.visibility.set`.
8172 ///
8173 /// # Parameters
8174 ///
8175 /// * `params` - Desired sharing status for the session.
8176 ///
8177 /// # Returns
8178 ///
8179 /// Effective sharing status and shareable GitHub URL after updating session visibility.
8180 ///
8181 /// <div class="warning">
8182 ///
8183 /// **Experimental.** This API is part of an experimental wire-protocol surface
8184 /// and may change or be removed in future SDK or CLI releases. Pin both the
8185 /// SDK and CLI versions if your code depends on it.
8186 ///
8187 /// </div>
8188 pub async fn set(&self, params: VisibilitySetRequest) -> Result<VisibilitySetResult, Error> {
8189 let mut wire_params = serde_json::to_value(params)?;
8190 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8191 let _value = self
8192 .session
8193 .client()
8194 .call(rpc_methods::SESSION_VISIBILITY_SET, Some(wire_params))
8195 .await?;
8196 Ok(serde_json::from_value(_value)?)
8197 }
8198}
8199
8200/// `session.workspaces.*` RPCs.
8201#[derive(Clone, Copy)]
8202pub struct SessionRpcWorkspaces<'a> {
8203 pub(crate) session: &'a Session,
8204}
8205
8206impl<'a> SessionRpcWorkspaces<'a> {
8207 /// Gets current workspace metadata for the session.
8208 ///
8209 /// Wire method: `session.workspaces.getWorkspace`.
8210 ///
8211 /// # Returns
8212 ///
8213 /// Current workspace metadata for the session, including its absolute filesystem path when available.
8214 ///
8215 /// <div class="warning">
8216 ///
8217 /// **Experimental.** This API is part of an experimental wire-protocol surface
8218 /// and may change or be removed in future SDK or CLI releases. Pin both the
8219 /// SDK and CLI versions if your code depends on it.
8220 ///
8221 /// </div>
8222 pub async fn get_workspace(&self) -> Result<WorkspacesGetWorkspaceResult, Error> {
8223 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8224 let _value = self
8225 .session
8226 .client()
8227 .call(
8228 rpc_methods::SESSION_WORKSPACES_GETWORKSPACE,
8229 Some(wire_params),
8230 )
8231 .await?;
8232 Ok(serde_json::from_value(_value)?)
8233 }
8234
8235 /// Lists files stored in the session workspace files directory.
8236 ///
8237 /// Wire method: `session.workspaces.listFiles`.
8238 ///
8239 /// # Returns
8240 ///
8241 /// Relative paths of files stored in the session workspace files directory.
8242 ///
8243 /// <div class="warning">
8244 ///
8245 /// **Experimental.** This API is part of an experimental wire-protocol surface
8246 /// and may change or be removed in future SDK or CLI releases. Pin both the
8247 /// SDK and CLI versions if your code depends on it.
8248 ///
8249 /// </div>
8250 pub async fn list_files(&self) -> Result<WorkspacesListFilesResult, Error> {
8251 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8252 let _value = self
8253 .session
8254 .client()
8255 .call(rpc_methods::SESSION_WORKSPACES_LISTFILES, Some(wire_params))
8256 .await?;
8257 Ok(serde_json::from_value(_value)?)
8258 }
8259
8260 /// Reads a file from the session workspace files directory.
8261 ///
8262 /// Wire method: `session.workspaces.readFile`.
8263 ///
8264 /// # Parameters
8265 ///
8266 /// * `params` - Relative path of the workspace file to read.
8267 ///
8268 /// # Returns
8269 ///
8270 /// Contents of the requested workspace file as a UTF-8 string.
8271 ///
8272 /// <div class="warning">
8273 ///
8274 /// **Experimental.** This API is part of an experimental wire-protocol surface
8275 /// and may change or be removed in future SDK or CLI releases. Pin both the
8276 /// SDK and CLI versions if your code depends on it.
8277 ///
8278 /// </div>
8279 pub async fn read_file(
8280 &self,
8281 params: WorkspacesReadFileRequest,
8282 ) -> Result<WorkspacesReadFileResult, Error> {
8283 let mut wire_params = serde_json::to_value(params)?;
8284 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8285 let _value = self
8286 .session
8287 .client()
8288 .call(rpc_methods::SESSION_WORKSPACES_READFILE, Some(wire_params))
8289 .await?;
8290 Ok(serde_json::from_value(_value)?)
8291 }
8292
8293 /// Creates or overwrites a file in the session workspace files directory.
8294 ///
8295 /// Wire method: `session.workspaces.createFile`.
8296 ///
8297 /// # Parameters
8298 ///
8299 /// * `params` - Relative path and UTF-8 content for the workspace file to create or overwrite.
8300 ///
8301 /// <div class="warning">
8302 ///
8303 /// **Experimental.** This API is part of an experimental wire-protocol surface
8304 /// and may change or be removed in future SDK or CLI releases. Pin both the
8305 /// SDK and CLI versions if your code depends on it.
8306 ///
8307 /// </div>
8308 pub async fn create_file(&self, params: WorkspacesCreateFileRequest) -> Result<(), Error> {
8309 let mut wire_params = serde_json::to_value(params)?;
8310 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8311 let _value = self
8312 .session
8313 .client()
8314 .call(
8315 rpc_methods::SESSION_WORKSPACES_CREATEFILE,
8316 Some(wire_params),
8317 )
8318 .await?;
8319 Ok(())
8320 }
8321
8322 /// Lists workspace checkpoints in chronological order.
8323 ///
8324 /// Wire method: `session.workspaces.listCheckpoints`.
8325 ///
8326 /// # Returns
8327 ///
8328 /// Workspace checkpoints in chronological order; empty when the workspace is not enabled.
8329 ///
8330 /// <div class="warning">
8331 ///
8332 /// **Experimental.** This API is part of an experimental wire-protocol surface
8333 /// and may change or be removed in future SDK or CLI releases. Pin both the
8334 /// SDK and CLI versions if your code depends on it.
8335 ///
8336 /// </div>
8337 pub async fn list_checkpoints(&self) -> Result<WorkspacesListCheckpointsResult, Error> {
8338 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8339 let _value = self
8340 .session
8341 .client()
8342 .call(
8343 rpc_methods::SESSION_WORKSPACES_LISTCHECKPOINTS,
8344 Some(wire_params),
8345 )
8346 .await?;
8347 Ok(serde_json::from_value(_value)?)
8348 }
8349
8350 /// Reads the content of a workspace checkpoint by number.
8351 ///
8352 /// Wire method: `session.workspaces.readCheckpoint`.
8353 ///
8354 /// # Parameters
8355 ///
8356 /// * `params` - Checkpoint number to read.
8357 ///
8358 /// # Returns
8359 ///
8360 /// Checkpoint content as a UTF-8 string, or null when the checkpoint or workspace is missing.
8361 ///
8362 /// <div class="warning">
8363 ///
8364 /// **Experimental.** This API is part of an experimental wire-protocol surface
8365 /// and may change or be removed in future SDK or CLI releases. Pin both the
8366 /// SDK and CLI versions if your code depends on it.
8367 ///
8368 /// </div>
8369 pub async fn read_checkpoint(
8370 &self,
8371 params: WorkspacesReadCheckpointRequest,
8372 ) -> Result<WorkspacesReadCheckpointResult, Error> {
8373 let mut wire_params = serde_json::to_value(params)?;
8374 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8375 let _value = self
8376 .session
8377 .client()
8378 .call(
8379 rpc_methods::SESSION_WORKSPACES_READCHECKPOINT,
8380 Some(wire_params),
8381 )
8382 .await?;
8383 Ok(serde_json::from_value(_value)?)
8384 }
8385
8386 /// Saves pasted content as a UTF-8 file in the session workspace.
8387 ///
8388 /// Wire method: `session.workspaces.saveLargePaste`.
8389 ///
8390 /// # Parameters
8391 ///
8392 /// * `params` - Pasted content to save as a UTF-8 file in the session workspace.
8393 ///
8394 /// # Returns
8395 ///
8396 /// Descriptor for the saved paste file, or null when the workspace is unavailable.
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 save_large_paste(
8406 &self,
8407 params: WorkspacesSaveLargePasteRequest,
8408 ) -> Result<WorkspacesSaveLargePasteResult, Error> {
8409 let mut wire_params = serde_json::to_value(params)?;
8410 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8411 let _value = self
8412 .session
8413 .client()
8414 .call(
8415 rpc_methods::SESSION_WORKSPACES_SAVELARGEPASTE,
8416 Some(wire_params),
8417 )
8418 .await?;
8419 Ok(serde_json::from_value(_value)?)
8420 }
8421
8422 /// Computes a diff for the session workspace.
8423 ///
8424 /// Wire method: `session.workspaces.diff`.
8425 ///
8426 /// # Parameters
8427 ///
8428 /// * `params` - Parameters for computing a workspace diff.
8429 ///
8430 /// # Returns
8431 ///
8432 /// Workspace diff result for the requested mode.
8433 ///
8434 /// <div class="warning">
8435 ///
8436 /// **Experimental.** This API is part of an experimental wire-protocol surface
8437 /// and may change or be removed in future SDK or CLI releases. Pin both the
8438 /// SDK and CLI versions if your code depends on it.
8439 ///
8440 /// </div>
8441 pub async fn diff(&self, params: WorkspacesDiffRequest) -> Result<WorkspaceDiffResult, Error> {
8442 let mut wire_params = serde_json::to_value(params)?;
8443 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8444 let _value = self
8445 .session
8446 .client()
8447 .call(rpc_methods::SESSION_WORKSPACES_DIFF, Some(wire_params))
8448 .await?;
8449 Ok(serde_json::from_value(_value)?)
8450 }
8451}