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 /// Returns the running runtime's complete catalog of well-known built-in model IDs without authentication or network access.
947 ///
948 /// Wire method: `models.getBuiltInCatalog`.
949 ///
950 /// # Returns
951 ///
952 /// The running runtime's complete catalog of well-known built-in model IDs, including supported models and additional IDs with built-in metadata.
953 ///
954 /// <div class="warning">
955 ///
956 /// **Experimental.** This API is part of an experimental wire-protocol surface
957 /// and may change or be removed in future SDK or CLI releases. Pin both the
958 /// SDK and CLI versions if your code depends on it.
959 ///
960 /// </div>
961 pub async fn get_built_in_catalog(&self) -> Result<BuiltInModelCatalog, Error> {
962 let wire_params = serde_json::json!({});
963 let _value = self
964 .client
965 .call(rpc_methods::MODELS_GETBUILTINCATALOG, Some(wire_params))
966 .await?;
967 Ok(serde_json::from_value(_value)?)
968 }
969}
970
971/// `plugins.*` RPCs.
972#[derive(Clone, Copy)]
973pub struct ClientRpcPlugins<'a> {
974 pub(crate) client: &'a Client,
975}
976
977impl<'a> ClientRpcPlugins<'a> {
978 /// `plugins.marketplaces.*` sub-namespace.
979 pub fn marketplaces(&self) -> ClientRpcPluginsMarketplaces<'a> {
980 ClientRpcPluginsMarketplaces {
981 client: self.client,
982 }
983 }
984
985 /// Lists plugins installed in user/global state.
986 ///
987 /// Wire method: `plugins.list`.
988 ///
989 /// # Returns
990 ///
991 /// Plugins installed in user/global state.
992 ///
993 /// <div class="warning">
994 ///
995 /// **Experimental.** This API is part of an experimental wire-protocol surface
996 /// and may change or be removed in future SDK or CLI releases. Pin both the
997 /// SDK and CLI versions if your code depends on it.
998 ///
999 /// </div>
1000 pub async fn list(&self) -> Result<PluginListResult, Error> {
1001 let wire_params = serde_json::json!({});
1002 let _value = self
1003 .client
1004 .call(rpc_methods::PLUGINS_LIST, Some(wire_params))
1005 .await?;
1006 Ok(serde_json::from_value(_value)?)
1007 }
1008
1009 /// Installs a plugin from a marketplace, GitHub repo, URL, or local path.
1010 ///
1011 /// Wire method: `plugins.install`.
1012 ///
1013 /// # Parameters
1014 ///
1015 /// * `params` - Plugin source and optional working directory for relative-path resolution.
1016 ///
1017 /// # Returns
1018 ///
1019 /// Result of installing a plugin.
1020 ///
1021 /// <div class="warning">
1022 ///
1023 /// **Experimental.** This API is part of an experimental wire-protocol surface
1024 /// and may change or be removed in future SDK or CLI releases. Pin both the
1025 /// SDK and CLI versions if your code depends on it.
1026 ///
1027 /// </div>
1028 pub async fn install(
1029 &self,
1030 params: PluginsInstallRequest,
1031 ) -> Result<PluginInstallResult, Error> {
1032 let wire_params = serde_json::to_value(params)?;
1033 let _value = self
1034 .client
1035 .call(rpc_methods::PLUGINS_INSTALL, Some(wire_params))
1036 .await?;
1037 Ok(serde_json::from_value(_value)?)
1038 }
1039
1040 /// Uninstalls an installed plugin.
1041 ///
1042 /// Wire method: `plugins.uninstall`.
1043 ///
1044 /// # Parameters
1045 ///
1046 /// * `params` - Name (or spec) of the plugin to uninstall.
1047 ///
1048 /// <div class="warning">
1049 ///
1050 /// **Experimental.** This API is part of an experimental wire-protocol surface
1051 /// and may change or be removed in future SDK or CLI releases. Pin both the
1052 /// SDK and CLI versions if your code depends on it.
1053 ///
1054 /// </div>
1055 pub async fn uninstall(&self, params: PluginsUninstallRequest) -> Result<(), Error> {
1056 let wire_params = serde_json::to_value(params)?;
1057 let _value = self
1058 .client
1059 .call(rpc_methods::PLUGINS_UNINSTALL, Some(wire_params))
1060 .await?;
1061 Ok(())
1062 }
1063
1064 /// Updates an installed plugin to its latest published version.
1065 ///
1066 /// Wire method: `plugins.update`.
1067 ///
1068 /// # Parameters
1069 ///
1070 /// * `params` - Name (or spec) of the plugin to update.
1071 ///
1072 /// # Returns
1073 ///
1074 /// Result of updating a single plugin.
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(&self, params: PluginsUpdateRequest) -> Result<PluginUpdateResult, Error> {
1084 let wire_params = serde_json::to_value(params)?;
1085 let _value = self
1086 .client
1087 .call(rpc_methods::PLUGINS_UPDATE, Some(wire_params))
1088 .await?;
1089 Ok(serde_json::from_value(_value)?)
1090 }
1091
1092 /// Updates every installed plugin to its latest published version.
1093 ///
1094 /// Wire method: `plugins.updateAll`.
1095 ///
1096 /// # Returns
1097 ///
1098 /// Result of updating all installed plugins.
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 update_all(&self) -> Result<PluginUpdateAllResult, Error> {
1108 let wire_params = serde_json::json!({});
1109 let _value = self
1110 .client
1111 .call(rpc_methods::PLUGINS_UPDATEALL, Some(wire_params))
1112 .await?;
1113 Ok(serde_json::from_value(_value)?)
1114 }
1115
1116 /// Enables installed plugins for new sessions.
1117 ///
1118 /// Wire method: `plugins.enable`.
1119 ///
1120 /// # Parameters
1121 ///
1122 /// * `params` - Plugin names (or specs) to enable.
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 enable(&self, params: PluginsEnableRequest) -> Result<(), Error> {
1132 let wire_params = serde_json::to_value(params)?;
1133 let _value = self
1134 .client
1135 .call(rpc_methods::PLUGINS_ENABLE, Some(wire_params))
1136 .await?;
1137 Ok(())
1138 }
1139
1140 /// Disables installed plugins for new sessions.
1141 ///
1142 /// Wire method: `plugins.disable`.
1143 ///
1144 /// # Parameters
1145 ///
1146 /// * `params` - Plugin names (or specs) to disable.
1147 ///
1148 /// <div class="warning">
1149 ///
1150 /// **Experimental.** This API is part of an experimental wire-protocol surface
1151 /// and may change or be removed in future SDK or CLI releases. Pin both the
1152 /// SDK and CLI versions if your code depends on it.
1153 ///
1154 /// </div>
1155 pub async fn disable(&self, params: PluginsDisableRequest) -> Result<(), Error> {
1156 let wire_params = serde_json::to_value(params)?;
1157 let _value = self
1158 .client
1159 .call(rpc_methods::PLUGINS_DISABLE, Some(wire_params))
1160 .await?;
1161 Ok(())
1162 }
1163}
1164
1165/// `plugins.marketplaces.*` RPCs.
1166#[derive(Clone, Copy)]
1167pub struct ClientRpcPluginsMarketplaces<'a> {
1168 pub(crate) client: &'a Client,
1169}
1170
1171impl<'a> ClientRpcPluginsMarketplaces<'a> {
1172 /// Lists all registered marketplaces (defaults + user-added).
1173 ///
1174 /// Wire method: `plugins.marketplaces.list`.
1175 ///
1176 /// # Returns
1177 ///
1178 /// All registered marketplaces, including built-in defaults.
1179 ///
1180 /// <div class="warning">
1181 ///
1182 /// **Experimental.** This API is part of an experimental wire-protocol surface
1183 /// and may change or be removed in future SDK or CLI releases. Pin both the
1184 /// SDK and CLI versions if your code depends on it.
1185 ///
1186 /// </div>
1187 pub async fn list(&self) -> Result<MarketplaceListResult, Error> {
1188 let wire_params = serde_json::json!({});
1189 let _value = self
1190 .client
1191 .call(rpc_methods::PLUGINS_MARKETPLACES_LIST, Some(wire_params))
1192 .await?;
1193 Ok(serde_json::from_value(_value)?)
1194 }
1195
1196 /// Registers a new marketplace from a source (owner/repo, URL, or local path).
1197 ///
1198 /// Wire method: `plugins.marketplaces.add`.
1199 ///
1200 /// # Parameters
1201 ///
1202 /// * `params` - Marketplace source and optional working directory for relative-path resolution.
1203 ///
1204 /// # Returns
1205 ///
1206 /// Result of registering a new marketplace.
1207 ///
1208 /// <div class="warning">
1209 ///
1210 /// **Experimental.** This API is part of an experimental wire-protocol surface
1211 /// and may change or be removed in future SDK or CLI releases. Pin both the
1212 /// SDK and CLI versions if your code depends on it.
1213 ///
1214 /// </div>
1215 pub async fn add(
1216 &self,
1217 params: PluginsMarketplacesAddRequest,
1218 ) -> Result<MarketplaceAddResult, Error> {
1219 let wire_params = serde_json::to_value(params)?;
1220 let _value = self
1221 .client
1222 .call(rpc_methods::PLUGINS_MARKETPLACES_ADD, Some(wire_params))
1223 .await?;
1224 Ok(serde_json::from_value(_value)?)
1225 }
1226
1227 /// 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`.
1228 ///
1229 /// Wire method: `plugins.marketplaces.remove`.
1230 ///
1231 /// # Parameters
1232 ///
1233 /// * `params` - Name of the marketplace to remove and an optional force flag.
1234 ///
1235 /// # Returns
1236 ///
1237 /// Outcome of the remove attempt, including dependent-plugin info when applicable.
1238 ///
1239 /// <div class="warning">
1240 ///
1241 /// **Experimental.** This API is part of an experimental wire-protocol surface
1242 /// and may change or be removed in future SDK or CLI releases. Pin both the
1243 /// SDK and CLI versions if your code depends on it.
1244 ///
1245 /// </div>
1246 pub async fn remove(
1247 &self,
1248 params: PluginsMarketplacesRemoveRequest,
1249 ) -> Result<MarketplaceRemoveResult, Error> {
1250 let wire_params = serde_json::to_value(params)?;
1251 let _value = self
1252 .client
1253 .call(rpc_methods::PLUGINS_MARKETPLACES_REMOVE, Some(wire_params))
1254 .await?;
1255 Ok(serde_json::from_value(_value)?)
1256 }
1257
1258 /// Lists plugins advertised by a registered marketplace.
1259 ///
1260 /// Wire method: `plugins.marketplaces.browse`.
1261 ///
1262 /// # Parameters
1263 ///
1264 /// * `params` - Name of the marketplace whose plugin catalog to fetch.
1265 ///
1266 /// # Returns
1267 ///
1268 /// Plugins advertised by the marketplace.
1269 ///
1270 /// <div class="warning">
1271 ///
1272 /// **Experimental.** This API is part of an experimental wire-protocol surface
1273 /// and may change or be removed in future SDK or CLI releases. Pin both the
1274 /// SDK and CLI versions if your code depends on it.
1275 ///
1276 /// </div>
1277 pub async fn browse(
1278 &self,
1279 params: PluginsMarketplacesBrowseRequest,
1280 ) -> Result<MarketplaceBrowseResult, Error> {
1281 let wire_params = serde_json::to_value(params)?;
1282 let _value = self
1283 .client
1284 .call(rpc_methods::PLUGINS_MARKETPLACES_BROWSE, 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 /// # Returns
1294 ///
1295 /// Result of refreshing one or more marketplace catalogs.
1296 ///
1297 /// <div class="warning">
1298 ///
1299 /// **Experimental.** This API is part of an experimental wire-protocol surface
1300 /// and may change or be removed in future SDK or CLI releases. Pin both the
1301 /// SDK and CLI versions if your code depends on it.
1302 ///
1303 /// </div>
1304 pub async fn refresh(&self) -> Result<MarketplaceRefreshResult, Error> {
1305 let wire_params = serde_json::json!({});
1306 let _value = self
1307 .client
1308 .call(rpc_methods::PLUGINS_MARKETPLACES_REFRESH, Some(wire_params))
1309 .await?;
1310 Ok(serde_json::from_value(_value)?)
1311 }
1312
1313 /// Re-fetches one or all registered marketplace catalogs.
1314 ///
1315 /// Wire method: `plugins.marketplaces.refresh`.
1316 ///
1317 /// # Parameters
1318 ///
1319 /// * `params` - Optional marketplace name; omit to refresh all.
1320 ///
1321 /// # Returns
1322 ///
1323 /// Result of refreshing one or more marketplace catalogs.
1324 ///
1325 /// <div class="warning">
1326 ///
1327 /// **Experimental.** This API is part of an experimental wire-protocol surface
1328 /// and may change or be removed in future SDK or CLI releases. Pin both the
1329 /// SDK and CLI versions if your code depends on it.
1330 ///
1331 /// </div>
1332 pub async fn refresh_with_params(
1333 &self,
1334 params: PluginsMarketplacesRefreshRequest,
1335 ) -> Result<MarketplaceRefreshResult, Error> {
1336 let wire_params = serde_json::to_value(params)?;
1337 let _value = self
1338 .client
1339 .call(rpc_methods::PLUGINS_MARKETPLACES_REFRESH, Some(wire_params))
1340 .await?;
1341 Ok(serde_json::from_value(_value)?)
1342 }
1343}
1344
1345/// `runtime.*` RPCs.
1346#[derive(Clone, Copy)]
1347pub struct ClientRpcRuntime<'a> {
1348 pub(crate) client: &'a Client,
1349}
1350
1351impl<'a> ClientRpcRuntime<'a> {
1352 /// Gracefully shuts down an SDK-owned runtime. The response is sent only after cleanup completes; callers may then terminate the owned runtime process.
1353 ///
1354 /// Wire method: `runtime.shutdown`.
1355 ///
1356 /// <div class="warning">
1357 ///
1358 /// **Experimental.** This API is part of an experimental wire-protocol surface
1359 /// and may change or be removed in future SDK or CLI releases. Pin both the
1360 /// SDK and CLI versions if your code depends on it.
1361 ///
1362 /// </div>
1363 pub async fn shutdown(&self) -> Result<(), Error> {
1364 let wire_params = serde_json::json!({});
1365 let _value = self
1366 .client
1367 .call(rpc_methods::RUNTIME_SHUTDOWN, Some(wire_params))
1368 .await?;
1369 Ok(())
1370 }
1371}
1372
1373/// `secrets.*` RPCs.
1374#[derive(Clone, Copy)]
1375pub struct ClientRpcSecrets<'a> {
1376 pub(crate) client: &'a Client,
1377}
1378
1379impl<'a> ClientRpcSecrets<'a> {
1380 /// Registers secret values for redaction in session logs and exports. The SDK calls this to inject dynamically generated secret values (e.g., OIDC tokens).
1381 ///
1382 /// Wire method: `secrets.addFilterValues`.
1383 ///
1384 /// # Parameters
1385 ///
1386 /// * `params` - Secret values to add to the redaction filter.
1387 ///
1388 /// # Returns
1389 ///
1390 /// Confirmation that the secret values were registered.
1391 ///
1392 /// <div class="warning">
1393 ///
1394 /// **Experimental.** This API is part of an experimental wire-protocol surface
1395 /// and may change or be removed in future SDK or CLI releases. Pin both the
1396 /// SDK and CLI versions if your code depends on it.
1397 ///
1398 /// </div>
1399 pub async fn add_filter_values(
1400 &self,
1401 params: SecretsAddFilterValuesRequest,
1402 ) -> Result<SecretsAddFilterValuesResult, Error> {
1403 let wire_params = serde_json::to_value(params)?;
1404 let _value = self
1405 .client
1406 .call(rpc_methods::SECRETS_ADDFILTERVALUES, Some(wire_params))
1407 .await?;
1408 Ok(serde_json::from_value(_value)?)
1409 }
1410}
1411
1412/// `sessionFs.*` RPCs.
1413#[derive(Clone, Copy)]
1414pub struct ClientRpcSessionFs<'a> {
1415 pub(crate) client: &'a Client,
1416}
1417
1418impl<'a> ClientRpcSessionFs<'a> {
1419 /// Registers an SDK client as the session filesystem provider.
1420 ///
1421 /// Wire method: `sessionFs.setProvider`.
1422 ///
1423 /// # Parameters
1424 ///
1425 /// * `params` - Initial working directory, session-state path layout, and path conventions used to register the calling SDK client as the session filesystem provider.
1426 ///
1427 /// # Returns
1428 ///
1429 /// Indicates whether the calling client was registered as the session filesystem provider.
1430 ///
1431 /// <div class="warning">
1432 ///
1433 /// **Experimental.** This API is part of an experimental wire-protocol surface
1434 /// and may change or be removed in future SDK or CLI releases. Pin both the
1435 /// SDK and CLI versions if your code depends on it.
1436 ///
1437 /// </div>
1438 pub async fn set_provider(
1439 &self,
1440 params: SessionFsSetProviderRequest,
1441 ) -> Result<SessionFsSetProviderResult, Error> {
1442 let wire_params = serde_json::to_value(params)?;
1443 let _value = self
1444 .client
1445 .call(rpc_methods::SESSIONFS_SETPROVIDER, Some(wire_params))
1446 .await?;
1447 Ok(serde_json::from_value(_value)?)
1448 }
1449}
1450
1451/// `sessions.*` RPCs.
1452#[derive(Clone, Copy)]
1453pub struct ClientRpcSessions<'a> {
1454 pub(crate) client: &'a Client,
1455}
1456
1457impl<'a> ClientRpcSessions<'a> {
1458 /// Creates or resumes a local session and returns the opened session ID.
1459 ///
1460 /// Wire method: `sessions.open`.
1461 ///
1462 /// # Returns
1463 ///
1464 /// Result of opening a session.
1465 ///
1466 /// <div class="warning">
1467 ///
1468 /// **Experimental.** This API is part of an experimental wire-protocol surface
1469 /// and may change or be removed in future SDK or CLI releases. Pin both the
1470 /// SDK and CLI versions if your code depends on it.
1471 ///
1472 /// </div>
1473 pub async fn open(&self) -> Result<SessionOpenResult, Error> {
1474 let wire_params = serde_json::json!({});
1475 let _value = self
1476 .client
1477 .call(rpc_methods::SESSIONS_OPEN, Some(wire_params))
1478 .await?;
1479 Ok(serde_json::from_value(_value)?)
1480 }
1481
1482 /// Creates a new session by forking persisted history from an existing session.
1483 ///
1484 /// Wire method: `sessions.fork`.
1485 ///
1486 /// # Parameters
1487 ///
1488 /// * `params` - Source session identifier to fork from, optional event-ID boundary, and optional friendly name for the new session.
1489 ///
1490 /// # Returns
1491 ///
1492 /// Identifier and optional friendly name assigned to the newly forked session.
1493 ///
1494 /// <div class="warning">
1495 ///
1496 /// **Experimental.** This API is part of an experimental wire-protocol surface
1497 /// and may change or be removed in future SDK or CLI releases. Pin both the
1498 /// SDK and CLI versions if your code depends on it.
1499 ///
1500 /// </div>
1501 pub async fn fork(&self, params: SessionsForkRequest) -> Result<SessionsForkResult, Error> {
1502 let wire_params = serde_json::to_value(params)?;
1503 let _value = self
1504 .client
1505 .call(rpc_methods::SESSIONS_FORK, Some(wire_params))
1506 .await?;
1507 Ok(serde_json::from_value(_value)?)
1508 }
1509
1510 /// Connects to an existing remote session and exposes it as an SDK session.
1511 ///
1512 /// Wire method: `sessions.connect`.
1513 ///
1514 /// # Parameters
1515 ///
1516 /// * `params` - Remote session connection parameters.
1517 ///
1518 /// # Returns
1519 ///
1520 /// Remote session connection result.
1521 ///
1522 /// <div class="warning">
1523 ///
1524 /// **Experimental.** This API is part of an experimental wire-protocol surface
1525 /// and may change or be removed in future SDK or CLI releases. Pin both the
1526 /// SDK and CLI versions if your code depends on it.
1527 ///
1528 /// </div>
1529 pub async fn connect(
1530 &self,
1531 params: ConnectRemoteSessionParams,
1532 ) -> Result<RemoteSessionConnectionResult, Error> {
1533 let wire_params = serde_json::to_value(params)?;
1534 let _value = self
1535 .client
1536 .call(rpc_methods::SESSIONS_CONNECT, 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 /// # Returns
1546 ///
1547 /// Sessions matching the filter, ordered most-recently-modified first.
1548 ///
1549 /// <div class="warning">
1550 ///
1551 /// **Experimental.** This API is part of an experimental wire-protocol surface
1552 /// and may change or be removed in future SDK or CLI releases. Pin both the
1553 /// SDK and CLI versions if your code depends on it.
1554 ///
1555 /// </div>
1556 pub async fn list(&self) -> Result<SessionList, Error> {
1557 let wire_params = serde_json::json!({});
1558 let _value = self
1559 .client
1560 .call(rpc_methods::SESSIONS_LIST, Some(wire_params))
1561 .await?;
1562 Ok(serde_json::from_value(_value)?)
1563 }
1564
1565 /// 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.).
1566 ///
1567 /// Wire method: `sessions.list`.
1568 ///
1569 /// # Parameters
1570 ///
1571 /// * `params` - Optional source filter, metadata-load limit, and context filter applied to the returned sessions.
1572 ///
1573 /// # Returns
1574 ///
1575 /// Sessions matching the filter, ordered most-recently-modified first.
1576 ///
1577 /// <div class="warning">
1578 ///
1579 /// **Experimental.** This API is part of an experimental wire-protocol surface
1580 /// and may change or be removed in future SDK or CLI releases. Pin both the
1581 /// SDK and CLI versions if your code depends on it.
1582 ///
1583 /// </div>
1584 pub async fn list_with_params(
1585 &self,
1586 params: SessionsListRequest,
1587 ) -> Result<SessionList, Error> {
1588 let wire_params = serde_json::to_value(params)?;
1589 let _value = self
1590 .client
1591 .call(rpc_methods::SESSIONS_LIST, Some(wire_params))
1592 .await?;
1593 Ok(serde_json::from_value(_value)?)
1594 }
1595
1596 /// Reads lightweight persisted metadata for one local session without opening it.
1597 ///
1598 /// Wire method: `sessions.getMetadata`.
1599 ///
1600 /// # Parameters
1601 ///
1602 /// * `params` - Session ID whose persisted metadata should be read.
1603 ///
1604 /// # Returns
1605 ///
1606 /// Persisted local session metadata when the session exists.
1607 ///
1608 /// <div class="warning">
1609 ///
1610 /// **Experimental.** This API is part of an experimental wire-protocol surface
1611 /// and may change or be removed in future SDK or CLI releases. Pin both the
1612 /// SDK and CLI versions if your code depends on it.
1613 ///
1614 /// </div>
1615 pub(crate) async fn get_metadata(
1616 &self,
1617 params: SessionsGetMetadataRequest,
1618 ) -> Result<SessionsGetMetadataResult, Error> {
1619 let wire_params = serde_json::to_value(params)?;
1620 let _value = self
1621 .client
1622 .call(rpc_methods::SESSIONS_GETMETADATA, Some(wire_params))
1623 .await?;
1624 Ok(serde_json::from_value(_value)?)
1625 }
1626
1627 /// Lists recent local session IDs that contain user-visible history, omitting housekeeping-only sessions.
1628 ///
1629 /// Wire method: `sessions.listNonEmptySessionIds`.
1630 ///
1631 /// # Parameters
1632 ///
1633 /// * `params` - Limit for non-empty local session IDs.
1634 ///
1635 /// # Returns
1636 ///
1637 /// Recent local session IDs that contain user-visible history.
1638 ///
1639 /// <div class="warning">
1640 ///
1641 /// **Experimental.** This API is part of an experimental wire-protocol surface
1642 /// and may change or be removed in future SDK or CLI releases. Pin both the
1643 /// SDK and CLI versions if your code depends on it.
1644 ///
1645 /// </div>
1646 pub(crate) async fn list_non_empty_session_ids(
1647 &self,
1648 params: SessionsListNonEmptySessionIdsRequest,
1649 ) -> Result<SessionsListNonEmptySessionIdsResult, Error> {
1650 let wire_params = serde_json::to_value(params)?;
1651 let _value = self
1652 .client
1653 .call(
1654 rpc_methods::SESSIONS_LISTNONEMPTYSESSIONIDS,
1655 Some(wire_params),
1656 )
1657 .await?;
1658 Ok(serde_json::from_value(_value)?)
1659 }
1660
1661 /// Finds the local session bound to a GitHub task ID, if any.
1662 ///
1663 /// Wire method: `sessions.findByTaskId`.
1664 ///
1665 /// # Parameters
1666 ///
1667 /// * `params` - GitHub task ID to look up.
1668 ///
1669 /// # Returns
1670 ///
1671 /// ID of the local session bound to the given GitHub task, or omitted when none.
1672 ///
1673 /// <div class="warning">
1674 ///
1675 /// **Experimental.** This API is part of an experimental wire-protocol surface
1676 /// and may change or be removed in future SDK or CLI releases. Pin both the
1677 /// SDK and CLI versions if your code depends on it.
1678 ///
1679 /// </div>
1680 pub async fn find_by_task_id(
1681 &self,
1682 params: SessionsFindByTaskIDRequest,
1683 ) -> Result<SessionsFindByTaskIDResult, Error> {
1684 let wire_params = serde_json::to_value(params)?;
1685 let _value = self
1686 .client
1687 .call(rpc_methods::SESSIONS_FINDBYTASKID, Some(wire_params))
1688 .await?;
1689 Ok(serde_json::from_value(_value)?)
1690 }
1691
1692 /// Resolves a UUID prefix to a unique session ID, if exactly one session matches.
1693 ///
1694 /// Wire method: `sessions.findByPrefix`.
1695 ///
1696 /// # Parameters
1697 ///
1698 /// * `params` - UUID prefix to resolve to a unique session ID.
1699 ///
1700 /// # Returns
1701 ///
1702 /// Session ID matching the prefix, omitted when no unique match exists.
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 find_by_prefix(
1712 &self,
1713 params: SessionsFindByPrefixRequest,
1714 ) -> Result<SessionsFindByPrefixResult, Error> {
1715 let wire_params = serde_json::to_value(params)?;
1716 let _value = self
1717 .client
1718 .call(rpc_methods::SESSIONS_FINDBYPREFIX, Some(wire_params))
1719 .await?;
1720 Ok(serde_json::from_value(_value)?)
1721 }
1722
1723 /// Returns the most-relevant prior session for a given working-directory context.
1724 ///
1725 /// Wire method: `sessions.getLastForContext`.
1726 ///
1727 /// # Parameters
1728 ///
1729 /// * `params` - Optional working-directory context used to score session relevance.
1730 ///
1731 /// # Returns
1732 ///
1733 /// Most-relevant session ID for the supplied context, or omitted when no sessions exist.
1734 ///
1735 /// <div class="warning">
1736 ///
1737 /// **Experimental.** This API is part of an experimental wire-protocol surface
1738 /// and may change or be removed in future SDK or CLI releases. Pin both the
1739 /// SDK and CLI versions if your code depends on it.
1740 ///
1741 /// </div>
1742 pub async fn get_last_for_context(
1743 &self,
1744 params: SessionsGetLastForContextRequest,
1745 ) -> Result<SessionsGetLastForContextResult, Error> {
1746 let wire_params = serde_json::to_value(params)?;
1747 let _value = self
1748 .client
1749 .call(rpc_methods::SESSIONS_GETLASTFORCONTEXT, Some(wire_params))
1750 .await?;
1751 Ok(serde_json::from_value(_value)?)
1752 }
1753
1754 /// 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.
1755 ///
1756 /// Wire method: `sessions.getEventFilePath`.
1757 ///
1758 /// # Parameters
1759 ///
1760 /// * `params` - Session ID whose event-log file path to compute.
1761 ///
1762 /// # Returns
1763 ///
1764 /// Absolute path to the session's events.jsonl file on disk.
1765 ///
1766 /// <div class="warning">
1767 ///
1768 /// **Experimental.** This API is part of an experimental wire-protocol surface
1769 /// and may change or be removed in future SDK or CLI releases. Pin both the
1770 /// SDK and CLI versions if your code depends on it.
1771 ///
1772 /// </div>
1773 pub(crate) async fn get_event_file_path(
1774 &self,
1775 params: SessionsGetEventFilePathRequest,
1776 ) -> Result<SessionsGetEventFilePathResult, Error> {
1777 let wire_params = serde_json::to_value(params)?;
1778 let _value = self
1779 .client
1780 .call(rpc_methods::SESSIONS_GETEVENTFILEPATH, Some(wire_params))
1781 .await?;
1782 Ok(serde_json::from_value(_value)?)
1783 }
1784
1785 /// Returns the on-disk byte size of each session's workspace directory.
1786 ///
1787 /// Wire method: `sessions.getSizes`.
1788 ///
1789 /// # Returns
1790 ///
1791 /// Map of sessionId -> on-disk size in bytes for each session's workspace directory.
1792 ///
1793 /// <div class="warning">
1794 ///
1795 /// **Experimental.** This API is part of an experimental wire-protocol surface
1796 /// and may change or be removed in future SDK or CLI releases. Pin both the
1797 /// SDK and CLI versions if your code depends on it.
1798 ///
1799 /// </div>
1800 pub async fn get_sizes(&self) -> Result<SessionSizes, Error> {
1801 let wire_params = serde_json::json!({});
1802 let _value = self
1803 .client
1804 .call(rpc_methods::SESSIONS_GETSIZES, Some(wire_params))
1805 .await?;
1806 Ok(serde_json::from_value(_value)?)
1807 }
1808
1809 /// Returns the subset of the supplied session IDs that are currently held by another running process.
1810 ///
1811 /// Wire method: `sessions.checkInUse`.
1812 ///
1813 /// # Parameters
1814 ///
1815 /// * `params` - Session IDs to test for live in-use locks.
1816 ///
1817 /// # Returns
1818 ///
1819 /// Session IDs from the input set that are currently in use by another process.
1820 ///
1821 /// <div class="warning">
1822 ///
1823 /// **Experimental.** This API is part of an experimental wire-protocol surface
1824 /// and may change or be removed in future SDK or CLI releases. Pin both the
1825 /// SDK and CLI versions if your code depends on it.
1826 ///
1827 /// </div>
1828 pub async fn check_in_use(
1829 &self,
1830 params: SessionsCheckInUseRequest,
1831 ) -> Result<SessionsCheckInUseResult, Error> {
1832 let wire_params = serde_json::to_value(params)?;
1833 let _value = self
1834 .client
1835 .call(rpc_methods::SESSIONS_CHECKINUSE, Some(wire_params))
1836 .await?;
1837 Ok(serde_json::from_value(_value)?)
1838 }
1839
1840 /// 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.
1841 ///
1842 /// Wire method: `sessions.getPersistedRemoteSteerable`.
1843 ///
1844 /// # Parameters
1845 ///
1846 /// * `params` - Session ID to look up the persisted remote-steerable flag for.
1847 ///
1848 /// # Returns
1849 ///
1850 /// The session's persisted remote-steerable flag, or omitted when no value has been persisted.
1851 ///
1852 /// <div class="warning">
1853 ///
1854 /// **Experimental.** This API is part of an experimental wire-protocol surface
1855 /// and may change or be removed in future SDK or CLI releases. Pin both the
1856 /// SDK and CLI versions if your code depends on it.
1857 ///
1858 /// </div>
1859 pub(crate) async fn get_persisted_remote_steerable(
1860 &self,
1861 params: SessionsGetPersistedRemoteSteerableRequest,
1862 ) -> Result<SessionsGetPersistedRemoteSteerableResult, Error> {
1863 let wire_params = serde_json::to_value(params)?;
1864 let _value = self
1865 .client
1866 .call(
1867 rpc_methods::SESSIONS_GETPERSISTEDREMOTESTEERABLE,
1868 Some(wire_params),
1869 )
1870 .await?;
1871 Ok(serde_json::from_value(_value)?)
1872 }
1873
1874 /// Closes a session: emits shutdown, flushes pending events, releases the in-use lock, and disposes the active session.
1875 ///
1876 /// Wire method: `sessions.close`.
1877 ///
1878 /// # Parameters
1879 ///
1880 /// * `params` - Session ID to close.
1881 ///
1882 /// # Returns
1883 ///
1884 /// 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.
1885 ///
1886 /// <div class="warning">
1887 ///
1888 /// **Experimental.** This API is part of an experimental wire-protocol surface
1889 /// and may change or be removed in future SDK or CLI releases. Pin both the
1890 /// SDK and CLI versions if your code depends on it.
1891 ///
1892 /// </div>
1893 pub async fn close(&self, params: SessionsCloseRequest) -> Result<SessionsCloseResult, Error> {
1894 let wire_params = serde_json::to_value(params)?;
1895 let _value = self
1896 .client
1897 .call(rpc_methods::SESSIONS_CLOSE, Some(wire_params))
1898 .await?;
1899 Ok(serde_json::from_value(_value)?)
1900 }
1901
1902 /// Closes, deactivates, and deletes a set of sessions, returning the bytes freed per session.
1903 ///
1904 /// Wire method: `sessions.bulkDelete`.
1905 ///
1906 /// # Parameters
1907 ///
1908 /// * `params` - Session IDs to close, deactivate, and delete from disk.
1909 ///
1910 /// # Returns
1911 ///
1912 /// Map of sessionId -> bytes freed by removing the session's workspace directory.
1913 ///
1914 /// <div class="warning">
1915 ///
1916 /// **Experimental.** This API is part of an experimental wire-protocol surface
1917 /// and may change or be removed in future SDK or CLI releases. Pin both the
1918 /// SDK and CLI versions if your code depends on it.
1919 ///
1920 /// </div>
1921 pub async fn bulk_delete(
1922 &self,
1923 params: SessionsBulkDeleteRequest,
1924 ) -> Result<SessionBulkDeleteResult, Error> {
1925 let wire_params = serde_json::to_value(params)?;
1926 let _value = self
1927 .client
1928 .call(rpc_methods::SESSIONS_BULKDELETE, Some(wire_params))
1929 .await?;
1930 Ok(serde_json::from_value(_value)?)
1931 }
1932
1933 /// Deletes one local session from disk after running the same lifecycle hooks as the session manager.
1934 ///
1935 /// Wire method: `sessions.delete`.
1936 ///
1937 /// # Parameters
1938 ///
1939 /// * `params` - Session ID to delete from disk.
1940 ///
1941 /// <div class="warning">
1942 ///
1943 /// **Experimental.** This API is part of an experimental wire-protocol surface
1944 /// and may change or be removed in future SDK or CLI releases. Pin both the
1945 /// SDK and CLI versions if your code depends on it.
1946 ///
1947 /// </div>
1948 pub(crate) async fn delete(&self, params: SessionsDeleteRequest) -> Result<(), Error> {
1949 let wire_params = serde_json::to_value(params)?;
1950 let _value = self
1951 .client
1952 .call(rpc_methods::SESSIONS_DELETE, Some(wire_params))
1953 .await?;
1954 Ok(())
1955 }
1956
1957 /// Deletes sessions older than the given threshold, with optional dry-run and exclusion list.
1958 ///
1959 /// Wire method: `sessions.pruneOld`.
1960 ///
1961 /// # Parameters
1962 ///
1963 /// * `params` - Age threshold and optional flags controlling which old sessions are pruned (or simulated when dryRun is true).
1964 ///
1965 /// # Returns
1966 ///
1967 /// Outcome of the prune operation: deleted IDs, dry-run candidates, skipped IDs, total bytes freed, and the dry-run flag.
1968 ///
1969 /// <div class="warning">
1970 ///
1971 /// **Experimental.** This API is part of an experimental wire-protocol surface
1972 /// and may change or be removed in future SDK or CLI releases. Pin both the
1973 /// SDK and CLI versions if your code depends on it.
1974 ///
1975 /// </div>
1976 pub async fn prune_old(
1977 &self,
1978 params: SessionsPruneOldRequest,
1979 ) -> Result<SessionPruneResult, Error> {
1980 let wire_params = serde_json::to_value(params)?;
1981 let _value = self
1982 .client
1983 .call(rpc_methods::SESSIONS_PRUNEOLD, Some(wire_params))
1984 .await?;
1985 Ok(serde_json::from_value(_value)?)
1986 }
1987
1988 /// Flushes a session's pending events to disk.
1989 ///
1990 /// Wire method: `sessions.save`.
1991 ///
1992 /// # Parameters
1993 ///
1994 /// * `params` - Session ID whose pending events should be flushed to disk.
1995 ///
1996 /// # Returns
1997 ///
1998 /// Flush a session's pending events to disk. No-op when no writer exists for the session (e.g., already closed).
1999 ///
2000 /// <div class="warning">
2001 ///
2002 /// **Experimental.** This API is part of an experimental wire-protocol surface
2003 /// and may change or be removed in future SDK or CLI releases. Pin both the
2004 /// SDK and CLI versions if your code depends on it.
2005 ///
2006 /// </div>
2007 pub async fn save(&self, params: SessionsSaveRequest) -> Result<SessionsSaveResult, Error> {
2008 let wire_params = serde_json::to_value(params)?;
2009 let _value = self
2010 .client
2011 .call(rpc_methods::SESSIONS_SAVE, Some(wire_params))
2012 .await?;
2013 Ok(serde_json::from_value(_value)?)
2014 }
2015
2016 /// Releases the in-use lock held by this process for a session.
2017 ///
2018 /// Wire method: `sessions.releaseLock`.
2019 ///
2020 /// # Parameters
2021 ///
2022 /// * `params` - Session ID whose in-use lock should be released.
2023 ///
2024 /// # Returns
2025 ///
2026 /// 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.
2027 ///
2028 /// <div class="warning">
2029 ///
2030 /// **Experimental.** This API is part of an experimental wire-protocol surface
2031 /// and may change or be removed in future SDK or CLI releases. Pin both the
2032 /// SDK and CLI versions if your code depends on it.
2033 ///
2034 /// </div>
2035 pub async fn release_lock(
2036 &self,
2037 params: SessionsReleaseLockRequest,
2038 ) -> Result<SessionsReleaseLockResult, Error> {
2039 let wire_params = serde_json::to_value(params)?;
2040 let _value = self
2041 .client
2042 .call(rpc_methods::SESSIONS_RELEASELOCK, Some(wire_params))
2043 .await?;
2044 Ok(serde_json::from_value(_value)?)
2045 }
2046
2047 /// Backfills missing summary and context fields on the supplied session metadata records.
2048 ///
2049 /// Wire method: `sessions.enrichMetadata`.
2050 ///
2051 /// # Parameters
2052 ///
2053 /// * `params` - Session metadata records to enrich with summary and context information.
2054 ///
2055 /// # Returns
2056 ///
2057 /// The enriched metadata records, with summary and context fields backfilled where available. Sessions confirmed empty and unnamed are omitted.
2058 ///
2059 /// <div class="warning">
2060 ///
2061 /// **Experimental.** This API is part of an experimental wire-protocol surface
2062 /// and may change or be removed in future SDK or CLI releases. Pin both the
2063 /// SDK and CLI versions if your code depends on it.
2064 ///
2065 /// </div>
2066 pub async fn enrich_metadata(
2067 &self,
2068 params: SessionsEnrichMetadataRequest,
2069 ) -> Result<SessionEnrichMetadataResult, Error> {
2070 let wire_params = serde_json::to_value(params)?;
2071 let _value = self
2072 .client
2073 .call(rpc_methods::SESSIONS_ENRICHMETADATA, Some(wire_params))
2074 .await?;
2075 Ok(serde_json::from_value(_value)?)
2076 }
2077
2078 /// Reloads user, plugin, and (optionally) repo hooks on the active session.
2079 ///
2080 /// Wire method: `sessions.reloadPluginHooks`.
2081 ///
2082 /// # Parameters
2083 ///
2084 /// * `params` - Active session ID and an optional flag for deferring repo-level hooks until folder trust.
2085 ///
2086 /// # Returns
2087 ///
2088 /// 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.
2089 ///
2090 /// <div class="warning">
2091 ///
2092 /// **Experimental.** This API is part of an experimental wire-protocol surface
2093 /// and may change or be removed in future SDK or CLI releases. Pin both the
2094 /// SDK and CLI versions if your code depends on it.
2095 ///
2096 /// </div>
2097 pub async fn reload_plugin_hooks(
2098 &self,
2099 params: SessionsReloadPluginHooksRequest,
2100 ) -> Result<SessionsReloadPluginHooksResult, Error> {
2101 let wire_params = serde_json::to_value(params)?;
2102 let _value = self
2103 .client
2104 .call(rpc_methods::SESSIONS_RELOADPLUGINHOOKS, Some(wire_params))
2105 .await?;
2106 Ok(serde_json::from_value(_value)?)
2107 }
2108
2109 /// Loads previously-deferred repo-level hooks on the active session, returning queued startup prompts.
2110 ///
2111 /// Wire method: `sessions.loadDeferredRepoHooks`.
2112 ///
2113 /// # Parameters
2114 ///
2115 /// * `params` - Active session ID whose deferred repo-level hooks should be loaded.
2116 ///
2117 /// # Returns
2118 ///
2119 /// Queued repo-level startup prompts and the total hook command count after loading.
2120 ///
2121 /// <div class="warning">
2122 ///
2123 /// **Experimental.** This API is part of an experimental wire-protocol surface
2124 /// and may change or be removed in future SDK or CLI releases. Pin both the
2125 /// SDK and CLI versions if your code depends on it.
2126 ///
2127 /// </div>
2128 pub async fn load_deferred_repo_hooks(
2129 &self,
2130 params: SessionsLoadDeferredRepoHooksRequest,
2131 ) -> Result<SessionLoadDeferredRepoHooksResult, Error> {
2132 let wire_params = serde_json::to_value(params)?;
2133 let _value = self
2134 .client
2135 .call(
2136 rpc_methods::SESSIONS_LOADDEFERREDREPOHOOKS,
2137 Some(wire_params),
2138 )
2139 .await?;
2140 Ok(serde_json::from_value(_value)?)
2141 }
2142
2143 /// Replaces the manager-wide additional plugins registered with the session manager.
2144 ///
2145 /// Wire method: `sessions.setAdditionalPlugins`.
2146 ///
2147 /// # Parameters
2148 ///
2149 /// * `params` - Manager-wide additional plugins to register; replaces any previously-configured set.
2150 ///
2151 /// # Returns
2152 ///
2153 /// 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.
2154 ///
2155 /// <div class="warning">
2156 ///
2157 /// **Experimental.** This API is part of an experimental wire-protocol surface
2158 /// and may change or be removed in future SDK or CLI releases. Pin both the
2159 /// SDK and CLI versions if your code depends on it.
2160 ///
2161 /// </div>
2162 pub async fn set_additional_plugins(
2163 &self,
2164 params: SessionsSetAdditionalPluginsRequest,
2165 ) -> Result<SessionsSetAdditionalPluginsResult, Error> {
2166 let wire_params = serde_json::to_value(params)?;
2167 let _value = self
2168 .client
2169 .call(
2170 rpc_methods::SESSIONS_SETADDITIONALPLUGINS,
2171 Some(wire_params),
2172 )
2173 .await?;
2174 Ok(serde_json::from_value(_value)?)
2175 }
2176
2177 /// 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.
2178 ///
2179 /// Wire method: `sessions.getBoardEntryCount`.
2180 ///
2181 /// # Parameters
2182 ///
2183 /// * `params` - Session ID whose board entry count should be returned.
2184 ///
2185 /// # Returns
2186 ///
2187 /// Dynamic-context board entry count, when available.
2188 ///
2189 /// <div class="warning">
2190 ///
2191 /// **Experimental.** This API is part of an experimental wire-protocol surface
2192 /// and may change or be removed in future SDK or CLI releases. Pin both the
2193 /// SDK and CLI versions if your code depends on it.
2194 ///
2195 /// </div>
2196 pub(crate) async fn get_board_entry_count(
2197 &self,
2198 params: SessionsGetBoardEntryCountRequest,
2199 ) -> Result<SessionsGetBoardEntryCountResult, Error> {
2200 let wire_params = serde_json::to_value(params)?;
2201 let _value = self
2202 .client
2203 .call(rpc_methods::SESSIONS_GETBOARDENTRYCOUNT, Some(wire_params))
2204 .await?;
2205 Ok(serde_json::from_value(_value)?)
2206 }
2207
2208 /// 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.
2209 ///
2210 /// Wire method: `sessions.startRemoteControl`.
2211 ///
2212 /// # Parameters
2213 ///
2214 /// * `params` - Parameters for attaching the remote-control singleton to a session.
2215 ///
2216 /// # Returns
2217 ///
2218 /// Wrapper for the singleton's current status.
2219 ///
2220 /// <div class="warning">
2221 ///
2222 /// **Experimental.** This API is part of an experimental wire-protocol surface
2223 /// and may change or be removed in future SDK or CLI releases. Pin both the
2224 /// SDK and CLI versions if your code depends on it.
2225 ///
2226 /// </div>
2227 pub async fn start_remote_control(
2228 &self,
2229 params: SessionsStartRemoteControlRequest,
2230 ) -> Result<RemoteControlStatusResult, Error> {
2231 let wire_params = serde_json::to_value(params)?;
2232 let _value = self
2233 .client
2234 .call(rpc_methods::SESSIONS_STARTREMOTECONTROL, Some(wire_params))
2235 .await?;
2236 Ok(serde_json::from_value(_value)?)
2237 }
2238
2239 /// 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.
2240 ///
2241 /// Wire method: `sessions.transferRemoteControl`.
2242 ///
2243 /// # Parameters
2244 ///
2245 /// * `params` - Parameters for atomically rebinding the remote-control singleton.
2246 ///
2247 /// # Returns
2248 ///
2249 /// Outcome of a transferRemoteControl call.
2250 ///
2251 /// <div class="warning">
2252 ///
2253 /// **Experimental.** This API is part of an experimental wire-protocol surface
2254 /// and may change or be removed in future SDK or CLI releases. Pin both the
2255 /// SDK and CLI versions if your code depends on it.
2256 ///
2257 /// </div>
2258 pub async fn transfer_remote_control(
2259 &self,
2260 params: SessionsTransferRemoteControlRequest,
2261 ) -> Result<RemoteControlTransferResult, Error> {
2262 let wire_params = serde_json::to_value(params)?;
2263 let _value = self
2264 .client
2265 .call(
2266 rpc_methods::SESSIONS_TRANSFERREMOTECONTROL,
2267 Some(wire_params),
2268 )
2269 .await?;
2270 Ok(serde_json::from_value(_value)?)
2271 }
2272
2273 /// 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.
2274 ///
2275 /// Wire method: `sessions.setRemoteControlSteering`.
2276 ///
2277 /// # Parameters
2278 ///
2279 /// * `params` - Patch for the singleton's steering state.
2280 ///
2281 /// # Returns
2282 ///
2283 /// Wrapper for the singleton's current status.
2284 ///
2285 /// <div class="warning">
2286 ///
2287 /// **Experimental.** This API is part of an experimental wire-protocol surface
2288 /// and may change or be removed in future SDK or CLI releases. Pin both the
2289 /// SDK and CLI versions if your code depends on it.
2290 ///
2291 /// </div>
2292 pub async fn set_remote_control_steering(
2293 &self,
2294 params: SessionsSetRemoteControlSteeringRequest,
2295 ) -> Result<RemoteControlStatusResult, Error> {
2296 let wire_params = serde_json::to_value(params)?;
2297 let _value = self
2298 .client
2299 .call(
2300 rpc_methods::SESSIONS_SETREMOTECONTROLSTEERING,
2301 Some(wire_params),
2302 )
2303 .await?;
2304 Ok(serde_json::from_value(_value)?)
2305 }
2306
2307 /// 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).
2308 ///
2309 /// Wire method: `sessions.stopRemoteControl`.
2310 ///
2311 /// # Returns
2312 ///
2313 /// Outcome of a stopRemoteControl call.
2314 ///
2315 /// <div class="warning">
2316 ///
2317 /// **Experimental.** This API is part of an experimental wire-protocol surface
2318 /// and may change or be removed in future SDK or CLI releases. Pin both the
2319 /// SDK and CLI versions if your code depends on it.
2320 ///
2321 /// </div>
2322 pub async fn stop_remote_control(&self) -> Result<RemoteControlStopResult, Error> {
2323 let wire_params = serde_json::json!({});
2324 let _value = self
2325 .client
2326 .call(rpc_methods::SESSIONS_STOPREMOTECONTROL, Some(wire_params))
2327 .await?;
2328 Ok(serde_json::from_value(_value)?)
2329 }
2330
2331 /// 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).
2332 ///
2333 /// Wire method: `sessions.stopRemoteControl`.
2334 ///
2335 /// # Parameters
2336 ///
2337 /// * `params` - Parameters for stopping the remote-control singleton.
2338 ///
2339 /// # Returns
2340 ///
2341 /// Outcome of a stopRemoteControl call.
2342 ///
2343 /// <div class="warning">
2344 ///
2345 /// **Experimental.** This API is part of an experimental wire-protocol surface
2346 /// and may change or be removed in future SDK or CLI releases. Pin both the
2347 /// SDK and CLI versions if your code depends on it.
2348 ///
2349 /// </div>
2350 pub async fn stop_remote_control_with_params(
2351 &self,
2352 params: SessionsStopRemoteControlRequest,
2353 ) -> Result<RemoteControlStopResult, Error> {
2354 let wire_params = serde_json::to_value(params)?;
2355 let _value = self
2356 .client
2357 .call(rpc_methods::SESSIONS_STOPREMOTECONTROL, Some(wire_params))
2358 .await?;
2359 Ok(serde_json::from_value(_value)?)
2360 }
2361
2362 /// Returns the current state of the remote-control singleton, including the attached session id and frontend URL when active.
2363 ///
2364 /// Wire method: `sessions.getRemoteControlStatus`.
2365 ///
2366 /// # Returns
2367 ///
2368 /// Wrapper for the singleton's current status.
2369 ///
2370 /// <div class="warning">
2371 ///
2372 /// **Experimental.** This API is part of an experimental wire-protocol surface
2373 /// and may change or be removed in future SDK or CLI releases. Pin both the
2374 /// SDK and CLI versions if your code depends on it.
2375 ///
2376 /// </div>
2377 pub async fn get_remote_control_status(&self) -> Result<RemoteControlStatusResult, Error> {
2378 let wire_params = serde_json::json!({});
2379 let _value = self
2380 .client
2381 .call(
2382 rpc_methods::SESSIONS_GETREMOTECONTROLSTATUS,
2383 Some(wire_params),
2384 )
2385 .await?;
2386 Ok(serde_json::from_value(_value)?)
2387 }
2388
2389 /// 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.
2390 ///
2391 /// Wire method: `sessions.registerExtensionToolsOnSession`.
2392 ///
2393 /// # Parameters
2394 ///
2395 /// * `params` - Params to attach an extension loader's tools to a session.
2396 ///
2397 /// # Returns
2398 ///
2399 /// Handle for releasing the extension tool registration.
2400 ///
2401 /// <div class="warning">
2402 ///
2403 /// **Experimental.** This API is part of an experimental wire-protocol surface
2404 /// and may change or be removed in future SDK or CLI releases. Pin both the
2405 /// SDK and CLI versions if your code depends on it.
2406 ///
2407 /// </div>
2408 pub(crate) async fn register_extension_tools_on_session(
2409 &self,
2410 params: RegisterExtensionToolsParams,
2411 ) -> Result<RegisterExtensionToolsResult, Error> {
2412 let wire_params = serde_json::to_value(params)?;
2413 let _value = self
2414 .client
2415 .call(
2416 rpc_methods::SESSIONS_REGISTEREXTENSIONTOOLSONSESSION,
2417 Some(wire_params),
2418 )
2419 .await?;
2420 Ok(serde_json::from_value(_value)?)
2421 }
2422
2423 /// 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.
2424 ///
2425 /// Wire method: `sessions.configureSessionExtensions`.
2426 ///
2427 /// # Parameters
2428 ///
2429 /// * `params` - Params to attach or detach an in-process ExtensionController delegate.
2430 ///
2431 /// <div class="warning">
2432 ///
2433 /// **Experimental.** This API is part of an experimental wire-protocol surface
2434 /// and may change or be removed in future SDK or CLI releases. Pin both the
2435 /// SDK and CLI versions if your code depends on it.
2436 ///
2437 /// </div>
2438 pub(crate) async fn configure_session_extensions(
2439 &self,
2440 params: ConfigureSessionExtensionsParams,
2441 ) -> Result<(), Error> {
2442 let wire_params = serde_json::to_value(params)?;
2443 let _value = self
2444 .client
2445 .call(
2446 rpc_methods::SESSIONS_CONFIGURESESSIONEXTENSIONS,
2447 Some(wire_params),
2448 )
2449 .await?;
2450 Ok(())
2451 }
2452}
2453
2454/// `skills.*` RPCs.
2455#[derive(Clone, Copy)]
2456pub struct ClientRpcSkills<'a> {
2457 pub(crate) client: &'a Client,
2458}
2459
2460impl<'a> ClientRpcSkills<'a> {
2461 /// `skills.config.*` sub-namespace.
2462 pub fn config(&self) -> ClientRpcSkillsConfig<'a> {
2463 ClientRpcSkillsConfig {
2464 client: self.client,
2465 }
2466 }
2467
2468 /// Discovers skills across global and project sources.
2469 ///
2470 /// Wire method: `skills.discover`.
2471 ///
2472 /// # Parameters
2473 ///
2474 /// * `params` - Optional project paths and additional skill directories to include in discovery.
2475 ///
2476 /// # Returns
2477 ///
2478 /// Skills discovered across global and project sources.
2479 ///
2480 /// <div class="warning">
2481 ///
2482 /// **Experimental.** This API is part of an experimental wire-protocol surface
2483 /// and may change or be removed in future SDK or CLI releases. Pin both the
2484 /// SDK and CLI versions if your code depends on it.
2485 ///
2486 /// </div>
2487 pub async fn discover(&self, params: SkillsDiscoverRequest) -> Result<ServerSkillList, Error> {
2488 let wire_params = serde_json::to_value(params)?;
2489 let _value = self
2490 .client
2491 .call(rpc_methods::SKILLS_DISCOVER, Some(wire_params))
2492 .await?;
2493 Ok(serde_json::from_value(_value)?)
2494 }
2495
2496 /// 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.
2497 ///
2498 /// Wire method: `skills.getDiscoveryPaths`.
2499 ///
2500 /// # Parameters
2501 ///
2502 /// * `params` - Optional project paths to enumerate.
2503 ///
2504 /// # Returns
2505 ///
2506 /// Canonical locations where skills can be created so the runtime will recognize them.
2507 ///
2508 /// <div class="warning">
2509 ///
2510 /// **Experimental.** This API is part of an experimental wire-protocol surface
2511 /// and may change or be removed in future SDK or CLI releases. Pin both the
2512 /// SDK and CLI versions if your code depends on it.
2513 ///
2514 /// </div>
2515 pub async fn get_discovery_paths(
2516 &self,
2517 params: SkillsGetDiscoveryPathsRequest,
2518 ) -> Result<SkillDiscoveryPathList, Error> {
2519 let wire_params = serde_json::to_value(params)?;
2520 let _value = self
2521 .client
2522 .call(rpc_methods::SKILLS_GETDISCOVERYPATHS, Some(wire_params))
2523 .await?;
2524 Ok(serde_json::from_value(_value)?)
2525 }
2526}
2527
2528/// `skills.config.*` RPCs.
2529#[derive(Clone, Copy)]
2530pub struct ClientRpcSkillsConfig<'a> {
2531 pub(crate) client: &'a Client,
2532}
2533
2534impl<'a> ClientRpcSkillsConfig<'a> {
2535 /// Replaces the global list of disabled skills.
2536 ///
2537 /// Wire method: `skills.config.setDisabledSkills`.
2538 ///
2539 /// # Parameters
2540 ///
2541 /// * `params` - Skill names to mark as disabled in global configuration, replacing any previous list.
2542 ///
2543 /// <div class="warning">
2544 ///
2545 /// **Experimental.** This API is part of an experimental wire-protocol surface
2546 /// and may change or be removed in future SDK or CLI releases. Pin both the
2547 /// SDK and CLI versions if your code depends on it.
2548 ///
2549 /// </div>
2550 pub async fn set_disabled_skills(
2551 &self,
2552 params: SkillsConfigSetDisabledSkillsRequest,
2553 ) -> Result<(), Error> {
2554 let wire_params = serde_json::to_value(params)?;
2555 let _value = self
2556 .client
2557 .call(
2558 rpc_methods::SKILLS_CONFIG_SETDISABLEDSKILLS,
2559 Some(wire_params),
2560 )
2561 .await?;
2562 Ok(())
2563 }
2564}
2565
2566/// `tools.*` RPCs.
2567#[derive(Clone, Copy)]
2568pub struct ClientRpcTools<'a> {
2569 pub(crate) client: &'a Client,
2570}
2571
2572impl<'a> ClientRpcTools<'a> {
2573 /// Lists built-in tools available for a model.
2574 ///
2575 /// Wire method: `tools.list`.
2576 ///
2577 /// # Parameters
2578 ///
2579 /// * `params` - Optional model identifier whose tool overrides should be applied to the listing.
2580 ///
2581 /// # Returns
2582 ///
2583 /// Built-in tools available for the requested model, with their parameters and instructions.
2584 ///
2585 /// <div class="warning">
2586 ///
2587 /// **Experimental.** This API is part of an experimental wire-protocol surface
2588 /// and may change or be removed in future SDK or CLI releases. Pin both the
2589 /// SDK and CLI versions if your code depends on it.
2590 ///
2591 /// </div>
2592 pub async fn list(&self, params: ToolsListRequest) -> Result<ToolList, Error> {
2593 let wire_params = serde_json::to_value(params)?;
2594 let _value = self
2595 .client
2596 .call(rpc_methods::TOOLS_LIST, Some(wire_params))
2597 .await?;
2598 Ok(serde_json::from_value(_value)?)
2599 }
2600}
2601
2602/// `user.*` RPCs.
2603#[derive(Clone, Copy)]
2604pub struct ClientRpcUser<'a> {
2605 pub(crate) client: &'a Client,
2606}
2607
2608impl<'a> ClientRpcUser<'a> {
2609 /// `user.settings.*` sub-namespace.
2610 pub fn settings(&self) -> ClientRpcUserSettings<'a> {
2611 ClientRpcUserSettings {
2612 client: self.client,
2613 }
2614 }
2615}
2616
2617/// `user.settings.*` RPCs.
2618#[derive(Clone, Copy)]
2619pub struct ClientRpcUserSettings<'a> {
2620 pub(crate) client: &'a Client,
2621}
2622
2623impl<'a> ClientRpcUserSettings<'a> {
2624 /// Drops this runtime process's in-memory user settings cache so the next settings read observes disk.
2625 ///
2626 /// Wire method: `user.settings.reload`.
2627 ///
2628 /// <div class="warning">
2629 ///
2630 /// **Experimental.** This API is part of an experimental wire-protocol surface
2631 /// and may change or be removed in future SDK or CLI releases. Pin both the
2632 /// SDK and CLI versions if your code depends on it.
2633 ///
2634 /// </div>
2635 pub async fn reload(&self) -> Result<(), Error> {
2636 let wire_params = serde_json::json!({});
2637 let _value = self
2638 .client
2639 .call(rpc_methods::USER_SETTINGS_RELOAD, Some(wire_params))
2640 .await?;
2641 Ok(())
2642 }
2643
2644 /// 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.
2645 ///
2646 /// Wire method: `user.settings.get`.
2647 ///
2648 /// # Returns
2649 ///
2650 /// 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.
2651 ///
2652 /// <div class="warning">
2653 ///
2654 /// **Experimental.** This API is part of an experimental wire-protocol surface
2655 /// and may change or be removed in future SDK or CLI releases. Pin both the
2656 /// SDK and CLI versions if your code depends on it.
2657 ///
2658 /// </div>
2659 pub async fn get(&self) -> Result<UserSettingsGetResult, Error> {
2660 let wire_params = serde_json::json!({});
2661 let _value = self
2662 .client
2663 .call(rpc_methods::USER_SETTINGS_GET, Some(wire_params))
2664 .await?;
2665 Ok(serde_json::from_value(_value)?)
2666 }
2667
2668 /// 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.
2669 ///
2670 /// Wire method: `user.settings.set`.
2671 ///
2672 /// # Parameters
2673 ///
2674 /// * `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.
2675 ///
2676 /// # Returns
2677 ///
2678 /// Outcome of writing user settings.
2679 ///
2680 /// <div class="warning">
2681 ///
2682 /// **Experimental.** This API is part of an experimental wire-protocol surface
2683 /// and may change or be removed in future SDK or CLI releases. Pin both the
2684 /// SDK and CLI versions if your code depends on it.
2685 ///
2686 /// </div>
2687 pub async fn set(
2688 &self,
2689 params: UserSettingsSetRequest,
2690 ) -> Result<UserSettingsSetResult, Error> {
2691 let wire_params = serde_json::to_value(params)?;
2692 let _value = self
2693 .client
2694 .call(rpc_methods::USER_SETTINGS_SET, Some(wire_params))
2695 .await?;
2696 Ok(serde_json::from_value(_value)?)
2697 }
2698}
2699
2700/// Typed view over a [`Session`]'s RPC namespace.
2701#[derive(Clone, Copy)]
2702pub struct SessionRpc<'a> {
2703 pub(crate) session: &'a Session,
2704}
2705
2706impl<'a> SessionRpc<'a> {
2707 /// `session.agent.*` sub-namespace.
2708 pub fn agent(&self) -> SessionRpcAgent<'a> {
2709 SessionRpcAgent {
2710 session: self.session,
2711 }
2712 }
2713
2714 /// `session.canvas.*` sub-namespace.
2715 pub fn canvas(&self) -> SessionRpcCanvas<'a> {
2716 SessionRpcCanvas {
2717 session: self.session,
2718 }
2719 }
2720
2721 /// `session.commands.*` sub-namespace.
2722 pub fn commands(&self) -> SessionRpcCommands<'a> {
2723 SessionRpcCommands {
2724 session: self.session,
2725 }
2726 }
2727
2728 /// `session.completions.*` sub-namespace.
2729 pub fn completions(&self) -> SessionRpcCompletions<'a> {
2730 SessionRpcCompletions {
2731 session: self.session,
2732 }
2733 }
2734
2735 /// `session.contentExclusion.*` sub-namespace.
2736 pub fn content_exclusion(&self) -> SessionRpcContentExclusion<'a> {
2737 SessionRpcContentExclusion {
2738 session: self.session,
2739 }
2740 }
2741
2742 /// `session.debug.*` sub-namespace.
2743 pub fn debug(&self) -> SessionRpcDebug<'a> {
2744 SessionRpcDebug {
2745 session: self.session,
2746 }
2747 }
2748
2749 /// `session.eventLog.*` sub-namespace.
2750 pub fn event_log(&self) -> SessionRpcEventLog<'a> {
2751 SessionRpcEventLog {
2752 session: self.session,
2753 }
2754 }
2755
2756 /// `session.extensions.*` sub-namespace.
2757 pub fn extensions(&self) -> SessionRpcExtensions<'a> {
2758 SessionRpcExtensions {
2759 session: self.session,
2760 }
2761 }
2762
2763 /// `session.factory.*` sub-namespace.
2764 pub fn factory(&self) -> SessionRpcFactory<'a> {
2765 SessionRpcFactory {
2766 session: self.session,
2767 }
2768 }
2769
2770 /// `session.fleet.*` sub-namespace.
2771 pub fn fleet(&self) -> SessionRpcFleet<'a> {
2772 SessionRpcFleet {
2773 session: self.session,
2774 }
2775 }
2776
2777 /// `session.gitHubAuth.*` sub-namespace.
2778 pub fn git_hub_auth(&self) -> SessionRpcGitHubAuth<'a> {
2779 SessionRpcGitHubAuth {
2780 session: self.session,
2781 }
2782 }
2783
2784 /// `session.history.*` sub-namespace.
2785 pub fn history(&self) -> SessionRpcHistory<'a> {
2786 SessionRpcHistory {
2787 session: self.session,
2788 }
2789 }
2790
2791 /// `session.instructions.*` sub-namespace.
2792 pub fn instructions(&self) -> SessionRpcInstructions<'a> {
2793 SessionRpcInstructions {
2794 session: self.session,
2795 }
2796 }
2797
2798 /// `session.limitPrediction.*` sub-namespace.
2799 pub fn limit_prediction(&self) -> SessionRpcLimitPrediction<'a> {
2800 SessionRpcLimitPrediction {
2801 session: self.session,
2802 }
2803 }
2804
2805 /// `session.lsp.*` sub-namespace.
2806 pub fn lsp(&self) -> SessionRpcLsp<'a> {
2807 SessionRpcLsp {
2808 session: self.session,
2809 }
2810 }
2811
2812 /// `session.mcp.*` sub-namespace.
2813 pub fn mcp(&self) -> SessionRpcMcp<'a> {
2814 SessionRpcMcp {
2815 session: self.session,
2816 }
2817 }
2818
2819 /// `session.metadata.*` sub-namespace.
2820 pub fn metadata(&self) -> SessionRpcMetadata<'a> {
2821 SessionRpcMetadata {
2822 session: self.session,
2823 }
2824 }
2825
2826 /// `session.mode.*` sub-namespace.
2827 pub fn mode(&self) -> SessionRpcMode<'a> {
2828 SessionRpcMode {
2829 session: self.session,
2830 }
2831 }
2832
2833 /// `session.model.*` sub-namespace.
2834 pub fn model(&self) -> SessionRpcModel<'a> {
2835 SessionRpcModel {
2836 session: self.session,
2837 }
2838 }
2839
2840 /// `session.name.*` sub-namespace.
2841 pub fn name(&self) -> SessionRpcName<'a> {
2842 SessionRpcName {
2843 session: self.session,
2844 }
2845 }
2846
2847 /// `session.options.*` sub-namespace.
2848 pub fn options(&self) -> SessionRpcOptions<'a> {
2849 SessionRpcOptions {
2850 session: self.session,
2851 }
2852 }
2853
2854 /// `session.permissions.*` sub-namespace.
2855 pub fn permissions(&self) -> SessionRpcPermissions<'a> {
2856 SessionRpcPermissions {
2857 session: self.session,
2858 }
2859 }
2860
2861 /// `session.plan.*` sub-namespace.
2862 pub fn plan(&self) -> SessionRpcPlan<'a> {
2863 SessionRpcPlan {
2864 session: self.session,
2865 }
2866 }
2867
2868 /// `session.plugins.*` sub-namespace.
2869 pub fn plugins(&self) -> SessionRpcPlugins<'a> {
2870 SessionRpcPlugins {
2871 session: self.session,
2872 }
2873 }
2874
2875 /// `session.provider.*` sub-namespace.
2876 pub fn provider(&self) -> SessionRpcProvider<'a> {
2877 SessionRpcProvider {
2878 session: self.session,
2879 }
2880 }
2881
2882 /// `session.queue.*` sub-namespace.
2883 pub fn queue(&self) -> SessionRpcQueue<'a> {
2884 SessionRpcQueue {
2885 session: self.session,
2886 }
2887 }
2888
2889 /// `session.remote.*` sub-namespace.
2890 pub fn remote(&self) -> SessionRpcRemote<'a> {
2891 SessionRpcRemote {
2892 session: self.session,
2893 }
2894 }
2895
2896 /// `session.schedule.*` sub-namespace.
2897 pub fn schedule(&self) -> SessionRpcSchedule<'a> {
2898 SessionRpcSchedule {
2899 session: self.session,
2900 }
2901 }
2902
2903 /// `session.settings.*` sub-namespace.
2904 pub fn settings(&self) -> SessionRpcSettings<'a> {
2905 SessionRpcSettings {
2906 session: self.session,
2907 }
2908 }
2909
2910 /// `session.shell.*` sub-namespace.
2911 pub fn shell(&self) -> SessionRpcShell<'a> {
2912 SessionRpcShell {
2913 session: self.session,
2914 }
2915 }
2916
2917 /// `session.skills.*` sub-namespace.
2918 pub fn skills(&self) -> SessionRpcSkills<'a> {
2919 SessionRpcSkills {
2920 session: self.session,
2921 }
2922 }
2923
2924 /// `session.tasks.*` sub-namespace.
2925 pub fn tasks(&self) -> SessionRpcTasks<'a> {
2926 SessionRpcTasks {
2927 session: self.session,
2928 }
2929 }
2930
2931 /// `session.telemetry.*` sub-namespace.
2932 pub fn telemetry(&self) -> SessionRpcTelemetry<'a> {
2933 SessionRpcTelemetry {
2934 session: self.session,
2935 }
2936 }
2937
2938 /// `session.tools.*` sub-namespace.
2939 pub fn tools(&self) -> SessionRpcTools<'a> {
2940 SessionRpcTools {
2941 session: self.session,
2942 }
2943 }
2944
2945 /// `session.ui.*` sub-namespace.
2946 pub fn ui(&self) -> SessionRpcUi<'a> {
2947 SessionRpcUi {
2948 session: self.session,
2949 }
2950 }
2951
2952 /// `session.usage.*` sub-namespace.
2953 pub fn usage(&self) -> SessionRpcUsage<'a> {
2954 SessionRpcUsage {
2955 session: self.session,
2956 }
2957 }
2958
2959 /// `session.visibility.*` sub-namespace.
2960 pub fn visibility(&self) -> SessionRpcVisibility<'a> {
2961 SessionRpcVisibility {
2962 session: self.session,
2963 }
2964 }
2965
2966 /// `session.workspaces.*` sub-namespace.
2967 pub fn workspaces(&self) -> SessionRpcWorkspaces<'a> {
2968 SessionRpcWorkspaces {
2969 session: self.session,
2970 }
2971 }
2972
2973 /// Suspends the session while preserving persisted state for later resume.
2974 ///
2975 /// Wire method: `session.suspend`.
2976 ///
2977 /// <div class="warning">
2978 ///
2979 /// **Experimental.** This API is part of an experimental wire-protocol surface
2980 /// and may change or be removed in future SDK or CLI releases. Pin both the
2981 /// SDK and CLI versions if your code depends on it.
2982 ///
2983 /// </div>
2984 pub async fn suspend(&self) -> Result<(), Error> {
2985 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
2986 let _value = self
2987 .session
2988 .client()
2989 .call(rpc_methods::SESSION_SUSPEND, Some(wire_params))
2990 .await?;
2991 Ok(())
2992 }
2993
2994 /// Sends a user message to the session and returns its message ID.
2995 ///
2996 /// Wire method: `session.send`.
2997 ///
2998 /// # Parameters
2999 ///
3000 /// * `params` - Parameters for sending a user message to the session
3001 ///
3002 /// # Returns
3003 ///
3004 /// Result of sending a user message
3005 ///
3006 /// <div class="warning">
3007 ///
3008 /// **Experimental.** This API is part of an experimental wire-protocol surface
3009 /// and may change or be removed in future SDK or CLI releases. Pin both the
3010 /// SDK and CLI versions if your code depends on it.
3011 ///
3012 /// </div>
3013 pub async fn send(&self, params: SendRequest) -> Result<SendResult, Error> {
3014 let mut wire_params = serde_json::to_value(params)?;
3015 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3016 let _value = self
3017 .session
3018 .client()
3019 .call(rpc_methods::SESSION_SEND, Some(wire_params))
3020 .await?;
3021 Ok(serde_json::from_value(_value)?)
3022 }
3023
3024 /// 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.
3025 ///
3026 /// Wire method: `session.sendMessages`.
3027 ///
3028 /// # Parameters
3029 ///
3030 /// * `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.
3031 ///
3032 /// # Returns
3033 ///
3034 /// Result of sending zero or more user messages
3035 ///
3036 /// <div class="warning">
3037 ///
3038 /// **Experimental.** This API is part of an experimental wire-protocol surface
3039 /// and may change or be removed in future SDK or CLI releases. Pin both the
3040 /// SDK and CLI versions if your code depends on it.
3041 ///
3042 /// </div>
3043 pub async fn send_messages(
3044 &self,
3045 params: SendMessagesRequest,
3046 ) -> Result<SendMessagesResult, Error> {
3047 let mut wire_params = serde_json::to_value(params)?;
3048 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3049 let _value = self
3050 .session
3051 .client()
3052 .call(rpc_methods::SESSION_SENDMESSAGES, Some(wire_params))
3053 .await?;
3054 Ok(serde_json::from_value(_value)?)
3055 }
3056
3057 /// Queues or sends an internal system notification to the session according to its passive policy.
3058 ///
3059 /// Wire method: `session.sendSystemNotification`.
3060 ///
3061 /// # Parameters
3062 ///
3063 /// * `params` - Internal request for sending a system notification.
3064 ///
3065 /// <div class="warning">
3066 ///
3067 /// **Experimental.** This API is part of an experimental wire-protocol surface
3068 /// and may change or be removed in future SDK or CLI releases. Pin both the
3069 /// SDK and CLI versions if your code depends on it.
3070 ///
3071 /// </div>
3072 pub(crate) async fn send_system_notification(
3073 &self,
3074 params: SendSystemNotificationRequest,
3075 ) -> Result<(), Error> {
3076 let mut wire_params = serde_json::to_value(params)?;
3077 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3078 let _value = self
3079 .session
3080 .client()
3081 .call(
3082 rpc_methods::SESSION_SENDSYSTEMNOTIFICATION,
3083 Some(wire_params),
3084 )
3085 .await?;
3086 Ok(())
3087 }
3088
3089 /// Aborts the current agent turn.
3090 ///
3091 /// Wire method: `session.abort`.
3092 ///
3093 /// # Parameters
3094 ///
3095 /// * `params` - Parameters for aborting the current turn
3096 ///
3097 /// # Returns
3098 ///
3099 /// Result of aborting the current turn
3100 ///
3101 /// <div class="warning">
3102 ///
3103 /// **Experimental.** This API is part of an experimental wire-protocol surface
3104 /// and may change or be removed in future SDK or CLI releases. Pin both the
3105 /// SDK and CLI versions if your code depends on it.
3106 ///
3107 /// </div>
3108 pub async fn abort(&self, params: AbortRequest) -> Result<AbortResult, Error> {
3109 let mut wire_params = serde_json::to_value(params)?;
3110 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3111 let _value = self
3112 .session
3113 .client()
3114 .call(rpc_methods::SESSION_ABORT, Some(wire_params))
3115 .await?;
3116 Ok(serde_json::from_value(_value)?)
3117 }
3118
3119 /// Interrupts the current main agent turn while leaving running background work (subagents, sidekicks, and promoted attached shells) alive. No-op when the main loop is not processing.
3120 ///
3121 /// Wire method: `session.interruptMainTurn`.
3122 ///
3123 /// # Parameters
3124 ///
3125 /// * `params` - Parameters for interrupting the main agent turn.
3126 ///
3127 /// # Returns
3128 ///
3129 /// Result of interrupting the main agent turn.
3130 ///
3131 /// <div class="warning">
3132 ///
3133 /// **Experimental.** This API is part of an experimental wire-protocol surface
3134 /// and may change or be removed in future SDK or CLI releases. Pin both the
3135 /// SDK and CLI versions if your code depends on it.
3136 ///
3137 /// </div>
3138 pub async fn interrupt_main_turn(
3139 &self,
3140 params: InterruptMainTurnRequest,
3141 ) -> Result<InterruptMainTurnResult, Error> {
3142 let mut wire_params = serde_json::to_value(params)?;
3143 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3144 let _value = self
3145 .session
3146 .client()
3147 .call(rpc_methods::SESSION_INTERRUPTMAINTURN, Some(wire_params))
3148 .await?;
3149 Ok(serde_json::from_value(_value)?)
3150 }
3151
3152 /// Cancels every running background agent (task-registry subagents plus sidekick agents) without interrupting the main agent loop. Promoted attached shells are left running.
3153 ///
3154 /// Wire method: `session.cancelAllBackgroundAgents`.
3155 ///
3156 /// # Returns
3157 ///
3158 /// The number of running background agents (task-registry agents) that were cancelled.
3159 ///
3160 /// <div class="warning">
3161 ///
3162 /// **Experimental.** This API is part of an experimental wire-protocol surface
3163 /// and may change or be removed in future SDK or CLI releases. Pin both the
3164 /// SDK and CLI versions if your code depends on it.
3165 ///
3166 /// </div>
3167 pub async fn cancel_all_background_agents(
3168 &self,
3169 ) -> Result<SessionCancelAllBackgroundAgentsResult, Error> {
3170 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3171 let _value = self
3172 .session
3173 .client()
3174 .call(
3175 rpc_methods::SESSION_CANCELALLBACKGROUNDAGENTS,
3176 Some(wire_params),
3177 )
3178 .await?;
3179 Ok(serde_json::from_value(_value)?)
3180 }
3181
3182 /// 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.
3183 ///
3184 /// Wire method: `session.shutdown`.
3185 ///
3186 /// # Parameters
3187 ///
3188 /// * `params` - Parameters for shutting down the session
3189 ///
3190 /// <div class="warning">
3191 ///
3192 /// **Experimental.** This API is part of an experimental wire-protocol surface
3193 /// and may change or be removed in future SDK or CLI releases. Pin both the
3194 /// SDK and CLI versions if your code depends on it.
3195 ///
3196 /// </div>
3197 pub async fn shutdown(&self, params: ShutdownRequest) -> Result<(), Error> {
3198 let mut wire_params = serde_json::to_value(params)?;
3199 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3200 let _value = self
3201 .session
3202 .client()
3203 .call(rpc_methods::SESSION_SHUTDOWN, Some(wire_params))
3204 .await?;
3205 Ok(())
3206 }
3207
3208 /// Emits a user-visible session log event.
3209 ///
3210 /// Wire method: `session.log`.
3211 ///
3212 /// # Parameters
3213 ///
3214 /// * `params` - Message text, optional severity level, persistence flag, optional follow-up URL, and optional tip.
3215 ///
3216 /// # Returns
3217 ///
3218 /// Identifier of the session event that was emitted for the log message.
3219 ///
3220 /// <div class="warning">
3221 ///
3222 /// **Experimental.** This API is part of an experimental wire-protocol surface
3223 /// and may change or be removed in future SDK or CLI releases. Pin both the
3224 /// SDK and CLI versions if your code depends on it.
3225 ///
3226 /// </div>
3227 pub async fn log(&self, params: LogRequest) -> Result<LogResult, Error> {
3228 let mut wire_params = serde_json::to_value(params)?;
3229 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3230 let _value = self
3231 .session
3232 .client()
3233 .call(rpc_methods::SESSION_LOG, Some(wire_params))
3234 .await?;
3235 Ok(serde_json::from_value(_value)?)
3236 }
3237}
3238
3239/// `session.agent.*` RPCs.
3240#[derive(Clone, Copy)]
3241pub struct SessionRpcAgent<'a> {
3242 pub(crate) session: &'a Session,
3243}
3244
3245impl<'a> SessionRpcAgent<'a> {
3246 /// Lists agents available to the session. Defaults to custom agents only; pass includeBuiltInAgents to include the effective built-in agents.
3247 ///
3248 /// Wire method: `session.agent.list`.
3249 ///
3250 /// # Returns
3251 ///
3252 /// Agents available to the session.
3253 ///
3254 /// <div class="warning">
3255 ///
3256 /// **Experimental.** This API is part of an experimental wire-protocol surface
3257 /// and may change or be removed in future SDK or CLI releases. Pin both the
3258 /// SDK and CLI versions if your code depends on it.
3259 ///
3260 /// </div>
3261 pub async fn list(&self) -> Result<AgentList, Error> {
3262 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3263 let _value = self
3264 .session
3265 .client()
3266 .call(rpc_methods::SESSION_AGENT_LIST, Some(wire_params))
3267 .await?;
3268 Ok(serde_json::from_value(_value)?)
3269 }
3270
3271 /// Lists agents available to the session. Defaults to custom agents only; pass includeBuiltInAgents to include the effective built-in agents.
3272 ///
3273 /// Wire method: `session.agent.list`.
3274 ///
3275 /// # Parameters
3276 ///
3277 /// * `params` - Controls whether built-in agents and authored prompt text are included.
3278 ///
3279 /// # Returns
3280 ///
3281 /// Agents available to the session.
3282 ///
3283 /// <div class="warning">
3284 ///
3285 /// **Experimental.** This API is part of an experimental wire-protocol surface
3286 /// and may change or be removed in future SDK or CLI releases. Pin both the
3287 /// SDK and CLI versions if your code depends on it.
3288 ///
3289 /// </div>
3290 pub async fn list_with_params(&self, params: AgentListRequest) -> Result<AgentList, Error> {
3291 let mut wire_params = serde_json::to_value(params)?;
3292 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3293 let _value = self
3294 .session
3295 .client()
3296 .call(rpc_methods::SESSION_AGENT_LIST, Some(wire_params))
3297 .await?;
3298 Ok(serde_json::from_value(_value)?)
3299 }
3300
3301 /// Gets the currently selected custom agent for the session.
3302 ///
3303 /// Wire method: `session.agent.getCurrent`.
3304 ///
3305 /// # Returns
3306 ///
3307 /// The currently selected custom agent, or null when using the default agent.
3308 ///
3309 /// <div class="warning">
3310 ///
3311 /// **Experimental.** This API is part of an experimental wire-protocol surface
3312 /// and may change or be removed in future SDK or CLI releases. Pin both the
3313 /// SDK and CLI versions if your code depends on it.
3314 ///
3315 /// </div>
3316 pub async fn get_current(&self) -> Result<AgentGetCurrentResult, Error> {
3317 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3318 let _value = self
3319 .session
3320 .client()
3321 .call(rpc_methods::SESSION_AGENT_GETCURRENT, Some(wire_params))
3322 .await?;
3323 Ok(serde_json::from_value(_value)?)
3324 }
3325
3326 /// Selects a custom agent for subsequent turns in the session.
3327 ///
3328 /// Wire method: `session.agent.select`.
3329 ///
3330 /// # Parameters
3331 ///
3332 /// * `params` - Name of the custom agent to select for subsequent turns.
3333 ///
3334 /// # Returns
3335 ///
3336 /// The newly selected custom agent.
3337 ///
3338 /// <div class="warning">
3339 ///
3340 /// **Experimental.** This API is part of an experimental wire-protocol surface
3341 /// and may change or be removed in future SDK or CLI releases. Pin both the
3342 /// SDK and CLI versions if your code depends on it.
3343 ///
3344 /// </div>
3345 pub async fn select(&self, params: AgentSelectRequest) -> Result<AgentSelectResult, Error> {
3346 let mut wire_params = serde_json::to_value(params)?;
3347 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3348 let _value = self
3349 .session
3350 .client()
3351 .call(rpc_methods::SESSION_AGENT_SELECT, Some(wire_params))
3352 .await?;
3353 Ok(serde_json::from_value(_value)?)
3354 }
3355
3356 /// Clears the selected custom agent and returns the session to the default agent.
3357 ///
3358 /// Wire method: `session.agent.deselect`.
3359 ///
3360 /// <div class="warning">
3361 ///
3362 /// **Experimental.** This API is part of an experimental wire-protocol surface
3363 /// and may change or be removed in future SDK or CLI releases. Pin both the
3364 /// SDK and CLI versions if your code depends on it.
3365 ///
3366 /// </div>
3367 pub async fn deselect(&self) -> Result<(), Error> {
3368 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3369 let _value = self
3370 .session
3371 .client()
3372 .call(rpc_methods::SESSION_AGENT_DESELECT, Some(wire_params))
3373 .await?;
3374 Ok(())
3375 }
3376
3377 /// Reloads custom agent definitions and returns the refreshed list.
3378 ///
3379 /// Wire method: `session.agent.reload`.
3380 ///
3381 /// # Returns
3382 ///
3383 /// Custom agents available to the session after reloading definitions from disk.
3384 ///
3385 /// <div class="warning">
3386 ///
3387 /// **Experimental.** This API is part of an experimental wire-protocol surface
3388 /// and may change or be removed in future SDK or CLI releases. Pin both the
3389 /// SDK and CLI versions if your code depends on it.
3390 ///
3391 /// </div>
3392 pub async fn reload(&self) -> Result<AgentReloadResult, Error> {
3393 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3394 let _value = self
3395 .session
3396 .client()
3397 .call(rpc_methods::SESSION_AGENT_RELOAD, Some(wire_params))
3398 .await?;
3399 Ok(serde_json::from_value(_value)?)
3400 }
3401}
3402
3403/// `session.canvas.*` RPCs.
3404#[derive(Clone, Copy)]
3405pub struct SessionRpcCanvas<'a> {
3406 pub(crate) session: &'a Session,
3407}
3408
3409impl<'a> SessionRpcCanvas<'a> {
3410 /// `session.canvas.action.*` sub-namespace.
3411 pub fn action(&self) -> SessionRpcCanvasAction<'a> {
3412 SessionRpcCanvasAction {
3413 session: self.session,
3414 }
3415 }
3416
3417 /// Lists canvases declared for the session.
3418 ///
3419 /// Wire method: `session.canvas.list`.
3420 ///
3421 /// # Returns
3422 ///
3423 /// Declared canvases available in this session.
3424 ///
3425 /// <div class="warning">
3426 ///
3427 /// **Experimental.** This API is part of an experimental wire-protocol surface
3428 /// and may change or be removed in future SDK or CLI releases. Pin both the
3429 /// SDK and CLI versions if your code depends on it.
3430 ///
3431 /// </div>
3432 pub async fn list(&self) -> Result<CanvasList, Error> {
3433 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3434 let _value = self
3435 .session
3436 .client()
3437 .call(rpc_methods::SESSION_CANVAS_LIST, Some(wire_params))
3438 .await?;
3439 Ok(serde_json::from_value(_value)?)
3440 }
3441
3442 /// Lists currently open canvas instances for the live session.
3443 ///
3444 /// Wire method: `session.canvas.listOpen`.
3445 ///
3446 /// # Returns
3447 ///
3448 /// Live open-canvas snapshot.
3449 ///
3450 /// <div class="warning">
3451 ///
3452 /// **Experimental.** This API is part of an experimental wire-protocol surface
3453 /// and may change or be removed in future SDK or CLI releases. Pin both the
3454 /// SDK and CLI versions if your code depends on it.
3455 ///
3456 /// </div>
3457 pub async fn list_open(&self) -> Result<CanvasListOpenResult, Error> {
3458 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3459 let _value = self
3460 .session
3461 .client()
3462 .call(rpc_methods::SESSION_CANVAS_LISTOPEN, Some(wire_params))
3463 .await?;
3464 Ok(serde_json::from_value(_value)?)
3465 }
3466
3467 /// Opens or focuses a canvas instance.
3468 ///
3469 /// Wire method: `session.canvas.open`.
3470 ///
3471 /// # Parameters
3472 ///
3473 /// * `params` - Canvas open parameters.
3474 ///
3475 /// # Returns
3476 ///
3477 /// Open canvas instance snapshot.
3478 ///
3479 /// <div class="warning">
3480 ///
3481 /// **Experimental.** This API is part of an experimental wire-protocol surface
3482 /// and may change or be removed in future SDK or CLI releases. Pin both the
3483 /// SDK and CLI versions if your code depends on it.
3484 ///
3485 /// </div>
3486 pub async fn open(&self, params: CanvasOpenRequest) -> Result<OpenCanvasInstance, Error> {
3487 let mut wire_params = serde_json::to_value(params)?;
3488 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3489 let _value = self
3490 .session
3491 .client()
3492 .call(rpc_methods::SESSION_CANVAS_OPEN, Some(wire_params))
3493 .await?;
3494 Ok(serde_json::from_value(_value)?)
3495 }
3496
3497 /// Closes an open canvas instance.
3498 ///
3499 /// Wire method: `session.canvas.close`.
3500 ///
3501 /// # Parameters
3502 ///
3503 /// * `params` - Canvas close parameters.
3504 ///
3505 /// <div class="warning">
3506 ///
3507 /// **Experimental.** This API is part of an experimental wire-protocol surface
3508 /// and may change or be removed in future SDK or CLI releases. Pin both the
3509 /// SDK and CLI versions if your code depends on it.
3510 ///
3511 /// </div>
3512 pub async fn close(&self, params: CanvasCloseRequest) -> Result<(), Error> {
3513 let mut wire_params = serde_json::to_value(params)?;
3514 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3515 let _value = self
3516 .session
3517 .client()
3518 .call(rpc_methods::SESSION_CANVAS_CLOSE, Some(wire_params))
3519 .await?;
3520 Ok(())
3521 }
3522}
3523
3524/// `session.canvas.action.*` RPCs.
3525#[derive(Clone, Copy)]
3526pub struct SessionRpcCanvasAction<'a> {
3527 pub(crate) session: &'a Session,
3528}
3529
3530impl<'a> SessionRpcCanvasAction<'a> {
3531 /// Invokes an action on an open canvas instance.
3532 ///
3533 /// Wire method: `session.canvas.action.invoke`.
3534 ///
3535 /// # Parameters
3536 ///
3537 /// * `params` - Canvas action invocation parameters.
3538 ///
3539 /// # Returns
3540 ///
3541 /// Canvas action invocation result.
3542 ///
3543 /// <div class="warning">
3544 ///
3545 /// **Experimental.** This API is part of an experimental wire-protocol surface
3546 /// and may change or be removed in future SDK or CLI releases. Pin both the
3547 /// SDK and CLI versions if your code depends on it.
3548 ///
3549 /// </div>
3550 pub async fn invoke(
3551 &self,
3552 params: CanvasActionInvokeRequest,
3553 ) -> Result<CanvasActionInvokeResult, Error> {
3554 let mut wire_params = serde_json::to_value(params)?;
3555 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3556 let _value = self
3557 .session
3558 .client()
3559 .call(rpc_methods::SESSION_CANVAS_ACTION_INVOKE, Some(wire_params))
3560 .await?;
3561 Ok(serde_json::from_value(_value)?)
3562 }
3563}
3564
3565/// `session.commands.*` RPCs.
3566#[derive(Clone, Copy)]
3567pub struct SessionRpcCommands<'a> {
3568 pub(crate) session: &'a Session,
3569}
3570
3571impl<'a> SessionRpcCommands<'a> {
3572 /// Lists slash commands available in the session.
3573 ///
3574 /// Wire method: `session.commands.list`.
3575 ///
3576 /// # Returns
3577 ///
3578 /// Slash commands available in the session, after applying any include/exclude filters.
3579 ///
3580 /// <div class="warning">
3581 ///
3582 /// **Experimental.** This API is part of an experimental wire-protocol surface
3583 /// and may change or be removed in future SDK or CLI releases. Pin both the
3584 /// SDK and CLI versions if your code depends on it.
3585 ///
3586 /// </div>
3587 pub async fn list(&self) -> Result<CommandList, Error> {
3588 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3589 let _value = self
3590 .session
3591 .client()
3592 .call(rpc_methods::SESSION_COMMANDS_LIST, Some(wire_params))
3593 .await?;
3594 Ok(serde_json::from_value(_value)?)
3595 }
3596
3597 /// Lists slash commands available in the session.
3598 ///
3599 /// Wire method: `session.commands.list`.
3600 ///
3601 /// # Parameters
3602 ///
3603 /// * `params` - Optional filters controlling which command sources to include in the listing.
3604 ///
3605 /// # Returns
3606 ///
3607 /// Slash commands available in the session, after applying any include/exclude filters.
3608 ///
3609 /// <div class="warning">
3610 ///
3611 /// **Experimental.** This API is part of an experimental wire-protocol surface
3612 /// and may change or be removed in future SDK or CLI releases. Pin both the
3613 /// SDK and CLI versions if your code depends on it.
3614 ///
3615 /// </div>
3616 pub async fn list_with_params(
3617 &self,
3618 params: CommandsListRequest,
3619 ) -> Result<CommandList, Error> {
3620 let mut wire_params = serde_json::to_value(params)?;
3621 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3622 let _value = self
3623 .session
3624 .client()
3625 .call(rpc_methods::SESSION_COMMANDS_LIST, Some(wire_params))
3626 .await?;
3627 Ok(serde_json::from_value(_value)?)
3628 }
3629
3630 /// Invokes a slash command in the session.
3631 ///
3632 /// Wire method: `session.commands.invoke`.
3633 ///
3634 /// # Parameters
3635 ///
3636 /// * `params` - Slash command name and optional raw input string to invoke.
3637 ///
3638 /// # Returns
3639 ///
3640 /// Result of invoking the slash command (text output, prompt to send to the agent, completion, or subcommand selection).
3641 ///
3642 /// <div class="warning">
3643 ///
3644 /// **Experimental.** This API is part of an experimental wire-protocol surface
3645 /// and may change or be removed in future SDK or CLI releases. Pin both the
3646 /// SDK and CLI versions if your code depends on it.
3647 ///
3648 /// </div>
3649 pub async fn invoke(
3650 &self,
3651 params: CommandsInvokeRequest,
3652 ) -> Result<SlashCommandInvocationResult, Error> {
3653 let mut wire_params = serde_json::to_value(params)?;
3654 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3655 let _value = self
3656 .session
3657 .client()
3658 .call(rpc_methods::SESSION_COMMANDS_INVOKE, Some(wire_params))
3659 .await?;
3660 Ok(serde_json::from_value(_value)?)
3661 }
3662
3663 /// Reports completion of a pending client-handled slash command.
3664 ///
3665 /// Wire method: `session.commands.handlePendingCommand`.
3666 ///
3667 /// # Parameters
3668 ///
3669 /// * `params` - Pending command request ID and an optional error if the client handler failed.
3670 ///
3671 /// # Returns
3672 ///
3673 /// Indicates whether the pending client-handled command was completed successfully.
3674 ///
3675 /// <div class="warning">
3676 ///
3677 /// **Experimental.** This API is part of an experimental wire-protocol surface
3678 /// and may change or be removed in future SDK or CLI releases. Pin both the
3679 /// SDK and CLI versions if your code depends on it.
3680 ///
3681 /// </div>
3682 pub async fn handle_pending_command(
3683 &self,
3684 params: CommandsHandlePendingCommandRequest,
3685 ) -> Result<CommandsHandlePendingCommandResult, Error> {
3686 let mut wire_params = serde_json::to_value(params)?;
3687 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3688 let _value = self
3689 .session
3690 .client()
3691 .call(
3692 rpc_methods::SESSION_COMMANDS_HANDLEPENDINGCOMMAND,
3693 Some(wire_params),
3694 )
3695 .await?;
3696 Ok(serde_json::from_value(_value)?)
3697 }
3698
3699 /// Executes a slash command synchronously and returns any error.
3700 ///
3701 /// Wire method: `session.commands.execute`.
3702 ///
3703 /// # Parameters
3704 ///
3705 /// * `params` - Slash command name and argument string to execute synchronously.
3706 ///
3707 /// # Returns
3708 ///
3709 /// Error message produced while executing the command, if any.
3710 ///
3711 /// <div class="warning">
3712 ///
3713 /// **Experimental.** This API is part of an experimental wire-protocol surface
3714 /// and may change or be removed in future SDK or CLI releases. Pin both the
3715 /// SDK and CLI versions if your code depends on it.
3716 ///
3717 /// </div>
3718 pub async fn execute(
3719 &self,
3720 params: ExecuteCommandParams,
3721 ) -> Result<ExecuteCommandResult, Error> {
3722 let mut wire_params = serde_json::to_value(params)?;
3723 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3724 let _value = self
3725 .session
3726 .client()
3727 .call(rpc_methods::SESSION_COMMANDS_EXECUTE, Some(wire_params))
3728 .await?;
3729 Ok(serde_json::from_value(_value)?)
3730 }
3731
3732 /// Enqueues a slash command for FIFO processing on the local session.
3733 ///
3734 /// Wire method: `session.commands.enqueue`.
3735 ///
3736 /// # Parameters
3737 ///
3738 /// * `params` - Slash-prefixed command string to enqueue for FIFO processing.
3739 ///
3740 /// # Returns
3741 ///
3742 /// Indicates whether the command was accepted into the local execution queue.
3743 ///
3744 /// <div class="warning">
3745 ///
3746 /// **Experimental.** This API is part of an experimental wire-protocol surface
3747 /// and may change or be removed in future SDK or CLI releases. Pin both the
3748 /// SDK and CLI versions if your code depends on it.
3749 ///
3750 /// </div>
3751 pub async fn enqueue(
3752 &self,
3753 params: EnqueueCommandParams,
3754 ) -> Result<EnqueueCommandResult, Error> {
3755 let mut wire_params = serde_json::to_value(params)?;
3756 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3757 let _value = self
3758 .session
3759 .client()
3760 .call(rpc_methods::SESSION_COMMANDS_ENQUEUE, Some(wire_params))
3761 .await?;
3762 Ok(serde_json::from_value(_value)?)
3763 }
3764
3765 /// Reports whether the host actually executed a queued command and whether to continue processing.
3766 ///
3767 /// Wire method: `session.commands.respondToQueuedCommand`.
3768 ///
3769 /// # Parameters
3770 ///
3771 /// * `params` - Queued-command request ID and the result indicating whether the host executed it (and whether to stop processing further queued commands).
3772 ///
3773 /// # Returns
3774 ///
3775 /// Indicates whether the queued-command response was matched to a pending request.
3776 ///
3777 /// <div class="warning">
3778 ///
3779 /// **Experimental.** This API is part of an experimental wire-protocol surface
3780 /// and may change or be removed in future SDK or CLI releases. Pin both the
3781 /// SDK and CLI versions if your code depends on it.
3782 ///
3783 /// </div>
3784 pub async fn respond_to_queued_command(
3785 &self,
3786 params: CommandsRespondToQueuedCommandRequest,
3787 ) -> Result<CommandsRespondToQueuedCommandResult, Error> {
3788 let mut wire_params = serde_json::to_value(params)?;
3789 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3790 let _value = self
3791 .session
3792 .client()
3793 .call(
3794 rpc_methods::SESSION_COMMANDS_RESPONDTOQUEUEDCOMMAND,
3795 Some(wire_params),
3796 )
3797 .await?;
3798 Ok(serde_json::from_value(_value)?)
3799 }
3800}
3801
3802/// `session.completions.*` RPCs.
3803#[derive(Clone, Copy)]
3804pub struct SessionRpcCompletions<'a> {
3805 pub(crate) session: &'a Session,
3806}
3807
3808impl<'a> SessionRpcCompletions<'a> {
3809 /// 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).
3810 ///
3811 /// Wire method: `session.completions.getTriggerCharacters`.
3812 ///
3813 /// # Returns
3814 ///
3815 /// 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`).
3816 ///
3817 /// <div class="warning">
3818 ///
3819 /// **Experimental.** This API is part of an experimental wire-protocol surface
3820 /// and may change or be removed in future SDK or CLI releases. Pin both the
3821 /// SDK and CLI versions if your code depends on it.
3822 ///
3823 /// </div>
3824 pub async fn get_trigger_characters(
3825 &self,
3826 ) -> Result<CompletionsGetTriggerCharactersResult, Error> {
3827 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
3828 let _value = self
3829 .session
3830 .client()
3831 .call(
3832 rpc_methods::SESSION_COMPLETIONS_GETTRIGGERCHARACTERS,
3833 Some(wire_params),
3834 )
3835 .await?;
3836 Ok(serde_json::from_value(_value)?)
3837 }
3838
3839 /// 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.
3840 ///
3841 /// Wire method: `session.completions.request`.
3842 ///
3843 /// # Parameters
3844 ///
3845 /// * `params` - Request host-driven completions for the current composer input.
3846 ///
3847 /// # Returns
3848 ///
3849 /// Host-driven completion items for the current composer input. Empty when the host returns no items or does not support completions.
3850 ///
3851 /// <div class="warning">
3852 ///
3853 /// **Experimental.** This API is part of an experimental wire-protocol surface
3854 /// and may change or be removed in future SDK or CLI releases. Pin both the
3855 /// SDK and CLI versions if your code depends on it.
3856 ///
3857 /// </div>
3858 pub async fn request(
3859 &self,
3860 params: CompletionsRequestRequest,
3861 ) -> Result<CompletionsRequestResult, Error> {
3862 let mut wire_params = serde_json::to_value(params)?;
3863 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3864 let _value = self
3865 .session
3866 .client()
3867 .call(rpc_methods::SESSION_COMPLETIONS_REQUEST, Some(wire_params))
3868 .await?;
3869 Ok(serde_json::from_value(_value)?)
3870 }
3871}
3872
3873/// `session.contentExclusion.*` RPCs.
3874#[derive(Clone, Copy)]
3875pub struct SessionRpcContentExclusion<'a> {
3876 pub(crate) session: &'a Session,
3877}
3878
3879impl<'a> SessionRpcContentExclusion<'a> {
3880 /// Checks local file system absolute paths within the session working directory against its content-exclusion policy. Results preserve input order. Unsupported paths/filesystems and unavailable policy evaluation return available false, and callers must treat every requested path as excluded.
3881 ///
3882 /// Wire method: `session.contentExclusion.checkPaths`.
3883 ///
3884 /// # Parameters
3885 ///
3886 /// * `params` - Local file system absolute paths within the session working directory to check against its content-exclusion policy.
3887 ///
3888 /// # Returns
3889 ///
3890 /// Batch content-exclusion result. Callers must fail closed when policy evaluation is unavailable.
3891 ///
3892 /// <div class="warning">
3893 ///
3894 /// **Experimental.** This API is part of an experimental wire-protocol surface
3895 /// and may change or be removed in future SDK or CLI releases. Pin both the
3896 /// SDK and CLI versions if your code depends on it.
3897 ///
3898 /// </div>
3899 pub async fn check_paths(
3900 &self,
3901 params: ContentExclusionCheckPathsRequest,
3902 ) -> Result<ContentExclusionCheckPathsResult, Error> {
3903 let mut wire_params = serde_json::to_value(params)?;
3904 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3905 let _value = self
3906 .session
3907 .client()
3908 .call(
3909 rpc_methods::SESSION_CONTENTEXCLUSION_CHECKPATHS,
3910 Some(wire_params),
3911 )
3912 .await?;
3913 Ok(serde_json::from_value(_value)?)
3914 }
3915}
3916
3917/// `session.debug.*` RPCs.
3918#[derive(Clone, Copy)]
3919pub struct SessionRpcDebug<'a> {
3920 pub(crate) session: &'a Session,
3921}
3922
3923impl<'a> SessionRpcDebug<'a> {
3924 /// 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.
3925 ///
3926 /// Wire method: `session.debug.collectLogs`.
3927 ///
3928 /// # Parameters
3929 ///
3930 /// * `params` - Options for collecting a redacted session debug bundle.
3931 ///
3932 /// # Returns
3933 ///
3934 /// Result of collecting a redacted debug bundle.
3935 ///
3936 /// <div class="warning">
3937 ///
3938 /// **Experimental.** This API is part of an experimental wire-protocol surface
3939 /// and may change or be removed in future SDK or CLI releases. Pin both the
3940 /// SDK and CLI versions if your code depends on it.
3941 ///
3942 /// </div>
3943 pub async fn collect_logs(
3944 &self,
3945 params: DebugCollectLogsRequest,
3946 ) -> Result<DebugCollectLogsResult, Error> {
3947 let mut wire_params = serde_json::to_value(params)?;
3948 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3949 let _value = self
3950 .session
3951 .client()
3952 .call(rpc_methods::SESSION_DEBUG_COLLECTLOGS, Some(wire_params))
3953 .await?;
3954 Ok(serde_json::from_value(_value)?)
3955 }
3956}
3957
3958/// `session.eventLog.*` RPCs.
3959#[derive(Clone, Copy)]
3960pub struct SessionRpcEventLog<'a> {
3961 pub(crate) session: &'a Session,
3962}
3963
3964impl<'a> SessionRpcEventLog<'a> {
3965 /// Reads a batch of session events from a cursor, optionally waiting for new events.
3966 ///
3967 /// Wire method: `session.eventLog.read`.
3968 ///
3969 /// # Parameters
3970 ///
3971 /// * `params` - Cursor, batch size, and optional long-poll/filter parameters for reading session events.
3972 ///
3973 /// # Returns
3974 ///
3975 /// Batch of session events returned by a read, with cursor and continuation metadata.
3976 ///
3977 /// <div class="warning">
3978 ///
3979 /// **Experimental.** This API is part of an experimental wire-protocol surface
3980 /// and may change or be removed in future SDK or CLI releases. Pin both the
3981 /// SDK and CLI versions if your code depends on it.
3982 ///
3983 /// </div>
3984 pub async fn read(&self, params: EventLogReadRequest) -> Result<EventsReadResult, Error> {
3985 let mut wire_params = serde_json::to_value(params)?;
3986 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
3987 let _value = self
3988 .session
3989 .client()
3990 .call(rpc_methods::SESSION_EVENTLOG_READ, Some(wire_params))
3991 .await?;
3992 Ok(serde_json::from_value(_value)?)
3993 }
3994
3995 /// Returns a snapshot of the current tail cursor without consuming events.
3996 ///
3997 /// Wire method: `session.eventLog.tail`.
3998 ///
3999 /// # Returns
4000 ///
4001 /// 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).
4002 ///
4003 /// <div class="warning">
4004 ///
4005 /// **Experimental.** This API is part of an experimental wire-protocol surface
4006 /// and may change or be removed in future SDK or CLI releases. Pin both the
4007 /// SDK and CLI versions if your code depends on it.
4008 ///
4009 /// </div>
4010 pub async fn tail(&self) -> Result<EventLogTailResult, Error> {
4011 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
4012 let _value = self
4013 .session
4014 .client()
4015 .call(rpc_methods::SESSION_EVENTLOG_TAIL, Some(wire_params))
4016 .await?;
4017 Ok(serde_json::from_value(_value)?)
4018 }
4019
4020 /// Registers consumer interest in an event type for runtime gating purposes.
4021 ///
4022 /// Wire method: `session.eventLog.registerInterest`.
4023 ///
4024 /// # Parameters
4025 ///
4026 /// * `params` - Event type to register consumer interest for, used by runtime gating logic.
4027 ///
4028 /// # Returns
4029 ///
4030 /// Opaque handle representing an event-type interest registration.
4031 ///
4032 /// <div class="warning">
4033 ///
4034 /// **Experimental.** This API is part of an experimental wire-protocol surface
4035 /// and may change or be removed in future SDK or CLI releases. Pin both the
4036 /// SDK and CLI versions if your code depends on it.
4037 ///
4038 /// </div>
4039 pub async fn register_interest(
4040 &self,
4041 params: RegisterEventInterestParams,
4042 ) -> Result<RegisterEventInterestResult, Error> {
4043 let mut wire_params = serde_json::to_value(params)?;
4044 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4045 let _value = self
4046 .session
4047 .client()
4048 .call(
4049 rpc_methods::SESSION_EVENTLOG_REGISTERINTEREST,
4050 Some(wire_params),
4051 )
4052 .await?;
4053 Ok(serde_json::from_value(_value)?)
4054 }
4055
4056 /// Releases a consumer's previously-registered interest in an event type.
4057 ///
4058 /// Wire method: `session.eventLog.releaseInterest`.
4059 ///
4060 /// # Parameters
4061 ///
4062 /// * `params` - Opaque handle previously returned by `registerInterest` to release.
4063 ///
4064 /// # Returns
4065 ///
4066 /// Indicates whether the operation succeeded.
4067 ///
4068 /// <div class="warning">
4069 ///
4070 /// **Experimental.** This API is part of an experimental wire-protocol surface
4071 /// and may change or be removed in future SDK or CLI releases. Pin both the
4072 /// SDK and CLI versions if your code depends on it.
4073 ///
4074 /// </div>
4075 pub async fn release_interest(
4076 &self,
4077 params: ReleaseEventInterestParams,
4078 ) -> Result<EventLogReleaseInterestResult, Error> {
4079 let mut wire_params = serde_json::to_value(params)?;
4080 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4081 let _value = self
4082 .session
4083 .client()
4084 .call(
4085 rpc_methods::SESSION_EVENTLOG_RELEASEINTEREST,
4086 Some(wire_params),
4087 )
4088 .await?;
4089 Ok(serde_json::from_value(_value)?)
4090 }
4091}
4092
4093/// `session.extensions.*` RPCs.
4094#[derive(Clone, Copy)]
4095pub struct SessionRpcExtensions<'a> {
4096 pub(crate) session: &'a Session,
4097}
4098
4099impl<'a> SessionRpcExtensions<'a> {
4100 /// Lists extensions discovered for the session and their current status.
4101 ///
4102 /// Wire method: `session.extensions.list`.
4103 ///
4104 /// # Returns
4105 ///
4106 /// Extensions discovered for the session, with their current status.
4107 ///
4108 /// <div class="warning">
4109 ///
4110 /// **Experimental.** This API is part of an experimental wire-protocol surface
4111 /// and may change or be removed in future SDK or CLI releases. Pin both the
4112 /// SDK and CLI versions if your code depends on it.
4113 ///
4114 /// </div>
4115 pub async fn list(&self) -> Result<ExtensionList, Error> {
4116 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
4117 let _value = self
4118 .session
4119 .client()
4120 .call(rpc_methods::SESSION_EXTENSIONS_LIST, Some(wire_params))
4121 .await?;
4122 Ok(serde_json::from_value(_value)?)
4123 }
4124
4125 /// Enables an extension for the session.
4126 ///
4127 /// Wire method: `session.extensions.enable`.
4128 ///
4129 /// # Parameters
4130 ///
4131 /// * `params` - Source-qualified extension identifier to enable for the session.
4132 ///
4133 /// <div class="warning">
4134 ///
4135 /// **Experimental.** This API is part of an experimental wire-protocol surface
4136 /// and may change or be removed in future SDK or CLI releases. Pin both the
4137 /// SDK and CLI versions if your code depends on it.
4138 ///
4139 /// </div>
4140 pub async fn enable(&self, params: ExtensionsEnableRequest) -> Result<(), Error> {
4141 let mut wire_params = serde_json::to_value(params)?;
4142 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4143 let _value = self
4144 .session
4145 .client()
4146 .call(rpc_methods::SESSION_EXTENSIONS_ENABLE, Some(wire_params))
4147 .await?;
4148 Ok(())
4149 }
4150
4151 /// Disables an extension for the session.
4152 ///
4153 /// Wire method: `session.extensions.disable`.
4154 ///
4155 /// # Parameters
4156 ///
4157 /// * `params` - Source-qualified extension identifier to disable for the session.
4158 ///
4159 /// <div class="warning">
4160 ///
4161 /// **Experimental.** This API is part of an experimental wire-protocol surface
4162 /// and may change or be removed in future SDK or CLI releases. Pin both the
4163 /// SDK and CLI versions if your code depends on it.
4164 ///
4165 /// </div>
4166 pub async fn disable(&self, params: ExtensionsDisableRequest) -> Result<(), Error> {
4167 let mut wire_params = serde_json::to_value(params)?;
4168 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4169 let _value = self
4170 .session
4171 .client()
4172 .call(rpc_methods::SESSION_EXTENSIONS_DISABLE, Some(wire_params))
4173 .await?;
4174 Ok(())
4175 }
4176
4177 /// Reloads extension definitions and processes for the session.
4178 ///
4179 /// Wire method: `session.extensions.reload`.
4180 ///
4181 /// <div class="warning">
4182 ///
4183 /// **Experimental.** This API is part of an experimental wire-protocol surface
4184 /// and may change or be removed in future SDK or CLI releases. Pin both the
4185 /// SDK and CLI versions if your code depends on it.
4186 ///
4187 /// </div>
4188 pub async fn reload(&self) -> Result<(), Error> {
4189 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
4190 let _value = self
4191 .session
4192 .client()
4193 .call(rpc_methods::SESSION_EXTENSIONS_RELOAD, Some(wire_params))
4194 .await?;
4195 Ok(())
4196 }
4197
4198 /// 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.
4199 ///
4200 /// Wire method: `session.extensions.sendAttachmentsToMessage`.
4201 ///
4202 /// # Parameters
4203 ///
4204 /// * `params` - Parameters for session.extensions.sendAttachmentsToMessage.
4205 ///
4206 /// <div class="warning">
4207 ///
4208 /// **Experimental.** This API is part of an experimental wire-protocol surface
4209 /// and may change or be removed in future SDK or CLI releases. Pin both the
4210 /// SDK and CLI versions if your code depends on it.
4211 ///
4212 /// </div>
4213 pub async fn send_attachments_to_message(
4214 &self,
4215 params: SendAttachmentsToMessageParams,
4216 ) -> Result<(), Error> {
4217 let mut wire_params = serde_json::to_value(params)?;
4218 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4219 let _value = self
4220 .session
4221 .client()
4222 .call(
4223 rpc_methods::SESSION_EXTENSIONS_SENDATTACHMENTSTOMESSAGE,
4224 Some(wire_params),
4225 )
4226 .await?;
4227 Ok(())
4228 }
4229}
4230
4231/// `session.factory.*` RPCs.
4232#[derive(Clone, Copy)]
4233pub struct SessionRpcFactory<'a> {
4234 pub(crate) session: &'a Session,
4235}
4236
4237impl<'a> SessionRpcFactory<'a> {
4238 /// `session.factory.journal.*` sub-namespace.
4239 pub fn journal(&self) -> SessionRpcFactoryJournal<'a> {
4240 SessionRpcFactoryJournal {
4241 session: self.session,
4242 }
4243 }
4244
4245 /// Runs a registered factory by name at the top level.
4246 ///
4247 /// Wire method: `session.factory.run`.
4248 ///
4249 /// # Parameters
4250 ///
4251 /// * `params` - Parameters for invoking a registered factory.
4252 ///
4253 /// # Returns
4254 ///
4255 /// Complete current or terminal factory run envelope.
4256 ///
4257 /// <div class="warning">
4258 ///
4259 /// **Experimental.** This API is part of an experimental wire-protocol surface
4260 /// and may change or be removed in future SDK or CLI releases. Pin both the
4261 /// SDK and CLI versions if your code depends on it.
4262 ///
4263 /// </div>
4264 pub async fn run(&self, params: FactoryRunRequest) -> Result<FactoryRunResult, Error> {
4265 let mut wire_params = serde_json::to_value(params)?;
4266 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4267 let _value = self
4268 .session
4269 .client()
4270 .call(rpc_methods::SESSION_FACTORY_RUN, Some(wire_params))
4271 .await?;
4272 Ok(serde_json::from_value(_value)?)
4273 }
4274
4275 /// Resumes a factory run using its persisted name, arguments, journal, and accounting.
4276 ///
4277 /// Wire method: `session.factory.resume`.
4278 ///
4279 /// # Parameters
4280 ///
4281 /// * `params` - Parameters for resuming a factory run from its persisted identity.
4282 ///
4283 /// # Returns
4284 ///
4285 /// Resolved persisted factory identity and resumed run envelope.
4286 ///
4287 /// <div class="warning">
4288 ///
4289 /// **Experimental.** This API is part of an experimental wire-protocol surface
4290 /// and may change or be removed in future SDK or CLI releases. Pin both the
4291 /// SDK and CLI versions if your code depends on it.
4292 ///
4293 /// </div>
4294 pub async fn resume(&self, params: FactoryResumeRequest) -> Result<FactoryResumeResult, Error> {
4295 let mut wire_params = serde_json::to_value(params)?;
4296 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4297 let _value = self
4298 .session
4299 .client()
4300 .call(rpc_methods::SESSION_FACTORY_RESUME, Some(wire_params))
4301 .await?;
4302 Ok(serde_json::from_value(_value)?)
4303 }
4304
4305 /// Gets the current or settled envelope for a factory run.
4306 ///
4307 /// Wire method: `session.factory.getRun`.
4308 ///
4309 /// # Parameters
4310 ///
4311 /// * `params` - Parameters for retrieving a factory run.
4312 ///
4313 /// # Returns
4314 ///
4315 /// Complete current or terminal factory run envelope.
4316 ///
4317 /// <div class="warning">
4318 ///
4319 /// **Experimental.** This API is part of an experimental wire-protocol surface
4320 /// and may change or be removed in future SDK or CLI releases. Pin both the
4321 /// SDK and CLI versions if your code depends on it.
4322 ///
4323 /// </div>
4324 pub async fn get_run(&self, params: FactoryGetRunRequest) -> Result<FactoryRunResult, Error> {
4325 let mut wire_params = serde_json::to_value(params)?;
4326 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4327 let _value = self
4328 .session
4329 .client()
4330 .call(rpc_methods::SESSION_FACTORY_GETRUN, Some(wire_params))
4331 .await?;
4332 Ok(serde_json::from_value(_value)?)
4333 }
4334
4335 /// Lists durable factory runs for this session in creation order.
4336 ///
4337 /// Wire method: `session.factory.listRuns`.
4338 ///
4339 /// # Returns
4340 ///
4341 /// Factory runs in durable creation order.
4342 ///
4343 /// <div class="warning">
4344 ///
4345 /// **Experimental.** This API is part of an experimental wire-protocol surface
4346 /// and may change or be removed in future SDK or CLI releases. Pin both the
4347 /// SDK and CLI versions if your code depends on it.
4348 ///
4349 /// </div>
4350 pub async fn list_runs(&self) -> Result<FactoryListRunsResult, Error> {
4351 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
4352 let _value = self
4353 .session
4354 .client()
4355 .call(rpc_methods::SESSION_FACTORY_LISTRUNS, Some(wire_params))
4356 .await?;
4357 Ok(serde_json::from_value(_value)?)
4358 }
4359
4360 /// Gets durable and live observability detail for one factory run.
4361 ///
4362 /// Wire method: `session.factory.getRunDetail`.
4363 ///
4364 /// # Parameters
4365 ///
4366 /// * `params` - Parameters for retrieving a factory run.
4367 ///
4368 /// # Returns
4369 ///
4370 /// Full factory run observability detail.
4371 ///
4372 /// <div class="warning">
4373 ///
4374 /// **Experimental.** This API is part of an experimental wire-protocol surface
4375 /// and may change or be removed in future SDK or CLI releases. Pin both the
4376 /// SDK and CLI versions if your code depends on it.
4377 ///
4378 /// </div>
4379 pub async fn get_run_detail(
4380 &self,
4381 params: FactoryGetRunRequest,
4382 ) -> Result<FactoryRunDetail, Error> {
4383 let mut wire_params = serde_json::to_value(params)?;
4384 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4385 let _value = self
4386 .session
4387 .client()
4388 .call(rpc_methods::SESSION_FACTORY_GETRUNDETAIL, Some(wire_params))
4389 .await?;
4390 Ok(serde_json::from_value(_value)?)
4391 }
4392
4393 /// Pages durable progress for one factory run.
4394 ///
4395 /// Wire method: `session.factory.getRunProgress`.
4396 ///
4397 /// # Parameters
4398 ///
4399 /// * `params` - Parameters for paging factory progress.
4400 ///
4401 /// # Returns
4402 ///
4403 /// A bidirectional page of factory progress.
4404 ///
4405 /// <div class="warning">
4406 ///
4407 /// **Experimental.** This API is part of an experimental wire-protocol surface
4408 /// and may change or be removed in future SDK or CLI releases. Pin both the
4409 /// SDK and CLI versions if your code depends on it.
4410 ///
4411 /// </div>
4412 pub async fn get_run_progress(
4413 &self,
4414 params: FactoryGetRunProgressRequest,
4415 ) -> Result<FactoryProgressPage, Error> {
4416 let mut wire_params = serde_json::to_value(params)?;
4417 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4418 let _value = self
4419 .session
4420 .client()
4421 .call(
4422 rpc_methods::SESSION_FACTORY_GETRUNPROGRESS,
4423 Some(wire_params),
4424 )
4425 .await?;
4426 Ok(serde_json::from_value(_value)?)
4427 }
4428
4429 /// Requests cancellation of a factory run and returns its run envelope.
4430 ///
4431 /// Wire method: `session.factory.cancel`.
4432 ///
4433 /// # Parameters
4434 ///
4435 /// * `params` - Parameters for cancelling a factory run.
4436 ///
4437 /// # Returns
4438 ///
4439 /// Complete current or terminal factory run envelope.
4440 ///
4441 /// <div class="warning">
4442 ///
4443 /// **Experimental.** This API is part of an experimental wire-protocol surface
4444 /// and may change or be removed in future SDK or CLI releases. Pin both the
4445 /// SDK and CLI versions if your code depends on it.
4446 ///
4447 /// </div>
4448 pub async fn cancel(&self, params: FactoryCancelRequest) -> Result<FactoryRunResult, Error> {
4449 let mut wire_params = serde_json::to_value(params)?;
4450 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4451 let _value = self
4452 .session
4453 .client()
4454 .call(rpc_methods::SESSION_FACTORY_CANCEL, Some(wire_params))
4455 .await?;
4456 Ok(serde_json::from_value(_value)?)
4457 }
4458
4459 /// Records a batch of ordered factory progress lines.
4460 ///
4461 /// Wire method: `session.factory.log`.
4462 ///
4463 /// # Parameters
4464 ///
4465 /// * `params` - Parameters for recording factory progress.
4466 ///
4467 /// # Returns
4468 ///
4469 /// Acknowledgement that a factory request was accepted.
4470 ///
4471 /// <div class="warning">
4472 ///
4473 /// **Experimental.** This API is part of an experimental wire-protocol surface
4474 /// and may change or be removed in future SDK or CLI releases. Pin both the
4475 /// SDK and CLI versions if your code depends on it.
4476 ///
4477 /// </div>
4478 pub async fn log(&self, params: FactoryLogRequest) -> Result<FactoryAckResult, Error> {
4479 let mut wire_params = serde_json::to_value(params)?;
4480 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4481 let _value = self
4482 .session
4483 .client()
4484 .call(rpc_methods::SESSION_FACTORY_LOG, Some(wire_params))
4485 .await?;
4486 Ok(serde_json::from_value(_value)?)
4487 }
4488
4489 /// Runs one factory-scoped subagent and returns its result.
4490 ///
4491 /// Wire method: `session.factory.agent`.
4492 ///
4493 /// # Parameters
4494 ///
4495 /// * `params` - Parameters for one factory-scoped subagent call.
4496 ///
4497 /// # Returns
4498 ///
4499 /// Result of one factory-scoped subagent call.
4500 ///
4501 /// <div class="warning">
4502 ///
4503 /// **Experimental.** This API is part of an experimental wire-protocol surface
4504 /// and may change or be removed in future SDK or CLI releases. Pin both the
4505 /// SDK and CLI versions if your code depends on it.
4506 ///
4507 /// </div>
4508 pub async fn agent(&self, params: FactoryAgentRequest) -> Result<FactoryAgentResult, Error> {
4509 let mut wire_params = serde_json::to_value(params)?;
4510 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4511 let _value = self
4512 .session
4513 .client()
4514 .call(rpc_methods::SESSION_FACTORY_AGENT, Some(wire_params))
4515 .await?;
4516 Ok(serde_json::from_value(_value)?)
4517 }
4518}
4519
4520/// `session.factory.journal.*` RPCs.
4521#[derive(Clone, Copy)]
4522pub struct SessionRpcFactoryJournal<'a> {
4523 pub(crate) session: &'a Session,
4524}
4525
4526impl<'a> SessionRpcFactoryJournal<'a> {
4527 /// Reads a memoized factory journal entry.
4528 ///
4529 /// Wire method: `session.factory.journal.get`.
4530 ///
4531 /// # Parameters
4532 ///
4533 /// * `params` - Parameters for reading a factory journal entry.
4534 ///
4535 /// # Returns
4536 ///
4537 /// Result of reading a factory journal entry.
4538 ///
4539 /// <div class="warning">
4540 ///
4541 /// **Experimental.** This API is part of an experimental wire-protocol surface
4542 /// and may change or be removed in future SDK or CLI releases. Pin both the
4543 /// SDK and CLI versions if your code depends on it.
4544 ///
4545 /// </div>
4546 pub async fn get(
4547 &self,
4548 params: FactoryJournalGetRequest,
4549 ) -> Result<FactoryJournalGetResult, Error> {
4550 let mut wire_params = serde_json::to_value(params)?;
4551 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4552 let _value = self
4553 .session
4554 .client()
4555 .call(rpc_methods::SESSION_FACTORY_JOURNAL_GET, Some(wire_params))
4556 .await?;
4557 Ok(serde_json::from_value(_value)?)
4558 }
4559
4560 /// Stores a memoized factory journal entry.
4561 ///
4562 /// Wire method: `session.factory.journal.put`.
4563 ///
4564 /// # Parameters
4565 ///
4566 /// * `params` - Parameters for storing a factory journal entry.
4567 ///
4568 /// # Returns
4569 ///
4570 /// Acknowledgement that a factory request was accepted.
4571 ///
4572 /// <div class="warning">
4573 ///
4574 /// **Experimental.** This API is part of an experimental wire-protocol surface
4575 /// and may change or be removed in future SDK or CLI releases. Pin both the
4576 /// SDK and CLI versions if your code depends on it.
4577 ///
4578 /// </div>
4579 pub async fn put(&self, params: FactoryJournalPutRequest) -> Result<FactoryAckResult, Error> {
4580 let mut wire_params = serde_json::to_value(params)?;
4581 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4582 let _value = self
4583 .session
4584 .client()
4585 .call(rpc_methods::SESSION_FACTORY_JOURNAL_PUT, Some(wire_params))
4586 .await?;
4587 Ok(serde_json::from_value(_value)?)
4588 }
4589}
4590
4591/// `session.fleet.*` RPCs.
4592#[derive(Clone, Copy)]
4593pub struct SessionRpcFleet<'a> {
4594 pub(crate) session: &'a Session,
4595}
4596
4597impl<'a> SessionRpcFleet<'a> {
4598 /// Starts fleet mode by submitting the fleet orchestration prompt to the session.
4599 ///
4600 /// Wire method: `session.fleet.start`.
4601 ///
4602 /// # Parameters
4603 ///
4604 /// * `params` - Optional user prompt to combine with the fleet orchestration instructions.
4605 ///
4606 /// # Returns
4607 ///
4608 /// Indicates whether fleet mode was successfully activated.
4609 ///
4610 /// <div class="warning">
4611 ///
4612 /// **Experimental.** This API is part of an experimental wire-protocol surface
4613 /// and may change or be removed in future SDK or CLI releases. Pin both the
4614 /// SDK and CLI versions if your code depends on it.
4615 ///
4616 /// </div>
4617 pub async fn start(&self, params: FleetStartRequest) -> Result<FleetStartResult, 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_FLEET_START, Some(wire_params))
4624 .await?;
4625 Ok(serde_json::from_value(_value)?)
4626 }
4627}
4628
4629/// `session.gitHubAuth.*` RPCs.
4630#[derive(Clone, Copy)]
4631pub struct SessionRpcGitHubAuth<'a> {
4632 pub(crate) session: &'a Session,
4633}
4634
4635impl<'a> SessionRpcGitHubAuth<'a> {
4636 /// Gets authentication status and account metadata for the session.
4637 ///
4638 /// Wire method: `session.gitHubAuth.getStatus`.
4639 ///
4640 /// # Returns
4641 ///
4642 /// Authentication status and account metadata for the session.
4643 ///
4644 /// <div class="warning">
4645 ///
4646 /// **Experimental.** This API is part of an experimental wire-protocol surface
4647 /// and may change or be removed in future SDK or CLI releases. Pin both the
4648 /// SDK and CLI versions if your code depends on it.
4649 ///
4650 /// </div>
4651 pub async fn get_status(&self) -> Result<SessionAuthStatus, Error> {
4652 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
4653 let _value = self
4654 .session
4655 .client()
4656 .call(rpc_methods::SESSION_GITHUBAUTH_GETSTATUS, Some(wire_params))
4657 .await?;
4658 Ok(serde_json::from_value(_value)?)
4659 }
4660
4661 /// Updates the session's auth credentials used for outbound model and API requests.
4662 ///
4663 /// Wire method: `session.gitHubAuth.setCredentials`.
4664 ///
4665 /// # Parameters
4666 ///
4667 /// * `params` - New auth credentials to install on the session. Omit to leave credentials unchanged.
4668 ///
4669 /// # Returns
4670 ///
4671 /// Indicates whether the credential update succeeded.
4672 ///
4673 /// <div class="warning">
4674 ///
4675 /// **Experimental.** This API is part of an experimental wire-protocol surface
4676 /// and may change or be removed in future SDK or CLI releases. Pin both the
4677 /// SDK and CLI versions if your code depends on it.
4678 ///
4679 /// </div>
4680 pub async fn set_credentials(
4681 &self,
4682 params: SessionSetCredentialsParams,
4683 ) -> Result<SessionSetCredentialsResult, Error> {
4684 let mut wire_params = serde_json::to_value(params)?;
4685 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4686 let _value = self
4687 .session
4688 .client()
4689 .call(
4690 rpc_methods::SESSION_GITHUBAUTH_SETCREDENTIALS,
4691 Some(wire_params),
4692 )
4693 .await?;
4694 Ok(serde_json::from_value(_value)?)
4695 }
4696}
4697
4698/// `session.history.*` RPCs.
4699#[derive(Clone, Copy)]
4700pub struct SessionRpcHistory<'a> {
4701 pub(crate) session: &'a Session,
4702}
4703
4704impl<'a> SessionRpcHistory<'a> {
4705 /// Compacts the session history to reduce context usage.
4706 ///
4707 /// Wire method: `session.history.compact`.
4708 ///
4709 /// # Returns
4710 ///
4711 /// Compaction outcome with the number of tokens and messages removed, summary text, and the resulting context window breakdown.
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 async fn compact(&self) -> Result<HistoryCompactResult, Error> {
4721 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
4722 let _value = self
4723 .session
4724 .client()
4725 .call(rpc_methods::SESSION_HISTORY_COMPACT, Some(wire_params))
4726 .await?;
4727 Ok(serde_json::from_value(_value)?)
4728 }
4729
4730 /// Compacts the session history to reduce context usage.
4731 ///
4732 /// Wire method: `session.history.compact`.
4733 ///
4734 /// # Parameters
4735 ///
4736 /// * `params` - Optional compaction parameters.
4737 ///
4738 /// # Returns
4739 ///
4740 /// Compaction outcome with the number of tokens and messages removed, summary text, and the resulting context window breakdown.
4741 ///
4742 /// <div class="warning">
4743 ///
4744 /// **Experimental.** This API is part of an experimental wire-protocol surface
4745 /// and may change or be removed in future SDK or CLI releases. Pin both the
4746 /// SDK and CLI versions if your code depends on it.
4747 ///
4748 /// </div>
4749 pub async fn compact_with_params(
4750 &self,
4751 params: HistoryCompactRequest,
4752 ) -> Result<HistoryCompactResult, Error> {
4753 let mut wire_params = serde_json::to_value(params)?;
4754 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4755 let _value = self
4756 .session
4757 .client()
4758 .call(rpc_methods::SESSION_HISTORY_COMPACT, Some(wire_params))
4759 .await?;
4760 Ok(serde_json::from_value(_value)?)
4761 }
4762
4763 /// Truncates persisted session history to a specific event.
4764 ///
4765 /// Wire method: `session.history.truncate`.
4766 ///
4767 /// # Parameters
4768 ///
4769 /// * `params` - Identifier of the event to truncate to; this event and all later events are removed.
4770 ///
4771 /// # Returns
4772 ///
4773 /// Number of events that were removed by the truncation.
4774 ///
4775 /// <div class="warning">
4776 ///
4777 /// **Experimental.** This API is part of an experimental wire-protocol surface
4778 /// and may change or be removed in future SDK or CLI releases. Pin both the
4779 /// SDK and CLI versions if your code depends on it.
4780 ///
4781 /// </div>
4782 pub async fn truncate(
4783 &self,
4784 params: HistoryTruncateRequest,
4785 ) -> Result<HistoryTruncateResult, Error> {
4786 let mut wire_params = serde_json::to_value(params)?;
4787 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4788 let _value = self
4789 .session
4790 .client()
4791 .call(rpc_methods::SESSION_HISTORY_TRUNCATE, Some(wire_params))
4792 .await?;
4793 Ok(serde_json::from_value(_value)?)
4794 }
4795
4796 /// Lists the user turns that the session can rewind to. Never rejects for a busy session: rewind reads need the session's file-change captures to be settled, so a session that still holds active work answers with `unavailableReason: "session-busy"` and no points, which the caller can retry.
4797 ///
4798 /// Wire method: `session.history.listRewindPoints`.
4799 ///
4800 /// # Returns
4801 ///
4802 /// Rewind points and file-change-tracking availability for the session.
4803 ///
4804 /// <div class="warning">
4805 ///
4806 /// **Experimental.** This API is part of an experimental wire-protocol surface
4807 /// and may change or be removed in future SDK or CLI releases. Pin both the
4808 /// SDK and CLI versions if your code depends on it.
4809 ///
4810 /// </div>
4811 pub async fn list_rewind_points(&self) -> Result<HistoryListRewindPointsResult, Error> {
4812 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
4813 let _value = self
4814 .session
4815 .client()
4816 .call(
4817 rpc_methods::SESSION_HISTORY_LISTREWINDPOINTS,
4818 Some(wire_params),
4819 )
4820 .await?;
4821 Ok(serde_json::from_value(_value)?)
4822 }
4823
4824 /// Previews the files that a conversation-and-files rewind would restore.
4825 ///
4826 /// Wire method: `session.history.previewRewind`.
4827 ///
4828 /// # Parameters
4829 ///
4830 /// * `params` - Event boundary to preview for conversation-and-files rewind.
4831 ///
4832 /// # Returns
4833 ///
4834 /// Files and aggregate changes for a prospective rewind.
4835 ///
4836 /// <div class="warning">
4837 ///
4838 /// **Experimental.** This API is part of an experimental wire-protocol surface
4839 /// and may change or be removed in future SDK or CLI releases. Pin both the
4840 /// SDK and CLI versions if your code depends on it.
4841 ///
4842 /// </div>
4843 pub async fn preview_rewind(
4844 &self,
4845 params: HistoryPreviewRewindRequest,
4846 ) -> Result<HistoryPreviewRewindResult, Error> {
4847 let mut wire_params = serde_json::to_value(params)?;
4848 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4849 let _value = self
4850 .session
4851 .client()
4852 .call(
4853 rpc_methods::SESSION_HISTORY_PREVIEWREWIND,
4854 Some(wire_params),
4855 )
4856 .await?;
4857 Ok(serde_json::from_value(_value)?)
4858 }
4859
4860 /// Rewinds the session conversation, optionally restoring files changed by the discarded turns. Not crash-atomic: file restore and conversation truncation are separate stores, applied in that order, so a process crash between them can leave the workspace rewound while the conversation still contains the discarded turns. There is no recovery journal; re-running the same rewind is the recovery path for a crash before truncation lands, since file restore is idempotent (already-restored files are reported as skipped) and truncation is re-derived from the still-retained boundary event. After truncation lands that boundary no longer exists, so the same request is rejected; the only stage that can still be outstanding is snapshot pruning, whose failure leaves orphan snapshots the capture store tolerates. The reverse inconsistency cannot occur, because truncation is never applied before file restore succeeds.
4861 ///
4862 /// Wire method: `session.history.rewind`.
4863 ///
4864 /// # Parameters
4865 ///
4866 /// * `params` - Boundary and mode for rewinding session history.
4867 ///
4868 /// # Returns
4869 ///
4870 /// Structured outcome of a rewind request.
4871 ///
4872 /// <div class="warning">
4873 ///
4874 /// **Experimental.** This API is part of an experimental wire-protocol surface
4875 /// and may change or be removed in future SDK or CLI releases. Pin both the
4876 /// SDK and CLI versions if your code depends on it.
4877 ///
4878 /// </div>
4879 pub async fn rewind(&self, params: HistoryRewindRequest) -> Result<HistoryRewindResult, Error> {
4880 let mut wire_params = serde_json::to_value(params)?;
4881 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
4882 let _value = self
4883 .session
4884 .client()
4885 .call(rpc_methods::SESSION_HISTORY_REWIND, Some(wire_params))
4886 .await?;
4887 Ok(serde_json::from_value(_value)?)
4888 }
4889
4890 /// Cancels any in-progress background compaction on a local session.
4891 ///
4892 /// Wire method: `session.history.cancelBackgroundCompaction`.
4893 ///
4894 /// # Returns
4895 ///
4896 /// Indicates whether an in-progress background compaction was cancelled.
4897 ///
4898 /// <div class="warning">
4899 ///
4900 /// **Experimental.** This API is part of an experimental wire-protocol surface
4901 /// and may change or be removed in future SDK or CLI releases. Pin both the
4902 /// SDK and CLI versions if your code depends on it.
4903 ///
4904 /// </div>
4905 pub async fn cancel_background_compaction(
4906 &self,
4907 ) -> Result<HistoryCancelBackgroundCompactionResult, Error> {
4908 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
4909 let _value = self
4910 .session
4911 .client()
4912 .call(
4913 rpc_methods::SESSION_HISTORY_CANCELBACKGROUNDCOMPACTION,
4914 Some(wire_params),
4915 )
4916 .await?;
4917 Ok(serde_json::from_value(_value)?)
4918 }
4919
4920 /// Aborts any in-progress manual compaction on a local session.
4921 ///
4922 /// Wire method: `session.history.abortManualCompaction`.
4923 ///
4924 /// # Returns
4925 ///
4926 /// Indicates whether an in-progress manual compaction was aborted.
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 abort_manual_compaction(
4936 &self,
4937 ) -> Result<HistoryAbortManualCompactionResult, Error> {
4938 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
4939 let _value = self
4940 .session
4941 .client()
4942 .call(
4943 rpc_methods::SESSION_HISTORY_ABORTMANUALCOMPACTION,
4944 Some(wire_params),
4945 )
4946 .await?;
4947 Ok(serde_json::from_value(_value)?)
4948 }
4949
4950 /// Produces a markdown summary of the session's conversation context for hand-off scenarios.
4951 ///
4952 /// Wire method: `session.history.summarizeForHandoff`.
4953 ///
4954 /// # Returns
4955 ///
4956 /// Markdown summary of the conversation context (empty when not available).
4957 ///
4958 /// <div class="warning">
4959 ///
4960 /// **Experimental.** This API is part of an experimental wire-protocol surface
4961 /// and may change or be removed in future SDK or CLI releases. Pin both the
4962 /// SDK and CLI versions if your code depends on it.
4963 ///
4964 /// </div>
4965 pub async fn summarize_for_handoff(&self) -> Result<HistorySummarizeForHandoffResult, Error> {
4966 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
4967 let _value = self
4968 .session
4969 .client()
4970 .call(
4971 rpc_methods::SESSION_HISTORY_SUMMARIZEFORHANDOFF,
4972 Some(wire_params),
4973 )
4974 .await?;
4975 Ok(serde_json::from_value(_value)?)
4976 }
4977}
4978
4979/// `session.instructions.*` RPCs.
4980#[derive(Clone, Copy)]
4981pub struct SessionRpcInstructions<'a> {
4982 pub(crate) session: &'a Session,
4983}
4984
4985impl<'a> SessionRpcInstructions<'a> {
4986 /// Gets instruction sources loaded for the session.
4987 ///
4988 /// Wire method: `session.instructions.getSources`.
4989 ///
4990 /// # Returns
4991 ///
4992 /// Instruction sources loaded for the session, in merge order.
4993 ///
4994 /// <div class="warning">
4995 ///
4996 /// **Experimental.** This API is part of an experimental wire-protocol surface
4997 /// and may change or be removed in future SDK or CLI releases. Pin both the
4998 /// SDK and CLI versions if your code depends on it.
4999 ///
5000 /// </div>
5001 pub async fn get_sources(&self) -> Result<InstructionsGetSourcesResult, Error> {
5002 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5003 let _value = self
5004 .session
5005 .client()
5006 .call(
5007 rpc_methods::SESSION_INSTRUCTIONS_GETSOURCES,
5008 Some(wire_params),
5009 )
5010 .await?;
5011 Ok(serde_json::from_value(_value)?)
5012 }
5013}
5014
5015/// `session.limitPrediction.*` RPCs.
5016#[derive(Clone, Copy)]
5017pub struct SessionRpcLimitPrediction<'a> {
5018 pub(crate) session: &'a Session,
5019}
5020
5021impl<'a> SessionRpcLimitPrediction<'a> {
5022 /// Predicts an AI-credit session limit for the session's resolved model. Returns an unavailable result instead of falling back when the current model is unresolved auto.
5023 ///
5024 /// Wire method: `session.limitPrediction.predict`.
5025 ///
5026 /// # Returns
5027 ///
5028 /// Prediction result. Available results include prediction details; unavailable results include an explicit reason.
5029 ///
5030 /// <div class="warning">
5031 ///
5032 /// **Experimental.** This API is part of an experimental wire-protocol surface
5033 /// and may change or be removed in future SDK or CLI releases. Pin both the
5034 /// SDK and CLI versions if your code depends on it.
5035 ///
5036 /// </div>
5037 pub async fn predict(&self) -> Result<SessionLimitPredictionResult, Error> {
5038 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5039 let _value = self
5040 .session
5041 .client()
5042 .call(
5043 rpc_methods::SESSION_LIMITPREDICTION_PREDICT,
5044 Some(wire_params),
5045 )
5046 .await?;
5047 Ok(serde_json::from_value(_value)?)
5048 }
5049
5050 /// Predicts an AI-credit session limit for the session's resolved model. Returns an unavailable result instead of falling back when the current model is unresolved auto.
5051 ///
5052 /// Wire method: `session.limitPrediction.predict`.
5053 ///
5054 /// # Parameters
5055 ///
5056 /// * `params` - Parameters for predicting an AI-credit session limit. Omitting `modelId` uses the session's currently selected model.
5057 ///
5058 /// # Returns
5059 ///
5060 /// Prediction result. Available results include prediction details; unavailable results include an explicit reason.
5061 ///
5062 /// <div class="warning">
5063 ///
5064 /// **Experimental.** This API is part of an experimental wire-protocol surface
5065 /// and may change or be removed in future SDK or CLI releases. Pin both the
5066 /// SDK and CLI versions if your code depends on it.
5067 ///
5068 /// </div>
5069 pub async fn predict_with_params(
5070 &self,
5071 params: SessionLimitPredictionRequest,
5072 ) -> Result<SessionLimitPredictionResult, Error> {
5073 let mut wire_params = serde_json::to_value(params)?;
5074 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5075 let _value = self
5076 .session
5077 .client()
5078 .call(
5079 rpc_methods::SESSION_LIMITPREDICTION_PREDICT,
5080 Some(wire_params),
5081 )
5082 .await?;
5083 Ok(serde_json::from_value(_value)?)
5084 }
5085}
5086
5087/// `session.lsp.*` RPCs.
5088#[derive(Clone, Copy)]
5089pub struct SessionRpcLsp<'a> {
5090 pub(crate) session: &'a Session,
5091}
5092
5093impl<'a> SessionRpcLsp<'a> {
5094 /// Loads the merged LSP configuration set for the session's working directory.
5095 ///
5096 /// Wire method: `session.lsp.initialize`.
5097 ///
5098 /// # Parameters
5099 ///
5100 /// * `params` - Parameters for (re)loading the merged LSP configuration set.
5101 ///
5102 /// <div class="warning">
5103 ///
5104 /// **Experimental.** This API is part of an experimental wire-protocol surface
5105 /// and may change or be removed in future SDK or CLI releases. Pin both the
5106 /// SDK and CLI versions if your code depends on it.
5107 ///
5108 /// </div>
5109 pub async fn initialize(&self, params: LspInitializeRequest) -> Result<(), Error> {
5110 let mut wire_params = serde_json::to_value(params)?;
5111 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5112 let _value = self
5113 .session
5114 .client()
5115 .call(rpc_methods::SESSION_LSP_INITIALIZE, Some(wire_params))
5116 .await?;
5117 Ok(())
5118 }
5119}
5120
5121/// `session.mcp.*` RPCs.
5122#[derive(Clone, Copy)]
5123pub struct SessionRpcMcp<'a> {
5124 pub(crate) session: &'a Session,
5125}
5126
5127impl<'a> SessionRpcMcp<'a> {
5128 /// `session.mcp.apps.*` sub-namespace.
5129 pub fn apps(&self) -> SessionRpcMcpApps<'a> {
5130 SessionRpcMcpApps {
5131 session: self.session,
5132 }
5133 }
5134
5135 /// `session.mcp.headers.*` sub-namespace.
5136 pub fn headers(&self) -> SessionRpcMcpHeaders<'a> {
5137 SessionRpcMcpHeaders {
5138 session: self.session,
5139 }
5140 }
5141
5142 /// `session.mcp.oauth.*` sub-namespace.
5143 pub fn oauth(&self) -> SessionRpcMcpOauth<'a> {
5144 SessionRpcMcpOauth {
5145 session: self.session,
5146 }
5147 }
5148
5149 /// `session.mcp.resources.*` sub-namespace.
5150 pub fn resources(&self) -> SessionRpcMcpResources<'a> {
5151 SessionRpcMcpResources {
5152 session: self.session,
5153 }
5154 }
5155
5156 /// 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.
5157 ///
5158 /// Wire method: `session.mcp.list`.
5159 ///
5160 /// # Returns
5161 ///
5162 /// MCP servers configured for the session, with their connection status and host-level state.
5163 ///
5164 /// <div class="warning">
5165 ///
5166 /// **Experimental.** This API is part of an experimental wire-protocol surface
5167 /// and may change or be removed in future SDK or CLI releases. Pin both the
5168 /// SDK and CLI versions if your code depends on it.
5169 ///
5170 /// </div>
5171 pub async fn list(&self) -> Result<McpServerList, Error> {
5172 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5173 let _value = self
5174 .session
5175 .client()
5176 .call(rpc_methods::SESSION_MCP_LIST, Some(wire_params))
5177 .await?;
5178 Ok(serde_json::from_value(_value)?)
5179 }
5180
5181 /// 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.
5182 ///
5183 /// Wire method: `session.mcp.listTools`.
5184 ///
5185 /// # Parameters
5186 ///
5187 /// * `params` - Server name whose tool list should be returned.
5188 ///
5189 /// # Returns
5190 ///
5191 /// Tools exposed by the connected MCP server. Throws when the server is not connected.
5192 ///
5193 /// <div class="warning">
5194 ///
5195 /// **Experimental.** This API is part of an experimental wire-protocol surface
5196 /// and may change or be removed in future SDK or CLI releases. Pin both the
5197 /// SDK and CLI versions if your code depends on it.
5198 ///
5199 /// </div>
5200 pub async fn list_tools(
5201 &self,
5202 params: McpListToolsRequest,
5203 ) -> Result<McpListToolsResult, Error> {
5204 let mut wire_params = serde_json::to_value(params)?;
5205 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5206 let _value = self
5207 .session
5208 .client()
5209 .call(rpc_methods::SESSION_MCP_LISTTOOLS, Some(wire_params))
5210 .await?;
5211 Ok(serde_json::from_value(_value)?)
5212 }
5213
5214 /// Enables an MCP server for the session.
5215 ///
5216 /// Wire method: `session.mcp.enable`.
5217 ///
5218 /// # Parameters
5219 ///
5220 /// * `params` - Name of the MCP server to enable for the session.
5221 ///
5222 /// <div class="warning">
5223 ///
5224 /// **Experimental.** This API is part of an experimental wire-protocol surface
5225 /// and may change or be removed in future SDK or CLI releases. Pin both the
5226 /// SDK and CLI versions if your code depends on it.
5227 ///
5228 /// </div>
5229 pub async fn enable(&self, params: McpEnableRequest) -> Result<(), Error> {
5230 let mut wire_params = serde_json::to_value(params)?;
5231 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5232 let _value = self
5233 .session
5234 .client()
5235 .call(rpc_methods::SESSION_MCP_ENABLE, Some(wire_params))
5236 .await?;
5237 Ok(())
5238 }
5239
5240 /// Disables an MCP server for the session.
5241 ///
5242 /// Wire method: `session.mcp.disable`.
5243 ///
5244 /// # Parameters
5245 ///
5246 /// * `params` - Name of the MCP server to disable for the session.
5247 ///
5248 /// <div class="warning">
5249 ///
5250 /// **Experimental.** This API is part of an experimental wire-protocol surface
5251 /// and may change or be removed in future SDK or CLI releases. Pin both the
5252 /// SDK and CLI versions if your code depends on it.
5253 ///
5254 /// </div>
5255 pub async fn disable(&self, params: McpDisableRequest) -> Result<(), Error> {
5256 let mut wire_params = serde_json::to_value(params)?;
5257 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5258 let _value = self
5259 .session
5260 .client()
5261 .call(rpc_methods::SESSION_MCP_DISABLE, Some(wire_params))
5262 .await?;
5263 Ok(())
5264 }
5265
5266 /// Reloads MCP server connections for the session.
5267 ///
5268 /// Wire method: `session.mcp.reload`.
5269 ///
5270 /// <div class="warning">
5271 ///
5272 /// **Experimental.** This API is part of an experimental wire-protocol surface
5273 /// and may change or be removed in future SDK or CLI releases. Pin both the
5274 /// SDK and CLI versions if your code depends on it.
5275 ///
5276 /// </div>
5277 pub async fn reload(&self) -> Result<(), Error> {
5278 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5279 let _value = self
5280 .session
5281 .client()
5282 .call(rpc_methods::SESSION_MCP_RELOAD, Some(wire_params))
5283 .await?;
5284 Ok(())
5285 }
5286
5287 /// Reloads MCP server connections for the session with an explicit host-provided configuration.
5288 ///
5289 /// Wire method: `session.mcp.reloadWithConfig`.
5290 ///
5291 /// # Parameters
5292 ///
5293 /// * `params` - Opaque MCP reload configuration.
5294 ///
5295 /// # Returns
5296 ///
5297 /// MCP server startup filtering result.
5298 ///
5299 /// <div class="warning">
5300 ///
5301 /// **Experimental.** This API is part of an experimental wire-protocol surface
5302 /// and may change or be removed in future SDK or CLI releases. Pin both the
5303 /// SDK and CLI versions if your code depends on it.
5304 ///
5305 /// </div>
5306 pub(crate) async fn reload_with_config(
5307 &self,
5308 params: McpReloadWithConfigRequest,
5309 ) -> Result<McpStartServersResult, Error> {
5310 let mut wire_params = serde_json::to_value(params)?;
5311 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5312 let _value = self
5313 .session
5314 .client()
5315 .call(rpc_methods::SESSION_MCP_RELOADWITHCONFIG, Some(wire_params))
5316 .await?;
5317 Ok(serde_json::from_value(_value)?)
5318 }
5319
5320 /// Runs an MCP sampling inference on behalf of an MCP server.
5321 ///
5322 /// Wire method: `session.mcp.executeSampling`.
5323 ///
5324 /// # Parameters
5325 ///
5326 /// * `params` - Identifiers and raw MCP CreateMessageRequest params used to run a sampling inference.
5327 ///
5328 /// # Returns
5329 ///
5330 /// Outcome of an MCP sampling execution: success result, failure error, or cancellation.
5331 ///
5332 /// <div class="warning">
5333 ///
5334 /// **Experimental.** This API is part of an experimental wire-protocol surface
5335 /// and may change or be removed in future SDK or CLI releases. Pin both the
5336 /// SDK and CLI versions if your code depends on it.
5337 ///
5338 /// </div>
5339 pub async fn execute_sampling(
5340 &self,
5341 params: McpExecuteSamplingParams,
5342 ) -> Result<McpSamplingExecutionResult, Error> {
5343 let mut wire_params = serde_json::to_value(params)?;
5344 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5345 let _value = self
5346 .session
5347 .client()
5348 .call(rpc_methods::SESSION_MCP_EXECUTESAMPLING, Some(wire_params))
5349 .await?;
5350 Ok(serde_json::from_value(_value)?)
5351 }
5352
5353 /// Cancels an in-flight MCP sampling execution by request ID.
5354 ///
5355 /// Wire method: `session.mcp.cancelSamplingExecution`.
5356 ///
5357 /// # Parameters
5358 ///
5359 /// * `params` - The requestId previously passed to executeSampling that should be cancelled.
5360 ///
5361 /// # Returns
5362 ///
5363 /// Indicates whether an in-flight sampling execution with the given requestId was found and cancelled.
5364 ///
5365 /// <div class="warning">
5366 ///
5367 /// **Experimental.** This API is part of an experimental wire-protocol surface
5368 /// and may change or be removed in future SDK or CLI releases. Pin both the
5369 /// SDK and CLI versions if your code depends on it.
5370 ///
5371 /// </div>
5372 pub async fn cancel_sampling_execution(
5373 &self,
5374 params: McpCancelSamplingExecutionParams,
5375 ) -> Result<McpCancelSamplingExecutionResult, Error> {
5376 let mut wire_params = serde_json::to_value(params)?;
5377 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5378 let _value = self
5379 .session
5380 .client()
5381 .call(
5382 rpc_methods::SESSION_MCP_CANCELSAMPLINGEXECUTION,
5383 Some(wire_params),
5384 )
5385 .await?;
5386 Ok(serde_json::from_value(_value)?)
5387 }
5388
5389 /// Sets how environment-variable values supplied to MCP servers are resolved (direct or indirect).
5390 ///
5391 /// Wire method: `session.mcp.setEnvValueMode`.
5392 ///
5393 /// # Parameters
5394 ///
5395 /// * `params` - Mode controlling how MCP server env values are resolved (`direct` or `indirect`).
5396 ///
5397 /// # Returns
5398 ///
5399 /// Env-value mode recorded on the session after the update.
5400 ///
5401 /// <div class="warning">
5402 ///
5403 /// **Experimental.** This API is part of an experimental wire-protocol surface
5404 /// and may change or be removed in future SDK or CLI releases. Pin both the
5405 /// SDK and CLI versions if your code depends on it.
5406 ///
5407 /// </div>
5408 pub async fn set_env_value_mode(
5409 &self,
5410 params: McpSetEnvValueModeParams,
5411 ) -> Result<McpSetEnvValueModeResult, Error> {
5412 let mut wire_params = serde_json::to_value(params)?;
5413 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5414 let _value = self
5415 .session
5416 .client()
5417 .call(rpc_methods::SESSION_MCP_SETENVVALUEMODE, Some(wire_params))
5418 .await?;
5419 Ok(serde_json::from_value(_value)?)
5420 }
5421
5422 /// Removes the auto-managed `github` MCP server when present.
5423 ///
5424 /// Wire method: `session.mcp.removeGitHub`.
5425 ///
5426 /// # Returns
5427 ///
5428 /// Indicates whether the auto-managed `github` MCP server was removed (false when nothing to remove).
5429 ///
5430 /// <div class="warning">
5431 ///
5432 /// **Experimental.** This API is part of an experimental wire-protocol surface
5433 /// and may change or be removed in future SDK or CLI releases. Pin both the
5434 /// SDK and CLI versions if your code depends on it.
5435 ///
5436 /// </div>
5437 pub async fn remove_git_hub(&self) -> Result<McpRemoveGitHubResult, Error> {
5438 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5439 let _value = self
5440 .session
5441 .client()
5442 .call(rpc_methods::SESSION_MCP_REMOVEGITHUB, Some(wire_params))
5443 .await?;
5444 Ok(serde_json::from_value(_value)?)
5445 }
5446
5447 /// Configures the built-in GitHub MCP server for the session's current auth context.
5448 ///
5449 /// Wire method: `session.mcp.configureGitHub`.
5450 ///
5451 /// # Parameters
5452 ///
5453 /// * `params` - Opaque auth info used to configure GitHub MCP.
5454 ///
5455 /// # Returns
5456 ///
5457 /// Result of configuring GitHub MCP.
5458 ///
5459 /// <div class="warning">
5460 ///
5461 /// **Experimental.** This API is part of an experimental wire-protocol surface
5462 /// and may change or be removed in future SDK or CLI releases. Pin both the
5463 /// SDK and CLI versions if your code depends on it.
5464 ///
5465 /// </div>
5466 pub(crate) async fn configure_git_hub(
5467 &self,
5468 params: McpConfigureGitHubRequest,
5469 ) -> Result<McpConfigureGitHubResult, Error> {
5470 let mut wire_params = serde_json::to_value(params)?;
5471 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5472 let _value = self
5473 .session
5474 .client()
5475 .call(rpc_methods::SESSION_MCP_CONFIGUREGITHUB, Some(wire_params))
5476 .await?;
5477 Ok(serde_json::from_value(_value)?)
5478 }
5479
5480 /// Starts an individual MCP server on the live session. Omit `config` for a config-free start-by-name of an already-configured server (reuses the server's already-registered configuration); supply `config` to start from a caller-supplied configuration. 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.
5481 ///
5482 /// Wire method: `session.mcp.startServer`.
5483 ///
5484 /// # Parameters
5485 ///
5486 /// * `params` - Server name and optional configuration for an individual MCP server start. Omit `config` for a config-free start-by-name of an already-configured server.
5487 ///
5488 /// <div class="warning">
5489 ///
5490 /// **Experimental.** This API is part of an experimental wire-protocol surface
5491 /// and may change or be removed in future SDK or CLI releases. Pin both the
5492 /// SDK and CLI versions if your code depends on it.
5493 ///
5494 /// </div>
5495 pub async fn start_server(&self, params: McpStartServerRequest) -> Result<(), Error> {
5496 let mut wire_params = serde_json::to_value(params)?;
5497 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5498 let _value = self
5499 .session
5500 .client()
5501 .call(rpc_methods::SESSION_MCP_STARTSERVER, Some(wire_params))
5502 .await?;
5503 Ok(())
5504 }
5505
5506 /// 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.*`).
5507 ///
5508 /// Wire method: `session.mcp.restartServer`.
5509 ///
5510 /// # Parameters
5511 ///
5512 /// * `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.
5513 ///
5514 /// <div class="warning">
5515 ///
5516 /// **Experimental.** This API is part of an experimental wire-protocol surface
5517 /// and may change or be removed in future SDK or CLI releases. Pin both the
5518 /// SDK and CLI versions if your code depends on it.
5519 ///
5520 /// </div>
5521 pub async fn restart_server(&self, params: McpRestartServerRequest) -> Result<(), Error> {
5522 let mut wire_params = serde_json::to_value(params)?;
5523 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5524 let _value = self
5525 .session
5526 .client()
5527 .call(rpc_methods::SESSION_MCP_RESTARTSERVER, Some(wire_params))
5528 .await?;
5529 Ok(())
5530 }
5531
5532 /// Stops an individual MCP server on the session's host.
5533 ///
5534 /// Wire method: `session.mcp.stopServer`.
5535 ///
5536 /// # Parameters
5537 ///
5538 /// * `params` - Server name for an individual MCP server stop.
5539 ///
5540 /// <div class="warning">
5541 ///
5542 /// **Experimental.** This API is part of an experimental wire-protocol surface
5543 /// and may change or be removed in future SDK or CLI releases. Pin both the
5544 /// SDK and CLI versions if your code depends on it.
5545 ///
5546 /// </div>
5547 pub async fn stop_server(&self, params: McpStopServerRequest) -> Result<(), Error> {
5548 let mut wire_params = serde_json::to_value(params)?;
5549 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5550 let _value = self
5551 .session
5552 .client()
5553 .call(rpc_methods::SESSION_MCP_STOPSERVER, Some(wire_params))
5554 .await?;
5555 Ok(())
5556 }
5557
5558 /// 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.
5559 ///
5560 /// Wire method: `session.mcp.registerExternalClient`.
5561 ///
5562 /// # Parameters
5563 ///
5564 /// * `params` - Registration parameters for an external MCP client.
5565 ///
5566 /// <div class="warning">
5567 ///
5568 /// **Experimental.** This API is part of an experimental wire-protocol surface
5569 /// and may change or be removed in future SDK or CLI releases. Pin both the
5570 /// SDK and CLI versions if your code depends on it.
5571 ///
5572 /// </div>
5573 pub(crate) async fn register_external_client(
5574 &self,
5575 params: McpRegisterExternalClientRequest,
5576 ) -> Result<(), Error> {
5577 let mut wire_params = serde_json::to_value(params)?;
5578 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5579 let _value = self
5580 .session
5581 .client()
5582 .call(
5583 rpc_methods::SESSION_MCP_REGISTEREXTERNALCLIENT,
5584 Some(wire_params),
5585 )
5586 .await?;
5587 Ok(())
5588 }
5589
5590 /// 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.
5591 ///
5592 /// Wire method: `session.mcp.unregisterExternalClient`.
5593 ///
5594 /// # Parameters
5595 ///
5596 /// * `params` - Server name identifying the external client to remove.
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(crate) async fn unregister_external_client(
5606 &self,
5607 params: McpUnregisterExternalClientRequest,
5608 ) -> Result<(), 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(
5615 rpc_methods::SESSION_MCP_UNREGISTEREXTERNALCLIENT,
5616 Some(wire_params),
5617 )
5618 .await?;
5619 Ok(())
5620 }
5621
5622 /// Checks whether a named MCP server is currently running on the session's host.
5623 ///
5624 /// Wire method: `session.mcp.isServerRunning`.
5625 ///
5626 /// # Parameters
5627 ///
5628 /// * `params` - Server name to check running status for.
5629 ///
5630 /// # Returns
5631 ///
5632 /// Whether the named MCP server is running.
5633 ///
5634 /// <div class="warning">
5635 ///
5636 /// **Experimental.** This API is part of an experimental wire-protocol surface
5637 /// and may change or be removed in future SDK or CLI releases. Pin both the
5638 /// SDK and CLI versions if your code depends on it.
5639 ///
5640 /// </div>
5641 pub async fn is_server_running(
5642 &self,
5643 params: McpIsServerRunningRequest,
5644 ) -> Result<McpIsServerRunningResult, Error> {
5645 let mut wire_params = serde_json::to_value(params)?;
5646 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5647 let _value = self
5648 .session
5649 .client()
5650 .call(rpc_methods::SESSION_MCP_ISSERVERRUNNING, Some(wire_params))
5651 .await?;
5652 Ok(serde_json::from_value(_value)?)
5653 }
5654}
5655
5656/// `session.mcp.apps.*` RPCs.
5657#[derive(Clone, Copy)]
5658pub struct SessionRpcMcpApps<'a> {
5659 pub(crate) session: &'a Session,
5660}
5661
5662impl<'a> SessionRpcMcpApps<'a> {
5663 /// Fetch an MCP resource (typically a `ui://` MCP App bundle, per SEP-1865) from a connected server. Requires the `mcp-apps` session capability.
5664 ///
5665 /// Wire method: `session.mcp.apps.readResource`.
5666 ///
5667 /// # Parameters
5668 ///
5669 /// * `params` - MCP server and resource URI to fetch.
5670 ///
5671 /// # Returns
5672 ///
5673 /// Resource contents returned by the MCP server.
5674 ///
5675 /// <div class="warning">
5676 ///
5677 /// **Experimental.** This API is part of an experimental wire-protocol surface
5678 /// and may change or be removed in future SDK or CLI releases. Pin both the
5679 /// SDK and CLI versions if your code depends on it.
5680 ///
5681 /// </div>
5682 pub async fn read_resource(
5683 &self,
5684 params: McpAppsReadResourceRequest,
5685 ) -> Result<McpAppsReadResourceResult, Error> {
5686 let mut wire_params = serde_json::to_value(params)?;
5687 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5688 let _value = self
5689 .session
5690 .client()
5691 .call(
5692 rpc_methods::SESSION_MCP_APPS_READRESOURCE,
5693 Some(wire_params),
5694 )
5695 .await?;
5696 Ok(serde_json::from_value(_value)?)
5697 }
5698
5699 /// 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"`.
5700 ///
5701 /// Wire method: `session.mcp.apps.listTools`.
5702 ///
5703 /// # Parameters
5704 ///
5705 /// * `params` - MCP server to list app-callable tools for.
5706 ///
5707 /// # Returns
5708 ///
5709 /// App-callable tools from the named MCP server.
5710 ///
5711 /// <div class="warning">
5712 ///
5713 /// **Experimental.** This API is part of an experimental wire-protocol surface
5714 /// and may change or be removed in future SDK or CLI releases. Pin both the
5715 /// SDK and CLI versions if your code depends on it.
5716 ///
5717 /// </div>
5718 pub async fn list_tools(
5719 &self,
5720 params: McpAppsListToolsRequest,
5721 ) -> Result<McpAppsListToolsResult, Error> {
5722 let mut wire_params = serde_json::to_value(params)?;
5723 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5724 let _value = self
5725 .session
5726 .client()
5727 .call(rpc_methods::SESSION_MCP_APPS_LISTTOOLS, Some(wire_params))
5728 .await?;
5729 Ok(serde_json::from_value(_value)?)
5730 }
5731
5732 /// 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`.
5733 ///
5734 /// Wire method: `session.mcp.apps.callTool`.
5735 ///
5736 /// # Parameters
5737 ///
5738 /// * `params` - MCP server, tool name, and arguments to invoke from an MCP App view.
5739 ///
5740 /// # Returns
5741 ///
5742 /// Standard MCP CallToolResult
5743 ///
5744 /// <div class="warning">
5745 ///
5746 /// **Experimental.** This API is part of an experimental wire-protocol surface
5747 /// and may change or be removed in future SDK or CLI releases. Pin both the
5748 /// SDK and CLI versions if your code depends on it.
5749 ///
5750 /// </div>
5751 pub async fn call_tool(
5752 &self,
5753 params: McpAppsCallToolRequest,
5754 ) -> Result<SessionMcpAppsCallToolResult, Error> {
5755 let mut wire_params = serde_json::to_value(params)?;
5756 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5757 let _value = self
5758 .session
5759 .client()
5760 .call(rpc_methods::SESSION_MCP_APPS_CALLTOOL, Some(wire_params))
5761 .await?;
5762 Ok(serde_json::from_value(_value)?)
5763 }
5764
5765 /// 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.
5766 ///
5767 /// Wire method: `session.mcp.apps.setHostContext`.
5768 ///
5769 /// # Parameters
5770 ///
5771 /// * `params` - Host context to advertise to MCP App guests.
5772 ///
5773 /// <div class="warning">
5774 ///
5775 /// **Experimental.** This API is part of an experimental wire-protocol surface
5776 /// and may change or be removed in future SDK or CLI releases. Pin both the
5777 /// SDK and CLI versions if your code depends on it.
5778 ///
5779 /// </div>
5780 pub async fn set_host_context(
5781 &self,
5782 params: McpAppsSetHostContextRequest,
5783 ) -> Result<(), Error> {
5784 let mut wire_params = serde_json::to_value(params)?;
5785 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5786 let _value = self
5787 .session
5788 .client()
5789 .call(
5790 rpc_methods::SESSION_MCP_APPS_SETHOSTCONTEXT,
5791 Some(wire_params),
5792 )
5793 .await?;
5794 Ok(())
5795 }
5796
5797 /// Read the current host context advertised to MCP App guests.
5798 ///
5799 /// Wire method: `session.mcp.apps.getHostContext`.
5800 ///
5801 /// # Returns
5802 ///
5803 /// Current host context advertised to MCP App guests.
5804 ///
5805 /// <div class="warning">
5806 ///
5807 /// **Experimental.** This API is part of an experimental wire-protocol surface
5808 /// and may change or be removed in future SDK or CLI releases. Pin both the
5809 /// SDK and CLI versions if your code depends on it.
5810 ///
5811 /// </div>
5812 pub async fn get_host_context(&self) -> Result<McpAppsHostContext, Error> {
5813 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
5814 let _value = self
5815 .session
5816 .client()
5817 .call(
5818 rpc_methods::SESSION_MCP_APPS_GETHOSTCONTEXT,
5819 Some(wire_params),
5820 )
5821 .await?;
5822 Ok(serde_json::from_value(_value)?)
5823 }
5824
5825 /// 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.
5826 ///
5827 /// Wire method: `session.mcp.apps.diagnose`.
5828 ///
5829 /// # Parameters
5830 ///
5831 /// * `params` - MCP server to diagnose MCP Apps wiring for.
5832 ///
5833 /// # Returns
5834 ///
5835 /// Diagnostic snapshot of MCP Apps wiring for the named server.
5836 ///
5837 /// <div class="warning">
5838 ///
5839 /// **Experimental.** This API is part of an experimental wire-protocol surface
5840 /// and may change or be removed in future SDK or CLI releases. Pin both the
5841 /// SDK and CLI versions if your code depends on it.
5842 ///
5843 /// </div>
5844 pub async fn diagnose(
5845 &self,
5846 params: McpAppsDiagnoseRequest,
5847 ) -> Result<McpAppsDiagnoseResult, Error> {
5848 let mut wire_params = serde_json::to_value(params)?;
5849 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5850 let _value = self
5851 .session
5852 .client()
5853 .call(rpc_methods::SESSION_MCP_APPS_DIAGNOSE, Some(wire_params))
5854 .await?;
5855 Ok(serde_json::from_value(_value)?)
5856 }
5857}
5858
5859/// `session.mcp.headers.*` RPCs.
5860#[derive(Clone, Copy)]
5861pub struct SessionRpcMcpHeaders<'a> {
5862 pub(crate) session: &'a Session,
5863}
5864
5865impl<'a> SessionRpcMcpHeaders<'a> {
5866 /// 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.
5867 ///
5868 /// Wire method: `session.mcp.headers.handlePendingHeadersRefreshRequest`.
5869 ///
5870 /// # Parameters
5871 ///
5872 /// * `params` - MCP headers refresh request id and the host response.
5873 ///
5874 /// # Returns
5875 ///
5876 /// Indicates whether the pending MCP headers refresh response was accepted.
5877 ///
5878 /// <div class="warning">
5879 ///
5880 /// **Experimental.** This API is part of an experimental wire-protocol surface
5881 /// and may change or be removed in future SDK or CLI releases. Pin both the
5882 /// SDK and CLI versions if your code depends on it.
5883 ///
5884 /// </div>
5885 pub async fn handle_pending_headers_refresh_request(
5886 &self,
5887 params: McpHeadersHandlePendingHeadersRefreshRequestRequest,
5888 ) -> Result<McpHeadersHandlePendingHeadersRefreshRequestResult, Error> {
5889 let mut wire_params = serde_json::to_value(params)?;
5890 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5891 let _value = self
5892 .session
5893 .client()
5894 .call(
5895 rpc_methods::SESSION_MCP_HEADERS_HANDLEPENDINGHEADERSREFRESHREQUEST,
5896 Some(wire_params),
5897 )
5898 .await?;
5899 Ok(serde_json::from_value(_value)?)
5900 }
5901}
5902
5903/// `session.mcp.oauth.*` RPCs.
5904#[derive(Clone, Copy)]
5905pub struct SessionRpcMcpOauth<'a> {
5906 pub(crate) session: &'a Session,
5907}
5908
5909impl<'a> SessionRpcMcpOauth<'a> {
5910 /// 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.
5911 ///
5912 /// Wire method: `session.mcp.oauth.handlePendingRequest`.
5913 ///
5914 /// # Parameters
5915 ///
5916 /// * `params` - Pending MCP OAuth request ID and host-provided token or cancellation response.
5917 ///
5918 /// # Returns
5919 ///
5920 /// Indicates whether the pending MCP OAuth response was accepted.
5921 ///
5922 /// <div class="warning">
5923 ///
5924 /// **Experimental.** This API is part of an experimental wire-protocol surface
5925 /// and may change or be removed in future SDK or CLI releases. Pin both the
5926 /// SDK and CLI versions if your code depends on it.
5927 ///
5928 /// </div>
5929 pub async fn handle_pending_request(
5930 &self,
5931 params: McpOauthHandlePendingRequest,
5932 ) -> Result<McpOauthHandlePendingResult, Error> {
5933 let mut wire_params = serde_json::to_value(params)?;
5934 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5935 let _value = self
5936 .session
5937 .client()
5938 .call(
5939 rpc_methods::SESSION_MCP_OAUTH_HANDLEPENDINGREQUEST,
5940 Some(wire_params),
5941 )
5942 .await?;
5943 Ok(serde_json::from_value(_value)?)
5944 }
5945
5946 /// Starts OAuth authentication for a remote MCP server.
5947 ///
5948 /// Wire method: `session.mcp.oauth.login`.
5949 ///
5950 /// # Parameters
5951 ///
5952 /// * `params` - Remote MCP server name and optional overrides controlling reauthentication, OAuth client display name, callback success-page copy, and static OAuth client selection.
5953 ///
5954 /// # Returns
5955 ///
5956 /// OAuth authorization URL the caller should open, or empty when cached tokens already authenticated the server.
5957 ///
5958 /// <div class="warning">
5959 ///
5960 /// **Experimental.** This API is part of an experimental wire-protocol surface
5961 /// and may change or be removed in future SDK or CLI releases. Pin both the
5962 /// SDK and CLI versions if your code depends on it.
5963 ///
5964 /// </div>
5965 pub async fn login(&self, params: McpOauthLoginRequest) -> Result<McpOauthLoginResult, Error> {
5966 let mut wire_params = serde_json::to_value(params)?;
5967 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
5968 let _value = self
5969 .session
5970 .client()
5971 .call(rpc_methods::SESSION_MCP_OAUTH_LOGIN, Some(wire_params))
5972 .await?;
5973 Ok(serde_json::from_value(_value)?)
5974 }
5975
5976 /// Responds to a pending MCP OAuth authorization request by its request id.
5977 ///
5978 /// Wire method: `session.mcp.oauth.respond`.
5979 ///
5980 /// # Parameters
5981 ///
5982 /// * `params` - Pending MCP OAuth request id to respond to.
5983 ///
5984 /// # Returns
5985 ///
5986 /// Indicates whether the pending MCP OAuth response was accepted.
5987 ///
5988 /// <div class="warning">
5989 ///
5990 /// **Experimental.** This API is part of an experimental wire-protocol surface
5991 /// and may change or be removed in future SDK or CLI releases. Pin both the
5992 /// SDK and CLI versions if your code depends on it.
5993 ///
5994 /// </div>
5995 pub async fn respond(
5996 &self,
5997 params: McpOauthRespondRequest,
5998 ) -> Result<McpOauthRespondResult, Error> {
5999 let mut wire_params = serde_json::to_value(params)?;
6000 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6001 let _value = self
6002 .session
6003 .client()
6004 .call(rpc_methods::SESSION_MCP_OAUTH_RESPOND, Some(wire_params))
6005 .await?;
6006 Ok(serde_json::from_value(_value)?)
6007 }
6008}
6009
6010/// `session.mcp.resources.*` RPCs.
6011#[derive(Clone, Copy)]
6012pub struct SessionRpcMcpResources<'a> {
6013 pub(crate) session: &'a Session,
6014}
6015
6016impl<'a> SessionRpcMcpResources<'a> {
6017 /// Fetch an MCP resource from a connected server by URI (proxies MCP `resources/read`).
6018 ///
6019 /// Wire method: `session.mcp.resources.read`.
6020 ///
6021 /// # Parameters
6022 ///
6023 /// * `params` - MCP server and resource URI to fetch.
6024 ///
6025 /// # Returns
6026 ///
6027 /// Resource contents returned by the MCP server.
6028 ///
6029 /// <div class="warning">
6030 ///
6031 /// **Experimental.** This API is part of an experimental wire-protocol surface
6032 /// and may change or be removed in future SDK or CLI releases. Pin both the
6033 /// SDK and CLI versions if your code depends on it.
6034 ///
6035 /// </div>
6036 pub async fn read(
6037 &self,
6038 params: McpResourcesReadRequest,
6039 ) -> Result<McpResourcesReadResult, Error> {
6040 let mut wire_params = serde_json::to_value(params)?;
6041 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6042 let _value = self
6043 .session
6044 .client()
6045 .call(rpc_methods::SESSION_MCP_RESOURCES_READ, Some(wire_params))
6046 .await?;
6047 Ok(serde_json::from_value(_value)?)
6048 }
6049
6050 /// Enumerate one page of resources a connected MCP server exposes (proxies MCP `resources/list`). Pass `cursor` to continue from a prior result's `nextCursor`.
6051 ///
6052 /// Wire method: `session.mcp.resources.list`.
6053 ///
6054 /// # Parameters
6055 ///
6056 /// * `params` - MCP server whose resources to enumerate.
6057 ///
6058 /// # Returns
6059 ///
6060 /// One page of resources advertised by the named MCP server.
6061 ///
6062 /// <div class="warning">
6063 ///
6064 /// **Experimental.** This API is part of an experimental wire-protocol surface
6065 /// and may change or be removed in future SDK or CLI releases. Pin both the
6066 /// SDK and CLI versions if your code depends on it.
6067 ///
6068 /// </div>
6069 pub async fn list(
6070 &self,
6071 params: McpResourcesListRequest,
6072 ) -> Result<McpResourcesListResult, Error> {
6073 let mut wire_params = serde_json::to_value(params)?;
6074 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6075 let _value = self
6076 .session
6077 .client()
6078 .call(rpc_methods::SESSION_MCP_RESOURCES_LIST, Some(wire_params))
6079 .await?;
6080 Ok(serde_json::from_value(_value)?)
6081 }
6082
6083 /// 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`.
6084 ///
6085 /// Wire method: `session.mcp.resources.listTemplates`.
6086 ///
6087 /// # Parameters
6088 ///
6089 /// * `params` - MCP server whose resource templates to enumerate.
6090 ///
6091 /// # Returns
6092 ///
6093 /// One page of resource templates advertised by the named MCP server.
6094 ///
6095 /// <div class="warning">
6096 ///
6097 /// **Experimental.** This API is part of an experimental wire-protocol surface
6098 /// and may change or be removed in future SDK or CLI releases. Pin both the
6099 /// SDK and CLI versions if your code depends on it.
6100 ///
6101 /// </div>
6102 pub async fn list_templates(
6103 &self,
6104 params: McpResourcesListTemplatesRequest,
6105 ) -> Result<McpResourcesListTemplatesResult, Error> {
6106 let mut wire_params = serde_json::to_value(params)?;
6107 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6108 let _value = self
6109 .session
6110 .client()
6111 .call(
6112 rpc_methods::SESSION_MCP_RESOURCES_LISTTEMPLATES,
6113 Some(wire_params),
6114 )
6115 .await?;
6116 Ok(serde_json::from_value(_value)?)
6117 }
6118}
6119
6120/// `session.metadata.*` RPCs.
6121#[derive(Clone, Copy)]
6122pub struct SessionRpcMetadata<'a> {
6123 pub(crate) session: &'a Session,
6124}
6125
6126impl<'a> SessionRpcMetadata<'a> {
6127 /// Returns a snapshot of the session's identifying metadata, mode, agent, and remote info.
6128 ///
6129 /// Wire method: `session.metadata.snapshot`.
6130 ///
6131 /// # Returns
6132 ///
6133 /// Point-in-time snapshot of slow-changing session identifier and state fields
6134 ///
6135 /// <div class="warning">
6136 ///
6137 /// **Experimental.** This API is part of an experimental wire-protocol surface
6138 /// and may change or be removed in future SDK or CLI releases. Pin both the
6139 /// SDK and CLI versions if your code depends on it.
6140 ///
6141 /// </div>
6142 pub async fn snapshot(&self) -> Result<SessionMetadataSnapshot, Error> {
6143 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6144 let _value = self
6145 .session
6146 .client()
6147 .call(rpc_methods::SESSION_METADATA_SNAPSHOT, Some(wire_params))
6148 .await?;
6149 Ok(serde_json::from_value(_value)?)
6150 }
6151
6152 /// Reports whether the local session is currently processing user/agent messages.
6153 ///
6154 /// Wire method: `session.metadata.isProcessing`.
6155 ///
6156 /// # Returns
6157 ///
6158 /// Indicates whether the local session is currently processing a turn or background continuation.
6159 ///
6160 /// <div class="warning">
6161 ///
6162 /// **Experimental.** This API is part of an experimental wire-protocol surface
6163 /// and may change or be removed in future SDK or CLI releases. Pin both the
6164 /// SDK and CLI versions if your code depends on it.
6165 ///
6166 /// </div>
6167 pub async fn is_processing(&self) -> Result<MetadataIsProcessingResult, Error> {
6168 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6169 let _value = self
6170 .session
6171 .client()
6172 .call(
6173 rpc_methods::SESSION_METADATA_ISPROCESSING,
6174 Some(wire_params),
6175 )
6176 .await?;
6177 Ok(serde_json::from_value(_value)?)
6178 }
6179
6180 /// Returns a snapshot of activity flags for the session.
6181 ///
6182 /// Wire method: `session.metadata.activity`.
6183 ///
6184 /// # Returns
6185 ///
6186 /// Current activity flags for the session.
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 activity(&self) -> Result<SessionActivity, Error> {
6196 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6197 let _value = self
6198 .session
6199 .client()
6200 .call(rpc_methods::SESSION_METADATA_ACTIVITY, Some(wire_params))
6201 .await?;
6202 Ok(serde_json::from_value(_value)?)
6203 }
6204
6205 /// Returns the token breakdown for the session's current context window for a given model.
6206 ///
6207 /// Wire method: `session.metadata.contextInfo`.
6208 ///
6209 /// # Parameters
6210 ///
6211 /// * `params` - Model identifier and token limits used to compute the context-info breakdown.
6212 ///
6213 /// # Returns
6214 ///
6215 /// Token breakdown for the session's current context window, or null if uninitialized.
6216 ///
6217 /// <div class="warning">
6218 ///
6219 /// **Experimental.** This API is part of an experimental wire-protocol surface
6220 /// and may change or be removed in future SDK or CLI releases. Pin both the
6221 /// SDK and CLI versions if your code depends on it.
6222 ///
6223 /// </div>
6224 pub async fn context_info(
6225 &self,
6226 params: MetadataContextInfoRequest,
6227 ) -> Result<MetadataContextInfoResult, Error> {
6228 let mut wire_params = serde_json::to_value(params)?;
6229 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6230 let _value = self
6231 .session
6232 .client()
6233 .call(rpc_methods::SESSION_METADATA_CONTEXTINFO, Some(wire_params))
6234 .await?;
6235 Ok(serde_json::from_value(_value)?)
6236 }
6237
6238 /// 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.
6239 ///
6240 /// Wire method: `session.metadata.getContextAttribution`.
6241 ///
6242 /// # Returns
6243 ///
6244 /// Per-source attribution breakdown for the session's current context window, or null if uninitialized.
6245 ///
6246 /// <div class="warning">
6247 ///
6248 /// **Experimental.** This API is part of an experimental wire-protocol surface
6249 /// and may change or be removed in future SDK or CLI releases. Pin both the
6250 /// SDK and CLI versions if your code depends on it.
6251 ///
6252 /// </div>
6253 pub async fn get_context_attribution(&self) -> Result<MetadataContextAttributionResult, Error> {
6254 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6255 let _value = self
6256 .session
6257 .client()
6258 .call(
6259 rpc_methods::SESSION_METADATA_GETCONTEXTATTRIBUTION,
6260 Some(wire_params),
6261 )
6262 .await?;
6263 Ok(serde_json::from_value(_value)?)
6264 }
6265
6266 /// 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.
6267 ///
6268 /// Wire method: `session.metadata.getContextHeaviestMessages`.
6269 ///
6270 /// # Parameters
6271 ///
6272 /// * `params` - Parameters for the heaviest-messages query.
6273 ///
6274 /// # Returns
6275 ///
6276 /// The heaviest individual messages in the session's context window, most-expensive first.
6277 ///
6278 /// <div class="warning">
6279 ///
6280 /// **Experimental.** This API is part of an experimental wire-protocol surface
6281 /// and may change or be removed in future SDK or CLI releases. Pin both the
6282 /// SDK and CLI versions if your code depends on it.
6283 ///
6284 /// </div>
6285 pub async fn get_context_heaviest_messages(
6286 &self,
6287 params: MetadataContextHeaviestMessagesRequest,
6288 ) -> Result<MetadataContextHeaviestMessagesResult, Error> {
6289 let mut wire_params = serde_json::to_value(params)?;
6290 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6291 let _value = self
6292 .session
6293 .client()
6294 .call(
6295 rpc_methods::SESSION_METADATA_GETCONTEXTHEAVIESTMESSAGES,
6296 Some(wire_params),
6297 )
6298 .await?;
6299 Ok(serde_json::from_value(_value)?)
6300 }
6301
6302 /// 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.
6303 ///
6304 /// Wire method: `session.metadata.recordContextChange`.
6305 ///
6306 /// # Parameters
6307 ///
6308 /// * `params` - Updated working-directory/git context to record on the session.
6309 ///
6310 /// # Returns
6311 ///
6312 /// 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.
6313 ///
6314 /// <div class="warning">
6315 ///
6316 /// **Experimental.** This API is part of an experimental wire-protocol surface
6317 /// and may change or be removed in future SDK or CLI releases. Pin both the
6318 /// SDK and CLI versions if your code depends on it.
6319 ///
6320 /// </div>
6321 pub async fn record_context_change(
6322 &self,
6323 params: MetadataRecordContextChangeRequest,
6324 ) -> Result<MetadataRecordContextChangeResult, Error> {
6325 let mut wire_params = serde_json::to_value(params)?;
6326 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6327 let _value = self
6328 .session
6329 .client()
6330 .call(
6331 rpc_methods::SESSION_METADATA_RECORDCONTEXTCHANGE,
6332 Some(wire_params),
6333 )
6334 .await?;
6335 Ok(serde_json::from_value(_value)?)
6336 }
6337
6338 /// 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.
6339 ///
6340 /// Wire method: `session.metadata.setWorkingDirectory`.
6341 ///
6342 /// # Parameters
6343 ///
6344 /// * `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.
6345 ///
6346 /// # Returns
6347 ///
6348 /// 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.
6349 ///
6350 /// <div class="warning">
6351 ///
6352 /// **Experimental.** This API is part of an experimental wire-protocol surface
6353 /// and may change or be removed in future SDK or CLI releases. Pin both the
6354 /// SDK and CLI versions if your code depends on it.
6355 ///
6356 /// </div>
6357 pub async fn set_working_directory(
6358 &self,
6359 params: MetadataSetWorkingDirectoryRequest,
6360 ) -> Result<MetadataSetWorkingDirectoryResult, Error> {
6361 let mut wire_params = serde_json::to_value(params)?;
6362 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6363 let _value = self
6364 .session
6365 .client()
6366 .call(
6367 rpc_methods::SESSION_METADATA_SETWORKINGDIRECTORY,
6368 Some(wire_params),
6369 )
6370 .await?;
6371 Ok(serde_json::from_value(_value)?)
6372 }
6373
6374 /// Re-tokenizes the session's existing messages against a model and returns aggregate token totals.
6375 ///
6376 /// Wire method: `session.metadata.recomputeContextTokens`.
6377 ///
6378 /// # Parameters
6379 ///
6380 /// * `params` - Model identifier to use when re-tokenizing the session's existing messages.
6381 ///
6382 /// # Returns
6383 ///
6384 /// 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.
6385 ///
6386 /// <div class="warning">
6387 ///
6388 /// **Experimental.** This API is part of an experimental wire-protocol surface
6389 /// and may change or be removed in future SDK or CLI releases. Pin both the
6390 /// SDK and CLI versions if your code depends on it.
6391 ///
6392 /// </div>
6393 pub async fn recompute_context_tokens(
6394 &self,
6395 params: MetadataRecomputeContextTokensRequest,
6396 ) -> Result<MetadataRecomputeContextTokensResult, Error> {
6397 let mut wire_params = serde_json::to_value(params)?;
6398 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6399 let _value = self
6400 .session
6401 .client()
6402 .call(
6403 rpc_methods::SESSION_METADATA_RECOMPUTECONTEXTTOKENS,
6404 Some(wire_params),
6405 )
6406 .await?;
6407 Ok(serde_json::from_value(_value)?)
6408 }
6409}
6410
6411/// `session.mode.*` RPCs.
6412#[derive(Clone, Copy)]
6413pub struct SessionRpcMode<'a> {
6414 pub(crate) session: &'a Session,
6415}
6416
6417impl<'a> SessionRpcMode<'a> {
6418 /// Gets the current agent interaction mode.
6419 ///
6420 /// Wire method: `session.mode.get`.
6421 ///
6422 /// # Returns
6423 ///
6424 /// The session mode the agent is operating in
6425 ///
6426 /// <div class="warning">
6427 ///
6428 /// **Experimental.** This API is part of an experimental wire-protocol surface
6429 /// and may change or be removed in future SDK or CLI releases. Pin both the
6430 /// SDK and CLI versions if your code depends on it.
6431 ///
6432 /// </div>
6433 pub async fn get(&self) -> Result<SessionMode, Error> {
6434 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6435 let _value = self
6436 .session
6437 .client()
6438 .call(rpc_methods::SESSION_MODE_GET, Some(wire_params))
6439 .await?;
6440 Ok(serde_json::from_value(_value)?)
6441 }
6442
6443 /// Sets the current agent interaction mode.
6444 ///
6445 /// Wire method: `session.mode.set`.
6446 ///
6447 /// # Parameters
6448 ///
6449 /// * `params` - Agent interaction mode to apply to the session.
6450 ///
6451 /// <div class="warning">
6452 ///
6453 /// **Experimental.** This API is part of an experimental wire-protocol surface
6454 /// and may change or be removed in future SDK or CLI releases. Pin both the
6455 /// SDK and CLI versions if your code depends on it.
6456 ///
6457 /// </div>
6458 pub async fn set(&self, params: ModeSetRequest) -> Result<(), Error> {
6459 let mut wire_params = serde_json::to_value(params)?;
6460 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6461 let _value = self
6462 .session
6463 .client()
6464 .call(rpc_methods::SESSION_MODE_SET, Some(wire_params))
6465 .await?;
6466 Ok(())
6467 }
6468}
6469
6470/// `session.model.*` RPCs.
6471#[derive(Clone, Copy)]
6472pub struct SessionRpcModel<'a> {
6473 pub(crate) session: &'a Session,
6474}
6475
6476impl<'a> SessionRpcModel<'a> {
6477 /// Gets the currently selected model for the session.
6478 ///
6479 /// Wire method: `session.model.getCurrent`.
6480 ///
6481 /// # Returns
6482 ///
6483 /// 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.
6484 ///
6485 /// <div class="warning">
6486 ///
6487 /// **Experimental.** This API is part of an experimental wire-protocol surface
6488 /// and may change or be removed in future SDK or CLI releases. Pin both the
6489 /// SDK and CLI versions if your code depends on it.
6490 ///
6491 /// </div>
6492 pub async fn get_current(&self) -> Result<CurrentModel, Error> {
6493 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6494 let _value = self
6495 .session
6496 .client()
6497 .call(rpc_methods::SESSION_MODEL_GETCURRENT, Some(wire_params))
6498 .await?;
6499 Ok(serde_json::from_value(_value)?)
6500 }
6501
6502 /// Switches the session to a model and optional reasoning configuration.
6503 ///
6504 /// Wire method: `session.model.switchTo`.
6505 ///
6506 /// # Parameters
6507 ///
6508 /// * `params` - Target model identifier and optional reasoning effort, summary, capability overrides, and context tier.
6509 ///
6510 /// # Returns
6511 ///
6512 /// The model identifier active on the session after the switch.
6513 ///
6514 /// <div class="warning">
6515 ///
6516 /// **Experimental.** This API is part of an experimental wire-protocol surface
6517 /// and may change or be removed in future SDK or CLI releases. Pin both the
6518 /// SDK and CLI versions if your code depends on it.
6519 ///
6520 /// </div>
6521 pub async fn switch_to(
6522 &self,
6523 params: ModelSwitchToRequest,
6524 ) -> Result<ModelSwitchToResult, Error> {
6525 let mut wire_params = serde_json::to_value(params)?;
6526 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6527 let _value = self
6528 .session
6529 .client()
6530 .call(rpc_methods::SESSION_MODEL_SWITCHTO, Some(wire_params))
6531 .await?;
6532 Ok(serde_json::from_value(_value)?)
6533 }
6534
6535 /// Updates the session's reasoning effort without changing the selected model.
6536 ///
6537 /// Wire method: `session.model.setReasoningEffort`.
6538 ///
6539 /// # Parameters
6540 ///
6541 /// * `params` - Reasoning effort level to apply to the currently selected model.
6542 ///
6543 /// # Returns
6544 ///
6545 /// 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.
6546 ///
6547 /// <div class="warning">
6548 ///
6549 /// **Experimental.** This API is part of an experimental wire-protocol surface
6550 /// and may change or be removed in future SDK or CLI releases. Pin both the
6551 /// SDK and CLI versions if your code depends on it.
6552 ///
6553 /// </div>
6554 pub async fn set_reasoning_effort(
6555 &self,
6556 params: ModelSetReasoningEffortRequest,
6557 ) -> Result<ModelSetReasoningEffortResult, Error> {
6558 let mut wire_params = serde_json::to_value(params)?;
6559 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6560 let _value = self
6561 .session
6562 .client()
6563 .call(
6564 rpc_methods::SESSION_MODEL_SETREASONINGEFFORT,
6565 Some(wire_params),
6566 )
6567 .await?;
6568 Ok(serde_json::from_value(_value)?)
6569 }
6570
6571 /// 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.
6572 ///
6573 /// Wire method: `session.model.list`.
6574 ///
6575 /// # Returns
6576 ///
6577 /// The list of models available to this session.
6578 ///
6579 /// <div class="warning">
6580 ///
6581 /// **Experimental.** This API is part of an experimental wire-protocol surface
6582 /// and may change or be removed in future SDK or CLI releases. Pin both the
6583 /// SDK and CLI versions if your code depends on it.
6584 ///
6585 /// </div>
6586 pub async fn list(&self) -> Result<SessionModelList, Error> {
6587 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6588 let _value = self
6589 .session
6590 .client()
6591 .call(rpc_methods::SESSION_MODEL_LIST, Some(wire_params))
6592 .await?;
6593 Ok(serde_json::from_value(_value)?)
6594 }
6595
6596 /// 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.
6597 ///
6598 /// Wire method: `session.model.list`.
6599 ///
6600 /// # Parameters
6601 ///
6602 /// * `params` - Optional listing options.
6603 ///
6604 /// # Returns
6605 ///
6606 /// The list of models available to this session.
6607 ///
6608 /// <div class="warning">
6609 ///
6610 /// **Experimental.** This API is part of an experimental wire-protocol surface
6611 /// and may change or be removed in future SDK or CLI releases. Pin both the
6612 /// SDK and CLI versions if your code depends on it.
6613 ///
6614 /// </div>
6615 pub async fn list_with_params(
6616 &self,
6617 params: ModelListRequest,
6618 ) -> Result<SessionModelList, Error> {
6619 let mut wire_params = serde_json::to_value(params)?;
6620 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6621 let _value = self
6622 .session
6623 .client()
6624 .call(rpc_methods::SESSION_MODEL_LIST, Some(wire_params))
6625 .await?;
6626 Ok(serde_json::from_value(_value)?)
6627 }
6628}
6629
6630/// `session.name.*` RPCs.
6631#[derive(Clone, Copy)]
6632pub struct SessionRpcName<'a> {
6633 pub(crate) session: &'a Session,
6634}
6635
6636impl<'a> SessionRpcName<'a> {
6637 /// Gets the session's friendly name.
6638 ///
6639 /// Wire method: `session.name.get`.
6640 ///
6641 /// # Returns
6642 ///
6643 /// The session's friendly name, or null when not yet set.
6644 ///
6645 /// <div class="warning">
6646 ///
6647 /// **Experimental.** This API is part of an experimental wire-protocol surface
6648 /// and may change or be removed in future SDK or CLI releases. Pin both the
6649 /// SDK and CLI versions if your code depends on it.
6650 ///
6651 /// </div>
6652 pub async fn get(&self) -> Result<NameGetResult, Error> {
6653 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6654 let _value = self
6655 .session
6656 .client()
6657 .call(rpc_methods::SESSION_NAME_GET, Some(wire_params))
6658 .await?;
6659 Ok(serde_json::from_value(_value)?)
6660 }
6661
6662 /// Sets the session's friendly name.
6663 ///
6664 /// Wire method: `session.name.set`.
6665 ///
6666 /// # Parameters
6667 ///
6668 /// * `params` - New friendly name to apply to the session.
6669 ///
6670 /// <div class="warning">
6671 ///
6672 /// **Experimental.** This API is part of an experimental wire-protocol surface
6673 /// and may change or be removed in future SDK or CLI releases. Pin both the
6674 /// SDK and CLI versions if your code depends on it.
6675 ///
6676 /// </div>
6677 pub async fn set(&self, params: NameSetRequest) -> Result<(), Error> {
6678 let mut wire_params = serde_json::to_value(params)?;
6679 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6680 let _value = self
6681 .session
6682 .client()
6683 .call(rpc_methods::SESSION_NAME_SET, Some(wire_params))
6684 .await?;
6685 Ok(())
6686 }
6687
6688 /// Persists an auto-generated session summary as the session's name when no user-set name exists.
6689 ///
6690 /// Wire method: `session.name.setAuto`.
6691 ///
6692 /// # Parameters
6693 ///
6694 /// * `params` - Auto-generated session summary to apply as the session's name when no user-set name exists.
6695 ///
6696 /// # Returns
6697 ///
6698 /// Indicates whether the auto-generated summary was applied as the session's name.
6699 ///
6700 /// <div class="warning">
6701 ///
6702 /// **Experimental.** This API is part of an experimental wire-protocol surface
6703 /// and may change or be removed in future SDK or CLI releases. Pin both the
6704 /// SDK and CLI versions if your code depends on it.
6705 ///
6706 /// </div>
6707 pub async fn set_auto(&self, params: NameSetAutoRequest) -> Result<NameSetAutoResult, Error> {
6708 let mut wire_params = serde_json::to_value(params)?;
6709 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6710 let _value = self
6711 .session
6712 .client()
6713 .call(rpc_methods::SESSION_NAME_SETAUTO, Some(wire_params))
6714 .await?;
6715 Ok(serde_json::from_value(_value)?)
6716 }
6717}
6718
6719/// `session.options.*` RPCs.
6720#[derive(Clone, Copy)]
6721pub struct SessionRpcOptions<'a> {
6722 pub(crate) session: &'a Session,
6723}
6724
6725impl<'a> SessionRpcOptions<'a> {
6726 /// Patches the genuinely-mutable subset of session options.
6727 ///
6728 /// Wire method: `session.options.update`.
6729 ///
6730 /// # Parameters
6731 ///
6732 /// * `params` - Patch of mutable session options to apply to the running session.
6733 ///
6734 /// # Returns
6735 ///
6736 /// Indicates whether the session options patch was applied successfully.
6737 ///
6738 /// <div class="warning">
6739 ///
6740 /// **Experimental.** This API is part of an experimental wire-protocol surface
6741 /// and may change or be removed in future SDK or CLI releases. Pin both the
6742 /// SDK and CLI versions if your code depends on it.
6743 ///
6744 /// </div>
6745 pub async fn update(
6746 &self,
6747 params: SessionUpdateOptionsParams,
6748 ) -> Result<SessionUpdateOptionsResult, Error> {
6749 let mut wire_params = serde_json::to_value(params)?;
6750 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6751 let _value = self
6752 .session
6753 .client()
6754 .call(rpc_methods::SESSION_OPTIONS_UPDATE, Some(wire_params))
6755 .await?;
6756 Ok(serde_json::from_value(_value)?)
6757 }
6758}
6759
6760/// `session.permissions.*` RPCs.
6761#[derive(Clone, Copy)]
6762pub struct SessionRpcPermissions<'a> {
6763 pub(crate) session: &'a Session,
6764}
6765
6766impl<'a> SessionRpcPermissions<'a> {
6767 /// `session.permissions.folderTrust.*` sub-namespace.
6768 pub fn folder_trust(&self) -> SessionRpcPermissionsFolderTrust<'a> {
6769 SessionRpcPermissionsFolderTrust {
6770 session: self.session,
6771 }
6772 }
6773
6774 /// `session.permissions.locations.*` sub-namespace.
6775 pub fn locations(&self) -> SessionRpcPermissionsLocations<'a> {
6776 SessionRpcPermissionsLocations {
6777 session: self.session,
6778 }
6779 }
6780
6781 /// `session.permissions.paths.*` sub-namespace.
6782 pub fn paths(&self) -> SessionRpcPermissionsPaths<'a> {
6783 SessionRpcPermissionsPaths {
6784 session: self.session,
6785 }
6786 }
6787
6788 /// `session.permissions.urls.*` sub-namespace.
6789 pub fn urls(&self) -> SessionRpcPermissionsUrls<'a> {
6790 SessionRpcPermissionsUrls {
6791 session: self.session,
6792 }
6793 }
6794
6795 /// Replaces selected permission policy fields (rules, paths, URLs, exclusions, allow-all flags) on the session.
6796 ///
6797 /// Wire method: `session.permissions.configure`.
6798 ///
6799 /// # Parameters
6800 ///
6801 /// * `params` - Patch of permission policy fields to apply (omit a field to leave it unchanged).
6802 ///
6803 /// # Returns
6804 ///
6805 /// Indicates whether the operation succeeded.
6806 ///
6807 /// <div class="warning">
6808 ///
6809 /// **Experimental.** This API is part of an experimental wire-protocol surface
6810 /// and may change or be removed in future SDK or CLI releases. Pin both the
6811 /// SDK and CLI versions if your code depends on it.
6812 ///
6813 /// </div>
6814 pub async fn configure(
6815 &self,
6816 params: PermissionsConfigureParams,
6817 ) -> Result<PermissionsConfigureResult, Error> {
6818 let mut wire_params = serde_json::to_value(params)?;
6819 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6820 let _value = self
6821 .session
6822 .client()
6823 .call(
6824 rpc_methods::SESSION_PERMISSIONS_CONFIGURE,
6825 Some(wire_params),
6826 )
6827 .await?;
6828 Ok(serde_json::from_value(_value)?)
6829 }
6830
6831 /// Provides a decision for a pending tool permission request.
6832 ///
6833 /// Wire method: `session.permissions.handlePendingPermissionRequest`.
6834 ///
6835 /// # Parameters
6836 ///
6837 /// * `params` - Pending permission request ID and the decision to apply (approve/reject and scope).
6838 ///
6839 /// # Returns
6840 ///
6841 /// Indicates whether the permission decision was applied; false when the request was already resolved.
6842 ///
6843 /// <div class="warning">
6844 ///
6845 /// **Experimental.** This API is part of an experimental wire-protocol surface
6846 /// and may change or be removed in future SDK or CLI releases. Pin both the
6847 /// SDK and CLI versions if your code depends on it.
6848 ///
6849 /// </div>
6850 pub async fn handle_pending_permission_request(
6851 &self,
6852 params: PermissionDecisionRequest,
6853 ) -> Result<PermissionRequestResult, Error> {
6854 let mut wire_params = serde_json::to_value(params)?;
6855 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6856 let _value = self
6857 .session
6858 .client()
6859 .call(
6860 rpc_methods::SESSION_PERMISSIONS_HANDLEPENDINGPERMISSIONREQUEST,
6861 Some(wire_params),
6862 )
6863 .await?;
6864 Ok(serde_json::from_value(_value)?)
6865 }
6866
6867 /// Reconstructs the set of pending tool permission requests from the session's event history.
6868 ///
6869 /// Wire method: `session.permissions.pendingRequests`.
6870 ///
6871 /// # Returns
6872 ///
6873 /// List of pending permission requests reconstructed from event history.
6874 ///
6875 /// <div class="warning">
6876 ///
6877 /// **Experimental.** This API is part of an experimental wire-protocol surface
6878 /// and may change or be removed in future SDK or CLI releases. Pin both the
6879 /// SDK and CLI versions if your code depends on it.
6880 ///
6881 /// </div>
6882 pub async fn pending_requests(&self) -> Result<PendingPermissionRequestList, Error> {
6883 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6884 let _value = self
6885 .session
6886 .client()
6887 .call(
6888 rpc_methods::SESSION_PERMISSIONS_PENDINGREQUESTS,
6889 Some(wire_params),
6890 )
6891 .await?;
6892 Ok(serde_json::from_value(_value)?)
6893 }
6894
6895 /// Enables or disables automatic approval of tool permission requests for the session.
6896 ///
6897 /// Wire method: `session.permissions.setApproveAll`.
6898 ///
6899 /// # Parameters
6900 ///
6901 /// * `params` - Allow-all toggle for tool permission requests, with an optional telemetry source.
6902 ///
6903 /// # Returns
6904 ///
6905 /// Indicates whether the operation succeeded.
6906 ///
6907 /// <div class="warning">
6908 ///
6909 /// **Experimental.** This API is part of an experimental wire-protocol surface
6910 /// and may change or be removed in future SDK or CLI releases. Pin both the
6911 /// SDK and CLI versions if your code depends on it.
6912 ///
6913 /// </div>
6914 pub async fn set_approve_all(
6915 &self,
6916 params: PermissionsSetApproveAllRequest,
6917 ) -> Result<PermissionsSetApproveAllResult, Error> {
6918 let mut wire_params = serde_json::to_value(params)?;
6919 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6920 let _value = self
6921 .session
6922 .client()
6923 .call(
6924 rpc_methods::SESSION_PERMISSIONS_SETAPPROVEALL,
6925 Some(wire_params),
6926 )
6927 .await?;
6928 Ok(serde_json::from_value(_value)?)
6929 }
6930
6931 /// 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.
6932 ///
6933 /// Wire method: `session.permissions.setAllowAll`.
6934 ///
6935 /// # Parameters
6936 ///
6937 /// * `params` - Allow-all mode to apply for the session.
6938 ///
6939 /// # Returns
6940 ///
6941 /// Indicates whether the operation succeeded and reports the post-mutation state.
6942 ///
6943 /// <div class="warning">
6944 ///
6945 /// **Experimental.** This API is part of an experimental wire-protocol surface
6946 /// and may change or be removed in future SDK or CLI releases. Pin both the
6947 /// SDK and CLI versions if your code depends on it.
6948 ///
6949 /// </div>
6950 pub async fn set_allow_all(
6951 &self,
6952 params: PermissionsSetAllowAllRequest,
6953 ) -> Result<AllowAllPermissionSetResult, Error> {
6954 let mut wire_params = serde_json::to_value(params)?;
6955 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
6956 let _value = self
6957 .session
6958 .client()
6959 .call(
6960 rpc_methods::SESSION_PERMISSIONS_SETALLOWALL,
6961 Some(wire_params),
6962 )
6963 .await?;
6964 Ok(serde_json::from_value(_value)?)
6965 }
6966
6967 /// Returns the current allow-all permission mode for the session.
6968 ///
6969 /// Wire method: `session.permissions.getAllowAll`.
6970 ///
6971 /// # Returns
6972 ///
6973 /// Current allow-all permission mode.
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 get_allow_all(&self) -> Result<AllowAllPermissionState, Error> {
6983 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
6984 let _value = self
6985 .session
6986 .client()
6987 .call(
6988 rpc_methods::SESSION_PERMISSIONS_GETALLOWALL,
6989 Some(wire_params),
6990 )
6991 .await?;
6992 Ok(serde_json::from_value(_value)?)
6993 }
6994
6995 /// Adds or removes session-scoped or location-scoped permission rules.
6996 ///
6997 /// Wire method: `session.permissions.modifyRules`.
6998 ///
6999 /// # Parameters
7000 ///
7001 /// * `params` - Scope and add/remove instructions for modifying session- or location-scoped permission rules.
7002 ///
7003 /// # Returns
7004 ///
7005 /// Indicates whether the operation succeeded.
7006 ///
7007 /// <div class="warning">
7008 ///
7009 /// **Experimental.** This API is part of an experimental wire-protocol surface
7010 /// and may change or be removed in future SDK or CLI releases. Pin both the
7011 /// SDK and CLI versions if your code depends on it.
7012 ///
7013 /// </div>
7014 pub async fn modify_rules(
7015 &self,
7016 params: PermissionsModifyRulesParams,
7017 ) -> Result<PermissionsModifyRulesResult, Error> {
7018 let mut wire_params = serde_json::to_value(params)?;
7019 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7020 let _value = self
7021 .session
7022 .client()
7023 .call(
7024 rpc_methods::SESSION_PERMISSIONS_MODIFYRULES,
7025 Some(wire_params),
7026 )
7027 .await?;
7028 Ok(serde_json::from_value(_value)?)
7029 }
7030
7031 /// Sets whether the client wants permission prompts bridged into session events.
7032 ///
7033 /// Wire method: `session.permissions.setRequired`.
7034 ///
7035 /// # Parameters
7036 ///
7037 /// * `params` - Toggles whether permission prompts should be bridged into session events for this client.
7038 ///
7039 /// # Returns
7040 ///
7041 /// Indicates whether the operation succeeded.
7042 ///
7043 /// <div class="warning">
7044 ///
7045 /// **Experimental.** This API is part of an experimental wire-protocol surface
7046 /// and may change or be removed in future SDK or CLI releases. Pin both the
7047 /// SDK and CLI versions if your code depends on it.
7048 ///
7049 /// </div>
7050 pub async fn set_required(
7051 &self,
7052 params: PermissionsSetRequiredRequest,
7053 ) -> Result<PermissionsSetRequiredResult, Error> {
7054 let mut wire_params = serde_json::to_value(params)?;
7055 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7056 let _value = self
7057 .session
7058 .client()
7059 .call(
7060 rpc_methods::SESSION_PERMISSIONS_SETREQUIRED,
7061 Some(wire_params),
7062 )
7063 .await?;
7064 Ok(serde_json::from_value(_value)?)
7065 }
7066
7067 /// Clears session-scoped tool permission approvals.
7068 ///
7069 /// Wire method: `session.permissions.resetSessionApprovals`.
7070 ///
7071 /// # Parameters
7072 ///
7073 /// * `params` - Clears session-scoped tool permission approvals, and optionally the location-scoped ones.
7074 ///
7075 /// # Returns
7076 ///
7077 /// Indicates whether the operation succeeded.
7078 ///
7079 /// <div class="warning">
7080 ///
7081 /// **Experimental.** This API is part of an experimental wire-protocol surface
7082 /// and may change or be removed in future SDK or CLI releases. Pin both the
7083 /// SDK and CLI versions if your code depends on it.
7084 ///
7085 /// </div>
7086 pub async fn reset_session_approvals(
7087 &self,
7088 params: PermissionsResetSessionApprovalsRequest,
7089 ) -> Result<PermissionsResetSessionApprovalsResult, Error> {
7090 let mut wire_params = serde_json::to_value(params)?;
7091 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7092 let _value = self
7093 .session
7094 .client()
7095 .call(
7096 rpc_methods::SESSION_PERMISSIONS_RESETSESSIONAPPROVALS,
7097 Some(wire_params),
7098 )
7099 .await?;
7100 Ok(serde_json::from_value(_value)?)
7101 }
7102
7103 /// Notifies the runtime that a permission prompt UI has been shown to the user.
7104 ///
7105 /// Wire method: `session.permissions.notifyPromptShown`.
7106 ///
7107 /// # Parameters
7108 ///
7109 /// * `params` - Notification payload describing the permission prompt that the client just rendered.
7110 ///
7111 /// # Returns
7112 ///
7113 /// Indicates whether the operation succeeded.
7114 ///
7115 /// <div class="warning">
7116 ///
7117 /// **Experimental.** This API is part of an experimental wire-protocol surface
7118 /// and may change or be removed in future SDK or CLI releases. Pin both the
7119 /// SDK and CLI versions if your code depends on it.
7120 ///
7121 /// </div>
7122 pub async fn notify_prompt_shown(
7123 &self,
7124 params: PermissionPromptShownNotification,
7125 ) -> Result<PermissionsNotifyPromptShownResult, Error> {
7126 let mut wire_params = serde_json::to_value(params)?;
7127 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7128 let _value = self
7129 .session
7130 .client()
7131 .call(
7132 rpc_methods::SESSION_PERMISSIONS_NOTIFYPROMPTSHOWN,
7133 Some(wire_params),
7134 )
7135 .await?;
7136 Ok(serde_json::from_value(_value)?)
7137 }
7138}
7139
7140/// `session.permissions.folderTrust.*` RPCs.
7141#[derive(Clone, Copy)]
7142pub struct SessionRpcPermissionsFolderTrust<'a> {
7143 pub(crate) session: &'a Session,
7144}
7145
7146impl<'a> SessionRpcPermissionsFolderTrust<'a> {
7147 /// Reports whether a folder is trusted according to the user's folder trust state.
7148 ///
7149 /// Wire method: `session.permissions.folderTrust.isTrusted`.
7150 ///
7151 /// # Parameters
7152 ///
7153 /// * `params` - Folder path to check for trust.
7154 ///
7155 /// # Returns
7156 ///
7157 /// Folder trust check result.
7158 ///
7159 /// <div class="warning">
7160 ///
7161 /// **Experimental.** This API is part of an experimental wire-protocol surface
7162 /// and may change or be removed in future SDK or CLI releases. Pin both the
7163 /// SDK and CLI versions if your code depends on it.
7164 ///
7165 /// </div>
7166 pub async fn is_trusted(
7167 &self,
7168 params: FolderTrustCheckParams,
7169 ) -> Result<FolderTrustCheckResult, Error> {
7170 let mut wire_params = serde_json::to_value(params)?;
7171 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7172 let _value = self
7173 .session
7174 .client()
7175 .call(
7176 rpc_methods::SESSION_PERMISSIONS_FOLDERTRUST_ISTRUSTED,
7177 Some(wire_params),
7178 )
7179 .await?;
7180 Ok(serde_json::from_value(_value)?)
7181 }
7182
7183 /// Adds a folder to the user's trusted folders list.
7184 ///
7185 /// Wire method: `session.permissions.folderTrust.addTrusted`.
7186 ///
7187 /// # Parameters
7188 ///
7189 /// * `params` - Folder path to add to trusted folders.
7190 ///
7191 /// # Returns
7192 ///
7193 /// Indicates whether the operation succeeded.
7194 ///
7195 /// <div class="warning">
7196 ///
7197 /// **Experimental.** This API is part of an experimental wire-protocol surface
7198 /// and may change or be removed in future SDK or CLI releases. Pin both the
7199 /// SDK and CLI versions if your code depends on it.
7200 ///
7201 /// </div>
7202 pub async fn add_trusted(
7203 &self,
7204 params: FolderTrustAddParams,
7205 ) -> Result<PermissionsFolderTrustAddTrustedResult, Error> {
7206 let mut wire_params = serde_json::to_value(params)?;
7207 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7208 let _value = self
7209 .session
7210 .client()
7211 .call(
7212 rpc_methods::SESSION_PERMISSIONS_FOLDERTRUST_ADDTRUSTED,
7213 Some(wire_params),
7214 )
7215 .await?;
7216 Ok(serde_json::from_value(_value)?)
7217 }
7218}
7219
7220/// `session.permissions.locations.*` RPCs.
7221#[derive(Clone, Copy)]
7222pub struct SessionRpcPermissionsLocations<'a> {
7223 pub(crate) session: &'a Session,
7224}
7225
7226impl<'a> SessionRpcPermissionsLocations<'a> {
7227 /// Resolves the permission location key and type for a working directory.
7228 ///
7229 /// Wire method: `session.permissions.locations.resolve`.
7230 ///
7231 /// # Parameters
7232 ///
7233 /// * `params` - Working directory to resolve into a location-permissions key.
7234 ///
7235 /// # Returns
7236 ///
7237 /// Resolved location-permissions key and type.
7238 ///
7239 /// <div class="warning">
7240 ///
7241 /// **Experimental.** This API is part of an experimental wire-protocol surface
7242 /// and may change or be removed in future SDK or CLI releases. Pin both the
7243 /// SDK and CLI versions if your code depends on it.
7244 ///
7245 /// </div>
7246 pub async fn resolve(
7247 &self,
7248 params: PermissionLocationResolveParams,
7249 ) -> Result<PermissionLocationResolveResult, Error> {
7250 let mut wire_params = serde_json::to_value(params)?;
7251 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7252 let _value = self
7253 .session
7254 .client()
7255 .call(
7256 rpc_methods::SESSION_PERMISSIONS_LOCATIONS_RESOLVE,
7257 Some(wire_params),
7258 )
7259 .await?;
7260 Ok(serde_json::from_value(_value)?)
7261 }
7262
7263 /// Applies persisted location-scoped tool approvals and allowed directories for a working directory to this session's permission service.
7264 ///
7265 /// Wire method: `session.permissions.locations.apply`.
7266 ///
7267 /// # Parameters
7268 ///
7269 /// * `params` - Working directory to load persisted location permissions for.
7270 ///
7271 /// # Returns
7272 ///
7273 /// Summary of persisted location permissions applied to the session.
7274 ///
7275 /// <div class="warning">
7276 ///
7277 /// **Experimental.** This API is part of an experimental wire-protocol surface
7278 /// and may change or be removed in future SDK or CLI releases. Pin both the
7279 /// SDK and CLI versions if your code depends on it.
7280 ///
7281 /// </div>
7282 pub async fn apply(
7283 &self,
7284 params: PermissionLocationApplyParams,
7285 ) -> Result<PermissionLocationApplyResult, Error> {
7286 let mut wire_params = serde_json::to_value(params)?;
7287 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7288 let _value = self
7289 .session
7290 .client()
7291 .call(
7292 rpc_methods::SESSION_PERMISSIONS_LOCATIONS_APPLY,
7293 Some(wire_params),
7294 )
7295 .await?;
7296 Ok(serde_json::from_value(_value)?)
7297 }
7298
7299 /// Persists a tool approval for a permission location and applies its rules to this session's live permission service.
7300 ///
7301 /// Wire method: `session.permissions.locations.addToolApproval`.
7302 ///
7303 /// # Parameters
7304 ///
7305 /// * `params` - Location-scoped tool approval to persist.
7306 ///
7307 /// # Returns
7308 ///
7309 /// Indicates whether the operation succeeded.
7310 ///
7311 /// <div class="warning">
7312 ///
7313 /// **Experimental.** This API is part of an experimental wire-protocol surface
7314 /// and may change or be removed in future SDK or CLI releases. Pin both the
7315 /// SDK and CLI versions if your code depends on it.
7316 ///
7317 /// </div>
7318 pub async fn add_tool_approval(
7319 &self,
7320 params: PermissionLocationAddToolApprovalParams,
7321 ) -> Result<PermissionsLocationsAddToolApprovalResult, Error> {
7322 let mut wire_params = serde_json::to_value(params)?;
7323 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7324 let _value = self
7325 .session
7326 .client()
7327 .call(
7328 rpc_methods::SESSION_PERMISSIONS_LOCATIONS_ADDTOOLAPPROVAL,
7329 Some(wire_params),
7330 )
7331 .await?;
7332 Ok(serde_json::from_value(_value)?)
7333 }
7334}
7335
7336/// `session.permissions.paths.*` RPCs.
7337#[derive(Clone, Copy)]
7338pub struct SessionRpcPermissionsPaths<'a> {
7339 pub(crate) session: &'a Session,
7340}
7341
7342impl<'a> SessionRpcPermissionsPaths<'a> {
7343 /// Returns the session's allowed directories and primary working directory.
7344 ///
7345 /// Wire method: `session.permissions.paths.list`.
7346 ///
7347 /// # Returns
7348 ///
7349 /// Snapshot of the session's allow-listed directories and primary working directory.
7350 ///
7351 /// <div class="warning">
7352 ///
7353 /// **Experimental.** This API is part of an experimental wire-protocol surface
7354 /// and may change or be removed in future SDK or CLI releases. Pin both the
7355 /// SDK and CLI versions if your code depends on it.
7356 ///
7357 /// </div>
7358 pub async fn list(&self) -> Result<PermissionPathsList, Error> {
7359 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7360 let _value = self
7361 .session
7362 .client()
7363 .call(
7364 rpc_methods::SESSION_PERMISSIONS_PATHS_LIST,
7365 Some(wire_params),
7366 )
7367 .await?;
7368 Ok(serde_json::from_value(_value)?)
7369 }
7370
7371 /// Adds a directory to the session's allow-list.
7372 ///
7373 /// Wire method: `session.permissions.paths.add`.
7374 ///
7375 /// # Parameters
7376 ///
7377 /// * `params` - Directory path to add to the session's allowed directories.
7378 ///
7379 /// # Returns
7380 ///
7381 /// Indicates whether the operation succeeded.
7382 ///
7383 /// <div class="warning">
7384 ///
7385 /// **Experimental.** This API is part of an experimental wire-protocol surface
7386 /// and may change or be removed in future SDK or CLI releases. Pin both the
7387 /// SDK and CLI versions if your code depends on it.
7388 ///
7389 /// </div>
7390 pub async fn add(
7391 &self,
7392 params: PermissionPathsAddParams,
7393 ) -> Result<PermissionsPathsAddResult, Error> {
7394 let mut wire_params = serde_json::to_value(params)?;
7395 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7396 let _value = self
7397 .session
7398 .client()
7399 .call(
7400 rpc_methods::SESSION_PERMISSIONS_PATHS_ADD,
7401 Some(wire_params),
7402 )
7403 .await?;
7404 Ok(serde_json::from_value(_value)?)
7405 }
7406
7407 /// Updates the session's primary working directory used by the permission policy.
7408 ///
7409 /// Wire method: `session.permissions.paths.updatePrimary`.
7410 ///
7411 /// # Parameters
7412 ///
7413 /// * `params` - Directory path to set as the session's new primary working directory.
7414 ///
7415 /// # Returns
7416 ///
7417 /// Indicates whether the operation succeeded.
7418 ///
7419 /// <div class="warning">
7420 ///
7421 /// **Experimental.** This API is part of an experimental wire-protocol surface
7422 /// and may change or be removed in future SDK or CLI releases. Pin both the
7423 /// SDK and CLI versions if your code depends on it.
7424 ///
7425 /// </div>
7426 pub async fn update_primary(
7427 &self,
7428 params: PermissionPathsUpdatePrimaryParams,
7429 ) -> Result<PermissionsPathsUpdatePrimaryResult, Error> {
7430 let mut wire_params = serde_json::to_value(params)?;
7431 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7432 let _value = self
7433 .session
7434 .client()
7435 .call(
7436 rpc_methods::SESSION_PERMISSIONS_PATHS_UPDATEPRIMARY,
7437 Some(wire_params),
7438 )
7439 .await?;
7440 Ok(serde_json::from_value(_value)?)
7441 }
7442
7443 /// Reports whether a path falls within any of the session's allowed directories.
7444 ///
7445 /// Wire method: `session.permissions.paths.isPathWithinAllowedDirectories`.
7446 ///
7447 /// # Parameters
7448 ///
7449 /// * `params` - Path to evaluate against the session's allowed directories.
7450 ///
7451 /// # Returns
7452 ///
7453 /// Indicates whether the supplied path is within the session's allowed directories.
7454 ///
7455 /// <div class="warning">
7456 ///
7457 /// **Experimental.** This API is part of an experimental wire-protocol surface
7458 /// and may change or be removed in future SDK or CLI releases. Pin both the
7459 /// SDK and CLI versions if your code depends on it.
7460 ///
7461 /// </div>
7462 pub async fn is_path_within_allowed_directories(
7463 &self,
7464 params: PermissionPathsAllowedCheckParams,
7465 ) -> Result<PermissionPathsAllowedCheckResult, Error> {
7466 let mut wire_params = serde_json::to_value(params)?;
7467 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7468 let _value = self
7469 .session
7470 .client()
7471 .call(
7472 rpc_methods::SESSION_PERMISSIONS_PATHS_ISPATHWITHINALLOWEDDIRECTORIES,
7473 Some(wire_params),
7474 )
7475 .await?;
7476 Ok(serde_json::from_value(_value)?)
7477 }
7478
7479 /// Reports whether a path falls within the session's workspace (primary) directory.
7480 ///
7481 /// Wire method: `session.permissions.paths.isPathWithinWorkspace`.
7482 ///
7483 /// # Parameters
7484 ///
7485 /// * `params` - Path to evaluate against the session's workspace (primary) directory.
7486 ///
7487 /// # Returns
7488 ///
7489 /// Indicates whether the supplied path is within the session's workspace directory.
7490 ///
7491 /// <div class="warning">
7492 ///
7493 /// **Experimental.** This API is part of an experimental wire-protocol surface
7494 /// and may change or be removed in future SDK or CLI releases. Pin both the
7495 /// SDK and CLI versions if your code depends on it.
7496 ///
7497 /// </div>
7498 pub async fn is_path_within_workspace(
7499 &self,
7500 params: PermissionPathsWorkspaceCheckParams,
7501 ) -> Result<PermissionPathsWorkspaceCheckResult, Error> {
7502 let mut wire_params = serde_json::to_value(params)?;
7503 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7504 let _value = self
7505 .session
7506 .client()
7507 .call(
7508 rpc_methods::SESSION_PERMISSIONS_PATHS_ISPATHWITHINWORKSPACE,
7509 Some(wire_params),
7510 )
7511 .await?;
7512 Ok(serde_json::from_value(_value)?)
7513 }
7514}
7515
7516/// `session.permissions.urls.*` RPCs.
7517#[derive(Clone, Copy)]
7518pub struct SessionRpcPermissionsUrls<'a> {
7519 pub(crate) session: &'a Session,
7520}
7521
7522impl<'a> SessionRpcPermissionsUrls<'a> {
7523 /// Toggles the runtime's URL-permission policy between unrestricted and restricted modes.
7524 ///
7525 /// Wire method: `session.permissions.urls.setUnrestrictedMode`.
7526 ///
7527 /// # Parameters
7528 ///
7529 /// * `params` - Whether the URL-permission policy should run in unrestricted mode.
7530 ///
7531 /// # Returns
7532 ///
7533 /// Indicates whether the operation succeeded.
7534 ///
7535 /// <div class="warning">
7536 ///
7537 /// **Experimental.** This API is part of an experimental wire-protocol surface
7538 /// and may change or be removed in future SDK or CLI releases. Pin both the
7539 /// SDK and CLI versions if your code depends on it.
7540 ///
7541 /// </div>
7542 pub async fn set_unrestricted_mode(
7543 &self,
7544 params: PermissionUrlsSetUnrestrictedModeParams,
7545 ) -> Result<PermissionsUrlsSetUnrestrictedModeResult, Error> {
7546 let mut wire_params = serde_json::to_value(params)?;
7547 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7548 let _value = self
7549 .session
7550 .client()
7551 .call(
7552 rpc_methods::SESSION_PERMISSIONS_URLS_SETUNRESTRICTEDMODE,
7553 Some(wire_params),
7554 )
7555 .await?;
7556 Ok(serde_json::from_value(_value)?)
7557 }
7558}
7559
7560/// `session.plan.*` RPCs.
7561#[derive(Clone, Copy)]
7562pub struct SessionRpcPlan<'a> {
7563 pub(crate) session: &'a Session,
7564}
7565
7566impl<'a> SessionRpcPlan<'a> {
7567 /// Reads the session plan file from the workspace.
7568 ///
7569 /// Wire method: `session.plan.read`.
7570 ///
7571 /// # Returns
7572 ///
7573 /// Existence, contents, and resolved path of the session plan file.
7574 ///
7575 /// <div class="warning">
7576 ///
7577 /// **Experimental.** This API is part of an experimental wire-protocol surface
7578 /// and may change or be removed in future SDK or CLI releases. Pin both the
7579 /// SDK and CLI versions if your code depends on it.
7580 ///
7581 /// </div>
7582 pub async fn read(&self) -> Result<PlanReadResult, Error> {
7583 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7584 let _value = self
7585 .session
7586 .client()
7587 .call(rpc_methods::SESSION_PLAN_READ, Some(wire_params))
7588 .await?;
7589 Ok(serde_json::from_value(_value)?)
7590 }
7591
7592 /// Writes new content to the session plan file.
7593 ///
7594 /// Wire method: `session.plan.update`.
7595 ///
7596 /// # Parameters
7597 ///
7598 /// * `params` - Replacement contents to write to the session plan file.
7599 ///
7600 /// <div class="warning">
7601 ///
7602 /// **Experimental.** This API is part of an experimental wire-protocol surface
7603 /// and may change or be removed in future SDK or CLI releases. Pin both the
7604 /// SDK and CLI versions if your code depends on it.
7605 ///
7606 /// </div>
7607 pub async fn update(&self, params: PlanUpdateRequest) -> Result<(), Error> {
7608 let mut wire_params = serde_json::to_value(params)?;
7609 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7610 let _value = self
7611 .session
7612 .client()
7613 .call(rpc_methods::SESSION_PLAN_UPDATE, Some(wire_params))
7614 .await?;
7615 Ok(())
7616 }
7617
7618 /// Deletes the session plan file from the workspace.
7619 ///
7620 /// Wire method: `session.plan.delete`.
7621 ///
7622 /// <div class="warning">
7623 ///
7624 /// **Experimental.** This API is part of an experimental wire-protocol surface
7625 /// and may change or be removed in future SDK or CLI releases. Pin both the
7626 /// SDK and CLI versions if your code depends on it.
7627 ///
7628 /// </div>
7629 pub async fn delete(&self) -> Result<(), Error> {
7630 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7631 let _value = self
7632 .session
7633 .client()
7634 .call(rpc_methods::SESSION_PLAN_DELETE, Some(wire_params))
7635 .await?;
7636 Ok(())
7637 }
7638
7639 /// Reads todo rows from the session SQL database for plan rendering.
7640 ///
7641 /// Wire method: `session.plan.readSqlTodos`.
7642 ///
7643 /// # Returns
7644 ///
7645 /// Todo rows read from the session SQL database. Empty when no session database is available.
7646 ///
7647 /// <div class="warning">
7648 ///
7649 /// **Experimental.** This API is part of an experimental wire-protocol surface
7650 /// and may change or be removed in future SDK or CLI releases. Pin both the
7651 /// SDK and CLI versions if your code depends on it.
7652 ///
7653 /// </div>
7654 pub async fn read_sql_todos(&self) -> Result<PlanReadSqlTodosResult, Error> {
7655 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7656 let _value = self
7657 .session
7658 .client()
7659 .call(rpc_methods::SESSION_PLAN_READSQLTODOS, Some(wire_params))
7660 .await?;
7661 Ok(serde_json::from_value(_value)?)
7662 }
7663
7664 /// 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.
7665 ///
7666 /// Wire method: `session.plan.readSqlTodosWithDependencies`.
7667 ///
7668 /// # Returns
7669 ///
7670 /// Todo rows + dependency edges read from the session SQL database.
7671 ///
7672 /// <div class="warning">
7673 ///
7674 /// **Experimental.** This API is part of an experimental wire-protocol surface
7675 /// and may change or be removed in future SDK or CLI releases. Pin both the
7676 /// SDK and CLI versions if your code depends on it.
7677 ///
7678 /// </div>
7679 pub async fn read_sql_todos_with_dependencies(
7680 &self,
7681 ) -> Result<PlanReadSqlTodosWithDependenciesResult, Error> {
7682 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7683 let _value = self
7684 .session
7685 .client()
7686 .call(
7687 rpc_methods::SESSION_PLAN_READSQLTODOSWITHDEPENDENCIES,
7688 Some(wire_params),
7689 )
7690 .await?;
7691 Ok(serde_json::from_value(_value)?)
7692 }
7693}
7694
7695/// `session.plugins.*` RPCs.
7696#[derive(Clone, Copy)]
7697pub struct SessionRpcPlugins<'a> {
7698 pub(crate) session: &'a Session,
7699}
7700
7701impl<'a> SessionRpcPlugins<'a> {
7702 /// Lists plugins installed for the session.
7703 ///
7704 /// Wire method: `session.plugins.list`.
7705 ///
7706 /// # Returns
7707 ///
7708 /// Plugins installed for the session, with their enabled state and version metadata.
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<PluginList, 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_PLUGINS_LIST, Some(wire_params))
7723 .await?;
7724 Ok(serde_json::from_value(_value)?)
7725 }
7726
7727 /// 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.
7728 ///
7729 /// Wire method: `session.plugins.reload`.
7730 ///
7731 /// <div class="warning">
7732 ///
7733 /// **Experimental.** This API is part of an experimental wire-protocol surface
7734 /// and may change or be removed in future SDK or CLI releases. Pin both the
7735 /// SDK and CLI versions if your code depends on it.
7736 ///
7737 /// </div>
7738 pub async fn reload(&self) -> Result<(), Error> {
7739 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7740 let _value = self
7741 .session
7742 .client()
7743 .call(rpc_methods::SESSION_PLUGINS_RELOAD, Some(wire_params))
7744 .await?;
7745 Ok(())
7746 }
7747
7748 /// 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.
7749 ///
7750 /// Wire method: `session.plugins.reload`.
7751 ///
7752 /// # Parameters
7753 ///
7754 /// * `params` - Optional flags controlling which side effects the reload performs.
7755 ///
7756 /// <div class="warning">
7757 ///
7758 /// **Experimental.** This API is part of an experimental wire-protocol surface
7759 /// and may change or be removed in future SDK or CLI releases. Pin both the
7760 /// SDK and CLI versions if your code depends on it.
7761 ///
7762 /// </div>
7763 pub async fn reload_with_params(&self, params: PluginsReloadRequest) -> Result<(), Error> {
7764 let mut wire_params = serde_json::to_value(params)?;
7765 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7766 let _value = self
7767 .session
7768 .client()
7769 .call(rpc_methods::SESSION_PLUGINS_RELOAD, Some(wire_params))
7770 .await?;
7771 Ok(())
7772 }
7773}
7774
7775/// `session.provider.*` RPCs.
7776#[derive(Clone, Copy)]
7777pub struct SessionRpcProvider<'a> {
7778 pub(crate) session: &'a Session,
7779}
7780
7781impl<'a> SessionRpcProvider<'a> {
7782 /// 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.
7783 ///
7784 /// Wire method: `session.provider.getEndpoint`.
7785 ///
7786 /// # Returns
7787 ///
7788 /// A snapshot of the provider endpoint the session is currently configured to talk to.
7789 ///
7790 /// <div class="warning">
7791 ///
7792 /// **Experimental.** This API is part of an experimental wire-protocol surface
7793 /// and may change or be removed in future SDK or CLI releases. Pin both the
7794 /// SDK and CLI versions if your code depends on it.
7795 ///
7796 /// </div>
7797 pub async fn get_endpoint(&self) -> Result<ProviderEndpoint, Error> {
7798 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7799 let _value = self
7800 .session
7801 .client()
7802 .call(rpc_methods::SESSION_PROVIDER_GETENDPOINT, Some(wire_params))
7803 .await?;
7804 Ok(serde_json::from_value(_value)?)
7805 }
7806
7807 /// 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.
7808 ///
7809 /// Wire method: `session.provider.getEndpoint`.
7810 ///
7811 /// # Parameters
7812 ///
7813 /// * `params` - Optional model identifier to scope the endpoint snapshot to.
7814 ///
7815 /// # Returns
7816 ///
7817 /// A snapshot of the provider endpoint the session is currently configured to talk to.
7818 ///
7819 /// <div class="warning">
7820 ///
7821 /// **Experimental.** This API is part of an experimental wire-protocol surface
7822 /// and may change or be removed in future SDK or CLI releases. Pin both the
7823 /// SDK and CLI versions if your code depends on it.
7824 ///
7825 /// </div>
7826 pub async fn get_endpoint_with_params(
7827 &self,
7828 params: ProviderGetEndpointRequest,
7829 ) -> Result<ProviderEndpoint, Error> {
7830 let mut wire_params = serde_json::to_value(params)?;
7831 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7832 let _value = self
7833 .session
7834 .client()
7835 .call(rpc_methods::SESSION_PROVIDER_GETENDPOINT, Some(wire_params))
7836 .await?;
7837 Ok(serde_json::from_value(_value)?)
7838 }
7839
7840 /// 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.
7841 ///
7842 /// Wire method: `session.provider.add`.
7843 ///
7844 /// # Parameters
7845 ///
7846 /// * `params` - BYOK providers and/or models to add to the session's registry at runtime. Both fields are optional; provide providers, models, or both.
7847 ///
7848 /// # Returns
7849 ///
7850 /// The selectable model entries synthesized for the models added by this call.
7851 ///
7852 /// <div class="warning">
7853 ///
7854 /// **Experimental.** This API is part of an experimental wire-protocol surface
7855 /// and may change or be removed in future SDK or CLI releases. Pin both the
7856 /// SDK and CLI versions if your code depends on it.
7857 ///
7858 /// </div>
7859 pub async fn add(&self, params: ProviderAddRequest) -> Result<ProviderAddResult, Error> {
7860 let mut wire_params = serde_json::to_value(params)?;
7861 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7862 let _value = self
7863 .session
7864 .client()
7865 .call(rpc_methods::SESSION_PROVIDER_ADD, Some(wire_params))
7866 .await?;
7867 Ok(serde_json::from_value(_value)?)
7868 }
7869}
7870
7871/// `session.queue.*` RPCs.
7872#[derive(Clone, Copy)]
7873pub struct SessionRpcQueue<'a> {
7874 pub(crate) session: &'a Session,
7875}
7876
7877impl<'a> SessionRpcQueue<'a> {
7878 /// Returns the local session's pending user-facing queued items and steering messages.
7879 ///
7880 /// Wire method: `session.queue.pendingItems`.
7881 ///
7882 /// # Returns
7883 ///
7884 /// Snapshot of the session's pending queued items and immediate-steering messages.
7885 ///
7886 /// <div class="warning">
7887 ///
7888 /// **Experimental.** This API is part of an experimental wire-protocol surface
7889 /// and may change or be removed in future SDK or CLI releases. Pin both the
7890 /// SDK and CLI versions if your code depends on it.
7891 ///
7892 /// </div>
7893 pub async fn pending_items(&self) -> Result<QueuePendingItemsResult, Error> {
7894 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7895 let _value = self
7896 .session
7897 .client()
7898 .call(rpc_methods::SESSION_QUEUE_PENDINGITEMS, Some(wire_params))
7899 .await?;
7900 Ok(serde_json::from_value(_value)?)
7901 }
7902
7903 /// Returns the internal native queue snapshot for in-process session orchestration.
7904 ///
7905 /// Wire method: `session.queue.snapshot`.
7906 ///
7907 /// # Returns
7908 ///
7909 /// Internal snapshot of native queue state for local session orchestration.
7910 ///
7911 /// <div class="warning">
7912 ///
7913 /// **Experimental.** This API is part of an experimental wire-protocol surface
7914 /// and may change or be removed in future SDK or CLI releases. Pin both the
7915 /// SDK and CLI versions if your code depends on it.
7916 ///
7917 /// </div>
7918 pub(crate) async fn snapshot(&self) -> Result<QueueSnapshotResult, Error> {
7919 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
7920 let _value = self
7921 .session
7922 .client()
7923 .call(rpc_methods::SESSION_QUEUE_SNAPSHOT, Some(wire_params))
7924 .await?;
7925 Ok(serde_json::from_value(_value)?)
7926 }
7927
7928 /// Moves an addressable queued item to a public visible position.
7929 ///
7930 /// Wire method: `session.queue.moveItem`.
7931 ///
7932 /// # Parameters
7933 ///
7934 /// * `params` - Parameters for moving a queued item by stable id.
7935 ///
7936 /// # Returns
7937 ///
7938 /// Result of moving a queued item.
7939 ///
7940 /// <div class="warning">
7941 ///
7942 /// **Experimental.** This API is part of an experimental wire-protocol surface
7943 /// and may change or be removed in future SDK or CLI releases. Pin both the
7944 /// SDK and CLI versions if your code depends on it.
7945 ///
7946 /// </div>
7947 pub async fn move_item(
7948 &self,
7949 params: QueueMoveItemRequest,
7950 ) -> Result<QueueMoveItemResult, Error> {
7951 let mut wire_params = serde_json::to_value(params)?;
7952 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7953 let _value = self
7954 .session
7955 .client()
7956 .call(rpc_methods::SESSION_QUEUE_MOVEITEM, Some(wire_params))
7957 .await?;
7958 Ok(serde_json::from_value(_value)?)
7959 }
7960
7961 /// Inserts a new queued message at a public visible position.
7962 ///
7963 /// Wire method: `session.queue.insertAt`.
7964 ///
7965 /// # Parameters
7966 ///
7967 /// * `params` - Parameters for inserting a queued message at a public visible position.
7968 ///
7969 /// # Returns
7970 ///
7971 /// Result of inserting a queued message.
7972 ///
7973 /// <div class="warning">
7974 ///
7975 /// **Experimental.** This API is part of an experimental wire-protocol surface
7976 /// and may change or be removed in future SDK or CLI releases. Pin both the
7977 /// SDK and CLI versions if your code depends on it.
7978 ///
7979 /// </div>
7980 pub async fn insert_at(
7981 &self,
7982 params: QueueInsertAtRequest,
7983 ) -> Result<QueueInsertAtResult, Error> {
7984 let mut wire_params = serde_json::to_value(params)?;
7985 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
7986 let _value = self
7987 .session
7988 .client()
7989 .call(rpc_methods::SESSION_QUEUE_INSERTAT, Some(wire_params))
7990 .await?;
7991 Ok(serde_json::from_value(_value)?)
7992 }
7993
7994 /// Removes an addressable queued item by its stable id.
7995 ///
7996 /// Wire method: `session.queue.removeAt`.
7997 ///
7998 /// # Parameters
7999 ///
8000 /// * `params` - Parameters for removing a queued item by stable id.
8001 ///
8002 /// # Returns
8003 ///
8004 /// Result of removing a queued item.
8005 ///
8006 /// <div class="warning">
8007 ///
8008 /// **Experimental.** This API is part of an experimental wire-protocol surface
8009 /// and may change or be removed in future SDK or CLI releases. Pin both the
8010 /// SDK and CLI versions if your code depends on it.
8011 ///
8012 /// </div>
8013 pub async fn remove_at(
8014 &self,
8015 params: QueueRemoveAtRequest,
8016 ) -> Result<QueueRemoveAtResult, Error> {
8017 let mut wire_params = serde_json::to_value(params)?;
8018 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8019 let _value = self
8020 .session
8021 .client()
8022 .call(rpc_methods::SESSION_QUEUE_REMOVEAT, Some(wire_params))
8023 .await?;
8024 Ok(serde_json::from_value(_value)?)
8025 }
8026
8027 /// Updates the text of an addressable single-message queue item.
8028 ///
8029 /// Wire method: `session.queue.updateText`.
8030 ///
8031 /// # Parameters
8032 ///
8033 /// * `params` - Parameters for editing a single queued message.
8034 ///
8035 /// # Returns
8036 ///
8037 /// Result of editing a queued message.
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 update_text(
8047 &self,
8048 params: QueueUpdateTextRequest,
8049 ) -> Result<QueueUpdateTextResult, 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(rpc_methods::SESSION_QUEUE_UPDATETEXT, Some(wire_params))
8056 .await?;
8057 Ok(serde_json::from_value(_value)?)
8058 }
8059
8060 /// Duplicates an addressable queued item immediately after its source.
8061 ///
8062 /// Wire method: `session.queue.duplicateAt`.
8063 ///
8064 /// # Parameters
8065 ///
8066 /// * `params` - Parameters for duplicating a queued item.
8067 ///
8068 /// # Returns
8069 ///
8070 /// Result of duplicating a queued item.
8071 ///
8072 /// <div class="warning">
8073 ///
8074 /// **Experimental.** This API is part of an experimental wire-protocol surface
8075 /// and may change or be removed in future SDK or CLI releases. Pin both the
8076 /// SDK and CLI versions if your code depends on it.
8077 ///
8078 /// </div>
8079 pub async fn duplicate_at(
8080 &self,
8081 params: QueueDuplicateAtRequest,
8082 ) -> Result<QueueDuplicateAtResult, Error> {
8083 let mut wire_params = serde_json::to_value(params)?;
8084 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8085 let _value = self
8086 .session
8087 .client()
8088 .call(rpc_methods::SESSION_QUEUE_DUPLICATEAT, Some(wire_params))
8089 .await?;
8090 Ok(serde_json::from_value(_value)?)
8091 }
8092
8093 /// Acquires or releases the queued-lane drain pause.
8094 ///
8095 /// Wire method: `session.queue.setDrainPaused`.
8096 ///
8097 /// # Parameters
8098 ///
8099 /// * `params` - Parameters for acquiring or releasing the queued-lane drain pause. Acquisition is exclusive and non-idempotent: `paused: true` against an already-paused session fails with `queue_already_paused`. The pause is never released automatically — it is not tied to the caller's lifetime, so a client that exits without sending `paused: false` leaves the lane frozen. Release is unowned: `paused: false` clears the pause for any caller, including one that never acquired it.
8100 ///
8101 /// <div class="warning">
8102 ///
8103 /// **Experimental.** This API is part of an experimental wire-protocol surface
8104 /// and may change or be removed in future SDK or CLI releases. Pin both the
8105 /// SDK and CLI versions if your code depends on it.
8106 ///
8107 /// </div>
8108 pub async fn set_drain_paused(&self, params: QueueSetDrainPausedRequest) -> Result<(), Error> {
8109 let mut wire_params = serde_json::to_value(params)?;
8110 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8111 let _value = self
8112 .session
8113 .client()
8114 .call(rpc_methods::SESSION_QUEUE_SETDRAINPAUSED, Some(wire_params))
8115 .await?;
8116 Ok(())
8117 }
8118
8119 /// Moves an addressable queued message into the live turn's steering lane.
8120 ///
8121 /// Wire method: `session.queue.sendNow`.
8122 ///
8123 /// # Parameters
8124 ///
8125 /// * `params` - Parameters for steering a queued message into a live turn.
8126 ///
8127 /// # Returns
8128 ///
8129 /// Result of trying to steer a queued message into a live turn.
8130 ///
8131 /// <div class="warning">
8132 ///
8133 /// **Experimental.** This API is part of an experimental wire-protocol surface
8134 /// and may change or be removed in future SDK or CLI releases. Pin both the
8135 /// SDK and CLI versions if your code depends on it.
8136 ///
8137 /// </div>
8138 pub async fn send_now(&self, params: QueueSendNowRequest) -> Result<QueueSendNowResult, Error> {
8139 let mut wire_params = serde_json::to_value(params)?;
8140 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8141 let _value = self
8142 .session
8143 .client()
8144 .call(rpc_methods::SESSION_QUEUE_SENDNOW, Some(wire_params))
8145 .await?;
8146 Ok(serde_json::from_value(_value)?)
8147 }
8148
8149 /// Reports whether the local session has native queued work pending.
8150 ///
8151 /// Wire method: `session.queue.hasPending`.
8152 ///
8153 /// # Returns
8154 ///
8155 /// Whether the native queue has pending work.
8156 ///
8157 /// <div class="warning">
8158 ///
8159 /// **Experimental.** This API is part of an experimental wire-protocol surface
8160 /// and may change or be removed in future SDK or CLI releases. Pin both the
8161 /// SDK and CLI versions if your code depends on it.
8162 ///
8163 /// </div>
8164 pub(crate) async fn has_pending(&self) -> Result<QueueHasPendingResult, Error> {
8165 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8166 let _value = self
8167 .session
8168 .client()
8169 .call(rpc_methods::SESSION_QUEUE_HASPENDING, Some(wire_params))
8170 .await?;
8171 Ok(serde_json::from_value(_value)?)
8172 }
8173
8174 /// Begins a native deferred-idle drain when background work has quiesced.
8175 ///
8176 /// Wire method: `session.queue.beginDeferredIdleDrain`.
8177 ///
8178 /// # Parameters
8179 ///
8180 /// * `params` - Inputs for starting a deferred-idle drain.
8181 ///
8182 /// # Returns
8183 ///
8184 /// Whether a deferred-idle drain should run.
8185 ///
8186 /// <div class="warning">
8187 ///
8188 /// **Experimental.** This API is part of an experimental wire-protocol surface
8189 /// and may change or be removed in future SDK or CLI releases. Pin both the
8190 /// SDK and CLI versions if your code depends on it.
8191 ///
8192 /// </div>
8193 pub(crate) async fn begin_deferred_idle_drain(
8194 &self,
8195 params: QueueBeginDeferredIdleDrainRequest,
8196 ) -> Result<QueueBeginDeferredIdleDrainResult, Error> {
8197 let mut wire_params = serde_json::to_value(params)?;
8198 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8199 let _value = self
8200 .session
8201 .client()
8202 .call(
8203 rpc_methods::SESSION_QUEUE_BEGINDEFERREDIDLEDRAIN,
8204 Some(wire_params),
8205 )
8206 .await?;
8207 Ok(serde_json::from_value(_value)?)
8208 }
8209
8210 /// Finishes a native deferred-idle drain and reports whether to drain queue work or emit idle.
8211 ///
8212 /// Wire method: `session.queue.finishDeferredIdleDrain`.
8213 ///
8214 /// # Parameters
8215 ///
8216 /// * `params` - Inputs for completing a deferred-idle drain.
8217 ///
8218 /// # Returns
8219 ///
8220 /// Action selected by the native deferred-idle drain.
8221 ///
8222 /// <div class="warning">
8223 ///
8224 /// **Experimental.** This API is part of an experimental wire-protocol surface
8225 /// and may change or be removed in future SDK or CLI releases. Pin both the
8226 /// SDK and CLI versions if your code depends on it.
8227 ///
8228 /// </div>
8229 pub(crate) async fn finish_deferred_idle_drain(
8230 &self,
8231 params: QueueFinishDeferredIdleDrainRequest,
8232 ) -> Result<QueueFinishDeferredIdleDrainResult, Error> {
8233 let mut wire_params = serde_json::to_value(params)?;
8234 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8235 let _value = self
8236 .session
8237 .client()
8238 .call(
8239 rpc_methods::SESSION_QUEUE_FINISHDEFERREDIDLEDRAIN,
8240 Some(wire_params),
8241 )
8242 .await?;
8243 Ok(serde_json::from_value(_value)?)
8244 }
8245
8246 /// Marks session.idle as deferred by native background work state.
8247 ///
8248 /// Wire method: `session.queue.deferSessionIdle`.
8249 ///
8250 /// # Parameters
8251 ///
8252 /// * `params` - Inputs for marking session.idle deferred in native state.
8253 ///
8254 /// <div class="warning">
8255 ///
8256 /// **Experimental.** This API is part of an experimental wire-protocol surface
8257 /// and may change or be removed in future SDK or CLI releases. Pin both the
8258 /// SDK and CLI versions if your code depends on it.
8259 ///
8260 /// </div>
8261 pub(crate) async fn defer_session_idle(
8262 &self,
8263 params: QueueDeferSessionIdleRequest,
8264 ) -> Result<(), Error> {
8265 let mut wire_params = serde_json::to_value(params)?;
8266 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8267 let _value = self
8268 .session
8269 .client()
8270 .call(
8271 rpc_methods::SESSION_QUEUE_DEFERSESSIONIDLE,
8272 Some(wire_params),
8273 )
8274 .await?;
8275 Ok(())
8276 }
8277
8278 /// Removes the most recently queued user-facing item (LIFO).
8279 ///
8280 /// Wire method: `session.queue.removeMostRecent`.
8281 ///
8282 /// # Returns
8283 ///
8284 /// Indicates whether a user-facing pending item was removed.
8285 ///
8286 /// <div class="warning">
8287 ///
8288 /// **Experimental.** This API is part of an experimental wire-protocol surface
8289 /// and may change or be removed in future SDK or CLI releases. Pin both the
8290 /// SDK and CLI versions if your code depends on it.
8291 ///
8292 /// </div>
8293 pub async fn remove_most_recent(&self) -> Result<QueueRemoveMostRecentResult, Error> {
8294 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8295 let _value = self
8296 .session
8297 .client()
8298 .call(
8299 rpc_methods::SESSION_QUEUE_REMOVEMOSTRECENT,
8300 Some(wire_params),
8301 )
8302 .await?;
8303 Ok(serde_json::from_value(_value)?)
8304 }
8305
8306 /// Clears all pending queued items on the local session.
8307 ///
8308 /// Wire method: `session.queue.clear`.
8309 ///
8310 /// <div class="warning">
8311 ///
8312 /// **Experimental.** This API is part of an experimental wire-protocol surface
8313 /// and may change or be removed in future SDK or CLI releases. Pin both the
8314 /// SDK and CLI versions if your code depends on it.
8315 ///
8316 /// </div>
8317 pub async fn clear(&self) -> Result<(), Error> {
8318 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8319 let _value = self
8320 .session
8321 .client()
8322 .call(rpc_methods::SESSION_QUEUE_CLEAR, Some(wire_params))
8323 .await?;
8324 Ok(())
8325 }
8326
8327 /// Consumes queued native system notifications matching an internal filter.
8328 ///
8329 /// Wire method: `session.queue.consumeSystemNotifications`.
8330 ///
8331 /// # Parameters
8332 ///
8333 /// * `params` - Internal filter for consuming queued system notifications.
8334 ///
8335 /// # Returns
8336 ///
8337 /// Indicates whether a user-facing pending item was removed.
8338 ///
8339 /// <div class="warning">
8340 ///
8341 /// **Experimental.** This API is part of an experimental wire-protocol surface
8342 /// and may change or be removed in future SDK or CLI releases. Pin both the
8343 /// SDK and CLI versions if your code depends on it.
8344 ///
8345 /// </div>
8346 pub(crate) async fn consume_system_notifications(
8347 &self,
8348 params: QueueConsumeSystemNotificationsRequest,
8349 ) -> Result<QueueRemoveMostRecentResult, Error> {
8350 let mut wire_params = serde_json::to_value(params)?;
8351 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8352 let _value = self
8353 .session
8354 .client()
8355 .call(
8356 rpc_methods::SESSION_QUEUE_CONSUMESYSTEMNOTIFICATIONS,
8357 Some(wire_params),
8358 )
8359 .await?;
8360 Ok(serde_json::from_value(_value)?)
8361 }
8362
8363 /// Enqueues the internal resume-pending wake item when orphan handling needs a follow-up turn.
8364 ///
8365 /// Wire method: `session.queue.enqueueResumePending`.
8366 ///
8367 /// # Returns
8368 ///
8369 /// Result of enqueueing the resume-pending wake item.
8370 ///
8371 /// <div class="warning">
8372 ///
8373 /// **Experimental.** This API is part of an experimental wire-protocol surface
8374 /// and may change or be removed in future SDK or CLI releases. Pin both the
8375 /// SDK and CLI versions if your code depends on it.
8376 ///
8377 /// </div>
8378 pub(crate) async fn enqueue_resume_pending(
8379 &self,
8380 ) -> Result<QueueEnqueueResumePendingResult, Error> {
8381 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8382 let _value = self
8383 .session
8384 .client()
8385 .call(
8386 rpc_methods::SESSION_QUEUE_ENQUEUERESUMEPENDING,
8387 Some(wire_params),
8388 )
8389 .await?;
8390 Ok(serde_json::from_value(_value)?)
8391 }
8392
8393 /// Drains the native local-session work queue for in-process session orchestration.
8394 ///
8395 /// Wire method: `session.queue.process`.
8396 ///
8397 /// <div class="warning">
8398 ///
8399 /// **Experimental.** This API is part of an experimental wire-protocol surface
8400 /// and may change or be removed in future SDK or CLI releases. Pin both the
8401 /// SDK and CLI versions if your code depends on it.
8402 ///
8403 /// </div>
8404 pub(crate) async fn process(&self) -> Result<(), Error> {
8405 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8406 let _value = self
8407 .session
8408 .client()
8409 .call(rpc_methods::SESSION_QUEUE_PROCESS, Some(wire_params))
8410 .await?;
8411 Ok(())
8412 }
8413}
8414
8415/// `session.remote.*` RPCs.
8416#[derive(Clone, Copy)]
8417pub struct SessionRpcRemote<'a> {
8418 pub(crate) session: &'a Session,
8419}
8420
8421impl<'a> SessionRpcRemote<'a> {
8422 /// Enables remote session export or steering.
8423 ///
8424 /// Wire method: `session.remote.enable`.
8425 ///
8426 /// # Parameters
8427 ///
8428 /// * `params` - Optional remote session mode ("off", "export", or "on"); defaults to enabling both export and remote steering.
8429 ///
8430 /// # Returns
8431 ///
8432 /// GitHub URL for the session and a flag indicating whether remote steering is enabled.
8433 ///
8434 /// <div class="warning">
8435 ///
8436 /// **Experimental.** This API is part of an experimental wire-protocol surface
8437 /// and may change or be removed in future SDK or CLI releases. Pin both the
8438 /// SDK and CLI versions if your code depends on it.
8439 ///
8440 /// </div>
8441 pub async fn enable(&self, params: RemoteEnableRequest) -> Result<RemoteEnableResult, Error> {
8442 let mut wire_params = serde_json::to_value(params)?;
8443 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8444 let _value = self
8445 .session
8446 .client()
8447 .call(rpc_methods::SESSION_REMOTE_ENABLE, Some(wire_params))
8448 .await?;
8449 Ok(serde_json::from_value(_value)?)
8450 }
8451
8452 /// Disables remote session export and steering.
8453 ///
8454 /// Wire method: `session.remote.disable`.
8455 ///
8456 /// <div class="warning">
8457 ///
8458 /// **Experimental.** This API is part of an experimental wire-protocol surface
8459 /// and may change or be removed in future SDK or CLI releases. Pin both the
8460 /// SDK and CLI versions if your code depends on it.
8461 ///
8462 /// </div>
8463 pub async fn disable(&self) -> Result<(), Error> {
8464 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8465 let _value = self
8466 .session
8467 .client()
8468 .call(rpc_methods::SESSION_REMOTE_DISABLE, Some(wire_params))
8469 .await?;
8470 Ok(())
8471 }
8472
8473 /// Persists a remote-steerability change emitted by the host as a session event.
8474 ///
8475 /// Wire method: `session.remote.notifySteerableChanged`.
8476 ///
8477 /// # Parameters
8478 ///
8479 /// * `params` - New remote-steerability state to persist as a `session.remote_steerable_changed` event.
8480 ///
8481 /// # Returns
8482 ///
8483 /// 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.
8484 ///
8485 /// <div class="warning">
8486 ///
8487 /// **Experimental.** This API is part of an experimental wire-protocol surface
8488 /// and may change or be removed in future SDK or CLI releases. Pin both the
8489 /// SDK and CLI versions if your code depends on it.
8490 ///
8491 /// </div>
8492 pub async fn notify_steerable_changed(
8493 &self,
8494 params: RemoteNotifySteerableChangedRequest,
8495 ) -> Result<RemoteNotifySteerableChangedResult, Error> {
8496 let mut wire_params = serde_json::to_value(params)?;
8497 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8498 let _value = self
8499 .session
8500 .client()
8501 .call(
8502 rpc_methods::SESSION_REMOTE_NOTIFYSTEERABLECHANGED,
8503 Some(wire_params),
8504 )
8505 .await?;
8506 Ok(serde_json::from_value(_value)?)
8507 }
8508}
8509
8510/// `session.schedule.*` RPCs.
8511#[derive(Clone, Copy)]
8512pub struct SessionRpcSchedule<'a> {
8513 pub(crate) session: &'a Session,
8514}
8515
8516impl<'a> SessionRpcSchedule<'a> {
8517 /// Lists the session's currently active scheduled prompts.
8518 ///
8519 /// Wire method: `session.schedule.list`.
8520 ///
8521 /// # Returns
8522 ///
8523 /// Snapshot of the currently active recurring prompts for this session.
8524 ///
8525 /// <div class="warning">
8526 ///
8527 /// **Experimental.** This API is part of an experimental wire-protocol surface
8528 /// and may change or be removed in future SDK or CLI releases. Pin both the
8529 /// SDK and CLI versions if your code depends on it.
8530 ///
8531 /// </div>
8532 pub async fn list(&self) -> Result<ScheduleList, Error> {
8533 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8534 let _value = self
8535 .session
8536 .client()
8537 .call(rpc_methods::SESSION_SCHEDULE_LIST, Some(wire_params))
8538 .await?;
8539 Ok(serde_json::from_value(_value)?)
8540 }
8541
8542 /// Hydrates the native schedule registry from persisted session events.
8543 ///
8544 /// Wire method: `session.schedule.hydrate`.
8545 ///
8546 /// <div class="warning">
8547 ///
8548 /// **Experimental.** This API is part of an experimental wire-protocol surface
8549 /// and may change or be removed in future SDK or CLI releases. Pin both the
8550 /// SDK and CLI versions if your code depends on it.
8551 ///
8552 /// </div>
8553 pub(crate) async fn hydrate(&self) -> Result<(), Error> {
8554 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8555 let _value = self
8556 .session
8557 .client()
8558 .call(rpc_methods::SESSION_SCHEDULE_HYDRATE, Some(wire_params))
8559 .await?;
8560 Ok(())
8561 }
8562
8563 /// Reports whether the session has an active self-paced scheduled prompt.
8564 ///
8565 /// Wire method: `session.schedule.hasSelfPaced`.
8566 ///
8567 /// # Returns
8568 ///
8569 /// Whether the session currently has an active self-paced schedule.
8570 ///
8571 /// <div class="warning">
8572 ///
8573 /// **Experimental.** This API is part of an experimental wire-protocol surface
8574 /// and may change or be removed in future SDK or CLI releases. Pin both the
8575 /// SDK and CLI versions if your code depends on it.
8576 ///
8577 /// </div>
8578 pub(crate) async fn has_self_paced(&self) -> Result<ScheduleHasSelfPacedResult, Error> {
8579 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8580 let _value = self
8581 .session
8582 .client()
8583 .call(
8584 rpc_methods::SESSION_SCHEDULE_HASSELFPACED,
8585 Some(wire_params),
8586 )
8587 .await?;
8588 Ok(serde_json::from_value(_value)?)
8589 }
8590
8591 /// Registers a relative-interval scheduled prompt.
8592 ///
8593 /// Wire method: `session.schedule.add`.
8594 ///
8595 /// # Parameters
8596 ///
8597 /// * `params` - Register a relative-interval scheduled prompt.
8598 ///
8599 /// # Returns
8600 ///
8601 /// Result of registering or re-arming a scheduled prompt.
8602 ///
8603 /// <div class="warning">
8604 ///
8605 /// **Experimental.** This API is part of an experimental wire-protocol surface
8606 /// and may change or be removed in future SDK or CLI releases. Pin both the
8607 /// SDK and CLI versions if your code depends on it.
8608 ///
8609 /// </div>
8610 pub(crate) async fn add(&self, params: ScheduleAddRequest) -> Result<ScheduleAddResult, Error> {
8611 let mut wire_params = serde_json::to_value(params)?;
8612 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8613 let _value = self
8614 .session
8615 .client()
8616 .call(rpc_methods::SESSION_SCHEDULE_ADD, Some(wire_params))
8617 .await?;
8618 Ok(serde_json::from_value(_value)?)
8619 }
8620
8621 /// Registers a recurring cron scheduled prompt.
8622 ///
8623 /// Wire method: `session.schedule.addCron`.
8624 ///
8625 /// # Parameters
8626 ///
8627 /// * `params` - Register a cron scheduled prompt.
8628 ///
8629 /// # Returns
8630 ///
8631 /// Result of registering or re-arming a scheduled prompt.
8632 ///
8633 /// <div class="warning">
8634 ///
8635 /// **Experimental.** This API is part of an experimental wire-protocol surface
8636 /// and may change or be removed in future SDK or CLI releases. Pin both the
8637 /// SDK and CLI versions if your code depends on it.
8638 ///
8639 /// </div>
8640 pub(crate) async fn add_cron(
8641 &self,
8642 params: ScheduleAddCronRequest,
8643 ) -> Result<ScheduleAddResult, Error> {
8644 let mut wire_params = serde_json::to_value(params)?;
8645 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8646 let _value = self
8647 .session
8648 .client()
8649 .call(rpc_methods::SESSION_SCHEDULE_ADDCRON, Some(wire_params))
8650 .await?;
8651 Ok(serde_json::from_value(_value)?)
8652 }
8653
8654 /// Registers an absolute-time scheduled prompt.
8655 ///
8656 /// Wire method: `session.schedule.addAt`.
8657 ///
8658 /// # Parameters
8659 ///
8660 /// * `params` - Register an absolute-time scheduled prompt.
8661 ///
8662 /// # Returns
8663 ///
8664 /// Result of registering or re-arming a scheduled prompt.
8665 ///
8666 /// <div class="warning">
8667 ///
8668 /// **Experimental.** This API is part of an experimental wire-protocol surface
8669 /// and may change or be removed in future SDK or CLI releases. Pin both the
8670 /// SDK and CLI versions if your code depends on it.
8671 ///
8672 /// </div>
8673 pub(crate) async fn add_at(
8674 &self,
8675 params: ScheduleAddAtRequest,
8676 ) -> Result<ScheduleAddResult, Error> {
8677 let mut wire_params = serde_json::to_value(params)?;
8678 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8679 let _value = self
8680 .session
8681 .client()
8682 .call(rpc_methods::SESSION_SCHEDULE_ADDAT, Some(wire_params))
8683 .await?;
8684 Ok(serde_json::from_value(_value)?)
8685 }
8686
8687 /// Registers a self-paced scheduled prompt.
8688 ///
8689 /// Wire method: `session.schedule.addSelfPaced`.
8690 ///
8691 /// # Parameters
8692 ///
8693 /// * `params` - Register a self-paced scheduled prompt.
8694 ///
8695 /// # Returns
8696 ///
8697 /// Result of registering or re-arming a scheduled prompt.
8698 ///
8699 /// <div class="warning">
8700 ///
8701 /// **Experimental.** This API is part of an experimental wire-protocol surface
8702 /// and may change or be removed in future SDK or CLI releases. Pin both the
8703 /// SDK and CLI versions if your code depends on it.
8704 ///
8705 /// </div>
8706 pub(crate) async fn add_self_paced(
8707 &self,
8708 params: ScheduleAddSelfPacedRequest,
8709 ) -> Result<ScheduleAddResult, Error> {
8710 let mut wire_params = serde_json::to_value(params)?;
8711 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8712 let _value = self
8713 .session
8714 .client()
8715 .call(
8716 rpc_methods::SESSION_SCHEDULE_ADDSELFPACED,
8717 Some(wire_params),
8718 )
8719 .await?;
8720 Ok(serde_json::from_value(_value)?)
8721 }
8722
8723 /// Re-arms an active self-paced scheduled prompt.
8724 ///
8725 /// Wire method: `session.schedule.rearmSelfPaced`.
8726 ///
8727 /// # Parameters
8728 ///
8729 /// * `params` - Re-arm a self-paced scheduled prompt.
8730 ///
8731 /// # Returns
8732 ///
8733 /// Result of registering or re-arming a scheduled prompt.
8734 ///
8735 /// <div class="warning">
8736 ///
8737 /// **Experimental.** This API is part of an experimental wire-protocol surface
8738 /// and may change or be removed in future SDK or CLI releases. Pin both the
8739 /// SDK and CLI versions if your code depends on it.
8740 ///
8741 /// </div>
8742 pub(crate) async fn rearm_self_paced(
8743 &self,
8744 params: ScheduleRearmSelfPacedRequest,
8745 ) -> Result<ScheduleAddResult, Error> {
8746 let mut wire_params = serde_json::to_value(params)?;
8747 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8748 let _value = self
8749 .session
8750 .client()
8751 .call(
8752 rpc_methods::SESSION_SCHEDULE_REARMSELFPACED,
8753 Some(wire_params),
8754 )
8755 .await?;
8756 Ok(serde_json::from_value(_value)?)
8757 }
8758
8759 /// Removes a scheduled prompt by id.
8760 ///
8761 /// Wire method: `session.schedule.stop`.
8762 ///
8763 /// # Parameters
8764 ///
8765 /// * `params` - Identifier of the scheduled prompt to remove.
8766 ///
8767 /// # Returns
8768 ///
8769 /// Remove a scheduled prompt by id. The result entry is omitted if the id was unknown.
8770 ///
8771 /// <div class="warning">
8772 ///
8773 /// **Experimental.** This API is part of an experimental wire-protocol surface
8774 /// and may change or be removed in future SDK or CLI releases. Pin both the
8775 /// SDK and CLI versions if your code depends on it.
8776 ///
8777 /// </div>
8778 pub async fn stop(&self, params: ScheduleStopRequest) -> Result<ScheduleStopResult, Error> {
8779 let mut wire_params = serde_json::to_value(params)?;
8780 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8781 let _value = self
8782 .session
8783 .client()
8784 .call(rpc_methods::SESSION_SCHEDULE_STOP, Some(wire_params))
8785 .await?;
8786 Ok(serde_json::from_value(_value)?)
8787 }
8788}
8789
8790/// `session.settings.*` RPCs.
8791#[derive(Clone, Copy)]
8792pub struct SessionRpcSettings<'a> {
8793 pub(crate) session: &'a Session,
8794}
8795
8796impl<'a> SessionRpcSettings<'a> {
8797 /// 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.
8798 ///
8799 /// Wire method: `session.settings.snapshot`.
8800 ///
8801 /// # Returns
8802 ///
8803 /// Redacted, serializable view of session runtime settings for SDK boundary consumers. Secrets and raw feature flags are intentionally excluded.
8804 ///
8805 /// <div class="warning">
8806 ///
8807 /// **Experimental.** This API is part of an experimental wire-protocol surface
8808 /// and may change or be removed in future SDK or CLI releases. Pin both the
8809 /// SDK and CLI versions if your code depends on it.
8810 ///
8811 /// </div>
8812 pub(crate) async fn snapshot(&self) -> Result<SessionSettingsSnapshot, Error> {
8813 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
8814 let _value = self
8815 .session
8816 .client()
8817 .call(rpc_methods::SESSION_SETTINGS_SNAPSHOT, Some(wire_params))
8818 .await?;
8819 Ok(serde_json::from_value(_value)?)
8820 }
8821
8822 /// 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.
8823 ///
8824 /// Wire method: `session.settings.evaluatePredicate`.
8825 ///
8826 /// # Parameters
8827 ///
8828 /// * `params` - Named Rust-owned settings predicate to evaluate for this session.
8829 ///
8830 /// # Returns
8831 ///
8832 /// Result of evaluating a Rust-owned settings predicate.
8833 ///
8834 /// <div class="warning">
8835 ///
8836 /// **Experimental.** This API is part of an experimental wire-protocol surface
8837 /// and may change or be removed in future SDK or CLI releases. Pin both the
8838 /// SDK and CLI versions if your code depends on it.
8839 ///
8840 /// </div>
8841 pub(crate) async fn evaluate_predicate(
8842 &self,
8843 params: SessionSettingsEvaluatePredicateRequest,
8844 ) -> Result<SessionSettingsEvaluatePredicateResult, Error> {
8845 let mut wire_params = serde_json::to_value(params)?;
8846 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8847 let _value = self
8848 .session
8849 .client()
8850 .call(
8851 rpc_methods::SESSION_SETTINGS_EVALUATEPREDICATE,
8852 Some(wire_params),
8853 )
8854 .await?;
8855 Ok(serde_json::from_value(_value)?)
8856 }
8857}
8858
8859/// `session.shell.*` RPCs.
8860#[derive(Clone, Copy)]
8861pub struct SessionRpcShell<'a> {
8862 pub(crate) session: &'a Session,
8863}
8864
8865impl<'a> SessionRpcShell<'a> {
8866 /// Starts a shell command and streams output through session notifications. The command runs as the leader of its own process group (POSIX) or in a dedicated job object (Windows), so a forced termination — via "shell.kill", the request timeout, or session disposal — signals that whole group/job rather than only the direct child. Two gaps are worth planning for: a command that exits on its own does not trigger that teardown, and on POSIX a descendant that moves itself into a new session or process group (for example via "setsid") leaves the signalled group, so either can leave a background process running.
8867 ///
8868 /// Wire method: `session.shell.exec`.
8869 ///
8870 /// # Parameters
8871 ///
8872 /// * `params` - Shell command to run, with optional working directory and timeout in milliseconds.
8873 ///
8874 /// # Returns
8875 ///
8876 /// Identifier of the spawned process, used to correlate streamed output and exit notifications.
8877 ///
8878 /// <div class="warning">
8879 ///
8880 /// **Experimental.** This API is part of an experimental wire-protocol surface
8881 /// and may change or be removed in future SDK or CLI releases. Pin both the
8882 /// SDK and CLI versions if your code depends on it.
8883 ///
8884 /// </div>
8885 pub async fn exec(&self, params: ShellExecRequest) -> Result<ShellExecResult, Error> {
8886 let mut wire_params = serde_json::to_value(params)?;
8887 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8888 let _value = self
8889 .session
8890 .client()
8891 .call(rpc_methods::SESSION_SHELL_EXEC, Some(wire_params))
8892 .await?;
8893 Ok(serde_json::from_value(_value)?)
8894 }
8895
8896 /// Sends a signal to a shell process previously started via "shell.exec". The signal targets the command's whole process group (POSIX) or job object (Windows), so descendants still in that group are signalled too, not just the direct child. On POSIX a descendant that moved itself into a new session or process group (for example via "setsid") is no longer in the signalled group and survives.
8897 ///
8898 /// Wire method: `session.shell.kill`.
8899 ///
8900 /// # Parameters
8901 ///
8902 /// * `params` - Identifier of a process previously returned by "shell.exec" and the signal to send.
8903 ///
8904 /// # Returns
8905 ///
8906 /// Indicates whether the signal was delivered; false if the process was unknown or already exited.
8907 ///
8908 /// <div class="warning">
8909 ///
8910 /// **Experimental.** This API is part of an experimental wire-protocol surface
8911 /// and may change or be removed in future SDK or CLI releases. Pin both the
8912 /// SDK and CLI versions if your code depends on it.
8913 ///
8914 /// </div>
8915 pub async fn kill(&self, params: ShellKillRequest) -> Result<ShellKillResult, Error> {
8916 let mut wire_params = serde_json::to_value(params)?;
8917 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8918 let _value = self
8919 .session
8920 .client()
8921 .call(rpc_methods::SESSION_SHELL_KILL, Some(wire_params))
8922 .await?;
8923 Ok(serde_json::from_value(_value)?)
8924 }
8925
8926 /// Executes a user-requested shell command through the session runtime.
8927 ///
8928 /// Wire method: `session.shell.executeUserRequested`.
8929 ///
8930 /// # Parameters
8931 ///
8932 /// * `params` - User-requested shell command and cancellation handle.
8933 ///
8934 /// # Returns
8935 ///
8936 /// Result of a user-requested shell command.
8937 ///
8938 /// <div class="warning">
8939 ///
8940 /// **Experimental.** This API is part of an experimental wire-protocol surface
8941 /// and may change or be removed in future SDK or CLI releases. Pin both the
8942 /// SDK and CLI versions if your code depends on it.
8943 ///
8944 /// </div>
8945 pub async fn execute_user_requested(
8946 &self,
8947 params: ShellExecuteUserRequestedRequest,
8948 ) -> Result<UserRequestedShellCommandResult, Error> {
8949 let mut wire_params = serde_json::to_value(params)?;
8950 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8951 let _value = self
8952 .session
8953 .client()
8954 .call(
8955 rpc_methods::SESSION_SHELL_EXECUTEUSERREQUESTED,
8956 Some(wire_params),
8957 )
8958 .await?;
8959 Ok(serde_json::from_value(_value)?)
8960 }
8961
8962 /// Cancels a user-requested shell command by request ID.
8963 ///
8964 /// Wire method: `session.shell.cancelUserRequested`.
8965 ///
8966 /// # Parameters
8967 ///
8968 /// * `params` - User-requested shell execution cancellation handle.
8969 ///
8970 /// # Returns
8971 ///
8972 /// Cancellation result for a user-requested shell command.
8973 ///
8974 /// <div class="warning">
8975 ///
8976 /// **Experimental.** This API is part of an experimental wire-protocol surface
8977 /// and may change or be removed in future SDK or CLI releases. Pin both the
8978 /// SDK and CLI versions if your code depends on it.
8979 ///
8980 /// </div>
8981 pub async fn cancel_user_requested(
8982 &self,
8983 params: ShellCancelUserRequestedRequest,
8984 ) -> Result<CancelUserRequestedShellCommandResult, Error> {
8985 let mut wire_params = serde_json::to_value(params)?;
8986 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
8987 let _value = self
8988 .session
8989 .client()
8990 .call(
8991 rpc_methods::SESSION_SHELL_CANCELUSERREQUESTED,
8992 Some(wire_params),
8993 )
8994 .await?;
8995 Ok(serde_json::from_value(_value)?)
8996 }
8997}
8998
8999/// `session.skills.*` RPCs.
9000#[derive(Clone, Copy)]
9001pub struct SessionRpcSkills<'a> {
9002 pub(crate) session: &'a Session,
9003}
9004
9005impl<'a> SessionRpcSkills<'a> {
9006 /// Lists skills available to the session.
9007 ///
9008 /// Wire method: `session.skills.list`.
9009 ///
9010 /// # Returns
9011 ///
9012 /// Skills available to the session, with their enabled state.
9013 ///
9014 /// <div class="warning">
9015 ///
9016 /// **Experimental.** This API is part of an experimental wire-protocol surface
9017 /// and may change or be removed in future SDK or CLI releases. Pin both the
9018 /// SDK and CLI versions if your code depends on it.
9019 ///
9020 /// </div>
9021 pub async fn list(&self) -> Result<SkillList, Error> {
9022 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9023 let _value = self
9024 .session
9025 .client()
9026 .call(rpc_methods::SESSION_SKILLS_LIST, Some(wire_params))
9027 .await?;
9028 Ok(serde_json::from_value(_value)?)
9029 }
9030
9031 /// Returns the skills that have been invoked during this session.
9032 ///
9033 /// Wire method: `session.skills.getInvoked`.
9034 ///
9035 /// # Returns
9036 ///
9037 /// Skills invoked during this session, ordered by invocation time (most recent last).
9038 ///
9039 /// <div class="warning">
9040 ///
9041 /// **Experimental.** This API is part of an experimental wire-protocol surface
9042 /// and may change or be removed in future SDK or CLI releases. Pin both the
9043 /// SDK and CLI versions if your code depends on it.
9044 ///
9045 /// </div>
9046 pub async fn get_invoked(&self) -> Result<SkillsGetInvokedResult, Error> {
9047 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9048 let _value = self
9049 .session
9050 .client()
9051 .call(rpc_methods::SESSION_SKILLS_GETINVOKED, Some(wire_params))
9052 .await?;
9053 Ok(serde_json::from_value(_value)?)
9054 }
9055
9056 /// Enables a skill for the session.
9057 ///
9058 /// Wire method: `session.skills.enable`.
9059 ///
9060 /// # Parameters
9061 ///
9062 /// * `params` - Name of the skill to enable for the session.
9063 ///
9064 /// <div class="warning">
9065 ///
9066 /// **Experimental.** This API is part of an experimental wire-protocol surface
9067 /// and may change or be removed in future SDK or CLI releases. Pin both the
9068 /// SDK and CLI versions if your code depends on it.
9069 ///
9070 /// </div>
9071 pub async fn enable(&self, params: SkillsEnableRequest) -> Result<(), Error> {
9072 let mut wire_params = serde_json::to_value(params)?;
9073 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9074 let _value = self
9075 .session
9076 .client()
9077 .call(rpc_methods::SESSION_SKILLS_ENABLE, Some(wire_params))
9078 .await?;
9079 Ok(())
9080 }
9081
9082 /// Disables a skill for the session.
9083 ///
9084 /// Wire method: `session.skills.disable`.
9085 ///
9086 /// # Parameters
9087 ///
9088 /// * `params` - Name of the skill to disable for the session.
9089 ///
9090 /// <div class="warning">
9091 ///
9092 /// **Experimental.** This API is part of an experimental wire-protocol surface
9093 /// and may change or be removed in future SDK or CLI releases. Pin both the
9094 /// SDK and CLI versions if your code depends on it.
9095 ///
9096 /// </div>
9097 pub async fn disable(&self, params: SkillsDisableRequest) -> Result<(), Error> {
9098 let mut wire_params = serde_json::to_value(params)?;
9099 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9100 let _value = self
9101 .session
9102 .client()
9103 .call(rpc_methods::SESSION_SKILLS_DISABLE, Some(wire_params))
9104 .await?;
9105 Ok(())
9106 }
9107
9108 /// Reloads skill definitions for the session.
9109 ///
9110 /// Wire method: `session.skills.reload`.
9111 ///
9112 /// # Returns
9113 ///
9114 /// Diagnostics from reloading skill definitions, with warnings and errors as separate lists.
9115 ///
9116 /// <div class="warning">
9117 ///
9118 /// **Experimental.** This API is part of an experimental wire-protocol surface
9119 /// and may change or be removed in future SDK or CLI releases. Pin both the
9120 /// SDK and CLI versions if your code depends on it.
9121 ///
9122 /// </div>
9123 pub async fn reload(&self) -> Result<SkillsLoadDiagnostics, Error> {
9124 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9125 let _value = self
9126 .session
9127 .client()
9128 .call(rpc_methods::SESSION_SKILLS_RELOAD, Some(wire_params))
9129 .await?;
9130 Ok(serde_json::from_value(_value)?)
9131 }
9132
9133 /// Ensures the session's skill definitions have been loaded from disk.
9134 ///
9135 /// Wire method: `session.skills.ensureLoaded`.
9136 ///
9137 /// <div class="warning">
9138 ///
9139 /// **Experimental.** This API is part of an experimental wire-protocol surface
9140 /// and may change or be removed in future SDK or CLI releases. Pin both the
9141 /// SDK and CLI versions if your code depends on it.
9142 ///
9143 /// </div>
9144 pub async fn ensure_loaded(&self) -> Result<(), Error> {
9145 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9146 let _value = self
9147 .session
9148 .client()
9149 .call(rpc_methods::SESSION_SKILLS_ENSURELOADED, Some(wire_params))
9150 .await?;
9151 Ok(())
9152 }
9153}
9154
9155/// `session.tasks.*` RPCs.
9156#[derive(Clone, Copy)]
9157pub struct SessionRpcTasks<'a> {
9158 pub(crate) session: &'a Session,
9159}
9160
9161impl<'a> SessionRpcTasks<'a> {
9162 /// Starts a background agent task in the session.
9163 ///
9164 /// Wire method: `session.tasks.startAgent`.
9165 ///
9166 /// # Parameters
9167 ///
9168 /// * `params` - Agent type, prompt, name, and optional description and model override for the new task.
9169 ///
9170 /// # Returns
9171 ///
9172 /// Identifier assigned to the newly started background agent task.
9173 ///
9174 /// <div class="warning">
9175 ///
9176 /// **Experimental.** This API is part of an experimental wire-protocol surface
9177 /// and may change or be removed in future SDK or CLI releases. Pin both the
9178 /// SDK and CLI versions if your code depends on it.
9179 ///
9180 /// </div>
9181 pub async fn start_agent(
9182 &self,
9183 params: TasksStartAgentRequest,
9184 ) -> Result<TasksStartAgentResult, Error> {
9185 let mut wire_params = serde_json::to_value(params)?;
9186 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9187 let _value = self
9188 .session
9189 .client()
9190 .call(rpc_methods::SESSION_TASKS_STARTAGENT, Some(wire_params))
9191 .await?;
9192 Ok(serde_json::from_value(_value)?)
9193 }
9194
9195 /// Lists background tasks tracked by the session.
9196 ///
9197 /// Wire method: `session.tasks.list`.
9198 ///
9199 /// # Returns
9200 ///
9201 /// Background tasks currently tracked by the session.
9202 ///
9203 /// <div class="warning">
9204 ///
9205 /// **Experimental.** This API is part of an experimental wire-protocol surface
9206 /// and may change or be removed in future SDK or CLI releases. Pin both the
9207 /// SDK and CLI versions if your code depends on it.
9208 ///
9209 /// </div>
9210 pub async fn list(&self) -> Result<TaskList, Error> {
9211 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9212 let _value = self
9213 .session
9214 .client()
9215 .call(rpc_methods::SESSION_TASKS_LIST, Some(wire_params))
9216 .await?;
9217 Ok(serde_json::from_value(_value)?)
9218 }
9219
9220 /// Refreshes metadata for any detached background shells the runtime knows about.
9221 ///
9222 /// Wire method: `session.tasks.refresh`.
9223 ///
9224 /// # Returns
9225 ///
9226 /// 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.
9227 ///
9228 /// <div class="warning">
9229 ///
9230 /// **Experimental.** This API is part of an experimental wire-protocol surface
9231 /// and may change or be removed in future SDK or CLI releases. Pin both the
9232 /// SDK and CLI versions if your code depends on it.
9233 ///
9234 /// </div>
9235 pub async fn refresh(&self) -> Result<TasksRefreshResult, Error> {
9236 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9237 let _value = self
9238 .session
9239 .client()
9240 .call(rpc_methods::SESSION_TASKS_REFRESH, Some(wire_params))
9241 .await?;
9242 Ok(serde_json::from_value(_value)?)
9243 }
9244
9245 /// Waits for all in-flight background tasks and any follow-up turns to settle.
9246 ///
9247 /// Wire method: `session.tasks.waitForPending`.
9248 ///
9249 /// # Returns
9250 ///
9251 /// 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).
9252 ///
9253 /// <div class="warning">
9254 ///
9255 /// **Experimental.** This API is part of an experimental wire-protocol surface
9256 /// and may change or be removed in future SDK or CLI releases. Pin both the
9257 /// SDK and CLI versions if your code depends on it.
9258 ///
9259 /// </div>
9260 pub async fn wait_for_pending(&self) -> Result<TasksWaitForPendingResult, Error> {
9261 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9262 let _value = self
9263 .session
9264 .client()
9265 .call(rpc_methods::SESSION_TASKS_WAITFORPENDING, Some(wire_params))
9266 .await?;
9267 Ok(serde_json::from_value(_value)?)
9268 }
9269
9270 /// Returns progress information for a background task by ID.
9271 ///
9272 /// Wire method: `session.tasks.getProgress`.
9273 ///
9274 /// # Parameters
9275 ///
9276 /// * `params` - Identifier of the background task to fetch progress for.
9277 ///
9278 /// # Returns
9279 ///
9280 /// Progress information for the task, or null when no task with that ID is tracked.
9281 ///
9282 /// <div class="warning">
9283 ///
9284 /// **Experimental.** This API is part of an experimental wire-protocol surface
9285 /// and may change or be removed in future SDK or CLI releases. Pin both the
9286 /// SDK and CLI versions if your code depends on it.
9287 ///
9288 /// </div>
9289 pub async fn get_progress(
9290 &self,
9291 params: TasksGetProgressRequest,
9292 ) -> Result<TasksGetProgressResult, Error> {
9293 let mut wire_params = serde_json::to_value(params)?;
9294 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9295 let _value = self
9296 .session
9297 .client()
9298 .call(rpc_methods::SESSION_TASKS_GETPROGRESS, Some(wire_params))
9299 .await?;
9300 Ok(serde_json::from_value(_value)?)
9301 }
9302
9303 /// Returns the first sync-waiting task that can currently be promoted to background mode.
9304 ///
9305 /// Wire method: `session.tasks.getCurrentPromotable`.
9306 ///
9307 /// # Returns
9308 ///
9309 /// The first sync-waiting task that can currently be promoted to background mode.
9310 ///
9311 /// <div class="warning">
9312 ///
9313 /// **Experimental.** This API is part of an experimental wire-protocol surface
9314 /// and may change or be removed in future SDK or CLI releases. Pin both the
9315 /// SDK and CLI versions if your code depends on it.
9316 ///
9317 /// </div>
9318 pub async fn get_current_promotable(&self) -> Result<TasksGetCurrentPromotableResult, Error> {
9319 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9320 let _value = self
9321 .session
9322 .client()
9323 .call(
9324 rpc_methods::SESSION_TASKS_GETCURRENTPROMOTABLE,
9325 Some(wire_params),
9326 )
9327 .await?;
9328 Ok(serde_json::from_value(_value)?)
9329 }
9330
9331 /// Promotes an eligible synchronously-waited task so it continues running in the background.
9332 ///
9333 /// Wire method: `session.tasks.promoteToBackground`.
9334 ///
9335 /// # Parameters
9336 ///
9337 /// * `params` - Identifier of the task to promote to background mode.
9338 ///
9339 /// # Returns
9340 ///
9341 /// Indicates whether the task was successfully promoted to background mode.
9342 ///
9343 /// <div class="warning">
9344 ///
9345 /// **Experimental.** This API is part of an experimental wire-protocol surface
9346 /// and may change or be removed in future SDK or CLI releases. Pin both the
9347 /// SDK and CLI versions if your code depends on it.
9348 ///
9349 /// </div>
9350 pub async fn promote_to_background(
9351 &self,
9352 params: TasksPromoteToBackgroundRequest,
9353 ) -> Result<TasksPromoteToBackgroundResult, Error> {
9354 let mut wire_params = serde_json::to_value(params)?;
9355 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9356 let _value = self
9357 .session
9358 .client()
9359 .call(
9360 rpc_methods::SESSION_TASKS_PROMOTETOBACKGROUND,
9361 Some(wire_params),
9362 )
9363 .await?;
9364 Ok(serde_json::from_value(_value)?)
9365 }
9366
9367 /// Atomically promotes the first promotable sync-waiting task to background mode and returns it.
9368 ///
9369 /// Wire method: `session.tasks.promoteCurrentToBackground`.
9370 ///
9371 /// # Returns
9372 ///
9373 /// The promoted task as it now exists in background mode, omitted if no promotable task was waiting.
9374 ///
9375 /// <div class="warning">
9376 ///
9377 /// **Experimental.** This API is part of an experimental wire-protocol surface
9378 /// and may change or be removed in future SDK or CLI releases. Pin both the
9379 /// SDK and CLI versions if your code depends on it.
9380 ///
9381 /// </div>
9382 pub async fn promote_current_to_background(
9383 &self,
9384 ) -> Result<TasksPromoteCurrentToBackgroundResult, Error> {
9385 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9386 let _value = self
9387 .session
9388 .client()
9389 .call(
9390 rpc_methods::SESSION_TASKS_PROMOTECURRENTTOBACKGROUND,
9391 Some(wire_params),
9392 )
9393 .await?;
9394 Ok(serde_json::from_value(_value)?)
9395 }
9396
9397 /// Cancels a background task.
9398 ///
9399 /// Wire method: `session.tasks.cancel`.
9400 ///
9401 /// # Parameters
9402 ///
9403 /// * `params` - Identifier of the background task to cancel.
9404 ///
9405 /// # Returns
9406 ///
9407 /// Indicates whether the background task was successfully cancelled.
9408 ///
9409 /// <div class="warning">
9410 ///
9411 /// **Experimental.** This API is part of an experimental wire-protocol surface
9412 /// and may change or be removed in future SDK or CLI releases. Pin both the
9413 /// SDK and CLI versions if your code depends on it.
9414 ///
9415 /// </div>
9416 pub async fn cancel(&self, params: TasksCancelRequest) -> Result<TasksCancelResult, Error> {
9417 let mut wire_params = serde_json::to_value(params)?;
9418 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9419 let _value = self
9420 .session
9421 .client()
9422 .call(rpc_methods::SESSION_TASKS_CANCEL, Some(wire_params))
9423 .await?;
9424 Ok(serde_json::from_value(_value)?)
9425 }
9426
9427 /// Removes a completed or cancelled background task from tracking.
9428 ///
9429 /// Wire method: `session.tasks.remove`.
9430 ///
9431 /// # Parameters
9432 ///
9433 /// * `params` - Identifier of the completed or cancelled task to remove from tracking.
9434 ///
9435 /// # Returns
9436 ///
9437 /// Indicates whether the task was removed. False when the task does not exist or is still running/idle.
9438 ///
9439 /// <div class="warning">
9440 ///
9441 /// **Experimental.** This API is part of an experimental wire-protocol surface
9442 /// and may change or be removed in future SDK or CLI releases. Pin both the
9443 /// SDK and CLI versions if your code depends on it.
9444 ///
9445 /// </div>
9446 pub async fn remove(&self, params: TasksRemoveRequest) -> Result<TasksRemoveResult, Error> {
9447 let mut wire_params = serde_json::to_value(params)?;
9448 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9449 let _value = self
9450 .session
9451 .client()
9452 .call(rpc_methods::SESSION_TASKS_REMOVE, Some(wire_params))
9453 .await?;
9454 Ok(serde_json::from_value(_value)?)
9455 }
9456
9457 /// Sends a message to a background agent task.
9458 ///
9459 /// Wire method: `session.tasks.sendMessage`.
9460 ///
9461 /// # Parameters
9462 ///
9463 /// * `params` - Identifier of the target agent task, message content, and optional sender agent ID.
9464 ///
9465 /// # Returns
9466 ///
9467 /// Indicates whether the message was delivered, with an error message when delivery failed.
9468 ///
9469 /// <div class="warning">
9470 ///
9471 /// **Experimental.** This API is part of an experimental wire-protocol surface
9472 /// and may change or be removed in future SDK or CLI releases. Pin both the
9473 /// SDK and CLI versions if your code depends on it.
9474 ///
9475 /// </div>
9476 pub async fn send_message(
9477 &self,
9478 params: TasksSendMessageRequest,
9479 ) -> Result<TasksSendMessageResult, Error> {
9480 let mut wire_params = serde_json::to_value(params)?;
9481 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9482 let _value = self
9483 .session
9484 .client()
9485 .call(rpc_methods::SESSION_TASKS_SENDMESSAGE, Some(wire_params))
9486 .await?;
9487 Ok(serde_json::from_value(_value)?)
9488 }
9489}
9490
9491/// `session.telemetry.*` RPCs.
9492#[derive(Clone, Copy)]
9493pub struct SessionRpcTelemetry<'a> {
9494 pub(crate) session: &'a Session,
9495}
9496
9497impl<'a> SessionRpcTelemetry<'a> {
9498 /// Gets the telemetry engagement ID currently associated with the session, when available.
9499 ///
9500 /// Wire method: `session.telemetry.getEngagementId`.
9501 ///
9502 /// # Returns
9503 ///
9504 /// Telemetry engagement ID for the session, when available.
9505 ///
9506 /// <div class="warning">
9507 ///
9508 /// **Experimental.** This API is part of an experimental wire-protocol surface
9509 /// and may change or be removed in future SDK or CLI releases. Pin both the
9510 /// SDK and CLI versions if your code depends on it.
9511 ///
9512 /// </div>
9513 pub async fn get_engagement_id(&self) -> Result<SessionTelemetryEngagement, Error> {
9514 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9515 let _value = self
9516 .session
9517 .client()
9518 .call(
9519 rpc_methods::SESSION_TELEMETRY_GETENGAGEMENTID,
9520 Some(wire_params),
9521 )
9522 .await?;
9523 Ok(serde_json::from_value(_value)?)
9524 }
9525
9526 /// Sets feature override key/value pairs to attach to subsequent telemetry events for the session.
9527 ///
9528 /// Wire method: `session.telemetry.setFeatureOverrides`.
9529 ///
9530 /// # Parameters
9531 ///
9532 /// * `params` - Feature override key/value pairs to attach to subsequent telemetry events from this session.
9533 ///
9534 /// <div class="warning">
9535 ///
9536 /// **Experimental.** This API is part of an experimental wire-protocol surface
9537 /// and may change or be removed in future SDK or CLI releases. Pin both the
9538 /// SDK and CLI versions if your code depends on it.
9539 ///
9540 /// </div>
9541 pub async fn set_feature_overrides(
9542 &self,
9543 params: TelemetrySetFeatureOverridesRequest,
9544 ) -> Result<(), Error> {
9545 let mut wire_params = serde_json::to_value(params)?;
9546 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9547 let _value = self
9548 .session
9549 .client()
9550 .call(
9551 rpc_methods::SESSION_TELEMETRY_SETFEATUREOVERRIDES,
9552 Some(wire_params),
9553 )
9554 .await?;
9555 Ok(())
9556 }
9557}
9558
9559/// `session.tools.*` RPCs.
9560#[derive(Clone, Copy)]
9561pub struct SessionRpcTools<'a> {
9562 pub(crate) session: &'a Session,
9563}
9564
9565impl<'a> SessionRpcTools<'a> {
9566 /// Provides the result for a pending external tool call.
9567 ///
9568 /// Wire method: `session.tools.handlePendingToolCall`.
9569 ///
9570 /// # Parameters
9571 ///
9572 /// * `params` - Pending external tool call request ID, with the tool result or an error describing why it failed.
9573 ///
9574 /// # Returns
9575 ///
9576 /// Indicates whether the external tool call result was handled successfully.
9577 ///
9578 /// <div class="warning">
9579 ///
9580 /// **Experimental.** This API is part of an experimental wire-protocol surface
9581 /// and may change or be removed in future SDK or CLI releases. Pin both the
9582 /// SDK and CLI versions if your code depends on it.
9583 ///
9584 /// </div>
9585 pub async fn handle_pending_tool_call(
9586 &self,
9587 params: HandlePendingToolCallRequest,
9588 ) -> Result<HandlePendingToolCallResult, Error> {
9589 let mut wire_params = serde_json::to_value(params)?;
9590 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9591 let _value = self
9592 .session
9593 .client()
9594 .call(
9595 rpc_methods::SESSION_TOOLS_HANDLEPENDINGTOOLCALL,
9596 Some(wire_params),
9597 )
9598 .await?;
9599 Ok(serde_json::from_value(_value)?)
9600 }
9601
9602 /// Resolves, builds, and validates the runtime tool list for the session.
9603 ///
9604 /// Wire method: `session.tools.initializeAndValidate`.
9605 ///
9606 /// # Returns
9607 ///
9608 /// 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.
9609 ///
9610 /// <div class="warning">
9611 ///
9612 /// **Experimental.** This API is part of an experimental wire-protocol surface
9613 /// and may change or be removed in future SDK or CLI releases. Pin both the
9614 /// SDK and CLI versions if your code depends on it.
9615 ///
9616 /// </div>
9617 pub async fn initialize_and_validate(&self) -> Result<ToolsInitializeAndValidateResult, Error> {
9618 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9619 let _value = self
9620 .session
9621 .client()
9622 .call(
9623 rpc_methods::SESSION_TOOLS_INITIALIZEANDVALIDATE,
9624 Some(wire_params),
9625 )
9626 .await?;
9627 Ok(serde_json::from_value(_value)?)
9628 }
9629
9630 /// Returns lightweight metadata for the session's currently initialized tools.
9631 ///
9632 /// Wire method: `session.tools.getCurrentMetadata`.
9633 ///
9634 /// # Returns
9635 ///
9636 /// Current lightweight tool metadata snapshot for the session.
9637 ///
9638 /// <div class="warning">
9639 ///
9640 /// **Experimental.** This API is part of an experimental wire-protocol surface
9641 /// and may change or be removed in future SDK or CLI releases. Pin both the
9642 /// SDK and CLI versions if your code depends on it.
9643 ///
9644 /// </div>
9645 pub async fn get_current_metadata(&self) -> Result<ToolsGetCurrentMetadataResult, Error> {
9646 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
9647 let _value = self
9648 .session
9649 .client()
9650 .call(
9651 rpc_methods::SESSION_TOOLS_GETCURRENTMETADATA,
9652 Some(wire_params),
9653 )
9654 .await?;
9655 Ok(serde_json::from_value(_value)?)
9656 }
9657
9658 /// Updates the current session's live subagent settings after user settings change. The persisted user settings remain the source of truth for future sessions.
9659 ///
9660 /// Wire method: `session.tools.updateSubagentSettings`.
9661 ///
9662 /// # Parameters
9663 ///
9664 /// * `params` - Subagent settings to apply to the current session
9665 ///
9666 /// # Returns
9667 ///
9668 /// Empty result after applying subagent settings
9669 ///
9670 /// <div class="warning">
9671 ///
9672 /// **Experimental.** This API is part of an experimental wire-protocol surface
9673 /// and may change or be removed in future SDK or CLI releases. Pin both the
9674 /// SDK and CLI versions if your code depends on it.
9675 ///
9676 /// </div>
9677 pub async fn update_subagent_settings(
9678 &self,
9679 params: UpdateSubagentSettingsRequest,
9680 ) -> Result<ToolsUpdateSubagentSettingsResult, Error> {
9681 let mut wire_params = serde_json::to_value(params)?;
9682 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9683 let _value = self
9684 .session
9685 .client()
9686 .call(
9687 rpc_methods::SESSION_TOOLS_UPDATESUBAGENTSETTINGS,
9688 Some(wire_params),
9689 )
9690 .await?;
9691 Ok(serde_json::from_value(_value)?)
9692 }
9693}
9694
9695/// `session.ui.*` RPCs.
9696#[derive(Clone, Copy)]
9697pub struct SessionRpcUi<'a> {
9698 pub(crate) session: &'a Session,
9699}
9700
9701impl<'a> SessionRpcUi<'a> {
9702 /// Runs a transient no-tools model query against the current conversation context.
9703 ///
9704 /// Wire method: `session.ui.ephemeralQuery`.
9705 ///
9706 /// # Parameters
9707 ///
9708 /// * `params` - Transient question to answer without adding it to conversation history.
9709 ///
9710 /// # Returns
9711 ///
9712 /// Transient answer generated from current conversation context.
9713 ///
9714 /// <div class="warning">
9715 ///
9716 /// **Experimental.** This API is part of an experimental wire-protocol surface
9717 /// and may change or be removed in future SDK or CLI releases. Pin both the
9718 /// SDK and CLI versions if your code depends on it.
9719 ///
9720 /// </div>
9721 pub async fn ephemeral_query(
9722 &self,
9723 params: UIEphemeralQueryRequest,
9724 ) -> Result<UIEphemeralQueryResult, Error> {
9725 let mut wire_params = serde_json::to_value(params)?;
9726 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9727 let _value = self
9728 .session
9729 .client()
9730 .call(rpc_methods::SESSION_UI_EPHEMERALQUERY, Some(wire_params))
9731 .await?;
9732 Ok(serde_json::from_value(_value)?)
9733 }
9734
9735 /// Requests structured input from a UI-capable client.
9736 ///
9737 /// Wire method: `session.ui.elicitation`.
9738 ///
9739 /// # Parameters
9740 ///
9741 /// * `params` - Prompt message and JSON schema describing the form fields to elicit from the user.
9742 ///
9743 /// # Returns
9744 ///
9745 /// The elicitation response (accept with form values, decline, or cancel)
9746 ///
9747 /// <div class="warning">
9748 ///
9749 /// **Experimental.** This API is part of an experimental wire-protocol surface
9750 /// and may change or be removed in future SDK or CLI releases. Pin both the
9751 /// SDK and CLI versions if your code depends on it.
9752 ///
9753 /// </div>
9754 pub async fn elicitation(
9755 &self,
9756 params: UIElicitationRequest,
9757 ) -> Result<UIElicitationResponse, Error> {
9758 let mut wire_params = serde_json::to_value(params)?;
9759 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9760 let _value = self
9761 .session
9762 .client()
9763 .call(rpc_methods::SESSION_UI_ELICITATION, Some(wire_params))
9764 .await?;
9765 Ok(serde_json::from_value(_value)?)
9766 }
9767
9768 /// Provides the user response for a pending elicitation request.
9769 ///
9770 /// Wire method: `session.ui.handlePendingElicitation`.
9771 ///
9772 /// # Parameters
9773 ///
9774 /// * `params` - Pending elicitation request ID and the user's response (accept/decline/cancel + form values).
9775 ///
9776 /// # Returns
9777 ///
9778 /// Indicates whether the elicitation response was accepted; false if it was already resolved by another client.
9779 ///
9780 /// <div class="warning">
9781 ///
9782 /// **Experimental.** This API is part of an experimental wire-protocol surface
9783 /// and may change or be removed in future SDK or CLI releases. Pin both the
9784 /// SDK and CLI versions if your code depends on it.
9785 ///
9786 /// </div>
9787 pub async fn handle_pending_elicitation(
9788 &self,
9789 params: UIHandlePendingElicitationRequest,
9790 ) -> Result<UIElicitationResult, Error> {
9791 let mut wire_params = serde_json::to_value(params)?;
9792 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9793 let _value = self
9794 .session
9795 .client()
9796 .call(
9797 rpc_methods::SESSION_UI_HANDLEPENDINGELICITATION,
9798 Some(wire_params),
9799 )
9800 .await?;
9801 Ok(serde_json::from_value(_value)?)
9802 }
9803
9804 /// Resolves a pending `user_input.requested` event with the user's response.
9805 ///
9806 /// Wire method: `session.ui.handlePendingUserInput`.
9807 ///
9808 /// # Parameters
9809 ///
9810 /// * `params` - Request ID of a pending `user_input.requested` event and the user's response.
9811 ///
9812 /// # Returns
9813 ///
9814 /// Indicates whether the pending UI request was resolved by this call.
9815 ///
9816 /// <div class="warning">
9817 ///
9818 /// **Experimental.** This API is part of an experimental wire-protocol surface
9819 /// and may change or be removed in future SDK or CLI releases. Pin both the
9820 /// SDK and CLI versions if your code depends on it.
9821 ///
9822 /// </div>
9823 pub async fn handle_pending_user_input(
9824 &self,
9825 params: UIHandlePendingUserInputRequest,
9826 ) -> Result<UIHandlePendingResult, Error> {
9827 let mut wire_params = serde_json::to_value(params)?;
9828 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9829 let _value = self
9830 .session
9831 .client()
9832 .call(
9833 rpc_methods::SESSION_UI_HANDLEPENDINGUSERINPUT,
9834 Some(wire_params),
9835 )
9836 .await?;
9837 Ok(serde_json::from_value(_value)?)
9838 }
9839
9840 /// Resolves a pending `sampling.requested` event with a sampling result, or rejects it.
9841 ///
9842 /// Wire method: `session.ui.handlePendingSampling`.
9843 ///
9844 /// # Parameters
9845 ///
9846 /// * `params` - Request ID of a pending `sampling.requested` event and an optional sampling result payload (omit to reject).
9847 ///
9848 /// # Returns
9849 ///
9850 /// Indicates whether the pending UI request was resolved by this call.
9851 ///
9852 /// <div class="warning">
9853 ///
9854 /// **Experimental.** This API is part of an experimental wire-protocol surface
9855 /// and may change or be removed in future SDK or CLI releases. Pin both the
9856 /// SDK and CLI versions if your code depends on it.
9857 ///
9858 /// </div>
9859 pub async fn handle_pending_sampling(
9860 &self,
9861 params: UIHandlePendingSamplingRequest,
9862 ) -> Result<UIHandlePendingResult, Error> {
9863 let mut wire_params = serde_json::to_value(params)?;
9864 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9865 let _value = self
9866 .session
9867 .client()
9868 .call(
9869 rpc_methods::SESSION_UI_HANDLEPENDINGSAMPLING,
9870 Some(wire_params),
9871 )
9872 .await?;
9873 Ok(serde_json::from_value(_value)?)
9874 }
9875
9876 /// Resolves a pending `auto_mode_switch.requested` event with the user's accept/decline decision.
9877 ///
9878 /// Wire method: `session.ui.handlePendingAutoModeSwitch`.
9879 ///
9880 /// # Parameters
9881 ///
9882 /// * `params` - Request ID of a pending `auto_mode_switch.requested` event and the user's response.
9883 ///
9884 /// # Returns
9885 ///
9886 /// Indicates whether the pending UI request was resolved by this call.
9887 ///
9888 /// <div class="warning">
9889 ///
9890 /// **Experimental.** This API is part of an experimental wire-protocol surface
9891 /// and may change or be removed in future SDK or CLI releases. Pin both the
9892 /// SDK and CLI versions if your code depends on it.
9893 ///
9894 /// </div>
9895 pub async fn handle_pending_auto_mode_switch(
9896 &self,
9897 params: UIHandlePendingAutoModeSwitchRequest,
9898 ) -> Result<UIHandlePendingResult, Error> {
9899 let mut wire_params = serde_json::to_value(params)?;
9900 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9901 let _value = self
9902 .session
9903 .client()
9904 .call(
9905 rpc_methods::SESSION_UI_HANDLEPENDINGAUTOMODESWITCH,
9906 Some(wire_params),
9907 )
9908 .await?;
9909 Ok(serde_json::from_value(_value)?)
9910 }
9911
9912 /// Resolves a pending `session_limits_exhausted.requested` event with the user's selected limit action.
9913 ///
9914 /// Wire method: `session.ui.handlePendingSessionLimitsExhausted`.
9915 ///
9916 /// # Parameters
9917 ///
9918 /// * `params` - Request ID of a pending `session_limits_exhausted.requested` event and the user's selected limit action.
9919 ///
9920 /// # Returns
9921 ///
9922 /// Indicates whether the pending UI request was resolved by this call.
9923 ///
9924 /// <div class="warning">
9925 ///
9926 /// **Experimental.** This API is part of an experimental wire-protocol surface
9927 /// and may change or be removed in future SDK or CLI releases. Pin both the
9928 /// SDK and CLI versions if your code depends on it.
9929 ///
9930 /// </div>
9931 pub async fn handle_pending_session_limits_exhausted(
9932 &self,
9933 params: UIHandlePendingSessionLimitsExhaustedRequest,
9934 ) -> Result<UIHandlePendingResult, Error> {
9935 let mut wire_params = serde_json::to_value(params)?;
9936 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9937 let _value = self
9938 .session
9939 .client()
9940 .call(
9941 rpc_methods::SESSION_UI_HANDLEPENDINGSESSIONLIMITSEXHAUSTED,
9942 Some(wire_params),
9943 )
9944 .await?;
9945 Ok(serde_json::from_value(_value)?)
9946 }
9947
9948 /// Resolves a pending `exit_plan_mode.requested` event with the user's response.
9949 ///
9950 /// Wire method: `session.ui.handlePendingExitPlanMode`.
9951 ///
9952 /// # Parameters
9953 ///
9954 /// * `params` - Request ID of a pending `exit_plan_mode.requested` event and the user's response.
9955 ///
9956 /// # Returns
9957 ///
9958 /// Indicates whether the pending UI request was resolved by this call.
9959 ///
9960 /// <div class="warning">
9961 ///
9962 /// **Experimental.** This API is part of an experimental wire-protocol surface
9963 /// and may change or be removed in future SDK or CLI releases. Pin both the
9964 /// SDK and CLI versions if your code depends on it.
9965 ///
9966 /// </div>
9967 pub async fn handle_pending_exit_plan_mode(
9968 &self,
9969 params: UIHandlePendingExitPlanModeRequest,
9970 ) -> Result<UIHandlePendingResult, Error> {
9971 let mut wire_params = serde_json::to_value(params)?;
9972 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
9973 let _value = self
9974 .session
9975 .client()
9976 .call(
9977 rpc_methods::SESSION_UI_HANDLEPENDINGEXITPLANMODE,
9978 Some(wire_params),
9979 )
9980 .await?;
9981 Ok(serde_json::from_value(_value)?)
9982 }
9983
9984 /// Registers an in-process handler for auto-mode-switch requests so the server bridge skips dispatch.
9985 ///
9986 /// Wire method: `session.ui.registerDirectAutoModeSwitchHandler`.
9987 ///
9988 /// # Returns
9989 ///
9990 /// 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).
9991 ///
9992 /// <div class="warning">
9993 ///
9994 /// **Experimental.** This API is part of an experimental wire-protocol surface
9995 /// and may change or be removed in future SDK or CLI releases. Pin both the
9996 /// SDK and CLI versions if your code depends on it.
9997 ///
9998 /// </div>
9999 pub async fn register_direct_auto_mode_switch_handler(
10000 &self,
10001 ) -> Result<UIRegisterDirectAutoModeSwitchHandlerResult, Error> {
10002 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10003 let _value = self
10004 .session
10005 .client()
10006 .call(
10007 rpc_methods::SESSION_UI_REGISTERDIRECTAUTOMODESWITCHHANDLER,
10008 Some(wire_params),
10009 )
10010 .await?;
10011 Ok(serde_json::from_value(_value)?)
10012 }
10013
10014 /// Unregisters a previously-registered in-process auto-mode-switch handler by its opaque handle.
10015 ///
10016 /// Wire method: `session.ui.unregisterDirectAutoModeSwitchHandler`.
10017 ///
10018 /// # Parameters
10019 ///
10020 /// * `params` - Opaque handle previously returned by `registerDirectAutoModeSwitchHandler` to release.
10021 ///
10022 /// # Returns
10023 ///
10024 /// Indicates whether the handle was active and the registration count was decremented.
10025 ///
10026 /// <div class="warning">
10027 ///
10028 /// **Experimental.** This API is part of an experimental wire-protocol surface
10029 /// and may change or be removed in future SDK or CLI releases. Pin both the
10030 /// SDK and CLI versions if your code depends on it.
10031 ///
10032 /// </div>
10033 pub async fn unregister_direct_auto_mode_switch_handler(
10034 &self,
10035 params: UIUnregisterDirectAutoModeSwitchHandlerRequest,
10036 ) -> Result<UIUnregisterDirectAutoModeSwitchHandlerResult, Error> {
10037 let mut wire_params = serde_json::to_value(params)?;
10038 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10039 let _value = self
10040 .session
10041 .client()
10042 .call(
10043 rpc_methods::SESSION_UI_UNREGISTERDIRECTAUTOMODESWITCHHANDLER,
10044 Some(wire_params),
10045 )
10046 .await?;
10047 Ok(serde_json::from_value(_value)?)
10048 }
10049}
10050
10051/// `session.usage.*` RPCs.
10052#[derive(Clone, Copy)]
10053pub struct SessionRpcUsage<'a> {
10054 pub(crate) session: &'a Session,
10055}
10056
10057impl<'a> SessionRpcUsage<'a> {
10058 /// Gets accumulated usage metrics for the session.
10059 ///
10060 /// Wire method: `session.usage.getMetrics`.
10061 ///
10062 /// # Returns
10063 ///
10064 /// Accumulated session usage metrics, including premium request cost, token counts, model breakdown, and code-change totals.
10065 ///
10066 /// <div class="warning">
10067 ///
10068 /// **Experimental.** This API is part of an experimental wire-protocol surface
10069 /// and may change or be removed in future SDK or CLI releases. Pin both the
10070 /// SDK and CLI versions if your code depends on it.
10071 ///
10072 /// </div>
10073 pub async fn get_metrics(&self) -> Result<UsageGetMetricsResult, Error> {
10074 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10075 let _value = self
10076 .session
10077 .client()
10078 .call(rpc_methods::SESSION_USAGE_GETMETRICS, Some(wire_params))
10079 .await?;
10080 Ok(serde_json::from_value(_value)?)
10081 }
10082}
10083
10084/// `session.visibility.*` RPCs.
10085#[derive(Clone, Copy)]
10086pub struct SessionRpcVisibility<'a> {
10087 pub(crate) session: &'a Session,
10088}
10089
10090impl<'a> SessionRpcVisibility<'a> {
10091 /// 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").
10092 ///
10093 /// Wire method: `session.visibility.get`.
10094 ///
10095 /// # Returns
10096 ///
10097 /// Current sharing status and shareable GitHub URL for a session.
10098 ///
10099 /// <div class="warning">
10100 ///
10101 /// **Experimental.** This API is part of an experimental wire-protocol surface
10102 /// and may change or be removed in future SDK or CLI releases. Pin both the
10103 /// SDK and CLI versions if your code depends on it.
10104 ///
10105 /// </div>
10106 pub async fn get(&self) -> Result<VisibilityGetResult, Error> {
10107 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10108 let _value = self
10109 .session
10110 .client()
10111 .call(rpc_methods::SESSION_VISIBILITY_GET, Some(wire_params))
10112 .await?;
10113 Ok(serde_json::from_value(_value)?)
10114 }
10115
10116 /// 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.
10117 ///
10118 /// Wire method: `session.visibility.set`.
10119 ///
10120 /// # Parameters
10121 ///
10122 /// * `params` - Desired sharing status for the session.
10123 ///
10124 /// # Returns
10125 ///
10126 /// Effective sharing status and shareable GitHub URL after updating session visibility.
10127 ///
10128 /// <div class="warning">
10129 ///
10130 /// **Experimental.** This API is part of an experimental wire-protocol surface
10131 /// and may change or be removed in future SDK or CLI releases. Pin both the
10132 /// SDK and CLI versions if your code depends on it.
10133 ///
10134 /// </div>
10135 pub async fn set(&self, params: VisibilitySetRequest) -> Result<VisibilitySetResult, Error> {
10136 let mut wire_params = serde_json::to_value(params)?;
10137 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10138 let _value = self
10139 .session
10140 .client()
10141 .call(rpc_methods::SESSION_VISIBILITY_SET, Some(wire_params))
10142 .await?;
10143 Ok(serde_json::from_value(_value)?)
10144 }
10145}
10146
10147/// `session.workspaces.*` RPCs.
10148#[derive(Clone, Copy)]
10149pub struct SessionRpcWorkspaces<'a> {
10150 pub(crate) session: &'a Session,
10151}
10152
10153impl<'a> SessionRpcWorkspaces<'a> {
10154 /// Gets current workspace metadata for the session.
10155 ///
10156 /// Wire method: `session.workspaces.getWorkspace`.
10157 ///
10158 /// # Returns
10159 ///
10160 /// Current workspace metadata for the session, including its absolute filesystem path when available.
10161 ///
10162 /// <div class="warning">
10163 ///
10164 /// **Experimental.** This API is part of an experimental wire-protocol surface
10165 /// and may change or be removed in future SDK or CLI releases. Pin both the
10166 /// SDK and CLI versions if your code depends on it.
10167 ///
10168 /// </div>
10169 pub async fn get_workspace(&self) -> Result<WorkspacesGetWorkspaceResult, Error> {
10170 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10171 let _value = self
10172 .session
10173 .client()
10174 .call(
10175 rpc_methods::SESSION_WORKSPACES_GETWORKSPACE,
10176 Some(wire_params),
10177 )
10178 .await?;
10179 Ok(serde_json::from_value(_value)?)
10180 }
10181
10182 /// Updates workspace metadata for a local session and returns the refreshed workspace.
10183 ///
10184 /// Wire method: `session.workspaces.updateMetadata`.
10185 ///
10186 /// # Parameters
10187 ///
10188 /// * `params` - Workspace metadata fields to update.
10189 ///
10190 /// # Returns
10191 ///
10192 /// Current workspace metadata for the session, including its absolute filesystem path when available.
10193 ///
10194 /// <div class="warning">
10195 ///
10196 /// **Experimental.** This API is part of an experimental wire-protocol surface
10197 /// and may change or be removed in future SDK or CLI releases. Pin both the
10198 /// SDK and CLI versions if your code depends on it.
10199 ///
10200 /// </div>
10201 pub async fn update_metadata(
10202 &self,
10203 params: WorkspacesUpdateMetadataRequest,
10204 ) -> Result<WorkspacesGetWorkspaceResult, Error> {
10205 let mut wire_params = serde_json::to_value(params)?;
10206 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10207 let _value = self
10208 .session
10209 .client()
10210 .call(
10211 rpc_methods::SESSION_WORKSPACES_UPDATEMETADATA,
10212 Some(wire_params),
10213 )
10214 .await?;
10215 Ok(serde_json::from_value(_value)?)
10216 }
10217
10218 /// Ensures a local session workspace exists and returns it.
10219 ///
10220 /// Wire method: `session.workspaces.ensure`.
10221 ///
10222 /// # Parameters
10223 ///
10224 /// * `params` - Optional session context used when creating a local workspace.
10225 ///
10226 /// # Returns
10227 ///
10228 /// Current workspace metadata for the session, including its absolute filesystem path when available.
10229 ///
10230 /// <div class="warning">
10231 ///
10232 /// **Experimental.** This API is part of an experimental wire-protocol surface
10233 /// and may change or be removed in future SDK or CLI releases. Pin both the
10234 /// SDK and CLI versions if your code depends on it.
10235 ///
10236 /// </div>
10237 pub async fn ensure(
10238 &self,
10239 params: WorkspacesEnsureRequest,
10240 ) -> Result<WorkspacesGetWorkspaceResult, Error> {
10241 let mut wire_params = serde_json::to_value(params)?;
10242 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10243 let _value = self
10244 .session
10245 .client()
10246 .call(rpc_methods::SESSION_WORKSPACES_ENSURE, Some(wire_params))
10247 .await?;
10248 Ok(serde_json::from_value(_value)?)
10249 }
10250
10251 /// Lists files stored in the session workspace files directory.
10252 ///
10253 /// Wire method: `session.workspaces.listFiles`.
10254 ///
10255 /// # Returns
10256 ///
10257 /// Relative paths of files stored in the session workspace files directory.
10258 ///
10259 /// <div class="warning">
10260 ///
10261 /// **Experimental.** This API is part of an experimental wire-protocol surface
10262 /// and may change or be removed in future SDK or CLI releases. Pin both the
10263 /// SDK and CLI versions if your code depends on it.
10264 ///
10265 /// </div>
10266 pub async fn list_files(&self) -> Result<WorkspacesListFilesResult, Error> {
10267 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10268 let _value = self
10269 .session
10270 .client()
10271 .call(rpc_methods::SESSION_WORKSPACES_LISTFILES, Some(wire_params))
10272 .await?;
10273 Ok(serde_json::from_value(_value)?)
10274 }
10275
10276 /// Reads a file from the session workspace files directory.
10277 ///
10278 /// Wire method: `session.workspaces.readFile`.
10279 ///
10280 /// # Parameters
10281 ///
10282 /// * `params` - Relative path of the workspace file to read.
10283 ///
10284 /// # Returns
10285 ///
10286 /// Contents of the requested workspace file as a UTF-8 string.
10287 ///
10288 /// <div class="warning">
10289 ///
10290 /// **Experimental.** This API is part of an experimental wire-protocol surface
10291 /// and may change or be removed in future SDK or CLI releases. Pin both the
10292 /// SDK and CLI versions if your code depends on it.
10293 ///
10294 /// </div>
10295 pub async fn read_file(
10296 &self,
10297 params: WorkspacesReadFileRequest,
10298 ) -> Result<WorkspacesReadFileResult, Error> {
10299 let mut wire_params = serde_json::to_value(params)?;
10300 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10301 let _value = self
10302 .session
10303 .client()
10304 .call(rpc_methods::SESSION_WORKSPACES_READFILE, Some(wire_params))
10305 .await?;
10306 Ok(serde_json::from_value(_value)?)
10307 }
10308
10309 /// Creates or overwrites a file in the session workspace files directory.
10310 ///
10311 /// Wire method: `session.workspaces.createFile`.
10312 ///
10313 /// # Parameters
10314 ///
10315 /// * `params` - Relative path and UTF-8 content for the workspace file to create or overwrite.
10316 ///
10317 /// <div class="warning">
10318 ///
10319 /// **Experimental.** This API is part of an experimental wire-protocol surface
10320 /// and may change or be removed in future SDK or CLI releases. Pin both the
10321 /// SDK and CLI versions if your code depends on it.
10322 ///
10323 /// </div>
10324 pub async fn create_file(&self, params: WorkspacesCreateFileRequest) -> Result<(), Error> {
10325 let mut wire_params = serde_json::to_value(params)?;
10326 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10327 let _value = self
10328 .session
10329 .client()
10330 .call(
10331 rpc_methods::SESSION_WORKSPACES_CREATEFILE,
10332 Some(wire_params),
10333 )
10334 .await?;
10335 Ok(())
10336 }
10337
10338 /// Lists workspace checkpoints in chronological order.
10339 ///
10340 /// Wire method: `session.workspaces.listCheckpoints`.
10341 ///
10342 /// # Returns
10343 ///
10344 /// Workspace checkpoints in chronological order; empty when the workspace is not enabled.
10345 ///
10346 /// <div class="warning">
10347 ///
10348 /// **Experimental.** This API is part of an experimental wire-protocol surface
10349 /// and may change or be removed in future SDK or CLI releases. Pin both the
10350 /// SDK and CLI versions if your code depends on it.
10351 ///
10352 /// </div>
10353 pub async fn list_checkpoints(&self) -> Result<WorkspacesListCheckpointsResult, Error> {
10354 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10355 let _value = self
10356 .session
10357 .client()
10358 .call(
10359 rpc_methods::SESSION_WORKSPACES_LISTCHECKPOINTS,
10360 Some(wire_params),
10361 )
10362 .await?;
10363 Ok(serde_json::from_value(_value)?)
10364 }
10365
10366 /// Reads the content of a workspace checkpoint by number.
10367 ///
10368 /// Wire method: `session.workspaces.readCheckpoint`.
10369 ///
10370 /// # Parameters
10371 ///
10372 /// * `params` - Checkpoint number to read.
10373 ///
10374 /// # Returns
10375 ///
10376 /// Checkpoint content as a UTF-8 string, or null when the checkpoint or workspace is missing.
10377 ///
10378 /// <div class="warning">
10379 ///
10380 /// **Experimental.** This API is part of an experimental wire-protocol surface
10381 /// and may change or be removed in future SDK or CLI releases. Pin both the
10382 /// SDK and CLI versions if your code depends on it.
10383 ///
10384 /// </div>
10385 pub async fn read_checkpoint(
10386 &self,
10387 params: WorkspacesReadCheckpointRequest,
10388 ) -> Result<WorkspacesReadCheckpointResult, Error> {
10389 let mut wire_params = serde_json::to_value(params)?;
10390 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10391 let _value = self
10392 .session
10393 .client()
10394 .call(
10395 rpc_methods::SESSION_WORKSPACES_READCHECKPOINT,
10396 Some(wire_params),
10397 )
10398 .await?;
10399 Ok(serde_json::from_value(_value)?)
10400 }
10401
10402 /// Adds a compaction summary checkpoint to the local session workspace.
10403 ///
10404 /// Wire method: `session.workspaces.addSummary`.
10405 ///
10406 /// # Parameters
10407 ///
10408 /// * `params` - Compaction summary checkpoint to persist.
10409 ///
10410 /// # Returns
10411 ///
10412 /// Persisted summary metadata and refreshed workspace metadata.
10413 ///
10414 /// <div class="warning">
10415 ///
10416 /// **Experimental.** This API is part of an experimental wire-protocol surface
10417 /// and may change or be removed in future SDK or CLI releases. Pin both the
10418 /// SDK and CLI versions if your code depends on it.
10419 ///
10420 /// </div>
10421 pub async fn add_summary(
10422 &self,
10423 params: WorkspacesAddSummaryRequest,
10424 ) -> Result<WorkspacesAddSummaryResult, Error> {
10425 let mut wire_params = serde_json::to_value(params)?;
10426 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10427 let _value = self
10428 .session
10429 .client()
10430 .call(
10431 rpc_methods::SESSION_WORKSPACES_ADDSUMMARY,
10432 Some(wire_params),
10433 )
10434 .await?;
10435 Ok(serde_json::from_value(_value)?)
10436 }
10437
10438 /// Truncates local workspace compaction summaries after a rollback.
10439 ///
10440 /// Wire method: `session.workspaces.truncateSummaries`.
10441 ///
10442 /// # Parameters
10443 ///
10444 /// * `params` - Rollback point for local workspace summaries.
10445 ///
10446 /// # Returns
10447 ///
10448 /// Current workspace metadata for the session, including its absolute filesystem path when available.
10449 ///
10450 /// <div class="warning">
10451 ///
10452 /// **Experimental.** This API is part of an experimental wire-protocol surface
10453 /// and may change or be removed in future SDK or CLI releases. Pin both the
10454 /// SDK and CLI versions if your code depends on it.
10455 ///
10456 /// </div>
10457 pub async fn truncate_summaries(
10458 &self,
10459 params: WorkspacesTruncateSummariesRequest,
10460 ) -> Result<WorkspacesGetWorkspaceResult, Error> {
10461 let mut wire_params = serde_json::to_value(params)?;
10462 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10463 let _value = self
10464 .session
10465 .client()
10466 .call(
10467 rpc_methods::SESSION_WORKSPACES_TRUNCATESUMMARIES,
10468 Some(wire_params),
10469 )
10470 .await?;
10471 Ok(serde_json::from_value(_value)?)
10472 }
10473
10474 /// Reads the autopilot objective state file from the local session workspace.
10475 ///
10476 /// Wire method: `session.workspaces.readAutopilotObjective`.
10477 ///
10478 /// # Returns
10479 ///
10480 /// Autopilot objective file content, or null when missing.
10481 ///
10482 /// <div class="warning">
10483 ///
10484 /// **Experimental.** This API is part of an experimental wire-protocol surface
10485 /// and may change or be removed in future SDK or CLI releases. Pin both the
10486 /// SDK and CLI versions if your code depends on it.
10487 ///
10488 /// </div>
10489 pub async fn read_autopilot_objective(
10490 &self,
10491 ) -> Result<WorkspacesReadAutopilotObjectiveResult, Error> {
10492 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10493 let _value = self
10494 .session
10495 .client()
10496 .call(
10497 rpc_methods::SESSION_WORKSPACES_READAUTOPILOTOBJECTIVE,
10498 Some(wire_params),
10499 )
10500 .await?;
10501 Ok(serde_json::from_value(_value)?)
10502 }
10503
10504 /// Writes the autopilot objective state file in the local session workspace.
10505 ///
10506 /// Wire method: `session.workspaces.writeAutopilotObjective`.
10507 ///
10508 /// # Parameters
10509 ///
10510 /// * `params` - Autopilot objective file content to persist.
10511 ///
10512 /// # Returns
10513 ///
10514 /// Result of writing the autopilot objective file.
10515 ///
10516 /// <div class="warning">
10517 ///
10518 /// **Experimental.** This API is part of an experimental wire-protocol surface
10519 /// and may change or be removed in future SDK or CLI releases. Pin both the
10520 /// SDK and CLI versions if your code depends on it.
10521 ///
10522 /// </div>
10523 pub async fn write_autopilot_objective(
10524 &self,
10525 params: WorkspacesWriteAutopilotObjectiveRequest,
10526 ) -> Result<WorkspacesWriteAutopilotObjectiveResult, Error> {
10527 let mut wire_params = serde_json::to_value(params)?;
10528 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10529 let _value = self
10530 .session
10531 .client()
10532 .call(
10533 rpc_methods::SESSION_WORKSPACES_WRITEAUTOPILOTOBJECTIVE,
10534 Some(wire_params),
10535 )
10536 .await?;
10537 Ok(serde_json::from_value(_value)?)
10538 }
10539
10540 /// Deletes the autopilot objective state file from the local session workspace.
10541 ///
10542 /// Wire method: `session.workspaces.deleteAutopilotObjective`.
10543 ///
10544 /// # Returns
10545 ///
10546 /// Result of deleting the autopilot objective file.
10547 ///
10548 /// <div class="warning">
10549 ///
10550 /// **Experimental.** This API is part of an experimental wire-protocol surface
10551 /// and may change or be removed in future SDK or CLI releases. Pin both the
10552 /// SDK and CLI versions if your code depends on it.
10553 ///
10554 /// </div>
10555 pub async fn delete_autopilot_objective(
10556 &self,
10557 ) -> Result<WorkspacesDeleteAutopilotObjectiveResult, Error> {
10558 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10559 let _value = self
10560 .session
10561 .client()
10562 .call(
10563 rpc_methods::SESSION_WORKSPACES_DELETEAUTOPILOTOBJECTIVE,
10564 Some(wire_params),
10565 )
10566 .await?;
10567 Ok(serde_json::from_value(_value)?)
10568 }
10569
10570 /// Checks whether the local session workspace has an autopilot objective state file.
10571 ///
10572 /// Wire method: `session.workspaces.autopilotObjectiveExists`.
10573 ///
10574 /// # Returns
10575 ///
10576 /// Whether the autopilot objective file exists.
10577 ///
10578 /// <div class="warning">
10579 ///
10580 /// **Experimental.** This API is part of an experimental wire-protocol surface
10581 /// and may change or be removed in future SDK or CLI releases. Pin both the
10582 /// SDK and CLI versions if your code depends on it.
10583 ///
10584 /// </div>
10585 pub async fn autopilot_objective_exists(
10586 &self,
10587 ) -> Result<WorkspacesAutopilotObjectiveExistsResult, Error> {
10588 let wire_params = serde_json::json!({ "sessionId": self.session.id() });
10589 let _value = self
10590 .session
10591 .client()
10592 .call(
10593 rpc_methods::SESSION_WORKSPACES_AUTOPILOTOBJECTIVEEXISTS,
10594 Some(wire_params),
10595 )
10596 .await?;
10597 Ok(serde_json::from_value(_value)?)
10598 }
10599
10600 /// Saves pasted content as a UTF-8 file in the session workspace.
10601 ///
10602 /// Wire method: `session.workspaces.saveLargePaste`.
10603 ///
10604 /// # Parameters
10605 ///
10606 /// * `params` - Pasted content to save as a UTF-8 file in the session workspace.
10607 ///
10608 /// # Returns
10609 ///
10610 /// Descriptor for the saved paste file, or null when the workspace is unavailable.
10611 ///
10612 /// <div class="warning">
10613 ///
10614 /// **Experimental.** This API is part of an experimental wire-protocol surface
10615 /// and may change or be removed in future SDK or CLI releases. Pin both the
10616 /// SDK and CLI versions if your code depends on it.
10617 ///
10618 /// </div>
10619 pub async fn save_large_paste(
10620 &self,
10621 params: WorkspacesSaveLargePasteRequest,
10622 ) -> Result<WorkspacesSaveLargePasteResult, Error> {
10623 let mut wire_params = serde_json::to_value(params)?;
10624 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10625 let _value = self
10626 .session
10627 .client()
10628 .call(
10629 rpc_methods::SESSION_WORKSPACES_SAVELARGEPASTE,
10630 Some(wire_params),
10631 )
10632 .await?;
10633 Ok(serde_json::from_value(_value)?)
10634 }
10635
10636 /// Computes a diff for the session workspace. Never rejects for a busy session: a `session`-mode diff that cannot read the session's file-change captures falls back to an unstaged git diff with `isFallback: true` and reports why in `unavailableReason`.
10637 ///
10638 /// Wire method: `session.workspaces.diff`.
10639 ///
10640 /// # Parameters
10641 ///
10642 /// * `params` - Parameters for computing a workspace diff.
10643 ///
10644 /// # Returns
10645 ///
10646 /// Workspace diff result for the requested mode.
10647 ///
10648 /// <div class="warning">
10649 ///
10650 /// **Experimental.** This API is part of an experimental wire-protocol surface
10651 /// and may change or be removed in future SDK or CLI releases. Pin both the
10652 /// SDK and CLI versions if your code depends on it.
10653 ///
10654 /// </div>
10655 pub async fn diff(&self, params: WorkspacesDiffRequest) -> Result<WorkspaceDiffResult, Error> {
10656 let mut wire_params = serde_json::to_value(params)?;
10657 wire_params["sessionId"] = serde_json::Value::String(self.session.id().to_string());
10658 let _value = self
10659 .session
10660 .client()
10661 .call(rpc_methods::SESSION_WORKSPACES_DIFF, Some(wire_params))
10662 .await?;
10663 Ok(serde_json::from_value(_value)?)
10664 }
10665}