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