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