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