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 and optional working directory for relative-path resolution.
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. This performs a live `tools/list` request. Tool UI metadata is returned independently of whether MCP Apps rendering is enabled for the session.
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 /// Fetch an MCP resource (typically a `ui://` MCP App bundle, per SEP-1865) from a connected server. Requires the `mcp-apps` session capability.
4835 ///
4836 /// Wire method: `session.mcp.apps.readResource`.
4837 ///
4838 /// # Parameters
4839 ///
4840 /// * `params` - MCP server and resource URI to fetch.
4841 ///
4842 /// # Returns
4843 ///
4844 /// Resource contents returned by the MCP server.
4845 ///
4846 /// <div class="warning">
4847 ///
4848 /// **Experimental.** This API is part of an experimental wire-protocol surface
4849 /// and may change or be removed in future SDK or CLI releases. Pin both the
4850 /// SDK and CLI versions if your code depends on it.
4851 ///
4852 /// </div>
4853 pub async fn read_resource(
4854 &self,
4855 params: McpAppsReadResourceRequest,
4856 ) -> Result<McpAppsReadResourceResult, Error> {
4857 let mut wire_params = serde_json::to_value(params)?;
4858 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4859 let _value = self
4860 .session
4861 .client()
4862 .call(
4863 rpc_methods::SESSION_MCP_APPS_READRESOURCE,
4864 Some(wire_params),
4865 )
4866 .await?;
4867 Ok(serde_json::from_value(_value)?)
4868 }
4869
4870 /// 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"`.
4871 ///
4872 /// Wire method: `session.mcp.apps.listTools`.
4873 ///
4874 /// # Parameters
4875 ///
4876 /// * `params` - MCP server to list app-callable tools for.
4877 ///
4878 /// # Returns
4879 ///
4880 /// App-callable tools from the named MCP server.
4881 ///
4882 /// <div class="warning">
4883 ///
4884 /// **Experimental.** This API is part of an experimental wire-protocol surface
4885 /// and may change or be removed in future SDK or CLI releases. Pin both the
4886 /// SDK and CLI versions if your code depends on it.
4887 ///
4888 /// </div>
4889 pub async fn list_tools(
4890 &self,
4891 params: McpAppsListToolsRequest,
4892 ) -> Result<McpAppsListToolsResult, Error> {
4893 let mut wire_params = serde_json::to_value(params)?;
4894 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4895 let _value = self
4896 .session
4897 .client()
4898 .call(rpc_methods::SESSION_MCP_APPS_LISTTOOLS, Some(wire_params))
4899 .await?;
4900 Ok(serde_json::from_value(_value)?)
4901 }
4902
4903 /// 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`.
4904 ///
4905 /// Wire method: `session.mcp.apps.callTool`.
4906 ///
4907 /// # Parameters
4908 ///
4909 /// * `params` - MCP server, tool name, and arguments to invoke from an MCP App view.
4910 ///
4911 /// # Returns
4912 ///
4913 /// Standard MCP CallToolResult
4914 ///
4915 /// <div class="warning">
4916 ///
4917 /// **Experimental.** This API is part of an experimental wire-protocol surface
4918 /// and may change or be removed in future SDK or CLI releases. Pin both the
4919 /// SDK and CLI versions if your code depends on it.
4920 ///
4921 /// </div>
4922 pub async fn call_tool(
4923 &self,
4924 params: McpAppsCallToolRequest,
4925 ) -> Result<SessionMcpAppsCallToolResult, Error> {
4926 let mut wire_params = serde_json::to_value(params)?;
4927 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4928 let _value = self
4929 .session
4930 .client()
4931 .call(rpc_methods::SESSION_MCP_APPS_CALLTOOL, Some(wire_params))
4932 .await?;
4933 Ok(serde_json::from_value(_value)?)
4934 }
4935
4936 /// 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.
4937 ///
4938 /// Wire method: `session.mcp.apps.setHostContext`.
4939 ///
4940 /// # Parameters
4941 ///
4942 /// * `params` - Host context to advertise to MCP App guests.
4943 ///
4944 /// <div class="warning">
4945 ///
4946 /// **Experimental.** This API is part of an experimental wire-protocol surface
4947 /// and may change or be removed in future SDK or CLI releases. Pin both the
4948 /// SDK and CLI versions if your code depends on it.
4949 ///
4950 /// </div>
4951 pub async fn set_host_context(
4952 &self,
4953 params: McpAppsSetHostContextRequest,
4954 ) -> Result<(), Error> {
4955 let mut wire_params = serde_json::to_value(params)?;
4956 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4957 let _value = self
4958 .session
4959 .client()
4960 .call(
4961 rpc_methods::SESSION_MCP_APPS_SETHOSTCONTEXT,
4962 Some(wire_params),
4963 )
4964 .await?;
4965 Ok(())
4966 }
4967
4968 /// Read the current host context advertised to MCP App guests.
4969 ///
4970 /// Wire method: `session.mcp.apps.getHostContext`.
4971 ///
4972 /// # Returns
4973 ///
4974 /// Current host context advertised to MCP App guests.
4975 ///
4976 /// <div class="warning">
4977 ///
4978 /// **Experimental.** This API is part of an experimental wire-protocol surface
4979 /// and may change or be removed in future SDK or CLI releases. Pin both the
4980 /// SDK and CLI versions if your code depends on it.
4981 ///
4982 /// </div>
4983 pub async fn get_host_context(&self) -> Result<McpAppsHostContext, Error> {
4984 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
4985 let _value = self
4986 .session
4987 .client()
4988 .call(
4989 rpc_methods::SESSION_MCP_APPS_GETHOSTCONTEXT,
4990 Some(wire_params),
4991 )
4992 .await?;
4993 Ok(serde_json::from_value(_value)?)
4994 }
4995
4996 /// 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.
4997 ///
4998 /// Wire method: `session.mcp.apps.diagnose`.
4999 ///
5000 /// # Parameters
5001 ///
5002 /// * `params` - MCP server to diagnose MCP Apps wiring for.
5003 ///
5004 /// # Returns
5005 ///
5006 /// Diagnostic snapshot of MCP Apps wiring for the named server.
5007 ///
5008 /// <div class="warning">
5009 ///
5010 /// **Experimental.** This API is part of an experimental wire-protocol surface
5011 /// and may change or be removed in future SDK or CLI releases. Pin both the
5012 /// SDK and CLI versions if your code depends on it.
5013 ///
5014 /// </div>
5015 pub async fn diagnose(
5016 &self,
5017 params: McpAppsDiagnoseRequest,
5018 ) -> Result<McpAppsDiagnoseResult, Error> {
5019 let mut wire_params = serde_json::to_value(params)?;
5020 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5021 let _value = self
5022 .session
5023 .client()
5024 .call(rpc_methods::SESSION_MCP_APPS_DIAGNOSE, Some(wire_params))
5025 .await?;
5026 Ok(serde_json::from_value(_value)?)
5027 }
5028}
5029
5030/// `session.mcp.headers.*` RPCs.
5031#[derive(Clone, Copy)]
5032pub struct SessionRpcMcpHeaders<'a> {
5033 pub(crate) session: &'a Session,
5034}
5035
5036impl<'a> SessionRpcMcpHeaders<'a> {
5037 /// 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.
5038 ///
5039 /// Wire method: `session.mcp.headers.handlePendingHeadersRefreshRequest`.
5040 ///
5041 /// # Parameters
5042 ///
5043 /// * `params` - MCP headers refresh request id and the host response.
5044 ///
5045 /// # Returns
5046 ///
5047 /// Indicates whether the pending MCP headers refresh response was accepted.
5048 ///
5049 /// <div class="warning">
5050 ///
5051 /// **Experimental.** This API is part of an experimental wire-protocol surface
5052 /// and may change or be removed in future SDK or CLI releases. Pin both the
5053 /// SDK and CLI versions if your code depends on it.
5054 ///
5055 /// </div>
5056 pub async fn handle_pending_headers_refresh_request(
5057 &self,
5058 params: McpHeadersHandlePendingHeadersRefreshRequestRequest,
5059 ) -> Result<McpHeadersHandlePendingHeadersRefreshRequestResult, Error> {
5060 let mut wire_params = serde_json::to_value(params)?;
5061 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5062 let _value = self
5063 .session
5064 .client()
5065 .call(
5066 rpc_methods::SESSION_MCP_HEADERS_HANDLEPENDINGHEADERSREFRESHREQUEST,
5067 Some(wire_params),
5068 )
5069 .await?;
5070 Ok(serde_json::from_value(_value)?)
5071 }
5072}
5073
5074/// `session.mcp.oauth.*` RPCs.
5075#[derive(Clone, Copy)]
5076pub struct SessionRpcMcpOauth<'a> {
5077 pub(crate) session: &'a Session,
5078}
5079
5080impl<'a> SessionRpcMcpOauth<'a> {
5081 /// 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.
5082 ///
5083 /// Wire method: `session.mcp.oauth.handlePendingRequest`.
5084 ///
5085 /// # Parameters
5086 ///
5087 /// * `params` - Pending MCP OAuth request ID and host-provided token or cancellation response.
5088 ///
5089 /// # Returns
5090 ///
5091 /// Indicates whether the pending MCP OAuth response was accepted.
5092 ///
5093 /// <div class="warning">
5094 ///
5095 /// **Experimental.** This API is part of an experimental wire-protocol surface
5096 /// and may change or be removed in future SDK or CLI releases. Pin both the
5097 /// SDK and CLI versions if your code depends on it.
5098 ///
5099 /// </div>
5100 pub async fn handle_pending_request(
5101 &self,
5102 params: McpOauthHandlePendingRequest,
5103 ) -> Result<McpOauthHandlePendingResult, Error> {
5104 let mut wire_params = serde_json::to_value(params)?;
5105 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5106 let _value = self
5107 .session
5108 .client()
5109 .call(
5110 rpc_methods::SESSION_MCP_OAUTH_HANDLEPENDINGREQUEST,
5111 Some(wire_params),
5112 )
5113 .await?;
5114 Ok(serde_json::from_value(_value)?)
5115 }
5116
5117 /// Starts OAuth authentication for a remote MCP server.
5118 ///
5119 /// Wire method: `session.mcp.oauth.login`.
5120 ///
5121 /// # Parameters
5122 ///
5123 /// * `params` - Remote MCP server name and optional overrides controlling reauthentication, OAuth client display name, callback success-page copy, and static OAuth client selection.
5124 ///
5125 /// # Returns
5126 ///
5127 /// OAuth authorization URL the caller should open, or empty when cached tokens already authenticated the server.
5128 ///
5129 /// <div class="warning">
5130 ///
5131 /// **Experimental.** This API is part of an experimental wire-protocol surface
5132 /// and may change or be removed in future SDK or CLI releases. Pin both the
5133 /// SDK and CLI versions if your code depends on it.
5134 ///
5135 /// </div>
5136 pub async fn login(&self, params: McpOauthLoginRequest) -> Result<McpOauthLoginResult, Error> {
5137 let mut wire_params = serde_json::to_value(params)?;
5138 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5139 let _value = self
5140 .session
5141 .client()
5142 .call(rpc_methods::SESSION_MCP_OAUTH_LOGIN, Some(wire_params))
5143 .await?;
5144 Ok(serde_json::from_value(_value)?)
5145 }
5146}
5147
5148/// `session.mcp.resources.*` RPCs.
5149#[derive(Clone, Copy)]
5150pub struct SessionRpcMcpResources<'a> {
5151 pub(crate) session: &'a Session,
5152}
5153
5154impl<'a> SessionRpcMcpResources<'a> {
5155 /// Fetch an MCP resource from a connected server by URI (proxies MCP `resources/read`).
5156 ///
5157 /// Wire method: `session.mcp.resources.read`.
5158 ///
5159 /// # Parameters
5160 ///
5161 /// * `params` - MCP server and resource URI to fetch.
5162 ///
5163 /// # Returns
5164 ///
5165 /// Resource contents returned by the MCP server.
5166 ///
5167 /// <div class="warning">
5168 ///
5169 /// **Experimental.** This API is part of an experimental wire-protocol surface
5170 /// and may change or be removed in future SDK or CLI releases. Pin both the
5171 /// SDK and CLI versions if your code depends on it.
5172 ///
5173 /// </div>
5174 pub async fn read(
5175 &self,
5176 params: McpResourcesReadRequest,
5177 ) -> Result<McpResourcesReadResult, Error> {
5178 let mut wire_params = serde_json::to_value(params)?;
5179 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5180 let _value = self
5181 .session
5182 .client()
5183 .call(rpc_methods::SESSION_MCP_RESOURCES_READ, Some(wire_params))
5184 .await?;
5185 Ok(serde_json::from_value(_value)?)
5186 }
5187
5188 /// Enumerate one page of resources a connected MCP server exposes (proxies MCP `resources/list`). Pass `cursor` to continue from a prior result's `nextCursor`.
5189 ///
5190 /// Wire method: `session.mcp.resources.list`.
5191 ///
5192 /// # Parameters
5193 ///
5194 /// * `params` - MCP server whose resources to enumerate.
5195 ///
5196 /// # Returns
5197 ///
5198 /// One page of resources advertised by the named MCP server.
5199 ///
5200 /// <div class="warning">
5201 ///
5202 /// **Experimental.** This API is part of an experimental wire-protocol surface
5203 /// and may change or be removed in future SDK or CLI releases. Pin both the
5204 /// SDK and CLI versions if your code depends on it.
5205 ///
5206 /// </div>
5207 pub async fn list(
5208 &self,
5209 params: McpResourcesListRequest,
5210 ) -> Result<McpResourcesListResult, Error> {
5211 let mut wire_params = serde_json::to_value(params)?;
5212 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5213 let _value = self
5214 .session
5215 .client()
5216 .call(rpc_methods::SESSION_MCP_RESOURCES_LIST, Some(wire_params))
5217 .await?;
5218 Ok(serde_json::from_value(_value)?)
5219 }
5220
5221 /// 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`.
5222 ///
5223 /// Wire method: `session.mcp.resources.listTemplates`.
5224 ///
5225 /// # Parameters
5226 ///
5227 /// * `params` - MCP server whose resource templates to enumerate.
5228 ///
5229 /// # Returns
5230 ///
5231 /// One page of resource templates advertised by the named MCP server.
5232 ///
5233 /// <div class="warning">
5234 ///
5235 /// **Experimental.** This API is part of an experimental wire-protocol surface
5236 /// and may change or be removed in future SDK or CLI releases. Pin both the
5237 /// SDK and CLI versions if your code depends on it.
5238 ///
5239 /// </div>
5240 pub async fn list_templates(
5241 &self,
5242 params: McpResourcesListTemplatesRequest,
5243 ) -> Result<McpResourcesListTemplatesResult, Error> {
5244 let mut wire_params = serde_json::to_value(params)?;
5245 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5246 let _value = self
5247 .session
5248 .client()
5249 .call(
5250 rpc_methods::SESSION_MCP_RESOURCES_LISTTEMPLATES,
5251 Some(wire_params),
5252 )
5253 .await?;
5254 Ok(serde_json::from_value(_value)?)
5255 }
5256}
5257
5258/// `session.metadata.*` RPCs.
5259#[derive(Clone, Copy)]
5260pub struct SessionRpcMetadata<'a> {
5261 pub(crate) session: &'a Session,
5262}
5263
5264impl<'a> SessionRpcMetadata<'a> {
5265 /// Returns a snapshot of the session's identifying metadata, mode, agent, and remote info.
5266 ///
5267 /// Wire method: `session.metadata.snapshot`.
5268 ///
5269 /// # Returns
5270 ///
5271 /// Point-in-time snapshot of slow-changing session identifier and state fields
5272 ///
5273 /// <div class="warning">
5274 ///
5275 /// **Experimental.** This API is part of an experimental wire-protocol surface
5276 /// and may change or be removed in future SDK or CLI releases. Pin both the
5277 /// SDK and CLI versions if your code depends on it.
5278 ///
5279 /// </div>
5280 pub async fn snapshot(&self) -> Result<SessionMetadataSnapshot, Error> {
5281 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5282 let _value = self
5283 .session
5284 .client()
5285 .call(rpc_methods::SESSION_METADATA_SNAPSHOT, Some(wire_params))
5286 .await?;
5287 Ok(serde_json::from_value(_value)?)
5288 }
5289
5290 /// Reports whether the local session is currently processing user/agent messages.
5291 ///
5292 /// Wire method: `session.metadata.isProcessing`.
5293 ///
5294 /// # Returns
5295 ///
5296 /// Indicates whether the local session is currently processing a turn or background continuation.
5297 ///
5298 /// <div class="warning">
5299 ///
5300 /// **Experimental.** This API is part of an experimental wire-protocol surface
5301 /// and may change or be removed in future SDK or CLI releases. Pin both the
5302 /// SDK and CLI versions if your code depends on it.
5303 ///
5304 /// </div>
5305 pub async fn is_processing(&self) -> Result<MetadataIsProcessingResult, Error> {
5306 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5307 let _value = self
5308 .session
5309 .client()
5310 .call(
5311 rpc_methods::SESSION_METADATA_ISPROCESSING,
5312 Some(wire_params),
5313 )
5314 .await?;
5315 Ok(serde_json::from_value(_value)?)
5316 }
5317
5318 /// Returns a snapshot of activity flags for the session.
5319 ///
5320 /// Wire method: `session.metadata.activity`.
5321 ///
5322 /// # Returns
5323 ///
5324 /// Current activity flags for the session.
5325 ///
5326 /// <div class="warning">
5327 ///
5328 /// **Experimental.** This API is part of an experimental wire-protocol surface
5329 /// and may change or be removed in future SDK or CLI releases. Pin both the
5330 /// SDK and CLI versions if your code depends on it.
5331 ///
5332 /// </div>
5333 pub async fn activity(&self) -> Result<SessionActivity, Error> {
5334 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5335 let _value = self
5336 .session
5337 .client()
5338 .call(rpc_methods::SESSION_METADATA_ACTIVITY, Some(wire_params))
5339 .await?;
5340 Ok(serde_json::from_value(_value)?)
5341 }
5342
5343 /// Returns the token breakdown for the session's current context window for a given model.
5344 ///
5345 /// Wire method: `session.metadata.contextInfo`.
5346 ///
5347 /// # Parameters
5348 ///
5349 /// * `params` - Model identifier and token limits used to compute the context-info breakdown.
5350 ///
5351 /// # Returns
5352 ///
5353 /// Token breakdown for the session's current context window, or null if uninitialized.
5354 ///
5355 /// <div class="warning">
5356 ///
5357 /// **Experimental.** This API is part of an experimental wire-protocol surface
5358 /// and may change or be removed in future SDK or CLI releases. Pin both the
5359 /// SDK and CLI versions if your code depends on it.
5360 ///
5361 /// </div>
5362 pub async fn context_info(
5363 &self,
5364 params: MetadataContextInfoRequest,
5365 ) -> Result<MetadataContextInfoResult, Error> {
5366 let mut wire_params = serde_json::to_value(params)?;
5367 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5368 let _value = self
5369 .session
5370 .client()
5371 .call(rpc_methods::SESSION_METADATA_CONTEXTINFO, Some(wire_params))
5372 .await?;
5373 Ok(serde_json::from_value(_value)?)
5374 }
5375
5376 /// 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.
5377 ///
5378 /// Wire method: `session.metadata.getContextAttribution`.
5379 ///
5380 /// # Returns
5381 ///
5382 /// Per-source attribution breakdown for the session's current context window, or null if uninitialized.
5383 ///
5384 /// <div class="warning">
5385 ///
5386 /// **Experimental.** This API is part of an experimental wire-protocol surface
5387 /// and may change or be removed in future SDK or CLI releases. Pin both the
5388 /// SDK and CLI versions if your code depends on it.
5389 ///
5390 /// </div>
5391 pub async fn get_context_attribution(&self) -> Result<MetadataContextAttributionResult, Error> {
5392 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5393 let _value = self
5394 .session
5395 .client()
5396 .call(
5397 rpc_methods::SESSION_METADATA_GETCONTEXTATTRIBUTION,
5398 Some(wire_params),
5399 )
5400 .await?;
5401 Ok(serde_json::from_value(_value)?)
5402 }
5403
5404 /// 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.
5405 ///
5406 /// Wire method: `session.metadata.getContextHeaviestMessages`.
5407 ///
5408 /// # Parameters
5409 ///
5410 /// * `params` - Parameters for the heaviest-messages query.
5411 ///
5412 /// # Returns
5413 ///
5414 /// The heaviest individual messages in the session's context window, most-expensive first.
5415 ///
5416 /// <div class="warning">
5417 ///
5418 /// **Experimental.** This API is part of an experimental wire-protocol surface
5419 /// and may change or be removed in future SDK or CLI releases. Pin both the
5420 /// SDK and CLI versions if your code depends on it.
5421 ///
5422 /// </div>
5423 pub async fn get_context_heaviest_messages(
5424 &self,
5425 params: MetadataContextHeaviestMessagesRequest,
5426 ) -> Result<MetadataContextHeaviestMessagesResult, Error> {
5427 let mut wire_params = serde_json::to_value(params)?;
5428 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5429 let _value = self
5430 .session
5431 .client()
5432 .call(
5433 rpc_methods::SESSION_METADATA_GETCONTEXTHEAVIESTMESSAGES,
5434 Some(wire_params),
5435 )
5436 .await?;
5437 Ok(serde_json::from_value(_value)?)
5438 }
5439
5440 /// Records a working-directory/git context change and emits a `session.context_changed` event.
5441 ///
5442 /// Wire method: `session.metadata.recordContextChange`.
5443 ///
5444 /// # Parameters
5445 ///
5446 /// * `params` - Updated working-directory/git context to record on the session.
5447 ///
5448 /// # Returns
5449 ///
5450 /// 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).
5451 ///
5452 /// <div class="warning">
5453 ///
5454 /// **Experimental.** This API is part of an experimental wire-protocol surface
5455 /// and may change or be removed in future SDK or CLI releases. Pin both the
5456 /// SDK and CLI versions if your code depends on it.
5457 ///
5458 /// </div>
5459 pub async fn record_context_change(
5460 &self,
5461 params: MetadataRecordContextChangeRequest,
5462 ) -> Result<MetadataRecordContextChangeResult, Error> {
5463 let mut wire_params = serde_json::to_value(params)?;
5464 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5465 let _value = self
5466 .session
5467 .client()
5468 .call(
5469 rpc_methods::SESSION_METADATA_RECORDCONTEXTCHANGE,
5470 Some(wire_params),
5471 )
5472 .await?;
5473 Ok(serde_json::from_value(_value)?)
5474 }
5475
5476 /// Updates the session's working directory. For local sessions the target is validated first (an absolute path that exists on disk) and the permission primary directory is re-based; a rejected validation fails the call before any session state changes.
5477 ///
5478 /// Wire method: `session.metadata.setWorkingDirectory`.
5479 ///
5480 /// # Parameters
5481 ///
5482 /// * `params` - Absolute path to set as the session's new working directory. For local sessions the path must be absolute and exist on disk: it is validated before any session state changes, and a failing validation rejects the call with nothing mutated, persisted, or emitted. Remote sessions record the path as-is.
5483 ///
5484 /// # Returns
5485 ///
5486 /// Update the session's working directory. Used by the host when the user explicitly changes cwd (e.g., the `/cd` slash command). The host is responsible for any related side-effects (file index, etc.); it does NOT change the process working directory (a session's cwd is per-session, not process-global). For local sessions the runtime validates the target first (an absolute path that exists on disk) and re-bases the permission primary directory; a rejected validation fails the call before anything is mutated, persisted, or emitted. Location-scoped permission rules are then re-keyed to the new directory (best-effort). Remote sessions only record the path.
5487 ///
5488 /// <div class="warning">
5489 ///
5490 /// **Experimental.** This API is part of an experimental wire-protocol surface
5491 /// and may change or be removed in future SDK or CLI releases. Pin both the
5492 /// SDK and CLI versions if your code depends on it.
5493 ///
5494 /// </div>
5495 pub async fn set_working_directory(
5496 &self,
5497 params: MetadataSetWorkingDirectoryRequest,
5498 ) -> Result<MetadataSetWorkingDirectoryResult, Error> {
5499 let mut wire_params = serde_json::to_value(params)?;
5500 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5501 let _value = self
5502 .session
5503 .client()
5504 .call(
5505 rpc_methods::SESSION_METADATA_SETWORKINGDIRECTORY,
5506 Some(wire_params),
5507 )
5508 .await?;
5509 Ok(serde_json::from_value(_value)?)
5510 }
5511
5512 /// Re-tokenizes the session's existing messages against a model and returns aggregate token totals.
5513 ///
5514 /// Wire method: `session.metadata.recomputeContextTokens`.
5515 ///
5516 /// # Parameters
5517 ///
5518 /// * `params` - Model identifier to use when re-tokenizing the session's existing messages.
5519 ///
5520 /// # Returns
5521 ///
5522 /// 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.
5523 ///
5524 /// <div class="warning">
5525 ///
5526 /// **Experimental.** This API is part of an experimental wire-protocol surface
5527 /// and may change or be removed in future SDK or CLI releases. Pin both the
5528 /// SDK and CLI versions if your code depends on it.
5529 ///
5530 /// </div>
5531 pub async fn recompute_context_tokens(
5532 &self,
5533 params: MetadataRecomputeContextTokensRequest,
5534 ) -> Result<MetadataRecomputeContextTokensResult, Error> {
5535 let mut wire_params = serde_json::to_value(params)?;
5536 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5537 let _value = self
5538 .session
5539 .client()
5540 .call(
5541 rpc_methods::SESSION_METADATA_RECOMPUTECONTEXTTOKENS,
5542 Some(wire_params),
5543 )
5544 .await?;
5545 Ok(serde_json::from_value(_value)?)
5546 }
5547}
5548
5549/// `session.mode.*` RPCs.
5550#[derive(Clone, Copy)]
5551pub struct SessionRpcMode<'a> {
5552 pub(crate) session: &'a Session,
5553}
5554
5555impl<'a> SessionRpcMode<'a> {
5556 /// Gets the current agent interaction mode.
5557 ///
5558 /// Wire method: `session.mode.get`.
5559 ///
5560 /// # Returns
5561 ///
5562 /// The session mode the agent is operating in
5563 ///
5564 /// <div class="warning">
5565 ///
5566 /// **Experimental.** This API is part of an experimental wire-protocol surface
5567 /// and may change or be removed in future SDK or CLI releases. Pin both the
5568 /// SDK and CLI versions if your code depends on it.
5569 ///
5570 /// </div>
5571 pub async fn get(&self) -> Result<SessionMode, Error> {
5572 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5573 let _value = self
5574 .session
5575 .client()
5576 .call(rpc_methods::SESSION_MODE_GET, Some(wire_params))
5577 .await?;
5578 Ok(serde_json::from_value(_value)?)
5579 }
5580
5581 /// Sets the current agent interaction mode.
5582 ///
5583 /// Wire method: `session.mode.set`.
5584 ///
5585 /// # Parameters
5586 ///
5587 /// * `params` - Agent interaction mode to apply to the session.
5588 ///
5589 /// <div class="warning">
5590 ///
5591 /// **Experimental.** This API is part of an experimental wire-protocol surface
5592 /// and may change or be removed in future SDK or CLI releases. Pin both the
5593 /// SDK and CLI versions if your code depends on it.
5594 ///
5595 /// </div>
5596 pub async fn set(&self, params: ModeSetRequest) -> Result<(), Error> {
5597 let mut wire_params = serde_json::to_value(params)?;
5598 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5599 let _value = self
5600 .session
5601 .client()
5602 .call(rpc_methods::SESSION_MODE_SET, Some(wire_params))
5603 .await?;
5604 Ok(())
5605 }
5606}
5607
5608/// `session.model.*` RPCs.
5609#[derive(Clone, Copy)]
5610pub struct SessionRpcModel<'a> {
5611 pub(crate) session: &'a Session,
5612}
5613
5614impl<'a> SessionRpcModel<'a> {
5615 /// Gets the currently selected model for the session.
5616 ///
5617 /// Wire method: `session.model.getCurrent`.
5618 ///
5619 /// # Returns
5620 ///
5621 /// 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.
5622 ///
5623 /// <div class="warning">
5624 ///
5625 /// **Experimental.** This API is part of an experimental wire-protocol surface
5626 /// and may change or be removed in future SDK or CLI releases. Pin both the
5627 /// SDK and CLI versions if your code depends on it.
5628 ///
5629 /// </div>
5630 pub async fn get_current(&self) -> Result<CurrentModel, Error> {
5631 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5632 let _value = self
5633 .session
5634 .client()
5635 .call(rpc_methods::SESSION_MODEL_GETCURRENT, Some(wire_params))
5636 .await?;
5637 Ok(serde_json::from_value(_value)?)
5638 }
5639
5640 /// Switches the session to a model and optional reasoning configuration.
5641 ///
5642 /// Wire method: `session.model.switchTo`.
5643 ///
5644 /// # Parameters
5645 ///
5646 /// * `params` - Target model identifier and optional reasoning effort, summary, capability overrides, and context tier.
5647 ///
5648 /// # Returns
5649 ///
5650 /// The model identifier active on the session after the switch.
5651 ///
5652 /// <div class="warning">
5653 ///
5654 /// **Experimental.** This API is part of an experimental wire-protocol surface
5655 /// and may change or be removed in future SDK or CLI releases. Pin both the
5656 /// SDK and CLI versions if your code depends on it.
5657 ///
5658 /// </div>
5659 pub async fn switch_to(
5660 &self,
5661 params: ModelSwitchToRequest,
5662 ) -> Result<ModelSwitchToResult, Error> {
5663 let mut wire_params = serde_json::to_value(params)?;
5664 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5665 let _value = self
5666 .session
5667 .client()
5668 .call(rpc_methods::SESSION_MODEL_SWITCHTO, Some(wire_params))
5669 .await?;
5670 Ok(serde_json::from_value(_value)?)
5671 }
5672
5673 /// Updates the session's reasoning effort without changing the selected model.
5674 ///
5675 /// Wire method: `session.model.setReasoningEffort`.
5676 ///
5677 /// # Parameters
5678 ///
5679 /// * `params` - Reasoning effort level to apply to the currently selected model.
5680 ///
5681 /// # Returns
5682 ///
5683 /// 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.
5684 ///
5685 /// <div class="warning">
5686 ///
5687 /// **Experimental.** This API is part of an experimental wire-protocol surface
5688 /// and may change or be removed in future SDK or CLI releases. Pin both the
5689 /// SDK and CLI versions if your code depends on it.
5690 ///
5691 /// </div>
5692 pub async fn set_reasoning_effort(
5693 &self,
5694 params: ModelSetReasoningEffortRequest,
5695 ) -> Result<ModelSetReasoningEffortResult, Error> {
5696 let mut wire_params = serde_json::to_value(params)?;
5697 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5698 let _value = self
5699 .session
5700 .client()
5701 .call(
5702 rpc_methods::SESSION_MODEL_SETREASONINGEFFORT,
5703 Some(wire_params),
5704 )
5705 .await?;
5706 Ok(serde_json::from_value(_value)?)
5707 }
5708
5709 /// 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.
5710 ///
5711 /// Wire method: `session.model.list`.
5712 ///
5713 /// # Returns
5714 ///
5715 /// The list of models available to this session.
5716 ///
5717 /// <div class="warning">
5718 ///
5719 /// **Experimental.** This API is part of an experimental wire-protocol surface
5720 /// and may change or be removed in future SDK or CLI releases. Pin both the
5721 /// SDK and CLI versions if your code depends on it.
5722 ///
5723 /// </div>
5724 pub async fn list(&self) -> Result<SessionModelList, Error> {
5725 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5726 let _value = self
5727 .session
5728 .client()
5729 .call(rpc_methods::SESSION_MODEL_LIST, Some(wire_params))
5730 .await?;
5731 Ok(serde_json::from_value(_value)?)
5732 }
5733
5734 /// 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.
5735 ///
5736 /// Wire method: `session.model.list`.
5737 ///
5738 /// # Parameters
5739 ///
5740 /// * `params` - Optional listing options.
5741 ///
5742 /// # Returns
5743 ///
5744 /// The list of models available to this session.
5745 ///
5746 /// <div class="warning">
5747 ///
5748 /// **Experimental.** This API is part of an experimental wire-protocol surface
5749 /// and may change or be removed in future SDK or CLI releases. Pin both the
5750 /// SDK and CLI versions if your code depends on it.
5751 ///
5752 /// </div>
5753 pub async fn list_with_params(
5754 &self,
5755 params: ModelListRequest,
5756 ) -> Result<SessionModelList, Error> {
5757 let mut wire_params = serde_json::to_value(params)?;
5758 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5759 let _value = self
5760 .session
5761 .client()
5762 .call(rpc_methods::SESSION_MODEL_LIST, Some(wire_params))
5763 .await?;
5764 Ok(serde_json::from_value(_value)?)
5765 }
5766}
5767
5768/// `session.name.*` RPCs.
5769#[derive(Clone, Copy)]
5770pub struct SessionRpcName<'a> {
5771 pub(crate) session: &'a Session,
5772}
5773
5774impl<'a> SessionRpcName<'a> {
5775 /// Gets the session's friendly name.
5776 ///
5777 /// Wire method: `session.name.get`.
5778 ///
5779 /// # Returns
5780 ///
5781 /// The session's friendly name, or null when not yet set.
5782 ///
5783 /// <div class="warning">
5784 ///
5785 /// **Experimental.** This API is part of an experimental wire-protocol surface
5786 /// and may change or be removed in future SDK or CLI releases. Pin both the
5787 /// SDK and CLI versions if your code depends on it.
5788 ///
5789 /// </div>
5790 pub async fn get(&self) -> Result<NameGetResult, Error> {
5791 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5792 let _value = self
5793 .session
5794 .client()
5795 .call(rpc_methods::SESSION_NAME_GET, Some(wire_params))
5796 .await?;
5797 Ok(serde_json::from_value(_value)?)
5798 }
5799
5800 /// Sets the session's friendly name.
5801 ///
5802 /// Wire method: `session.name.set`.
5803 ///
5804 /// # Parameters
5805 ///
5806 /// * `params` - New friendly name to apply to the session.
5807 ///
5808 /// <div class="warning">
5809 ///
5810 /// **Experimental.** This API is part of an experimental wire-protocol surface
5811 /// and may change or be removed in future SDK or CLI releases. Pin both the
5812 /// SDK and CLI versions if your code depends on it.
5813 ///
5814 /// </div>
5815 pub async fn set(&self, params: NameSetRequest) -> Result<(), Error> {
5816 let mut wire_params = serde_json::to_value(params)?;
5817 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5818 let _value = self
5819 .session
5820 .client()
5821 .call(rpc_methods::SESSION_NAME_SET, Some(wire_params))
5822 .await?;
5823 Ok(())
5824 }
5825
5826 /// Persists an auto-generated session summary as the session's name when no user-set name exists.
5827 ///
5828 /// Wire method: `session.name.setAuto`.
5829 ///
5830 /// # Parameters
5831 ///
5832 /// * `params` - Auto-generated session summary to apply as the session's name when no user-set name exists.
5833 ///
5834 /// # Returns
5835 ///
5836 /// Indicates whether the auto-generated summary was applied as the session's name.
5837 ///
5838 /// <div class="warning">
5839 ///
5840 /// **Experimental.** This API is part of an experimental wire-protocol surface
5841 /// and may change or be removed in future SDK or CLI releases. Pin both the
5842 /// SDK and CLI versions if your code depends on it.
5843 ///
5844 /// </div>
5845 pub async fn set_auto(&self, params: NameSetAutoRequest) -> Result<NameSetAutoResult, Error> {
5846 let mut wire_params = serde_json::to_value(params)?;
5847 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5848 let _value = self
5849 .session
5850 .client()
5851 .call(rpc_methods::SESSION_NAME_SETAUTO, Some(wire_params))
5852 .await?;
5853 Ok(serde_json::from_value(_value)?)
5854 }
5855}
5856
5857/// `session.options.*` RPCs.
5858#[derive(Clone, Copy)]
5859pub struct SessionRpcOptions<'a> {
5860 pub(crate) session: &'a Session,
5861}
5862
5863impl<'a> SessionRpcOptions<'a> {
5864 /// Patches the genuinely-mutable subset of session options.
5865 ///
5866 /// Wire method: `session.options.update`.
5867 ///
5868 /// # Parameters
5869 ///
5870 /// * `params` - Patch of mutable session options to apply to the running session.
5871 ///
5872 /// # Returns
5873 ///
5874 /// Indicates whether the session options patch was applied successfully.
5875 ///
5876 /// <div class="warning">
5877 ///
5878 /// **Experimental.** This API is part of an experimental wire-protocol surface
5879 /// and may change or be removed in future SDK or CLI releases. Pin both the
5880 /// SDK and CLI versions if your code depends on it.
5881 ///
5882 /// </div>
5883 pub async fn update(
5884 &self,
5885 params: SessionUpdateOptionsParams,
5886 ) -> Result<SessionUpdateOptionsResult, Error> {
5887 let mut wire_params = serde_json::to_value(params)?;
5888 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5889 let _value = self
5890 .session
5891 .client()
5892 .call(rpc_methods::SESSION_OPTIONS_UPDATE, Some(wire_params))
5893 .await?;
5894 Ok(serde_json::from_value(_value)?)
5895 }
5896}
5897
5898/// `session.permissions.*` RPCs.
5899#[derive(Clone, Copy)]
5900pub struct SessionRpcPermissions<'a> {
5901 pub(crate) session: &'a Session,
5902}
5903
5904impl<'a> SessionRpcPermissions<'a> {
5905 /// `session.permissions.folderTrust.*` sub-namespace.
5906 pub fn folder_trust(&self) -> SessionRpcPermissionsFolderTrust<'a> {
5907 SessionRpcPermissionsFolderTrust {
5908 session: self.session,
5909 }
5910 }
5911
5912 /// `session.permissions.locations.*` sub-namespace.
5913 pub fn locations(&self) -> SessionRpcPermissionsLocations<'a> {
5914 SessionRpcPermissionsLocations {
5915 session: self.session,
5916 }
5917 }
5918
5919 /// `session.permissions.paths.*` sub-namespace.
5920 pub fn paths(&self) -> SessionRpcPermissionsPaths<'a> {
5921 SessionRpcPermissionsPaths {
5922 session: self.session,
5923 }
5924 }
5925
5926 /// `session.permissions.urls.*` sub-namespace.
5927 pub fn urls(&self) -> SessionRpcPermissionsUrls<'a> {
5928 SessionRpcPermissionsUrls {
5929 session: self.session,
5930 }
5931 }
5932
5933 /// Replaces selected permission policy fields (rules, paths, URLs, exclusions, allow-all flags) on the session.
5934 ///
5935 /// Wire method: `session.permissions.configure`.
5936 ///
5937 /// # Parameters
5938 ///
5939 /// * `params` - Patch of permission policy fields to apply (omit a field to leave it unchanged).
5940 ///
5941 /// # Returns
5942 ///
5943 /// Indicates whether the operation succeeded.
5944 ///
5945 /// <div class="warning">
5946 ///
5947 /// **Experimental.** This API is part of an experimental wire-protocol surface
5948 /// and may change or be removed in future SDK or CLI releases. Pin both the
5949 /// SDK and CLI versions if your code depends on it.
5950 ///
5951 /// </div>
5952 pub async fn configure(
5953 &self,
5954 params: PermissionsConfigureParams,
5955 ) -> Result<PermissionsConfigureResult, Error> {
5956 let mut wire_params = serde_json::to_value(params)?;
5957 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5958 let _value = self
5959 .session
5960 .client()
5961 .call(
5962 rpc_methods::SESSION_PERMISSIONS_CONFIGURE,
5963 Some(wire_params),
5964 )
5965 .await?;
5966 Ok(serde_json::from_value(_value)?)
5967 }
5968
5969 /// Provides a decision for a pending tool permission request.
5970 ///
5971 /// Wire method: `session.permissions.handlePendingPermissionRequest`.
5972 ///
5973 /// # Parameters
5974 ///
5975 /// * `params` - Pending permission request ID and the decision to apply (approve/reject and scope).
5976 ///
5977 /// # Returns
5978 ///
5979 /// Indicates whether the permission decision was applied; false when the request was already resolved.
5980 ///
5981 /// <div class="warning">
5982 ///
5983 /// **Experimental.** This API is part of an experimental wire-protocol surface
5984 /// and may change or be removed in future SDK or CLI releases. Pin both the
5985 /// SDK and CLI versions if your code depends on it.
5986 ///
5987 /// </div>
5988 pub async fn handle_pending_permission_request(
5989 &self,
5990 params: PermissionDecisionRequest,
5991 ) -> Result<PermissionRequestResult, Error> {
5992 let mut wire_params = serde_json::to_value(params)?;
5993 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5994 let _value = self
5995 .session
5996 .client()
5997 .call(
5998 rpc_methods::SESSION_PERMISSIONS_HANDLEPENDINGPERMISSIONREQUEST,
5999 Some(wire_params),
6000 )
6001 .await?;
6002 Ok(serde_json::from_value(_value)?)
6003 }
6004
6005 /// Reconstructs the set of pending tool permission requests from the session's event history.
6006 ///
6007 /// Wire method: `session.permissions.pendingRequests`.
6008 ///
6009 /// # Returns
6010 ///
6011 /// List of pending permission requests reconstructed from event history.
6012 ///
6013 /// <div class="warning">
6014 ///
6015 /// **Experimental.** This API is part of an experimental wire-protocol surface
6016 /// and may change or be removed in future SDK or CLI releases. Pin both the
6017 /// SDK and CLI versions if your code depends on it.
6018 ///
6019 /// </div>
6020 pub async fn pending_requests(&self) -> Result<PendingPermissionRequestList, Error> {
6021 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6022 let _value = self
6023 .session
6024 .client()
6025 .call(
6026 rpc_methods::SESSION_PERMISSIONS_PENDINGREQUESTS,
6027 Some(wire_params),
6028 )
6029 .await?;
6030 Ok(serde_json::from_value(_value)?)
6031 }
6032
6033 /// Enables or disables automatic approval of tool permission requests for the session.
6034 ///
6035 /// Wire method: `session.permissions.setApproveAll`.
6036 ///
6037 /// # Parameters
6038 ///
6039 /// * `params` - Allow-all toggle for tool permission requests, with an optional telemetry source.
6040 ///
6041 /// # Returns
6042 ///
6043 /// Indicates whether the operation succeeded.
6044 ///
6045 /// <div class="warning">
6046 ///
6047 /// **Experimental.** This API is part of an experimental wire-protocol surface
6048 /// and may change or be removed in future SDK or CLI releases. Pin both the
6049 /// SDK and CLI versions if your code depends on it.
6050 ///
6051 /// </div>
6052 pub async fn set_approve_all(
6053 &self,
6054 params: PermissionsSetApproveAllRequest,
6055 ) -> Result<PermissionsSetApproveAllResult, Error> {
6056 let mut wire_params = serde_json::to_value(params)?;
6057 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6058 let _value = self
6059 .session
6060 .client()
6061 .call(
6062 rpc_methods::SESSION_PERMISSIONS_SETAPPROVEALL,
6063 Some(wire_params),
6064 )
6065 .await?;
6066 Ok(serde_json::from_value(_value)?)
6067 }
6068
6069 /// 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.
6070 ///
6071 /// Wire method: `session.permissions.setAllowAll`.
6072 ///
6073 /// # Parameters
6074 ///
6075 /// * `params` - Allow-all mode to apply for the session.
6076 ///
6077 /// # Returns
6078 ///
6079 /// Indicates whether the operation succeeded and reports the post-mutation state.
6080 ///
6081 /// <div class="warning">
6082 ///
6083 /// **Experimental.** This API is part of an experimental wire-protocol surface
6084 /// and may change or be removed in future SDK or CLI releases. Pin both the
6085 /// SDK and CLI versions if your code depends on it.
6086 ///
6087 /// </div>
6088 pub async fn set_allow_all(
6089 &self,
6090 params: PermissionsSetAllowAllRequest,
6091 ) -> Result<AllowAllPermissionSetResult, Error> {
6092 let mut wire_params = serde_json::to_value(params)?;
6093 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6094 let _value = self
6095 .session
6096 .client()
6097 .call(
6098 rpc_methods::SESSION_PERMISSIONS_SETALLOWALL,
6099 Some(wire_params),
6100 )
6101 .await?;
6102 Ok(serde_json::from_value(_value)?)
6103 }
6104
6105 /// Returns the current allow-all permission mode for the session.
6106 ///
6107 /// Wire method: `session.permissions.getAllowAll`.
6108 ///
6109 /// # Returns
6110 ///
6111 /// Current allow-all permission mode.
6112 ///
6113 /// <div class="warning">
6114 ///
6115 /// **Experimental.** This API is part of an experimental wire-protocol surface
6116 /// and may change or be removed in future SDK or CLI releases. Pin both the
6117 /// SDK and CLI versions if your code depends on it.
6118 ///
6119 /// </div>
6120 pub async fn get_allow_all(&self) -> Result<AllowAllPermissionState, Error> {
6121 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6122 let _value = self
6123 .session
6124 .client()
6125 .call(
6126 rpc_methods::SESSION_PERMISSIONS_GETALLOWALL,
6127 Some(wire_params),
6128 )
6129 .await?;
6130 Ok(serde_json::from_value(_value)?)
6131 }
6132
6133 /// Adds or removes session-scoped or location-scoped permission rules.
6134 ///
6135 /// Wire method: `session.permissions.modifyRules`.
6136 ///
6137 /// # Parameters
6138 ///
6139 /// * `params` - Scope and add/remove instructions for modifying session- or location-scoped permission rules.
6140 ///
6141 /// # Returns
6142 ///
6143 /// Indicates whether the operation succeeded.
6144 ///
6145 /// <div class="warning">
6146 ///
6147 /// **Experimental.** This API is part of an experimental wire-protocol surface
6148 /// and may change or be removed in future SDK or CLI releases. Pin both the
6149 /// SDK and CLI versions if your code depends on it.
6150 ///
6151 /// </div>
6152 pub async fn modify_rules(
6153 &self,
6154 params: PermissionsModifyRulesParams,
6155 ) -> Result<PermissionsModifyRulesResult, Error> {
6156 let mut wire_params = serde_json::to_value(params)?;
6157 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6158 let _value = self
6159 .session
6160 .client()
6161 .call(
6162 rpc_methods::SESSION_PERMISSIONS_MODIFYRULES,
6163 Some(wire_params),
6164 )
6165 .await?;
6166 Ok(serde_json::from_value(_value)?)
6167 }
6168
6169 /// Sets whether the client wants permission prompts bridged into session events.
6170 ///
6171 /// Wire method: `session.permissions.setRequired`.
6172 ///
6173 /// # Parameters
6174 ///
6175 /// * `params` - Toggles whether permission prompts should be bridged into session events for this client.
6176 ///
6177 /// # Returns
6178 ///
6179 /// Indicates whether the operation succeeded.
6180 ///
6181 /// <div class="warning">
6182 ///
6183 /// **Experimental.** This API is part of an experimental wire-protocol surface
6184 /// and may change or be removed in future SDK or CLI releases. Pin both the
6185 /// SDK and CLI versions if your code depends on it.
6186 ///
6187 /// </div>
6188 pub async fn set_required(
6189 &self,
6190 params: PermissionsSetRequiredRequest,
6191 ) -> Result<PermissionsSetRequiredResult, Error> {
6192 let mut wire_params = serde_json::to_value(params)?;
6193 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6194 let _value = self
6195 .session
6196 .client()
6197 .call(
6198 rpc_methods::SESSION_PERMISSIONS_SETREQUIRED,
6199 Some(wire_params),
6200 )
6201 .await?;
6202 Ok(serde_json::from_value(_value)?)
6203 }
6204
6205 /// Clears session-scoped tool permission approvals.
6206 ///
6207 /// Wire method: `session.permissions.resetSessionApprovals`.
6208 ///
6209 /// # Returns
6210 ///
6211 /// Indicates whether the operation succeeded.
6212 ///
6213 /// <div class="warning">
6214 ///
6215 /// **Experimental.** This API is part of an experimental wire-protocol surface
6216 /// and may change or be removed in future SDK or CLI releases. Pin both the
6217 /// SDK and CLI versions if your code depends on it.
6218 ///
6219 /// </div>
6220 pub async fn reset_session_approvals(
6221 &self,
6222 ) -> Result<PermissionsResetSessionApprovalsResult, Error> {
6223 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6224 let _value = self
6225 .session
6226 .client()
6227 .call(
6228 rpc_methods::SESSION_PERMISSIONS_RESETSESSIONAPPROVALS,
6229 Some(wire_params),
6230 )
6231 .await?;
6232 Ok(serde_json::from_value(_value)?)
6233 }
6234
6235 /// Notifies the runtime that a permission prompt UI has been shown to the user.
6236 ///
6237 /// Wire method: `session.permissions.notifyPromptShown`.
6238 ///
6239 /// # Parameters
6240 ///
6241 /// * `params` - Notification payload describing the permission prompt that the client just rendered.
6242 ///
6243 /// # Returns
6244 ///
6245 /// Indicates whether the operation succeeded.
6246 ///
6247 /// <div class="warning">
6248 ///
6249 /// **Experimental.** This API is part of an experimental wire-protocol surface
6250 /// and may change or be removed in future SDK or CLI releases. Pin both the
6251 /// SDK and CLI versions if your code depends on it.
6252 ///
6253 /// </div>
6254 pub async fn notify_prompt_shown(
6255 &self,
6256 params: PermissionPromptShownNotification,
6257 ) -> Result<PermissionsNotifyPromptShownResult, Error> {
6258 let mut wire_params = serde_json::to_value(params)?;
6259 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6260 let _value = self
6261 .session
6262 .client()
6263 .call(
6264 rpc_methods::SESSION_PERMISSIONS_NOTIFYPROMPTSHOWN,
6265 Some(wire_params),
6266 )
6267 .await?;
6268 Ok(serde_json::from_value(_value)?)
6269 }
6270}
6271
6272/// `session.permissions.folderTrust.*` RPCs.
6273#[derive(Clone, Copy)]
6274pub struct SessionRpcPermissionsFolderTrust<'a> {
6275 pub(crate) session: &'a Session,
6276}
6277
6278impl<'a> SessionRpcPermissionsFolderTrust<'a> {
6279 /// Reports whether a folder is trusted according to the user's folder trust state.
6280 ///
6281 /// Wire method: `session.permissions.folderTrust.isTrusted`.
6282 ///
6283 /// # Parameters
6284 ///
6285 /// * `params` - Folder path to check for trust.
6286 ///
6287 /// # Returns
6288 ///
6289 /// Folder trust check result.
6290 ///
6291 /// <div class="warning">
6292 ///
6293 /// **Experimental.** This API is part of an experimental wire-protocol surface
6294 /// and may change or be removed in future SDK or CLI releases. Pin both the
6295 /// SDK and CLI versions if your code depends on it.
6296 ///
6297 /// </div>
6298 pub async fn is_trusted(
6299 &self,
6300 params: FolderTrustCheckParams,
6301 ) -> Result<FolderTrustCheckResult, Error> {
6302 let mut wire_params = serde_json::to_value(params)?;
6303 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6304 let _value = self
6305 .session
6306 .client()
6307 .call(
6308 rpc_methods::SESSION_PERMISSIONS_FOLDERTRUST_ISTRUSTED,
6309 Some(wire_params),
6310 )
6311 .await?;
6312 Ok(serde_json::from_value(_value)?)
6313 }
6314
6315 /// Adds a folder to the user's trusted folders list.
6316 ///
6317 /// Wire method: `session.permissions.folderTrust.addTrusted`.
6318 ///
6319 /// # Parameters
6320 ///
6321 /// * `params` - Folder path to add to trusted folders.
6322 ///
6323 /// # Returns
6324 ///
6325 /// Indicates whether the operation succeeded.
6326 ///
6327 /// <div class="warning">
6328 ///
6329 /// **Experimental.** This API is part of an experimental wire-protocol surface
6330 /// and may change or be removed in future SDK or CLI releases. Pin both the
6331 /// SDK and CLI versions if your code depends on it.
6332 ///
6333 /// </div>
6334 pub async fn add_trusted(
6335 &self,
6336 params: FolderTrustAddParams,
6337 ) -> Result<PermissionsFolderTrustAddTrustedResult, Error> {
6338 let mut wire_params = serde_json::to_value(params)?;
6339 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6340 let _value = self
6341 .session
6342 .client()
6343 .call(
6344 rpc_methods::SESSION_PERMISSIONS_FOLDERTRUST_ADDTRUSTED,
6345 Some(wire_params),
6346 )
6347 .await?;
6348 Ok(serde_json::from_value(_value)?)
6349 }
6350}
6351
6352/// `session.permissions.locations.*` RPCs.
6353#[derive(Clone, Copy)]
6354pub struct SessionRpcPermissionsLocations<'a> {
6355 pub(crate) session: &'a Session,
6356}
6357
6358impl<'a> SessionRpcPermissionsLocations<'a> {
6359 /// Resolves the permission location key and type for a working directory.
6360 ///
6361 /// Wire method: `session.permissions.locations.resolve`.
6362 ///
6363 /// # Parameters
6364 ///
6365 /// * `params` - Working directory to resolve into a location-permissions key.
6366 ///
6367 /// # Returns
6368 ///
6369 /// Resolved location-permissions key and type.
6370 ///
6371 /// <div class="warning">
6372 ///
6373 /// **Experimental.** This API is part of an experimental wire-protocol surface
6374 /// and may change or be removed in future SDK or CLI releases. Pin both the
6375 /// SDK and CLI versions if your code depends on it.
6376 ///
6377 /// </div>
6378 pub async fn resolve(
6379 &self,
6380 params: PermissionLocationResolveParams,
6381 ) -> Result<PermissionLocationResolveResult, Error> {
6382 let mut wire_params = serde_json::to_value(params)?;
6383 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6384 let _value = self
6385 .session
6386 .client()
6387 .call(
6388 rpc_methods::SESSION_PERMISSIONS_LOCATIONS_RESOLVE,
6389 Some(wire_params),
6390 )
6391 .await?;
6392 Ok(serde_json::from_value(_value)?)
6393 }
6394
6395 /// Applies persisted location-scoped tool approvals and allowed directories for a working directory to this session's permission service.
6396 ///
6397 /// Wire method: `session.permissions.locations.apply`.
6398 ///
6399 /// # Parameters
6400 ///
6401 /// * `params` - Working directory to load persisted location permissions for.
6402 ///
6403 /// # Returns
6404 ///
6405 /// Summary of persisted location permissions applied to the session.
6406 ///
6407 /// <div class="warning">
6408 ///
6409 /// **Experimental.** This API is part of an experimental wire-protocol surface
6410 /// and may change or be removed in future SDK or CLI releases. Pin both the
6411 /// SDK and CLI versions if your code depends on it.
6412 ///
6413 /// </div>
6414 pub async fn apply(
6415 &self,
6416 params: PermissionLocationApplyParams,
6417 ) -> Result<PermissionLocationApplyResult, Error> {
6418 let mut wire_params = serde_json::to_value(params)?;
6419 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6420 let _value = self
6421 .session
6422 .client()
6423 .call(
6424 rpc_methods::SESSION_PERMISSIONS_LOCATIONS_APPLY,
6425 Some(wire_params),
6426 )
6427 .await?;
6428 Ok(serde_json::from_value(_value)?)
6429 }
6430
6431 /// Persists a tool approval for a permission location and applies its rules to this session's live permission service.
6432 ///
6433 /// Wire method: `session.permissions.locations.addToolApproval`.
6434 ///
6435 /// # Parameters
6436 ///
6437 /// * `params` - Location-scoped tool approval to persist.
6438 ///
6439 /// # Returns
6440 ///
6441 /// Indicates whether the operation succeeded.
6442 ///
6443 /// <div class="warning">
6444 ///
6445 /// **Experimental.** This API is part of an experimental wire-protocol surface
6446 /// and may change or be removed in future SDK or CLI releases. Pin both the
6447 /// SDK and CLI versions if your code depends on it.
6448 ///
6449 /// </div>
6450 pub async fn add_tool_approval(
6451 &self,
6452 params: PermissionLocationAddToolApprovalParams,
6453 ) -> Result<PermissionsLocationsAddToolApprovalResult, Error> {
6454 let mut wire_params = serde_json::to_value(params)?;
6455 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6456 let _value = self
6457 .session
6458 .client()
6459 .call(
6460 rpc_methods::SESSION_PERMISSIONS_LOCATIONS_ADDTOOLAPPROVAL,
6461 Some(wire_params),
6462 )
6463 .await?;
6464 Ok(serde_json::from_value(_value)?)
6465 }
6466}
6467
6468/// `session.permissions.paths.*` RPCs.
6469#[derive(Clone, Copy)]
6470pub struct SessionRpcPermissionsPaths<'a> {
6471 pub(crate) session: &'a Session,
6472}
6473
6474impl<'a> SessionRpcPermissionsPaths<'a> {
6475 /// Returns the session's allowed directories and primary working directory.
6476 ///
6477 /// Wire method: `session.permissions.paths.list`.
6478 ///
6479 /// # Returns
6480 ///
6481 /// Snapshot of the session's allow-listed directories and primary working directory.
6482 ///
6483 /// <div class="warning">
6484 ///
6485 /// **Experimental.** This API is part of an experimental wire-protocol surface
6486 /// and may change or be removed in future SDK or CLI releases. Pin both the
6487 /// SDK and CLI versions if your code depends on it.
6488 ///
6489 /// </div>
6490 pub async fn list(&self) -> Result<PermissionPathsList, Error> {
6491 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6492 let _value = self
6493 .session
6494 .client()
6495 .call(
6496 rpc_methods::SESSION_PERMISSIONS_PATHS_LIST,
6497 Some(wire_params),
6498 )
6499 .await?;
6500 Ok(serde_json::from_value(_value)?)
6501 }
6502
6503 /// Adds a directory to the session's allow-list.
6504 ///
6505 /// Wire method: `session.permissions.paths.add`.
6506 ///
6507 /// # Parameters
6508 ///
6509 /// * `params` - Directory path to add to the session's allowed directories.
6510 ///
6511 /// # Returns
6512 ///
6513 /// Indicates whether the operation succeeded.
6514 ///
6515 /// <div class="warning">
6516 ///
6517 /// **Experimental.** This API is part of an experimental wire-protocol surface
6518 /// and may change or be removed in future SDK or CLI releases. Pin both the
6519 /// SDK and CLI versions if your code depends on it.
6520 ///
6521 /// </div>
6522 pub async fn add(
6523 &self,
6524 params: PermissionPathsAddParams,
6525 ) -> Result<PermissionsPathsAddResult, Error> {
6526 let mut wire_params = serde_json::to_value(params)?;
6527 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6528 let _value = self
6529 .session
6530 .client()
6531 .call(
6532 rpc_methods::SESSION_PERMISSIONS_PATHS_ADD,
6533 Some(wire_params),
6534 )
6535 .await?;
6536 Ok(serde_json::from_value(_value)?)
6537 }
6538
6539 /// Updates the session's primary working directory used by the permission policy.
6540 ///
6541 /// Wire method: `session.permissions.paths.updatePrimary`.
6542 ///
6543 /// # Parameters
6544 ///
6545 /// * `params` - Directory path to set as the session's new primary working directory.
6546 ///
6547 /// # Returns
6548 ///
6549 /// Indicates whether the operation succeeded.
6550 ///
6551 /// <div class="warning">
6552 ///
6553 /// **Experimental.** This API is part of an experimental wire-protocol surface
6554 /// and may change or be removed in future SDK or CLI releases. Pin both the
6555 /// SDK and CLI versions if your code depends on it.
6556 ///
6557 /// </div>
6558 pub async fn update_primary(
6559 &self,
6560 params: PermissionPathsUpdatePrimaryParams,
6561 ) -> Result<PermissionsPathsUpdatePrimaryResult, Error> {
6562 let mut wire_params = serde_json::to_value(params)?;
6563 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6564 let _value = self
6565 .session
6566 .client()
6567 .call(
6568 rpc_methods::SESSION_PERMISSIONS_PATHS_UPDATEPRIMARY,
6569 Some(wire_params),
6570 )
6571 .await?;
6572 Ok(serde_json::from_value(_value)?)
6573 }
6574
6575 /// Reports whether a path falls within any of the session's allowed directories.
6576 ///
6577 /// Wire method: `session.permissions.paths.isPathWithinAllowedDirectories`.
6578 ///
6579 /// # Parameters
6580 ///
6581 /// * `params` - Path to evaluate against the session's allowed directories.
6582 ///
6583 /// # Returns
6584 ///
6585 /// Indicates whether the supplied path is within the session's allowed directories.
6586 ///
6587 /// <div class="warning">
6588 ///
6589 /// **Experimental.** This API is part of an experimental wire-protocol surface
6590 /// and may change or be removed in future SDK or CLI releases. Pin both the
6591 /// SDK and CLI versions if your code depends on it.
6592 ///
6593 /// </div>
6594 pub async fn is_path_within_allowed_directories(
6595 &self,
6596 params: PermissionPathsAllowedCheckParams,
6597 ) -> Result<PermissionPathsAllowedCheckResult, Error> {
6598 let mut wire_params = serde_json::to_value(params)?;
6599 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6600 let _value = self
6601 .session
6602 .client()
6603 .call(
6604 rpc_methods::SESSION_PERMISSIONS_PATHS_ISPATHWITHINALLOWEDDIRECTORIES,
6605 Some(wire_params),
6606 )
6607 .await?;
6608 Ok(serde_json::from_value(_value)?)
6609 }
6610
6611 /// Reports whether a path falls within the session's workspace (primary) directory.
6612 ///
6613 /// Wire method: `session.permissions.paths.isPathWithinWorkspace`.
6614 ///
6615 /// # Parameters
6616 ///
6617 /// * `params` - Path to evaluate against the session's workspace (primary) directory.
6618 ///
6619 /// # Returns
6620 ///
6621 /// Indicates whether the supplied path is within the session's workspace directory.
6622 ///
6623 /// <div class="warning">
6624 ///
6625 /// **Experimental.** This API is part of an experimental wire-protocol surface
6626 /// and may change or be removed in future SDK or CLI releases. Pin both the
6627 /// SDK and CLI versions if your code depends on it.
6628 ///
6629 /// </div>
6630 pub async fn is_path_within_workspace(
6631 &self,
6632 params: PermissionPathsWorkspaceCheckParams,
6633 ) -> Result<PermissionPathsWorkspaceCheckResult, Error> {
6634 let mut wire_params = serde_json::to_value(params)?;
6635 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6636 let _value = self
6637 .session
6638 .client()
6639 .call(
6640 rpc_methods::SESSION_PERMISSIONS_PATHS_ISPATHWITHINWORKSPACE,
6641 Some(wire_params),
6642 )
6643 .await?;
6644 Ok(serde_json::from_value(_value)?)
6645 }
6646}
6647
6648/// `session.permissions.urls.*` RPCs.
6649#[derive(Clone, Copy)]
6650pub struct SessionRpcPermissionsUrls<'a> {
6651 pub(crate) session: &'a Session,
6652}
6653
6654impl<'a> SessionRpcPermissionsUrls<'a> {
6655 /// Toggles the runtime's URL-permission policy between unrestricted and restricted modes.
6656 ///
6657 /// Wire method: `session.permissions.urls.setUnrestrictedMode`.
6658 ///
6659 /// # Parameters
6660 ///
6661 /// * `params` - Whether the URL-permission policy should run in unrestricted mode.
6662 ///
6663 /// # Returns
6664 ///
6665 /// Indicates whether the operation succeeded.
6666 ///
6667 /// <div class="warning">
6668 ///
6669 /// **Experimental.** This API is part of an experimental wire-protocol surface
6670 /// and may change or be removed in future SDK or CLI releases. Pin both the
6671 /// SDK and CLI versions if your code depends on it.
6672 ///
6673 /// </div>
6674 pub async fn set_unrestricted_mode(
6675 &self,
6676 params: PermissionUrlsSetUnrestrictedModeParams,
6677 ) -> Result<PermissionsUrlsSetUnrestrictedModeResult, Error> {
6678 let mut wire_params = serde_json::to_value(params)?;
6679 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6680 let _value = self
6681 .session
6682 .client()
6683 .call(
6684 rpc_methods::SESSION_PERMISSIONS_URLS_SETUNRESTRICTEDMODE,
6685 Some(wire_params),
6686 )
6687 .await?;
6688 Ok(serde_json::from_value(_value)?)
6689 }
6690}
6691
6692/// `session.plan.*` RPCs.
6693#[derive(Clone, Copy)]
6694pub struct SessionRpcPlan<'a> {
6695 pub(crate) session: &'a Session,
6696}
6697
6698impl<'a> SessionRpcPlan<'a> {
6699 /// Reads the session plan file from the workspace.
6700 ///
6701 /// Wire method: `session.plan.read`.
6702 ///
6703 /// # Returns
6704 ///
6705 /// Existence, contents, and resolved path of the session plan file.
6706 ///
6707 /// <div class="warning">
6708 ///
6709 /// **Experimental.** This API is part of an experimental wire-protocol surface
6710 /// and may change or be removed in future SDK or CLI releases. Pin both the
6711 /// SDK and CLI versions if your code depends on it.
6712 ///
6713 /// </div>
6714 pub async fn read(&self) -> Result<PlanReadResult, Error> {
6715 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6716 let _value = self
6717 .session
6718 .client()
6719 .call(rpc_methods::SESSION_PLAN_READ, Some(wire_params))
6720 .await?;
6721 Ok(serde_json::from_value(_value)?)
6722 }
6723
6724 /// Writes new content to the session plan file.
6725 ///
6726 /// Wire method: `session.plan.update`.
6727 ///
6728 /// # Parameters
6729 ///
6730 /// * `params` - Replacement contents to write to the session plan file.
6731 ///
6732 /// <div class="warning">
6733 ///
6734 /// **Experimental.** This API is part of an experimental wire-protocol surface
6735 /// and may change or be removed in future SDK or CLI releases. Pin both the
6736 /// SDK and CLI versions if your code depends on it.
6737 ///
6738 /// </div>
6739 pub async fn update(&self, params: PlanUpdateRequest) -> Result<(), Error> {
6740 let mut wire_params = serde_json::to_value(params)?;
6741 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6742 let _value = self
6743 .session
6744 .client()
6745 .call(rpc_methods::SESSION_PLAN_UPDATE, Some(wire_params))
6746 .await?;
6747 Ok(())
6748 }
6749
6750 /// Deletes the session plan file from the workspace.
6751 ///
6752 /// Wire method: `session.plan.delete`.
6753 ///
6754 /// <div class="warning">
6755 ///
6756 /// **Experimental.** This API is part of an experimental wire-protocol surface
6757 /// and may change or be removed in future SDK or CLI releases. Pin both the
6758 /// SDK and CLI versions if your code depends on it.
6759 ///
6760 /// </div>
6761 pub async fn delete(&self) -> Result<(), Error> {
6762 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6763 let _value = self
6764 .session
6765 .client()
6766 .call(rpc_methods::SESSION_PLAN_DELETE, Some(wire_params))
6767 .await?;
6768 Ok(())
6769 }
6770
6771 /// Reads todo rows from the session SQL database for plan rendering.
6772 ///
6773 /// Wire method: `session.plan.readSqlTodos`.
6774 ///
6775 /// # Returns
6776 ///
6777 /// Todo rows read from the session SQL database. Empty when no session database is available.
6778 ///
6779 /// <div class="warning">
6780 ///
6781 /// **Experimental.** This API is part of an experimental wire-protocol surface
6782 /// and may change or be removed in future SDK or CLI releases. Pin both the
6783 /// SDK and CLI versions if your code depends on it.
6784 ///
6785 /// </div>
6786 pub async fn read_sql_todos(&self) -> Result<PlanReadSqlTodosResult, Error> {
6787 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6788 let _value = self
6789 .session
6790 .client()
6791 .call(rpc_methods::SESSION_PLAN_READSQLTODOS, Some(wire_params))
6792 .await?;
6793 Ok(serde_json::from_value(_value)?)
6794 }
6795
6796 /// 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.
6797 ///
6798 /// Wire method: `session.plan.readSqlTodosWithDependencies`.
6799 ///
6800 /// # Returns
6801 ///
6802 /// Todo rows + dependency edges read from the session SQL database.
6803 ///
6804 /// <div class="warning">
6805 ///
6806 /// **Experimental.** This API is part of an experimental wire-protocol surface
6807 /// and may change or be removed in future SDK or CLI releases. Pin both the
6808 /// SDK and CLI versions if your code depends on it.
6809 ///
6810 /// </div>
6811 pub async fn read_sql_todos_with_dependencies(
6812 &self,
6813 ) -> Result<PlanReadSqlTodosWithDependenciesResult, Error> {
6814 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6815 let _value = self
6816 .session
6817 .client()
6818 .call(
6819 rpc_methods::SESSION_PLAN_READSQLTODOSWITHDEPENDENCIES,
6820 Some(wire_params),
6821 )
6822 .await?;
6823 Ok(serde_json::from_value(_value)?)
6824 }
6825}
6826
6827/// `session.plugins.*` RPCs.
6828#[derive(Clone, Copy)]
6829pub struct SessionRpcPlugins<'a> {
6830 pub(crate) session: &'a Session,
6831}
6832
6833impl<'a> SessionRpcPlugins<'a> {
6834 /// Lists plugins installed for the session.
6835 ///
6836 /// Wire method: `session.plugins.list`.
6837 ///
6838 /// # Returns
6839 ///
6840 /// Plugins installed for the session, with their enabled state and version metadata.
6841 ///
6842 /// <div class="warning">
6843 ///
6844 /// **Experimental.** This API is part of an experimental wire-protocol surface
6845 /// and may change or be removed in future SDK or CLI releases. Pin both the
6846 /// SDK and CLI versions if your code depends on it.
6847 ///
6848 /// </div>
6849 pub async fn list(&self) -> Result<PluginList, Error> {
6850 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6851 let _value = self
6852 .session
6853 .client()
6854 .call(rpc_methods::SESSION_PLUGINS_LIST, Some(wire_params))
6855 .await?;
6856 Ok(serde_json::from_value(_value)?)
6857 }
6858
6859 /// 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.
6860 ///
6861 /// Wire method: `session.plugins.reload`.
6862 ///
6863 /// <div class="warning">
6864 ///
6865 /// **Experimental.** This API is part of an experimental wire-protocol surface
6866 /// and may change or be removed in future SDK or CLI releases. Pin both the
6867 /// SDK and CLI versions if your code depends on it.
6868 ///
6869 /// </div>
6870 pub async fn reload(&self) -> Result<(), Error> {
6871 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6872 let _value = self
6873 .session
6874 .client()
6875 .call(rpc_methods::SESSION_PLUGINS_RELOAD, Some(wire_params))
6876 .await?;
6877 Ok(())
6878 }
6879
6880 /// 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.
6881 ///
6882 /// Wire method: `session.plugins.reload`.
6883 ///
6884 /// # Parameters
6885 ///
6886 /// * `params` - Optional flags controlling which side effects the reload performs.
6887 ///
6888 /// <div class="warning">
6889 ///
6890 /// **Experimental.** This API is part of an experimental wire-protocol surface
6891 /// and may change or be removed in future SDK or CLI releases. Pin both the
6892 /// SDK and CLI versions if your code depends on it.
6893 ///
6894 /// </div>
6895 pub async fn reload_with_params(&self, params: PluginsReloadRequest) -> Result<(), Error> {
6896 let mut wire_params = serde_json::to_value(params)?;
6897 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6898 let _value = self
6899 .session
6900 .client()
6901 .call(rpc_methods::SESSION_PLUGINS_RELOAD, Some(wire_params))
6902 .await?;
6903 Ok(())
6904 }
6905}
6906
6907/// `session.provider.*` RPCs.
6908#[derive(Clone, Copy)]
6909pub struct SessionRpcProvider<'a> {
6910 pub(crate) session: &'a Session,
6911}
6912
6913impl<'a> SessionRpcProvider<'a> {
6914 /// 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.
6915 ///
6916 /// Wire method: `session.provider.getEndpoint`.
6917 ///
6918 /// # Returns
6919 ///
6920 /// A snapshot of the provider endpoint the session is currently configured to talk to.
6921 ///
6922 /// <div class="warning">
6923 ///
6924 /// **Experimental.** This API is part of an experimental wire-protocol surface
6925 /// and may change or be removed in future SDK or CLI releases. Pin both the
6926 /// SDK and CLI versions if your code depends on it.
6927 ///
6928 /// </div>
6929 pub async fn get_endpoint(&self) -> Result<ProviderEndpoint, Error> {
6930 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6931 let _value = self
6932 .session
6933 .client()
6934 .call(rpc_methods::SESSION_PROVIDER_GETENDPOINT, Some(wire_params))
6935 .await?;
6936 Ok(serde_json::from_value(_value)?)
6937 }
6938
6939 /// 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.
6940 ///
6941 /// Wire method: `session.provider.getEndpoint`.
6942 ///
6943 /// # Parameters
6944 ///
6945 /// * `params` - Optional model identifier to scope the endpoint snapshot to.
6946 ///
6947 /// # Returns
6948 ///
6949 /// A snapshot of the provider endpoint the session is currently configured to talk to.
6950 ///
6951 /// <div class="warning">
6952 ///
6953 /// **Experimental.** This API is part of an experimental wire-protocol surface
6954 /// and may change or be removed in future SDK or CLI releases. Pin both the
6955 /// SDK and CLI versions if your code depends on it.
6956 ///
6957 /// </div>
6958 pub async fn get_endpoint_with_params(
6959 &self,
6960 params: ProviderGetEndpointRequest,
6961 ) -> Result<ProviderEndpoint, Error> {
6962 let mut wire_params = serde_json::to_value(params)?;
6963 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6964 let _value = self
6965 .session
6966 .client()
6967 .call(rpc_methods::SESSION_PROVIDER_GETENDPOINT, Some(wire_params))
6968 .await?;
6969 Ok(serde_json::from_value(_value)?)
6970 }
6971
6972 /// 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.
6973 ///
6974 /// Wire method: `session.provider.add`.
6975 ///
6976 /// # Parameters
6977 ///
6978 /// * `params` - BYOK providers and/or models to add to the session's registry at runtime. Both fields are optional; provide providers, models, or both.
6979 ///
6980 /// # Returns
6981 ///
6982 /// The selectable model entries synthesized for the models added by this call.
6983 ///
6984 /// <div class="warning">
6985 ///
6986 /// **Experimental.** This API is part of an experimental wire-protocol surface
6987 /// and may change or be removed in future SDK or CLI releases. Pin both the
6988 /// SDK and CLI versions if your code depends on it.
6989 ///
6990 /// </div>
6991 pub async fn add(&self, params: ProviderAddRequest) -> Result<ProviderAddResult, Error> {
6992 let mut wire_params = serde_json::to_value(params)?;
6993 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6994 let _value = self
6995 .session
6996 .client()
6997 .call(rpc_methods::SESSION_PROVIDER_ADD, Some(wire_params))
6998 .await?;
6999 Ok(serde_json::from_value(_value)?)
7000 }
7001}
7002
7003/// `session.queue.*` RPCs.
7004#[derive(Clone, Copy)]
7005pub struct SessionRpcQueue<'a> {
7006 pub(crate) session: &'a Session,
7007}
7008
7009impl<'a> SessionRpcQueue<'a> {
7010 /// Returns the local session's pending user-facing queued items and steering messages.
7011 ///
7012 /// Wire method: `session.queue.pendingItems`.
7013 ///
7014 /// # Returns
7015 ///
7016 /// Snapshot of the session's pending queued items and immediate-steering messages.
7017 ///
7018 /// <div class="warning">
7019 ///
7020 /// **Experimental.** This API is part of an experimental wire-protocol surface
7021 /// and may change or be removed in future SDK or CLI releases. Pin both the
7022 /// SDK and CLI versions if your code depends on it.
7023 ///
7024 /// </div>
7025 pub async fn pending_items(&self) -> Result<QueuePendingItemsResult, Error> {
7026 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7027 let _value = self
7028 .session
7029 .client()
7030 .call(rpc_methods::SESSION_QUEUE_PENDINGITEMS, Some(wire_params))
7031 .await?;
7032 Ok(serde_json::from_value(_value)?)
7033 }
7034
7035 /// Removes the most recently queued user-facing item (LIFO).
7036 ///
7037 /// Wire method: `session.queue.removeMostRecent`.
7038 ///
7039 /// # Returns
7040 ///
7041 /// Indicates whether a user-facing pending item was removed.
7042 ///
7043 /// <div class="warning">
7044 ///
7045 /// **Experimental.** This API is part of an experimental wire-protocol surface
7046 /// and may change or be removed in future SDK or CLI releases. Pin both the
7047 /// SDK and CLI versions if your code depends on it.
7048 ///
7049 /// </div>
7050 pub async fn remove_most_recent(&self) -> Result<QueueRemoveMostRecentResult, Error> {
7051 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7052 let _value = self
7053 .session
7054 .client()
7055 .call(
7056 rpc_methods::SESSION_QUEUE_REMOVEMOSTRECENT,
7057 Some(wire_params),
7058 )
7059 .await?;
7060 Ok(serde_json::from_value(_value)?)
7061 }
7062
7063 /// Clears all pending queued items on the local session.
7064 ///
7065 /// Wire method: `session.queue.clear`.
7066 ///
7067 /// <div class="warning">
7068 ///
7069 /// **Experimental.** This API is part of an experimental wire-protocol surface
7070 /// and may change or be removed in future SDK or CLI releases. Pin both the
7071 /// SDK and CLI versions if your code depends on it.
7072 ///
7073 /// </div>
7074 pub async fn clear(&self) -> Result<(), Error> {
7075 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7076 let _value = self
7077 .session
7078 .client()
7079 .call(rpc_methods::SESSION_QUEUE_CLEAR, Some(wire_params))
7080 .await?;
7081 Ok(())
7082 }
7083}
7084
7085/// `session.remote.*` RPCs.
7086#[derive(Clone, Copy)]
7087pub struct SessionRpcRemote<'a> {
7088 pub(crate) session: &'a Session,
7089}
7090
7091impl<'a> SessionRpcRemote<'a> {
7092 /// Enables remote session export or steering.
7093 ///
7094 /// Wire method: `session.remote.enable`.
7095 ///
7096 /// # Parameters
7097 ///
7098 /// * `params` - Optional remote session mode ("off", "export", or "on"); defaults to enabling both export and remote steering.
7099 ///
7100 /// # Returns
7101 ///
7102 /// GitHub URL for the session and a flag indicating whether remote steering is enabled.
7103 ///
7104 /// <div class="warning">
7105 ///
7106 /// **Experimental.** This API is part of an experimental wire-protocol surface
7107 /// and may change or be removed in future SDK or CLI releases. Pin both the
7108 /// SDK and CLI versions if your code depends on it.
7109 ///
7110 /// </div>
7111 pub async fn enable(&self, params: RemoteEnableRequest) -> Result<RemoteEnableResult, Error> {
7112 let mut wire_params = serde_json::to_value(params)?;
7113 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7114 let _value = self
7115 .session
7116 .client()
7117 .call(rpc_methods::SESSION_REMOTE_ENABLE, Some(wire_params))
7118 .await?;
7119 Ok(serde_json::from_value(_value)?)
7120 }
7121
7122 /// Disables remote session export and steering.
7123 ///
7124 /// Wire method: `session.remote.disable`.
7125 ///
7126 /// <div class="warning">
7127 ///
7128 /// **Experimental.** This API is part of an experimental wire-protocol surface
7129 /// and may change or be removed in future SDK or CLI releases. Pin both the
7130 /// SDK and CLI versions if your code depends on it.
7131 ///
7132 /// </div>
7133 pub async fn disable(&self) -> Result<(), Error> {
7134 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7135 let _value = self
7136 .session
7137 .client()
7138 .call(rpc_methods::SESSION_REMOTE_DISABLE, Some(wire_params))
7139 .await?;
7140 Ok(())
7141 }
7142
7143 /// Persists a remote-steerability change emitted by the host as a session event.
7144 ///
7145 /// Wire method: `session.remote.notifySteerableChanged`.
7146 ///
7147 /// # Parameters
7148 ///
7149 /// * `params` - New remote-steerability state to persist as a `session.remote_steerable_changed` event.
7150 ///
7151 /// # Returns
7152 ///
7153 /// 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.
7154 ///
7155 /// <div class="warning">
7156 ///
7157 /// **Experimental.** This API is part of an experimental wire-protocol surface
7158 /// and may change or be removed in future SDK or CLI releases. Pin both the
7159 /// SDK and CLI versions if your code depends on it.
7160 ///
7161 /// </div>
7162 pub async fn notify_steerable_changed(
7163 &self,
7164 params: RemoteNotifySteerableChangedRequest,
7165 ) -> Result<RemoteNotifySteerableChangedResult, Error> {
7166 let mut wire_params = serde_json::to_value(params)?;
7167 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7168 let _value = self
7169 .session
7170 .client()
7171 .call(
7172 rpc_methods::SESSION_REMOTE_NOTIFYSTEERABLECHANGED,
7173 Some(wire_params),
7174 )
7175 .await?;
7176 Ok(serde_json::from_value(_value)?)
7177 }
7178}
7179
7180/// `session.schedule.*` RPCs.
7181#[derive(Clone, Copy)]
7182pub struct SessionRpcSchedule<'a> {
7183 pub(crate) session: &'a Session,
7184}
7185
7186impl<'a> SessionRpcSchedule<'a> {
7187 /// Lists the session's currently active scheduled prompts.
7188 ///
7189 /// Wire method: `session.schedule.list`.
7190 ///
7191 /// # Returns
7192 ///
7193 /// Snapshot of the currently active recurring prompts for this session.
7194 ///
7195 /// <div class="warning">
7196 ///
7197 /// **Experimental.** This API is part of an experimental wire-protocol surface
7198 /// and may change or be removed in future SDK or CLI releases. Pin both the
7199 /// SDK and CLI versions if your code depends on it.
7200 ///
7201 /// </div>
7202 pub async fn list(&self) -> Result<ScheduleList, Error> {
7203 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7204 let _value = self
7205 .session
7206 .client()
7207 .call(rpc_methods::SESSION_SCHEDULE_LIST, Some(wire_params))
7208 .await?;
7209 Ok(serde_json::from_value(_value)?)
7210 }
7211
7212 /// Removes a scheduled prompt by id.
7213 ///
7214 /// Wire method: `session.schedule.stop`.
7215 ///
7216 /// # Parameters
7217 ///
7218 /// * `params` - Identifier of the scheduled prompt to remove.
7219 ///
7220 /// # Returns
7221 ///
7222 /// Remove a scheduled prompt by id. The result entry is omitted if the id was unknown.
7223 ///
7224 /// <div class="warning">
7225 ///
7226 /// **Experimental.** This API is part of an experimental wire-protocol surface
7227 /// and may change or be removed in future SDK or CLI releases. Pin both the
7228 /// SDK and CLI versions if your code depends on it.
7229 ///
7230 /// </div>
7231 pub async fn stop(&self, params: ScheduleStopRequest) -> Result<ScheduleStopResult, Error> {
7232 let mut wire_params = serde_json::to_value(params)?;
7233 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7234 let _value = self
7235 .session
7236 .client()
7237 .call(rpc_methods::SESSION_SCHEDULE_STOP, Some(wire_params))
7238 .await?;
7239 Ok(serde_json::from_value(_value)?)
7240 }
7241}
7242
7243/// `session.settings.*` RPCs.
7244#[derive(Clone, Copy)]
7245pub struct SessionRpcSettings<'a> {
7246 pub(crate) session: &'a Session,
7247}
7248
7249impl<'a> SessionRpcSettings<'a> {
7250 /// 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.
7251 ///
7252 /// Wire method: `session.settings.snapshot`.
7253 ///
7254 /// # Returns
7255 ///
7256 /// Redacted, serializable view of session runtime settings for SDK boundary consumers. Secrets and raw feature flags are intentionally excluded.
7257 ///
7258 /// <div class="warning">
7259 ///
7260 /// **Experimental.** This API is part of an experimental wire-protocol surface
7261 /// and may change or be removed in future SDK or CLI releases. Pin both the
7262 /// SDK and CLI versions if your code depends on it.
7263 ///
7264 /// </div>
7265 pub(crate) async fn snapshot(&self) -> Result<SessionSettingsSnapshot, Error> {
7266 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7267 let _value = self
7268 .session
7269 .client()
7270 .call(rpc_methods::SESSION_SETTINGS_SNAPSHOT, Some(wire_params))
7271 .await?;
7272 Ok(serde_json::from_value(_value)?)
7273 }
7274
7275 /// 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.
7276 ///
7277 /// Wire method: `session.settings.evaluatePredicate`.
7278 ///
7279 /// # Parameters
7280 ///
7281 /// * `params` - Named Rust-owned settings predicate to evaluate for this session.
7282 ///
7283 /// # Returns
7284 ///
7285 /// Result of evaluating a Rust-owned settings predicate.
7286 ///
7287 /// <div class="warning">
7288 ///
7289 /// **Experimental.** This API is part of an experimental wire-protocol surface
7290 /// and may change or be removed in future SDK or CLI releases. Pin both the
7291 /// SDK and CLI versions if your code depends on it.
7292 ///
7293 /// </div>
7294 pub(crate) async fn evaluate_predicate(
7295 &self,
7296 params: SessionSettingsEvaluatePredicateRequest,
7297 ) -> Result<SessionSettingsEvaluatePredicateResult, Error> {
7298 let mut wire_params = serde_json::to_value(params)?;
7299 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7300 let _value = self
7301 .session
7302 .client()
7303 .call(
7304 rpc_methods::SESSION_SETTINGS_EVALUATEPREDICATE,
7305 Some(wire_params),
7306 )
7307 .await?;
7308 Ok(serde_json::from_value(_value)?)
7309 }
7310}
7311
7312/// `session.shell.*` RPCs.
7313#[derive(Clone, Copy)]
7314pub struct SessionRpcShell<'a> {
7315 pub(crate) session: &'a Session,
7316}
7317
7318impl<'a> SessionRpcShell<'a> {
7319 /// Starts a shell command and streams output through session notifications.
7320 ///
7321 /// Wire method: `session.shell.exec`.
7322 ///
7323 /// # Parameters
7324 ///
7325 /// * `params` - Shell command to run, with optional working directory and timeout in milliseconds.
7326 ///
7327 /// # Returns
7328 ///
7329 /// Identifier of the spawned process, used to correlate streamed output and exit notifications.
7330 ///
7331 /// <div class="warning">
7332 ///
7333 /// **Experimental.** This API is part of an experimental wire-protocol surface
7334 /// and may change or be removed in future SDK or CLI releases. Pin both the
7335 /// SDK and CLI versions if your code depends on it.
7336 ///
7337 /// </div>
7338 pub async fn exec(&self, params: ShellExecRequest) -> Result<ShellExecResult, Error> {
7339 let mut wire_params = serde_json::to_value(params)?;
7340 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7341 let _value = self
7342 .session
7343 .client()
7344 .call(rpc_methods::SESSION_SHELL_EXEC, Some(wire_params))
7345 .await?;
7346 Ok(serde_json::from_value(_value)?)
7347 }
7348
7349 /// Sends a signal to a shell process previously started via "shell.exec".
7350 ///
7351 /// Wire method: `session.shell.kill`.
7352 ///
7353 /// # Parameters
7354 ///
7355 /// * `params` - Identifier of a process previously returned by "shell.exec" and the signal to send.
7356 ///
7357 /// # Returns
7358 ///
7359 /// Indicates whether the signal was delivered; false if the process was unknown or already exited.
7360 ///
7361 /// <div class="warning">
7362 ///
7363 /// **Experimental.** This API is part of an experimental wire-protocol surface
7364 /// and may change or be removed in future SDK or CLI releases. Pin both the
7365 /// SDK and CLI versions if your code depends on it.
7366 ///
7367 /// </div>
7368 pub async fn kill(&self, params: ShellKillRequest) -> Result<ShellKillResult, Error> {
7369 let mut wire_params = serde_json::to_value(params)?;
7370 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7371 let _value = self
7372 .session
7373 .client()
7374 .call(rpc_methods::SESSION_SHELL_KILL, Some(wire_params))
7375 .await?;
7376 Ok(serde_json::from_value(_value)?)
7377 }
7378
7379 /// Executes a user-requested shell command through the session runtime.
7380 ///
7381 /// Wire method: `session.shell.executeUserRequested`.
7382 ///
7383 /// # Parameters
7384 ///
7385 /// * `params` - User-requested shell command and cancellation handle.
7386 ///
7387 /// # Returns
7388 ///
7389 /// Result of a user-requested shell command.
7390 ///
7391 /// <div class="warning">
7392 ///
7393 /// **Experimental.** This API is part of an experimental wire-protocol surface
7394 /// and may change or be removed in future SDK or CLI releases. Pin both the
7395 /// SDK and CLI versions if your code depends on it.
7396 ///
7397 /// </div>
7398 pub async fn execute_user_requested(
7399 &self,
7400 params: ShellExecuteUserRequestedRequest,
7401 ) -> Result<UserRequestedShellCommandResult, Error> {
7402 let mut wire_params = serde_json::to_value(params)?;
7403 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7404 let _value = self
7405 .session
7406 .client()
7407 .call(
7408 rpc_methods::SESSION_SHELL_EXECUTEUSERREQUESTED,
7409 Some(wire_params),
7410 )
7411 .await?;
7412 Ok(serde_json::from_value(_value)?)
7413 }
7414
7415 /// Cancels a user-requested shell command by request ID.
7416 ///
7417 /// Wire method: `session.shell.cancelUserRequested`.
7418 ///
7419 /// # Parameters
7420 ///
7421 /// * `params` - User-requested shell execution cancellation handle.
7422 ///
7423 /// # Returns
7424 ///
7425 /// Cancellation result for a user-requested shell command.
7426 ///
7427 /// <div class="warning">
7428 ///
7429 /// **Experimental.** This API is part of an experimental wire-protocol surface
7430 /// and may change or be removed in future SDK or CLI releases. Pin both the
7431 /// SDK and CLI versions if your code depends on it.
7432 ///
7433 /// </div>
7434 pub async fn cancel_user_requested(
7435 &self,
7436 params: ShellCancelUserRequestedRequest,
7437 ) -> Result<CancelUserRequestedShellCommandResult, Error> {
7438 let mut wire_params = serde_json::to_value(params)?;
7439 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7440 let _value = self
7441 .session
7442 .client()
7443 .call(
7444 rpc_methods::SESSION_SHELL_CANCELUSERREQUESTED,
7445 Some(wire_params),
7446 )
7447 .await?;
7448 Ok(serde_json::from_value(_value)?)
7449 }
7450}
7451
7452/// `session.skills.*` RPCs.
7453#[derive(Clone, Copy)]
7454pub struct SessionRpcSkills<'a> {
7455 pub(crate) session: &'a Session,
7456}
7457
7458impl<'a> SessionRpcSkills<'a> {
7459 /// Lists skills available to the session.
7460 ///
7461 /// Wire method: `session.skills.list`.
7462 ///
7463 /// # Returns
7464 ///
7465 /// Skills available to the session, with their enabled state.
7466 ///
7467 /// <div class="warning">
7468 ///
7469 /// **Experimental.** This API is part of an experimental wire-protocol surface
7470 /// and may change or be removed in future SDK or CLI releases. Pin both the
7471 /// SDK and CLI versions if your code depends on it.
7472 ///
7473 /// </div>
7474 pub async fn list(&self) -> Result<SkillList, Error> {
7475 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7476 let _value = self
7477 .session
7478 .client()
7479 .call(rpc_methods::SESSION_SKILLS_LIST, Some(wire_params))
7480 .await?;
7481 Ok(serde_json::from_value(_value)?)
7482 }
7483
7484 /// Returns the skills that have been invoked during this session.
7485 ///
7486 /// Wire method: `session.skills.getInvoked`.
7487 ///
7488 /// # Returns
7489 ///
7490 /// Skills invoked during this session, ordered by invocation time (most recent last).
7491 ///
7492 /// <div class="warning">
7493 ///
7494 /// **Experimental.** This API is part of an experimental wire-protocol surface
7495 /// and may change or be removed in future SDK or CLI releases. Pin both the
7496 /// SDK and CLI versions if your code depends on it.
7497 ///
7498 /// </div>
7499 pub async fn get_invoked(&self) -> Result<SkillsGetInvokedResult, Error> {
7500 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7501 let _value = self
7502 .session
7503 .client()
7504 .call(rpc_methods::SESSION_SKILLS_GETINVOKED, Some(wire_params))
7505 .await?;
7506 Ok(serde_json::from_value(_value)?)
7507 }
7508
7509 /// Enables a skill for the session.
7510 ///
7511 /// Wire method: `session.skills.enable`.
7512 ///
7513 /// # Parameters
7514 ///
7515 /// * `params` - Name of the skill to enable for the session.
7516 ///
7517 /// <div class="warning">
7518 ///
7519 /// **Experimental.** This API is part of an experimental wire-protocol surface
7520 /// and may change or be removed in future SDK or CLI releases. Pin both the
7521 /// SDK and CLI versions if your code depends on it.
7522 ///
7523 /// </div>
7524 pub async fn enable(&self, params: SkillsEnableRequest) -> Result<(), Error> {
7525 let mut wire_params = serde_json::to_value(params)?;
7526 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7527 let _value = self
7528 .session
7529 .client()
7530 .call(rpc_methods::SESSION_SKILLS_ENABLE, Some(wire_params))
7531 .await?;
7532 Ok(())
7533 }
7534
7535 /// Disables a skill for the session.
7536 ///
7537 /// Wire method: `session.skills.disable`.
7538 ///
7539 /// # Parameters
7540 ///
7541 /// * `params` - Name of the skill to disable for the session.
7542 ///
7543 /// <div class="warning">
7544 ///
7545 /// **Experimental.** This API is part of an experimental wire-protocol surface
7546 /// and may change or be removed in future SDK or CLI releases. Pin both the
7547 /// SDK and CLI versions if your code depends on it.
7548 ///
7549 /// </div>
7550 pub async fn disable(&self, params: SkillsDisableRequest) -> Result<(), Error> {
7551 let mut wire_params = serde_json::to_value(params)?;
7552 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7553 let _value = self
7554 .session
7555 .client()
7556 .call(rpc_methods::SESSION_SKILLS_DISABLE, Some(wire_params))
7557 .await?;
7558 Ok(())
7559 }
7560
7561 /// Reloads skill definitions for the session.
7562 ///
7563 /// Wire method: `session.skills.reload`.
7564 ///
7565 /// # Returns
7566 ///
7567 /// Diagnostics from reloading skill definitions, with warnings and errors as separate lists.
7568 ///
7569 /// <div class="warning">
7570 ///
7571 /// **Experimental.** This API is part of an experimental wire-protocol surface
7572 /// and may change or be removed in future SDK or CLI releases. Pin both the
7573 /// SDK and CLI versions if your code depends on it.
7574 ///
7575 /// </div>
7576 pub async fn reload(&self) -> Result<SkillsLoadDiagnostics, Error> {
7577 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7578 let _value = self
7579 .session
7580 .client()
7581 .call(rpc_methods::SESSION_SKILLS_RELOAD, Some(wire_params))
7582 .await?;
7583 Ok(serde_json::from_value(_value)?)
7584 }
7585
7586 /// Ensures the session's skill definitions have been loaded from disk.
7587 ///
7588 /// Wire method: `session.skills.ensureLoaded`.
7589 ///
7590 /// <div class="warning">
7591 ///
7592 /// **Experimental.** This API is part of an experimental wire-protocol surface
7593 /// and may change or be removed in future SDK or CLI releases. Pin both the
7594 /// SDK and CLI versions if your code depends on it.
7595 ///
7596 /// </div>
7597 pub async fn ensure_loaded(&self) -> Result<(), Error> {
7598 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7599 let _value = self
7600 .session
7601 .client()
7602 .call(rpc_methods::SESSION_SKILLS_ENSURELOADED, Some(wire_params))
7603 .await?;
7604 Ok(())
7605 }
7606}
7607
7608/// `session.tasks.*` RPCs.
7609#[derive(Clone, Copy)]
7610pub struct SessionRpcTasks<'a> {
7611 pub(crate) session: &'a Session,
7612}
7613
7614impl<'a> SessionRpcTasks<'a> {
7615 /// Starts a background agent task in the session.
7616 ///
7617 /// Wire method: `session.tasks.startAgent`.
7618 ///
7619 /// # Parameters
7620 ///
7621 /// * `params` - Agent type, prompt, name, and optional description and model override for the new task.
7622 ///
7623 /// # Returns
7624 ///
7625 /// Identifier assigned to the newly started background agent task.
7626 ///
7627 /// <div class="warning">
7628 ///
7629 /// **Experimental.** This API is part of an experimental wire-protocol surface
7630 /// and may change or be removed in future SDK or CLI releases. Pin both the
7631 /// SDK and CLI versions if your code depends on it.
7632 ///
7633 /// </div>
7634 pub async fn start_agent(
7635 &self,
7636 params: TasksStartAgentRequest,
7637 ) -> Result<TasksStartAgentResult, Error> {
7638 let mut wire_params = serde_json::to_value(params)?;
7639 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7640 let _value = self
7641 .session
7642 .client()
7643 .call(rpc_methods::SESSION_TASKS_STARTAGENT, Some(wire_params))
7644 .await?;
7645 Ok(serde_json::from_value(_value)?)
7646 }
7647
7648 /// Lists background tasks tracked by the session.
7649 ///
7650 /// Wire method: `session.tasks.list`.
7651 ///
7652 /// # Returns
7653 ///
7654 /// Background tasks currently tracked by the session.
7655 ///
7656 /// <div class="warning">
7657 ///
7658 /// **Experimental.** This API is part of an experimental wire-protocol surface
7659 /// and may change or be removed in future SDK or CLI releases. Pin both the
7660 /// SDK and CLI versions if your code depends on it.
7661 ///
7662 /// </div>
7663 pub async fn list(&self) -> Result<TaskList, Error> {
7664 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7665 let _value = self
7666 .session
7667 .client()
7668 .call(rpc_methods::SESSION_TASKS_LIST, Some(wire_params))
7669 .await?;
7670 Ok(serde_json::from_value(_value)?)
7671 }
7672
7673 /// Refreshes metadata for any detached background shells the runtime knows about.
7674 ///
7675 /// Wire method: `session.tasks.refresh`.
7676 ///
7677 /// # Returns
7678 ///
7679 /// 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.
7680 ///
7681 /// <div class="warning">
7682 ///
7683 /// **Experimental.** This API is part of an experimental wire-protocol surface
7684 /// and may change or be removed in future SDK or CLI releases. Pin both the
7685 /// SDK and CLI versions if your code depends on it.
7686 ///
7687 /// </div>
7688 pub async fn refresh(&self) -> Result<TasksRefreshResult, Error> {
7689 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7690 let _value = self
7691 .session
7692 .client()
7693 .call(rpc_methods::SESSION_TASKS_REFRESH, Some(wire_params))
7694 .await?;
7695 Ok(serde_json::from_value(_value)?)
7696 }
7697
7698 /// Waits for all in-flight background tasks and any follow-up turns to settle.
7699 ///
7700 /// Wire method: `session.tasks.waitForPending`.
7701 ///
7702 /// # Returns
7703 ///
7704 /// 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).
7705 ///
7706 /// <div class="warning">
7707 ///
7708 /// **Experimental.** This API is part of an experimental wire-protocol surface
7709 /// and may change or be removed in future SDK or CLI releases. Pin both the
7710 /// SDK and CLI versions if your code depends on it.
7711 ///
7712 /// </div>
7713 pub async fn wait_for_pending(&self) -> Result<TasksWaitForPendingResult, Error> {
7714 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7715 let _value = self
7716 .session
7717 .client()
7718 .call(rpc_methods::SESSION_TASKS_WAITFORPENDING, Some(wire_params))
7719 .await?;
7720 Ok(serde_json::from_value(_value)?)
7721 }
7722
7723 /// Returns progress information for a background task by ID.
7724 ///
7725 /// Wire method: `session.tasks.getProgress`.
7726 ///
7727 /// # Parameters
7728 ///
7729 /// * `params` - Identifier of the background task to fetch progress for.
7730 ///
7731 /// # Returns
7732 ///
7733 /// Progress information for the task, or null when no task with that ID is tracked.
7734 ///
7735 /// <div class="warning">
7736 ///
7737 /// **Experimental.** This API is part of an experimental wire-protocol surface
7738 /// and may change or be removed in future SDK or CLI releases. Pin both the
7739 /// SDK and CLI versions if your code depends on it.
7740 ///
7741 /// </div>
7742 pub async fn get_progress(
7743 &self,
7744 params: TasksGetProgressRequest,
7745 ) -> Result<TasksGetProgressResult, Error> {
7746 let mut wire_params = serde_json::to_value(params)?;
7747 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7748 let _value = self
7749 .session
7750 .client()
7751 .call(rpc_methods::SESSION_TASKS_GETPROGRESS, Some(wire_params))
7752 .await?;
7753 Ok(serde_json::from_value(_value)?)
7754 }
7755
7756 /// Returns the first sync-waiting task that can currently be promoted to background mode.
7757 ///
7758 /// Wire method: `session.tasks.getCurrentPromotable`.
7759 ///
7760 /// # Returns
7761 ///
7762 /// The first sync-waiting task that can currently be promoted to background mode.
7763 ///
7764 /// <div class="warning">
7765 ///
7766 /// **Experimental.** This API is part of an experimental wire-protocol surface
7767 /// and may change or be removed in future SDK or CLI releases. Pin both the
7768 /// SDK and CLI versions if your code depends on it.
7769 ///
7770 /// </div>
7771 pub async fn get_current_promotable(&self) -> Result<TasksGetCurrentPromotableResult, Error> {
7772 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7773 let _value = self
7774 .session
7775 .client()
7776 .call(
7777 rpc_methods::SESSION_TASKS_GETCURRENTPROMOTABLE,
7778 Some(wire_params),
7779 )
7780 .await?;
7781 Ok(serde_json::from_value(_value)?)
7782 }
7783
7784 /// Promotes an eligible synchronously-waited task so it continues running in the background.
7785 ///
7786 /// Wire method: `session.tasks.promoteToBackground`.
7787 ///
7788 /// # Parameters
7789 ///
7790 /// * `params` - Identifier of the task to promote to background mode.
7791 ///
7792 /// # Returns
7793 ///
7794 /// Indicates whether the task was successfully promoted to background mode.
7795 ///
7796 /// <div class="warning">
7797 ///
7798 /// **Experimental.** This API is part of an experimental wire-protocol surface
7799 /// and may change or be removed in future SDK or CLI releases. Pin both the
7800 /// SDK and CLI versions if your code depends on it.
7801 ///
7802 /// </div>
7803 pub async fn promote_to_background(
7804 &self,
7805 params: TasksPromoteToBackgroundRequest,
7806 ) -> Result<TasksPromoteToBackgroundResult, Error> {
7807 let mut wire_params = serde_json::to_value(params)?;
7808 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7809 let _value = self
7810 .session
7811 .client()
7812 .call(
7813 rpc_methods::SESSION_TASKS_PROMOTETOBACKGROUND,
7814 Some(wire_params),
7815 )
7816 .await?;
7817 Ok(serde_json::from_value(_value)?)
7818 }
7819
7820 /// Atomically promotes the first promotable sync-waiting task to background mode and returns it.
7821 ///
7822 /// Wire method: `session.tasks.promoteCurrentToBackground`.
7823 ///
7824 /// # Returns
7825 ///
7826 /// The promoted task as it now exists in background mode, omitted if no promotable task was waiting.
7827 ///
7828 /// <div class="warning">
7829 ///
7830 /// **Experimental.** This API is part of an experimental wire-protocol surface
7831 /// and may change or be removed in future SDK or CLI releases. Pin both the
7832 /// SDK and CLI versions if your code depends on it.
7833 ///
7834 /// </div>
7835 pub async fn promote_current_to_background(
7836 &self,
7837 ) -> Result<TasksPromoteCurrentToBackgroundResult, Error> {
7838 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7839 let _value = self
7840 .session
7841 .client()
7842 .call(
7843 rpc_methods::SESSION_TASKS_PROMOTECURRENTTOBACKGROUND,
7844 Some(wire_params),
7845 )
7846 .await?;
7847 Ok(serde_json::from_value(_value)?)
7848 }
7849
7850 /// Cancels a background task.
7851 ///
7852 /// Wire method: `session.tasks.cancel`.
7853 ///
7854 /// # Parameters
7855 ///
7856 /// * `params` - Identifier of the background task to cancel.
7857 ///
7858 /// # Returns
7859 ///
7860 /// Indicates whether the background task was successfully cancelled.
7861 ///
7862 /// <div class="warning">
7863 ///
7864 /// **Experimental.** This API is part of an experimental wire-protocol surface
7865 /// and may change or be removed in future SDK or CLI releases. Pin both the
7866 /// SDK and CLI versions if your code depends on it.
7867 ///
7868 /// </div>
7869 pub async fn cancel(&self, params: TasksCancelRequest) -> Result<TasksCancelResult, Error> {
7870 let mut wire_params = serde_json::to_value(params)?;
7871 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7872 let _value = self
7873 .session
7874 .client()
7875 .call(rpc_methods::SESSION_TASKS_CANCEL, Some(wire_params))
7876 .await?;
7877 Ok(serde_json::from_value(_value)?)
7878 }
7879
7880 /// Removes a completed or cancelled background task from tracking.
7881 ///
7882 /// Wire method: `session.tasks.remove`.
7883 ///
7884 /// # Parameters
7885 ///
7886 /// * `params` - Identifier of the completed or cancelled task to remove from tracking.
7887 ///
7888 /// # Returns
7889 ///
7890 /// Indicates whether the task was removed. False when the task does not exist or is still running/idle.
7891 ///
7892 /// <div class="warning">
7893 ///
7894 /// **Experimental.** This API is part of an experimental wire-protocol surface
7895 /// and may change or be removed in future SDK or CLI releases. Pin both the
7896 /// SDK and CLI versions if your code depends on it.
7897 ///
7898 /// </div>
7899 pub async fn remove(&self, params: TasksRemoveRequest) -> Result<TasksRemoveResult, Error> {
7900 let mut wire_params = serde_json::to_value(params)?;
7901 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7902 let _value = self
7903 .session
7904 .client()
7905 .call(rpc_methods::SESSION_TASKS_REMOVE, Some(wire_params))
7906 .await?;
7907 Ok(serde_json::from_value(_value)?)
7908 }
7909
7910 /// Sends a message to a background agent task.
7911 ///
7912 /// Wire method: `session.tasks.sendMessage`.
7913 ///
7914 /// # Parameters
7915 ///
7916 /// * `params` - Identifier of the target agent task, message content, and optional sender agent ID.
7917 ///
7918 /// # Returns
7919 ///
7920 /// Indicates whether the message was delivered, with an error message when delivery failed.
7921 ///
7922 /// <div class="warning">
7923 ///
7924 /// **Experimental.** This API is part of an experimental wire-protocol surface
7925 /// and may change or be removed in future SDK or CLI releases. Pin both the
7926 /// SDK and CLI versions if your code depends on it.
7927 ///
7928 /// </div>
7929 pub async fn send_message(
7930 &self,
7931 params: TasksSendMessageRequest,
7932 ) -> Result<TasksSendMessageResult, Error> {
7933 let mut wire_params = serde_json::to_value(params)?;
7934 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7935 let _value = self
7936 .session
7937 .client()
7938 .call(rpc_methods::SESSION_TASKS_SENDMESSAGE, Some(wire_params))
7939 .await?;
7940 Ok(serde_json::from_value(_value)?)
7941 }
7942}
7943
7944/// `session.telemetry.*` RPCs.
7945#[derive(Clone, Copy)]
7946pub struct SessionRpcTelemetry<'a> {
7947 pub(crate) session: &'a Session,
7948}
7949
7950impl<'a> SessionRpcTelemetry<'a> {
7951 /// Gets the telemetry engagement ID currently associated with the session, when available.
7952 ///
7953 /// Wire method: `session.telemetry.getEngagementId`.
7954 ///
7955 /// # Returns
7956 ///
7957 /// Telemetry engagement ID for the session, when available.
7958 ///
7959 /// <div class="warning">
7960 ///
7961 /// **Experimental.** This API is part of an experimental wire-protocol surface
7962 /// and may change or be removed in future SDK or CLI releases. Pin both the
7963 /// SDK and CLI versions if your code depends on it.
7964 ///
7965 /// </div>
7966 pub async fn get_engagement_id(&self) -> Result<SessionTelemetryEngagement, Error> {
7967 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7968 let _value = self
7969 .session
7970 .client()
7971 .call(
7972 rpc_methods::SESSION_TELEMETRY_GETENGAGEMENTID,
7973 Some(wire_params),
7974 )
7975 .await?;
7976 Ok(serde_json::from_value(_value)?)
7977 }
7978
7979 /// Sets feature override key/value pairs to attach to subsequent telemetry events for the session.
7980 ///
7981 /// Wire method: `session.telemetry.setFeatureOverrides`.
7982 ///
7983 /// # Parameters
7984 ///
7985 /// * `params` - Feature override key/value pairs to attach to subsequent telemetry events from this session.
7986 ///
7987 /// <div class="warning">
7988 ///
7989 /// **Experimental.** This API is part of an experimental wire-protocol surface
7990 /// and may change or be removed in future SDK or CLI releases. Pin both the
7991 /// SDK and CLI versions if your code depends on it.
7992 ///
7993 /// </div>
7994 pub async fn set_feature_overrides(
7995 &self,
7996 params: TelemetrySetFeatureOverridesRequest,
7997 ) -> Result<(), Error> {
7998 let mut wire_params = serde_json::to_value(params)?;
7999 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8000 let _value = self
8001 .session
8002 .client()
8003 .call(
8004 rpc_methods::SESSION_TELEMETRY_SETFEATUREOVERRIDES,
8005 Some(wire_params),
8006 )
8007 .await?;
8008 Ok(())
8009 }
8010}
8011
8012/// `session.tools.*` RPCs.
8013#[derive(Clone, Copy)]
8014pub struct SessionRpcTools<'a> {
8015 pub(crate) session: &'a Session,
8016}
8017
8018impl<'a> SessionRpcTools<'a> {
8019 /// Provides the result for a pending external tool call.
8020 ///
8021 /// Wire method: `session.tools.handlePendingToolCall`.
8022 ///
8023 /// # Parameters
8024 ///
8025 /// * `params` - Pending external tool call request ID, with the tool result or an error describing why it failed.
8026 ///
8027 /// # Returns
8028 ///
8029 /// Indicates whether the external tool call result was handled successfully.
8030 ///
8031 /// <div class="warning">
8032 ///
8033 /// **Experimental.** This API is part of an experimental wire-protocol surface
8034 /// and may change or be removed in future SDK or CLI releases. Pin both the
8035 /// SDK and CLI versions if your code depends on it.
8036 ///
8037 /// </div>
8038 pub async fn handle_pending_tool_call(
8039 &self,
8040 params: HandlePendingToolCallRequest,
8041 ) -> Result<HandlePendingToolCallResult, Error> {
8042 let mut wire_params = serde_json::to_value(params)?;
8043 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8044 let _value = self
8045 .session
8046 .client()
8047 .call(
8048 rpc_methods::SESSION_TOOLS_HANDLEPENDINGTOOLCALL,
8049 Some(wire_params),
8050 )
8051 .await?;
8052 Ok(serde_json::from_value(_value)?)
8053 }
8054
8055 /// Resolves, builds, and validates the runtime tool list for the session.
8056 ///
8057 /// Wire method: `session.tools.initializeAndValidate`.
8058 ///
8059 /// # Returns
8060 ///
8061 /// 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.
8062 ///
8063 /// <div class="warning">
8064 ///
8065 /// **Experimental.** This API is part of an experimental wire-protocol surface
8066 /// and may change or be removed in future SDK or CLI releases. Pin both the
8067 /// SDK and CLI versions if your code depends on it.
8068 ///
8069 /// </div>
8070 pub async fn initialize_and_validate(&self) -> Result<ToolsInitializeAndValidateResult, Error> {
8071 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8072 let _value = self
8073 .session
8074 .client()
8075 .call(
8076 rpc_methods::SESSION_TOOLS_INITIALIZEANDVALIDATE,
8077 Some(wire_params),
8078 )
8079 .await?;
8080 Ok(serde_json::from_value(_value)?)
8081 }
8082
8083 /// Returns lightweight metadata for the session's currently initialized tools.
8084 ///
8085 /// Wire method: `session.tools.getCurrentMetadata`.
8086 ///
8087 /// # Returns
8088 ///
8089 /// Current lightweight tool metadata snapshot for the session.
8090 ///
8091 /// <div class="warning">
8092 ///
8093 /// **Experimental.** This API is part of an experimental wire-protocol surface
8094 /// and may change or be removed in future SDK or CLI releases. Pin both the
8095 /// SDK and CLI versions if your code depends on it.
8096 ///
8097 /// </div>
8098 pub async fn get_current_metadata(&self) -> Result<ToolsGetCurrentMetadataResult, Error> {
8099 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8100 let _value = self
8101 .session
8102 .client()
8103 .call(
8104 rpc_methods::SESSION_TOOLS_GETCURRENTMETADATA,
8105 Some(wire_params),
8106 )
8107 .await?;
8108 Ok(serde_json::from_value(_value)?)
8109 }
8110
8111 /// Updates the current session's live subagent settings after user settings change. The persisted user settings remain the source of truth for future sessions.
8112 ///
8113 /// Wire method: `session.tools.updateSubagentSettings`.
8114 ///
8115 /// # Parameters
8116 ///
8117 /// * `params` - Subagent settings to apply to the current session
8118 ///
8119 /// # Returns
8120 ///
8121 /// Empty result after applying subagent settings
8122 ///
8123 /// <div class="warning">
8124 ///
8125 /// **Experimental.** This API is part of an experimental wire-protocol surface
8126 /// and may change or be removed in future SDK or CLI releases. Pin both the
8127 /// SDK and CLI versions if your code depends on it.
8128 ///
8129 /// </div>
8130 pub async fn update_subagent_settings(
8131 &self,
8132 params: UpdateSubagentSettingsRequest,
8133 ) -> Result<ToolsUpdateSubagentSettingsResult, Error> {
8134 let mut wire_params = serde_json::to_value(params)?;
8135 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8136 let _value = self
8137 .session
8138 .client()
8139 .call(
8140 rpc_methods::SESSION_TOOLS_UPDATESUBAGENTSETTINGS,
8141 Some(wire_params),
8142 )
8143 .await?;
8144 Ok(serde_json::from_value(_value)?)
8145 }
8146}
8147
8148/// `session.ui.*` RPCs.
8149#[derive(Clone, Copy)]
8150pub struct SessionRpcUi<'a> {
8151 pub(crate) session: &'a Session,
8152}
8153
8154impl<'a> SessionRpcUi<'a> {
8155 /// Runs a transient no-tools model query against the current conversation context.
8156 ///
8157 /// Wire method: `session.ui.ephemeralQuery`.
8158 ///
8159 /// # Parameters
8160 ///
8161 /// * `params` - Transient question to answer without adding it to conversation history.
8162 ///
8163 /// # Returns
8164 ///
8165 /// Transient answer generated from current conversation context.
8166 ///
8167 /// <div class="warning">
8168 ///
8169 /// **Experimental.** This API is part of an experimental wire-protocol surface
8170 /// and may change or be removed in future SDK or CLI releases. Pin both the
8171 /// SDK and CLI versions if your code depends on it.
8172 ///
8173 /// </div>
8174 pub async fn ephemeral_query(
8175 &self,
8176 params: UIEphemeralQueryRequest,
8177 ) -> Result<UIEphemeralQueryResult, Error> {
8178 let mut wire_params = serde_json::to_value(params)?;
8179 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8180 let _value = self
8181 .session
8182 .client()
8183 .call(rpc_methods::SESSION_UI_EPHEMERALQUERY, Some(wire_params))
8184 .await?;
8185 Ok(serde_json::from_value(_value)?)
8186 }
8187
8188 /// Requests structured input from a UI-capable client.
8189 ///
8190 /// Wire method: `session.ui.elicitation`.
8191 ///
8192 /// # Parameters
8193 ///
8194 /// * `params` - Prompt message and JSON schema describing the form fields to elicit from the user.
8195 ///
8196 /// # Returns
8197 ///
8198 /// The elicitation response (accept with form values, decline, or cancel)
8199 ///
8200 /// <div class="warning">
8201 ///
8202 /// **Experimental.** This API is part of an experimental wire-protocol surface
8203 /// and may change or be removed in future SDK or CLI releases. Pin both the
8204 /// SDK and CLI versions if your code depends on it.
8205 ///
8206 /// </div>
8207 pub async fn elicitation(
8208 &self,
8209 params: UIElicitationRequest,
8210 ) -> Result<UIElicitationResponse, Error> {
8211 let mut wire_params = serde_json::to_value(params)?;
8212 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8213 let _value = self
8214 .session
8215 .client()
8216 .call(rpc_methods::SESSION_UI_ELICITATION, Some(wire_params))
8217 .await?;
8218 Ok(serde_json::from_value(_value)?)
8219 }
8220
8221 /// Provides the user response for a pending elicitation request.
8222 ///
8223 /// Wire method: `session.ui.handlePendingElicitation`.
8224 ///
8225 /// # Parameters
8226 ///
8227 /// * `params` - Pending elicitation request ID and the user's response (accept/decline/cancel + form values).
8228 ///
8229 /// # Returns
8230 ///
8231 /// Indicates whether the elicitation response was accepted; false if it was already resolved by another client.
8232 ///
8233 /// <div class="warning">
8234 ///
8235 /// **Experimental.** This API is part of an experimental wire-protocol surface
8236 /// and may change or be removed in future SDK or CLI releases. Pin both the
8237 /// SDK and CLI versions if your code depends on it.
8238 ///
8239 /// </div>
8240 pub async fn handle_pending_elicitation(
8241 &self,
8242 params: UIHandlePendingElicitationRequest,
8243 ) -> Result<UIElicitationResult, Error> {
8244 let mut wire_params = serde_json::to_value(params)?;
8245 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8246 let _value = self
8247 .session
8248 .client()
8249 .call(
8250 rpc_methods::SESSION_UI_HANDLEPENDINGELICITATION,
8251 Some(wire_params),
8252 )
8253 .await?;
8254 Ok(serde_json::from_value(_value)?)
8255 }
8256
8257 /// Resolves a pending `user_input.requested` event with the user's response.
8258 ///
8259 /// Wire method: `session.ui.handlePendingUserInput`.
8260 ///
8261 /// # Parameters
8262 ///
8263 /// * `params` - Request ID of a pending `user_input.requested` event and the user's response.
8264 ///
8265 /// # Returns
8266 ///
8267 /// Indicates whether the pending UI request was resolved by this call.
8268 ///
8269 /// <div class="warning">
8270 ///
8271 /// **Experimental.** This API is part of an experimental wire-protocol surface
8272 /// and may change or be removed in future SDK or CLI releases. Pin both the
8273 /// SDK and CLI versions if your code depends on it.
8274 ///
8275 /// </div>
8276 pub async fn handle_pending_user_input(
8277 &self,
8278 params: UIHandlePendingUserInputRequest,
8279 ) -> Result<UIHandlePendingResult, Error> {
8280 let mut wire_params = serde_json::to_value(params)?;
8281 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8282 let _value = self
8283 .session
8284 .client()
8285 .call(
8286 rpc_methods::SESSION_UI_HANDLEPENDINGUSERINPUT,
8287 Some(wire_params),
8288 )
8289 .await?;
8290 Ok(serde_json::from_value(_value)?)
8291 }
8292
8293 /// Resolves a pending `sampling.requested` event with a sampling result, or rejects it.
8294 ///
8295 /// Wire method: `session.ui.handlePendingSampling`.
8296 ///
8297 /// # Parameters
8298 ///
8299 /// * `params` - Request ID of a pending `sampling.requested` event and an optional sampling result payload (omit to reject).
8300 ///
8301 /// # Returns
8302 ///
8303 /// Indicates whether the pending UI request was resolved by this call.
8304 ///
8305 /// <div class="warning">
8306 ///
8307 /// **Experimental.** This API is part of an experimental wire-protocol surface
8308 /// and may change or be removed in future SDK or CLI releases. Pin both the
8309 /// SDK and CLI versions if your code depends on it.
8310 ///
8311 /// </div>
8312 pub async fn handle_pending_sampling(
8313 &self,
8314 params: UIHandlePendingSamplingRequest,
8315 ) -> Result<UIHandlePendingResult, Error> {
8316 let mut wire_params = serde_json::to_value(params)?;
8317 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8318 let _value = self
8319 .session
8320 .client()
8321 .call(
8322 rpc_methods::SESSION_UI_HANDLEPENDINGSAMPLING,
8323 Some(wire_params),
8324 )
8325 .await?;
8326 Ok(serde_json::from_value(_value)?)
8327 }
8328
8329 /// Resolves a pending `auto_mode_switch.requested` event with the user's accept/decline decision.
8330 ///
8331 /// Wire method: `session.ui.handlePendingAutoModeSwitch`.
8332 ///
8333 /// # Parameters
8334 ///
8335 /// * `params` - Request ID of a pending `auto_mode_switch.requested` event and the user's response.
8336 ///
8337 /// # Returns
8338 ///
8339 /// Indicates whether the pending UI request was resolved by this call.
8340 ///
8341 /// <div class="warning">
8342 ///
8343 /// **Experimental.** This API is part of an experimental wire-protocol surface
8344 /// and may change or be removed in future SDK or CLI releases. Pin both the
8345 /// SDK and CLI versions if your code depends on it.
8346 ///
8347 /// </div>
8348 pub async fn handle_pending_auto_mode_switch(
8349 &self,
8350 params: UIHandlePendingAutoModeSwitchRequest,
8351 ) -> Result<UIHandlePendingResult, Error> {
8352 let mut wire_params = serde_json::to_value(params)?;
8353 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8354 let _value = self
8355 .session
8356 .client()
8357 .call(
8358 rpc_methods::SESSION_UI_HANDLEPENDINGAUTOMODESWITCH,
8359 Some(wire_params),
8360 )
8361 .await?;
8362 Ok(serde_json::from_value(_value)?)
8363 }
8364
8365 /// Resolves a pending `session_limits_exhausted.requested` event with the user's selected limit action.
8366 ///
8367 /// Wire method: `session.ui.handlePendingSessionLimitsExhausted`.
8368 ///
8369 /// # Parameters
8370 ///
8371 /// * `params` - Request ID of a pending `session_limits_exhausted.requested` event and the user's selected limit action.
8372 ///
8373 /// # Returns
8374 ///
8375 /// Indicates whether the pending UI request was resolved by this call.
8376 ///
8377 /// <div class="warning">
8378 ///
8379 /// **Experimental.** This API is part of an experimental wire-protocol surface
8380 /// and may change or be removed in future SDK or CLI releases. Pin both the
8381 /// SDK and CLI versions if your code depends on it.
8382 ///
8383 /// </div>
8384 pub async fn handle_pending_session_limits_exhausted(
8385 &self,
8386 params: UIHandlePendingSessionLimitsExhaustedRequest,
8387 ) -> Result<UIHandlePendingResult, Error> {
8388 let mut wire_params = serde_json::to_value(params)?;
8389 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8390 let _value = self
8391 .session
8392 .client()
8393 .call(
8394 rpc_methods::SESSION_UI_HANDLEPENDINGSESSIONLIMITSEXHAUSTED,
8395 Some(wire_params),
8396 )
8397 .await?;
8398 Ok(serde_json::from_value(_value)?)
8399 }
8400
8401 /// Resolves a pending `exit_plan_mode.requested` event with the user's response.
8402 ///
8403 /// Wire method: `session.ui.handlePendingExitPlanMode`.
8404 ///
8405 /// # Parameters
8406 ///
8407 /// * `params` - Request ID of a pending `exit_plan_mode.requested` event and the user's response.
8408 ///
8409 /// # Returns
8410 ///
8411 /// Indicates whether the pending UI request was resolved by this call.
8412 ///
8413 /// <div class="warning">
8414 ///
8415 /// **Experimental.** This API is part of an experimental wire-protocol surface
8416 /// and may change or be removed in future SDK or CLI releases. Pin both the
8417 /// SDK and CLI versions if your code depends on it.
8418 ///
8419 /// </div>
8420 pub async fn handle_pending_exit_plan_mode(
8421 &self,
8422 params: UIHandlePendingExitPlanModeRequest,
8423 ) -> Result<UIHandlePendingResult, Error> {
8424 let mut wire_params = serde_json::to_value(params)?;
8425 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8426 let _value = self
8427 .session
8428 .client()
8429 .call(
8430 rpc_methods::SESSION_UI_HANDLEPENDINGEXITPLANMODE,
8431 Some(wire_params),
8432 )
8433 .await?;
8434 Ok(serde_json::from_value(_value)?)
8435 }
8436
8437 /// Registers an in-process handler for auto-mode-switch requests so the server bridge skips dispatch.
8438 ///
8439 /// Wire method: `session.ui.registerDirectAutoModeSwitchHandler`.
8440 ///
8441 /// # Returns
8442 ///
8443 /// 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).
8444 ///
8445 /// <div class="warning">
8446 ///
8447 /// **Experimental.** This API is part of an experimental wire-protocol surface
8448 /// and may change or be removed in future SDK or CLI releases. Pin both the
8449 /// SDK and CLI versions if your code depends on it.
8450 ///
8451 /// </div>
8452 pub async fn register_direct_auto_mode_switch_handler(
8453 &self,
8454 ) -> Result<UIRegisterDirectAutoModeSwitchHandlerResult, Error> {
8455 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8456 let _value = self
8457 .session
8458 .client()
8459 .call(
8460 rpc_methods::SESSION_UI_REGISTERDIRECTAUTOMODESWITCHHANDLER,
8461 Some(wire_params),
8462 )
8463 .await?;
8464 Ok(serde_json::from_value(_value)?)
8465 }
8466
8467 /// Unregisters a previously-registered in-process auto-mode-switch handler by its opaque handle.
8468 ///
8469 /// Wire method: `session.ui.unregisterDirectAutoModeSwitchHandler`.
8470 ///
8471 /// # Parameters
8472 ///
8473 /// * `params` - Opaque handle previously returned by `registerDirectAutoModeSwitchHandler` to release.
8474 ///
8475 /// # Returns
8476 ///
8477 /// Indicates whether the handle was active and the registration count was decremented.
8478 ///
8479 /// <div class="warning">
8480 ///
8481 /// **Experimental.** This API is part of an experimental wire-protocol surface
8482 /// and may change or be removed in future SDK or CLI releases. Pin both the
8483 /// SDK and CLI versions if your code depends on it.
8484 ///
8485 /// </div>
8486 pub async fn unregister_direct_auto_mode_switch_handler(
8487 &self,
8488 params: UIUnregisterDirectAutoModeSwitchHandlerRequest,
8489 ) -> Result<UIUnregisterDirectAutoModeSwitchHandlerResult, Error> {
8490 let mut wire_params = serde_json::to_value(params)?;
8491 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8492 let _value = self
8493 .session
8494 .client()
8495 .call(
8496 rpc_methods::SESSION_UI_UNREGISTERDIRECTAUTOMODESWITCHHANDLER,
8497 Some(wire_params),
8498 )
8499 .await?;
8500 Ok(serde_json::from_value(_value)?)
8501 }
8502}
8503
8504/// `session.usage.*` RPCs.
8505#[derive(Clone, Copy)]
8506pub struct SessionRpcUsage<'a> {
8507 pub(crate) session: &'a Session,
8508}
8509
8510impl<'a> SessionRpcUsage<'a> {
8511 /// Gets accumulated usage metrics for the session.
8512 ///
8513 /// Wire method: `session.usage.getMetrics`.
8514 ///
8515 /// # Returns
8516 ///
8517 /// Accumulated session usage metrics, including premium request cost, token counts, model breakdown, and code-change totals.
8518 ///
8519 /// <div class="warning">
8520 ///
8521 /// **Experimental.** This API is part of an experimental wire-protocol surface
8522 /// and may change or be removed in future SDK or CLI releases. Pin both the
8523 /// SDK and CLI versions if your code depends on it.
8524 ///
8525 /// </div>
8526 pub async fn get_metrics(&self) -> Result<UsageGetMetricsResult, Error> {
8527 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8528 let _value = self
8529 .session
8530 .client()
8531 .call(rpc_methods::SESSION_USAGE_GETMETRICS, Some(wire_params))
8532 .await?;
8533 Ok(serde_json::from_value(_value)?)
8534 }
8535}
8536
8537/// `session.visibility.*` RPCs.
8538#[derive(Clone, Copy)]
8539pub struct SessionRpcVisibility<'a> {
8540 pub(crate) session: &'a Session,
8541}
8542
8543impl<'a> SessionRpcVisibility<'a> {
8544 /// 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").
8545 ///
8546 /// Wire method: `session.visibility.get`.
8547 ///
8548 /// # Returns
8549 ///
8550 /// Current sharing status and shareable GitHub URL for a session.
8551 ///
8552 /// <div class="warning">
8553 ///
8554 /// **Experimental.** This API is part of an experimental wire-protocol surface
8555 /// and may change or be removed in future SDK or CLI releases. Pin both the
8556 /// SDK and CLI versions if your code depends on it.
8557 ///
8558 /// </div>
8559 pub async fn get(&self) -> Result<VisibilityGetResult, Error> {
8560 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8561 let _value = self
8562 .session
8563 .client()
8564 .call(rpc_methods::SESSION_VISIBILITY_GET, Some(wire_params))
8565 .await?;
8566 Ok(serde_json::from_value(_value)?)
8567 }
8568
8569 /// 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.
8570 ///
8571 /// Wire method: `session.visibility.set`.
8572 ///
8573 /// # Parameters
8574 ///
8575 /// * `params` - Desired sharing status for the session.
8576 ///
8577 /// # Returns
8578 ///
8579 /// Effective sharing status and shareable GitHub URL after updating session visibility.
8580 ///
8581 /// <div class="warning">
8582 ///
8583 /// **Experimental.** This API is part of an experimental wire-protocol surface
8584 /// and may change or be removed in future SDK or CLI releases. Pin both the
8585 /// SDK and CLI versions if your code depends on it.
8586 ///
8587 /// </div>
8588 pub async fn set(&self, params: VisibilitySetRequest) -> Result<VisibilitySetResult, Error> {
8589 let mut wire_params = serde_json::to_value(params)?;
8590 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8591 let _value = self
8592 .session
8593 .client()
8594 .call(rpc_methods::SESSION_VISIBILITY_SET, Some(wire_params))
8595 .await?;
8596 Ok(serde_json::from_value(_value)?)
8597 }
8598}
8599
8600/// `session.workspaces.*` RPCs.
8601#[derive(Clone, Copy)]
8602pub struct SessionRpcWorkspaces<'a> {
8603 pub(crate) session: &'a Session,
8604}
8605
8606impl<'a> SessionRpcWorkspaces<'a> {
8607 /// Gets current workspace metadata for the session.
8608 ///
8609 /// Wire method: `session.workspaces.getWorkspace`.
8610 ///
8611 /// # Returns
8612 ///
8613 /// Current workspace metadata for the session, including its absolute filesystem path when available.
8614 ///
8615 /// <div class="warning">
8616 ///
8617 /// **Experimental.** This API is part of an experimental wire-protocol surface
8618 /// and may change or be removed in future SDK or CLI releases. Pin both the
8619 /// SDK and CLI versions if your code depends on it.
8620 ///
8621 /// </div>
8622 pub async fn get_workspace(&self) -> Result<WorkspacesGetWorkspaceResult, Error> {
8623 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8624 let _value = self
8625 .session
8626 .client()
8627 .call(
8628 rpc_methods::SESSION_WORKSPACES_GETWORKSPACE,
8629 Some(wire_params),
8630 )
8631 .await?;
8632 Ok(serde_json::from_value(_value)?)
8633 }
8634
8635 /// Lists files stored in the session workspace files directory.
8636 ///
8637 /// Wire method: `session.workspaces.listFiles`.
8638 ///
8639 /// # Returns
8640 ///
8641 /// Relative paths of files stored in the session workspace files directory.
8642 ///
8643 /// <div class="warning">
8644 ///
8645 /// **Experimental.** This API is part of an experimental wire-protocol surface
8646 /// and may change or be removed in future SDK or CLI releases. Pin both the
8647 /// SDK and CLI versions if your code depends on it.
8648 ///
8649 /// </div>
8650 pub async fn list_files(&self) -> Result<WorkspacesListFilesResult, Error> {
8651 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8652 let _value = self
8653 .session
8654 .client()
8655 .call(rpc_methods::SESSION_WORKSPACES_LISTFILES, Some(wire_params))
8656 .await?;
8657 Ok(serde_json::from_value(_value)?)
8658 }
8659
8660 /// Reads a file from the session workspace files directory.
8661 ///
8662 /// Wire method: `session.workspaces.readFile`.
8663 ///
8664 /// # Parameters
8665 ///
8666 /// * `params` - Relative path of the workspace file to read.
8667 ///
8668 /// # Returns
8669 ///
8670 /// Contents of the requested workspace file as a UTF-8 string.
8671 ///
8672 /// <div class="warning">
8673 ///
8674 /// **Experimental.** This API is part of an experimental wire-protocol surface
8675 /// and may change or be removed in future SDK or CLI releases. Pin both the
8676 /// SDK and CLI versions if your code depends on it.
8677 ///
8678 /// </div>
8679 pub async fn read_file(
8680 &self,
8681 params: WorkspacesReadFileRequest,
8682 ) -> Result<WorkspacesReadFileResult, Error> {
8683 let mut wire_params = serde_json::to_value(params)?;
8684 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8685 let _value = self
8686 .session
8687 .client()
8688 .call(rpc_methods::SESSION_WORKSPACES_READFILE, Some(wire_params))
8689 .await?;
8690 Ok(serde_json::from_value(_value)?)
8691 }
8692
8693 /// Creates or overwrites a file in the session workspace files directory.
8694 ///
8695 /// Wire method: `session.workspaces.createFile`.
8696 ///
8697 /// # Parameters
8698 ///
8699 /// * `params` - Relative path and UTF-8 content for the workspace file to create or overwrite.
8700 ///
8701 /// <div class="warning">
8702 ///
8703 /// **Experimental.** This API is part of an experimental wire-protocol surface
8704 /// and may change or be removed in future SDK or CLI releases. Pin both the
8705 /// SDK and CLI versions if your code depends on it.
8706 ///
8707 /// </div>
8708 pub async fn create_file(&self, params: WorkspacesCreateFileRequest) -> Result<(), Error> {
8709 let mut wire_params = serde_json::to_value(params)?;
8710 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8711 let _value = self
8712 .session
8713 .client()
8714 .call(
8715 rpc_methods::SESSION_WORKSPACES_CREATEFILE,
8716 Some(wire_params),
8717 )
8718 .await?;
8719 Ok(())
8720 }
8721
8722 /// Lists workspace checkpoints in chronological order.
8723 ///
8724 /// Wire method: `session.workspaces.listCheckpoints`.
8725 ///
8726 /// # Returns
8727 ///
8728 /// Workspace checkpoints in chronological order; empty when the workspace is not enabled.
8729 ///
8730 /// <div class="warning">
8731 ///
8732 /// **Experimental.** This API is part of an experimental wire-protocol surface
8733 /// and may change or be removed in future SDK or CLI releases. Pin both the
8734 /// SDK and CLI versions if your code depends on it.
8735 ///
8736 /// </div>
8737 pub async fn list_checkpoints(&self) -> Result<WorkspacesListCheckpointsResult, Error> {
8738 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8739 let _value = self
8740 .session
8741 .client()
8742 .call(
8743 rpc_methods::SESSION_WORKSPACES_LISTCHECKPOINTS,
8744 Some(wire_params),
8745 )
8746 .await?;
8747 Ok(serde_json::from_value(_value)?)
8748 }
8749
8750 /// Reads the content of a workspace checkpoint by number.
8751 ///
8752 /// Wire method: `session.workspaces.readCheckpoint`.
8753 ///
8754 /// # Parameters
8755 ///
8756 /// * `params` - Checkpoint number to read.
8757 ///
8758 /// # Returns
8759 ///
8760 /// Checkpoint content as a UTF-8 string, or null when the checkpoint or workspace is missing.
8761 ///
8762 /// <div class="warning">
8763 ///
8764 /// **Experimental.** This API is part of an experimental wire-protocol surface
8765 /// and may change or be removed in future SDK or CLI releases. Pin both the
8766 /// SDK and CLI versions if your code depends on it.
8767 ///
8768 /// </div>
8769 pub async fn read_checkpoint(
8770 &self,
8771 params: WorkspacesReadCheckpointRequest,
8772 ) -> Result<WorkspacesReadCheckpointResult, Error> {
8773 let mut wire_params = serde_json::to_value(params)?;
8774 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8775 let _value = self
8776 .session
8777 .client()
8778 .call(
8779 rpc_methods::SESSION_WORKSPACES_READCHECKPOINT,
8780 Some(wire_params),
8781 )
8782 .await?;
8783 Ok(serde_json::from_value(_value)?)
8784 }
8785
8786 /// Saves pasted content as a UTF-8 file in the session workspace.
8787 ///
8788 /// Wire method: `session.workspaces.saveLargePaste`.
8789 ///
8790 /// # Parameters
8791 ///
8792 /// * `params` - Pasted content to save as a UTF-8 file in the session workspace.
8793 ///
8794 /// # Returns
8795 ///
8796 /// Descriptor for the saved paste file, or null when the workspace is unavailable.
8797 ///
8798 /// <div class="warning">
8799 ///
8800 /// **Experimental.** This API is part of an experimental wire-protocol surface
8801 /// and may change or be removed in future SDK or CLI releases. Pin both the
8802 /// SDK and CLI versions if your code depends on it.
8803 ///
8804 /// </div>
8805 pub async fn save_large_paste(
8806 &self,
8807 params: WorkspacesSaveLargePasteRequest,
8808 ) -> Result<WorkspacesSaveLargePasteResult, Error> {
8809 let mut wire_params = serde_json::to_value(params)?;
8810 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8811 let _value = self
8812 .session
8813 .client()
8814 .call(
8815 rpc_methods::SESSION_WORKSPACES_SAVELARGEPASTE,
8816 Some(wire_params),
8817 )
8818 .await?;
8819 Ok(serde_json::from_value(_value)?)
8820 }
8821
8822 /// Computes a diff for the session workspace.
8823 ///
8824 /// Wire method: `session.workspaces.diff`.
8825 ///
8826 /// # Parameters
8827 ///
8828 /// * `params` - Parameters for computing a workspace diff.
8829 ///
8830 /// # Returns
8831 ///
8832 /// Workspace diff result for the requested mode.
8833 ///
8834 /// <div class="warning">
8835 ///
8836 /// **Experimental.** This API is part of an experimental wire-protocol surface
8837 /// and may change or be removed in future SDK or CLI releases. Pin both the
8838 /// SDK and CLI versions if your code depends on it.
8839 ///
8840 /// </div>
8841 pub async fn diff(&self, params: WorkspacesDiffRequest) -> Result<WorkspaceDiffResult, Error> {
8842 let mut wire_params = serde_json::to_value(params)?;
8843 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8844 let _value = self
8845 .session
8846 .client()
8847 .call(rpc_methods::SESSION_WORKSPACES_DIFF, Some(wire_params))
8848 .await?;
8849 Ok(serde_json::from_value(_value)?)
8850 }
8851}