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` - Parameters for the `server.connect` handshake: an optional connection token and optional connection-level opt-ins (e.g. GitHub telemetry forwarding).
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 /// 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.
2238 ///
2239 /// Wire method: `sessions.registerExtensionToolsOnSession`.
2240 ///
2241 /// # Parameters
2242 ///
2243 /// * `params` - Params to attach an extension loader's tools to a session.
2244 ///
2245 /// # Returns
2246 ///
2247 /// Handle for releasing the extension tool registration.
2248 ///
2249 /// <div class="warning">
2250 ///
2251 /// **Experimental.** This API is part of an experimental wire-protocol surface
2252 /// and may change or be removed in future SDK or CLI releases. Pin both the
2253 /// SDK and CLI versions if your code depends on it.
2254 ///
2255 /// </div>
2256 pub(crate) async fn register_extension_tools_on_session(
2257 &self,
2258 params: RegisterExtensionToolsParams,
2259 ) -> Result<RegisterExtensionToolsResult, Error> {
2260 let wire_params = serde_json::to_value(params)?;
2261 let _value = self
2262 .client
2263 .call(
2264 rpc_methods::SESSIONS_REGISTEREXTENSIONTOOLSONSESSION,
2265 Some(wire_params),
2266 )
2267 .await?;
2268 Ok(serde_json::from_value(_value)?)
2269 }
2270
2271 /// 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.
2272 ///
2273 /// Wire method: `sessions.configureSessionExtensions`.
2274 ///
2275 /// # Parameters
2276 ///
2277 /// * `params` - Params to attach or detach an in-process ExtensionController delegate.
2278 ///
2279 /// <div class="warning">
2280 ///
2281 /// **Experimental.** This API is part of an experimental wire-protocol surface
2282 /// and may change or be removed in future SDK or CLI releases. Pin both the
2283 /// SDK and CLI versions if your code depends on it.
2284 ///
2285 /// </div>
2286 pub(crate) async fn configure_session_extensions(
2287 &self,
2288 params: ConfigureSessionExtensionsParams,
2289 ) -> Result<(), Error> {
2290 let wire_params = serde_json::to_value(params)?;
2291 let _value = self
2292 .client
2293 .call(
2294 rpc_methods::SESSIONS_CONFIGURESESSIONEXTENSIONS,
2295 Some(wire_params),
2296 )
2297 .await?;
2298 Ok(())
2299 }
2300}
2301
2302/// `skills.*` RPCs.
2303#[derive(Clone, Copy)]
2304pub struct ClientRpcSkills<'a> {
2305 pub(crate) client: &'a Client,
2306}
2307
2308impl<'a> ClientRpcSkills<'a> {
2309 /// `skills.config.*` sub-namespace.
2310 pub fn config(&self) -> ClientRpcSkillsConfig<'a> {
2311 ClientRpcSkillsConfig {
2312 client: self.client,
2313 }
2314 }
2315
2316 /// Discovers skills across global and project sources.
2317 ///
2318 /// Wire method: `skills.discover`.
2319 ///
2320 /// # Parameters
2321 ///
2322 /// * `params` - Optional project paths and additional skill directories to include in discovery.
2323 ///
2324 /// # Returns
2325 ///
2326 /// Skills discovered across global and project sources.
2327 ///
2328 /// <div class="warning">
2329 ///
2330 /// **Experimental.** This API is part of an experimental wire-protocol surface
2331 /// and may change or be removed in future SDK or CLI releases. Pin both the
2332 /// SDK and CLI versions if your code depends on it.
2333 ///
2334 /// </div>
2335 pub async fn discover(&self, params: SkillsDiscoverRequest) -> Result<ServerSkillList, Error> {
2336 let wire_params = serde_json::to_value(params)?;
2337 let _value = self
2338 .client
2339 .call(rpc_methods::SKILLS_DISCOVER, Some(wire_params))
2340 .await?;
2341 Ok(serde_json::from_value(_value)?)
2342 }
2343
2344 /// 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.
2345 ///
2346 /// Wire method: `skills.getDiscoveryPaths`.
2347 ///
2348 /// # Parameters
2349 ///
2350 /// * `params` - Optional project paths to enumerate.
2351 ///
2352 /// # Returns
2353 ///
2354 /// Canonical locations where skills can be created so the runtime will recognize them.
2355 ///
2356 /// <div class="warning">
2357 ///
2358 /// **Experimental.** This API is part of an experimental wire-protocol surface
2359 /// and may change or be removed in future SDK or CLI releases. Pin both the
2360 /// SDK and CLI versions if your code depends on it.
2361 ///
2362 /// </div>
2363 pub async fn get_discovery_paths(
2364 &self,
2365 params: SkillsGetDiscoveryPathsRequest,
2366 ) -> Result<SkillDiscoveryPathList, Error> {
2367 let wire_params = serde_json::to_value(params)?;
2368 let _value = self
2369 .client
2370 .call(rpc_methods::SKILLS_GETDISCOVERYPATHS, Some(wire_params))
2371 .await?;
2372 Ok(serde_json::from_value(_value)?)
2373 }
2374}
2375
2376/// `skills.config.*` RPCs.
2377#[derive(Clone, Copy)]
2378pub struct ClientRpcSkillsConfig<'a> {
2379 pub(crate) client: &'a Client,
2380}
2381
2382impl<'a> ClientRpcSkillsConfig<'a> {
2383 /// Replaces the global list of disabled skills.
2384 ///
2385 /// Wire method: `skills.config.setDisabledSkills`.
2386 ///
2387 /// # Parameters
2388 ///
2389 /// * `params` - Skill names to mark as disabled in global configuration, replacing any previous list.
2390 ///
2391 /// <div class="warning">
2392 ///
2393 /// **Experimental.** This API is part of an experimental wire-protocol surface
2394 /// and may change or be removed in future SDK or CLI releases. Pin both the
2395 /// SDK and CLI versions if your code depends on it.
2396 ///
2397 /// </div>
2398 pub async fn set_disabled_skills(
2399 &self,
2400 params: SkillsConfigSetDisabledSkillsRequest,
2401 ) -> Result<(), Error> {
2402 let wire_params = serde_json::to_value(params)?;
2403 let _value = self
2404 .client
2405 .call(
2406 rpc_methods::SKILLS_CONFIG_SETDISABLEDSKILLS,
2407 Some(wire_params),
2408 )
2409 .await?;
2410 Ok(())
2411 }
2412}
2413
2414/// `tools.*` RPCs.
2415#[derive(Clone, Copy)]
2416pub struct ClientRpcTools<'a> {
2417 pub(crate) client: &'a Client,
2418}
2419
2420impl<'a> ClientRpcTools<'a> {
2421 /// Lists built-in tools available for a model.
2422 ///
2423 /// Wire method: `tools.list`.
2424 ///
2425 /// # Parameters
2426 ///
2427 /// * `params` - Optional model identifier whose tool overrides should be applied to the listing.
2428 ///
2429 /// # Returns
2430 ///
2431 /// Built-in tools available for the requested model, with their parameters and instructions.
2432 ///
2433 /// <div class="warning">
2434 ///
2435 /// **Experimental.** This API is part of an experimental wire-protocol surface
2436 /// and may change or be removed in future SDK or CLI releases. Pin both the
2437 /// SDK and CLI versions if your code depends on it.
2438 ///
2439 /// </div>
2440 pub async fn list(&self, params: ToolsListRequest) -> Result<ToolList, Error> {
2441 let wire_params = serde_json::to_value(params)?;
2442 let _value = self
2443 .client
2444 .call(rpc_methods::TOOLS_LIST, Some(wire_params))
2445 .await?;
2446 Ok(serde_json::from_value(_value)?)
2447 }
2448}
2449
2450/// `user.*` RPCs.
2451#[derive(Clone, Copy)]
2452pub struct ClientRpcUser<'a> {
2453 pub(crate) client: &'a Client,
2454}
2455
2456impl<'a> ClientRpcUser<'a> {
2457 /// `user.settings.*` sub-namespace.
2458 pub fn settings(&self) -> ClientRpcUserSettings<'a> {
2459 ClientRpcUserSettings {
2460 client: self.client,
2461 }
2462 }
2463}
2464
2465/// `user.settings.*` RPCs.
2466#[derive(Clone, Copy)]
2467pub struct ClientRpcUserSettings<'a> {
2468 pub(crate) client: &'a Client,
2469}
2470
2471impl<'a> ClientRpcUserSettings<'a> {
2472 /// Drops this runtime process's in-memory user settings cache so the next settings read observes disk.
2473 ///
2474 /// Wire method: `user.settings.reload`.
2475 ///
2476 /// <div class="warning">
2477 ///
2478 /// **Experimental.** This API is part of an experimental wire-protocol surface
2479 /// and may change or be removed in future SDK or CLI releases. Pin both the
2480 /// SDK and CLI versions if your code depends on it.
2481 ///
2482 /// </div>
2483 pub async fn reload(&self) -> Result<(), Error> {
2484 let wire_params = serde_json::json!({});
2485 let _value = self
2486 .client
2487 .call(rpc_methods::USER_SETTINGS_RELOAD, Some(wire_params))
2488 .await?;
2489 Ok(())
2490 }
2491
2492 /// 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.
2493 ///
2494 /// Wire method: `user.settings.get`.
2495 ///
2496 /// # Returns
2497 ///
2498 /// 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.
2499 ///
2500 /// <div class="warning">
2501 ///
2502 /// **Experimental.** This API is part of an experimental wire-protocol surface
2503 /// and may change or be removed in future SDK or CLI releases. Pin both the
2504 /// SDK and CLI versions if your code depends on it.
2505 ///
2506 /// </div>
2507 pub async fn get(&self) -> Result<UserSettingsGetResult, Error> {
2508 let wire_params = serde_json::json!({});
2509 let _value = self
2510 .client
2511 .call(rpc_methods::USER_SETTINGS_GET, Some(wire_params))
2512 .await?;
2513 Ok(serde_json::from_value(_value)?)
2514 }
2515
2516 /// 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.
2517 ///
2518 /// Wire method: `user.settings.set`.
2519 ///
2520 /// # Parameters
2521 ///
2522 /// * `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.
2523 ///
2524 /// # Returns
2525 ///
2526 /// Outcome of writing user settings.
2527 ///
2528 /// <div class="warning">
2529 ///
2530 /// **Experimental.** This API is part of an experimental wire-protocol surface
2531 /// and may change or be removed in future SDK or CLI releases. Pin both the
2532 /// SDK and CLI versions if your code depends on it.
2533 ///
2534 /// </div>
2535 pub async fn set(
2536 &self,
2537 params: UserSettingsSetRequest,
2538 ) -> Result<UserSettingsSetResult, Error> {
2539 let wire_params = serde_json::to_value(params)?;
2540 let _value = self
2541 .client
2542 .call(rpc_methods::USER_SETTINGS_SET, Some(wire_params))
2543 .await?;
2544 Ok(serde_json::from_value(_value)?)
2545 }
2546}
2547
2548/// Typed view over a [`Session`]'s RPC namespace.
2549#[derive(Clone, Copy)]
2550pub struct SessionRpc<'a> {
2551 pub(crate) session: &'a Session,
2552}
2553
2554impl<'a> SessionRpc<'a> {
2555 /// `session.agent.*` sub-namespace.
2556 pub fn agent(&self) -> SessionRpcAgent<'a> {
2557 SessionRpcAgent {
2558 session: self.session,
2559 }
2560 }
2561
2562 /// `session.canvas.*` sub-namespace.
2563 pub fn canvas(&self) -> SessionRpcCanvas<'a> {
2564 SessionRpcCanvas {
2565 session: self.session,
2566 }
2567 }
2568
2569 /// `session.commands.*` sub-namespace.
2570 pub fn commands(&self) -> SessionRpcCommands<'a> {
2571 SessionRpcCommands {
2572 session: self.session,
2573 }
2574 }
2575
2576 /// `session.completions.*` sub-namespace.
2577 pub fn completions(&self) -> SessionRpcCompletions<'a> {
2578 SessionRpcCompletions {
2579 session: self.session,
2580 }
2581 }
2582
2583 /// `session.debug.*` sub-namespace.
2584 pub fn debug(&self) -> SessionRpcDebug<'a> {
2585 SessionRpcDebug {
2586 session: self.session,
2587 }
2588 }
2589
2590 /// `session.eventLog.*` sub-namespace.
2591 pub fn event_log(&self) -> SessionRpcEventLog<'a> {
2592 SessionRpcEventLog {
2593 session: self.session,
2594 }
2595 }
2596
2597 /// `session.extensions.*` sub-namespace.
2598 pub fn extensions(&self) -> SessionRpcExtensions<'a> {
2599 SessionRpcExtensions {
2600 session: self.session,
2601 }
2602 }
2603
2604 /// `session.fleet.*` sub-namespace.
2605 pub fn fleet(&self) -> SessionRpcFleet<'a> {
2606 SessionRpcFleet {
2607 session: self.session,
2608 }
2609 }
2610
2611 /// `session.gitHubAuth.*` sub-namespace.
2612 pub fn git_hub_auth(&self) -> SessionRpcGitHubAuth<'a> {
2613 SessionRpcGitHubAuth {
2614 session: self.session,
2615 }
2616 }
2617
2618 /// `session.history.*` sub-namespace.
2619 pub fn history(&self) -> SessionRpcHistory<'a> {
2620 SessionRpcHistory {
2621 session: self.session,
2622 }
2623 }
2624
2625 /// `session.instructions.*` sub-namespace.
2626 pub fn instructions(&self) -> SessionRpcInstructions<'a> {
2627 SessionRpcInstructions {
2628 session: self.session,
2629 }
2630 }
2631
2632 /// `session.lsp.*` sub-namespace.
2633 pub fn lsp(&self) -> SessionRpcLsp<'a> {
2634 SessionRpcLsp {
2635 session: self.session,
2636 }
2637 }
2638
2639 /// `session.mcp.*` sub-namespace.
2640 pub fn mcp(&self) -> SessionRpcMcp<'a> {
2641 SessionRpcMcp {
2642 session: self.session,
2643 }
2644 }
2645
2646 /// `session.metadata.*` sub-namespace.
2647 pub fn metadata(&self) -> SessionRpcMetadata<'a> {
2648 SessionRpcMetadata {
2649 session: self.session,
2650 }
2651 }
2652
2653 /// `session.mode.*` sub-namespace.
2654 pub fn mode(&self) -> SessionRpcMode<'a> {
2655 SessionRpcMode {
2656 session: self.session,
2657 }
2658 }
2659
2660 /// `session.model.*` sub-namespace.
2661 pub fn model(&self) -> SessionRpcModel<'a> {
2662 SessionRpcModel {
2663 session: self.session,
2664 }
2665 }
2666
2667 /// `session.name.*` sub-namespace.
2668 pub fn name(&self) -> SessionRpcName<'a> {
2669 SessionRpcName {
2670 session: self.session,
2671 }
2672 }
2673
2674 /// `session.options.*` sub-namespace.
2675 pub fn options(&self) -> SessionRpcOptions<'a> {
2676 SessionRpcOptions {
2677 session: self.session,
2678 }
2679 }
2680
2681 /// `session.permissions.*` sub-namespace.
2682 pub fn permissions(&self) -> SessionRpcPermissions<'a> {
2683 SessionRpcPermissions {
2684 session: self.session,
2685 }
2686 }
2687
2688 /// `session.plan.*` sub-namespace.
2689 pub fn plan(&self) -> SessionRpcPlan<'a> {
2690 SessionRpcPlan {
2691 session: self.session,
2692 }
2693 }
2694
2695 /// `session.plugins.*` sub-namespace.
2696 pub fn plugins(&self) -> SessionRpcPlugins<'a> {
2697 SessionRpcPlugins {
2698 session: self.session,
2699 }
2700 }
2701
2702 /// `session.provider.*` sub-namespace.
2703 pub fn provider(&self) -> SessionRpcProvider<'a> {
2704 SessionRpcProvider {
2705 session: self.session,
2706 }
2707 }
2708
2709 /// `session.queue.*` sub-namespace.
2710 pub fn queue(&self) -> SessionRpcQueue<'a> {
2711 SessionRpcQueue {
2712 session: self.session,
2713 }
2714 }
2715
2716 /// `session.remote.*` sub-namespace.
2717 pub fn remote(&self) -> SessionRpcRemote<'a> {
2718 SessionRpcRemote {
2719 session: self.session,
2720 }
2721 }
2722
2723 /// `session.schedule.*` sub-namespace.
2724 pub fn schedule(&self) -> SessionRpcSchedule<'a> {
2725 SessionRpcSchedule {
2726 session: self.session,
2727 }
2728 }
2729
2730 /// `session.settings.*` sub-namespace.
2731 pub fn settings(&self) -> SessionRpcSettings<'a> {
2732 SessionRpcSettings {
2733 session: self.session,
2734 }
2735 }
2736
2737 /// `session.shell.*` sub-namespace.
2738 pub fn shell(&self) -> SessionRpcShell<'a> {
2739 SessionRpcShell {
2740 session: self.session,
2741 }
2742 }
2743
2744 /// `session.skills.*` sub-namespace.
2745 pub fn skills(&self) -> SessionRpcSkills<'a> {
2746 SessionRpcSkills {
2747 session: self.session,
2748 }
2749 }
2750
2751 /// `session.tasks.*` sub-namespace.
2752 pub fn tasks(&self) -> SessionRpcTasks<'a> {
2753 SessionRpcTasks {
2754 session: self.session,
2755 }
2756 }
2757
2758 /// `session.telemetry.*` sub-namespace.
2759 pub fn telemetry(&self) -> SessionRpcTelemetry<'a> {
2760 SessionRpcTelemetry {
2761 session: self.session,
2762 }
2763 }
2764
2765 /// `session.tools.*` sub-namespace.
2766 pub fn tools(&self) -> SessionRpcTools<'a> {
2767 SessionRpcTools {
2768 session: self.session,
2769 }
2770 }
2771
2772 /// `session.ui.*` sub-namespace.
2773 pub fn ui(&self) -> SessionRpcUi<'a> {
2774 SessionRpcUi {
2775 session: self.session,
2776 }
2777 }
2778
2779 /// `session.usage.*` sub-namespace.
2780 pub fn usage(&self) -> SessionRpcUsage<'a> {
2781 SessionRpcUsage {
2782 session: self.session,
2783 }
2784 }
2785
2786 /// `session.visibility.*` sub-namespace.
2787 pub fn visibility(&self) -> SessionRpcVisibility<'a> {
2788 SessionRpcVisibility {
2789 session: self.session,
2790 }
2791 }
2792
2793 /// `session.workspaces.*` sub-namespace.
2794 pub fn workspaces(&self) -> SessionRpcWorkspaces<'a> {
2795 SessionRpcWorkspaces {
2796 session: self.session,
2797 }
2798 }
2799
2800 /// Suspends the session while preserving persisted state for later resume.
2801 ///
2802 /// Wire method: `session.suspend`.
2803 ///
2804 /// <div class="warning">
2805 ///
2806 /// **Experimental.** This API is part of an experimental wire-protocol surface
2807 /// and may change or be removed in future SDK or CLI releases. Pin both the
2808 /// SDK and CLI versions if your code depends on it.
2809 ///
2810 /// </div>
2811 pub async fn suspend(&self) -> Result<(), Error> {
2812 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
2813 let _value = self
2814 .session
2815 .client()
2816 .call(rpc_methods::SESSION_SUSPEND, Some(wire_params))
2817 .await?;
2818 Ok(())
2819 }
2820
2821 /// Sends a user message to the session and returns its message ID.
2822 ///
2823 /// Wire method: `session.send`.
2824 ///
2825 /// # Parameters
2826 ///
2827 /// * `params` - Parameters for sending a user message to the session
2828 ///
2829 /// # Returns
2830 ///
2831 /// Result of sending a user message
2832 ///
2833 /// <div class="warning">
2834 ///
2835 /// **Experimental.** This API is part of an experimental wire-protocol surface
2836 /// and may change or be removed in future SDK or CLI releases. Pin both the
2837 /// SDK and CLI versions if your code depends on it.
2838 ///
2839 /// </div>
2840 pub async fn send(&self, params: SendRequest) -> Result<SendResult, Error> {
2841 let mut wire_params = serde_json::to_value(params)?;
2842 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
2843 let _value = self
2844 .session
2845 .client()
2846 .call(rpc_methods::SESSION_SEND, Some(wire_params))
2847 .await?;
2848 Ok(serde_json::from_value(_value)?)
2849 }
2850
2851 /// Aborts the current agent turn.
2852 ///
2853 /// Wire method: `session.abort`.
2854 ///
2855 /// # Parameters
2856 ///
2857 /// * `params` - Parameters for aborting the current turn
2858 ///
2859 /// # Returns
2860 ///
2861 /// Result of aborting the current turn
2862 ///
2863 /// <div class="warning">
2864 ///
2865 /// **Experimental.** This API is part of an experimental wire-protocol surface
2866 /// and may change or be removed in future SDK or CLI releases. Pin both the
2867 /// SDK and CLI versions if your code depends on it.
2868 ///
2869 /// </div>
2870 pub async fn abort(&self, params: AbortRequest) -> Result<AbortResult, Error> {
2871 let mut wire_params = serde_json::to_value(params)?;
2872 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
2873 let _value = self
2874 .session
2875 .client()
2876 .call(rpc_methods::SESSION_ABORT, Some(wire_params))
2877 .await?;
2878 Ok(serde_json::from_value(_value)?)
2879 }
2880
2881 /// 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.
2882 ///
2883 /// Wire method: `session.shutdown`.
2884 ///
2885 /// # Parameters
2886 ///
2887 /// * `params` - Parameters for shutting down the session
2888 ///
2889 /// <div class="warning">
2890 ///
2891 /// **Experimental.** This API is part of an experimental wire-protocol surface
2892 /// and may change or be removed in future SDK or CLI releases. Pin both the
2893 /// SDK and CLI versions if your code depends on it.
2894 ///
2895 /// </div>
2896 pub async fn shutdown(&self, params: ShutdownRequest) -> Result<(), Error> {
2897 let mut wire_params = serde_json::to_value(params)?;
2898 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
2899 let _value = self
2900 .session
2901 .client()
2902 .call(rpc_methods::SESSION_SHUTDOWN, Some(wire_params))
2903 .await?;
2904 Ok(())
2905 }
2906
2907 /// Emits a user-visible session log event.
2908 ///
2909 /// Wire method: `session.log`.
2910 ///
2911 /// # Parameters
2912 ///
2913 /// * `params` - Message text, optional severity level, persistence flag, optional follow-up URL, and optional tip.
2914 ///
2915 /// # Returns
2916 ///
2917 /// Identifier of the session event that was emitted for the log message.
2918 ///
2919 /// <div class="warning">
2920 ///
2921 /// **Experimental.** This API is part of an experimental wire-protocol surface
2922 /// and may change or be removed in future SDK or CLI releases. Pin both the
2923 /// SDK and CLI versions if your code depends on it.
2924 ///
2925 /// </div>
2926 pub async fn log(&self, params: LogRequest) -> Result<LogResult, Error> {
2927 let mut wire_params = serde_json::to_value(params)?;
2928 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
2929 let _value = self
2930 .session
2931 .client()
2932 .call(rpc_methods::SESSION_LOG, Some(wire_params))
2933 .await?;
2934 Ok(serde_json::from_value(_value)?)
2935 }
2936}
2937
2938/// `session.agent.*` RPCs.
2939#[derive(Clone, Copy)]
2940pub struct SessionRpcAgent<'a> {
2941 pub(crate) session: &'a Session,
2942}
2943
2944impl<'a> SessionRpcAgent<'a> {
2945 /// Lists custom agents available to the session.
2946 ///
2947 /// Wire method: `session.agent.list`.
2948 ///
2949 /// # Returns
2950 ///
2951 /// Custom agents available to the session.
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 list(&self) -> Result<AgentList, Error> {
2961 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
2962 let _value = self
2963 .session
2964 .client()
2965 .call(rpc_methods::SESSION_AGENT_LIST, Some(wire_params))
2966 .await?;
2967 Ok(serde_json::from_value(_value)?)
2968 }
2969
2970 /// Gets the currently selected custom agent for the session.
2971 ///
2972 /// Wire method: `session.agent.getCurrent`.
2973 ///
2974 /// # Returns
2975 ///
2976 /// The currently selected custom agent, or null when using the default agent.
2977 ///
2978 /// <div class="warning">
2979 ///
2980 /// **Experimental.** This API is part of an experimental wire-protocol surface
2981 /// and may change or be removed in future SDK or CLI releases. Pin both the
2982 /// SDK and CLI versions if your code depends on it.
2983 ///
2984 /// </div>
2985 pub async fn get_current(&self) -> Result<AgentGetCurrentResult, Error> {
2986 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
2987 let _value = self
2988 .session
2989 .client()
2990 .call(rpc_methods::SESSION_AGENT_GETCURRENT, Some(wire_params))
2991 .await?;
2992 Ok(serde_json::from_value(_value)?)
2993 }
2994
2995 /// Selects a custom agent for subsequent turns in the session.
2996 ///
2997 /// Wire method: `session.agent.select`.
2998 ///
2999 /// # Parameters
3000 ///
3001 /// * `params` - Name of the custom agent to select for subsequent turns.
3002 ///
3003 /// # Returns
3004 ///
3005 /// The newly selected custom agent.
3006 ///
3007 /// <div class="warning">
3008 ///
3009 /// **Experimental.** This API is part of an experimental wire-protocol surface
3010 /// and may change or be removed in future SDK or CLI releases. Pin both the
3011 /// SDK and CLI versions if your code depends on it.
3012 ///
3013 /// </div>
3014 pub async fn select(&self, params: AgentSelectRequest) -> Result<AgentSelectResult, Error> {
3015 let mut wire_params = serde_json::to_value(params)?;
3016 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3017 let _value = self
3018 .session
3019 .client()
3020 .call(rpc_methods::SESSION_AGENT_SELECT, Some(wire_params))
3021 .await?;
3022 Ok(serde_json::from_value(_value)?)
3023 }
3024
3025 /// Clears the selected custom agent and returns the session to the default agent.
3026 ///
3027 /// Wire method: `session.agent.deselect`.
3028 ///
3029 /// <div class="warning">
3030 ///
3031 /// **Experimental.** This API is part of an experimental wire-protocol surface
3032 /// and may change or be removed in future SDK or CLI releases. Pin both the
3033 /// SDK and CLI versions if your code depends on it.
3034 ///
3035 /// </div>
3036 pub async fn deselect(&self) -> Result<(), Error> {
3037 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3038 let _value = self
3039 .session
3040 .client()
3041 .call(rpc_methods::SESSION_AGENT_DESELECT, Some(wire_params))
3042 .await?;
3043 Ok(())
3044 }
3045
3046 /// Reloads custom agent definitions and returns the refreshed list.
3047 ///
3048 /// Wire method: `session.agent.reload`.
3049 ///
3050 /// # Returns
3051 ///
3052 /// Custom agents available to the session after reloading definitions from disk.
3053 ///
3054 /// <div class="warning">
3055 ///
3056 /// **Experimental.** This API is part of an experimental wire-protocol surface
3057 /// and may change or be removed in future SDK or CLI releases. Pin both the
3058 /// SDK and CLI versions if your code depends on it.
3059 ///
3060 /// </div>
3061 pub async fn reload(&self) -> Result<AgentReloadResult, Error> {
3062 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3063 let _value = self
3064 .session
3065 .client()
3066 .call(rpc_methods::SESSION_AGENT_RELOAD, Some(wire_params))
3067 .await?;
3068 Ok(serde_json::from_value(_value)?)
3069 }
3070}
3071
3072/// `session.canvas.*` RPCs.
3073#[derive(Clone, Copy)]
3074pub struct SessionRpcCanvas<'a> {
3075 pub(crate) session: &'a Session,
3076}
3077
3078impl<'a> SessionRpcCanvas<'a> {
3079 /// `session.canvas.action.*` sub-namespace.
3080 pub fn action(&self) -> SessionRpcCanvasAction<'a> {
3081 SessionRpcCanvasAction {
3082 session: self.session,
3083 }
3084 }
3085
3086 /// Lists canvases declared for the session.
3087 ///
3088 /// Wire method: `session.canvas.list`.
3089 ///
3090 /// # Returns
3091 ///
3092 /// Declared canvases available in this session.
3093 ///
3094 /// <div class="warning">
3095 ///
3096 /// **Experimental.** This API is part of an experimental wire-protocol surface
3097 /// and may change or be removed in future SDK or CLI releases. Pin both the
3098 /// SDK and CLI versions if your code depends on it.
3099 ///
3100 /// </div>
3101 pub async fn list(&self) -> Result<CanvasList, Error> {
3102 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3103 let _value = self
3104 .session
3105 .client()
3106 .call(rpc_methods::SESSION_CANVAS_LIST, Some(wire_params))
3107 .await?;
3108 Ok(serde_json::from_value(_value)?)
3109 }
3110
3111 /// Lists currently open canvas instances for the live session.
3112 ///
3113 /// Wire method: `session.canvas.listOpen`.
3114 ///
3115 /// # Returns
3116 ///
3117 /// Live open-canvas snapshot.
3118 ///
3119 /// <div class="warning">
3120 ///
3121 /// **Experimental.** This API is part of an experimental wire-protocol surface
3122 /// and may change or be removed in future SDK or CLI releases. Pin both the
3123 /// SDK and CLI versions if your code depends on it.
3124 ///
3125 /// </div>
3126 pub async fn list_open(&self) -> Result<CanvasListOpenResult, Error> {
3127 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3128 let _value = self
3129 .session
3130 .client()
3131 .call(rpc_methods::SESSION_CANVAS_LISTOPEN, Some(wire_params))
3132 .await?;
3133 Ok(serde_json::from_value(_value)?)
3134 }
3135
3136 /// Opens or focuses a canvas instance.
3137 ///
3138 /// Wire method: `session.canvas.open`.
3139 ///
3140 /// # Parameters
3141 ///
3142 /// * `params` - Canvas open parameters.
3143 ///
3144 /// # Returns
3145 ///
3146 /// Open canvas instance snapshot.
3147 ///
3148 /// <div class="warning">
3149 ///
3150 /// **Experimental.** This API is part of an experimental wire-protocol surface
3151 /// and may change or be removed in future SDK or CLI releases. Pin both the
3152 /// SDK and CLI versions if your code depends on it.
3153 ///
3154 /// </div>
3155 pub async fn open(&self, params: CanvasOpenRequest) -> Result<OpenCanvasInstance, Error> {
3156 let mut wire_params = serde_json::to_value(params)?;
3157 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3158 let _value = self
3159 .session
3160 .client()
3161 .call(rpc_methods::SESSION_CANVAS_OPEN, Some(wire_params))
3162 .await?;
3163 Ok(serde_json::from_value(_value)?)
3164 }
3165
3166 /// Closes an open canvas instance.
3167 ///
3168 /// Wire method: `session.canvas.close`.
3169 ///
3170 /// # Parameters
3171 ///
3172 /// * `params` - Canvas close parameters.
3173 ///
3174 /// <div class="warning">
3175 ///
3176 /// **Experimental.** This API is part of an experimental wire-protocol surface
3177 /// and may change or be removed in future SDK or CLI releases. Pin both the
3178 /// SDK and CLI versions if your code depends on it.
3179 ///
3180 /// </div>
3181 pub async fn close(&self, params: CanvasCloseRequest) -> Result<(), Error> {
3182 let mut wire_params = serde_json::to_value(params)?;
3183 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3184 let _value = self
3185 .session
3186 .client()
3187 .call(rpc_methods::SESSION_CANVAS_CLOSE, Some(wire_params))
3188 .await?;
3189 Ok(())
3190 }
3191}
3192
3193/// `session.canvas.action.*` RPCs.
3194#[derive(Clone, Copy)]
3195pub struct SessionRpcCanvasAction<'a> {
3196 pub(crate) session: &'a Session,
3197}
3198
3199impl<'a> SessionRpcCanvasAction<'a> {
3200 /// Invokes an action on an open canvas instance.
3201 ///
3202 /// Wire method: `session.canvas.action.invoke`.
3203 ///
3204 /// # Parameters
3205 ///
3206 /// * `params` - Canvas action invocation parameters.
3207 ///
3208 /// # Returns
3209 ///
3210 /// Canvas action invocation result.
3211 ///
3212 /// <div class="warning">
3213 ///
3214 /// **Experimental.** This API is part of an experimental wire-protocol surface
3215 /// and may change or be removed in future SDK or CLI releases. Pin both the
3216 /// SDK and CLI versions if your code depends on it.
3217 ///
3218 /// </div>
3219 pub async fn invoke(
3220 &self,
3221 params: CanvasActionInvokeRequest,
3222 ) -> Result<CanvasActionInvokeResult, Error> {
3223 let mut wire_params = serde_json::to_value(params)?;
3224 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3225 let _value = self
3226 .session
3227 .client()
3228 .call(rpc_methods::SESSION_CANVAS_ACTION_INVOKE, Some(wire_params))
3229 .await?;
3230 Ok(serde_json::from_value(_value)?)
3231 }
3232}
3233
3234/// `session.commands.*` RPCs.
3235#[derive(Clone, Copy)]
3236pub struct SessionRpcCommands<'a> {
3237 pub(crate) session: &'a Session,
3238}
3239
3240impl<'a> SessionRpcCommands<'a> {
3241 /// Lists slash commands available in the session.
3242 ///
3243 /// Wire method: `session.commands.list`.
3244 ///
3245 /// # Returns
3246 ///
3247 /// Slash commands available in the session, after applying any include/exclude filters.
3248 ///
3249 /// <div class="warning">
3250 ///
3251 /// **Experimental.** This API is part of an experimental wire-protocol surface
3252 /// and may change or be removed in future SDK or CLI releases. Pin both the
3253 /// SDK and CLI versions if your code depends on it.
3254 ///
3255 /// </div>
3256 pub async fn list(&self) -> Result<CommandList, Error> {
3257 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3258 let _value = self
3259 .session
3260 .client()
3261 .call(rpc_methods::SESSION_COMMANDS_LIST, Some(wire_params))
3262 .await?;
3263 Ok(serde_json::from_value(_value)?)
3264 }
3265
3266 /// Lists slash commands available in the session.
3267 ///
3268 /// Wire method: `session.commands.list`.
3269 ///
3270 /// # Parameters
3271 ///
3272 /// * `params` - Optional filters controlling which command sources to include in the listing.
3273 ///
3274 /// # Returns
3275 ///
3276 /// Slash commands available in the session, after applying any include/exclude filters.
3277 ///
3278 /// <div class="warning">
3279 ///
3280 /// **Experimental.** This API is part of an experimental wire-protocol surface
3281 /// and may change or be removed in future SDK or CLI releases. Pin both the
3282 /// SDK and CLI versions if your code depends on it.
3283 ///
3284 /// </div>
3285 pub async fn list_with_params(
3286 &self,
3287 params: CommandsListRequest,
3288 ) -> Result<CommandList, Error> {
3289 let mut wire_params = serde_json::to_value(params)?;
3290 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3291 let _value = self
3292 .session
3293 .client()
3294 .call(rpc_methods::SESSION_COMMANDS_LIST, Some(wire_params))
3295 .await?;
3296 Ok(serde_json::from_value(_value)?)
3297 }
3298
3299 /// Invokes a slash command in the session.
3300 ///
3301 /// Wire method: `session.commands.invoke`.
3302 ///
3303 /// # Parameters
3304 ///
3305 /// * `params` - Slash command name and optional raw input string to invoke.
3306 ///
3307 /// # Returns
3308 ///
3309 /// Result of invoking the slash command (text output, prompt to send to the agent, completion, or subcommand selection).
3310 ///
3311 /// <div class="warning">
3312 ///
3313 /// **Experimental.** This API is part of an experimental wire-protocol surface
3314 /// and may change or be removed in future SDK or CLI releases. Pin both the
3315 /// SDK and CLI versions if your code depends on it.
3316 ///
3317 /// </div>
3318 pub async fn invoke(
3319 &self,
3320 params: CommandsInvokeRequest,
3321 ) -> Result<SlashCommandInvocationResult, Error> {
3322 let mut wire_params = serde_json::to_value(params)?;
3323 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3324 let _value = self
3325 .session
3326 .client()
3327 .call(rpc_methods::SESSION_COMMANDS_INVOKE, Some(wire_params))
3328 .await?;
3329 Ok(serde_json::from_value(_value)?)
3330 }
3331
3332 /// Reports completion of a pending client-handled slash command.
3333 ///
3334 /// Wire method: `session.commands.handlePendingCommand`.
3335 ///
3336 /// # Parameters
3337 ///
3338 /// * `params` - Pending command request ID and an optional error if the client handler failed.
3339 ///
3340 /// # Returns
3341 ///
3342 /// Indicates whether the pending client-handled command was completed successfully.
3343 ///
3344 /// <div class="warning">
3345 ///
3346 /// **Experimental.** This API is part of an experimental wire-protocol surface
3347 /// and may change or be removed in future SDK or CLI releases. Pin both the
3348 /// SDK and CLI versions if your code depends on it.
3349 ///
3350 /// </div>
3351 pub async fn handle_pending_command(
3352 &self,
3353 params: CommandsHandlePendingCommandRequest,
3354 ) -> Result<CommandsHandlePendingCommandResult, Error> {
3355 let mut wire_params = serde_json::to_value(params)?;
3356 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3357 let _value = self
3358 .session
3359 .client()
3360 .call(
3361 rpc_methods::SESSION_COMMANDS_HANDLEPENDINGCOMMAND,
3362 Some(wire_params),
3363 )
3364 .await?;
3365 Ok(serde_json::from_value(_value)?)
3366 }
3367
3368 /// Executes a slash command synchronously and returns any error.
3369 ///
3370 /// Wire method: `session.commands.execute`.
3371 ///
3372 /// # Parameters
3373 ///
3374 /// * `params` - Slash command name and argument string to execute synchronously.
3375 ///
3376 /// # Returns
3377 ///
3378 /// Error message produced while executing the command, if any.
3379 ///
3380 /// <div class="warning">
3381 ///
3382 /// **Experimental.** This API is part of an experimental wire-protocol surface
3383 /// and may change or be removed in future SDK or CLI releases. Pin both the
3384 /// SDK and CLI versions if your code depends on it.
3385 ///
3386 /// </div>
3387 pub async fn execute(
3388 &self,
3389 params: ExecuteCommandParams,
3390 ) -> Result<ExecuteCommandResult, Error> {
3391 let mut wire_params = serde_json::to_value(params)?;
3392 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3393 let _value = self
3394 .session
3395 .client()
3396 .call(rpc_methods::SESSION_COMMANDS_EXECUTE, Some(wire_params))
3397 .await?;
3398 Ok(serde_json::from_value(_value)?)
3399 }
3400
3401 /// Enqueues a slash command for FIFO processing on the local session.
3402 ///
3403 /// Wire method: `session.commands.enqueue`.
3404 ///
3405 /// # Parameters
3406 ///
3407 /// * `params` - Slash-prefixed command string to enqueue for FIFO processing.
3408 ///
3409 /// # Returns
3410 ///
3411 /// Indicates whether the command was accepted into the local execution queue.
3412 ///
3413 /// <div class="warning">
3414 ///
3415 /// **Experimental.** This API is part of an experimental wire-protocol surface
3416 /// and may change or be removed in future SDK or CLI releases. Pin both the
3417 /// SDK and CLI versions if your code depends on it.
3418 ///
3419 /// </div>
3420 pub async fn enqueue(
3421 &self,
3422 params: EnqueueCommandParams,
3423 ) -> Result<EnqueueCommandResult, Error> {
3424 let mut wire_params = serde_json::to_value(params)?;
3425 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3426 let _value = self
3427 .session
3428 .client()
3429 .call(rpc_methods::SESSION_COMMANDS_ENQUEUE, Some(wire_params))
3430 .await?;
3431 Ok(serde_json::from_value(_value)?)
3432 }
3433
3434 /// Reports whether the host actually executed a queued command and whether to continue processing.
3435 ///
3436 /// Wire method: `session.commands.respondToQueuedCommand`.
3437 ///
3438 /// # Parameters
3439 ///
3440 /// * `params` - Queued-command request ID and the result indicating whether the host executed it (and whether to stop processing further queued commands).
3441 ///
3442 /// # Returns
3443 ///
3444 /// Indicates whether the queued-command response was matched to a pending request.
3445 ///
3446 /// <div class="warning">
3447 ///
3448 /// **Experimental.** This API is part of an experimental wire-protocol surface
3449 /// and may change or be removed in future SDK or CLI releases. Pin both the
3450 /// SDK and CLI versions if your code depends on it.
3451 ///
3452 /// </div>
3453 pub async fn respond_to_queued_command(
3454 &self,
3455 params: CommandsRespondToQueuedCommandRequest,
3456 ) -> Result<CommandsRespondToQueuedCommandResult, Error> {
3457 let mut wire_params = serde_json::to_value(params)?;
3458 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3459 let _value = self
3460 .session
3461 .client()
3462 .call(
3463 rpc_methods::SESSION_COMMANDS_RESPONDTOQUEUEDCOMMAND,
3464 Some(wire_params),
3465 )
3466 .await?;
3467 Ok(serde_json::from_value(_value)?)
3468 }
3469}
3470
3471/// `session.completions.*` RPCs.
3472#[derive(Clone, Copy)]
3473pub struct SessionRpcCompletions<'a> {
3474 pub(crate) session: &'a Session,
3475}
3476
3477impl<'a> SessionRpcCompletions<'a> {
3478 /// Gets the characters that should trigger host-driven completions for the session. Empty disables host-driven completions (e.g. local sessions, or a relay host that does not advertise them).
3479 ///
3480 /// Wire method: `session.completions.getTriggerCharacters`.
3481 ///
3482 /// # Returns
3483 ///
3484 /// Characters that, when typed in the composer, should trigger a `completions.request`. Empty when the session has no host-driven completions (e.g. local sessions, or a relay host that does not advertise `completionTriggerCharacters`).
3485 ///
3486 /// <div class="warning">
3487 ///
3488 /// **Experimental.** This API is part of an experimental wire-protocol surface
3489 /// and may change or be removed in future SDK or CLI releases. Pin both the
3490 /// SDK and CLI versions if your code depends on it.
3491 ///
3492 /// </div>
3493 pub async fn get_trigger_characters(
3494 &self,
3495 ) -> Result<CompletionsGetTriggerCharactersResult, Error> {
3496 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3497 let _value = self
3498 .session
3499 .client()
3500 .call(
3501 rpc_methods::SESSION_COMPLETIONS_GETTRIGGERCHARACTERS,
3502 Some(wire_params),
3503 )
3504 .await?;
3505 Ok(serde_json::from_value(_value)?)
3506 }
3507
3508 /// Requests host-driven completion items for the current composer input. Returns an empty list when the host has no items or does not support completions.
3509 ///
3510 /// Wire method: `session.completions.request`.
3511 ///
3512 /// # Parameters
3513 ///
3514 /// * `params` - Request host-driven completions for the current composer input.
3515 ///
3516 /// # Returns
3517 ///
3518 /// Host-driven completion items for the current composer input. Empty when the host returns no items or does not support completions.
3519 ///
3520 /// <div class="warning">
3521 ///
3522 /// **Experimental.** This API is part of an experimental wire-protocol surface
3523 /// and may change or be removed in future SDK or CLI releases. Pin both the
3524 /// SDK and CLI versions if your code depends on it.
3525 ///
3526 /// </div>
3527 pub async fn request(
3528 &self,
3529 params: CompletionsRequestRequest,
3530 ) -> Result<CompletionsRequestResult, Error> {
3531 let mut wire_params = serde_json::to_value(params)?;
3532 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3533 let _value = self
3534 .session
3535 .client()
3536 .call(rpc_methods::SESSION_COMPLETIONS_REQUEST, Some(wire_params))
3537 .await?;
3538 Ok(serde_json::from_value(_value)?)
3539 }
3540}
3541
3542/// `session.debug.*` RPCs.
3543#[derive(Clone, Copy)]
3544pub struct SessionRpcDebug<'a> {
3545 pub(crate) session: &'a Session,
3546}
3547
3548impl<'a> SessionRpcDebug<'a> {
3549 /// Collects a redacted session debug log bundle into a local archive or staging directory. The runtime includes session-owned logs by default and accepts caller-provided diagnostic entries so host applications can add their own files without changing this API shape.
3550 ///
3551 /// Wire method: `session.debug.collectLogs`.
3552 ///
3553 /// # Parameters
3554 ///
3555 /// * `params` - Options for collecting a redacted session debug bundle.
3556 ///
3557 /// # Returns
3558 ///
3559 /// Result of collecting a redacted debug bundle.
3560 ///
3561 /// <div class="warning">
3562 ///
3563 /// **Experimental.** This API is part of an experimental wire-protocol surface
3564 /// and may change or be removed in future SDK or CLI releases. Pin both the
3565 /// SDK and CLI versions if your code depends on it.
3566 ///
3567 /// </div>
3568 pub async fn collect_logs(
3569 &self,
3570 params: DebugCollectLogsRequest,
3571 ) -> Result<DebugCollectLogsResult, Error> {
3572 let mut wire_params = serde_json::to_value(params)?;
3573 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3574 let _value = self
3575 .session
3576 .client()
3577 .call(rpc_methods::SESSION_DEBUG_COLLECTLOGS, Some(wire_params))
3578 .await?;
3579 Ok(serde_json::from_value(_value)?)
3580 }
3581}
3582
3583/// `session.eventLog.*` RPCs.
3584#[derive(Clone, Copy)]
3585pub struct SessionRpcEventLog<'a> {
3586 pub(crate) session: &'a Session,
3587}
3588
3589impl<'a> SessionRpcEventLog<'a> {
3590 /// Reads a batch of session events from a cursor, optionally waiting for new events.
3591 ///
3592 /// Wire method: `session.eventLog.read`.
3593 ///
3594 /// # Parameters
3595 ///
3596 /// * `params` - Cursor, batch size, and optional long-poll/filter parameters for reading session events.
3597 ///
3598 /// # Returns
3599 ///
3600 /// Batch of session events returned by a read, with cursor and continuation metadata.
3601 ///
3602 /// <div class="warning">
3603 ///
3604 /// **Experimental.** This API is part of an experimental wire-protocol surface
3605 /// and may change or be removed in future SDK or CLI releases. Pin both the
3606 /// SDK and CLI versions if your code depends on it.
3607 ///
3608 /// </div>
3609 pub async fn read(&self, params: EventLogReadRequest) -> Result<EventsReadResult, Error> {
3610 let mut wire_params = serde_json::to_value(params)?;
3611 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3612 let _value = self
3613 .session
3614 .client()
3615 .call(rpc_methods::SESSION_EVENTLOG_READ, Some(wire_params))
3616 .await?;
3617 Ok(serde_json::from_value(_value)?)
3618 }
3619
3620 /// Returns a snapshot of the current tail cursor without consuming events.
3621 ///
3622 /// Wire method: `session.eventLog.tail`.
3623 ///
3624 /// # Returns
3625 ///
3626 /// 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).
3627 ///
3628 /// <div class="warning">
3629 ///
3630 /// **Experimental.** This API is part of an experimental wire-protocol surface
3631 /// and may change or be removed in future SDK or CLI releases. Pin both the
3632 /// SDK and CLI versions if your code depends on it.
3633 ///
3634 /// </div>
3635 pub async fn tail(&self) -> Result<EventLogTailResult, Error> {
3636 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3637 let _value = self
3638 .session
3639 .client()
3640 .call(rpc_methods::SESSION_EVENTLOG_TAIL, Some(wire_params))
3641 .await?;
3642 Ok(serde_json::from_value(_value)?)
3643 }
3644
3645 /// Registers consumer interest in an event type for runtime gating purposes.
3646 ///
3647 /// Wire method: `session.eventLog.registerInterest`.
3648 ///
3649 /// # Parameters
3650 ///
3651 /// * `params` - Event type to register consumer interest for, used by runtime gating logic.
3652 ///
3653 /// # Returns
3654 ///
3655 /// Opaque handle representing an event-type interest registration.
3656 ///
3657 /// <div class="warning">
3658 ///
3659 /// **Experimental.** This API is part of an experimental wire-protocol surface
3660 /// and may change or be removed in future SDK or CLI releases. Pin both the
3661 /// SDK and CLI versions if your code depends on it.
3662 ///
3663 /// </div>
3664 pub async fn register_interest(
3665 &self,
3666 params: RegisterEventInterestParams,
3667 ) -> Result<RegisterEventInterestResult, Error> {
3668 let mut wire_params = serde_json::to_value(params)?;
3669 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3670 let _value = self
3671 .session
3672 .client()
3673 .call(
3674 rpc_methods::SESSION_EVENTLOG_REGISTERINTEREST,
3675 Some(wire_params),
3676 )
3677 .await?;
3678 Ok(serde_json::from_value(_value)?)
3679 }
3680
3681 /// Releases a consumer's previously-registered interest in an event type.
3682 ///
3683 /// Wire method: `session.eventLog.releaseInterest`.
3684 ///
3685 /// # Parameters
3686 ///
3687 /// * `params` - Opaque handle previously returned by `registerInterest` to release.
3688 ///
3689 /// # Returns
3690 ///
3691 /// Indicates whether the operation succeeded.
3692 ///
3693 /// <div class="warning">
3694 ///
3695 /// **Experimental.** This API is part of an experimental wire-protocol surface
3696 /// and may change or be removed in future SDK or CLI releases. Pin both the
3697 /// SDK and CLI versions if your code depends on it.
3698 ///
3699 /// </div>
3700 pub async fn release_interest(
3701 &self,
3702 params: ReleaseEventInterestParams,
3703 ) -> Result<EventLogReleaseInterestResult, Error> {
3704 let mut wire_params = serde_json::to_value(params)?;
3705 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3706 let _value = self
3707 .session
3708 .client()
3709 .call(
3710 rpc_methods::SESSION_EVENTLOG_RELEASEINTEREST,
3711 Some(wire_params),
3712 )
3713 .await?;
3714 Ok(serde_json::from_value(_value)?)
3715 }
3716}
3717
3718/// `session.extensions.*` RPCs.
3719#[derive(Clone, Copy)]
3720pub struct SessionRpcExtensions<'a> {
3721 pub(crate) session: &'a Session,
3722}
3723
3724impl<'a> SessionRpcExtensions<'a> {
3725 /// Lists extensions discovered for the session and their current status.
3726 ///
3727 /// Wire method: `session.extensions.list`.
3728 ///
3729 /// # Returns
3730 ///
3731 /// Extensions discovered for the session, with their current status.
3732 ///
3733 /// <div class="warning">
3734 ///
3735 /// **Experimental.** This API is part of an experimental wire-protocol surface
3736 /// and may change or be removed in future SDK or CLI releases. Pin both the
3737 /// SDK and CLI versions if your code depends on it.
3738 ///
3739 /// </div>
3740 pub async fn list(&self) -> Result<ExtensionList, Error> {
3741 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3742 let _value = self
3743 .session
3744 .client()
3745 .call(rpc_methods::SESSION_EXTENSIONS_LIST, Some(wire_params))
3746 .await?;
3747 Ok(serde_json::from_value(_value)?)
3748 }
3749
3750 /// Enables an extension for the session.
3751 ///
3752 /// Wire method: `session.extensions.enable`.
3753 ///
3754 /// # Parameters
3755 ///
3756 /// * `params` - Source-qualified extension identifier to enable for the session.
3757 ///
3758 /// <div class="warning">
3759 ///
3760 /// **Experimental.** This API is part of an experimental wire-protocol surface
3761 /// and may change or be removed in future SDK or CLI releases. Pin both the
3762 /// SDK and CLI versions if your code depends on it.
3763 ///
3764 /// </div>
3765 pub async fn enable(&self, params: ExtensionsEnableRequest) -> Result<(), Error> {
3766 let mut wire_params = serde_json::to_value(params)?;
3767 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3768 let _value = self
3769 .session
3770 .client()
3771 .call(rpc_methods::SESSION_EXTENSIONS_ENABLE, Some(wire_params))
3772 .await?;
3773 Ok(())
3774 }
3775
3776 /// Disables an extension for the session.
3777 ///
3778 /// Wire method: `session.extensions.disable`.
3779 ///
3780 /// # Parameters
3781 ///
3782 /// * `params` - Source-qualified extension identifier to disable for the session.
3783 ///
3784 /// <div class="warning">
3785 ///
3786 /// **Experimental.** This API is part of an experimental wire-protocol surface
3787 /// and may change or be removed in future SDK or CLI releases. Pin both the
3788 /// SDK and CLI versions if your code depends on it.
3789 ///
3790 /// </div>
3791 pub async fn disable(&self, params: ExtensionsDisableRequest) -> Result<(), Error> {
3792 let mut wire_params = serde_json::to_value(params)?;
3793 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3794 let _value = self
3795 .session
3796 .client()
3797 .call(rpc_methods::SESSION_EXTENSIONS_DISABLE, Some(wire_params))
3798 .await?;
3799 Ok(())
3800 }
3801
3802 /// Reloads extension definitions and processes for the session.
3803 ///
3804 /// Wire method: `session.extensions.reload`.
3805 ///
3806 /// <div class="warning">
3807 ///
3808 /// **Experimental.** This API is part of an experimental wire-protocol surface
3809 /// and may change or be removed in future SDK or CLI releases. Pin both the
3810 /// SDK and CLI versions if your code depends on it.
3811 ///
3812 /// </div>
3813 pub async fn reload(&self) -> Result<(), Error> {
3814 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3815 let _value = self
3816 .session
3817 .client()
3818 .call(rpc_methods::SESSION_EXTENSIONS_RELOAD, Some(wire_params))
3819 .await?;
3820 Ok(())
3821 }
3822
3823 /// 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.
3824 ///
3825 /// Wire method: `session.extensions.sendAttachmentsToMessage`.
3826 ///
3827 /// # Parameters
3828 ///
3829 /// * `params` - Parameters for session.extensions.sendAttachmentsToMessage.
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 send_attachments_to_message(
3839 &self,
3840 params: SendAttachmentsToMessageParams,
3841 ) -> Result<(), Error> {
3842 let mut wire_params = serde_json::to_value(params)?;
3843 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3844 let _value = self
3845 .session
3846 .client()
3847 .call(
3848 rpc_methods::SESSION_EXTENSIONS_SENDATTACHMENTSTOMESSAGE,
3849 Some(wire_params),
3850 )
3851 .await?;
3852 Ok(())
3853 }
3854}
3855
3856/// `session.fleet.*` RPCs.
3857#[derive(Clone, Copy)]
3858pub struct SessionRpcFleet<'a> {
3859 pub(crate) session: &'a Session,
3860}
3861
3862impl<'a> SessionRpcFleet<'a> {
3863 /// Starts fleet mode by submitting the fleet orchestration prompt to the session.
3864 ///
3865 /// Wire method: `session.fleet.start`.
3866 ///
3867 /// # Parameters
3868 ///
3869 /// * `params` - Optional user prompt to combine with the fleet orchestration instructions.
3870 ///
3871 /// # Returns
3872 ///
3873 /// Indicates whether fleet mode was successfully activated.
3874 ///
3875 /// <div class="warning">
3876 ///
3877 /// **Experimental.** This API is part of an experimental wire-protocol surface
3878 /// and may change or be removed in future SDK or CLI releases. Pin both the
3879 /// SDK and CLI versions if your code depends on it.
3880 ///
3881 /// </div>
3882 pub async fn start(&self, params: FleetStartRequest) -> Result<FleetStartResult, Error> {
3883 let mut wire_params = serde_json::to_value(params)?;
3884 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3885 let _value = self
3886 .session
3887 .client()
3888 .call(rpc_methods::SESSION_FLEET_START, Some(wire_params))
3889 .await?;
3890 Ok(serde_json::from_value(_value)?)
3891 }
3892}
3893
3894/// `session.gitHubAuth.*` RPCs.
3895#[derive(Clone, Copy)]
3896pub struct SessionRpcGitHubAuth<'a> {
3897 pub(crate) session: &'a Session,
3898}
3899
3900impl<'a> SessionRpcGitHubAuth<'a> {
3901 /// Gets authentication status and account metadata for the session.
3902 ///
3903 /// Wire method: `session.gitHubAuth.getStatus`.
3904 ///
3905 /// # Returns
3906 ///
3907 /// Authentication status and account metadata for the session.
3908 ///
3909 /// <div class="warning">
3910 ///
3911 /// **Experimental.** This API is part of an experimental wire-protocol surface
3912 /// and may change or be removed in future SDK or CLI releases. Pin both the
3913 /// SDK and CLI versions if your code depends on it.
3914 ///
3915 /// </div>
3916 pub async fn get_status(&self) -> Result<SessionAuthStatus, Error> {
3917 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3918 let _value = self
3919 .session
3920 .client()
3921 .call(rpc_methods::SESSION_GITHUBAUTH_GETSTATUS, Some(wire_params))
3922 .await?;
3923 Ok(serde_json::from_value(_value)?)
3924 }
3925
3926 /// Updates the session's auth credentials used for outbound model and API requests.
3927 ///
3928 /// Wire method: `session.gitHubAuth.setCredentials`.
3929 ///
3930 /// # Parameters
3931 ///
3932 /// * `params` - New auth credentials to install on the session. Omit to leave credentials unchanged.
3933 ///
3934 /// # Returns
3935 ///
3936 /// Indicates whether the credential update succeeded.
3937 ///
3938 /// <div class="warning">
3939 ///
3940 /// **Experimental.** This API is part of an experimental wire-protocol surface
3941 /// and may change or be removed in future SDK or CLI releases. Pin both the
3942 /// SDK and CLI versions if your code depends on it.
3943 ///
3944 /// </div>
3945 pub async fn set_credentials(
3946 &self,
3947 params: SessionSetCredentialsParams,
3948 ) -> Result<SessionSetCredentialsResult, Error> {
3949 let mut wire_params = serde_json::to_value(params)?;
3950 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3951 let _value = self
3952 .session
3953 .client()
3954 .call(
3955 rpc_methods::SESSION_GITHUBAUTH_SETCREDENTIALS,
3956 Some(wire_params),
3957 )
3958 .await?;
3959 Ok(serde_json::from_value(_value)?)
3960 }
3961}
3962
3963/// `session.history.*` RPCs.
3964#[derive(Clone, Copy)]
3965pub struct SessionRpcHistory<'a> {
3966 pub(crate) session: &'a Session,
3967}
3968
3969impl<'a> SessionRpcHistory<'a> {
3970 /// Compacts the session history to reduce context usage.
3971 ///
3972 /// Wire method: `session.history.compact`.
3973 ///
3974 /// # Returns
3975 ///
3976 /// Compaction outcome with the number of tokens and messages removed, summary text, and the resulting context window breakdown.
3977 ///
3978 /// <div class="warning">
3979 ///
3980 /// **Experimental.** This API is part of an experimental wire-protocol surface
3981 /// and may change or be removed in future SDK or CLI releases. Pin both the
3982 /// SDK and CLI versions if your code depends on it.
3983 ///
3984 /// </div>
3985 pub async fn compact(&self) -> Result<HistoryCompactResult, Error> {
3986 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3987 let _value = self
3988 .session
3989 .client()
3990 .call(rpc_methods::SESSION_HISTORY_COMPACT, Some(wire_params))
3991 .await?;
3992 Ok(serde_json::from_value(_value)?)
3993 }
3994
3995 /// Compacts the session history to reduce context usage.
3996 ///
3997 /// Wire method: `session.history.compact`.
3998 ///
3999 /// # Parameters
4000 ///
4001 /// * `params` - Optional compaction parameters.
4002 ///
4003 /// # Returns
4004 ///
4005 /// Compaction outcome with the number of tokens and messages removed, summary text, and the resulting context window breakdown.
4006 ///
4007 /// <div class="warning">
4008 ///
4009 /// **Experimental.** This API is part of an experimental wire-protocol surface
4010 /// and may change or be removed in future SDK or CLI releases. Pin both the
4011 /// SDK and CLI versions if your code depends on it.
4012 ///
4013 /// </div>
4014 pub async fn compact_with_params(
4015 &self,
4016 params: HistoryCompactRequest,
4017 ) -> Result<HistoryCompactResult, Error> {
4018 let mut wire_params = serde_json::to_value(params)?;
4019 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4020 let _value = self
4021 .session
4022 .client()
4023 .call(rpc_methods::SESSION_HISTORY_COMPACT, Some(wire_params))
4024 .await?;
4025 Ok(serde_json::from_value(_value)?)
4026 }
4027
4028 /// Truncates persisted session history to a specific event.
4029 ///
4030 /// Wire method: `session.history.truncate`.
4031 ///
4032 /// # Parameters
4033 ///
4034 /// * `params` - Identifier of the event to truncate to; this event and all later events are removed.
4035 ///
4036 /// # Returns
4037 ///
4038 /// Number of events that were removed by the truncation.
4039 ///
4040 /// <div class="warning">
4041 ///
4042 /// **Experimental.** This API is part of an experimental wire-protocol surface
4043 /// and may change or be removed in future SDK or CLI releases. Pin both the
4044 /// SDK and CLI versions if your code depends on it.
4045 ///
4046 /// </div>
4047 pub async fn truncate(
4048 &self,
4049 params: HistoryTruncateRequest,
4050 ) -> Result<HistoryTruncateResult, Error> {
4051 let mut wire_params = serde_json::to_value(params)?;
4052 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4053 let _value = self
4054 .session
4055 .client()
4056 .call(rpc_methods::SESSION_HISTORY_TRUNCATE, Some(wire_params))
4057 .await?;
4058 Ok(serde_json::from_value(_value)?)
4059 }
4060
4061 /// Cancels any in-progress background compaction on a local session.
4062 ///
4063 /// Wire method: `session.history.cancelBackgroundCompaction`.
4064 ///
4065 /// # Returns
4066 ///
4067 /// Indicates whether an in-progress background compaction was cancelled.
4068 ///
4069 /// <div class="warning">
4070 ///
4071 /// **Experimental.** This API is part of an experimental wire-protocol surface
4072 /// and may change or be removed in future SDK or CLI releases. Pin both the
4073 /// SDK and CLI versions if your code depends on it.
4074 ///
4075 /// </div>
4076 pub async fn cancel_background_compaction(
4077 &self,
4078 ) -> Result<HistoryCancelBackgroundCompactionResult, Error> {
4079 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
4080 let _value = self
4081 .session
4082 .client()
4083 .call(
4084 rpc_methods::SESSION_HISTORY_CANCELBACKGROUNDCOMPACTION,
4085 Some(wire_params),
4086 )
4087 .await?;
4088 Ok(serde_json::from_value(_value)?)
4089 }
4090
4091 /// Aborts any in-progress manual compaction on a local session.
4092 ///
4093 /// Wire method: `session.history.abortManualCompaction`.
4094 ///
4095 /// # Returns
4096 ///
4097 /// Indicates whether an in-progress manual compaction was aborted.
4098 ///
4099 /// <div class="warning">
4100 ///
4101 /// **Experimental.** This API is part of an experimental wire-protocol surface
4102 /// and may change or be removed in future SDK or CLI releases. Pin both the
4103 /// SDK and CLI versions if your code depends on it.
4104 ///
4105 /// </div>
4106 pub async fn abort_manual_compaction(
4107 &self,
4108 ) -> Result<HistoryAbortManualCompactionResult, Error> {
4109 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
4110 let _value = self
4111 .session
4112 .client()
4113 .call(
4114 rpc_methods::SESSION_HISTORY_ABORTMANUALCOMPACTION,
4115 Some(wire_params),
4116 )
4117 .await?;
4118 Ok(serde_json::from_value(_value)?)
4119 }
4120
4121 /// Produces a markdown summary of the session's conversation context for hand-off scenarios.
4122 ///
4123 /// Wire method: `session.history.summarizeForHandoff`.
4124 ///
4125 /// # Returns
4126 ///
4127 /// Markdown summary of the conversation context (empty when not available).
4128 ///
4129 /// <div class="warning">
4130 ///
4131 /// **Experimental.** This API is part of an experimental wire-protocol surface
4132 /// and may change or be removed in future SDK or CLI releases. Pin both the
4133 /// SDK and CLI versions if your code depends on it.
4134 ///
4135 /// </div>
4136 pub async fn summarize_for_handoff(&self) -> Result<HistorySummarizeForHandoffResult, Error> {
4137 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
4138 let _value = self
4139 .session
4140 .client()
4141 .call(
4142 rpc_methods::SESSION_HISTORY_SUMMARIZEFORHANDOFF,
4143 Some(wire_params),
4144 )
4145 .await?;
4146 Ok(serde_json::from_value(_value)?)
4147 }
4148}
4149
4150/// `session.instructions.*` RPCs.
4151#[derive(Clone, Copy)]
4152pub struct SessionRpcInstructions<'a> {
4153 pub(crate) session: &'a Session,
4154}
4155
4156impl<'a> SessionRpcInstructions<'a> {
4157 /// Gets instruction sources loaded for the session.
4158 ///
4159 /// Wire method: `session.instructions.getSources`.
4160 ///
4161 /// # Returns
4162 ///
4163 /// Instruction sources loaded for the session, in merge order.
4164 ///
4165 /// <div class="warning">
4166 ///
4167 /// **Experimental.** This API is part of an experimental wire-protocol surface
4168 /// and may change or be removed in future SDK or CLI releases. Pin both the
4169 /// SDK and CLI versions if your code depends on it.
4170 ///
4171 /// </div>
4172 pub async fn get_sources(&self) -> Result<InstructionsGetSourcesResult, Error> {
4173 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
4174 let _value = self
4175 .session
4176 .client()
4177 .call(
4178 rpc_methods::SESSION_INSTRUCTIONS_GETSOURCES,
4179 Some(wire_params),
4180 )
4181 .await?;
4182 Ok(serde_json::from_value(_value)?)
4183 }
4184}
4185
4186/// `session.lsp.*` RPCs.
4187#[derive(Clone, Copy)]
4188pub struct SessionRpcLsp<'a> {
4189 pub(crate) session: &'a Session,
4190}
4191
4192impl<'a> SessionRpcLsp<'a> {
4193 /// Loads the merged LSP configuration set for the session's working directory.
4194 ///
4195 /// Wire method: `session.lsp.initialize`.
4196 ///
4197 /// # Parameters
4198 ///
4199 /// * `params` - Parameters for (re)loading the merged LSP configuration set.
4200 ///
4201 /// <div class="warning">
4202 ///
4203 /// **Experimental.** This API is part of an experimental wire-protocol surface
4204 /// and may change or be removed in future SDK or CLI releases. Pin both the
4205 /// SDK and CLI versions if your code depends on it.
4206 ///
4207 /// </div>
4208 pub async fn initialize(&self, params: LspInitializeRequest) -> Result<(), Error> {
4209 let mut wire_params = serde_json::to_value(params)?;
4210 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4211 let _value = self
4212 .session
4213 .client()
4214 .call(rpc_methods::SESSION_LSP_INITIALIZE, Some(wire_params))
4215 .await?;
4216 Ok(())
4217 }
4218}
4219
4220/// `session.mcp.*` RPCs.
4221#[derive(Clone, Copy)]
4222pub struct SessionRpcMcp<'a> {
4223 pub(crate) session: &'a Session,
4224}
4225
4226impl<'a> SessionRpcMcp<'a> {
4227 /// `session.mcp.apps.*` sub-namespace.
4228 pub fn apps(&self) -> SessionRpcMcpApps<'a> {
4229 SessionRpcMcpApps {
4230 session: self.session,
4231 }
4232 }
4233
4234 /// `session.mcp.headers.*` sub-namespace.
4235 pub fn headers(&self) -> SessionRpcMcpHeaders<'a> {
4236 SessionRpcMcpHeaders {
4237 session: self.session,
4238 }
4239 }
4240
4241 /// `session.mcp.oauth.*` sub-namespace.
4242 pub fn oauth(&self) -> SessionRpcMcpOauth<'a> {
4243 SessionRpcMcpOauth {
4244 session: self.session,
4245 }
4246 }
4247
4248 /// 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.
4249 ///
4250 /// Wire method: `session.mcp.list`.
4251 ///
4252 /// # Returns
4253 ///
4254 /// MCP servers configured for the session, with their connection status and host-level state.
4255 ///
4256 /// <div class="warning">
4257 ///
4258 /// **Experimental.** This API is part of an experimental wire-protocol surface
4259 /// and may change or be removed in future SDK or CLI releases. Pin both the
4260 /// SDK and CLI versions if your code depends on it.
4261 ///
4262 /// </div>
4263 pub async fn list(&self) -> Result<McpServerList, Error> {
4264 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
4265 let _value = self
4266 .session
4267 .client()
4268 .call(rpc_methods::SESSION_MCP_LIST, Some(wire_params))
4269 .await?;
4270 Ok(serde_json::from_value(_value)?)
4271 }
4272
4273 /// Lists the tools exposed by a connected MCP server on this session's host.
4274 ///
4275 /// Wire method: `session.mcp.listTools`.
4276 ///
4277 /// # Parameters
4278 ///
4279 /// * `params` - Server name whose tool list should be returned.
4280 ///
4281 /// # Returns
4282 ///
4283 /// Tools exposed by the connected MCP server. Throws when the server is not connected.
4284 ///
4285 /// <div class="warning">
4286 ///
4287 /// **Experimental.** This API is part of an experimental wire-protocol surface
4288 /// and may change or be removed in future SDK or CLI releases. Pin both the
4289 /// SDK and CLI versions if your code depends on it.
4290 ///
4291 /// </div>
4292 pub async fn list_tools(
4293 &self,
4294 params: McpListToolsRequest,
4295 ) -> Result<McpListToolsResult, Error> {
4296 let mut wire_params = serde_json::to_value(params)?;
4297 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4298 let _value = self
4299 .session
4300 .client()
4301 .call(rpc_methods::SESSION_MCP_LISTTOOLS, Some(wire_params))
4302 .await?;
4303 Ok(serde_json::from_value(_value)?)
4304 }
4305
4306 /// Enables an MCP server for the session.
4307 ///
4308 /// Wire method: `session.mcp.enable`.
4309 ///
4310 /// # Parameters
4311 ///
4312 /// * `params` - Name of the MCP server to enable for the session.
4313 ///
4314 /// <div class="warning">
4315 ///
4316 /// **Experimental.** This API is part of an experimental wire-protocol surface
4317 /// and may change or be removed in future SDK or CLI releases. Pin both the
4318 /// SDK and CLI versions if your code depends on it.
4319 ///
4320 /// </div>
4321 pub async fn enable(&self, params: McpEnableRequest) -> Result<(), Error> {
4322 let mut wire_params = serde_json::to_value(params)?;
4323 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4324 let _value = self
4325 .session
4326 .client()
4327 .call(rpc_methods::SESSION_MCP_ENABLE, Some(wire_params))
4328 .await?;
4329 Ok(())
4330 }
4331
4332 /// Disables an MCP server for the session.
4333 ///
4334 /// Wire method: `session.mcp.disable`.
4335 ///
4336 /// # Parameters
4337 ///
4338 /// * `params` - Name of the MCP server to disable for the session.
4339 ///
4340 /// <div class="warning">
4341 ///
4342 /// **Experimental.** This API is part of an experimental wire-protocol surface
4343 /// and may change or be removed in future SDK or CLI releases. Pin both the
4344 /// SDK and CLI versions if your code depends on it.
4345 ///
4346 /// </div>
4347 pub async fn disable(&self, params: McpDisableRequest) -> Result<(), Error> {
4348 let mut wire_params = serde_json::to_value(params)?;
4349 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4350 let _value = self
4351 .session
4352 .client()
4353 .call(rpc_methods::SESSION_MCP_DISABLE, Some(wire_params))
4354 .await?;
4355 Ok(())
4356 }
4357
4358 /// Reloads MCP server connections for the session.
4359 ///
4360 /// Wire method: `session.mcp.reload`.
4361 ///
4362 /// <div class="warning">
4363 ///
4364 /// **Experimental.** This API is part of an experimental wire-protocol surface
4365 /// and may change or be removed in future SDK or CLI releases. Pin both the
4366 /// SDK and CLI versions if your code depends on it.
4367 ///
4368 /// </div>
4369 pub async fn reload(&self) -> Result<(), Error> {
4370 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
4371 let _value = self
4372 .session
4373 .client()
4374 .call(rpc_methods::SESSION_MCP_RELOAD, Some(wire_params))
4375 .await?;
4376 Ok(())
4377 }
4378
4379 /// Reloads MCP server connections for the session with an explicit host-provided configuration.
4380 ///
4381 /// Wire method: `session.mcp.reloadWithConfig`.
4382 ///
4383 /// # Parameters
4384 ///
4385 /// * `params` - Opaque MCP reload configuration.
4386 ///
4387 /// # Returns
4388 ///
4389 /// MCP server startup filtering result.
4390 ///
4391 /// <div class="warning">
4392 ///
4393 /// **Experimental.** This API is part of an experimental wire-protocol surface
4394 /// and may change or be removed in future SDK or CLI releases. Pin both the
4395 /// SDK and CLI versions if your code depends on it.
4396 ///
4397 /// </div>
4398 pub(crate) async fn reload_with_config(
4399 &self,
4400 params: McpReloadWithConfigRequest,
4401 ) -> Result<McpStartServersResult, Error> {
4402 let mut wire_params = serde_json::to_value(params)?;
4403 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4404 let _value = self
4405 .session
4406 .client()
4407 .call(rpc_methods::SESSION_MCP_RELOADWITHCONFIG, Some(wire_params))
4408 .await?;
4409 Ok(serde_json::from_value(_value)?)
4410 }
4411
4412 /// Runs an MCP sampling inference on behalf of an MCP server.
4413 ///
4414 /// Wire method: `session.mcp.executeSampling`.
4415 ///
4416 /// # Parameters
4417 ///
4418 /// * `params` - Identifiers and raw MCP CreateMessageRequest params used to run a sampling inference.
4419 ///
4420 /// # Returns
4421 ///
4422 /// Outcome of an MCP sampling execution: success result, failure error, or cancellation.
4423 ///
4424 /// <div class="warning">
4425 ///
4426 /// **Experimental.** This API is part of an experimental wire-protocol surface
4427 /// and may change or be removed in future SDK or CLI releases. Pin both the
4428 /// SDK and CLI versions if your code depends on it.
4429 ///
4430 /// </div>
4431 pub async fn execute_sampling(
4432 &self,
4433 params: McpExecuteSamplingParams,
4434 ) -> Result<McpSamplingExecutionResult, Error> {
4435 let mut wire_params = serde_json::to_value(params)?;
4436 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4437 let _value = self
4438 .session
4439 .client()
4440 .call(rpc_methods::SESSION_MCP_EXECUTESAMPLING, Some(wire_params))
4441 .await?;
4442 Ok(serde_json::from_value(_value)?)
4443 }
4444
4445 /// Cancels an in-flight MCP sampling execution by request ID.
4446 ///
4447 /// Wire method: `session.mcp.cancelSamplingExecution`.
4448 ///
4449 /// # Parameters
4450 ///
4451 /// * `params` - The requestId previously passed to executeSampling that should be cancelled.
4452 ///
4453 /// # Returns
4454 ///
4455 /// Indicates whether an in-flight sampling execution with the given requestId was found and cancelled.
4456 ///
4457 /// <div class="warning">
4458 ///
4459 /// **Experimental.** This API is part of an experimental wire-protocol surface
4460 /// and may change or be removed in future SDK or CLI releases. Pin both the
4461 /// SDK and CLI versions if your code depends on it.
4462 ///
4463 /// </div>
4464 pub async fn cancel_sampling_execution(
4465 &self,
4466 params: McpCancelSamplingExecutionParams,
4467 ) -> Result<McpCancelSamplingExecutionResult, Error> {
4468 let mut wire_params = serde_json::to_value(params)?;
4469 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4470 let _value = self
4471 .session
4472 .client()
4473 .call(
4474 rpc_methods::SESSION_MCP_CANCELSAMPLINGEXECUTION,
4475 Some(wire_params),
4476 )
4477 .await?;
4478 Ok(serde_json::from_value(_value)?)
4479 }
4480
4481 /// Sets how environment-variable values supplied to MCP servers are resolved (direct or indirect).
4482 ///
4483 /// Wire method: `session.mcp.setEnvValueMode`.
4484 ///
4485 /// # Parameters
4486 ///
4487 /// * `params` - Mode controlling how MCP server env values are resolved (`direct` or `indirect`).
4488 ///
4489 /// # Returns
4490 ///
4491 /// Env-value mode recorded on the session after the update.
4492 ///
4493 /// <div class="warning">
4494 ///
4495 /// **Experimental.** This API is part of an experimental wire-protocol surface
4496 /// and may change or be removed in future SDK or CLI releases. Pin both the
4497 /// SDK and CLI versions if your code depends on it.
4498 ///
4499 /// </div>
4500 pub async fn set_env_value_mode(
4501 &self,
4502 params: McpSetEnvValueModeParams,
4503 ) -> Result<McpSetEnvValueModeResult, Error> {
4504 let mut wire_params = serde_json::to_value(params)?;
4505 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4506 let _value = self
4507 .session
4508 .client()
4509 .call(rpc_methods::SESSION_MCP_SETENVVALUEMODE, Some(wire_params))
4510 .await?;
4511 Ok(serde_json::from_value(_value)?)
4512 }
4513
4514 /// Removes the auto-managed `github` MCP server when present.
4515 ///
4516 /// Wire method: `session.mcp.removeGitHub`.
4517 ///
4518 /// # Returns
4519 ///
4520 /// Indicates whether the auto-managed `github` MCP server was removed (false when nothing to remove).
4521 ///
4522 /// <div class="warning">
4523 ///
4524 /// **Experimental.** This API is part of an experimental wire-protocol surface
4525 /// and may change or be removed in future SDK or CLI releases. Pin both the
4526 /// SDK and CLI versions if your code depends on it.
4527 ///
4528 /// </div>
4529 pub async fn remove_git_hub(&self) -> Result<McpRemoveGitHubResult, Error> {
4530 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
4531 let _value = self
4532 .session
4533 .client()
4534 .call(rpc_methods::SESSION_MCP_REMOVEGITHUB, Some(wire_params))
4535 .await?;
4536 Ok(serde_json::from_value(_value)?)
4537 }
4538
4539 /// Configures the built-in GitHub MCP server for the session's current auth context.
4540 ///
4541 /// Wire method: `session.mcp.configureGitHub`.
4542 ///
4543 /// # Parameters
4544 ///
4545 /// * `params` - Opaque auth info used to configure GitHub MCP.
4546 ///
4547 /// # Returns
4548 ///
4549 /// Result of configuring GitHub MCP.
4550 ///
4551 /// <div class="warning">
4552 ///
4553 /// **Experimental.** This API is part of an experimental wire-protocol surface
4554 /// and may change or be removed in future SDK or CLI releases. Pin both the
4555 /// SDK and CLI versions if your code depends on it.
4556 ///
4557 /// </div>
4558 pub(crate) async fn configure_git_hub(
4559 &self,
4560 params: McpConfigureGitHubRequest,
4561 ) -> Result<McpConfigureGitHubResult, Error> {
4562 let mut wire_params = serde_json::to_value(params)?;
4563 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4564 let _value = self
4565 .session
4566 .client()
4567 .call(rpc_methods::SESSION_MCP_CONFIGUREGITHUB, Some(wire_params))
4568 .await?;
4569 Ok(serde_json::from_value(_value)?)
4570 }
4571
4572 /// Starts an individual MCP server on the session's host.
4573 ///
4574 /// Wire method: `session.mcp.startServer`.
4575 ///
4576 /// # Parameters
4577 ///
4578 /// * `params` - Server name and opaque configuration for an individual MCP server start.
4579 ///
4580 /// <div class="warning">
4581 ///
4582 /// **Experimental.** This API is part of an experimental wire-protocol surface
4583 /// and may change or be removed in future SDK or CLI releases. Pin both the
4584 /// SDK and CLI versions if your code depends on it.
4585 ///
4586 /// </div>
4587 pub(crate) async fn start_server(&self, params: McpStartServerRequest) -> Result<(), Error> {
4588 let mut wire_params = serde_json::to_value(params)?;
4589 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4590 let _value = self
4591 .session
4592 .client()
4593 .call(rpc_methods::SESSION_MCP_STARTSERVER, Some(wire_params))
4594 .await?;
4595 Ok(())
4596 }
4597
4598 /// Restarts an individual MCP server on the session's host (stops then starts).
4599 ///
4600 /// Wire method: `session.mcp.restartServer`.
4601 ///
4602 /// # Parameters
4603 ///
4604 /// * `params` - Server name and opaque configuration for an individual MCP server restart.
4605 ///
4606 /// <div class="warning">
4607 ///
4608 /// **Experimental.** This API is part of an experimental wire-protocol surface
4609 /// and may change or be removed in future SDK or CLI releases. Pin both the
4610 /// SDK and CLI versions if your code depends on it.
4611 ///
4612 /// </div>
4613 pub(crate) async fn restart_server(
4614 &self,
4615 params: McpRestartServerRequest,
4616 ) -> Result<(), Error> {
4617 let mut wire_params = serde_json::to_value(params)?;
4618 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4619 let _value = self
4620 .session
4621 .client()
4622 .call(rpc_methods::SESSION_MCP_RESTARTSERVER, Some(wire_params))
4623 .await?;
4624 Ok(())
4625 }
4626
4627 /// Stops an individual MCP server on the session's host.
4628 ///
4629 /// Wire method: `session.mcp.stopServer`.
4630 ///
4631 /// # Parameters
4632 ///
4633 /// * `params` - Server name for an individual MCP server stop.
4634 ///
4635 /// <div class="warning">
4636 ///
4637 /// **Experimental.** This API is part of an experimental wire-protocol surface
4638 /// and may change or be removed in future SDK or CLI releases. Pin both the
4639 /// SDK and CLI versions if your code depends on it.
4640 ///
4641 /// </div>
4642 pub async fn stop_server(&self, params: McpStopServerRequest) -> Result<(), Error> {
4643 let mut wire_params = serde_json::to_value(params)?;
4644 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4645 let _value = self
4646 .session
4647 .client()
4648 .call(rpc_methods::SESSION_MCP_STOPSERVER, Some(wire_params))
4649 .await?;
4650 Ok(())
4651 }
4652
4653 /// 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.
4654 ///
4655 /// Wire method: `session.mcp.registerExternalClient`.
4656 ///
4657 /// # Parameters
4658 ///
4659 /// * `params` - Registration parameters for an external MCP client.
4660 ///
4661 /// <div class="warning">
4662 ///
4663 /// **Experimental.** This API is part of an experimental wire-protocol surface
4664 /// and may change or be removed in future SDK or CLI releases. Pin both the
4665 /// SDK and CLI versions if your code depends on it.
4666 ///
4667 /// </div>
4668 pub(crate) async fn register_external_client(
4669 &self,
4670 params: McpRegisterExternalClientRequest,
4671 ) -> Result<(), Error> {
4672 let mut wire_params = serde_json::to_value(params)?;
4673 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4674 let _value = self
4675 .session
4676 .client()
4677 .call(
4678 rpc_methods::SESSION_MCP_REGISTEREXTERNALCLIENT,
4679 Some(wire_params),
4680 )
4681 .await?;
4682 Ok(())
4683 }
4684
4685 /// 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.
4686 ///
4687 /// Wire method: `session.mcp.unregisterExternalClient`.
4688 ///
4689 /// # Parameters
4690 ///
4691 /// * `params` - Server name identifying the external client to remove.
4692 ///
4693 /// <div class="warning">
4694 ///
4695 /// **Experimental.** This API is part of an experimental wire-protocol surface
4696 /// and may change or be removed in future SDK or CLI releases. Pin both the
4697 /// SDK and CLI versions if your code depends on it.
4698 ///
4699 /// </div>
4700 pub(crate) async fn unregister_external_client(
4701 &self,
4702 params: McpUnregisterExternalClientRequest,
4703 ) -> Result<(), Error> {
4704 let mut wire_params = serde_json::to_value(params)?;
4705 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4706 let _value = self
4707 .session
4708 .client()
4709 .call(
4710 rpc_methods::SESSION_MCP_UNREGISTEREXTERNALCLIENT,
4711 Some(wire_params),
4712 )
4713 .await?;
4714 Ok(())
4715 }
4716
4717 /// Checks whether a named MCP server is currently running on the session's host.
4718 ///
4719 /// Wire method: `session.mcp.isServerRunning`.
4720 ///
4721 /// # Parameters
4722 ///
4723 /// * `params` - Server name to check running status for.
4724 ///
4725 /// # Returns
4726 ///
4727 /// Whether the named MCP server is running.
4728 ///
4729 /// <div class="warning">
4730 ///
4731 /// **Experimental.** This API is part of an experimental wire-protocol surface
4732 /// and may change or be removed in future SDK or CLI releases. Pin both the
4733 /// SDK and CLI versions if your code depends on it.
4734 ///
4735 /// </div>
4736 pub async fn is_server_running(
4737 &self,
4738 params: McpIsServerRunningRequest,
4739 ) -> Result<McpIsServerRunningResult, Error> {
4740 let mut wire_params = serde_json::to_value(params)?;
4741 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4742 let _value = self
4743 .session
4744 .client()
4745 .call(rpc_methods::SESSION_MCP_ISSERVERRUNNING, Some(wire_params))
4746 .await?;
4747 Ok(serde_json::from_value(_value)?)
4748 }
4749}
4750
4751/// `session.mcp.apps.*` RPCs.
4752#[derive(Clone, Copy)]
4753pub struct SessionRpcMcpApps<'a> {
4754 pub(crate) session: &'a Session,
4755}
4756
4757impl<'a> SessionRpcMcpApps<'a> {
4758 /// Fetch an MCP resource (typically a `ui://` MCP App bundle, per SEP-1865) from a connected server. Requires the `mcp-apps` session capability.
4759 ///
4760 /// Wire method: `session.mcp.apps.readResource`.
4761 ///
4762 /// # Parameters
4763 ///
4764 /// * `params` - MCP server and resource URI to fetch.
4765 ///
4766 /// # Returns
4767 ///
4768 /// Resource contents returned by the MCP server.
4769 ///
4770 /// <div class="warning">
4771 ///
4772 /// **Experimental.** This API is part of an experimental wire-protocol surface
4773 /// and may change or be removed in future SDK or CLI releases. Pin both the
4774 /// SDK and CLI versions if your code depends on it.
4775 ///
4776 /// </div>
4777 pub async fn read_resource(
4778 &self,
4779 params: McpAppsReadResourceRequest,
4780 ) -> Result<McpAppsReadResourceResult, Error> {
4781 let mut wire_params = serde_json::to_value(params)?;
4782 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4783 let _value = self
4784 .session
4785 .client()
4786 .call(
4787 rpc_methods::SESSION_MCP_APPS_READRESOURCE,
4788 Some(wire_params),
4789 )
4790 .await?;
4791 Ok(serde_json::from_value(_value)?)
4792 }
4793
4794 /// 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"`.
4795 ///
4796 /// Wire method: `session.mcp.apps.listTools`.
4797 ///
4798 /// # Parameters
4799 ///
4800 /// * `params` - MCP server to list app-callable tools for.
4801 ///
4802 /// # Returns
4803 ///
4804 /// App-callable tools from the named MCP server.
4805 ///
4806 /// <div class="warning">
4807 ///
4808 /// **Experimental.** This API is part of an experimental wire-protocol surface
4809 /// and may change or be removed in future SDK or CLI releases. Pin both the
4810 /// SDK and CLI versions if your code depends on it.
4811 ///
4812 /// </div>
4813 pub async fn list_tools(
4814 &self,
4815 params: McpAppsListToolsRequest,
4816 ) -> Result<McpAppsListToolsResult, Error> {
4817 let mut wire_params = serde_json::to_value(params)?;
4818 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4819 let _value = self
4820 .session
4821 .client()
4822 .call(rpc_methods::SESSION_MCP_APPS_LISTTOOLS, Some(wire_params))
4823 .await?;
4824 Ok(serde_json::from_value(_value)?)
4825 }
4826
4827 /// 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`.
4828 ///
4829 /// Wire method: `session.mcp.apps.callTool`.
4830 ///
4831 /// # Parameters
4832 ///
4833 /// * `params` - MCP server, tool name, and arguments to invoke from an MCP App view.
4834 ///
4835 /// # Returns
4836 ///
4837 /// Standard MCP CallToolResult
4838 ///
4839 /// <div class="warning">
4840 ///
4841 /// **Experimental.** This API is part of an experimental wire-protocol surface
4842 /// and may change or be removed in future SDK or CLI releases. Pin both the
4843 /// SDK and CLI versions if your code depends on it.
4844 ///
4845 /// </div>
4846 pub async fn call_tool(
4847 &self,
4848 params: McpAppsCallToolRequest,
4849 ) -> Result<SessionMcpAppsCallToolResult, Error> {
4850 let mut wire_params = serde_json::to_value(params)?;
4851 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4852 let _value = self
4853 .session
4854 .client()
4855 .call(rpc_methods::SESSION_MCP_APPS_CALLTOOL, Some(wire_params))
4856 .await?;
4857 Ok(serde_json::from_value(_value)?)
4858 }
4859
4860 /// 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.
4861 ///
4862 /// Wire method: `session.mcp.apps.setHostContext`.
4863 ///
4864 /// # Parameters
4865 ///
4866 /// * `params` - Host context to advertise to MCP App guests.
4867 ///
4868 /// <div class="warning">
4869 ///
4870 /// **Experimental.** This API is part of an experimental wire-protocol surface
4871 /// and may change or be removed in future SDK or CLI releases. Pin both the
4872 /// SDK and CLI versions if your code depends on it.
4873 ///
4874 /// </div>
4875 pub async fn set_host_context(
4876 &self,
4877 params: McpAppsSetHostContextRequest,
4878 ) -> Result<(), Error> {
4879 let mut wire_params = serde_json::to_value(params)?;
4880 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4881 let _value = self
4882 .session
4883 .client()
4884 .call(
4885 rpc_methods::SESSION_MCP_APPS_SETHOSTCONTEXT,
4886 Some(wire_params),
4887 )
4888 .await?;
4889 Ok(())
4890 }
4891
4892 /// Read the current host context advertised to MCP App guests.
4893 ///
4894 /// Wire method: `session.mcp.apps.getHostContext`.
4895 ///
4896 /// # Returns
4897 ///
4898 /// Current host context advertised to MCP App guests.
4899 ///
4900 /// <div class="warning">
4901 ///
4902 /// **Experimental.** This API is part of an experimental wire-protocol surface
4903 /// and may change or be removed in future SDK or CLI releases. Pin both the
4904 /// SDK and CLI versions if your code depends on it.
4905 ///
4906 /// </div>
4907 pub async fn get_host_context(&self) -> Result<McpAppsHostContext, Error> {
4908 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
4909 let _value = self
4910 .session
4911 .client()
4912 .call(
4913 rpc_methods::SESSION_MCP_APPS_GETHOSTCONTEXT,
4914 Some(wire_params),
4915 )
4916 .await?;
4917 Ok(serde_json::from_value(_value)?)
4918 }
4919
4920 /// 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.
4921 ///
4922 /// Wire method: `session.mcp.apps.diagnose`.
4923 ///
4924 /// # Parameters
4925 ///
4926 /// * `params` - MCP server to diagnose MCP Apps wiring for.
4927 ///
4928 /// # Returns
4929 ///
4930 /// Diagnostic snapshot of MCP Apps wiring for the named server.
4931 ///
4932 /// <div class="warning">
4933 ///
4934 /// **Experimental.** This API is part of an experimental wire-protocol surface
4935 /// and may change or be removed in future SDK or CLI releases. Pin both the
4936 /// SDK and CLI versions if your code depends on it.
4937 ///
4938 /// </div>
4939 pub async fn diagnose(
4940 &self,
4941 params: McpAppsDiagnoseRequest,
4942 ) -> Result<McpAppsDiagnoseResult, Error> {
4943 let mut wire_params = serde_json::to_value(params)?;
4944 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4945 let _value = self
4946 .session
4947 .client()
4948 .call(rpc_methods::SESSION_MCP_APPS_DIAGNOSE, Some(wire_params))
4949 .await?;
4950 Ok(serde_json::from_value(_value)?)
4951 }
4952}
4953
4954/// `session.mcp.headers.*` RPCs.
4955#[derive(Clone, Copy)]
4956pub struct SessionRpcMcpHeaders<'a> {
4957 pub(crate) session: &'a Session,
4958}
4959
4960impl<'a> SessionRpcMcpHeaders<'a> {
4961 /// 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.
4962 ///
4963 /// Wire method: `session.mcp.headers.handlePendingHeadersRefreshRequest`.
4964 ///
4965 /// # Parameters
4966 ///
4967 /// * `params` - MCP headers refresh request id and the host response.
4968 ///
4969 /// # Returns
4970 ///
4971 /// Indicates whether the pending MCP headers refresh response was accepted.
4972 ///
4973 /// <div class="warning">
4974 ///
4975 /// **Experimental.** This API is part of an experimental wire-protocol surface
4976 /// and may change or be removed in future SDK or CLI releases. Pin both the
4977 /// SDK and CLI versions if your code depends on it.
4978 ///
4979 /// </div>
4980 pub async fn handle_pending_headers_refresh_request(
4981 &self,
4982 params: McpHeadersHandlePendingHeadersRefreshRequestRequest,
4983 ) -> Result<McpHeadersHandlePendingHeadersRefreshRequestResult, Error> {
4984 let mut wire_params = serde_json::to_value(params)?;
4985 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4986 let _value = self
4987 .session
4988 .client()
4989 .call(
4990 rpc_methods::SESSION_MCP_HEADERS_HANDLEPENDINGHEADERSREFRESHREQUEST,
4991 Some(wire_params),
4992 )
4993 .await?;
4994 Ok(serde_json::from_value(_value)?)
4995 }
4996}
4997
4998/// `session.mcp.oauth.*` RPCs.
4999#[derive(Clone, Copy)]
5000pub struct SessionRpcMcpOauth<'a> {
5001 pub(crate) session: &'a Session,
5002}
5003
5004impl<'a> SessionRpcMcpOauth<'a> {
5005 /// 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.
5006 ///
5007 /// Wire method: `session.mcp.oauth.handlePendingRequest`.
5008 ///
5009 /// # Parameters
5010 ///
5011 /// * `params` - Pending MCP OAuth request ID and host-provided token or cancellation response.
5012 ///
5013 /// # Returns
5014 ///
5015 /// Indicates whether the pending MCP OAuth response was accepted.
5016 ///
5017 /// <div class="warning">
5018 ///
5019 /// **Experimental.** This API is part of an experimental wire-protocol surface
5020 /// and may change or be removed in future SDK or CLI releases. Pin both the
5021 /// SDK and CLI versions if your code depends on it.
5022 ///
5023 /// </div>
5024 pub async fn handle_pending_request(
5025 &self,
5026 params: McpOauthHandlePendingRequest,
5027 ) -> Result<McpOauthHandlePendingResult, Error> {
5028 let mut wire_params = serde_json::to_value(params)?;
5029 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5030 let _value = self
5031 .session
5032 .client()
5033 .call(
5034 rpc_methods::SESSION_MCP_OAUTH_HANDLEPENDINGREQUEST,
5035 Some(wire_params),
5036 )
5037 .await?;
5038 Ok(serde_json::from_value(_value)?)
5039 }
5040
5041 /// Starts OAuth authentication for a remote MCP server.
5042 ///
5043 /// Wire method: `session.mcp.oauth.login`.
5044 ///
5045 /// # Parameters
5046 ///
5047 /// * `params` - Remote MCP server name and optional overrides controlling reauthentication, OAuth client display name, callback success-page copy, and static OAuth client selection.
5048 ///
5049 /// # Returns
5050 ///
5051 /// OAuth authorization URL the caller should open, or empty when cached tokens already authenticated the server.
5052 ///
5053 /// <div class="warning">
5054 ///
5055 /// **Experimental.** This API is part of an experimental wire-protocol surface
5056 /// and may change or be removed in future SDK or CLI releases. Pin both the
5057 /// SDK and CLI versions if your code depends on it.
5058 ///
5059 /// </div>
5060 pub async fn login(&self, params: McpOauthLoginRequest) -> Result<McpOauthLoginResult, Error> {
5061 let mut wire_params = serde_json::to_value(params)?;
5062 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5063 let _value = self
5064 .session
5065 .client()
5066 .call(rpc_methods::SESSION_MCP_OAUTH_LOGIN, Some(wire_params))
5067 .await?;
5068 Ok(serde_json::from_value(_value)?)
5069 }
5070}
5071
5072/// `session.metadata.*` RPCs.
5073#[derive(Clone, Copy)]
5074pub struct SessionRpcMetadata<'a> {
5075 pub(crate) session: &'a Session,
5076}
5077
5078impl<'a> SessionRpcMetadata<'a> {
5079 /// Returns a snapshot of the session's identifying metadata, mode, agent, and remote info.
5080 ///
5081 /// Wire method: `session.metadata.snapshot`.
5082 ///
5083 /// # Returns
5084 ///
5085 /// Point-in-time snapshot of slow-changing session identifier and state fields
5086 ///
5087 /// <div class="warning">
5088 ///
5089 /// **Experimental.** This API is part of an experimental wire-protocol surface
5090 /// and may change or be removed in future SDK or CLI releases. Pin both the
5091 /// SDK and CLI versions if your code depends on it.
5092 ///
5093 /// </div>
5094 pub async fn snapshot(&self) -> Result<SessionMetadataSnapshot, Error> {
5095 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5096 let _value = self
5097 .session
5098 .client()
5099 .call(rpc_methods::SESSION_METADATA_SNAPSHOT, Some(wire_params))
5100 .await?;
5101 Ok(serde_json::from_value(_value)?)
5102 }
5103
5104 /// Reports whether the local session is currently processing user/agent messages.
5105 ///
5106 /// Wire method: `session.metadata.isProcessing`.
5107 ///
5108 /// # Returns
5109 ///
5110 /// Indicates whether the local session is currently processing a turn or background continuation.
5111 ///
5112 /// <div class="warning">
5113 ///
5114 /// **Experimental.** This API is part of an experimental wire-protocol surface
5115 /// and may change or be removed in future SDK or CLI releases. Pin both the
5116 /// SDK and CLI versions if your code depends on it.
5117 ///
5118 /// </div>
5119 pub async fn is_processing(&self) -> Result<MetadataIsProcessingResult, Error> {
5120 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5121 let _value = self
5122 .session
5123 .client()
5124 .call(
5125 rpc_methods::SESSION_METADATA_ISPROCESSING,
5126 Some(wire_params),
5127 )
5128 .await?;
5129 Ok(serde_json::from_value(_value)?)
5130 }
5131
5132 /// Returns a snapshot of activity flags for the session.
5133 ///
5134 /// Wire method: `session.metadata.activity`.
5135 ///
5136 /// # Returns
5137 ///
5138 /// Current activity flags for the session.
5139 ///
5140 /// <div class="warning">
5141 ///
5142 /// **Experimental.** This API is part of an experimental wire-protocol surface
5143 /// and may change or be removed in future SDK or CLI releases. Pin both the
5144 /// SDK and CLI versions if your code depends on it.
5145 ///
5146 /// </div>
5147 pub async fn activity(&self) -> Result<SessionActivity, Error> {
5148 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5149 let _value = self
5150 .session
5151 .client()
5152 .call(rpc_methods::SESSION_METADATA_ACTIVITY, Some(wire_params))
5153 .await?;
5154 Ok(serde_json::from_value(_value)?)
5155 }
5156
5157 /// Returns the token breakdown for the session's current context window for a given model.
5158 ///
5159 /// Wire method: `session.metadata.contextInfo`.
5160 ///
5161 /// # Parameters
5162 ///
5163 /// * `params` - Model identifier and token limits used to compute the context-info breakdown.
5164 ///
5165 /// # Returns
5166 ///
5167 /// Token breakdown for the session's current context window, or null if uninitialized.
5168 ///
5169 /// <div class="warning">
5170 ///
5171 /// **Experimental.** This API is part of an experimental wire-protocol surface
5172 /// and may change or be removed in future SDK or CLI releases. Pin both the
5173 /// SDK and CLI versions if your code depends on it.
5174 ///
5175 /// </div>
5176 pub async fn context_info(
5177 &self,
5178 params: MetadataContextInfoRequest,
5179 ) -> Result<MetadataContextInfoResult, Error> {
5180 let mut wire_params = serde_json::to_value(params)?;
5181 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5182 let _value = self
5183 .session
5184 .client()
5185 .call(rpc_methods::SESSION_METADATA_CONTEXTINFO, Some(wire_params))
5186 .await?;
5187 Ok(serde_json::from_value(_value)?)
5188 }
5189
5190 /// Returns the experimental per-source attribution breakdown of the session's current context window as a flat list of entries (skills, subagents, MCP servers, built-in tools, plugin rollups, system/tool-definition costs, with nesting via parentId), plus the successful compaction count. The heaviest individual messages are available separately via `metadata.getContextHeaviestMessages`. Returns null until the session has initialized its system prompt and tool metadata.
5191 ///
5192 /// Wire method: `session.metadata.getContextAttribution`.
5193 ///
5194 /// # Returns
5195 ///
5196 /// Per-source attribution breakdown for the session's current context window, or null if uninitialized.
5197 ///
5198 /// <div class="warning">
5199 ///
5200 /// **Experimental.** This API is part of an experimental wire-protocol surface
5201 /// and may change or be removed in future SDK or CLI releases. Pin both the
5202 /// SDK and CLI versions if your code depends on it.
5203 ///
5204 /// </div>
5205 pub async fn get_context_attribution(&self) -> Result<MetadataContextAttributionResult, Error> {
5206 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5207 let _value = self
5208 .session
5209 .client()
5210 .call(
5211 rpc_methods::SESSION_METADATA_GETCONTEXTATTRIBUTION,
5212 Some(wire_params),
5213 )
5214 .await?;
5215 Ok(serde_json::from_value(_value)?)
5216 }
5217
5218 /// Returns the largest individual messages currently in the session's context window, most-expensive first. Companion to `metadata.getContextAttribution`. Returns an empty list until the session has initialized.
5219 ///
5220 /// Wire method: `session.metadata.getContextHeaviestMessages`.
5221 ///
5222 /// # Parameters
5223 ///
5224 /// * `params` - Parameters for the heaviest-messages query.
5225 ///
5226 /// # Returns
5227 ///
5228 /// The heaviest individual messages in the session's context window, most-expensive first.
5229 ///
5230 /// <div class="warning">
5231 ///
5232 /// **Experimental.** This API is part of an experimental wire-protocol surface
5233 /// and may change or be removed in future SDK or CLI releases. Pin both the
5234 /// SDK and CLI versions if your code depends on it.
5235 ///
5236 /// </div>
5237 pub async fn get_context_heaviest_messages(
5238 &self,
5239 params: MetadataContextHeaviestMessagesRequest,
5240 ) -> Result<MetadataContextHeaviestMessagesResult, Error> {
5241 let mut wire_params = serde_json::to_value(params)?;
5242 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5243 let _value = self
5244 .session
5245 .client()
5246 .call(
5247 rpc_methods::SESSION_METADATA_GETCONTEXTHEAVIESTMESSAGES,
5248 Some(wire_params),
5249 )
5250 .await?;
5251 Ok(serde_json::from_value(_value)?)
5252 }
5253
5254 /// Records a working-directory/git context change and emits a `session.context_changed` event.
5255 ///
5256 /// Wire method: `session.metadata.recordContextChange`.
5257 ///
5258 /// # Parameters
5259 ///
5260 /// * `params` - Updated working-directory/git context to record on the session.
5261 ///
5262 /// # Returns
5263 ///
5264 /// 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).
5265 ///
5266 /// <div class="warning">
5267 ///
5268 /// **Experimental.** This API is part of an experimental wire-protocol surface
5269 /// and may change or be removed in future SDK or CLI releases. Pin both the
5270 /// SDK and CLI versions if your code depends on it.
5271 ///
5272 /// </div>
5273 pub async fn record_context_change(
5274 &self,
5275 params: MetadataRecordContextChangeRequest,
5276 ) -> Result<MetadataRecordContextChangeResult, Error> {
5277 let mut wire_params = serde_json::to_value(params)?;
5278 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5279 let _value = self
5280 .session
5281 .client()
5282 .call(
5283 rpc_methods::SESSION_METADATA_RECORDCONTEXTCHANGE,
5284 Some(wire_params),
5285 )
5286 .await?;
5287 Ok(serde_json::from_value(_value)?)
5288 }
5289
5290 /// Updates the session's recorded working directory.
5291 ///
5292 /// Wire method: `session.metadata.setWorkingDirectory`.
5293 ///
5294 /// # Parameters
5295 ///
5296 /// * `params` - Absolute path to set as the session's new working directory.
5297 ///
5298 /// # Returns
5299 ///
5300 /// 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.
5301 ///
5302 /// <div class="warning">
5303 ///
5304 /// **Experimental.** This API is part of an experimental wire-protocol surface
5305 /// and may change or be removed in future SDK or CLI releases. Pin both the
5306 /// SDK and CLI versions if your code depends on it.
5307 ///
5308 /// </div>
5309 pub async fn set_working_directory(
5310 &self,
5311 params: MetadataSetWorkingDirectoryRequest,
5312 ) -> Result<MetadataSetWorkingDirectoryResult, Error> {
5313 let mut wire_params = serde_json::to_value(params)?;
5314 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5315 let _value = self
5316 .session
5317 .client()
5318 .call(
5319 rpc_methods::SESSION_METADATA_SETWORKINGDIRECTORY,
5320 Some(wire_params),
5321 )
5322 .await?;
5323 Ok(serde_json::from_value(_value)?)
5324 }
5325
5326 /// Re-tokenizes the session's existing messages against a model and returns aggregate token totals.
5327 ///
5328 /// Wire method: `session.metadata.recomputeContextTokens`.
5329 ///
5330 /// # Parameters
5331 ///
5332 /// * `params` - Model identifier to use when re-tokenizing the session's existing messages.
5333 ///
5334 /// # Returns
5335 ///
5336 /// 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.
5337 ///
5338 /// <div class="warning">
5339 ///
5340 /// **Experimental.** This API is part of an experimental wire-protocol surface
5341 /// and may change or be removed in future SDK or CLI releases. Pin both the
5342 /// SDK and CLI versions if your code depends on it.
5343 ///
5344 /// </div>
5345 pub async fn recompute_context_tokens(
5346 &self,
5347 params: MetadataRecomputeContextTokensRequest,
5348 ) -> Result<MetadataRecomputeContextTokensResult, Error> {
5349 let mut wire_params = serde_json::to_value(params)?;
5350 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5351 let _value = self
5352 .session
5353 .client()
5354 .call(
5355 rpc_methods::SESSION_METADATA_RECOMPUTECONTEXTTOKENS,
5356 Some(wire_params),
5357 )
5358 .await?;
5359 Ok(serde_json::from_value(_value)?)
5360 }
5361}
5362
5363/// `session.mode.*` RPCs.
5364#[derive(Clone, Copy)]
5365pub struct SessionRpcMode<'a> {
5366 pub(crate) session: &'a Session,
5367}
5368
5369impl<'a> SessionRpcMode<'a> {
5370 /// Gets the current agent interaction mode.
5371 ///
5372 /// Wire method: `session.mode.get`.
5373 ///
5374 /// # Returns
5375 ///
5376 /// The session mode the agent is operating in
5377 ///
5378 /// <div class="warning">
5379 ///
5380 /// **Experimental.** This API is part of an experimental wire-protocol surface
5381 /// and may change or be removed in future SDK or CLI releases. Pin both the
5382 /// SDK and CLI versions if your code depends on it.
5383 ///
5384 /// </div>
5385 pub async fn get(&self) -> Result<SessionMode, Error> {
5386 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5387 let _value = self
5388 .session
5389 .client()
5390 .call(rpc_methods::SESSION_MODE_GET, Some(wire_params))
5391 .await?;
5392 Ok(serde_json::from_value(_value)?)
5393 }
5394
5395 /// Sets the current agent interaction mode.
5396 ///
5397 /// Wire method: `session.mode.set`.
5398 ///
5399 /// # Parameters
5400 ///
5401 /// * `params` - Agent interaction mode to apply to the session.
5402 ///
5403 /// <div class="warning">
5404 ///
5405 /// **Experimental.** This API is part of an experimental wire-protocol surface
5406 /// and may change or be removed in future SDK or CLI releases. Pin both the
5407 /// SDK and CLI versions if your code depends on it.
5408 ///
5409 /// </div>
5410 pub async fn set(&self, params: ModeSetRequest) -> Result<(), Error> {
5411 let mut wire_params = serde_json::to_value(params)?;
5412 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5413 let _value = self
5414 .session
5415 .client()
5416 .call(rpc_methods::SESSION_MODE_SET, Some(wire_params))
5417 .await?;
5418 Ok(())
5419 }
5420}
5421
5422/// `session.model.*` RPCs.
5423#[derive(Clone, Copy)]
5424pub struct SessionRpcModel<'a> {
5425 pub(crate) session: &'a Session,
5426}
5427
5428impl<'a> SessionRpcModel<'a> {
5429 /// Gets the currently selected model for the session.
5430 ///
5431 /// Wire method: `session.model.getCurrent`.
5432 ///
5433 /// # Returns
5434 ///
5435 /// 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.
5436 ///
5437 /// <div class="warning">
5438 ///
5439 /// **Experimental.** This API is part of an experimental wire-protocol surface
5440 /// and may change or be removed in future SDK or CLI releases. Pin both the
5441 /// SDK and CLI versions if your code depends on it.
5442 ///
5443 /// </div>
5444 pub async fn get_current(&self) -> Result<CurrentModel, Error> {
5445 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5446 let _value = self
5447 .session
5448 .client()
5449 .call(rpc_methods::SESSION_MODEL_GETCURRENT, Some(wire_params))
5450 .await?;
5451 Ok(serde_json::from_value(_value)?)
5452 }
5453
5454 /// Switches the session to a model and optional reasoning configuration.
5455 ///
5456 /// Wire method: `session.model.switchTo`.
5457 ///
5458 /// # Parameters
5459 ///
5460 /// * `params` - Target model identifier and optional reasoning effort, summary, capability overrides, and context tier.
5461 ///
5462 /// # Returns
5463 ///
5464 /// The model identifier active on the session after the switch.
5465 ///
5466 /// <div class="warning">
5467 ///
5468 /// **Experimental.** This API is part of an experimental wire-protocol surface
5469 /// and may change or be removed in future SDK or CLI releases. Pin both the
5470 /// SDK and CLI versions if your code depends on it.
5471 ///
5472 /// </div>
5473 pub async fn switch_to(
5474 &self,
5475 params: ModelSwitchToRequest,
5476 ) -> Result<ModelSwitchToResult, Error> {
5477 let mut wire_params = serde_json::to_value(params)?;
5478 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5479 let _value = self
5480 .session
5481 .client()
5482 .call(rpc_methods::SESSION_MODEL_SWITCHTO, Some(wire_params))
5483 .await?;
5484 Ok(serde_json::from_value(_value)?)
5485 }
5486
5487 /// Updates the session's reasoning effort without changing the selected model.
5488 ///
5489 /// Wire method: `session.model.setReasoningEffort`.
5490 ///
5491 /// # Parameters
5492 ///
5493 /// * `params` - Reasoning effort level to apply to the currently selected model.
5494 ///
5495 /// # Returns
5496 ///
5497 /// 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.
5498 ///
5499 /// <div class="warning">
5500 ///
5501 /// **Experimental.** This API is part of an experimental wire-protocol surface
5502 /// and may change or be removed in future SDK or CLI releases. Pin both the
5503 /// SDK and CLI versions if your code depends on it.
5504 ///
5505 /// </div>
5506 pub async fn set_reasoning_effort(
5507 &self,
5508 params: ModelSetReasoningEffortRequest,
5509 ) -> Result<ModelSetReasoningEffortResult, Error> {
5510 let mut wire_params = serde_json::to_value(params)?;
5511 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5512 let _value = self
5513 .session
5514 .client()
5515 .call(
5516 rpc_methods::SESSION_MODEL_SETREASONINGEFFORT,
5517 Some(wire_params),
5518 )
5519 .await?;
5520 Ok(serde_json::from_value(_value)?)
5521 }
5522
5523 /// 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.
5524 ///
5525 /// Wire method: `session.model.list`.
5526 ///
5527 /// # Returns
5528 ///
5529 /// The list of models available to this session.
5530 ///
5531 /// <div class="warning">
5532 ///
5533 /// **Experimental.** This API is part of an experimental wire-protocol surface
5534 /// and may change or be removed in future SDK or CLI releases. Pin both the
5535 /// SDK and CLI versions if your code depends on it.
5536 ///
5537 /// </div>
5538 pub async fn list(&self) -> Result<SessionModelList, Error> {
5539 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5540 let _value = self
5541 .session
5542 .client()
5543 .call(rpc_methods::SESSION_MODEL_LIST, Some(wire_params))
5544 .await?;
5545 Ok(serde_json::from_value(_value)?)
5546 }
5547
5548 /// 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.
5549 ///
5550 /// Wire method: `session.model.list`.
5551 ///
5552 /// # Parameters
5553 ///
5554 /// * `params` - Optional listing options.
5555 ///
5556 /// # Returns
5557 ///
5558 /// The list of models available to this session.
5559 ///
5560 /// <div class="warning">
5561 ///
5562 /// **Experimental.** This API is part of an experimental wire-protocol surface
5563 /// and may change or be removed in future SDK or CLI releases. Pin both the
5564 /// SDK and CLI versions if your code depends on it.
5565 ///
5566 /// </div>
5567 pub async fn list_with_params(
5568 &self,
5569 params: ModelListRequest,
5570 ) -> Result<SessionModelList, Error> {
5571 let mut wire_params = serde_json::to_value(params)?;
5572 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5573 let _value = self
5574 .session
5575 .client()
5576 .call(rpc_methods::SESSION_MODEL_LIST, Some(wire_params))
5577 .await?;
5578 Ok(serde_json::from_value(_value)?)
5579 }
5580}
5581
5582/// `session.name.*` RPCs.
5583#[derive(Clone, Copy)]
5584pub struct SessionRpcName<'a> {
5585 pub(crate) session: &'a Session,
5586}
5587
5588impl<'a> SessionRpcName<'a> {
5589 /// Gets the session's friendly name.
5590 ///
5591 /// Wire method: `session.name.get`.
5592 ///
5593 /// # Returns
5594 ///
5595 /// The session's friendly name, or null when not yet set.
5596 ///
5597 /// <div class="warning">
5598 ///
5599 /// **Experimental.** This API is part of an experimental wire-protocol surface
5600 /// and may change or be removed in future SDK or CLI releases. Pin both the
5601 /// SDK and CLI versions if your code depends on it.
5602 ///
5603 /// </div>
5604 pub async fn get(&self) -> Result<NameGetResult, Error> {
5605 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5606 let _value = self
5607 .session
5608 .client()
5609 .call(rpc_methods::SESSION_NAME_GET, Some(wire_params))
5610 .await?;
5611 Ok(serde_json::from_value(_value)?)
5612 }
5613
5614 /// Sets the session's friendly name.
5615 ///
5616 /// Wire method: `session.name.set`.
5617 ///
5618 /// # Parameters
5619 ///
5620 /// * `params` - New friendly name to apply to the session.
5621 ///
5622 /// <div class="warning">
5623 ///
5624 /// **Experimental.** This API is part of an experimental wire-protocol surface
5625 /// and may change or be removed in future SDK or CLI releases. Pin both the
5626 /// SDK and CLI versions if your code depends on it.
5627 ///
5628 /// </div>
5629 pub async fn set(&self, params: NameSetRequest) -> Result<(), Error> {
5630 let mut wire_params = serde_json::to_value(params)?;
5631 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5632 let _value = self
5633 .session
5634 .client()
5635 .call(rpc_methods::SESSION_NAME_SET, Some(wire_params))
5636 .await?;
5637 Ok(())
5638 }
5639
5640 /// Persists an auto-generated session summary as the session's name when no user-set name exists.
5641 ///
5642 /// Wire method: `session.name.setAuto`.
5643 ///
5644 /// # Parameters
5645 ///
5646 /// * `params` - Auto-generated session summary to apply as the session's name when no user-set name exists.
5647 ///
5648 /// # Returns
5649 ///
5650 /// Indicates whether the auto-generated summary was applied as the session's name.
5651 ///
5652 /// <div class="warning">
5653 ///
5654 /// **Experimental.** This API is part of an experimental wire-protocol surface
5655 /// and may change or be removed in future SDK or CLI releases. Pin both the
5656 /// SDK and CLI versions if your code depends on it.
5657 ///
5658 /// </div>
5659 pub async fn set_auto(&self, params: NameSetAutoRequest) -> Result<NameSetAutoResult, Error> {
5660 let mut wire_params = serde_json::to_value(params)?;
5661 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5662 let _value = self
5663 .session
5664 .client()
5665 .call(rpc_methods::SESSION_NAME_SETAUTO, Some(wire_params))
5666 .await?;
5667 Ok(serde_json::from_value(_value)?)
5668 }
5669}
5670
5671/// `session.options.*` RPCs.
5672#[derive(Clone, Copy)]
5673pub struct SessionRpcOptions<'a> {
5674 pub(crate) session: &'a Session,
5675}
5676
5677impl<'a> SessionRpcOptions<'a> {
5678 /// Patches the genuinely-mutable subset of session options.
5679 ///
5680 /// Wire method: `session.options.update`.
5681 ///
5682 /// # Parameters
5683 ///
5684 /// * `params` - Patch of mutable session options to apply to the running session.
5685 ///
5686 /// # Returns
5687 ///
5688 /// Indicates whether the session options patch was applied successfully.
5689 ///
5690 /// <div class="warning">
5691 ///
5692 /// **Experimental.** This API is part of an experimental wire-protocol surface
5693 /// and may change or be removed in future SDK or CLI releases. Pin both the
5694 /// SDK and CLI versions if your code depends on it.
5695 ///
5696 /// </div>
5697 pub async fn update(
5698 &self,
5699 params: SessionUpdateOptionsParams,
5700 ) -> Result<SessionUpdateOptionsResult, Error> {
5701 let mut wire_params = serde_json::to_value(params)?;
5702 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5703 let _value = self
5704 .session
5705 .client()
5706 .call(rpc_methods::SESSION_OPTIONS_UPDATE, Some(wire_params))
5707 .await?;
5708 Ok(serde_json::from_value(_value)?)
5709 }
5710}
5711
5712/// `session.permissions.*` RPCs.
5713#[derive(Clone, Copy)]
5714pub struct SessionRpcPermissions<'a> {
5715 pub(crate) session: &'a Session,
5716}
5717
5718impl<'a> SessionRpcPermissions<'a> {
5719 /// `session.permissions.folderTrust.*` sub-namespace.
5720 pub fn folder_trust(&self) -> SessionRpcPermissionsFolderTrust<'a> {
5721 SessionRpcPermissionsFolderTrust {
5722 session: self.session,
5723 }
5724 }
5725
5726 /// `session.permissions.locations.*` sub-namespace.
5727 pub fn locations(&self) -> SessionRpcPermissionsLocations<'a> {
5728 SessionRpcPermissionsLocations {
5729 session: self.session,
5730 }
5731 }
5732
5733 /// `session.permissions.paths.*` sub-namespace.
5734 pub fn paths(&self) -> SessionRpcPermissionsPaths<'a> {
5735 SessionRpcPermissionsPaths {
5736 session: self.session,
5737 }
5738 }
5739
5740 /// `session.permissions.urls.*` sub-namespace.
5741 pub fn urls(&self) -> SessionRpcPermissionsUrls<'a> {
5742 SessionRpcPermissionsUrls {
5743 session: self.session,
5744 }
5745 }
5746
5747 /// Replaces selected permission policy fields (rules, paths, URLs, exclusions, allow-all flags) on the session.
5748 ///
5749 /// Wire method: `session.permissions.configure`.
5750 ///
5751 /// # Parameters
5752 ///
5753 /// * `params` - Patch of permission policy fields to apply (omit a field to leave it unchanged).
5754 ///
5755 /// # Returns
5756 ///
5757 /// Indicates whether the operation succeeded.
5758 ///
5759 /// <div class="warning">
5760 ///
5761 /// **Experimental.** This API is part of an experimental wire-protocol surface
5762 /// and may change or be removed in future SDK or CLI releases. Pin both the
5763 /// SDK and CLI versions if your code depends on it.
5764 ///
5765 /// </div>
5766 pub async fn configure(
5767 &self,
5768 params: PermissionsConfigureParams,
5769 ) -> Result<PermissionsConfigureResult, Error> {
5770 let mut wire_params = serde_json::to_value(params)?;
5771 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5772 let _value = self
5773 .session
5774 .client()
5775 .call(
5776 rpc_methods::SESSION_PERMISSIONS_CONFIGURE,
5777 Some(wire_params),
5778 )
5779 .await?;
5780 Ok(serde_json::from_value(_value)?)
5781 }
5782
5783 /// Provides a decision for a pending tool permission request.
5784 ///
5785 /// Wire method: `session.permissions.handlePendingPermissionRequest`.
5786 ///
5787 /// # Parameters
5788 ///
5789 /// * `params` - Pending permission request ID and the decision to apply (approve/reject and scope).
5790 ///
5791 /// # Returns
5792 ///
5793 /// Indicates whether the permission decision was applied; false when the request was already resolved.
5794 ///
5795 /// <div class="warning">
5796 ///
5797 /// **Experimental.** This API is part of an experimental wire-protocol surface
5798 /// and may change or be removed in future SDK or CLI releases. Pin both the
5799 /// SDK and CLI versions if your code depends on it.
5800 ///
5801 /// </div>
5802 pub async fn handle_pending_permission_request(
5803 &self,
5804 params: PermissionDecisionRequest,
5805 ) -> Result<PermissionRequestResult, Error> {
5806 let mut wire_params = serde_json::to_value(params)?;
5807 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5808 let _value = self
5809 .session
5810 .client()
5811 .call(
5812 rpc_methods::SESSION_PERMISSIONS_HANDLEPENDINGPERMISSIONREQUEST,
5813 Some(wire_params),
5814 )
5815 .await?;
5816 Ok(serde_json::from_value(_value)?)
5817 }
5818
5819 /// Reconstructs the set of pending tool permission requests from the session's event history.
5820 ///
5821 /// Wire method: `session.permissions.pendingRequests`.
5822 ///
5823 /// # Returns
5824 ///
5825 /// List of pending permission requests reconstructed from event history.
5826 ///
5827 /// <div class="warning">
5828 ///
5829 /// **Experimental.** This API is part of an experimental wire-protocol surface
5830 /// and may change or be removed in future SDK or CLI releases. Pin both the
5831 /// SDK and CLI versions if your code depends on it.
5832 ///
5833 /// </div>
5834 pub async fn pending_requests(&self) -> Result<PendingPermissionRequestList, Error> {
5835 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5836 let _value = self
5837 .session
5838 .client()
5839 .call(
5840 rpc_methods::SESSION_PERMISSIONS_PENDINGREQUESTS,
5841 Some(wire_params),
5842 )
5843 .await?;
5844 Ok(serde_json::from_value(_value)?)
5845 }
5846
5847 /// Enables or disables automatic approval of tool permission requests for the session.
5848 ///
5849 /// Wire method: `session.permissions.setApproveAll`.
5850 ///
5851 /// # Parameters
5852 ///
5853 /// * `params` - Allow-all toggle for tool permission requests, with an optional telemetry source.
5854 ///
5855 /// # Returns
5856 ///
5857 /// Indicates whether the operation succeeded.
5858 ///
5859 /// <div class="warning">
5860 ///
5861 /// **Experimental.** This API is part of an experimental wire-protocol surface
5862 /// and may change or be removed in future SDK or CLI releases. Pin both the
5863 /// SDK and CLI versions if your code depends on it.
5864 ///
5865 /// </div>
5866 pub async fn set_approve_all(
5867 &self,
5868 params: PermissionsSetApproveAllRequest,
5869 ) -> Result<PermissionsSetApproveAllResult, Error> {
5870 let mut wire_params = serde_json::to_value(params)?;
5871 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5872 let _value = self
5873 .session
5874 .client()
5875 .call(
5876 rpc_methods::SESSION_PERMISSIONS_SETAPPROVEALL,
5877 Some(wire_params),
5878 )
5879 .await?;
5880 Ok(serde_json::from_value(_value)?)
5881 }
5882
5883 /// Sets the allow-all permission mode for the session. Used by attach-mode clients (e.g. LocalRpcSession's `/allow-all` forwarder) to flip the target session's permission state. The `on` mode swaps in unrestricted path and URL managers and emits `session.permissions_changed` on transition; the `auto` mode keeps normal prompt paths active while attaching LLM safety recommendations. 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.
5884 ///
5885 /// Wire method: `session.permissions.setAllowAll`.
5886 ///
5887 /// # Parameters
5888 ///
5889 /// * `params` - Allow-all mode to apply for the session.
5890 ///
5891 /// # Returns
5892 ///
5893 /// Indicates whether the operation succeeded and reports the post-mutation state.
5894 ///
5895 /// <div class="warning">
5896 ///
5897 /// **Experimental.** This API is part of an experimental wire-protocol surface
5898 /// and may change or be removed in future SDK or CLI releases. Pin both the
5899 /// SDK and CLI versions if your code depends on it.
5900 ///
5901 /// </div>
5902 pub async fn set_allow_all(
5903 &self,
5904 params: PermissionsSetAllowAllRequest,
5905 ) -> Result<AllowAllPermissionSetResult, Error> {
5906 let mut wire_params = serde_json::to_value(params)?;
5907 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5908 let _value = self
5909 .session
5910 .client()
5911 .call(
5912 rpc_methods::SESSION_PERMISSIONS_SETALLOWALL,
5913 Some(wire_params),
5914 )
5915 .await?;
5916 Ok(serde_json::from_value(_value)?)
5917 }
5918
5919 /// Returns the current allow-all permission mode for the session.
5920 ///
5921 /// Wire method: `session.permissions.getAllowAll`.
5922 ///
5923 /// # Returns
5924 ///
5925 /// Current allow-all permission mode.
5926 ///
5927 /// <div class="warning">
5928 ///
5929 /// **Experimental.** This API is part of an experimental wire-protocol surface
5930 /// and may change or be removed in future SDK or CLI releases. Pin both the
5931 /// SDK and CLI versions if your code depends on it.
5932 ///
5933 /// </div>
5934 pub async fn get_allow_all(&self) -> Result<AllowAllPermissionState, Error> {
5935 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5936 let _value = self
5937 .session
5938 .client()
5939 .call(
5940 rpc_methods::SESSION_PERMISSIONS_GETALLOWALL,
5941 Some(wire_params),
5942 )
5943 .await?;
5944 Ok(serde_json::from_value(_value)?)
5945 }
5946
5947 /// Adds or removes session-scoped or location-scoped permission rules.
5948 ///
5949 /// Wire method: `session.permissions.modifyRules`.
5950 ///
5951 /// # Parameters
5952 ///
5953 /// * `params` - Scope and add/remove instructions for modifying session- or location-scoped permission rules.
5954 ///
5955 /// # Returns
5956 ///
5957 /// Indicates whether the operation succeeded.
5958 ///
5959 /// <div class="warning">
5960 ///
5961 /// **Experimental.** This API is part of an experimental wire-protocol surface
5962 /// and may change or be removed in future SDK or CLI releases. Pin both the
5963 /// SDK and CLI versions if your code depends on it.
5964 ///
5965 /// </div>
5966 pub async fn modify_rules(
5967 &self,
5968 params: PermissionsModifyRulesParams,
5969 ) -> Result<PermissionsModifyRulesResult, Error> {
5970 let mut wire_params = serde_json::to_value(params)?;
5971 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5972 let _value = self
5973 .session
5974 .client()
5975 .call(
5976 rpc_methods::SESSION_PERMISSIONS_MODIFYRULES,
5977 Some(wire_params),
5978 )
5979 .await?;
5980 Ok(serde_json::from_value(_value)?)
5981 }
5982
5983 /// Sets whether the client wants permission prompts bridged into session events.
5984 ///
5985 /// Wire method: `session.permissions.setRequired`.
5986 ///
5987 /// # Parameters
5988 ///
5989 /// * `params` - Toggles whether permission prompts should be bridged into session events for this client.
5990 ///
5991 /// # Returns
5992 ///
5993 /// Indicates whether the operation succeeded.
5994 ///
5995 /// <div class="warning">
5996 ///
5997 /// **Experimental.** This API is part of an experimental wire-protocol surface
5998 /// and may change or be removed in future SDK or CLI releases. Pin both the
5999 /// SDK and CLI versions if your code depends on it.
6000 ///
6001 /// </div>
6002 pub async fn set_required(
6003 &self,
6004 params: PermissionsSetRequiredRequest,
6005 ) -> Result<PermissionsSetRequiredResult, Error> {
6006 let mut wire_params = serde_json::to_value(params)?;
6007 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6008 let _value = self
6009 .session
6010 .client()
6011 .call(
6012 rpc_methods::SESSION_PERMISSIONS_SETREQUIRED,
6013 Some(wire_params),
6014 )
6015 .await?;
6016 Ok(serde_json::from_value(_value)?)
6017 }
6018
6019 /// Clears session-scoped tool permission approvals.
6020 ///
6021 /// Wire method: `session.permissions.resetSessionApprovals`.
6022 ///
6023 /// # Returns
6024 ///
6025 /// Indicates whether the operation succeeded.
6026 ///
6027 /// <div class="warning">
6028 ///
6029 /// **Experimental.** This API is part of an experimental wire-protocol surface
6030 /// and may change or be removed in future SDK or CLI releases. Pin both the
6031 /// SDK and CLI versions if your code depends on it.
6032 ///
6033 /// </div>
6034 pub async fn reset_session_approvals(
6035 &self,
6036 ) -> Result<PermissionsResetSessionApprovalsResult, Error> {
6037 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6038 let _value = self
6039 .session
6040 .client()
6041 .call(
6042 rpc_methods::SESSION_PERMISSIONS_RESETSESSIONAPPROVALS,
6043 Some(wire_params),
6044 )
6045 .await?;
6046 Ok(serde_json::from_value(_value)?)
6047 }
6048
6049 /// Notifies the runtime that a permission prompt UI has been shown to the user.
6050 ///
6051 /// Wire method: `session.permissions.notifyPromptShown`.
6052 ///
6053 /// # Parameters
6054 ///
6055 /// * `params` - Notification payload describing the permission prompt that the client just rendered.
6056 ///
6057 /// # Returns
6058 ///
6059 /// Indicates whether the operation succeeded.
6060 ///
6061 /// <div class="warning">
6062 ///
6063 /// **Experimental.** This API is part of an experimental wire-protocol surface
6064 /// and may change or be removed in future SDK or CLI releases. Pin both the
6065 /// SDK and CLI versions if your code depends on it.
6066 ///
6067 /// </div>
6068 pub async fn notify_prompt_shown(
6069 &self,
6070 params: PermissionPromptShownNotification,
6071 ) -> Result<PermissionsNotifyPromptShownResult, Error> {
6072 let mut wire_params = serde_json::to_value(params)?;
6073 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6074 let _value = self
6075 .session
6076 .client()
6077 .call(
6078 rpc_methods::SESSION_PERMISSIONS_NOTIFYPROMPTSHOWN,
6079 Some(wire_params),
6080 )
6081 .await?;
6082 Ok(serde_json::from_value(_value)?)
6083 }
6084}
6085
6086/// `session.permissions.folderTrust.*` RPCs.
6087#[derive(Clone, Copy)]
6088pub struct SessionRpcPermissionsFolderTrust<'a> {
6089 pub(crate) session: &'a Session,
6090}
6091
6092impl<'a> SessionRpcPermissionsFolderTrust<'a> {
6093 /// Reports whether a folder is trusted according to the user's folder trust state.
6094 ///
6095 /// Wire method: `session.permissions.folderTrust.isTrusted`.
6096 ///
6097 /// # Parameters
6098 ///
6099 /// * `params` - Folder path to check for trust.
6100 ///
6101 /// # Returns
6102 ///
6103 /// Folder trust check result.
6104 ///
6105 /// <div class="warning">
6106 ///
6107 /// **Experimental.** This API is part of an experimental wire-protocol surface
6108 /// and may change or be removed in future SDK or CLI releases. Pin both the
6109 /// SDK and CLI versions if your code depends on it.
6110 ///
6111 /// </div>
6112 pub async fn is_trusted(
6113 &self,
6114 params: FolderTrustCheckParams,
6115 ) -> Result<FolderTrustCheckResult, Error> {
6116 let mut wire_params = serde_json::to_value(params)?;
6117 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6118 let _value = self
6119 .session
6120 .client()
6121 .call(
6122 rpc_methods::SESSION_PERMISSIONS_FOLDERTRUST_ISTRUSTED,
6123 Some(wire_params),
6124 )
6125 .await?;
6126 Ok(serde_json::from_value(_value)?)
6127 }
6128
6129 /// Adds a folder to the user's trusted folders list.
6130 ///
6131 /// Wire method: `session.permissions.folderTrust.addTrusted`.
6132 ///
6133 /// # Parameters
6134 ///
6135 /// * `params` - Folder path to add to trusted folders.
6136 ///
6137 /// # Returns
6138 ///
6139 /// Indicates whether the operation succeeded.
6140 ///
6141 /// <div class="warning">
6142 ///
6143 /// **Experimental.** This API is part of an experimental wire-protocol surface
6144 /// and may change or be removed in future SDK or CLI releases. Pin both the
6145 /// SDK and CLI versions if your code depends on it.
6146 ///
6147 /// </div>
6148 pub async fn add_trusted(
6149 &self,
6150 params: FolderTrustAddParams,
6151 ) -> Result<PermissionsFolderTrustAddTrustedResult, Error> {
6152 let mut wire_params = serde_json::to_value(params)?;
6153 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6154 let _value = self
6155 .session
6156 .client()
6157 .call(
6158 rpc_methods::SESSION_PERMISSIONS_FOLDERTRUST_ADDTRUSTED,
6159 Some(wire_params),
6160 )
6161 .await?;
6162 Ok(serde_json::from_value(_value)?)
6163 }
6164}
6165
6166/// `session.permissions.locations.*` RPCs.
6167#[derive(Clone, Copy)]
6168pub struct SessionRpcPermissionsLocations<'a> {
6169 pub(crate) session: &'a Session,
6170}
6171
6172impl<'a> SessionRpcPermissionsLocations<'a> {
6173 /// Resolves the permission location key and type for a working directory.
6174 ///
6175 /// Wire method: `session.permissions.locations.resolve`.
6176 ///
6177 /// # Parameters
6178 ///
6179 /// * `params` - Working directory to resolve into a location-permissions key.
6180 ///
6181 /// # Returns
6182 ///
6183 /// Resolved location-permissions key and type.
6184 ///
6185 /// <div class="warning">
6186 ///
6187 /// **Experimental.** This API is part of an experimental wire-protocol surface
6188 /// and may change or be removed in future SDK or CLI releases. Pin both the
6189 /// SDK and CLI versions if your code depends on it.
6190 ///
6191 /// </div>
6192 pub async fn resolve(
6193 &self,
6194 params: PermissionLocationResolveParams,
6195 ) -> Result<PermissionLocationResolveResult, Error> {
6196 let mut wire_params = serde_json::to_value(params)?;
6197 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6198 let _value = self
6199 .session
6200 .client()
6201 .call(
6202 rpc_methods::SESSION_PERMISSIONS_LOCATIONS_RESOLVE,
6203 Some(wire_params),
6204 )
6205 .await?;
6206 Ok(serde_json::from_value(_value)?)
6207 }
6208
6209 /// Applies persisted location-scoped tool approvals and allowed directories for a working directory to this session's permission service.
6210 ///
6211 /// Wire method: `session.permissions.locations.apply`.
6212 ///
6213 /// # Parameters
6214 ///
6215 /// * `params` - Working directory to load persisted location permissions for.
6216 ///
6217 /// # Returns
6218 ///
6219 /// Summary of persisted location permissions applied to the session.
6220 ///
6221 /// <div class="warning">
6222 ///
6223 /// **Experimental.** This API is part of an experimental wire-protocol surface
6224 /// and may change or be removed in future SDK or CLI releases. Pin both the
6225 /// SDK and CLI versions if your code depends on it.
6226 ///
6227 /// </div>
6228 pub async fn apply(
6229 &self,
6230 params: PermissionLocationApplyParams,
6231 ) -> Result<PermissionLocationApplyResult, Error> {
6232 let mut wire_params = serde_json::to_value(params)?;
6233 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6234 let _value = self
6235 .session
6236 .client()
6237 .call(
6238 rpc_methods::SESSION_PERMISSIONS_LOCATIONS_APPLY,
6239 Some(wire_params),
6240 )
6241 .await?;
6242 Ok(serde_json::from_value(_value)?)
6243 }
6244
6245 /// Persists a tool approval for a permission location and applies its rules to this session's live permission service.
6246 ///
6247 /// Wire method: `session.permissions.locations.addToolApproval`.
6248 ///
6249 /// # Parameters
6250 ///
6251 /// * `params` - Location-scoped tool approval to persist.
6252 ///
6253 /// # Returns
6254 ///
6255 /// Indicates whether the operation succeeded.
6256 ///
6257 /// <div class="warning">
6258 ///
6259 /// **Experimental.** This API is part of an experimental wire-protocol surface
6260 /// and may change or be removed in future SDK or CLI releases. Pin both the
6261 /// SDK and CLI versions if your code depends on it.
6262 ///
6263 /// </div>
6264 pub async fn add_tool_approval(
6265 &self,
6266 params: PermissionLocationAddToolApprovalParams,
6267 ) -> Result<PermissionsLocationsAddToolApprovalResult, Error> {
6268 let mut wire_params = serde_json::to_value(params)?;
6269 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6270 let _value = self
6271 .session
6272 .client()
6273 .call(
6274 rpc_methods::SESSION_PERMISSIONS_LOCATIONS_ADDTOOLAPPROVAL,
6275 Some(wire_params),
6276 )
6277 .await?;
6278 Ok(serde_json::from_value(_value)?)
6279 }
6280}
6281
6282/// `session.permissions.paths.*` RPCs.
6283#[derive(Clone, Copy)]
6284pub struct SessionRpcPermissionsPaths<'a> {
6285 pub(crate) session: &'a Session,
6286}
6287
6288impl<'a> SessionRpcPermissionsPaths<'a> {
6289 /// Returns the session's allowed directories and primary working directory.
6290 ///
6291 /// Wire method: `session.permissions.paths.list`.
6292 ///
6293 /// # Returns
6294 ///
6295 /// Snapshot of the session's allow-listed directories and primary working directory.
6296 ///
6297 /// <div class="warning">
6298 ///
6299 /// **Experimental.** This API is part of an experimental wire-protocol surface
6300 /// and may change or be removed in future SDK or CLI releases. Pin both the
6301 /// SDK and CLI versions if your code depends on it.
6302 ///
6303 /// </div>
6304 pub async fn list(&self) -> Result<PermissionPathsList, Error> {
6305 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6306 let _value = self
6307 .session
6308 .client()
6309 .call(
6310 rpc_methods::SESSION_PERMISSIONS_PATHS_LIST,
6311 Some(wire_params),
6312 )
6313 .await?;
6314 Ok(serde_json::from_value(_value)?)
6315 }
6316
6317 /// Adds a directory to the session's allow-list.
6318 ///
6319 /// Wire method: `session.permissions.paths.add`.
6320 ///
6321 /// # Parameters
6322 ///
6323 /// * `params` - Directory path to add to the session's allowed directories.
6324 ///
6325 /// # Returns
6326 ///
6327 /// Indicates whether the operation succeeded.
6328 ///
6329 /// <div class="warning">
6330 ///
6331 /// **Experimental.** This API is part of an experimental wire-protocol surface
6332 /// and may change or be removed in future SDK or CLI releases. Pin both the
6333 /// SDK and CLI versions if your code depends on it.
6334 ///
6335 /// </div>
6336 pub async fn add(
6337 &self,
6338 params: PermissionPathsAddParams,
6339 ) -> Result<PermissionsPathsAddResult, Error> {
6340 let mut wire_params = serde_json::to_value(params)?;
6341 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6342 let _value = self
6343 .session
6344 .client()
6345 .call(
6346 rpc_methods::SESSION_PERMISSIONS_PATHS_ADD,
6347 Some(wire_params),
6348 )
6349 .await?;
6350 Ok(serde_json::from_value(_value)?)
6351 }
6352
6353 /// Updates the session's primary working directory used by the permission policy.
6354 ///
6355 /// Wire method: `session.permissions.paths.updatePrimary`.
6356 ///
6357 /// # Parameters
6358 ///
6359 /// * `params` - Directory path to set as the session's new primary working directory.
6360 ///
6361 /// # Returns
6362 ///
6363 /// Indicates whether the operation succeeded.
6364 ///
6365 /// <div class="warning">
6366 ///
6367 /// **Experimental.** This API is part of an experimental wire-protocol surface
6368 /// and may change or be removed in future SDK or CLI releases. Pin both the
6369 /// SDK and CLI versions if your code depends on it.
6370 ///
6371 /// </div>
6372 pub async fn update_primary(
6373 &self,
6374 params: PermissionPathsUpdatePrimaryParams,
6375 ) -> Result<PermissionsPathsUpdatePrimaryResult, Error> {
6376 let mut wire_params = serde_json::to_value(params)?;
6377 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6378 let _value = self
6379 .session
6380 .client()
6381 .call(
6382 rpc_methods::SESSION_PERMISSIONS_PATHS_UPDATEPRIMARY,
6383 Some(wire_params),
6384 )
6385 .await?;
6386 Ok(serde_json::from_value(_value)?)
6387 }
6388
6389 /// Reports whether a path falls within any of the session's allowed directories.
6390 ///
6391 /// Wire method: `session.permissions.paths.isPathWithinAllowedDirectories`.
6392 ///
6393 /// # Parameters
6394 ///
6395 /// * `params` - Path to evaluate against the session's allowed directories.
6396 ///
6397 /// # Returns
6398 ///
6399 /// Indicates whether the supplied path is within the session's allowed directories.
6400 ///
6401 /// <div class="warning">
6402 ///
6403 /// **Experimental.** This API is part of an experimental wire-protocol surface
6404 /// and may change or be removed in future SDK or CLI releases. Pin both the
6405 /// SDK and CLI versions if your code depends on it.
6406 ///
6407 /// </div>
6408 pub async fn is_path_within_allowed_directories(
6409 &self,
6410 params: PermissionPathsAllowedCheckParams,
6411 ) -> Result<PermissionPathsAllowedCheckResult, Error> {
6412 let mut wire_params = serde_json::to_value(params)?;
6413 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6414 let _value = self
6415 .session
6416 .client()
6417 .call(
6418 rpc_methods::SESSION_PERMISSIONS_PATHS_ISPATHWITHINALLOWEDDIRECTORIES,
6419 Some(wire_params),
6420 )
6421 .await?;
6422 Ok(serde_json::from_value(_value)?)
6423 }
6424
6425 /// Reports whether a path falls within the session's workspace (primary) directory.
6426 ///
6427 /// Wire method: `session.permissions.paths.isPathWithinWorkspace`.
6428 ///
6429 /// # Parameters
6430 ///
6431 /// * `params` - Path to evaluate against the session's workspace (primary) directory.
6432 ///
6433 /// # Returns
6434 ///
6435 /// Indicates whether the supplied path is within the session's workspace directory.
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 is_path_within_workspace(
6445 &self,
6446 params: PermissionPathsWorkspaceCheckParams,
6447 ) -> Result<PermissionPathsWorkspaceCheckResult, Error> {
6448 let mut wire_params = serde_json::to_value(params)?;
6449 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6450 let _value = self
6451 .session
6452 .client()
6453 .call(
6454 rpc_methods::SESSION_PERMISSIONS_PATHS_ISPATHWITHINWORKSPACE,
6455 Some(wire_params),
6456 )
6457 .await?;
6458 Ok(serde_json::from_value(_value)?)
6459 }
6460}
6461
6462/// `session.permissions.urls.*` RPCs.
6463#[derive(Clone, Copy)]
6464pub struct SessionRpcPermissionsUrls<'a> {
6465 pub(crate) session: &'a Session,
6466}
6467
6468impl<'a> SessionRpcPermissionsUrls<'a> {
6469 /// Toggles the runtime's URL-permission policy between unrestricted and restricted modes.
6470 ///
6471 /// Wire method: `session.permissions.urls.setUnrestrictedMode`.
6472 ///
6473 /// # Parameters
6474 ///
6475 /// * `params` - Whether the URL-permission policy should run in unrestricted mode.
6476 ///
6477 /// # Returns
6478 ///
6479 /// Indicates whether the operation succeeded.
6480 ///
6481 /// <div class="warning">
6482 ///
6483 /// **Experimental.** This API is part of an experimental wire-protocol surface
6484 /// and may change or be removed in future SDK or CLI releases. Pin both the
6485 /// SDK and CLI versions if your code depends on it.
6486 ///
6487 /// </div>
6488 pub async fn set_unrestricted_mode(
6489 &self,
6490 params: PermissionUrlsSetUnrestrictedModeParams,
6491 ) -> Result<PermissionsUrlsSetUnrestrictedModeResult, Error> {
6492 let mut wire_params = serde_json::to_value(params)?;
6493 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6494 let _value = self
6495 .session
6496 .client()
6497 .call(
6498 rpc_methods::SESSION_PERMISSIONS_URLS_SETUNRESTRICTEDMODE,
6499 Some(wire_params),
6500 )
6501 .await?;
6502 Ok(serde_json::from_value(_value)?)
6503 }
6504}
6505
6506/// `session.plan.*` RPCs.
6507#[derive(Clone, Copy)]
6508pub struct SessionRpcPlan<'a> {
6509 pub(crate) session: &'a Session,
6510}
6511
6512impl<'a> SessionRpcPlan<'a> {
6513 /// Reads the session plan file from the workspace.
6514 ///
6515 /// Wire method: `session.plan.read`.
6516 ///
6517 /// # Returns
6518 ///
6519 /// Existence, contents, and resolved path of the session plan file.
6520 ///
6521 /// <div class="warning">
6522 ///
6523 /// **Experimental.** This API is part of an experimental wire-protocol surface
6524 /// and may change or be removed in future SDK or CLI releases. Pin both the
6525 /// SDK and CLI versions if your code depends on it.
6526 ///
6527 /// </div>
6528 pub async fn read(&self) -> Result<PlanReadResult, Error> {
6529 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6530 let _value = self
6531 .session
6532 .client()
6533 .call(rpc_methods::SESSION_PLAN_READ, Some(wire_params))
6534 .await?;
6535 Ok(serde_json::from_value(_value)?)
6536 }
6537
6538 /// Writes new content to the session plan file.
6539 ///
6540 /// Wire method: `session.plan.update`.
6541 ///
6542 /// # Parameters
6543 ///
6544 /// * `params` - Replacement contents to write to the session plan file.
6545 ///
6546 /// <div class="warning">
6547 ///
6548 /// **Experimental.** This API is part of an experimental wire-protocol surface
6549 /// and may change or be removed in future SDK or CLI releases. Pin both the
6550 /// SDK and CLI versions if your code depends on it.
6551 ///
6552 /// </div>
6553 pub async fn update(&self, params: PlanUpdateRequest) -> Result<(), Error> {
6554 let mut wire_params = serde_json::to_value(params)?;
6555 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6556 let _value = self
6557 .session
6558 .client()
6559 .call(rpc_methods::SESSION_PLAN_UPDATE, Some(wire_params))
6560 .await?;
6561 Ok(())
6562 }
6563
6564 /// Deletes the session plan file from the workspace.
6565 ///
6566 /// Wire method: `session.plan.delete`.
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 delete(&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_PLAN_DELETE, Some(wire_params))
6581 .await?;
6582 Ok(())
6583 }
6584
6585 /// Reads todo rows from the session SQL database for plan rendering.
6586 ///
6587 /// Wire method: `session.plan.readSqlTodos`.
6588 ///
6589 /// # Returns
6590 ///
6591 /// Todo rows read from the session SQL database. Empty when no session database is available.
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 read_sql_todos(&self) -> Result<PlanReadSqlTodosResult, Error> {
6601 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6602 let _value = self
6603 .session
6604 .client()
6605 .call(rpc_methods::SESSION_PLAN_READSQLTODOS, Some(wire_params))
6606 .await?;
6607 Ok(serde_json::from_value(_value)?)
6608 }
6609
6610 /// 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.
6611 ///
6612 /// Wire method: `session.plan.readSqlTodosWithDependencies`.
6613 ///
6614 /// # Returns
6615 ///
6616 /// Todo rows + dependency edges read from the session SQL database.
6617 ///
6618 /// <div class="warning">
6619 ///
6620 /// **Experimental.** This API is part of an experimental wire-protocol surface
6621 /// and may change or be removed in future SDK or CLI releases. Pin both the
6622 /// SDK and CLI versions if your code depends on it.
6623 ///
6624 /// </div>
6625 pub async fn read_sql_todos_with_dependencies(
6626 &self,
6627 ) -> Result<PlanReadSqlTodosWithDependenciesResult, Error> {
6628 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6629 let _value = self
6630 .session
6631 .client()
6632 .call(
6633 rpc_methods::SESSION_PLAN_READSQLTODOSWITHDEPENDENCIES,
6634 Some(wire_params),
6635 )
6636 .await?;
6637 Ok(serde_json::from_value(_value)?)
6638 }
6639}
6640
6641/// `session.plugins.*` RPCs.
6642#[derive(Clone, Copy)]
6643pub struct SessionRpcPlugins<'a> {
6644 pub(crate) session: &'a Session,
6645}
6646
6647impl<'a> SessionRpcPlugins<'a> {
6648 /// Lists plugins installed for the session.
6649 ///
6650 /// Wire method: `session.plugins.list`.
6651 ///
6652 /// # Returns
6653 ///
6654 /// Plugins installed for the session, with their enabled state and version metadata.
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 list(&self) -> Result<PluginList, Error> {
6664 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6665 let _value = self
6666 .session
6667 .client()
6668 .call(rpc_methods::SESSION_PLUGINS_LIST, Some(wire_params))
6669 .await?;
6670 Ok(serde_json::from_value(_value)?)
6671 }
6672
6673 /// 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.
6674 ///
6675 /// Wire method: `session.plugins.reload`.
6676 ///
6677 /// <div class="warning">
6678 ///
6679 /// **Experimental.** This API is part of an experimental wire-protocol surface
6680 /// and may change or be removed in future SDK or CLI releases. Pin both the
6681 /// SDK and CLI versions if your code depends on it.
6682 ///
6683 /// </div>
6684 pub async fn reload(&self) -> Result<(), Error> {
6685 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6686 let _value = self
6687 .session
6688 .client()
6689 .call(rpc_methods::SESSION_PLUGINS_RELOAD, Some(wire_params))
6690 .await?;
6691 Ok(())
6692 }
6693
6694 /// 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.
6695 ///
6696 /// Wire method: `session.plugins.reload`.
6697 ///
6698 /// # Parameters
6699 ///
6700 /// * `params` - Optional flags controlling which side effects the reload performs.
6701 ///
6702 /// <div class="warning">
6703 ///
6704 /// **Experimental.** This API is part of an experimental wire-protocol surface
6705 /// and may change or be removed in future SDK or CLI releases. Pin both the
6706 /// SDK and CLI versions if your code depends on it.
6707 ///
6708 /// </div>
6709 pub async fn reload_with_params(&self, params: PluginsReloadRequest) -> Result<(), Error> {
6710 let mut wire_params = serde_json::to_value(params)?;
6711 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6712 let _value = self
6713 .session
6714 .client()
6715 .call(rpc_methods::SESSION_PLUGINS_RELOAD, Some(wire_params))
6716 .await?;
6717 Ok(())
6718 }
6719}
6720
6721/// `session.provider.*` RPCs.
6722#[derive(Clone, Copy)]
6723pub struct SessionRpcProvider<'a> {
6724 pub(crate) session: &'a Session,
6725}
6726
6727impl<'a> SessionRpcProvider<'a> {
6728 /// 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.
6729 ///
6730 /// Wire method: `session.provider.getEndpoint`.
6731 ///
6732 /// # Returns
6733 ///
6734 /// A snapshot of the provider endpoint the session is currently configured to talk to.
6735 ///
6736 /// <div class="warning">
6737 ///
6738 /// **Experimental.** This API is part of an experimental wire-protocol surface
6739 /// and may change or be removed in future SDK or CLI releases. Pin both the
6740 /// SDK and CLI versions if your code depends on it.
6741 ///
6742 /// </div>
6743 pub async fn get_endpoint(&self) -> Result<ProviderEndpoint, Error> {
6744 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6745 let _value = self
6746 .session
6747 .client()
6748 .call(rpc_methods::SESSION_PROVIDER_GETENDPOINT, Some(wire_params))
6749 .await?;
6750 Ok(serde_json::from_value(_value)?)
6751 }
6752
6753 /// 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.
6754 ///
6755 /// Wire method: `session.provider.getEndpoint`.
6756 ///
6757 /// # Parameters
6758 ///
6759 /// * `params` - Optional model identifier to scope the endpoint snapshot to.
6760 ///
6761 /// # Returns
6762 ///
6763 /// A snapshot of the provider endpoint the session is currently configured to talk to.
6764 ///
6765 /// <div class="warning">
6766 ///
6767 /// **Experimental.** This API is part of an experimental wire-protocol surface
6768 /// and may change or be removed in future SDK or CLI releases. Pin both the
6769 /// SDK and CLI versions if your code depends on it.
6770 ///
6771 /// </div>
6772 pub async fn get_endpoint_with_params(
6773 &self,
6774 params: ProviderGetEndpointRequest,
6775 ) -> Result<ProviderEndpoint, Error> {
6776 let mut wire_params = serde_json::to_value(params)?;
6777 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6778 let _value = self
6779 .session
6780 .client()
6781 .call(rpc_methods::SESSION_PROVIDER_GETENDPOINT, Some(wire_params))
6782 .await?;
6783 Ok(serde_json::from_value(_value)?)
6784 }
6785
6786 /// 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.
6787 ///
6788 /// Wire method: `session.provider.add`.
6789 ///
6790 /// # Parameters
6791 ///
6792 /// * `params` - BYOK providers and/or models to add to the session's registry at runtime. Both fields are optional; provide providers, models, or both.
6793 ///
6794 /// # Returns
6795 ///
6796 /// The selectable model entries synthesized for the models added by this call.
6797 ///
6798 /// <div class="warning">
6799 ///
6800 /// **Experimental.** This API is part of an experimental wire-protocol surface
6801 /// and may change or be removed in future SDK or CLI releases. Pin both the
6802 /// SDK and CLI versions if your code depends on it.
6803 ///
6804 /// </div>
6805 pub async fn add(&self, params: ProviderAddRequest) -> Result<ProviderAddResult, Error> {
6806 let mut wire_params = serde_json::to_value(params)?;
6807 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6808 let _value = self
6809 .session
6810 .client()
6811 .call(rpc_methods::SESSION_PROVIDER_ADD, Some(wire_params))
6812 .await?;
6813 Ok(serde_json::from_value(_value)?)
6814 }
6815}
6816
6817/// `session.queue.*` RPCs.
6818#[derive(Clone, Copy)]
6819pub struct SessionRpcQueue<'a> {
6820 pub(crate) session: &'a Session,
6821}
6822
6823impl<'a> SessionRpcQueue<'a> {
6824 /// Returns the local session's pending user-facing queued items and steering messages.
6825 ///
6826 /// Wire method: `session.queue.pendingItems`.
6827 ///
6828 /// # Returns
6829 ///
6830 /// Snapshot of the session's pending queued items and immediate-steering messages.
6831 ///
6832 /// <div class="warning">
6833 ///
6834 /// **Experimental.** This API is part of an experimental wire-protocol surface
6835 /// and may change or be removed in future SDK or CLI releases. Pin both the
6836 /// SDK and CLI versions if your code depends on it.
6837 ///
6838 /// </div>
6839 pub async fn pending_items(&self) -> Result<QueuePendingItemsResult, Error> {
6840 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6841 let _value = self
6842 .session
6843 .client()
6844 .call(rpc_methods::SESSION_QUEUE_PENDINGITEMS, Some(wire_params))
6845 .await?;
6846 Ok(serde_json::from_value(_value)?)
6847 }
6848
6849 /// Removes the most recently queued user-facing item (LIFO).
6850 ///
6851 /// Wire method: `session.queue.removeMostRecent`.
6852 ///
6853 /// # Returns
6854 ///
6855 /// Indicates whether a user-facing pending item was removed.
6856 ///
6857 /// <div class="warning">
6858 ///
6859 /// **Experimental.** This API is part of an experimental wire-protocol surface
6860 /// and may change or be removed in future SDK or CLI releases. Pin both the
6861 /// SDK and CLI versions if your code depends on it.
6862 ///
6863 /// </div>
6864 pub async fn remove_most_recent(&self) -> Result<QueueRemoveMostRecentResult, Error> {
6865 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6866 let _value = self
6867 .session
6868 .client()
6869 .call(
6870 rpc_methods::SESSION_QUEUE_REMOVEMOSTRECENT,
6871 Some(wire_params),
6872 )
6873 .await?;
6874 Ok(serde_json::from_value(_value)?)
6875 }
6876
6877 /// Clears all pending queued items on the local session.
6878 ///
6879 /// Wire method: `session.queue.clear`.
6880 ///
6881 /// <div class="warning">
6882 ///
6883 /// **Experimental.** This API is part of an experimental wire-protocol surface
6884 /// and may change or be removed in future SDK or CLI releases. Pin both the
6885 /// SDK and CLI versions if your code depends on it.
6886 ///
6887 /// </div>
6888 pub async fn clear(&self) -> Result<(), Error> {
6889 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6890 let _value = self
6891 .session
6892 .client()
6893 .call(rpc_methods::SESSION_QUEUE_CLEAR, Some(wire_params))
6894 .await?;
6895 Ok(())
6896 }
6897}
6898
6899/// `session.remote.*` RPCs.
6900#[derive(Clone, Copy)]
6901pub struct SessionRpcRemote<'a> {
6902 pub(crate) session: &'a Session,
6903}
6904
6905impl<'a> SessionRpcRemote<'a> {
6906 /// Enables remote session export or steering.
6907 ///
6908 /// Wire method: `session.remote.enable`.
6909 ///
6910 /// # Parameters
6911 ///
6912 /// * `params` - Optional remote session mode ("off", "export", or "on"); defaults to enabling both export and remote steering.
6913 ///
6914 /// # Returns
6915 ///
6916 /// GitHub URL for the session and a flag indicating whether remote steering is enabled.
6917 ///
6918 /// <div class="warning">
6919 ///
6920 /// **Experimental.** This API is part of an experimental wire-protocol surface
6921 /// and may change or be removed in future SDK or CLI releases. Pin both the
6922 /// SDK and CLI versions if your code depends on it.
6923 ///
6924 /// </div>
6925 pub async fn enable(&self, params: RemoteEnableRequest) -> Result<RemoteEnableResult, Error> {
6926 let mut wire_params = serde_json::to_value(params)?;
6927 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6928 let _value = self
6929 .session
6930 .client()
6931 .call(rpc_methods::SESSION_REMOTE_ENABLE, Some(wire_params))
6932 .await?;
6933 Ok(serde_json::from_value(_value)?)
6934 }
6935
6936 /// Disables remote session export and steering.
6937 ///
6938 /// Wire method: `session.remote.disable`.
6939 ///
6940 /// <div class="warning">
6941 ///
6942 /// **Experimental.** This API is part of an experimental wire-protocol surface
6943 /// and may change or be removed in future SDK or CLI releases. Pin both the
6944 /// SDK and CLI versions if your code depends on it.
6945 ///
6946 /// </div>
6947 pub async fn disable(&self) -> Result<(), Error> {
6948 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6949 let _value = self
6950 .session
6951 .client()
6952 .call(rpc_methods::SESSION_REMOTE_DISABLE, Some(wire_params))
6953 .await?;
6954 Ok(())
6955 }
6956
6957 /// Persists a remote-steerability change emitted by the host as a session event.
6958 ///
6959 /// Wire method: `session.remote.notifySteerableChanged`.
6960 ///
6961 /// # Parameters
6962 ///
6963 /// * `params` - New remote-steerability state to persist as a `session.remote_steerable_changed` event.
6964 ///
6965 /// # Returns
6966 ///
6967 /// 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.
6968 ///
6969 /// <div class="warning">
6970 ///
6971 /// **Experimental.** This API is part of an experimental wire-protocol surface
6972 /// and may change or be removed in future SDK or CLI releases. Pin both the
6973 /// SDK and CLI versions if your code depends on it.
6974 ///
6975 /// </div>
6976 pub async fn notify_steerable_changed(
6977 &self,
6978 params: RemoteNotifySteerableChangedRequest,
6979 ) -> Result<RemoteNotifySteerableChangedResult, Error> {
6980 let mut wire_params = serde_json::to_value(params)?;
6981 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6982 let _value = self
6983 .session
6984 .client()
6985 .call(
6986 rpc_methods::SESSION_REMOTE_NOTIFYSTEERABLECHANGED,
6987 Some(wire_params),
6988 )
6989 .await?;
6990 Ok(serde_json::from_value(_value)?)
6991 }
6992}
6993
6994/// `session.schedule.*` RPCs.
6995#[derive(Clone, Copy)]
6996pub struct SessionRpcSchedule<'a> {
6997 pub(crate) session: &'a Session,
6998}
6999
7000impl<'a> SessionRpcSchedule<'a> {
7001 /// Lists the session's currently active scheduled prompts.
7002 ///
7003 /// Wire method: `session.schedule.list`.
7004 ///
7005 /// # Returns
7006 ///
7007 /// Snapshot of the currently active recurring prompts for this session.
7008 ///
7009 /// <div class="warning">
7010 ///
7011 /// **Experimental.** This API is part of an experimental wire-protocol surface
7012 /// and may change or be removed in future SDK or CLI releases. Pin both the
7013 /// SDK and CLI versions if your code depends on it.
7014 ///
7015 /// </div>
7016 pub async fn list(&self) -> Result<ScheduleList, Error> {
7017 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7018 let _value = self
7019 .session
7020 .client()
7021 .call(rpc_methods::SESSION_SCHEDULE_LIST, Some(wire_params))
7022 .await?;
7023 Ok(serde_json::from_value(_value)?)
7024 }
7025
7026 /// Removes a scheduled prompt by id.
7027 ///
7028 /// Wire method: `session.schedule.stop`.
7029 ///
7030 /// # Parameters
7031 ///
7032 /// * `params` - Identifier of the scheduled prompt to remove.
7033 ///
7034 /// # Returns
7035 ///
7036 /// Remove a scheduled prompt by id. The result entry is omitted if the id was unknown.
7037 ///
7038 /// <div class="warning">
7039 ///
7040 /// **Experimental.** This API is part of an experimental wire-protocol surface
7041 /// and may change or be removed in future SDK or CLI releases. Pin both the
7042 /// SDK and CLI versions if your code depends on it.
7043 ///
7044 /// </div>
7045 pub async fn stop(&self, params: ScheduleStopRequest) -> Result<ScheduleStopResult, Error> {
7046 let mut wire_params = serde_json::to_value(params)?;
7047 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7048 let _value = self
7049 .session
7050 .client()
7051 .call(rpc_methods::SESSION_SCHEDULE_STOP, Some(wire_params))
7052 .await?;
7053 Ok(serde_json::from_value(_value)?)
7054 }
7055}
7056
7057/// `session.settings.*` RPCs.
7058#[derive(Clone, Copy)]
7059pub struct SessionRpcSettings<'a> {
7060 pub(crate) session: &'a Session,
7061}
7062
7063impl<'a> SessionRpcSettings<'a> {
7064 /// Returns a redacted snapshot of session runtime settings, with secrets and raw feature flags excluded. Internal: the runtime settings shape is a runtime-internal surface and is deliberately kept out of the public SDK, because consumers should not depend on the runtime's internal settings layout. It remains callable in-process and is expected to be reworked as the runtime internals are consolidated.
7065 ///
7066 /// Wire method: `session.settings.snapshot`.
7067 ///
7068 /// # Returns
7069 ///
7070 /// Redacted, serializable view of session runtime settings for SDK boundary consumers. Secrets and raw feature flags are intentionally excluded.
7071 ///
7072 /// <div class="warning">
7073 ///
7074 /// **Experimental.** This API is part of an experimental wire-protocol surface
7075 /// and may change or be removed in future SDK or CLI releases. Pin both the
7076 /// SDK and CLI versions if your code depends on it.
7077 ///
7078 /// </div>
7079 pub(crate) async fn snapshot(&self) -> Result<SessionSettingsSnapshot, Error> {
7080 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7081 let _value = self
7082 .session
7083 .client()
7084 .call(rpc_methods::SESSION_SETTINGS_SNAPSHOT, Some(wire_params))
7085 .await?;
7086 Ok(serde_json::from_value(_value)?)
7087 }
7088
7089 /// Evaluates a named Rust-owned settings predicate without exposing raw feature flags. Internal: the raw feature-flag names and composition are runtime-internal, so this predicate-evaluation helper is kept out of the public SDK surface and is callable in-process only.
7090 ///
7091 /// Wire method: `session.settings.evaluatePredicate`.
7092 ///
7093 /// # Parameters
7094 ///
7095 /// * `params` - Named Rust-owned settings predicate to evaluate for this session.
7096 ///
7097 /// # Returns
7098 ///
7099 /// Result of evaluating a Rust-owned settings predicate.
7100 ///
7101 /// <div class="warning">
7102 ///
7103 /// **Experimental.** This API is part of an experimental wire-protocol surface
7104 /// and may change or be removed in future SDK or CLI releases. Pin both the
7105 /// SDK and CLI versions if your code depends on it.
7106 ///
7107 /// </div>
7108 pub(crate) async fn evaluate_predicate(
7109 &self,
7110 params: SessionSettingsEvaluatePredicateRequest,
7111 ) -> Result<SessionSettingsEvaluatePredicateResult, Error> {
7112 let mut wire_params = serde_json::to_value(params)?;
7113 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7114 let _value = self
7115 .session
7116 .client()
7117 .call(
7118 rpc_methods::SESSION_SETTINGS_EVALUATEPREDICATE,
7119 Some(wire_params),
7120 )
7121 .await?;
7122 Ok(serde_json::from_value(_value)?)
7123 }
7124}
7125
7126/// `session.shell.*` RPCs.
7127#[derive(Clone, Copy)]
7128pub struct SessionRpcShell<'a> {
7129 pub(crate) session: &'a Session,
7130}
7131
7132impl<'a> SessionRpcShell<'a> {
7133 /// Starts a shell command and streams output through session notifications.
7134 ///
7135 /// Wire method: `session.shell.exec`.
7136 ///
7137 /// # Parameters
7138 ///
7139 /// * `params` - Shell command to run, with optional working directory and timeout in milliseconds.
7140 ///
7141 /// # Returns
7142 ///
7143 /// Identifier of the spawned process, used to correlate streamed output and exit notifications.
7144 ///
7145 /// <div class="warning">
7146 ///
7147 /// **Experimental.** This API is part of an experimental wire-protocol surface
7148 /// and may change or be removed in future SDK or CLI releases. Pin both the
7149 /// SDK and CLI versions if your code depends on it.
7150 ///
7151 /// </div>
7152 pub async fn exec(&self, params: ShellExecRequest) -> Result<ShellExecResult, Error> {
7153 let mut wire_params = serde_json::to_value(params)?;
7154 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7155 let _value = self
7156 .session
7157 .client()
7158 .call(rpc_methods::SESSION_SHELL_EXEC, Some(wire_params))
7159 .await?;
7160 Ok(serde_json::from_value(_value)?)
7161 }
7162
7163 /// Sends a signal to a shell process previously started via "shell.exec".
7164 ///
7165 /// Wire method: `session.shell.kill`.
7166 ///
7167 /// # Parameters
7168 ///
7169 /// * `params` - Identifier of a process previously returned by "shell.exec" and the signal to send.
7170 ///
7171 /// # Returns
7172 ///
7173 /// Indicates whether the signal was delivered; false if the process was unknown or already exited.
7174 ///
7175 /// <div class="warning">
7176 ///
7177 /// **Experimental.** This API is part of an experimental wire-protocol surface
7178 /// and may change or be removed in future SDK or CLI releases. Pin both the
7179 /// SDK and CLI versions if your code depends on it.
7180 ///
7181 /// </div>
7182 pub async fn kill(&self, params: ShellKillRequest) -> Result<ShellKillResult, Error> {
7183 let mut wire_params = serde_json::to_value(params)?;
7184 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7185 let _value = self
7186 .session
7187 .client()
7188 .call(rpc_methods::SESSION_SHELL_KILL, Some(wire_params))
7189 .await?;
7190 Ok(serde_json::from_value(_value)?)
7191 }
7192
7193 /// Executes a user-requested shell command through the session runtime.
7194 ///
7195 /// Wire method: `session.shell.executeUserRequested`.
7196 ///
7197 /// # Parameters
7198 ///
7199 /// * `params` - User-requested shell command and cancellation handle.
7200 ///
7201 /// # Returns
7202 ///
7203 /// Result of a user-requested shell command.
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 execute_user_requested(
7213 &self,
7214 params: ShellExecuteUserRequestedRequest,
7215 ) -> Result<UserRequestedShellCommandResult, Error> {
7216 let mut wire_params = serde_json::to_value(params)?;
7217 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7218 let _value = self
7219 .session
7220 .client()
7221 .call(
7222 rpc_methods::SESSION_SHELL_EXECUTEUSERREQUESTED,
7223 Some(wire_params),
7224 )
7225 .await?;
7226 Ok(serde_json::from_value(_value)?)
7227 }
7228
7229 /// Cancels a user-requested shell command by request ID.
7230 ///
7231 /// Wire method: `session.shell.cancelUserRequested`.
7232 ///
7233 /// # Parameters
7234 ///
7235 /// * `params` - User-requested shell execution cancellation handle.
7236 ///
7237 /// # Returns
7238 ///
7239 /// Cancellation result for a user-requested shell command.
7240 ///
7241 /// <div class="warning">
7242 ///
7243 /// **Experimental.** This API is part of an experimental wire-protocol surface
7244 /// and may change or be removed in future SDK or CLI releases. Pin both the
7245 /// SDK and CLI versions if your code depends on it.
7246 ///
7247 /// </div>
7248 pub async fn cancel_user_requested(
7249 &self,
7250 params: ShellCancelUserRequestedRequest,
7251 ) -> Result<CancelUserRequestedShellCommandResult, Error> {
7252 let mut wire_params = serde_json::to_value(params)?;
7253 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7254 let _value = self
7255 .session
7256 .client()
7257 .call(
7258 rpc_methods::SESSION_SHELL_CANCELUSERREQUESTED,
7259 Some(wire_params),
7260 )
7261 .await?;
7262 Ok(serde_json::from_value(_value)?)
7263 }
7264}
7265
7266/// `session.skills.*` RPCs.
7267#[derive(Clone, Copy)]
7268pub struct SessionRpcSkills<'a> {
7269 pub(crate) session: &'a Session,
7270}
7271
7272impl<'a> SessionRpcSkills<'a> {
7273 /// Lists skills available to the session.
7274 ///
7275 /// Wire method: `session.skills.list`.
7276 ///
7277 /// # Returns
7278 ///
7279 /// Skills available to the session, with their enabled state.
7280 ///
7281 /// <div class="warning">
7282 ///
7283 /// **Experimental.** This API is part of an experimental wire-protocol surface
7284 /// and may change or be removed in future SDK or CLI releases. Pin both the
7285 /// SDK and CLI versions if your code depends on it.
7286 ///
7287 /// </div>
7288 pub async fn list(&self) -> Result<SkillList, Error> {
7289 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7290 let _value = self
7291 .session
7292 .client()
7293 .call(rpc_methods::SESSION_SKILLS_LIST, Some(wire_params))
7294 .await?;
7295 Ok(serde_json::from_value(_value)?)
7296 }
7297
7298 /// Returns the skills that have been invoked during this session.
7299 ///
7300 /// Wire method: `session.skills.getInvoked`.
7301 ///
7302 /// # Returns
7303 ///
7304 /// Skills invoked during this session, ordered by invocation time (most recent last).
7305 ///
7306 /// <div class="warning">
7307 ///
7308 /// **Experimental.** This API is part of an experimental wire-protocol surface
7309 /// and may change or be removed in future SDK or CLI releases. Pin both the
7310 /// SDK and CLI versions if your code depends on it.
7311 ///
7312 /// </div>
7313 pub async fn get_invoked(&self) -> Result<SkillsGetInvokedResult, Error> {
7314 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7315 let _value = self
7316 .session
7317 .client()
7318 .call(rpc_methods::SESSION_SKILLS_GETINVOKED, Some(wire_params))
7319 .await?;
7320 Ok(serde_json::from_value(_value)?)
7321 }
7322
7323 /// Enables a skill for the session.
7324 ///
7325 /// Wire method: `session.skills.enable`.
7326 ///
7327 /// # Parameters
7328 ///
7329 /// * `params` - Name of the skill to enable for the session.
7330 ///
7331 /// <div class="warning">
7332 ///
7333 /// **Experimental.** This API is part of an experimental wire-protocol surface
7334 /// and may change or be removed in future SDK or CLI releases. Pin both the
7335 /// SDK and CLI versions if your code depends on it.
7336 ///
7337 /// </div>
7338 pub async fn enable(&self, params: SkillsEnableRequest) -> Result<(), Error> {
7339 let mut wire_params = serde_json::to_value(params)?;
7340 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7341 let _value = self
7342 .session
7343 .client()
7344 .call(rpc_methods::SESSION_SKILLS_ENABLE, Some(wire_params))
7345 .await?;
7346 Ok(())
7347 }
7348
7349 /// Disables a skill for the session.
7350 ///
7351 /// Wire method: `session.skills.disable`.
7352 ///
7353 /// # Parameters
7354 ///
7355 /// * `params` - Name of the skill to disable for the session.
7356 ///
7357 /// <div class="warning">
7358 ///
7359 /// **Experimental.** This API is part of an experimental wire-protocol surface
7360 /// and may change or be removed in future SDK or CLI releases. Pin both the
7361 /// SDK and CLI versions if your code depends on it.
7362 ///
7363 /// </div>
7364 pub async fn disable(&self, params: SkillsDisableRequest) -> Result<(), Error> {
7365 let mut wire_params = serde_json::to_value(params)?;
7366 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7367 let _value = self
7368 .session
7369 .client()
7370 .call(rpc_methods::SESSION_SKILLS_DISABLE, Some(wire_params))
7371 .await?;
7372 Ok(())
7373 }
7374
7375 /// Reloads skill definitions for the session.
7376 ///
7377 /// Wire method: `session.skills.reload`.
7378 ///
7379 /// # Returns
7380 ///
7381 /// Diagnostics from reloading skill definitions, with warnings and errors as separate lists.
7382 ///
7383 /// <div class="warning">
7384 ///
7385 /// **Experimental.** This API is part of an experimental wire-protocol surface
7386 /// and may change or be removed in future SDK or CLI releases. Pin both the
7387 /// SDK and CLI versions if your code depends on it.
7388 ///
7389 /// </div>
7390 pub async fn reload(&self) -> Result<SkillsLoadDiagnostics, Error> {
7391 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7392 let _value = self
7393 .session
7394 .client()
7395 .call(rpc_methods::SESSION_SKILLS_RELOAD, Some(wire_params))
7396 .await?;
7397 Ok(serde_json::from_value(_value)?)
7398 }
7399
7400 /// Ensures the session's skill definitions have been loaded from disk.
7401 ///
7402 /// Wire method: `session.skills.ensureLoaded`.
7403 ///
7404 /// <div class="warning">
7405 ///
7406 /// **Experimental.** This API is part of an experimental wire-protocol surface
7407 /// and may change or be removed in future SDK or CLI releases. Pin both the
7408 /// SDK and CLI versions if your code depends on it.
7409 ///
7410 /// </div>
7411 pub async fn ensure_loaded(&self) -> Result<(), Error> {
7412 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7413 let _value = self
7414 .session
7415 .client()
7416 .call(rpc_methods::SESSION_SKILLS_ENSURELOADED, Some(wire_params))
7417 .await?;
7418 Ok(())
7419 }
7420}
7421
7422/// `session.tasks.*` RPCs.
7423#[derive(Clone, Copy)]
7424pub struct SessionRpcTasks<'a> {
7425 pub(crate) session: &'a Session,
7426}
7427
7428impl<'a> SessionRpcTasks<'a> {
7429 /// Starts a background agent task in the session.
7430 ///
7431 /// Wire method: `session.tasks.startAgent`.
7432 ///
7433 /// # Parameters
7434 ///
7435 /// * `params` - Agent type, prompt, name, and optional description and model override for the new task.
7436 ///
7437 /// # Returns
7438 ///
7439 /// Identifier assigned to the newly started background agent task.
7440 ///
7441 /// <div class="warning">
7442 ///
7443 /// **Experimental.** This API is part of an experimental wire-protocol surface
7444 /// and may change or be removed in future SDK or CLI releases. Pin both the
7445 /// SDK and CLI versions if your code depends on it.
7446 ///
7447 /// </div>
7448 pub async fn start_agent(
7449 &self,
7450 params: TasksStartAgentRequest,
7451 ) -> Result<TasksStartAgentResult, Error> {
7452 let mut wire_params = serde_json::to_value(params)?;
7453 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7454 let _value = self
7455 .session
7456 .client()
7457 .call(rpc_methods::SESSION_TASKS_STARTAGENT, Some(wire_params))
7458 .await?;
7459 Ok(serde_json::from_value(_value)?)
7460 }
7461
7462 /// Lists background tasks tracked by the session.
7463 ///
7464 /// Wire method: `session.tasks.list`.
7465 ///
7466 /// # Returns
7467 ///
7468 /// Background tasks currently tracked by the session.
7469 ///
7470 /// <div class="warning">
7471 ///
7472 /// **Experimental.** This API is part of an experimental wire-protocol surface
7473 /// and may change or be removed in future SDK or CLI releases. Pin both the
7474 /// SDK and CLI versions if your code depends on it.
7475 ///
7476 /// </div>
7477 pub async fn list(&self) -> Result<TaskList, Error> {
7478 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7479 let _value = self
7480 .session
7481 .client()
7482 .call(rpc_methods::SESSION_TASKS_LIST, Some(wire_params))
7483 .await?;
7484 Ok(serde_json::from_value(_value)?)
7485 }
7486
7487 /// Refreshes metadata for any detached background shells the runtime knows about.
7488 ///
7489 /// Wire method: `session.tasks.refresh`.
7490 ///
7491 /// # Returns
7492 ///
7493 /// 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.
7494 ///
7495 /// <div class="warning">
7496 ///
7497 /// **Experimental.** This API is part of an experimental wire-protocol surface
7498 /// and may change or be removed in future SDK or CLI releases. Pin both the
7499 /// SDK and CLI versions if your code depends on it.
7500 ///
7501 /// </div>
7502 pub async fn refresh(&self) -> Result<TasksRefreshResult, Error> {
7503 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7504 let _value = self
7505 .session
7506 .client()
7507 .call(rpc_methods::SESSION_TASKS_REFRESH, Some(wire_params))
7508 .await?;
7509 Ok(serde_json::from_value(_value)?)
7510 }
7511
7512 /// Waits for all in-flight background tasks and any follow-up turns to settle.
7513 ///
7514 /// Wire method: `session.tasks.waitForPending`.
7515 ///
7516 /// # Returns
7517 ///
7518 /// 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).
7519 ///
7520 /// <div class="warning">
7521 ///
7522 /// **Experimental.** This API is part of an experimental wire-protocol surface
7523 /// and may change or be removed in future SDK or CLI releases. Pin both the
7524 /// SDK and CLI versions if your code depends on it.
7525 ///
7526 /// </div>
7527 pub async fn wait_for_pending(&self) -> Result<TasksWaitForPendingResult, Error> {
7528 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7529 let _value = self
7530 .session
7531 .client()
7532 .call(rpc_methods::SESSION_TASKS_WAITFORPENDING, Some(wire_params))
7533 .await?;
7534 Ok(serde_json::from_value(_value)?)
7535 }
7536
7537 /// Returns progress information for a background task by ID.
7538 ///
7539 /// Wire method: `session.tasks.getProgress`.
7540 ///
7541 /// # Parameters
7542 ///
7543 /// * `params` - Identifier of the background task to fetch progress for.
7544 ///
7545 /// # Returns
7546 ///
7547 /// Progress information for the task, or null when no task with that ID is tracked.
7548 ///
7549 /// <div class="warning">
7550 ///
7551 /// **Experimental.** This API is part of an experimental wire-protocol surface
7552 /// and may change or be removed in future SDK or CLI releases. Pin both the
7553 /// SDK and CLI versions if your code depends on it.
7554 ///
7555 /// </div>
7556 pub async fn get_progress(
7557 &self,
7558 params: TasksGetProgressRequest,
7559 ) -> Result<TasksGetProgressResult, Error> {
7560 let mut wire_params = serde_json::to_value(params)?;
7561 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7562 let _value = self
7563 .session
7564 .client()
7565 .call(rpc_methods::SESSION_TASKS_GETPROGRESS, Some(wire_params))
7566 .await?;
7567 Ok(serde_json::from_value(_value)?)
7568 }
7569
7570 /// Returns the first sync-waiting task that can currently be promoted to background mode.
7571 ///
7572 /// Wire method: `session.tasks.getCurrentPromotable`.
7573 ///
7574 /// # Returns
7575 ///
7576 /// The first sync-waiting task that can currently be promoted to background mode.
7577 ///
7578 /// <div class="warning">
7579 ///
7580 /// **Experimental.** This API is part of an experimental wire-protocol surface
7581 /// and may change or be removed in future SDK or CLI releases. Pin both the
7582 /// SDK and CLI versions if your code depends on it.
7583 ///
7584 /// </div>
7585 pub async fn get_current_promotable(&self) -> Result<TasksGetCurrentPromotableResult, Error> {
7586 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7587 let _value = self
7588 .session
7589 .client()
7590 .call(
7591 rpc_methods::SESSION_TASKS_GETCURRENTPROMOTABLE,
7592 Some(wire_params),
7593 )
7594 .await?;
7595 Ok(serde_json::from_value(_value)?)
7596 }
7597
7598 /// Promotes an eligible synchronously-waited task so it continues running in the background.
7599 ///
7600 /// Wire method: `session.tasks.promoteToBackground`.
7601 ///
7602 /// # Parameters
7603 ///
7604 /// * `params` - Identifier of the task to promote to background mode.
7605 ///
7606 /// # Returns
7607 ///
7608 /// Indicates whether the task was successfully promoted to background mode.
7609 ///
7610 /// <div class="warning">
7611 ///
7612 /// **Experimental.** This API is part of an experimental wire-protocol surface
7613 /// and may change or be removed in future SDK or CLI releases. Pin both the
7614 /// SDK and CLI versions if your code depends on it.
7615 ///
7616 /// </div>
7617 pub async fn promote_to_background(
7618 &self,
7619 params: TasksPromoteToBackgroundRequest,
7620 ) -> Result<TasksPromoteToBackgroundResult, Error> {
7621 let mut wire_params = serde_json::to_value(params)?;
7622 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7623 let _value = self
7624 .session
7625 .client()
7626 .call(
7627 rpc_methods::SESSION_TASKS_PROMOTETOBACKGROUND,
7628 Some(wire_params),
7629 )
7630 .await?;
7631 Ok(serde_json::from_value(_value)?)
7632 }
7633
7634 /// Atomically promotes the first promotable sync-waiting task to background mode and returns it.
7635 ///
7636 /// Wire method: `session.tasks.promoteCurrentToBackground`.
7637 ///
7638 /// # Returns
7639 ///
7640 /// The promoted task as it now exists in background mode, omitted if no promotable task was waiting.
7641 ///
7642 /// <div class="warning">
7643 ///
7644 /// **Experimental.** This API is part of an experimental wire-protocol surface
7645 /// and may change or be removed in future SDK or CLI releases. Pin both the
7646 /// SDK and CLI versions if your code depends on it.
7647 ///
7648 /// </div>
7649 pub async fn promote_current_to_background(
7650 &self,
7651 ) -> Result<TasksPromoteCurrentToBackgroundResult, Error> {
7652 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7653 let _value = self
7654 .session
7655 .client()
7656 .call(
7657 rpc_methods::SESSION_TASKS_PROMOTECURRENTTOBACKGROUND,
7658 Some(wire_params),
7659 )
7660 .await?;
7661 Ok(serde_json::from_value(_value)?)
7662 }
7663
7664 /// Cancels a background task.
7665 ///
7666 /// Wire method: `session.tasks.cancel`.
7667 ///
7668 /// # Parameters
7669 ///
7670 /// * `params` - Identifier of the background task to cancel.
7671 ///
7672 /// # Returns
7673 ///
7674 /// Indicates whether the background task was successfully cancelled.
7675 ///
7676 /// <div class="warning">
7677 ///
7678 /// **Experimental.** This API is part of an experimental wire-protocol surface
7679 /// and may change or be removed in future SDK or CLI releases. Pin both the
7680 /// SDK and CLI versions if your code depends on it.
7681 ///
7682 /// </div>
7683 pub async fn cancel(&self, params: TasksCancelRequest) -> Result<TasksCancelResult, Error> {
7684 let mut wire_params = serde_json::to_value(params)?;
7685 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7686 let _value = self
7687 .session
7688 .client()
7689 .call(rpc_methods::SESSION_TASKS_CANCEL, Some(wire_params))
7690 .await?;
7691 Ok(serde_json::from_value(_value)?)
7692 }
7693
7694 /// Removes a completed or cancelled background task from tracking.
7695 ///
7696 /// Wire method: `session.tasks.remove`.
7697 ///
7698 /// # Parameters
7699 ///
7700 /// * `params` - Identifier of the completed or cancelled task to remove from tracking.
7701 ///
7702 /// # Returns
7703 ///
7704 /// Indicates whether the task was removed. False when the task does not exist or is still running/idle.
7705 ///
7706 /// <div class="warning">
7707 ///
7708 /// **Experimental.** This API is part of an experimental wire-protocol surface
7709 /// and may change or be removed in future SDK or CLI releases. Pin both the
7710 /// SDK and CLI versions if your code depends on it.
7711 ///
7712 /// </div>
7713 pub async fn remove(&self, params: TasksRemoveRequest) -> Result<TasksRemoveResult, Error> {
7714 let mut wire_params = serde_json::to_value(params)?;
7715 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7716 let _value = self
7717 .session
7718 .client()
7719 .call(rpc_methods::SESSION_TASKS_REMOVE, Some(wire_params))
7720 .await?;
7721 Ok(serde_json::from_value(_value)?)
7722 }
7723
7724 /// Sends a message to a background agent task.
7725 ///
7726 /// Wire method: `session.tasks.sendMessage`.
7727 ///
7728 /// # Parameters
7729 ///
7730 /// * `params` - Identifier of the target agent task, message content, and optional sender agent ID.
7731 ///
7732 /// # Returns
7733 ///
7734 /// Indicates whether the message was delivered, with an error message when delivery failed.
7735 ///
7736 /// <div class="warning">
7737 ///
7738 /// **Experimental.** This API is part of an experimental wire-protocol surface
7739 /// and may change or be removed in future SDK or CLI releases. Pin both the
7740 /// SDK and CLI versions if your code depends on it.
7741 ///
7742 /// </div>
7743 pub async fn send_message(
7744 &self,
7745 params: TasksSendMessageRequest,
7746 ) -> Result<TasksSendMessageResult, Error> {
7747 let mut wire_params = serde_json::to_value(params)?;
7748 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7749 let _value = self
7750 .session
7751 .client()
7752 .call(rpc_methods::SESSION_TASKS_SENDMESSAGE, Some(wire_params))
7753 .await?;
7754 Ok(serde_json::from_value(_value)?)
7755 }
7756}
7757
7758/// `session.telemetry.*` RPCs.
7759#[derive(Clone, Copy)]
7760pub struct SessionRpcTelemetry<'a> {
7761 pub(crate) session: &'a Session,
7762}
7763
7764impl<'a> SessionRpcTelemetry<'a> {
7765 /// Gets the telemetry engagement ID currently associated with the session, when available.
7766 ///
7767 /// Wire method: `session.telemetry.getEngagementId`.
7768 ///
7769 /// # Returns
7770 ///
7771 /// Telemetry engagement ID for the session, when available.
7772 ///
7773 /// <div class="warning">
7774 ///
7775 /// **Experimental.** This API is part of an experimental wire-protocol surface
7776 /// and may change or be removed in future SDK or CLI releases. Pin both the
7777 /// SDK and CLI versions if your code depends on it.
7778 ///
7779 /// </div>
7780 pub async fn get_engagement_id(&self) -> Result<SessionTelemetryEngagement, Error> {
7781 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7782 let _value = self
7783 .session
7784 .client()
7785 .call(
7786 rpc_methods::SESSION_TELEMETRY_GETENGAGEMENTID,
7787 Some(wire_params),
7788 )
7789 .await?;
7790 Ok(serde_json::from_value(_value)?)
7791 }
7792
7793 /// Sets feature override key/value pairs to attach to subsequent telemetry events for the session.
7794 ///
7795 /// Wire method: `session.telemetry.setFeatureOverrides`.
7796 ///
7797 /// # Parameters
7798 ///
7799 /// * `params` - Feature override key/value pairs to attach to subsequent telemetry events from this session.
7800 ///
7801 /// <div class="warning">
7802 ///
7803 /// **Experimental.** This API is part of an experimental wire-protocol surface
7804 /// and may change or be removed in future SDK or CLI releases. Pin both the
7805 /// SDK and CLI versions if your code depends on it.
7806 ///
7807 /// </div>
7808 pub async fn set_feature_overrides(
7809 &self,
7810 params: TelemetrySetFeatureOverridesRequest,
7811 ) -> Result<(), Error> {
7812 let mut wire_params = serde_json::to_value(params)?;
7813 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7814 let _value = self
7815 .session
7816 .client()
7817 .call(
7818 rpc_methods::SESSION_TELEMETRY_SETFEATUREOVERRIDES,
7819 Some(wire_params),
7820 )
7821 .await?;
7822 Ok(())
7823 }
7824}
7825
7826/// `session.tools.*` RPCs.
7827#[derive(Clone, Copy)]
7828pub struct SessionRpcTools<'a> {
7829 pub(crate) session: &'a Session,
7830}
7831
7832impl<'a> SessionRpcTools<'a> {
7833 /// Provides the result for a pending external tool call.
7834 ///
7835 /// Wire method: `session.tools.handlePendingToolCall`.
7836 ///
7837 /// # Parameters
7838 ///
7839 /// * `params` - Pending external tool call request ID, with the tool result or an error describing why it failed.
7840 ///
7841 /// # Returns
7842 ///
7843 /// Indicates whether the external tool call result was handled successfully.
7844 ///
7845 /// <div class="warning">
7846 ///
7847 /// **Experimental.** This API is part of an experimental wire-protocol surface
7848 /// and may change or be removed in future SDK or CLI releases. Pin both the
7849 /// SDK and CLI versions if your code depends on it.
7850 ///
7851 /// </div>
7852 pub async fn handle_pending_tool_call(
7853 &self,
7854 params: HandlePendingToolCallRequest,
7855 ) -> Result<HandlePendingToolCallResult, Error> {
7856 let mut wire_params = serde_json::to_value(params)?;
7857 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7858 let _value = self
7859 .session
7860 .client()
7861 .call(
7862 rpc_methods::SESSION_TOOLS_HANDLEPENDINGTOOLCALL,
7863 Some(wire_params),
7864 )
7865 .await?;
7866 Ok(serde_json::from_value(_value)?)
7867 }
7868
7869 /// Resolves, builds, and validates the runtime tool list for the session.
7870 ///
7871 /// Wire method: `session.tools.initializeAndValidate`.
7872 ///
7873 /// # Returns
7874 ///
7875 /// 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.
7876 ///
7877 /// <div class="warning">
7878 ///
7879 /// **Experimental.** This API is part of an experimental wire-protocol surface
7880 /// and may change or be removed in future SDK or CLI releases. Pin both the
7881 /// SDK and CLI versions if your code depends on it.
7882 ///
7883 /// </div>
7884 pub async fn initialize_and_validate(&self) -> Result<ToolsInitializeAndValidateResult, Error> {
7885 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7886 let _value = self
7887 .session
7888 .client()
7889 .call(
7890 rpc_methods::SESSION_TOOLS_INITIALIZEANDVALIDATE,
7891 Some(wire_params),
7892 )
7893 .await?;
7894 Ok(serde_json::from_value(_value)?)
7895 }
7896
7897 /// Returns lightweight metadata for the session's currently initialized tools.
7898 ///
7899 /// Wire method: `session.tools.getCurrentMetadata`.
7900 ///
7901 /// # Returns
7902 ///
7903 /// Current lightweight tool metadata snapshot for the session.
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 get_current_metadata(&self) -> Result<ToolsGetCurrentMetadataResult, Error> {
7913 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7914 let _value = self
7915 .session
7916 .client()
7917 .call(
7918 rpc_methods::SESSION_TOOLS_GETCURRENTMETADATA,
7919 Some(wire_params),
7920 )
7921 .await?;
7922 Ok(serde_json::from_value(_value)?)
7923 }
7924
7925 /// Updates the current session's live subagent settings after user settings change. The persisted user settings remain the source of truth for future sessions.
7926 ///
7927 /// Wire method: `session.tools.updateSubagentSettings`.
7928 ///
7929 /// # Parameters
7930 ///
7931 /// * `params` - Subagent settings to apply to the current session
7932 ///
7933 /// # Returns
7934 ///
7935 /// Empty result after applying subagent settings
7936 ///
7937 /// <div class="warning">
7938 ///
7939 /// **Experimental.** This API is part of an experimental wire-protocol surface
7940 /// and may change or be removed in future SDK or CLI releases. Pin both the
7941 /// SDK and CLI versions if your code depends on it.
7942 ///
7943 /// </div>
7944 pub async fn update_subagent_settings(
7945 &self,
7946 params: UpdateSubagentSettingsRequest,
7947 ) -> Result<ToolsUpdateSubagentSettingsResult, Error> {
7948 let mut wire_params = serde_json::to_value(params)?;
7949 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7950 let _value = self
7951 .session
7952 .client()
7953 .call(
7954 rpc_methods::SESSION_TOOLS_UPDATESUBAGENTSETTINGS,
7955 Some(wire_params),
7956 )
7957 .await?;
7958 Ok(serde_json::from_value(_value)?)
7959 }
7960}
7961
7962/// `session.ui.*` RPCs.
7963#[derive(Clone, Copy)]
7964pub struct SessionRpcUi<'a> {
7965 pub(crate) session: &'a Session,
7966}
7967
7968impl<'a> SessionRpcUi<'a> {
7969 /// Runs a transient no-tools model query against the current conversation context.
7970 ///
7971 /// Wire method: `session.ui.ephemeralQuery`.
7972 ///
7973 /// # Parameters
7974 ///
7975 /// * `params` - Transient question to answer without adding it to conversation history.
7976 ///
7977 /// # Returns
7978 ///
7979 /// Transient answer generated from current conversation context.
7980 ///
7981 /// <div class="warning">
7982 ///
7983 /// **Experimental.** This API is part of an experimental wire-protocol surface
7984 /// and may change or be removed in future SDK or CLI releases. Pin both the
7985 /// SDK and CLI versions if your code depends on it.
7986 ///
7987 /// </div>
7988 pub async fn ephemeral_query(
7989 &self,
7990 params: UIEphemeralQueryRequest,
7991 ) -> Result<UIEphemeralQueryResult, Error> {
7992 let mut wire_params = serde_json::to_value(params)?;
7993 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7994 let _value = self
7995 .session
7996 .client()
7997 .call(rpc_methods::SESSION_UI_EPHEMERALQUERY, Some(wire_params))
7998 .await?;
7999 Ok(serde_json::from_value(_value)?)
8000 }
8001
8002 /// Requests structured input from a UI-capable client.
8003 ///
8004 /// Wire method: `session.ui.elicitation`.
8005 ///
8006 /// # Parameters
8007 ///
8008 /// * `params` - Prompt message and JSON schema describing the form fields to elicit from the user.
8009 ///
8010 /// # Returns
8011 ///
8012 /// The elicitation response (accept with form values, decline, or cancel)
8013 ///
8014 /// <div class="warning">
8015 ///
8016 /// **Experimental.** This API is part of an experimental wire-protocol surface
8017 /// and may change or be removed in future SDK or CLI releases. Pin both the
8018 /// SDK and CLI versions if your code depends on it.
8019 ///
8020 /// </div>
8021 pub async fn elicitation(
8022 &self,
8023 params: UIElicitationRequest,
8024 ) -> Result<UIElicitationResponse, Error> {
8025 let mut wire_params = serde_json::to_value(params)?;
8026 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8027 let _value = self
8028 .session
8029 .client()
8030 .call(rpc_methods::SESSION_UI_ELICITATION, Some(wire_params))
8031 .await?;
8032 Ok(serde_json::from_value(_value)?)
8033 }
8034
8035 /// Provides the user response for a pending elicitation request.
8036 ///
8037 /// Wire method: `session.ui.handlePendingElicitation`.
8038 ///
8039 /// # Parameters
8040 ///
8041 /// * `params` - Pending elicitation request ID and the user's response (accept/decline/cancel + form values).
8042 ///
8043 /// # Returns
8044 ///
8045 /// Indicates whether the elicitation response was accepted; false if it was already resolved by another client.
8046 ///
8047 /// <div class="warning">
8048 ///
8049 /// **Experimental.** This API is part of an experimental wire-protocol surface
8050 /// and may change or be removed in future SDK or CLI releases. Pin both the
8051 /// SDK and CLI versions if your code depends on it.
8052 ///
8053 /// </div>
8054 pub async fn handle_pending_elicitation(
8055 &self,
8056 params: UIHandlePendingElicitationRequest,
8057 ) -> Result<UIElicitationResult, Error> {
8058 let mut wire_params = serde_json::to_value(params)?;
8059 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8060 let _value = self
8061 .session
8062 .client()
8063 .call(
8064 rpc_methods::SESSION_UI_HANDLEPENDINGELICITATION,
8065 Some(wire_params),
8066 )
8067 .await?;
8068 Ok(serde_json::from_value(_value)?)
8069 }
8070
8071 /// Resolves a pending `user_input.requested` event with the user's response.
8072 ///
8073 /// Wire method: `session.ui.handlePendingUserInput`.
8074 ///
8075 /// # Parameters
8076 ///
8077 /// * `params` - Request ID of a pending `user_input.requested` event and the user's response.
8078 ///
8079 /// # Returns
8080 ///
8081 /// Indicates whether the pending UI request was resolved by this call.
8082 ///
8083 /// <div class="warning">
8084 ///
8085 /// **Experimental.** This API is part of an experimental wire-protocol surface
8086 /// and may change or be removed in future SDK or CLI releases. Pin both the
8087 /// SDK and CLI versions if your code depends on it.
8088 ///
8089 /// </div>
8090 pub async fn handle_pending_user_input(
8091 &self,
8092 params: UIHandlePendingUserInputRequest,
8093 ) -> Result<UIHandlePendingResult, Error> {
8094 let mut wire_params = serde_json::to_value(params)?;
8095 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8096 let _value = self
8097 .session
8098 .client()
8099 .call(
8100 rpc_methods::SESSION_UI_HANDLEPENDINGUSERINPUT,
8101 Some(wire_params),
8102 )
8103 .await?;
8104 Ok(serde_json::from_value(_value)?)
8105 }
8106
8107 /// Resolves a pending `sampling.requested` event with a sampling result, or rejects it.
8108 ///
8109 /// Wire method: `session.ui.handlePendingSampling`.
8110 ///
8111 /// # Parameters
8112 ///
8113 /// * `params` - Request ID of a pending `sampling.requested` event and an optional sampling result payload (omit to reject).
8114 ///
8115 /// # Returns
8116 ///
8117 /// Indicates whether the pending UI request was resolved by this call.
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 handle_pending_sampling(
8127 &self,
8128 params: UIHandlePendingSamplingRequest,
8129 ) -> Result<UIHandlePendingResult, Error> {
8130 let mut wire_params = serde_json::to_value(params)?;
8131 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8132 let _value = self
8133 .session
8134 .client()
8135 .call(
8136 rpc_methods::SESSION_UI_HANDLEPENDINGSAMPLING,
8137 Some(wire_params),
8138 )
8139 .await?;
8140 Ok(serde_json::from_value(_value)?)
8141 }
8142
8143 /// Resolves a pending `auto_mode_switch.requested` event with the user's accept/decline decision.
8144 ///
8145 /// Wire method: `session.ui.handlePendingAutoModeSwitch`.
8146 ///
8147 /// # Parameters
8148 ///
8149 /// * `params` - Request ID of a pending `auto_mode_switch.requested` event and the user's response.
8150 ///
8151 /// # Returns
8152 ///
8153 /// Indicates whether the pending UI request was resolved by this call.
8154 ///
8155 /// <div class="warning">
8156 ///
8157 /// **Experimental.** This API is part of an experimental wire-protocol surface
8158 /// and may change or be removed in future SDK or CLI releases. Pin both the
8159 /// SDK and CLI versions if your code depends on it.
8160 ///
8161 /// </div>
8162 pub async fn handle_pending_auto_mode_switch(
8163 &self,
8164 params: UIHandlePendingAutoModeSwitchRequest,
8165 ) -> Result<UIHandlePendingResult, Error> {
8166 let mut wire_params = serde_json::to_value(params)?;
8167 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8168 let _value = self
8169 .session
8170 .client()
8171 .call(
8172 rpc_methods::SESSION_UI_HANDLEPENDINGAUTOMODESWITCH,
8173 Some(wire_params),
8174 )
8175 .await?;
8176 Ok(serde_json::from_value(_value)?)
8177 }
8178
8179 /// Resolves a pending `session_limits_exhausted.requested` event with the user's selected limit action.
8180 ///
8181 /// Wire method: `session.ui.handlePendingSessionLimitsExhausted`.
8182 ///
8183 /// # Parameters
8184 ///
8185 /// * `params` - Request ID of a pending `session_limits_exhausted.requested` event and the user's selected limit action.
8186 ///
8187 /// # Returns
8188 ///
8189 /// Indicates whether the pending UI request was resolved by this call.
8190 ///
8191 /// <div class="warning">
8192 ///
8193 /// **Experimental.** This API is part of an experimental wire-protocol surface
8194 /// and may change or be removed in future SDK or CLI releases. Pin both the
8195 /// SDK and CLI versions if your code depends on it.
8196 ///
8197 /// </div>
8198 pub async fn handle_pending_session_limits_exhausted(
8199 &self,
8200 params: UIHandlePendingSessionLimitsExhaustedRequest,
8201 ) -> Result<UIHandlePendingResult, Error> {
8202 let mut wire_params = serde_json::to_value(params)?;
8203 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8204 let _value = self
8205 .session
8206 .client()
8207 .call(
8208 rpc_methods::SESSION_UI_HANDLEPENDINGSESSIONLIMITSEXHAUSTED,
8209 Some(wire_params),
8210 )
8211 .await?;
8212 Ok(serde_json::from_value(_value)?)
8213 }
8214
8215 /// Resolves a pending `exit_plan_mode.requested` event with the user's response.
8216 ///
8217 /// Wire method: `session.ui.handlePendingExitPlanMode`.
8218 ///
8219 /// # Parameters
8220 ///
8221 /// * `params` - Request ID of a pending `exit_plan_mode.requested` event and the user's response.
8222 ///
8223 /// # Returns
8224 ///
8225 /// Indicates whether the pending UI request was resolved by this call.
8226 ///
8227 /// <div class="warning">
8228 ///
8229 /// **Experimental.** This API is part of an experimental wire-protocol surface
8230 /// and may change or be removed in future SDK or CLI releases. Pin both the
8231 /// SDK and CLI versions if your code depends on it.
8232 ///
8233 /// </div>
8234 pub async fn handle_pending_exit_plan_mode(
8235 &self,
8236 params: UIHandlePendingExitPlanModeRequest,
8237 ) -> Result<UIHandlePendingResult, Error> {
8238 let mut wire_params = serde_json::to_value(params)?;
8239 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8240 let _value = self
8241 .session
8242 .client()
8243 .call(
8244 rpc_methods::SESSION_UI_HANDLEPENDINGEXITPLANMODE,
8245 Some(wire_params),
8246 )
8247 .await?;
8248 Ok(serde_json::from_value(_value)?)
8249 }
8250
8251 /// Registers an in-process handler for auto-mode-switch requests so the server bridge skips dispatch.
8252 ///
8253 /// Wire method: `session.ui.registerDirectAutoModeSwitchHandler`.
8254 ///
8255 /// # Returns
8256 ///
8257 /// 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).
8258 ///
8259 /// <div class="warning">
8260 ///
8261 /// **Experimental.** This API is part of an experimental wire-protocol surface
8262 /// and may change or be removed in future SDK or CLI releases. Pin both the
8263 /// SDK and CLI versions if your code depends on it.
8264 ///
8265 /// </div>
8266 pub async fn register_direct_auto_mode_switch_handler(
8267 &self,
8268 ) -> Result<UIRegisterDirectAutoModeSwitchHandlerResult, Error> {
8269 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8270 let _value = self
8271 .session
8272 .client()
8273 .call(
8274 rpc_methods::SESSION_UI_REGISTERDIRECTAUTOMODESWITCHHANDLER,
8275 Some(wire_params),
8276 )
8277 .await?;
8278 Ok(serde_json::from_value(_value)?)
8279 }
8280
8281 /// Unregisters a previously-registered in-process auto-mode-switch handler by its opaque handle.
8282 ///
8283 /// Wire method: `session.ui.unregisterDirectAutoModeSwitchHandler`.
8284 ///
8285 /// # Parameters
8286 ///
8287 /// * `params` - Opaque handle previously returned by `registerDirectAutoModeSwitchHandler` to release.
8288 ///
8289 /// # Returns
8290 ///
8291 /// Indicates whether the handle was active and the registration count was decremented.
8292 ///
8293 /// <div class="warning">
8294 ///
8295 /// **Experimental.** This API is part of an experimental wire-protocol surface
8296 /// and may change or be removed in future SDK or CLI releases. Pin both the
8297 /// SDK and CLI versions if your code depends on it.
8298 ///
8299 /// </div>
8300 pub async fn unregister_direct_auto_mode_switch_handler(
8301 &self,
8302 params: UIUnregisterDirectAutoModeSwitchHandlerRequest,
8303 ) -> Result<UIUnregisterDirectAutoModeSwitchHandlerResult, Error> {
8304 let mut wire_params = serde_json::to_value(params)?;
8305 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8306 let _value = self
8307 .session
8308 .client()
8309 .call(
8310 rpc_methods::SESSION_UI_UNREGISTERDIRECTAUTOMODESWITCHHANDLER,
8311 Some(wire_params),
8312 )
8313 .await?;
8314 Ok(serde_json::from_value(_value)?)
8315 }
8316}
8317
8318/// `session.usage.*` RPCs.
8319#[derive(Clone, Copy)]
8320pub struct SessionRpcUsage<'a> {
8321 pub(crate) session: &'a Session,
8322}
8323
8324impl<'a> SessionRpcUsage<'a> {
8325 /// Gets accumulated usage metrics for the session.
8326 ///
8327 /// Wire method: `session.usage.getMetrics`.
8328 ///
8329 /// # Returns
8330 ///
8331 /// Accumulated session usage metrics, including premium request cost, token counts, model breakdown, and code-change totals.
8332 ///
8333 /// <div class="warning">
8334 ///
8335 /// **Experimental.** This API is part of an experimental wire-protocol surface
8336 /// and may change or be removed in future SDK or CLI releases. Pin both the
8337 /// SDK and CLI versions if your code depends on it.
8338 ///
8339 /// </div>
8340 pub async fn get_metrics(&self) -> Result<UsageGetMetricsResult, Error> {
8341 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8342 let _value = self
8343 .session
8344 .client()
8345 .call(rpc_methods::SESSION_USAGE_GETMETRICS, Some(wire_params))
8346 .await?;
8347 Ok(serde_json::from_value(_value)?)
8348 }
8349}
8350
8351/// `session.visibility.*` RPCs.
8352#[derive(Clone, Copy)]
8353pub struct SessionRpcVisibility<'a> {
8354 pub(crate) session: &'a Session,
8355}
8356
8357impl<'a> SessionRpcVisibility<'a> {
8358 /// 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").
8359 ///
8360 /// Wire method: `session.visibility.get`.
8361 ///
8362 /// # Returns
8363 ///
8364 /// Current sharing status and shareable GitHub URL for a session.
8365 ///
8366 /// <div class="warning">
8367 ///
8368 /// **Experimental.** This API is part of an experimental wire-protocol surface
8369 /// and may change or be removed in future SDK or CLI releases. Pin both the
8370 /// SDK and CLI versions if your code depends on it.
8371 ///
8372 /// </div>
8373 pub async fn get(&self) -> Result<VisibilityGetResult, Error> {
8374 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8375 let _value = self
8376 .session
8377 .client()
8378 .call(rpc_methods::SESSION_VISIBILITY_GET, Some(wire_params))
8379 .await?;
8380 Ok(serde_json::from_value(_value)?)
8381 }
8382
8383 /// 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.
8384 ///
8385 /// Wire method: `session.visibility.set`.
8386 ///
8387 /// # Parameters
8388 ///
8389 /// * `params` - Desired sharing status for the session.
8390 ///
8391 /// # Returns
8392 ///
8393 /// Effective sharing status and shareable GitHub URL after updating session visibility.
8394 ///
8395 /// <div class="warning">
8396 ///
8397 /// **Experimental.** This API is part of an experimental wire-protocol surface
8398 /// and may change or be removed in future SDK or CLI releases. Pin both the
8399 /// SDK and CLI versions if your code depends on it.
8400 ///
8401 /// </div>
8402 pub async fn set(&self, params: VisibilitySetRequest) -> Result<VisibilitySetResult, Error> {
8403 let mut wire_params = serde_json::to_value(params)?;
8404 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8405 let _value = self
8406 .session
8407 .client()
8408 .call(rpc_methods::SESSION_VISIBILITY_SET, Some(wire_params))
8409 .await?;
8410 Ok(serde_json::from_value(_value)?)
8411 }
8412}
8413
8414/// `session.workspaces.*` RPCs.
8415#[derive(Clone, Copy)]
8416pub struct SessionRpcWorkspaces<'a> {
8417 pub(crate) session: &'a Session,
8418}
8419
8420impl<'a> SessionRpcWorkspaces<'a> {
8421 /// Gets current workspace metadata for the session.
8422 ///
8423 /// Wire method: `session.workspaces.getWorkspace`.
8424 ///
8425 /// # Returns
8426 ///
8427 /// Current workspace metadata for the session, including its absolute filesystem path when available.
8428 ///
8429 /// <div class="warning">
8430 ///
8431 /// **Experimental.** This API is part of an experimental wire-protocol surface
8432 /// and may change or be removed in future SDK or CLI releases. Pin both the
8433 /// SDK and CLI versions if your code depends on it.
8434 ///
8435 /// </div>
8436 pub async fn get_workspace(&self) -> Result<WorkspacesGetWorkspaceResult, Error> {
8437 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8438 let _value = self
8439 .session
8440 .client()
8441 .call(
8442 rpc_methods::SESSION_WORKSPACES_GETWORKSPACE,
8443 Some(wire_params),
8444 )
8445 .await?;
8446 Ok(serde_json::from_value(_value)?)
8447 }
8448
8449 /// Lists files stored in the session workspace files directory.
8450 ///
8451 /// Wire method: `session.workspaces.listFiles`.
8452 ///
8453 /// # Returns
8454 ///
8455 /// Relative paths of files stored in the session workspace files directory.
8456 ///
8457 /// <div class="warning">
8458 ///
8459 /// **Experimental.** This API is part of an experimental wire-protocol surface
8460 /// and may change or be removed in future SDK or CLI releases. Pin both the
8461 /// SDK and CLI versions if your code depends on it.
8462 ///
8463 /// </div>
8464 pub async fn list_files(&self) -> Result<WorkspacesListFilesResult, Error> {
8465 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8466 let _value = self
8467 .session
8468 .client()
8469 .call(rpc_methods::SESSION_WORKSPACES_LISTFILES, Some(wire_params))
8470 .await?;
8471 Ok(serde_json::from_value(_value)?)
8472 }
8473
8474 /// Reads a file from the session workspace files directory.
8475 ///
8476 /// Wire method: `session.workspaces.readFile`.
8477 ///
8478 /// # Parameters
8479 ///
8480 /// * `params` - Relative path of the workspace file to read.
8481 ///
8482 /// # Returns
8483 ///
8484 /// Contents of the requested workspace file as a UTF-8 string.
8485 ///
8486 /// <div class="warning">
8487 ///
8488 /// **Experimental.** This API is part of an experimental wire-protocol surface
8489 /// and may change or be removed in future SDK or CLI releases. Pin both the
8490 /// SDK and CLI versions if your code depends on it.
8491 ///
8492 /// </div>
8493 pub async fn read_file(
8494 &self,
8495 params: WorkspacesReadFileRequest,
8496 ) -> Result<WorkspacesReadFileResult, Error> {
8497 let mut wire_params = serde_json::to_value(params)?;
8498 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8499 let _value = self
8500 .session
8501 .client()
8502 .call(rpc_methods::SESSION_WORKSPACES_READFILE, Some(wire_params))
8503 .await?;
8504 Ok(serde_json::from_value(_value)?)
8505 }
8506
8507 /// Creates or overwrites a file in the session workspace files directory.
8508 ///
8509 /// Wire method: `session.workspaces.createFile`.
8510 ///
8511 /// # Parameters
8512 ///
8513 /// * `params` - Relative path and UTF-8 content for the workspace file to create or overwrite.
8514 ///
8515 /// <div class="warning">
8516 ///
8517 /// **Experimental.** This API is part of an experimental wire-protocol surface
8518 /// and may change or be removed in future SDK or CLI releases. Pin both the
8519 /// SDK and CLI versions if your code depends on it.
8520 ///
8521 /// </div>
8522 pub async fn create_file(&self, params: WorkspacesCreateFileRequest) -> Result<(), Error> {
8523 let mut wire_params = serde_json::to_value(params)?;
8524 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8525 let _value = self
8526 .session
8527 .client()
8528 .call(
8529 rpc_methods::SESSION_WORKSPACES_CREATEFILE,
8530 Some(wire_params),
8531 )
8532 .await?;
8533 Ok(())
8534 }
8535
8536 /// Lists workspace checkpoints in chronological order.
8537 ///
8538 /// Wire method: `session.workspaces.listCheckpoints`.
8539 ///
8540 /// # Returns
8541 ///
8542 /// Workspace checkpoints in chronological order; empty when the workspace is not enabled.
8543 ///
8544 /// <div class="warning">
8545 ///
8546 /// **Experimental.** This API is part of an experimental wire-protocol surface
8547 /// and may change or be removed in future SDK or CLI releases. Pin both the
8548 /// SDK and CLI versions if your code depends on it.
8549 ///
8550 /// </div>
8551 pub async fn list_checkpoints(&self) -> Result<WorkspacesListCheckpointsResult, Error> {
8552 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8553 let _value = self
8554 .session
8555 .client()
8556 .call(
8557 rpc_methods::SESSION_WORKSPACES_LISTCHECKPOINTS,
8558 Some(wire_params),
8559 )
8560 .await?;
8561 Ok(serde_json::from_value(_value)?)
8562 }
8563
8564 /// Reads the content of a workspace checkpoint by number.
8565 ///
8566 /// Wire method: `session.workspaces.readCheckpoint`.
8567 ///
8568 /// # Parameters
8569 ///
8570 /// * `params` - Checkpoint number to read.
8571 ///
8572 /// # Returns
8573 ///
8574 /// Checkpoint content as a UTF-8 string, or null when the checkpoint or workspace is missing.
8575 ///
8576 /// <div class="warning">
8577 ///
8578 /// **Experimental.** This API is part of an experimental wire-protocol surface
8579 /// and may change or be removed in future SDK or CLI releases. Pin both the
8580 /// SDK and CLI versions if your code depends on it.
8581 ///
8582 /// </div>
8583 pub async fn read_checkpoint(
8584 &self,
8585 params: WorkspacesReadCheckpointRequest,
8586 ) -> Result<WorkspacesReadCheckpointResult, Error> {
8587 let mut wire_params = serde_json::to_value(params)?;
8588 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8589 let _value = self
8590 .session
8591 .client()
8592 .call(
8593 rpc_methods::SESSION_WORKSPACES_READCHECKPOINT,
8594 Some(wire_params),
8595 )
8596 .await?;
8597 Ok(serde_json::from_value(_value)?)
8598 }
8599
8600 /// Saves pasted content as a UTF-8 file in the session workspace.
8601 ///
8602 /// Wire method: `session.workspaces.saveLargePaste`.
8603 ///
8604 /// # Parameters
8605 ///
8606 /// * `params` - Pasted content to save as a UTF-8 file in the session workspace.
8607 ///
8608 /// # Returns
8609 ///
8610 /// Descriptor for the saved paste file, or null when the workspace is unavailable.
8611 ///
8612 /// <div class="warning">
8613 ///
8614 /// **Experimental.** This API is part of an experimental wire-protocol surface
8615 /// and may change or be removed in future SDK or CLI releases. Pin both the
8616 /// SDK and CLI versions if your code depends on it.
8617 ///
8618 /// </div>
8619 pub async fn save_large_paste(
8620 &self,
8621 params: WorkspacesSaveLargePasteRequest,
8622 ) -> Result<WorkspacesSaveLargePasteResult, Error> {
8623 let mut wire_params = serde_json::to_value(params)?;
8624 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8625 let _value = self
8626 .session
8627 .client()
8628 .call(
8629 rpc_methods::SESSION_WORKSPACES_SAVELARGEPASTE,
8630 Some(wire_params),
8631 )
8632 .await?;
8633 Ok(serde_json::from_value(_value)?)
8634 }
8635
8636 /// Computes a diff for the session workspace.
8637 ///
8638 /// Wire method: `session.workspaces.diff`.
8639 ///
8640 /// # Parameters
8641 ///
8642 /// * `params` - Parameters for computing a workspace diff.
8643 ///
8644 /// # Returns
8645 ///
8646 /// Workspace diff result for the requested mode.
8647 ///
8648 /// <div class="warning">
8649 ///
8650 /// **Experimental.** This API is part of an experimental wire-protocol surface
8651 /// and may change or be removed in future SDK or CLI releases. Pin both the
8652 /// SDK and CLI versions if your code depends on it.
8653 ///
8654 /// </div>
8655 pub async fn diff(&self, params: WorkspacesDiffRequest) -> Result<WorkspaceDiffResult, Error> {
8656 let mut wire_params = serde_json::to_value(params)?;
8657 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8658 let _value = self
8659 .session
8660 .client()
8661 .call(rpc_methods::SESSION_WORKSPACES_DIFF, Some(wire_params))
8662 .await?;
8663 Ok(serde_json::from_value(_value)?)
8664 }
8665}