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