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